We need the char/misc/iio fixes in here as well to build on.
Unified · Split
| @@ -226,6 +226,8 @@ Domen Puncer <domen@coderock.org> · 225 unmodified lines | ||
| 226 | 226 | Douglas Gilbert <dougg@torque.net> |
| 227 | 227 | Drew Fustini <fustini@kernel.org> <drew@pdp7.com> |
| 228 | 228 | <duje@dujemihanovic.xyz> <duje.mihanovic@skole.hr> |
| 229 | +Easwar Hariharan <easwar.hariharan@linux.microsoft.com> <easwar.hariharan@intel.com> | |
| 230 | +Easwar Hariharan <easwar.hariharan@linux.microsoft.com> <eahariha@linux.microsoft.com> | |
| 229 | 231 | Ed L. Cashin <ecashin@coraid.com> |
| 230 | 232 | Elliot Berman <quic_eberman@quicinc.com> <eberman@codeaurora.org> |
| 231 | 233 | Enric Balletbo i Serra <eballetbo@kernel.org> <enric.balletbo@collabora.com> |
| @@ -435,8 +435,8 @@ both cgroups. · 434 unmodified lines | ||
| 435 | 435 | Controlling Controllers |
| 436 | 436 | ----------------------- |
| 437 | 437 | |
| 438 | −Availablity | |
| 439 | −~~~~~~~~~~~ | |
| 438 | +Availability | |
| 439 | +~~~~~~~~~~~~ | |
| 440 | 440 | |
| 441 | 441 | A controller is available in a cgroup when it is supported by the kernel (i.e., |
| 442 | 442 | compiled in, not disabled and not attached to a v1 hierarchy) and listed in the |
| @@ -76,20 +76,21 @@ unit as preprocessor statement. The above example would then read:: · 75 unmodified lines | ||
| 76 | 76 | within the corresponding compilation unit before the #include for |
| 77 | 77 | <linux/export.h>. Typically it's placed before the first #include statement. |
| 78 | 78 | |
| 79 | −Using the EXPORT_SYMBOL_GPL_FOR_MODULES() macro | |
| 80 | −----------------------------------------------- | |
| 79 | +Using the EXPORT_SYMBOL_FOR_MODULES() macro | |
| 80 | +------------------------------------------- | |
| 81 | 81 | |
| 82 | 82 | Symbols exported using this macro are put into a module namespace. This |
| 83 | −namespace cannot be imported. | |
| 83 | +namespace cannot be imported. These exports are GPL-only as they are only | |
| 84 | +intended for in-tree modules. | |
| 84 | 85 | |
| 85 | 86 | The macro takes a comma separated list of module names, allowing only those |
| 86 | 87 | modules to access this symbol. Simple tail-globs are supported. |
| 87 | 88 | |
| 88 | 89 | For example:: |
| 89 | 90 | |
| 90 | − EXPORT_SYMBOL_GPL_FOR_MODULES(preempt_notifier_inc, "kvm,kvm-*") | |
| 91 | + EXPORT_SYMBOL_FOR_MODULES(preempt_notifier_inc, "kvm,kvm-*") | |
| 91 | 92 | |
| 92 | −will limit usage of this symbol to modules whoes name matches the given | |
| 93 | +will limit usage of this symbol to modules whose name matches the given | |
| 93 | 94 | patterns. |
| 94 | 95 | |
| 95 | 96 | How to use Symbols exported in Namespaces |
| @@ -7,7 +7,7 @@ $schema: http://devicetree.org/meta-schemas/core.yaml# · 6 unmodified lines | ||
| 7 | 7 | title: Infineon Buck Regulators with PMBUS interfaces |
| 8 | 8 | |
| 9 | 9 | maintainers: |
| 10 | − - Not Me. | |
| 10 | + - Guenter Roeck <linux@roeck-us.net> | |
| 11 | 11 | |
| 12 | 12 | allOf: |
| 13 | 13 | - $ref: regulator.yaml# |
| @@ -12,6 +12,8 @@ add_addr_timeout - INTEGER (seconds) · 11 unmodified lines | ||
| 12 | 12 | resent to an MPTCP peer that has not acknowledged a previous |
| 13 | 13 | ADD_ADDR message. |
| 14 | 14 | |
| 15 | + Do not retransmit if set to 0. | |
| 16 | + | |
| 15 | 17 | The default value matches TCP_RTO_MAX. This is a per-namespace |
| 16 | 18 | sysctl. |
| 17 | 19 | |
| @@ -8,8 +8,22 @@ like to know when a security bug is found so that it can be fixed and · 7 unmodified lines | ||
| 8 | 8 | disclosed as quickly as possible. Please report security bugs to the |
| 9 | 9 | Linux kernel security team. |
| 10 | 10 | |
| 11 | −Contact | |
| 12 | −------- | |
| 11 | +The security team and maintainers almost always require additional | |
| 12 | +information beyond what was initially provided in a report and rely on | |
| 13 | +active and efficient collaboration with the reporter to perform further | |
| 14 | +testing (e.g., verifying versions, configuration options, mitigations, or | |
| 15 | +patches). Before contacting the security team, the reporter must ensure | |
| 16 | +they are available to explain their findings, engage in discussions, and | |
| 17 | +run additional tests. Reports where the reporter does not respond promptly | |
| 18 | +or cannot effectively discuss their findings may be abandoned if the | |
| 19 | +communication does not quickly improve. | |
| 20 | + | |
| 21 | +As it is with any bug, the more information provided the easier it | |
| 22 | +will be to diagnose and fix. Please review the procedure outlined in | |
| 23 | +'Documentation/admin-guide/reporting-issues.rst' if you are unclear about what | |
| 24 | +information is helpful. Any exploit code is very helpful and will not | |
| 25 | +be released without consent from the reporter unless it has already been | |
| 26 | +made public. | |
| 13 | 27 | |
| 14 | 28 | The Linux kernel security team can be contacted by email at |
| 15 | 29 | <security@kernel.org>. This is a private list of security officers |
| @@ -19,13 +33,6 @@ that can speed up the process considerably. It is possible that the · 3 unmodified lines | ||
| 19 | 33 | security team will bring in extra help from area maintainers to |
| 20 | 34 | understand and fix the security vulnerability. |
| 21 | 35 | |
| 22 | −As it is with any bug, the more information provided the easier it | |
| 23 | −will be to diagnose and fix. Please review the procedure outlined in | |
| 24 | −'Documentation/admin-guide/reporting-issues.rst' if you are unclear about what | |
| 25 | −information is helpful. Any exploit code is very helpful and will not | |
| 26 | −be released without consent from the reporter unless it has already been | |
| 27 | −made public. | |
| 28 | − | |
| 29 | 36 | Please send plain text emails without attachments where possible. |
| 30 | 37 | It is much harder to have a context-quoted discussion about a complex |
| 31 | 38 | issue if all the details are hidden away in attachments. Think of it like a |
| @@ -43,7 +43,7 @@ Following IOMMUFD objects are exposed to userspace: · 42 unmodified lines | ||
| 43 | 43 | |
| 44 | 44 | - IOMMUFD_OBJ_HWPT_PAGING, representing an actual hardware I/O page table |
| 45 | 45 | (i.e. a single struct iommu_domain) managed by the iommu driver. "PAGING" |
| 46 | − primarly indicates this type of HWPT should be linked to an IOAS. It also | |
| 46 | + primarily indicates this type of HWPT should be linked to an IOAS. It also | |
| 47 | 47 | indicates that it is backed by an iommu_domain with __IOMMU_DOMAIN_PAGING |
| 48 | 48 | feature flag. This can be either an UNMANAGED stage-1 domain for a device |
| 49 | 49 | running in the user space, or a nesting parent stage-2 domain for mappings |
| @@ -76,7 +76,7 @@ Following IOMMUFD objects are exposed to userspace: · 26 unmodified lines | ||
| 76 | 76 | |
| 77 | 77 | * Security namespace for guest owned ID, e.g. guest-controlled cache tags |
| 78 | 78 | * Non-device-affiliated event reporting, e.g. invalidation queue errors |
| 79 | − * Access to a sharable nesting parent pagetable across physical IOMMUs | |
| 79 | + * Access to a shareable nesting parent pagetable across physical IOMMUs | |
| 80 | 80 | * Virtualization of various platforms IDs, e.g. RIDs and others |
| 81 | 81 | * Delivery of paravirtualized invalidation |
| 82 | 82 | * Direct assigned invalidation queues |
| @@ -8427,6 +8427,17 @@ T: git https://gitlab.freedesktop.org/drm/misc/kernel.git · 8426 unmodified lines | ||
| 8427 | 8427 | F: drivers/gpu/drm/scheduler/ |
| 8428 | 8428 | F: include/drm/gpu_scheduler.h |
| 8429 | 8429 | |
| 8430 | +DRM GPUVM | |
| 8431 | +M: Danilo Krummrich <dakr@kernel.org> | |
| 8432 | +R: Matthew Brost <matthew.brost@intel.com> | |
| 8433 | +R: Thomas Hellström <thomas.hellstrom@linux.intel.com> | |
| 8434 | +R: Alice Ryhl <aliceryhl@google.com> | |
| 8435 | +L: dri-devel@lists.freedesktop.org | |
| 8436 | +S: Supported | |
| 8437 | +T: git https://gitlab.freedesktop.org/drm/misc/kernel.git | |
| 8438 | +F: drivers/gpu/drm/drm_gpuvm.c | |
| 8439 | +F: include/drm/drm_gpuvm.h | |
| 8440 | + | |
| 8430 | 8441 | DRM LOG |
| 8431 | 8442 | M: Jocelyn Falempe <jfalempe@redhat.com> |
| 8432 | 8443 | M: Javier Martinez Canillas <javierm@redhat.com> |
| @@ -10656,7 +10667,8 @@ S: Maintained · 2223 unmodified lines | ||
| 10656 | 10667 | F: block/partitions/efi.* |
| 10657 | 10668 | |
| 10658 | 10669 | HABANALABS PCI DRIVER |
| 10659 | −M: Yaron Avizrat <yaron.avizrat@intel.com> | |
| 10670 | +M: Koby Elbaz <koby.elbaz@intel.com> | |
| 10671 | +M: Konstantin Sinyuk <konstantin.sinyuk@intel.com> | |
| 10660 | 10672 | L: dri-devel@lists.freedesktop.org |
| 10661 | 10673 | S: Supported |
| 10662 | 10674 | C: irc://irc.oftc.net/dri-devel |
| @@ -11014,7 +11026,7 @@ F: Documentation/admin-guide/perf/hns3-pmu.rst · 351 unmodified lines | ||
| 11014 | 11026 | F: drivers/perf/hisilicon/hns3_pmu.c |
| 11015 | 11027 | |
| 11016 | 11028 | HISILICON I2C CONTROLLER DRIVER |
| 11017 | −M: Yicong Yang <yangyicong@hisilicon.com> | |
| 11029 | +M: Devyn Liu <liudingyuan@h-partners.com> | |
| 11018 | 11030 | L: linux-i2c@vger.kernel.org |
| 11019 | 11031 | S: Maintained |
| 11020 | 11032 | W: https://www.hisilicon.com |
| @@ -12282,7 +12294,6 @@ F: include/linux/avf/virtchnl.h · 1261 unmodified lines | ||
| 12282 | 12294 | F: include/linux/net/intel/*/ |
| 12283 | 12295 | |
| 12284 | 12296 | INTEL ETHERNET PROTOCOL DRIVER FOR RDMA |
| 12285 | −M: Mustafa Ismail <mustafa.ismail@intel.com> | |
| 12286 | 12297 | M: Tatyana Nikolova <tatyana.e.nikolova@intel.com> |
| 12287 | 12298 | L: linux-rdma@vger.kernel.org |
| 12288 | 12299 | S: Supported |
| @@ -16059,6 +16070,23 @@ F: mm/mempolicy.c · 3770 unmodified lines | ||
| 16059 | 16070 | F: mm/migrate.c |
| 16060 | 16071 | F: mm/migrate_device.c |
| 16061 | 16072 | |
| 16073 | +MEMORY MANAGEMENT - MGLRU (MULTI-GEN LRU) | |
| 16074 | +M: Andrew Morton <akpm@linux-foundation.org> | |
| 16075 | +M: Axel Rasmussen <axelrasmussen@google.com> | |
| 16076 | +M: Yuanchu Xie <yuanchu@google.com> | |
| 16077 | +R: Wei Xu <weixugc@google.com> | |
| 16078 | +L: linux-mm@kvack.org | |
| 16079 | +S: Maintained | |
| 16080 | +W: http://www.linux-mm.org | |
| 16081 | +T: git git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm | |
| 16082 | +F: Documentation/admin-guide/mm/multigen_lru.rst | |
| 16083 | +F: Documentation/mm/multigen_lru.rst | |
| 16084 | +F: include/linux/mm_inline.h | |
| 16085 | +F: include/linux/mmzone.h | |
| 16086 | +F: mm/swap.c | |
| 16087 | +F: mm/vmscan.c | |
| 16088 | +F: mm/workingset.c | |
| 16089 | + | |
| 16062 | 16090 | MEMORY MANAGEMENT - MISC |
| 16063 | 16091 | M: Andrew Morton <akpm@linux-foundation.org> |
| 16064 | 16092 | M: David Hildenbrand <david@redhat.com> |
| @@ -16249,8 +16277,10 @@ S: Maintained · 184 unmodified lines | ||
| 16249 | 16277 | W: http://www.linux-mm.org |
| 16250 | 16278 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm |
| 16251 | 16279 | F: rust/helpers/mm.c |
| 16280 | +F: rust/helpers/page.c | |
| 16252 | 16281 | F: rust/kernel/mm.rs |
| 16253 | 16282 | F: rust/kernel/mm/ |
| 16283 | +F: rust/kernel/page.rs | |
| 16254 | 16284 | |
| 16255 | 16285 | MEMORY MAPPING |
| 16256 | 16286 | M: Andrew Morton <akpm@linux-foundation.org> |
| @@ -22175,7 +22205,7 @@ F: arch/s390/mm · 5918 unmodified lines | ||
| 22175 | 22205 | |
| 22176 | 22206 | S390 NETWORK DRIVERS |
| 22177 | 22207 | M: Alexandra Winter <wintera@linux.ibm.com> |
| 22178 | −M: Thorsten Winkler <twinkler@linux.ibm.com> | |
| 22208 | +R: Aswin Karuvally <aswin@linux.ibm.com> | |
| 22179 | 22209 | L: linux-s390@vger.kernel.org |
| 22180 | 22210 | L: netdev@vger.kernel.org |
| 22181 | 22211 | S: Supported |
| @@ -2,7 +2,7 @@ · 1 unmodified line | ||
| 2 | 2 | VERSION = 6 |
| 3 | 3 | PATCHLEVEL = 17 |
| 4 | 4 | SUBLEVEL = 0 |
| 5 | −EXTRAVERSION = -rc2 | |
| 5 | +EXTRAVERSION = -rc3 | |
| 6 | 6 | NAME = Baby Opossum Posse |
| 7 | 7 | |
| 8 | 8 | # *DOCUMENTATION* |
| @@ -102,7 +102,13 @@ KBUILD_CFLAGS += $(call cc-option,-mthin-add-sub) $(call cc-option,-Wa$(comma) · 101 unmodified lines | ||
| 102 | 102 | |
| 103 | 103 | ifdef CONFIG_OBJTOOL |
| 104 | 104 | ifdef CONFIG_CC_HAS_ANNOTATE_TABLEJUMP |
| 105 | +# The annotate-tablejump option can not be passed to LLVM backend when LTO is enabled. | |
| 106 | +# Ensure it is aware of linker with LTO, '--loongarch-annotate-tablejump' also needs to | |
| 107 | +# be passed via '-mllvm' to ld.lld. | |
| 105 | 108 | KBUILD_CFLAGS += -mannotate-tablejump |
| 109 | +ifdef CONFIG_LTO_CLANG | |
| 110 | +KBUILD_LDFLAGS += -mllvm --loongarch-annotate-tablejump | |
| 111 | +endif | |
| 106 | 112 | else |
| 107 | 113 | KBUILD_CFLAGS += -fno-jump-tables # keep compatibility with older compilers |
| 108 | 114 | endif |
| @@ -58,7 +58,7 @@ · 57 unmodified lines | ||
| 58 | 58 | .endm |
| 59 | 59 | |
| 60 | 60 | .macro STACKLEAK_ERASE |
| 61 | −#ifdef CONFIG_GCC_PLUGIN_STACKLEAK | |
| 61 | +#ifdef CONFIG_KSTACK_ERASE | |
| 62 | 62 | bl stackleak_erase_on_task_stack |
| 63 | 63 | #endif |
| 64 | 64 | .endm |
| @@ -0,0 +1,8 @@ | ||
| 1 | +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ | |
| 2 | + | |
| 3 | +#ifndef _UAPI_ASM_LOONGARCH_SETUP_H | |
| 4 | +#define _UAPI_ASM_LOONGARCH_SETUP_H | |
| 5 | + | |
| 6 | +#define COMMAND_LINE_SIZE 4096 | |
| 7 | + | |
| 8 | +#endif /* _UAPI_ASM_LOONGARCH_SETUP_H */ | |
| @@ -8,6 +8,7 @@ · 7 unmodified lines | ||
| 8 | 8 | #include <linux/module.h> |
| 9 | 9 | #include <linux/moduleloader.h> |
| 10 | 10 | #include <linux/ftrace.h> |
| 11 | +#include <linux/sort.h> | |
| 11 | 12 | |
| 12 | 13 | Elf_Addr module_emit_got_entry(struct module *mod, Elf_Shdr *sechdrs, Elf_Addr val) |
| 13 | 14 | { |
| @@ -61,39 +62,38 @@ Elf_Addr module_emit_plt_entry(struct module *mod, Elf_Shdr *sechdrs, Elf_Addr v · 47 unmodified lines | ||
| 61 | 62 | return (Elf_Addr)&plt[nr]; |
| 62 | 63 | } |
| 63 | 64 | |
| 64 | −static int is_rela_equal(const Elf_Rela *x, const Elf_Rela *y) | |
| 65 | −{ | |
| 66 | − return x->r_info == y->r_info && x->r_addend == y->r_addend; | |
| 67 | −} | |
| 65 | +#define cmp_3way(a, b) ((a) < (b) ? -1 : (a) > (b)) | |
| 68 | 66 | |
| 69 | −static bool duplicate_rela(const Elf_Rela *rela, int idx) | |
| 67 | +static int compare_rela(const void *x, const void *y) | |
| 70 | 68 | { |
| 71 | − int i; | |
| 69 | + int ret; | |
| 70 | + const Elf_Rela *rela_x = x, *rela_y = y; | |
| 72 | 71 | |
| 73 | − for (i = 0; i < idx; i++) { | |
| 74 | − if (is_rela_equal(&rela[i], &rela[idx])) | |
| 75 | − return true; | |
| 76 | − } | |
| 72 | + ret = cmp_3way(rela_x->r_info, rela_y->r_info); | |
| 73 | + if (ret == 0) | |
| 74 | + ret = cmp_3way(rela_x->r_addend, rela_y->r_addend); | |
| 77 | 75 | |
| 78 | − return false; | |
| 76 | + return ret; | |
| 79 | 77 | } |
| 80 | 78 | |
| 81 | 79 | static void count_max_entries(Elf_Rela *relas, int num, |
| 82 | 80 | unsigned int *plts, unsigned int *gots) |
| 83 | 81 | { |
| 84 | − unsigned int i, type; | |
| 82 | + unsigned int i; | |
| 83 | + | |
| 84 | + sort(relas, num, sizeof(Elf_Rela), compare_rela, NULL); | |
| 85 | 85 | |
| 86 | 86 | for (i = 0; i < num; i++) { |
| 87 | − type = ELF_R_TYPE(relas[i].r_info); | |
| 88 | − switch (type) { | |
| 87 | + if (i && !compare_rela(&relas[i-1], &relas[i])) | |
| 88 | + continue; | |
| 89 | + | |
| 90 | + switch (ELF_R_TYPE(relas[i].r_info)) { | |
| 89 | 91 | case R_LARCH_SOP_PUSH_PLT_PCREL: |
| 90 | 92 | case R_LARCH_B26: |
| 91 | − if (!duplicate_rela(relas, i)) | |
| 92 | − (*plts)++; | |
| 93 | + (*plts)++; | |
| 93 | 94 | break; |
| 94 | 95 | case R_LARCH_GOT_PC_HI20: |
| 95 | − if (!duplicate_rela(relas, i)) | |
| 96 | − (*gots)++; | |
| 96 | + (*gots)++; | |
| 97 | 97 | break; |
| 98 | 98 | default: |
| 99 | 99 | break; /* Do nothing. */ |
| @@ -677,6 +677,11 @@ static int setup_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc, · 676 unmodified lines | ||
| 677 | 677 | for (i = 1; i < 32; i++) |
| 678 | 678 | err |= __put_user(regs->regs[i], &sc->sc_regs[i]); |
| 679 | 679 | |
| 680 | +#ifdef CONFIG_CPU_HAS_LBT | |
| 681 | + if (extctx->lbt.addr) | |
| 682 | + err |= protected_save_lbt_context(extctx); | |
| 683 | +#endif | |
| 684 | + | |
| 680 | 685 | if (extctx->lasx.addr) |
| 681 | 686 | err |= protected_save_lasx_context(extctx); |
| 682 | 687 | else if (extctx->lsx.addr) |
| @@ -684,11 +689,6 @@ static int setup_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc, · 1 unmodified line | ||
| 684 | 689 | else if (extctx->fpu.addr) |
| 685 | 690 | err |= protected_save_fpu_context(extctx); |
| 686 | 691 | |
| 687 | −#ifdef CONFIG_CPU_HAS_LBT | |
| 688 | − if (extctx->lbt.addr) | |
| 689 | − err |= protected_save_lbt_context(extctx); | |
| 690 | −#endif | |
| 691 | − | |
| 692 | 692 | /* Set the "end" magic */ |
| 693 | 693 | info = (struct sctx_info *)extctx->end.addr; |
| 694 | 694 | err |= __put_user(0, &info->magic); |
| @@ -5,6 +5,7 @@ · 4 unmodified lines | ||
| 5 | 5 | * Copyright (C) 2020-2022 Loongson Technology Corporation Limited |
| 6 | 6 | */ |
| 7 | 7 | #include <linux/clockchips.h> |
| 8 | +#include <linux/cpuhotplug.h> | |
| 8 | 9 | #include <linux/delay.h> |
| 9 | 10 | #include <linux/export.h> |
| 10 | 11 | #include <linux/init.h> |
| @@ -102,6 +103,23 @@ static int constant_timer_next_event(unsigned long delta, struct clock_event_dev · 91 unmodified lines | ||
| 102 | 103 | return 0; |
| 103 | 104 | } |
| 104 | 105 | |
| 106 | +static int arch_timer_starting(unsigned int cpu) | |
| 107 | +{ | |
| 108 | + set_csr_ecfg(ECFGF_TIMER); | |
| 109 | + | |
| 110 | + return 0; | |
| 111 | +} | |
| 112 | + | |
| 113 | +static int arch_timer_dying(unsigned int cpu) | |
| 114 | +{ | |
| 115 | + constant_set_state_shutdown(this_cpu_ptr(&constant_clockevent_device)); | |
| 116 | + | |
| 117 | + /* Clear Timer Interrupt */ | |
| 118 | + write_csr_tintclear(CSR_TINTCLR_TI); | |
| 119 | + | |
| 120 | + return 0; | |
| 121 | +} | |
| 122 | + | |
| 105 | 123 | static unsigned long get_loops_per_jiffy(void) |
| 106 | 124 | { |
| 107 | 125 | unsigned long lpj = (unsigned long)const_clock_freq; |
| @@ -172,6 +190,10 @@ int constant_clockevent_init(void) · 64 unmodified lines | ||
| 172 | 190 | lpj_fine = get_loops_per_jiffy(); |
| 173 | 191 | pr_info("Constant clock event device register\n"); |
| 174 | 192 | |
| 193 | + cpuhp_setup_state(CPUHP_AP_LOONGARCH_ARCH_TIMER_STARTING, | |
| 194 | + "clockevents/loongarch/timer:starting", | |
| 195 | + arch_timer_starting, arch_timer_dying); | |
| 196 | + | |
| 175 | 197 | return 0; |
| 176 | 198 | } |
| 177 | 199 | |
| @@ -45,7 +45,12 @@ static void eiointc_update_irq(struct loongarch_eiointc *s, int irq, int level) · 44 unmodified lines | ||
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | cpu = s->sw_coremap[irq]; |
| 48 | − vcpu = kvm_get_vcpu(s->kvm, cpu); | |
| 48 | + vcpu = kvm_get_vcpu_by_id(s->kvm, cpu); | |
| 49 | + if (unlikely(vcpu == NULL)) { | |
| 50 | + kvm_err("%s: invalid target cpu: %d\n", __func__, cpu); | |
| 51 | + return; | |
| 52 | + } | |
| 53 | + | |
| 49 | 54 | if (level) { |
| 50 | 55 | /* if not enable return false */ |
| 51 | 56 | if (!test_bit(irq, (unsigned long *)s->enable.reg_u32)) |
| @@ -99,7 +99,7 @@ static void write_mailbox(struct kvm_vcpu *vcpu, int offset, uint64_t data, int · 98 unmodified lines | ||
| 99 | 99 | static int send_ipi_data(struct kvm_vcpu *vcpu, gpa_t addr, uint64_t data) |
| 100 | 100 | { |
| 101 | 101 | int i, idx, ret; |
| 102 | − uint32_t val = 0, mask = 0; | |
| 102 | + uint64_t val = 0, mask = 0; | |
| 103 | 103 | |
| 104 | 104 | /* |
| 105 | 105 | * Bit 27-30 is mask for byte writing. |
| @@ -108,7 +108,7 @@ static int send_ipi_data(struct kvm_vcpu *vcpu, gpa_t addr, uint64_t data) · 2 unmodified lines | ||
| 108 | 108 | if ((data >> 27) & 0xf) { |
| 109 | 109 | /* Read the old val */ |
| 110 | 110 | idx = srcu_read_lock(&vcpu->kvm->srcu); |
| 111 | − ret = kvm_io_bus_read(vcpu, KVM_IOCSR_BUS, addr, sizeof(val), &val); | |
| 111 | + ret = kvm_io_bus_read(vcpu, KVM_IOCSR_BUS, addr, 4, &val); | |
| 112 | 112 | srcu_read_unlock(&vcpu->kvm->srcu, idx); |
| 113 | 113 | if (unlikely(ret)) { |
| 114 | 114 | kvm_err("%s: : read data from addr %llx failed\n", __func__, addr); |
| @@ -124,7 +124,7 @@ static int send_ipi_data(struct kvm_vcpu *vcpu, gpa_t addr, uint64_t data) · 9 unmodified lines | ||
| 124 | 124 | } |
| 125 | 125 | val |= ((uint32_t)(data >> 32) & ~mask); |
| 126 | 126 | idx = srcu_read_lock(&vcpu->kvm->srcu); |
| 127 | − ret = kvm_io_bus_write(vcpu, KVM_IOCSR_BUS, addr, sizeof(val), &val); | |
| 127 | + ret = kvm_io_bus_write(vcpu, KVM_IOCSR_BUS, addr, 4, &val); | |
| 128 | 128 | srcu_read_unlock(&vcpu->kvm->srcu, idx); |
| 129 | 129 | if (unlikely(ret)) |
| 130 | 130 | kvm_err("%s: : write data to addr %llx failed\n", __func__, addr); |
| @@ -298,7 +298,7 @@ static int kvm_ipi_regs_access(struct kvm_device *dev, · 167 unmodified lines | ||
| 298 | 298 | cpu = (attr->attr >> 16) & 0x3ff; |
| 299 | 299 | addr = attr->attr & 0xff; |
| 300 | 300 | |
| 301 | − vcpu = kvm_get_vcpu(dev->kvm, cpu); | |
| 301 | + vcpu = kvm_get_vcpu_by_id(dev->kvm, cpu); | |
| 302 | 302 | if (unlikely(vcpu == NULL)) { |
| 303 | 303 | kvm_err("%s: invalid target cpu: %d\n", __func__, cpu); |
| 304 | 304 | return -EINVAL; |
| @@ -195,6 +195,11 @@ static int kvm_pch_pic_read(struct kvm_vcpu *vcpu, · 194 unmodified lines | ||
| 195 | 195 | return -EINVAL; |
| 196 | 196 | } |
| 197 | 197 | |
| 198 | + if (addr & (len - 1)) { | |
| 199 | + kvm_err("%s: pch pic not aligned addr %llx len %d\n", __func__, addr, len); | |
| 200 | + return -EINVAL; | |
| 201 | + } | |
| 202 | + | |
| 198 | 203 | /* statistics of pch pic reading */ |
| 199 | 204 | vcpu->stat.pch_pic_read_exits++; |
| 200 | 205 | ret = loongarch_pch_pic_read(s, addr, len, val); |
| @@ -302,6 +307,11 @@ static int kvm_pch_pic_write(struct kvm_vcpu *vcpu, · 101 unmodified lines | ||
| 302 | 307 | return -EINVAL; |
| 303 | 308 | } |
| 304 | 309 | |
| 310 | + if (addr & (len - 1)) { | |
| 311 | + kvm_err("%s: pch pic not aligned addr %llx len %d\n", __func__, addr, len); | |
| 312 | + return -EINVAL; | |
| 313 | + } | |
| 314 | + | |
| 305 | 315 | /* statistics of pch pic writing */ |
| 306 | 316 | vcpu->stat.pch_pic_write_exits++; |
| 307 | 317 | ret = loongarch_pch_pic_write(s, addr, len, val); |
| @@ -1283,9 +1283,11 @@ int kvm_own_lbt(struct kvm_vcpu *vcpu) · 1282 unmodified lines | ||
| 1283 | 1283 | return -EINVAL; |
| 1284 | 1284 | |
| 1285 | 1285 | preempt_disable(); |
| 1286 | − set_csr_euen(CSR_EUEN_LBTEN); | |
| 1287 | − _restore_lbt(&vcpu->arch.lbt); | |
| 1288 | − vcpu->arch.aux_inuse |= KVM_LARCH_LBT; | |
| 1286 | + if (!(vcpu->arch.aux_inuse & KVM_LARCH_LBT)) { | |
| 1287 | + set_csr_euen(CSR_EUEN_LBTEN); | |
| 1288 | + _restore_lbt(&vcpu->arch.lbt); | |
| 1289 | + vcpu->arch.aux_inuse |= KVM_LARCH_LBT; | |
| 1290 | + } | |
| 1289 | 1291 | preempt_enable(); |
| 1290 | 1292 | |
| 1291 | 1293 | return 0; |
| @@ -82,13 +82,16 @@ · 81 unmodified lines | ||
| 82 | 82 | }; |
| 83 | 83 | }; |
| 84 | 84 | |
| 85 | − etop@e180000 { | |
| 85 | + ethernet@e180000 { | |
| 86 | 86 | compatible = "lantiq,etop-xway"; |
| 87 | 87 | reg = <0xe180000 0x40000>; |
| 88 | 88 | interrupt-parent = <&icu0>; |
| 89 | 89 | interrupts = <73 78>; |
| 90 | + interrupt-names = "tx", "rx"; | |
| 90 | 91 | phy-mode = "rmii"; |
| 91 | 92 | mac-address = [ 00 11 22 33 44 55 ]; |
| 93 | + lantiq,rx-burst-length = <4>; | |
| 94 | + lantiq,tx-burst-length = <4>; | |
| 92 | 95 | }; |
| 93 | 96 | |
| 94 | 97 | stp0: stp@e100bb0 { |
| @@ -497,7 +497,7 @@ void __init ltq_soc_init(void) · 496 unmodified lines | ||
| 497 | 497 | ifccr = CGU_IFCCR_VR9; |
| 498 | 498 | pcicr = CGU_PCICR_VR9; |
| 499 | 499 | } else { |
| 500 | − clkdev_add_pmu("1e180000.etop", NULL, 1, 0, PMU_PPE); | |
| 500 | + clkdev_add_pmu("1e180000.ethernet", NULL, 1, 0, PMU_PPE); | |
| 501 | 501 | } |
| 502 | 502 | |
| 503 | 503 | if (!of_machine_is_compatible("lantiq,ase")) |
| @@ -531,9 +531,9 @@ void __init ltq_soc_init(void) · 27 unmodified lines | ||
| 531 | 531 | CLOCK_133M, CLOCK_133M); |
| 532 | 532 | clkdev_add_pmu("1e101000.usb", "otg", 1, 0, PMU_USB0); |
| 533 | 533 | clkdev_add_pmu("1f203018.usb2-phy", "phy", 1, 0, PMU_USB0_P); |
| 534 | − clkdev_add_pmu("1e180000.etop", "ppe", 1, 0, PMU_PPE); | |
| 535 | − clkdev_add_cgu("1e180000.etop", "ephycgu", CGU_EPHY); | |
| 536 | − clkdev_add_pmu("1e180000.etop", "ephy", 1, 0, PMU_EPHY); | |
| 534 | + clkdev_add_pmu("1e180000.ethernet", "ppe", 1, 0, PMU_PPE); | |
| 535 | + clkdev_add_cgu("1e180000.ethernet", "ephycgu", CGU_EPHY); | |
| 536 | + clkdev_add_pmu("1e180000.ethernet", "ephy", 1, 0, PMU_EPHY); | |
| 537 | 537 | clkdev_add_pmu("1e103000.sdio", NULL, 1, 0, PMU_ASE_SDIO); |
| 538 | 538 | clkdev_add_pmu("1e116000.mei", "dfe", 1, 0, PMU_DFE); |
| 539 | 539 | } else if (of_machine_is_compatible("lantiq,grx390")) { |
| @@ -592,7 +592,7 @@ void __init ltq_soc_init(void) · 52 unmodified lines | ||
| 592 | 592 | clkdev_add_pmu("1e101000.usb", "otg", 1, 0, PMU_USB0 | PMU_AHBM); |
| 593 | 593 | clkdev_add_pmu("1f203034.usb2-phy", "phy", 1, 0, PMU_USB1_P); |
| 594 | 594 | clkdev_add_pmu("1e106000.usb", "otg", 1, 0, PMU_USB1 | PMU_AHBM); |
| 595 | − clkdev_add_pmu("1e180000.etop", "switch", 1, 0, PMU_SWITCH); | |
| 595 | + clkdev_add_pmu("1e180000.ethernet", "switch", 1, 0, PMU_SWITCH); | |
| 596 | 596 | clkdev_add_pmu("1e103000.sdio", NULL, 1, 0, PMU_SDIO); |
| 597 | 597 | clkdev_add_pmu("1e103100.deu", NULL, 1, 0, PMU_DEU); |
| 598 | 598 | clkdev_add_pmu("1e116000.mei", "dfe", 1, 0, PMU_DFE); |
| @@ -530,6 +530,9 @@ void setup_vmem(unsigned long kernel_start, unsigned long kernel_end, unsigned l · 529 unmodified lines | ||
| 530 | 530 | lowcore_address + sizeof(struct lowcore), |
| 531 | 531 | POPULATE_LOWCORE); |
| 532 | 532 | for_each_physmem_usable_range(i, &start, &end) { |
| 533 | + /* Do not map lowcore with identity mapping */ | |
| 534 | + if (!start) | |
| 535 | + start = sizeof(struct lowcore); | |
| 533 | 536 | pgtable_populate((unsigned long)__identity_va(start), |
| 534 | 537 | (unsigned long)__identity_va(end), |
| 535 | 538 | POPULATE_IDENTITY); |
| @@ -5,6 +5,7 @@ CONFIG_WATCH_QUEUE=y · 4 unmodified lines | ||
| 5 | 5 | CONFIG_AUDIT=y |
| 6 | 6 | CONFIG_NO_HZ_IDLE=y |
| 7 | 7 | CONFIG_HIGH_RES_TIMERS=y |
| 8 | +CONFIG_POSIX_AUX_CLOCKS=y | |
| 8 | 9 | CONFIG_BPF_SYSCALL=y |
| 9 | 10 | CONFIG_BPF_JIT=y |
| 10 | 11 | CONFIG_BPF_JIT_ALWAYS_ON=y |
| @@ -19,6 +20,7 @@ CONFIG_TASK_XACCT=y · 8 unmodified lines | ||
| 19 | 20 | CONFIG_TASK_IO_ACCOUNTING=y |
| 20 | 21 | CONFIG_IKCONFIG=y |
| 21 | 22 | CONFIG_IKCONFIG_PROC=y |
| 23 | +CONFIG_SCHED_PROXY_EXEC=y | |
| 22 | 24 | CONFIG_NUMA_BALANCING=y |
| 23 | 25 | CONFIG_MEMCG=y |
| 24 | 26 | CONFIG_BLK_CGROUP=y |
| @@ -42,6 +44,7 @@ CONFIG_PROFILING=y · 17 unmodified lines | ||
| 42 | 44 | CONFIG_KEXEC=y |
| 43 | 45 | CONFIG_KEXEC_FILE=y |
| 44 | 46 | CONFIG_KEXEC_SIG=y |
| 47 | +CONFIG_CRASH_DM_CRYPT=y | |
| 45 | 48 | CONFIG_LIVEPATCH=y |
| 46 | 49 | CONFIG_MARCH_Z13=y |
| 47 | 50 | CONFIG_NR_CPUS=512 |
| @@ -105,6 +108,7 @@ CONFIG_CMA_AREAS=7 · 57 unmodified lines | ||
| 105 | 108 | CONFIG_MEM_SOFT_DIRTY=y |
| 106 | 109 | CONFIG_DEFERRED_STRUCT_PAGE_INIT=y |
| 107 | 110 | CONFIG_IDLE_PAGE_TRACKING=y |
| 111 | +CONFIG_ZONE_DEVICE=y | |
| 108 | 112 | CONFIG_PERCPU_STATS=y |
| 109 | 113 | CONFIG_GUP_TEST=y |
| 110 | 114 | CONFIG_ANON_VMA_NAME=y |
| @@ -223,17 +227,19 @@ CONFIG_NETFILTER_XT_TARGET_CONNMARK=m · 112 unmodified lines | ||
| 223 | 227 | CONFIG_NETFILTER_XT_TARGET_CONNSECMARK=m |
| 224 | 228 | CONFIG_NETFILTER_XT_TARGET_CT=m |
| 225 | 229 | CONFIG_NETFILTER_XT_TARGET_DSCP=m |
| 230 | +CONFIG_NETFILTER_XT_TARGET_HL=m | |
| 226 | 231 | CONFIG_NETFILTER_XT_TARGET_HMARK=m |
| 227 | 232 | CONFIG_NETFILTER_XT_TARGET_IDLETIMER=m |
| 228 | 233 | CONFIG_NETFILTER_XT_TARGET_LOG=m |
| 229 | 234 | CONFIG_NETFILTER_XT_TARGET_MARK=m |
| 235 | +CONFIG_NETFILTER_XT_NAT=m | |
| 230 | 236 | CONFIG_NETFILTER_XT_TARGET_NETMAP=m |
| 231 | 237 | CONFIG_NETFILTER_XT_TARGET_NFLOG=m |
| 232 | 238 | CONFIG_NETFILTER_XT_TARGET_NFQUEUE=m |
| 233 | 239 | CONFIG_NETFILTER_XT_TARGET_REDIRECT=m |
| 240 | +CONFIG_NETFILTER_XT_TARGET_MASQUERADE=m | |
| 234 | 241 | CONFIG_NETFILTER_XT_TARGET_TEE=m |
| 235 | 242 | CONFIG_NETFILTER_XT_TARGET_TPROXY=m |
| 236 | −CONFIG_NETFILTER_XT_TARGET_TRACE=m | |
| 237 | 243 | CONFIG_NETFILTER_XT_TARGET_SECMARK=m |
| 238 | 244 | CONFIG_NETFILTER_XT_TARGET_TCPMSS=m |
| 239 | 245 | CONFIG_NETFILTER_XT_TARGET_TCPOPTSTRIP=m |
| @@ -248,6 +254,7 @@ CONFIG_NETFILTER_XT_MATCH_CONNLIMIT=m · 8 unmodified lines | ||
| 248 | 254 | CONFIG_NETFILTER_XT_MATCH_CONNMARK=m |
| 249 | 255 | CONFIG_NETFILTER_XT_MATCH_CONNTRACK=m |
| 250 | 256 | CONFIG_NETFILTER_XT_MATCH_CPU=m |
| 257 | +CONFIG_NETFILTER_XT_MATCH_DCCP=m | |
| 251 | 258 | CONFIG_NETFILTER_XT_MATCH_DEVGROUP=m |
| 252 | 259 | CONFIG_NETFILTER_XT_MATCH_DSCP=m |
| 253 | 260 | CONFIG_NETFILTER_XT_MATCH_ESP=m |
| @@ -318,16 +325,8 @@ CONFIG_IP_NF_MATCH_AH=m · 64 unmodified lines | ||
| 318 | 325 | CONFIG_IP_NF_MATCH_ECN=m |
| 319 | 326 | CONFIG_IP_NF_MATCH_RPFILTER=m |
| 320 | 327 | CONFIG_IP_NF_MATCH_TTL=m |
| 321 | −CONFIG_IP_NF_FILTER=m | |
| 322 | 328 | CONFIG_IP_NF_TARGET_REJECT=m |
| 323 | −CONFIG_IP_NF_NAT=m | |
| 324 | −CONFIG_IP_NF_TARGET_MASQUERADE=m | |
| 325 | −CONFIG_IP_NF_MANGLE=m | |
| 326 | 329 | CONFIG_IP_NF_TARGET_ECN=m |
| 327 | −CONFIG_IP_NF_TARGET_TTL=m | |
| 328 | −CONFIG_IP_NF_RAW=m | |
| 329 | −CONFIG_IP_NF_SECURITY=m | |
| 330 | −CONFIG_IP_NF_ARPFILTER=m | |
| 331 | 330 | CONFIG_IP_NF_ARP_MANGLE=m |
| 332 | 331 | CONFIG_NFT_FIB_IPV6=m |
| 333 | 332 | CONFIG_IP6_NF_IPTABLES=m |
| @@ -340,15 +339,9 @@ CONFIG_IP6_NF_MATCH_IPV6HEADER=m · 6 unmodified lines | ||
| 340 | 339 | CONFIG_IP6_NF_MATCH_MH=m |
| 341 | 340 | CONFIG_IP6_NF_MATCH_RPFILTER=m |
| 342 | 341 | CONFIG_IP6_NF_MATCH_RT=m |
| 343 | −CONFIG_IP6_NF_TARGET_HL=m | |
| 344 | −CONFIG_IP6_NF_FILTER=m | |
| 345 | 342 | CONFIG_IP6_NF_TARGET_REJECT=m |
| 346 | −CONFIG_IP6_NF_MANGLE=m | |
| 347 | −CONFIG_IP6_NF_RAW=m | |
| 348 | −CONFIG_IP6_NF_SECURITY=m | |
| 349 | −CONFIG_IP6_NF_NAT=m | |
| 350 | −CONFIG_IP6_NF_TARGET_MASQUERADE=m | |
| 351 | 343 | CONFIG_NF_TABLES_BRIDGE=m |
| 344 | +CONFIG_IP_SCTP=m | |
| 352 | 345 | CONFIG_RDS=m |
| 353 | 346 | CONFIG_RDS_RDMA=m |
| 354 | 347 | CONFIG_RDS_TCP=m |
| @@ -383,6 +376,7 @@ CONFIG_NET_SCH_FQ_CODEL=m · 28 unmodified lines | ||
| 383 | 376 | CONFIG_NET_SCH_INGRESS=m |
| 384 | 377 | CONFIG_NET_SCH_PLUG=m |
| 385 | 378 | CONFIG_NET_SCH_ETS=m |
| 379 | +CONFIG_NET_SCH_DUALPI2=m | |
| 386 | 380 | CONFIG_NET_CLS_BASIC=m |
| 387 | 381 | CONFIG_NET_CLS_ROUTE4=m |
| 388 | 382 | CONFIG_NET_CLS_FW=m |
| @@ -504,6 +498,7 @@ CONFIG_DM_VDO=m · 115 unmodified lines | ||
| 504 | 498 | CONFIG_NETDEVICES=y |
| 505 | 499 | CONFIG_BONDING=m |
| 506 | 500 | CONFIG_DUMMY=m |
| 501 | +CONFIG_OVPN=m | |
| 507 | 502 | CONFIG_EQUALIZER=m |
| 508 | 503 | CONFIG_IFB=m |
| 509 | 504 | CONFIG_MACVLAN=m |
| @@ -641,6 +636,7 @@ CONFIG_VP_VDPA=m · 131 unmodified lines | ||
| 641 | 636 | CONFIG_VHOST_NET=m |
| 642 | 637 | CONFIG_VHOST_VSOCK=m |
| 643 | 638 | CONFIG_VHOST_VDPA=m |
| 639 | +CONFIG_DEV_DAX=m | |
| 644 | 640 | CONFIG_EXT4_FS=y |
| 645 | 641 | CONFIG_EXT4_FS_POSIX_ACL=y |
| 646 | 642 | CONFIG_EXT4_FS_SECURITY=y |
| @@ -665,6 +661,7 @@ CONFIG_NILFS2_FS=m · 18 unmodified lines | ||
| 665 | 661 | CONFIG_BCACHEFS_FS=y |
| 666 | 662 | CONFIG_BCACHEFS_QUOTA=y |
| 667 | 663 | CONFIG_BCACHEFS_POSIX_ACL=y |
| 664 | +CONFIG_FS_DAX=y | |
| 668 | 665 | CONFIG_EXPORTFS_BLOCK_OPS=y |
| 669 | 666 | CONFIG_FS_ENCRYPTION=y |
| 670 | 667 | CONFIG_FS_VERITY=y |
| @@ -755,6 +752,8 @@ CONFIG_HARDENED_USERCOPY=y · 84 unmodified lines | ||
| 755 | 752 | CONFIG_BUG_ON_DATA_CORRUPTION=y |
| 756 | 753 | CONFIG_CRYPTO_USER=m |
| 757 | 754 | CONFIG_CRYPTO_SELFTESTS=y |
| 755 | +CONFIG_CRYPTO_SELFTESTS_FULL=y | |
| 756 | +CONFIG_CRYPTO_NULL=y | |
| 758 | 757 | CONFIG_CRYPTO_PCRYPT=m |
| 759 | 758 | CONFIG_CRYPTO_CRYPTD=m |
| 760 | 759 | CONFIG_CRYPTO_BENCHMARK=m |
| @@ -783,7 +782,6 @@ CONFIG_CRYPTO_HCTR2=m · 22 unmodified lines | ||
| 783 | 782 | CONFIG_CRYPTO_LRW=m |
| 784 | 783 | CONFIG_CRYPTO_PCBC=m |
| 785 | 784 | CONFIG_CRYPTO_AEGIS128=m |
| 786 | −CONFIG_CRYPTO_CHACHA20POLY1305=m | |
| 787 | 785 | CONFIG_CRYPTO_GCM=y |
| 788 | 786 | CONFIG_CRYPTO_SEQIV=y |
| 789 | 787 | CONFIG_CRYPTO_MD4=m |
| @@ -822,6 +820,7 @@ CONFIG_SYSTEM_BLACKLIST_KEYRING=y · 32 unmodified lines | ||
| 822 | 820 | CONFIG_CRYPTO_KRB5=m |
| 823 | 821 | CONFIG_CRYPTO_KRB5_SELFTESTS=y |
| 824 | 822 | CONFIG_CORDIC=m |
| 823 | +CONFIG_TRACE_MMIO_ACCESS=y | |
| 825 | 824 | CONFIG_RANDOM32_SELFTEST=y |
| 826 | 825 | CONFIG_XZ_DEC_MICROLZMA=y |
| 827 | 826 | CONFIG_DMA_CMA=y |
| @@ -4,6 +4,7 @@ CONFIG_WATCH_QUEUE=y · 3 unmodified lines | ||
| 4 | 4 | CONFIG_AUDIT=y |
| 5 | 5 | CONFIG_NO_HZ_IDLE=y |
| 6 | 6 | CONFIG_HIGH_RES_TIMERS=y |
| 7 | +CONFIG_POSIX_AUX_CLOCKS=y | |
| 7 | 8 | CONFIG_BPF_SYSCALL=y |
| 8 | 9 | CONFIG_BPF_JIT=y |
| 9 | 10 | CONFIG_BPF_JIT_ALWAYS_ON=y |
| @@ -17,6 +18,7 @@ CONFIG_TASK_XACCT=y · 7 unmodified lines | ||
| 17 | 18 | CONFIG_TASK_IO_ACCOUNTING=y |
| 18 | 19 | CONFIG_IKCONFIG=y |
| 19 | 20 | CONFIG_IKCONFIG_PROC=y |
| 21 | +CONFIG_SCHED_PROXY_EXEC=y | |
| 20 | 22 | CONFIG_NUMA_BALANCING=y |
| 21 | 23 | CONFIG_MEMCG=y |
| 22 | 24 | CONFIG_BLK_CGROUP=y |
| @@ -40,11 +42,12 @@ CONFIG_PROFILING=y · 17 unmodified lines | ||
| 40 | 42 | CONFIG_KEXEC=y |
| 41 | 43 | CONFIG_KEXEC_FILE=y |
| 42 | 44 | CONFIG_KEXEC_SIG=y |
| 45 | +CONFIG_CRASH_DM_CRYPT=y | |
| 43 | 46 | CONFIG_LIVEPATCH=y |
| 44 | 47 | CONFIG_MARCH_Z13=y |
| 45 | 48 | CONFIG_NR_CPUS=512 |
| 46 | 49 | CONFIG_NUMA=y |
| 47 | −CONFIG_HZ_100=y | |
| 50 | +CONFIG_HZ_1000=y | |
| 48 | 51 | CONFIG_CERT_STORE=y |
| 49 | 52 | CONFIG_EXPOLINE=y |
| 50 | 53 | CONFIG_EXPOLINE_AUTO=y |
| @@ -97,6 +100,7 @@ CONFIG_CMA_AREAS=7 · 46 unmodified lines | ||
| 97 | 100 | CONFIG_MEM_SOFT_DIRTY=y |
| 98 | 101 | CONFIG_DEFERRED_STRUCT_PAGE_INIT=y |
| 99 | 102 | CONFIG_IDLE_PAGE_TRACKING=y |
| 103 | +CONFIG_ZONE_DEVICE=y | |
| 100 | 104 | CONFIG_PERCPU_STATS=y |
| 101 | 105 | CONFIG_ANON_VMA_NAME=y |
| 102 | 106 | CONFIG_USERFAULTFD=y |
| @@ -214,17 +218,19 @@ CONFIG_NETFILTER_XT_TARGET_CONNMARK=m · 111 unmodified lines | ||
| 214 | 218 | CONFIG_NETFILTER_XT_TARGET_CONNSECMARK=m |
| 215 | 219 | CONFIG_NETFILTER_XT_TARGET_CT=m |
| 216 | 220 | CONFIG_NETFILTER_XT_TARGET_DSCP=m |
| 221 | +CONFIG_NETFILTER_XT_TARGET_HL=m | |
| 217 | 222 | CONFIG_NETFILTER_XT_TARGET_HMARK=m |
| 218 | 223 | CONFIG_NETFILTER_XT_TARGET_IDLETIMER=m |
| 219 | 224 | CONFIG_NETFILTER_XT_TARGET_LOG=m |
| 220 | 225 | CONFIG_NETFILTER_XT_TARGET_MARK=m |
| 226 | +CONFIG_NETFILTER_XT_NAT=m | |
| 221 | 227 | CONFIG_NETFILTER_XT_TARGET_NETMAP=m |
| 222 | 228 | CONFIG_NETFILTER_XT_TARGET_NFLOG=m |
| 223 | 229 | CONFIG_NETFILTER_XT_TARGET_NFQUEUE=m |
| 224 | 230 | CONFIG_NETFILTER_XT_TARGET_REDIRECT=m |
| 231 | +CONFIG_NETFILTER_XT_TARGET_MASQUERADE=m | |
| 225 | 232 | CONFIG_NETFILTER_XT_TARGET_TEE=m |
| 226 | 233 | CONFIG_NETFILTER_XT_TARGET_TPROXY=m |
| 227 | −CONFIG_NETFILTER_XT_TARGET_TRACE=m | |
| 228 | 234 | CONFIG_NETFILTER_XT_TARGET_SECMARK=m |
| 229 | 235 | CONFIG_NETFILTER_XT_TARGET_TCPMSS=m |
| 230 | 236 | CONFIG_NETFILTER_XT_TARGET_TCPOPTSTRIP=m |
| @@ -239,6 +245,7 @@ CONFIG_NETFILTER_XT_MATCH_CONNLIMIT=m · 8 unmodified lines | ||
| 239 | 245 | CONFIG_NETFILTER_XT_MATCH_CONNMARK=m |
| 240 | 246 | CONFIG_NETFILTER_XT_MATCH_CONNTRACK=m |
| 241 | 247 | CONFIG_NETFILTER_XT_MATCH_CPU=m |
| 248 | +CONFIG_NETFILTER_XT_MATCH_DCCP=m | |
| 242 | 249 | CONFIG_NETFILTER_XT_MATCH_DEVGROUP=m |
| 243 | 250 | CONFIG_NETFILTER_XT_MATCH_DSCP=m |
| 244 | 251 | CONFIG_NETFILTER_XT_MATCH_ESP=m |
| @@ -309,16 +316,8 @@ CONFIG_IP_NF_MATCH_AH=m · 64 unmodified lines | ||
| 309 | 316 | CONFIG_IP_NF_MATCH_ECN=m |
| 310 | 317 | CONFIG_IP_NF_MATCH_RPFILTER=m |
| 311 | 318 | CONFIG_IP_NF_MATCH_TTL=m |
| 312 | −CONFIG_IP_NF_FILTER=m | |
| 313 | 319 | CONFIG_IP_NF_TARGET_REJECT=m |
| 314 | −CONFIG_IP_NF_NAT=m | |
| 315 | −CONFIG_IP_NF_TARGET_MASQUERADE=m | |
| 316 | −CONFIG_IP_NF_MANGLE=m | |
| 317 | 320 | CONFIG_IP_NF_TARGET_ECN=m |
| 318 | −CONFIG_IP_NF_TARGET_TTL=m | |
| 319 | −CONFIG_IP_NF_RAW=m | |
| 320 | −CONFIG_IP_NF_SECURITY=m | |
| 321 | −CONFIG_IP_NF_ARPFILTER=m | |
| 322 | 321 | CONFIG_IP_NF_ARP_MANGLE=m |
| 323 | 322 | CONFIG_NFT_FIB_IPV6=m |
| 324 | 323 | CONFIG_IP6_NF_IPTABLES=m |
| @@ -331,15 +330,9 @@ CONFIG_IP6_NF_MATCH_IPV6HEADER=m · 6 unmodified lines | ||
| 331 | 330 | CONFIG_IP6_NF_MATCH_MH=m |
| 332 | 331 | CONFIG_IP6_NF_MATCH_RPFILTER=m |
| 333 | 332 | CONFIG_IP6_NF_MATCH_RT=m |
| 334 | −CONFIG_IP6_NF_TARGET_HL=m | |
| 335 | −CONFIG_IP6_NF_FILTER=m | |
| 336 | 333 | CONFIG_IP6_NF_TARGET_REJECT=m |
| 337 | −CONFIG_IP6_NF_MANGLE=m | |
| 338 | −CONFIG_IP6_NF_RAW=m | |
| 339 | −CONFIG_IP6_NF_SECURITY=m | |
| 340 | −CONFIG_IP6_NF_NAT=m | |
| 341 | −CONFIG_IP6_NF_TARGET_MASQUERADE=m | |
| 342 | 334 | CONFIG_NF_TABLES_BRIDGE=m |
| 335 | +CONFIG_IP_SCTP=m | |
| 343 | 336 | CONFIG_RDS=m |
| 344 | 337 | CONFIG_RDS_RDMA=m |
| 345 | 338 | CONFIG_RDS_TCP=m |
| @@ -373,6 +366,7 @@ CONFIG_NET_SCH_FQ_CODEL=m · 27 unmodified lines | ||
| 373 | 366 | CONFIG_NET_SCH_INGRESS=m |
| 374 | 367 | CONFIG_NET_SCH_PLUG=m |
| 375 | 368 | CONFIG_NET_SCH_ETS=m |
| 369 | +CONFIG_NET_SCH_DUALPI2=m | |
| 376 | 370 | CONFIG_NET_CLS_BASIC=m |
| 377 | 371 | CONFIG_NET_CLS_ROUTE4=m |
| 378 | 372 | CONFIG_NET_CLS_FW=m |
| @@ -494,6 +488,7 @@ CONFIG_DM_VDO=m · 115 unmodified lines | ||
| 494 | 488 | CONFIG_NETDEVICES=y |
| 495 | 489 | CONFIG_BONDING=m |
| 496 | 490 | CONFIG_DUMMY=m |
| 491 | +CONFIG_OVPN=m | |
| 497 | 492 | CONFIG_EQUALIZER=m |
| 498 | 493 | CONFIG_IFB=m |
| 499 | 494 | CONFIG_MACVLAN=m |
| @@ -631,6 +626,7 @@ CONFIG_VP_VDPA=m · 131 unmodified lines | ||
| 631 | 626 | CONFIG_VHOST_NET=m |
| 632 | 627 | CONFIG_VHOST_VSOCK=m |
| 633 | 628 | CONFIG_VHOST_VDPA=m |
| 629 | +CONFIG_DEV_DAX=m | |
| 634 | 630 | CONFIG_EXT4_FS=y |
| 635 | 631 | CONFIG_EXT4_FS_POSIX_ACL=y |
| 636 | 632 | CONFIG_EXT4_FS_SECURITY=y |
| @@ -652,6 +648,7 @@ CONFIG_NILFS2_FS=m · 15 unmodified lines | ||
| 652 | 648 | CONFIG_BCACHEFS_FS=m |
| 653 | 649 | CONFIG_BCACHEFS_QUOTA=y |
| 654 | 650 | CONFIG_BCACHEFS_POSIX_ACL=y |
| 651 | +CONFIG_FS_DAX=y | |
| 655 | 652 | CONFIG_EXPORTFS_BLOCK_OPS=y |
| 656 | 653 | CONFIG_FS_ENCRYPTION=y |
| 657 | 654 | CONFIG_FS_VERITY=y |
| @@ -683,7 +680,6 @@ CONFIG_TMPFS_POSIX_ACL=y · 25 unmodified lines | ||
| 683 | 680 | CONFIG_TMPFS_INODE64=y |
| 684 | 681 | CONFIG_TMPFS_QUOTA=y |
| 685 | 682 | CONFIG_HUGETLBFS=y |
| 686 | −CONFIG_CONFIGFS_FS=m | |
| 687 | 683 | CONFIG_ECRYPT_FS=m |
| 688 | 684 | CONFIG_CRAMFS=m |
| 689 | 685 | CONFIG_SQUASHFS=m |
| @@ -741,6 +737,7 @@ CONFIG_BUG_ON_DATA_CORRUPTION=y · 51 unmodified lines | ||
| 741 | 737 | CONFIG_CRYPTO_FIPS=y |
| 742 | 738 | CONFIG_CRYPTO_USER=m |
| 743 | 739 | CONFIG_CRYPTO_SELFTESTS=y |
| 740 | +CONFIG_CRYPTO_NULL=y | |
| 744 | 741 | CONFIG_CRYPTO_PCRYPT=m |
| 745 | 742 | CONFIG_CRYPTO_CRYPTD=m |
| 746 | 743 | CONFIG_CRYPTO_BENCHMARK=m |
| @@ -769,7 +766,6 @@ CONFIG_CRYPTO_HCTR2=m · 22 unmodified lines | ||
| 769 | 766 | CONFIG_CRYPTO_LRW=m |
| 770 | 767 | CONFIG_CRYPTO_PCBC=m |
| 771 | 768 | CONFIG_CRYPTO_AEGIS128=m |
| 772 | −CONFIG_CRYPTO_CHACHA20POLY1305=m | |
| 773 | 769 | CONFIG_CRYPTO_GCM=y |
| 774 | 770 | CONFIG_CRYPTO_SEQIV=y |
| 775 | 771 | CONFIG_CRYPTO_MD4=m |
| @@ -1,5 +1,6 @@ | ||
| 1 | 1 | CONFIG_NO_HZ_IDLE=y |
| 2 | 2 | CONFIG_HIGH_RES_TIMERS=y |
| 3 | +CONFIG_POSIX_AUX_CLOCKS=y | |
| 3 | 4 | CONFIG_BPF_SYSCALL=y |
| 4 | 5 | # CONFIG_CPU_ISOLATION is not set |
| 5 | 6 | # CONFIG_UTS_NS is not set |
| @@ -11,7 +12,7 @@ CONFIG_CC_OPTIMIZE_FOR_SIZE=y · 5 unmodified lines | ||
| 11 | 12 | CONFIG_KEXEC=y |
| 12 | 13 | CONFIG_MARCH_Z13=y |
| 13 | 14 | CONFIG_NR_CPUS=2 |
| 14 | −CONFIG_HZ_100=y | |
| 15 | +CONFIG_HZ_1000=y | |
| 15 | 16 | # CONFIG_CHSC_SCH is not set |
| 16 | 17 | # CONFIG_SCM_BUS is not set |
| 17 | 18 | # CONFIG_AP is not set |
| @@ -6,6 +6,7 @@ · 5 unmodified lines | ||
| 6 | 6 | * Author(s): Michael Holzheu <holzheu@linux.vnet.ibm.com> |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | +#include <linux/security.h> | |
| 9 | 10 | #include <linux/slab.h> |
| 10 | 11 | #include "hypfs.h" |
| 11 | 12 | |
| @@ -66,23 +67,27 @@ static long dbfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg) · 54 unmodified lines | ||
| 66 | 67 | long rc; |
| 67 | 68 | |
| 68 | 69 | mutex_lock(&df->lock); |
| 69 | − if (df->unlocked_ioctl) | |
| 70 | − rc = df->unlocked_ioctl(file, cmd, arg); | |
| 71 | − else | |
| 72 | − rc = -ENOTTY; | |
| 70 | + rc = df->unlocked_ioctl(file, cmd, arg); | |
| 73 | 71 | mutex_unlock(&df->lock); |
| 74 | 72 | return rc; |
| 75 | 73 | } |
| 76 | 74 | |
| 77 | −static const struct file_operations dbfs_ops = { | |
| 75 | +static const struct file_operations dbfs_ops_ioctl = { | |
| 78 | 76 | .read = dbfs_read, |
| 79 | 77 | .unlocked_ioctl = dbfs_ioctl, |
| 80 | 78 | }; |
| 81 | 79 | |
| 80 | +static const struct file_operations dbfs_ops = { | |
| 81 | + .read = dbfs_read, | |
| 82 | +}; | |
| 83 | + | |
| 82 | 84 | void hypfs_dbfs_create_file(struct hypfs_dbfs_file *df) |
| 83 | 85 | { |
| 84 | − df->dentry = debugfs_create_file(df->name, 0400, dbfs_dir, df, | |
| 85 | − &dbfs_ops); | |
| 86 | + const struct file_operations *fops = &dbfs_ops; | |
| 87 | + | |
| 88 | + if (df->unlocked_ioctl && !security_locked_down(LOCKDOWN_DEBUGFS)) | |
| 89 | + fops = &dbfs_ops_ioctl; | |
| 90 | + df->dentry = debugfs_create_file(df->name, 0400, dbfs_dir, df, fops); | |
| 86 | 91 | mutex_init(&df->lock); |
| 87 | 92 | } |
| 88 | 93 | |
| @@ -94,12 +94,13 @@ DECLARE_STATIC_CALL(xen_hypercall, xen_hypercall_func); · 93 unmodified lines | ||
| 94 | 94 | #ifdef MODULE |
| 95 | 95 | #define __ADDRESSABLE_xen_hypercall |
| 96 | 96 | #else |
| 97 | −#define __ADDRESSABLE_xen_hypercall __ADDRESSABLE_ASM_STR(__SCK__xen_hypercall) | |
| 97 | +#define __ADDRESSABLE_xen_hypercall \ | |
| 98 | + __stringify(.global STATIC_CALL_KEY(xen_hypercall);) | |
| 98 | 99 | #endif |
| 99 | 100 | |
| 100 | 101 | #define __HYPERCALL \ |
| 101 | 102 | __ADDRESSABLE_xen_hypercall \ |
| 102 | − "call __SCT__xen_hypercall" | |
| 103 | + __stringify(call STATIC_CALL_TRAMP(xen_hypercall)) | |
| 103 | 104 | |
| 104 | 105 | #define __HYPERCALL_ENTRY(x) "a" (x) |
| 105 | 106 | |
| @@ -1326,8 +1326,8 @@ static const char * const s5_reset_reason_txt[] = { · 1325 unmodified lines | ||
| 1326 | 1326 | |
| 1327 | 1327 | static __init int print_s5_reset_status_mmio(void) |
| 1328 | 1328 | { |
| 1329 | − unsigned long value; | |
| 1330 | 1329 | void __iomem *addr; |
| 1330 | + u32 value; | |
| 1331 | 1331 | int i; |
| 1332 | 1332 | |
| 1333 | 1333 | if (!cpu_feature_enabled(X86_FEATURE_ZEN)) |
| @@ -1340,12 +1340,16 @@ static __init int print_s5_reset_status_mmio(void) · 6 unmodified lines | ||
| 1340 | 1340 | value = ioread32(addr); |
| 1341 | 1341 | iounmap(addr); |
| 1342 | 1342 | |
| 1343 | + /* Value with "all bits set" is an error response and should be ignored. */ | |
| 1344 | + if (value == U32_MAX) | |
| 1345 | + return 0; | |
| 1346 | + | |
| 1343 | 1347 | for (i = 0; i < ARRAY_SIZE(s5_reset_reason_txt); i++) { |
| 1344 | 1348 | if (!(value & BIT(i))) |
| 1345 | 1349 | continue; |
| 1346 | 1350 | |
| 1347 | 1351 | if (s5_reset_reason_txt[i]) { |
| 1348 | − pr_info("x86/amd: Previous system reset reason [0x%08lx]: %s\n", | |
| 1352 | + pr_info("x86/amd: Previous system reset reason [0x%08x]: %s\n", | |
| 1349 | 1353 | value, s5_reset_reason_txt[i]); |
| 1350 | 1354 | } |
| 1351 | 1355 | } |
| @@ -1068,10 +1068,8 @@ static void __init gds_select_mitigation(void) · 1067 unmodified lines | ||
| 1068 | 1068 | if (gds_mitigation == GDS_MITIGATION_AUTO) { |
| 1069 | 1069 | if (should_mitigate_vuln(X86_BUG_GDS)) |
| 1070 | 1070 | gds_mitigation = GDS_MITIGATION_FULL; |
| 1071 | − else { | |
| 1071 | + else | |
| 1072 | 1072 | gds_mitigation = GDS_MITIGATION_OFF; |
| 1073 | − return; | |
| 1074 | − } | |
| 1075 | 1073 | } |
| 1076 | 1074 | |
| 1077 | 1075 | /* No microcode */ |
| @@ -16,6 +16,7 @@ · 15 unmodified lines | ||
| 16 | 16 | #include <asm/spec-ctrl.h> |
| 17 | 17 | #include <asm/delay.h> |
| 18 | 18 | #include <asm/msr.h> |
| 19 | +#include <asm/resctrl.h> | |
| 19 | 20 | |
| 20 | 21 | #include "cpu.h" |
| 21 | 22 | |
| @@ -117,6 +118,8 @@ static void bsp_init_hygon(struct cpuinfo_x86 *c) · 95 unmodified lines | ||
| 117 | 118 | x86_amd_ls_cfg_ssbd_mask = 1ULL << 10; |
| 118 | 119 | } |
| 119 | 120 | } |
| 121 | + | |
| 122 | + resctrl_cpu_detect(c); | |
| 120 | 123 | } |
| 121 | 124 | |
| 122 | 125 | static void early_init_hygon(struct cpuinfo_x86 *c) |
| @@ -557,7 +557,7 @@ static inline int bio_check_eod(struct bio *bio) · 556 unmodified lines | ||
| 557 | 557 | sector_t maxsector = bdev_nr_sectors(bio->bi_bdev); |
| 558 | 558 | unsigned int nr_sectors = bio_sectors(bio); |
| 559 | 559 | |
| 560 | − if (nr_sectors && | |
| 560 | + if (nr_sectors && maxsector && | |
| 561 | 561 | (nr_sectors > maxsector || |
| 562 | 562 | bio->bi_iter.bi_sector > maxsector - nr_sectors)) { |
| 563 | 563 | pr_info_ratelimited("%s: attempt to access beyond end of device\n" |
| @@ -95,6 +95,7 @@ static const char *const blk_queue_flag_name[] = { · 94 unmodified lines | ||
| 95 | 95 | QUEUE_FLAG_NAME(SQ_SCHED), |
| 96 | 96 | QUEUE_FLAG_NAME(DISABLE_WBT_DEF), |
| 97 | 97 | QUEUE_FLAG_NAME(NO_ELV_SWITCH), |
| 98 | + QUEUE_FLAG_NAME(QOS_ENABLED), | |
| 98 | 99 | }; |
| 99 | 100 | #undef QUEUE_FLAG_NAME |
| 100 | 101 | |
| @@ -5033,6 +5033,7 @@ static void __blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set, · 5032 unmodified lines | ||
| 5033 | 5033 | unsigned int memflags; |
| 5034 | 5034 | int i; |
| 5035 | 5035 | struct xarray elv_tbl, et_tbl; |
| 5036 | + bool queues_frozen = false; | |
| 5036 | 5037 | |
| 5037 | 5038 | lockdep_assert_held(&set->tag_list_lock); |
| 5038 | 5039 | |
| @@ -5056,9 +5057,6 @@ static void __blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set, · 17 unmodified lines | ||
| 5056 | 5057 | blk_mq_sysfs_unregister_hctxs(q); |
| 5057 | 5058 | } |
| 5058 | 5059 | |
| 5059 | − list_for_each_entry(q, &set->tag_list, tag_set_list) | |
| 5060 | − blk_mq_freeze_queue_nomemsave(q); | |
| 5061 | − | |
| 5062 | 5060 | /* |
| 5063 | 5061 | * Switch IO scheduler to 'none', cleaning up the data associated |
| 5064 | 5062 | * with the previous scheduler. We will switch back once we are done |
| @@ -5068,6 +5066,9 @@ static void __blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set, · 3 unmodified lines | ||
| 5068 | 5066 | if (blk_mq_elv_switch_none(q, &elv_tbl)) |
| 5069 | 5067 | goto switch_back; |
| 5070 | 5068 | |
| 5069 | + list_for_each_entry(q, &set->tag_list, tag_set_list) | |
| 5070 | + blk_mq_freeze_queue_nomemsave(q); | |
| 5071 | + queues_frozen = true; | |
| 5071 | 5072 | if (blk_mq_realloc_tag_set_tags(set, nr_hw_queues) < 0) |
| 5072 | 5073 | goto switch_back; |
| 5073 | 5074 | |
| @@ -5091,8 +5092,12 @@ fallback: · 17 unmodified lines | ||
| 5091 | 5092 | } |
| 5092 | 5093 | switch_back: |
| 5093 | 5094 | /* The blk_mq_elv_switch_back unfreezes queue for us. */ |
| 5094 | − list_for_each_entry(q, &set->tag_list, tag_set_list) | |
| 5095 | + list_for_each_entry(q, &set->tag_list, tag_set_list) { | |
| 5096 | + /* switch_back expects queue to be frozen */ | |
| 5097 | + if (!queues_frozen) | |
| 5098 | + blk_mq_freeze_queue_nomemsave(q); | |
| 5095 | 5099 | blk_mq_elv_switch_back(q, &elv_tbl, &et_tbl); |
| 5100 | + } | |
| 5096 | 5101 | |
| 5097 | 5102 | list_for_each_entry(q, &set->tag_list, tag_set_list) { |
| 5098 | 5103 | blk_mq_sysfs_register_hctxs(q); |
| @@ -2,8 +2,6 @@ · 1 unmodified line | ||
| 2 | 2 | |
| 3 | 3 | #include "blk-rq-qos.h" |
| 4 | 4 | |
| 5 | −__read_mostly DEFINE_STATIC_KEY_FALSE(block_rq_qos); | |
| 6 | − | |
| 7 | 5 | /* |
| 8 | 6 | * Increment 'v', if 'v' is below 'below'. Returns true if we succeeded, |
| 9 | 7 | * false if 'v' + 1 would be bigger than 'below'. |
| @@ -319,8 +317,8 @@ void rq_qos_exit(struct request_queue *q) · 309 unmodified lines | ||
| 319 | 317 | struct rq_qos *rqos = q->rq_qos; |
| 320 | 318 | q->rq_qos = rqos->next; |
| 321 | 319 | rqos->ops->exit(rqos); |
| 322 | − static_branch_dec(&block_rq_qos); | |
| 323 | 320 | } |
| 321 | + blk_queue_flag_clear(QUEUE_FLAG_QOS_ENABLED, q); | |
| 324 | 322 | mutex_unlock(&q->rq_qos_mutex); |
| 325 | 323 | } |
| 326 | 324 | |
| @@ -346,7 +344,7 @@ int rq_qos_add(struct rq_qos *rqos, struct gendisk *disk, enum rq_qos_id id, · 19 unmodified lines | ||
| 346 | 344 | goto ebusy; |
| 347 | 345 | rqos->next = q->rq_qos; |
| 348 | 346 | q->rq_qos = rqos; |
| 349 | − static_branch_inc(&block_rq_qos); | |
| 347 | + blk_queue_flag_set(QUEUE_FLAG_QOS_ENABLED, q); | |
| 350 | 348 | |
| 351 | 349 | blk_mq_unfreeze_queue(q, memflags); |
| 352 | 350 | |
| @@ -377,6 +375,8 @@ void rq_qos_del(struct rq_qos *rqos) · 24 unmodified lines | ||
| 377 | 375 | break; |
| 378 | 376 | } |
| 379 | 377 | } |
| 378 | + if (!q->rq_qos) | |
| 379 | + blk_queue_flag_clear(QUEUE_FLAG_QOS_ENABLED, q); | |
| 380 | 380 | blk_mq_unfreeze_queue(q, memflags); |
| 381 | 381 | |
| 382 | 382 | mutex_lock(&q->debugfs_mutex); |
| @@ -12,7 +12,6 @@ · 11 unmodified lines | ||
| 12 | 12 | #include "blk-mq-debugfs.h" |
| 13 | 13 | |
| 14 | 14 | struct blk_mq_debugfs_attr; |
| 15 | −extern struct static_key_false block_rq_qos; | |
| 16 | 15 | |
| 17 | 16 | enum rq_qos_id { |
| 18 | 17 | RQ_QOS_WBT, |
| @@ -113,43 +112,55 @@ void __rq_qos_queue_depth_changed(struct rq_qos *rqos); · 94 unmodified lines | ||
| 113 | 112 | |
| 114 | 113 | static inline void rq_qos_cleanup(struct request_queue *q, struct bio *bio) |
| 115 | 114 | { |
| 116 | − if (static_branch_unlikely(&block_rq_qos) && q->rq_qos) | |
| 115 | + if (unlikely(test_bit(QUEUE_FLAG_QOS_ENABLED, &q->queue_flags)) && | |
| 116 | + q->rq_qos) | |
| 117 | 117 | __rq_qos_cleanup(q->rq_qos, bio); |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | static inline void rq_qos_done(struct request_queue *q, struct request *rq) |
| 121 | 121 | { |
| 122 | − if (static_branch_unlikely(&block_rq_qos) && q->rq_qos && | |
| 123 | − !blk_rq_is_passthrough(rq)) | |
| 122 | + if (unlikely(test_bit(QUEUE_FLAG_QOS_ENABLED, &q->queue_flags)) && | |
| 123 | + q->rq_qos && !blk_rq_is_passthrough(rq)) | |
| 124 | 124 | __rq_qos_done(q->rq_qos, rq); |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | static inline void rq_qos_issue(struct request_queue *q, struct request *rq) |
| 128 | 128 | { |
| 129 | − if (static_branch_unlikely(&block_rq_qos) && q->rq_qos) | |
| 129 | + if (unlikely(test_bit(QUEUE_FLAG_QOS_ENABLED, &q->queue_flags)) && | |
| 130 | + q->rq_qos) | |
| 130 | 131 | __rq_qos_issue(q->rq_qos, rq); |
| 131 | 132 | } |
| 132 | 133 | |
| 133 | 134 | static inline void rq_qos_requeue(struct request_queue *q, struct request *rq) |
| 134 | 135 | { |
| 135 | − if (static_branch_unlikely(&block_rq_qos) && q->rq_qos) | |
| 136 | + if (unlikely(test_bit(QUEUE_FLAG_QOS_ENABLED, &q->queue_flags)) && | |
| 137 | + q->rq_qos) | |
| 136 | 138 | __rq_qos_requeue(q->rq_qos, rq); |
| 137 | 139 | } |
| 138 | 140 | |
| 139 | 141 | static inline void rq_qos_done_bio(struct bio *bio) |
| 140 | 142 | { |
| 141 | − if (static_branch_unlikely(&block_rq_qos) && | |
| 142 | − bio->bi_bdev && (bio_flagged(bio, BIO_QOS_THROTTLED) || | |
| 143 | − bio_flagged(bio, BIO_QOS_MERGED))) { | |
| 144 | − struct request_queue *q = bdev_get_queue(bio->bi_bdev); | |
| 145 | − if (q->rq_qos) | |
| 146 | − __rq_qos_done_bio(q->rq_qos, bio); | |
| 147 | − } | |
| 143 | + struct request_queue *q; | |
| 144 | + | |
| 145 | + if (!bio->bi_bdev || (!bio_flagged(bio, BIO_QOS_THROTTLED) && | |
| 146 | + !bio_flagged(bio, BIO_QOS_MERGED))) | |
| 147 | + return; | |
| 148 | + | |
| 149 | + q = bdev_get_queue(bio->bi_bdev); | |
| 150 | + | |
| 151 | + /* | |
| 152 | + * If a bio has BIO_QOS_xxx set, it implicitly implies that | |
| 153 | + * q->rq_qos is present. So, we skip re-checking q->rq_qos | |
| 154 | + * here as an extra optimization and directly call | |
| 155 | + * __rq_qos_done_bio(). | |
| 156 | + */ | |
| 157 | + __rq_qos_done_bio(q->rq_qos, bio); | |
| 148 | 158 | } |
| 149 | 159 | |
| 150 | 160 | static inline void rq_qos_throttle(struct request_queue *q, struct bio *bio) |
| 151 | 161 | { |
| 152 | − if (static_branch_unlikely(&block_rq_qos) && q->rq_qos) { | |
| 162 | + if (unlikely(test_bit(QUEUE_FLAG_QOS_ENABLED, &q->queue_flags)) && | |
| 163 | + q->rq_qos) { | |
| 153 | 164 | bio_set_flag(bio, BIO_QOS_THROTTLED); |
| 154 | 165 | __rq_qos_throttle(q->rq_qos, bio); |
| 155 | 166 | } |
| @@ -158,14 +169,16 @@ static inline void rq_qos_throttle(struct request_queue *q, struct bio *bio) · 2 unmodified lines | ||
| 158 | 169 | static inline void rq_qos_track(struct request_queue *q, struct request *rq, |
| 159 | 170 | struct bio *bio) |
| 160 | 171 | { |
| 161 | − if (static_branch_unlikely(&block_rq_qos) && q->rq_qos) | |
| 172 | + if (unlikely(test_bit(QUEUE_FLAG_QOS_ENABLED, &q->queue_flags)) && | |
| 173 | + q->rq_qos) | |
| 162 | 174 | __rq_qos_track(q->rq_qos, rq, bio); |
| 163 | 175 | } |
| 164 | 176 | |
| 165 | 177 | static inline void rq_qos_merge(struct request_queue *q, struct request *rq, |
| 166 | 178 | struct bio *bio) |
| 167 | 179 | { |
| 168 | − if (static_branch_unlikely(&block_rq_qos) && q->rq_qos) { | |
| 180 | + if (unlikely(test_bit(QUEUE_FLAG_QOS_ENABLED, &q->queue_flags)) && | |
| 181 | + q->rq_qos) { | |
| 169 | 182 | bio_set_flag(bio, BIO_QOS_MERGED); |
| 170 | 183 | __rq_qos_merge(q->rq_qos, rq, bio); |
| 171 | 184 | } |
| @@ -173,7 +186,8 @@ static inline void rq_qos_merge(struct request_queue *q, struct request *rq, · 1 unmodified line | ||
| 173 | 186 | |
| 174 | 187 | static inline void rq_qos_queue_depth_changed(struct request_queue *q) |
| 175 | 188 | { |
| 176 | − if (static_branch_unlikely(&block_rq_qos) && q->rq_qos) | |
| 189 | + if (unlikely(test_bit(QUEUE_FLAG_QOS_ENABLED, &q->queue_flags)) && | |
| 190 | + q->rq_qos) | |
| 177 | 191 | __rq_qos_queue_depth_changed(q->rq_qos); |
| 178 | 192 | } |
| 179 | 193 | |
| @@ -157,16 +157,14 @@ static int blk_validate_integrity_limits(struct queue_limits *lim) · 156 unmodified lines | ||
| 157 | 157 | switch (bi->csum_type) { |
| 158 | 158 | case BLK_INTEGRITY_CSUM_NONE: |
| 159 | 159 | if (bi->pi_tuple_size) { |
| 160 | − pr_warn("pi_tuple_size must be 0 when checksum type \ | |
| 161 | − is none\n"); | |
| 160 | + pr_warn("pi_tuple_size must be 0 when checksum type is none\n"); | |
| 162 | 161 | return -EINVAL; |
| 163 | 162 | } |
| 164 | 163 | break; |
| 165 | 164 | case BLK_INTEGRITY_CSUM_CRC: |
| 166 | 165 | case BLK_INTEGRITY_CSUM_IP: |
| 167 | 166 | if (bi->pi_tuple_size != sizeof(struct t10_pi_tuple)) { |
| 168 | − pr_warn("pi_tuple_size mismatch for T10 PI: expected \ | |
| 169 | − %zu, got %u\n", | |
| 167 | + pr_warn("pi_tuple_size mismatch for T10 PI: expected %zu, got %u\n", | |
| 170 | 168 | sizeof(struct t10_pi_tuple), |
| 171 | 169 | bi->pi_tuple_size); |
| 172 | 170 | return -EINVAL; |
| @@ -174,8 +172,7 @@ static int blk_validate_integrity_limits(struct queue_limits *lim) · 1 unmodified line | ||
| 174 | 172 | break; |
| 175 | 173 | case BLK_INTEGRITY_CSUM_CRC64: |
| 176 | 174 | if (bi->pi_tuple_size != sizeof(struct crc64_pi_tuple)) { |
| 177 | − pr_warn("pi_tuple_size mismatch for CRC64 PI: \ | |
| 178 | − expected %zu, got %u\n", | |
| 175 | + pr_warn("pi_tuple_size mismatch for CRC64 PI: expected %zu, got %u\n", | |
| 179 | 176 | sizeof(struct crc64_pi_tuple), |
| 180 | 177 | bi->pi_tuple_size); |
| 181 | 178 | return -EINVAL; |
| @@ -972,6 +969,8 @@ bool queue_limits_stack_integrity(struct queue_limits *t, · 790 unmodified lines | ||
| 972 | 969 | goto incompatible; |
| 973 | 970 | if (ti->csum_type != bi->csum_type) |
| 974 | 971 | goto incompatible; |
| 972 | + if (ti->pi_tuple_size != bi->pi_tuple_size) | |
| 973 | + goto incompatible; | |
| 975 | 974 | if ((ti->flags & BLK_INTEGRITY_REF_TAG) != |
| 976 | 975 | (bi->flags & BLK_INTEGRITY_REF_TAG)) |
| 977 | 976 | goto incompatible; |
| @@ -980,6 +979,7 @@ bool queue_limits_stack_integrity(struct queue_limits *t, · 2 unmodified lines | ||
| 980 | 979 | ti->flags |= (bi->flags & BLK_INTEGRITY_DEVICE_CAPABLE) | |
| 981 | 980 | (bi->flags & BLK_INTEGRITY_REF_TAG); |
| 982 | 981 | ti->csum_type = bi->csum_type; |
| 982 | + ti->pi_tuple_size = bi->pi_tuple_size; | |
| 983 | 983 | ti->metadata_size = bi->metadata_size; |
| 984 | 984 | ti->pi_offset = bi->pi_offset; |
| 985 | 985 | ti->interval_exp = bi->interval_exp; |
| @@ -10437,7 +10437,7 @@ end: · 10436 unmodified lines | ||
| 10437 | 10437 | (u64 *)(lin_dma_pkts_arr), DEBUGFS_WRITE64); |
| 10438 | 10438 | WREG32(sob_addr, 0); |
| 10439 | 10439 | |
| 10440 | − kfree(lin_dma_pkts_arr); | |
| 10440 | + kvfree(lin_dma_pkts_arr); | |
| 10441 | 10441 | |
| 10442 | 10442 | return rc; |
| 10443 | 10443 | } |
| @@ -315,7 +315,7 @@ static void __iomem *einj_get_parameter_address(void) · 314 unmodified lines | ||
| 315 | 315 | memcpy_fromio(&v5param, p, v5param_size); |
| 316 | 316 | acpi5 = 1; |
| 317 | 317 | check_vendor_extension(pa_v5, &v5param); |
| 318 | − if (available_error_type & ACPI65_EINJV2_SUPP) { | |
| 318 | + if (is_v2 && available_error_type & ACPI65_EINJV2_SUPP) { | |
| 319 | 319 | len = v5param.einjv2_struct.length; |
| 320 | 320 | offset = offsetof(struct einjv2_extension_struct, component_arr); |
| 321 | 321 | max_nr_components = (len - offset) / |
| @@ -540,6 +540,9 @@ static int __einj_error_inject(u32 type, u32 flags, u64 param1, u64 param2, · 218 unmodified lines | ||
| 540 | 540 | struct set_error_type_with_address *v5param; |
| 541 | 541 | |
| 542 | 542 | v5param = kmalloc(v5param_size, GFP_KERNEL); |
| 543 | + if (!v5param) | |
| 544 | + return -ENOMEM; | |
| 545 | + | |
| 543 | 546 | memcpy_fromio(v5param, einj_param, v5param_size); |
| 544 | 547 | v5param->type = type; |
| 545 | 548 | if (type & ACPI5_VENDOR_BIT) { |
| @@ -1091,7 +1094,7 @@ err_put_table: · 545 unmodified lines | ||
| 1091 | 1094 | return rc; |
| 1092 | 1095 | } |
| 1093 | 1096 | |
| 1094 | −static void __exit einj_remove(struct faux_device *fdev) | |
| 1097 | +static void einj_remove(struct faux_device *fdev) | |
| 1095 | 1098 | { |
| 1096 | 1099 | struct apei_exec_context ctx; |
| 1097 | 1100 | |
| @@ -1114,15 +1117,9 @@ static void __exit einj_remove(struct faux_device *fdev) · 16 unmodified lines | ||
| 1114 | 1117 | } |
| 1115 | 1118 | |
| 1116 | 1119 | static struct faux_device *einj_dev; |
| 1117 | −/* | |
| 1118 | − * einj_remove() lives in .exit.text. For drivers registered via | |
| 1119 | − * platform_driver_probe() this is ok because they cannot get unbound at | |
| 1120 | − * runtime. So mark the driver struct with __refdata to prevent modpost | |
| 1121 | − * triggering a section mismatch warning. | |
| 1122 | − */ | |
| 1123 | −static struct faux_device_ops einj_device_ops __refdata = { | |
| 1120 | +static struct faux_device_ops einj_device_ops = { | |
| 1124 | 1121 | .probe = einj_probe, |
| 1125 | − .remove = __exit_p(einj_remove), | |
| 1122 | + .remove = einj_remove, | |
| 1126 | 1123 | }; |
| 1127 | 1124 | |
| 1128 | 1125 | static int __init einj_init(void) |
| @@ -329,7 +329,7 @@ static bool applicable_image(const void *data, struct pfru_update_cap_info *cap, · 328 unmodified lines | ||
| 329 | 329 | if (type == PFRU_CODE_INJECT_TYPE) |
| 330 | 330 | return payload_hdr->rt_ver >= cap->code_rt_version; |
| 331 | 331 | |
| 332 | − return payload_hdr->rt_ver >= cap->drv_rt_version; | |
| 332 | + return payload_hdr->svn_ver >= cap->drv_svn; | |
| 333 | 333 | } |
| 334 | 334 | |
| 335 | 335 | static void print_update_debug_info(struct pfru_updated_result *result, |
| @@ -137,20 +137,29 @@ static void loop_global_unlock(struct loop_device *lo, bool global) · 136 unmodified lines | ||
| 137 | 137 | static int max_part; |
| 138 | 138 | static int part_shift; |
| 139 | 139 | |
| 140 | −static loff_t get_size(loff_t offset, loff_t sizelimit, struct file *file) | |
| 140 | +static loff_t lo_calculate_size(struct loop_device *lo, struct file *file) | |
| 141 | 141 | { |
| 142 | + struct kstat stat; | |
| 142 | 143 | loff_t loopsize; |
| 144 | + int ret; | |
| 143 | 145 | |
| 144 | − /* Compute loopsize in bytes */ | |
| 145 | − loopsize = i_size_read(file->f_mapping->host); | |
| 146 | − if (offset > 0) | |
| 147 | − loopsize -= offset; | |
| 146 | + /* | |
| 147 | + * Get the accurate file size. This provides better results than | |
| 148 | + * cached inode data, particularly for network filesystems where | |
| 149 | + * metadata may be stale. | |
| 150 | + */ | |
| 151 | + ret = vfs_getattr_nosec(&file->f_path, &stat, STATX_SIZE, 0); | |
| 152 | + if (ret) | |
| 153 | + return 0; | |
| 154 | + | |
| 155 | + loopsize = stat.size; | |
| 156 | + if (lo->lo_offset > 0) | |
| 157 | + loopsize -= lo->lo_offset; | |
| 148 | 158 | /* offset is beyond i_size, weird but possible */ |
| 149 | 159 | if (loopsize < 0) |
| 150 | 160 | return 0; |
| 151 | − | |
| 152 | − if (sizelimit > 0 && sizelimit < loopsize) | |
| 153 | − loopsize = sizelimit; | |
| 161 | + if (lo->lo_sizelimit > 0 && lo->lo_sizelimit < loopsize) | |
| 162 | + loopsize = lo->lo_sizelimit; | |
| 154 | 163 | /* |
| 155 | 164 | * Unfortunately, if we want to do I/O on the device, |
| 156 | 165 | * the number of 512-byte sectors has to fit into a sector_t. |
| @@ -158,11 +167,6 @@ static loff_t get_size(loff_t offset, loff_t sizelimit, struct file *file) · 1 unmodified line | ||
| 158 | 167 | return loopsize >> 9; |
| 159 | 168 | } |
| 160 | 169 | |
| 161 | −static loff_t get_loop_size(struct loop_device *lo, struct file *file) | |
| 162 | −{ | |
| 163 | − return get_size(lo->lo_offset, lo->lo_sizelimit, file); | |
| 164 | −} | |
| 165 | − | |
| 166 | 170 | /* |
| 167 | 171 | * We support direct I/O only if lo_offset is aligned with the logical I/O size |
| 168 | 172 | * of backing device, and the logical block size of loop is bigger than that of |
| @@ -569,7 +573,7 @@ static int loop_change_fd(struct loop_device *lo, struct block_device *bdev, · 400 unmodified lines | ||
| 569 | 573 | error = -EINVAL; |
| 570 | 574 | |
| 571 | 575 | /* size of the new backing store needs to be the same */ |
| 572 | − if (get_loop_size(lo, file) != get_loop_size(lo, old_file)) | |
| 576 | + if (lo_calculate_size(lo, file) != lo_calculate_size(lo, old_file)) | |
| 573 | 577 | goto out_err; |
| 574 | 578 | |
| 575 | 579 | /* |
| @@ -1063,7 +1067,7 @@ static int loop_configure(struct loop_device *lo, blk_mode_t mode, · 487 unmodified lines | ||
| 1063 | 1067 | loop_update_dio(lo); |
| 1064 | 1068 | loop_sysfs_init(lo); |
| 1065 | 1069 | |
| 1066 | − size = get_loop_size(lo, file); | |
| 1070 | + size = lo_calculate_size(lo, file); | |
| 1067 | 1071 | loop_set_size(lo, size); |
| 1068 | 1072 | |
| 1069 | 1073 | /* Order wrt reading lo_state in loop_validate_file(). */ |
| @@ -1255,8 +1259,7 @@ out_unfreeze: · 185 unmodified lines | ||
| 1255 | 1259 | if (partscan) |
| 1256 | 1260 | clear_bit(GD_SUPPRESS_PART_SCAN, &lo->lo_disk->state); |
| 1257 | 1261 | if (!err && size_changed) { |
| 1258 | − loff_t new_size = get_size(lo->lo_offset, lo->lo_sizelimit, | |
| 1259 | − lo->lo_backing_file); | |
| 1262 | + loff_t new_size = lo_calculate_size(lo, lo->lo_backing_file); | |
| 1260 | 1263 | loop_set_size(lo, new_size); |
| 1261 | 1264 | } |
| 1262 | 1265 | out_unlock: |
| @@ -1399,7 +1402,7 @@ static int loop_set_capacity(struct loop_device *lo) · 136 unmodified lines | ||
| 1399 | 1402 | if (unlikely(lo->lo_state != Lo_bound)) |
| 1400 | 1403 | return -ENXIO; |
| 1401 | 1404 | |
| 1402 | − size = get_loop_size(lo, lo->lo_backing_file); | |
| 1405 | + size = lo_calculate_size(lo, lo->lo_backing_file); | |
| 1403 | 1406 | loop_set_size(lo, size); |
| 1404 | 1407 | |
| 1405 | 1408 | return 0; |
| @@ -642,12 +642,7 @@ static int btmtk_usb_hci_wmt_sync(struct hci_dev *hdev, · 641 unmodified lines | ||
| 642 | 642 | * WMT command. |
| 643 | 643 | */ |
| 644 | 644 | err = wait_on_bit_timeout(&data->flags, BTMTK_TX_WAIT_VND_EVT, |
| 645 | − TASK_INTERRUPTIBLE, HCI_INIT_TIMEOUT); | |
| 646 | − if (err == -EINTR) { | |
| 647 | − bt_dev_err(hdev, "Execution of wmt command interrupted"); | |
| 648 | − clear_bit(BTMTK_TX_WAIT_VND_EVT, &data->flags); | |
| 649 | − goto err_free_wc; | |
| 650 | − } | |
| 645 | + TASK_UNINTERRUPTIBLE, HCI_INIT_TIMEOUT); | |
| 651 | 646 | |
| 652 | 647 | if (err) { |
| 653 | 648 | bt_dev_err(hdev, "Execution of wmt command timed out"); |
| @@ -543,10 +543,10 @@ static int ps_setup(struct hci_dev *hdev) · 542 unmodified lines | ||
| 543 | 543 | } |
| 544 | 544 | |
| 545 | 545 | if (psdata->wakeup_source) { |
| 546 | − ret = devm_request_irq(&serdev->dev, psdata->irq_handler, | |
| 547 | − ps_host_wakeup_irq_handler, | |
| 548 | − IRQF_ONESHOT | IRQF_TRIGGER_FALLING, | |
| 549 | − dev_name(&serdev->dev), nxpdev); | |
| 546 | + ret = devm_request_threaded_irq(&serdev->dev, psdata->irq_handler, | |
| 547 | + NULL, ps_host_wakeup_irq_handler, | |
| 548 | + IRQF_ONESHOT, | |
| 549 | + dev_name(&serdev->dev), nxpdev); | |
| 550 | 550 | if (ret) |
| 551 | 551 | bt_dev_info(hdev, "error setting wakeup IRQ handler, ignoring\n"); |
| 552 | 552 | disable_irq(psdata->irq_handler); |
| @@ -129,8 +129,7 @@ static int cdx_rpmsg_probe(struct rpmsg_device *rpdev) · 128 unmodified lines | ||
| 129 | 129 | |
| 130 | 130 | chinfo.src = RPMSG_ADDR_ANY; |
| 131 | 131 | chinfo.dst = rpdev->dst; |
| 132 | − strscpy(chinfo.name, cdx_rpmsg_id_table[0].name, | |
| 133 | − strlen(cdx_rpmsg_id_table[0].name)); | |
| 132 | + strscpy(chinfo.name, cdx_rpmsg_id_table[0].name, sizeof(chinfo.name)); | |
| 134 | 133 | |
| 135 | 134 | cdx_mcdi->ept = rpmsg_create_ept(rpdev, cdx_rpmsg_cb, NULL, chinfo); |
| 136 | 135 | if (!cdx_mcdi->ept) { |
| @@ -1587,6 +1587,9 @@ static int do_insnlist_ioctl(struct comedi_device *dev, · 1586 unmodified lines | ||
| 1587 | 1587 | memset(&data[n], 0, (MIN_SAMPLES - n) * |
| 1588 | 1588 | sizeof(unsigned int)); |
| 1589 | 1589 | } |
| 1590 | + } else { | |
| 1591 | + memset(data, 0, max_t(unsigned int, n, MIN_SAMPLES) * | |
| 1592 | + sizeof(unsigned int)); | |
| 1590 | 1593 | } |
| 1591 | 1594 | ret = parse_insn(dev, insns + i, data, file); |
| 1592 | 1595 | if (ret < 0) |
| @@ -1670,6 +1673,8 @@ static int do_insn_ioctl(struct comedi_device *dev, · 77 unmodified lines | ||
| 1670 | 1673 | memset(&data[insn->n], 0, |
| 1671 | 1674 | (MIN_SAMPLES - insn->n) * sizeof(unsigned int)); |
| 1672 | 1675 | } |
| 1676 | + } else { | |
| 1677 | + memset(data, 0, n_data * sizeof(unsigned int)); | |
| 1673 | 1678 | } |
| 1674 | 1679 | ret = parse_insn(dev, insn, data, file); |
| 1675 | 1680 | if (ret < 0) |
| @@ -620,11 +620,9 @@ static int insn_rw_emulate_bits(struct comedi_device *dev, · 619 unmodified lines | ||
| 620 | 620 | unsigned int chan = CR_CHAN(insn->chanspec); |
| 621 | 621 | unsigned int base_chan = (chan < 32) ? 0 : chan; |
| 622 | 622 | unsigned int _data[2]; |
| 623 | + unsigned int i; | |
| 623 | 624 | int ret; |
| 624 | 625 | |
| 625 | − if (insn->n == 0) | |
| 626 | − return 0; | |
| 627 | − | |
| 628 | 626 | memset(_data, 0, sizeof(_data)); |
| 629 | 627 | memset(&_insn, 0, sizeof(_insn)); |
| 630 | 628 | _insn.insn = INSN_BITS; |
| @@ -635,18 +633,21 @@ static int insn_rw_emulate_bits(struct comedi_device *dev, · 4 unmodified lines | ||
| 635 | 633 | if (insn->insn == INSN_WRITE) { |
| 636 | 634 | if (!(s->subdev_flags & SDF_WRITABLE)) |
| 637 | 635 | return -EINVAL; |
| 638 | − _data[0] = 1U << (chan - base_chan); /* mask */ | |
| 639 | − _data[1] = data[0] ? (1U << (chan - base_chan)) : 0; /* bits */ | |
| 636 | + _data[0] = 1U << (chan - base_chan); /* mask */ | |
| 640 | 637 | } |
| 638 | + for (i = 0; i < insn->n; i++) { | |
| 639 | + if (insn->insn == INSN_WRITE) | |
| 640 | + _data[1] = data[i] ? _data[0] : 0; /* bits */ | |
| 641 | 641 | |
| 642 | − ret = s->insn_bits(dev, s, &_insn, _data); | |
| 643 | − if (ret < 0) | |
| 644 | − return ret; | |
| 642 | + ret = s->insn_bits(dev, s, &_insn, _data); | |
| 643 | + if (ret < 0) | |
| 644 | + return ret; | |
| 645 | 645 | |
| 646 | − if (insn->insn == INSN_READ) | |
| 647 | − data[0] = (_data[1] >> (chan - base_chan)) & 1; | |
| 646 | + if (insn->insn == INSN_READ) | |
| 647 | + data[i] = (_data[1] >> (chan - base_chan)) & 1; | |
| 648 | + } | |
| 648 | 649 | |
| 649 | − return 1; | |
| 650 | + return insn->n; | |
| 650 | 651 | } |
| 651 | 652 | |
| 652 | 653 | static int __comedi_device_postconfig_async(struct comedi_device *dev, |
| @@ -328,7 +328,8 @@ static int pcl726_attach(struct comedi_device *dev, · 327 unmodified lines | ||
| 328 | 328 | * Hook up the external trigger source interrupt only if the |
| 329 | 329 | * user config option is valid and the board supports interrupts. |
| 330 | 330 | */ |
| 331 | − if (it->options[1] && (board->irq_mask & (1 << it->options[1]))) { | |
| 331 | + if (it->options[1] > 0 && it->options[1] < 16 && | |
| 332 | + (board->irq_mask & (1U << it->options[1]))) { | |
| 332 | 333 | ret = request_irq(it->options[1], pcl726_interrupt, 0, |
| 333 | 334 | dev->board_name, dev); |
| 334 | 335 | if (ret == 0) { |
| @@ -287,20 +287,15 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev, · 286 unmodified lines | ||
| 287 | 287 | return 0; |
| 288 | 288 | } |
| 289 | 289 | |
| 290 | − if (tick_nohz_tick_stopped()) { | |
| 291 | − /* | |
| 292 | − * If the tick is already stopped, the cost of possible short | |
| 293 | − * idle duration misprediction is much higher, because the CPU | |
| 294 | − * may be stuck in a shallow idle state for a long time as a | |
| 295 | − * result of it. In that case say we might mispredict and use | |
| 296 | − * the known time till the closest timer event for the idle | |
| 297 | − * state selection. | |
| 298 | − */ | |
| 299 | − if (predicted_ns < TICK_NSEC) | |
| 300 | − predicted_ns = data->next_timer_ns; | |
| 301 | − } else if (latency_req > predicted_ns) { | |
| 302 | − latency_req = predicted_ns; | |
| 303 | − } | |
| 290 | + /* | |
| 291 | + * If the tick is already stopped, the cost of possible short idle | |
| 292 | + * duration misprediction is much higher, because the CPU may be stuck | |
| 293 | + * in a shallow idle state for a long time as a result of it. In that | |
| 294 | + * case, say we might mispredict and use the known time till the closest | |
| 295 | + * timer event for the idle state selection. | |
| 296 | + */ | |
| 297 | + if (tick_nohz_tick_stopped() && predicted_ns < TICK_NSEC) | |
| 298 | + predicted_ns = data->next_timer_ns; | |
| 304 | 299 | |
| 305 | 300 | /* |
| 306 | 301 | * Find the idle state with the lowest power while satisfying |
| @@ -316,13 +311,15 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev, · 9 unmodified lines | ||
| 316 | 311 | if (idx == -1) |
| 317 | 312 | idx = i; /* first enabled state */ |
| 318 | 313 | |
| 314 | + if (s->exit_latency_ns > latency_req) | |
| 315 | + break; | |
| 316 | + | |
| 319 | 317 | if (s->target_residency_ns > predicted_ns) { |
| 320 | 318 | /* |
| 321 | 319 | * Use a physical idle state, not busy polling, unless |
| 322 | 320 | * a timer is going to trigger soon enough. |
| 323 | 321 | */ |
| 324 | 322 | if ((drv->states[idx].flags & CPUIDLE_FLAG_POLLING) && |
| 325 | − s->exit_latency_ns <= latency_req && | |
| 326 | 323 | s->target_residency_ns <= data->next_timer_ns) { |
| 327 | 324 | predicted_ns = s->target_residency_ns; |
| 328 | 325 | idx = i; |
| @@ -354,8 +351,6 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev, · 25 unmodified lines | ||
| 354 | 351 | |
| 355 | 352 | return idx; |
| 356 | 353 | } |
| 357 | − if (s->exit_latency_ns > latency_req) | |
| 358 | − break; | |
| 359 | 354 | |
| 360 | 355 | idx = i; |
| 361 | 356 | } |
| @@ -405,12 +405,12 @@ static int zynq_fpga_ops_write(struct fpga_manager *mgr, struct sg_table *sgt) · 404 unmodified lines | ||
| 405 | 405 | } |
| 406 | 406 | } |
| 407 | 407 | |
| 408 | − priv->dma_nelms = | |
| 409 | − dma_map_sgtable(mgr->dev.parent, sgt, DMA_TO_DEVICE, 0); | |
| 410 | − if (priv->dma_nelms == 0) { | |
| 408 | + err = dma_map_sgtable(mgr->dev.parent, sgt, DMA_TO_DEVICE, 0); | |
| 409 | + if (err) { | |
| 411 | 410 | dev_err(&mgr->dev, "Unable to DMA map (TO_DEVICE)\n"); |
| 412 | − return -ENOMEM; | |
| 411 | + return err; | |
| 413 | 412 | } |
| 413 | + priv->dma_nelms = sgt->nents; | |
| 414 | 414 | |
| 415 | 415 | /* enable clock */ |
| 416 | 416 | err = clk_enable(priv->clk); |
| @@ -514,7 +514,7 @@ bool amdgpu_dmabuf_is_xgmi_accessible(struct amdgpu_device *adev, · 513 unmodified lines | ||
| 514 | 514 | return false; |
| 515 | 515 | |
| 516 | 516 | if (drm_gem_is_imported(obj)) { |
| 517 | − struct dma_buf *dma_buf = obj->dma_buf; | |
| 517 | + struct dma_buf *dma_buf = obj->import_attach->dmabuf; | |
| 518 | 518 | |
| 519 | 519 | if (dma_buf->ops != &amdgpu_dmabuf_ops) |
| 520 | 520 | /* No XGMI with non AMD GPUs */ |
| @@ -317,7 +317,8 @@ static int amdgpu_gem_object_open(struct drm_gem_object *obj, · 316 unmodified lines | ||
| 317 | 317 | */ |
| 318 | 318 | if (!vm->is_compute_context || !vm->process_info) |
| 319 | 319 | return 0; |
| 320 | − if (!drm_gem_is_imported(obj) || !dma_buf_is_dynamic(obj->dma_buf)) | |
| 320 | + if (!drm_gem_is_imported(obj) || | |
| 321 | + !dma_buf_is_dynamic(obj->import_attach->dmabuf)) | |
| 321 | 322 | return 0; |
| 322 | 323 | mutex_lock_nested(&vm->process_info->lock, 1); |
| 323 | 324 | if (!WARN_ON(!vm->process_info->eviction_fence)) { |
| @@ -1283,7 +1283,7 @@ int amdgpu_vm_bo_update(struct amdgpu_device *adev, struct amdgpu_bo_va *bo_va, · 1282 unmodified lines | ||
| 1283 | 1283 | struct drm_gem_object *obj = &bo->tbo.base; |
| 1284 | 1284 | |
| 1285 | 1285 | if (drm_gem_is_imported(obj) && bo_va->is_xgmi) { |
| 1286 | − struct dma_buf *dma_buf = obj->dma_buf; | |
| 1286 | + struct dma_buf *dma_buf = obj->import_attach->dmabuf; | |
| 1287 | 1287 | struct drm_gem_object *gobj = dma_buf->priv; |
| 1288 | 1288 | struct amdgpu_bo *abo = gem_to_amdgpu_bo(gobj); |
| 1289 | 1289 | |
| @@ -7792,6 +7792,9 @@ amdgpu_dm_connector_atomic_check(struct drm_connector *conn, · 7791 unmodified lines | ||
| 7792 | 7792 | struct amdgpu_dm_connector *aconn = to_amdgpu_dm_connector(conn); |
| 7793 | 7793 | int ret; |
| 7794 | 7794 | |
| 7795 | + if (WARN_ON(unlikely(!old_con_state || !new_con_state))) | |
| 7796 | + return -EINVAL; | |
| 7797 | + | |
| 7795 | 7798 | trace_amdgpu_dm_connector_atomic_check(new_con_state); |
| 7796 | 7799 | |
| 7797 | 7800 | if (conn->connector_type == DRM_MODE_CONNECTOR_DisplayPort) { |
| @@ -299,6 +299,25 @@ static inline int amdgpu_dm_crtc_set_vblank(struct drm_crtc *crtc, bool enable) · 298 unmodified lines | ||
| 299 | 299 | irq_type = amdgpu_display_crtc_idx_to_irq_type(adev, acrtc->crtc_id); |
| 300 | 300 | |
| 301 | 301 | if (enable) { |
| 302 | + struct dc *dc = adev->dm.dc; | |
| 303 | + struct drm_vblank_crtc *vblank = drm_crtc_vblank_crtc(crtc); | |
| 304 | + struct psr_settings *psr = &acrtc_state->stream->link->psr_settings; | |
| 305 | + struct replay_settings *pr = &acrtc_state->stream->link->replay_settings; | |
| 306 | + bool sr_supported = (psr->psr_version != DC_PSR_VERSION_UNSUPPORTED) || | |
| 307 | + pr->config.replay_supported; | |
| 308 | + | |
| 309 | + /* | |
| 310 | + * IPS & self-refresh feature can cause vblank counter resets between | |
| 311 | + * vblank disable and enable. | |
| 312 | + * It may cause system stuck due to waiting for the vblank counter. | |
| 313 | + * Call this function to estimate missed vblanks by using timestamps and | |
| 314 | + * update the vblank counter in DRM. | |
| 315 | + */ | |
| 316 | + if (dc->caps.ips_support && | |
| 317 | + dc->config.disable_ips != DMUB_IPS_DISABLE_ALL && | |
| 318 | + sr_supported && vblank->config.disable_immediate) | |
| 319 | + drm_crtc_vblank_restore(crtc); | |
| 320 | + | |
| 302 | 321 | /* vblank irq on -> Only need vupdate irq in vrr mode */ |
| 303 | 322 | if (amdgpu_dm_crtc_vrr_active(acrtc_state)) |
| 304 | 323 | rc = amdgpu_dm_crtc_set_vupdate_irq(crtc, true); |
| @@ -174,11 +174,8 @@ static struct graphics_object_id bios_parser_get_connector_id( · 173 unmodified lines | ||
| 174 | 174 | return object_id; |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | − if (tbl->ucNumberOfObjects <= i) { | |
| 178 | − dm_error("Can't find connector id %d in connector table of size %d.\n", | |
| 179 | − i, tbl->ucNumberOfObjects); | |
| 177 | + if (tbl->ucNumberOfObjects <= i) | |
| 180 | 178 | return object_id; |
| 181 | − } | |
| 182 | 179 | |
| 183 | 180 | id = le16_to_cpu(tbl->asObjects[i].usObjectID); |
| 184 | 181 | object_id = object_id_from_bios_object_id(id); |
| @@ -993,7 +993,7 @@ static enum bp_result set_pixel_clock_v3( · 992 unmodified lines | ||
| 993 | 993 | allocation.sPCLKInput.usFbDiv = |
| 994 | 994 | cpu_to_le16((uint16_t)bp_params->feedback_divider); |
| 995 | 995 | allocation.sPCLKInput.ucFracFbDiv = |
| 996 | − (uint8_t)bp_params->fractional_feedback_divider; | |
| 996 | + (uint8_t)(bp_params->fractional_feedback_divider / 100000); | |
| 997 | 997 | allocation.sPCLKInput.ucPostDiv = |
| 998 | 998 | (uint8_t)bp_params->pixel_clock_post_divider; |
| 999 | 999 | |
| @@ -72,9 +72,9 @@ static const struct state_dependent_clocks dce80_max_clks_by_state[] = { · 71 unmodified lines | ||
| 72 | 72 | /* ClocksStateLow */ |
| 73 | 73 | { .display_clk_khz = 352000, .pixel_clk_khz = 330000}, |
| 74 | 74 | /* ClocksStateNominal */ |
| 75 | −{ .display_clk_khz = 600000, .pixel_clk_khz = 400000 }, | |
| 75 | +{ .display_clk_khz = 625000, .pixel_clk_khz = 400000 }, | |
| 76 | 76 | /* ClocksStatePerformance */ |
| 77 | −{ .display_clk_khz = 600000, .pixel_clk_khz = 400000 } }; | |
| 77 | +{ .display_clk_khz = 625000, .pixel_clk_khz = 400000 } }; | |
| 78 | 78 | |
| 79 | 79 | int dentist_get_divider_from_did(int did) |
| 80 | 80 | { |
| @@ -391,8 +391,6 @@ static void dce_pplib_apply_display_requirements( · 310 unmodified lines | ||
| 391 | 391 | { |
| 392 | 392 | struct dm_pp_display_configuration *pp_display_cfg = &context->pp_display_cfg; |
| 393 | 393 | |
| 394 | − pp_display_cfg->avail_mclk_switch_time_us = dce110_get_min_vblank_time_us(context); | |
| 395 | − | |
| 396 | 394 | dce110_fill_display_configs(context, pp_display_cfg); |
| 397 | 395 | |
| 398 | 396 | if (memcmp(&dc->current_state->pp_display_cfg, pp_display_cfg, sizeof(*pp_display_cfg)) != 0) |
| @@ -405,11 +403,9 @@ static void dce_update_clocks(struct clk_mgr *clk_mgr_base, · 6 unmodified lines | ||
| 405 | 403 | { |
| 406 | 404 | struct clk_mgr_internal *clk_mgr_dce = TO_CLK_MGR_INTERNAL(clk_mgr_base); |
| 407 | 405 | struct dm_pp_power_level_change_request level_change_req; |
| 408 | − int patched_disp_clk = context->bw_ctx.bw.dce.dispclk_khz; | |
| 409 | − | |
| 410 | − /*TODO: W/A for dal3 linux, investigate why this works */ | |
| 411 | − if (!clk_mgr_dce->dfs_bypass_active) | |
| 412 | − patched_disp_clk = patched_disp_clk * 115 / 100; | |
| 406 | + const int max_disp_clk = | |
| 407 | + clk_mgr_dce->max_clks_by_state[DM_PP_CLOCKS_STATE_PERFORMANCE].display_clk_khz; | |
| 408 | + int patched_disp_clk = MIN(max_disp_clk, context->bw_ctx.bw.dce.dispclk_khz); | |
| 413 | 409 | |
| 414 | 410 | level_change_req.power_level = dce_get_required_clocks_state(clk_mgr_base, context); |
| 415 | 411 | /* get max clock state from PPLIB */ |
| @@ -120,9 +120,15 @@ void dce110_fill_display_configs( · 119 unmodified lines | ||
| 120 | 120 | const struct dc_state *context, |
| 121 | 121 | struct dm_pp_display_configuration *pp_display_cfg) |
| 122 | 122 | { |
| 123 | + struct dc *dc = context->clk_mgr->ctx->dc; | |
| 123 | 124 | int j; |
| 124 | 125 | int num_cfgs = 0; |
| 125 | 126 | |
| 127 | + pp_display_cfg->avail_mclk_switch_time_us = dce110_get_min_vblank_time_us(context); | |
| 128 | + pp_display_cfg->disp_clk_khz = dc->clk_mgr->clks.dispclk_khz; | |
| 129 | + pp_display_cfg->avail_mclk_switch_time_in_disp_active_us = 0; | |
| 130 | + pp_display_cfg->crtc_index = dc->res_pool->res_cap->num_timing_generator; | |
| 131 | + | |
| 126 | 132 | for (j = 0; j < context->stream_count; j++) { |
| 127 | 133 | int k; |
| 128 | 134 | |
| @@ -164,6 +170,23 @@ void dce110_fill_display_configs( · 35 unmodified lines | ||
| 164 | 170 | cfg->v_refresh /= stream->timing.h_total; |
| 165 | 171 | cfg->v_refresh = (cfg->v_refresh + stream->timing.v_total / 2) |
| 166 | 172 | / stream->timing.v_total; |
| 173 | + | |
| 174 | + /* Find first CRTC index and calculate its line time. | |
| 175 | + * This is necessary for DPM on SI GPUs. | |
| 176 | + */ | |
| 177 | + if (cfg->pipe_idx < pp_display_cfg->crtc_index) { | |
| 178 | + const struct dc_crtc_timing *timing = | |
| 179 | + &context->streams[0]->timing; | |
| 180 | + | |
| 181 | + pp_display_cfg->crtc_index = cfg->pipe_idx; | |
| 182 | + pp_display_cfg->line_time_in_us = | |
| 183 | + timing->h_total * 10000 / timing->pix_clk_100hz; | |
| 184 | + } | |
| 185 | + } | |
| 186 | + | |
| 187 | + if (!num_cfgs) { | |
| 188 | + pp_display_cfg->crtc_index = 0; | |
| 189 | + pp_display_cfg->line_time_in_us = 0; | |
| 167 | 190 | } |
| 168 | 191 | |
| 169 | 192 | pp_display_cfg->display_count = num_cfgs; |
| @@ -223,25 +246,8 @@ void dce11_pplib_apply_display_requirements( · 53 unmodified lines | ||
| 223 | 246 | pp_display_cfg->min_engine_clock_deep_sleep_khz |
| 224 | 247 | = context->bw_ctx.bw.dce.sclk_deep_sleep_khz; |
| 225 | 248 | |
| 226 | − pp_display_cfg->avail_mclk_switch_time_us = | |
| 227 | − dce110_get_min_vblank_time_us(context); | |
| 228 | − /* TODO: dce11.2*/ | |
| 229 | − pp_display_cfg->avail_mclk_switch_time_in_disp_active_us = 0; | |
| 230 | − | |
| 231 | − pp_display_cfg->disp_clk_khz = dc->clk_mgr->clks.dispclk_khz; | |
| 232 | − | |
| 233 | 249 | dce110_fill_display_configs(context, pp_display_cfg); |
| 234 | 250 | |
| 235 | − /* TODO: is this still applicable?*/ | |
| 236 | − if (pp_display_cfg->display_count == 1) { | |
| 237 | − const struct dc_crtc_timing *timing = | |
| 238 | − &context->streams[0]->timing; | |
| 239 | − | |
| 240 | − pp_display_cfg->crtc_index = | |
| 241 | − pp_display_cfg->disp_configs[0].pipe_idx; | |
| 242 | − pp_display_cfg->line_time_in_us = timing->h_total * 10000 / timing->pix_clk_100hz; | |
| 243 | − } | |
| 244 | − | |
| 245 | 251 | if (memcmp(&dc->current_state->pp_display_cfg, pp_display_cfg, sizeof(*pp_display_cfg)) != 0) |
| 246 | 252 | dm_pp_apply_display_requirements(dc->ctx, pp_display_cfg); |
| 247 | 253 | } |
| @@ -83,22 +83,13 @@ static const struct state_dependent_clocks dce60_max_clks_by_state[] = { · 82 unmodified lines | ||
| 83 | 83 | static int dce60_get_dp_ref_freq_khz(struct clk_mgr *clk_mgr_base) |
| 84 | 84 | { |
| 85 | 85 | struct clk_mgr_internal *clk_mgr = TO_CLK_MGR_INTERNAL(clk_mgr_base); |
| 86 | − int dprefclk_wdivider; | |
| 87 | − int dp_ref_clk_khz; | |
| 88 | − int target_div; | |
| 86 | + struct dc_context *ctx = clk_mgr_base->ctx; | |
| 87 | + int dp_ref_clk_khz = 0; | |
| 89 | 88 | |
| 90 | − /* DCE6 has no DPREFCLK_CNTL to read DP Reference Clock source */ | |
| 91 | − | |
| 92 | − /* Read the mmDENTIST_DISPCLK_CNTL to get the currently | |
| 93 | − * programmed DID DENTIST_DPREFCLK_WDIVIDER*/ | |
| 94 | − REG_GET(DENTIST_DISPCLK_CNTL, DENTIST_DPREFCLK_WDIVIDER, &dprefclk_wdivider); | |
| 95 | − | |
| 96 | − /* Convert DENTIST_DPREFCLK_WDIVIDERto actual divider*/ | |
| 97 | − target_div = dentist_get_divider_from_did(dprefclk_wdivider); | |
| 98 | − | |
| 99 | − /* Calculate the current DFS clock, in kHz.*/ | |
| 100 | − dp_ref_clk_khz = (DENTIST_DIVIDER_RANGE_SCALE_FACTOR | |
| 101 | − * clk_mgr->base.dentist_vco_freq_khz) / target_div; | |
| 89 | + if (ASIC_REV_IS_TAHITI_P(ctx->asic_id.hw_internal_rev)) | |
| 90 | + dp_ref_clk_khz = ctx->dc_bios->fw_info.default_display_engine_pll_frequency; | |
| 91 | + else | |
| 92 | + dp_ref_clk_khz = clk_mgr_base->clks.dispclk_khz; | |
| 102 | 93 | |
| 103 | 94 | return dce_adjust_dp_ref_freq_for_ss(clk_mgr, dp_ref_clk_khz); |
| 104 | 95 | } |
| @@ -109,8 +100,6 @@ static void dce60_pplib_apply_display_requirements( · 4 unmodified lines | ||
| 109 | 100 | { |
| 110 | 101 | struct dm_pp_display_configuration *pp_display_cfg = &context->pp_display_cfg; |
| 111 | 102 | |
| 112 | − pp_display_cfg->avail_mclk_switch_time_us = dce110_get_min_vblank_time_us(context); | |
| 113 | − | |
| 114 | 103 | dce110_fill_display_configs(context, pp_display_cfg); |
| 115 | 104 | |
| 116 | 105 | if (memcmp(&dc->current_state->pp_display_cfg, pp_display_cfg, sizeof(*pp_display_cfg)) != 0) |
| @@ -123,11 +112,9 @@ static void dce60_update_clocks(struct clk_mgr *clk_mgr_base, · 6 unmodified lines | ||
| 123 | 112 | { |
| 124 | 113 | struct clk_mgr_internal *clk_mgr_dce = TO_CLK_MGR_INTERNAL(clk_mgr_base); |
| 125 | 114 | struct dm_pp_power_level_change_request level_change_req; |
| 126 | − int patched_disp_clk = context->bw_ctx.bw.dce.dispclk_khz; | |
| 127 | − | |
| 128 | − /*TODO: W/A for dal3 linux, investigate why this works */ | |
| 129 | − if (!clk_mgr_dce->dfs_bypass_active) | |
| 130 | − patched_disp_clk = patched_disp_clk * 115 / 100; | |
| 115 | + const int max_disp_clk = | |
| 116 | + clk_mgr_dce->max_clks_by_state[DM_PP_CLOCKS_STATE_PERFORMANCE].display_clk_khz; | |
| 117 | + int patched_disp_clk = MIN(max_disp_clk, context->bw_ctx.bw.dce.dispclk_khz); | |
| 131 | 118 | |
| 132 | 119 | level_change_req.power_level = dce_get_required_clocks_state(clk_mgr_base, context); |
| 133 | 120 | /* get max clock state from PPLIB */ |
| @@ -217,11 +217,24 @@ static bool create_links( · 216 unmodified lines | ||
| 217 | 217 | connectors_num, |
| 218 | 218 | num_virtual_links); |
| 219 | 219 | |
| 220 | − // condition loop on link_count to allow skipping invalid indices | |
| 220 | + /* When getting the number of connectors, the VBIOS reports the number of valid indices, | |
| 221 | + * but it doesn't say which indices are valid, and not every index has an actual connector. | |
| 222 | + * So, if we don't find a connector on an index, that is not an error. | |
| 223 | + * | |
| 224 | + * - There is no guarantee that the first N indices will be valid | |
| 225 | + * - VBIOS may report a higher amount of valid indices than there are actual connectors | |
| 226 | + * - Some VBIOS have valid configurations for more connectors than there actually are | |
| 227 | + * on the card. This may be because the manufacturer used the same VBIOS for different | |
| 228 | + * variants of the same card. | |
| 229 | + */ | |
| 221 | 230 | for (i = 0; dc->link_count < connectors_num && i < MAX_LINKS; i++) { |
| 231 | + struct graphics_object_id connector_id = bios->funcs->get_connector_id(bios, i); | |
| 222 | 232 | struct link_init_data link_init_params = {0}; |
| 223 | 233 | struct dc_link *link; |
| 224 | 234 | |
| 235 | + if (connector_id.id == CONNECTOR_ID_UNKNOWN) | |
| 236 | + continue; | |
| 237 | + | |
| 225 | 238 | DC_LOG_DC("BIOS object table - printing link object info for connector number: %d, link_index: %d", i, dc->link_count); |
| 226 | 239 | |
| 227 | 240 | link_init_params.ctx = dc->ctx; |
| @@ -896,13 +896,13 @@ void dce110_link_encoder_construct( · 895 unmodified lines | ||
| 896 | 896 | enc110->base.id, &bp_cap_info); |
| 897 | 897 | |
| 898 | 898 | /* Override features with DCE-specific values */ |
| 899 | − if (BP_RESULT_OK == result) { | |
| 899 | + if (result == BP_RESULT_OK) { | |
| 900 | 900 | enc110->base.features.flags.bits.IS_HBR2_CAPABLE = |
| 901 | 901 | bp_cap_info.DP_HBR2_EN; |
| 902 | 902 | enc110->base.features.flags.bits.IS_HBR3_CAPABLE = |
| 903 | 903 | bp_cap_info.DP_HBR3_EN; |
| 904 | 904 | enc110->base.features.flags.bits.HDMI_6GB_EN = bp_cap_info.HDMI_6GB_EN; |
| 905 | − } else { | |
| 905 | + } else if (result != BP_RESULT_NORECORD) { | |
| 906 | 906 | DC_LOG_WARNING("%s: Failed to get encoder_cap_info from VBIOS with error code %d!\n", |
| 907 | 907 | __func__, |
| 908 | 908 | result); |
| @@ -1798,13 +1798,13 @@ void dce60_link_encoder_construct( · 889 unmodified lines | ||
| 1798 | 1798 | enc110->base.id, &bp_cap_info); |
| 1799 | 1799 | |
| 1800 | 1800 | /* Override features with DCE-specific values */ |
| 1801 | − if (BP_RESULT_OK == result) { | |
| 1801 | + if (result == BP_RESULT_OK) { | |
| 1802 | 1802 | enc110->base.features.flags.bits.IS_HBR2_CAPABLE = |
| 1803 | 1803 | bp_cap_info.DP_HBR2_EN; |
| 1804 | 1804 | enc110->base.features.flags.bits.IS_HBR3_CAPABLE = |
| 1805 | 1805 | bp_cap_info.DP_HBR3_EN; |
| 1806 | 1806 | enc110->base.features.flags.bits.HDMI_6GB_EN = bp_cap_info.HDMI_6GB_EN; |
| 1807 | − } else { | |
| 1807 | + } else if (result != BP_RESULT_NORECORD) { | |
| 1808 | 1808 | DC_LOG_WARNING("%s: Failed to get encoder_cap_info from VBIOS with error code %d!\n", |
| 1809 | 1809 | __func__, |
| 1810 | 1810 | result); |
| @@ -4,7 +4,6 @@ · 3 unmodified lines | ||
| 4 | 4 | |
| 5 | 5 | #include "dc.h" |
| 6 | 6 | #include "dc_dmub_srv.h" |
| 7 | −#include "dc_dp_types.h" | |
| 8 | 7 | #include "dmub/dmub_srv.h" |
| 9 | 8 | #include "core_types.h" |
| 10 | 9 | #include "dmub_replay.h" |
| @@ -44,45 +43,21 @@ static void dmub_replay_get_state(struct dmub_replay *dmub, enum replay_state *s · 33 unmodified lines | ||
| 44 | 43 | /* |
| 45 | 44 | * Enable/Disable Replay. |
| 46 | 45 | */ |
| 47 | −static void dmub_replay_enable(struct dmub_replay *dmub, bool enable, bool wait, uint8_t panel_inst, | |
| 48 | − struct dc_link *link) | |
| 46 | +static void dmub_replay_enable(struct dmub_replay *dmub, bool enable, bool wait, uint8_t panel_inst) | |
| 49 | 47 | { |
| 50 | 48 | union dmub_rb_cmd cmd; |
| 51 | 49 | struct dc_context *dc = dmub->ctx; |
| 52 | 50 | uint32_t retry_count; |
| 53 | 51 | enum replay_state state = REPLAY_STATE_0; |
| 54 | − struct pipe_ctx *pipe_ctx = NULL; | |
| 55 | − struct resource_context *res_ctx = &link->ctx->dc->current_state->res_ctx; | |
| 56 | − uint8_t i; | |
| 57 | 52 | |
| 58 | 53 | memset(&cmd, 0, sizeof(cmd)); |
| 59 | 54 | cmd.replay_enable.header.type = DMUB_CMD__REPLAY; |
| 60 | 55 | cmd.replay_enable.data.panel_inst = panel_inst; |
| 61 | 56 | |
| 62 | 57 | cmd.replay_enable.header.sub_type = DMUB_CMD__REPLAY_ENABLE; |
| 63 | − if (enable) { | |
| 58 | + if (enable) | |
| 64 | 59 | cmd.replay_enable.data.enable = REPLAY_ENABLE; |
| 65 | − // hpo stream/link encoder assignments are not static, need to update everytime we try to enable replay | |
| 66 | − if (link->cur_link_settings.link_rate >= LINK_RATE_UHBR10) { | |
| 67 | − for (i = 0; i < MAX_PIPES; i++) { | |
| 68 | − if (res_ctx && | |
| 69 | − res_ctx->pipe_ctx[i].stream && | |
| 70 | − res_ctx->pipe_ctx[i].stream->link && | |
| 71 | − res_ctx->pipe_ctx[i].stream->link == link && | |
| 72 | − res_ctx->pipe_ctx[i].stream->link->connector_signal == SIGNAL_TYPE_EDP) { | |
| 73 | − pipe_ctx = &res_ctx->pipe_ctx[i]; | |
| 74 | − //TODO: refactor for multi edp support | |
| 75 | − break; | |
| 76 | − } | |
| 77 | − } | |
| 78 | − | |
| 79 | − if (!pipe_ctx) | |
| 80 | − return; | |
| 81 | − | |
| 82 | − cmd.replay_enable.data.hpo_stream_enc_inst = pipe_ctx->stream_res.hpo_dp_stream_enc->inst; | |
| 83 | − cmd.replay_enable.data.hpo_link_enc_inst = pipe_ctx->link_res.hpo_dp_link_enc->inst; | |
| 84 | − } | |
| 85 | − } else | |
| 60 | + else | |
| 86 | 61 | cmd.replay_enable.data.enable = REPLAY_DISABLE; |
| 87 | 62 | |
| 88 | 63 | cmd.replay_enable.header.payload_bytes = sizeof(struct dmub_rb_cmd_replay_enable_data); |
| @@ -174,17 +149,6 @@ static bool dmub_replay_copy_settings(struct dmub_replay *dmub, · 85 unmodified lines | ||
| 174 | 149 | copy_settings_data->digbe_inst = replay_context->digbe_inst; |
| 175 | 150 | copy_settings_data->digfe_inst = replay_context->digfe_inst; |
| 176 | 151 | |
| 177 | − if (link->cur_link_settings.link_rate >= LINK_RATE_UHBR10) { | |
| 178 | − if (pipe_ctx->stream_res.hpo_dp_stream_enc) | |
| 179 | − copy_settings_data->hpo_stream_enc_inst = pipe_ctx->stream_res.hpo_dp_stream_enc->inst; | |
| 180 | − else | |
| 181 | − copy_settings_data->hpo_stream_enc_inst = 0; | |
| 182 | − if (pipe_ctx->link_res.hpo_dp_link_enc) | |
| 183 | − copy_settings_data->hpo_link_enc_inst = pipe_ctx->link_res.hpo_dp_link_enc->inst; | |
| 184 | − else | |
| 185 | − copy_settings_data->hpo_link_enc_inst = 0; | |
| 186 | − } | |
| 187 | − | |
| 188 | 152 | if (pipe_ctx->plane_res.dpp) |
| 189 | 153 | copy_settings_data->dpp_inst = pipe_ctx->plane_res.dpp->inst; |
| 190 | 154 | else |
| @@ -247,7 +211,6 @@ static void dmub_replay_set_coasting_vtotal(struct dmub_replay *dmub, · 56 unmodified lines | ||
| 247 | 211 | pCmd->header.type = DMUB_CMD__REPLAY; |
| 248 | 212 | pCmd->header.sub_type = DMUB_CMD__REPLAY_SET_COASTING_VTOTAL; |
| 249 | 213 | pCmd->header.payload_bytes = sizeof(struct dmub_cmd_replay_set_coasting_vtotal_data); |
| 250 | − pCmd->replay_set_coasting_vtotal_data.panel_inst = panel_inst; | |
| 251 | 214 | pCmd->replay_set_coasting_vtotal_data.coasting_vtotal = (coasting_vtotal & 0xFFFF); |
| 252 | 215 | pCmd->replay_set_coasting_vtotal_data.coasting_vtotal_high = (coasting_vtotal & 0xFFFF0000) >> 16; |
| 253 | 216 | |
| @@ -19,7 +19,7 @@ struct dmub_replay_funcs { · 18 unmodified lines | ||
| 19 | 19 | void (*replay_get_state)(struct dmub_replay *dmub, enum replay_state *state, |
| 20 | 20 | uint8_t panel_inst); |
| 21 | 21 | void (*replay_enable)(struct dmub_replay *dmub, bool enable, bool wait, |
| 22 | − uint8_t panel_inst, struct dc_link *link); | |
| 22 | + uint8_t panel_inst); | |
| 23 | 23 | bool (*replay_copy_settings)(struct dmub_replay *dmub, struct dc_link *link, |
| 24 | 24 | struct replay_context *replay_context, uint8_t panel_inst); |
| 25 | 25 | void (*replay_set_power_opt)(struct dmub_replay *dmub, unsigned int power_opt, |
| @@ -944,7 +944,7 @@ bool edp_set_replay_allow_active(struct dc_link *link, const bool *allow_active, · 943 unmodified lines | ||
| 944 | 944 | // TODO: Handle mux change case if force_static is set |
| 945 | 945 | // If force_static is set, just change the replay_allow_active state directly |
| 946 | 946 | if (replay != NULL && link->replay_settings.replay_feature_enabled) |
| 947 | − replay->funcs->replay_enable(replay, *allow_active, wait, panel_inst, link); | |
| 947 | + replay->funcs->replay_enable(replay, *allow_active, wait, panel_inst); | |
| 948 | 948 | link->replay_settings.replay_allow_active = *allow_active; |
| 949 | 949 | } |
| 950 | 950 | |
| @@ -4047,14 +4047,6 @@ struct dmub_cmd_replay_copy_settings_data { · 4046 unmodified lines | ||
| 4047 | 4047 | * DIG BE HW instance. |
| 4048 | 4048 | */ |
| 4049 | 4049 | uint8_t digbe_inst; |
| 4050 | − /** | |
| 4051 | − * @hpo_stream_enc_inst: HPO stream encoder instance | |
| 4052 | − */ | |
| 4053 | − uint8_t hpo_stream_enc_inst; | |
| 4054 | − /** | |
| 4055 | − * @hpo_link_enc_inst: HPO link encoder instance | |
| 4056 | − */ | |
| 4057 | − uint8_t hpo_link_enc_inst; | |
| 4058 | 4050 | /** |
| 4059 | 4051 | * AUX HW instance. |
| 4060 | 4052 | */ |
| @@ -4159,18 +4151,6 @@ struct dmub_rb_cmd_replay_enable_data { · 98 unmodified lines | ||
| 4159 | 4151 | * This does not support HDMI/DP2 for now. |
| 4160 | 4152 | */ |
| 4161 | 4153 | uint8_t phy_rate; |
| 4162 | − /** | |
| 4163 | − * @hpo_stream_enc_inst: HPO stream encoder instance | |
| 4164 | − */ | |
| 4165 | − uint8_t hpo_stream_enc_inst; | |
| 4166 | − /** | |
| 4167 | − * @hpo_link_enc_inst: HPO link encoder instance | |
| 4168 | − */ | |
| 4169 | − uint8_t hpo_link_enc_inst; | |
| 4170 | − /** | |
| 4171 | − * @pad: Align structure to 4 byte boundary. | |
| 4172 | − */ | |
| 4173 | − uint8_t pad[2]; | |
| 4174 | 4154 | }; |
| 4175 | 4155 | |
| 4176 | 4156 | /** |
| @@ -260,6 +260,9 @@ enum mod_hdcp_status mod_hdcp_hdcp1_create_session(struct mod_hdcp *hdcp) · 259 unmodified lines | ||
| 260 | 260 | return MOD_HDCP_STATUS_FAILURE; |
| 261 | 261 | } |
| 262 | 262 | |
| 263 | + if (!display) | |
| 264 | + return MOD_HDCP_STATUS_DISPLAY_NOT_FOUND; | |
| 265 | + | |
| 263 | 266 | hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.context.mem_context.shared_buf; |
| 264 | 267 | |
| 265 | 268 | mutex_lock(&psp->hdcp_context.mutex); |
| @@ -1697,9 +1697,11 @@ static int smu_v14_0_2_get_power_limit(struct smu_context *smu, · 1696 unmodified lines | ||
| 1697 | 1697 | uint32_t *min_power_limit) |
| 1698 | 1698 | { |
| 1699 | 1699 | struct smu_table_context *table_context = &smu->smu_table; |
| 1700 | + struct smu_14_0_2_powerplay_table *powerplay_table = | |
| 1701 | + table_context->power_play_table; | |
| 1700 | 1702 | PPTable_t *pptable = table_context->driver_pptable; |
| 1701 | 1703 | CustomSkuTable_t *skutable = &pptable->CustomSkuTable; |
| 1702 | − uint32_t power_limit; | |
| 1704 | + uint32_t power_limit, od_percent_upper = 0, od_percent_lower = 0; | |
| 1703 | 1705 | uint32_t msg_limit = pptable->SkuTable.MsgLimits.Power[PPT_THROTTLER_PPT0][POWER_SOURCE_AC]; |
| 1704 | 1706 | |
| 1705 | 1707 | if (smu_v14_0_get_current_power_limit(smu, &power_limit)) |
| @@ -1712,11 +1714,29 @@ static int smu_v14_0_2_get_power_limit(struct smu_context *smu, · 6 unmodified lines | ||
| 1712 | 1714 | if (default_power_limit) |
| 1713 | 1715 | *default_power_limit = power_limit; |
| 1714 | 1716 | |
| 1715 | − if (max_power_limit) | |
| 1716 | − *max_power_limit = msg_limit; | |
| 1717 | + if (powerplay_table) { | |
| 1718 | + if (smu->od_enabled && | |
| 1719 | + smu_v14_0_2_is_od_feature_supported(smu, PP_OD_FEATURE_PPT_BIT)) { | |
| 1720 | + od_percent_upper = pptable->SkuTable.OverDriveLimitsBasicMax.Ppt; | |
| 1721 | + od_percent_lower = pptable->SkuTable.OverDriveLimitsBasicMin.Ppt; | |
| 1722 | + } else if (smu_v14_0_2_is_od_feature_supported(smu, PP_OD_FEATURE_PPT_BIT)) { | |
| 1723 | + od_percent_upper = 0; | |
| 1724 | + od_percent_lower = pptable->SkuTable.OverDriveLimitsBasicMin.Ppt; | |
| 1725 | + } | |
| 1726 | + } | |
| 1727 | + | |
| 1728 | + dev_dbg(smu->adev->dev, "od percent upper:%d, od percent lower:%d (default power: %d)\n", | |
| 1729 | + od_percent_upper, od_percent_lower, power_limit); | |
| 1730 | + | |
| 1731 | + if (max_power_limit) { | |
| 1732 | + *max_power_limit = msg_limit * (100 + od_percent_upper); | |
| 1733 | + *max_power_limit /= 100; | |
| 1734 | + } | |
| 1717 | 1735 | |
| 1718 | − if (min_power_limit) | |
| 1719 | − *min_power_limit = 0; | |
| 1736 | + if (min_power_limit) { | |
| 1737 | + *min_power_limit = power_limit * (100 + od_percent_lower); | |
| 1738 | + *min_power_limit /= 100; | |
| 1739 | + } | |
| 1720 | 1740 | |
| 1721 | 1741 | return 0; |
| 1722 | 1742 | } |
| @@ -1474,8 +1474,8 @@ analogix_dp_probe(struct device *dev, struct analogix_dp_plat_data *plat_data) · 1473 unmodified lines | ||
| 1474 | 1474 | |
| 1475 | 1475 | dp = devm_drm_bridge_alloc(dev, struct analogix_dp_device, bridge, |
| 1476 | 1476 | &analogix_dp_bridge_funcs); |
| 1477 | − if (!dp) | |
| 1478 | − return ERR_PTR(-ENOMEM); | |
| 1477 | + if (IS_ERR(dp)) | |
| 1478 | + return ERR_CAST(dp); | |
| 1479 | 1479 | |
| 1480 | 1480 | dp->dev = &pdev->dev; |
| 1481 | 1481 | dp->dpms_mode = DRM_MODE_DPMS_OFF; |
| @@ -2432,6 +2432,8 @@ static const struct drm_gpuvm_ops lock_ops = { · 2431 unmodified lines | ||
| 2432 | 2432 | * |
| 2433 | 2433 | * The expected usage is: |
| 2434 | 2434 | * |
| 2435 | + * .. code-block:: c | |
| 2436 | + * | |
| 2435 | 2437 | * vm_bind { |
| 2436 | 2438 | * struct drm_exec exec; |
| 2437 | 2439 | * |
| @@ -381,6 +381,26 @@ struct DecFifo { · 380 unmodified lines | ||
| 381 | 381 | len: usize, |
| 382 | 382 | } |
| 383 | 383 | |
| 384 | +// On arm32 architecture, dividing an `u64` by a constant will generate a call | |
| 385 | +// to `__aeabi_uldivmod` which is not present in the kernel. | |
| 386 | +// So use the multiply by inverse method for this architecture. | |
| 387 | +fn div10(val: u64) -> u64 { | |
| 388 | + if cfg!(target_arch = "arm") { | |
| 389 | + let val_h = val >> 32; | |
| 390 | + let val_l = val & 0xFFFFFFFF; | |
| 391 | + let b_h: u64 = 0x66666666; | |
| 392 | + let b_l: u64 = 0x66666667; | |
| 393 | + | |
| 394 | + let tmp1 = val_h * b_l + ((val_l * b_l) >> 32); | |
| 395 | + let tmp2 = val_l * b_h + (tmp1 & 0xffffffff); | |
| 396 | + let tmp3 = val_h * b_h + (tmp1 >> 32) + (tmp2 >> 32); | |
| 397 | + | |
| 398 | + tmp3 >> 2 | |
| 399 | + } else { | |
| 400 | + val / 10 | |
| 401 | + } | |
| 402 | +} | |
| 403 | + | |
| 384 | 404 | impl DecFifo { |
| 385 | 405 | fn push(&mut self, data: u64, len: usize) { |
| 386 | 406 | let mut chunk = data; |
| @@ -389,7 +409,7 @@ impl DecFifo { · 2 unmodified lines | ||
| 389 | 409 | } |
| 390 | 410 | for i in 0..len { |
| 391 | 411 | self.decimals[i] = (chunk % 10) as u8; |
| 392 | − chunk /= 10; | |
| 412 | + chunk = div10(chunk); | |
| 393 | 413 | } |
| 394 | 414 | self.len += len; |
| 395 | 415 | } |
| @@ -325,6 +325,17 @@ static int hibmc_dp_link_downgrade_training_eq(struct hibmc_dp_dev *dp) · 324 unmodified lines | ||
| 325 | 325 | return hibmc_dp_link_reduce_rate(dp); |
| 326 | 326 | } |
| 327 | 327 | |
| 328 | +static void hibmc_dp_update_caps(struct hibmc_dp_dev *dp) | |
| 329 | +{ | |
| 330 | + dp->link.cap.link_rate = dp->dpcd[DP_MAX_LINK_RATE]; | |
| 331 | + if (dp->link.cap.link_rate > DP_LINK_BW_8_1 || !dp->link.cap.link_rate) | |
| 332 | + dp->link.cap.link_rate = DP_LINK_BW_8_1; | |
| 333 | + | |
| 334 | + dp->link.cap.lanes = dp->dpcd[DP_MAX_LANE_COUNT] & DP_MAX_LANE_COUNT_MASK; | |
| 335 | + if (dp->link.cap.lanes > HIBMC_DP_LANE_NUM_MAX) | |
| 336 | + dp->link.cap.lanes = HIBMC_DP_LANE_NUM_MAX; | |
| 337 | +} | |
| 338 | + | |
| 328 | 339 | int hibmc_dp_link_training(struct hibmc_dp_dev *dp) |
| 329 | 340 | { |
| 330 | 341 | struct hibmc_dp_link *link = &dp->link; |
| @@ -334,8 +345,7 @@ int hibmc_dp_link_training(struct hibmc_dp_dev *dp) · 3 unmodified lines | ||
| 334 | 345 | if (ret) |
| 335 | 346 | drm_err(dp->dev, "dp aux read dpcd failed, ret: %d\n", ret); |
| 336 | 347 | |
| 337 | − dp->link.cap.link_rate = dp->dpcd[DP_MAX_LINK_RATE]; | |
| 338 | − dp->link.cap.lanes = 0x2; | |
| 348 | + hibmc_dp_update_caps(dp); | |
| 339 | 349 | |
| 340 | 350 | ret = hibmc_dp_get_serdes_rate_cfg(dp); |
| 341 | 351 | if (ret < 0) |
| @@ -32,7 +32,7 @@ · 31 unmodified lines | ||
| 32 | 32 | |
| 33 | 33 | DEFINE_DRM_GEM_FOPS(hibmc_fops); |
| 34 | 34 | |
| 35 | −static const char *g_irqs_names_map[HIBMC_MAX_VECTORS] = { "vblank", "hpd" }; | |
| 35 | +static const char *g_irqs_names_map[HIBMC_MAX_VECTORS] = { "hibmc-vblank", "hibmc-hpd" }; | |
| 36 | 36 | |
| 37 | 37 | static irqreturn_t hibmc_interrupt(int irq, void *arg) |
| 38 | 38 | { |
| @@ -115,6 +115,8 @@ static const struct drm_mode_config_funcs hibmc_mode_funcs = { · 76 unmodified lines | ||
| 115 | 115 | static int hibmc_kms_init(struct hibmc_drm_private *priv) |
| 116 | 116 | { |
| 117 | 117 | struct drm_device *dev = &priv->dev; |
| 118 | + struct drm_encoder *encoder; | |
| 119 | + u32 clone_mask = 0; | |
| 118 | 120 | int ret; |
| 119 | 121 | |
| 120 | 122 | ret = drmm_mode_config_init(dev); |
| @@ -154,6 +156,12 @@ static int hibmc_kms_init(struct hibmc_drm_private *priv) · 33 unmodified lines | ||
| 154 | 156 | return ret; |
| 155 | 157 | } |
| 156 | 158 | |
| 159 | + drm_for_each_encoder(encoder, dev) | |
| 160 | + clone_mask |= drm_encoder_mask(encoder); | |
| 161 | + | |
| 162 | + drm_for_each_encoder(encoder, dev) | |
| 163 | + encoder->possible_clones = clone_mask; | |
| 164 | + | |
| 157 | 165 | return 0; |
| 158 | 166 | } |
| 159 | 167 | |
| @@ -277,7 +285,6 @@ static void hibmc_unload(struct drm_device *dev) · 117 unmodified lines | ||
| 277 | 285 | static int hibmc_msi_init(struct drm_device *dev) |
| 278 | 286 | { |
| 279 | 287 | struct pci_dev *pdev = to_pci_dev(dev->dev); |
| 280 | − char name[32] = {0}; | |
| 281 | 288 | int valid_irq_num; |
| 282 | 289 | int irq; |
| 283 | 290 | int ret; |
| @@ -292,9 +299,6 @@ static int hibmc_msi_init(struct drm_device *dev) · 8 unmodified lines | ||
| 292 | 299 | valid_irq_num = ret; |
| 293 | 300 | |
| 294 | 301 | for (int i = 0; i < valid_irq_num; i++) { |
| 295 | − snprintf(name, ARRAY_SIZE(name) - 1, "%s-%s-%s", | |
| 296 | − dev->driver->name, pci_name(pdev), g_irqs_names_map[i]); | |
| 297 | − | |
| 298 | 302 | irq = pci_irq_vector(pdev, i); |
| 299 | 303 | |
| 300 | 304 | if (i) |
| @@ -302,10 +306,10 @@ static int hibmc_msi_init(struct drm_device *dev) · 1 unmodified line | ||
| 302 | 306 | ret = devm_request_threaded_irq(&pdev->dev, irq, |
| 303 | 307 | hibmc_dp_interrupt, |
| 304 | 308 | hibmc_dp_hpd_isr, |
| 305 | − IRQF_SHARED, name, dev); | |
| 309 | + IRQF_SHARED, g_irqs_names_map[i], dev); | |
| 306 | 310 | else |
| 307 | 311 | ret = devm_request_irq(&pdev->dev, irq, hibmc_interrupt, |
| 308 | − IRQF_SHARED, name, dev); | |
| 312 | + IRQF_SHARED, g_irqs_names_map[i], dev); | |
| 309 | 313 | if (ret) { |
| 310 | 314 | drm_err(dev, "install irq failed: %d\n", ret); |
| 311 | 315 | return ret; |
| @@ -323,13 +327,13 @@ static int hibmc_load(struct drm_device *dev) · 11 unmodified lines | ||
| 323 | 327 | |
| 324 | 328 | ret = hibmc_hw_init(priv); |
| 325 | 329 | if (ret) |
| 326 | − goto err; | |
| 330 | + return ret; | |
| 327 | 331 | |
| 328 | 332 | ret = drmm_vram_helper_init(dev, pci_resource_start(pdev, 0), |
| 329 | 333 | pci_resource_len(pdev, 0)); |
| 330 | 334 | if (ret) { |
| 331 | 335 | drm_err(dev, "Error initializing VRAM MM; %d\n", ret); |
| 332 | − goto err; | |
| 336 | + return ret; | |
| 333 | 337 | } |
| 334 | 338 | |
| 335 | 339 | ret = hibmc_kms_init(priv); |
| @@ -69,6 +69,7 @@ int hibmc_de_init(struct hibmc_drm_private *priv); · 68 unmodified lines | ||
| 69 | 69 | int hibmc_vdac_init(struct hibmc_drm_private *priv); |
| 70 | 70 | |
| 71 | 71 | int hibmc_ddc_create(struct drm_device *drm_dev, struct hibmc_vdac *connector); |
| 72 | +void hibmc_ddc_del(struct hibmc_vdac *vdac); | |
| 72 | 73 | |
| 73 | 74 | int hibmc_dp_init(struct hibmc_drm_private *priv); |
| 74 | 75 | |
| @@ -95,3 +95,8 @@ int hibmc_ddc_create(struct drm_device *drm_dev, struct hibmc_vdac *vdac) · 94 unmodified lines | ||
| 95 | 95 | |
| 96 | 96 | return i2c_bit_add_bus(&vdac->adapter); |
| 97 | 97 | } |
| 98 | + | |
| 99 | +void hibmc_ddc_del(struct hibmc_vdac *vdac) | |
| 100 | +{ | |
| 101 | + i2c_del_adapter(&vdac->adapter); | |
| 102 | +} | |
| @@ -53,7 +53,7 @@ static void hibmc_connector_destroy(struct drm_connector *connector) · 52 unmodified lines | ||
| 53 | 53 | { |
| 54 | 54 | struct hibmc_vdac *vdac = to_hibmc_vdac(connector); |
| 55 | 55 | |
| 56 | − i2c_del_adapter(&vdac->adapter); | |
| 56 | + hibmc_ddc_del(vdac); | |
| 57 | 57 | drm_connector_cleanup(connector); |
| 58 | 58 | } |
| 59 | 59 | |
| @@ -110,7 +110,7 @@ int hibmc_vdac_init(struct hibmc_drm_private *priv) · 50 unmodified lines | ||
| 110 | 110 | ret = drmm_encoder_init(dev, encoder, NULL, DRM_MODE_ENCODER_DAC, NULL); |
| 111 | 111 | if (ret) { |
| 112 | 112 | drm_err(dev, "failed to init encoder: %d\n", ret); |
| 113 | − return ret; | |
| 113 | + goto err; | |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | drm_encoder_helper_add(encoder, &hibmc_encoder_helper_funcs); |
| @@ -121,7 +121,7 @@ int hibmc_vdac_init(struct hibmc_drm_private *priv) · 4 unmodified lines | ||
| 121 | 121 | &vdac->adapter); |
| 122 | 122 | if (ret) { |
| 123 | 123 | drm_err(dev, "failed to init connector: %d\n", ret); |
| 124 | − return ret; | |
| 124 | + goto err; | |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | drm_connector_helper_add(connector, &hibmc_connector_helper_funcs); |
| @@ -131,4 +131,9 @@ int hibmc_vdac_init(struct hibmc_drm_private *priv) · 3 unmodified lines | ||
| 131 | 131 | connector->polled = DRM_CONNECTOR_POLL_CONNECT | DRM_CONNECTOR_POLL_DISCONNECT; |
| 132 | 132 | |
| 133 | 133 | return 0; |
| 134 | + | |
| 135 | +err: | |
| 136 | + hibmc_ddc_del(vdac); | |
| 137 | + | |
| 138 | + return ret; | |
| 134 | 139 | } |
| @@ -1506,10 +1506,14 @@ u32 gen11_gu_misc_irq_ack(struct intel_display *display, const u32 master_ctl) · 1505 unmodified lines | ||
| 1506 | 1506 | if (!(master_ctl & GEN11_GU_MISC_IRQ)) |
| 1507 | 1507 | return 0; |
| 1508 | 1508 | |
| 1509 | + intel_display_rpm_assert_block(display); | |
| 1510 | + | |
| 1509 | 1511 | iir = intel_de_read(display, GEN11_GU_MISC_IIR); |
| 1510 | 1512 | if (likely(iir)) |
| 1511 | 1513 | intel_de_write(display, GEN11_GU_MISC_IIR, iir); |
| 1512 | 1514 | |
| 1515 | + intel_display_rpm_assert_unblock(display); | |
| 1516 | + | |
| 1513 | 1517 | return iir; |
| 1514 | 1518 | } |
| 1515 | 1519 | |
| @@ -23,6 +23,7 @@ · 22 unmodified lines | ||
| 23 | 23 | #include "intel_modeset_lock.h" |
| 24 | 24 | #include "intel_tc.h" |
| 25 | 25 | |
| 26 | +#define DP_PIN_ASSIGNMENT_NONE 0x0 | |
| 26 | 27 | #define DP_PIN_ASSIGNMENT_C 0x3 |
| 27 | 28 | #define DP_PIN_ASSIGNMENT_D 0x4 |
| 28 | 29 | #define DP_PIN_ASSIGNMENT_E 0x5 |
| @@ -66,6 +67,7 @@ struct intel_tc_port { · 37 unmodified lines | ||
| 66 | 67 | enum tc_port_mode init_mode; |
| 67 | 68 | enum phy_fia phy_fia; |
| 68 | 69 | u8 phy_fia_idx; |
| 70 | + u8 max_lane_count; | |
| 69 | 71 | }; |
| 70 | 72 | |
| 71 | 73 | static enum intel_display_power_domain |
| @@ -307,6 +309,8 @@ static int lnl_tc_port_get_max_lane_count(struct intel_digital_port *dig_port) · 235 unmodified lines | ||
| 307 | 309 | REG_FIELD_GET(TCSS_DDI_STATUS_PIN_ASSIGNMENT_MASK, val); |
| 308 | 310 | |
| 309 | 311 | switch (pin_assignment) { |
| 312 | + case DP_PIN_ASSIGNMENT_NONE: | |
| 313 | + return 0; | |
| 310 | 314 | default: |
| 311 | 315 | MISSING_CASE(pin_assignment); |
| 312 | 316 | fallthrough; |
| @@ -365,12 +369,12 @@ static int intel_tc_port_get_max_lane_count(struct intel_digital_port *dig_port) · 52 unmodified lines | ||
| 365 | 369 | } |
| 366 | 370 | } |
| 367 | 371 | |
| 368 | −int intel_tc_port_max_lane_count(struct intel_digital_port *dig_port) | |
| 372 | +static int get_max_lane_count(struct intel_tc_port *tc) | |
| 369 | 373 | { |
| 370 | − struct intel_display *display = to_intel_display(dig_port); | |
| 371 | − struct intel_tc_port *tc = to_tc_port(dig_port); | |
| 374 | + struct intel_display *display = to_intel_display(tc->dig_port); | |
| 375 | + struct intel_digital_port *dig_port = tc->dig_port; | |
| 372 | 376 | |
| 373 | − if (!intel_encoder_is_tc(&dig_port->base) || tc->mode != TC_PORT_DP_ALT) | |
| 377 | + if (tc->mode != TC_PORT_DP_ALT) | |
| 374 | 378 | return 4; |
| 375 | 379 | |
| 376 | 380 | assert_tc_cold_blocked(tc); |
| @@ -384,6 +388,25 @@ int intel_tc_port_max_lane_count(struct intel_digital_port *dig_port) · 7 unmodified lines | ||
| 384 | 388 | return intel_tc_port_get_max_lane_count(dig_port); |
| 385 | 389 | } |
| 386 | 390 | |
| 391 | +static void read_pin_configuration(struct intel_tc_port *tc) | |
| 392 | +{ | |
| 393 | + tc->max_lane_count = get_max_lane_count(tc); | |
| 394 | +} | |
| 395 | + | |
| 396 | +int intel_tc_port_max_lane_count(struct intel_digital_port *dig_port) | |
| 397 | +{ | |
| 398 | + struct intel_display *display = to_intel_display(dig_port); | |
| 399 | + struct intel_tc_port *tc = to_tc_port(dig_port); | |
| 400 | + | |
| 401 | + if (!intel_encoder_is_tc(&dig_port->base)) | |
| 402 | + return 4; | |
| 403 | + | |
| 404 | + if (DISPLAY_VER(display) < 20) | |
| 405 | + return get_max_lane_count(tc); | |
| 406 | + | |
| 407 | + return tc->max_lane_count; | |
| 408 | +} | |
| 409 | + | |
| 387 | 410 | void intel_tc_port_set_fia_lane_count(struct intel_digital_port *dig_port, |
| 388 | 411 | int required_lanes) |
| 389 | 412 | { |
| @@ -596,9 +619,12 @@ static void icl_tc_phy_get_hw_state(struct intel_tc_port *tc) · 206 unmodified lines | ||
| 596 | 619 | tc_cold_wref = __tc_cold_block(tc, &domain); |
| 597 | 620 | |
| 598 | 621 | tc->mode = tc_phy_get_current_mode(tc); |
| 599 | − if (tc->mode != TC_PORT_DISCONNECTED) | |
| 622 | + if (tc->mode != TC_PORT_DISCONNECTED) { | |
| 600 | 623 | tc->lock_wakeref = tc_cold_block(tc); |
| 601 | 624 | |
| 625 | + read_pin_configuration(tc); | |
| 626 | + } | |
| 627 | + | |
| 602 | 628 | __tc_cold_unblock(tc, domain, tc_cold_wref); |
| 603 | 629 | } |
| 604 | 630 | |
| @@ -656,8 +682,11 @@ static bool icl_tc_phy_connect(struct intel_tc_port *tc, · 51 unmodified lines | ||
| 656 | 682 | |
| 657 | 683 | tc->lock_wakeref = tc_cold_block(tc); |
| 658 | 684 | |
| 659 | − if (tc->mode == TC_PORT_TBT_ALT) | |
| 685 | + if (tc->mode == TC_PORT_TBT_ALT) { | |
| 686 | + read_pin_configuration(tc); | |
| 687 | + | |
| 660 | 688 | return true; |
| 689 | + } | |
| 661 | 690 | |
| 662 | 691 | if ((!tc_phy_is_ready(tc) || |
| 663 | 692 | !icl_tc_phy_take_ownership(tc, true)) && |
| @@ -668,6 +697,7 @@ static bool icl_tc_phy_connect(struct intel_tc_port *tc, · 4 unmodified lines | ||
| 668 | 697 | goto out_unblock_tc_cold; |
| 669 | 698 | } |
| 670 | 699 | |
| 700 | + read_pin_configuration(tc); | |
| 671 | 701 | |
| 672 | 702 | if (!tc_phy_verify_legacy_or_dp_alt_mode(tc, required_lanes)) |
| 673 | 703 | goto out_release_phy; |
| @@ -858,9 +888,12 @@ static void adlp_tc_phy_get_hw_state(struct intel_tc_port *tc) · 184 unmodified lines | ||
| 858 | 888 | port_wakeref = intel_display_power_get(display, port_power_domain); |
| 859 | 889 | |
| 860 | 890 | tc->mode = tc_phy_get_current_mode(tc); |
| 861 | − if (tc->mode != TC_PORT_DISCONNECTED) | |
| 891 | + if (tc->mode != TC_PORT_DISCONNECTED) { | |
| 862 | 892 | tc->lock_wakeref = tc_cold_block(tc); |
| 863 | 893 | |
| 894 | + read_pin_configuration(tc); | |
| 895 | + } | |
| 896 | + | |
| 864 | 897 | intel_display_power_put(display, port_power_domain, port_wakeref); |
| 865 | 898 | } |
| 866 | 899 | |
| @@ -873,6 +906,9 @@ static bool adlp_tc_phy_connect(struct intel_tc_port *tc, int required_lanes) · 6 unmodified lines | ||
| 873 | 906 | |
| 874 | 907 | if (tc->mode == TC_PORT_TBT_ALT) { |
| 875 | 908 | tc->lock_wakeref = tc_cold_block(tc); |
| 909 | + | |
| 910 | + read_pin_configuration(tc); | |
| 911 | + | |
| 876 | 912 | return true; |
| 877 | 913 | } |
| 878 | 914 | |
| @@ -894,6 +930,8 @@ static bool adlp_tc_phy_connect(struct intel_tc_port *tc, int required_lanes) · 15 unmodified lines | ||
| 894 | 930 | |
| 895 | 931 | tc->lock_wakeref = tc_cold_block(tc); |
| 896 | 932 | |
| 933 | + read_pin_configuration(tc); | |
| 934 | + | |
| 897 | 935 | if (!tc_phy_verify_legacy_or_dp_alt_mode(tc, required_lanes)) |
| 898 | 936 | goto out_unblock_tc_cold; |
| 899 | 937 | |
| @@ -1124,9 +1162,18 @@ static void xelpdp_tc_phy_get_hw_state(struct intel_tc_port *tc) · 224 unmodified lines | ||
| 1124 | 1162 | tc_cold_wref = __tc_cold_block(tc, &domain); |
| 1125 | 1163 | |
| 1126 | 1164 | tc->mode = tc_phy_get_current_mode(tc); |
| 1127 | − if (tc->mode != TC_PORT_DISCONNECTED) | |
| 1165 | + if (tc->mode != TC_PORT_DISCONNECTED) { | |
| 1128 | 1166 | tc->lock_wakeref = tc_cold_block(tc); |
| 1129 | 1167 | |
| 1168 | + read_pin_configuration(tc); | |
| 1169 | + /* | |
| 1170 | + * Set a valid lane count value for a DP-alt sink which got | |
| 1171 | + * disconnected. The driver can only disable the output on this PHY. | |
| 1172 | + */ | |
| 1173 | + if (tc->max_lane_count == 0) | |
| 1174 | + tc->max_lane_count = 4; | |
| 1175 | + } | |
| 1176 | + | |
| 1130 | 1177 | drm_WARN_ON(display->drm, |
| 1131 | 1178 | (tc->mode == TC_PORT_DP_ALT || tc->mode == TC_PORT_LEGACY) && |
| 1132 | 1179 | !xelpdp_tc_phy_tcss_power_is_enabled(tc)); |
| @@ -1138,14 +1185,19 @@ static bool xelpdp_tc_phy_connect(struct intel_tc_port *tc, int required_lanes) · 5 unmodified lines | ||
| 1138 | 1185 | { |
| 1139 | 1186 | tc->lock_wakeref = tc_cold_block(tc); |
| 1140 | 1187 | |
| 1141 | − if (tc->mode == TC_PORT_TBT_ALT) | |
| 1188 | + if (tc->mode == TC_PORT_TBT_ALT) { | |
| 1189 | + read_pin_configuration(tc); | |
| 1190 | + | |
| 1142 | 1191 | return true; |
| 1192 | + } | |
| 1143 | 1193 | |
| 1144 | 1194 | if (!xelpdp_tc_phy_enable_tcss_power(tc, true)) |
| 1145 | 1195 | goto out_unblock_tccold; |
| 1146 | 1196 | |
| 1147 | 1197 | xelpdp_tc_phy_take_ownership(tc, true); |
| 1148 | 1198 | |
| 1199 | + read_pin_configuration(tc); | |
| 1200 | + | |
| 1149 | 1201 | if (!tc_phy_verify_legacy_or_dp_alt_mode(tc, required_lanes)) |
| 1150 | 1202 | goto out_release_phy; |
| 1151 | 1203 | |
| @@ -1226,14 +1278,19 @@ static void tc_phy_get_hw_state(struct intel_tc_port *tc) · 74 unmodified lines | ||
| 1226 | 1278 | tc->phy_ops->get_hw_state(tc); |
| 1227 | 1279 | } |
| 1228 | 1280 | |
| 1229 | −static bool tc_phy_is_ready_and_owned(struct intel_tc_port *tc, | |
| 1230 | − bool phy_is_ready, bool phy_is_owned) | |
| 1281 | +/* Is the PHY owned by display i.e. is it in legacy or DP-alt mode? */ | |
| 1282 | +static bool tc_phy_owned_by_display(struct intel_tc_port *tc, | |
| 1283 | + bool phy_is_ready, bool phy_is_owned) | |
| 1231 | 1284 | { |
| 1232 | 1285 | struct intel_display *display = to_intel_display(tc->dig_port); |
| 1233 | 1286 | |
| 1234 | − drm_WARN_ON(display->drm, phy_is_owned && !phy_is_ready); | |
| 1287 | + if (DISPLAY_VER(display) < 20) { | |
| 1288 | + drm_WARN_ON(display->drm, phy_is_owned && !phy_is_ready); | |
| 1235 | 1289 | |
| 1236 | − return phy_is_ready && phy_is_owned; | |
| 1290 | + return phy_is_ready && phy_is_owned; | |
| 1291 | + } else { | |
| 1292 | + return phy_is_owned; | |
| 1293 | + } | |
| 1237 | 1294 | } |
| 1238 | 1295 | |
| 1239 | 1296 | static bool tc_phy_is_connected(struct intel_tc_port *tc, |
| @@ -1244,7 +1301,7 @@ static bool tc_phy_is_connected(struct intel_tc_port *tc, · 4 unmodified lines | ||
| 1244 | 1301 | bool phy_is_owned = tc_phy_is_owned(tc); |
| 1245 | 1302 | bool is_connected; |
| 1246 | 1303 | |
| 1247 | − if (tc_phy_is_ready_and_owned(tc, phy_is_ready, phy_is_owned)) | |
| 1304 | + if (tc_phy_owned_by_display(tc, phy_is_ready, phy_is_owned)) | |
| 1248 | 1305 | is_connected = port_pll_type == ICL_PORT_DPLL_MG_PHY; |
| 1249 | 1306 | else |
| 1250 | 1307 | is_connected = port_pll_type == ICL_PORT_DPLL_DEFAULT; |
| @@ -1352,7 +1409,7 @@ tc_phy_get_current_mode(struct intel_tc_port *tc) · 101 unmodified lines | ||
| 1352 | 1409 | phy_is_ready = tc_phy_is_ready(tc); |
| 1353 | 1410 | phy_is_owned = tc_phy_is_owned(tc); |
| 1354 | 1411 | |
| 1355 | − if (!tc_phy_is_ready_and_owned(tc, phy_is_ready, phy_is_owned)) { | |
| 1412 | + if (!tc_phy_owned_by_display(tc, phy_is_ready, phy_is_owned)) { | |
| 1356 | 1413 | mode = get_tc_mode_in_phy_not_owned_state(tc, live_mode); |
| 1357 | 1414 | } else { |
| 1358 | 1415 | drm_WARN_ON(display->drm, live_mode == TC_PORT_TBT_ALT); |
| @@ -1441,11 +1498,11 @@ static void intel_tc_port_reset_mode(struct intel_tc_port *tc, · 82 unmodified lines | ||
| 1441 | 1498 | intel_display_power_flush_work(display); |
| 1442 | 1499 | if (!intel_tc_cold_requires_aux_pw(dig_port)) { |
| 1443 | 1500 | enum intel_display_power_domain aux_domain; |
| 1444 | − bool aux_powered; | |
| 1445 | 1501 | |
| 1446 | 1502 | aux_domain = intel_aux_power_domain(dig_port); |
| 1447 | − aux_powered = intel_display_power_is_enabled(display, aux_domain); | |
| 1448 | − drm_WARN_ON(display->drm, aux_powered); | |
| 1503 | + if (intel_display_power_is_enabled(display, aux_domain)) | |
| 1504 | + drm_dbg_kms(display->drm, "Port %s: AUX unexpectedly powered\n", | |
| 1505 | + tc->port_name); | |
| 1449 | 1506 | } |
| 1450 | 1507 | |
| 1451 | 1508 | tc_phy_disconnect(tc); |
| @@ -634,6 +634,8 @@ static void cfl_ctx_workarounds_init(struct intel_engine_cs *engine, · 633 unmodified lines | ||
| 634 | 634 | static void icl_ctx_workarounds_init(struct intel_engine_cs *engine, |
| 635 | 635 | struct i915_wa_list *wal) |
| 636 | 636 | { |
| 637 | + struct drm_i915_private *i915 = engine->i915; | |
| 638 | + | |
| 637 | 639 | /* Wa_1406697149 (WaDisableBankHangMode:icl) */ |
| 638 | 640 | wa_write(wal, GEN8_L3CNTLREG, GEN8_ERRDETBCTRL); |
| 639 | 641 | |
| @@ -669,6 +671,15 @@ static void icl_ctx_workarounds_init(struct intel_engine_cs *engine, · 29 unmodified lines | ||
| 669 | 671 | |
| 670 | 672 | /* Wa_1406306137:icl,ehl */ |
| 671 | 673 | wa_mcr_masked_en(wal, GEN9_ROW_CHICKEN4, GEN11_DIS_PICK_2ND_EU); |
| 674 | + | |
| 675 | + if (IS_JASPERLAKE(i915) || IS_ELKHARTLAKE(i915)) { | |
| 676 | + /* | |
| 677 | + * Disable Repacking for Compression (masked R/W access) | |
| 678 | + * before rendering compressed surfaces for display. | |
| 679 | + */ | |
| 680 | + wa_masked_en(wal, CACHE_MODE_0_GEN7, | |
| 681 | + DISABLE_REPACKING_FOR_COMPRESSION); | |
| 682 | + } | |
| 672 | 683 | } |
| 673 | 684 | |
| 674 | 685 | /* |
| @@ -2306,15 +2317,6 @@ rcs_engine_wa_init(struct intel_engine_cs *engine, struct i915_wa_list *wal) · 1631 unmodified lines | ||
| 2306 | 2317 | GEN8_RC_SEMA_IDLE_MSG_DISABLE); |
| 2307 | 2318 | } |
| 2308 | 2319 | |
| 2309 | − if (IS_JASPERLAKE(i915) || IS_ELKHARTLAKE(i915)) { | |
| 2310 | − /* | |
| 2311 | − * "Disable Repacking for Compression (masked R/W access) | |
| 2312 | − * before rendering compressed surfaces for display." | |
| 2313 | − */ | |
| 2314 | − wa_masked_en(wal, CACHE_MODE_0_GEN7, | |
| 2315 | − DISABLE_REPACKING_FOR_COMPRESSION); | |
| 2316 | − } | |
| 2317 | − | |
| 2318 | 2320 | if (GRAPHICS_VER(i915) == 11) { |
| 2319 | 2321 | /* This is not an Wa. Enable for better image quality */ |
| 2320 | 2322 | wa_masked_en(wal, |
| @@ -60,14 +60,14 @@ · 59 unmodified lines | ||
| 60 | 60 | * virtual address in the GPU's VA space there is no guarantee that the actual |
| 61 | 61 | * mappings are created in the GPU's MMU. If the given memory is swapped out |
| 62 | 62 | * at the time the bind operation is executed the kernel will stash the mapping |
| 63 | − * details into it's internal alloctor and create the actual MMU mappings once | |
| 63 | + * details into it's internal allocator and create the actual MMU mappings once | |
| 64 | 64 | * the memory is swapped back in. While this is transparent for userspace, it is |
| 65 | 65 | * guaranteed that all the backing memory is swapped back in and all the memory |
| 66 | 66 | * mappings, as requested by userspace previously, are actually mapped once the |
| 67 | 67 | * DRM_NOUVEAU_EXEC ioctl is called to submit an exec job. |
| 68 | 68 | * |
| 69 | 69 | * A VM_BIND job can be executed either synchronously or asynchronously. If |
| 70 | − * exectued asynchronously, userspace may provide a list of syncobjs this job | |
| 70 | + * executed asynchronously, userspace may provide a list of syncobjs this job | |
| 71 | 71 | * will wait for and/or a list of syncobj the kernel will signal once the |
| 72 | 72 | * VM_BIND job finished execution. If executed synchronously the ioctl will |
| 73 | 73 | * block until the bind job is finished. For synchronous jobs the kernel will |
| @@ -82,7 +82,7 @@ · 8 unmodified lines | ||
| 82 | 82 | * Since VM_BIND jobs update the GPU's VA space on job submit, EXEC jobs do have |
| 83 | 83 | * an up to date view of the VA space. However, the actual mappings might still |
| 84 | 84 | * be pending. Hence, EXEC jobs require to have the particular fences - of |
| 85 | − * the corresponding VM_BIND jobs they depent on - attached to them. | |
| 85 | + * the corresponding VM_BIND jobs they depend on - attached to them. | |
| 86 | 86 | */ |
| 87 | 87 | |
| 88 | 88 | static int |
| @@ -219,7 +219,8 @@ nvif_vmm_ctor(struct nvif_mmu *mmu, const char *name, s32 oclass, · 218 unmodified lines | ||
| 219 | 219 | case RAW: args->type = NVIF_VMM_V0_TYPE_RAW; break; |
| 220 | 220 | default: |
| 221 | 221 | WARN_ON(1); |
| 222 | − return -EINVAL; | |
| 222 | + ret = -EINVAL; | |
| 223 | + goto done; | |
| 223 | 224 | } |
| 224 | 225 | |
| 225 | 226 | memcpy(args->data, argv, argc); |
| @@ -325,7 +325,7 @@ r535_gsp_msgq_recv(struct nvkm_gsp *gsp, u32 gsp_rpc_len, int *retries) · 324 unmodified lines | ||
| 325 | 325 | |
| 326 | 326 | rpc = r535_gsp_msgq_peek(gsp, sizeof(*rpc), info.retries); |
| 327 | 327 | if (IS_ERR_OR_NULL(rpc)) { |
| 328 | − kfree(buf); | |
| 328 | + kvfree(buf); | |
| 329 | 329 | return rpc; |
| 330 | 330 | } |
| 331 | 331 | |
| @@ -334,7 +334,7 @@ r535_gsp_msgq_recv(struct nvkm_gsp *gsp, u32 gsp_rpc_len, int *retries) · 2 unmodified lines | ||
| 334 | 334 | |
| 335 | 335 | rpc = r535_gsp_msgq_recv_one_elem(gsp, &info); |
| 336 | 336 | if (IS_ERR_OR_NULL(rpc)) { |
| 337 | − kfree(buf); | |
| 337 | + kvfree(buf); | |
| 338 | 338 | return rpc; |
| 339 | 339 | } |
| 340 | 340 | |
| @@ -39,7 +39,8 @@ impl File { · 38 unmodified lines | ||
| 39 | 39 | _ => return Err(EINVAL), |
| 40 | 40 | }; |
| 41 | 41 | |
| 42 | − getparam.set_value(value); | |
| 42 | + #[allow(clippy::useless_conversion)] | |
| 43 | + getparam.set_value(value.into()); | |
| 43 | 44 | |
| 44 | 45 | Ok(0) |
| 45 | 46 | } |
| @@ -53,6 +53,7 @@ config ROCKCHIP_CDN_DP · 52 unmodified lines | ||
| 53 | 53 | bool "Rockchip cdn DP" |
| 54 | 54 | depends on EXTCON=y || (EXTCON=m && DRM_ROCKCHIP=m) |
| 55 | 55 | select DRM_DISPLAY_HELPER |
| 56 | + select DRM_BRIDGE_CONNECTOR | |
| 56 | 57 | select DRM_DISPLAY_DP_HELPER |
| 57 | 58 | help |
| 58 | 59 | This selects support for Rockchip SoC specific extensions |
| @@ -2579,12 +2579,13 @@ static int vop2_win_init(struct vop2 *vop2) · 2578 unmodified lines | ||
| 2579 | 2579 | } |
| 2580 | 2580 | |
| 2581 | 2581 | /* |
| 2582 | − * The window registers are only updated when config done is written. | |
| 2583 | − * Until that they read back the old value. As we read-modify-write | |
| 2584 | − * these registers mark them as non-volatile. This makes sure we read | |
| 2585 | − * the new values from the regmap register cache. | |
| 2582 | + * The window and video port registers are only updated when config | |
| 2583 | + * done is written. Until that they read back the old value. As we | |
| 2584 | + * read-modify-write these registers mark them as non-volatile. This | |
| 2585 | + * makes sure we read the new values from the regmap register cache. | |
| 2586 | 2586 | */ |
| 2587 | 2587 | static const struct regmap_range vop2_nonvolatile_range[] = { |
| 2588 | + regmap_reg_range(RK3568_VP0_CTRL_BASE, RK3588_VP3_CTRL_BASE + 255), | |
| 2588 | 2589 | regmap_reg_range(0x1000, 0x23ff), |
| 2589 | 2590 | }; |
| 2590 | 2591 | |
| @@ -1033,13 +1033,14 @@ static void drm_test_fb_xrgb8888_to_xrgb2101010(struct kunit *test) · 1032 unmodified lines | ||
| 1033 | 1033 | NULL : &result->dst_pitch; |
| 1034 | 1034 | |
| 1035 | 1035 | drm_fb_xrgb8888_to_xrgb2101010(&dst, dst_pitch, &src, &fb, ¶ms->clip, &fmtcnv_state); |
| 1036 | − buf = le32buf_to_cpu(test, buf, dst_size / sizeof(u32)); | |
| 1036 | + buf = le32buf_to_cpu(test, (__force const __le32 *)buf, dst_size / sizeof(u32)); | |
| 1037 | 1037 | KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); |
| 1038 | 1038 | |
| 1039 | 1039 | buf = dst.vaddr; /* restore original value of buf */ |
| 1040 | 1040 | memset(buf, 0, dst_size); |
| 1041 | 1041 | |
| 1042 | 1042 | drm_fb_xrgb8888_to_xrgb2101010(&dst, dst_pitch, &src, &fb, ¶ms->clip, &fmtcnv_state); |
| 1043 | + buf = le32buf_to_cpu(test, (__force const __le32 *)buf, dst_size / sizeof(u32)); | |
| 1043 | 1044 | KUNIT_EXPECT_MEMEQ(test, buf, result->expected, dst_size); |
| 1044 | 1045 | } |
| 1045 | 1046 | |
| @@ -408,7 +408,7 @@ struct xe_migrate *xe_migrate_init(struct xe_tile *tile) · 407 unmodified lines | ||
| 408 | 408 | |
| 409 | 409 | /* Special layout, prepared below.. */ |
| 410 | 410 | vm = xe_vm_create(xe, XE_VM_FLAG_MIGRATION | |
| 411 | − XE_VM_FLAG_SET_TILE_ID(tile)); | |
| 411 | + XE_VM_FLAG_SET_TILE_ID(tile), NULL); | |
| 412 | 412 | if (IS_ERR(vm)) |
| 413 | 413 | return ERR_CAST(vm); |
| 414 | 414 | |
| @@ -101,7 +101,7 @@ static int allocate_gsc_client_resources(struct xe_gt *gt, · 100 unmodified lines | ||
| 101 | 101 | xe_assert(xe, hwe); |
| 102 | 102 | |
| 103 | 103 | /* PXP instructions must be issued from PPGTT */ |
| 104 | − vm = xe_vm_create(xe, XE_VM_FLAG_GSC); | |
| 104 | + vm = xe_vm_create(xe, XE_VM_FLAG_GSC, NULL); | |
| 105 | 105 | if (IS_ERR(vm)) |
| 106 | 106 | return PTR_ERR(vm); |
| 107 | 107 | |
| @@ -1640,7 +1640,7 @@ static void xe_vm_free_scratch(struct xe_vm *vm) · 1639 unmodified lines | ||
| 1640 | 1640 | } |
| 1641 | 1641 | } |
| 1642 | 1642 | |
| 1643 | −struct xe_vm *xe_vm_create(struct xe_device *xe, u32 flags) | |
| 1643 | +struct xe_vm *xe_vm_create(struct xe_device *xe, u32 flags, struct xe_file *xef) | |
| 1644 | 1644 | { |
| 1645 | 1645 | struct drm_gem_object *vm_resv_obj; |
| 1646 | 1646 | struct xe_vm *vm; |
| @@ -1661,9 +1661,10 @@ struct xe_vm *xe_vm_create(struct xe_device *xe, u32 flags) · 14 unmodified lines | ||
| 1661 | 1661 | vm->xe = xe; |
| 1662 | 1662 | |
| 1663 | 1663 | vm->size = 1ull << xe->info.va_bits; |
| 1664 | − | |
| 1665 | 1664 | vm->flags = flags; |
| 1666 | 1665 | |
| 1666 | + if (xef) | |
| 1667 | + vm->xef = xe_file_get(xef); | |
| 1667 | 1668 | /** |
| 1668 | 1669 | * GSC VMs are kernel-owned, only used for PXP ops and can sometimes be |
| 1669 | 1670 | * manipulated under the PXP mutex. However, the PXP mutex can be taken |
| @@ -1794,6 +1795,20 @@ struct xe_vm *xe_vm_create(struct xe_device *xe, u32 flags) · 124 unmodified lines | ||
| 1794 | 1795 | if (number_tiles > 1) |
| 1795 | 1796 | vm->composite_fence_ctx = dma_fence_context_alloc(1); |
| 1796 | 1797 | |
| 1798 | + if (xef && xe->info.has_asid) { | |
| 1799 | + u32 asid; | |
| 1800 | + | |
| 1801 | + down_write(&xe->usm.lock); | |
| 1802 | + err = xa_alloc_cyclic(&xe->usm.asid_to_vm, &asid, vm, | |
| 1803 | + XA_LIMIT(1, XE_MAX_ASID - 1), | |
| 1804 | + &xe->usm.next_asid, GFP_KERNEL); | |
| 1805 | + up_write(&xe->usm.lock); | |
| 1806 | + if (err < 0) | |
| 1807 | + goto err_unlock_close; | |
| 1808 | + | |
| 1809 | + vm->usm.asid = asid; | |
| 1810 | + } | |
| 1811 | + | |
| 1797 | 1812 | trace_xe_vm_create(vm); |
| 1798 | 1813 | |
| 1799 | 1814 | return vm; |
| @@ -1814,6 +1829,8 @@ err_no_resv: · 14 unmodified lines | ||
| 1814 | 1829 | for_each_tile(tile, xe, id) |
| 1815 | 1830 | xe_range_fence_tree_fini(&vm->rftree[id]); |
| 1816 | 1831 | ttm_lru_bulk_move_fini(&xe->ttm, &vm->lru_bulk_move); |
| 1832 | + if (vm->xef) | |
| 1833 | + xe_file_put(vm->xef); | |
| 1817 | 1834 | kfree(vm); |
| 1818 | 1835 | if (flags & XE_VM_FLAG_LR_MODE) |
| 1819 | 1836 | xe_pm_runtime_put(xe); |
| @@ -2059,9 +2076,8 @@ int xe_vm_create_ioctl(struct drm_device *dev, void *data, · 239 unmodified lines | ||
| 2059 | 2076 | struct xe_device *xe = to_xe_device(dev); |
| 2060 | 2077 | struct xe_file *xef = to_xe_file(file); |
| 2061 | 2078 | struct drm_xe_vm_create *args = data; |
| 2062 | − struct xe_tile *tile; | |
| 2063 | 2079 | struct xe_vm *vm; |
| 2064 | − u32 id, asid; | |
| 2080 | + u32 id; | |
| 2065 | 2081 | int err; |
| 2066 | 2082 | u32 flags = 0; |
| 2067 | 2083 | |
| @@ -2097,29 +2113,10 @@ int xe_vm_create_ioctl(struct drm_device *dev, void *data, · 29 unmodified lines | ||
| 2097 | 2113 | if (args->flags & DRM_XE_VM_CREATE_FLAG_FAULT_MODE) |
| 2098 | 2114 | flags |= XE_VM_FLAG_FAULT_MODE; |
| 2099 | 2115 | |
| 2100 | − vm = xe_vm_create(xe, flags); | |
| 2116 | + vm = xe_vm_create(xe, flags, xef); | |
| 2101 | 2117 | if (IS_ERR(vm)) |
| 2102 | 2118 | return PTR_ERR(vm); |
| 2103 | 2119 | |
| 2104 | − if (xe->info.has_asid) { | |
| 2105 | − down_write(&xe->usm.lock); | |
| 2106 | − err = xa_alloc_cyclic(&xe->usm.asid_to_vm, &asid, vm, | |
| 2107 | − XA_LIMIT(1, XE_MAX_ASID - 1), | |
| 2108 | − &xe->usm.next_asid, GFP_KERNEL); | |
| 2109 | − up_write(&xe->usm.lock); | |
| 2110 | − if (err < 0) | |
| 2111 | − goto err_close_and_put; | |
| 2112 | − | |
| 2113 | − vm->usm.asid = asid; | |
| 2114 | − } | |
| 2115 | − | |
| 2116 | − vm->xef = xe_file_get(xef); | |
| 2117 | − | |
| 2118 | − /* Record BO memory for VM pagetable created against client */ | |
| 2119 | − for_each_tile(tile, xe, id) | |
| 2120 | − if (vm->pt_root[id]) | |
| 2121 | − xe_drm_client_add_bo(vm->xef->client, vm->pt_root[id]->bo); | |
| 2122 | − | |
| 2123 | 2120 | #if IS_ENABLED(CONFIG_DRM_XE_DEBUG_MEM) |
| 2124 | 2121 | /* Warning: Security issue - never enable by default */ |
| 2125 | 2122 | args->reserved[0] = xe_bo_main_addr(vm->pt_root[0]->bo, XE_PAGE_SIZE); |
| @@ -3421,6 +3418,7 @@ static int vm_bind_ioctl_check_args(struct xe_device *xe, struct xe_vm *vm, · 1295 unmodified lines | ||
| 3421 | 3418 | free_bind_ops: |
| 3422 | 3419 | if (args->num_binds > 1) |
| 3423 | 3420 | kvfree(*bind_ops); |
| 3421 | + *bind_ops = NULL; | |
| 3424 | 3422 | return err; |
| 3425 | 3423 | } |
| 3426 | 3424 | |
| @@ -3527,7 +3525,7 @@ int xe_vm_bind_ioctl(struct drm_device *dev, void *data, struct drm_file *file) · 100 unmodified lines | ||
| 3527 | 3525 | struct xe_exec_queue *q = NULL; |
| 3528 | 3526 | u32 num_syncs, num_ufence = 0; |
| 3529 | 3527 | struct xe_sync_entry *syncs = NULL; |
| 3530 | − struct drm_xe_vm_bind_op *bind_ops; | |
| 3528 | + struct drm_xe_vm_bind_op *bind_ops = NULL; | |
| 3531 | 3529 | struct xe_vma_ops vops; |
| 3532 | 3530 | struct dma_fence *fence; |
| 3533 | 3531 | int err; |
| @@ -26,7 +26,7 @@ struct xe_sync_entry; · 25 unmodified lines | ||
| 26 | 26 | struct xe_svm_range; |
| 27 | 27 | struct drm_exec; |
| 28 | 28 | |
| 29 | −struct xe_vm *xe_vm_create(struct xe_device *xe, u32 flags); | |
| 29 | +struct xe_vm *xe_vm_create(struct xe_device *xe, u32 flags, struct xe_file *xef); | |
| 30 | 30 | |
| 31 | 31 | struct xe_vm *xe_vm_lookup(struct xe_file *xef, u32 id); |
| 32 | 32 | int xe_vma_cmp_vma_cb(const void *key, const struct rb_node *node); |
| @@ -143,10 +143,10 @@ static int rtl9300_i2c_write(struct rtl9300_i2c *i2c, u8 *buf, int len) · 142 unmodified lines | ||
| 143 | 143 | return -EIO; |
| 144 | 144 | |
| 145 | 145 | for (i = 0; i < len; i++) { |
| 146 | − if (i % 4 == 0) | |
| 147 | − vals[i/4] = 0; | |
| 148 | − vals[i/4] <<= 8; | |
| 149 | − vals[i/4] |= buf[i]; | |
| 146 | + unsigned int shift = (i % 4) * 8; | |
| 147 | + unsigned int reg = i / 4; | |
| 148 | + | |
| 149 | + vals[reg] |= buf[i] << shift; | |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | return regmap_bulk_write(i2c->regmap, i2c->reg_base + RTL9300_I2C_MST_DATA_WORD0, |
| @@ -175,7 +175,7 @@ static int rtl9300_i2c_execute_xfer(struct rtl9300_i2c *i2c, char read_write, · 22 unmodified lines | ||
| 175 | 175 | return ret; |
| 176 | 176 | |
| 177 | 177 | ret = regmap_read_poll_timeout(i2c->regmap, i2c->reg_base + RTL9300_I2C_MST_CTRL1, |
| 178 | − val, !(val & RTL9300_I2C_MST_CTRL1_I2C_TRIG), 100, 2000); | |
| 178 | + val, !(val & RTL9300_I2C_MST_CTRL1_I2C_TRIG), 100, 100000); | |
| 179 | 179 | if (ret) |
| 180 | 180 | return ret; |
| 181 | 181 | |
| @@ -281,15 +281,19 @@ static int rtl9300_i2c_smbus_xfer(struct i2c_adapter *adap, u16 addr, unsigned s · 99 unmodified lines | ||
| 281 | 281 | ret = rtl9300_i2c_reg_addr_set(i2c, command, 1); |
| 282 | 282 | if (ret) |
| 283 | 283 | goto out_unlock; |
| 284 | − ret = rtl9300_i2c_config_xfer(i2c, chan, addr, data->block[0]); | |
| 284 | + if (data->block[0] < 1 || data->block[0] > I2C_SMBUS_BLOCK_MAX) { | |
| 285 | + ret = -EINVAL; | |
| 286 | + goto out_unlock; | |
| 287 | + } | |
| 288 | + ret = rtl9300_i2c_config_xfer(i2c, chan, addr, data->block[0] + 1); | |
| 285 | 289 | if (ret) |
| 286 | 290 | goto out_unlock; |
| 287 | 291 | if (read_write == I2C_SMBUS_WRITE) { |
| 288 | − ret = rtl9300_i2c_write(i2c, &data->block[1], data->block[0]); | |
| 292 | + ret = rtl9300_i2c_write(i2c, &data->block[0], data->block[0] + 1); | |
| 289 | 293 | if (ret) |
| 290 | 294 | goto out_unlock; |
| 291 | 295 | } |
| 292 | − len = data->block[0]; | |
| 296 | + len = data->block[0] + 1; | |
| 293 | 297 | break; |
| 294 | 298 | |
| 295 | 299 | default: |
| @@ -477,7 +477,7 @@ static irqreturn_t sca3300_trigger_handler(int irq, void *p) · 476 unmodified lines | ||
| 477 | 477 | struct iio_dev *indio_dev = pf->indio_dev; |
| 478 | 478 | struct sca3300_data *data = iio_priv(indio_dev); |
| 479 | 479 | int bit, ret, val, i = 0; |
| 480 | − IIO_DECLARE_BUFFER_WITH_TS(s16, channels, SCA3300_SCAN_MAX); | |
| 480 | + IIO_DECLARE_BUFFER_WITH_TS(s16, channels, SCA3300_SCAN_MAX) = { }; | |
| 481 | 481 | |
| 482 | 482 | iio_for_each_active_channel(indio_dev, bit) { |
| 483 | 483 | ret = sca3300_read_reg(data, indio_dev->channels[bit].address, &val); |
| @@ -1300,7 +1300,7 @@ config RN5T618_ADC · 1299 unmodified lines | ||
| 1300 | 1300 | |
| 1301 | 1301 | config ROHM_BD79124 |
| 1302 | 1302 | tristate "Rohm BD79124 ADC driver" |
| 1303 | − depends on I2C | |
| 1303 | + depends on I2C && GPIOLIB | |
| 1304 | 1304 | select REGMAP_I2C |
| 1305 | 1305 | select IIO_ADC_HELPER |
| 1306 | 1306 | help |
| @@ -849,7 +849,7 @@ enum { · 848 unmodified lines | ||
| 849 | 849 | static int ad7124_syscalib_locked(struct ad7124_state *st, const struct iio_chan_spec *chan) |
| 850 | 850 | { |
| 851 | 851 | struct device *dev = &st->sd.spi->dev; |
| 852 | − struct ad7124_channel *ch = &st->channels[chan->channel]; | |
| 852 | + struct ad7124_channel *ch = &st->channels[chan->address]; | |
| 853 | 853 | int ret; |
| 854 | 854 | |
| 855 | 855 | if (ch->syscalib_mode == AD7124_SYSCALIB_ZERO_SCALE) { |
| @@ -865,8 +865,8 @@ static int ad7124_syscalib_locked(struct ad7124_state *st, const struct iio_chan · 9 unmodified lines | ||
| 865 | 865 | if (ret < 0) |
| 866 | 866 | return ret; |
| 867 | 867 | |
| 868 | − dev_dbg(dev, "offset for channel %d after zero-scale calibration: 0x%x\n", | |
| 869 | − chan->channel, ch->cfg.calibration_offset); | |
| 868 | + dev_dbg(dev, "offset for channel %lu after zero-scale calibration: 0x%x\n", | |
| 869 | + chan->address, ch->cfg.calibration_offset); | |
| 870 | 870 | } else { |
| 871 | 871 | ch->cfg.calibration_gain = st->gain_default; |
| 872 | 872 | |
| @@ -880,8 +880,8 @@ static int ad7124_syscalib_locked(struct ad7124_state *st, const struct iio_chan · 7 unmodified lines | ||
| 880 | 880 | if (ret < 0) |
| 881 | 881 | return ret; |
| 882 | 882 | |
| 883 | − dev_dbg(dev, "gain for channel %d after full-scale calibration: 0x%x\n", | |
| 884 | − chan->channel, ch->cfg.calibration_gain); | |
| 883 | + dev_dbg(dev, "gain for channel %lu after full-scale calibration: 0x%x\n", | |
| 884 | + chan->address, ch->cfg.calibration_gain); | |
| 885 | 885 | } |
| 886 | 886 | |
| 887 | 887 | return 0; |
| @@ -924,7 +924,7 @@ static int ad7124_set_syscalib_mode(struct iio_dev *indio_dev, · 36 unmodified lines | ||
| 924 | 924 | { |
| 925 | 925 | struct ad7124_state *st = iio_priv(indio_dev); |
| 926 | 926 | |
| 927 | − st->channels[chan->channel].syscalib_mode = mode; | |
| 927 | + st->channels[chan->address].syscalib_mode = mode; | |
| 928 | 928 | |
| 929 | 929 | return 0; |
| 930 | 930 | } |
| @@ -934,7 +934,7 @@ static int ad7124_get_syscalib_mode(struct iio_dev *indio_dev, · 3 unmodified lines | ||
| 934 | 934 | { |
| 935 | 935 | struct ad7124_state *st = iio_priv(indio_dev); |
| 936 | 936 | |
| 937 | − return st->channels[chan->channel].syscalib_mode; | |
| 937 | + return st->channels[chan->address].syscalib_mode; | |
| 938 | 938 | } |
| 939 | 939 | |
| 940 | 940 | static const struct iio_enum ad7124_syscalib_mode_enum = { |
| @@ -200,7 +200,7 @@ struct ad7173_channel_config { · 199 unmodified lines | ||
| 200 | 200 | /* |
| 201 | 201 | * Following fields are used to compare equality. If you |
| 202 | 202 | * make adaptations in it, you most likely also have to adapt |
| 203 | − * ad7173_find_live_config(), too. | |
| 203 | + * ad7173_is_setup_equal(), too. | |
| 204 | 204 | */ |
| 205 | 205 | struct_group(config_props, |
| 206 | 206 | bool bipolar; |
| @@ -561,12 +561,19 @@ static void ad7173_reset_usage_cnts(struct ad7173_state *st) · 354 unmodified lines | ||
| 561 | 561 | st->config_usage_counter = 0; |
| 562 | 562 | } |
| 563 | 563 | |
| 564 | −static struct ad7173_channel_config * | |
| 565 | −ad7173_find_live_config(struct ad7173_state *st, struct ad7173_channel_config *cfg) | |
| 564 | +/** | |
| 565 | + * ad7173_is_setup_equal - Compare two channel setups | |
| 566 | + * @cfg1: First channel configuration | |
| 567 | + * @cfg2: Second channel configuration | |
| 568 | + * | |
| 569 | + * Compares all configuration options that affect the registers connected to | |
| 570 | + * SETUP_SEL, namely CONFIGx, FILTERx, GAINx and OFFSETx. | |
| 571 | + * | |
| 572 | + * Returns: true if the setups are identical, false otherwise | |
| 573 | + */ | |
| 574 | +static bool ad7173_is_setup_equal(const struct ad7173_channel_config *cfg1, | |
| 575 | + const struct ad7173_channel_config *cfg2) | |
| 566 | 576 | { |
| 567 | − struct ad7173_channel_config *cfg_aux; | |
| 568 | − int i; | |
| 569 | − | |
| 570 | 577 | /* |
| 571 | 578 | * This is just to make sure that the comparison is adapted after |
| 572 | 579 | * struct ad7173_channel_config was changed. |
| @@ -579,14 +586,22 @@ ad7173_find_live_config(struct ad7173_state *st, struct ad7173_channel_config *c · 6 unmodified lines | ||
| 579 | 586 | u8 ref_sel; |
| 580 | 587 | })); |
| 581 | 588 | |
| 589 | + return cfg1->bipolar == cfg2->bipolar && | |
| 590 | + cfg1->input_buf == cfg2->input_buf && | |
| 591 | + cfg1->odr == cfg2->odr && | |
| 592 | + cfg1->ref_sel == cfg2->ref_sel; | |
| 593 | +} | |
| 594 | + | |
| 595 | +static struct ad7173_channel_config * | |
| 596 | +ad7173_find_live_config(struct ad7173_state *st, struct ad7173_channel_config *cfg) | |
| 597 | +{ | |
| 598 | + struct ad7173_channel_config *cfg_aux; | |
| 599 | + int i; | |
| 600 | + | |
| 582 | 601 | for (i = 0; i < st->num_channels; i++) { |
| 583 | 602 | cfg_aux = &st->channels[i].cfg; |
| 584 | 603 | |
| 585 | − if (cfg_aux->live && | |
| 586 | − cfg->bipolar == cfg_aux->bipolar && | |
| 587 | − cfg->input_buf == cfg_aux->input_buf && | |
| 588 | − cfg->odr == cfg_aux->odr && | |
| 589 | − cfg->ref_sel == cfg_aux->ref_sel) | |
| 604 | + if (cfg_aux->live && ad7173_is_setup_equal(cfg, cfg_aux)) | |
| 590 | 605 | return cfg_aux; |
| 591 | 606 | } |
| 592 | 607 | return NULL; |
| @@ -1228,7 +1243,7 @@ static int ad7173_update_scan_mode(struct iio_dev *indio_dev, · 635 unmodified lines | ||
| 1228 | 1243 | const unsigned long *scan_mask) |
| 1229 | 1244 | { |
| 1230 | 1245 | struct ad7173_state *st = iio_priv(indio_dev); |
| 1231 | − int i, ret; | |
| 1246 | + int i, j, k, ret; | |
| 1232 | 1247 | |
| 1233 | 1248 | for (i = 0; i < indio_dev->num_channels; i++) { |
| 1234 | 1249 | if (test_bit(i, scan_mask)) |
| @@ -1239,6 +1254,54 @@ static int ad7173_update_scan_mode(struct iio_dev *indio_dev, · 4 unmodified lines | ||
| 1239 | 1254 | return ret; |
| 1240 | 1255 | } |
| 1241 | 1256 | |
| 1257 | + /* | |
| 1258 | + * On some chips, there are more channels that setups, so if there were | |
| 1259 | + * more unique setups requested than the number of available slots, | |
| 1260 | + * ad7173_set_channel() will have written over some of the slots. We | |
| 1261 | + * can detect this by making sure each assigned cfg_slot matches the | |
| 1262 | + * requested configuration. If it doesn't, we know that the slot was | |
| 1263 | + * overwritten by a different channel. | |
| 1264 | + */ | |
| 1265 | + for_each_set_bit(i, scan_mask, indio_dev->num_channels) { | |
| 1266 | + const struct ad7173_channel_config *cfg1, *cfg2; | |
| 1267 | + | |
| 1268 | + cfg1 = &st->channels[i].cfg; | |
| 1269 | + | |
| 1270 | + for_each_set_bit(j, scan_mask, indio_dev->num_channels) { | |
| 1271 | + cfg2 = &st->channels[j].cfg; | |
| 1272 | + | |
| 1273 | + /* | |
| 1274 | + * Only compare configs that are assigned to the same | |
| 1275 | + * SETUP_SEL slot and don't compare channel to itself. | |
| 1276 | + */ | |
| 1277 | + if (i == j || cfg1->cfg_slot != cfg2->cfg_slot) | |
| 1278 | + continue; | |
| 1279 | + | |
| 1280 | + /* | |
| 1281 | + * If we find two different configs trying to use the | |
| 1282 | + * same SETUP_SEL slot, then we know that the that we | |
| 1283 | + * have too many unique configurations requested for | |
| 1284 | + * the available slots and at least one was overwritten. | |
| 1285 | + */ | |
| 1286 | + if (!ad7173_is_setup_equal(cfg1, cfg2)) { | |
| 1287 | + /* | |
| 1288 | + * At this point, there isn't a way to tell | |
| 1289 | + * which setups are actually programmed in the | |
| 1290 | + * ADC anymore, so we could read them back to | |
| 1291 | + * see, but it is simpler to just turn off all | |
| 1292 | + * of the live flags so that everything gets | |
| 1293 | + * reprogramed on the next attempt read a sample. | |
| 1294 | + */ | |
| 1295 | + for (k = 0; k < st->num_channels; k++) | |
| 1296 | + st->channels[k].cfg.live = false; | |
| 1297 | + | |
| 1298 | + dev_err(&st->sd.spi->dev, | |
| 1299 | + "Too many unique channel configurations requested for scan\n"); | |
| 1300 | + return -EINVAL; | |
| 1301 | + } | |
| 1302 | + } | |
| 1303 | + } | |
| 1304 | + | |
| 1242 | 1305 | return 0; |
| 1243 | 1306 | } |
| 1244 | 1307 | |
| @@ -873,6 +873,7 @@ static const struct ad7380_chip_info adaq4381_4_chip_info = { · 872 unmodified lines | ||
| 873 | 873 | .has_hardware_gain = true, |
| 874 | 874 | .available_scan_masks = ad7380_4_channel_scan_masks, |
| 875 | 875 | .timing_specs = &ad7380_4_timing, |
| 876 | + .max_conversion_rate_hz = 4 * MEGA, | |
| 876 | 877 | }; |
| 877 | 878 | |
| 878 | 879 | static const struct spi_offload_config ad7380_offload_config = { |
| @@ -89,7 +89,6 @@ struct rzg2l_adc { · 88 unmodified lines | ||
| 89 | 89 | struct completion completion; |
| 90 | 90 | struct mutex lock; |
| 91 | 91 | u16 last_val[RZG2L_ADC_MAX_CHANNELS]; |
| 92 | − bool was_rpm_active; | |
| 93 | 92 | }; |
| 94 | 93 | |
| 95 | 94 | /** |
| @@ -428,6 +427,8 @@ static int rzg2l_adc_probe(struct platform_device *pdev) · 332 unmodified lines | ||
| 428 | 427 | if (!indio_dev) |
| 429 | 428 | return -ENOMEM; |
| 430 | 429 | |
| 430 | + platform_set_drvdata(pdev, indio_dev); | |
| 431 | + | |
| 431 | 432 | adc = iio_priv(indio_dev); |
| 432 | 433 | |
| 433 | 434 | adc->hw_params = device_get_match_data(dev); |
| @@ -460,8 +461,6 @@ static int rzg2l_adc_probe(struct platform_device *pdev) · 26 unmodified lines | ||
| 460 | 461 | if (ret) |
| 461 | 462 | return ret; |
| 462 | 463 | |
| 463 | − platform_set_drvdata(pdev, indio_dev); | |
| 464 | − | |
| 465 | 464 | ret = rzg2l_adc_hw_init(dev, adc); |
| 466 | 465 | if (ret) |
| 467 | 466 | return dev_err_probe(&pdev->dev, ret, |
| @@ -541,14 +540,9 @@ static int rzg2l_adc_suspend(struct device *dev) · 73 unmodified lines | ||
| 541 | 540 | }; |
| 542 | 541 | int ret; |
| 543 | 542 | |
| 544 | − if (pm_runtime_suspended(dev)) { | |
| 545 | − adc->was_rpm_active = false; | |
| 546 | − } else { | |
| 547 | − ret = pm_runtime_force_suspend(dev); | |
| 548 | − if (ret) | |
| 549 | − return ret; | |
| 550 | − adc->was_rpm_active = true; | |
| 551 | − } | |
| 543 | + ret = pm_runtime_force_suspend(dev); | |
| 544 | + if (ret) | |
| 545 | + return ret; | |
| 552 | 546 | |
| 553 | 547 | ret = reset_control_bulk_assert(ARRAY_SIZE(resets), resets); |
| 554 | 548 | if (ret) |
| @@ -557,9 +551,7 @@ static int rzg2l_adc_suspend(struct device *dev) · 2 unmodified lines | ||
| 557 | 551 | return 0; |
| 558 | 552 | |
| 559 | 553 | rpm_restore: |
| 560 | − if (adc->was_rpm_active) | |
| 561 | − pm_runtime_force_resume(dev); | |
| 562 | − | |
| 554 | + pm_runtime_force_resume(dev); | |
| 563 | 555 | return ret; |
| 564 | 556 | } |
| 565 | 557 | |
| @@ -577,11 +569,9 @@ static int rzg2l_adc_resume(struct device *dev) · 11 unmodified lines | ||
| 577 | 569 | if (ret) |
| 578 | 570 | return ret; |
| 579 | 571 | |
| 580 | − if (adc->was_rpm_active) { | |
| 581 | − ret = pm_runtime_force_resume(dev); | |
| 582 | − if (ret) | |
| 583 | − goto resets_restore; | |
| 584 | − } | |
| 572 | + ret = pm_runtime_force_resume(dev); | |
| 573 | + if (ret) | |
| 574 | + goto resets_restore; | |
| 585 | 575 | |
| 586 | 576 | ret = rzg2l_adc_hw_init(dev, adc); |
| 587 | 577 | if (ret) |
| @@ -590,10 +580,7 @@ static int rzg2l_adc_resume(struct device *dev) · 2 unmodified lines | ||
| 590 | 580 | return 0; |
| 591 | 581 | |
| 592 | 582 | rpm_restore: |
| 593 | − if (adc->was_rpm_active) { | |
| 594 | − pm_runtime_mark_last_busy(dev); | |
| 595 | − pm_runtime_put_autosuspend(dev); | |
| 596 | − } | |
| 583 | + pm_runtime_force_suspend(dev); | |
| 597 | 584 | resets_restore: |
| 598 | 585 | reset_control_bulk_assert(ARRAY_SIZE(resets), resets); |
| 599 | 586 | return ret; |
| @@ -32,8 +32,12 @@ static int inv_icm42600_temp_read(struct inv_icm42600_state *st, s16 *temp) · 31 unmodified lines | ||
| 32 | 32 | goto exit; |
| 33 | 33 | |
| 34 | 34 | *temp = (s16)be16_to_cpup(raw); |
| 35 | + /* | |
| 36 | + * Temperature data is invalid if both accel and gyro are off. | |
| 37 | + * Return -EBUSY in this case. | |
| 38 | + */ | |
| 35 | 39 | if (*temp == INV_ICM42600_DATA_INVALID) |
| 36 | − ret = -EINVAL; | |
| 40 | + ret = -EBUSY; | |
| 37 | 41 | |
| 38 | 42 | exit: |
| 39 | 43 | mutex_unlock(&st->lock); |
| @@ -639,7 +639,7 @@ static irqreturn_t as73211_trigger_handler(int irq __always_unused, void *p) · 638 unmodified lines | ||
| 639 | 639 | struct { |
| 640 | 640 | __le16 chan[4]; |
| 641 | 641 | aligned_s64 ts; |
| 642 | − } scan; | |
| 642 | + } scan = { }; | |
| 643 | 643 | int data_result, ret; |
| 644 | 644 | |
| 645 | 645 | mutex_lock(&data->mutex); |
| @@ -3213,11 +3213,12 @@ int bmp280_common_probe(struct device *dev, · 3212 unmodified lines | ||
| 3213 | 3213 | |
| 3214 | 3214 | /* Bring chip out of reset if there is an assigned GPIO line */ |
| 3215 | 3215 | gpiod = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH); |
| 3216 | + if (IS_ERR(gpiod)) | |
| 3217 | + return dev_err_probe(dev, PTR_ERR(gpiod), "failed to get reset GPIO\n"); | |
| 3218 | + | |
| 3216 | 3219 | /* Deassert the signal */ |
| 3217 | − if (gpiod) { | |
| 3218 | − dev_info(dev, "release reset\n"); | |
| 3219 | − gpiod_set_value(gpiod, 0); | |
| 3220 | − } | |
| 3220 | + dev_info(dev, "release reset\n"); | |
| 3221 | + gpiod_set_value(gpiod, 0); | |
| 3221 | 3222 | |
| 3222 | 3223 | data->regmap = regmap; |
| 3223 | 3224 | |
| @@ -938,12 +938,18 @@ static irqreturn_t isl29501_trigger_handler(int irq, void *p) · 937 unmodified lines | ||
| 938 | 938 | struct iio_dev *indio_dev = pf->indio_dev; |
| 939 | 939 | struct isl29501_private *isl29501 = iio_priv(indio_dev); |
| 940 | 940 | const unsigned long *active_mask = indio_dev->active_scan_mask; |
| 941 | − u32 buffer[4] __aligned(8) = {}; /* 1x16-bit + naturally aligned ts */ | |
| 942 | − | |
| 943 | − if (test_bit(ISL29501_DISTANCE_SCAN_INDEX, active_mask)) | |
| 944 | − isl29501_register_read(isl29501, REG_DISTANCE, buffer); | |
| 941 | + u32 value; | |
| 942 | + struct { | |
| 943 | + u16 data; | |
| 944 | + aligned_s64 ts; | |
| 945 | + } scan = { }; | |
| 946 | + | |
| 947 | + if (test_bit(ISL29501_DISTANCE_SCAN_INDEX, active_mask)) { | |
| 948 | + isl29501_register_read(isl29501, REG_DISTANCE, &value); | |
| 949 | + scan.data = value; | |
| 950 | + } | |
| 945 | 951 | |
| 946 | − iio_push_to_buffers_with_timestamp(indio_dev, buffer, pf->timestamp); | |
| 952 | + iio_push_to_buffers_with_timestamp(indio_dev, &scan, pf->timestamp); | |
| 947 | 953 | iio_trigger_notify_done(indio_dev->trig); |
| 948 | 954 | |
| 949 | 955 | return IRQ_HANDLED; |
| @@ -11,6 +11,7 @@ · 10 unmodified lines | ||
| 11 | 11 | #include <linux/module.h> |
| 12 | 12 | #include <linux/err.h> |
| 13 | 13 | #include <linux/spi/spi.h> |
| 14 | +#include <linux/types.h> | |
| 14 | 15 | #include <linux/iio/iio.h> |
| 15 | 16 | #include <linux/iio/sysfs.h> |
| 16 | 17 | #include <linux/iio/trigger.h> |
| @@ -121,8 +122,15 @@ struct maxim_thermocouple_data { · 104 unmodified lines | ||
| 121 | 122 | struct spi_device *spi; |
| 122 | 123 | const struct maxim_thermocouple_chip *chip; |
| 123 | 124 | char tc_type; |
| 124 | − | |
| 125 | − u8 buffer[16] __aligned(IIO_DMA_MINALIGN); | |
| 125 | + /* Buffer for reading up to 2 hardware channels. */ | |
| 126 | + struct { | |
| 127 | + union { | |
| 128 | + __be16 raw16; | |
| 129 | + __be32 raw32; | |
| 130 | + __be16 raw[2]; | |
| 131 | + }; | |
| 132 | + aligned_s64 timestamp; | |
| 133 | + } buffer __aligned(IIO_DMA_MINALIGN); | |
| 126 | 134 | }; |
| 127 | 135 | |
| 128 | 136 | static int maxim_thermocouple_read(struct maxim_thermocouple_data *data, |
| @@ -130,18 +138,16 @@ static int maxim_thermocouple_read(struct maxim_thermocouple_data *data, · 1 unmodified line | ||
| 130 | 138 | { |
| 131 | 139 | unsigned int storage_bytes = data->chip->read_size; |
| 132 | 140 | unsigned int shift = chan->scan_type.shift + (chan->address * 8); |
| 133 | − __be16 buf16; | |
| 134 | − __be32 buf32; | |
| 135 | 141 | int ret; |
| 136 | 142 | |
| 137 | 143 | switch (storage_bytes) { |
| 138 | 144 | case 2: |
| 139 | − ret = spi_read(data->spi, (void *)&buf16, storage_bytes); | |
| 140 | − *val = be16_to_cpu(buf16); | |
| 145 | + ret = spi_read(data->spi, &data->buffer.raw16, storage_bytes); | |
| 146 | + *val = be16_to_cpu(data->buffer.raw16); | |
| 141 | 147 | break; |
| 142 | 148 | case 4: |
| 143 | − ret = spi_read(data->spi, (void *)&buf32, storage_bytes); | |
| 144 | − *val = be32_to_cpu(buf32); | |
| 149 | + ret = spi_read(data->spi, &data->buffer.raw32, storage_bytes); | |
| 150 | + *val = be32_to_cpu(data->buffer.raw32); | |
| 145 | 151 | break; |
| 146 | 152 | default: |
| 147 | 153 | ret = -EINVAL; |
| @@ -166,9 +172,9 @@ static irqreturn_t maxim_thermocouple_trigger_handler(int irq, void *private) · 18 unmodified lines | ||
| 166 | 172 | struct maxim_thermocouple_data *data = iio_priv(indio_dev); |
| 167 | 173 | int ret; |
| 168 | 174 | |
| 169 | − ret = spi_read(data->spi, data->buffer, data->chip->read_size); | |
| 175 | + ret = spi_read(data->spi, data->buffer.raw, data->chip->read_size); | |
| 170 | 176 | if (!ret) { |
| 171 | − iio_push_to_buffers_with_ts(indio_dev, data->buffer, | |
| 177 | + iio_push_to_buffers_with_ts(indio_dev, &data->buffer, | |
| 172 | 178 | sizeof(data->buffer), |
| 173 | 179 | iio_get_time_ns(indio_dev)); |
| 174 | 180 | } |
| @@ -115,7 +115,7 @@ static int ib_init_umem_odp(struct ib_umem_odp *umem_odp, · 114 unmodified lines | ||
| 115 | 115 | |
| 116 | 116 | out_free_map: |
| 117 | 117 | if (ib_uses_virt_dma(dev)) |
| 118 | − kfree(map->pfn_list); | |
| 118 | + kvfree(map->pfn_list); | |
| 119 | 119 | else |
| 120 | 120 | hmm_dma_map_free(dev->dma_device, map); |
| 121 | 121 | return ret; |
| @@ -287,7 +287,7 @@ static void ib_umem_odp_free(struct ib_umem_odp *umem_odp) · 165 unmodified lines | ||
| 287 | 287 | mutex_unlock(&umem_odp->umem_mutex); |
| 288 | 288 | mmu_interval_notifier_remove(&umem_odp->notifier); |
| 289 | 289 | if (ib_uses_virt_dma(dev)) |
| 290 | − kfree(umem_odp->map.pfn_list); | |
| 290 | + kvfree(umem_odp->map.pfn_list); | |
| 291 | 291 | else |
| 292 | 292 | hmm_dma_map_free(dev->dma_device, &umem_odp->map); |
| 293 | 293 | } |
| @@ -1921,7 +1921,6 @@ int bnxt_re_modify_srq(struct ib_srq *ib_srq, struct ib_srq_attr *srq_attr, · 1920 unmodified lines | ||
| 1921 | 1921 | struct bnxt_re_srq *srq = container_of(ib_srq, struct bnxt_re_srq, |
| 1922 | 1922 | ib_srq); |
| 1923 | 1923 | struct bnxt_re_dev *rdev = srq->rdev; |
| 1924 | − int rc; | |
| 1925 | 1924 | |
| 1926 | 1925 | switch (srq_attr_mask) { |
| 1927 | 1926 | case IB_SRQ_MAX_WR: |
| @@ -1933,11 +1932,8 @@ int bnxt_re_modify_srq(struct ib_srq *ib_srq, struct ib_srq_attr *srq_attr, · 5 unmodified lines | ||
| 1933 | 1932 | return -EINVAL; |
| 1934 | 1933 | |
| 1935 | 1934 | srq->qplib_srq.threshold = srq_attr->srq_limit; |
| 1936 | − rc = bnxt_qplib_modify_srq(&rdev->qplib_res, &srq->qplib_srq); | |
| 1937 | − if (rc) { | |
| 1938 | − ibdev_err(&rdev->ibdev, "Modify HW SRQ failed!"); | |
| 1939 | − return rc; | |
| 1940 | − } | |
| 1935 | + bnxt_qplib_srq_arm_db(&srq->qplib_srq.dbinfo, srq->qplib_srq.threshold); | |
| 1936 | + | |
| 1941 | 1937 | /* On success, update the shadow */ |
| 1942 | 1938 | srq->srq_limit = srq_attr->srq_limit; |
| 1943 | 1939 | /* No need to Build and send response back to udata */ |
| @@ -2017,6 +2017,28 @@ static void bnxt_re_free_nqr_mem(struct bnxt_re_dev *rdev) · 2016 unmodified lines | ||
| 2017 | 2017 | rdev->nqr = NULL; |
| 2018 | 2018 | } |
| 2019 | 2019 | |
| 2020 | +/* When DEL_GID fails, driver is not freeing GID ctx memory. | |
| 2021 | + * To avoid the memory leak, free the memory during unload | |
| 2022 | + */ | |
| 2023 | +static void bnxt_re_free_gid_ctx(struct bnxt_re_dev *rdev) | |
| 2024 | +{ | |
| 2025 | + struct bnxt_qplib_sgid_tbl *sgid_tbl = &rdev->qplib_res.sgid_tbl; | |
| 2026 | + struct bnxt_re_gid_ctx *ctx, **ctx_tbl; | |
| 2027 | + int i; | |
| 2028 | + | |
| 2029 | + if (!sgid_tbl->active) | |
| 2030 | + return; | |
| 2031 | + | |
| 2032 | + ctx_tbl = sgid_tbl->ctx; | |
| 2033 | + for (i = 0; i < sgid_tbl->max; i++) { | |
| 2034 | + if (sgid_tbl->hw_id[i] == 0xFFFF) | |
| 2035 | + continue; | |
| 2036 | + | |
| 2037 | + ctx = ctx_tbl[i]; | |
| 2038 | + kfree(ctx); | |
| 2039 | + } | |
| 2040 | +} | |
| 2041 | + | |
| 2020 | 2042 | static void bnxt_re_dev_uninit(struct bnxt_re_dev *rdev, u8 op_type) |
| 2021 | 2043 | { |
| 2022 | 2044 | u8 type; |
| @@ -2030,6 +2052,7 @@ static void bnxt_re_dev_uninit(struct bnxt_re_dev *rdev, u8 op_type) · 7 unmodified lines | ||
| 2030 | 2052 | if (test_and_clear_bit(BNXT_RE_FLAG_QOS_WORK_REG, &rdev->flags)) |
| 2031 | 2053 | cancel_delayed_work_sync(&rdev->worker); |
| 2032 | 2054 | |
| 2055 | + bnxt_re_free_gid_ctx(rdev); | |
| 2033 | 2056 | if (test_and_clear_bit(BNXT_RE_FLAG_RESOURCES_INITIALIZED, |
| 2034 | 2057 | &rdev->flags)) |
| 2035 | 2058 | bnxt_re_cleanup_res(rdev); |
| @@ -705,9 +705,7 @@ int bnxt_qplib_create_srq(struct bnxt_qplib_res *res, · 704 unmodified lines | ||
| 705 | 705 | srq->dbinfo.db = srq->dpi->dbr; |
| 706 | 706 | srq->dbinfo.max_slot = 1; |
| 707 | 707 | srq->dbinfo.priv_db = res->dpi_tbl.priv_db; |
| 708 | − if (srq->threshold) | |
| 709 | − bnxt_qplib_armen_db(&srq->dbinfo, DBC_DBC_TYPE_SRQ_ARMENA); | |
| 710 | − srq->arm_req = false; | |
| 708 | + bnxt_qplib_armen_db(&srq->dbinfo, DBC_DBC_TYPE_SRQ_ARMENA); | |
| 711 | 709 | |
| 712 | 710 | return 0; |
| 713 | 711 | fail: |
| @@ -717,24 +715,6 @@ fail: · 3 unmodified lines | ||
| 717 | 715 | return rc; |
| 718 | 716 | } |
| 719 | 717 | |
| 720 | −int bnxt_qplib_modify_srq(struct bnxt_qplib_res *res, | |
| 721 | − struct bnxt_qplib_srq *srq) | |
| 722 | −{ | |
| 723 | − struct bnxt_qplib_hwq *srq_hwq = &srq->hwq; | |
| 724 | − u32 count; | |
| 725 | − | |
| 726 | − count = __bnxt_qplib_get_avail(srq_hwq); | |
| 727 | − if (count > srq->threshold) { | |
| 728 | − srq->arm_req = false; | |
| 729 | − bnxt_qplib_srq_arm_db(&srq->dbinfo, srq->threshold); | |
| 730 | − } else { | |
| 731 | − /* Deferred arming */ | |
| 732 | − srq->arm_req = true; | |
| 733 | − } | |
| 734 | − | |
| 735 | − return 0; | |
| 736 | −} | |
| 737 | − | |
| 738 | 718 | int bnxt_qplib_query_srq(struct bnxt_qplib_res *res, |
| 739 | 719 | struct bnxt_qplib_srq *srq) |
| 740 | 720 | { |
| @@ -776,7 +756,6 @@ int bnxt_qplib_post_srq_recv(struct bnxt_qplib_srq *srq, · 35 unmodified lines | ||
| 776 | 756 | struct bnxt_qplib_hwq *srq_hwq = &srq->hwq; |
| 777 | 757 | struct rq_wqe *srqe; |
| 778 | 758 | struct sq_sge *hw_sge; |
| 779 | − u32 count = 0; | |
| 780 | 759 | int i, next; |
| 781 | 760 | |
| 782 | 761 | spin_lock(&srq_hwq->lock); |
| @@ -808,15 +787,8 @@ int bnxt_qplib_post_srq_recv(struct bnxt_qplib_srq *srq, · 25 unmodified lines | ||
| 808 | 787 | |
| 809 | 788 | bnxt_qplib_hwq_incr_prod(&srq->dbinfo, srq_hwq, srq->dbinfo.max_slot); |
| 810 | 789 | |
| 811 | − spin_lock(&srq_hwq->lock); | |
| 812 | − count = __bnxt_qplib_get_avail(srq_hwq); | |
| 813 | − spin_unlock(&srq_hwq->lock); | |
| 814 | 790 | /* Ring DB */ |
| 815 | 791 | bnxt_qplib_ring_prod_db(&srq->dbinfo, DBC_DBC_TYPE_SRQ); |
| 816 | − if (srq->arm_req == true && count > srq->threshold) { | |
| 817 | − srq->arm_req = false; | |
| 818 | − bnxt_qplib_srq_arm_db(&srq->dbinfo, srq->threshold); | |
| 819 | − } | |
| 820 | 792 | |
| 821 | 793 | return 0; |
| 822 | 794 | } |
| @@ -546,8 +546,6 @@ int bnxt_qplib_enable_nq(struct pci_dev *pdev, struct bnxt_qplib_nq *nq, · 545 unmodified lines | ||
| 546 | 546 | srqn_handler_t srq_handler); |
| 547 | 547 | int bnxt_qplib_create_srq(struct bnxt_qplib_res *res, |
| 548 | 548 | struct bnxt_qplib_srq *srq); |
| 549 | −int bnxt_qplib_modify_srq(struct bnxt_qplib_res *res, | |
| 550 | − struct bnxt_qplib_srq *srq); | |
| 551 | 549 | int bnxt_qplib_query_srq(struct bnxt_qplib_res *res, |
| 552 | 550 | struct bnxt_qplib_srq *srq); |
| 553 | 551 | void bnxt_qplib_destroy_srq(struct bnxt_qplib_res *res, |
| @@ -121,6 +121,7 @@ static int __alloc_pbl(struct bnxt_qplib_res *res, · 120 unmodified lines | ||
| 121 | 121 | pbl->pg_arr = vmalloc_array(pages, sizeof(void *)); |
| 122 | 122 | if (!pbl->pg_arr) |
| 123 | 123 | return -ENOMEM; |
| 124 | + memset(pbl->pg_arr, 0, pages * sizeof(void *)); | |
| 124 | 125 | |
| 125 | 126 | pbl->pg_map_arr = vmalloc_array(pages, sizeof(dma_addr_t)); |
| 126 | 127 | if (!pbl->pg_map_arr) { |
| @@ -128,6 +129,7 @@ static int __alloc_pbl(struct bnxt_qplib_res *res, · 1 unmodified line | ||
| 128 | 129 | pbl->pg_arr = NULL; |
| 129 | 130 | return -ENOMEM; |
| 130 | 131 | } |
| 132 | + memset(pbl->pg_map_arr, 0, pages * sizeof(dma_addr_t)); | |
| 131 | 133 | pbl->pg_count = 0; |
| 132 | 134 | pbl->pg_size = sginfo->pgsize; |
| 133 | 135 | |
| @@ -994,6 +994,8 @@ int erdma_create_qp(struct ib_qp *ibqp, struct ib_qp_init_attr *attrs, · 993 unmodified lines | ||
| 994 | 994 | old_entry = xa_store(&dev->qp_xa, 1, qp, GFP_KERNEL); |
| 995 | 995 | if (xa_is_err(old_entry)) |
| 996 | 996 | ret = xa_err(old_entry); |
| 997 | + else | |
| 998 | + qp->ibqp.qp_num = 1; | |
| 997 | 999 | } else { |
| 998 | 1000 | ret = xa_alloc_cyclic(&dev->qp_xa, &qp->ibqp.qp_num, qp, |
| 999 | 1001 | XA_LIMIT(1, dev->attrs.max_qp - 1), |
| @@ -1031,7 +1033,9 @@ int erdma_create_qp(struct ib_qp *ibqp, struct ib_qp_init_attr *attrs, · 31 unmodified lines | ||
| 1031 | 1033 | if (ret) |
| 1032 | 1034 | goto err_out_cmd; |
| 1033 | 1035 | } else { |
| 1034 | − init_kernel_qp(dev, qp, attrs); | |
| 1036 | + ret = init_kernel_qp(dev, qp, attrs); | |
| 1037 | + if (ret) | |
| 1038 | + goto err_out_xa; | |
| 1035 | 1039 | } |
| 1036 | 1040 | |
| 1037 | 1041 | qp->attrs.max_send_sge = attrs->cap.max_send_sge; |
| @@ -3043,7 +3043,7 @@ static void hns_roce_v2_exit(struct hns_roce_dev *hr_dev) · 3042 unmodified lines | ||
| 3043 | 3043 | if (!hr_dev->is_vf) |
| 3044 | 3044 | hns_roce_free_link_table(hr_dev); |
| 3045 | 3045 | |
| 3046 | − if (hr_dev->pci_dev->revision == PCI_REVISION_ID_HIP09) | |
| 3046 | + if (hr_dev->pci_dev->revision >= PCI_REVISION_ID_HIP09) | |
| 3047 | 3047 | free_dip_entry(hr_dev); |
| 3048 | 3048 | } |
| 3049 | 3049 | |
| @@ -5476,7 +5476,7 @@ out: · 2426 unmodified lines | ||
| 5476 | 5476 | return ret; |
| 5477 | 5477 | } |
| 5478 | 5478 | |
| 5479 | −static int hns_roce_v2_query_sccc(struct hns_roce_dev *hr_dev, u32 qpn, | |
| 5479 | +static int hns_roce_v2_query_sccc(struct hns_roce_dev *hr_dev, u32 sccn, | |
| 5480 | 5480 | void *buffer) |
| 5481 | 5481 | { |
| 5482 | 5482 | struct hns_roce_v2_scc_context *context; |
| @@ -5488,7 +5488,7 @@ static int hns_roce_v2_query_sccc(struct hns_roce_dev *hr_dev, u32 qpn, · 5 unmodified lines | ||
| 5488 | 5488 | return PTR_ERR(mailbox); |
| 5489 | 5489 | |
| 5490 | 5490 | ret = hns_roce_cmd_mbox(hr_dev, 0, mailbox->dma, HNS_ROCE_CMD_QUERY_SCCC, |
| 5491 | − qpn); | |
| 5491 | + sccn); | |
| 5492 | 5492 | if (ret) |
| 5493 | 5493 | goto out; |
| 5494 | 5494 | |
| @@ -100,6 +100,7 @@ int hns_roce_fill_res_qp_entry_raw(struct sk_buff *msg, struct ib_qp *ib_qp) · 99 unmodified lines | ||
| 100 | 100 | struct hns_roce_v2_qp_context qpc; |
| 101 | 101 | struct hns_roce_v2_scc_context sccc; |
| 102 | 102 | } context = {}; |
| 103 | + u32 sccn = hr_qp->qpn; | |
| 103 | 104 | int ret; |
| 104 | 105 | |
| 105 | 106 | if (!hr_dev->hw->query_qpc) |
| @@ -116,7 +117,13 @@ int hns_roce_fill_res_qp_entry_raw(struct sk_buff *msg, struct ib_qp *ib_qp) · 10 unmodified lines | ||
| 116 | 117 | !hr_dev->hw->query_sccc) |
| 117 | 118 | goto out; |
| 118 | 119 | |
| 119 | − ret = hr_dev->hw->query_sccc(hr_dev, hr_qp->qpn, &context.sccc); | |
| 120 | + if (hr_qp->cong_type == CONG_TYPE_DIP) { | |
| 121 | + if (!hr_qp->dip) | |
| 122 | + goto out; | |
| 123 | + sccn = hr_qp->dip->dip_idx; | |
| 124 | + } | |
| 125 | + | |
| 126 | + ret = hr_dev->hw->query_sccc(hr_dev, sccn, &context.sccc); | |
| 120 | 127 | if (ret) |
| 121 | 128 | ibdev_warn_ratelimited(&hr_dev->ib_dev, |
| 122 | 129 | "failed to query SCCC, ret = %d.\n", |
| @@ -345,33 +345,15 @@ int rxe_prepare(struct rxe_av *av, struct rxe_pkt_info *pkt, · 344 unmodified lines | ||
| 345 | 345 | |
| 346 | 346 | static void rxe_skb_tx_dtor(struct sk_buff *skb) |
| 347 | 347 | { |
| 348 | − struct net_device *ndev = skb->dev; | |
| 349 | − struct rxe_dev *rxe; | |
| 350 | − unsigned int qp_index; | |
| 351 | − struct rxe_qp *qp; | |
| 348 | + struct rxe_qp *qp = skb->sk->sk_user_data; | |
| 352 | 349 | int skb_out; |
| 353 | 350 | |
| 354 | − rxe = rxe_get_dev_from_net(ndev); | |
| 355 | − if (!rxe && is_vlan_dev(ndev)) | |
| 356 | − rxe = rxe_get_dev_from_net(vlan_dev_real_dev(ndev)); | |
| 357 | − if (WARN_ON(!rxe)) | |
| 358 | − return; | |
| 359 | − | |
| 360 | − qp_index = (int)(uintptr_t)skb->sk->sk_user_data; | |
| 361 | − if (!qp_index) | |
| 362 | − return; | |
| 363 | − | |
| 364 | − qp = rxe_pool_get_index(&rxe->qp_pool, qp_index); | |
| 365 | − if (!qp) | |
| 366 | − goto put_dev; | |
| 367 | − | |
| 368 | 351 | skb_out = atomic_dec_return(&qp->skb_out); |
| 369 | − if (qp->need_req_skb && skb_out < RXE_INFLIGHT_SKBS_PER_QP_LOW) | |
| 352 | + if (unlikely(qp->need_req_skb && | |
| 353 | + skb_out < RXE_INFLIGHT_SKBS_PER_QP_LOW)) | |
| 370 | 354 | rxe_sched_task(&qp->send_task); |
| 371 | 355 | |
| 372 | 356 | rxe_put(qp); |
| 373 | −put_dev: | |
| 374 | − ib_device_put(&rxe->ib_dev); | |
| 375 | 357 | sock_put(skb->sk); |
| 376 | 358 | } |
| 377 | 359 | |
| @@ -383,6 +365,7 @@ static int rxe_send(struct sk_buff *skb, struct rxe_pkt_info *pkt) · 5 unmodified lines | ||
| 383 | 365 | sock_hold(sk); |
| 384 | 366 | skb->sk = sk; |
| 385 | 367 | skb->destructor = rxe_skb_tx_dtor; |
| 368 | + rxe_get(pkt->qp); | |
| 386 | 369 | atomic_inc(&pkt->qp->skb_out); |
| 387 | 370 | |
| 388 | 371 | if (skb->protocol == htons(ETH_P_IP)) |
| @@ -405,6 +388,7 @@ static int rxe_loopback(struct sk_buff *skb, struct rxe_pkt_info *pkt) · 16 unmodified lines | ||
| 405 | 388 | sock_hold(sk); |
| 406 | 389 | skb->sk = sk; |
| 407 | 390 | skb->destructor = rxe_skb_tx_dtor; |
| 391 | + rxe_get(pkt->qp); | |
| 408 | 392 | atomic_inc(&pkt->qp->skb_out); |
| 409 | 393 | |
| 410 | 394 | if (skb->protocol == htons(ETH_P_IP)) |
| @@ -497,6 +481,9 @@ struct sk_buff *rxe_init_packet(struct rxe_dev *rxe, struct rxe_av *av, · 86 unmodified lines | ||
| 497 | 481 | goto out; |
| 498 | 482 | } |
| 499 | 483 | |
| 484 | + /* Add time stamp to skb. */ | |
| 485 | + skb->tstamp = ktime_get(); | |
| 486 | + | |
| 500 | 487 | skb_reserve(skb, hdr_len + LL_RESERVED_SPACE(ndev)); |
| 501 | 488 | |
| 502 | 489 | /* FIXME: hold reference to this netdev until life of this skb. */ |
| @@ -244,7 +244,7 @@ static int rxe_qp_init_req(struct rxe_dev *rxe, struct rxe_qp *qp, · 243 unmodified lines | ||
| 244 | 244 | err = sock_create_kern(&init_net, AF_INET, SOCK_DGRAM, 0, &qp->sk); |
| 245 | 245 | if (err < 0) |
| 246 | 246 | return err; |
| 247 | − qp->sk->sk->sk_user_data = (void *)(uintptr_t)qp->elem.index; | |
| 247 | + qp->sk->sk->sk_user_data = qp; | |
| 248 | 248 | |
| 249 | 249 | /* pick a source UDP port number for this QP based on |
| 250 | 250 | * the source QPN. this spreads traffic for different QPs |
| @@ -3638,7 +3638,7 @@ static int __init parse_ivrs_acpihid(char *str) · 3637 unmodified lines | ||
| 3638 | 3638 | { |
| 3639 | 3639 | u32 seg = 0, bus, dev, fn; |
| 3640 | 3640 | char *hid, *uid, *p, *addr; |
| 3641 | − char acpiid[ACPIID_LEN] = {0}; | |
| 3641 | + char acpiid[ACPIID_LEN + 1] = { }; /* size with NULL terminator */ | |
| 3642 | 3642 | int i; |
| 3643 | 3643 | |
| 3644 | 3644 | addr = strchr(str, '@'); |
| @@ -3664,7 +3664,7 @@ static int __init parse_ivrs_acpihid(char *str) · 19 unmodified lines | ||
| 3664 | 3664 | /* We have the '@', make it the terminator to get just the acpiid */ |
| 3665 | 3665 | *addr++ = 0; |
| 3666 | 3666 | |
| 3667 | − if (strlen(str) > ACPIID_LEN + 1) | |
| 3667 | + if (strlen(str) > ACPIID_LEN) | |
| 3668 | 3668 | goto not_found; |
| 3669 | 3669 | |
| 3670 | 3670 | if (sscanf(str, "=%s", acpiid) != 1) |
| @@ -2997,9 +2997,9 @@ void arm_smmu_attach_commit(struct arm_smmu_attach_state *state) · 2996 unmodified lines | ||
| 2997 | 2997 | /* ATS is being switched off, invalidate the entire ATC */ |
| 2998 | 2998 | arm_smmu_atc_inv_master(master, IOMMU_NO_PASID); |
| 2999 | 2999 | } |
| 3000 | − master->ats_enabled = state->ats_enabled; | |
| 3001 | 3000 | |
| 3002 | 3001 | arm_smmu_remove_master_domain(master, state->old_domain, state->ssid); |
| 3002 | + master->ats_enabled = state->ats_enabled; | |
| 3003 | 3003 | } |
| 3004 | 3004 | |
| 3005 | 3005 | static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev) |
| @@ -301,9 +301,11 @@ static void tegra241_vintf_user_handle_error(struct tegra241_vintf *vintf) · 300 unmodified lines | ||
| 301 | 301 | struct iommu_vevent_tegra241_cmdqv vevent_data; |
| 302 | 302 | int i; |
| 303 | 303 | |
| 304 | − for (i = 0; i < LVCMDQ_ERR_MAP_NUM_64; i++) | |
| 305 | − vevent_data.lvcmdq_err_map[i] = | |
| 306 | − readq_relaxed(REG_VINTF(vintf, LVCMDQ_ERR_MAP_64(i))); | |
| 304 | + for (i = 0; i < LVCMDQ_ERR_MAP_NUM_64; i++) { | |
| 305 | + u64 err = readq_relaxed(REG_VINTF(vintf, LVCMDQ_ERR_MAP_64(i))); | |
| 306 | + | |
| 307 | + vevent_data.lvcmdq_err_map[i] = cpu_to_le64(err); | |
| 308 | + } | |
| 307 | 309 | |
| 308 | 310 | iommufd_viommu_report_event(viommu, IOMMU_VEVENTQ_TYPE_TEGRA241_CMDQV, |
| 309 | 311 | &vevent_data, sizeof(vevent_data)); |
| @@ -339,7 +339,7 @@ iommufd_hw_queue_alloc_phys(struct iommu_hw_queue_alloc *cmd, · 338 unmodified lines | ||
| 339 | 339 | } |
| 340 | 340 | |
| 341 | 341 | *base_pa = (page_to_pfn(pages[0]) << PAGE_SHIFT) + offset; |
| 342 | − kfree(pages); | |
| 342 | + kvfree(pages); | |
| 343 | 343 | return access; |
| 344 | 344 | |
| 345 | 345 | out_unpin: |
| @@ -349,7 +349,7 @@ out_detach: · 3 unmodified lines | ||
| 349 | 349 | out_destroy: |
| 350 | 350 | iommufd_access_destroy_internal(viommu->ictx, access); |
| 351 | 351 | out_free: |
| 352 | − kfree(pages); | |
| 352 | + kvfree(pages); | |
| 353 | 353 | return ERR_PTR(rc); |
| 354 | 354 | } |
| 355 | 355 | |
| @@ -1283,7 +1283,7 @@ static phys_addr_t riscv_iommu_iova_to_phys(struct iommu_domain *iommu_domain, · 1282 unmodified lines | ||
| 1283 | 1283 | unsigned long *ptr; |
| 1284 | 1284 | |
| 1285 | 1285 | ptr = riscv_iommu_pte_fetch(domain, iova, &pte_size); |
| 1286 | − if (_io_pte_none(*ptr) || !_io_pte_present(*ptr)) | |
| 1286 | + if (!ptr) | |
| 1287 | 1287 | return 0; |
| 1288 | 1288 | |
| 1289 | 1289 | return pfn_to_phys(__page_val_to_pfn(*ptr)) | (iova & (pte_size - 1)); |
| @@ -998,8 +998,7 @@ static void viommu_get_resv_regions(struct device *dev, struct list_head *head) · 997 unmodified lines | ||
| 998 | 998 | iommu_dma_get_resv_regions(dev, head); |
| 999 | 999 | } |
| 1000 | 1000 | |
| 1001 | −static const struct iommu_ops viommu_ops; | |
| 1002 | −static struct virtio_driver virtio_iommu_drv; | |
| 1001 | +static const struct bus_type *virtio_bus_type; | |
| 1003 | 1002 | |
| 1004 | 1003 | static int viommu_match_node(struct device *dev, const void *data) |
| 1005 | 1004 | { |
| @@ -1008,8 +1007,9 @@ static int viommu_match_node(struct device *dev, const void *data) · 2 unmodified lines | ||
| 1008 | 1007 | |
| 1009 | 1008 | static struct viommu_dev *viommu_get_by_fwnode(struct fwnode_handle *fwnode) |
| 1010 | 1009 | { |
| 1011 | − struct device *dev = driver_find_device(&virtio_iommu_drv.driver, NULL, | |
| 1012 | − fwnode, viommu_match_node); | |
| 1010 | + struct device *dev = bus_find_device(virtio_bus_type, NULL, fwnode, | |
| 1011 | + viommu_match_node); | |
| 1012 | + | |
| 1013 | 1013 | put_device(dev); |
| 1014 | 1014 | |
| 1015 | 1015 | return dev ? dev_to_virtio(dev)->priv : NULL; |
| @@ -1160,6 +1160,9 @@ static int viommu_probe(struct virtio_device *vdev) · 144 unmodified lines | ||
| 1160 | 1160 | if (!viommu) |
| 1161 | 1161 | return -ENOMEM; |
| 1162 | 1162 | |
| 1163 | + /* Borrow this for easy lookups later */ | |
| 1164 | + virtio_bus_type = dev->bus; | |
| 1165 | + | |
| 1163 | 1166 | spin_lock_init(&viommu->request_lock); |
| 1164 | 1167 | ida_init(&viommu->domain_ids); |
| 1165 | 1168 | viommu->dev = dev; |
| @@ -1229,10 +1232,10 @@ static int viommu_probe(struct virtio_device *vdev) · 63 unmodified lines | ||
| 1229 | 1232 | if (ret) |
| 1230 | 1233 | goto err_free_vqs; |
| 1231 | 1234 | |
| 1232 | − iommu_device_register(&viommu->iommu, &viommu_ops, parent_dev); | |
| 1233 | − | |
| 1234 | 1235 | vdev->priv = viommu; |
| 1235 | 1236 | |
| 1237 | + iommu_device_register(&viommu->iommu, &viommu_ops, parent_dev); | |
| 1238 | + | |
| 1236 | 1239 | dev_info(dev, "input address: %u bits\n", |
| 1237 | 1240 | order_base_2(viommu->geometry.aperture_end)); |
| 1238 | 1241 | dev_info(dev, "page mask: %#llx\n", viommu->pgsize_bitmap); |
| @@ -339,6 +339,7 @@ static int start_readonly; · 338 unmodified lines | ||
| 339 | 339 | * so all the races disappear. |
| 340 | 340 | */ |
| 341 | 341 | static bool create_on_open = true; |
| 342 | +static bool legacy_async_del_gendisk = true; | |
| 342 | 343 | |
| 343 | 344 | /* |
| 344 | 345 | * We have a system wide 'event count' that is incremented |
| @@ -877,15 +878,18 @@ void mddev_unlock(struct mddev *mddev) · 532 unmodified lines | ||
| 877 | 878 | export_rdev(rdev, mddev); |
| 878 | 879 | } |
| 879 | 880 | |
| 880 | − /* Call del_gendisk after release reconfig_mutex to avoid | |
| 881 | − * deadlock (e.g. call del_gendisk under the lock and an | |
| 882 | − * access to sysfs files waits the lock) | |
| 883 | − * And MD_DELETED is only used for md raid which is set in | |
| 884 | − * do_md_stop. dm raid only uses md_stop to stop. So dm raid | |
| 885 | − * doesn't need to check MD_DELETED when getting reconfig lock | |
| 886 | − */ | |
| 887 | − if (test_bit(MD_DELETED, &mddev->flags)) | |
| 888 | − del_gendisk(mddev->gendisk); | |
| 881 | + if (!legacy_async_del_gendisk) { | |
| 882 | + /* | |
| 883 | + * Call del_gendisk after release reconfig_mutex to avoid | |
| 884 | + * deadlock (e.g. call del_gendisk under the lock and an | |
| 885 | + * access to sysfs files waits the lock) | |
| 886 | + * And MD_DELETED is only used for md raid which is set in | |
| 887 | + * do_md_stop. dm raid only uses md_stop to stop. So dm raid | |
| 888 | + * doesn't need to check MD_DELETED when getting reconfig lock | |
| 889 | + */ | |
| 890 | + if (test_bit(MD_DELETED, &mddev->flags)) | |
| 891 | + del_gendisk(mddev->gendisk); | |
| 892 | + } | |
| 889 | 893 | } |
| 890 | 894 | EXPORT_SYMBOL_GPL(mddev_unlock); |
| 891 | 895 | |
| @@ -1419,7 +1423,7 @@ static int super_90_validate(struct mddev *mddev, struct md_rdev *freshest, stru · 527 unmodified lines | ||
| 1419 | 1423 | else { |
| 1420 | 1424 | if (sb->events_hi == sb->cp_events_hi && |
| 1421 | 1425 | sb->events_lo == sb->cp_events_lo) { |
| 1422 | − mddev->resync_offset = sb->resync_offset; | |
| 1426 | + mddev->resync_offset = sb->recovery_cp; | |
| 1423 | 1427 | } else |
| 1424 | 1428 | mddev->resync_offset = 0; |
| 1425 | 1429 | } |
| @@ -1547,13 +1551,13 @@ static void super_90_sync(struct mddev *mddev, struct md_rdev *rdev) · 121 unmodified lines | ||
| 1547 | 1551 | mddev->minor_version = sb->minor_version; |
| 1548 | 1552 | if (mddev->in_sync) |
| 1549 | 1553 | { |
| 1550 | − sb->resync_offset = mddev->resync_offset; | |
| 1554 | + sb->recovery_cp = mddev->resync_offset; | |
| 1551 | 1555 | sb->cp_events_hi = (mddev->events>>32); |
| 1552 | 1556 | sb->cp_events_lo = (u32)mddev->events; |
| 1553 | 1557 | if (mddev->resync_offset == MaxSector) |
| 1554 | 1558 | sb->state = (1<< MD_SB_CLEAN); |
| 1555 | 1559 | } else |
| 1556 | − sb->resync_offset = 0; | |
| 1560 | + sb->recovery_cp = 0; | |
| 1557 | 1561 | |
| 1558 | 1562 | sb->layout = mddev->layout; |
| 1559 | 1563 | sb->chunk_size = mddev->chunk_sectors << 9; |
| @@ -4835,9 +4839,42 @@ out_unlock: · 3275 unmodified lines | ||
| 4835 | 4839 | static struct md_sysfs_entry md_metadata = |
| 4836 | 4840 | __ATTR_PREALLOC(metadata_version, S_IRUGO|S_IWUSR, metadata_show, metadata_store); |
| 4837 | 4841 | |
| 4842 | +static bool rdev_needs_recovery(struct md_rdev *rdev, sector_t sectors) | |
| 4843 | +{ | |
| 4844 | + return rdev->raid_disk >= 0 && | |
| 4845 | + !test_bit(Journal, &rdev->flags) && | |
| 4846 | + !test_bit(Faulty, &rdev->flags) && | |
| 4847 | + !test_bit(In_sync, &rdev->flags) && | |
| 4848 | + rdev->recovery_offset < sectors; | |
| 4849 | +} | |
| 4850 | + | |
| 4851 | +static enum sync_action md_get_active_sync_action(struct mddev *mddev) | |
| 4852 | +{ | |
| 4853 | + struct md_rdev *rdev; | |
| 4854 | + bool is_recover = false; | |
| 4855 | + | |
| 4856 | + if (mddev->resync_offset < MaxSector) | |
| 4857 | + return ACTION_RESYNC; | |
| 4858 | + | |
| 4859 | + if (mddev->reshape_position != MaxSector) | |
| 4860 | + return ACTION_RESHAPE; | |
| 4861 | + | |
| 4862 | + rcu_read_lock(); | |
| 4863 | + rdev_for_each_rcu(rdev, mddev) { | |
| 4864 | + if (rdev_needs_recovery(rdev, MaxSector)) { | |
| 4865 | + is_recover = true; | |
| 4866 | + break; | |
| 4867 | + } | |
| 4868 | + } | |
| 4869 | + rcu_read_unlock(); | |
| 4870 | + | |
| 4871 | + return is_recover ? ACTION_RECOVER : ACTION_IDLE; | |
| 4872 | +} | |
| 4873 | + | |
| 4838 | 4874 | enum sync_action md_sync_action(struct mddev *mddev) |
| 4839 | 4875 | { |
| 4840 | 4876 | unsigned long recovery = mddev->recovery; |
| 4877 | + enum sync_action active_action; | |
| 4841 | 4878 | |
| 4842 | 4879 | /* |
| 4843 | 4880 | * frozen has the highest priority, means running sync_thread will be |
| @@ -4861,8 +4898,17 @@ enum sync_action md_sync_action(struct mddev *mddev) · 17 unmodified lines | ||
| 4861 | 4898 | !test_bit(MD_RECOVERY_NEEDED, &recovery)) |
| 4862 | 4899 | return ACTION_IDLE; |
| 4863 | 4900 | |
| 4864 | − if (test_bit(MD_RECOVERY_RESHAPE, &recovery) || | |
| 4865 | − mddev->reshape_position != MaxSector) | |
| 4901 | + /* | |
| 4902 | + * Check if any sync operation (resync/recover/reshape) is | |
| 4903 | + * currently active. This ensures that only one sync operation | |
| 4904 | + * can run at a time. Returns the type of active operation, or | |
| 4905 | + * ACTION_IDLE if none are active. | |
| 4906 | + */ | |
| 4907 | + active_action = md_get_active_sync_action(mddev); | |
| 4908 | + if (active_action != ACTION_IDLE) | |
| 4909 | + return active_action; | |
| 4910 | + | |
| 4911 | + if (test_bit(MD_RECOVERY_RESHAPE, &recovery)) | |
| 4866 | 4912 | return ACTION_RESHAPE; |
| 4867 | 4913 | |
| 4868 | 4914 | if (test_bit(MD_RECOVERY_RECOVER, &recovery)) |
| @@ -5818,6 +5864,13 @@ static void md_kobj_release(struct kobject *ko) · 949 unmodified lines | ||
| 5818 | 5864 | { |
| 5819 | 5865 | struct mddev *mddev = container_of(ko, struct mddev, kobj); |
| 5820 | 5866 | |
| 5867 | + if (legacy_async_del_gendisk) { | |
| 5868 | + if (mddev->sysfs_state) | |
| 5869 | + sysfs_put(mddev->sysfs_state); | |
| 5870 | + if (mddev->sysfs_level) | |
| 5871 | + sysfs_put(mddev->sysfs_level); | |
| 5872 | + del_gendisk(mddev->gendisk); | |
| 5873 | + } | |
| 5821 | 5874 | put_disk(mddev->gendisk); |
| 5822 | 5875 | } |
| 5823 | 5876 | |
| @@ -6021,6 +6074,9 @@ static int md_alloc_and_put(dev_t dev, char *name) · 197 unmodified lines | ||
| 6021 | 6074 | { |
| 6022 | 6075 | struct mddev *mddev = md_alloc(dev, name); |
| 6023 | 6076 | |
| 6077 | + if (legacy_async_del_gendisk) | |
| 6078 | + pr_warn("md: async del_gendisk mode will be removed in future, please upgrade to mdadm-4.5+\n"); | |
| 6079 | + | |
| 6024 | 6080 | if (IS_ERR(mddev)) |
| 6025 | 6081 | return PTR_ERR(mddev); |
| 6026 | 6082 | mddev_put(mddev); |
| @@ -6431,10 +6487,22 @@ static void md_clean(struct mddev *mddev) · 404 unmodified lines | ||
| 6431 | 6487 | mddev->persistent = 0; |
| 6432 | 6488 | mddev->level = LEVEL_NONE; |
| 6433 | 6489 | mddev->clevel[0] = 0; |
| 6434 | − /* if UNTIL_STOP is set, it's cleared here */ | |
| 6435 | − mddev->hold_active = 0; | |
| 6436 | − /* Don't clear MD_CLOSING, or mddev can be opened again. */ | |
| 6437 | − mddev->flags &= BIT_ULL_MASK(MD_CLOSING); | |
| 6490 | + | |
| 6491 | + /* | |
| 6492 | + * For legacy_async_del_gendisk mode, it can stop the array in the | |
| 6493 | + * middle of assembling it, then it still can access the array. So | |
| 6494 | + * it needs to clear MD_CLOSING. If not legacy_async_del_gendisk, | |
| 6495 | + * it can't open the array again after stopping it. So it doesn't | |
| 6496 | + * clear MD_CLOSING. | |
| 6497 | + */ | |
| 6498 | + if (legacy_async_del_gendisk && mddev->hold_active) { | |
| 6499 | + clear_bit(MD_CLOSING, &mddev->flags); | |
| 6500 | + } else { | |
| 6501 | + /* if UNTIL_STOP is set, it's cleared here */ | |
| 6502 | + mddev->hold_active = 0; | |
| 6503 | + /* Don't clear MD_CLOSING, or mddev can be opened again. */ | |
| 6504 | + mddev->flags &= BIT_ULL_MASK(MD_CLOSING); | |
| 6505 | + } | |
| 6438 | 6506 | mddev->sb_flags = 0; |
| 6439 | 6507 | mddev->ro = MD_RDWR; |
| 6440 | 6508 | mddev->metadata_type[0] = 0; |
| @@ -6658,7 +6726,8 @@ static int do_md_stop(struct mddev *mddev, int mode) · 217 unmodified lines | ||
| 6658 | 6726 | |
| 6659 | 6727 | export_array(mddev); |
| 6660 | 6728 | md_clean(mddev); |
| 6661 | − set_bit(MD_DELETED, &mddev->flags); | |
| 6729 | + if (!legacy_async_del_gendisk) | |
| 6730 | + set_bit(MD_DELETED, &mddev->flags); | |
| 6662 | 6731 | } |
| 6663 | 6732 | md_new_event(); |
| 6664 | 6733 | sysfs_notify_dirent_safe(mddev->sysfs_state); |
| @@ -8968,11 +9037,7 @@ static sector_t md_sync_position(struct mddev *mddev, enum sync_action action) · 2303 unmodified lines | ||
| 8968 | 9037 | start = MaxSector; |
| 8969 | 9038 | rcu_read_lock(); |
| 8970 | 9039 | rdev_for_each_rcu(rdev, mddev) |
| 8971 | − if (rdev->raid_disk >= 0 && | |
| 8972 | − !test_bit(Journal, &rdev->flags) && | |
| 8973 | − !test_bit(Faulty, &rdev->flags) && | |
| 8974 | − !test_bit(In_sync, &rdev->flags) && | |
| 8975 | − rdev->recovery_offset < start) | |
| 9040 | + if (rdev_needs_recovery(rdev, start)) | |
| 8976 | 9041 | start = rdev->recovery_offset; |
| 8977 | 9042 | rcu_read_unlock(); |
| 8978 | 9043 | |
| @@ -9331,12 +9396,8 @@ void md_do_sync(struct md_thread *thread) · 352 unmodified lines | ||
| 9331 | 9396 | test_bit(MD_RECOVERY_RECOVER, &mddev->recovery)) { |
| 9332 | 9397 | rcu_read_lock(); |
| 9333 | 9398 | rdev_for_each_rcu(rdev, mddev) |
| 9334 | − if (rdev->raid_disk >= 0 && | |
| 9335 | − mddev->delta_disks >= 0 && | |
| 9336 | − !test_bit(Journal, &rdev->flags) && | |
| 9337 | − !test_bit(Faulty, &rdev->flags) && | |
| 9338 | − !test_bit(In_sync, &rdev->flags) && | |
| 9339 | − rdev->recovery_offset < mddev->curr_resync) | |
| 9399 | + if (mddev->delta_disks >= 0 && | |
| 9400 | + rdev_needs_recovery(rdev, mddev->curr_resync)) | |
| 9340 | 9401 | rdev->recovery_offset = mddev->curr_resync; |
| 9341 | 9402 | rcu_read_unlock(); |
| 9342 | 9403 | } |
| @@ -10392,6 +10453,7 @@ module_param_call(start_ro, set_ro, get_ro, NULL, S_IRUSR|S_IWUSR); · 1049 unmodified lines | ||
| 10392 | 10453 | module_param(start_dirty_degraded, int, S_IRUGO|S_IWUSR); |
| 10393 | 10454 | module_param_call(new_array, add_named_array, NULL, NULL, S_IWUSR); |
| 10394 | 10455 | module_param(create_on_open, bool, S_IRUSR|S_IWUSR); |
| 10456 | +module_param(legacy_async_del_gendisk, bool, 0600); | |
| 10395 | 10457 | |
| 10396 | 10458 | MODULE_LICENSE("GPL"); |
| 10397 | 10459 | MODULE_DESCRIPTION("MD RAID framework"); |
| @@ -555,7 +555,6 @@ EXPORT_SYMBOL(memstick_add_host); · 554 unmodified lines | ||
| 555 | 555 | */ |
| 556 | 556 | void memstick_remove_host(struct memstick_host *host) |
| 557 | 557 | { |
| 558 | − host->removing = 1; | |
| 559 | 558 | flush_workqueue(workqueue); |
| 560 | 559 | mutex_lock(&host->lock); |
| 561 | 560 | if (host->card) |
| @@ -812,6 +812,7 @@ static void rtsx_usb_ms_drv_remove(struct platform_device *pdev) · 811 unmodified lines | ||
| 812 | 812 | int err; |
| 813 | 813 | |
| 814 | 814 | host->eject = true; |
| 815 | + msh->removing = true; | |
| 815 | 816 | cancel_work_sync(&host->handle_req); |
| 816 | 817 | cancel_delayed_work_sync(&host->poll_card); |
| 817 | 818 | |
| @@ -99,6 +99,9 @@ · 98 unmodified lines | ||
| 99 | 99 | #define HIWORD_UPDATE(val, mask, shift) \ |
| 100 | 100 | ((val) << (shift) | (mask) << ((shift) + 16)) |
| 101 | 101 | |
| 102 | +#define CD_STABLE_TIMEOUT_US 1000000 | |
| 103 | +#define CD_STABLE_MAX_SLEEP_US 10 | |
| 104 | + | |
| 102 | 105 | /** |
| 103 | 106 | * struct sdhci_arasan_soc_ctl_field - Field used in sdhci_arasan_soc_ctl_map |
| 104 | 107 | * |
| @@ -206,12 +209,15 @@ struct sdhci_arasan_data { · 101 unmodified lines | ||
| 206 | 209 | * 19MHz instead |
| 207 | 210 | */ |
| 208 | 211 | #define SDHCI_ARASAN_QUIRK_CLOCK_25_BROKEN BIT(2) |
| 212 | +/* Enable CD stable check before power-up */ | |
| 213 | +#define SDHCI_ARASAN_QUIRK_ENSURE_CD_STABLE BIT(3) | |
| 209 | 214 | }; |
| 210 | 215 | |
| 211 | 216 | struct sdhci_arasan_of_data { |
| 212 | 217 | const struct sdhci_arasan_soc_ctl_map *soc_ctl_map; |
| 213 | 218 | const struct sdhci_pltfm_data *pdata; |
| 214 | 219 | const struct sdhci_arasan_clk_ops *clk_ops; |
| 220 | + u32 quirks; | |
| 215 | 221 | }; |
| 216 | 222 | |
| 217 | 223 | static const struct sdhci_arasan_soc_ctl_map rk3399_soc_ctl_map = { |
| @@ -514,6 +520,24 @@ static int sdhci_arasan_voltage_switch(struct mmc_host *mmc, · 296 unmodified lines | ||
| 514 | 520 | return -EINVAL; |
| 515 | 521 | } |
| 516 | 522 | |
| 523 | +static void sdhci_arasan_set_power_and_bus_voltage(struct sdhci_host *host, unsigned char mode, | |
| 524 | + unsigned short vdd) | |
| 525 | +{ | |
| 526 | + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); | |
| 527 | + struct sdhci_arasan_data *sdhci_arasan = sdhci_pltfm_priv(pltfm_host); | |
| 528 | + u32 reg; | |
| 529 | + | |
| 530 | + /* | |
| 531 | + * Ensure that the card detect logic has stabilized before powering up, this is | |
| 532 | + * necessary after a host controller reset. | |
| 533 | + */ | |
| 534 | + if (mode == MMC_POWER_UP && sdhci_arasan->quirks & SDHCI_ARASAN_QUIRK_ENSURE_CD_STABLE) | |
| 535 | + read_poll_timeout(sdhci_readl, reg, reg & SDHCI_CD_STABLE, CD_STABLE_MAX_SLEEP_US, | |
| 536 | + CD_STABLE_TIMEOUT_US, false, host, SDHCI_PRESENT_STATE); | |
| 537 | + | |
| 538 | + sdhci_set_power_and_bus_voltage(host, mode, vdd); | |
| 539 | +} | |
| 540 | + | |
| 517 | 541 | static const struct sdhci_ops sdhci_arasan_ops = { |
| 518 | 542 | .set_clock = sdhci_arasan_set_clock, |
| 519 | 543 | .get_max_clock = sdhci_pltfm_clk_get_max_clock, |
| @@ -521,7 +545,7 @@ static const struct sdhci_ops sdhci_arasan_ops = { · 1 unmodified line | ||
| 521 | 545 | .set_bus_width = sdhci_set_bus_width, |
| 522 | 546 | .reset = sdhci_arasan_reset, |
| 523 | 547 | .set_uhs_signaling = sdhci_set_uhs_signaling, |
| 524 | − .set_power = sdhci_set_power_and_bus_voltage, | |
| 548 | + .set_power = sdhci_arasan_set_power_and_bus_voltage, | |
| 525 | 549 | .hw_reset = sdhci_arasan_hw_reset, |
| 526 | 550 | }; |
| 527 | 551 | |
| @@ -570,7 +594,7 @@ static const struct sdhci_ops sdhci_arasan_cqe_ops = { · 42 unmodified lines | ||
| 570 | 594 | .set_bus_width = sdhci_set_bus_width, |
| 571 | 595 | .reset = sdhci_arasan_reset, |
| 572 | 596 | .set_uhs_signaling = sdhci_set_uhs_signaling, |
| 573 | − .set_power = sdhci_set_power_and_bus_voltage, | |
| 597 | + .set_power = sdhci_arasan_set_power_and_bus_voltage, | |
| 574 | 598 | .irq = sdhci_arasan_cqhci_irq, |
| 575 | 599 | }; |
| 576 | 600 | |
| @@ -1447,6 +1471,7 @@ static const struct sdhci_arasan_clk_ops zynqmp_clk_ops = { · 870 unmodified lines | ||
| 1447 | 1471 | static struct sdhci_arasan_of_data sdhci_arasan_zynqmp_data = { |
| 1448 | 1472 | .pdata = &sdhci_arasan_zynqmp_pdata, |
| 1449 | 1473 | .clk_ops = &zynqmp_clk_ops, |
| 1474 | + .quirks = SDHCI_ARASAN_QUIRK_ENSURE_CD_STABLE, | |
| 1450 | 1475 | }; |
| 1451 | 1476 | |
| 1452 | 1477 | static const struct sdhci_arasan_clk_ops versal_clk_ops = { |
| @@ -1457,6 +1482,7 @@ static const struct sdhci_arasan_clk_ops versal_clk_ops = { · 4 unmodified lines | ||
| 1457 | 1482 | static struct sdhci_arasan_of_data sdhci_arasan_versal_data = { |
| 1458 | 1483 | .pdata = &sdhci_arasan_zynqmp_pdata, |
| 1459 | 1484 | .clk_ops = &versal_clk_ops, |
| 1485 | + .quirks = SDHCI_ARASAN_QUIRK_ENSURE_CD_STABLE, | |
| 1460 | 1486 | }; |
| 1461 | 1487 | |
| 1462 | 1488 | static const struct sdhci_arasan_clk_ops versal_net_clk_ops = { |
| @@ -1467,6 +1493,7 @@ static const struct sdhci_arasan_clk_ops versal_net_clk_ops = { · 4 unmodified lines | ||
| 1467 | 1493 | static struct sdhci_arasan_of_data sdhci_arasan_versal_net_data = { |
| 1468 | 1494 | .pdata = &sdhci_arasan_versal_net_pdata, |
| 1469 | 1495 | .clk_ops = &versal_net_clk_ops, |
| 1496 | + .quirks = SDHCI_ARASAN_QUIRK_ENSURE_CD_STABLE, | |
| 1470 | 1497 | }; |
| 1471 | 1498 | |
| 1472 | 1499 | static struct sdhci_arasan_of_data intel_keembay_emmc_data = { |
| @@ -1937,6 +1964,8 @@ static int sdhci_arasan_probe(struct platform_device *pdev) · 464 unmodified lines | ||
| 1937 | 1964 | if (of_device_is_compatible(np, "rockchip,rk3399-sdhci-5.1")) |
| 1938 | 1965 | sdhci_arasan_update_clockmultiplier(host, 0x0); |
| 1939 | 1966 | |
| 1967 | + sdhci_arasan->quirks |= data->quirks; | |
| 1968 | + | |
| 1940 | 1969 | if (of_device_is_compatible(np, "intel,keembay-sdhci-5.1-emmc") || |
| 1941 | 1970 | of_device_is_compatible(np, "intel,keembay-sdhci-5.1-sd") || |
| 1942 | 1971 | of_device_is_compatible(np, "intel,keembay-sdhci-5.1-sdio")) { |
| @@ -287,6 +287,20 @@ · 286 unmodified lines | ||
| 287 | 287 | #define GLI_MAX_TUNING_LOOP 40 |
| 288 | 288 | |
| 289 | 289 | /* Genesys Logic chipset */ |
| 290 | +static void sdhci_gli_mask_replay_timer_timeout(struct pci_dev *pdev) | |
| 291 | +{ | |
| 292 | + int aer; | |
| 293 | + u32 value; | |
| 294 | + | |
| 295 | + /* mask the replay timer timeout of AER */ | |
| 296 | + aer = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_ERR); | |
| 297 | + if (aer) { | |
| 298 | + pci_read_config_dword(pdev, aer + PCI_ERR_COR_MASK, &value); | |
| 299 | + value |= PCI_ERR_COR_REP_TIMER; | |
| 300 | + pci_write_config_dword(pdev, aer + PCI_ERR_COR_MASK, value); | |
| 301 | + } | |
| 302 | +} | |
| 303 | + | |
| 290 | 304 | static inline void gl9750_wt_on(struct sdhci_host *host) |
| 291 | 305 | { |
| 292 | 306 | u32 wt_value; |
| @@ -607,7 +621,6 @@ static void gl9750_hw_setting(struct sdhci_host *host) · 314 unmodified lines | ||
| 607 | 621 | { |
| 608 | 622 | struct sdhci_pci_slot *slot = sdhci_priv(host); |
| 609 | 623 | struct pci_dev *pdev; |
| 610 | − int aer; | |
| 611 | 624 | u32 value; |
| 612 | 625 | |
| 613 | 626 | pdev = slot->chip->pdev; |
| @@ -626,12 +639,7 @@ static void gl9750_hw_setting(struct sdhci_host *host) · 12 unmodified lines | ||
| 626 | 639 | pci_set_power_state(pdev, PCI_D0); |
| 627 | 640 | |
| 628 | 641 | /* mask the replay timer timeout of AER */ |
| 629 | − aer = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_ERR); | |
| 630 | − if (aer) { | |
| 631 | − pci_read_config_dword(pdev, aer + PCI_ERR_COR_MASK, &value); | |
| 632 | − value |= PCI_ERR_COR_REP_TIMER; | |
| 633 | − pci_write_config_dword(pdev, aer + PCI_ERR_COR_MASK, value); | |
| 634 | − } | |
| 642 | + sdhci_gli_mask_replay_timer_timeout(pdev); | |
| 635 | 643 | |
| 636 | 644 | gl9750_wt_off(host); |
| 637 | 645 | } |
| @@ -806,7 +814,6 @@ static void sdhci_gl9755_set_clock(struct sdhci_host *host, unsigned int clock) · 168 unmodified lines | ||
| 806 | 814 | static void gl9755_hw_setting(struct sdhci_pci_slot *slot) |
| 807 | 815 | { |
| 808 | 816 | struct pci_dev *pdev = slot->chip->pdev; |
| 809 | − int aer; | |
| 810 | 817 | u32 value; |
| 811 | 818 | |
| 812 | 819 | gl9755_wt_on(pdev); |
| @@ -841,12 +848,7 @@ static void gl9755_hw_setting(struct sdhci_pci_slot *slot) · 28 unmodified lines | ||
| 841 | 848 | pci_set_power_state(pdev, PCI_D0); |
| 842 | 849 | |
| 843 | 850 | /* mask the replay timer timeout of AER */ |
| 844 | − aer = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_ERR); | |
| 845 | − if (aer) { | |
| 846 | − pci_read_config_dword(pdev, aer + PCI_ERR_COR_MASK, &value); | |
| 847 | − value |= PCI_ERR_COR_REP_TIMER; | |
| 848 | − pci_write_config_dword(pdev, aer + PCI_ERR_COR_MASK, value); | |
| 849 | − } | |
| 851 | + sdhci_gli_mask_replay_timer_timeout(pdev); | |
| 850 | 852 | |
| 851 | 853 | gl9755_wt_off(pdev); |
| 852 | 854 | } |
| @@ -1751,7 +1753,7 @@ cleanup: · 898 unmodified lines | ||
| 1751 | 1753 | return ret; |
| 1752 | 1754 | } |
| 1753 | 1755 | |
| 1754 | −static void gli_set_gl9763e(struct sdhci_pci_slot *slot) | |
| 1756 | +static void gl9763e_hw_setting(struct sdhci_pci_slot *slot) | |
| 1755 | 1757 | { |
| 1756 | 1758 | struct pci_dev *pdev = slot->chip->pdev; |
| 1757 | 1759 | u32 value; |
| @@ -1780,6 +1782,9 @@ static void gli_set_gl9763e(struct sdhci_pci_slot *slot) · 22 unmodified lines | ||
| 1780 | 1782 | value |= FIELD_PREP(GLI_9763E_HS400_RXDLY, GLI_9763E_HS400_RXDLY_5); |
| 1781 | 1783 | pci_write_config_dword(pdev, PCIE_GLI_9763E_CLKRXDLY, value); |
| 1782 | 1784 | |
| 1785 | + /* mask the replay timer timeout of AER */ | |
| 1786 | + sdhci_gli_mask_replay_timer_timeout(pdev); | |
| 1787 | + | |
| 1783 | 1788 | pci_read_config_dword(pdev, PCIE_GLI_9763E_VHS, &value); |
| 1784 | 1789 | value &= ~GLI_9763E_VHS_REV; |
| 1785 | 1790 | value |= FIELD_PREP(GLI_9763E_VHS_REV, GLI_9763E_VHS_REV_R); |
| @@ -1923,7 +1928,7 @@ static int gli_probe_slot_gl9763e(struct sdhci_pci_slot *slot) · 137 unmodified lines | ||
| 1923 | 1928 | gli_pcie_enable_msi(slot); |
| 1924 | 1929 | host->mmc_host_ops.hs400_enhanced_strobe = |
| 1925 | 1930 | gl9763e_hs400_enhanced_strobe; |
| 1926 | − gli_set_gl9763e(slot); | |
| 1931 | + gl9763e_hw_setting(slot); | |
| 1927 | 1932 | sdhci_enable_v4_mode(host); |
| 1928 | 1933 | |
| 1929 | 1934 | return 0; |
| @@ -156,6 +156,7 @@ struct sdhci_am654_data { · 155 unmodified lines | ||
| 156 | 156 | |
| 157 | 157 | #define SDHCI_AM654_QUIRK_FORCE_CDTEST BIT(0) |
| 158 | 158 | #define SDHCI_AM654_QUIRK_SUPPRESS_V1P8_ENA BIT(1) |
| 159 | +#define SDHCI_AM654_QUIRK_DISABLE_HS400 BIT(2) | |
| 159 | 160 | }; |
| 160 | 161 | |
| 161 | 162 | struct window { |
| @@ -765,6 +766,7 @@ static int sdhci_am654_init(struct sdhci_host *host) · 603 unmodified lines | ||
| 765 | 766 | { |
| 766 | 767 | struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); |
| 767 | 768 | struct sdhci_am654_data *sdhci_am654 = sdhci_pltfm_priv(pltfm_host); |
| 769 | + struct device *dev = mmc_dev(host->mmc); | |
| 768 | 770 | u32 ctl_cfg_2 = 0; |
| 769 | 771 | u32 mask; |
| 770 | 772 | u32 val; |
| @@ -820,6 +822,12 @@ static int sdhci_am654_init(struct sdhci_host *host) · 49 unmodified lines | ||
| 820 | 822 | if (ret) |
| 821 | 823 | goto err_cleanup_host; |
| 822 | 824 | |
| 825 | + if (sdhci_am654->quirks & SDHCI_AM654_QUIRK_DISABLE_HS400 && | |
| 826 | + host->mmc->caps2 & (MMC_CAP2_HS400 | MMC_CAP2_HS400_ES)) { | |
| 827 | + dev_info(dev, "HS400 mode not supported on this silicon revision, disabling it\n"); | |
| 828 | + host->mmc->caps2 &= ~(MMC_CAP2_HS400 | MMC_CAP2_HS400_ES); | |
| 829 | + } | |
| 830 | + | |
| 823 | 831 | ret = __sdhci_add_host(host); |
| 824 | 832 | if (ret) |
| 825 | 833 | goto err_cleanup_host; |
| @@ -883,6 +891,12 @@ static int sdhci_am654_get_of_property(struct platform_device *pdev, · 57 unmodified lines | ||
| 883 | 891 | return 0; |
| 884 | 892 | } |
| 885 | 893 | |
| 894 | +static const struct soc_device_attribute sdhci_am654_descope_hs400[] = { | |
| 895 | + { .family = "AM62PX", .revision = "SR1.0" }, | |
| 896 | + { .family = "AM62PX", .revision = "SR1.1" }, | |
| 897 | + { /* sentinel */ } | |
| 898 | +}; | |
| 899 | + | |
| 886 | 900 | static const struct of_device_id sdhci_am654_of_match[] = { |
| 887 | 901 | { |
| 888 | 902 | .compatible = "ti,am654-sdhci-5.1", |
| @@ -970,6 +984,10 @@ static int sdhci_am654_probe(struct platform_device *pdev) · 81 unmodified lines | ||
| 970 | 984 | if (ret) |
| 971 | 985 | return dev_err_probe(dev, ret, "parsing dt failed\n"); |
| 972 | 986 | |
| 987 | + soc = soc_device_match(sdhci_am654_descope_hs400); | |
| 988 | + if (soc) | |
| 989 | + sdhci_am654->quirks |= SDHCI_AM654_QUIRK_DISABLE_HS400; | |
| 990 | + | |
| 973 | 991 | host->mmc_host_ops.start_signal_voltage_switch = sdhci_am654_start_signal_voltage_switch; |
| 974 | 992 | host->mmc_host_ops.execute_tuning = sdhci_am654_execute_tuning; |
| 975 | 993 | |
| @@ -538,8 +538,8 @@ static struct most_channel *get_channel(char *mdev, char *mdev_ch) · 537 unmodified lines | ||
| 538 | 538 | dev = bus_find_device_by_name(&mostbus, NULL, mdev); |
| 539 | 539 | if (!dev) |
| 540 | 540 | return NULL; |
| 541 | − put_device(dev); | |
| 542 | 541 | iface = dev_get_drvdata(dev); |
| 542 | + put_device(dev); | |
| 543 | 543 | list_for_each_entry_safe(c, tmp, &iface->p->channel_list, list) { |
| 544 | 544 | if (!strcmp(dev_name(&c->dev), mdev_ch)) |
| 545 | 545 | return c; |
| @@ -95,13 +95,13 @@ static int ad_marker_send(struct port *port, struct bond_marker *marker); · 94 unmodified lines | ||
| 95 | 95 | static void ad_mux_machine(struct port *port, bool *update_slave_arr); |
| 96 | 96 | static void ad_rx_machine(struct lacpdu *lacpdu, struct port *port); |
| 97 | 97 | static void ad_tx_machine(struct port *port); |
| 98 | −static void ad_periodic_machine(struct port *port, struct bond_params *bond_params); | |
| 98 | +static void ad_periodic_machine(struct port *port); | |
| 99 | 99 | static void ad_port_selection_logic(struct port *port, bool *update_slave_arr); |
| 100 | 100 | static void ad_agg_selection_logic(struct aggregator *aggregator, |
| 101 | 101 | bool *update_slave_arr); |
| 102 | 102 | static void ad_clear_agg(struct aggregator *aggregator); |
| 103 | 103 | static void ad_initialize_agg(struct aggregator *aggregator); |
| 104 | −static void ad_initialize_port(struct port *port, int lacp_fast); | |
| 104 | +static void ad_initialize_port(struct port *port, const struct bond_params *bond_params); | |
| 105 | 105 | static void ad_enable_collecting(struct port *port); |
| 106 | 106 | static void ad_disable_distributing(struct port *port, |
| 107 | 107 | bool *update_slave_arr); |
| @@ -1307,10 +1307,16 @@ static void ad_rx_machine(struct lacpdu *lacpdu, struct port *port) · 1199 unmodified lines | ||
| 1307 | 1307 | * case of EXPIRED even if LINK_DOWN didn't arrive for |
| 1308 | 1308 | * the port. |
| 1309 | 1309 | */ |
| 1310 | − port->partner_oper.port_state &= ~LACP_STATE_SYNCHRONIZATION; | |
| 1311 | 1310 | port->sm_vars &= ~AD_PORT_MATCHED; |
| 1311 | + /* Based on IEEE 8021AX-2014, Figure 6-18 - Receive | |
| 1312 | + * machine state diagram, the statue should be | |
| 1313 | + * Partner_Oper_Port_State.Synchronization = FALSE; | |
| 1314 | + * Partner_Oper_Port_State.LACP_Timeout = Short Timeout; | |
| 1315 | + * start current_while_timer(Short Timeout); | |
| 1316 | + * Actor_Oper_Port_State.Expired = TRUE; | |
| 1317 | + */ | |
| 1318 | + port->partner_oper.port_state &= ~LACP_STATE_SYNCHRONIZATION; | |
| 1312 | 1319 | port->partner_oper.port_state |= LACP_STATE_LACP_TIMEOUT; |
| 1313 | − port->partner_oper.port_state |= LACP_STATE_LACP_ACTIVITY; | |
| 1314 | 1320 | port->sm_rx_timer_counter = __ad_timer_to_ticks(AD_CURRENT_WHILE_TIMER, (u16)(AD_SHORT_TIMEOUT)); |
| 1315 | 1321 | port->actor_oper_port_state |= LACP_STATE_EXPIRED; |
| 1316 | 1322 | port->sm_vars |= AD_PORT_CHURNED; |
| @@ -1417,11 +1423,10 @@ static void ad_tx_machine(struct port *port) · 100 unmodified lines | ||
| 1417 | 1423 | /** |
| 1418 | 1424 | * ad_periodic_machine - handle a port's periodic state machine |
| 1419 | 1425 | * @port: the port we're looking at |
| 1420 | − * @bond_params: bond parameters we will use | |
| 1421 | 1426 | * |
| 1422 | 1427 | * Turn ntt flag on priodically to perform periodic transmission of lacpdu's. |
| 1423 | 1428 | */ |
| 1424 | −static void ad_periodic_machine(struct port *port, struct bond_params *bond_params) | |
| 1429 | +static void ad_periodic_machine(struct port *port) | |
| 1425 | 1430 | { |
| 1426 | 1431 | periodic_states_t last_state; |
| 1427 | 1432 | |
| @@ -1430,8 +1435,7 @@ static void ad_periodic_machine(struct port *port, struct bond_params *bond_para · 2 unmodified lines | ||
| 1430 | 1435 | |
| 1431 | 1436 | /* check if port was reinitialized */ |
| 1432 | 1437 | if (((port->sm_vars & AD_PORT_BEGIN) || !(port->sm_vars & AD_PORT_LACP_ENABLED) || !port->is_enabled) || |
| 1433 | − (!(port->actor_oper_port_state & LACP_STATE_LACP_ACTIVITY) && !(port->partner_oper.port_state & LACP_STATE_LACP_ACTIVITY)) || | |
| 1434 | − !bond_params->lacp_active) { | |
| 1438 | + (!(port->actor_oper_port_state & LACP_STATE_LACP_ACTIVITY) && !(port->partner_oper.port_state & LACP_STATE_LACP_ACTIVITY))) { | |
| 1435 | 1439 | port->sm_periodic_state = AD_NO_PERIODIC; |
| 1436 | 1440 | } |
| 1437 | 1441 | /* check if state machine should change state */ |
| @@ -1955,16 +1959,16 @@ static void ad_initialize_agg(struct aggregator *aggregator) · 517 unmodified lines | ||
| 1955 | 1959 | /** |
| 1956 | 1960 | * ad_initialize_port - initialize a given port's parameters |
| 1957 | 1961 | * @port: the port we're looking at |
| 1958 | − * @lacp_fast: boolean. whether fast periodic should be used | |
| 1962 | + * @bond_params: bond parameters we will use | |
| 1959 | 1963 | */ |
| 1960 | −static void ad_initialize_port(struct port *port, int lacp_fast) | |
| 1964 | +static void ad_initialize_port(struct port *port, const struct bond_params *bond_params) | |
| 1961 | 1965 | { |
| 1962 | 1966 | static const struct port_params tmpl = { |
| 1963 | 1967 | .system_priority = 0xffff, |
| 1964 | 1968 | .key = 1, |
| 1965 | 1969 | .port_number = 1, |
| 1966 | 1970 | .port_priority = 0xff, |
| 1967 | − .port_state = 1, | |
| 1971 | + .port_state = 0, | |
| 1968 | 1972 | }; |
| 1969 | 1973 | static const struct lacpdu lacpdu = { |
| 1970 | 1974 | .subtype = 0x01, |
| @@ -1982,12 +1986,14 @@ static void ad_initialize_port(struct port *port, int lacp_fast) · 11 unmodified lines | ||
| 1982 | 1986 | port->actor_port_priority = 0xff; |
| 1983 | 1987 | port->actor_port_aggregator_identifier = 0; |
| 1984 | 1988 | port->ntt = false; |
| 1985 | − port->actor_admin_port_state = LACP_STATE_AGGREGATION | | |
| 1986 | − LACP_STATE_LACP_ACTIVITY; | |
| 1987 | − port->actor_oper_port_state = LACP_STATE_AGGREGATION | | |
| 1988 | − LACP_STATE_LACP_ACTIVITY; | |
| 1989 | + port->actor_admin_port_state = LACP_STATE_AGGREGATION; | |
| 1990 | + port->actor_oper_port_state = LACP_STATE_AGGREGATION; | |
| 1991 | + if (bond_params->lacp_active) { | |
| 1992 | + port->actor_admin_port_state |= LACP_STATE_LACP_ACTIVITY; | |
| 1993 | + port->actor_oper_port_state |= LACP_STATE_LACP_ACTIVITY; | |
| 1994 | + } | |
| 1989 | 1995 | |
| 1990 | − if (lacp_fast) | |
| 1996 | + if (bond_params->lacp_fast) | |
| 1991 | 1997 | port->actor_oper_port_state |= LACP_STATE_LACP_TIMEOUT; |
| 1992 | 1998 | |
| 1993 | 1999 | memcpy(&port->partner_admin, &tmpl, sizeof(tmpl)); |
| @@ -2201,7 +2207,7 @@ void bond_3ad_bind_slave(struct slave *slave) · 207 unmodified lines | ||
| 2201 | 2207 | /* port initialization */ |
| 2202 | 2208 | port = &(SLAVE_AD_INFO(slave)->port); |
| 2203 | 2209 | |
| 2204 | − ad_initialize_port(port, bond->params.lacp_fast); | |
| 2210 | + ad_initialize_port(port, &bond->params); | |
| 2205 | 2211 | |
| 2206 | 2212 | port->slave = slave; |
| 2207 | 2213 | port->actor_port_number = SLAVE_AD_INFO(slave)->id; |
| @@ -2513,7 +2519,7 @@ void bond_3ad_state_machine_handler(struct work_struct *work) · 305 unmodified lines | ||
| 2513 | 2519 | } |
| 2514 | 2520 | |
| 2515 | 2521 | ad_rx_machine(NULL, port); |
| 2516 | − ad_periodic_machine(port, &bond->params); | |
| 2522 | + ad_periodic_machine(port); | |
| 2517 | 2523 | ad_port_selection_logic(port, &update_slave_arr); |
| 2518 | 2524 | ad_mux_machine(port, &update_slave_arr); |
| 2519 | 2525 | ad_tx_machine(port); |
| @@ -2883,6 +2889,31 @@ void bond_3ad_update_lacp_rate(struct bonding *bond) · 363 unmodified lines | ||
| 2883 | 2889 | spin_unlock_bh(&bond->mode_lock); |
| 2884 | 2890 | } |
| 2885 | 2891 | |
| 2892 | +/** | |
| 2893 | + * bond_3ad_update_lacp_active - change the lacp active | |
| 2894 | + * @bond: bonding struct | |
| 2895 | + * | |
| 2896 | + * Update actor_oper_port_state when lacp_active is modified. | |
| 2897 | + */ | |
| 2898 | +void bond_3ad_update_lacp_active(struct bonding *bond) | |
| 2899 | +{ | |
| 2900 | + struct port *port = NULL; | |
| 2901 | + struct list_head *iter; | |
| 2902 | + struct slave *slave; | |
| 2903 | + int lacp_active; | |
| 2904 | + | |
| 2905 | + lacp_active = bond->params.lacp_active; | |
| 2906 | + spin_lock_bh(&bond->mode_lock); | |
| 2907 | + bond_for_each_slave(bond, slave, iter) { | |
| 2908 | + port = &(SLAVE_AD_INFO(slave)->port); | |
| 2909 | + if (lacp_active) | |
| 2910 | + port->actor_oper_port_state |= LACP_STATE_LACP_ACTIVITY; | |
| 2911 | + else | |
| 2912 | + port->actor_oper_port_state &= ~LACP_STATE_LACP_ACTIVITY; | |
| 2913 | + } | |
| 2914 | + spin_unlock_bh(&bond->mode_lock); | |
| 2915 | +} | |
| 2916 | + | |
| 2886 | 2917 | size_t bond_3ad_stats_size(void) |
| 2887 | 2918 | { |
| 2888 | 2919 | return nla_total_size_64bit(sizeof(u64)) + /* BOND_3AD_STAT_LACPDU_RX */ |
| @@ -1660,6 +1660,7 @@ static int bond_option_lacp_active_set(struct bonding *bond, · 1659 unmodified lines | ||
| 1660 | 1660 | netdev_dbg(bond->dev, "Setting LACP active to %s (%llu)\n", |
| 1661 | 1661 | newval->string, newval->value); |
| 1662 | 1662 | bond->params.lacp_active = newval->value; |
| 1663 | + bond_3ad_update_lacp_active(bond); | |
| 1663 | 1664 | |
| 1664 | 1665 | return 0; |
| 1665 | 1666 | } |
| @@ -2078,7 +2078,7 @@ int b53_fdb_dump(struct dsa_switch *ds, int port, · 2077 unmodified lines | ||
| 2078 | 2078 | |
| 2079 | 2079 | /* Start search operation */ |
| 2080 | 2080 | reg = ARL_SRCH_STDN; |
| 2081 | − b53_write8(priv, offset, B53_ARL_SRCH_CTL, reg); | |
| 2081 | + b53_write8(priv, B53_ARLIO_PAGE, offset, reg); | |
| 2082 | 2082 | |
| 2083 | 2083 | do { |
| 2084 | 2084 | ret = b53_arl_search_wait(priv); |
| @@ -2457,6 +2457,12 @@ static void ksz_update_port_member(struct ksz_device *dev, int port) · 2456 unmodified lines | ||
| 2457 | 2457 | dev->dev_ops->cfg_port_member(dev, i, val | cpu_port); |
| 2458 | 2458 | } |
| 2459 | 2459 | |
| 2460 | + /* HSR ports are setup once so need to use the assigned membership | |
| 2461 | + * when the port is enabled. | |
| 2462 | + */ | |
| 2463 | + if (!port_member && p->stp_state == BR_STATE_FORWARDING && | |
| 2464 | + (dev->hsr_ports & BIT(port))) | |
| 2465 | + port_member = dev->hsr_ports; | |
| 2460 | 2466 | dev->dev_ops->cfg_port_member(dev, port, port_member | cpu_port); |
| 2461 | 2467 | } |
| 2462 | 2468 | |
| @@ -736,10 +736,8 @@ static void airoha_ppe_foe_insert_entry(struct airoha_ppe *ppe, · 735 unmodified lines | ||
| 736 | 736 | continue; |
| 737 | 737 | } |
| 738 | 738 | |
| 739 | − if (commit_done || !airoha_ppe_foe_compare_entry(e, hwe)) { | |
| 740 | − e->hash = 0xffff; | |
| 739 | + if (!airoha_ppe_foe_compare_entry(e, hwe)) | |
| 741 | 740 | continue; |
| 742 | − } | |
| 743 | 741 | |
| 744 | 742 | airoha_ppe_foe_commit_entry(ppe, &e->data, hash); |
| 745 | 743 | commit_done = true; |
| @@ -5332,7 +5332,7 @@ static void bnxt_free_ntp_fltrs(struct bnxt *bp, bool all) · 5331 unmodified lines | ||
| 5332 | 5332 | { |
| 5333 | 5333 | int i; |
| 5334 | 5334 | |
| 5335 | − netdev_assert_locked(bp->dev); | |
| 5335 | + netdev_assert_locked_or_invisible(bp->dev); | |
| 5336 | 5336 | |
| 5337 | 5337 | /* Under netdev instance lock and all our NAPIs have been disabled. |
| 5338 | 5338 | * It's safe to delete the hash table. |
| @@ -5113,7 +5113,8 @@ static const struct macb_config sama7g5_gem_config = { · 5112 unmodified lines | ||
| 5113 | 5113 | |
| 5114 | 5114 | static const struct macb_config sama7g5_emac_config = { |
| 5115 | 5115 | .caps = MACB_CAPS_USRIO_DEFAULT_IS_MII_GMII | |
| 5116 | − MACB_CAPS_MIIONRGMII | MACB_CAPS_GEM_HAS_PTP, | |
| 5116 | + MACB_CAPS_USRIO_HAS_CLKEN | MACB_CAPS_MIIONRGMII | | |
| 5117 | + MACB_CAPS_GEM_HAS_PTP, | |
| 5117 | 5118 | .dma_burst_length = 16, |
| 5118 | 5119 | .clk_init = macb_clk_init, |
| 5119 | 5120 | .init = macb_init, |
| @@ -2870,6 +2870,8 @@ static void gve_shutdown(struct pci_dev *pdev) · 2869 unmodified lines | ||
| 2870 | 2870 | struct gve_priv *priv = netdev_priv(netdev); |
| 2871 | 2871 | bool was_up = netif_running(priv->dev); |
| 2872 | 2872 | |
| 2873 | + netif_device_detach(netdev); | |
| 2874 | + | |
| 2873 | 2875 | rtnl_lock(); |
| 2874 | 2876 | netdev_lock(netdev); |
| 2875 | 2877 | if (was_up && gve_close(priv->dev)) { |
| @@ -7149,6 +7149,13 @@ static int igc_probe(struct pci_dev *pdev, · 7148 unmodified lines | ||
| 7149 | 7149 | adapter->port_num = hw->bus.func; |
| 7150 | 7150 | adapter->msg_enable = netif_msg_init(debug, DEFAULT_MSG_ENABLE); |
| 7151 | 7151 | |
| 7152 | + /* PCI config space info */ | |
| 7153 | + hw->vendor_id = pdev->vendor; | |
| 7154 | + hw->device_id = pdev->device; | |
| 7155 | + hw->revision_id = pdev->revision; | |
| 7156 | + hw->subsystem_vendor_id = pdev->subsystem_vendor; | |
| 7157 | + hw->subsystem_device_id = pdev->subsystem_device; | |
| 7158 | + | |
| 7152 | 7159 | /* Disable ASPM L1.2 on I226 devices to avoid packet loss */ |
| 7153 | 7160 | if (igc_is_device_id_i226(hw)) |
| 7154 | 7161 | pci_disable_link_state(pdev, PCIE_LINK_STATE_L1_2); |
| @@ -7175,13 +7182,6 @@ static int igc_probe(struct pci_dev *pdev, · 20 unmodified lines | ||
| 7175 | 7182 | netdev->mem_start = pci_resource_start(pdev, 0); |
| 7176 | 7183 | netdev->mem_end = pci_resource_end(pdev, 0); |
| 7177 | 7184 | |
| 7178 | − /* PCI config space info */ | |
| 7179 | − hw->vendor_id = pdev->vendor; | |
| 7180 | − hw->device_id = pdev->device; | |
| 7181 | − hw->revision_id = pdev->revision; | |
| 7182 | − hw->subsystem_vendor_id = pdev->subsystem_vendor; | |
| 7183 | − hw->subsystem_device_id = pdev->subsystem_device; | |
| 7184 | − | |
| 7185 | 7185 | /* Copy the default MAC and PHY function pointers */ |
| 7186 | 7186 | memcpy(&hw->mac.ops, ei->mac_ops, sizeof(hw->mac.ops)); |
| 7187 | 7187 | memcpy(&hw->phy.ops, ei->phy_ops, sizeof(hw->phy.ops)); |
| @@ -968,10 +968,6 @@ static void ixgbe_update_xoff_rx_lfc(struct ixgbe_adapter *adapter) · 967 unmodified lines | ||
| 968 | 968 | for (i = 0; i < adapter->num_tx_queues; i++) |
| 969 | 969 | clear_bit(__IXGBE_HANG_CHECK_ARMED, |
| 970 | 970 | &adapter->tx_ring[i]->state); |
| 971 | − | |
| 972 | − for (i = 0; i < adapter->num_xdp_queues; i++) | |
| 973 | − clear_bit(__IXGBE_HANG_CHECK_ARMED, | |
| 974 | − &adapter->xdp_ring[i]->state); | |
| 975 | 971 | } |
| 976 | 972 | |
| 977 | 973 | static void ixgbe_update_xoff_received(struct ixgbe_adapter *adapter) |
| @@ -1214,7 +1210,7 @@ static void ixgbe_pf_handle_tx_hang(struct ixgbe_ring *tx_ring, · 236 unmodified lines | ||
| 1214 | 1210 | struct ixgbe_adapter *adapter = netdev_priv(tx_ring->netdev); |
| 1215 | 1211 | struct ixgbe_hw *hw = &adapter->hw; |
| 1216 | 1212 | |
| 1217 | − e_err(drv, "Detected Tx Unit Hang%s\n" | |
| 1213 | + e_err(drv, "Detected Tx Unit Hang\n" | |
| 1218 | 1214 | " Tx Queue <%d>\n" |
| 1219 | 1215 | " TDH, TDT <%x>, <%x>\n" |
| 1220 | 1216 | " next_to_use <%x>\n" |
| @@ -1222,16 +1218,14 @@ static void ixgbe_pf_handle_tx_hang(struct ixgbe_ring *tx_ring, · 1 unmodified line | ||
| 1222 | 1218 | "tx_buffer_info[next_to_clean]\n" |
| 1223 | 1219 | " time_stamp <%lx>\n" |
| 1224 | 1220 | " jiffies <%lx>\n", |
| 1225 | − ring_is_xdp(tx_ring) ? " (XDP)" : "", | |
| 1226 | 1221 | tx_ring->queue_index, |
| 1227 | 1222 | IXGBE_READ_REG(hw, IXGBE_TDH(tx_ring->reg_idx)), |
| 1228 | 1223 | IXGBE_READ_REG(hw, IXGBE_TDT(tx_ring->reg_idx)), |
| 1229 | 1224 | tx_ring->next_to_use, next, |
| 1230 | 1225 | tx_ring->tx_buffer_info[next].time_stamp, jiffies); |
| 1231 | 1226 | |
| 1232 | − if (!ring_is_xdp(tx_ring)) | |
| 1233 | − netif_stop_subqueue(tx_ring->netdev, | |
| 1234 | − tx_ring->queue_index); | |
| 1227 | + netif_stop_subqueue(tx_ring->netdev, | |
| 1228 | + tx_ring->queue_index); | |
| 1235 | 1229 | } |
| 1236 | 1230 | |
| 1237 | 1231 | /** |
| @@ -1451,6 +1445,9 @@ static bool ixgbe_clean_tx_irq(struct ixgbe_q_vector *q_vector, · 213 unmodified lines | ||
| 1451 | 1445 | total_bytes); |
| 1452 | 1446 | adapter->tx_ipsec += total_ipsec; |
| 1453 | 1447 | |
| 1448 | + if (ring_is_xdp(tx_ring)) | |
| 1449 | + return !!budget; | |
| 1450 | + | |
| 1454 | 1451 | if (check_for_tx_hang(tx_ring) && ixgbe_check_tx_hang(tx_ring)) { |
| 1455 | 1452 | if (adapter->hw.mac.type == ixgbe_mac_e610) |
| 1456 | 1453 | ixgbe_handle_mdd_event(adapter, tx_ring); |
| @@ -1468,9 +1465,6 @@ static bool ixgbe_clean_tx_irq(struct ixgbe_q_vector *q_vector, · 11 unmodified lines | ||
| 1468 | 1465 | return true; |
| 1469 | 1466 | } |
| 1470 | 1467 | |
| 1471 | − if (ring_is_xdp(tx_ring)) | |
| 1472 | − return !!budget; | |
| 1473 | − | |
| 1474 | 1468 | #define TX_WAKE_THRESHOLD (DESC_NEEDED * 2) |
| 1475 | 1469 | txq = netdev_get_tx_queue(tx_ring->netdev, tx_ring->queue_index); |
| 1476 | 1470 | if (!__netif_txq_completed_wake(txq, total_packets, total_bytes, |
| @@ -7974,12 +7968,9 @@ static void ixgbe_check_hang_subtask(struct ixgbe_adapter *adapter) · 6497 unmodified lines | ||
| 7974 | 7968 | return; |
| 7975 | 7969 | |
| 7976 | 7970 | /* Force detection of hung controller */ |
| 7977 | − if (netif_carrier_ok(adapter->netdev)) { | |
| 7971 | + if (netif_carrier_ok(adapter->netdev)) | |
| 7978 | 7972 | for (i = 0; i < adapter->num_tx_queues; i++) |
| 7979 | 7973 | set_check_for_tx_hang(adapter->tx_ring[i]); |
| 7980 | − for (i = 0; i < adapter->num_xdp_queues; i++) | |
| 7981 | − set_check_for_tx_hang(adapter->xdp_ring[i]); | |
| 7982 | − } | |
| 7983 | 7974 | |
| 7984 | 7975 | if (!(adapter->flags & IXGBE_FLAG_MSIX_ENABLED)) { |
| 7985 | 7976 | /* |
| @@ -8199,13 +8190,6 @@ static bool ixgbe_ring_tx_pending(struct ixgbe_adapter *adapter) · 213 unmodified lines | ||
| 8199 | 8190 | return true; |
| 8200 | 8191 | } |
| 8201 | 8192 | |
| 8202 | − for (i = 0; i < adapter->num_xdp_queues; i++) { | |
| 8203 | − struct ixgbe_ring *ring = adapter->xdp_ring[i]; | |
| 8204 | − | |
| 8205 | − if (ring->next_to_use != ring->next_to_clean) | |
| 8206 | − return true; | |
| 8207 | − } | |
| 8208 | − | |
| 8209 | 8193 | return false; |
| 8210 | 8194 | } |
| 8211 | 8195 | |
| @@ -11005,6 +10989,10 @@ static int ixgbe_xdp_xmit(struct net_device *dev, int n, · 2793 unmodified lines | ||
| 11005 | 10989 | if (unlikely(test_bit(__IXGBE_DOWN, &adapter->state))) |
| 11006 | 10990 | return -ENETDOWN; |
| 11007 | 10991 | |
| 10992 | + if (!netif_carrier_ok(adapter->netdev) || | |
| 10993 | + !netif_running(adapter->netdev)) | |
| 10994 | + return -ENETDOWN; | |
| 10995 | + | |
| 11008 | 10996 | if (unlikely(flags & ~XDP_XMIT_FLAGS_MASK)) |
| 11009 | 10997 | return -EINVAL; |
| 11010 | 10998 | |
| @@ -398,7 +398,7 @@ static bool ixgbe_xmit_zc(struct ixgbe_ring *xdp_ring, unsigned int budget) · 397 unmodified lines | ||
| 398 | 398 | dma_addr_t dma; |
| 399 | 399 | u32 cmd_type; |
| 400 | 400 | |
| 401 | − while (budget-- > 0) { | |
| 401 | + while (likely(budget)) { | |
| 402 | 402 | if (unlikely(!ixgbe_desc_unused(xdp_ring))) { |
| 403 | 403 | work_done = false; |
| 404 | 404 | break; |
| @@ -433,6 +433,8 @@ static bool ixgbe_xmit_zc(struct ixgbe_ring *xdp_ring, unsigned int budget) · 28 unmodified lines | ||
| 433 | 433 | xdp_ring->next_to_use++; |
| 434 | 434 | if (xdp_ring->next_to_use == xdp_ring->count) |
| 435 | 435 | xdp_ring->next_to_use = 0; |
| 436 | + | |
| 437 | + budget--; | |
| 436 | 438 | } |
| 437 | 439 | |
| 438 | 440 | if (tx_desc) { |
| @@ -606,8 +606,8 @@ static void npc_set_features(struct rvu *rvu, int blkaddr, u8 intf) · 605 unmodified lines | ||
| 606 | 606 | if (!npc_check_field(rvu, blkaddr, NPC_LB, intf)) |
| 607 | 607 | *features &= ~BIT_ULL(NPC_OUTER_VID); |
| 608 | 608 | |
| 609 | − /* Set SPI flag only if AH/ESP and IPSEC_SPI are in the key */ | |
| 610 | − if (npc_check_field(rvu, blkaddr, NPC_IPSEC_SPI, intf) && | |
| 609 | + /* Allow extracting SPI field from AH and ESP headers at same offset */ | |
| 610 | + if (npc_is_field_present(rvu, NPC_IPSEC_SPI, intf) && | |
| 611 | 611 | (*features & (BIT_ULL(NPC_IPPROTO_ESP) | BIT_ULL(NPC_IPPROTO_AH)))) |
| 612 | 612 | *features |= BIT_ULL(NPC_IPSEC_SPI); |
| 613 | 613 | |
| @@ -101,7 +101,9 @@ mtk_flow_get_wdma_info(struct net_device *dev, const u8 *addr, struct mtk_wdma_i · 100 unmodified lines | ||
| 101 | 101 | if (!IS_ENABLED(CONFIG_NET_MEDIATEK_SOC_WED)) |
| 102 | 102 | return -1; |
| 103 | 103 | |
| 104 | + rcu_read_lock(); | |
| 104 | 105 | err = dev_fill_forward_path(dev, addr, &stack); |
| 106 | + rcu_read_unlock(); | |
| 105 | 107 | if (err) |
| 106 | 108 | return err; |
| 107 | 109 | |
| @@ -26,7 +26,6 @@ struct mlx5e_dcbx { · 25 unmodified lines | ||
| 26 | 26 | u8 cap; |
| 27 | 27 | |
| 28 | 28 | /* Buffer configuration */ |
| 29 | − bool manual_buffer; | |
| 30 | 29 | u32 cable_len; |
| 31 | 30 | u32 xoff; |
| 32 | 31 | u16 port_buff_cell_sz; |
| @@ -272,8 +272,8 @@ static int port_update_shared_buffer(struct mlx5_core_dev *mdev, · 271 unmodified lines | ||
| 272 | 272 | /* Total shared buffer size is split in a ratio of 3:1 between |
| 273 | 273 | * lossy and lossless pools respectively. |
| 274 | 274 | */ |
| 275 | − lossy_epool_size = (shared_buffer_size / 4) * 3; | |
| 276 | 275 | lossless_ipool_size = shared_buffer_size / 4; |
| 276 | + lossy_epool_size = shared_buffer_size - lossless_ipool_size; | |
| 277 | 277 | |
| 278 | 278 | mlx5e_port_set_sbpr(mdev, 0, MLX5_EGRESS_DIR, MLX5_LOSSY_POOL, 0, |
| 279 | 279 | lossy_epool_size); |
| @@ -288,14 +288,12 @@ static int port_set_buffer(struct mlx5e_priv *priv, · 8 unmodified lines | ||
| 288 | 288 | u16 port_buff_cell_sz = priv->dcbx.port_buff_cell_sz; |
| 289 | 289 | struct mlx5_core_dev *mdev = priv->mdev; |
| 290 | 290 | int sz = MLX5_ST_SZ_BYTES(pbmc_reg); |
| 291 | − u32 new_headroom_size = 0; | |
| 292 | − u32 current_headroom_size; | |
| 291 | + u32 current_headroom_cells = 0; | |
| 292 | + u32 new_headroom_cells = 0; | |
| 293 | 293 | void *in; |
| 294 | 294 | int err; |
| 295 | 295 | int i; |
| 296 | 296 | |
| 297 | − current_headroom_size = port_buffer->headroom_size; | |
| 298 | − | |
| 299 | 297 | in = kzalloc(sz, GFP_KERNEL); |
| 300 | 298 | if (!in) |
| 301 | 299 | return -ENOMEM; |
| @@ -306,12 +304,14 @@ static int port_set_buffer(struct mlx5e_priv *priv, · 4 unmodified lines | ||
| 306 | 304 | |
| 307 | 305 | for (i = 0; i < MLX5E_MAX_NETWORK_BUFFER; i++) { |
| 308 | 306 | void *buffer = MLX5_ADDR_OF(pbmc_reg, in, buffer[i]); |
| 307 | + current_headroom_cells += MLX5_GET(bufferx_reg, buffer, size); | |
| 308 | + | |
| 309 | 309 | u64 size = port_buffer->buffer[i].size; |
| 310 | 310 | u64 xoff = port_buffer->buffer[i].xoff; |
| 311 | 311 | u64 xon = port_buffer->buffer[i].xon; |
| 312 | 312 | |
| 313 | − new_headroom_size += size; | |
| 314 | 313 | do_div(size, port_buff_cell_sz); |
| 314 | + new_headroom_cells += size; | |
| 315 | 315 | do_div(xoff, port_buff_cell_sz); |
| 316 | 316 | do_div(xon, port_buff_cell_sz); |
| 317 | 317 | MLX5_SET(bufferx_reg, buffer, size, size); |
| @@ -320,10 +320,8 @@ static int port_set_buffer(struct mlx5e_priv *priv, · 2 unmodified lines | ||
| 320 | 320 | MLX5_SET(bufferx_reg, buffer, xon_threshold, xon); |
| 321 | 321 | } |
| 322 | 322 | |
| 323 | − new_headroom_size /= port_buff_cell_sz; | |
| 324 | − current_headroom_size /= port_buff_cell_sz; | |
| 325 | − err = port_update_shared_buffer(priv->mdev, current_headroom_size, | |
| 326 | − new_headroom_size); | |
| 323 | + err = port_update_shared_buffer(priv->mdev, current_headroom_cells, | |
| 324 | + new_headroom_cells); | |
| 327 | 325 | if (err) |
| 328 | 326 | goto out; |
| 329 | 327 | |
| @@ -173,6 +173,8 @@ static void mlx5_ct_fs_hmfs_fill_rule_actions(struct mlx5_ct_fs_hmfs *fs_hmfs, · 172 unmodified lines | ||
| 173 | 173 | |
| 174 | 174 | memset(rule_actions, 0, NUM_CT_HMFS_RULES * sizeof(*rule_actions)); |
| 175 | 175 | rule_actions[0].action = mlx5_fc_get_hws_action(fs_hmfs->ctx, attr->counter); |
| 176 | + rule_actions[0].counter.offset = | |
| 177 | + attr->counter->id - attr->counter->bulk->base_id; | |
| 176 | 178 | /* Modify header is special, it may require extra arguments outside the action itself. */ |
| 177 | 179 | if (mh_action->mh_data) { |
| 178 | 180 | rule_actions[1].modify_header.offset = mh_action->mh_data->offset; |
| @@ -362,6 +362,7 @@ static int mlx5e_dcbnl_ieee_getpfc(struct net_device *dev, · 361 unmodified lines | ||
| 362 | 362 | static int mlx5e_dcbnl_ieee_setpfc(struct net_device *dev, |
| 363 | 363 | struct ieee_pfc *pfc) |
| 364 | 364 | { |
| 365 | + u8 buffer_ownership = MLX5_BUF_OWNERSHIP_UNKNOWN; | |
| 365 | 366 | struct mlx5e_priv *priv = netdev_priv(dev); |
| 366 | 367 | struct mlx5_core_dev *mdev = priv->mdev; |
| 367 | 368 | u32 old_cable_len = priv->dcbx.cable_len; |
| @@ -389,7 +390,14 @@ static int mlx5e_dcbnl_ieee_setpfc(struct net_device *dev, · 21 unmodified lines | ||
| 389 | 390 | |
| 390 | 391 | if (MLX5_BUFFER_SUPPORTED(mdev)) { |
| 391 | 392 | pfc_new.pfc_en = (changed & MLX5E_PORT_BUFFER_PFC) ? pfc->pfc_en : curr_pfc_en; |
| 392 | − if (priv->dcbx.manual_buffer) | |
| 393 | + ret = mlx5_query_port_buffer_ownership(mdev, | |
| 394 | + &buffer_ownership); | |
| 395 | + if (ret) | |
| 396 | + netdev_err(dev, | |
| 397 | + "%s, Failed to get buffer ownership: %d\n", | |
| 398 | + __func__, ret); | |
| 399 | + | |
| 400 | + if (buffer_ownership == MLX5_BUF_OWNERSHIP_SW_OWNED) | |
| 393 | 401 | ret = mlx5e_port_manual_buffer_config(priv, changed, |
| 394 | 402 | dev->mtu, &pfc_new, |
| 395 | 403 | NULL, NULL); |
| @@ -982,7 +990,6 @@ static int mlx5e_dcbnl_setbuffer(struct net_device *dev, · 586 unmodified lines | ||
| 982 | 990 | if (!changed) |
| 983 | 991 | return 0; |
| 984 | 992 | |
| 985 | − priv->dcbx.manual_buffer = true; | |
| 986 | 993 | err = mlx5e_port_manual_buffer_config(priv, changed, dev->mtu, NULL, |
| 987 | 994 | buffer_size, prio2buffer); |
| 988 | 995 | return err; |
| @@ -1252,7 +1259,6 @@ void mlx5e_dcbnl_initialize(struct mlx5e_priv *priv) · 263 unmodified lines | ||
| 1252 | 1259 | priv->dcbx.cap |= DCB_CAP_DCBX_HOST; |
| 1253 | 1260 | |
| 1254 | 1261 | priv->dcbx.port_buff_cell_sz = mlx5e_query_port_buffers_cell_size(priv); |
| 1255 | − priv->dcbx.manual_buffer = false; | |
| 1256 | 1262 | priv->dcbx.cable_len = MLX5E_DEFAULT_CABLE_LEN; |
| 1257 | 1263 | |
| 1258 | 1264 | mlx5e_ets_init(priv); |
| @@ -47,10 +47,12 @@ static void mlx5_esw_offloads_pf_vf_devlink_port_attrs_set(struct mlx5_eswitch * · 46 unmodified lines | ||
| 47 | 47 | devlink_port_attrs_pci_vf_set(dl_port, controller_num, pfnum, |
| 48 | 48 | vport_num - 1, external); |
| 49 | 49 | } else if (mlx5_core_is_ec_vf_vport(esw->dev, vport_num)) { |
| 50 | + u16 base_vport = mlx5_core_ec_vf_vport_base(dev); | |
| 51 | + | |
| 50 | 52 | memcpy(dl_port->attrs.switch_id.id, ppid.id, ppid.id_len); |
| 51 | 53 | dl_port->attrs.switch_id.id_len = ppid.id_len; |
| 52 | 54 | devlink_port_attrs_pci_vf_set(dl_port, 0, pfnum, |
| 53 | − vport_num - 1, false); | |
| 55 | + vport_num - base_vport, false); | |
| 54 | 56 | } |
| 55 | 57 | } |
| 56 | 58 | |
| @@ -102,6 +102,8 @@ struct mlx5_esw_sched_node { · 101 unmodified lines | ||
| 102 | 102 | u8 level; |
| 103 | 103 | /* Valid only when this node represents a traffic class. */ |
| 104 | 104 | u8 tc; |
| 105 | + /* Valid only for a TC arbiter node or vport TC arbiter. */ | |
| 106 | + u32 tc_bw[DEVLINK_RATE_TCS_MAX]; | |
| 105 | 107 | }; |
| 106 | 108 | |
| 107 | 109 | static void esw_qos_node_attach_to_parent(struct mlx5_esw_sched_node *node) |
| @@ -462,6 +464,7 @@ static int · 354 unmodified lines | ||
| 462 | 464 | esw_qos_vport_create_sched_element(struct mlx5_esw_sched_node *vport_node, |
| 463 | 465 | struct netlink_ext_ack *extack) |
| 464 | 466 | { |
| 467 | + struct mlx5_esw_sched_node *parent = vport_node->parent; | |
| 465 | 468 | u32 sched_ctx[MLX5_ST_SZ_DW(scheduling_context)] = {}; |
| 466 | 469 | struct mlx5_core_dev *dev = vport_node->esw->dev; |
| 467 | 470 | void *attr; |
| @@ -477,7 +480,7 @@ esw_qos_vport_create_sched_element(struct mlx5_esw_sched_node *vport_node, · 9 unmodified lines | ||
| 477 | 480 | attr = MLX5_ADDR_OF(scheduling_context, sched_ctx, element_attributes); |
| 478 | 481 | MLX5_SET(vport_element, attr, vport_number, vport_node->vport->vport); |
| 479 | 482 | MLX5_SET(scheduling_context, sched_ctx, parent_element_id, |
| 480 | − vport_node->parent->ix); | |
| 483 | + parent ? parent->ix : vport_node->esw->qos.root_tsar_ix); | |
| 481 | 484 | MLX5_SET(scheduling_context, sched_ctx, max_average_bw, |
| 482 | 485 | vport_node->max_rate); |
| 483 | 486 | |
| @@ -608,10 +611,7 @@ static void · 124 unmodified lines | ||
| 608 | 611 | esw_qos_tc_arbiter_get_bw_shares(struct mlx5_esw_sched_node *tc_arbiter_node, |
| 609 | 612 | u32 *tc_bw) |
| 610 | 613 | { |
| 611 | − struct mlx5_esw_sched_node *vports_tc_node; | |
| 612 | − | |
| 613 | − list_for_each_entry(vports_tc_node, &tc_arbiter_node->children, entry) | |
| 614 | − tc_bw[vports_tc_node->tc] = vports_tc_node->bw_share; | |
| 614 | + memcpy(tc_bw, tc_arbiter_node->tc_bw, sizeof(tc_arbiter_node->tc_bw)); | |
| 615 | 615 | } |
| 616 | 616 | |
| 617 | 617 | static void |
| @@ -628,6 +628,7 @@ esw_qos_set_tc_arbiter_bw_shares(struct mlx5_esw_sched_node *tc_arbiter_node, · 10 unmodified lines | ||
| 628 | 628 | u8 tc = vports_tc_node->tc; |
| 629 | 629 | u32 bw_share; |
| 630 | 630 | |
| 631 | + tc_arbiter_node->tc_bw[tc] = tc_bw[tc]; | |
| 631 | 632 | bw_share = tc_bw[tc] * fw_max_bw_share; |
| 632 | 633 | bw_share = esw_qos_calc_bw_share(bw_share, divider, |
| 633 | 634 | fw_max_bw_share); |
| @@ -786,48 +787,15 @@ static int esw_qos_create(struct mlx5_eswitch *esw, struct netlink_ext_ack *exta · 152 unmodified lines | ||
| 786 | 787 | return err; |
| 787 | 788 | } |
| 788 | 789 | |
| 789 | − if (MLX5_CAP_QOS(dev, log_esw_max_sched_depth)) { | |
| 790 | − esw->qos.node0 = __esw_qos_create_vports_sched_node(esw, NULL, extack); | |
| 791 | − } else { | |
| 792 | − /* The eswitch doesn't support scheduling nodes. | |
| 793 | − * Create a software-only node0 using the root TSAR to attach vport QoS to. | |
| 794 | − */ | |
| 795 | − if (!__esw_qos_alloc_node(esw, | |
| 796 | − esw->qos.root_tsar_ix, | |
| 797 | − SCHED_NODE_TYPE_VPORTS_TSAR, | |
| 798 | − NULL)) | |
| 799 | − esw->qos.node0 = ERR_PTR(-ENOMEM); | |
| 800 | − else | |
| 801 | − list_add_tail(&esw->qos.node0->entry, | |
| 802 | − &esw->qos.domain->nodes); | |
| 803 | − } | |
| 804 | − if (IS_ERR(esw->qos.node0)) { | |
| 805 | − err = PTR_ERR(esw->qos.node0); | |
| 806 | − esw_warn(dev, "E-Switch create rate node 0 failed (%d)\n", err); | |
| 807 | − goto err_node0; | |
| 808 | − } | |
| 809 | 790 | refcount_set(&esw->qos.refcnt, 1); |
| 810 | 791 | |
| 811 | 792 | return 0; |
| 812 | − | |
| 813 | −err_node0: | |
| 814 | − if (mlx5_destroy_scheduling_element_cmd(esw->dev, SCHEDULING_HIERARCHY_E_SWITCH, | |
| 815 | − esw->qos.root_tsar_ix)) | |
| 816 | − esw_warn(esw->dev, "E-Switch destroy root TSAR failed.\n"); | |
| 817 | − | |
| 818 | − return err; | |
| 819 | 793 | } |
| 820 | 794 | |
| 821 | 795 | static void esw_qos_destroy(struct mlx5_eswitch *esw) |
| 822 | 796 | { |
| 823 | 797 | int err; |
| 824 | 798 | |
| 825 | − if (esw->qos.node0->ix != esw->qos.root_tsar_ix) | |
| 826 | − __esw_qos_destroy_node(esw->qos.node0, NULL); | |
| 827 | − else | |
| 828 | − __esw_qos_free_node(esw->qos.node0); | |
| 829 | − esw->qos.node0 = NULL; | |
| 830 | − | |
| 831 | 799 | err = mlx5_destroy_scheduling_element_cmd(esw->dev, |
| 832 | 800 | SCHEDULING_HIERARCHY_E_SWITCH, |
| 833 | 801 | esw->qos.root_tsar_ix); |
| @@ -990,13 +958,16 @@ esw_qos_vport_tc_enable(struct mlx5_vport *vport, enum sched_node_type type, · 156 unmodified lines | ||
| 990 | 958 | struct netlink_ext_ack *extack) |
| 991 | 959 | { |
| 992 | 960 | struct mlx5_esw_sched_node *vport_node = vport->qos.sched_node; |
| 993 | − int err, new_level, max_level; | |
| 961 | + struct mlx5_esw_sched_node *parent = vport_node->parent; | |
| 962 | + int err; | |
| 994 | 963 | |
| 995 | 964 | if (type == SCHED_NODE_TYPE_TC_ARBITER_TSAR) { |
| 965 | + int new_level, max_level; | |
| 966 | + | |
| 996 | 967 | /* Increase the parent's level by 2 to account for both the |
| 997 | 968 | * TC arbiter and the vports TC scheduling element. |
| 998 | 969 | */ |
| 999 | − new_level = vport_node->parent->level + 2; | |
| 970 | + new_level = (parent ? parent->level : 2) + 2; | |
| 1000 | 971 | max_level = 1 << MLX5_CAP_QOS(vport_node->esw->dev, |
| 1001 | 972 | log_esw_max_sched_depth); |
| 1002 | 973 | if (new_level > max_level) { |
| @@ -1033,9 +1004,7 @@ esw_qos_vport_tc_enable(struct mlx5_vport *vport, enum sched_node_type type, · 30 unmodified lines | ||
| 1033 | 1004 | err_sched_nodes: |
| 1034 | 1005 | if (type == SCHED_NODE_TYPE_RATE_LIMITER) { |
| 1035 | 1006 | esw_qos_node_destroy_sched_element(vport_node, NULL); |
| 1036 | − list_add_tail(&vport_node->entry, | |
| 1037 | − &vport_node->parent->children); | |
| 1038 | − vport_node->level = vport_node->parent->level + 1; | |
| 1007 | + esw_qos_node_attach_to_parent(vport_node); | |
| 1039 | 1008 | } else { |
| 1040 | 1009 | esw_qos_tc_arbiter_scheduling_teardown(vport_node, NULL); |
| 1041 | 1010 | } |
| @@ -1083,7 +1052,6 @@ err_out: · 41 unmodified lines | ||
| 1083 | 1052 | static void esw_qos_vport_disable(struct mlx5_vport *vport, struct netlink_ext_ack *extack) |
| 1084 | 1053 | { |
| 1085 | 1054 | struct mlx5_esw_sched_node *vport_node = vport->qos.sched_node; |
| 1086 | − struct mlx5_esw_sched_node *parent = vport_node->parent; | |
| 1087 | 1055 | enum sched_node_type curr_type = vport_node->type; |
| 1088 | 1056 | |
| 1089 | 1057 | if (curr_type == SCHED_NODE_TYPE_VPORT) |
| @@ -1092,8 +1060,9 @@ static void esw_qos_vport_disable(struct mlx5_vport *vport, struct netlink_ext_a · 2 unmodified lines | ||
| 1092 | 1060 | esw_qos_vport_tc_disable(vport, extack); |
| 1093 | 1061 | |
| 1094 | 1062 | vport_node->bw_share = 0; |
| 1063 | + memset(vport_node->tc_bw, 0, sizeof(vport_node->tc_bw)); | |
| 1095 | 1064 | list_del_init(&vport_node->entry); |
| 1096 | − esw_qos_normalize_min_rate(parent->esw, parent, extack); | |
| 1065 | + esw_qos_normalize_min_rate(vport_node->esw, vport_node->parent, extack); | |
| 1097 | 1066 | |
| 1098 | 1067 | trace_mlx5_esw_vport_qos_destroy(vport_node->esw->dev, vport); |
| 1099 | 1068 | } |
| @@ -1103,25 +1072,23 @@ static int esw_qos_vport_enable(struct mlx5_vport *vport, · 3 unmodified lines | ||
| 1103 | 1072 | struct mlx5_esw_sched_node *parent, |
| 1104 | 1073 | struct netlink_ext_ack *extack) |
| 1105 | 1074 | { |
| 1075 | + struct mlx5_esw_sched_node *vport_node = vport->qos.sched_node; | |
| 1106 | 1076 | int err; |
| 1107 | 1077 | |
| 1108 | 1078 | esw_assert_qos_lock_held(vport->dev->priv.eswitch); |
| 1109 | 1079 | |
| 1110 | − esw_qos_node_set_parent(vport->qos.sched_node, parent); | |
| 1111 | − if (type == SCHED_NODE_TYPE_VPORT) { | |
| 1112 | − err = esw_qos_vport_create_sched_element(vport->qos.sched_node, | |
| 1113 | − extack); | |
| 1114 | − } else { | |
| 1080 | + esw_qos_node_set_parent(vport_node, parent); | |
| 1081 | + if (type == SCHED_NODE_TYPE_VPORT) | |
| 1082 | + err = esw_qos_vport_create_sched_element(vport_node, extack); | |
| 1083 | + else | |
| 1115 | 1084 | err = esw_qos_vport_tc_enable(vport, type, extack); |
| 1116 | − } | |
| 1117 | 1085 | if (err) |
| 1118 | 1086 | return err; |
| 1119 | 1087 | |
| 1120 | − vport->qos.sched_node->type = type; | |
| 1121 | − esw_qos_normalize_min_rate(parent->esw, parent, extack); | |
| 1122 | − trace_mlx5_esw_vport_qos_create(vport->dev, vport, | |
| 1123 | − vport->qos.sched_node->max_rate, | |
| 1124 | − vport->qos.sched_node->bw_share); | |
| 1088 | + vport_node->type = type; | |
| 1089 | + esw_qos_normalize_min_rate(vport_node->esw, parent, extack); | |
| 1090 | + trace_mlx5_esw_vport_qos_create(vport->dev, vport, vport_node->max_rate, | |
| 1091 | + vport_node->bw_share); | |
| 1125 | 1092 | |
| 1126 | 1093 | return 0; |
| 1127 | 1094 | } |
| @@ -1132,6 +1099,7 @@ static int mlx5_esw_qos_vport_enable(struct mlx5_vport *vport, enum sched_node_t · 4 unmodified lines | ||
| 1132 | 1099 | { |
| 1133 | 1100 | struct mlx5_eswitch *esw = vport->dev->priv.eswitch; |
| 1134 | 1101 | struct mlx5_esw_sched_node *sched_node; |
| 1102 | + struct mlx5_eswitch *parent_esw; | |
| 1135 | 1103 | int err; |
| 1136 | 1104 | |
| 1137 | 1105 | esw_assert_qos_lock_held(esw); |
| @@ -1139,10 +1107,14 @@ static int mlx5_esw_qos_vport_enable(struct mlx5_vport *vport, enum sched_node_t · 1 unmodified line | ||
| 1139 | 1107 | if (err) |
| 1140 | 1108 | return err; |
| 1141 | 1109 | |
| 1142 | − parent = parent ?: esw->qos.node0; | |
| 1143 | − sched_node = __esw_qos_alloc_node(parent->esw, 0, type, parent); | |
| 1144 | − if (!sched_node) | |
| 1110 | + parent_esw = parent ? parent->esw : esw; | |
| 1111 | + sched_node = __esw_qos_alloc_node(parent_esw, 0, type, parent); | |
| 1112 | + if (!sched_node) { | |
| 1113 | + esw_qos_put(esw); | |
| 1145 | 1114 | return -ENOMEM; |
| 1115 | + } | |
| 1116 | + if (!parent) | |
| 1117 | + list_add_tail(&sched_node->entry, &esw->qos.domain->nodes); | |
| 1146 | 1118 | |
| 1147 | 1119 | sched_node->max_rate = max_rate; |
| 1148 | 1120 | sched_node->min_rate = min_rate; |
| @@ -1150,6 +1122,7 @@ static int mlx5_esw_qos_vport_enable(struct mlx5_vport *vport, enum sched_node_t · 1 unmodified line | ||
| 1150 | 1122 | vport->qos.sched_node = sched_node; |
| 1151 | 1123 | err = esw_qos_vport_enable(vport, type, parent, extack); |
| 1152 | 1124 | if (err) { |
| 1125 | + __esw_qos_free_node(sched_node); | |
| 1153 | 1126 | esw_qos_put(esw); |
| 1154 | 1127 | vport->qos.sched_node = NULL; |
| 1155 | 1128 | } |
| @@ -1157,6 +1130,19 @@ static int mlx5_esw_qos_vport_enable(struct mlx5_vport *vport, enum sched_node_t · 1 unmodified line | ||
| 1157 | 1130 | return err; |
| 1158 | 1131 | } |
| 1159 | 1132 | |
| 1133 | +static void mlx5_esw_qos_vport_disable_locked(struct mlx5_vport *vport) | |
| 1134 | +{ | |
| 1135 | + struct mlx5_eswitch *esw = vport->dev->priv.eswitch; | |
| 1136 | + | |
| 1137 | + esw_assert_qos_lock_held(esw); | |
| 1138 | + if (!vport->qos.sched_node) | |
| 1139 | + return; | |
| 1140 | + | |
| 1141 | + esw_qos_vport_disable(vport, NULL); | |
| 1142 | + mlx5_esw_qos_vport_qos_free(vport); | |
| 1143 | + esw_qos_put(esw); | |
| 1144 | +} | |
| 1145 | + | |
| 1160 | 1146 | void mlx5_esw_qos_vport_disable(struct mlx5_vport *vport) |
| 1161 | 1147 | { |
| 1162 | 1148 | struct mlx5_eswitch *esw = vport->dev->priv.eswitch; |
| @@ -1168,11 +1154,9 @@ void mlx5_esw_qos_vport_disable(struct mlx5_vport *vport) · 5 unmodified lines | ||
| 1168 | 1154 | goto unlock; |
| 1169 | 1155 | |
| 1170 | 1156 | parent = vport->qos.sched_node->parent; |
| 1171 | − WARN(parent != esw->qos.node0, "Disabling QoS on port before detaching it from node"); | |
| 1157 | + WARN(parent, "Disabling QoS on port before detaching it from node"); | |
| 1172 | 1158 | |
| 1173 | − esw_qos_vport_disable(vport, NULL); | |
| 1174 | − mlx5_esw_qos_vport_qos_free(vport); | |
| 1175 | − esw_qos_put(esw); | |
| 1159 | + mlx5_esw_qos_vport_disable_locked(vport); | |
| 1176 | 1160 | unlock: |
| 1177 | 1161 | esw_qos_unlock(esw); |
| 1178 | 1162 | } |
| @@ -1262,13 +1246,13 @@ static int esw_qos_vport_update(struct mlx5_vport *vport, · 83 unmodified lines | ||
| 1262 | 1246 | struct mlx5_esw_sched_node *parent, |
| 1263 | 1247 | struct netlink_ext_ack *extack) |
| 1264 | 1248 | { |
| 1265 | − struct mlx5_esw_sched_node *curr_parent = vport->qos.sched_node->parent; | |
| 1266 | − enum sched_node_type curr_type = vport->qos.sched_node->type; | |
| 1249 | + struct mlx5_esw_sched_node *vport_node = vport->qos.sched_node; | |
| 1250 | + struct mlx5_esw_sched_node *curr_parent = vport_node->parent; | |
| 1251 | + enum sched_node_type curr_type = vport_node->type; | |
| 1267 | 1252 | u32 curr_tc_bw[DEVLINK_RATE_TCS_MAX] = {0}; |
| 1268 | 1253 | int err; |
| 1269 | 1254 | |
| 1270 | 1255 | esw_assert_qos_lock_held(vport->dev->priv.eswitch); |
| 1271 | − parent = parent ?: curr_parent; | |
| 1272 | 1256 | if (curr_type == type && curr_parent == parent) |
| 1273 | 1257 | return 0; |
| 1274 | 1258 | |
| @@ -1276,10 +1260,8 @@ static int esw_qos_vport_update(struct mlx5_vport *vport, · 1 unmodified line | ||
| 1276 | 1260 | if (err) |
| 1277 | 1261 | return err; |
| 1278 | 1262 | |
| 1279 | − if (curr_type == SCHED_NODE_TYPE_TC_ARBITER_TSAR && curr_type == type) { | |
| 1280 | − esw_qos_tc_arbiter_get_bw_shares(vport->qos.sched_node, | |
| 1281 | − curr_tc_bw); | |
| 1282 | − } | |
| 1263 | + if (curr_type == SCHED_NODE_TYPE_TC_ARBITER_TSAR && curr_type == type) | |
| 1264 | + esw_qos_tc_arbiter_get_bw_shares(vport_node, curr_tc_bw); | |
| 1283 | 1265 | |
| 1284 | 1266 | esw_qos_vport_disable(vport, extack); |
| 1285 | 1267 | |
| @@ -1290,8 +1272,8 @@ static int esw_qos_vport_update(struct mlx5_vport *vport, · 4 unmodified lines | ||
| 1290 | 1272 | } |
| 1291 | 1273 | |
| 1292 | 1274 | if (curr_type == SCHED_NODE_TYPE_TC_ARBITER_TSAR && curr_type == type) { |
| 1293 | − esw_qos_set_tc_arbiter_bw_shares(vport->qos.sched_node, | |
| 1294 | − curr_tc_bw, extack); | |
| 1275 | + esw_qos_set_tc_arbiter_bw_shares(vport_node, curr_tc_bw, | |
| 1276 | + extack); | |
| 1295 | 1277 | } |
| 1296 | 1278 | |
| 1297 | 1279 | return err; |
| @@ -1306,16 +1288,16 @@ static int esw_qos_vport_update_parent(struct mlx5_vport *vport, struct mlx5_esw · 8 unmodified lines | ||
| 1306 | 1288 | |
| 1307 | 1289 | esw_assert_qos_lock_held(esw); |
| 1308 | 1290 | curr_parent = vport->qos.sched_node->parent; |
| 1309 | − parent = parent ?: esw->qos.node0; | |
| 1310 | 1291 | if (curr_parent == parent) |
| 1311 | 1292 | return 0; |
| 1312 | 1293 | |
| 1313 | 1294 | /* Set vport QoS type based on parent node type if different from |
| 1314 | 1295 | * default QoS; otherwise, use the vport's current QoS type. |
| 1315 | 1296 | */ |
| 1316 | − if (parent->type == SCHED_NODE_TYPE_TC_ARBITER_TSAR) | |
| 1297 | + if (parent && parent->type == SCHED_NODE_TYPE_TC_ARBITER_TSAR) | |
| 1317 | 1298 | type = SCHED_NODE_TYPE_RATE_LIMITER; |
| 1318 | − else if (curr_parent->type == SCHED_NODE_TYPE_TC_ARBITER_TSAR) | |
| 1299 | + else if (curr_parent && | |
| 1300 | + curr_parent->type == SCHED_NODE_TYPE_TC_ARBITER_TSAR) | |
| 1319 | 1301 | type = SCHED_NODE_TYPE_VPORT; |
| 1320 | 1302 | else |
| 1321 | 1303 | type = vport->qos.sched_node->type; |
| @@ -1654,9 +1636,10 @@ static bool esw_qos_validate_unsupported_tc_bw(struct mlx5_eswitch *esw, · 332 unmodified lines | ||
| 1654 | 1636 | static bool esw_qos_vport_validate_unsupported_tc_bw(struct mlx5_vport *vport, |
| 1655 | 1637 | u32 *tc_bw) |
| 1656 | 1638 | { |
| 1657 | − struct mlx5_eswitch *esw = vport->qos.sched_node ? | |
| 1658 | − vport->qos.sched_node->parent->esw : | |
| 1659 | − vport->dev->priv.eswitch; | |
| 1639 | + struct mlx5_esw_sched_node *node = vport->qos.sched_node; | |
| 1640 | + struct mlx5_eswitch *esw = vport->dev->priv.eswitch; | |
| 1641 | + | |
| 1642 | + esw = (node && node->parent) ? node->parent->esw : esw; | |
| 1660 | 1643 | |
| 1661 | 1644 | return esw_qos_validate_unsupported_tc_bw(esw, tc_bw); |
| 1662 | 1645 | } |
| @@ -1673,6 +1656,21 @@ static bool esw_qos_tc_bw_disabled(u32 *tc_bw) · 10 unmodified lines | ||
| 1673 | 1656 | return true; |
| 1674 | 1657 | } |
| 1675 | 1658 | |
| 1659 | +static void esw_vport_qos_prune_empty(struct mlx5_vport *vport) | |
| 1660 | +{ | |
| 1661 | + struct mlx5_esw_sched_node *vport_node = vport->qos.sched_node; | |
| 1662 | + | |
| 1663 | + esw_assert_qos_lock_held(vport->dev->priv.eswitch); | |
| 1664 | + if (!vport_node) | |
| 1665 | + return; | |
| 1666 | + | |
| 1667 | + if (vport_node->parent || vport_node->max_rate || | |
| 1668 | + vport_node->min_rate || !esw_qos_tc_bw_disabled(vport_node->tc_bw)) | |
| 1669 | + return; | |
| 1670 | + | |
| 1671 | + mlx5_esw_qos_vport_disable_locked(vport); | |
| 1672 | +} | |
| 1673 | + | |
| 1676 | 1674 | int mlx5_esw_qos_init(struct mlx5_eswitch *esw) |
| 1677 | 1675 | { |
| 1678 | 1676 | if (esw->qos.domain) |
| @@ -1706,6 +1704,10 @@ int mlx5_esw_devlink_rate_leaf_tx_share_set(struct devlink_rate *rate_leaf, void · 27 unmodified lines | ||
| 1706 | 1704 | |
| 1707 | 1705 | esw_qos_lock(esw); |
| 1708 | 1706 | err = mlx5_esw_qos_set_vport_min_rate(vport, tx_share, extack); |
| 1707 | + if (err) | |
| 1708 | + goto out; | |
| 1709 | + esw_vport_qos_prune_empty(vport); | |
| 1710 | +out: | |
| 1709 | 1711 | esw_qos_unlock(esw); |
| 1710 | 1712 | return err; |
| 1711 | 1713 | } |
| @@ -1727,6 +1729,10 @@ int mlx5_esw_devlink_rate_leaf_tx_max_set(struct devlink_rate *rate_leaf, void * · 15 unmodified lines | ||
| 1727 | 1729 | |
| 1728 | 1730 | esw_qos_lock(esw); |
| 1729 | 1731 | err = mlx5_esw_qos_set_vport_max_rate(vport, tx_max, extack); |
| 1732 | + if (err) | |
| 1733 | + goto out; | |
| 1734 | + esw_vport_qos_prune_empty(vport); | |
| 1735 | +out: | |
| 1730 | 1736 | esw_qos_unlock(esw); |
| 1731 | 1737 | return err; |
| 1732 | 1738 | } |
| @@ -1763,7 +1769,8 @@ int mlx5_esw_devlink_rate_leaf_tc_bw_set(struct devlink_rate *rate_leaf, · 30 unmodified lines | ||
| 1763 | 1769 | if (disable) { |
| 1764 | 1770 | if (vport_node->type == SCHED_NODE_TYPE_TC_ARBITER_TSAR) |
| 1765 | 1771 | err = esw_qos_vport_update(vport, SCHED_NODE_TYPE_VPORT, |
| 1766 | − NULL, extack); | |
| 1772 | + vport_node->parent, extack); | |
| 1773 | + esw_vport_qos_prune_empty(vport); | |
| 1767 | 1774 | goto unlock; |
| 1768 | 1775 | } |
| 1769 | 1776 | |
| @@ -1775,7 +1782,7 @@ int mlx5_esw_devlink_rate_leaf_tc_bw_set(struct devlink_rate *rate_leaf, · 5 unmodified lines | ||
| 1775 | 1782 | } else { |
| 1776 | 1783 | err = esw_qos_vport_update(vport, |
| 1777 | 1784 | SCHED_NODE_TYPE_TC_ARBITER_TSAR, |
| 1778 | − NULL, extack); | |
| 1785 | + vport_node->parent, extack); | |
| 1779 | 1786 | } |
| 1780 | 1787 | if (!err) |
| 1781 | 1788 | esw_qos_set_tc_arbiter_bw_shares(vport_node, tc_bw, extack); |
| @@ -1924,14 +1931,20 @@ int mlx5_esw_devlink_rate_leaf_parent_set(struct devlink_rate *devlink_rate, · 142 unmodified lines | ||
| 1924 | 1931 | void *priv, void *parent_priv, |
| 1925 | 1932 | struct netlink_ext_ack *extack) |
| 1926 | 1933 | { |
| 1927 | − struct mlx5_esw_sched_node *node; | |
| 1934 | + struct mlx5_esw_sched_node *node = parent ? parent_priv : NULL; | |
| 1928 | 1935 | struct mlx5_vport *vport = priv; |
| 1936 | + int err; | |
| 1929 | 1937 | |
| 1930 | − if (!parent) | |
| 1931 | − return mlx5_esw_qos_vport_update_parent(vport, NULL, extack); | |
| 1938 | + err = mlx5_esw_qos_vport_update_parent(vport, node, extack); | |
| 1939 | + if (!err) { | |
| 1940 | + struct mlx5_eswitch *esw = vport->dev->priv.eswitch; | |
| 1941 | + | |
| 1942 | + esw_qos_lock(esw); | |
| 1943 | + esw_vport_qos_prune_empty(vport); | |
| 1944 | + esw_qos_unlock(esw); | |
| 1945 | + } | |
| 1932 | 1946 | |
| 1933 | − node = parent_priv; | |
| 1934 | − return mlx5_esw_qos_vport_update_parent(vport, node, extack); | |
| 1947 | + return err; | |
| 1935 | 1948 | } |
| 1936 | 1949 | |
| 1937 | 1950 | static bool esw_qos_is_node_empty(struct mlx5_esw_sched_node *node) |
| @@ -373,11 +373,6 @@ struct mlx5_eswitch { · 372 unmodified lines | ||
| 373 | 373 | refcount_t refcnt; |
| 374 | 374 | u32 root_tsar_ix; |
| 375 | 375 | struct mlx5_qos_domain *domain; |
| 376 | − /* Contains all vports with QoS enabled but no explicit node. | |
| 377 | − * Cannot be NULL if QoS is enabled, but may be a fake node | |
| 378 | − * referencing the root TSAR if the esw doesn't support nodes. | |
| 379 | − */ | |
| 380 | − struct mlx5_esw_sched_node *node0; | |
| 381 | 376 | } qos; |
| 382 | 377 | |
| 383 | 378 | struct mlx5_esw_bridge_offloads *br_offloads; |
| @@ -367,6 +367,8 @@ int mlx5_query_port_dcbx_param(struct mlx5_core_dev *mdev, u32 *out); · 366 unmodified lines | ||
| 367 | 367 | int mlx5_set_port_dcbx_param(struct mlx5_core_dev *mdev, u32 *in); |
| 368 | 368 | int mlx5_set_trust_state(struct mlx5_core_dev *mdev, u8 trust_state); |
| 369 | 369 | int mlx5_query_trust_state(struct mlx5_core_dev *mdev, u8 *trust_state); |
| 370 | +int mlx5_query_port_buffer_ownership(struct mlx5_core_dev *mdev, | |
| 371 | + u8 *buffer_ownership); | |
| 370 | 372 | int mlx5_set_dscp2prio(struct mlx5_core_dev *mdev, u8 dscp, u8 prio); |
| 371 | 373 | int mlx5_query_dscp2prio(struct mlx5_core_dev *mdev, u8 *dscp2prio); |
| 372 | 374 | |
| @@ -968,6 +968,26 @@ int mlx5_query_trust_state(struct mlx5_core_dev *mdev, u8 *trust_state) · 967 unmodified lines | ||
| 968 | 968 | return err; |
| 969 | 969 | } |
| 970 | 970 | |
| 971 | +int mlx5_query_port_buffer_ownership(struct mlx5_core_dev *mdev, | |
| 972 | + u8 *buffer_ownership) | |
| 973 | +{ | |
| 974 | + u32 out[MLX5_ST_SZ_DW(pfcc_reg)] = {}; | |
| 975 | + int err; | |
| 976 | + | |
| 977 | + if (!MLX5_CAP_PCAM_FEATURE(mdev, buffer_ownership)) { | |
| 978 | + *buffer_ownership = MLX5_BUF_OWNERSHIP_UNKNOWN; | |
| 979 | + return 0; | |
| 980 | + } | |
| 981 | + | |
| 982 | + err = mlx5_query_pfcc_reg(mdev, out, sizeof(out)); | |
| 983 | + if (err) | |
| 984 | + return err; | |
| 985 | + | |
| 986 | + *buffer_ownership = MLX5_GET(pfcc_reg, out, buf_ownership); | |
| 987 | + | |
| 988 | + return 0; | |
| 989 | +} | |
| 990 | + | |
| 971 | 991 | int mlx5_set_dscp2prio(struct mlx5_core_dev *mdev, u8 dscp, u8 prio) |
| 972 | 992 | { |
| 973 | 993 | int sz = MLX5_ST_SZ_BYTES(qpdpm_reg); |
| @@ -74,9 +74,9 @@ static void hws_bwc_matcher_init_attr(struct mlx5hws_bwc_matcher *bwc_matcher, · 73 unmodified lines | ||
| 74 | 74 | static int |
| 75 | 75 | hws_bwc_matcher_move_all_simple(struct mlx5hws_bwc_matcher *bwc_matcher) |
| 76 | 76 | { |
| 77 | − bool move_error = false, poll_error = false, drain_error = false; | |
| 78 | 77 | struct mlx5hws_context *ctx = bwc_matcher->matcher->tbl->ctx; |
| 79 | 78 | struct mlx5hws_matcher *matcher = bwc_matcher->matcher; |
| 79 | + int drain_error = 0, move_error = 0, poll_error = 0; | |
| 80 | 80 | u16 bwc_queues = mlx5hws_bwc_queues(ctx); |
| 81 | 81 | struct mlx5hws_rule_attr rule_attr; |
| 82 | 82 | struct mlx5hws_bwc_rule *bwc_rule; |
| @@ -84,6 +84,7 @@ hws_bwc_matcher_move_all_simple(struct mlx5hws_bwc_matcher *bwc_matcher) · 1 unmodified line | ||
| 84 | 84 | struct list_head *rules_list; |
| 85 | 85 | u32 pending_rules; |
| 86 | 86 | int i, ret = 0; |
| 87 | + bool drain; | |
| 87 | 88 | |
| 88 | 89 | mlx5hws_bwc_rule_fill_attr(bwc_matcher, 0, 0, &rule_attr); |
| 89 | 90 | |
| @@ -99,23 +100,37 @@ hws_bwc_matcher_move_all_simple(struct mlx5hws_bwc_matcher *bwc_matcher) · 9 unmodified lines | ||
| 99 | 100 | ret = mlx5hws_matcher_resize_rule_move(matcher, |
| 100 | 101 | bwc_rule->rule, |
| 101 | 102 | &rule_attr); |
| 102 | − if (unlikely(ret && !move_error)) { | |
| 103 | − mlx5hws_err(ctx, | |
| 104 | − "Moving BWC rule: move failed (%d), attempting to move rest of the rules\n", | |
| 105 | − ret); | |
| 106 | − move_error = true; | |
| 103 | + if (unlikely(ret)) { | |
| 104 | + if (!move_error) { | |
| 105 | + mlx5hws_err(ctx, | |
| 106 | + "Moving BWC rule: move failed (%d), attempting to move rest of the rules\n", | |
| 107 | + ret); | |
| 108 | + move_error = ret; | |
| 109 | + } | |
| 110 | + /* Rule wasn't queued, no need to poll */ | |
| 111 | + continue; | |
| 107 | 112 | } |
| 108 | 113 | |
| 109 | 114 | pending_rules++; |
| 115 | + drain = pending_rules >= | |
| 116 | + hws_bwc_get_burst_th(ctx, rule_attr.queue_id); | |
| 110 | 117 | ret = mlx5hws_bwc_queue_poll(ctx, |
| 111 | 118 | rule_attr.queue_id, |
| 112 | 119 | &pending_rules, |
| 113 | − false); | |
| 114 | − if (unlikely(ret && !poll_error)) { | |
| 115 | − mlx5hws_err(ctx, | |
| 116 | − "Moving BWC rule: poll failed (%d), attempting to move rest of the rules\n", | |
| 117 | − ret); | |
| 118 | − poll_error = true; | |
| 120 | + drain); | |
| 121 | + if (unlikely(ret)) { | |
| 122 | + if (ret == -ETIMEDOUT) { | |
| 123 | + mlx5hws_err(ctx, | |
| 124 | + "Moving BWC rule: timeout polling for completions (%d), aborting rehash\n", | |
| 125 | + ret); | |
| 126 | + return ret; | |
| 127 | + } | |
| 128 | + if (!poll_error) { | |
| 129 | + mlx5hws_err(ctx, | |
| 130 | + "Moving BWC rule: polling for completions failed (%d), attempting to move rest of the rules\n", | |
| 131 | + ret); | |
| 132 | + poll_error = ret; | |
| 133 | + } | |
| 119 | 134 | } |
| 120 | 135 | } |
| 121 | 136 | |
| @@ -126,17 +141,30 @@ hws_bwc_matcher_move_all_simple(struct mlx5hws_bwc_matcher *bwc_matcher) · 4 unmodified lines | ||
| 126 | 141 | rule_attr.queue_id, |
| 127 | 142 | &pending_rules, |
| 128 | 143 | true); |
| 129 | − if (unlikely(ret && !drain_error)) { | |
| 130 | − mlx5hws_err(ctx, | |
| 131 | − "Moving BWC rule: drain failed (%d), attempting to move rest of the rules\n", | |
| 132 | − ret); | |
| 133 | − drain_error = true; | |
| 144 | + if (unlikely(ret)) { | |
| 145 | + if (ret == -ETIMEDOUT) { | |
| 146 | + mlx5hws_err(ctx, | |
| 147 | + "Moving bwc rule: timeout draining completions (%d), aborting rehash\n", | |
| 148 | + ret); | |
| 149 | + return ret; | |
| 150 | + } | |
| 151 | + if (!drain_error) { | |
| 152 | + mlx5hws_err(ctx, | |
| 153 | + "Moving bwc rule: drain failed (%d), attempting to move rest of the rules\n", | |
| 154 | + ret); | |
| 155 | + drain_error = ret; | |
| 156 | + } | |
| 134 | 157 | } |
| 135 | 158 | } |
| 136 | 159 | } |
| 137 | 160 | |
| 138 | − if (move_error || poll_error || drain_error) | |
| 139 | − ret = -EINVAL; | |
| 161 | + /* Return the first error that happened */ | |
| 162 | + if (unlikely(move_error)) | |
| 163 | + return move_error; | |
| 164 | + if (unlikely(poll_error)) | |
| 165 | + return poll_error; | |
| 166 | + if (unlikely(drain_error)) | |
| 167 | + return drain_error; | |
| 140 | 168 | |
| 141 | 169 | return ret; |
| 142 | 170 | } |
| @@ -1035,6 +1063,21 @@ int mlx5hws_bwc_rule_create_simple(struct mlx5hws_bwc_rule *bwc_rule, · 892 unmodified lines | ||
| 1035 | 1063 | return 0; /* rule inserted successfully */ |
| 1036 | 1064 | } |
| 1037 | 1065 | |
| 1066 | + /* Rule insertion could fail due to queue being full, timeout, or | |
| 1067 | + * matcher in resize. In such cases, no point in trying to rehash. | |
| 1068 | + */ | |
| 1069 | + if (ret == -EBUSY || ret == -ETIMEDOUT || ret == -EAGAIN) { | |
| 1070 | + mutex_unlock(queue_lock); | |
| 1071 | + mlx5hws_err(ctx, | |
| 1072 | + "BWC rule insertion failed - %s (%d)\n", | |
| 1073 | + ret == -EBUSY ? "queue is full" : | |
| 1074 | + ret == -ETIMEDOUT ? "timeout" : | |
| 1075 | + ret == -EAGAIN ? "matcher in resize" : "N/A", | |
| 1076 | + ret); | |
| 1077 | + hws_bwc_rule_cnt_dec(bwc_rule); | |
| 1078 | + return ret; | |
| 1079 | + } | |
| 1080 | + | |
| 1038 | 1081 | /* At this point the rule wasn't added. |
| 1039 | 1082 | * It could be because there was collision, or some other problem. |
| 1040 | 1083 | * Try rehash by size and insert rule again - last chance. |
| @@ -1328,11 +1328,11 @@ mlx5hws_bwc_matcher_move_all_complex(struct mlx5hws_bwc_matcher *bwc_matcher) · 1327 unmodified lines | ||
| 1328 | 1328 | { |
| 1329 | 1329 | struct mlx5hws_context *ctx = bwc_matcher->matcher->tbl->ctx; |
| 1330 | 1330 | struct mlx5hws_matcher *matcher = bwc_matcher->matcher; |
| 1331 | − bool move_error = false, poll_error = false; | |
| 1332 | 1331 | u16 bwc_queues = mlx5hws_bwc_queues(ctx); |
| 1333 | 1332 | struct mlx5hws_bwc_rule *tmp_bwc_rule; |
| 1334 | 1333 | struct mlx5hws_rule_attr rule_attr; |
| 1335 | 1334 | struct mlx5hws_table *isolated_tbl; |
| 1335 | + int move_error = 0, poll_error = 0; | |
| 1336 | 1336 | struct mlx5hws_rule *tmp_rule; |
| 1337 | 1337 | struct list_head *rules_list; |
| 1338 | 1338 | u32 expected_completions = 1; |
| @@ -1391,11 +1391,15 @@ mlx5hws_bwc_matcher_move_all_complex(struct mlx5hws_bwc_matcher *bwc_matcher) · 52 unmodified lines | ||
| 1391 | 1391 | ret = mlx5hws_matcher_resize_rule_move(matcher, |
| 1392 | 1392 | tmp_rule, |
| 1393 | 1393 | &rule_attr); |
| 1394 | − if (unlikely(ret && !move_error)) { | |
| 1395 | − mlx5hws_err(ctx, | |
| 1396 | − "Moving complex BWC rule failed (%d), attempting to move rest of the rules\n", | |
| 1397 | − ret); | |
| 1398 | − move_error = true; | |
| 1394 | + if (unlikely(ret)) { | |
| 1395 | + if (!move_error) { | |
| 1396 | + mlx5hws_err(ctx, | |
| 1397 | + "Moving complex BWC rule: move failed (%d), attempting to move rest of the rules\n", | |
| 1398 | + ret); | |
| 1399 | + move_error = ret; | |
| 1400 | + } | |
| 1401 | + /* Rule wasn't queued, no need to poll */ | |
| 1402 | + continue; | |
| 1399 | 1403 | } |
| 1400 | 1404 | |
| 1401 | 1405 | expected_completions = 1; |
| @@ -1403,11 +1407,19 @@ mlx5hws_bwc_matcher_move_all_complex(struct mlx5hws_bwc_matcher *bwc_matcher) · 1 unmodified line | ||
| 1403 | 1407 | rule_attr.queue_id, |
| 1404 | 1408 | &expected_completions, |
| 1405 | 1409 | true); |
| 1406 | − if (unlikely(ret && !poll_error)) { | |
| 1407 | − mlx5hws_err(ctx, | |
| 1408 | − "Moving complex BWC rule: poll failed (%d), attempting to move rest of the rules\n", | |
| 1409 | − ret); | |
| 1410 | − poll_error = true; | |
| 1410 | + if (unlikely(ret)) { | |
| 1411 | + if (ret == -ETIMEDOUT) { | |
| 1412 | + mlx5hws_err(ctx, | |
| 1413 | + "Moving complex BWC rule: timeout polling for completions (%d), aborting rehash\n", | |
| 1414 | + ret); | |
| 1415 | + return ret; | |
| 1416 | + } | |
| 1417 | + if (!poll_error) { | |
| 1418 | + mlx5hws_err(ctx, | |
| 1419 | + "Moving complex BWC rule: polling for completions failed (%d), attempting to move rest of the rules\n", | |
| 1420 | + ret); | |
| 1421 | + poll_error = ret; | |
| 1422 | + } | |
| 1411 | 1423 | } |
| 1412 | 1424 | |
| 1413 | 1425 | /* Done moving the rule to the new matcher, |
| @@ -1422,8 +1434,11 @@ mlx5hws_bwc_matcher_move_all_complex(struct mlx5hws_bwc_matcher *bwc_matcher) · 8 unmodified lines | ||
| 1422 | 1434 | } |
| 1423 | 1435 | } |
| 1424 | 1436 | |
| 1425 | − if (move_error || poll_error) | |
| 1426 | − ret = -EINVAL; | |
| 1437 | + /* Return the first error that happened */ | |
| 1438 | + if (unlikely(move_error)) | |
| 1439 | + return move_error; | |
| 1440 | + if (unlikely(poll_error)) | |
| 1441 | + return poll_error; | |
| 1427 | 1442 | |
| 1428 | 1443 | return ret; |
| 1429 | 1444 | } |
| @@ -55,6 +55,7 @@ int mlx5hws_cmd_flow_table_create(struct mlx5_core_dev *mdev, · 54 unmodified lines | ||
| 55 | 55 | |
| 56 | 56 | MLX5_SET(create_flow_table_in, in, opcode, MLX5_CMD_OP_CREATE_FLOW_TABLE); |
| 57 | 57 | MLX5_SET(create_flow_table_in, in, table_type, ft_attr->type); |
| 58 | + MLX5_SET(create_flow_table_in, in, uid, ft_attr->uid); | |
| 58 | 59 | |
| 59 | 60 | ft_ctx = MLX5_ADDR_OF(create_flow_table_in, in, flow_table_context); |
| 60 | 61 | MLX5_SET(flow_table_context, ft_ctx, level, ft_attr->level); |
| @@ -36,6 +36,7 @@ struct mlx5hws_cmd_set_fte_attr { · 35 unmodified lines | ||
| 36 | 36 | struct mlx5hws_cmd_ft_create_attr { |
| 37 | 37 | u8 type; |
| 38 | 38 | u8 level; |
| 39 | + u16 uid; | |
| 39 | 40 | bool rtc_valid; |
| 40 | 41 | bool decap_en; |
| 41 | 42 | bool reformat_en; |
| @@ -267,6 +267,7 @@ static int mlx5_cmd_hws_create_flow_table(struct mlx5_flow_root_namespace *ns, · 266 unmodified lines | ||
| 267 | 267 | |
| 268 | 268 | tbl_attr.type = MLX5HWS_TABLE_TYPE_FDB; |
| 269 | 269 | tbl_attr.level = ft_attr->level; |
| 270 | + tbl_attr.uid = ft_attr->uid; | |
| 270 | 271 | tbl = mlx5hws_table_create(ctx, &tbl_attr); |
| 271 | 272 | if (!tbl) { |
| 272 | 273 | mlx5_core_err(ns->dev, "Failed creating hws flow_table\n"); |
| @@ -85,6 +85,7 @@ static int hws_matcher_create_end_ft_isolated(struct mlx5hws_matcher *matcher) · 84 unmodified lines | ||
| 85 | 85 | |
| 86 | 86 | ret = mlx5hws_table_create_default_ft(tbl->ctx->mdev, |
| 87 | 87 | tbl, |
| 88 | + 0, | |
| 88 | 89 | &matcher->end_ft_id); |
| 89 | 90 | if (ret) { |
| 90 | 91 | mlx5hws_err(tbl->ctx, "Isolated matcher: failed to create end flow table\n"); |
| @@ -112,7 +113,9 @@ static int hws_matcher_create_end_ft(struct mlx5hws_matcher *matcher) · 21 unmodified lines | ||
| 112 | 113 | if (mlx5hws_matcher_is_isolated(matcher)) |
| 113 | 114 | ret = hws_matcher_create_end_ft_isolated(matcher); |
| 114 | 115 | else |
| 115 | − ret = mlx5hws_table_create_default_ft(tbl->ctx->mdev, tbl, | |
| 116 | + ret = mlx5hws_table_create_default_ft(tbl->ctx->mdev, | |
| 117 | + tbl, | |
| 118 | + 0, | |
| 116 | 119 | &matcher->end_ft_id); |
| 117 | 120 | |
| 118 | 121 | if (ret) { |
| @@ -75,6 +75,7 @@ struct mlx5hws_context_attr { · 74 unmodified lines | ||
| 75 | 75 | struct mlx5hws_table_attr { |
| 76 | 76 | enum mlx5hws_table_type type; |
| 77 | 77 | u32 level; |
| 78 | + u16 uid; | |
| 78 | 79 | }; |
| 79 | 80 | |
| 80 | 81 | enum mlx5hws_matcher_flow_src { |
| @@ -964,7 +964,6 @@ static int hws_send_ring_open_cq(struct mlx5_core_dev *mdev, · 963 unmodified lines | ||
| 964 | 964 | return -ENOMEM; |
| 965 | 965 | |
| 966 | 966 | MLX5_SET(cqc, cqc_data, uar_page, mdev->priv.uar->index); |
| 967 | − MLX5_SET(cqc, cqc_data, cqe_sz, queue->num_entries); | |
| 968 | 967 | MLX5_SET(cqc, cqc_data, log_cq_size, ilog2(queue->num_entries)); |
| 969 | 968 | |
| 970 | 969 | err = hws_send_ring_alloc_cq(mdev, numa_node, queue, cqc_data, cq); |
| @@ -9,6 +9,7 @@ u32 mlx5hws_table_get_id(struct mlx5hws_table *tbl) · 8 unmodified lines | ||
| 9 | 9 | } |
| 10 | 10 | |
| 11 | 11 | static void hws_table_init_next_ft_attr(struct mlx5hws_table *tbl, |
| 12 | + u16 uid, | |
| 12 | 13 | struct mlx5hws_cmd_ft_create_attr *ft_attr) |
| 13 | 14 | { |
| 14 | 15 | ft_attr->type = tbl->fw_ft_type; |
| @@ -16,7 +17,9 @@ static void hws_table_init_next_ft_attr(struct mlx5hws_table *tbl, · 1 unmodified line | ||
| 16 | 17 | ft_attr->level = tbl->ctx->caps->fdb_ft.max_level - 1; |
| 17 | 18 | else |
| 18 | 19 | ft_attr->level = tbl->ctx->caps->nic_ft.max_level - 1; |
| 20 | + | |
| 19 | 21 | ft_attr->rtc_valid = true; |
| 22 | + ft_attr->uid = uid; | |
| 20 | 23 | } |
| 21 | 24 | |
| 22 | 25 | static void hws_table_set_cap_attr(struct mlx5hws_table *tbl, |
| @@ -119,12 +122,12 @@ static int hws_table_connect_to_default_miss_tbl(struct mlx5hws_table *tbl, u32 · 96 unmodified lines | ||
| 119 | 122 | |
| 120 | 123 | int mlx5hws_table_create_default_ft(struct mlx5_core_dev *mdev, |
| 121 | 124 | struct mlx5hws_table *tbl, |
| 122 | − u32 *ft_id) | |
| 125 | + u16 uid, u32 *ft_id) | |
| 123 | 126 | { |
| 124 | 127 | struct mlx5hws_cmd_ft_create_attr ft_attr = {0}; |
| 125 | 128 | int ret; |
| 126 | 129 | |
| 127 | − hws_table_init_next_ft_attr(tbl, &ft_attr); | |
| 130 | + hws_table_init_next_ft_attr(tbl, uid, &ft_attr); | |
| 128 | 131 | hws_table_set_cap_attr(tbl, &ft_attr); |
| 129 | 132 | |
| 130 | 133 | ret = mlx5hws_cmd_flow_table_create(mdev, &ft_attr, ft_id); |
| @@ -189,7 +192,10 @@ static int hws_table_init(struct mlx5hws_table *tbl) · 58 unmodified lines | ||
| 189 | 192 | } |
| 190 | 193 | |
| 191 | 194 | mutex_lock(&ctx->ctrl_lock); |
| 192 | − ret = mlx5hws_table_create_default_ft(tbl->ctx->mdev, tbl, &tbl->ft_id); | |
| 195 | + ret = mlx5hws_table_create_default_ft(tbl->ctx->mdev, | |
| 196 | + tbl, | |
| 197 | + tbl->uid, | |
| 198 | + &tbl->ft_id); | |
| 193 | 199 | if (ret) { |
| 194 | 200 | mlx5hws_err(tbl->ctx, "Failed to create flow table object\n"); |
| 195 | 201 | mutex_unlock(&ctx->ctrl_lock); |
| @@ -239,6 +245,7 @@ struct mlx5hws_table *mlx5hws_table_create(struct mlx5hws_context *ctx, · 43 unmodified lines | ||
| 239 | 245 | tbl->ctx = ctx; |
| 240 | 246 | tbl->type = attr->type; |
| 241 | 247 | tbl->level = attr->level; |
| 248 | + tbl->uid = attr->uid; | |
| 242 | 249 | |
| 243 | 250 | ret = hws_table_init(tbl); |
| 244 | 251 | if (ret) { |
| @@ -18,6 +18,7 @@ struct mlx5hws_table { · 17 unmodified lines | ||
| 18 | 18 | enum mlx5hws_table_type type; |
| 19 | 19 | u32 fw_ft_type; |
| 20 | 20 | u32 level; |
| 21 | + u16 uid; | |
| 21 | 22 | struct list_head matchers_list; |
| 22 | 23 | struct list_head tbl_list_node; |
| 23 | 24 | struct mlx5hws_default_miss default_miss; |
| @@ -47,7 +48,7 @@ u32 mlx5hws_table_get_res_fw_ft_type(enum mlx5hws_table_type tbl_type, · 23 unmodified lines | ||
| 47 | 48 | |
| 48 | 49 | int mlx5hws_table_create_default_ft(struct mlx5_core_dev *mdev, |
| 49 | 50 | struct mlx5hws_table *tbl, |
| 50 | − u32 *ft_id); | |
| 51 | + u16 uid, u32 *ft_id); | |
| 51 | 52 | |
| 52 | 53 | void mlx5hws_table_destroy_default_ft(struct mlx5hws_table *tbl, |
| 53 | 54 | u32 ft_id); |
| @@ -2375,6 +2375,8 @@ static const struct mlxsw_listener mlxsw_sp_listener[] = { · 2374 unmodified lines | ||
| 2375 | 2375 | ROUTER_EXP, false), |
| 2376 | 2376 | MLXSW_SP_RXL_NO_MARK(DISCARD_ING_ROUTER_DIP_LINK_LOCAL, FORWARD, |
| 2377 | 2377 | ROUTER_EXP, false), |
| 2378 | + MLXSW_SP_RXL_NO_MARK(DISCARD_ING_ROUTER_SIP_LINK_LOCAL, FORWARD, | |
| 2379 | + ROUTER_EXP, false), | |
| 2378 | 2380 | /* Multicast Router Traps */ |
| 2379 | 2381 | MLXSW_SP_RXL_MARK(ACL1, TRAP_TO_CPU, MULTICAST, false), |
| 2380 | 2382 | MLXSW_SP_RXL_L3_MARK(ACL2, TRAP_TO_CPU, MULTICAST, false), |
| @@ -94,6 +94,7 @@ enum { · 93 unmodified lines | ||
| 94 | 94 | MLXSW_TRAP_ID_DISCARD_ING_ROUTER_IPV4_SIP_BC = 0x16A, |
| 95 | 95 | MLXSW_TRAP_ID_DISCARD_ING_ROUTER_IPV4_DIP_LOCAL_NET = 0x16B, |
| 96 | 96 | MLXSW_TRAP_ID_DISCARD_ING_ROUTER_DIP_LINK_LOCAL = 0x16C, |
| 97 | + MLXSW_TRAP_ID_DISCARD_ING_ROUTER_SIP_LINK_LOCAL = 0x16D, | |
| 97 | 98 | MLXSW_TRAP_ID_DISCARD_ROUTER_IRIF_EN = 0x178, |
| 98 | 99 | MLXSW_TRAP_ID_DISCARD_ROUTER_ERIF_EN = 0x179, |
| 99 | 100 | MLXSW_TRAP_ID_DISCARD_ROUTER_LPM4 = 0x17B, |
| @@ -32,6 +32,10 @@ · 31 unmodified lines | ||
| 32 | 32 | /* MAC Specific Addr 1 Top Reg */ |
| 33 | 33 | #define LAN865X_REG_MAC_H_SADDR1 0x00010023 |
| 34 | 34 | |
| 35 | +/* MAC TSU Timer Increment Register */ | |
| 36 | +#define LAN865X_REG_MAC_TSU_TIMER_INCR 0x00010077 | |
| 37 | +#define MAC_TSU_TIMER_INCR_COUNT_NANOSECONDS 0x0028 | |
| 38 | + | |
| 35 | 39 | struct lan865x_priv { |
| 36 | 40 | struct work_struct multicast_work; |
| 37 | 41 | struct net_device *netdev; |
| @@ -311,6 +315,8 @@ static int lan865x_net_open(struct net_device *netdev) · 273 unmodified lines | ||
| 311 | 315 | |
| 312 | 316 | phy_start(netdev->phydev); |
| 313 | 317 | |
| 318 | + netif_start_queue(netdev); | |
| 319 | + | |
| 314 | 320 | return 0; |
| 315 | 321 | } |
| 316 | 322 | |
| @@ -344,6 +350,21 @@ static int lan865x_probe(struct spi_device *spi) · 27 unmodified lines | ||
| 344 | 350 | goto free_netdev; |
| 345 | 351 | } |
| 346 | 352 | |
| 353 | + /* LAN865x Rev.B0/B1 configuration parameters from AN1760 | |
| 354 | + * As per the Configuration Application Note AN1760 published in the | |
| 355 | + * link, https://www.microchip.com/en-us/application-notes/an1760 | |
| 356 | + * Revision F (DS60001760G - June 2024), configure the MAC to set time | |
| 357 | + * stamping at the end of the Start of Frame Delimiter (SFD) and set the | |
| 358 | + * Timer Increment reg to 40 ns to be used as a 25 MHz internal clock. | |
| 359 | + */ | |
| 360 | + ret = oa_tc6_write_register(priv->tc6, LAN865X_REG_MAC_TSU_TIMER_INCR, | |
| 361 | + MAC_TSU_TIMER_INCR_COUNT_NANOSECONDS); | |
| 362 | + if (ret) { | |
| 363 | + dev_err(&spi->dev, "Failed to config TSU Timer Incr reg: %d\n", | |
| 364 | + ret); | |
| 365 | + goto oa_tc6_exit; | |
| 366 | + } | |
| 367 | + | |
| 347 | 368 | /* As per the point s3 in the below errata, SPI receive Ethernet frame |
| 348 | 369 | * transfer may halt when starting the next frame in the same data block |
| 349 | 370 | * (chunk) as the end of a previous frame. The RFA field should be |
| @@ -241,7 +241,7 @@ union rtase_rx_desc { · 240 unmodified lines | ||
| 241 | 241 | #define RTASE_RX_RES BIT(20) |
| 242 | 242 | #define RTASE_RX_RUNT BIT(19) |
| 243 | 243 | #define RTASE_RX_RWT BIT(18) |
| 244 | −#define RTASE_RX_CRC BIT(16) | |
| 244 | +#define RTASE_RX_CRC BIT(17) | |
| 245 | 245 | #define RTASE_RX_V6F BIT(31) |
| 246 | 246 | #define RTASE_RX_V4F BIT(30) |
| 247 | 247 | #define RTASE_RX_UDPT BIT(29) |
| @@ -152,7 +152,7 @@ static int thead_set_clk_tx_rate(void *bsp_priv, struct clk *clk_tx_i, · 151 unmodified lines | ||
| 152 | 152 | static int thead_dwmac_enable_clk(struct plat_stmmacenet_data *plat) |
| 153 | 153 | { |
| 154 | 154 | struct thead_dwmac *dwmac = plat->bsp_priv; |
| 155 | − u32 reg; | |
| 155 | + u32 reg, div; | |
| 156 | 156 | |
| 157 | 157 | switch (plat->mac_interface) { |
| 158 | 158 | case PHY_INTERFACE_MODE_MII: |
| @@ -164,6 +164,13 @@ static int thead_dwmac_enable_clk(struct plat_stmmacenet_data *plat) · 5 unmodified lines | ||
| 164 | 164 | case PHY_INTERFACE_MODE_RGMII_RXID: |
| 165 | 165 | case PHY_INTERFACE_MODE_RGMII_TXID: |
| 166 | 166 | /* use pll */ |
| 167 | + div = clk_get_rate(plat->stmmac_clk) / rgmii_clock(SPEED_1000); | |
| 168 | + reg = FIELD_PREP(GMAC_PLLCLK_DIV_EN, 1) | | |
| 169 | + FIELD_PREP(GMAC_PLLCLK_DIV_NUM, div); | |
| 170 | + | |
| 171 | + writel(0, dwmac->apb_base + GMAC_PLLCLK_DIV); | |
| 172 | + writel(reg, dwmac->apb_base + GMAC_PLLCLK_DIV); | |
| 173 | + | |
| 167 | 174 | writel(GMAC_GTXCLK_SEL_PLL, dwmac->apb_base + GMAC_GTXCLK_SEL); |
| 168 | 175 | reg = GMAC_TX_CLK_EN | GMAC_TX_CLK_N_EN | GMAC_TX_CLK_OUT_EN | |
| 169 | 176 | GMAC_RX_CLK_EN | GMAC_RX_CLK_N_EN; |
| @@ -203,6 +203,44 @@ static void prueth_emac_stop(struct prueth *prueth) · 202 unmodified lines | ||
| 203 | 203 | } |
| 204 | 204 | } |
| 205 | 205 | |
| 206 | +static void icssg_enable_fw_offload(struct prueth *prueth) | |
| 207 | +{ | |
| 208 | + struct prueth_emac *emac; | |
| 209 | + int mac; | |
| 210 | + | |
| 211 | + for (mac = PRUETH_MAC0; mac < PRUETH_NUM_MACS; mac++) { | |
| 212 | + emac = prueth->emac[mac]; | |
| 213 | + if (prueth->is_hsr_offload_mode) { | |
| 214 | + if (emac->ndev->features & NETIF_F_HW_HSR_TAG_RM) | |
| 215 | + icssg_set_port_state(emac, ICSSG_EMAC_HSR_RX_OFFLOAD_ENABLE); | |
| 216 | + else | |
| 217 | + icssg_set_port_state(emac, ICSSG_EMAC_HSR_RX_OFFLOAD_DISABLE); | |
| 218 | + } | |
| 219 | + | |
| 220 | + if (prueth->is_switch_mode || prueth->is_hsr_offload_mode) { | |
| 221 | + if (netif_running(emac->ndev)) { | |
| 222 | + icssg_fdb_add_del(emac, eth_stp_addr, prueth->default_vlan, | |
| 223 | + ICSSG_FDB_ENTRY_P0_MEMBERSHIP | | |
| 224 | + ICSSG_FDB_ENTRY_P1_MEMBERSHIP | | |
| 225 | + ICSSG_FDB_ENTRY_P2_MEMBERSHIP | | |
| 226 | + ICSSG_FDB_ENTRY_BLOCK, | |
| 227 | + true); | |
| 228 | + icssg_vtbl_modify(emac, emac->port_vlan | DEFAULT_VID, | |
| 229 | + BIT(emac->port_id) | DEFAULT_PORT_MASK, | |
| 230 | + BIT(emac->port_id) | DEFAULT_UNTAG_MASK, | |
| 231 | + true); | |
| 232 | + if (prueth->is_hsr_offload_mode) | |
| 233 | + icssg_vtbl_modify(emac, DEFAULT_VID, | |
| 234 | + DEFAULT_PORT_MASK, | |
| 235 | + DEFAULT_UNTAG_MASK, true); | |
| 236 | + icssg_set_pvid(prueth, emac->port_vlan, emac->port_id); | |
| 237 | + if (prueth->is_switch_mode) | |
| 238 | + icssg_set_port_state(emac, ICSSG_EMAC_PORT_VLAN_AWARE_ENABLE); | |
| 239 | + } | |
| 240 | + } | |
| 241 | + } | |
| 242 | +} | |
| 243 | + | |
| 206 | 244 | static int prueth_emac_common_start(struct prueth *prueth) |
| 207 | 245 | { |
| 208 | 246 | struct prueth_emac *emac; |
| @@ -753,6 +791,7 @@ static int emac_ndo_open(struct net_device *ndev) · 544 unmodified lines | ||
| 753 | 791 | ret = prueth_emac_common_start(prueth); |
| 754 | 792 | if (ret) |
| 755 | 793 | goto free_rx_irq; |
| 794 | + icssg_enable_fw_offload(prueth); | |
| 756 | 795 | } |
| 757 | 796 | |
| 758 | 797 | flow_cfg = emac->dram.va + ICSSG_CONFIG_OFFSET + PSI_L_REGULAR_FLOW_ID_BASE_OFFSET; |
| @@ -1360,8 +1399,7 @@ static int prueth_emac_restart(struct prueth *prueth) · 601 unmodified lines | ||
| 1360 | 1399 | |
| 1361 | 1400 | static void icssg_change_mode(struct prueth *prueth) |
| 1362 | 1401 | { |
| 1363 | − struct prueth_emac *emac; | |
| 1364 | − int mac, ret; | |
| 1402 | + int ret; | |
| 1365 | 1403 | |
| 1366 | 1404 | ret = prueth_emac_restart(prueth); |
| 1367 | 1405 | if (ret) { |
| @@ -1369,35 +1407,7 @@ static void icssg_change_mode(struct prueth *prueth) · 1 unmodified line | ||
| 1369 | 1407 | return; |
| 1370 | 1408 | } |
| 1371 | 1409 | |
| 1372 | − for (mac = PRUETH_MAC0; mac < PRUETH_NUM_MACS; mac++) { | |
| 1373 | − emac = prueth->emac[mac]; | |
| 1374 | − if (prueth->is_hsr_offload_mode) { | |
| 1375 | − if (emac->ndev->features & NETIF_F_HW_HSR_TAG_RM) | |
| 1376 | − icssg_set_port_state(emac, ICSSG_EMAC_HSR_RX_OFFLOAD_ENABLE); | |
| 1377 | − else | |
| 1378 | − icssg_set_port_state(emac, ICSSG_EMAC_HSR_RX_OFFLOAD_DISABLE); | |
| 1379 | − } | |
| 1380 | − | |
| 1381 | − if (netif_running(emac->ndev)) { | |
| 1382 | − icssg_fdb_add_del(emac, eth_stp_addr, prueth->default_vlan, | |
| 1383 | − ICSSG_FDB_ENTRY_P0_MEMBERSHIP | | |
| 1384 | − ICSSG_FDB_ENTRY_P1_MEMBERSHIP | | |
| 1385 | − ICSSG_FDB_ENTRY_P2_MEMBERSHIP | | |
| 1386 | − ICSSG_FDB_ENTRY_BLOCK, | |
| 1387 | − true); | |
| 1388 | − icssg_vtbl_modify(emac, emac->port_vlan | DEFAULT_VID, | |
| 1389 | − BIT(emac->port_id) | DEFAULT_PORT_MASK, | |
| 1390 | − BIT(emac->port_id) | DEFAULT_UNTAG_MASK, | |
| 1391 | − true); | |
| 1392 | − if (prueth->is_hsr_offload_mode) | |
| 1393 | − icssg_vtbl_modify(emac, DEFAULT_VID, | |
| 1394 | − DEFAULT_PORT_MASK, | |
| 1395 | − DEFAULT_UNTAG_MASK, true); | |
| 1396 | − icssg_set_pvid(prueth, emac->port_vlan, emac->port_id); | |
| 1397 | − if (prueth->is_switch_mode) | |
| 1398 | − icssg_set_port_state(emac, ICSSG_EMAC_PORT_VLAN_AWARE_ENABLE); | |
| 1399 | − } | |
| 1400 | − } | |
| 1410 | + icssg_enable_fw_offload(prueth); | |
| 1401 | 1411 | } |
| 1402 | 1412 | |
| 1403 | 1413 | static int prueth_netdevice_port_link(struct net_device *ndev, |
| @@ -192,7 +192,7 @@ void wx_setup_vfmrqc_vf(struct wx *wx) · 191 unmodified lines | ||
| 192 | 192 | u8 i, j; |
| 193 | 193 | |
| 194 | 194 | /* Fill out hash function seeds */ |
| 195 | − netdev_rss_key_fill(wx->rss_key, sizeof(wx->rss_key)); | |
| 195 | + netdev_rss_key_fill(wx->rss_key, WX_RSS_KEY_SIZE); | |
| 196 | 196 | for (i = 0; i < WX_RSS_KEY_SIZE / 4; i++) |
| 197 | 197 | wr32(wx, WX_VXRSSRK(i), wx->rss_key[i]); |
| 198 | 198 | |
| @@ -1160,6 +1160,7 @@ static void axienet_dma_rx_cb(void *data, const struct dmaengine_result *result) · 1159 unmodified lines | ||
| 1160 | 1160 | struct axienet_local *lp = data; |
| 1161 | 1161 | struct sk_buff *skb; |
| 1162 | 1162 | u32 *app_metadata; |
| 1163 | + int i; | |
| 1163 | 1164 | |
| 1164 | 1165 | skbuf_dma = axienet_get_rx_desc(lp, lp->rx_ring_tail++); |
| 1165 | 1166 | skb = skbuf_dma->skb; |
| @@ -1178,7 +1179,10 @@ static void axienet_dma_rx_cb(void *data, const struct dmaengine_result *result) · 12 unmodified lines | ||
| 1178 | 1179 | u64_stats_add(&lp->rx_packets, 1); |
| 1179 | 1180 | u64_stats_add(&lp->rx_bytes, rx_len); |
| 1180 | 1181 | u64_stats_update_end(&lp->rx_stat_sync); |
| 1181 | − axienet_rx_submit_desc(lp->ndev); | |
| 1182 | + | |
| 1183 | + for (i = 0; i < CIRC_SPACE(lp->rx_ring_head, lp->rx_ring_tail, | |
| 1184 | + RX_BUF_NUM_DEFAULT); i++) | |
| 1185 | + axienet_rx_submit_desc(lp->ndev); | |
| 1182 | 1186 | dma_async_issue_pending(lp->rx_chan); |
| 1183 | 1187 | } |
| 1184 | 1188 | |
| @@ -1457,7 +1461,6 @@ static void axienet_rx_submit_desc(struct net_device *ndev) · 272 unmodified lines | ||
| 1457 | 1461 | if (!skbuf_dma) |
| 1458 | 1462 | return; |
| 1459 | 1463 | |
| 1460 | − lp->rx_ring_head++; | |
| 1461 | 1464 | skb = netdev_alloc_skb(ndev, lp->max_frm_size); |
| 1462 | 1465 | if (!skb) |
| 1463 | 1466 | return; |
| @@ -1482,6 +1485,7 @@ static void axienet_rx_submit_desc(struct net_device *ndev) · 18 unmodified lines | ||
| 1482 | 1485 | skbuf_dma->desc = dma_rx_desc; |
| 1483 | 1486 | dma_rx_desc->callback_param = lp; |
| 1484 | 1487 | dma_rx_desc->callback_result = axienet_dma_rx_cb; |
| 1488 | + lp->rx_ring_head++; | |
| 1485 | 1489 | dmaengine_submit(dma_rx_desc); |
| 1486 | 1490 | |
| 1487 | 1491 | return; |
| @@ -362,6 +362,13 @@ struct vsc85xx_hw_stat { · 361 unmodified lines | ||
| 362 | 362 | u16 mask; |
| 363 | 363 | }; |
| 364 | 364 | |
| 365 | +struct vsc8531_skb_cb { | |
| 366 | + u32 ns; | |
| 367 | +}; | |
| 368 | + | |
| 369 | +#define VSC8531_SKB_CB(skb) \ | |
| 370 | + ((struct vsc8531_skb_cb *)((skb)->cb)) | |
| 371 | + | |
| 365 | 372 | struct vsc8531_private { |
| 366 | 373 | int rate_magic; |
| 367 | 374 | u16 supp_led_modes; |
| @@ -410,6 +417,11 @@ struct vsc8531_private { · 42 unmodified lines | ||
| 410 | 417 | */ |
| 411 | 418 | struct mutex ts_lock; |
| 412 | 419 | struct mutex phc_lock; |
| 420 | + | |
| 421 | + /* list of skbs that were received and need timestamp information but it | |
| 422 | + * didn't received it yet | |
| 423 | + */ | |
| 424 | + struct sk_buff_head rx_skbs_list; | |
| 413 | 425 | }; |
| 414 | 426 | |
| 415 | 427 | /* Shared structure between the PHYs of the same package. |
| @@ -2335,6 +2335,13 @@ static int vsc85xx_probe(struct phy_device *phydev) · 2334 unmodified lines | ||
| 2335 | 2335 | return vsc85xx_dt_led_modes_get(phydev, default_mode); |
| 2336 | 2336 | } |
| 2337 | 2337 | |
| 2338 | +static void vsc85xx_remove(struct phy_device *phydev) | |
| 2339 | +{ | |
| 2340 | + struct vsc8531_private *priv = phydev->priv; | |
| 2341 | + | |
| 2342 | + skb_queue_purge(&priv->rx_skbs_list); | |
| 2343 | +} | |
| 2344 | + | |
| 2338 | 2345 | /* Microsemi VSC85xx PHYs */ |
| 2339 | 2346 | static struct phy_driver vsc85xx_driver[] = { |
| 2340 | 2347 | { |
| @@ -2589,6 +2596,7 @@ static struct phy_driver vsc85xx_driver[] = { · 248 unmodified lines | ||
| 2589 | 2596 | .config_intr = &vsc85xx_config_intr, |
| 2590 | 2597 | .suspend = &genphy_suspend, |
| 2591 | 2598 | .resume = &genphy_resume, |
| 2599 | + .remove = &vsc85xx_remove, | |
| 2592 | 2600 | .probe = &vsc8574_probe, |
| 2593 | 2601 | .set_wol = &vsc85xx_wol_set, |
| 2594 | 2602 | .get_wol = &vsc85xx_wol_get, |
| @@ -2614,6 +2622,7 @@ static struct phy_driver vsc85xx_driver[] = { · 19 unmodified lines | ||
| 2614 | 2622 | .config_intr = &vsc85xx_config_intr, |
| 2615 | 2623 | .suspend = &genphy_suspend, |
| 2616 | 2624 | .resume = &genphy_resume, |
| 2625 | + .remove = &vsc85xx_remove, | |
| 2617 | 2626 | .probe = &vsc8574_probe, |
| 2618 | 2627 | .set_wol = &vsc85xx_wol_set, |
| 2619 | 2628 | .get_wol = &vsc85xx_wol_get, |
| @@ -2639,6 +2648,7 @@ static struct phy_driver vsc85xx_driver[] = { · 19 unmodified lines | ||
| 2639 | 2648 | .config_intr = &vsc85xx_config_intr, |
| 2640 | 2649 | .suspend = &genphy_suspend, |
| 2641 | 2650 | .resume = &genphy_resume, |
| 2651 | + .remove = &vsc85xx_remove, | |
| 2642 | 2652 | .probe = &vsc8584_probe, |
| 2643 | 2653 | .get_tunable = &vsc85xx_get_tunable, |
| 2644 | 2654 | .set_tunable = &vsc85xx_set_tunable, |
| @@ -2662,6 +2672,7 @@ static struct phy_driver vsc85xx_driver[] = { · 17 unmodified lines | ||
| 2662 | 2672 | .config_intr = &vsc85xx_config_intr, |
| 2663 | 2673 | .suspend = &genphy_suspend, |
| 2664 | 2674 | .resume = &genphy_resume, |
| 2675 | + .remove = &vsc85xx_remove, | |
| 2665 | 2676 | .probe = &vsc8584_probe, |
| 2666 | 2677 | .get_tunable = &vsc85xx_get_tunable, |
| 2667 | 2678 | .set_tunable = &vsc85xx_set_tunable, |
| @@ -2685,6 +2696,7 @@ static struct phy_driver vsc85xx_driver[] = { · 17 unmodified lines | ||
| 2685 | 2696 | .config_intr = &vsc85xx_config_intr, |
| 2686 | 2697 | .suspend = &genphy_suspend, |
| 2687 | 2698 | .resume = &genphy_resume, |
| 2699 | + .remove = &vsc85xx_remove, | |
| 2688 | 2700 | .probe = &vsc8584_probe, |
| 2689 | 2701 | .get_tunable = &vsc85xx_get_tunable, |
| 2690 | 2702 | .set_tunable = &vsc85xx_set_tunable, |
| @@ -1194,9 +1194,7 @@ static bool vsc85xx_rxtstamp(struct mii_timestamper *mii_ts, · 1193 unmodified lines | ||
| 1194 | 1194 | { |
| 1195 | 1195 | struct vsc8531_private *vsc8531 = |
| 1196 | 1196 | container_of(mii_ts, struct vsc8531_private, mii_ts); |
| 1197 | − struct skb_shared_hwtstamps *shhwtstamps = NULL; | |
| 1198 | 1197 | struct vsc85xx_ptphdr *ptphdr; |
| 1199 | − struct timespec64 ts; | |
| 1200 | 1198 | unsigned long ns; |
| 1201 | 1199 | |
| 1202 | 1200 | if (!vsc8531->ptp->configured) |
| @@ -1206,27 +1204,52 @@ static bool vsc85xx_rxtstamp(struct mii_timestamper *mii_ts, · 3 unmodified lines | ||
| 1206 | 1204 | type == PTP_CLASS_NONE) |
| 1207 | 1205 | return false; |
| 1208 | 1206 | |
| 1209 | − vsc85xx_gettime(&vsc8531->ptp->caps, &ts); | |
| 1210 | − | |
| 1211 | 1207 | ptphdr = get_ptp_header_rx(skb, vsc8531->ptp->rx_filter); |
| 1212 | 1208 | if (!ptphdr) |
| 1213 | 1209 | return false; |
| 1214 | 1210 | |
| 1215 | − shhwtstamps = skb_hwtstamps(skb); | |
| 1216 | − memset(shhwtstamps, 0, sizeof(struct skb_shared_hwtstamps)); | |
| 1217 | − | |
| 1218 | 1211 | ns = ntohl(ptphdr->rsrvd2); |
| 1219 | 1212 | |
| 1220 | − /* nsec is in reserved field */ | |
| 1221 | − if (ts.tv_nsec < ns) | |
| 1222 | − ts.tv_sec--; | |
| 1213 | + VSC8531_SKB_CB(skb)->ns = ns; | |
| 1214 | + skb_queue_tail(&vsc8531->rx_skbs_list, skb); | |
| 1223 | 1215 | |
| 1224 | − shhwtstamps->hwtstamp = ktime_set(ts.tv_sec, ns); | |
| 1225 | − netif_rx(skb); | |
| 1216 | + ptp_schedule_worker(vsc8531->ptp->ptp_clock, 0); | |
| 1226 | 1217 | |
| 1227 | 1218 | return true; |
| 1228 | 1219 | } |
| 1229 | 1220 | |
| 1221 | +static long vsc85xx_do_aux_work(struct ptp_clock_info *info) | |
| 1222 | +{ | |
| 1223 | + struct vsc85xx_ptp *ptp = container_of(info, struct vsc85xx_ptp, caps); | |
| 1224 | + struct skb_shared_hwtstamps *shhwtstamps = NULL; | |
| 1225 | + struct phy_device *phydev = ptp->phydev; | |
| 1226 | + struct vsc8531_private *priv = phydev->priv; | |
| 1227 | + struct sk_buff_head received; | |
| 1228 | + struct sk_buff *rx_skb; | |
| 1229 | + struct timespec64 ts; | |
| 1230 | + unsigned long flags; | |
| 1231 | + | |
| 1232 | + __skb_queue_head_init(&received); | |
| 1233 | + spin_lock_irqsave(&priv->rx_skbs_list.lock, flags); | |
| 1234 | + skb_queue_splice_tail_init(&priv->rx_skbs_list, &received); | |
| 1235 | + spin_unlock_irqrestore(&priv->rx_skbs_list.lock, flags); | |
| 1236 | + | |
| 1237 | + vsc85xx_gettime(info, &ts); | |
| 1238 | + while ((rx_skb = __skb_dequeue(&received)) != NULL) { | |
| 1239 | + shhwtstamps = skb_hwtstamps(rx_skb); | |
| 1240 | + memset(shhwtstamps, 0, sizeof(struct skb_shared_hwtstamps)); | |
| 1241 | + | |
| 1242 | + if (ts.tv_nsec < VSC8531_SKB_CB(rx_skb)->ns) | |
| 1243 | + ts.tv_sec--; | |
| 1244 | + | |
| 1245 | + shhwtstamps->hwtstamp = ktime_set(ts.tv_sec, | |
| 1246 | + VSC8531_SKB_CB(rx_skb)->ns); | |
| 1247 | + netif_rx(rx_skb); | |
| 1248 | + } | |
| 1249 | + | |
| 1250 | + return -1; | |
| 1251 | +} | |
| 1252 | + | |
| 1230 | 1253 | static const struct ptp_clock_info vsc85xx_clk_caps = { |
| 1231 | 1254 | .owner = THIS_MODULE, |
| 1232 | 1255 | .name = "VSC85xx timer", |
| @@ -1240,6 +1263,7 @@ static const struct ptp_clock_info vsc85xx_clk_caps = { · 7 unmodified lines | ||
| 1240 | 1263 | .adjfine = &vsc85xx_adjfine, |
| 1241 | 1264 | .gettime64 = &vsc85xx_gettime, |
| 1242 | 1265 | .settime64 = &vsc85xx_settime, |
| 1266 | + .do_aux_work = &vsc85xx_do_aux_work, | |
| 1243 | 1267 | }; |
| 1244 | 1268 | |
| 1245 | 1269 | static struct vsc8531_private *vsc8584_base_priv(struct phy_device *phydev) |
| @@ -1567,6 +1591,7 @@ int vsc8584_ptp_probe(struct phy_device *phydev) · 321 unmodified lines | ||
| 1567 | 1591 | |
| 1568 | 1592 | mutex_init(&vsc8531->phc_lock); |
| 1569 | 1593 | mutex_init(&vsc8531->ts_lock); |
| 1594 | + skb_queue_head_init(&vsc8531->rx_skbs_list); | |
| 1570 | 1595 | |
| 1571 | 1596 | /* Retrieve the shared load/save GPIO. Request it as non exclusive as |
| 1572 | 1597 | * the same GPIO can be requested by all the PHYs of the same package. |
| @@ -33,6 +33,7 @@ · 32 unmodified lines | ||
| 33 | 33 | #include <linux/ppp_channel.h> |
| 34 | 34 | #include <linux/ppp-comp.h> |
| 35 | 35 | #include <linux/skbuff.h> |
| 36 | +#include <linux/rculist.h> | |
| 36 | 37 | #include <linux/rtnetlink.h> |
| 37 | 38 | #include <linux/if_arp.h> |
| 38 | 39 | #include <linux/ip.h> |
| @@ -1598,11 +1599,14 @@ static int ppp_fill_forward_path(struct net_device_path_ctx *ctx, · 1559 unmodified lines | ||
| 1598 | 1599 | if (ppp->flags & SC_MULTILINK) |
| 1599 | 1600 | return -EOPNOTSUPP; |
| 1600 | 1601 | |
| 1601 | − if (list_empty(&ppp->channels)) | |
| 1602 | + pch = list_first_or_null_rcu(&ppp->channels, struct channel, clist); | |
| 1603 | + if (!pch) | |
| 1604 | + return -ENODEV; | |
| 1605 | + | |
| 1606 | + chan = READ_ONCE(pch->chan); | |
| 1607 | + if (!chan) | |
| 1602 | 1608 | return -ENODEV; |
| 1603 | 1609 | |
| 1604 | − pch = list_first_entry(&ppp->channels, struct channel, clist); | |
| 1605 | − chan = pch->chan; | |
| 1606 | 1610 | if (!chan->ops->fill_forward_path) |
| 1607 | 1611 | return -EOPNOTSUPP; |
| 1608 | 1612 | |
| @@ -2994,7 +2998,7 @@ ppp_unregister_channel(struct ppp_channel *chan) · 1385 unmodified lines | ||
| 2994 | 2998 | */ |
| 2995 | 2999 | down_write(&pch->chan_sem); |
| 2996 | 3000 | spin_lock_bh(&pch->downl); |
| 2997 | − pch->chan = NULL; | |
| 3001 | + WRITE_ONCE(pch->chan, NULL); | |
| 2998 | 3002 | spin_unlock_bh(&pch->downl); |
| 2999 | 3003 | up_write(&pch->chan_sem); |
| 3000 | 3004 | ppp_disconnect_channel(pch); |
| @@ -3515,7 +3519,7 @@ ppp_connect_channel(struct channel *pch, int unit) · 514 unmodified lines | ||
| 3515 | 3519 | hdrlen = pch->file.hdrlen + 2; /* for protocol bytes */ |
| 3516 | 3520 | if (hdrlen > ppp->dev->hard_header_len) |
| 3517 | 3521 | ppp->dev->hard_header_len = hdrlen; |
| 3518 | − list_add_tail(&pch->clist, &ppp->channels); | |
| 3522 | + list_add_tail_rcu(&pch->clist, &ppp->channels); | |
| 3519 | 3523 | ++ppp->n_channels; |
| 3520 | 3524 | pch->ppp = ppp; |
| 3521 | 3525 | refcount_inc(&ppp->file.refcnt); |
| @@ -3545,10 +3549,11 @@ ppp_disconnect_channel(struct channel *pch) · 23 unmodified lines | ||
| 3545 | 3549 | if (ppp) { |
| 3546 | 3550 | /* remove it from the ppp unit's list */ |
| 3547 | 3551 | ppp_lock(ppp); |
| 3548 | − list_del(&pch->clist); | |
| 3552 | + list_del_rcu(&pch->clist); | |
| 3549 | 3553 | if (--ppp->n_channels == 0) |
| 3550 | 3554 | wake_up_interruptible(&ppp->file.rwait); |
| 3551 | 3555 | ppp_unlock(ppp); |
| 3556 | + synchronize_net(); | |
| 3552 | 3557 | if (refcount_dec_and_test(&ppp->file.refcnt)) |
| 3553 | 3558 | ppp_destroy_interface(ppp); |
| 3554 | 3559 | err = 0; |
| @@ -1041,6 +1041,10 @@ pd692x0_configure_managers(struct pd692x0_priv *priv, int nmanagers) · 1040 unmodified lines | ||
| 1041 | 1041 | int pw_budget; |
| 1042 | 1042 | |
| 1043 | 1043 | pw_budget = regulator_get_unclaimed_power_budget(supply); |
| 1044 | + if (!pw_budget) | |
| 1045 | + /* Do nothing if no power budget */ | |
| 1046 | + continue; | |
| 1047 | + | |
| 1044 | 1048 | /* Max power budget per manager */ |
| 1045 | 1049 | if (pw_budget > 6000000) |
| 1046 | 1050 | pw_budget = 6000000; |
| @@ -1162,12 +1166,44 @@ pd692x0_write_ports_matrix(struct pd692x0_priv *priv, · 115 unmodified lines | ||
| 1162 | 1166 | return 0; |
| 1163 | 1167 | } |
| 1164 | 1168 | |
| 1169 | +static void pd692x0_of_put_managers(struct pd692x0_priv *priv, | |
| 1170 | + struct pd692x0_manager *manager, | |
| 1171 | + int nmanagers) | |
| 1172 | +{ | |
| 1173 | + int i, j; | |
| 1174 | + | |
| 1175 | + for (i = 0; i < nmanagers; i++) { | |
| 1176 | + for (j = 0; j < manager[i].nports; j++) | |
| 1177 | + of_node_put(manager[i].port_node[j]); | |
| 1178 | + of_node_put(manager[i].node); | |
| 1179 | + } | |
| 1180 | +} | |
| 1181 | + | |
| 1182 | +static void pd692x0_managers_free_pw_budget(struct pd692x0_priv *priv) | |
| 1183 | +{ | |
| 1184 | + int i; | |
| 1185 | + | |
| 1186 | + for (i = 0; i < PD692X0_MAX_MANAGERS; i++) { | |
| 1187 | + struct regulator *supply; | |
| 1188 | + | |
| 1189 | + if (!priv->manager_reg[i] || !priv->manager_pw_budget[i]) | |
| 1190 | + continue; | |
| 1191 | + | |
| 1192 | + supply = priv->manager_reg[i]->supply; | |
| 1193 | + if (!supply) | |
| 1194 | + continue; | |
| 1195 | + | |
| 1196 | + regulator_free_power_budget(supply, | |
| 1197 | + priv->manager_pw_budget[i]); | |
| 1198 | + } | |
| 1199 | +} | |
| 1200 | + | |
| 1165 | 1201 | static int pd692x0_setup_pi_matrix(struct pse_controller_dev *pcdev) |
| 1166 | 1202 | { |
| 1167 | 1203 | struct pd692x0_manager *manager __free(kfree) = NULL; |
| 1168 | 1204 | struct pd692x0_priv *priv = to_pd692x0_priv(pcdev); |
| 1169 | 1205 | struct pd692x0_matrix port_matrix[PD692X0_MAX_PIS]; |
| 1170 | − int ret, i, j, nmanagers; | |
| 1206 | + int ret, nmanagers; | |
| 1171 | 1207 | |
| 1172 | 1208 | /* Should we flash the port matrix */ |
| 1173 | 1209 | if (priv->fw_state != PD692X0_FW_OK && |
| @@ -1185,31 +1221,27 @@ static int pd692x0_setup_pi_matrix(struct pse_controller_dev *pcdev) · 11 unmodified lines | ||
| 1185 | 1221 | nmanagers = ret; |
| 1186 | 1222 | ret = pd692x0_register_managers_regulator(priv, manager, nmanagers); |
| 1187 | 1223 | if (ret) |
| 1188 | − goto out; | |
| 1224 | + goto err_of_managers; | |
| 1189 | 1225 | |
| 1190 | 1226 | ret = pd692x0_configure_managers(priv, nmanagers); |
| 1191 | 1227 | if (ret) |
| 1192 | − goto out; | |
| 1228 | + goto err_of_managers; | |
| 1193 | 1229 | |
| 1194 | 1230 | ret = pd692x0_set_ports_matrix(priv, manager, nmanagers, port_matrix); |
| 1195 | 1231 | if (ret) |
| 1196 | − goto out; | |
| 1232 | + goto err_managers_req_pw; | |
| 1197 | 1233 | |
| 1198 | 1234 | ret = pd692x0_write_ports_matrix(priv, port_matrix); |
| 1199 | 1235 | if (ret) |
| 1200 | − goto out; | |
| 1201 | − | |
| 1202 | −out: | |
| 1203 | − for (i = 0; i < nmanagers; i++) { | |
| 1204 | − struct regulator *supply = priv->manager_reg[i]->supply; | |
| 1236 | + goto err_managers_req_pw; | |
| 1205 | 1237 | |
| 1206 | − regulator_free_power_budget(supply, | |
| 1207 | − priv->manager_pw_budget[i]); | |
| 1238 | + pd692x0_of_put_managers(priv, manager, nmanagers); | |
| 1239 | + return 0; | |
| 1208 | 1240 | |
| 1209 | − for (j = 0; j < manager[i].nports; j++) | |
| 1210 | − of_node_put(manager[i].port_node[j]); | |
| 1211 | − of_node_put(manager[i].node); | |
| 1212 | − } | |
| 1241 | +err_managers_req_pw: | |
| 1242 | + pd692x0_managers_free_pw_budget(priv); | |
| 1243 | +err_of_managers: | |
| 1244 | + pd692x0_of_put_managers(priv, manager, nmanagers); | |
| 1213 | 1245 | return ret; |
| 1214 | 1246 | } |
| 1215 | 1247 | |
| @@ -1748,6 +1780,7 @@ static void pd692x0_i2c_remove(struct i2c_client *client) · 532 unmodified lines | ||
| 1748 | 1780 | { |
| 1749 | 1781 | struct pd692x0_priv *priv = i2c_get_clientdata(client); |
| 1750 | 1782 | |
| 1783 | + pd692x0_managers_free_pw_budget(priv); | |
| 1751 | 1784 | firmware_upload_unregister(priv->fwl); |
| 1752 | 1785 | } |
| 1753 | 1786 | |
| @@ -676,7 +676,7 @@ static int ax88772_init_mdio(struct usbnet *dev) · 675 unmodified lines | ||
| 676 | 676 | priv->mdio->read = &asix_mdio_bus_read; |
| 677 | 677 | priv->mdio->write = &asix_mdio_bus_write; |
| 678 | 678 | priv->mdio->name = "Asix MDIO Bus"; |
| 679 | − priv->mdio->phy_mask = ~(BIT(priv->phy_addr) | BIT(AX_EMBD_PHY_ADDR)); | |
| 679 | + priv->mdio->phy_mask = ~(BIT(priv->phy_addr & 0x1f) | BIT(AX_EMBD_PHY_ADDR)); | |
| 680 | 680 | /* mii bus name is usb-<usb bus number>-<usb device number> */ |
| 681 | 681 | snprintf(priv->mdio->id, MII_BUS_ID_SIZE, "usb-%03d:%03d", |
| 682 | 682 | dev->udev->bus->busnum, dev->udev->devnum); |
| @@ -2087,6 +2087,13 @@ static const struct usb_device_id cdc_devs[] = { · 2086 unmodified lines | ||
| 2087 | 2087 | .driver_info = (unsigned long)&wwan_info, |
| 2088 | 2088 | }, |
| 2089 | 2089 | |
| 2090 | + /* Intel modem (label from OEM reads Fibocom L850-GL) */ | |
| 2091 | + { USB_DEVICE_AND_INTERFACE_INFO(0x8087, 0x095a, | |
| 2092 | + USB_CLASS_COMM, | |
| 2093 | + USB_CDC_SUBCLASS_NCM, USB_CDC_PROTO_NONE), | |
| 2094 | + .driver_info = (unsigned long)&wwan_info, | |
| 2095 | + }, | |
| 2096 | + | |
| 2090 | 2097 | /* DisplayLink docking stations */ |
| 2091 | 2098 | { .match_flags = USB_DEVICE_ID_MATCH_INT_INFO |
| 2092 | 2099 | | USB_DEVICE_ID_MATCH_VENDOR, |
| @@ -400,7 +400,7 @@ static irqreturn_t xilinx_pcie_intr_handler(int irq, void *data) · 399 unmodified lines | ||
| 400 | 400 | if (val & XILINX_PCIE_RPIFR1_MSI_INTR) { |
| 401 | 401 | val = pcie_read(pcie, XILINX_PCIE_REG_RPIFR2) & |
| 402 | 402 | XILINX_PCIE_RPIFR2_MSG_DATA; |
| 403 | − domain = pcie->msi_domain->parent; | |
| 403 | + domain = pcie->msi_domain; | |
| 404 | 404 | } else { |
| 405 | 405 | val = (val & XILINX_PCIE_RPIFR1_INTR_MASK) >> |
| 406 | 406 | XILINX_PCIE_RPIFR1_INTR_SHIFT; |
| @@ -306,9 +306,6 @@ static bool vmd_init_dev_msi_info(struct device *dev, struct irq_domain *domain, · 305 unmodified lines | ||
| 306 | 306 | struct irq_domain *real_parent, |
| 307 | 307 | struct msi_domain_info *info) |
| 308 | 308 | { |
| 309 | − if (WARN_ON_ONCE(info->bus_token != DOMAIN_BUS_PCI_DEVICE_MSIX)) | |
| 310 | − return false; | |
| 311 | − | |
| 312 | 309 | if (!msi_lib_init_dev_msi_info(dev, domain, real_parent, info)) |
| 313 | 310 | return false; |
| 314 | 311 | |
| @@ -504,7 +504,7 @@ static int init_acpi(struct device *dev) · 503 unmodified lines | ||
| 504 | 504 | |
| 505 | 505 | dev_set_drvdata(dev, &hsmp_pdev->sock[sock_ind]); |
| 506 | 506 | |
| 507 | − return ret; | |
| 507 | + return 0; | |
| 508 | 508 | } |
| 509 | 509 | |
| 510 | 510 | static const struct bin_attribute hsmp_metric_tbl_attr = { |
| @@ -356,6 +356,11 @@ ssize_t hsmp_metric_tbl_read(struct hsmp_socket *sock, char *buf, size_t size) · 355 unmodified lines | ||
| 356 | 356 | if (!sock || !buf) |
| 357 | 357 | return -EINVAL; |
| 358 | 358 | |
| 359 | + if (!sock->metric_tbl_addr) { | |
| 360 | + dev_err(sock->dev, "Metrics table address not available\n"); | |
| 361 | + return -ENOMEM; | |
| 362 | + } | |
| 363 | + | |
| 359 | 364 | /* Do not support lseek(), also don't allow more than the size of metric table */ |
| 360 | 365 | if (size != sizeof(struct hsmp_metric_table)) { |
| 361 | 366 | dev_err(sock->dev, "Wrong buffer size\n"); |
| @@ -28,10 +28,15 @@ static struct quirk_entry quirk_spurious_8042 = { · 27 unmodified lines | ||
| 28 | 28 | .spurious_8042 = true, |
| 29 | 29 | }; |
| 30 | 30 | |
| 31 | +static struct quirk_entry quirk_s2idle_spurious_8042 = { | |
| 32 | + .s2idle_bug_mmio = FCH_PM_BASE + FCH_PM_SCRATCH, | |
| 33 | + .spurious_8042 = true, | |
| 34 | +}; | |
| 35 | + | |
| 31 | 36 | static const struct dmi_system_id fwbug_list[] = { |
| 32 | 37 | { |
| 33 | 38 | .ident = "L14 Gen2 AMD", |
| 34 | − .driver_data = &quirk_s2idle_bug, | |
| 39 | + .driver_data = &quirk_s2idle_spurious_8042, | |
| 35 | 40 | .matches = { |
| 36 | 41 | DMI_MATCH(DMI_BOARD_VENDOR, "LENOVO"), |
| 37 | 42 | DMI_MATCH(DMI_PRODUCT_NAME, "20X5"), |
| @@ -39,7 +44,7 @@ static const struct dmi_system_id fwbug_list[] = { · 1 unmodified line | ||
| 39 | 44 | }, |
| 40 | 45 | { |
| 41 | 46 | .ident = "T14s Gen2 AMD", |
| 42 | − .driver_data = &quirk_s2idle_bug, | |
| 47 | + .driver_data = &quirk_s2idle_spurious_8042, | |
| 43 | 48 | .matches = { |
| 44 | 49 | DMI_MATCH(DMI_BOARD_VENDOR, "LENOVO"), |
| 45 | 50 | DMI_MATCH(DMI_PRODUCT_NAME, "20XF"), |
| @@ -47,7 +52,7 @@ static const struct dmi_system_id fwbug_list[] = { · 1 unmodified line | ||
| 47 | 52 | }, |
| 48 | 53 | { |
| 49 | 54 | .ident = "X13 Gen2 AMD", |
| 50 | − .driver_data = &quirk_s2idle_bug, | |
| 55 | + .driver_data = &quirk_s2idle_spurious_8042, | |
| 51 | 56 | .matches = { |
| 52 | 57 | DMI_MATCH(DMI_BOARD_VENDOR, "LENOVO"), |
| 53 | 58 | DMI_MATCH(DMI_PRODUCT_NAME, "20XH"), |
| @@ -55,7 +60,7 @@ static const struct dmi_system_id fwbug_list[] = { · 1 unmodified line | ||
| 55 | 60 | }, |
| 56 | 61 | { |
| 57 | 62 | .ident = "T14 Gen2 AMD", |
| 58 | − .driver_data = &quirk_s2idle_bug, | |
| 63 | + .driver_data = &quirk_s2idle_spurious_8042, | |
| 59 | 64 | .matches = { |
| 60 | 65 | DMI_MATCH(DMI_BOARD_VENDOR, "LENOVO"), |
| 61 | 66 | DMI_MATCH(DMI_PRODUCT_NAME, "20XK"), |
| @@ -63,7 +68,7 @@ static const struct dmi_system_id fwbug_list[] = { · 1 unmodified line | ||
| 63 | 68 | }, |
| 64 | 69 | { |
| 65 | 70 | .ident = "T14 Gen1 AMD", |
| 66 | − .driver_data = &quirk_s2idle_bug, | |
| 71 | + .driver_data = &quirk_s2idle_spurious_8042, | |
| 67 | 72 | .matches = { |
| 68 | 73 | DMI_MATCH(DMI_BOARD_VENDOR, "LENOVO"), |
| 69 | 74 | DMI_MATCH(DMI_PRODUCT_NAME, "20UD"), |
| @@ -71,7 +76,7 @@ static const struct dmi_system_id fwbug_list[] = { · 1 unmodified line | ||
| 71 | 76 | }, |
| 72 | 77 | { |
| 73 | 78 | .ident = "T14 Gen1 AMD", |
| 74 | − .driver_data = &quirk_s2idle_bug, | |
| 79 | + .driver_data = &quirk_s2idle_spurious_8042, | |
| 75 | 80 | .matches = { |
| 76 | 81 | DMI_MATCH(DMI_BOARD_VENDOR, "LENOVO"), |
| 77 | 82 | DMI_MATCH(DMI_PRODUCT_NAME, "20UE"), |
| @@ -79,7 +84,7 @@ static const struct dmi_system_id fwbug_list[] = { · 1 unmodified line | ||
| 79 | 84 | }, |
| 80 | 85 | { |
| 81 | 86 | .ident = "T14s Gen1 AMD", |
| 82 | − .driver_data = &quirk_s2idle_bug, | |
| 87 | + .driver_data = &quirk_s2idle_spurious_8042, | |
| 83 | 88 | .matches = { |
| 84 | 89 | DMI_MATCH(DMI_BOARD_VENDOR, "LENOVO"), |
| 85 | 90 | DMI_MATCH(DMI_PRODUCT_NAME, "20UH"), |
| @@ -87,7 +92,7 @@ static const struct dmi_system_id fwbug_list[] = { · 1 unmodified line | ||
| 87 | 92 | }, |
| 88 | 93 | { |
| 89 | 94 | .ident = "T14s Gen1 AMD", |
| 90 | − .driver_data = &quirk_s2idle_bug, | |
| 95 | + .driver_data = &quirk_s2idle_spurious_8042, | |
| 91 | 96 | .matches = { |
| 92 | 97 | DMI_MATCH(DMI_BOARD_VENDOR, "LENOVO"), |
| 93 | 98 | DMI_MATCH(DMI_PRODUCT_NAME, "20UJ"), |
| @@ -95,7 +100,7 @@ static const struct dmi_system_id fwbug_list[] = { · 1 unmodified line | ||
| 95 | 100 | }, |
| 96 | 101 | { |
| 97 | 102 | .ident = "P14s Gen1 AMD", |
| 98 | − .driver_data = &quirk_s2idle_bug, | |
| 103 | + .driver_data = &quirk_s2idle_spurious_8042, | |
| 99 | 104 | .matches = { |
| 100 | 105 | DMI_MATCH(DMI_BOARD_VENDOR, "LENOVO"), |
| 101 | 106 | DMI_MATCH(DMI_PRODUCT_NAME, "20Y1"), |
| @@ -103,7 +108,7 @@ static const struct dmi_system_id fwbug_list[] = { · 1 unmodified line | ||
| 103 | 108 | }, |
| 104 | 109 | { |
| 105 | 110 | .ident = "P14s Gen2 AMD", |
| 106 | − .driver_data = &quirk_s2idle_bug, | |
| 111 | + .driver_data = &quirk_s2idle_spurious_8042, | |
| 107 | 112 | .matches = { |
| 108 | 113 | DMI_MATCH(DMI_BOARD_VENDOR, "LENOVO"), |
| 109 | 114 | DMI_MATCH(DMI_PRODUCT_NAME, "21A0"), |
| @@ -111,7 +116,7 @@ static const struct dmi_system_id fwbug_list[] = { · 1 unmodified line | ||
| 111 | 116 | }, |
| 112 | 117 | { |
| 113 | 118 | .ident = "P14s Gen2 AMD", |
| 114 | − .driver_data = &quirk_s2idle_bug, | |
| 119 | + .driver_data = &quirk_s2idle_spurious_8042, | |
| 115 | 120 | .matches = { |
| 116 | 121 | DMI_MATCH(DMI_BOARD_VENDOR, "LENOVO"), |
| 117 | 122 | DMI_MATCH(DMI_PRODUCT_NAME, "21A1"), |
| @@ -152,7 +157,7 @@ static const struct dmi_system_id fwbug_list[] = { · 34 unmodified lines | ||
| 152 | 157 | }, |
| 153 | 158 | { |
| 154 | 159 | .ident = "IdeaPad 1 14AMN7", |
| 155 | − .driver_data = &quirk_s2idle_bug, | |
| 160 | + .driver_data = &quirk_s2idle_spurious_8042, | |
| 156 | 161 | .matches = { |
| 157 | 162 | DMI_MATCH(DMI_BOARD_VENDOR, "LENOVO"), |
| 158 | 163 | DMI_MATCH(DMI_PRODUCT_NAME, "82VF"), |
| @@ -160,7 +165,7 @@ static const struct dmi_system_id fwbug_list[] = { · 1 unmodified line | ||
| 160 | 165 | }, |
| 161 | 166 | { |
| 162 | 167 | .ident = "IdeaPad 1 15AMN7", |
| 163 | − .driver_data = &quirk_s2idle_bug, | |
| 168 | + .driver_data = &quirk_s2idle_spurious_8042, | |
| 164 | 169 | .matches = { |
| 165 | 170 | DMI_MATCH(DMI_BOARD_VENDOR, "LENOVO"), |
| 166 | 171 | DMI_MATCH(DMI_PRODUCT_NAME, "82VG"), |
| @@ -168,7 +173,7 @@ static const struct dmi_system_id fwbug_list[] = { · 1 unmodified line | ||
| 168 | 173 | }, |
| 169 | 174 | { |
| 170 | 175 | .ident = "IdeaPad 1 15AMN7", |
| 171 | − .driver_data = &quirk_s2idle_bug, | |
| 176 | + .driver_data = &quirk_s2idle_spurious_8042, | |
| 172 | 177 | .matches = { |
| 173 | 178 | DMI_MATCH(DMI_BOARD_VENDOR, "LENOVO"), |
| 174 | 179 | DMI_MATCH(DMI_PRODUCT_NAME, "82X5"), |
| @@ -176,7 +181,7 @@ static const struct dmi_system_id fwbug_list[] = { · 1 unmodified line | ||
| 176 | 181 | }, |
| 177 | 182 | { |
| 178 | 183 | .ident = "IdeaPad Slim 3 14AMN8", |
| 179 | − .driver_data = &quirk_s2idle_bug, | |
| 184 | + .driver_data = &quirk_s2idle_spurious_8042, | |
| 180 | 185 | .matches = { |
| 181 | 186 | DMI_MATCH(DMI_BOARD_VENDOR, "LENOVO"), |
| 182 | 187 | DMI_MATCH(DMI_PRODUCT_NAME, "82XN"), |
| @@ -184,7 +189,7 @@ static const struct dmi_system_id fwbug_list[] = { · 1 unmodified line | ||
| 184 | 189 | }, |
| 185 | 190 | { |
| 186 | 191 | .ident = "IdeaPad Slim 3 15AMN8", |
| 187 | − .driver_data = &quirk_s2idle_bug, | |
| 192 | + .driver_data = &quirk_s2idle_spurious_8042, | |
| 188 | 193 | .matches = { |
| 189 | 194 | DMI_MATCH(DMI_BOARD_VENDOR, "LENOVO"), |
| 190 | 195 | DMI_MATCH(DMI_PRODUCT_NAME, "82XQ"), |
| @@ -193,7 +198,7 @@ static const struct dmi_system_id fwbug_list[] = { · 2 unmodified lines | ||
| 193 | 198 | /* https://gitlab.freedesktop.org/drm/amd/-/issues/4434 */ |
| 194 | 199 | { |
| 195 | 200 | .ident = "Lenovo Yoga 6 13ALC6", |
| 196 | − .driver_data = &quirk_s2idle_bug, | |
| 201 | + .driver_data = &quirk_s2idle_spurious_8042, | |
| 197 | 202 | .matches = { |
| 198 | 203 | DMI_MATCH(DMI_BOARD_VENDOR, "LENOVO"), |
| 199 | 204 | DMI_MATCH(DMI_PRODUCT_NAME, "82ND"), |
| @@ -202,7 +207,7 @@ static const struct dmi_system_id fwbug_list[] = { · 2 unmodified lines | ||
| 202 | 207 | /* https://gitlab.freedesktop.org/drm/amd/-/issues/2684 */ |
| 203 | 208 | { |
| 204 | 209 | .ident = "HP Laptop 15s-eq2xxx", |
| 205 | − .driver_data = &quirk_s2idle_bug, | |
| 210 | + .driver_data = &quirk_s2idle_spurious_8042, | |
| 206 | 211 | .matches = { |
| 207 | 212 | DMI_MATCH(DMI_SYS_VENDOR, "HP"), |
| 208 | 213 | DMI_MATCH(DMI_PRODUCT_NAME, "HP Laptop 15s-eq2xxx"), |
| @@ -285,6 +290,16 @@ void amd_pmc_quirks_init(struct amd_pmc_dev *dev) · 76 unmodified lines | ||
| 285 | 290 | { |
| 286 | 291 | const struct dmi_system_id *dmi_id; |
| 287 | 292 | |
| 293 | + /* | |
| 294 | + * IRQ1 may cause an interrupt during resume even without a keyboard | |
| 295 | + * press. | |
| 296 | + * | |
| 297 | + * Affects Renoir, Cezanne and Barcelo SoCs | |
| 298 | + * | |
| 299 | + * A solution is available in PMFW 64.66.0, but it must be activated by | |
| 300 | + * SBIOS. If SBIOS is known to have the fix a quirk can be added for | |
| 301 | + * a given system to avoid workaround. | |
| 302 | + */ | |
| 288 | 303 | if (dev->cpu_id == AMD_CPU_ID_CZN) |
| 289 | 304 | dev->disable_8042_wakeup = true; |
| 290 | 305 | |
| @@ -295,6 +310,5 @@ void amd_pmc_quirks_init(struct amd_pmc_dev *dev) · 4 unmodified lines | ||
| 295 | 310 | if (dev->quirks->s2idle_bug_mmio) |
| 296 | 311 | pr_info("Using s2idle quirk to avoid %s platform firmware bug\n", |
| 297 | 312 | dmi_id->ident); |
| 298 | − if (dev->quirks->spurious_8042) | |
| 299 | − dev->disable_8042_wakeup = true; | |
| 313 | + dev->disable_8042_wakeup = dev->quirks->spurious_8042; | |
| 300 | 314 | } |
| @@ -530,19 +530,6 @@ static int amd_pmc_get_os_hint(struct amd_pmc_dev *dev) · 529 unmodified lines | ||
| 530 | 530 | static int amd_pmc_wa_irq1(struct amd_pmc_dev *pdev) |
| 531 | 531 | { |
| 532 | 532 | struct device *d; |
| 533 | − int rc; | |
| 534 | − | |
| 535 | − /* cezanne platform firmware has a fix in 64.66.0 */ | |
| 536 | − if (pdev->cpu_id == AMD_CPU_ID_CZN) { | |
| 537 | − if (!pdev->major) { | |
| 538 | − rc = amd_pmc_get_smu_version(pdev); | |
| 539 | − if (rc) | |
| 540 | − return rc; | |
| 541 | − } | |
| 542 | − | |
| 543 | − if (pdev->major > 64 || (pdev->major == 64 && pdev->minor > 65)) | |
| 544 | − return 0; | |
| 545 | − } | |
| 546 | 533 | |
| 547 | 534 | d = bus_find_device_by_name(&serio_bus, NULL, "serio0"); |
| 548 | 535 | if (!d) |
| @@ -39,6 +39,7 @@ struct token_sysfs_data { · 38 unmodified lines | ||
| 39 | 39 | struct smbios_device { |
| 40 | 40 | struct list_head list; |
| 41 | 41 | struct device *device; |
| 42 | + int priority; | |
| 42 | 43 | int (*call_fn)(struct calling_interface_buffer *arg); |
| 43 | 44 | }; |
| 44 | 45 | |
| @@ -145,7 +146,7 @@ int dell_smbios_error(int value) · 100 unmodified lines | ||
| 145 | 146 | } |
| 146 | 147 | EXPORT_SYMBOL_GPL(dell_smbios_error); |
| 147 | 148 | |
| 148 | −int dell_smbios_register_device(struct device *d, void *call_fn) | |
| 149 | +int dell_smbios_register_device(struct device *d, int priority, void *call_fn) | |
| 149 | 150 | { |
| 150 | 151 | struct smbios_device *priv; |
| 151 | 152 | |
| @@ -154,6 +155,7 @@ int dell_smbios_register_device(struct device *d, void *call_fn) · 2 unmodified lines | ||
| 154 | 155 | return -ENOMEM; |
| 155 | 156 | get_device(d); |
| 156 | 157 | priv->device = d; |
| 158 | + priv->priority = priority; | |
| 157 | 159 | priv->call_fn = call_fn; |
| 158 | 160 | mutex_lock(&smbios_mutex); |
| 159 | 161 | list_add_tail(&priv->list, &smbios_device_list); |
| @@ -292,28 +294,25 @@ EXPORT_SYMBOL_GPL(dell_smbios_call_filter); · 132 unmodified lines | ||
| 292 | 294 | |
| 293 | 295 | int dell_smbios_call(struct calling_interface_buffer *buffer) |
| 294 | 296 | { |
| 295 | − int (*call_fn)(struct calling_interface_buffer *) = NULL; | |
| 296 | − struct device *selected_dev = NULL; | |
| 297 | + struct smbios_device *selected = NULL; | |
| 297 | 298 | struct smbios_device *priv; |
| 298 | 299 | int ret; |
| 299 | 300 | |
| 300 | 301 | mutex_lock(&smbios_mutex); |
| 301 | 302 | list_for_each_entry(priv, &smbios_device_list, list) { |
| 302 | − if (!selected_dev || priv->device->id >= selected_dev->id) { | |
| 303 | − dev_dbg(priv->device, "Trying device ID: %d\n", | |
| 304 | − priv->device->id); | |
| 305 | − call_fn = priv->call_fn; | |
| 306 | − selected_dev = priv->device; | |
| 303 | + if (!selected || priv->priority >= selected->priority) { | |
| 304 | + dev_dbg(priv->device, "Trying device ID: %d\n", priv->priority); | |
| 305 | + selected = priv; | |
| 307 | 306 | } |
| 308 | 307 | } |
| 309 | 308 | |
| 310 | − if (!selected_dev) { | |
| 309 | + if (!selected) { | |
| 311 | 310 | ret = -ENODEV; |
| 312 | 311 | pr_err("No dell-smbios drivers are loaded\n"); |
| 313 | 312 | goto out_smbios_call; |
| 314 | 313 | } |
| 315 | 314 | |
| 316 | − ret = call_fn(buffer); | |
| 315 | + ret = selected->call_fn(buffer); | |
| 317 | 316 | |
| 318 | 317 | out_smbios_call: |
| 319 | 318 | mutex_unlock(&smbios_mutex); |
| @@ -125,8 +125,7 @@ int init_dell_smbios_smm(void) · 124 unmodified lines | ||
| 125 | 125 | if (ret) |
| 126 | 126 | goto fail_platform_device_add; |
| 127 | 127 | |
| 128 | − ret = dell_smbios_register_device(&platform_device->dev, | |
| 129 | − &dell_smbios_smm_call); | |
| 128 | + ret = dell_smbios_register_device(&platform_device->dev, 0, &dell_smbios_smm_call); | |
| 130 | 129 | if (ret) |
| 131 | 130 | goto fail_register; |
| 132 | 131 | |
| @@ -264,9 +264,7 @@ static int dell_smbios_wmi_probe(struct wmi_device *wdev, const void *context) · 263 unmodified lines | ||
| 264 | 264 | if (ret) |
| 265 | 265 | return ret; |
| 266 | 266 | |
| 267 | − /* ID is used by dell-smbios to set priority of drivers */ | |
| 268 | − wdev->dev.id = 1; | |
| 269 | − ret = dell_smbios_register_device(&wdev->dev, &dell_smbios_wmi_call); | |
| 267 | + ret = dell_smbios_register_device(&wdev->dev, 1, &dell_smbios_wmi_call); | |
| 270 | 268 | if (ret) |
| 271 | 269 | return ret; |
| 272 | 270 | |
| @@ -64,7 +64,7 @@ struct calling_interface_structure { · 63 unmodified lines | ||
| 64 | 64 | struct calling_interface_token tokens[]; |
| 65 | 65 | } __packed; |
| 66 | 66 | |
| 67 | −int dell_smbios_register_device(struct device *d, void *call_fn); | |
| 67 | +int dell_smbios_register_device(struct device *d, int priority, void *call_fn); | |
| 68 | 68 | void dell_smbios_unregister_device(struct device *d); |
| 69 | 69 | |
| 70 | 70 | int dell_smbios_error(int value); |
| @@ -92,9 +92,9 @@ static const char * const victus_thermal_profile_boards[] = { · 91 unmodified lines | ||
| 92 | 92 | "8A25" |
| 93 | 93 | }; |
| 94 | 94 | |
| 95 | −/* DMI Board names of Victus 16-s1000 laptops */ | |
| 95 | +/* DMI Board names of Victus 16-r1000 and Victus 16-s1000 laptops */ | |
| 96 | 96 | static const char * const victus_s_thermal_profile_boards[] = { |
| 97 | − "8C9C" | |
| 97 | + "8C99", "8C9C" | |
| 98 | 98 | }; |
| 99 | 99 | |
| 100 | 100 | enum hp_wmi_radio { |
| @@ -192,9 +192,14 @@ static int uncore_read_control_freq(struct uncore_data *data, unsigned int *valu · 191 unmodified lines | ||
| 192 | 192 | static int write_eff_lat_ctrl(struct uncore_data *data, unsigned int val, enum uncore_index index) |
| 193 | 193 | { |
| 194 | 194 | struct tpmi_uncore_cluster_info *cluster_info; |
| 195 | + struct tpmi_uncore_struct *uncore_root; | |
| 195 | 196 | u64 control; |
| 196 | 197 | |
| 197 | 198 | cluster_info = container_of(data, struct tpmi_uncore_cluster_info, uncore_data); |
| 199 | + uncore_root = cluster_info->uncore_root; | |
| 200 | + | |
| 201 | + if (uncore_root->write_blocked) | |
| 202 | + return -EPERM; | |
| 198 | 203 | |
| 199 | 204 | if (cluster_info->root_domain) |
| 200 | 205 | return -ENODATA; |
| @@ -40,7 +40,6 @@ struct pca9450 { · 39 unmodified lines | ||
| 40 | 40 | struct device *dev; |
| 41 | 41 | struct regmap *regmap; |
| 42 | 42 | struct gpio_desc *sd_vsel_gpio; |
| 43 | − struct notifier_block restart_nb; | |
| 44 | 43 | enum pca9450_chip_type type; |
| 45 | 44 | unsigned int rcnt; |
| 46 | 45 | int irq; |
| @@ -1100,10 +1099,9 @@ static irqreturn_t pca9450_irq_handler(int irq, void *data) · 1053 unmodified lines | ||
| 1100 | 1099 | return IRQ_HANDLED; |
| 1101 | 1100 | } |
| 1102 | 1101 | |
| 1103 | −static int pca9450_i2c_restart_handler(struct notifier_block *nb, | |
| 1104 | − unsigned long action, void *data) | |
| 1102 | +static int pca9450_i2c_restart_handler(struct sys_off_data *data) | |
| 1105 | 1103 | { |
| 1106 | − struct pca9450 *pca9450 = container_of(nb, struct pca9450, restart_nb); | |
| 1104 | + struct pca9450 *pca9450 = data->cb_data; | |
| 1107 | 1105 | struct i2c_client *i2c = container_of(pca9450->dev, struct i2c_client, dev); |
| 1108 | 1106 | |
| 1109 | 1107 | dev_dbg(&i2c->dev, "Restarting device..\n"); |
| @@ -1261,10 +1259,9 @@ static int pca9450_i2c_probe(struct i2c_client *i2c) · 151 unmodified lines | ||
| 1261 | 1259 | pca9450->sd_vsel_fixed_low = |
| 1262 | 1260 | of_property_read_bool(ldo5->dev.of_node, "nxp,sd-vsel-fixed-low"); |
| 1263 | 1261 | |
| 1264 | − pca9450->restart_nb.notifier_call = pca9450_i2c_restart_handler; | |
| 1265 | − pca9450->restart_nb.priority = PCA9450_RESTART_HANDLER_PRIORITY; | |
| 1266 | − | |
| 1267 | − if (register_restart_handler(&pca9450->restart_nb)) | |
| 1262 | + if (devm_register_sys_off_handler(&i2c->dev, SYS_OFF_MODE_RESTART, | |
| 1263 | + PCA9450_RESTART_HANDLER_PRIORITY, | |
| 1264 | + pca9450_i2c_restart_handler, pca9450)) | |
| 1268 | 1265 | dev_warn(&i2c->dev, "Failed to register restart handler\n"); |
| 1269 | 1266 | |
| 1270 | 1267 | dev_info(&i2c->dev, "%s probed.\n", |
| @@ -454,9 +454,9 @@ static int tps65219_regulator_probe(struct platform_device *pdev) · 453 unmodified lines | ||
| 454 | 454 | irq_type->irq_name, |
| 455 | 455 | irq_data); |
| 456 | 456 | if (error) |
| 457 | − return dev_err_probe(tps->dev, PTR_ERR(rdev), | |
| 458 | − "Failed to request %s IRQ %d: %d\n", | |
| 459 | − irq_type->irq_name, irq, error); | |
| 457 | + return dev_err_probe(tps->dev, error, | |
| 458 | + "Failed to request %s IRQ %d\n", | |
| 459 | + irq_type->irq_name, irq); | |
| 460 | 460 | } |
| 461 | 461 | |
| 462 | 462 | for (i = 0; i < pmic->dev_irq_size; ++i) { |
| @@ -477,9 +477,9 @@ static int tps65219_regulator_probe(struct platform_device *pdev) · 14 unmodified lines | ||
| 477 | 477 | irq_type->irq_name, |
| 478 | 478 | irq_data); |
| 479 | 479 | if (error) |
| 480 | − return dev_err_probe(tps->dev, PTR_ERR(rdev), | |
| 481 | − "Failed to request %s IRQ %d: %d\n", | |
| 482 | − irq_type->irq_name, irq, error); | |
| 480 | + return dev_err_probe(tps->dev, error, | |
| 481 | + "Failed to request %s IRQ %d\n", | |
| 482 | + irq_type->irq_name, irq); | |
| 483 | 483 | } |
| 484 | 484 | |
| 485 | 485 | return 0; |
| @@ -77,6 +77,13 @@ unsigned long sclp_console_full; · 76 unmodified lines | ||
| 77 | 77 | /* The currently active SCLP command word. */ |
| 78 | 78 | static sclp_cmdw_t active_cmd; |
| 79 | 79 | |
| 80 | +static inline struct sccb_header *sclpint_to_sccb(u32 sccb_int) | |
| 81 | +{ | |
| 82 | + if (sccb_int) | |
| 83 | + return __va(sccb_int); | |
| 84 | + return NULL; | |
| 85 | +} | |
| 86 | + | |
| 80 | 87 | static inline void sclp_trace(int prio, char *id, u32 a, u64 b, bool err) |
| 81 | 88 | { |
| 82 | 89 | struct sclp_trace_entry e; |
| @@ -620,7 +627,7 @@ __sclp_find_req(u32 sccb) · 537 unmodified lines | ||
| 620 | 627 | |
| 621 | 628 | static bool ok_response(u32 sccb_int, sclp_cmdw_t cmd) |
| 622 | 629 | { |
| 623 | − struct sccb_header *sccb = (struct sccb_header *)__va(sccb_int); | |
| 630 | + struct sccb_header *sccb = sclpint_to_sccb(sccb_int); | |
| 624 | 631 | struct evbuf_header *evbuf; |
| 625 | 632 | u16 response; |
| 626 | 633 | |
| @@ -659,7 +666,7 @@ static void sclp_interrupt_handler(struct ext_code ext_code, · 32 unmodified lines | ||
| 659 | 666 | |
| 660 | 667 | /* INT: Interrupt received (a=intparm, b=cmd) */ |
| 661 | 668 | sclp_trace_sccb(0, "INT", param32, active_cmd, active_cmd, |
| 662 | − (struct sccb_header *)__va(finished_sccb), | |
| 669 | + sclpint_to_sccb(finished_sccb), | |
| 663 | 670 | !ok_response(finished_sccb, active_cmd)); |
| 664 | 671 | |
| 665 | 672 | if (finished_sccb) { |
| @@ -323,8 +323,6 @@ enum fnic_state { · 322 unmodified lines | ||
| 323 | 323 | FNIC_IN_ETH_TRANS_FC_MODE, |
| 324 | 324 | }; |
| 325 | 325 | |
| 326 | −struct mempool; | |
| 327 | − | |
| 328 | 326 | enum fnic_role_e { |
| 329 | 327 | FNIC_ROLE_FCP_INITIATOR = 0, |
| 330 | 328 | }; |
| @@ -6606,6 +6606,8 @@ static struct iscsi_endpoint *qla4xxx_get_ep_fwdb(struct scsi_qla_host *ha, · 6605 unmodified lines | ||
| 6606 | 6606 | |
| 6607 | 6607 | ep = qla4xxx_ep_connect(ha->host, (struct sockaddr *)dst_addr, 0); |
| 6608 | 6608 | vfree(dst_addr); |
| 6609 | + if (IS_ERR(ep)) | |
| 6610 | + return NULL; | |
| 6609 | 6611 | return ep; |
| 6610 | 6612 | } |
| 6611 | 6613 | |
| @@ -330,13 +330,11 @@ static int fsl_lpspi_set_bitrate(struct fsl_lpspi_data *fsl_lpspi) · 329 unmodified lines | ||
| 330 | 330 | } |
| 331 | 331 | |
| 332 | 332 | if (config.speed_hz > perclk_rate / 2) { |
| 333 | − dev_err(fsl_lpspi->dev, | |
| 334 | − "per-clk should be at least two times of transfer speed"); | |
| 335 | − return -EINVAL; | |
| 333 | + div = 2; | |
| 334 | + } else { | |
| 335 | + div = DIV_ROUND_UP(perclk_rate, config.speed_hz); | |
| 336 | 336 | } |
| 337 | 337 | |
| 338 | − div = DIV_ROUND_UP(perclk_rate, config.speed_hz); | |
| 339 | − | |
| 340 | 338 | for (prescale = 0; prescale <= prescale_max; prescale++) { |
| 341 | 339 | scldiv = div / (1 << prescale) - 2; |
| 342 | 340 | if (scldiv >= 0 && scldiv < 256) { |
| @@ -265,6 +265,9 @@ static bool spi_mem_internal_supports_op(struct spi_mem *mem, · 264 unmodified lines | ||
| 265 | 265 | */ |
| 266 | 266 | bool spi_mem_supports_op(struct spi_mem *mem, const struct spi_mem_op *op) |
| 267 | 267 | { |
| 268 | + /* Make sure the operation frequency is correct before going futher */ | |
| 269 | + spi_mem_adjust_op_freq(mem, (struct spi_mem_op *)op); | |
| 270 | + | |
| 268 | 271 | if (spi_mem_check_op(op)) |
| 269 | 272 | return false; |
| 270 | 273 | |
| @@ -577,6 +580,7 @@ EXPORT_SYMBOL_GPL(spi_mem_adjust_op_freq); · 306 unmodified lines | ||
| 577 | 580 | * spi_mem_calc_op_duration() - Derives the theoretical length (in ns) of an |
| 578 | 581 | * operation. This helps finding the best variant |
| 579 | 582 | * among a list of possible choices. |
| 583 | + * @mem: the SPI memory | |
| 580 | 584 | * @op: the operation to benchmark |
| 581 | 585 | * |
| 582 | 586 | * Some chips have per-op frequency limitations, PCBs usually have their own |
| @@ -210,13 +210,21 @@ static int qcom_spi_ooblayout_ecc(struct mtd_info *mtd, int section, · 209 unmodified lines | ||
| 210 | 210 | struct qcom_nand_controller *snandc = nand_to_qcom_snand(nand); |
| 211 | 211 | struct qpic_ecc *qecc = snandc->qspi->ecc; |
| 212 | 212 | |
| 213 | − if (section > 1) | |
| 214 | − return -ERANGE; | |
| 215 | − | |
| 216 | − oobregion->length = qecc->ecc_bytes_hw + qecc->spare_bytes; | |
| 217 | − oobregion->offset = mtd->oobsize - oobregion->length; | |
| 213 | + switch (section) { | |
| 214 | + case 0: | |
| 215 | + oobregion->offset = 0; | |
| 216 | + oobregion->length = qecc->bytes * (qecc->steps - 1) + | |
| 217 | + qecc->bbm_size; | |
| 218 | + return 0; | |
| 219 | + case 1: | |
| 220 | + oobregion->offset = qecc->bytes * (qecc->steps - 1) + | |
| 221 | + qecc->bbm_size + | |
| 222 | + qecc->steps * 4; | |
| 223 | + oobregion->length = mtd->oobsize - oobregion->offset; | |
| 224 | + return 0; | |
| 225 | + } | |
| 218 | 226 | |
| 219 | − return 0; | |
| 227 | + return -ERANGE; | |
| 220 | 228 | } |
| 221 | 229 | |
| 222 | 230 | static int qcom_spi_ooblayout_free(struct mtd_info *mtd, int section, |
| @@ -1196,7 +1204,7 @@ static int qcom_spi_program_oob(struct qcom_nand_controller *snandc, · 973 unmodified lines | ||
| 1196 | 1204 | u32 cfg0, cfg1, ecc_bch_cfg, ecc_buf_cfg; |
| 1197 | 1205 | |
| 1198 | 1206 | cfg0 = (ecc_cfg->cfg0 & ~CW_PER_PAGE_MASK) | |
| 1199 | − FIELD_PREP(CW_PER_PAGE_MASK, num_cw - 1); | |
| 1207 | + FIELD_PREP(CW_PER_PAGE_MASK, 0); | |
| 1200 | 1208 | cfg1 = ecc_cfg->cfg1; |
| 1201 | 1209 | ecc_bch_cfg = ecc_cfg->ecc_bch_cfg; |
| 1202 | 1210 | ecc_buf_cfg = ecc_cfg->ecc_buf_cfg; |
| @@ -378,7 +378,7 @@ static void spi_st_remove(struct platform_device *pdev) · 377 unmodified lines | ||
| 378 | 378 | pinctrl_pm_select_sleep_state(&pdev->dev); |
| 379 | 379 | } |
| 380 | 380 | |
| 381 | −static int __maybe_unused spi_st_runtime_suspend(struct device *dev) | |
| 381 | +static int spi_st_runtime_suspend(struct device *dev) | |
| 382 | 382 | { |
| 383 | 383 | struct spi_controller *host = dev_get_drvdata(dev); |
| 384 | 384 | struct spi_st *spi_st = spi_controller_get_devdata(host); |
| @@ -391,7 +391,7 @@ static int __maybe_unused spi_st_runtime_suspend(struct device *dev) · 6 unmodified lines | ||
| 391 | 391 | return 0; |
| 392 | 392 | } |
| 393 | 393 | |
| 394 | −static int __maybe_unused spi_st_runtime_resume(struct device *dev) | |
| 394 | +static int spi_st_runtime_resume(struct device *dev) | |
| 395 | 395 | { |
| 396 | 396 | struct spi_controller *host = dev_get_drvdata(dev); |
| 397 | 397 | struct spi_st *spi_st = spi_controller_get_devdata(host); |
| @@ -428,8 +428,8 @@ static int __maybe_unused spi_st_resume(struct device *dev) · 30 unmodified lines | ||
| 428 | 428 | } |
| 429 | 429 | |
| 430 | 430 | static const struct dev_pm_ops spi_st_pm = { |
| 431 | − SET_SYSTEM_SLEEP_PM_OPS(spi_st_suspend, spi_st_resume) | |
| 432 | − SET_RUNTIME_PM_OPS(spi_st_runtime_suspend, spi_st_runtime_resume, NULL) | |
| 431 | + SYSTEM_SLEEP_PM_OPS(spi_st_suspend, spi_st_resume) | |
| 432 | + RUNTIME_PM_OPS(spi_st_runtime_suspend, spi_st_runtime_resume, NULL) | |
| 433 | 433 | }; |
| 434 | 434 | |
| 435 | 435 | static const struct of_device_id stm_spi_match[] = { |
| @@ -441,7 +441,7 @@ MODULE_DEVICE_TABLE(of, stm_spi_match); · 5 unmodified lines | ||
| 441 | 441 | static struct platform_driver spi_st_driver = { |
| 442 | 442 | .driver = { |
| 443 | 443 | .name = "spi-st", |
| 444 | − .pm = pm_sleep_ptr(&spi_st_pm), | |
| 444 | + .pm = pm_ptr(&spi_st_pm), | |
| 445 | 445 | .of_match_table = of_match_ptr(stm_spi_match), |
| 446 | 446 | }, |
| 447 | 447 | .probe = spi_st_probe, |
| @@ -147,7 +147,7 @@ void rsa_enable(struct uart_8250_port *up) · 146 unmodified lines | ||
| 147 | 147 | if (up->port.uartclk == SERIAL_RSA_BAUD_BASE * 16) |
| 148 | 148 | serial_out(up, UART_RSA_FRR, 0); |
| 149 | 149 | } |
| 150 | −EXPORT_SYMBOL_GPL_FOR_MODULES(rsa_enable, "8250_base"); | |
| 150 | +EXPORT_SYMBOL_FOR_MODULES(rsa_enable, "8250_base"); | |
| 151 | 151 | |
| 152 | 152 | /* |
| 153 | 153 | * Attempts to turn off the RSA FIFO and resets the RSA board back to 115kbps compat mode. It is |
| @@ -179,7 +179,7 @@ void rsa_disable(struct uart_8250_port *up) · 25 unmodified lines | ||
| 179 | 179 | up->port.uartclk = SERIAL_RSA_BAUD_BASE_LO * 16; |
| 180 | 180 | uart_port_unlock_irq(&up->port); |
| 181 | 181 | } |
| 182 | −EXPORT_SYMBOL_GPL_FOR_MODULES(rsa_disable, "8250_base"); | |
| 182 | +EXPORT_SYMBOL_FOR_MODULES(rsa_disable, "8250_base"); | |
| 183 | 183 | |
| 184 | 184 | void rsa_autoconfig(struct uart_8250_port *up) |
| 185 | 185 | { |
| @@ -192,7 +192,7 @@ void rsa_autoconfig(struct uart_8250_port *up) · 6 unmodified lines | ||
| 192 | 192 | if (__rsa_enable(up)) |
| 193 | 193 | up->port.type = PORT_RSA; |
| 194 | 194 | } |
| 195 | −EXPORT_SYMBOL_GPL_FOR_MODULES(rsa_autoconfig, "8250_base"); | |
| 195 | +EXPORT_SYMBOL_FOR_MODULES(rsa_autoconfig, "8250_base"); | |
| 196 | 196 | |
| 197 | 197 | void rsa_reset(struct uart_8250_port *up) |
| 198 | 198 | { |
| @@ -201,7 +201,7 @@ void rsa_reset(struct uart_8250_port *up) · 2 unmodified lines | ||
| 201 | 201 | |
| 202 | 202 | serial_out(up, UART_RSA_FRR, 0); |
| 203 | 203 | } |
| 204 | −EXPORT_SYMBOL_GPL_FOR_MODULES(rsa_reset, "8250_base"); | |
| 204 | +EXPORT_SYMBOL_FOR_MODULES(rsa_reset, "8250_base"); | |
| 205 | 205 | |
| 206 | 206 | #ifdef CONFIG_SERIAL_8250_DEPRECATED_OPTIONS |
| 207 | 207 | #ifndef MODULE |
| @@ -1303,7 +1303,7 @@ static u32 ufshcd_pending_cmds(struct ufs_hba *hba) · 1302 unmodified lines | ||
| 1303 | 1303 | * |
| 1304 | 1304 | * Return: 0 upon success; -EBUSY upon timeout. |
| 1305 | 1305 | */ |
| 1306 | −static int ufshcd_wait_for_doorbell_clr(struct ufs_hba *hba, | |
| 1306 | +static int ufshcd_wait_for_pending_cmds(struct ufs_hba *hba, | |
| 1307 | 1307 | u64 wait_timeout_us) |
| 1308 | 1308 | { |
| 1309 | 1309 | int ret = 0; |
| @@ -1431,7 +1431,7 @@ static int ufshcd_clock_scaling_prepare(struct ufs_hba *hba, u64 timeout_us) · 121 unmodified lines | ||
| 1431 | 1431 | down_write(&hba->clk_scaling_lock); |
| 1432 | 1432 | |
| 1433 | 1433 | if (!hba->clk_scaling.is_allowed || |
| 1434 | − ufshcd_wait_for_doorbell_clr(hba, timeout_us)) { | |
| 1434 | + ufshcd_wait_for_pending_cmds(hba, timeout_us)) { | |
| 1435 | 1435 | ret = -EBUSY; |
| 1436 | 1436 | up_write(&hba->clk_scaling_lock); |
| 1437 | 1437 | mutex_unlock(&hba->wb_mutex); |
| @@ -3199,7 +3199,8 @@ ufshcd_dev_cmd_completion(struct ufs_hba *hba, struct ufshcd_lrb *lrbp) · 1761 unmodified lines | ||
| 3199 | 3199 | } |
| 3200 | 3200 | |
| 3201 | 3201 | /* |
| 3202 | − * Return: 0 upon success; < 0 upon failure. | |
| 3202 | + * Return: 0 upon success; > 0 in case the UFS device reported an OCS error; | |
| 3203 | + * < 0 if another error occurred. | |
| 3203 | 3204 | */ |
| 3204 | 3205 | static int ufshcd_wait_for_dev_cmd(struct ufs_hba *hba, |
| 3205 | 3206 | struct ufshcd_lrb *lrbp, int max_timeout) |
| @@ -3275,7 +3276,6 @@ retry: · 69 unmodified lines | ||
| 3275 | 3276 | } |
| 3276 | 3277 | } |
| 3277 | 3278 | |
| 3278 | − WARN_ONCE(err > 0, "Incorrect return value %d > 0\n", err); | |
| 3279 | 3279 | return err; |
| 3280 | 3280 | } |
| 3281 | 3281 | |
| @@ -3294,7 +3294,8 @@ static void ufshcd_dev_man_unlock(struct ufs_hba *hba) · 12 unmodified lines | ||
| 3294 | 3294 | } |
| 3295 | 3295 | |
| 3296 | 3296 | /* |
| 3297 | − * Return: 0 upon success; < 0 upon failure. | |
| 3297 | + * Return: 0 upon success; > 0 in case the UFS device reported an OCS error; | |
| 3298 | + * < 0 if another error occurred. | |
| 3298 | 3299 | */ |
| 3299 | 3300 | static int ufshcd_issue_dev_cmd(struct ufs_hba *hba, struct ufshcd_lrb *lrbp, |
| 3300 | 3301 | const u32 tag, int timeout) |
| @@ -3317,7 +3318,8 @@ static int ufshcd_issue_dev_cmd(struct ufs_hba *hba, struct ufshcd_lrb *lrbp, · 16 unmodified lines | ||
| 3317 | 3318 | * @cmd_type: specifies the type (NOP, Query...) |
| 3318 | 3319 | * @timeout: timeout in milliseconds |
| 3319 | 3320 | * |
| 3320 | − * Return: 0 upon success; < 0 upon failure. | |
| 3321 | + * Return: 0 upon success; > 0 in case the UFS device reported an OCS error; | |
| 3322 | + * < 0 if another error occurred. | |
| 3321 | 3323 | * |
| 3322 | 3324 | * NOTE: Since there is only one available tag for device management commands, |
| 3323 | 3325 | * it is expected you hold the hba->dev_cmd.lock mutex. |
| @@ -3363,6 +3365,10 @@ static inline void ufshcd_init_query(struct ufs_hba *hba, · 39 unmodified lines | ||
| 3363 | 3365 | (*request)->upiu_req.selector = selector; |
| 3364 | 3366 | } |
| 3365 | 3367 | |
| 3368 | +/* | |
| 3369 | + * Return: 0 upon success; > 0 in case the UFS device reported an OCS error; | |
| 3370 | + * < 0 if another error occurred. | |
| 3371 | + */ | |
| 3366 | 3372 | static int ufshcd_query_flag_retry(struct ufs_hba *hba, |
| 3367 | 3373 | enum query_opcode opcode, enum flag_idn idn, u8 index, bool *flag_res) |
| 3368 | 3374 | { |
| @@ -3383,7 +3389,6 @@ static int ufshcd_query_flag_retry(struct ufs_hba *hba, · 14 unmodified lines | ||
| 3383 | 3389 | dev_err(hba->dev, |
| 3384 | 3390 | "%s: query flag, opcode %d, idn %d, failed with error %d after %d retries\n", |
| 3385 | 3391 | __func__, opcode, idn, ret, retries); |
| 3386 | − WARN_ONCE(ret > 0, "Incorrect return value %d > 0\n", ret); | |
| 3387 | 3392 | return ret; |
| 3388 | 3393 | } |
| 3389 | 3394 | |
| @@ -3395,7 +3400,8 @@ static int ufshcd_query_flag_retry(struct ufs_hba *hba, · 5 unmodified lines | ||
| 3395 | 3400 | * @index: flag index to access |
| 3396 | 3401 | * @flag_res: the flag value after the query request completes |
| 3397 | 3402 | * |
| 3398 | − * Return: 0 for success; < 0 upon failure. | |
| 3403 | + * Return: 0 upon success; > 0 in case the UFS device reported an OCS error; | |
| 3404 | + * < 0 if another error occurred. | |
| 3399 | 3405 | */ |
| 3400 | 3406 | int ufshcd_query_flag(struct ufs_hba *hba, enum query_opcode opcode, |
| 3401 | 3407 | enum flag_idn idn, u8 index, bool *flag_res) |
| @@ -3451,7 +3457,6 @@ int ufshcd_query_flag(struct ufs_hba *hba, enum query_opcode opcode, · 49 unmodified lines | ||
| 3451 | 3457 | |
| 3452 | 3458 | out_unlock: |
| 3453 | 3459 | ufshcd_dev_man_unlock(hba); |
| 3454 | − WARN_ONCE(err > 0, "Incorrect return value %d > 0\n", err); | |
| 3455 | 3460 | return err; |
| 3456 | 3461 | } |
| 3457 | 3462 | |
| @@ -3464,8 +3469,9 @@ out_unlock: · 6 unmodified lines | ||
| 3464 | 3469 | * @selector: selector field |
| 3465 | 3470 | * @attr_val: the attribute value after the query request completes |
| 3466 | 3471 | * |
| 3467 | − * Return: 0 upon success; < 0 upon failure. | |
| 3468 | −*/ | |
| 3472 | + * Return: 0 upon success; > 0 in case the UFS device reported an OCS error; | |
| 3473 | + * < 0 if another error occurred. | |
| 3474 | + */ | |
| 3469 | 3475 | int ufshcd_query_attr(struct ufs_hba *hba, enum query_opcode opcode, |
| 3470 | 3476 | enum attr_idn idn, u8 index, u8 selector, u32 *attr_val) |
| 3471 | 3477 | { |
| @@ -3513,7 +3519,6 @@ int ufshcd_query_attr(struct ufs_hba *hba, enum query_opcode opcode, · 41 unmodified lines | ||
| 3513 | 3519 | |
| 3514 | 3520 | out_unlock: |
| 3515 | 3521 | ufshcd_dev_man_unlock(hba); |
| 3516 | − WARN_ONCE(err > 0, "Incorrect return value %d > 0\n", err); | |
| 3517 | 3522 | return err; |
| 3518 | 3523 | } |
| 3519 | 3524 | |
| @@ -3528,8 +3533,9 @@ out_unlock: · 8 unmodified lines | ||
| 3528 | 3533 | * @attr_val: the attribute value after the query request |
| 3529 | 3534 | * completes |
| 3530 | 3535 | * |
| 3531 | − * Return: 0 for success; < 0 upon failure. | |
| 3532 | −*/ | |
| 3536 | + * Return: 0 upon success; > 0 in case the UFS device reported an OCS error; | |
| 3537 | + * < 0 if another error occurred. | |
| 3538 | + */ | |
| 3533 | 3539 | int ufshcd_query_attr_retry(struct ufs_hba *hba, |
| 3534 | 3540 | enum query_opcode opcode, enum attr_idn idn, u8 index, u8 selector, |
| 3535 | 3541 | u32 *attr_val) |
| @@ -3551,12 +3557,12 @@ int ufshcd_query_attr_retry(struct ufs_hba *hba, · 15 unmodified lines | ||
| 3551 | 3557 | dev_err(hba->dev, |
| 3552 | 3558 | "%s: query attribute, idn %d, failed with error %d after %d retries\n", |
| 3553 | 3559 | __func__, idn, ret, QUERY_REQ_RETRIES); |
| 3554 | − WARN_ONCE(ret > 0, "Incorrect return value %d > 0\n", ret); | |
| 3555 | 3560 | return ret; |
| 3556 | 3561 | } |
| 3557 | 3562 | |
| 3558 | 3563 | /* |
| 3559 | − * Return: 0 if successful; < 0 upon failure. | |
| 3564 | + * Return: 0 upon success; > 0 in case the UFS device reported an OCS error; | |
| 3565 | + * < 0 if another error occurred. | |
| 3560 | 3566 | */ |
| 3561 | 3567 | static int __ufshcd_query_descriptor(struct ufs_hba *hba, |
| 3562 | 3568 | enum query_opcode opcode, enum desc_idn idn, u8 index, |
| @@ -3615,7 +3621,6 @@ static int __ufshcd_query_descriptor(struct ufs_hba *hba, · 52 unmodified lines | ||
| 3615 | 3621 | out_unlock: |
| 3616 | 3622 | hba->dev_cmd.query.descriptor = NULL; |
| 3617 | 3623 | ufshcd_dev_man_unlock(hba); |
| 3618 | − WARN_ONCE(err > 0, "Incorrect return value %d > 0\n", err); | |
| 3619 | 3624 | return err; |
| 3620 | 3625 | } |
| 3621 | 3626 | |
| @@ -3632,7 +3637,8 @@ out_unlock: · 10 unmodified lines | ||
| 3632 | 3637 | * The buf_len parameter will contain, on return, the length parameter |
| 3633 | 3638 | * received on the response. |
| 3634 | 3639 | * |
| 3635 | − * Return: 0 for success; < 0 upon failure. | |
| 3640 | + * Return: 0 upon success; > 0 in case the UFS device reported an OCS error; | |
| 3641 | + * < 0 if another error occurred. | |
| 3636 | 3642 | */ |
| 3637 | 3643 | int ufshcd_query_descriptor_retry(struct ufs_hba *hba, |
| 3638 | 3644 | enum query_opcode opcode, |
| @@ -3650,7 +3656,6 @@ int ufshcd_query_descriptor_retry(struct ufs_hba *hba, · 11 unmodified lines | ||
| 3650 | 3656 | break; |
| 3651 | 3657 | } |
| 3652 | 3658 | |
| 3653 | − WARN_ONCE(err > 0, "Incorrect return value %d > 0\n", err); | |
| 3654 | 3659 | return err; |
| 3655 | 3660 | } |
| 3656 | 3661 | |
| @@ -3663,7 +3668,8 @@ int ufshcd_query_descriptor_retry(struct ufs_hba *hba, · 6 unmodified lines | ||
| 3663 | 3668 | * @param_read_buf: pointer to buffer where parameter would be read |
| 3664 | 3669 | * @param_size: sizeof(param_read_buf) |
| 3665 | 3670 | * |
| 3666 | − * Return: 0 in case of success; < 0 upon failure. | |
| 3671 | + * Return: 0 upon success; > 0 in case the UFS device reported an OCS error; | |
| 3672 | + * < 0 if another error occurred. | |
| 3667 | 3673 | */ |
| 3668 | 3674 | int ufshcd_read_desc_param(struct ufs_hba *hba, |
| 3669 | 3675 | enum desc_idn desc_id, |
| @@ -3730,7 +3736,6 @@ int ufshcd_read_desc_param(struct ufs_hba *hba, · 60 unmodified lines | ||
| 3730 | 3736 | out: |
| 3731 | 3737 | if (is_kmalloc) |
| 3732 | 3738 | kfree(desc_buf); |
| 3733 | − WARN_ONCE(ret > 0, "Incorrect return value %d > 0\n", ret); | |
| 3734 | 3739 | return ret; |
| 3735 | 3740 | } |
| 3736 | 3741 | |
| @@ -4781,7 +4786,8 @@ EXPORT_SYMBOL_GPL(ufshcd_config_pwr_mode); · 1044 unmodified lines | ||
| 4781 | 4786 | * |
| 4782 | 4787 | * Set fDeviceInit flag and poll until device toggles it. |
| 4783 | 4788 | * |
| 4784 | − * Return: 0 upon success; < 0 upon failure. | |
| 4789 | + * Return: 0 upon success; > 0 in case the UFS device reported an OCS error; | |
| 4790 | + * < 0 if another error occurred. | |
| 4785 | 4791 | */ |
| 4786 | 4792 | static int ufshcd_complete_dev_init(struct ufs_hba *hba) |
| 4787 | 4793 | { |
| @@ -5135,7 +5141,8 @@ out: · 347 unmodified lines | ||
| 5135 | 5141 | * not respond with NOP IN UPIU within timeout of %NOP_OUT_TIMEOUT |
| 5136 | 5142 | * and we retry sending NOP OUT for %NOP_OUT_RETRIES iterations. |
| 5137 | 5143 | * |
| 5138 | − * Return: 0 upon success; < 0 upon failure. | |
| 5144 | + * Return: 0 upon success; > 0 in case the UFS device reported an OCS error; | |
| 5145 | + * < 0 if another error occurred. | |
| 5139 | 5146 | */ |
| 5140 | 5147 | static int ufshcd_verify_dev_init(struct ufs_hba *hba) |
| 5141 | 5148 | { |
| @@ -5559,9 +5566,9 @@ static irqreturn_t ufshcd_uic_cmd_compl(struct ufs_hba *hba, u32 intr_status) · 417 unmodified lines | ||
| 5559 | 5566 | irqreturn_t retval = IRQ_NONE; |
| 5560 | 5567 | struct uic_command *cmd; |
| 5561 | 5568 | |
| 5562 | − spin_lock(hba->host->host_lock); | |
| 5569 | + guard(spinlock_irqsave)(hba->host->host_lock); | |
| 5563 | 5570 | cmd = hba->active_uic_cmd; |
| 5564 | − if (WARN_ON_ONCE(!cmd)) | |
| 5571 | + if (!cmd) | |
| 5565 | 5572 | goto unlock; |
| 5566 | 5573 | |
| 5567 | 5574 | if (ufshcd_is_auto_hibern8_error(hba, intr_status)) |
| @@ -5586,8 +5593,6 @@ static irqreturn_t ufshcd_uic_cmd_compl(struct ufs_hba *hba, u32 intr_status) · 18 unmodified lines | ||
| 5586 | 5593 | ufshcd_add_uic_command_trace(hba, cmd, UFS_CMD_COMP); |
| 5587 | 5594 | |
| 5588 | 5595 | unlock: |
| 5589 | − spin_unlock(hba->host->host_lock); | |
| 5590 | − | |
| 5591 | 5596 | return retval; |
| 5592 | 5597 | } |
| 5593 | 5598 | |
| @@ -5869,7 +5874,8 @@ static inline int ufshcd_enable_ee(struct ufs_hba *hba, u16 mask) · 275 unmodified lines | ||
| 5869 | 5874 | * as the device is allowed to manage its own way of handling background |
| 5870 | 5875 | * operations. |
| 5871 | 5876 | * |
| 5872 | − * Return: zero on success, non-zero on failure. | |
| 5877 | + * Return: 0 upon success; > 0 in case the UFS device reported an OCS error; | |
| 5878 | + * < 0 if another error occurred. | |
| 5873 | 5879 | */ |
| 5874 | 5880 | static int ufshcd_enable_auto_bkops(struct ufs_hba *hba) |
| 5875 | 5881 | { |
| @@ -5908,7 +5914,8 @@ out: · 32 unmodified lines | ||
| 5908 | 5914 | * host is idle so that BKOPS are managed effectively without any negative |
| 5909 | 5915 | * impacts. |
| 5910 | 5916 | * |
| 5911 | − * Return: zero on success, non-zero on failure. | |
| 5917 | + * Return: 0 upon success; > 0 in case the UFS device reported an OCS error; | |
| 5918 | + * < 0 if another error occurred. | |
| 5912 | 5919 | */ |
| 5913 | 5920 | static int ufshcd_disable_auto_bkops(struct ufs_hba *hba) |
| 5914 | 5921 | { |
| @@ -6058,6 +6065,10 @@ out: · 143 unmodified lines | ||
| 6058 | 6065 | __func__, err); |
| 6059 | 6066 | } |
| 6060 | 6067 | |
| 6068 | +/* | |
| 6069 | + * Return: 0 upon success; > 0 in case the UFS device reported an OCS error; | |
| 6070 | + * < 0 if another error occurred. | |
| 6071 | + */ | |
| 6061 | 6072 | int ufshcd_read_device_lvl_exception_id(struct ufs_hba *hba, u64 *exception_id) |
| 6062 | 6073 | { |
| 6063 | 6074 | struct utp_upiu_query_v4_0 *upiu_resp; |
| @@ -6920,7 +6931,7 @@ static irqreturn_t ufshcd_check_errors(struct ufs_hba *hba, u32 intr_status) · 856 unmodified lines | ||
| 6920 | 6931 | bool queue_eh_work = false; |
| 6921 | 6932 | irqreturn_t retval = IRQ_NONE; |
| 6922 | 6933 | |
| 6923 | − spin_lock(hba->host->host_lock); | |
| 6934 | + guard(spinlock_irqsave)(hba->host->host_lock); | |
| 6924 | 6935 | hba->errors |= UFSHCD_ERROR_MASK & intr_status; |
| 6925 | 6936 | |
| 6926 | 6937 | if (hba->errors & INT_FATAL_ERRORS) { |
| @@ -6979,7 +6990,7 @@ static irqreturn_t ufshcd_check_errors(struct ufs_hba *hba, u32 intr_status) · 52 unmodified lines | ||
| 6979 | 6990 | */ |
| 6980 | 6991 | hba->errors = 0; |
| 6981 | 6992 | hba->uic_error = 0; |
| 6982 | − spin_unlock(hba->host->host_lock); | |
| 6993 | + | |
| 6983 | 6994 | return retval; |
| 6984 | 6995 | } |
| 6985 | 6996 | |
| @@ -7454,7 +7465,8 @@ int ufshcd_exec_raw_upiu_cmd(struct ufs_hba *hba, · 468 unmodified lines | ||
| 7454 | 7465 | * @sg_list: Pointer to SG list when DATA IN/OUT UPIU is required in ARPMB operation |
| 7455 | 7466 | * @dir: DMA direction |
| 7456 | 7467 | * |
| 7457 | − * Return: zero on success, non-zero on failure. | |
| 7468 | + * Return: 0 upon success; > 0 in case the UFS device reported an OCS error; | |
| 7469 | + * < 0 if another error occurred. | |
| 7458 | 7470 | */ |
| 7459 | 7471 | int ufshcd_advanced_rpmb_req_handler(struct ufs_hba *hba, struct utp_upiu_req *req_upiu, |
| 7460 | 7472 | struct utp_upiu_req *rsp_upiu, struct ufs_ehs *req_ehs, |
| @@ -2070,17 +2070,6 @@ static irqreturn_t ufs_qcom_mcq_esi_handler(int irq, void *data) · 2069 unmodified lines | ||
| 2070 | 2070 | return IRQ_HANDLED; |
| 2071 | 2071 | } |
| 2072 | 2072 | |
| 2073 | −static void ufs_qcom_irq_free(struct ufs_qcom_irq *uqi) | |
| 2074 | −{ | |
| 2075 | − for (struct ufs_qcom_irq *q = uqi; q->irq; q++) | |
| 2076 | − devm_free_irq(q->hba->dev, q->irq, q->hba); | |
| 2077 | − | |
| 2078 | − platform_device_msi_free_irqs_all(uqi->hba->dev); | |
| 2079 | − devm_kfree(uqi->hba->dev, uqi); | |
| 2080 | −} | |
| 2081 | − | |
| 2082 | −DEFINE_FREE(ufs_qcom_irq, struct ufs_qcom_irq *, if (_T) ufs_qcom_irq_free(_T)) | |
| 2083 | − | |
| 2084 | 2073 | static int ufs_qcom_config_esi(struct ufs_hba *hba) |
| 2085 | 2074 | { |
| 2086 | 2075 | struct ufs_qcom_host *host = ufshcd_get_variant(hba); |
| @@ -2095,18 +2084,18 @@ static int ufs_qcom_config_esi(struct ufs_hba *hba) · 8 unmodified lines | ||
| 2095 | 2084 | */ |
| 2096 | 2085 | nr_irqs = hba->nr_hw_queues - hba->nr_queues[HCTX_TYPE_POLL]; |
| 2097 | 2086 | |
| 2098 | − struct ufs_qcom_irq *qi __free(ufs_qcom_irq) = | |
| 2099 | − devm_kcalloc(hba->dev, nr_irqs, sizeof(*qi), GFP_KERNEL); | |
| 2100 | − if (!qi) | |
| 2101 | − return -ENOMEM; | |
| 2102 | − /* Preset so __free() has a pointer to hba in all error paths */ | |
| 2103 | − qi[0].hba = hba; | |
| 2104 | − | |
| 2105 | 2087 | ret = platform_device_msi_init_and_alloc_irqs(hba->dev, nr_irqs, |
| 2106 | 2088 | ufs_qcom_write_msi_msg); |
| 2107 | 2089 | if (ret) { |
| 2108 | − dev_err(hba->dev, "Failed to request Platform MSI %d\n", ret); | |
| 2109 | − return ret; | |
| 2090 | + dev_warn(hba->dev, "Platform MSI not supported or failed, continuing without ESI\n"); | |
| 2091 | + return ret; /* Continue without ESI */ | |
| 2092 | + } | |
| 2093 | + | |
| 2094 | + struct ufs_qcom_irq *qi = devm_kcalloc(hba->dev, nr_irqs, sizeof(*qi), GFP_KERNEL); | |
| 2095 | + | |
| 2096 | + if (!qi) { | |
| 2097 | + platform_device_msi_free_irqs_all(hba->dev); | |
| 2098 | + return -ENOMEM; | |
| 2110 | 2099 | } |
| 2111 | 2100 | |
| 2112 | 2101 | for (int idx = 0; idx < nr_irqs; idx++) { |
| @@ -2117,15 +2106,17 @@ static int ufs_qcom_config_esi(struct ufs_hba *hba) · 4 unmodified lines | ||
| 2117 | 2106 | ret = devm_request_irq(hba->dev, qi[idx].irq, ufs_qcom_mcq_esi_handler, |
| 2118 | 2107 | IRQF_SHARED, "qcom-mcq-esi", qi + idx); |
| 2119 | 2108 | if (ret) { |
| 2120 | − dev_err(hba->dev, "%s: Fail to request IRQ for %d, err = %d\n", | |
| 2109 | + dev_err(hba->dev, "%s: Failed to request IRQ for %d, err = %d\n", | |
| 2121 | 2110 | __func__, qi[idx].irq, ret); |
| 2122 | − qi[idx].irq = 0; | |
| 2111 | + /* Free previously allocated IRQs */ | |
| 2112 | + for (int j = 0; j < idx; j++) | |
| 2113 | + devm_free_irq(hba->dev, qi[j].irq, qi + j); | |
| 2114 | + platform_device_msi_free_irqs_all(hba->dev); | |
| 2115 | + devm_kfree(hba->dev, qi); | |
| 2123 | 2116 | return ret; |
| 2124 | 2117 | } |
| 2125 | 2118 | } |
| 2126 | 2119 | |
| 2127 | − retain_and_null_ptr(qi); | |
| 2128 | − | |
| 2129 | 2120 | if (host->hw_ver.major >= 6) { |
| 2130 | 2121 | ufshcd_rmwl(hba, ESI_VEC_MASK, FIELD_PREP(ESI_VEC_MASK, MAX_ESI_VEC - 1), |
| 2131 | 2122 | REG_UFS_CFG3); |
| @@ -630,6 +630,7 @@ static const struct pci_device_id ufshcd_pci_tbl[] = { · 629 unmodified lines | ||
| 630 | 630 | { PCI_VDEVICE(INTEL, 0xA847), (kernel_ulong_t)&ufs_intel_mtl_hba_vops }, |
| 631 | 631 | { PCI_VDEVICE(INTEL, 0x7747), (kernel_ulong_t)&ufs_intel_mtl_hba_vops }, |
| 632 | 632 | { PCI_VDEVICE(INTEL, 0xE447), (kernel_ulong_t)&ufs_intel_mtl_hba_vops }, |
| 633 | + { PCI_VDEVICE(INTEL, 0x4D47), (kernel_ulong_t)&ufs_intel_mtl_hba_vops }, | |
| 633 | 634 | { } /* terminate list */ |
| 634 | 635 | }; |
| 635 | 636 | |
| @@ -338,7 +338,8 @@ static int ci_hdrc_imx_notify_event(struct ci_hdrc *ci, unsigned int event) · 337 unmodified lines | ||
| 338 | 338 | schedule_work(&ci->usb_phy->chg_work); |
| 339 | 339 | break; |
| 340 | 340 | case CI_HDRC_CONTROLLER_PULLUP_EVENT: |
| 341 | − if (ci->role == CI_ROLE_GADGET) | |
| 341 | + if (ci->role == CI_ROLE_GADGET && | |
| 342 | + ci->gadget.speed == USB_SPEED_HIGH) | |
| 342 | 343 | imx_usbmisc_pullup(data->usbmisc_data, |
| 343 | 344 | ci->gadget.connected); |
| 344 | 345 | break; |
| @@ -1068,15 +1068,24 @@ static void usbmisc_imx7d_pullup(struct imx_usbmisc_data *data, bool on) · 1067 unmodified lines | ||
| 1068 | 1068 | unsigned long flags; |
| 1069 | 1069 | u32 val; |
| 1070 | 1070 | |
| 1071 | + if (on) | |
| 1072 | + return; | |
| 1073 | + | |
| 1071 | 1074 | spin_lock_irqsave(&usbmisc->lock, flags); |
| 1072 | 1075 | val = readl(usbmisc->base + MX7D_USBNC_USB_CTRL2); |
| 1073 | − if (!on) { | |
| 1074 | − val &= ~MX7D_USBNC_USB_CTRL2_OPMODE_OVERRIDE_MASK; | |
| 1075 | − val |= MX7D_USBNC_USB_CTRL2_OPMODE(1); | |
| 1076 | − val |= MX7D_USBNC_USB_CTRL2_OPMODE_OVERRIDE_EN; | |
| 1077 | − } else { | |
| 1078 | − val &= ~MX7D_USBNC_USB_CTRL2_OPMODE_OVERRIDE_EN; | |
| 1079 | − } | |
| 1076 | + val &= ~MX7D_USBNC_USB_CTRL2_OPMODE_OVERRIDE_MASK; | |
| 1077 | + val |= MX7D_USBNC_USB_CTRL2_OPMODE(1); | |
| 1078 | + val |= MX7D_USBNC_USB_CTRL2_OPMODE_OVERRIDE_EN; | |
| 1079 | + writel(val, usbmisc->base + MX7D_USBNC_USB_CTRL2); | |
| 1080 | + spin_unlock_irqrestore(&usbmisc->lock, flags); | |
| 1081 | + | |
| 1082 | + /* Last for at least 1 micro-frame to let host see disconnect signal */ | |
| 1083 | + usleep_range(125, 150); | |
| 1084 | + | |
| 1085 | + spin_lock_irqsave(&usbmisc->lock, flags); | |
| 1086 | + val &= ~MX7D_USBNC_USB_CTRL2_OPMODE_OVERRIDE_MASK; | |
| 1087 | + val |= MX7D_USBNC_USB_CTRL2_OPMODE(0); | |
| 1088 | + val &= ~MX7D_USBNC_USB_CTRL2_OPMODE_OVERRIDE_EN; | |
| 1080 | 1089 | writel(val, usbmisc->base + MX7D_USBNC_USB_CTRL2); |
| 1081 | 1090 | spin_unlock_irqrestore(&usbmisc->lock, flags); |
| 1082 | 1091 | } |
| @@ -1636,7 +1636,6 @@ static void __usb_hcd_giveback_urb(struct urb *urb) · 1635 unmodified lines | ||
| 1636 | 1636 | struct usb_hcd *hcd = bus_to_hcd(urb->dev->bus); |
| 1637 | 1637 | struct usb_anchor *anchor = urb->anchor; |
| 1638 | 1638 | int status = urb->unlinked; |
| 1639 | − unsigned long flags; | |
| 1640 | 1639 | |
| 1641 | 1640 | urb->hcpriv = NULL; |
| 1642 | 1641 | if (unlikely((urb->transfer_flags & URB_SHORT_NOT_OK) && |
| @@ -1654,14 +1653,13 @@ static void __usb_hcd_giveback_urb(struct urb *urb) · 11 unmodified lines | ||
| 1654 | 1653 | /* pass ownership to the completion handler */ |
| 1655 | 1654 | urb->status = status; |
| 1656 | 1655 | /* |
| 1657 | − * Only collect coverage in the softirq context and disable interrupts | |
| 1658 | − * to avoid scenarios with nested remote coverage collection sections | |
| 1659 | − * that KCOV does not support. | |
| 1660 | − * See the comment next to kcov_remote_start_usb_softirq() for details. | |
| 1656 | + * This function can be called in task context inside another remote | |
| 1657 | + * coverage collection section, but kcov doesn't support that kind of | |
| 1658 | + * recursion yet. Only collect coverage in softirq context for now. | |
| 1661 | 1659 | */ |
| 1662 | − flags = kcov_remote_start_usb_softirq((u64)urb->dev->bus->busnum); | |
| 1660 | + kcov_remote_start_usb_softirq((u64)urb->dev->bus->busnum); | |
| 1663 | 1661 | urb->complete(urb); |
| 1664 | − kcov_remote_stop_softirq(flags); | |
| 1662 | + kcov_remote_stop_softirq(); | |
| 1665 | 1663 | |
| 1666 | 1664 | usb_anchor_resume_wakeups(anchor); |
| 1667 | 1665 | atomic_dec(&urb->use_count); |
| @@ -1719,10 +1717,10 @@ static void usb_giveback_urb_bh(struct work_struct *work) · 51 unmodified lines | ||
| 1719 | 1717 | * @urb: urb being returned to the USB device driver. |
| 1720 | 1718 | * @status: completion status code for the URB. |
| 1721 | 1719 | * |
| 1722 | − * Context: atomic. The completion callback is invoked in caller's context. | |
| 1723 | − * For HCDs with HCD_BH flag set, the completion callback is invoked in BH | |
| 1724 | − * context (except for URBs submitted to the root hub which always complete in | |
| 1725 | − * caller's context). | |
| 1720 | + * Context: atomic. The completion callback is invoked either in a work queue | |
| 1721 | + * (BH) context or in the caller's context, depending on whether the HCD_BH | |
| 1722 | + * flag is set in the @hcd structure, except that URBs submitted to the | |
| 1723 | + * root hub always complete in BH context. | |
| 1726 | 1724 | * |
| 1727 | 1725 | * This hands the URB from HCD to its USB device driver, using its |
| 1728 | 1726 | * completion function. The HCD has freed all per-urb resources |
| @@ -2166,7 +2164,7 @@ static struct urb *request_single_step_set_feature_urb( · 437 unmodified lines | ||
| 2166 | 2164 | urb->complete = usb_ehset_completion; |
| 2167 | 2165 | urb->status = -EINPROGRESS; |
| 2168 | 2166 | urb->actual_length = 0; |
| 2169 | − urb->transfer_flags = URB_DIR_IN; | |
| 2167 | + urb->transfer_flags = URB_DIR_IN | URB_NO_TRANSFER_DMA_MAP; | |
| 2170 | 2168 | usb_get_urb(urb); |
| 2171 | 2169 | atomic_inc(&urb->use_count); |
| 2172 | 2170 | atomic_inc(&urb->dev->urbnum); |
| @@ -2230,9 +2228,15 @@ int ehset_single_step_set_feature(struct usb_hcd *hcd, int port) · 57 unmodified lines | ||
| 2230 | 2228 | |
| 2231 | 2229 | /* Complete remaining DATA and STATUS stages using the same URB */ |
| 2232 | 2230 | urb->status = -EINPROGRESS; |
| 2231 | + urb->transfer_flags &= ~URB_NO_TRANSFER_DMA_MAP; | |
| 2233 | 2232 | usb_get_urb(urb); |
| 2234 | 2233 | atomic_inc(&urb->use_count); |
| 2235 | 2234 | atomic_inc(&urb->dev->urbnum); |
| 2235 | + if (map_urb_for_dma(hcd, urb, GFP_KERNEL)) { | |
| 2236 | + usb_put_urb(urb); | |
| 2237 | + goto out1; | |
| 2238 | + } | |
| 2239 | + | |
| 2236 | 2240 | retval = hcd->driver->submit_single_step_set_feature(hcd, urb, 0); |
| 2237 | 2241 | if (!retval && !wait_for_completion_timeout(&done, |
| 2238 | 2242 | msecs_to_jiffies(2000))) { |
| @@ -371,6 +371,7 @@ static const struct usb_device_id usb_quirk_list[] = { · 370 unmodified lines | ||
| 371 | 371 | { USB_DEVICE(0x0781, 0x5591), .driver_info = USB_QUIRK_NO_LPM }, |
| 372 | 372 | |
| 373 | 373 | /* SanDisk Corp. SanDisk 3.2Gen1 */ |
| 374 | + { USB_DEVICE(0x0781, 0x5596), .driver_info = USB_QUIRK_DELAY_INIT }, | |
| 374 | 375 | { USB_DEVICE(0x0781, 0x55a3), .driver_info = USB_QUIRK_DELAY_INIT }, |
| 375 | 376 | |
| 376 | 377 | /* SanDisk Extreme 55AE */ |
| @@ -41,6 +41,7 @@ · 40 unmodified lines | ||
| 41 | 41 | #define PCI_DEVICE_ID_INTEL_TGPLP 0xa0ee |
| 42 | 42 | #define PCI_DEVICE_ID_INTEL_TGPH 0x43ee |
| 43 | 43 | #define PCI_DEVICE_ID_INTEL_JSP 0x4dee |
| 44 | +#define PCI_DEVICE_ID_INTEL_WCL 0x4d7e | |
| 44 | 45 | #define PCI_DEVICE_ID_INTEL_ADL 0x460e |
| 45 | 46 | #define PCI_DEVICE_ID_INTEL_ADL_PCH 0x51ee |
| 46 | 47 | #define PCI_DEVICE_ID_INTEL_ADLN 0x465e |
| @@ -431,6 +432,7 @@ static const struct pci_device_id dwc3_pci_id_table[] = { · 384 unmodified lines | ||
| 431 | 432 | { PCI_DEVICE_DATA(INTEL, TGPLP, &dwc3_pci_intel_swnode) }, |
| 432 | 433 | { PCI_DEVICE_DATA(INTEL, TGPH, &dwc3_pci_intel_swnode) }, |
| 433 | 434 | { PCI_DEVICE_DATA(INTEL, JSP, &dwc3_pci_intel_swnode) }, |
| 435 | + { PCI_DEVICE_DATA(INTEL, WCL, &dwc3_pci_intel_swnode) }, | |
| 434 | 436 | { PCI_DEVICE_DATA(INTEL, ADL, &dwc3_pci_intel_swnode) }, |
| 435 | 437 | { PCI_DEVICE_DATA(INTEL, ADL_PCH, &dwc3_pci_intel_swnode) }, |
| 436 | 438 | { PCI_DEVICE_DATA(INTEL, ADLN, &dwc3_pci_intel_swnode) }, |
| @@ -288,7 +288,9 @@ void dwc3_ep0_out_start(struct dwc3 *dwc) · 287 unmodified lines | ||
| 288 | 288 | dwc3_ep0_prepare_one_trb(dep, dwc->ep0_trb_addr, 8, |
| 289 | 289 | DWC3_TRBCTL_CONTROL_SETUP, false); |
| 290 | 290 | ret = dwc3_ep0_start_trans(dep); |
| 291 | − WARN_ON(ret < 0); | |
| 291 | + if (ret < 0) | |
| 292 | + dev_err(dwc->dev, "ep0 out start transfer failed: %d\n", ret); | |
| 293 | + | |
| 292 | 294 | for (i = 2; i < DWC3_ENDPOINTS_NUM; i++) { |
| 293 | 295 | struct dwc3_ep *dwc3_ep; |
| 294 | 296 | |
| @@ -1061,7 +1063,9 @@ static void __dwc3_ep0_do_control_data(struct dwc3 *dwc, · 766 unmodified lines | ||
| 1061 | 1063 | ret = dwc3_ep0_start_trans(dep); |
| 1062 | 1064 | } |
| 1063 | 1065 | |
| 1064 | − WARN_ON(ret < 0); | |
| 1066 | + if (ret < 0) | |
| 1067 | + dev_err(dwc->dev, | |
| 1068 | + "ep0 data phase start transfer failed: %d\n", ret); | |
| 1065 | 1069 | } |
| 1066 | 1070 | |
| 1067 | 1071 | static int dwc3_ep0_start_control_status(struct dwc3_ep *dep) |
| @@ -1078,7 +1082,12 @@ static int dwc3_ep0_start_control_status(struct dwc3_ep *dep) · 10 unmodified lines | ||
| 1078 | 1082 | |
| 1079 | 1083 | static void __dwc3_ep0_do_control_status(struct dwc3 *dwc, struct dwc3_ep *dep) |
| 1080 | 1084 | { |
| 1081 | − WARN_ON(dwc3_ep0_start_control_status(dep)); | |
| 1085 | + int ret; | |
| 1086 | + | |
| 1087 | + ret = dwc3_ep0_start_control_status(dep); | |
| 1088 | + if (ret) | |
| 1089 | + dev_err(dwc->dev, | |
| 1090 | + "ep0 status phase start transfer failed: %d\n", ret); | |
| 1082 | 1091 | } |
| 1083 | 1092 | |
| 1084 | 1093 | static void dwc3_ep0_do_control_status(struct dwc3 *dwc, |
| @@ -1121,7 +1130,10 @@ void dwc3_ep0_end_control_data(struct dwc3 *dwc, struct dwc3_ep *dep) · 36 unmodified lines | ||
| 1121 | 1130 | cmd |= DWC3_DEPCMD_PARAM(dep->resource_index); |
| 1122 | 1131 | memset(¶ms, 0, sizeof(params)); |
| 1123 | 1132 | ret = dwc3_send_gadget_ep_cmd(dep, cmd, ¶ms); |
| 1124 | − WARN_ON_ONCE(ret); | |
| 1133 | + if (ret) | |
| 1134 | + dev_err_ratelimited(dwc->dev, | |
| 1135 | + "ep0 data phase end transfer failed: %d\n", ret); | |
| 1136 | + | |
| 1125 | 1137 | dep->resource_index = 0; |
| 1126 | 1138 | } |
| 1127 | 1139 | |
| @@ -1772,7 +1772,11 @@ static int __dwc3_stop_active_transfer(struct dwc3_ep *dep, bool force, bool int · 1771 unmodified lines | ||
| 1772 | 1772 | dep->flags |= DWC3_EP_DELAY_STOP; |
| 1773 | 1773 | return 0; |
| 1774 | 1774 | } |
| 1775 | − WARN_ON_ONCE(ret); | |
| 1775 | + | |
| 1776 | + if (ret) | |
| 1777 | + dev_err_ratelimited(dep->dwc->dev, | |
| 1778 | + "end transfer failed: %d\n", ret); | |
| 1779 | + | |
| 1776 | 1780 | dep->resource_index = 0; |
| 1777 | 1781 | |
| 1778 | 1782 | if (!interrupt) |
| @@ -3777,6 +3781,15 @@ static void dwc3_gadget_endpoint_transfer_complete(struct dwc3_ep *dep, · 1998 unmodified lines | ||
| 3777 | 3781 | static void dwc3_gadget_endpoint_transfer_not_ready(struct dwc3_ep *dep, |
| 3778 | 3782 | const struct dwc3_event_depevt *event) |
| 3779 | 3783 | { |
| 3784 | + /* | |
| 3785 | + * During a device-initiated disconnect, a late xferNotReady event can | |
| 3786 | + * be generated after the End Transfer command resets the event filter, | |
| 3787 | + * but before the controller is halted. Ignore it to prevent a new | |
| 3788 | + * transfer from starting. | |
| 3789 | + */ | |
| 3790 | + if (!dep->dwc->connected) | |
| 3791 | + return; | |
| 3792 | + | |
| 3780 | 3793 | dwc3_gadget_endpoint_frame_from_event(dep, event); |
| 3781 | 3794 | |
| 3782 | 3795 | /* |
| @@ -4039,7 +4052,9 @@ static void dwc3_clear_stall_all_ep(struct dwc3 *dwc) · 256 unmodified lines | ||
| 4039 | 4052 | dep->flags &= ~DWC3_EP_STALL; |
| 4040 | 4053 | |
| 4041 | 4054 | ret = dwc3_send_clear_stall_ep_cmd(dep); |
| 4042 | − WARN_ON_ONCE(ret); | |
| 4055 | + if (ret) | |
| 4056 | + dev_err_ratelimited(dwc->dev, | |
| 4057 | + "failed to clear STALL on %s\n", dep->name); | |
| 4043 | 4058 | } |
| 4044 | 4059 | } |
| 4045 | 4060 | |
| @@ -502,6 +502,7 @@ struct tegra_xudc { · 501 unmodified lines | ||
| 502 | 502 | struct clk_bulk_data *clks; |
| 503 | 503 | |
| 504 | 504 | bool device_mode; |
| 505 | + bool current_device_mode; | |
| 505 | 506 | struct work_struct usb_role_sw_work; |
| 506 | 507 | |
| 507 | 508 | struct phy **usb3_phy; |
| @@ -715,6 +716,8 @@ static void tegra_xudc_device_mode_on(struct tegra_xudc *xudc) · 207 unmodified lines | ||
| 715 | 716 | |
| 716 | 717 | phy_set_mode_ext(xudc->curr_utmi_phy, PHY_MODE_USB_OTG, |
| 717 | 718 | USB_ROLE_DEVICE); |
| 719 | + | |
| 720 | + xudc->current_device_mode = true; | |
| 718 | 721 | } |
| 719 | 722 | |
| 720 | 723 | static void tegra_xudc_device_mode_off(struct tegra_xudc *xudc) |
| @@ -725,6 +728,8 @@ static void tegra_xudc_device_mode_off(struct tegra_xudc *xudc) · 4 unmodified lines | ||
| 725 | 728 | |
| 726 | 729 | dev_dbg(xudc->dev, "device mode off\n"); |
| 727 | 730 | |
| 731 | + xudc->current_device_mode = false; | |
| 732 | + | |
| 728 | 733 | connected = !!(xudc_readl(xudc, PORTSC) & PORTSC_CCS); |
| 729 | 734 | |
| 730 | 735 | reinit_completion(&xudc->disconnect_complete); |
| @@ -4044,10 +4049,10 @@ static int __maybe_unused tegra_xudc_resume(struct device *dev) · 3313 unmodified lines | ||
| 4044 | 4049 | |
| 4045 | 4050 | spin_lock_irqsave(&xudc->lock, flags); |
| 4046 | 4051 | xudc->suspended = false; |
| 4052 | + if (xudc->device_mode != xudc->current_device_mode) | |
| 4053 | + schedule_work(&xudc->usb_role_sw_work); | |
| 4047 | 4054 | spin_unlock_irqrestore(&xudc->lock, flags); |
| 4048 | 4055 | |
| 4049 | − schedule_work(&xudc->usb_role_sw_work); | |
| 4050 | − | |
| 4051 | 4056 | pm_runtime_enable(dev); |
| 4052 | 4057 | |
| 4053 | 4058 | return 0; |
| @@ -704,8 +704,7 @@ static int xhci_enter_test_mode(struct xhci_hcd *xhci, · 703 unmodified lines | ||
| 704 | 704 | if (!xhci->devs[i]) |
| 705 | 705 | continue; |
| 706 | 706 | |
| 707 | − retval = xhci_disable_slot(xhci, i); | |
| 708 | − xhci_free_virt_device(xhci, i); | |
| 707 | + retval = xhci_disable_and_free_slot(xhci, i); | |
| 709 | 708 | if (retval) |
| 710 | 709 | xhci_err(xhci, "Failed to disable slot %d, %d. Enter test mode anyway\n", |
| 711 | 710 | i, retval); |
| @@ -865,21 +865,20 @@ free_tts: · 864 unmodified lines | ||
| 865 | 865 | * will be manipulated by the configure endpoint, allocate device, or update |
| 866 | 866 | * hub functions while this function is removing the TT entries from the list. |
| 867 | 867 | */ |
| 868 | −void xhci_free_virt_device(struct xhci_hcd *xhci, int slot_id) | |
| 868 | +void xhci_free_virt_device(struct xhci_hcd *xhci, struct xhci_virt_device *dev, | |
| 869 | + int slot_id) | |
| 869 | 870 | { |
| 870 | − struct xhci_virt_device *dev; | |
| 871 | 871 | int i; |
| 872 | 872 | int old_active_eps = 0; |
| 873 | 873 | |
| 874 | 874 | /* Slot ID 0 is reserved */ |
| 875 | − if (slot_id == 0 || !xhci->devs[slot_id]) | |
| 875 | + if (slot_id == 0 || !dev) | |
| 876 | 876 | return; |
| 877 | 877 | |
| 878 | − dev = xhci->devs[slot_id]; | |
| 879 | − | |
| 880 | − xhci->dcbaa->dev_context_ptrs[slot_id] = 0; | |
| 881 | − if (!dev) | |
| 882 | − return; | |
| 878 | + /* If device ctx array still points to _this_ device, clear it */ | |
| 879 | + if (dev->out_ctx && | |
| 880 | + xhci->dcbaa->dev_context_ptrs[slot_id] == cpu_to_le64(dev->out_ctx->dma)) | |
| 881 | + xhci->dcbaa->dev_context_ptrs[slot_id] = 0; | |
| 883 | 882 | |
| 884 | 883 | trace_xhci_free_virt_device(dev); |
| 885 | 884 | |
| @@ -920,8 +919,9 @@ void xhci_free_virt_device(struct xhci_hcd *xhci, int slot_id) · 34 unmodified lines | ||
| 920 | 919 | dev->udev->slot_id = 0; |
| 921 | 920 | if (dev->rhub_port && dev->rhub_port->slot_id == slot_id) |
| 922 | 921 | dev->rhub_port->slot_id = 0; |
| 923 | − kfree(xhci->devs[slot_id]); | |
| 924 | − xhci->devs[slot_id] = NULL; | |
| 922 | + if (xhci->devs[slot_id] == dev) | |
| 923 | + xhci->devs[slot_id] = NULL; | |
| 924 | + kfree(dev); | |
| 925 | 925 | } |
| 926 | 926 | |
| 927 | 927 | /* |
| @@ -962,7 +962,7 @@ static void xhci_free_virt_devices_depth_first(struct xhci_hcd *xhci, int slot_i · 34 unmodified lines | ||
| 962 | 962 | out: |
| 963 | 963 | /* we are now at a leaf device */ |
| 964 | 964 | xhci_debugfs_remove_slot(xhci, slot_id); |
| 965 | − xhci_free_virt_device(xhci, slot_id); | |
| 965 | + xhci_free_virt_device(xhci, vdev, slot_id); | |
| 966 | 966 | } |
| 967 | 967 | |
| 968 | 968 | int xhci_alloc_virt_device(struct xhci_hcd *xhci, int slot_id, |
| @@ -47,8 +47,9 @@ · 46 unmodified lines | ||
| 47 | 47 | #define RENESAS_ROM_ERASE_MAGIC 0x5A65726F |
| 48 | 48 | #define RENESAS_ROM_WRITE_MAGIC 0x53524F4D |
| 49 | 49 | |
| 50 | −#define RENESAS_RETRY 10000 | |
| 51 | −#define RENESAS_DELAY 10 | |
| 50 | +#define RENESAS_RETRY 50000 /* 50000 * RENESAS_DELAY ~= 500ms */ | |
| 51 | +#define RENESAS_CHIP_ERASE_RETRY 500000 /* 500000 * RENESAS_DELAY ~= 5s */ | |
| 52 | +#define RENESAS_DELAY 10 | |
| 52 | 53 | |
| 53 | 54 | #define RENESAS_FW_NAME "renesas_usb_fw.mem" |
| 54 | 55 | |
| @@ -407,7 +408,7 @@ static void renesas_rom_erase(struct pci_dev *pdev) · 352 unmodified lines | ||
| 407 | 408 | /* sleep a bit while ROM is erased */ |
| 408 | 409 | msleep(20); |
| 409 | 410 | |
| 410 | − for (i = 0; i < RENESAS_RETRY; i++) { | |
| 411 | + for (i = 0; i < RENESAS_CHIP_ERASE_RETRY; i++) { | |
| 411 | 412 | retval = pci_read_config_byte(pdev, RENESAS_ROM_STATUS, |
| 412 | 413 | &status); |
| 413 | 414 | status &= RENESAS_ROM_STATUS_ERASE; |
| @@ -1592,7 +1592,8 @@ static void xhci_handle_cmd_enable_slot(int slot_id, struct xhci_command *comman · 1591 unmodified lines | ||
| 1592 | 1592 | command->slot_id = 0; |
| 1593 | 1593 | } |
| 1594 | 1594 | |
| 1595 | −static void xhci_handle_cmd_disable_slot(struct xhci_hcd *xhci, int slot_id) | |
| 1595 | +static void xhci_handle_cmd_disable_slot(struct xhci_hcd *xhci, int slot_id, | |
| 1596 | + u32 cmd_comp_code) | |
| 1596 | 1597 | { |
| 1597 | 1598 | struct xhci_virt_device *virt_dev; |
| 1598 | 1599 | struct xhci_slot_ctx *slot_ctx; |
| @@ -1607,6 +1608,10 @@ static void xhci_handle_cmd_disable_slot(struct xhci_hcd *xhci, int slot_id) · 8 unmodified lines | ||
| 1607 | 1608 | if (xhci->quirks & XHCI_EP_LIMIT_QUIRK) |
| 1608 | 1609 | /* Delete default control endpoint resources */ |
| 1609 | 1610 | xhci_free_device_endpoint_resources(xhci, virt_dev, true); |
| 1611 | + if (cmd_comp_code == COMP_SUCCESS) { | |
| 1612 | + xhci->dcbaa->dev_context_ptrs[slot_id] = 0; | |
| 1613 | + xhci->devs[slot_id] = NULL; | |
| 1614 | + } | |
| 1610 | 1615 | } |
| 1611 | 1616 | |
| 1612 | 1617 | static void xhci_handle_cmd_config_ep(struct xhci_hcd *xhci, int slot_id) |
| @@ -1856,7 +1861,7 @@ static void handle_cmd_completion(struct xhci_hcd *xhci, · 243 unmodified lines | ||
| 1856 | 1861 | xhci_handle_cmd_enable_slot(slot_id, cmd, cmd_comp_code); |
| 1857 | 1862 | break; |
| 1858 | 1863 | case TRB_DISABLE_SLOT: |
| 1859 | − xhci_handle_cmd_disable_slot(xhci, slot_id); | |
| 1864 | + xhci_handle_cmd_disable_slot(xhci, slot_id, cmd_comp_code); | |
| 1860 | 1865 | break; |
| 1861 | 1866 | case TRB_CONFIG_EP: |
| 1862 | 1867 | if (!cmd->completion) |
| @@ -309,6 +309,7 @@ int xhci_enable_interrupter(struct xhci_interrupter *ir) · 308 unmodified lines | ||
| 309 | 309 | return -EINVAL; |
| 310 | 310 | |
| 311 | 311 | iman = readl(&ir->ir_set->iman); |
| 312 | + iman &= ~IMAN_IP; | |
| 312 | 313 | iman |= IMAN_IE; |
| 313 | 314 | writel(iman, &ir->ir_set->iman); |
| 314 | 315 | |
| @@ -325,6 +326,7 @@ int xhci_disable_interrupter(struct xhci_hcd *xhci, struct xhci_interrupter *ir) · 10 unmodified lines | ||
| 325 | 326 | return -EINVAL; |
| 326 | 327 | |
| 327 | 328 | iman = readl(&ir->ir_set->iman); |
| 329 | + iman &= ~IMAN_IP; | |
| 328 | 330 | iman &= ~IMAN_IE; |
| 329 | 331 | writel(iman, &ir->ir_set->iman); |
| 330 | 332 | |
| @@ -3932,8 +3934,7 @@ static int xhci_discover_or_reset_device(struct usb_hcd *hcd, · 3601 unmodified lines | ||
| 3932 | 3934 | * Obtaining a new device slot to inform the xHCI host that |
| 3933 | 3935 | * the USB device has been reset. |
| 3934 | 3936 | */ |
| 3935 | − ret = xhci_disable_slot(xhci, udev->slot_id); | |
| 3936 | − xhci_free_virt_device(xhci, udev->slot_id); | |
| 3937 | + ret = xhci_disable_and_free_slot(xhci, udev->slot_id); | |
| 3937 | 3938 | if (!ret) { |
| 3938 | 3939 | ret = xhci_alloc_dev(hcd, udev); |
| 3939 | 3940 | if (ret == 1) |
| @@ -4090,7 +4091,7 @@ static void xhci_free_dev(struct usb_hcd *hcd, struct usb_device *udev) · 150 unmodified lines | ||
| 4090 | 4091 | xhci_disable_slot(xhci, udev->slot_id); |
| 4091 | 4092 | |
| 4092 | 4093 | spin_lock_irqsave(&xhci->lock, flags); |
| 4093 | − xhci_free_virt_device(xhci, udev->slot_id); | |
| 4094 | + xhci_free_virt_device(xhci, virt_dev, udev->slot_id); | |
| 4094 | 4095 | spin_unlock_irqrestore(&xhci->lock, flags); |
| 4095 | 4096 | |
| 4096 | 4097 | } |
| @@ -4139,6 +4140,16 @@ int xhci_disable_slot(struct xhci_hcd *xhci, u32 slot_id) · 42 unmodified lines | ||
| 4139 | 4140 | return 0; |
| 4140 | 4141 | } |
| 4141 | 4142 | |
| 4143 | +int xhci_disable_and_free_slot(struct xhci_hcd *xhci, u32 slot_id) | |
| 4144 | +{ | |
| 4145 | + struct xhci_virt_device *vdev = xhci->devs[slot_id]; | |
| 4146 | + int ret; | |
| 4147 | + | |
| 4148 | + ret = xhci_disable_slot(xhci, slot_id); | |
| 4149 | + xhci_free_virt_device(xhci, vdev, slot_id); | |
| 4150 | + return ret; | |
| 4151 | +} | |
| 4152 | + | |
| 4142 | 4153 | /* |
| 4143 | 4154 | * Checks if we have enough host controller resources for the default control |
| 4144 | 4155 | * endpoint. |
| @@ -4245,8 +4256,7 @@ int xhci_alloc_dev(struct usb_hcd *hcd, struct usb_device *udev) · 100 unmodified lines | ||
| 4245 | 4256 | return 1; |
| 4246 | 4257 | |
| 4247 | 4258 | disable_slot: |
| 4248 | − xhci_disable_slot(xhci, udev->slot_id); | |
| 4249 | − xhci_free_virt_device(xhci, udev->slot_id); | |
| 4259 | + xhci_disable_and_free_slot(xhci, udev->slot_id); | |
| 4250 | 4260 | |
| 4251 | 4261 | return 0; |
| 4252 | 4262 | } |
| @@ -4382,8 +4392,7 @@ static int xhci_setup_device(struct usb_hcd *hcd, struct usb_device *udev, · 129 unmodified lines | ||
| 4382 | 4392 | dev_warn(&udev->dev, "Device not responding to setup %s.\n", act); |
| 4383 | 4393 | |
| 4384 | 4394 | mutex_unlock(&xhci->mutex); |
| 4385 | − ret = xhci_disable_slot(xhci, udev->slot_id); | |
| 4386 | − xhci_free_virt_device(xhci, udev->slot_id); | |
| 4395 | + ret = xhci_disable_and_free_slot(xhci, udev->slot_id); | |
| 4387 | 4396 | if (!ret) { |
| 4388 | 4397 | if (xhci_alloc_dev(hcd, udev) == 1) |
| 4389 | 4398 | xhci_setup_addressable_virt_dev(xhci, udev); |
| @@ -1791,7 +1791,7 @@ void xhci_dbg_trace(struct xhci_hcd *xhci, void (*trace)(struct va_format *), · 1790 unmodified lines | ||
| 1791 | 1791 | /* xHCI memory management */ |
| 1792 | 1792 | void xhci_mem_cleanup(struct xhci_hcd *xhci); |
| 1793 | 1793 | int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags); |
| 1794 | −void xhci_free_virt_device(struct xhci_hcd *xhci, int slot_id); | |
| 1794 | +void xhci_free_virt_device(struct xhci_hcd *xhci, struct xhci_virt_device *dev, int slot_id); | |
| 1795 | 1795 | int xhci_alloc_virt_device(struct xhci_hcd *xhci, int slot_id, struct usb_device *udev, gfp_t flags); |
| 1796 | 1796 | int xhci_setup_addressable_virt_dev(struct xhci_hcd *xhci, struct usb_device *udev); |
| 1797 | 1797 | void xhci_copy_ep0_dequeue_into_input_ctx(struct xhci_hcd *xhci, |
| @@ -1888,6 +1888,7 @@ void xhci_reset_bandwidth(struct usb_hcd *hcd, struct usb_device *udev); · 90 unmodified lines | ||
| 1888 | 1888 | int xhci_update_hub_device(struct usb_hcd *hcd, struct usb_device *hdev, |
| 1889 | 1889 | struct usb_tt *tt, gfp_t mem_flags); |
| 1890 | 1890 | int xhci_disable_slot(struct xhci_hcd *xhci, u32 slot_id); |
| 1891 | +int xhci_disable_and_free_slot(struct xhci_hcd *xhci, u32 slot_id); | |
| 1891 | 1892 | int xhci_ext_cap_init(struct xhci_hcd *xhci); |
| 1892 | 1893 | |
| 1893 | 1894 | int xhci_suspend(struct xhci_hcd *xhci, bool do_wakeup); |
| @@ -252,7 +252,7 @@ static int rts51x_bulk_transport(struct us_data *us, u8 lun, · 251 unmodified lines | ||
| 252 | 252 | return USB_STOR_TRANSPORT_ERROR; |
| 253 | 253 | } |
| 254 | 254 | |
| 255 | − residue = bcs->Residue; | |
| 255 | + residue = le32_to_cpu(bcs->Residue); | |
| 256 | 256 | if (bcs->Tag != us->tag) |
| 257 | 257 | return USB_STOR_TRANSPORT_ERROR; |
| 258 | 258 | |
| @@ -934,6 +934,13 @@ UNUSUAL_DEV( 0x05e3, 0x0723, 0x9451, 0x9451, · 933 unmodified lines | ||
| 934 | 934 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, |
| 935 | 935 | US_FL_SANE_SENSE ), |
| 936 | 936 | |
| 937 | +/* Added by Maël GUERIN <mael.guerin@murena.io> */ | |
| 938 | +UNUSUAL_DEV( 0x0603, 0x8611, 0x0000, 0xffff, | |
| 939 | + "Novatek", | |
| 940 | + "NTK96550-based camera", | |
| 941 | + USB_SC_SCSI, USB_PR_BULK, NULL, | |
| 942 | + US_FL_BULK_IGNORE_TAG ), | |
| 943 | + | |
| 937 | 944 | /* |
| 938 | 945 | * Reported by Hanno Boeck <hanno@gmx.de> |
| 939 | 946 | * Taken from the Lycoris Kernel |
| @@ -1494,6 +1501,28 @@ UNUSUAL_DEV( 0x0bc2, 0x3332, 0x0000, 0x9999, · 554 unmodified lines | ||
| 1494 | 1501 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, |
| 1495 | 1502 | US_FL_NO_WP_DETECT ), |
| 1496 | 1503 | |
| 1504 | +/* | |
| 1505 | + * Reported by Zenm Chen <zenmchen@gmail.com> | |
| 1506 | + * Ignore driver CD mode, otherwise usb_modeswitch may fail to switch | |
| 1507 | + * the device into Wi-Fi mode. | |
| 1508 | + */ | |
| 1509 | +UNUSUAL_DEV( 0x0bda, 0x1a2b, 0x0000, 0xffff, | |
| 1510 | + "Realtek", | |
| 1511 | + "DISK", | |
| 1512 | + USB_SC_DEVICE, USB_PR_DEVICE, NULL, | |
| 1513 | + US_FL_IGNORE_DEVICE ), | |
| 1514 | + | |
| 1515 | +/* | |
| 1516 | + * Reported by Zenm Chen <zenmchen@gmail.com> | |
| 1517 | + * Ignore driver CD mode, otherwise usb_modeswitch may fail to switch | |
| 1518 | + * the device into Wi-Fi mode. | |
| 1519 | + */ | |
| 1520 | +UNUSUAL_DEV( 0x0bda, 0xa192, 0x0000, 0xffff, | |
| 1521 | + "Realtek", | |
| 1522 | + "DISK", | |
| 1523 | + USB_SC_DEVICE, USB_PR_DEVICE, NULL, | |
| 1524 | + US_FL_IGNORE_DEVICE ), | |
| 1525 | + | |
| 1497 | 1526 | UNUSUAL_DEV( 0x0d49, 0x7310, 0x0000, 0x9999, |
| 1498 | 1527 | "Maxtor", |
| 1499 | 1528 | "USB to SATA", |
| @@ -1485,6 +1485,9 @@ static irqreturn_t fusb302_irq_intn(int irq, void *dev_id) · 1484 unmodified lines | ||
| 1485 | 1485 | struct fusb302_chip *chip = dev_id; |
| 1486 | 1486 | unsigned long flags; |
| 1487 | 1487 | |
| 1488 | + /* Disable our level triggered IRQ until our irq_work has cleared it */ | |
| 1489 | + disable_irq_nosync(chip->gpio_int_n_irq); | |
| 1490 | + | |
| 1488 | 1491 | spin_lock_irqsave(&chip->irq_lock, flags); |
| 1489 | 1492 | if (chip->irq_suspended) |
| 1490 | 1493 | chip->irq_while_suspended = true; |
| @@ -1627,6 +1630,7 @@ static void fusb302_irq_work(struct work_struct *work) · 136 unmodified lines | ||
| 1627 | 1630 | } |
| 1628 | 1631 | done: |
| 1629 | 1632 | mutex_unlock(&chip->lock); |
| 1633 | + enable_irq(chip->gpio_int_n_irq); | |
| 1630 | 1634 | } |
| 1631 | 1635 | |
| 1632 | 1636 | static int init_gpio(struct fusb302_chip *chip) |
| @@ -1751,10 +1755,9 @@ static int fusb302_probe(struct i2c_client *client) · 118 unmodified lines | ||
| 1751 | 1755 | goto destroy_workqueue; |
| 1752 | 1756 | } |
| 1753 | 1757 | |
| 1754 | − ret = devm_request_threaded_irq(dev, chip->gpio_int_n_irq, | |
| 1755 | − NULL, fusb302_irq_intn, | |
| 1756 | − IRQF_ONESHOT | IRQF_TRIGGER_LOW, | |
| 1757 | − "fsc_interrupt_int_n", chip); | |
| 1758 | + ret = request_irq(chip->gpio_int_n_irq, fusb302_irq_intn, | |
| 1759 | + IRQF_ONESHOT | IRQF_TRIGGER_LOW, | |
| 1760 | + "fsc_interrupt_int_n", chip); | |
| 1758 | 1761 | if (ret < 0) { |
| 1759 | 1762 | dev_err(dev, "cannot request IRQ for GPIO Int_N, ret=%d", ret); |
| 1760 | 1763 | goto tcpm_unregister_port; |
| @@ -1779,6 +1782,7 @@ static void fusb302_remove(struct i2c_client *client) · 18 unmodified lines | ||
| 1779 | 1782 | struct fusb302_chip *chip = i2c_get_clientdata(client); |
| 1780 | 1783 | |
| 1781 | 1784 | disable_irq_wake(chip->gpio_int_n_irq); |
| 1785 | + free_irq(chip->gpio_int_n_irq, chip); | |
| 1782 | 1786 | cancel_work_sync(&chip->irq_work); |
| 1783 | 1787 | cancel_delayed_work_sync(&chip->bc_lvl_handler); |
| 1784 | 1788 | tcpm_unregister_port(chip->tcpm_port); |
| @@ -188,6 +188,11 @@ static int max_contaminant_read_comparators(struct max_tcpci_chip *chip, u8 *ven · 187 unmodified lines | ||
| 188 | 188 | if (ret < 0) |
| 189 | 189 | return ret; |
| 190 | 190 | |
| 191 | + /* Disable low power mode */ | |
| 192 | + ret = regmap_update_bits(regmap, TCPC_VENDOR_CC_CTRL2, CCLPMODESEL, | |
| 193 | + FIELD_PREP(CCLPMODESEL, | |
| 194 | + LOW_POWER_MODE_DISABLE)); | |
| 195 | + | |
| 191 | 196 | /* Sleep to allow comparators settle */ |
| 192 | 197 | usleep_range(5000, 6000); |
| 193 | 198 | ret = regmap_update_bits(regmap, TCPC_TCPC_CTRL, TCPC_TCPC_CTRL_ORIENTATION, PLUG_ORNT_CC1); |
| @@ -324,6 +329,39 @@ static int max_contaminant_enable_dry_detection(struct max_tcpci_chip *chip) · 130 unmodified lines | ||
| 324 | 329 | return 0; |
| 325 | 330 | } |
| 326 | 331 | |
| 332 | +static int max_contaminant_enable_toggling(struct max_tcpci_chip *chip) | |
| 333 | +{ | |
| 334 | + struct regmap *regmap = chip->data.regmap; | |
| 335 | + int ret; | |
| 336 | + | |
| 337 | + /* Disable dry detection if enabled. */ | |
| 338 | + ret = regmap_update_bits(regmap, TCPC_VENDOR_CC_CTRL2, CCLPMODESEL, | |
| 339 | + FIELD_PREP(CCLPMODESEL, | |
| 340 | + LOW_POWER_MODE_DISABLE)); | |
| 341 | + if (ret) | |
| 342 | + return ret; | |
| 343 | + | |
| 344 | + ret = regmap_update_bits(regmap, TCPC_VENDOR_CC_CTRL1, CCCONNDRY, 0); | |
| 345 | + if (ret) | |
| 346 | + return ret; | |
| 347 | + | |
| 348 | + ret = max_tcpci_write8(chip, TCPC_ROLE_CTRL, TCPC_ROLE_CTRL_DRP | | |
| 349 | + FIELD_PREP(TCPC_ROLE_CTRL_CC1, | |
| 350 | + TCPC_ROLE_CTRL_CC_RD) | | |
| 351 | + FIELD_PREP(TCPC_ROLE_CTRL_CC2, | |
| 352 | + TCPC_ROLE_CTRL_CC_RD)); | |
| 353 | + if (ret) | |
| 354 | + return ret; | |
| 355 | + | |
| 356 | + ret = regmap_update_bits(regmap, TCPC_TCPC_CTRL, | |
| 357 | + TCPC_TCPC_CTRL_EN_LK4CONN_ALRT, | |
| 358 | + TCPC_TCPC_CTRL_EN_LK4CONN_ALRT); | |
| 359 | + if (ret) | |
| 360 | + return ret; | |
| 361 | + | |
| 362 | + return max_tcpci_write8(chip, TCPC_COMMAND, TCPC_CMD_LOOK4CONNECTION); | |
| 363 | +} | |
| 364 | + | |
| 327 | 365 | bool max_contaminant_is_contaminant(struct max_tcpci_chip *chip, bool disconnect_while_debounce, |
| 328 | 366 | bool *cc_handled) |
| 329 | 367 | { |
| @@ -340,6 +378,12 @@ bool max_contaminant_is_contaminant(struct max_tcpci_chip *chip, bool disconnect · 10 unmodified lines | ||
| 340 | 378 | if (ret < 0) |
| 341 | 379 | return false; |
| 342 | 380 | |
| 381 | + if (cc_status & TCPC_CC_STATUS_TOGGLING) { | |
| 382 | + if (chip->contaminant_state == DETECTED) | |
| 383 | + return true; | |
| 384 | + return false; | |
| 385 | + } | |
| 386 | + | |
| 343 | 387 | if (chip->contaminant_state == NOT_DETECTED || chip->contaminant_state == SINK) { |
| 344 | 388 | if (!disconnect_while_debounce) |
| 345 | 389 | msleep(100); |
| @@ -372,6 +416,12 @@ bool max_contaminant_is_contaminant(struct max_tcpci_chip *chip, bool disconnect · 26 unmodified lines | ||
| 372 | 416 | max_contaminant_enable_dry_detection(chip); |
| 373 | 417 | return true; |
| 374 | 418 | } |
| 419 | + | |
| 420 | + ret = max_contaminant_enable_toggling(chip); | |
| 421 | + if (ret) | |
| 422 | + dev_err(chip->dev, | |
| 423 | + "Failed to enable toggling, ret=%d", | |
| 424 | + ret); | |
| 375 | 425 | } |
| 376 | 426 | } else if (chip->contaminant_state == DETECTED) { |
| 377 | 427 | if (!(cc_status & TCPC_CC_STATUS_TOGGLING)) { |
| @@ -379,6 +429,14 @@ bool max_contaminant_is_contaminant(struct max_tcpci_chip *chip, bool disconnect · 1 unmodified line | ||
| 379 | 429 | if (chip->contaminant_state == DETECTED) { |
| 380 | 430 | max_contaminant_enable_dry_detection(chip); |
| 381 | 431 | return true; |
| 432 | + } else { | |
| 433 | + ret = max_contaminant_enable_toggling(chip); | |
| 434 | + if (ret) { | |
| 435 | + dev_err(chip->dev, | |
| 436 | + "Failed to enable toggling, ret=%d", | |
| 437 | + ret); | |
| 438 | + return true; | |
| 439 | + } | |
| 382 | 440 | } |
| 383 | 441 | } |
| 384 | 442 | } |
| @@ -21,6 +21,7 @@ · 20 unmodified lines | ||
| 21 | 21 | #define CCOVPDIS BIT(6) |
| 22 | 22 | #define SBURPCTRL BIT(5) |
| 23 | 23 | #define CCLPMODESEL GENMASK(4, 3) |
| 24 | +#define LOW_POWER_MODE_DISABLE 0 | |
| 24 | 25 | #define ULTRA_LOW_POWER_MODE 1 |
| 25 | 26 | #define CCRPCTRL GENMASK(2, 0) |
| 26 | 27 | #define UA_1_SRC 1 |
| @@ -718,26 +718,6 @@ int xs_watch_msg(struct xs_watch_event *event) · 717 unmodified lines | ||
| 718 | 718 | return 0; |
| 719 | 719 | } |
| 720 | 720 | |
| 721 | −/* | |
| 722 | − * Certain older XenBus toolstack cannot handle reading values that are | |
| 723 | − * not populated. Some Xen 3.4 installation are incapable of doing this | |
| 724 | − * so if we are running on anything older than 4 do not attempt to read | |
| 725 | − * control/platform-feature-xs_reset_watches. | |
| 726 | − */ | |
| 727 | −static bool xen_strict_xenbus_quirk(void) | |
| 728 | −{ | |
| 729 | −#ifdef CONFIG_X86 | |
| 730 | − uint32_t eax, ebx, ecx, edx, base; | |
| 731 | − | |
| 732 | − base = xen_cpuid_base(); | |
| 733 | − cpuid(base + 1, &eax, &ebx, &ecx, &edx); | |
| 734 | − | |
| 735 | − if ((eax >> 16) < 4) | |
| 736 | − return true; | |
| 737 | −#endif | |
| 738 | − return false; | |
| 739 | − | |
| 740 | −} | |
| 741 | 721 | static void xs_reset_watches(void) |
| 742 | 722 | { |
| 743 | 723 | int err; |
| @@ -745,9 +725,6 @@ static void xs_reset_watches(void) · 1 unmodified line | ||
| 745 | 725 | if (!xen_hvm_domain() || xen_initial_domain()) |
| 746 | 726 | return; |
| 747 | 727 | |
| 748 | − if (xen_strict_xenbus_quirk()) | |
| 749 | − return; | |
| 750 | − | |
| 751 | 728 | if (!xenbus_read_unsigned("control", |
| 752 | 729 | "platform-feature-xs_reset_watches", 0)) |
| 753 | 730 | return; |
| @@ -129,7 +129,7 @@ struct inode *anon_inode_make_secure_inode(struct super_block *sb, const char *n · 128 unmodified lines | ||
| 129 | 129 | } |
| 130 | 130 | return inode; |
| 131 | 131 | } |
| 132 | −EXPORT_SYMBOL_GPL_FOR_MODULES(anon_inode_make_secure_inode, "kvm"); | |
| 132 | +EXPORT_SYMBOL_FOR_MODULES(anon_inode_make_secure_inode, "kvm"); | |
| 133 | 133 | |
| 134 | 134 | static struct file *__anon_inode_getfile(const char *name, |
| 135 | 135 | const struct file_operations *fops, |
| @@ -1512,7 +1512,7 @@ out: · 1511 unmodified lines | ||
| 1512 | 1512 | |
| 1513 | 1513 | /* |
| 1514 | 1514 | * Return 0 if we have submitted or queued the sector for submission. |
| 1515 | − * Return <0 for critical errors. | |
| 1515 | + * Return <0 for critical errors, and the sector will have its dirty flag cleared. | |
| 1516 | 1516 | * |
| 1517 | 1517 | * Caller should make sure filepos < i_size and handle filepos >= i_size case. |
| 1518 | 1518 | */ |
| @@ -1535,8 +1535,17 @@ static int submit_one_sector(struct btrfs_inode *inode, · 16 unmodified lines | ||
| 1535 | 1535 | ASSERT(filepos < i_size); |
| 1536 | 1536 | |
| 1537 | 1537 | em = btrfs_get_extent(inode, NULL, filepos, sectorsize); |
| 1538 | − if (IS_ERR(em)) | |
| 1538 | + if (IS_ERR(em)) { | |
| 1539 | + /* | |
| 1540 | + * When submission failed, we should still clear the folio dirty. | |
| 1541 | + * Or the folio will be written back again but without any | |
| 1542 | + * ordered extent. | |
| 1543 | + */ | |
| 1544 | + btrfs_folio_clear_dirty(fs_info, folio, filepos, sectorsize); | |
| 1545 | + btrfs_folio_set_writeback(fs_info, folio, filepos, sectorsize); | |
| 1546 | + btrfs_folio_clear_writeback(fs_info, folio, filepos, sectorsize); | |
| 1539 | 1547 | return PTR_ERR(em); |
| 1548 | + } | |
| 1540 | 1549 | |
| 1541 | 1550 | extent_offset = filepos - em->start; |
| 1542 | 1551 | em_end = btrfs_extent_map_end(em); |
| @@ -1609,8 +1618,12 @@ static noinline_for_stack int extent_writepage_io(struct btrfs_inode *inode, · 66 unmodified lines | ||
| 1609 | 1618 | folio_unlock(folio); |
| 1610 | 1619 | return 1; |
| 1611 | 1620 | } |
| 1612 | − if (ret < 0) | |
| 1621 | + if (ret < 0) { | |
| 1622 | + btrfs_folio_clear_dirty(fs_info, folio, start, len); | |
| 1623 | + btrfs_folio_set_writeback(fs_info, folio, start, len); | |
| 1624 | + btrfs_folio_clear_writeback(fs_info, folio, start, len); | |
| 1613 | 1625 | return ret; |
| 1626 | + } | |
| 1614 | 1627 | |
| 1615 | 1628 | for (cur = start; cur < start + len; cur += fs_info->sectorsize) |
| 1616 | 1629 | set_bit((cur - folio_start) >> fs_info->sectorsize_bits, &range_bitmap); |
| @@ -1666,8 +1679,8 @@ static noinline_for_stack int extent_writepage_io(struct btrfs_inode *inode, · 49 unmodified lines | ||
| 1666 | 1679 | * Here we set writeback and clear for the range. If the full folio |
| 1667 | 1680 | * is no longer dirty then we clear the PAGECACHE_TAG_DIRTY tag. |
| 1668 | 1681 | * |
| 1669 | − * If we hit any error, the corresponding sector will still be dirty | |
| 1670 | − * thus no need to clear PAGECACHE_TAG_DIRTY. | |
| 1682 | + * If we hit any error, the corresponding sector will have its dirty | |
| 1683 | + * flag cleared and writeback finished, thus no need to handle the error case. | |
| 1671 | 1684 | */ |
| 1672 | 1685 | if (!submitted_io && !error) { |
| 1673 | 1686 | btrfs_folio_set_writeback(fs_info, folio, start, len); |
| @@ -1813,6 +1826,7 @@ static noinline_for_stack bool lock_extent_buffer_for_io(struct extent_buffer *e · 139 unmodified lines | ||
| 1813 | 1826 | xas_load(&xas); |
| 1814 | 1827 | xas_set_mark(&xas, PAGECACHE_TAG_WRITEBACK); |
| 1815 | 1828 | xas_clear_mark(&xas, PAGECACHE_TAG_DIRTY); |
| 1829 | + xas_clear_mark(&xas, PAGECACHE_TAG_TOWRITE); | |
| 1816 | 1830 | xas_unlock_irqrestore(&xas, flags); |
| 1817 | 1831 | |
| 1818 | 1832 | btrfs_set_header_flag(eb, BTRFS_HEADER_FLAG_WRITTEN); |
| @@ -4189,6 +4189,23 @@ int btrfs_update_inode_fallback(struct btrfs_trans_handle *trans, · 4188 unmodified lines | ||
| 4189 | 4189 | return ret; |
| 4190 | 4190 | } |
| 4191 | 4191 | |
| 4192 | +static void update_time_after_link_or_unlink(struct btrfs_inode *dir) | |
| 4193 | +{ | |
| 4194 | + struct timespec64 now; | |
| 4195 | + | |
| 4196 | + /* | |
| 4197 | + * If we are replaying a log tree, we do not want to update the mtime | |
| 4198 | + * and ctime of the parent directory with the current time, since the | |
| 4199 | + * log replay procedure is responsible for setting them to their correct | |
| 4200 | + * values (the ones it had when the fsync was done). | |
| 4201 | + */ | |
| 4202 | + if (test_bit(BTRFS_FS_LOG_RECOVERING, &dir->root->fs_info->flags)) | |
| 4203 | + return; | |
| 4204 | + | |
| 4205 | + now = inode_set_ctime_current(&dir->vfs_inode); | |
| 4206 | + inode_set_mtime_to_ts(&dir->vfs_inode, now); | |
| 4207 | +} | |
| 4208 | + | |
| 4192 | 4209 | /* |
| 4193 | 4210 | * unlink helper that gets used here in inode.c and in the tree logging |
| 4194 | 4211 | * recovery code. It remove a link in a directory with a given name, and |
| @@ -4289,7 +4306,7 @@ skip_backref: · 94 unmodified lines | ||
| 4289 | 4306 | inode_inc_iversion(&inode->vfs_inode); |
| 4290 | 4307 | inode_set_ctime_current(&inode->vfs_inode); |
| 4291 | 4308 | inode_inc_iversion(&dir->vfs_inode); |
| 4292 | − inode_set_mtime_to_ts(&dir->vfs_inode, inode_set_ctime_current(&dir->vfs_inode)); | |
| 4309 | + update_time_after_link_or_unlink(dir); | |
| 4293 | 4310 | |
| 4294 | 4311 | return btrfs_update_inode(trans, dir); |
| 4295 | 4312 | } |
| @@ -6683,15 +6700,7 @@ int btrfs_add_link(struct btrfs_trans_handle *trans, · 2387 unmodified lines | ||
| 6683 | 6700 | btrfs_i_size_write(parent_inode, parent_inode->vfs_inode.i_size + |
| 6684 | 6701 | name->len * 2); |
| 6685 | 6702 | inode_inc_iversion(&parent_inode->vfs_inode); |
| 6686 | − /* | |
| 6687 | − * If we are replaying a log tree, we do not want to update the mtime | |
| 6688 | − * and ctime of the parent directory with the current time, since the | |
| 6689 | − * log replay procedure is responsible for setting them to their correct | |
| 6690 | − * values (the ones it had when the fsync was done). | |
| 6691 | − */ | |
| 6692 | − if (!test_bit(BTRFS_FS_LOG_RECOVERING, &root->fs_info->flags)) | |
| 6693 | − inode_set_mtime_to_ts(&parent_inode->vfs_inode, | |
| 6694 | − inode_set_ctime_current(&parent_inode->vfs_inode)); | |
| 6703 | + update_time_after_link_or_unlink(parent_inode); | |
| 6695 | 6704 | |
| 6696 | 6705 | ret = btrfs_update_inode(trans, parent_inode); |
| 6697 | 6706 | if (ret) |
| @@ -448,8 +448,25 @@ void btrfs_subpage_set_writeback(const struct btrfs_fs_info *fs_info, · 447 unmodified lines | ||
| 448 | 448 | |
| 449 | 449 | spin_lock_irqsave(&bfs->lock, flags); |
| 450 | 450 | bitmap_set(bfs->bitmaps, start_bit, len >> fs_info->sectorsize_bits); |
| 451 | + | |
| 452 | + /* | |
| 453 | + * Don't clear the TOWRITE tag when starting writeback on a still-dirty | |
| 454 | + * folio. Doing so can cause WB_SYNC_ALL writepages() to overlook it, | |
| 455 | + * assume writeback is complete, and exit too early — violating sync | |
| 456 | + * ordering guarantees. | |
| 457 | + */ | |
| 451 | 458 | if (!folio_test_writeback(folio)) |
| 452 | − folio_start_writeback(folio); | |
| 459 | + __folio_start_writeback(folio, true); | |
| 460 | + if (!folio_test_dirty(folio)) { | |
| 461 | + struct address_space *mapping = folio_mapping(folio); | |
| 462 | + XA_STATE(xas, &mapping->i_pages, folio->index); | |
| 463 | + unsigned long flags; | |
| 464 | + | |
| 465 | + xas_lock_irqsave(&xas, flags); | |
| 466 | + xas_load(&xas); | |
| 467 | + xas_clear_mark(&xas, PAGECACHE_TAG_TOWRITE); | |
| 468 | + xas_unlock_irqrestore(&xas, flags); | |
| 469 | + } | |
| 453 | 470 | spin_unlock_irqrestore(&bfs->lock, flags); |
| 454 | 471 | } |
| 455 | 472 | |
| @@ -88,6 +88,9 @@ struct btrfs_fs_context { · 87 unmodified lines | ||
| 88 | 88 | refcount_t refs; |
| 89 | 89 | }; |
| 90 | 90 | |
| 91 | +static void btrfs_emit_options(struct btrfs_fs_info *info, | |
| 92 | + struct btrfs_fs_context *old); | |
| 93 | + | |
| 91 | 94 | enum { |
| 92 | 95 | Opt_acl, |
| 93 | 96 | Opt_clear_cache, |
| @@ -698,12 +701,9 @@ bool btrfs_check_options(const struct btrfs_fs_info *info, · 604 unmodified lines | ||
| 698 | 701 | |
| 699 | 702 | if (!test_bit(BTRFS_FS_STATE_REMOUNTING, &info->fs_state)) { |
| 700 | 703 | if (btrfs_raw_test_opt(*mount_opt, SPACE_CACHE)) { |
| 701 | − btrfs_info(info, "disk space caching is enabled"); | |
| 702 | 704 | btrfs_warn(info, |
| 703 | 705 | "space cache v1 is being deprecated and will be removed in a future release, please use -o space_cache=v2"); |
| 704 | 706 | } |
| 705 | − if (btrfs_raw_test_opt(*mount_opt, FREE_SPACE_TREE)) | |
| 706 | − btrfs_info(info, "using free-space-tree"); | |
| 707 | 707 | } |
| 708 | 708 | |
| 709 | 709 | return ret; |
| @@ -980,6 +980,8 @@ static int btrfs_fill_super(struct super_block *sb, · 270 unmodified lines | ||
| 980 | 980 | return ret; |
| 981 | 981 | } |
| 982 | 982 | |
| 983 | + btrfs_emit_options(fs_info, NULL); | |
| 984 | + | |
| 983 | 985 | inode = btrfs_iget(BTRFS_FIRST_FREE_OBJECTID, fs_info->fs_root); |
| 984 | 986 | if (IS_ERR(inode)) { |
| 985 | 987 | ret = PTR_ERR(inode); |
| @@ -1437,7 +1439,7 @@ static void btrfs_emit_options(struct btrfs_fs_info *info, · 451 unmodified lines | ||
| 1437 | 1439 | { |
| 1438 | 1440 | btrfs_info_if_set(info, old, NODATASUM, "setting nodatasum"); |
| 1439 | 1441 | btrfs_info_if_set(info, old, DEGRADED, "allowing degraded mounts"); |
| 1440 | − btrfs_info_if_set(info, old, NODATASUM, "setting nodatasum"); | |
| 1442 | + btrfs_info_if_set(info, old, NODATACOW, "setting nodatacow"); | |
| 1441 | 1443 | btrfs_info_if_set(info, old, SSD, "enabling ssd optimizations"); |
| 1442 | 1444 | btrfs_info_if_set(info, old, SSD_SPREAD, "using spread ssd allocation scheme"); |
| 1443 | 1445 | btrfs_info_if_set(info, old, NOBARRIER, "turning off barriers"); |
| @@ -1459,10 +1461,11 @@ static void btrfs_emit_options(struct btrfs_fs_info *info, · 15 unmodified lines | ||
| 1459 | 1461 | btrfs_info_if_set(info, old, IGNOREMETACSUMS, "ignoring meta csums"); |
| 1460 | 1462 | btrfs_info_if_set(info, old, IGNORESUPERFLAGS, "ignoring unknown super block flags"); |
| 1461 | 1463 | |
| 1464 | + btrfs_info_if_unset(info, old, NODATASUM, "setting datasum"); | |
| 1462 | 1465 | btrfs_info_if_unset(info, old, NODATACOW, "setting datacow"); |
| 1463 | 1466 | btrfs_info_if_unset(info, old, SSD, "not using ssd optimizations"); |
| 1464 | 1467 | btrfs_info_if_unset(info, old, SSD_SPREAD, "not using spread ssd allocation scheme"); |
| 1465 | − btrfs_info_if_unset(info, old, NOBARRIER, "turning off barriers"); | |
| 1468 | + btrfs_info_if_unset(info, old, NOBARRIER, "turning on barriers"); | |
| 1466 | 1469 | btrfs_info_if_unset(info, old, NOTREELOG, "enabling tree log"); |
| 1467 | 1470 | btrfs_info_if_unset(info, old, SPACE_CACHE, "disabling disk space caching"); |
| 1468 | 1471 | btrfs_info_if_unset(info, old, FREE_SPACE_TREE, "disabling free space tree"); |
| @@ -17,6 +17,7 @@ · 16 unmodified lines | ||
| 17 | 17 | #include "accessors.h" |
| 18 | 18 | #include "bio.h" |
| 19 | 19 | #include "transaction.h" |
| 20 | +#include "sysfs.h" | |
| 20 | 21 | |
| 21 | 22 | /* Maximum number of zones to report per blkdev_report_zones() call */ |
| 22 | 23 | #define BTRFS_REPORT_NR_ZONES 4096 |
| @@ -42,6 +43,9 @@ · 19 unmodified lines | ||
| 42 | 43 | /* Number of superblock log zones */ |
| 43 | 44 | #define BTRFS_NR_SB_LOG_ZONES 2 |
| 44 | 45 | |
| 46 | +/* Default number of max active zones when the device has no limits. */ | |
| 47 | +#define BTRFS_DEFAULT_MAX_ACTIVE_ZONES 128 | |
| 48 | + | |
| 45 | 49 | /* |
| 46 | 50 | * Minimum of active zones we need: |
| 47 | 51 | * |
| @@ -416,7 +420,10 @@ int btrfs_get_dev_zone_info(struct btrfs_device *device, bool populate_cache) · 368 unmodified lines | ||
| 416 | 420 | if (!IS_ALIGNED(nr_sectors, zone_sectors)) |
| 417 | 421 | zone_info->nr_zones++; |
| 418 | 422 | |
| 419 | − max_active_zones = bdev_max_active_zones(bdev); | |
| 423 | + max_active_zones = min_not_zero(bdev_max_active_zones(bdev), | |
| 424 | + bdev_max_open_zones(bdev)); | |
| 425 | + if (!max_active_zones && zone_info->nr_zones > BTRFS_DEFAULT_MAX_ACTIVE_ZONES) | |
| 426 | + max_active_zones = BTRFS_DEFAULT_MAX_ACTIVE_ZONES; | |
| 420 | 427 | if (max_active_zones && max_active_zones < BTRFS_MIN_ACTIVE_ZONES) { |
| 421 | 428 | btrfs_err(fs_info, |
| 422 | 429 | "zoned: %s: max active zones %u is too small, need at least %u active zones", |
| @@ -2168,10 +2175,15 @@ bool btrfs_zone_activate(struct btrfs_block_group *block_group) · 1745 unmodified lines | ||
| 2168 | 2175 | goto out_unlock; |
| 2169 | 2176 | } |
| 2170 | 2177 | |
| 2171 | − /* No space left */ | |
| 2172 | − if (btrfs_zoned_bg_is_full(block_group)) { | |
| 2173 | − ret = false; | |
| 2174 | − goto out_unlock; | |
| 2178 | + if (block_group->flags & BTRFS_BLOCK_GROUP_DATA) { | |
| 2179 | + /* The caller should check if the block group is full. */ | |
| 2180 | + if (WARN_ON_ONCE(btrfs_zoned_bg_is_full(block_group))) { | |
| 2181 | + ret = false; | |
| 2182 | + goto out_unlock; | |
| 2183 | + } | |
| 2184 | + } else { | |
| 2185 | + /* Since it is already written, it should have been active. */ | |
| 2186 | + WARN_ON_ONCE(block_group->meta_write_pointer != block_group->start); | |
| 2175 | 2187 | } |
| 2176 | 2188 | |
| 2177 | 2189 | for (i = 0; i < map->num_stripes; i++) { |
| @@ -2230,7 +2242,7 @@ static void wait_eb_writebacks(struct btrfs_block_group *block_group) · 52 unmodified lines | ||
| 2230 | 2242 | struct btrfs_fs_info *fs_info = block_group->fs_info; |
| 2231 | 2243 | const u64 end = block_group->start + block_group->length; |
| 2232 | 2244 | struct extent_buffer *eb; |
| 2233 | − unsigned long index, start = (block_group->start >> fs_info->sectorsize_bits); | |
| 2245 | + unsigned long index, start = (block_group->start >> fs_info->nodesize_bits); | |
| 2234 | 2246 | |
| 2235 | 2247 | rcu_read_lock(); |
| 2236 | 2248 | xa_for_each_start(&fs_info->buffer_tree, index, eb, start) { |
| @@ -2245,6 +2257,40 @@ static void wait_eb_writebacks(struct btrfs_block_group *block_group) · 8 unmodified lines | ||
| 2245 | 2257 | rcu_read_unlock(); |
| 2246 | 2258 | } |
| 2247 | 2259 | |
| 2260 | +static int call_zone_finish(struct btrfs_block_group *block_group, | |
| 2261 | + struct btrfs_io_stripe *stripe) | |
| 2262 | +{ | |
| 2263 | + struct btrfs_device *device = stripe->dev; | |
| 2264 | + const u64 physical = stripe->physical; | |
| 2265 | + struct btrfs_zoned_device_info *zinfo = device->zone_info; | |
| 2266 | + int ret; | |
| 2267 | + | |
| 2268 | + if (!device->bdev) | |
| 2269 | + return 0; | |
| 2270 | + | |
| 2271 | + if (zinfo->max_active_zones == 0) | |
| 2272 | + return 0; | |
| 2273 | + | |
| 2274 | + if (btrfs_dev_is_sequential(device, physical)) { | |
| 2275 | + unsigned int nofs_flags; | |
| 2276 | + | |
| 2277 | + nofs_flags = memalloc_nofs_save(); | |
| 2278 | + ret = blkdev_zone_mgmt(device->bdev, REQ_OP_ZONE_FINISH, | |
| 2279 | + physical >> SECTOR_SHIFT, | |
| 2280 | + zinfo->zone_size >> SECTOR_SHIFT); | |
| 2281 | + memalloc_nofs_restore(nofs_flags); | |
| 2282 | + | |
| 2283 | + if (ret) | |
| 2284 | + return ret; | |
| 2285 | + } | |
| 2286 | + | |
| 2287 | + if (!(block_group->flags & BTRFS_BLOCK_GROUP_DATA)) | |
| 2288 | + zinfo->reserved_active_zones++; | |
| 2289 | + btrfs_dev_clear_active_zone(device, physical); | |
| 2290 | + | |
| 2291 | + return 0; | |
| 2292 | +} | |
| 2293 | + | |
| 2248 | 2294 | static int do_zone_finish(struct btrfs_block_group *block_group, bool fully_written) |
| 2249 | 2295 | { |
| 2250 | 2296 | struct btrfs_fs_info *fs_info = block_group->fs_info; |
| @@ -2329,31 +2375,12 @@ static int do_zone_finish(struct btrfs_block_group *block_group, bool fully_writ · 78 unmodified lines | ||
| 2329 | 2375 | down_read(&dev_replace->rwsem); |
| 2330 | 2376 | map = block_group->physical_map; |
| 2331 | 2377 | for (i = 0; i < map->num_stripes; i++) { |
| 2332 | − struct btrfs_device *device = map->stripes[i].dev; | |
| 2333 | − const u64 physical = map->stripes[i].physical; | |
| 2334 | − struct btrfs_zoned_device_info *zinfo = device->zone_info; | |
| 2335 | − unsigned int nofs_flags; | |
| 2336 | − | |
| 2337 | − if (!device->bdev) | |
| 2338 | − continue; | |
| 2339 | − | |
| 2340 | − if (zinfo->max_active_zones == 0) | |
| 2341 | − continue; | |
| 2342 | − | |
| 2343 | − nofs_flags = memalloc_nofs_save(); | |
| 2344 | − ret = blkdev_zone_mgmt(device->bdev, REQ_OP_ZONE_FINISH, | |
| 2345 | − physical >> SECTOR_SHIFT, | |
| 2346 | − zinfo->zone_size >> SECTOR_SHIFT); | |
| 2347 | − memalloc_nofs_restore(nofs_flags); | |
| 2348 | 2378 | |
| 2379 | + ret = call_zone_finish(block_group, &map->stripes[i]); | |
| 2349 | 2380 | if (ret) { |
| 2350 | 2381 | up_read(&dev_replace->rwsem); |
| 2351 | 2382 | return ret; |
| 2352 | 2383 | } |
| 2353 | − | |
| 2354 | − if (!(block_group->flags & BTRFS_BLOCK_GROUP_DATA)) | |
| 2355 | − zinfo->reserved_active_zones++; | |
| 2356 | − btrfs_dev_clear_active_zone(device, physical); | |
| 2357 | 2384 | } |
| 2358 | 2385 | up_read(&dev_replace->rwsem); |
| 2359 | 2386 | |
| @@ -2504,12 +2531,12 @@ void btrfs_clear_data_reloc_bg(struct btrfs_block_group *bg) · 144 unmodified lines | ||
| 2504 | 2531 | void btrfs_zoned_reserve_data_reloc_bg(struct btrfs_fs_info *fs_info) |
| 2505 | 2532 | { |
| 2506 | 2533 | struct btrfs_space_info *data_sinfo = fs_info->data_sinfo; |
| 2507 | − struct btrfs_space_info *space_info = data_sinfo->sub_group[0]; | |
| 2534 | + struct btrfs_space_info *space_info = data_sinfo; | |
| 2508 | 2535 | struct btrfs_trans_handle *trans; |
| 2509 | 2536 | struct btrfs_block_group *bg; |
| 2510 | 2537 | struct list_head *bg_list; |
| 2511 | 2538 | u64 alloc_flags; |
| 2512 | − bool initial = false; | |
| 2539 | + bool first = true; | |
| 2513 | 2540 | bool did_chunk_alloc = false; |
| 2514 | 2541 | int index; |
| 2515 | 2542 | int ret; |
| @@ -2523,21 +2550,52 @@ void btrfs_zoned_reserve_data_reloc_bg(struct btrfs_fs_info *fs_info) · 7 unmodified lines | ||
| 2523 | 2550 | if (sb_rdonly(fs_info->sb)) |
| 2524 | 2551 | return; |
| 2525 | 2552 | |
| 2526 | − ASSERT(space_info->subgroup_id == BTRFS_SUB_GROUP_DATA_RELOC); | |
| 2527 | 2553 | alloc_flags = btrfs_get_alloc_profile(fs_info, space_info->flags); |
| 2528 | 2554 | index = btrfs_bg_flags_to_raid_index(alloc_flags); |
| 2529 | 2555 | |
| 2530 | − bg_list = &data_sinfo->block_groups[index]; | |
| 2556 | + /* Scan the data space_info to find empty block groups. Take the second one. */ | |
| 2531 | 2557 | again: |
| 2558 | + bg_list = &space_info->block_groups[index]; | |
| 2532 | 2559 | list_for_each_entry(bg, bg_list, list) { |
| 2533 | − if (bg->used > 0) | |
| 2560 | + if (bg->alloc_offset != 0) | |
| 2534 | 2561 | continue; |
| 2535 | 2562 | |
| 2536 | − if (!initial) { | |
| 2537 | − initial = true; | |
| 2563 | + if (first) { | |
| 2564 | + first = false; | |
| 2538 | 2565 | continue; |
| 2539 | 2566 | } |
| 2540 | 2567 | |
| 2568 | + if (space_info == data_sinfo) { | |
| 2569 | + /* Migrate the block group to the data relocation space_info. */ | |
| 2570 | + struct btrfs_space_info *reloc_sinfo = data_sinfo->sub_group[0]; | |
| 2571 | + int factor; | |
| 2572 | + | |
| 2573 | + ASSERT(reloc_sinfo->subgroup_id == BTRFS_SUB_GROUP_DATA_RELOC); | |
| 2574 | + factor = btrfs_bg_type_to_factor(bg->flags); | |
| 2575 | + | |
| 2576 | + down_write(&space_info->groups_sem); | |
| 2577 | + list_del_init(&bg->list); | |
| 2578 | + /* We can assume this as we choose the second empty one. */ | |
| 2579 | + ASSERT(!list_empty(&space_info->block_groups[index])); | |
| 2580 | + up_write(&space_info->groups_sem); | |
| 2581 | + | |
| 2582 | + spin_lock(&space_info->lock); | |
| 2583 | + space_info->total_bytes -= bg->length; | |
| 2584 | + space_info->disk_total -= bg->length * factor; | |
| 2585 | + /* There is no allocation ever happened. */ | |
| 2586 | + ASSERT(bg->used == 0); | |
| 2587 | + ASSERT(bg->zone_unusable == 0); | |
| 2588 | + /* No super block in a block group on the zoned setup. */ | |
| 2589 | + ASSERT(bg->bytes_super == 0); | |
| 2590 | + spin_unlock(&space_info->lock); | |
| 2591 | + | |
| 2592 | + bg->space_info = reloc_sinfo; | |
| 2593 | + if (reloc_sinfo->block_group_kobjs[index] == NULL) | |
| 2594 | + btrfs_sysfs_add_block_group_type(bg); | |
| 2595 | + | |
| 2596 | + btrfs_add_bg_to_space_info(fs_info, bg); | |
| 2597 | + } | |
| 2598 | + | |
| 2541 | 2599 | fs_info->data_reloc_bg = bg->start; |
| 2542 | 2600 | set_bit(BLOCK_GROUP_FLAG_ZONED_DATA_RELOC, &bg->runtime_flags); |
| 2543 | 2601 | btrfs_zone_activate(bg); |
| @@ -2552,11 +2610,18 @@ again: · 8 unmodified lines | ||
| 2552 | 2610 | if (IS_ERR(trans)) |
| 2553 | 2611 | return; |
| 2554 | 2612 | |
| 2613 | + /* Allocate new BG in the data relocation space_info. */ | |
| 2614 | + space_info = data_sinfo->sub_group[0]; | |
| 2615 | + ASSERT(space_info->subgroup_id == BTRFS_SUB_GROUP_DATA_RELOC); | |
| 2555 | 2616 | ret = btrfs_chunk_alloc(trans, space_info, alloc_flags, CHUNK_ALLOC_FORCE); |
| 2556 | 2617 | btrfs_end_transaction(trans); |
| 2557 | 2618 | if (ret == 1) { |
| 2619 | + /* | |
| 2620 | + * We allocated a new block group in the data relocation space_info. We | |
| 2621 | + * can take that one. | |
| 2622 | + */ | |
| 2623 | + first = false; | |
| 2558 | 2624 | did_chunk_alloc = true; |
| 2559 | − bg_list = &space_info->block_groups[index]; | |
| 2560 | 2625 | goto again; |
| 2561 | 2626 | } |
| 2562 | 2627 | } |
| @@ -157,8 +157,8 @@ static void __end_buffer_read_notouch(struct buffer_head *bh, int uptodate) · 156 unmodified lines | ||
| 157 | 157 | */ |
| 158 | 158 | void end_buffer_read_sync(struct buffer_head *bh, int uptodate) |
| 159 | 159 | { |
| 160 | − __end_buffer_read_notouch(bh, uptodate); | |
| 161 | 160 | put_bh(bh); |
| 161 | + __end_buffer_read_notouch(bh, uptodate); | |
| 162 | 162 | } |
| 163 | 163 | EXPORT_SYMBOL(end_buffer_read_sync); |
| 164 | 164 | |
| @@ -345,7 +345,7 @@ static bool coredump_parse(struct core_name *cn, struct coredump_params *cprm, · 344 unmodified lines | ||
| 345 | 345 | was_space = false; |
| 346 | 346 | err = cn_printf(cn, "%c", '\0'); |
| 347 | 347 | if (err) |
| 348 | − return err; | |
| 348 | + return false; | |
| 349 | 349 | (*argv)[(*argc)++] = cn->used; |
| 350 | 350 | } |
| 351 | 351 | } |
| @@ -183,6 +183,9 @@ static int debugfs_reconfigure(struct fs_context *fc) · 182 unmodified lines | ||
| 183 | 183 | struct debugfs_fs_info *sb_opts = sb->s_fs_info; |
| 184 | 184 | struct debugfs_fs_info *new_opts = fc->s_fs_info; |
| 185 | 185 | |
| 186 | + if (!new_opts) | |
| 187 | + return 0; | |
| 188 | + | |
| 186 | 189 | sync_filesystem(sb); |
| 187 | 190 | |
| 188 | 191 | /* structure copy of new mount options to sb */ |
| @@ -282,10 +285,16 @@ static int debugfs_fill_super(struct super_block *sb, struct fs_context *fc) · 93 unmodified lines | ||
| 282 | 285 | |
| 283 | 286 | static int debugfs_get_tree(struct fs_context *fc) |
| 284 | 287 | { |
| 288 | + int err; | |
| 289 | + | |
| 285 | 290 | if (!(debugfs_allow & DEBUGFS_ALLOW_API)) |
| 286 | 291 | return -EPERM; |
| 287 | 292 | |
| 288 | − return get_tree_single(fc, debugfs_fill_super); | |
| 293 | + err = get_tree_single(fc, debugfs_fill_super); | |
| 294 | + if (err) | |
| 295 | + return err; | |
| 296 | + | |
| 297 | + return debugfs_reconfigure(fc); | |
| 289 | 298 | } |
| 290 | 299 | |
| 291 | 300 | static void debugfs_free_fc(struct fs_context *fc) |
| @@ -393,6 +393,14 @@ static unsigned int ext4_getfsmap_find_sb(struct super_block *sb, · 392 unmodified lines | ||
| 393 | 393 | /* Reserved GDT blocks */ |
| 394 | 394 | if (!ext4_has_feature_meta_bg(sb) || metagroup < first_meta_bg) { |
| 395 | 395 | len = le16_to_cpu(sbi->s_es->s_reserved_gdt_blocks); |
| 396 | + | |
| 397 | + /* | |
| 398 | + * mkfs.ext4 can set s_reserved_gdt_blocks as 0 in some cases, | |
| 399 | + * check for that. | |
| 400 | + */ | |
| 401 | + if (!len) | |
| 402 | + return 0; | |
| 403 | + | |
| 396 | 404 | error = ext4_getfsmap_fill(meta_list, fsb, len, |
| 397 | 405 | EXT4_FMR_OWN_RESV_GDT); |
| 398 | 406 | if (error) |
| @@ -526,6 +534,7 @@ static int ext4_getfsmap_datadev(struct super_block *sb, · 127 unmodified lines | ||
| 526 | 534 | ext4_group_t end_ag; |
| 527 | 535 | ext4_grpblk_t first_cluster; |
| 528 | 536 | ext4_grpblk_t last_cluster; |
| 537 | + struct ext4_fsmap irec; | |
| 529 | 538 | int error = 0; |
| 530 | 539 | |
| 531 | 540 | bofs = le32_to_cpu(sbi->s_es->s_first_data_block); |
| @@ -609,10 +618,18 @@ static int ext4_getfsmap_datadev(struct super_block *sb, · 77 unmodified lines | ||
| 609 | 618 | goto err; |
| 610 | 619 | } |
| 611 | 620 | |
| 612 | − /* Report any gaps at the end of the bg */ | |
| 621 | + /* | |
| 622 | + * The dummy record below will cause ext4_getfsmap_helper() to report | |
| 623 | + * any allocated blocks at the end of the range. | |
| 624 | + */ | |
| 625 | + irec.fmr_device = 0; | |
| 626 | + irec.fmr_physical = end_fsb + 1; | |
| 627 | + irec.fmr_length = 0; | |
| 628 | + irec.fmr_owner = EXT4_FMR_OWN_FREE; | |
| 629 | + irec.fmr_flags = 0; | |
| 630 | + | |
| 613 | 631 | info->gfi_last = true; |
| 614 | − error = ext4_getfsmap_datadev_helper(sb, end_ag, last_cluster + 1, | |
| 615 | − 0, info); | |
| 632 | + error = ext4_getfsmap_helper(sb, info, &irec); | |
| 616 | 633 | if (error) |
| 617 | 634 | goto err; |
| 618 | 635 | |
| @@ -539,7 +539,7 @@ int ext4_ind_map_blocks(handle_t *handle, struct inode *inode, · 538 unmodified lines | ||
| 539 | 539 | int indirect_blks; |
| 540 | 540 | int blocks_to_boundary = 0; |
| 541 | 541 | int depth; |
| 542 | − int count = 0; | |
| 542 | + u64 count = 0; | |
| 543 | 543 | ext4_fsblk_t first_block = 0; |
| 544 | 544 | |
| 545 | 545 | trace_ext4_ind_map_blocks_enter(inode, map->m_lblk, map->m_len, flags); |
| @@ -588,7 +588,7 @@ int ext4_ind_map_blocks(handle_t *handle, struct inode *inode, · 42 unmodified lines | ||
| 588 | 588 | count++; |
| 589 | 589 | /* Fill in size of a hole we found */ |
| 590 | 590 | map->m_pblk = 0; |
| 591 | − map->m_len = min_t(unsigned int, map->m_len, count); | |
| 591 | + map->m_len = umin(map->m_len, count); | |
| 592 | 592 | goto cleanup; |
| 593 | 593 | } |
| 594 | 594 | |
| @@ -146,7 +146,7 @@ static inline int ext4_begin_ordered_truncate(struct inode *inode, · 145 unmodified lines | ||
| 146 | 146 | */ |
| 147 | 147 | int ext4_inode_is_fast_symlink(struct inode *inode) |
| 148 | 148 | { |
| 149 | − if (!(EXT4_I(inode)->i_flags & EXT4_EA_INODE_FL)) { | |
| 149 | + if (!ext4_has_feature_ea_inode(inode->i_sb)) { | |
| 150 | 150 | int ea_blocks = EXT4_I(inode)->i_file_acl ? |
| 151 | 151 | EXT4_CLUSTER_SIZE(inode->i_sb) >> 9 : 0; |
| 152 | 152 | |
| @@ -3155,7 +3155,7 @@ retry: · 3002 unmodified lines | ||
| 3155 | 3155 | folio_unlock(folio); |
| 3156 | 3156 | folio_put(folio); |
| 3157 | 3157 | /* |
| 3158 | − * block_write_begin may have instantiated a few blocks | |
| 3158 | + * ext4_block_write_begin may have instantiated a few blocks | |
| 3159 | 3159 | * outside i_size. Trim these off again. Don't need |
| 3160 | 3160 | * i_size_read because we hold inode lock. |
| 3161 | 3161 | */ |
| @@ -2965,7 +2965,6 @@ int ext4_init_new_dir(handle_t *handle, struct inode *dir, · 2964 unmodified lines | ||
| 2965 | 2965 | struct inode *inode) |
| 2966 | 2966 | { |
| 2967 | 2967 | struct buffer_head *dir_block = NULL; |
| 2968 | − struct ext4_dir_entry_2 *de; | |
| 2969 | 2968 | ext4_lblk_t block = 0; |
| 2970 | 2969 | int err; |
| 2971 | 2970 | |
| @@ -2982,10 +2981,7 @@ int ext4_init_new_dir(handle_t *handle, struct inode *dir, · 10 unmodified lines | ||
| 2982 | 2981 | dir_block = ext4_append(handle, inode, &block); |
| 2983 | 2982 | if (IS_ERR(dir_block)) |
| 2984 | 2983 | return PTR_ERR(dir_block); |
| 2985 | − de = (struct ext4_dir_entry_2 *)dir_block->b_data; | |
| 2986 | 2984 | err = ext4_init_dirblock(handle, inode, dir_block, dir->i_ino, NULL, 0); |
| 2987 | − if (err) | |
| 2988 | − goto out; | |
| 2989 | 2985 | out: |
| 2990 | 2986 | brelse(dir_block); |
| 2991 | 2987 | return err; |
| @@ -589,8 +589,9 @@ int ext4_init_orphan_info(struct super_block *sb) · 588 unmodified lines | ||
| 589 | 589 | } |
| 590 | 590 | oi->of_blocks = inode->i_size >> sb->s_blocksize_bits; |
| 591 | 591 | oi->of_csum_seed = EXT4_I(inode)->i_csum_seed; |
| 592 | − oi->of_binfo = kmalloc(oi->of_blocks*sizeof(struct ext4_orphan_block), | |
| 593 | − GFP_KERNEL); | |
| 592 | + oi->of_binfo = kmalloc_array(oi->of_blocks, | |
| 593 | + sizeof(struct ext4_orphan_block), | |
| 594 | + GFP_KERNEL); | |
| 594 | 595 | if (!oi->of_binfo) { |
| 595 | 596 | ret = -ENOMEM; |
| 596 | 597 | goto out_put; |
| @@ -547,7 +547,7 @@ int ext4_bio_write_folio(struct ext4_io_submit *io, struct folio *folio, · 546 unmodified lines | ||
| 547 | 547 | * first page of the bio. Otherwise it can deadlock. |
| 548 | 548 | */ |
| 549 | 549 | if (io->io_bio) |
| 550 | − gfp_flags = GFP_NOWAIT | __GFP_NOWARN; | |
| 550 | + gfp_flags = GFP_NOWAIT; | |
| 551 | 551 | retry_encrypt: |
| 552 | 552 | bounce_page = fscrypt_encrypt_pagecache_blocks(folio, |
| 553 | 553 | enc_bytes, 0, gfp_flags); |
| @@ -268,7 +268,7 @@ struct buffer_head *ext4_sb_bread_unmovable(struct super_block *sb, · 267 unmodified lines | ||
| 268 | 268 | void ext4_sb_breadahead_unmovable(struct super_block *sb, sector_t block) |
| 269 | 269 | { |
| 270 | 270 | struct buffer_head *bh = bdev_getblk(sb->s_bdev, block, |
| 271 | − sb->s_blocksize, GFP_NOWAIT | __GFP_NOWARN); | |
| 271 | + sb->s_blocksize, GFP_NOWAIT); | |
| 272 | 272 | |
| 273 | 273 | if (likely(bh)) { |
| 274 | 274 | if (trylock_buffer(bh)) |
| @@ -1998,6 +1998,9 @@ int ext4_init_fs_context(struct fs_context *fc) · 1723 unmodified lines | ||
| 1998 | 1998 | fc->fs_private = ctx; |
| 1999 | 1999 | fc->ops = &ext4_context_ops; |
| 2000 | 2000 | |
| 2001 | + /* i_version is always enabled now */ | |
| 2002 | + fc->sb_flags |= SB_I_VERSION; | |
| 2003 | + | |
| 2001 | 2004 | return 0; |
| 2002 | 2005 | } |
| 2003 | 2006 | |
| @@ -2975,6 +2978,8 @@ static int _ext4_show_options(struct seq_file *seq, struct super_block *sb, · 971 unmodified lines | ||
| 2975 | 2978 | SEQ_OPTS_PRINT("min_batch_time=%u", sbi->s_min_batch_time); |
| 2976 | 2979 | if (nodefs || sbi->s_max_batch_time != EXT4_DEF_MAX_BATCH_TIME) |
| 2977 | 2980 | SEQ_OPTS_PRINT("max_batch_time=%u", sbi->s_max_batch_time); |
| 2981 | + if (nodefs && sb->s_flags & SB_I_VERSION) | |
| 2982 | + SEQ_OPTS_PUTS("i_version"); | |
| 2978 | 2983 | if (nodefs || sbi->s_stripe) |
| 2979 | 2984 | SEQ_OPTS_PRINT("stripe=%lu", sbi->s_stripe); |
| 2980 | 2985 | if (nodefs || EXT4_MOUNT_DATA_FLAGS & |
| @@ -5314,9 +5319,6 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb) · 2333 unmodified lines | ||
| 5314 | 5319 | sb->s_flags = (sb->s_flags & ~SB_POSIXACL) | |
| 5315 | 5320 | (test_opt(sb, POSIX_ACL) ? SB_POSIXACL : 0); |
| 5316 | 5321 | |
| 5317 | − /* i_version is always enabled now */ | |
| 5318 | − sb->s_flags |= SB_I_VERSION; | |
| 5319 | − | |
| 5320 | 5322 | /* HSM events are allowed by default. */ |
| 5321 | 5323 | sb->s_iflags |= SB_I_ALLOW_HSM; |
| 5322 | 5324 | |
| @@ -5414,6 +5416,8 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb) · 91 unmodified lines | ||
| 5414 | 5416 | err = ext4_load_and_init_journal(sb, es, ctx); |
| 5415 | 5417 | if (err) |
| 5416 | 5418 | goto failed_mount3a; |
| 5419 | + if (bdev_read_only(sb->s_bdev)) | |
| 5420 | + needs_recovery = 0; | |
| 5417 | 5421 | } else if (test_opt(sb, NOLOAD) && !sb_rdonly(sb) && |
| 5418 | 5422 | ext4_has_feature_journal_needs_recovery(sb)) { |
| 5419 | 5423 | ext4_msg(sb, KERN_ERR, "required journal recovery " |
| @@ -402,7 +402,7 @@ static long do_handle_open(int mountdirfd, struct file_handle __user *ufh, · 401 unmodified lines | ||
| 402 | 402 | if (retval) |
| 403 | 403 | return retval; |
| 404 | 404 | |
| 405 | − CLASS(get_unused_fd, fd)(O_CLOEXEC); | |
| 405 | + CLASS(get_unused_fd, fd)(open_flag); | |
| 406 | 406 | if (fd < 0) |
| 407 | 407 | return fd; |
| 408 | 408 | |
| @@ -2608,10 +2608,6 @@ void __mark_inode_dirty(struct inode *inode, int flags) · 2607 unmodified lines | ||
| 2608 | 2608 | wakeup_bdi = inode_io_list_move_locked(inode, wb, |
| 2609 | 2609 | dirty_list); |
| 2610 | 2610 | |
| 2611 | − spin_unlock(&wb->list_lock); | |
| 2612 | − spin_unlock(&inode->i_lock); | |
| 2613 | − trace_writeback_dirty_inode_enqueue(inode); | |
| 2614 | − | |
| 2615 | 2611 | /* |
| 2616 | 2612 | * If this is the first dirty inode for this bdi, |
| 2617 | 2613 | * we have to wake-up the corresponding bdi thread |
| @@ -2621,6 +2617,11 @@ void __mark_inode_dirty(struct inode *inode, int flags) · 3 unmodified lines | ||
| 2621 | 2617 | if (wakeup_bdi && |
| 2622 | 2618 | (wb->bdi->capabilities & BDI_CAP_WRITEBACK)) |
| 2623 | 2619 | wb_wakeup_delayed(wb); |
| 2620 | + | |
| 2621 | + spin_unlock(&wb->list_lock); | |
| 2622 | + spin_unlock(&inode->i_lock); | |
| 2623 | + trace_writeback_dirty_inode_enqueue(inode); | |
| 2624 | + | |
| 2624 | 2625 | return; |
| 2625 | 2626 | } |
| 2626 | 2627 | } |
| @@ -289,11 +289,6 @@ void fuse_change_attributes_common(struct inode *inode, struct fuse_attr *attr, · 288 unmodified lines | ||
| 289 | 289 | } |
| 290 | 290 | } |
| 291 | 291 | |
| 292 | − if (attr->blksize != 0) | |
| 293 | − inode->i_blkbits = ilog2(attr->blksize); | |
| 294 | − else | |
| 295 | − inode->i_blkbits = inode->i_sb->s_blocksize_bits; | |
| 296 | − | |
| 297 | 292 | /* |
| 298 | 293 | * Don't set the sticky bit in i_mode, unless we want the VFS |
| 299 | 294 | * to check permissions. This prevents failures due to the |
| @@ -363,14 +363,14 @@ static int iomap_dio_bio_iter(struct iomap_iter *iter, struct iomap_dio *dio) · 362 unmodified lines | ||
| 363 | 363 | if (iomap->flags & IOMAP_F_SHARED) |
| 364 | 364 | dio->flags |= IOMAP_DIO_COW; |
| 365 | 365 | |
| 366 | − if (iomap->flags & IOMAP_F_NEW) { | |
| 366 | + if (iomap->flags & IOMAP_F_NEW) | |
| 367 | 367 | need_zeroout = true; |
| 368 | − } else if (iomap->type == IOMAP_MAPPED) { | |
| 369 | − if (iomap_dio_can_use_fua(iomap, dio)) | |
| 370 | − bio_opf |= REQ_FUA; | |
| 371 | − else | |
| 372 | − dio->flags &= ~IOMAP_DIO_WRITE_THROUGH; | |
| 373 | − } | |
| 368 | + else if (iomap->type == IOMAP_MAPPED && | |
| 369 | + iomap_dio_can_use_fua(iomap, dio)) | |
| 370 | + bio_opf |= REQ_FUA; | |
| 371 | + | |
| 372 | + if (!(bio_opf & REQ_FUA)) | |
| 373 | + dio->flags &= ~IOMAP_DIO_WRITE_THROUGH; | |
| 374 | 374 | |
| 375 | 375 | /* |
| 376 | 376 | * We can only do deferred completion for pure overwrites that |
| @@ -285,6 +285,7 @@ restart: · 284 unmodified lines | ||
| 285 | 285 | retry: |
| 286 | 286 | if (batch_count) |
| 287 | 287 | __flush_batch(journal, &batch_count); |
| 288 | + cond_resched(); | |
| 288 | 289 | spin_lock(&journal->j_list_lock); |
| 289 | 290 | goto restart; |
| 290 | 291 | } |
| @@ -142,9 +142,9 @@ ssize_t kernfs_iop_listxattr(struct dentry *dentry, char *buf, size_t size) · 141 unmodified lines | ||
| 142 | 142 | struct kernfs_node *kn = kernfs_dentry_node(dentry); |
| 143 | 143 | struct kernfs_iattrs *attrs; |
| 144 | 144 | |
| 145 | − attrs = kernfs_iattrs_noalloc(kn); | |
| 145 | + attrs = kernfs_iattrs(kn); | |
| 146 | 146 | if (!attrs) |
| 147 | − return -ENODATA; | |
| 147 | + return -ENOMEM; | |
| 148 | 148 | |
| 149 | 149 | return simple_xattr_list(d_inode(dentry), &attrs->xattrs, buf, size); |
| 150 | 150 | } |
| @@ -1197,10 +1197,7 @@ static void commit_tree(struct mount *mnt) · 1196 unmodified lines | ||
| 1197 | 1197 | |
| 1198 | 1198 | if (!mnt_ns_attached(mnt)) { |
| 1199 | 1199 | for (struct mount *m = mnt; m; m = next_mnt(m, mnt)) |
| 1200 | − if (unlikely(mnt_ns_attached(m))) | |
| 1201 | − m = skip_mnt_tree(m); | |
| 1202 | − else | |
| 1203 | − mnt_add_to_ns(n, m); | |
| 1200 | + mnt_add_to_ns(n, m); | |
| 1204 | 1201 | n->nr_mounts += n->pending_mounts; |
| 1205 | 1202 | n->pending_mounts = 0; |
| 1206 | 1203 | } |
| @@ -2704,6 +2701,7 @@ static int attach_recursive_mnt(struct mount *source_mnt, · 1497 unmodified lines | ||
| 2704 | 2701 | lock_mnt_tree(child); |
| 2705 | 2702 | q = __lookup_mnt(&child->mnt_parent->mnt, |
| 2706 | 2703 | child->mnt_mountpoint); |
| 2704 | + commit_tree(child); | |
| 2707 | 2705 | if (q) { |
| 2708 | 2706 | struct mountpoint *mp = root.mp; |
| 2709 | 2707 | struct mount *r = child; |
| @@ -2713,7 +2711,6 @@ static int attach_recursive_mnt(struct mount *source_mnt, · 3 unmodified lines | ||
| 2713 | 2711 | mp = shorter; |
| 2714 | 2712 | mnt_change_mountpoint(r, mp, q); |
| 2715 | 2713 | } |
| 2716 | − commit_tree(child); | |
| 2717 | 2714 | } |
| 2718 | 2715 | unpin_mountpoint(&root); |
| 2719 | 2716 | unlock_mount_hash(); |
| @@ -2862,6 +2859,19 @@ static int graft_tree(struct mount *mnt, struct mount *p, struct mountpoint *mp) · 142 unmodified lines | ||
| 2862 | 2859 | return attach_recursive_mnt(mnt, p, mp); |
| 2863 | 2860 | } |
| 2864 | 2861 | |
| 2862 | +static int may_change_propagation(const struct mount *m) | |
| 2863 | +{ | |
| 2864 | + struct mnt_namespace *ns = m->mnt_ns; | |
| 2865 | + | |
| 2866 | + // it must be mounted in some namespace | |
| 2867 | + if (IS_ERR_OR_NULL(ns)) // is_mounted() | |
| 2868 | + return -EINVAL; | |
| 2869 | + // and the caller must be admin in userns of that namespace | |
| 2870 | + if (!ns_capable(ns->user_ns, CAP_SYS_ADMIN)) | |
| 2871 | + return -EPERM; | |
| 2872 | + return 0; | |
| 2873 | +} | |
| 2874 | + | |
| 2865 | 2875 | /* |
| 2866 | 2876 | * Sanity check the flags to change_mnt_propagation. |
| 2867 | 2877 | */ |
| @@ -2898,10 +2908,10 @@ static int do_change_type(struct path *path, int ms_flags) · 30 unmodified lines | ||
| 2898 | 2908 | return -EINVAL; |
| 2899 | 2909 | |
| 2900 | 2910 | namespace_lock(); |
| 2901 | − if (!check_mnt(mnt)) { | |
| 2902 | − err = -EINVAL; | |
| 2911 | + err = may_change_propagation(mnt); | |
| 2912 | + if (err) | |
| 2903 | 2913 | goto out_unlock; |
| 2904 | − } | |
| 2914 | + | |
| 2905 | 2915 | if (type == MS_SHARED) { |
| 2906 | 2916 | err = invent_group_ids(mnt, recurse); |
| 2907 | 2917 | if (err) |
| @@ -3347,18 +3357,11 @@ static int do_set_group(struct path *from_path, struct path *to_path) · 439 unmodified lines | ||
| 3347 | 3357 | |
| 3348 | 3358 | namespace_lock(); |
| 3349 | 3359 | |
| 3350 | − err = -EINVAL; | |
| 3351 | − /* To and From must be mounted */ | |
| 3352 | − if (!is_mounted(&from->mnt)) | |
| 3353 | − goto out; | |
| 3354 | − if (!is_mounted(&to->mnt)) | |
| 3355 | − goto out; | |
| 3356 | − | |
| 3357 | − err = -EPERM; | |
| 3358 | − /* We should be allowed to modify mount namespaces of both mounts */ | |
| 3359 | − if (!ns_capable(from->mnt_ns->user_ns, CAP_SYS_ADMIN)) | |
| 3360 | + err = may_change_propagation(from); | |
| 3361 | + if (err) | |
| 3360 | 3362 | goto out; |
| 3361 | − if (!ns_capable(to->mnt_ns->user_ns, CAP_SYS_ADMIN)) | |
| 3363 | + err = may_change_propagation(to); | |
| 3364 | + if (err) | |
| 3362 | 3365 | goto out; |
| 3363 | 3366 | |
| 3364 | 3367 | err = -EINVAL; |
| @@ -4551,20 +4554,10 @@ SYSCALL_DEFINE5(move_mount, · 1186 unmodified lines | ||
| 4551 | 4554 | if (flags & MOVE_MOUNT_SET_GROUP) mflags |= MNT_TREE_PROPAGATION; |
| 4552 | 4555 | if (flags & MOVE_MOUNT_BENEATH) mflags |= MNT_TREE_BENEATH; |
| 4553 | 4556 | |
| 4554 | − lflags = 0; | |
| 4555 | − if (flags & MOVE_MOUNT_F_SYMLINKS) lflags |= LOOKUP_FOLLOW; | |
| 4556 | − if (flags & MOVE_MOUNT_F_AUTOMOUNTS) lflags |= LOOKUP_AUTOMOUNT; | |
| 4557 | 4557 | uflags = 0; |
| 4558 | − if (flags & MOVE_MOUNT_F_EMPTY_PATH) uflags = AT_EMPTY_PATH; | |
| 4559 | − from_name = getname_maybe_null(from_pathname, uflags); | |
| 4560 | − if (IS_ERR(from_name)) | |
| 4561 | − return PTR_ERR(from_name); | |
| 4558 | + if (flags & MOVE_MOUNT_T_EMPTY_PATH) | |
| 4559 | + uflags = AT_EMPTY_PATH; | |
| 4562 | 4560 | |
| 4563 | − lflags = 0; | |
| 4564 | − if (flags & MOVE_MOUNT_T_SYMLINKS) lflags |= LOOKUP_FOLLOW; | |
| 4565 | − if (flags & MOVE_MOUNT_T_AUTOMOUNTS) lflags |= LOOKUP_AUTOMOUNT; | |
| 4566 | − uflags = 0; | |
| 4567 | − if (flags & MOVE_MOUNT_T_EMPTY_PATH) uflags = AT_EMPTY_PATH; | |
| 4568 | 4561 | to_name = getname_maybe_null(to_pathname, uflags); |
| 4569 | 4562 | if (IS_ERR(to_name)) |
| 4570 | 4563 | return PTR_ERR(to_name); |
| @@ -4577,11 +4570,24 @@ SYSCALL_DEFINE5(move_mount, · 6 unmodified lines | ||
| 4577 | 4570 | to_path = fd_file(f_to)->f_path; |
| 4578 | 4571 | path_get(&to_path); |
| 4579 | 4572 | } else { |
| 4573 | + lflags = 0; | |
| 4574 | + if (flags & MOVE_MOUNT_T_SYMLINKS) | |
| 4575 | + lflags |= LOOKUP_FOLLOW; | |
| 4576 | + if (flags & MOVE_MOUNT_T_AUTOMOUNTS) | |
| 4577 | + lflags |= LOOKUP_AUTOMOUNT; | |
| 4580 | 4578 | ret = filename_lookup(to_dfd, to_name, lflags, &to_path, NULL); |
| 4581 | 4579 | if (ret) |
| 4582 | 4580 | return ret; |
| 4583 | 4581 | } |
| 4584 | 4582 | |
| 4583 | + uflags = 0; | |
| 4584 | + if (flags & MOVE_MOUNT_F_EMPTY_PATH) | |
| 4585 | + uflags = AT_EMPTY_PATH; | |
| 4586 | + | |
| 4587 | + from_name = getname_maybe_null(from_pathname, uflags); | |
| 4588 | + if (IS_ERR(from_name)) | |
| 4589 | + return PTR_ERR(from_name); | |
| 4590 | + | |
| 4585 | 4591 | if (!from_name && from_dfd >= 0) { |
| 4586 | 4592 | CLASS(fd_raw, f_from)(from_dfd); |
| 4587 | 4593 | if (fd_empty(f_from)) |
| @@ -4590,6 +4596,11 @@ SYSCALL_DEFINE5(move_mount, · 2 unmodified lines | ||
| 4590 | 4596 | return vfs_move_mount(&fd_file(f_from)->f_path, &to_path, mflags); |
| 4591 | 4597 | } |
| 4592 | 4598 | |
| 4599 | + lflags = 0; | |
| 4600 | + if (flags & MOVE_MOUNT_F_SYMLINKS) | |
| 4601 | + lflags |= LOOKUP_FOLLOW; | |
| 4602 | + if (flags & MOVE_MOUNT_F_AUTOMOUNTS) | |
| 4603 | + lflags |= LOOKUP_AUTOMOUNT; | |
| 4593 | 4604 | ret = filename_lookup(from_dfd, from_name, lflags, &from_path, NULL); |
| 4594 | 4605 | if (ret) |
| 4595 | 4606 | return ret; |
| @@ -5176,7 +5187,8 @@ SYSCALL_DEFINE5(open_tree_attr, int, dfd, const char __user *, filename, · 580 unmodified lines | ||
| 5176 | 5187 | int ret; |
| 5177 | 5188 | struct mount_kattr kattr = {}; |
| 5178 | 5189 | |
| 5179 | − kattr.kflags = MOUNT_KATTR_IDMAP_REPLACE; | |
| 5190 | + if (flags & OPEN_TREE_CLONE) | |
| 5191 | + kattr.kflags = MOUNT_KATTR_IDMAP_REPLACE; | |
| 5180 | 5192 | if (flags & AT_RECURSIVE) |
| 5181 | 5193 | kattr.kflags |= MOUNT_KATTR_RECURSE; |
| 5182 | 5194 | |
| @@ -281,8 +281,10 @@ reassess: · 280 unmodified lines | ||
| 281 | 281 | } else if (test_bit(NETFS_RREQ_SHORT_TRANSFER, &rreq->flags)) { |
| 282 | 282 | notes |= MADE_PROGRESS; |
| 283 | 283 | } else { |
| 284 | − if (!stream->failed) | |
| 284 | + if (!stream->failed) { | |
| 285 | 285 | stream->transferred += transferred; |
| 286 | + stream->transferred_valid = true; | |
| 287 | + } | |
| 286 | 288 | if (front->transferred < front->len) |
| 287 | 289 | set_bit(NETFS_RREQ_SHORT_TRANSFER, &rreq->flags); |
| 288 | 290 | notes |= MADE_PROGRESS; |
| @@ -254,6 +254,7 @@ reassess_streams: · 253 unmodified lines | ||
| 254 | 254 | if (front->start + front->transferred > stream->collected_to) { |
| 255 | 255 | stream->collected_to = front->start + front->transferred; |
| 256 | 256 | stream->transferred = stream->collected_to - wreq->start; |
| 257 | + stream->transferred_valid = true; | |
| 257 | 258 | notes |= MADE_PROGRESS; |
| 258 | 259 | } |
| 259 | 260 | if (test_bit(NETFS_SREQ_FAILED, &front->flags)) { |
| @@ -356,6 +357,7 @@ bool netfs_write_collection(struct netfs_io_request *wreq) · 96 unmodified lines | ||
| 356 | 357 | { |
| 357 | 358 | struct netfs_inode *ictx = netfs_inode(wreq->inode); |
| 358 | 359 | size_t transferred; |
| 360 | + bool transferred_valid = false; | |
| 359 | 361 | int s; |
| 360 | 362 | |
| 361 | 363 | _enter("R=%x", wreq->debug_id); |
| @@ -376,12 +378,16 @@ bool netfs_write_collection(struct netfs_io_request *wreq) · 14 unmodified lines | ||
| 376 | 378 | continue; |
| 377 | 379 | if (!list_empty(&stream->subrequests)) |
| 378 | 380 | return false; |
| 379 | − if (stream->transferred < transferred) | |
| 381 | + if (stream->transferred_valid && | |
| 382 | + stream->transferred < transferred) { | |
| 380 | 383 | transferred = stream->transferred; |
| 384 | + transferred_valid = true; | |
| 385 | + } | |
| 381 | 386 | } |
| 382 | 387 | |
| 383 | 388 | /* Okay, declare that all I/O is complete. */ |
| 384 | − wreq->transferred = transferred; | |
| 389 | + if (transferred_valid) | |
| 390 | + wreq->transferred = transferred; | |
| 385 | 391 | trace_netfs_rreq(wreq, netfs_rreq_trace_write_done); |
| 386 | 392 | |
| 387 | 393 | if (wreq->io_streams[1].active && |
| @@ -118,12 +118,12 @@ struct netfs_io_request *netfs_create_write_req(struct address_space *mapping, · 117 unmodified lines | ||
| 118 | 118 | wreq->io_streams[0].prepare_write = ictx->ops->prepare_write; |
| 119 | 119 | wreq->io_streams[0].issue_write = ictx->ops->issue_write; |
| 120 | 120 | wreq->io_streams[0].collected_to = start; |
| 121 | − wreq->io_streams[0].transferred = LONG_MAX; | |
| 121 | + wreq->io_streams[0].transferred = 0; | |
| 122 | 122 | |
| 123 | 123 | wreq->io_streams[1].stream_nr = 1; |
| 124 | 124 | wreq->io_streams[1].source = NETFS_WRITE_TO_CACHE; |
| 125 | 125 | wreq->io_streams[1].collected_to = start; |
| 126 | − wreq->io_streams[1].transferred = LONG_MAX; | |
| 126 | + wreq->io_streams[1].transferred = 0; | |
| 127 | 127 | if (fscache_resources_valid(&wreq->cache_resources)) { |
| 128 | 128 | wreq->io_streams[1].avail = true; |
| 129 | 129 | wreq->io_streams[1].active = true; |
| @@ -253,13 +253,14 @@ nfs_page_group_unlock(struct nfs_page *req) · 252 unmodified lines | ||
| 253 | 253 | nfs_page_clear_headlock(req); |
| 254 | 254 | } |
| 255 | 255 | |
| 256 | −/* | |
| 257 | − * nfs_page_group_sync_on_bit_locked | |
| 256 | +/** | |
| 257 | + * nfs_page_group_sync_on_bit_locked - Test if all requests have @bit set | |
| 258 | + * @req: request in page group | |
| 259 | + * @bit: PG_* bit that is used to sync page group | |
| 258 | 260 | * |
| 259 | 261 | * must be called with page group lock held |
| 260 | 262 | */ |
| 261 | −static bool | |
| 262 | −nfs_page_group_sync_on_bit_locked(struct nfs_page *req, unsigned int bit) | |
| 263 | +bool nfs_page_group_sync_on_bit_locked(struct nfs_page *req, unsigned int bit) | |
| 263 | 264 | { |
| 264 | 265 | struct nfs_page *head = req->wb_head; |
| 265 | 266 | struct nfs_page *tmp; |
| @@ -153,20 +153,10 @@ nfs_page_set_inode_ref(struct nfs_page *req, struct inode *inode) · 152 unmodified lines | ||
| 153 | 153 | } |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | −static int | |
| 157 | −nfs_cancel_remove_inode(struct nfs_page *req, struct inode *inode) | |
| 156 | +static void nfs_cancel_remove_inode(struct nfs_page *req, struct inode *inode) | |
| 158 | 157 | { |
| 159 | − int ret; | |
| 160 | − | |
| 161 | − if (!test_bit(PG_REMOVE, &req->wb_flags)) | |
| 162 | − return 0; | |
| 163 | − ret = nfs_page_group_lock(req); | |
| 164 | − if (ret) | |
| 165 | − return ret; | |
| 166 | 158 | if (test_and_clear_bit(PG_REMOVE, &req->wb_flags)) |
| 167 | 159 | nfs_page_set_inode_ref(req, inode); |
| 168 | − nfs_page_group_unlock(req); | |
| 169 | − return 0; | |
| 170 | 160 | } |
| 171 | 161 | |
| 172 | 162 | /** |
| @@ -585,19 +575,18 @@ retry: · 412 unmodified lines | ||
| 585 | 575 | } |
| 586 | 576 | } |
| 587 | 577 | |
| 578 | + ret = nfs_page_group_lock(head); | |
| 579 | + if (ret < 0) | |
| 580 | + goto out_unlock; | |
| 581 | + | |
| 588 | 582 | /* Ensure that nobody removed the request before we locked it */ |
| 589 | 583 | if (head != folio->private) { |
| 584 | + nfs_page_group_unlock(head); | |
| 590 | 585 | nfs_unlock_and_release_request(head); |
| 591 | 586 | goto retry; |
| 592 | 587 | } |
| 593 | 588 | |
| 594 | − ret = nfs_cancel_remove_inode(head, inode); | |
| 595 | − if (ret < 0) | |
| 596 | − goto out_unlock; | |
| 597 | − | |
| 598 | − ret = nfs_page_group_lock(head); | |
| 599 | − if (ret < 0) | |
| 600 | − goto out_unlock; | |
| 589 | + nfs_cancel_remove_inode(head, inode); | |
| 601 | 590 | |
| 602 | 591 | /* lock each request in the page group */ |
| 603 | 592 | for (subreq = head->wb_this_page; |
| @@ -786,7 +775,8 @@ static void nfs_inode_remove_request(struct nfs_page *req) · 182 unmodified lines | ||
| 786 | 775 | { |
| 787 | 776 | struct nfs_inode *nfsi = NFS_I(nfs_page_to_inode(req)); |
| 788 | 777 | |
| 789 | − if (nfs_page_group_sync_on_bit(req, PG_REMOVE)) { | |
| 778 | + nfs_page_group_lock(req); | |
| 779 | + if (nfs_page_group_sync_on_bit_locked(req, PG_REMOVE)) { | |
| 790 | 780 | struct folio *folio = nfs_page_to_folio(req->wb_head); |
| 791 | 781 | struct address_space *mapping = folio->mapping; |
| 792 | 782 | |
| @@ -798,6 +788,7 @@ static void nfs_inode_remove_request(struct nfs_page *req) · 5 unmodified lines | ||
| 798 | 788 | } |
| 799 | 789 | spin_unlock(&mapping->i_private_lock); |
| 800 | 790 | } |
| 791 | + nfs_page_group_unlock(req); | |
| 801 | 792 | |
| 802 | 793 | if (test_and_clear_bit(PG_INODE_REF, &req->wb_flags)) { |
| 803 | 794 | atomic_long_dec(&nfsi->nrequests); |
| @@ -225,7 +225,7 @@ struct dentry *ovl_create_temp(struct ovl_fs *ofs, struct dentry *workdir, · 224 unmodified lines | ||
| 225 | 225 | struct ovl_cattr *attr) |
| 226 | 226 | { |
| 227 | 227 | struct dentry *ret; |
| 228 | − inode_lock(workdir->d_inode); | |
| 228 | + inode_lock_nested(workdir->d_inode, I_MUTEX_PARENT); | |
| 229 | 229 | ret = ovl_create_real(ofs, workdir, |
| 230 | 230 | ovl_lookup_temp(ofs, workdir), attr); |
| 231 | 231 | inode_unlock(workdir->d_inode); |
| @@ -1552,7 +1552,8 @@ void ovl_copyattr(struct inode *inode) · 1551 unmodified lines | ||
| 1552 | 1552 | int ovl_parent_lock(struct dentry *parent, struct dentry *child) |
| 1553 | 1553 | { |
| 1554 | 1554 | inode_lock_nested(parent->d_inode, I_MUTEX_PARENT); |
| 1555 | − if (!child || child->d_parent == parent) | |
| 1555 | + if (!child || | |
| 1556 | + (!d_unhashed(child) && child->d_parent == parent)) | |
| 1556 | 1557 | return 0; |
| 1557 | 1558 | |
| 1558 | 1559 | inode_unlock(parent->d_inode); |
| @@ -296,12 +296,12 @@ static __u32 pidfs_coredump_mask(unsigned long mm_flags) · 295 unmodified lines | ||
| 296 | 296 | static long pidfd_info(struct file *file, unsigned int cmd, unsigned long arg) |
| 297 | 297 | { |
| 298 | 298 | struct pidfd_info __user *uinfo = (struct pidfd_info __user *)arg; |
| 299 | + struct task_struct *task __free(put_task) = NULL; | |
| 299 | 300 | struct pid *pid = pidfd_pid(file); |
| 300 | 301 | size_t usize = _IOC_SIZE(cmd); |
| 301 | 302 | struct pidfd_info kinfo = {}; |
| 302 | 303 | struct pidfs_exit_info *exit_info; |
| 303 | 304 | struct user_namespace *user_ns; |
| 304 | − struct task_struct *task; | |
| 305 | 305 | struct pidfs_attr *attr; |
| 306 | 306 | const struct cred *c; |
| 307 | 307 | __u64 mask; |
| @@ -111,7 +111,8 @@ void change_mnt_propagation(struct mount *mnt, int type) · 110 unmodified lines | ||
| 111 | 111 | return; |
| 112 | 112 | } |
| 113 | 113 | if (IS_MNT_SHARED(mnt)) { |
| 114 | − m = propagation_source(mnt); | |
| 114 | + if (type == MS_SLAVE || !hlist_empty(&mnt->mnt_slave_list)) | |
| 115 | + m = propagation_source(mnt); | |
| 115 | 116 | if (list_empty(&mnt->mnt_share)) { |
| 116 | 117 | mnt_release_group_id(mnt); |
| 117 | 118 | } else { |
| @@ -637,10 +638,11 @@ void propagate_umount(struct list_head *set) · 519 unmodified lines | ||
| 637 | 638 | } |
| 638 | 639 | |
| 639 | 640 | // now to_umount consists of all acceptable candidates |
| 640 | − // deal with reparenting of remaining overmounts on those | |
| 641 | + // deal with reparenting of surviving overmounts on those | |
| 641 | 642 | list_for_each_entry(m, &to_umount, mnt_list) { |
| 642 | − if (m->overmount) | |
| 643 | − reparent(m->overmount); | |
| 643 | + struct mount *over = m->overmount; | |
| 644 | + if (over && !will_be_unmounted(over)) | |
| 645 | + reparent(over); | |
| 644 | 646 | } |
| 645 | 647 | |
| 646 | 648 | // and fold them into the set |
| @@ -4496,7 +4496,7 @@ smb3_init_transform_rq(struct TCP_Server_Info *server, int num_rqst, · 4495 unmodified lines | ||
| 4496 | 4496 | for (int i = 1; i < num_rqst; i++) { |
| 4497 | 4497 | struct smb_rqst *old = &old_rq[i - 1]; |
| 4498 | 4498 | struct smb_rqst *new = &new_rq[i]; |
| 4499 | − struct folio_queue *buffer; | |
| 4499 | + struct folio_queue *buffer = NULL; | |
| 4500 | 4500 | size_t size = iov_iter_count(&old->rq_iter); |
| 4501 | 4501 | |
| 4502 | 4502 | orig_len += smb_rqst_len(server, old); |
| @@ -504,7 +504,8 @@ void ksmbd_conn_transport_destroy(void) · 503 unmodified lines | ||
| 504 | 504 | { |
| 505 | 505 | mutex_lock(&init_lock); |
| 506 | 506 | ksmbd_tcp_destroy(); |
| 507 | − ksmbd_rdma_destroy(); | |
| 507 | + ksmbd_rdma_stop_listening(); | |
| 508 | 508 | stop_sessions(); |
| 509 | + ksmbd_rdma_destroy(); | |
| 509 | 510 | mutex_unlock(&init_lock); |
| 510 | 511 | } |
| @@ -46,7 +46,12 @@ struct ksmbd_conn { · 45 unmodified lines | ||
| 46 | 46 | struct mutex srv_mutex; |
| 47 | 47 | int status; |
| 48 | 48 | unsigned int cli_cap; |
| 49 | − __be32 inet_addr; | |
| 49 | + union { | |
| 50 | + __be32 inet_addr; | |
| 51 | +#if IS_ENABLED(CONFIG_IPV6) | |
| 52 | + u8 inet6_addr[16]; | |
| 53 | +#endif | |
| 54 | + }; | |
| 50 | 55 | char *request_buf; |
| 51 | 56 | struct ksmbd_transport *transport; |
| 52 | 57 | struct nls_table *local_nls; |
| @@ -1102,8 +1102,10 @@ void smb_send_parent_lease_break_noti(struct ksmbd_file *fp, · 1101 unmodified lines | ||
| 1102 | 1102 | if (!atomic_inc_not_zero(&opinfo->refcount)) |
| 1103 | 1103 | continue; |
| 1104 | 1104 | |
| 1105 | − if (ksmbd_conn_releasing(opinfo->conn)) | |
| 1105 | + if (ksmbd_conn_releasing(opinfo->conn)) { | |
| 1106 | + opinfo_put(opinfo); | |
| 1106 | 1107 | continue; |
| 1108 | + } | |
| 1107 | 1109 | |
| 1108 | 1110 | oplock_break(opinfo, SMB2_OPLOCK_LEVEL_NONE, NULL); |
| 1109 | 1111 | opinfo_put(opinfo); |
| @@ -1139,8 +1141,11 @@ void smb_lazy_parent_lease_break_close(struct ksmbd_file *fp) · 29 unmodified lines | ||
| 1139 | 1141 | if (!atomic_inc_not_zero(&opinfo->refcount)) |
| 1140 | 1142 | continue; |
| 1141 | 1143 | |
| 1142 | − if (ksmbd_conn_releasing(opinfo->conn)) | |
| 1144 | + if (ksmbd_conn_releasing(opinfo->conn)) { | |
| 1145 | + opinfo_put(opinfo); | |
| 1143 | 1146 | continue; |
| 1147 | + } | |
| 1148 | + | |
| 1144 | 1149 | oplock_break(opinfo, SMB2_OPLOCK_LEVEL_NONE, NULL); |
| 1145 | 1150 | opinfo_put(opinfo); |
| 1146 | 1151 | } |
| @@ -1343,8 +1348,10 @@ void smb_break_all_levII_oplock(struct ksmbd_work *work, struct ksmbd_file *fp, · 196 unmodified lines | ||
| 1343 | 1348 | if (!atomic_inc_not_zero(&brk_op->refcount)) |
| 1344 | 1349 | continue; |
| 1345 | 1350 | |
| 1346 | − if (ksmbd_conn_releasing(brk_op->conn)) | |
| 1351 | + if (ksmbd_conn_releasing(brk_op->conn)) { | |
| 1352 | + opinfo_put(brk_op); | |
| 1347 | 1353 | continue; |
| 1354 | + } | |
| 1348 | 1355 | |
| 1349 | 1356 | if (brk_op->is_lease && (brk_op->o_lease->state & |
| 1350 | 1357 | (~(SMB2_LEASE_READ_CACHING_LE | |
| @@ -2194,7 +2194,7 @@ int ksmbd_rdma_init(void) · 2193 unmodified lines | ||
| 2194 | 2194 | return 0; |
| 2195 | 2195 | } |
| 2196 | 2196 | |
| 2197 | −void ksmbd_rdma_destroy(void) | |
| 2197 | +void ksmbd_rdma_stop_listening(void) | |
| 2198 | 2198 | { |
| 2199 | 2199 | if (!smb_direct_listener.cm_id) |
| 2200 | 2200 | return; |
| @@ -2203,7 +2203,10 @@ void ksmbd_rdma_destroy(void) · 2 unmodified lines | ||
| 2203 | 2203 | rdma_destroy_id(smb_direct_listener.cm_id); |
| 2204 | 2204 | |
| 2205 | 2205 | smb_direct_listener.cm_id = NULL; |
| 2206 | +} | |
| 2206 | 2207 | |
| 2208 | +void ksmbd_rdma_destroy(void) | |
| 2209 | +{ | |
| 2207 | 2210 | if (smb_direct_wq) { |
| 2208 | 2211 | destroy_workqueue(smb_direct_wq); |
| 2209 | 2212 | smb_direct_wq = NULL; |
| @@ -54,13 +54,15 @@ struct smb_direct_data_transfer { · 53 unmodified lines | ||
| 54 | 54 | |
| 55 | 55 | #ifdef CONFIG_SMB_SERVER_SMBDIRECT |
| 56 | 56 | int ksmbd_rdma_init(void); |
| 57 | +void ksmbd_rdma_stop_listening(void); | |
| 57 | 58 | void ksmbd_rdma_destroy(void); |
| 58 | 59 | bool ksmbd_rdma_capable_netdev(struct net_device *netdev); |
| 59 | 60 | void init_smbd_max_io_size(unsigned int sz); |
| 60 | 61 | unsigned int get_smbd_max_read_write_size(void); |
| 61 | 62 | #else |
| 62 | 63 | static inline int ksmbd_rdma_init(void) { return 0; } |
| 63 | −static inline int ksmbd_rdma_destroy(void) { return 0; } | |
| 64 | +static inline void ksmbd_rdma_stop_listening(void) { } | |
| 65 | +static inline void ksmbd_rdma_destroy(void) { } | |
| 64 | 66 | static inline bool ksmbd_rdma_capable_netdev(struct net_device *netdev) { return false; } |
| 65 | 67 | static inline void init_smbd_max_io_size(unsigned int sz) { } |
| 66 | 68 | static inline unsigned int get_smbd_max_read_write_size(void) { return 0; } |
| @@ -85,7 +85,14 @@ static struct tcp_transport *alloc_transport(struct socket *client_sk) · 84 unmodified lines | ||
| 85 | 85 | return NULL; |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | +#if IS_ENABLED(CONFIG_IPV6) | |
| 89 | + if (client_sk->sk->sk_family == AF_INET6) | |
| 90 | + memcpy(&conn->inet6_addr, &client_sk->sk->sk_v6_daddr, 16); | |
| 91 | + else | |
| 92 | + conn->inet_addr = inet_sk(client_sk->sk)->inet_daddr; | |
| 93 | +#else | |
| 88 | 94 | conn->inet_addr = inet_sk(client_sk->sk)->inet_daddr; |
| 95 | +#endif | |
| 89 | 96 | conn->transport = KSMBD_TRANS(t); |
| 90 | 97 | KSMBD_TRANS(t)->conn = conn; |
| 91 | 98 | KSMBD_TRANS(t)->ops = &ksmbd_tcp_transport_ops; |
| @@ -229,7 +236,6 @@ static int ksmbd_kthread_fn(void *p) · 137 unmodified lines | ||
| 229 | 236 | { |
| 230 | 237 | struct socket *client_sk = NULL; |
| 231 | 238 | struct interface *iface = (struct interface *)p; |
| 232 | − struct inet_sock *csk_inet; | |
| 233 | 239 | struct ksmbd_conn *conn; |
| 234 | 240 | int ret; |
| 235 | 241 | |
| @@ -252,13 +258,27 @@ static int ksmbd_kthread_fn(void *p) · 16 unmodified lines | ||
| 252 | 258 | /* |
| 253 | 259 | * Limits repeated connections from clients with the same IP. |
| 254 | 260 | */ |
| 255 | − csk_inet = inet_sk(client_sk->sk); | |
| 256 | 261 | down_read(&conn_list_lock); |
| 257 | 262 | list_for_each_entry(conn, &conn_list, conns_list) |
| 258 | − if (csk_inet->inet_daddr == conn->inet_addr) { | |
| 263 | +#if IS_ENABLED(CONFIG_IPV6) | |
| 264 | + if (client_sk->sk->sk_family == AF_INET6) { | |
| 265 | + if (memcmp(&client_sk->sk->sk_v6_daddr, | |
| 266 | + &conn->inet6_addr, 16) == 0) { | |
| 267 | + ret = -EAGAIN; | |
| 268 | + break; | |
| 269 | + } | |
| 270 | + } else if (inet_sk(client_sk->sk)->inet_daddr == | |
| 271 | + conn->inet_addr) { | |
| 272 | + ret = -EAGAIN; | |
| 273 | + break; | |
| 274 | + } | |
| 275 | +#else | |
| 276 | + if (inet_sk(client_sk->sk)->inet_daddr == | |
| 277 | + conn->inet_addr) { | |
| 259 | 278 | ret = -EAGAIN; |
| 260 | 279 | break; |
| 261 | 280 | } |
| 281 | +#endif | |
| 262 | 282 | up_read(&conn_list_lock); |
| 263 | 283 | if (ret == -EAGAIN) |
| 264 | 284 | continue; |
| @@ -739,6 +739,9 @@ iter_file_splice_write(struct pipe_inode_info *pipe, struct file *out, · 738 unmodified lines | ||
| 739 | 739 | sd.pos = kiocb.ki_pos; |
| 740 | 740 | if (ret <= 0) |
| 741 | 741 | break; |
| 742 | + WARN_ONCE(ret > sd.total_len - left, | |
| 743 | + "Splice Exceeded! ret=%zd tot=%zu left=%zu\n", | |
| 744 | + ret, sd.total_len, left); | |
| 742 | 745 | |
| 743 | 746 | sd.num_spliced += ret; |
| 744 | 747 | sd.total_len -= ret; |
| @@ -187,10 +187,15 @@ static int squashfs_fill_super(struct super_block *sb, struct fs_context *fc) · 186 unmodified lines | ||
| 187 | 187 | unsigned short flags; |
| 188 | 188 | unsigned int fragments; |
| 189 | 189 | u64 lookup_table_start, xattr_id_table_start, next_table; |
| 190 | − int err; | |
| 190 | + int err, devblksize = sb_min_blocksize(sb, SQUASHFS_DEVBLK_SIZE); | |
| 191 | 191 | |
| 192 | 192 | TRACE("Entered squashfs_fill_superblock\n"); |
| 193 | 193 | |
| 194 | + if (!devblksize) { | |
| 195 | + errorf(fc, "squashfs: unable to set blocksize\n"); | |
| 196 | + return -EINVAL; | |
| 197 | + } | |
| 198 | + | |
| 194 | 199 | sb->s_fs_info = kzalloc(sizeof(*msblk), GFP_KERNEL); |
| 195 | 200 | if (sb->s_fs_info == NULL) { |
| 196 | 201 | ERROR("Failed to allocate squashfs_sb_info\n"); |
| @@ -201,12 +206,7 @@ static int squashfs_fill_super(struct super_block *sb, struct fs_context *fc) · 4 unmodified lines | ||
| 201 | 206 | |
| 202 | 207 | msblk->panic_on_errors = (opts->errors == Opt_errors_panic); |
| 203 | 208 | |
| 204 | − msblk->devblksize = sb_min_blocksize(sb, SQUASHFS_DEVBLK_SIZE); | |
| 205 | − if (!msblk->devblksize) { | |
| 206 | − errorf(fc, "squashfs: unable to set blocksize\n"); | |
| 207 | − return -EINVAL; | |
| 208 | − } | |
| 209 | − | |
| 209 | + msblk->devblksize = devblksize; | |
| 210 | 210 | msblk->devblksize_log2 = ffz(~msblk->devblksize); |
| 211 | 211 | |
| 212 | 212 | mutex_init(&msblk->meta_index_mutex); |
| @@ -656,6 +656,7 @@ enum { · 655 unmodified lines | ||
| 656 | 656 | QUEUE_FLAG_SQ_SCHED, /* single queue style io dispatch */ |
| 657 | 657 | QUEUE_FLAG_DISABLE_WBT_DEF, /* for sched to disable/enable wbt */ |
| 658 | 658 | QUEUE_FLAG_NO_ELV_SWITCH, /* can't switch elevator any more */ |
| 659 | + QUEUE_FLAG_QOS_ENABLED, /* qos is enabled */ | |
| 659 | 660 | QUEUE_FLAG_MAX |
| 660 | 661 | }; |
| 661 | 662 | |
| @@ -288,14 +288,6 @@ static inline void *offset_to_ptr(const int *off) · 287 unmodified lines | ||
| 288 | 288 | #define __ADDRESSABLE(sym) \ |
| 289 | 289 | ___ADDRESSABLE(sym, __section(".discard.addressable")) |
| 290 | 290 | |
| 291 | −#define __ADDRESSABLE_ASM(sym) \ | |
| 292 | − .pushsection .discard.addressable,"aw"; \ | |
| 293 | − .align ARCH_SEL(8,4); \ | |
| 294 | − ARCH_SEL(.quad, .long) __stringify(sym); \ | |
| 295 | − .popsection; | |
| 296 | − | |
| 297 | −#define __ADDRESSABLE_ASM_STR(sym) __stringify(__ADDRESSABLE_ASM(sym)) | |
| 298 | − | |
| 299 | 291 | /* |
| 300 | 292 | * This returns a constant expression while determining if an argument is |
| 301 | 293 | * a constant expression, most importantly without evaluating the argument. |
| @@ -168,6 +168,7 @@ enum cpuhp_state { · 167 unmodified lines | ||
| 168 | 168 | CPUHP_AP_QCOM_TIMER_STARTING, |
| 169 | 169 | CPUHP_AP_TEGRA_TIMER_STARTING, |
| 170 | 170 | CPUHP_AP_ARMADA_TIMER_STARTING, |
| 171 | + CPUHP_AP_LOONGARCH_ARCH_TIMER_STARTING, | |
| 171 | 172 | CPUHP_AP_MIPS_GIC_TIMER_STARTING, |
| 172 | 173 | CPUHP_AP_ARC_TIMER_STARTING, |
| 173 | 174 | CPUHP_AP_REALTEK_TIMER_STARTING, |
| @@ -91,6 +91,6 @@ · 90 unmodified lines | ||
| 91 | 91 | #define EXPORT_SYMBOL_NS(sym, ns) __EXPORT_SYMBOL(sym, "", ns) |
| 92 | 92 | #define EXPORT_SYMBOL_NS_GPL(sym, ns) __EXPORT_SYMBOL(sym, "GPL", ns) |
| 93 | 93 | |
| 94 | −#define EXPORT_SYMBOL_GPL_FOR_MODULES(sym, mods) __EXPORT_SYMBOL(sym, "GPL", "module:" mods) | |
| 94 | +#define EXPORT_SYMBOL_FOR_MODULES(sym, mods) __EXPORT_SYMBOL(sym, "GPL", "module:" mods) | |
| 95 | 95 | |
| 96 | 96 | #endif /* _LINUX_EXPORT_H */ |
| @@ -264,12 +264,7 @@ static inline bool iosys_map_is_set(const struct iosys_map *map) · 263 unmodified lines | ||
| 264 | 264 | */ |
| 265 | 265 | static inline void iosys_map_clear(struct iosys_map *map) |
| 266 | 266 | { |
| 267 | − if (map->is_iomem) { | |
| 268 | − map->vaddr_iomem = NULL; | |
| 269 | − map->is_iomem = false; | |
| 270 | − } else { | |
| 271 | − map->vaddr = NULL; | |
| 272 | − } | |
| 267 | + memset(map, 0, sizeof(*map)); | |
| 273 | 268 | } |
| 274 | 269 | |
| 275 | 270 | /** |
| @@ -160,7 +160,7 @@ size_t iterate_folioq(struct iov_iter *iter, size_t len, void *priv, void *priv2 · 159 unmodified lines | ||
| 160 | 160 | |
| 161 | 161 | do { |
| 162 | 162 | struct folio *folio = folioq_folio(folioq, slot); |
| 163 | − size_t part, remain, consumed; | |
| 163 | + size_t part, remain = 0, consumed; | |
| 164 | 164 | size_t fsize; |
| 165 | 165 | void *base; |
| 166 | 166 | |
| @@ -168,14 +168,16 @@ size_t iterate_folioq(struct iov_iter *iter, size_t len, void *priv, void *priv2 · 1 unmodified line | ||
| 168 | 168 | break; |
| 169 | 169 | |
| 170 | 170 | fsize = folioq_folio_size(folioq, slot); |
| 171 | − base = kmap_local_folio(folio, skip); | |
| 172 | − part = umin(len, PAGE_SIZE - skip % PAGE_SIZE); | |
| 173 | − remain = step(base, progress, part, priv, priv2); | |
| 174 | − kunmap_local(base); | |
| 175 | − consumed = part - remain; | |
| 176 | − len -= consumed; | |
| 177 | − progress += consumed; | |
| 178 | − skip += consumed; | |
| 171 | + if (skip < fsize) { | |
| 172 | + base = kmap_local_folio(folio, skip); | |
| 173 | + part = umin(len, PAGE_SIZE - skip % PAGE_SIZE); | |
| 174 | + remain = step(base, progress, part, priv, priv2); | |
| 175 | + kunmap_local(base); | |
| 176 | + consumed = part - remain; | |
| 177 | + len -= consumed; | |
| 178 | + progress += consumed; | |
| 179 | + skip += consumed; | |
| 180 | + } | |
| 179 | 181 | if (skip >= fsize) { |
| 180 | 182 | skip = 0; |
| 181 | 183 | slot++; |
| @@ -57,47 +57,21 @@ static inline void kcov_remote_start_usb(u64 id) · 56 unmodified lines | ||
| 57 | 57 | |
| 58 | 58 | /* |
| 59 | 59 | * The softirq flavor of kcov_remote_*() functions is introduced as a temporary |
| 60 | − * workaround for KCOV's lack of nested remote coverage sections support. | |
| 61 | − * | |
| 62 | − * Adding support is tracked in https://bugzilla.kernel.org/show_bug.cgi?id=210337. | |
| 63 | − * | |
| 64 | − * kcov_remote_start_usb_softirq(): | |
| 65 | − * | |
| 66 | − * 1. Only collects coverage when called in the softirq context. This allows | |
| 67 | − * avoiding nested remote coverage collection sections in the task context. | |
| 68 | − * For example, USB/IP calls usb_hcd_giveback_urb() in the task context | |
| 69 | − * within an existing remote coverage collection section. Thus, KCOV should | |
| 70 | − * not attempt to start collecting coverage within the coverage collection | |
| 71 | − * section in __usb_hcd_giveback_urb() in this case. | |
| 72 | − * | |
| 73 | − * 2. Disables interrupts for the duration of the coverage collection section. | |
| 74 | − * This allows avoiding nested remote coverage collection sections in the | |
| 75 | − * softirq context (a softirq might occur during the execution of a work in | |
| 76 | − * the BH workqueue, which runs with in_serving_softirq() > 0). | |
| 77 | − * For example, usb_giveback_urb_bh() runs in the BH workqueue with | |
| 78 | − * interrupts enabled, so __usb_hcd_giveback_urb() might be interrupted in | |
| 79 | − * the middle of its remote coverage collection section, and the interrupt | |
| 80 | − * handler might invoke __usb_hcd_giveback_urb() again. | |
| 60 | + * work around for kcov's lack of nested remote coverage sections support in | |
| 61 | + * task context. Adding support for nested sections is tracked in: | |
| 62 | + * https://bugzilla.kernel.org/show_bug.cgi?id=210337 | |
| 81 | 63 | */ |
| 82 | 64 | |
| 83 | −static inline unsigned long kcov_remote_start_usb_softirq(u64 id) | |
| 65 | +static inline void kcov_remote_start_usb_softirq(u64 id) | |
| 84 | 66 | { |
| 85 | − unsigned long flags = 0; | |
| 86 | − | |
| 87 | − if (in_serving_softirq()) { | |
| 88 | − local_irq_save(flags); | |
| 67 | + if (in_serving_softirq() && !in_hardirq()) | |
| 89 | 68 | kcov_remote_start_usb(id); |
| 90 | − } | |
| 91 | − | |
| 92 | − return flags; | |
| 93 | 69 | } |
| 94 | 70 | |
| 95 | −static inline void kcov_remote_stop_softirq(unsigned long flags) | |
| 71 | +static inline void kcov_remote_stop_softirq(void) | |
| 96 | 72 | { |
| 97 | − if (in_serving_softirq()) { | |
| 73 | + if (in_serving_softirq() && !in_hardirq()) | |
| 98 | 74 | kcov_remote_stop(); |
| 99 | − local_irq_restore(flags); | |
| 100 | − } | |
| 101 | 75 | } |
| 102 | 76 | |
| 103 | 77 | #ifdef CONFIG_64BIT |
| @@ -131,11 +105,8 @@ static inline u64 kcov_common_handle(void) · 27 unmodified lines | ||
| 131 | 105 | } |
| 132 | 106 | static inline void kcov_remote_start_common(u64 id) {} |
| 133 | 107 | static inline void kcov_remote_start_usb(u64 id) {} |
| 134 | −static inline unsigned long kcov_remote_start_usb_softirq(u64 id) | |
| 135 | −{ | |
| 136 | − return 0; | |
| 137 | −} | |
| 138 | −static inline void kcov_remote_stop_softirq(unsigned long flags) {} | |
| 108 | +static inline void kcov_remote_start_usb_softirq(u64 id) {} | |
| 109 | +static inline void kcov_remote_stop_softirq(void) {} | |
| 139 | 110 | |
| 140 | 111 | #endif /* CONFIG_KCOV */ |
| 141 | 112 | #endif /* _LINUX_KCOV_H */ |
| @@ -79,6 +79,7 @@ void migration_entry_wait_on_locked(swp_entry_t entry, spinlock_t *ptl) · 78 unmodified lines | ||
| 79 | 79 | void folio_migrate_flags(struct folio *newfolio, struct folio *folio); |
| 80 | 80 | int folio_migrate_mapping(struct address_space *mapping, |
| 81 | 81 | struct folio *newfolio, struct folio *folio, int extra_count); |
| 82 | +int set_movable_ops(const struct movable_operations *ops, enum pagetype type); | |
| 82 | 83 | |
| 83 | 84 | #else |
| 84 | 85 | |
| @@ -100,6 +101,10 @@ static inline int migrate_huge_page_move_mapping(struct address_space *mapping, · 15 unmodified lines | ||
| 100 | 101 | { |
| 101 | 102 | return -ENOSYS; |
| 102 | 103 | } |
| 104 | +static inline int set_movable_ops(const struct movable_operations *ops, enum pagetype type) | |
| 105 | +{ | |
| 106 | + return -ENOSYS; | |
| 107 | +} | |
| 103 | 108 | |
| 104 | 109 | #endif /* CONFIG_MIGRATION */ |
| 105 | 110 | |
| @@ -150,6 +150,7 @@ struct netfs_io_stream { · 149 unmodified lines | ||
| 150 | 150 | bool active; /* T if stream is active */ |
| 151 | 151 | bool need_retry; /* T if this stream needs retrying */ |
| 152 | 152 | bool failed; /* T if this stream failed */ |
| 153 | + bool transferred_valid; /* T is ->transferred is valid */ | |
| 153 | 154 | }; |
| 154 | 155 | |
| 155 | 156 | /* |
| @@ -160,6 +160,7 @@ extern void nfs_join_page_group(struct nfs_page *head, · 159 unmodified lines | ||
| 160 | 160 | extern int nfs_page_group_lock(struct nfs_page *); |
| 161 | 161 | extern void nfs_page_group_unlock(struct nfs_page *); |
| 162 | 162 | extern bool nfs_page_group_sync_on_bit(struct nfs_page *, unsigned int); |
| 163 | +extern bool nfs_page_group_sync_on_bit_locked(struct nfs_page *, unsigned int); | |
| 163 | 164 | extern int nfs_page_set_headlock(struct nfs_page *req); |
| 164 | 165 | extern void nfs_page_clear_headlock(struct nfs_page *req); |
| 165 | 166 | extern bool nfs_async_iocounter_wait(struct rpc_task *, struct nfs_lock_context *); |
| @@ -647,7 +647,7 @@ static inline void sco_exit(void) · 646 unmodified lines | ||
| 647 | 647 | #if IS_ENABLED(CONFIG_BT_LE) |
| 648 | 648 | int iso_init(void); |
| 649 | 649 | int iso_exit(void); |
| 650 | −bool iso_enabled(void); | |
| 650 | +bool iso_inited(void); | |
| 651 | 651 | #else |
| 652 | 652 | static inline int iso_init(void) |
| 653 | 653 | { |
| @@ -659,7 +659,7 @@ static inline int iso_exit(void) · 5 unmodified lines | ||
| 659 | 659 | return 0; |
| 660 | 660 | } |
| 661 | 661 | |
| 662 | −static inline bool iso_enabled(void) | |
| 662 | +static inline bool iso_inited(void) | |
| 663 | 663 | { |
| 664 | 664 | return false; |
| 665 | 665 | } |
| @@ -129,7 +129,9 @@ struct hci_conn_hash { · 128 unmodified lines | ||
| 129 | 129 | struct list_head list; |
| 130 | 130 | unsigned int acl_num; |
| 131 | 131 | unsigned int sco_num; |
| 132 | − unsigned int iso_num; | |
| 132 | + unsigned int cis_num; | |
| 133 | + unsigned int bis_num; | |
| 134 | + unsigned int pa_num; | |
| 133 | 135 | unsigned int le_num; |
| 134 | 136 | unsigned int le_num_peripheral; |
| 135 | 137 | }; |
| @@ -1014,9 +1016,13 @@ static inline void hci_conn_hash_add(struct hci_dev *hdev, struct hci_conn *c) · 878 unmodified lines | ||
| 1014 | 1016 | h->sco_num++; |
| 1015 | 1017 | break; |
| 1016 | 1018 | case CIS_LINK: |
| 1019 | + h->cis_num++; | |
| 1020 | + break; | |
| 1017 | 1021 | case BIS_LINK: |
| 1022 | + h->bis_num++; | |
| 1023 | + break; | |
| 1018 | 1024 | case PA_LINK: |
| 1019 | − h->iso_num++; | |
| 1025 | + h->pa_num++; | |
| 1020 | 1026 | break; |
| 1021 | 1027 | } |
| 1022 | 1028 | } |
| @@ -1042,9 +1048,13 @@ static inline void hci_conn_hash_del(struct hci_dev *hdev, struct hci_conn *c) · 19 unmodified lines | ||
| 1042 | 1048 | h->sco_num--; |
| 1043 | 1049 | break; |
| 1044 | 1050 | case CIS_LINK: |
| 1051 | + h->cis_num--; | |
| 1052 | + break; | |
| 1045 | 1053 | case BIS_LINK: |
| 1054 | + h->bis_num--; | |
| 1055 | + break; | |
| 1046 | 1056 | case PA_LINK: |
| 1047 | − h->iso_num--; | |
| 1057 | + h->pa_num--; | |
| 1048 | 1058 | break; |
| 1049 | 1059 | } |
| 1050 | 1060 | } |
| @@ -1061,9 +1071,11 @@ static inline unsigned int hci_conn_num(struct hci_dev *hdev, __u8 type) · 10 unmodified lines | ||
| 1061 | 1071 | case ESCO_LINK: |
| 1062 | 1072 | return h->sco_num; |
| 1063 | 1073 | case CIS_LINK: |
| 1074 | + return h->cis_num; | |
| 1064 | 1075 | case BIS_LINK: |
| 1076 | + return h->bis_num; | |
| 1065 | 1077 | case PA_LINK: |
| 1066 | − return h->iso_num; | |
| 1078 | + return h->pa_num; | |
| 1067 | 1079 | default: |
| 1068 | 1080 | return 0; |
| 1069 | 1081 | } |
| @@ -1073,7 +1085,15 @@ static inline unsigned int hci_conn_count(struct hci_dev *hdev) · 3 unmodified lines | ||
| 1073 | 1085 | { |
| 1074 | 1086 | struct hci_conn_hash *c = &hdev->conn_hash; |
| 1075 | 1087 | |
| 1076 | − return c->acl_num + c->sco_num + c->le_num + c->iso_num; | |
| 1088 | + return c->acl_num + c->sco_num + c->le_num + c->cis_num + c->bis_num + | |
| 1089 | + c->pa_num; | |
| 1090 | +} | |
| 1091 | + | |
| 1092 | +static inline unsigned int hci_iso_count(struct hci_dev *hdev) | |
| 1093 | +{ | |
| 1094 | + struct hci_conn_hash *c = &hdev->conn_hash; | |
| 1095 | + | |
| 1096 | + return c->cis_num + c->bis_num; | |
| 1077 | 1097 | } |
| 1078 | 1098 | |
| 1079 | 1099 | static inline bool hci_conn_valid(struct hci_dev *hdev, struct hci_conn *conn) |
| @@ -1915,6 +1935,8 @@ void hci_conn_del_sysfs(struct hci_conn *conn); · 835 unmodified lines | ||
| 1915 | 1935 | !hci_dev_test_flag(dev, HCI_RPA_EXPIRED)) |
| 1916 | 1936 | #define adv_rpa_valid(adv) (bacmp(&adv->random_addr, BDADDR_ANY) && \ |
| 1917 | 1937 | !adv->rpa_expired) |
| 1938 | +#define le_enabled(dev) (lmp_le_capable(dev) && \ | |
| 1939 | + hci_dev_test_flag(dev, HCI_LE_ENABLED)) | |
| 1918 | 1940 | |
| 1919 | 1941 | #define scan_1m(dev) (((dev)->le_tx_def_phys & HCI_LE_SET_PHY_1M) || \ |
| 1920 | 1942 | ((dev)->le_rx_def_phys & HCI_LE_SET_PHY_1M)) |
| @@ -1932,6 +1954,7 @@ void hci_conn_del_sysfs(struct hci_conn *conn); · 11 unmodified lines | ||
| 1932 | 1954 | ((dev)->le_rx_def_phys & HCI_LE_SET_PHY_CODED)) |
| 1933 | 1955 | |
| 1934 | 1956 | #define ll_privacy_capable(dev) ((dev)->le_features[0] & HCI_LE_LL_PRIVACY) |
| 1957 | +#define ll_privacy_enabled(dev) (le_enabled(dev) && ll_privacy_capable(dev)) | |
| 1935 | 1958 | |
| 1936 | 1959 | #define privacy_mode_capable(dev) (ll_privacy_capable(dev) && \ |
| 1937 | 1960 | ((dev)->commands[39] & 0x04)) |
| @@ -1981,14 +2004,23 @@ void hci_conn_del_sysfs(struct hci_conn *conn); · 43 unmodified lines | ||
| 1981 | 2004 | |
| 1982 | 2005 | /* CIS Master/Slave and BIS support */ |
| 1983 | 2006 | #define iso_capable(dev) (cis_capable(dev) || bis_capable(dev)) |
| 2007 | +#define iso_enabled(dev) (le_enabled(dev) && iso_capable(dev)) | |
| 1984 | 2008 | #define cis_capable(dev) \ |
| 1985 | 2009 | (cis_central_capable(dev) || cis_peripheral_capable(dev)) |
| 2010 | +#define cis_enabled(dev) (le_enabled(dev) && cis_capable(dev)) | |
| 1986 | 2011 | #define cis_central_capable(dev) \ |
| 1987 | 2012 | ((dev)->le_features[3] & HCI_LE_CIS_CENTRAL) |
| 2013 | +#define cis_central_enabled(dev) \ | |
| 2014 | + (le_enabled(dev) && cis_central_capable(dev)) | |
| 1988 | 2015 | #define cis_peripheral_capable(dev) \ |
| 1989 | 2016 | ((dev)->le_features[3] & HCI_LE_CIS_PERIPHERAL) |
| 2017 | +#define cis_peripheral_enabled(dev) \ | |
| 2018 | + (le_enabled(dev) && cis_peripheral_capable(dev)) | |
| 1990 | 2019 | #define bis_capable(dev) ((dev)->le_features[3] & HCI_LE_ISO_BROADCASTER) |
| 1991 | −#define sync_recv_capable(dev) ((dev)->le_features[3] & HCI_LE_ISO_SYNC_RECEIVER) | |
| 2020 | +#define bis_enabled(dev) (le_enabled(dev) && bis_capable(dev)) | |
| 2021 | +#define sync_recv_capable(dev) \ | |
| 2022 | + ((dev)->le_features[3] & HCI_LE_ISO_SYNC_RECEIVER) | |
| 2023 | +#define sync_recv_enabled(dev) (le_enabled(dev) && sync_recv_capable(dev)) | |
| 1992 | 2024 | |
| 1993 | 2025 | #define mws_transport_config_capable(dev) (((dev)->commands[30] & 0x08) && \ |
| 1994 | 2026 | (!hci_test_quirk((dev), HCI_QUIRK_BROKEN_MWS_TRANSPORT_CONFIG))) |
| @@ -307,6 +307,7 @@ int bond_3ad_lacpdu_recv(const struct sk_buff *skb, struct bonding *bond, · 306 unmodified lines | ||
| 307 | 307 | struct slave *slave); |
| 308 | 308 | int bond_3ad_set_carrier(struct bonding *bond); |
| 309 | 309 | void bond_3ad_update_lacp_rate(struct bonding *bond); |
| 310 | +void bond_3ad_update_lacp_active(struct bonding *bond); | |
| 310 | 311 | void bond_3ad_update_ad_actor_settings(struct bonding *bond); |
| 311 | 312 | int bond_3ad_stats_fill(struct sk_buff *skb, struct bond_3ad_stats *stats); |
| 312 | 313 | size_t bond_3ad_stats_size(void); |
| @@ -1038,12 +1038,17 @@ static inline struct sk_buff *qdisc_dequeue_internal(struct Qdisc *sch, bool dir · 1037 unmodified lines | ||
| 1038 | 1038 | skb = __skb_dequeue(&sch->gso_skb); |
| 1039 | 1039 | if (skb) { |
| 1040 | 1040 | sch->q.qlen--; |
| 1041 | + qdisc_qstats_backlog_dec(sch, skb); | |
| 1041 | 1042 | return skb; |
| 1042 | 1043 | } |
| 1043 | − if (direct) | |
| 1044 | − return __qdisc_dequeue_head(&sch->q); | |
| 1045 | − else | |
| 1044 | + if (direct) { | |
| 1045 | + skb = __qdisc_dequeue_head(&sch->q); | |
| 1046 | + if (skb) | |
| 1047 | + qdisc_qstats_backlog_dec(sch, skb); | |
| 1048 | + return skb; | |
| 1049 | + } else { | |
| 1046 | 1050 | return sch->dequeue(sch); |
| 1051 | + } | |
| 1047 | 1052 | } |
| 1048 | 1053 | |
| 1049 | 1054 | static inline struct sk_buff *qdisc_dequeue_head(struct Qdisc *sch) |
| @@ -107,8 +107,8 @@ · 106 unmodified lines | ||
| 107 | 107 | #define CS35L56_DSP1_PMEM_5114 0x3804FE8 |
| 108 | 108 | |
| 109 | 109 | #define CS35L63_DSP1_FW_VER CS35L56_DSP1_FW_VER |
| 110 | −#define CS35L63_DSP1_HALO_STATE 0x280396C | |
| 111 | −#define CS35L63_DSP1_PM_CUR_STATE 0x28042C8 | |
| 110 | +#define CS35L63_DSP1_HALO_STATE 0x2803C04 | |
| 111 | +#define CS35L63_DSP1_PM_CUR_STATE 0x2804518 | |
| 112 | 112 | #define CS35L63_PROTECTION_STATUS 0x340009C |
| 113 | 113 | #define CS35L63_TRANSDUCER_ACTUAL_PS 0x34000F4 |
| 114 | 114 | #define CS35L63_MAIN_RENDER_USER_MUTE 0x3400020 |
| @@ -306,6 +306,7 @@ struct cs35l56_base { · 191 unmodified lines | ||
| 306 | 306 | struct gpio_desc *reset_gpio; |
| 307 | 307 | struct cs35l56_spi_payload *spi_payload_buf; |
| 308 | 308 | const struct cs35l56_fw_reg *fw_reg; |
| 309 | + const struct cirrus_amp_cal_controls *calibration_controls; | |
| 309 | 310 | }; |
| 310 | 311 | |
| 311 | 312 | static inline bool cs35l56_is_otp_register(unsigned int reg) |
| @@ -2,7 +2,7 @@ · 1 unmodified line | ||
| 2 | 2 | // |
| 3 | 3 | // ALSA SoC Texas Instruments TAS2781 Audio Smart Amplifier |
| 4 | 4 | // |
| 5 | −// Copyright (C) 2022 - 2024 Texas Instruments Incorporated | |
| 5 | +// Copyright (C) 2022 - 2025 Texas Instruments Incorporated | |
| 6 | 6 | // https://www.ti.com |
| 7 | 7 | // |
| 8 | 8 | // The TAS2781 driver implements a flexible and configurable |
| @@ -15,7 +15,7 @@ · 6 unmodified lines | ||
| 15 | 15 | #ifndef __TAS2781_TLV_H__ |
| 16 | 16 | #define __TAS2781_TLV_H__ |
| 17 | 17 | |
| 18 | −static const __maybe_unused DECLARE_TLV_DB_SCALE(dvc_tlv, -10000, 50, 0); | |
| 19 | −static const __maybe_unused DECLARE_TLV_DB_SCALE(amp_vol_tlv, 1100, 50, 0); | |
| 18 | +static const __maybe_unused DECLARE_TLV_DB_SCALE(tas2781_dvc_tlv, -10000, 50, 0); | |
| 19 | +static const __maybe_unused DECLARE_TLV_DB_SCALE(tas2781_amp_tlv, 1100, 50, 0); | |
| 20 | 20 | |
| 21 | 21 | #endif |
| @@ -89,6 +89,7 @@ struct pfru_payload_hdr { · 88 unmodified lines | ||
| 89 | 89 | __u32 hw_ver; |
| 90 | 90 | __u32 rt_ver; |
| 91 | 91 | __u8 platform_id[16]; |
| 92 | + __u32 svn_ver; | |
| 92 | 93 | }; |
| 93 | 94 | |
| 94 | 95 | enum pfru_dsm_status { |
| @@ -173,7 +173,7 @@ typedef struct mdp_superblock_s { · 172 unmodified lines | ||
| 173 | 173 | #else |
| 174 | 174 | #error unspecified endianness |
| 175 | 175 | #endif |
| 176 | − __u32 resync_offset; /* 11 resync checkpoint sector count */ | |
| 176 | + __u32 recovery_cp; /* 11 resync checkpoint sector count */ | |
| 177 | 177 | /* There are only valid for minor_version > 90 */ |
| 178 | 178 | __u64 reshape_position; /* 12,13 next address in array-space for reshape */ |
| 179 | 179 | __u32 new_level; /* 14 new level we are reshaping to */ |
| @@ -288,6 +288,7 @@ int io_futex_wait(struct io_kiocb *req, unsigned int issue_flags) · 287 unmodified lines | ||
| 288 | 288 | goto done_unlock; |
| 289 | 289 | } |
| 290 | 290 | |
| 291 | + req->flags |= REQ_F_ASYNC_DATA; | |
| 291 | 292 | req->async_data = ifd; |
| 292 | 293 | ifd->q = futex_q_init; |
| 293 | 294 | ifd->q.bitset = iof->futex_mask; |
| @@ -309,6 +310,8 @@ done: · 15 unmodified lines | ||
| 309 | 310 | if (ret < 0) |
| 310 | 311 | req_set_fail(req); |
| 311 | 312 | io_req_set_res(req, ret, 0); |
| 313 | + req->async_data = NULL; | |
| 314 | + req->flags &= ~REQ_F_ASYNC_DATA; | |
| 312 | 315 | kfree(ifd); |
| 313 | 316 | return IOU_COMPLETE; |
| 314 | 317 | } |
| @@ -2119,6 +2119,7 @@ static int io_init_req(struct io_ring_ctx *ctx, struct io_kiocb *req, · 2118 unmodified lines | ||
| 2119 | 2119 | req->file = NULL; |
| 2120 | 2120 | req->tctx = current->io_uring; |
| 2121 | 2121 | req->cancel_seq_set = false; |
| 2122 | + req->async_data = NULL; | |
| 2122 | 2123 | |
| 2123 | 2124 | if (unlikely(opcode >= IORING_OP_LAST)) { |
| 2124 | 2125 | req->opcode = 0; |
| @@ -97,6 +97,7 @@ config KEXEC_JUMP · 96 unmodified lines | ||
| 97 | 97 | config KEXEC_HANDOVER |
| 98 | 98 | bool "kexec handover" |
| 99 | 99 | depends on ARCH_SUPPORTS_KEXEC_HANDOVER && ARCH_SUPPORTS_KEXEC_FILE |
| 100 | + depends on !DEFERRED_STRUCT_PAGE_INIT | |
| 100 | 101 | select MEMBLOCK_KHO_SCRATCH |
| 101 | 102 | select KEXEC_FILE |
| 102 | 103 | select DEBUG_FS |
| @@ -280,7 +280,7 @@ static inline void check_insane_mems_config(nodemask_t *nodes) · 279 unmodified lines | ||
| 280 | 280 | { |
| 281 | 281 | if (!cpusets_insane_config() && |
| 282 | 282 | movable_only_nodes(nodes)) { |
| 283 | − static_branch_enable(&cpusets_insane_config_key); | |
| 283 | + static_branch_enable_cpuslocked(&cpusets_insane_config_key); | |
| 284 | 284 | pr_info("Unsupported (movable nodes only) cpuset configuration detected (nmask=%*pbl)!\n" |
| 285 | 285 | "Cpuset allocations might fail even with a lot of memory available.\n", |
| 286 | 286 | nodemask_pr_args(nodes)); |
| @@ -1843,7 +1843,7 @@ static int update_parent_effective_cpumask(struct cpuset *cs, int cmd, · 1556 unmodified lines | ||
| 1843 | 1843 | if (is_partition_valid(cs)) |
| 1844 | 1844 | adding = cpumask_and(tmp->addmask, |
| 1845 | 1845 | xcpus, parent->effective_xcpus); |
| 1846 | − } else if (is_partition_invalid(cs) && | |
| 1846 | + } else if (is_partition_invalid(cs) && !cpumask_empty(xcpus) && | |
| 1847 | 1847 | cpumask_subset(xcpus, parent->effective_xcpus)) { |
| 1848 | 1848 | struct cgroup_subsys_state *css; |
| 1849 | 1849 | struct cpuset *child; |
| @@ -3358,14 +3358,12 @@ static ssize_t cpuset_partition_write(struct kernfs_open_file *of, char *buf, · 1508 unmodified lines | ||
| 3358 | 3358 | else |
| 3359 | 3359 | return -EINVAL; |
| 3360 | 3360 | |
| 3361 | − css_get(&cs->css); | |
| 3362 | 3361 | cpus_read_lock(); |
| 3363 | 3362 | mutex_lock(&cpuset_mutex); |
| 3364 | 3363 | if (is_cpuset_online(cs)) |
| 3365 | 3364 | retval = update_prstate(cs, val); |
| 3366 | 3365 | mutex_unlock(&cpuset_mutex); |
| 3367 | 3366 | cpus_read_unlock(); |
| 3368 | − css_put(&cs->css); | |
| 3369 | 3367 | return retval ?: nbytes; |
| 3370 | 3368 | } |
| 3371 | 3369 | |
| @@ -3870,9 +3868,10 @@ retry: · 498 unmodified lines | ||
| 3870 | 3868 | partcmd = partcmd_invalidate; |
| 3871 | 3869 | /* |
| 3872 | 3870 | * On the other hand, an invalid partition root may be transitioned |
| 3873 | − * back to a regular one. | |
| 3871 | + * back to a regular one with a non-empty effective xcpus. | |
| 3874 | 3872 | */ |
| 3875 | − else if (is_partition_valid(parent) && is_partition_invalid(cs)) | |
| 3873 | + else if (is_partition_valid(parent) && is_partition_invalid(cs) && | |
| 3874 | + !cpumask_empty(cs->effective_xcpus)) | |
| 3876 | 3875 | partcmd = partcmd_update; |
| 3877 | 3876 | |
| 3878 | 3877 | if (partcmd >= 0) { |
| @@ -479,6 +479,9 @@ void css_rstat_exit(struct cgroup_subsys_state *css) · 478 unmodified lines | ||
| 479 | 479 | if (!css_uses_rstat(css)) |
| 480 | 480 | return; |
| 481 | 481 | |
| 482 | + if (!css->rstat_cpu) | |
| 483 | + return; | |
| 484 | + | |
| 482 | 485 | css_rstat_flush(css); |
| 483 | 486 | |
| 484 | 487 | /* sanity check */ |
| @@ -2665,6 +2665,9 @@ static void perf_log_itrace_start(struct perf_event *event); · 2664 unmodified lines | ||
| 2665 | 2665 | |
| 2666 | 2666 | static void perf_event_unthrottle(struct perf_event *event, bool start) |
| 2667 | 2667 | { |
| 2668 | + if (event->state != PERF_EVENT_STATE_ACTIVE) | |
| 2669 | + return; | |
| 2670 | + | |
| 2668 | 2671 | event->hw.interrupts = 0; |
| 2669 | 2672 | if (start) |
| 2670 | 2673 | event->pmu->start(event, 0); |
| @@ -2674,6 +2677,9 @@ static void perf_event_unthrottle(struct perf_event *event, bool start) · 3 unmodified lines | ||
| 2674 | 2677 | |
| 2675 | 2678 | static void perf_event_throttle(struct perf_event *event) |
| 2676 | 2679 | { |
| 2680 | + if (event->state != PERF_EVENT_STATE_ACTIVE) | |
| 2681 | + return; | |
| 2682 | + | |
| 2677 | 2683 | event->hw.interrupts = MAX_INTERRUPTS; |
| 2678 | 2684 | event->pmu->stop(event, 0); |
| 2679 | 2685 | if (event == event->group_leader) |
| @@ -144,14 +144,34 @@ static int __kho_preserve_order(struct kho_mem_track *track, unsigned long pfn, · 143 unmodified lines | ||
| 144 | 144 | unsigned int order) |
| 145 | 145 | { |
| 146 | 146 | struct kho_mem_phys_bits *bits; |
| 147 | − struct kho_mem_phys *physxa; | |
| 147 | + struct kho_mem_phys *physxa, *new_physxa; | |
| 148 | 148 | const unsigned long pfn_high = pfn >> order; |
| 149 | 149 | |
| 150 | 150 | might_sleep(); |
| 151 | 151 | |
| 152 | − physxa = xa_load_or_alloc(&track->orders, order, sizeof(*physxa)); | |
| 153 | − if (IS_ERR(physxa)) | |
| 154 | − return PTR_ERR(physxa); | |
| 152 | + physxa = xa_load(&track->orders, order); | |
| 153 | + if (!physxa) { | |
| 154 | + int err; | |
| 155 | + | |
| 156 | + new_physxa = kzalloc(sizeof(*physxa), GFP_KERNEL); | |
| 157 | + if (!new_physxa) | |
| 158 | + return -ENOMEM; | |
| 159 | + | |
| 160 | + xa_init(&new_physxa->phys_bits); | |
| 161 | + physxa = xa_cmpxchg(&track->orders, order, NULL, new_physxa, | |
| 162 | + GFP_KERNEL); | |
| 163 | + | |
| 164 | + err = xa_err(physxa); | |
| 165 | + if (err || physxa) { | |
| 166 | + xa_destroy(&new_physxa->phys_bits); | |
| 167 | + kfree(new_physxa); | |
| 168 | + | |
| 169 | + if (err) | |
| 170 | + return err; | |
| 171 | + } else { | |
| 172 | + physxa = new_physxa; | |
| 173 | + } | |
| 174 | + } | |
| 155 | 175 | |
| 156 | 176 | bits = xa_load_or_alloc(&physxa->phys_bits, pfn_high / PRESERVE_BITS, |
| 157 | 177 | sizeof(*bits)); |
| @@ -544,6 +564,7 @@ err_free_scratch_areas: · 386 unmodified lines | ||
| 544 | 564 | err_free_scratch_desc: |
| 545 | 565 | memblock_free(kho_scratch, kho_scratch_cnt * sizeof(*kho_scratch)); |
| 546 | 566 | err_disable_kho: |
| 567 | + pr_warn("Failed to reserve scratch area, disabling kexec handover\n"); | |
| 547 | 568 | kho_enable = false; |
| 548 | 569 | } |
| 549 | 570 | |
| @@ -513,13 +513,14 @@ EXPORT_SYMBOL(param_array_ops); · 512 unmodified lines | ||
| 513 | 513 | int param_set_copystring(const char *val, const struct kernel_param *kp) |
| 514 | 514 | { |
| 515 | 515 | const struct kparam_string *kps = kp->str; |
| 516 | + const size_t len = strnlen(val, kps->maxlen); | |
| 516 | 517 | |
| 517 | − if (strnlen(val, kps->maxlen) == kps->maxlen) { | |
| 518 | + if (len == kps->maxlen) { | |
| 518 | 519 | pr_err("%s: string doesn't fit in %u chars.\n", |
| 519 | 520 | kp->name, kps->maxlen-1); |
| 520 | 521 | return -ENOSPC; |
| 521 | 522 | } |
| 522 | − strcpy(kps->string, val); | |
| 523 | + memcpy(kps->string, val, len + 1); | |
| 523 | 524 | return 0; |
| 524 | 525 | } |
| 525 | 526 | EXPORT_SYMBOL(param_set_copystring); |
| @@ -841,7 +842,7 @@ static void __init param_sysfs_builtin(void) · 315 unmodified lines | ||
| 841 | 842 | dot = strchr(kp->name, '.'); |
| 842 | 843 | if (!dot) { |
| 843 | 844 | /* This happens for core_param() */ |
| 844 | − strcpy(modname, "kernel"); | |
| 845 | + strscpy(modname, "kernel"); | |
| 845 | 846 | name_len = 0; |
| 846 | 847 | } else { |
| 847 | 848 | name_len = dot - kp->name + 1; |
| @@ -5749,6 +5749,9 @@ static int scx_enable(struct sched_ext_ops *ops, struct bpf_link *link) · 5748 unmodified lines | ||
| 5749 | 5749 | __setscheduler_class(p->policy, p->prio); |
| 5750 | 5750 | struct sched_enq_and_set_ctx ctx; |
| 5751 | 5751 | |
| 5752 | + if (!tryget_task_struct(p)) | |
| 5753 | + continue; | |
| 5754 | + | |
| 5752 | 5755 | if (old_class != new_class && p->se.sched_delayed) |
| 5753 | 5756 | dequeue_task(task_rq(p), p, DEQUEUE_SLEEP | DEQUEUE_DELAYED); |
| 5754 | 5757 | |
| @@ -5761,6 +5764,7 @@ static int scx_enable(struct sched_ext_ops *ops, struct bpf_link *link) · 6 unmodified lines | ||
| 5761 | 5764 | sched_enq_and_set_task(&ctx); |
| 5762 | 5765 | |
| 5763 | 5766 | check_class_changed(task_rq(p), p, old_class, p->prio); |
| 5767 | + put_task_struct(p); | |
| 5764 | 5768 | } |
| 5765 | 5769 | scx_task_iter_stop(&sti); |
| 5766 | 5770 | percpu_up_write(&scx_fork_rwsem); |
| @@ -4067,6 +4067,7 @@ SYSCALL_DEFINE4(pidfd_send_signal, int, pidfd, int, sig, · 4066 unmodified lines | ||
| 4067 | 4067 | { |
| 4068 | 4068 | struct pid *pid; |
| 4069 | 4069 | enum pid_type type; |
| 4070 | + int ret; | |
| 4070 | 4071 | |
| 4071 | 4072 | /* Enforce flags be set to 0 until we add an extension. */ |
| 4072 | 4073 | if (flags & ~PIDFD_SEND_SIGNAL_FLAGS) |
| @@ -4108,7 +4109,10 @@ SYSCALL_DEFINE4(pidfd_send_signal, int, pidfd, int, sig, · 35 unmodified lines | ||
| 4108 | 4109 | } |
| 4109 | 4110 | } |
| 4110 | 4111 | |
| 4111 | − return do_pidfd_send_signal(pid, sig, type, info, flags); | |
| 4112 | + ret = do_pidfd_send_signal(pid, sig, type, info, flags); | |
| 4113 | + put_pid(pid); | |
| 4114 | + | |
| 4115 | + return ret; | |
| 4112 | 4116 | } |
| 4113 | 4117 | |
| 4114 | 4118 | static int |
| @@ -1397,6 +1397,7 @@ error: · 1396 unmodified lines | ||
| 1397 | 1397 | ftrace_graph_active--; |
| 1398 | 1398 | gops->saved_func = NULL; |
| 1399 | 1399 | fgraph_lru_release_index(i); |
| 1400 | + unregister_pm_notifier(&ftrace_suspend_notifier); | |
| 1400 | 1401 | } |
| 1401 | 1402 | return ret; |
| 1402 | 1403 | } |
| @@ -4661,13 +4661,17 @@ ftrace_regex_open(struct ftrace_ops *ops, int flag, · 4660 unmodified lines | ||
| 4661 | 4661 | } else { |
| 4662 | 4662 | iter->hash = alloc_and_copy_ftrace_hash(size_bits, hash); |
| 4663 | 4663 | } |
| 4664 | + } else { | |
| 4665 | + if (hash) | |
| 4666 | + iter->hash = alloc_and_copy_ftrace_hash(hash->size_bits, hash); | |
| 4667 | + else | |
| 4668 | + iter->hash = EMPTY_HASH; | |
| 4669 | + } | |
| 4664 | 4670 | |
| 4665 | − if (!iter->hash) { | |
| 4666 | − trace_parser_put(&iter->parser); | |
| 4667 | − goto out_unlock; | |
| 4668 | − } | |
| 4669 | − } else | |
| 4670 | − iter->hash = hash; | |
| 4671 | + if (!iter->hash) { | |
| 4672 | + trace_parser_put(&iter->parser); | |
| 4673 | + goto out_unlock; | |
| 4674 | + } | |
| 4671 | 4675 | |
| 4672 | 4676 | ret = 0; |
| 4673 | 4677 | |
| @@ -6543,9 +6547,6 @@ int ftrace_regex_release(struct inode *inode, struct file *file) · 1869 unmodified lines | ||
| 6543 | 6547 | ftrace_hash_move_and_update_ops(iter->ops, orig_hash, |
| 6544 | 6548 | iter->hash, filter_hash); |
| 6545 | 6549 | mutex_unlock(&ftrace_lock); |
| 6546 | − } else { | |
| 6547 | − /* For read only, the hash is the ops hash */ | |
| 6548 | − iter->hash = NULL; | |
| 6549 | 6550 | } |
| 6550 | 6551 | |
| 6551 | 6552 | mutex_unlock(&iter->ops->func_hash->regex_lock); |
| @@ -7666,7 +7666,7 @@ static __init int test_ringbuffer(void) · 7665 unmodified lines | ||
| 7666 | 7666 | rb_test_started = true; |
| 7667 | 7667 | |
| 7668 | 7668 | set_current_state(TASK_INTERRUPTIBLE); |
| 7669 | − /* Just run for 10 seconds */; | |
| 7669 | + /* Just run for 10 seconds */ | |
| 7670 | 7670 | schedule_timeout(10 * HZ); |
| 7671 | 7671 | |
| 7672 | 7672 | kthread_stop(rb_hammer); |
| @@ -1816,7 +1816,7 @@ int trace_get_user(struct trace_parser *parser, const char __user *ubuf, · 1815 unmodified lines | ||
| 1816 | 1816 | |
| 1817 | 1817 | ret = get_user(ch, ubuf++); |
| 1818 | 1818 | if (ret) |
| 1819 | − return ret; | |
| 1819 | + goto fail; | |
| 1820 | 1820 | |
| 1821 | 1821 | read++; |
| 1822 | 1822 | cnt--; |
| @@ -1830,7 +1830,7 @@ int trace_get_user(struct trace_parser *parser, const char __user *ubuf, · 7 unmodified lines | ||
| 1830 | 1830 | while (cnt && isspace(ch)) { |
| 1831 | 1831 | ret = get_user(ch, ubuf++); |
| 1832 | 1832 | if (ret) |
| 1833 | − return ret; | |
| 1833 | + goto fail; | |
| 1834 | 1834 | read++; |
| 1835 | 1835 | cnt--; |
| 1836 | 1836 | } |
| @@ -1848,12 +1848,14 @@ int trace_get_user(struct trace_parser *parser, const char __user *ubuf, · 11 unmodified lines | ||
| 1848 | 1848 | while (cnt && !isspace(ch) && ch) { |
| 1849 | 1849 | if (parser->idx < parser->size - 1) |
| 1850 | 1850 | parser->buffer[parser->idx++] = ch; |
| 1851 | − else | |
| 1852 | − return -EINVAL; | |
| 1851 | + else { | |
| 1852 | + ret = -EINVAL; | |
| 1853 | + goto fail; | |
| 1854 | + } | |
| 1853 | 1855 | |
| 1854 | 1856 | ret = get_user(ch, ubuf++); |
| 1855 | 1857 | if (ret) |
| 1856 | − return ret; | |
| 1858 | + goto fail; | |
| 1857 | 1859 | read++; |
| 1858 | 1860 | cnt--; |
| 1859 | 1861 | } |
| @@ -1868,11 +1870,15 @@ int trace_get_user(struct trace_parser *parser, const char __user *ubuf, · 8 unmodified lines | ||
| 1868 | 1870 | /* Make sure the parsed string always terminates with '\0'. */ |
| 1869 | 1871 | parser->buffer[parser->idx] = 0; |
| 1870 | 1872 | } else { |
| 1871 | − return -EINVAL; | |
| 1873 | + ret = -EINVAL; | |
| 1874 | + goto fail; | |
| 1872 | 1875 | } |
| 1873 | 1876 | |
| 1874 | 1877 | *ppos += read; |
| 1875 | 1878 | return read; |
| 1879 | +fail: | |
| 1880 | + trace_parser_fail(parser); | |
| 1881 | + return ret; | |
| 1876 | 1882 | } |
| 1877 | 1883 | |
| 1878 | 1884 | /* TODO add a seq_buf_to_buffer() */ |
| @@ -10632,10 +10638,10 @@ static void ftrace_dump_one(struct trace_array *tr, enum ftrace_dump_mode dump_m · 8753 unmodified lines | ||
| 10632 | 10638 | ret = print_trace_line(&iter); |
| 10633 | 10639 | if (ret != TRACE_TYPE_NO_CONSUME) |
| 10634 | 10640 | trace_consume(&iter); |
| 10641 | + | |
| 10642 | + trace_printk_seq(&iter.seq); | |
| 10635 | 10643 | } |
| 10636 | 10644 | touch_nmi_watchdog(); |
| 10637 | − | |
| 10638 | − trace_printk_seq(&iter.seq); | |
| 10639 | 10645 | } |
| 10640 | 10646 | |
| 10641 | 10647 | if (!cnt) |
| @@ -1292,6 +1292,7 @@ bool ftrace_event_is_function(struct trace_event_call *call); · 1291 unmodified lines | ||
| 1292 | 1292 | */ |
| 1293 | 1293 | struct trace_parser { |
| 1294 | 1294 | bool cont; |
| 1295 | + bool fail; | |
| 1295 | 1296 | char *buffer; |
| 1296 | 1297 | unsigned idx; |
| 1297 | 1298 | unsigned size; |
| @@ -1299,7 +1300,7 @@ struct trace_parser { · 1 unmodified line | ||
| 1299 | 1300 | |
| 1300 | 1301 | static inline bool trace_parser_loaded(struct trace_parser *parser) |
| 1301 | 1302 | { |
| 1302 | − return (parser->idx != 0); | |
| 1303 | + return !parser->fail && parser->idx != 0; | |
| 1303 | 1304 | } |
| 1304 | 1305 | |
| 1305 | 1306 | static inline bool trace_parser_cont(struct trace_parser *parser) |
| @@ -1313,6 +1314,11 @@ static inline void trace_parser_clear(struct trace_parser *parser) · 7 unmodified lines | ||
| 1313 | 1314 | parser->idx = 0; |
| 1314 | 1315 | } |
| 1315 | 1316 | |
| 1317 | +static inline void trace_parser_fail(struct trace_parser *parser) | |
| 1318 | +{ | |
| 1319 | + parser->fail = true; | |
| 1320 | +} | |
| 1321 | + | |
| 1316 | 1322 | extern int trace_parser_get_init(struct trace_parser *parser, int size); |
| 1317 | 1323 | extern void trace_parser_put(struct trace_parser *parser); |
| 1318 | 1324 | extern int trace_get_user(struct trace_parser *parser, const char __user *ubuf, |
| @@ -2204,7 +2210,7 @@ static inline bool is_good_system_name(const char *name) · 885 unmodified lines | ||
| 2204 | 2210 | static inline void sanitize_event_name(char *name) |
| 2205 | 2211 | { |
| 2206 | 2212 | while (*name++ != '\0') |
| 2207 | − if (*name == ':' || *name == '.') | |
| 2213 | + if (*name == ':' || *name == '.' || *name == '*') | |
| 2208 | 2214 | *name = '_'; |
| 2209 | 2215 | } |
| 2210 | 2216 | |
| @@ -27,14 +27,21 @@ struct fgraph_cpu_data { · 26 unmodified lines | ||
| 27 | 27 | unsigned long enter_funcs[FTRACE_RETFUNC_DEPTH]; |
| 28 | 28 | }; |
| 29 | 29 | |
| 30 | +struct fgraph_ent_args { | |
| 31 | + struct ftrace_graph_ent_entry ent; | |
| 32 | + /* Force the sizeof of args[] to have FTRACE_REGS_MAX_ARGS entries */ | |
| 33 | + unsigned long args[FTRACE_REGS_MAX_ARGS]; | |
| 34 | +}; | |
| 35 | + | |
| 30 | 36 | struct fgraph_data { |
| 31 | 37 | struct fgraph_cpu_data __percpu *cpu_data; |
| 32 | 38 | |
| 33 | 39 | /* Place to preserve last processed entry. */ |
| 34 | 40 | union { |
| 35 | − struct ftrace_graph_ent_entry ent; | |
| 41 | + struct fgraph_ent_args ent; | |
| 42 | + /* TODO allow retaddr to have args */ | |
| 36 | 43 | struct fgraph_retaddr_ent_entry rent; |
| 37 | − } ent; | |
| 44 | + }; | |
| 38 | 45 | struct ftrace_graph_ret_entry ret; |
| 39 | 46 | int failed; |
| 40 | 47 | int cpu; |
| @@ -627,10 +634,13 @@ get_return_for_leaf(struct trace_iterator *iter, · 586 unmodified lines | ||
| 627 | 634 | * Save current and next entries for later reference |
| 628 | 635 | * if the output fails. |
| 629 | 636 | */ |
| 630 | − if (unlikely(curr->ent.type == TRACE_GRAPH_RETADDR_ENT)) | |
| 631 | − data->ent.rent = *(struct fgraph_retaddr_ent_entry *)curr; | |
| 632 | − else | |
| 633 | − data->ent.ent = *curr; | |
| 637 | + if (unlikely(curr->ent.type == TRACE_GRAPH_RETADDR_ENT)) { | |
| 638 | + data->rent = *(struct fgraph_retaddr_ent_entry *)curr; | |
| 639 | + } else { | |
| 640 | + int size = min((int)sizeof(data->ent), (int)iter->ent_size); | |
| 641 | + | |
| 642 | + memcpy(&data->ent, curr, size); | |
| 643 | + } | |
| 634 | 644 | /* |
| 635 | 645 | * If the next event is not a return type, then |
| 636 | 646 | * we only care about what type it is. Otherwise we can |
| @@ -140,8 +140,8 @@ config CRYPTO_LIB_CHACHA20POLY1305 · 139 unmodified lines | ||
| 140 | 140 | config CRYPTO_LIB_SHA1 |
| 141 | 141 | tristate |
| 142 | 142 | help |
| 143 | − The SHA-1 library functions. Select this if your module uses any of | |
| 144 | − the functions from <crypto/sha1.h>. | |
| 143 | + The SHA-1 and HMAC-SHA1 library functions. Select this if your module | |
| 144 | + uses any of the functions from <crypto/sha1.h>. | |
| 145 | 145 | |
| 146 | 146 | config CRYPTO_LIB_SHA1_ARCH |
| 147 | 147 | bool |
| @@ -157,9 +157,9 @@ config CRYPTO_LIB_SHA1_ARCH · 9 unmodified lines | ||
| 157 | 157 | config CRYPTO_LIB_SHA256 |
| 158 | 158 | tristate |
| 159 | 159 | help |
| 160 | − Enable the SHA-256 library interface. This interface may be fulfilled | |
| 161 | − by either the generic implementation or an arch-specific one, if one | |
| 162 | − is available and enabled. | |
| 160 | + The SHA-224, SHA-256, HMAC-SHA224, and HMAC-SHA256 library functions. | |
| 161 | + Select this if your module uses any of these functions from | |
| 162 | + <crypto/sha2.h>. | |
| 163 | 163 | |
| 164 | 164 | config CRYPTO_LIB_SHA256_ARCH |
| 165 | 165 | bool |
| @@ -100,7 +100,6 @@ ifeq ($(CONFIG_ARM),y) · 99 unmodified lines | ||
| 100 | 100 | libsha256-y += arm/sha256-ce.o arm/sha256-core.o |
| 101 | 101 | $(obj)/arm/sha256-core.S: $(src)/arm/sha256-armv4.pl |
| 102 | 102 | $(call cmd,perlasm) |
| 103 | −clean-files += arm/sha256-core.S | |
| 104 | 103 | AFLAGS_arm/sha256-core.o += $(aflags-thumb2-y) |
| 105 | 104 | endif |
| 106 | 105 | |
| @@ -108,7 +107,6 @@ ifeq ($(CONFIG_ARM64),y) · 1 unmodified line | ||
| 108 | 107 | libsha256-y += arm64/sha256-core.o |
| 109 | 108 | $(obj)/arm64/sha256-core.S: $(src)/arm64/sha2-armv8.pl |
| 110 | 109 | $(call cmd,perlasm_with_args) |
| 111 | −clean-files += arm64/sha256-core.S | |
| 112 | 110 | libsha256-$(CONFIG_KERNEL_MODE_NEON) += arm64/sha256-ce.o |
| 113 | 111 | endif |
| 114 | 112 | |
| @@ -132,7 +130,6 @@ ifeq ($(CONFIG_ARM),y) · 17 unmodified lines | ||
| 132 | 130 | libsha512-y += arm/sha512-core.o |
| 133 | 131 | $(obj)/arm/sha512-core.S: $(src)/arm/sha512-armv4.pl |
| 134 | 132 | $(call cmd,perlasm) |
| 135 | −clean-files += arm/sha512-core.S | |
| 136 | 133 | AFLAGS_arm/sha512-core.o += $(aflags-thumb2-y) |
| 137 | 134 | endif |
| 138 | 135 | |
| @@ -140,7 +137,6 @@ ifeq ($(CONFIG_ARM64),y) · 1 unmodified line | ||
| 140 | 137 | libsha512-y += arm64/sha512-core.o |
| 141 | 138 | $(obj)/arm64/sha512-core.S: $(src)/arm64/sha2-armv8.pl |
| 142 | 139 | $(call cmd,perlasm_with_args) |
| 143 | −clean-files += arm64/sha512-core.S | |
| 144 | 140 | libsha512-$(CONFIG_KERNEL_MODE_NEON) += arm64/sha512-ce-core.o |
| 145 | 141 | endif |
| 146 | 142 | |
| @@ -167,3 +163,7 @@ obj-$(CONFIG_PPC) += powerpc/ · 20 unmodified lines | ||
| 167 | 163 | obj-$(CONFIG_RISCV) += riscv/ |
| 168 | 164 | obj-$(CONFIG_S390) += s390/ |
| 169 | 165 | obj-$(CONFIG_X86) += x86/ |
| 166 | + | |
| 167 | +# clean-files must be defined unconditionally | |
| 168 | +clean-files += arm/sha256-core.S arm/sha512-core.S | |
| 169 | +clean-files += arm64/sha256-core.S arm64/sha512-core.S | |
| @@ -254,4 +254,10 @@ const struct movable_operations balloon_mops = { · 253 unmodified lines | ||
| 254 | 254 | .putback_page = balloon_page_putback, |
| 255 | 255 | }; |
| 256 | 256 | |
| 257 | +static int __init balloon_init(void) | |
| 258 | +{ | |
| 259 | + return set_movable_ops(&balloon_mops, PGTY_offline); | |
| 260 | +} | |
| 261 | +core_initcall(balloon_init); | |
| 262 | + | |
| 257 | 263 | #endif /* CONFIG_BALLOON_COMPACTION */ |
| @@ -845,6 +845,18 @@ static struct damos_filter *damos_nth_filter(int n, struct damos *s) · 844 unmodified lines | ||
| 845 | 845 | return NULL; |
| 846 | 846 | } |
| 847 | 847 | |
| 848 | +static struct damos_filter *damos_nth_ops_filter(int n, struct damos *s) | |
| 849 | +{ | |
| 850 | + struct damos_filter *filter; | |
| 851 | + int i = 0; | |
| 852 | + | |
| 853 | + damos_for_each_ops_filter(filter, s) { | |
| 854 | + if (i++ == n) | |
| 855 | + return filter; | |
| 856 | + } | |
| 857 | + return NULL; | |
| 858 | +} | |
| 859 | + | |
| 848 | 860 | static void damos_commit_filter_arg( |
| 849 | 861 | struct damos_filter *dst, struct damos_filter *src) |
| 850 | 862 | { |
| @@ -871,6 +883,7 @@ static void damos_commit_filter( · 20 unmodified lines | ||
| 871 | 883 | { |
| 872 | 884 | dst->type = src->type; |
| 873 | 885 | dst->matching = src->matching; |
| 886 | + dst->allow = src->allow; | |
| 874 | 887 | damos_commit_filter_arg(dst, src); |
| 875 | 888 | } |
| 876 | 889 | |
| @@ -908,7 +921,7 @@ static int damos_commit_ops_filters(struct damos *dst, struct damos *src) · 31 unmodified lines | ||
| 908 | 921 | int i = 0, j = 0; |
| 909 | 922 | |
| 910 | 923 | damos_for_each_ops_filter_safe(dst_filter, next, dst) { |
| 911 | − src_filter = damos_nth_filter(i++, src); | |
| 924 | + src_filter = damos_nth_ops_filter(i++, src); | |
| 912 | 925 | if (src_filter) |
| 913 | 926 | damos_commit_filter(dst_filter, src_filter); |
| 914 | 927 | else |
| @@ -2158,8 +2158,8 @@ static void damon_sysfs_scheme_rm_dirs(struct damon_sysfs_scheme *scheme) · 2157 unmodified lines | ||
| 2158 | 2158 | { |
| 2159 | 2159 | damon_sysfs_access_pattern_rm_dirs(scheme->access_pattern); |
| 2160 | 2160 | kobject_put(&scheme->access_pattern->kobj); |
| 2161 | − kobject_put(&scheme->dests->kobj); | |
| 2162 | 2161 | damos_sysfs_dests_rm_dirs(scheme->dests); |
| 2162 | + kobject_put(&scheme->dests->kobj); | |
| 2163 | 2163 | damon_sysfs_quotas_rm_dirs(scheme->quotas); |
| 2164 | 2164 | kobject_put(&scheme->quotas->kobj); |
| 2165 | 2165 | kobject_put(&scheme->watermarks->kobj); |
| @@ -990,29 +990,34 @@ static void __init destroy_args(struct pgtable_debug_args *args) · 989 unmodified lines | ||
| 990 | 990 | |
| 991 | 991 | /* Free page table entries */ |
| 992 | 992 | if (args->start_ptep) { |
| 993 | + pmd_clear(args->pmdp); | |
| 993 | 994 | pte_free(args->mm, args->start_ptep); |
| 994 | 995 | mm_dec_nr_ptes(args->mm); |
| 995 | 996 | } |
| 996 | 997 | |
| 997 | 998 | if (args->start_pmdp) { |
| 999 | + pud_clear(args->pudp); | |
| 998 | 1000 | pmd_free(args->mm, args->start_pmdp); |
| 999 | 1001 | mm_dec_nr_pmds(args->mm); |
| 1000 | 1002 | } |
| 1001 | 1003 | |
| 1002 | 1004 | if (args->start_pudp) { |
| 1005 | + p4d_clear(args->p4dp); | |
| 1003 | 1006 | pud_free(args->mm, args->start_pudp); |
| 1004 | 1007 | mm_dec_nr_puds(args->mm); |
| 1005 | 1008 | } |
| 1006 | 1009 | |
| 1007 | − if (args->start_p4dp) | |
| 1010 | + if (args->start_p4dp) { | |
| 1011 | + pgd_clear(args->pgdp); | |
| 1008 | 1012 | p4d_free(args->mm, args->start_p4dp); |
| 1013 | + } | |
| 1009 | 1014 | |
| 1010 | 1015 | /* Free vma and mm struct */ |
| 1011 | 1016 | if (args->vma) |
| 1012 | 1017 | vm_area_free(args->vma); |
| 1013 | 1018 | |
| 1014 | 1019 | if (args->mm) |
| 1015 | − mmdrop(args->mm); | |
| 1020 | + mmput(args->mm); | |
| 1016 | 1021 | } |
| 1017 | 1022 | |
| 1018 | 1023 | static struct page * __init |
| @@ -853,9 +853,17 @@ static int hwpoison_hugetlb_range(pte_t *ptep, unsigned long hmask, · 852 unmodified lines | ||
| 853 | 853 | #define hwpoison_hugetlb_range NULL |
| 854 | 854 | #endif |
| 855 | 855 | |
| 856 | +static int hwpoison_test_walk(unsigned long start, unsigned long end, | |
| 857 | + struct mm_walk *walk) | |
| 858 | +{ | |
| 859 | + /* We also want to consider pages mapped into VM_PFNMAP. */ | |
| 860 | + return 0; | |
| 861 | +} | |
| 862 | + | |
| 856 | 863 | static const struct mm_walk_ops hwpoison_walk_ops = { |
| 857 | 864 | .pmd_entry = hwpoison_pte_range, |
| 858 | 865 | .hugetlb_entry = hwpoison_hugetlb_range, |
| 866 | + .test_walk = hwpoison_test_walk, | |
| 859 | 867 | .walk_lock = PGWALK_RDLOCK, |
| 860 | 868 | }; |
| 861 | 869 | |
| @@ -43,8 +43,6 @@ · 42 unmodified lines | ||
| 43 | 43 | #include <linux/sched/sysctl.h> |
| 44 | 44 | #include <linux/memory-tiers.h> |
| 45 | 45 | #include <linux/pagewalk.h> |
| 46 | −#include <linux/balloon_compaction.h> | |
| 47 | −#include <linux/zsmalloc.h> | |
| 48 | 46 | |
| 49 | 47 | #include <asm/tlbflush.h> |
| 50 | 48 | |
| @@ -53,6 +51,33 @@ · 2 unmodified lines | ||
| 53 | 51 | #include "internal.h" |
| 54 | 52 | #include "swap.h" |
| 55 | 53 | |
| 54 | +static const struct movable_operations *offline_movable_ops; | |
| 55 | +static const struct movable_operations *zsmalloc_movable_ops; | |
| 56 | + | |
| 57 | +int set_movable_ops(const struct movable_operations *ops, enum pagetype type) | |
| 58 | +{ | |
| 59 | + /* | |
| 60 | + * We only allow for selected types and don't handle concurrent | |
| 61 | + * registration attempts yet. | |
| 62 | + */ | |
| 63 | + switch (type) { | |
| 64 | + case PGTY_offline: | |
| 65 | + if (offline_movable_ops && ops) | |
| 66 | + return -EBUSY; | |
| 67 | + offline_movable_ops = ops; | |
| 68 | + break; | |
| 69 | + case PGTY_zsmalloc: | |
| 70 | + if (zsmalloc_movable_ops && ops) | |
| 71 | + return -EBUSY; | |
| 72 | + zsmalloc_movable_ops = ops; | |
| 73 | + break; | |
| 74 | + default: | |
| 75 | + return -EINVAL; | |
| 76 | + } | |
| 77 | + return 0; | |
| 78 | +} | |
| 79 | +EXPORT_SYMBOL_GPL(set_movable_ops); | |
| 80 | + | |
| 56 | 81 | static const struct movable_operations *page_movable_ops(struct page *page) |
| 57 | 82 | { |
| 58 | 83 | VM_WARN_ON_ONCE_PAGE(!page_has_movable_ops(page), page); |
| @@ -62,15 +87,12 @@ static const struct movable_operations *page_movable_ops(struct page *page) · 3 unmodified lines | ||
| 62 | 87 | * it as movable, the page type must be sticky until the page gets freed |
| 63 | 88 | * back to the buddy. |
| 64 | 89 | */ |
| 65 | −#ifdef CONFIG_BALLOON_COMPACTION | |
| 66 | 90 | if (PageOffline(page)) |
| 67 | 91 | /* Only balloon compaction sets PageOffline pages movable. */ |
| 68 | − return &balloon_mops; | |
| 69 | −#endif /* CONFIG_BALLOON_COMPACTION */ | |
| 70 | −#if defined(CONFIG_ZSMALLOC) && defined(CONFIG_COMPACTION) | |
| 92 | + return offline_movable_ops; | |
| 71 | 93 | if (PageZsmalloc(page)) |
| 72 | − return &zsmalloc_mops; | |
| 73 | −#endif /* defined(CONFIG_ZSMALLOC) && defined(CONFIG_COMPACTION) */ | |
| 94 | + return zsmalloc_movable_ops; | |
| 95 | + | |
| 74 | 96 | return NULL; |
| 75 | 97 | } |
| 76 | 98 | |
| @@ -323,6 +323,25 @@ static inline bool arch_supports_page_table_move(void) · 322 unmodified lines | ||
| 323 | 323 | } |
| 324 | 324 | #endif |
| 325 | 325 | |
| 326 | +static inline bool uffd_supports_page_table_move(struct pagetable_move_control *pmc) | |
| 327 | +{ | |
| 328 | + /* | |
| 329 | + * If we are moving a VMA that has uffd-wp registered but with | |
| 330 | + * remap events disabled (new VMA will not be registered with uffd), we | |
| 331 | + * need to ensure that the uffd-wp state is cleared from all pgtables. | |
| 332 | + * This means recursing into lower page tables in move_page_tables(). | |
| 333 | + * | |
| 334 | + * We might get called with VMAs reversed when recovering from a | |
| 335 | + * failed page table move. In that case, the | |
| 336 | + * "old"-but-actually-"originally new" VMA during recovery will not have | |
| 337 | + * a uffd context. Recursing into lower page tables during the original | |
| 338 | + * move but not during the recovery move will cause trouble, because we | |
| 339 | + * run into already-existing page tables. So check both VMAs. | |
| 340 | + */ | |
| 341 | + return !vma_has_uffd_without_event_remap(pmc->old) && | |
| 342 | + !vma_has_uffd_without_event_remap(pmc->new); | |
| 343 | +} | |
| 344 | + | |
| 326 | 345 | #ifdef CONFIG_HAVE_MOVE_PMD |
| 327 | 346 | static bool move_normal_pmd(struct pagetable_move_control *pmc, |
| 328 | 347 | pmd_t *old_pmd, pmd_t *new_pmd) |
| @@ -335,6 +354,8 @@ static bool move_normal_pmd(struct pagetable_move_control *pmc, · 6 unmodified lines | ||
| 335 | 354 | |
| 336 | 355 | if (!arch_supports_page_table_move()) |
| 337 | 356 | return false; |
| 357 | + if (!uffd_supports_page_table_move(pmc)) | |
| 358 | + return false; | |
| 338 | 359 | /* |
| 339 | 360 | * The destination pmd shouldn't be established, free_pgtables() |
| 340 | 361 | * should have released it. |
| @@ -361,15 +382,6 @@ static bool move_normal_pmd(struct pagetable_move_control *pmc, · 20 unmodified lines | ||
| 361 | 382 | if (WARN_ON_ONCE(!pmd_none(*new_pmd))) |
| 362 | 383 | return false; |
| 363 | 384 | |
| 364 | − /* If this pmd belongs to a uffd vma with remap events disabled, we need | |
| 365 | − * to ensure that the uffd-wp state is cleared from all pgtables. This | |
| 366 | − * means recursing into lower page tables in move_page_tables(), and we | |
| 367 | − * can reuse the existing code if we simply treat the entry as "not | |
| 368 | − * moved". | |
| 369 | − */ | |
| 370 | − if (vma_has_uffd_without_event_remap(vma)) | |
| 371 | − return false; | |
| 372 | − | |
| 373 | 385 | /* |
| 374 | 386 | * We don't have to worry about the ordering of src and dst |
| 375 | 387 | * ptlocks because exclusive mmap_lock prevents deadlock. |
| @@ -418,6 +430,8 @@ static bool move_normal_pud(struct pagetable_move_control *pmc, · 42 unmodified lines | ||
| 418 | 430 | |
| 419 | 431 | if (!arch_supports_page_table_move()) |
| 420 | 432 | return false; |
| 433 | + if (!uffd_supports_page_table_move(pmc)) | |
| 434 | + return false; | |
| 421 | 435 | /* |
| 422 | 436 | * The destination pud shouldn't be established, free_pgtables() |
| 423 | 437 | * should have released it. |
| @@ -425,15 +439,6 @@ static bool move_normal_pud(struct pagetable_move_control *pmc, · 1 unmodified line | ||
| 425 | 439 | if (WARN_ON_ONCE(!pud_none(*new_pud))) |
| 426 | 440 | return false; |
| 427 | 441 | |
| 428 | − /* If this pud belongs to a uffd vma with remap events disabled, we need | |
| 429 | − * to ensure that the uffd-wp state is cleared from all pgtables. This | |
| 430 | − * means recursing into lower page tables in move_page_tables(), and we | |
| 431 | − * can reuse the existing code if we simply treat the entry as "not | |
| 432 | − * moved". | |
| 433 | − */ | |
| 434 | − if (vma_has_uffd_without_event_remap(vma)) | |
| 435 | − return false; | |
| 436 | − | |
| 437 | 442 | /* |
| 438 | 443 | * We don't have to worry about the ordering of src and dst |
| 439 | 444 | * ptlocks because exclusive mmap_lock prevents deadlock. |
| @@ -1620,7 +1625,7 @@ static void notify_uffd(struct vma_remap_struct *vrm, bool failed) · 1180 unmodified lines | ||
| 1620 | 1625 | |
| 1621 | 1626 | static bool vma_multi_allowed(struct vm_area_struct *vma) |
| 1622 | 1627 | { |
| 1623 | − struct file *file; | |
| 1628 | + struct file *file = vma->vm_file; | |
| 1624 | 1629 | |
| 1625 | 1630 | /* |
| 1626 | 1631 | * We can't support moving multiple uffd VMAs as notify requires |
| @@ -1633,15 +1638,17 @@ static bool vma_multi_allowed(struct vm_area_struct *vma) · 6 unmodified lines | ||
| 1633 | 1638 | * Custom get unmapped area might result in MREMAP_FIXED not |
| 1634 | 1639 | * being obeyed. |
| 1635 | 1640 | */ |
| 1636 | − file = vma->vm_file; | |
| 1637 | − if (file && !vma_is_shmem(vma) && !is_vm_hugetlb_page(vma)) { | |
| 1638 | − const struct file_operations *fop = file->f_op; | |
| 1639 | − | |
| 1640 | − if (fop->get_unmapped_area) | |
| 1641 | − return false; | |
| 1642 | − } | |
| 1641 | + if (!file || !file->f_op->get_unmapped_area) | |
| 1642 | + return true; | |
| 1643 | + /* Known good. */ | |
| 1644 | + if (vma_is_shmem(vma)) | |
| 1645 | + return true; | |
| 1646 | + if (is_vm_hugetlb_page(vma)) | |
| 1647 | + return true; | |
| 1648 | + if (file->f_op->get_unmapped_area == thp_get_unmapped_area) | |
| 1649 | + return true; | |
| 1643 | 1650 | |
| 1644 | − return true; | |
| 1651 | + return false; | |
| 1645 | 1652 | } |
| 1646 | 1653 | |
| 1647 | 1654 | static int check_prep_vma(struct vma_remap_struct *vrm) |
| @@ -1818,10 +1825,11 @@ static unsigned long remap_move(struct vma_remap_struct *vrm) · 170 unmodified lines | ||
| 1818 | 1825 | unsigned long start = vrm->addr; |
| 1819 | 1826 | unsigned long end = vrm->addr + vrm->old_len; |
| 1820 | 1827 | unsigned long new_addr = vrm->new_addr; |
| 1821 | − bool allowed = true, seen_vma = false; | |
| 1822 | 1828 | unsigned long target_addr = new_addr; |
| 1823 | 1829 | unsigned long res = -EFAULT; |
| 1824 | 1830 | unsigned long last_end; |
| 1831 | + bool seen_vma = false; | |
| 1832 | + | |
| 1825 | 1833 | VMA_ITERATOR(vmi, current->mm, start); |
| 1826 | 1834 | |
| 1827 | 1835 | /* |
| @@ -1834,9 +1842,7 @@ static unsigned long remap_move(struct vma_remap_struct *vrm) · 6 unmodified lines | ||
| 1834 | 1842 | unsigned long addr = max(vma->vm_start, start); |
| 1835 | 1843 | unsigned long len = min(end, vma->vm_end) - addr; |
| 1836 | 1844 | unsigned long offset, res_vma; |
| 1837 | − | |
| 1838 | − if (!allowed) | |
| 1839 | − return -EFAULT; | |
| 1845 | + bool multi_allowed; | |
| 1840 | 1846 | |
| 1841 | 1847 | /* No gap permitted at the start of the range. */ |
| 1842 | 1848 | if (!seen_vma && start < vma->vm_start) |
| @@ -1865,9 +1871,15 @@ static unsigned long remap_move(struct vma_remap_struct *vrm) · 22 unmodified lines | ||
| 1865 | 1871 | vrm->new_addr = target_addr + offset; |
| 1866 | 1872 | vrm->old_len = vrm->new_len = len; |
| 1867 | 1873 | |
| 1868 | − allowed = vma_multi_allowed(vma); | |
| 1869 | − if (seen_vma && !allowed) | |
| 1870 | − return -EFAULT; | |
| 1874 | + multi_allowed = vma_multi_allowed(vma); | |
| 1875 | + if (!multi_allowed) { | |
| 1876 | + /* This is not the first VMA, abort immediately. */ | |
| 1877 | + if (seen_vma) | |
| 1878 | + return -EFAULT; | |
| 1879 | + /* This is the first, but there are more, abort. */ | |
| 1880 | + if (vma->vm_end < end) | |
| 1881 | + return -EFAULT; | |
| 1882 | + } | |
| 1871 | 1883 | |
| 1872 | 1884 | res_vma = check_prep_vma(vrm); |
| 1873 | 1885 | if (!res_vma) |
| @@ -1876,7 +1888,7 @@ static unsigned long remap_move(struct vma_remap_struct *vrm) · 2 unmodified lines | ||
| 1876 | 1888 | return res_vma; |
| 1877 | 1889 | |
| 1878 | 1890 | if (!seen_vma) { |
| 1879 | − VM_WARN_ON_ONCE(allowed && res_vma != new_addr); | |
| 1891 | + VM_WARN_ON_ONCE(multi_allowed && res_vma != new_addr); | |
| 1880 | 1892 | res = res_vma; |
| 1881 | 1893 | } |
| 1882 | 1894 | |
| @@ -5772,9 +5772,9 @@ static int __init init_lru_gen(void) · 5771 unmodified lines | ||
| 5772 | 5772 | if (sysfs_create_group(mm_kobj, &lru_gen_attr_group)) |
| 5773 | 5773 | pr_err("lru_gen: failed to create sysfs group\n"); |
| 5774 | 5774 | |
| 5775 | − debugfs_create_file_aux_num("lru_gen", 0644, NULL, NULL, 1, | |
| 5775 | + debugfs_create_file_aux_num("lru_gen", 0644, NULL, NULL, false, | |
| 5776 | 5776 | &lru_gen_rw_fops); |
| 5777 | − debugfs_create_file_aux_num("lru_gen_full", 0444, NULL, NULL, 0, | |
| 5777 | + debugfs_create_file_aux_num("lru_gen_full", 0444, NULL, NULL, true, | |
| 5778 | 5778 | &lru_gen_ro_fops); |
| 5779 | 5779 | |
| 5780 | 5780 | return 0; |
| @@ -2246,8 +2246,15 @@ EXPORT_SYMBOL_GPL(zs_destroy_pool); · 2245 unmodified lines | ||
| 2246 | 2246 | |
| 2247 | 2247 | static int __init zs_init(void) |
| 2248 | 2248 | { |
| 2249 | + int rc __maybe_unused; | |
| 2250 | + | |
| 2249 | 2251 | #ifdef CONFIG_ZPOOL |
| 2250 | 2252 | zpool_register_driver(&zs_zpool_driver); |
| 2253 | +#endif | |
| 2254 | +#ifdef CONFIG_COMPACTION | |
| 2255 | + rc = set_movable_ops(&zsmalloc_mops, PGTY_zsmalloc); | |
| 2256 | + if (rc) | |
| 2257 | + return rc; | |
| 2251 | 2258 | #endif |
| 2252 | 2259 | zs_stat_init(); |
| 2253 | 2260 | return 0; |
| @@ -2257,6 +2264,9 @@ static void __exit zs_exit(void) · 3 unmodified lines | ||
| 2257 | 2264 | { |
| 2258 | 2265 | #ifdef CONFIG_ZPOOL |
| 2259 | 2266 | zpool_unregister_driver(&zs_zpool_driver); |
| 2267 | +#endif | |
| 2268 | +#ifdef CONFIG_COMPACTION | |
| 2269 | + set_movable_ops(NULL, PGTY_zsmalloc); | |
| 2260 | 2270 | #endif |
| 2261 | 2271 | zs_stat_exit(); |
| 2262 | 2272 | } |
| @@ -339,7 +339,8 @@ static int hci_enhanced_setup_sync(struct hci_dev *hdev, void *data) · 338 unmodified lines | ||
| 339 | 339 | case BT_CODEC_TRANSPARENT: |
| 340 | 340 | if (!find_next_esco_param(conn, esco_param_msbc, |
| 341 | 341 | ARRAY_SIZE(esco_param_msbc))) |
| 342 | − return false; | |
| 342 | + return -EINVAL; | |
| 343 | + | |
| 343 | 344 | param = &esco_param_msbc[conn->attempt - 1]; |
| 344 | 345 | cp.tx_coding_format.id = 0x03; |
| 345 | 346 | cp.rx_coding_format.id = 0x03; |
| @@ -830,7 +831,17 @@ static void bis_cleanup(struct hci_conn *conn) · 484 unmodified lines | ||
| 830 | 831 | /* Check if ISO connection is a BIS and terminate advertising |
| 831 | 832 | * set and BIG if there are no other connections using it. |
| 832 | 833 | */ |
| 833 | − bis = hci_conn_hash_lookup_big(hdev, conn->iso_qos.bcast.big); | |
| 834 | + bis = hci_conn_hash_lookup_big_state(hdev, | |
| 835 | + conn->iso_qos.bcast.big, | |
| 836 | + BT_CONNECTED, | |
| 837 | + HCI_ROLE_MASTER); | |
| 838 | + if (bis) | |
| 839 | + return; | |
| 840 | + | |
| 841 | + bis = hci_conn_hash_lookup_big_state(hdev, | |
| 842 | + conn->iso_qos.bcast.big, | |
| 843 | + BT_CONNECT, | |
| 844 | + HCI_ROLE_MASTER); | |
| 834 | 845 | if (bis) |
| 835 | 846 | return; |
| 836 | 847 | |
| @@ -2249,7 +2260,7 @@ struct hci_conn *hci_connect_bis(struct hci_dev *hdev, bdaddr_t *dst, · 1412 unmodified lines | ||
| 2249 | 2260 | * the start periodic advertising and create BIG commands have |
| 2250 | 2261 | * been queued |
| 2251 | 2262 | */ |
| 2252 | − hci_conn_hash_list_state(hdev, bis_mark_per_adv, PA_LINK, | |
| 2263 | + hci_conn_hash_list_state(hdev, bis_mark_per_adv, BIS_LINK, | |
| 2253 | 2264 | BT_BOUND, &data); |
| 2254 | 2265 | |
| 2255 | 2266 | /* Queue start periodic advertising and create BIG */ |
| @@ -6745,8 +6745,8 @@ static void hci_le_cis_established_evt(struct hci_dev *hdev, void *data, · 6744 unmodified lines | ||
| 6745 | 6745 | qos->ucast.out.latency = |
| 6746 | 6746 | DIV_ROUND_CLOSEST(get_unaligned_le24(ev->p_latency), |
| 6747 | 6747 | 1000); |
| 6748 | − qos->ucast.in.sdu = le16_to_cpu(ev->c_mtu); | |
| 6749 | − qos->ucast.out.sdu = le16_to_cpu(ev->p_mtu); | |
| 6748 | + qos->ucast.in.sdu = ev->c_bn ? le16_to_cpu(ev->c_mtu) : 0; | |
| 6749 | + qos->ucast.out.sdu = ev->p_bn ? le16_to_cpu(ev->p_mtu) : 0; | |
| 6750 | 6750 | qos->ucast.in.phy = ev->c_phy; |
| 6751 | 6751 | qos->ucast.out.phy = ev->p_phy; |
| 6752 | 6752 | break; |
| @@ -6760,8 +6760,8 @@ static void hci_le_cis_established_evt(struct hci_dev *hdev, void *data, · 7 unmodified lines | ||
| 6760 | 6760 | qos->ucast.in.latency = |
| 6761 | 6761 | DIV_ROUND_CLOSEST(get_unaligned_le24(ev->p_latency), |
| 6762 | 6762 | 1000); |
| 6763 | − qos->ucast.out.sdu = le16_to_cpu(ev->c_mtu); | |
| 6764 | − qos->ucast.in.sdu = le16_to_cpu(ev->p_mtu); | |
| 6763 | + qos->ucast.out.sdu = ev->c_bn ? le16_to_cpu(ev->c_mtu) : 0; | |
| 6764 | + qos->ucast.in.sdu = ev->p_bn ? le16_to_cpu(ev->p_mtu) : 0; | |
| 6765 | 6765 | qos->ucast.out.phy = ev->c_phy; |
| 6766 | 6766 | qos->ucast.in.phy = ev->p_phy; |
| 6767 | 6767 | break; |
| @@ -6957,9 +6957,14 @@ static void hci_le_big_sync_established_evt(struct hci_dev *hdev, void *data, · 189 unmodified lines | ||
| 6957 | 6957 | continue; |
| 6958 | 6958 | } |
| 6959 | 6959 | |
| 6960 | − if (ev->status != 0x42) | |
| 6960 | + if (ev->status != 0x42) { | |
| 6961 | 6961 | /* Mark PA sync as established */ |
| 6962 | 6962 | set_bit(HCI_CONN_PA_SYNC, &bis->flags); |
| 6963 | + /* Reset cleanup callback of PA Sync so it doesn't | |
| 6964 | + * terminate the sync when deleting the connection. | |
| 6965 | + */ | |
| 6966 | + conn->cleanup = NULL; | |
| 6967 | + } | |
| 6963 | 6968 | |
| 6964 | 6969 | bis->sync_handle = conn->sync_handle; |
| 6965 | 6970 | bis->iso_qos.bcast.big = ev->handle; |
| @@ -3344,7 +3344,7 @@ static int hci_powered_update_adv_sync(struct hci_dev *hdev) · 3343 unmodified lines | ||
| 3344 | 3344 | * advertising data. This also applies to the case |
| 3345 | 3345 | * where BR/EDR was toggled during the AUTO_OFF phase. |
| 3346 | 3346 | */ |
| 3347 | − if (hci_dev_test_flag(hdev, HCI_ADVERTISING) || | |
| 3347 | + if (hci_dev_test_flag(hdev, HCI_ADVERTISING) && | |
| 3348 | 3348 | list_empty(&hdev->adv_instances)) { |
| 3349 | 3349 | if (ext_adv_capable(hdev)) { |
| 3350 | 3350 | err = hci_setup_ext_adv_instance_sync(hdev, 0x00); |
| @@ -4531,14 +4531,14 @@ static int hci_le_set_host_feature_sync(struct hci_dev *hdev) · 1180 unmodified lines | ||
| 4531 | 4531 | { |
| 4532 | 4532 | struct hci_cp_le_set_host_feature cp; |
| 4533 | 4533 | |
| 4534 | − if (!cis_capable(hdev)) | |
| 4534 | + if (!iso_capable(hdev)) | |
| 4535 | 4535 | return 0; |
| 4536 | 4536 | |
| 4537 | 4537 | memset(&cp, 0, sizeof(cp)); |
| 4538 | 4538 | |
| 4539 | 4539 | /* Connected Isochronous Channels (Host Support) */ |
| 4540 | 4540 | cp.bit_number = 32; |
| 4541 | − cp.bit_value = 1; | |
| 4541 | + cp.bit_value = iso_enabled(hdev) ? 0x01 : 0x00; | |
| 4542 | 4542 | |
| 4543 | 4543 | return __hci_cmd_sync_status(hdev, HCI_OP_LE_SET_HOST_FEATURE, |
| 4544 | 4544 | sizeof(cp), &cp, HCI_CMD_TIMEOUT); |
| @@ -6985,8 +6985,6 @@ static void create_pa_complete(struct hci_dev *hdev, void *data, int err) · 2440 unmodified lines | ||
| 6985 | 6985 | |
| 6986 | 6986 | hci_dev_lock(hdev); |
| 6987 | 6987 | |
| 6988 | − hci_dev_clear_flag(hdev, HCI_PA_SYNC); | |
| 6989 | − | |
| 6990 | 6988 | if (!hci_conn_valid(hdev, conn)) |
| 6991 | 6989 | clear_bit(HCI_CONN_CREATE_PA_SYNC, &conn->flags); |
| 6992 | 6990 | |
| @@ -7047,10 +7045,13 @@ static int hci_le_pa_create_sync(struct hci_dev *hdev, void *data) · 54 unmodified lines | ||
| 7047 | 7045 | /* SID has not been set listen for HCI_EV_LE_EXT_ADV_REPORT to update |
| 7048 | 7046 | * it. |
| 7049 | 7047 | */ |
| 7050 | − if (conn->sid == HCI_SID_INVALID) | |
| 7051 | − __hci_cmd_sync_status_sk(hdev, HCI_OP_NOP, 0, NULL, | |
| 7052 | − HCI_EV_LE_EXT_ADV_REPORT, | |
| 7053 | − conn->conn_timeout, NULL); | |
| 7048 | + if (conn->sid == HCI_SID_INVALID) { | |
| 7049 | + err = __hci_cmd_sync_status_sk(hdev, HCI_OP_NOP, 0, NULL, | |
| 7050 | + HCI_EV_LE_EXT_ADV_REPORT, | |
| 7051 | + conn->conn_timeout, NULL); | |
| 7052 | + if (err == -ETIMEDOUT) | |
| 7053 | + goto done; | |
| 7054 | + } | |
| 7054 | 7055 | |
| 7055 | 7056 | memset(&cp, 0, sizeof(cp)); |
| 7056 | 7057 | cp.options = qos->bcast.options; |
| @@ -7080,6 +7081,12 @@ static int hci_le_pa_create_sync(struct hci_dev *hdev, void *data) · 23 unmodified lines | ||
| 7080 | 7081 | __hci_cmd_sync_status(hdev, HCI_OP_LE_PA_CREATE_SYNC_CANCEL, |
| 7081 | 7082 | 0, NULL, HCI_CMD_TIMEOUT); |
| 7082 | 7083 | |
| 7084 | +done: | |
| 7085 | + hci_dev_clear_flag(hdev, HCI_PA_SYNC); | |
| 7086 | + | |
| 7087 | + /* Update passive scan since HCI_PA_SYNC flag has been cleared */ | |
| 7088 | + hci_update_passive_scan_sync(hdev); | |
| 7089 | + | |
| 7083 | 7090 | return err; |
| 7084 | 7091 | } |
| 7085 | 7092 | |
| @@ -1347,7 +1347,7 @@ static int iso_sock_getname(struct socket *sock, struct sockaddr *addr, · 1346 unmodified lines | ||
| 1347 | 1347 | bacpy(&sa->iso_bdaddr, &iso_pi(sk)->dst); |
| 1348 | 1348 | sa->iso_bdaddr_type = iso_pi(sk)->dst_type; |
| 1349 | 1349 | |
| 1350 | − if (hcon && hcon->type == BIS_LINK) { | |
| 1350 | + if (hcon && (hcon->type == BIS_LINK || hcon->type == PA_LINK)) { | |
| 1351 | 1351 | sa->iso_bc->bc_sid = iso_pi(sk)->bc_sid; |
| 1352 | 1352 | sa->iso_bc->bc_num_bis = iso_pi(sk)->bc_num_bis; |
| 1353 | 1353 | memcpy(sa->iso_bc->bc_bis, iso_pi(sk)->bc_bis, |
| @@ -2483,11 +2483,11 @@ static const struct net_proto_family iso_sock_family_ops = { · 1129 unmodified lines | ||
| 2483 | 2483 | .create = iso_sock_create, |
| 2484 | 2484 | }; |
| 2485 | 2485 | |
| 2486 | −static bool iso_inited; | |
| 2486 | +static bool inited; | |
| 2487 | 2487 | |
| 2488 | −bool iso_enabled(void) | |
| 2488 | +bool iso_inited(void) | |
| 2489 | 2489 | { |
| 2490 | − return iso_inited; | |
| 2490 | + return inited; | |
| 2491 | 2491 | } |
| 2492 | 2492 | |
| 2493 | 2493 | int iso_init(void) |
| @@ -2496,7 +2496,7 @@ int iso_init(void) · 2 unmodified lines | ||
| 2496 | 2496 | |
| 2497 | 2497 | BUILD_BUG_ON(sizeof(struct sockaddr_iso) > sizeof(struct sockaddr)); |
| 2498 | 2498 | |
| 2499 | − if (iso_inited) | |
| 2499 | + if (inited) | |
| 2500 | 2500 | return -EALREADY; |
| 2501 | 2501 | |
| 2502 | 2502 | err = proto_register(&iso_proto, 0); |
| @@ -2524,7 +2524,7 @@ int iso_init(void) · 21 unmodified lines | ||
| 2524 | 2524 | iso_debugfs = debugfs_create_file("iso", 0444, bt_debugfs, |
| 2525 | 2525 | NULL, &iso_debugfs_fops); |
| 2526 | 2526 | |
| 2527 | − iso_inited = true; | |
| 2527 | + inited = true; | |
| 2528 | 2528 | |
| 2529 | 2529 | return 0; |
| 2530 | 2530 | |
| @@ -2535,7 +2535,7 @@ error: · 4 unmodified lines | ||
| 2535 | 2535 | |
| 2536 | 2536 | int iso_exit(void) |
| 2537 | 2537 | { |
| 2538 | − if (!iso_inited) | |
| 2538 | + if (!inited) | |
| 2539 | 2539 | return -EALREADY; |
| 2540 | 2540 | |
| 2541 | 2541 | bt_procfs_cleanup(&init_net, "iso"); |
| @@ -2549,7 +2549,7 @@ int iso_exit(void) · 7 unmodified lines | ||
| 2549 | 2549 | |
| 2550 | 2550 | proto_unregister(&iso_proto); |
| 2551 | 2551 | |
| 2552 | − iso_inited = false; | |
| 2552 | + inited = false; | |
| 2553 | 2553 | |
| 2554 | 2554 | return 0; |
| 2555 | 2555 | } |
| @@ -922,19 +922,19 @@ static u32 get_current_settings(struct hci_dev *hdev) · 921 unmodified lines | ||
| 922 | 922 | if (hci_dev_test_flag(hdev, HCI_WIDEBAND_SPEECH_ENABLED)) |
| 923 | 923 | settings |= MGMT_SETTING_WIDEBAND_SPEECH; |
| 924 | 924 | |
| 925 | − if (cis_central_capable(hdev)) | |
| 925 | + if (cis_central_enabled(hdev)) | |
| 926 | 926 | settings |= MGMT_SETTING_CIS_CENTRAL; |
| 927 | 927 | |
| 928 | − if (cis_peripheral_capable(hdev)) | |
| 928 | + if (cis_peripheral_enabled(hdev)) | |
| 929 | 929 | settings |= MGMT_SETTING_CIS_PERIPHERAL; |
| 930 | 930 | |
| 931 | − if (bis_capable(hdev)) | |
| 931 | + if (bis_enabled(hdev)) | |
| 932 | 932 | settings |= MGMT_SETTING_ISO_BROADCASTER; |
| 933 | 933 | |
| 934 | − if (sync_recv_capable(hdev)) | |
| 934 | + if (sync_recv_enabled(hdev)) | |
| 935 | 935 | settings |= MGMT_SETTING_ISO_SYNC_RECEIVER; |
| 936 | 936 | |
| 937 | − if (ll_privacy_capable(hdev)) | |
| 937 | + if (ll_privacy_enabled(hdev)) | |
| 938 | 938 | settings |= MGMT_SETTING_LL_PRIVACY; |
| 939 | 939 | |
| 940 | 940 | return settings; |
| @@ -4513,7 +4513,7 @@ static int read_exp_features_info(struct sock *sk, struct hci_dev *hdev, · 3572 unmodified lines | ||
| 4513 | 4513 | } |
| 4514 | 4514 | |
| 4515 | 4515 | if (IS_ENABLED(CONFIG_BT_LE)) { |
| 4516 | − flags = iso_enabled() ? BIT(0) : 0; | |
| 4516 | + flags = iso_inited() ? BIT(0) : 0; | |
| 4517 | 4517 | memcpy(rp->features[idx].uuid, iso_socket_uuid, 16); |
| 4518 | 4518 | rp->features[idx].flags = cpu_to_le32(flags); |
| 4519 | 4519 | idx++; |
| @@ -4818,6 +4818,14 @@ void br_multicast_set_query_intvl(struct net_bridge_mcast *brmctx, · 4817 unmodified lines | ||
| 4818 | 4818 | intvl_jiffies = BR_MULTICAST_QUERY_INTVL_MIN; |
| 4819 | 4819 | } |
| 4820 | 4820 | |
| 4821 | + if (intvl_jiffies > BR_MULTICAST_QUERY_INTVL_MAX) { | |
| 4822 | + br_info(brmctx->br, | |
| 4823 | + "trying to set multicast query interval above maximum, setting to %lu (%ums)\n", | |
| 4824 | + jiffies_to_clock_t(BR_MULTICAST_QUERY_INTVL_MAX), | |
| 4825 | + jiffies_to_msecs(BR_MULTICAST_QUERY_INTVL_MAX)); | |
| 4826 | + intvl_jiffies = BR_MULTICAST_QUERY_INTVL_MAX; | |
| 4827 | + } | |
| 4828 | + | |
| 4821 | 4829 | brmctx->multicast_query_interval = intvl_jiffies; |
| 4822 | 4830 | } |
| 4823 | 4831 | |
| @@ -4834,6 +4842,14 @@ void br_multicast_set_startup_query_intvl(struct net_bridge_mcast *brmctx, · 10 unmodified lines | ||
| 4834 | 4842 | intvl_jiffies = BR_MULTICAST_STARTUP_QUERY_INTVL_MIN; |
| 4835 | 4843 | } |
| 4836 | 4844 | |
| 4845 | + if (intvl_jiffies > BR_MULTICAST_STARTUP_QUERY_INTVL_MAX) { | |
| 4846 | + br_info(brmctx->br, | |
| 4847 | + "trying to set multicast startup query interval above maximum, setting to %lu (%ums)\n", | |
| 4848 | + jiffies_to_clock_t(BR_MULTICAST_STARTUP_QUERY_INTVL_MAX), | |
| 4849 | + jiffies_to_msecs(BR_MULTICAST_STARTUP_QUERY_INTVL_MAX)); | |
| 4850 | + intvl_jiffies = BR_MULTICAST_STARTUP_QUERY_INTVL_MAX; | |
| 4851 | + } | |
| 4852 | + | |
| 4837 | 4853 | brmctx->multicast_startup_query_interval = intvl_jiffies; |
| 4838 | 4854 | } |
| 4839 | 4855 | |
| @@ -31,6 +31,8 @@ · 30 unmodified lines | ||
| 31 | 31 | #define BR_MULTICAST_DEFAULT_HASH_MAX 4096 |
| 32 | 32 | #define BR_MULTICAST_QUERY_INTVL_MIN msecs_to_jiffies(1000) |
| 33 | 33 | #define BR_MULTICAST_STARTUP_QUERY_INTVL_MIN BR_MULTICAST_QUERY_INTVL_MIN |
| 34 | +#define BR_MULTICAST_QUERY_INTVL_MAX msecs_to_jiffies(86400000) /* 24 hours */ | |
| 35 | +#define BR_MULTICAST_STARTUP_QUERY_INTVL_MAX BR_MULTICAST_QUERY_INTVL_MAX | |
| 34 | 36 | |
| 35 | 37 | #define BR_HWDOM_MAX BITS_PER_LONG |
| 36 | 38 | |
| @@ -3779,6 +3779,18 @@ static netdev_features_t gso_features_check(const struct sk_buff *skb, · 3778 unmodified lines | ||
| 3779 | 3779 | features &= ~NETIF_F_TSO_MANGLEID; |
| 3780 | 3780 | } |
| 3781 | 3781 | |
| 3782 | + /* NETIF_F_IPV6_CSUM does not support IPv6 extension headers, | |
| 3783 | + * so neither does TSO that depends on it. | |
| 3784 | + */ | |
| 3785 | + if (features & NETIF_F_IPV6_CSUM && | |
| 3786 | + (skb_shinfo(skb)->gso_type & SKB_GSO_TCPV6 || | |
| 3787 | + (skb_shinfo(skb)->gso_type & SKB_GSO_UDP_L4 && | |
| 3788 | + vlan_get_protocol(skb) == htons(ETH_P_IPV6))) && | |
| 3789 | + skb_transport_header_was_set(skb) && | |
| 3790 | + skb_network_header_len(skb) != sizeof(struct ipv6hdr) && | |
| 3791 | + !ipv6_has_hopopt_jumbo(skb)) | |
| 3792 | + features &= ~(NETIF_F_IPV6_CSUM | NETIF_F_TSO6 | NETIF_F_GSO_UDP_L4); | |
| 3793 | + | |
| 3782 | 3794 | return features; |
| 3783 | 3795 | } |
| 3784 | 3796 | |
| @@ -63,8 +63,14 @@ static rx_handler_result_t hsr_handle_frame(struct sk_buff **pskb) · 62 unmodified lines | ||
| 63 | 63 | skb_push(skb, ETH_HLEN); |
| 64 | 64 | skb_reset_mac_header(skb); |
| 65 | 65 | if ((!hsr->prot_version && protocol == htons(ETH_P_PRP)) || |
| 66 | − protocol == htons(ETH_P_HSR)) | |
| 66 | + protocol == htons(ETH_P_HSR)) { | |
| 67 | + if (!pskb_may_pull(skb, ETH_HLEN + HSR_HLEN)) { | |
| 68 | + kfree_skb(skb); | |
| 69 | + goto finish_consume; | |
| 70 | + } | |
| 71 | + | |
| 67 | 72 | skb_set_network_header(skb, ETH_HLEN + HSR_HLEN); |
| 73 | + } | |
| 68 | 74 | skb_reset_mac_len(skb); |
| 69 | 75 | |
| 70 | 76 | /* Only the frames received over the interlink port will assign a |
| @@ -247,8 +247,7 @@ void nf_send_reset(struct net *net, struct sock *sk, struct sk_buff *oldskb, · 246 unmodified lines | ||
| 247 | 247 | if (!oth) |
| 248 | 248 | return; |
| 249 | 249 | |
| 250 | − if ((hook == NF_INET_PRE_ROUTING || hook == NF_INET_INGRESS) && | |
| 251 | − nf_reject_fill_skb_dst(oldskb) < 0) | |
| 250 | + if (!skb_dst(oldskb) && nf_reject_fill_skb_dst(oldskb) < 0) | |
| 252 | 251 | return; |
| 253 | 252 | |
| 254 | 253 | if (skb_rtable(oldskb)->rt_flags & (RTCF_BROADCAST | RTCF_MULTICAST)) |
| @@ -321,8 +320,7 @@ void nf_send_unreach(struct sk_buff *skb_in, int code, int hook) · 66 unmodified lines | ||
| 321 | 320 | if (iph->frag_off & htons(IP_OFFSET)) |
| 322 | 321 | return; |
| 323 | 322 | |
| 324 | − if ((hook == NF_INET_PRE_ROUTING || hook == NF_INET_INGRESS) && | |
| 325 | − nf_reject_fill_skb_dst(skb_in) < 0) | |
| 323 | + if (!skb_dst(skb_in) && nf_reject_fill_skb_dst(skb_in) < 0) | |
| 326 | 324 | return; |
| 327 | 325 | |
| 328 | 326 | if (skb_csum_unnecessary(skb_in) || |
| @@ -293,7 +293,7 @@ void nf_send_reset6(struct net *net, struct sock *sk, struct sk_buff *oldskb, · 292 unmodified lines | ||
| 293 | 293 | fl6.fl6_sport = otcph->dest; |
| 294 | 294 | fl6.fl6_dport = otcph->source; |
| 295 | 295 | |
| 296 | − if (hook == NF_INET_PRE_ROUTING || hook == NF_INET_INGRESS) { | |
| 296 | + if (!skb_dst(oldskb)) { | |
| 297 | 297 | nf_ip6_route(net, &dst, flowi6_to_flowi(&fl6), false); |
| 298 | 298 | if (!dst) |
| 299 | 299 | return; |
| @@ -397,8 +397,7 @@ void nf_send_unreach6(struct net *net, struct sk_buff *skb_in, · 97 unmodified lines | ||
| 397 | 397 | if (hooknum == NF_INET_LOCAL_OUT && skb_in->dev == NULL) |
| 398 | 398 | skb_in->dev = net->loopback_dev; |
| 399 | 399 | |
| 400 | − if ((hooknum == NF_INET_PRE_ROUTING || hooknum == NF_INET_INGRESS) && | |
| 401 | − nf_reject6_fill_skb_dst(skb_in) < 0) | |
| 400 | + if (!skb_dst(skb_in) && nf_reject6_fill_skb_dst(skb_in) < 0) | |
| 402 | 401 | return; |
| 403 | 402 | |
| 404 | 403 | icmpv6_send(skb_in, ICMPV6_DEST_UNREACH, code, 0); |
| @@ -35,6 +35,7 @@ · 34 unmodified lines | ||
| 35 | 35 | #include <net/xfrm.h> |
| 36 | 36 | |
| 37 | 37 | #include <crypto/hash.h> |
| 38 | +#include <crypto/utils.h> | |
| 38 | 39 | #include <net/seg6.h> |
| 39 | 40 | #include <net/genetlink.h> |
| 40 | 41 | #include <net/seg6_hmac.h> |
| @@ -280,7 +281,7 @@ bool seg6_hmac_validate_skb(struct sk_buff *skb) · 239 unmodified lines | ||
| 280 | 281 | if (seg6_hmac_compute(hinfo, srh, &ipv6_hdr(skb)->saddr, hmac_output)) |
| 281 | 282 | return false; |
| 282 | 283 | |
| 283 | − if (memcmp(hmac_output, tlv->hmac, SEG6_HMAC_FIELD_LEN) != 0) | |
| 284 | + if (crypto_memneq(hmac_output, tlv->hmac, SEG6_HMAC_FIELD_LEN)) | |
| 284 | 285 | return false; |
| 285 | 286 | |
| 286 | 287 | return true; |
| @@ -304,6 +305,9 @@ int seg6_hmac_info_add(struct net *net, u32 key, struct seg6_hmac_info *hinfo) · 17 unmodified lines | ||
| 304 | 305 | struct seg6_pernet_data *sdata = seg6_pernet(net); |
| 305 | 306 | int err; |
| 306 | 307 | |
| 308 | + if (!__hmac_get_algo(hinfo->alg_id)) | |
| 309 | + return -EINVAL; | |
| 310 | + | |
| 307 | 311 | err = rhashtable_lookup_insert_fast(&sdata->hmac_infos, &hinfo->node, |
| 308 | 312 | rht_params); |
| 309 | 313 | |
| @@ -1118,7 +1118,9 @@ static bool add_addr_hmac_valid(struct mptcp_sock *msk, · 1117 unmodified lines | ||
| 1118 | 1118 | return hmac == mp_opt->ahmac; |
| 1119 | 1119 | } |
| 1120 | 1120 | |
| 1121 | −/* Return false if a subflow has been reset, else return true */ | |
| 1121 | +/* Return false in case of error (or subflow has been reset), | |
| 1122 | + * else return true. | |
| 1123 | + */ | |
| 1122 | 1124 | bool mptcp_incoming_options(struct sock *sk, struct sk_buff *skb) |
| 1123 | 1125 | { |
| 1124 | 1126 | struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk); |
| @@ -1222,7 +1224,7 @@ bool mptcp_incoming_options(struct sock *sk, struct sk_buff *skb) · 97 unmodified lines | ||
| 1222 | 1224 | |
| 1223 | 1225 | mpext = skb_ext_add(skb, SKB_EXT_MPTCP); |
| 1224 | 1226 | if (!mpext) |
| 1225 | − return true; | |
| 1227 | + return false; | |
| 1226 | 1228 | |
| 1227 | 1229 | memset(mpext, 0, sizeof(*mpext)); |
| 1228 | 1230 | |
| @@ -274,6 +274,7 @@ static void mptcp_pm_add_timer(struct timer_list *timer) · 273 unmodified lines | ||
| 274 | 274 | add_timer); |
| 275 | 275 | struct mptcp_sock *msk = entry->sock; |
| 276 | 276 | struct sock *sk = (struct sock *)msk; |
| 277 | + unsigned int timeout; | |
| 277 | 278 | |
| 278 | 279 | pr_debug("msk=%p\n", msk); |
| 279 | 280 | |
| @@ -291,6 +292,10 @@ static void mptcp_pm_add_timer(struct timer_list *timer) · 11 unmodified lines | ||
| 291 | 292 | goto out; |
| 292 | 293 | } |
| 293 | 294 | |
| 295 | + timeout = mptcp_get_add_addr_timeout(sock_net(sk)); | |
| 296 | + if (!timeout) | |
| 297 | + goto out; | |
| 298 | + | |
| 294 | 299 | spin_lock_bh(&msk->pm.lock); |
| 295 | 300 | |
| 296 | 301 | if (!mptcp_pm_should_add_signal_addr(msk)) { |
| @@ -302,7 +307,7 @@ static void mptcp_pm_add_timer(struct timer_list *timer) · 5 unmodified lines | ||
| 302 | 307 | |
| 303 | 308 | if (entry->retrans_times < ADD_ADDR_RETRANS_MAX) |
| 304 | 309 | sk_reset_timer(sk, timer, |
| 305 | − jiffies + mptcp_get_add_addr_timeout(sock_net(sk))); | |
| 310 | + jiffies + timeout); | |
| 306 | 311 | |
| 307 | 312 | spin_unlock_bh(&msk->pm.lock); |
| 308 | 313 | |
| @@ -344,6 +349,7 @@ bool mptcp_pm_alloc_anno_list(struct mptcp_sock *msk, · 35 unmodified lines | ||
| 344 | 349 | struct mptcp_pm_add_entry *add_entry = NULL; |
| 345 | 350 | struct sock *sk = (struct sock *)msk; |
| 346 | 351 | struct net *net = sock_net(sk); |
| 352 | + unsigned int timeout; | |
| 347 | 353 | |
| 348 | 354 | lockdep_assert_held(&msk->pm.lock); |
| 349 | 355 | |
| @@ -353,9 +359,7 @@ bool mptcp_pm_alloc_anno_list(struct mptcp_sock *msk, · 3 unmodified lines | ||
| 353 | 359 | if (WARN_ON_ONCE(mptcp_pm_is_kernel(msk))) |
| 354 | 360 | return false; |
| 355 | 361 | |
| 356 | − sk_reset_timer(sk, &add_entry->add_timer, | |
| 357 | − jiffies + mptcp_get_add_addr_timeout(net)); | |
| 358 | − return true; | |
| 362 | + goto reset_timer; | |
| 359 | 363 | } |
| 360 | 364 | |
| 361 | 365 | add_entry = kmalloc(sizeof(*add_entry), GFP_ATOMIC); |
| @@ -369,8 +373,10 @@ bool mptcp_pm_alloc_anno_list(struct mptcp_sock *msk, · 7 unmodified lines | ||
| 369 | 373 | add_entry->retrans_times = 0; |
| 370 | 374 | |
| 371 | 375 | timer_setup(&add_entry->add_timer, mptcp_pm_add_timer, 0); |
| 372 | − sk_reset_timer(sk, &add_entry->add_timer, | |
| 373 | − jiffies + mptcp_get_add_addr_timeout(net)); | |
| 376 | +reset_timer: | |
| 377 | + timeout = mptcp_get_add_addr_timeout(net); | |
| 378 | + if (timeout) | |
| 379 | + sk_reset_timer(sk, &add_entry->add_timer, jiffies + timeout); | |
| 374 | 380 | |
| 375 | 381 | return true; |
| 376 | 382 | } |
| @@ -1085,7 +1085,6 @@ static void __flush_addrs(struct list_head *list) · 1084 unmodified lines | ||
| 1085 | 1085 | static void __reset_counters(struct pm_nl_pernet *pernet) |
| 1086 | 1086 | { |
| 1087 | 1087 | WRITE_ONCE(pernet->add_addr_signal_max, 0); |
| 1088 | − WRITE_ONCE(pernet->add_addr_accept_max, 0); | |
| 1089 | 1088 | WRITE_ONCE(pernet->local_addr_max, 0); |
| 1090 | 1089 | pernet->addrs = 0; |
| 1091 | 1090 | } |
| @@ -1750,7 +1750,7 @@ static s32 cake_enqueue(struct sk_buff *skb, struct Qdisc *sch, · 1749 unmodified lines | ||
| 1750 | 1750 | ktime_t now = ktime_get(); |
| 1751 | 1751 | struct cake_tin_data *b; |
| 1752 | 1752 | struct cake_flow *flow; |
| 1753 | − u32 idx; | |
| 1753 | + u32 idx, tin; | |
| 1754 | 1754 | |
| 1755 | 1755 | /* choose flow to insert into */ |
| 1756 | 1756 | idx = cake_classify(sch, &b, skb, q->flow_mode, &ret); |
| @@ -1760,6 +1760,7 @@ static s32 cake_enqueue(struct sk_buff *skb, struct Qdisc *sch, · 3 unmodified lines | ||
| 1760 | 1760 | __qdisc_drop(skb, to_free); |
| 1761 | 1761 | return ret; |
| 1762 | 1762 | } |
| 1763 | + tin = (u32)(b - q->tins); | |
| 1763 | 1764 | idx--; |
| 1764 | 1765 | flow = &b->flows[idx]; |
| 1765 | 1766 | |
| @@ -1927,13 +1928,22 @@ static s32 cake_enqueue(struct sk_buff *skb, struct Qdisc *sch, · 161 unmodified lines | ||
| 1927 | 1928 | q->buffer_max_used = q->buffer_used; |
| 1928 | 1929 | |
| 1929 | 1930 | if (q->buffer_used > q->buffer_limit) { |
| 1931 | + bool same_flow = false; | |
| 1930 | 1932 | u32 dropped = 0; |
| 1933 | + u32 drop_id; | |
| 1931 | 1934 | |
| 1932 | 1935 | while (q->buffer_used > q->buffer_limit) { |
| 1933 | 1936 | dropped++; |
| 1934 | − cake_drop(sch, to_free); | |
| 1937 | + drop_id = cake_drop(sch, to_free); | |
| 1938 | + | |
| 1939 | + if ((drop_id >> 16) == tin && | |
| 1940 | + (drop_id & 0xFFFF) == idx) | |
| 1941 | + same_flow = true; | |
| 1935 | 1942 | } |
| 1936 | 1943 | b->drop_overlimit += dropped; |
| 1944 | + | |
| 1945 | + if (same_flow) | |
| 1946 | + return NET_XMIT_CN; | |
| 1937 | 1947 | } |
| 1938 | 1948 | return NET_XMIT_SUCCESS; |
| 1939 | 1949 | } |
| @@ -101,9 +101,9 @@ static const struct nla_policy codel_policy[TCA_CODEL_MAX + 1] = { · 100 unmodified lines | ||
| 101 | 101 | static int codel_change(struct Qdisc *sch, struct nlattr *opt, |
| 102 | 102 | struct netlink_ext_ack *extack) |
| 103 | 103 | { |
| 104 | + unsigned int dropped_pkts = 0, dropped_bytes = 0; | |
| 104 | 105 | struct codel_sched_data *q = qdisc_priv(sch); |
| 105 | 106 | struct nlattr *tb[TCA_CODEL_MAX + 1]; |
| 106 | − unsigned int qlen, dropped = 0; | |
| 107 | 107 | int err; |
| 108 | 108 | |
| 109 | 109 | err = nla_parse_nested_deprecated(tb, TCA_CODEL_MAX, opt, |
| @@ -142,15 +142,17 @@ static int codel_change(struct Qdisc *sch, struct nlattr *opt, · 32 unmodified lines | ||
| 142 | 142 | WRITE_ONCE(q->params.ecn, |
| 143 | 143 | !!nla_get_u32(tb[TCA_CODEL_ECN])); |
| 144 | 144 | |
| 145 | − qlen = sch->q.qlen; | |
| 146 | 145 | while (sch->q.qlen > sch->limit) { |
| 147 | 146 | struct sk_buff *skb = qdisc_dequeue_internal(sch, true); |
| 148 | 147 | |
| 149 | − dropped += qdisc_pkt_len(skb); | |
| 150 | − qdisc_qstats_backlog_dec(sch, skb); | |
| 148 | + if (!skb) | |
| 149 | + break; | |
| 150 | + | |
| 151 | + dropped_pkts++; | |
| 152 | + dropped_bytes += qdisc_pkt_len(skb); | |
| 151 | 153 | rtnl_qdisc_drop(skb, sch); |
| 152 | 154 | } |
| 153 | − qdisc_tree_reduce_backlog(sch, qlen - sch->q.qlen, dropped); | |
| 155 | + qdisc_tree_reduce_backlog(sch, dropped_pkts, dropped_bytes); | |
| 154 | 156 | |
| 155 | 157 | sch_tree_unlock(sch); |
| 156 | 158 | return 0; |
| @@ -927,7 +927,8 @@ static int dualpi2_init(struct Qdisc *sch, struct nlattr *opt, · 926 unmodified lines | ||
| 927 | 927 | |
| 928 | 928 | q->sch = sch; |
| 929 | 929 | dualpi2_reset_default(sch); |
| 930 | − hrtimer_setup(&q->pi2_timer, dualpi2_timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS_PINNED); | |
| 930 | + hrtimer_setup(&q->pi2_timer, dualpi2_timer, CLOCK_MONOTONIC, | |
| 931 | + HRTIMER_MODE_ABS_PINNED_SOFT); | |
| 931 | 932 | |
| 932 | 933 | if (opt && nla_len(opt)) { |
| 933 | 934 | err = dualpi2_change(sch, opt, extack); |
| @@ -937,7 +938,7 @@ static int dualpi2_init(struct Qdisc *sch, struct nlattr *opt, · 3 unmodified lines | ||
| 937 | 938 | } |
| 938 | 939 | |
| 939 | 940 | hrtimer_start(&q->pi2_timer, next_pi2_timeout(q), |
| 940 | − HRTIMER_MODE_ABS_PINNED); | |
| 941 | + HRTIMER_MODE_ABS_PINNED_SOFT); | |
| 941 | 942 | return 0; |
| 942 | 943 | } |
| 943 | 944 | |
| @@ -1013,11 +1013,11 @@ static int fq_load_priomap(struct fq_sched_data *q, · 1012 unmodified lines | ||
| 1013 | 1013 | static int fq_change(struct Qdisc *sch, struct nlattr *opt, |
| 1014 | 1014 | struct netlink_ext_ack *extack) |
| 1015 | 1015 | { |
| 1016 | + unsigned int dropped_pkts = 0, dropped_bytes = 0; | |
| 1016 | 1017 | struct fq_sched_data *q = qdisc_priv(sch); |
| 1017 | 1018 | struct nlattr *tb[TCA_FQ_MAX + 1]; |
| 1018 | − int err, drop_count = 0; | |
| 1019 | − unsigned drop_len = 0; | |
| 1020 | 1019 | u32 fq_log; |
| 1020 | + int err; | |
| 1021 | 1021 | |
| 1022 | 1022 | err = nla_parse_nested_deprecated(tb, TCA_FQ_MAX, opt, fq_policy, |
| 1023 | 1023 | NULL); |
| @@ -1135,16 +1135,18 @@ static int fq_change(struct Qdisc *sch, struct nlattr *opt, · 111 unmodified lines | ||
| 1135 | 1135 | err = fq_resize(sch, fq_log); |
| 1136 | 1136 | sch_tree_lock(sch); |
| 1137 | 1137 | } |
| 1138 | + | |
| 1138 | 1139 | while (sch->q.qlen > sch->limit) { |
| 1139 | 1140 | struct sk_buff *skb = qdisc_dequeue_internal(sch, false); |
| 1140 | 1141 | |
| 1141 | 1142 | if (!skb) |
| 1142 | 1143 | break; |
| 1143 | − drop_len += qdisc_pkt_len(skb); | |
| 1144 | + | |
| 1145 | + dropped_pkts++; | |
| 1146 | + dropped_bytes += qdisc_pkt_len(skb); | |
| 1144 | 1147 | rtnl_kfree_skbs(skb, skb); |
| 1145 | − drop_count++; | |
| 1146 | 1148 | } |
| 1147 | − qdisc_tree_reduce_backlog(sch, drop_count, drop_len); | |
| 1149 | + qdisc_tree_reduce_backlog(sch, dropped_pkts, dropped_bytes); | |
| 1148 | 1150 | |
| 1149 | 1151 | sch_tree_unlock(sch); |
| 1150 | 1152 | return err; |
| @@ -366,6 +366,7 @@ static const struct nla_policy fq_codel_policy[TCA_FQ_CODEL_MAX + 1] = { · 365 unmodified lines | ||
| 366 | 366 | static int fq_codel_change(struct Qdisc *sch, struct nlattr *opt, |
| 367 | 367 | struct netlink_ext_ack *extack) |
| 368 | 368 | { |
| 369 | + unsigned int dropped_pkts = 0, dropped_bytes = 0; | |
| 369 | 370 | struct fq_codel_sched_data *q = qdisc_priv(sch); |
| 370 | 371 | struct nlattr *tb[TCA_FQ_CODEL_MAX + 1]; |
| 371 | 372 | u32 quantum = 0; |
| @@ -443,13 +444,14 @@ static int fq_codel_change(struct Qdisc *sch, struct nlattr *opt, · 71 unmodified lines | ||
| 443 | 444 | q->memory_usage > q->memory_limit) { |
| 444 | 445 | struct sk_buff *skb = qdisc_dequeue_internal(sch, false); |
| 445 | 446 | |
| 446 | − q->cstats.drop_len += qdisc_pkt_len(skb); | |
| 447 | + if (!skb) | |
| 448 | + break; | |
| 449 | + | |
| 450 | + dropped_pkts++; | |
| 451 | + dropped_bytes += qdisc_pkt_len(skb); | |
| 447 | 452 | rtnl_kfree_skbs(skb, skb); |
| 448 | − q->cstats.drop_count++; | |
| 449 | 453 | } |
| 450 | − qdisc_tree_reduce_backlog(sch, q->cstats.drop_count, q->cstats.drop_len); | |
| 451 | − q->cstats.drop_count = 0; | |
| 452 | − q->cstats.drop_len = 0; | |
| 454 | + qdisc_tree_reduce_backlog(sch, dropped_pkts, dropped_bytes); | |
| 453 | 455 | |
| 454 | 456 | sch_tree_unlock(sch); |
| 455 | 457 | return 0; |
| @@ -287,10 +287,9 @@ begin: · 286 unmodified lines | ||
| 287 | 287 | static int fq_pie_change(struct Qdisc *sch, struct nlattr *opt, |
| 288 | 288 | struct netlink_ext_ack *extack) |
| 289 | 289 | { |
| 290 | + unsigned int dropped_pkts = 0, dropped_bytes = 0; | |
| 290 | 291 | struct fq_pie_sched_data *q = qdisc_priv(sch); |
| 291 | 292 | struct nlattr *tb[TCA_FQ_PIE_MAX + 1]; |
| 292 | − unsigned int len_dropped = 0; | |
| 293 | − unsigned int num_dropped = 0; | |
| 294 | 293 | int err; |
| 295 | 294 | |
| 296 | 295 | err = nla_parse_nested(tb, TCA_FQ_PIE_MAX, opt, fq_pie_policy, extack); |
| @@ -368,11 +367,14 @@ static int fq_pie_change(struct Qdisc *sch, struct nlattr *opt, · 71 unmodified lines | ||
| 368 | 367 | while (sch->q.qlen > sch->limit) { |
| 369 | 368 | struct sk_buff *skb = qdisc_dequeue_internal(sch, false); |
| 370 | 369 | |
| 371 | − len_dropped += qdisc_pkt_len(skb); | |
| 372 | − num_dropped += 1; | |
| 370 | + if (!skb) | |
| 371 | + break; | |
| 372 | + | |
| 373 | + dropped_pkts++; | |
| 374 | + dropped_bytes += qdisc_pkt_len(skb); | |
| 373 | 375 | rtnl_kfree_skbs(skb, skb); |
| 374 | 376 | } |
| 375 | − qdisc_tree_reduce_backlog(sch, num_dropped, len_dropped); | |
| 377 | + qdisc_tree_reduce_backlog(sch, dropped_pkts, dropped_bytes); | |
| 376 | 378 | |
| 377 | 379 | sch_tree_unlock(sch); |
| 378 | 380 | return 0; |
| @@ -508,9 +508,9 @@ static const struct nla_policy hhf_policy[TCA_HHF_MAX + 1] = { · 507 unmodified lines | ||
| 508 | 508 | static int hhf_change(struct Qdisc *sch, struct nlattr *opt, |
| 509 | 509 | struct netlink_ext_ack *extack) |
| 510 | 510 | { |
| 511 | + unsigned int dropped_pkts = 0, dropped_bytes = 0; | |
| 511 | 512 | struct hhf_sched_data *q = qdisc_priv(sch); |
| 512 | 513 | struct nlattr *tb[TCA_HHF_MAX + 1]; |
| 513 | − unsigned int qlen, prev_backlog; | |
| 514 | 514 | int err; |
| 515 | 515 | u64 non_hh_quantum; |
| 516 | 516 | u32 new_quantum = q->quantum; |
| @@ -561,15 +561,17 @@ static int hhf_change(struct Qdisc *sch, struct nlattr *opt, · 44 unmodified lines | ||
| 561 | 561 | usecs_to_jiffies(us)); |
| 562 | 562 | } |
| 563 | 563 | |
| 564 | − qlen = sch->q.qlen; | |
| 565 | − prev_backlog = sch->qstats.backlog; | |
| 566 | 564 | while (sch->q.qlen > sch->limit) { |
| 567 | 565 | struct sk_buff *skb = qdisc_dequeue_internal(sch, false); |
| 568 | 566 | |
| 567 | + if (!skb) | |
| 568 | + break; | |
| 569 | + | |
| 570 | + dropped_pkts++; | |
| 571 | + dropped_bytes += qdisc_pkt_len(skb); | |
| 569 | 572 | rtnl_kfree_skbs(skb, skb); |
| 570 | 573 | } |
| 571 | − qdisc_tree_reduce_backlog(sch, qlen - sch->q.qlen, | |
| 572 | − prev_backlog - sch->qstats.backlog); | |
| 574 | + qdisc_tree_reduce_backlog(sch, dropped_pkts, dropped_bytes); | |
| 573 | 575 | |
| 574 | 576 | sch_tree_unlock(sch); |
| 575 | 577 | return 0; |
| @@ -592,7 +592,7 @@ htb_change_class_mode(struct htb_sched *q, struct htb_class *cl, s64 *diff) · 591 unmodified lines | ||
| 592 | 592 | */ |
| 593 | 593 | static inline void htb_activate(struct htb_sched *q, struct htb_class *cl) |
| 594 | 594 | { |
| 595 | − WARN_ON(cl->level || !cl->leaf.q || !cl->leaf.q->q.qlen); | |
| 595 | + WARN_ON(cl->level || !cl->leaf.q); | |
| 596 | 596 | |
| 597 | 597 | if (!cl->prio_activity) { |
| 598 | 598 | cl->prio_activity = 1 << cl->prio; |
| @@ -141,9 +141,9 @@ static const struct nla_policy pie_policy[TCA_PIE_MAX + 1] = { · 140 unmodified lines | ||
| 141 | 141 | static int pie_change(struct Qdisc *sch, struct nlattr *opt, |
| 142 | 142 | struct netlink_ext_ack *extack) |
| 143 | 143 | { |
| 144 | + unsigned int dropped_pkts = 0, dropped_bytes = 0; | |
| 144 | 145 | struct pie_sched_data *q = qdisc_priv(sch); |
| 145 | 146 | struct nlattr *tb[TCA_PIE_MAX + 1]; |
| 146 | − unsigned int qlen, dropped = 0; | |
| 147 | 147 | int err; |
| 148 | 148 | |
| 149 | 149 | err = nla_parse_nested_deprecated(tb, TCA_PIE_MAX, opt, pie_policy, |
| @@ -193,15 +193,17 @@ static int pie_change(struct Qdisc *sch, struct nlattr *opt, · 43 unmodified lines | ||
| 193 | 193 | nla_get_u32(tb[TCA_PIE_DQ_RATE_ESTIMATOR])); |
| 194 | 194 | |
| 195 | 195 | /* Drop excess packets if new limit is lower */ |
| 196 | − qlen = sch->q.qlen; | |
| 197 | 196 | while (sch->q.qlen > sch->limit) { |
| 198 | 197 | struct sk_buff *skb = qdisc_dequeue_internal(sch, true); |
| 199 | 198 | |
| 200 | − dropped += qdisc_pkt_len(skb); | |
| 201 | − qdisc_qstats_backlog_dec(sch, skb); | |
| 199 | + if (!skb) | |
| 200 | + break; | |
| 201 | + | |
| 202 | + dropped_pkts++; | |
| 203 | + dropped_bytes += qdisc_pkt_len(skb); | |
| 202 | 204 | rtnl_qdisc_drop(skb, sch); |
| 203 | 205 | } |
| 204 | − qdisc_tree_reduce_backlog(sch, qlen - sch->q.qlen, dropped); | |
| 206 | + qdisc_tree_reduce_backlog(sch, dropped_pkts, dropped_bytes); | |
| 205 | 207 | |
| 206 | 208 | sch_tree_unlock(sch); |
| 207 | 209 | return 0; |
| @@ -2568,8 +2568,9 @@ static void smc_listen_work(struct work_struct *work) · 2567 unmodified lines | ||
| 2568 | 2568 | goto out_decl; |
| 2569 | 2569 | } |
| 2570 | 2570 | |
| 2571 | − smc_listen_out_connected(new_smc); | |
| 2572 | 2571 | SMC_STAT_SERV_SUCC_INC(sock_net(newclcsock->sk), ini); |
| 2572 | + /* smc_listen_out() will release smcsk */ | |
| 2573 | + smc_listen_out_connected(new_smc); | |
| 2573 | 2574 | goto out_free; |
| 2574 | 2575 | |
| 2575 | 2576 | out_unlock: |
| @@ -1808,6 +1808,9 @@ int decrypt_skb(struct sock *sk, struct scatterlist *sgout) · 1807 unmodified lines | ||
| 1808 | 1808 | return tls_decrypt_sg(sk, NULL, sgout, &darg); |
| 1809 | 1809 | } |
| 1810 | 1810 | |
| 1811 | +/* All records returned from a recvmsg() call must have the same type. | |
| 1812 | + * 0 is not a valid content type. Use it as "no type reported, yet". | |
| 1813 | + */ | |
| 1811 | 1814 | static int tls_record_content_type(struct msghdr *msg, struct tls_msg *tlm, |
| 1812 | 1815 | u8 *control) |
| 1813 | 1816 | { |
| @@ -2051,8 +2054,10 @@ int tls_sw_recvmsg(struct sock *sk, · 237 unmodified lines | ||
| 2051 | 2054 | if (err < 0) |
| 2052 | 2055 | goto end; |
| 2053 | 2056 | |
| 2057 | + /* process_rx_list() will set @control if it processed any records */ | |
| 2054 | 2058 | copied = err; |
| 2055 | − if (len <= copied || (copied && control != TLS_RECORD_TYPE_DATA) || rx_more) | |
| 2059 | + if (len <= copied || rx_more || | |
| 2060 | + (control && control != TLS_RECORD_TYPE_DATA)) | |
| 2056 | 2061 | goto end; |
| 2057 | 2062 | |
| 2058 | 2063 | target = sock_rcvlowat(sk, flags & MSG_WAITALL, len); |
| @@ -43,17 +43,6 @@ pub struct Vmalloc; · 42 unmodified lines | ||
| 43 | 43 | /// For more details see [self]. |
| 44 | 44 | pub struct KVmalloc; |
| 45 | 45 | |
| 46 | −/// Returns a proper size to alloc a new object aligned to `new_layout`'s alignment. | |
| 47 | −fn aligned_size(new_layout: Layout) -> usize { | |
| 48 | − // Customized layouts from `Layout::from_size_align()` can have size < align, so pad first. | |
| 49 | − let layout = new_layout.pad_to_align(); | |
| 50 | − | |
| 51 | − // Note that `layout.size()` (after padding) is guaranteed to be a multiple of `layout.align()` | |
| 52 | − // which together with the slab guarantees means the `krealloc` will return a properly aligned | |
| 53 | − // object (see comments in `kmalloc()` for more information). | |
| 54 | − layout.size() | |
| 55 | −} | |
| 56 | − | |
| 57 | 46 | /// # Invariants |
| 58 | 47 | /// |
| 59 | 48 | /// One of the following: `krealloc`, `vrealloc`, `kvrealloc`. |
| @@ -88,7 +77,7 @@ impl ReallocFunc { · 28 unmodified lines | ||
| 88 | 77 | old_layout: Layout, |
| 89 | 78 | flags: Flags, |
| 90 | 79 | ) -> Result<NonNull<[u8]>, AllocError> { |
| 91 | − let size = aligned_size(layout); | |
| 80 | + let size = layout.size(); | |
| 92 | 81 | let ptr = match ptr { |
| 93 | 82 | Some(ptr) => { |
| 94 | 83 | if old_layout.size() == 0 { |
| @@ -123,6 +112,17 @@ impl ReallocFunc { · 28 unmodified lines | ||
| 123 | 112 | } |
| 124 | 113 | } |
| 125 | 114 | |
| 115 | +impl Kmalloc { | |
| 116 | + /// Returns a [`Layout`] that makes [`Kmalloc`] fulfill the requested size and alignment of | |
| 117 | + /// `layout`. | |
| 118 | + pub fn aligned_layout(layout: Layout) -> Layout { | |
| 119 | + // Note that `layout.size()` (after padding) is guaranteed to be a multiple of | |
| 120 | + // `layout.align()` which together with the slab guarantees means that `Kmalloc` will return | |
| 121 | + // a properly aligned object (see comments in `kmalloc()` for more information). | |
| 122 | + layout.pad_to_align() | |
| 123 | + } | |
| 124 | +} | |
| 125 | + | |
| 126 | 126 | // SAFETY: `realloc` delegates to `ReallocFunc::call`, which guarantees that |
| 127 | 127 | // - memory remains valid until it is explicitly freed, |
| 128 | 128 | // - passing a pointer to a valid memory allocation is OK, |
| @@ -135,6 +135,8 @@ unsafe impl Allocator for Kmalloc { · 6 unmodified lines | ||
| 135 | 135 | old_layout: Layout, |
| 136 | 136 | flags: Flags, |
| 137 | 137 | ) -> Result<NonNull<[u8]>, AllocError> { |
| 138 | + let layout = Kmalloc::aligned_layout(layout); | |
| 139 | + | |
| 138 | 140 | // SAFETY: `ReallocFunc::call` has the same safety requirements as `Allocator::realloc`. |
| 139 | 141 | unsafe { ReallocFunc::KREALLOC.call(ptr, layout, old_layout, flags) } |
| 140 | 142 | } |
| @@ -176,6 +178,10 @@ unsafe impl Allocator for KVmalloc { · 35 unmodified lines | ||
| 176 | 178 | old_layout: Layout, |
| 177 | 179 | flags: Flags, |
| 178 | 180 | ) -> Result<NonNull<[u8]>, AllocError> { |
| 181 | + // `KVmalloc` may use the `Kmalloc` backend, hence we have to enforce a `Kmalloc` | |
| 182 | + // compatible layout. | |
| 183 | + let layout = Kmalloc::aligned_layout(layout); | |
| 184 | + | |
| 179 | 185 | // TODO: Support alignments larger than PAGE_SIZE. |
| 180 | 186 | if layout.align() > bindings::PAGE_SIZE { |
| 181 | 187 | pr_warn!("KVmalloc does not support alignments larger than PAGE_SIZE yet.\n"); |
| @@ -22,6 +22,17 @@ pub type Kmalloc = Cmalloc; · 21 unmodified lines | ||
| 22 | 22 | pub type Vmalloc = Kmalloc; |
| 23 | 23 | pub type KVmalloc = Kmalloc; |
| 24 | 24 | |
| 25 | +impl Cmalloc { | |
| 26 | + /// Returns a [`Layout`] that makes [`Kmalloc`] fulfill the requested size and alignment of | |
| 27 | + /// `layout`. | |
| 28 | + pub fn aligned_layout(layout: Layout) -> Layout { | |
| 29 | + // Note that `layout.size()` (after padding) is guaranteed to be a multiple of | |
| 30 | + // `layout.align()` which together with the slab guarantees means that `Kmalloc` will return | |
| 31 | + // a properly aligned object (see comments in `kmalloc()` for more information). | |
| 32 | + layout.pad_to_align() | |
| 33 | + } | |
| 34 | +} | |
| 35 | + | |
| 25 | 36 | extern "C" { |
| 26 | 37 | #[link_name = "aligned_alloc"] |
| 27 | 38 | fn libc_aligned_alloc(align: usize, size: usize) -> *mut crate::ffi::c_void; |
| @@ -15,23 +15,130 @@ use crate::c_str; · 14 unmodified lines | ||
| 15 | 15 | |
| 16 | 16 | pub mod property; |
| 17 | 17 | |
| 18 | −/// A reference-counted device. | |
| 18 | +/// The core representation of a device in the kernel's driver model. | |
| 19 | 19 | /// |
| 20 | −/// This structure represents the Rust abstraction for a C `struct device`. This implementation | |
| 21 | −/// abstracts the usage of an already existing C `struct device` within Rust code that we get | |
| 22 | −/// passed from the C side. | |
| 20 | +/// This structure represents the Rust abstraction for a C `struct device`. A [`Device`] can either | |
| 21 | +/// exist as temporary reference (see also [`Device::from_raw`]), which is only valid within a | |
| 22 | +/// certain scope or as [`ARef<Device>`], owning a dedicated reference count. | |
| 23 | 23 | /// |
| 24 | −/// An instance of this abstraction can be obtained temporarily or permanent. | |
| 24 | +/// # Device Types | |
| 25 | 25 | /// |
| 26 | −/// A temporary one is bound to the lifetime of the C `struct device` pointer used for creation. | |
| 27 | −/// A permanent instance is always reference-counted and hence not restricted by any lifetime | |
| 28 | −/// boundaries. | |
| 26 | +/// A [`Device`] can represent either a bus device or a class device. | |
| 29 | 27 | /// |
| 30 | −/// For subsystems it is recommended to create a permanent instance to wrap into a subsystem | |
| 31 | −/// specific device structure (e.g. `pci::Device`). This is useful for passing it to drivers in | |
| 32 | −/// `T::probe()`, such that a driver can store the `ARef<Device>` (equivalent to storing a | |
| 33 | −/// `struct device` pointer in a C driver) for arbitrary purposes, e.g. allocating DMA coherent | |
| 34 | −/// memory. | |
| 28 | +/// ## Bus Devices | |
| 29 | +/// | |
| 30 | +/// A bus device is a [`Device`] that is associated with a physical or virtual bus. Examples of | |
| 31 | +/// buses include PCI, USB, I2C, and SPI. Devices attached to a bus are registered with a specific | |
| 32 | +/// bus type, which facilitates matching devices with appropriate drivers based on IDs or other | |
| 33 | +/// identifying information. Bus devices are visible in sysfs under `/sys/bus/<bus-name>/devices/`. | |
| 34 | +/// | |
| 35 | +/// ## Class Devices | |
| 36 | +/// | |
| 37 | +/// A class device is a [`Device`] that is associated with a logical category of functionality | |
| 38 | +/// rather than a physical bus. Examples of classes include block devices, network interfaces, sound | |
| 39 | +/// cards, and input devices. Class devices are grouped under a common class and exposed to | |
| 40 | +/// userspace via entries in `/sys/class/<class-name>/`. | |
| 41 | +/// | |
| 42 | +/// # Device Context | |
| 43 | +/// | |
| 44 | +/// [`Device`] references are generic over a [`DeviceContext`], which represents the type state of | |
| 45 | +/// a [`Device`]. | |
| 46 | +/// | |
| 47 | +/// As the name indicates, this type state represents the context of the scope the [`Device`] | |
| 48 | +/// reference is valid in. For instance, the [`Bound`] context guarantees that the [`Device`] is | |
| 49 | +/// bound to a driver for the entire duration of the existence of a [`Device<Bound>`] reference. | |
| 50 | +/// | |
| 51 | +/// Other [`DeviceContext`] types besides [`Bound`] are [`Normal`], [`Core`] and [`CoreInternal`]. | |
| 52 | +/// | |
| 53 | +/// Unless selected otherwise [`Device`] defaults to the [`Normal`] [`DeviceContext`], which by | |
| 54 | +/// itself has no additional requirements. | |
| 55 | +/// | |
| 56 | +/// It is always up to the caller of [`Device::from_raw`] to select the correct [`DeviceContext`] | |
| 57 | +/// type for the corresponding scope the [`Device`] reference is created in. | |
| 58 | +/// | |
| 59 | +/// All [`DeviceContext`] types other than [`Normal`] are intended to be used with | |
| 60 | +/// [bus devices](#bus-devices) only. | |
| 61 | +/// | |
| 62 | +/// # Implementing Bus Devices | |
| 63 | +/// | |
| 64 | +/// This section provides a guideline to implement bus specific devices, such as [`pci::Device`] or | |
| 65 | +/// [`platform::Device`]. | |
| 66 | +/// | |
| 67 | +/// A bus specific device should be defined as follows. | |
| 68 | +/// | |
| 69 | +/// ```ignore | |
| 70 | +/// #[repr(transparent)] | |
| 71 | +/// pub struct Device<Ctx: device::DeviceContext = device::Normal>( | |
| 72 | +/// Opaque<bindings::bus_device_type>, | |
| 73 | +/// PhantomData<Ctx>, | |
| 74 | +/// ); | |
| 75 | +/// ``` | |
| 76 | +/// | |
| 77 | +/// Since devices are reference counted, [`AlwaysRefCounted`] should be implemented for `Device` | |
| 78 | +/// (i.e. `Device<Normal>`). Note that [`AlwaysRefCounted`] must not be implemented for any other | |
| 79 | +/// [`DeviceContext`], since all other device context types are only valid within a certain scope. | |
| 80 | +/// | |
| 81 | +/// In order to be able to implement the [`DeviceContext`] dereference hierarchy, bus device | |
| 82 | +/// implementations should call the [`impl_device_context_deref`] macro as shown below. | |
| 83 | +/// | |
| 84 | +/// ```ignore | |
| 85 | +/// // SAFETY: `Device` is a transparent wrapper of a type that doesn't depend on `Device`'s | |
| 86 | +/// // generic argument. | |
| 87 | +/// kernel::impl_device_context_deref!(unsafe { Device }); | |
| 88 | +/// ``` | |
| 89 | +/// | |
| 90 | +/// In order to convert from a any [`Device<Ctx>`] to [`ARef<Device>`], bus devices can implement | |
| 91 | +/// the following macro call. | |
| 92 | +/// | |
| 93 | +/// ```ignore | |
| 94 | +/// kernel::impl_device_context_into_aref!(Device); | |
| 95 | +/// ``` | |
| 96 | +/// | |
| 97 | +/// Bus devices should also implement the following [`AsRef`] implementation, such that users can | |
| 98 | +/// easily derive a generic [`Device`] reference. | |
| 99 | +/// | |
| 100 | +/// ```ignore | |
| 101 | +/// impl<Ctx: device::DeviceContext> AsRef<device::Device<Ctx>> for Device<Ctx> { | |
| 102 | +/// fn as_ref(&self) -> &device::Device<Ctx> { | |
| 103 | +/// ... | |
| 104 | +/// } | |
| 105 | +/// } | |
| 106 | +/// ``` | |
| 107 | +/// | |
| 108 | +/// # Implementing Class Devices | |
| 109 | +/// | |
| 110 | +/// Class device implementations require less infrastructure and depend slightly more on the | |
| 111 | +/// specific subsystem. | |
| 112 | +/// | |
| 113 | +/// An example implementation for a class device could look like this. | |
| 114 | +/// | |
| 115 | +/// ```ignore | |
| 116 | +/// #[repr(C)] | |
| 117 | +/// pub struct Device<T: class::Driver> { | |
| 118 | +/// dev: Opaque<bindings::class_device_type>, | |
| 119 | +/// data: T::Data, | |
| 120 | +/// } | |
| 121 | +/// ``` | |
| 122 | +/// | |
| 123 | +/// This class device uses the sub-classing pattern to embed the driver's private data within the | |
| 124 | +/// allocation of the class device. For this to be possible the class device is generic over the | |
| 125 | +/// class specific `Driver` trait implementation. | |
| 126 | +/// | |
| 127 | +/// Just like any device, class devices are reference counted and should hence implement | |
| 128 | +/// [`AlwaysRefCounted`] for `Device`. | |
| 129 | +/// | |
| 130 | +/// Class devices should also implement the following [`AsRef`] implementation, such that users can | |
| 131 | +/// easily derive a generic [`Device`] reference. | |
| 132 | +/// | |
| 133 | +/// ```ignore | |
| 134 | +/// impl<T: class::Driver> AsRef<device::Device> for Device<T> { | |
| 135 | +/// fn as_ref(&self) -> &device::Device { | |
| 136 | +/// ... | |
| 137 | +/// } | |
| 138 | +/// } | |
| 139 | +/// ``` | |
| 140 | +/// | |
| 141 | +/// An example for a class device implementation is [`drm::Device`]. | |
| 35 | 142 | /// |
| 36 | 143 | /// # Invariants |
| 37 | 144 | /// |
| @@ -42,6 +149,12 @@ pub mod property; · 4 unmodified lines | ||
| 42 | 149 | /// |
| 43 | 150 | /// `bindings::device::release` is valid to be called from any thread, hence `ARef<Device>` can be |
| 44 | 151 | /// dropped from any thread. |
| 152 | +/// | |
| 153 | +/// [`AlwaysRefCounted`]: kernel::types::AlwaysRefCounted | |
| 154 | +/// [`drm::Device`]: kernel::drm::Device | |
| 155 | +/// [`impl_device_context_deref`]: kernel::impl_device_context_deref | |
| 156 | +/// [`pci::Device`]: kernel::pci::Device | |
| 157 | +/// [`platform::Device`]: kernel::platform::Device | |
| 45 | 158 | #[repr(transparent)] |
| 46 | 159 | pub struct Device<Ctx: DeviceContext = Normal>(Opaque<bindings::device>, PhantomData<Ctx>); |
| 47 | 160 | |
| @@ -311,28 +424,75 @@ unsafe impl Send for Device {} · 263 unmodified lines | ||
| 311 | 424 | // synchronization in `struct device`. |
| 312 | 425 | unsafe impl Sync for Device {} |
| 313 | 426 | |
| 314 | −/// Marker trait for the context of a bus specific device. | |
| 427 | +/// Marker trait for the context or scope of a bus specific device. | |
| 428 | +/// | |
| 429 | +/// [`DeviceContext`] is a marker trait for types representing the context of a bus specific | |
| 430 | +/// [`Device`]. | |
| 431 | +/// | |
| 432 | +/// The specific device context types are: [`CoreInternal`], [`Core`], [`Bound`] and [`Normal`]. | |
| 315 | 433 | /// |
| 316 | −/// Some functions of a bus specific device should only be called from a certain context, i.e. bus | |
| 317 | −/// callbacks, such as `probe()`. | |
| 434 | +/// [`DeviceContext`] types are hierarchical, which means that there is a strict hierarchy that | |
| 435 | +/// defines which [`DeviceContext`] type can be derived from another. For instance, any | |
| 436 | +/// [`Device<Core>`] can dereference to a [`Device<Bound>`]. | |
| 318 | 437 | /// |
| 319 | −/// This is the marker trait for structures representing the context of a bus specific device. | |
| 438 | +/// The following enumeration illustrates the dereference hierarchy of [`DeviceContext`] types. | |
| 439 | +/// | |
| 440 | +/// - [`CoreInternal`] => [`Core`] => [`Bound`] => [`Normal`] | |
| 441 | +/// | |
| 442 | +/// Bus devices can automatically implement the dereference hierarchy by using | |
| 443 | +/// [`impl_device_context_deref`]. | |
| 444 | +/// | |
| 445 | +/// Note that the guarantee for a [`Device`] reference to have a certain [`DeviceContext`] comes | |
| 446 | +/// from the specific scope the [`Device`] reference is valid in. | |
| 447 | +/// | |
| 448 | +/// [`impl_device_context_deref`]: kernel::impl_device_context_deref | |
| 320 | 449 | pub trait DeviceContext: private::Sealed {} |
| 321 | 450 | |
| 322 | −/// The [`Normal`] context is the context of a bus specific device when it is not an argument of | |
| 323 | −/// any bus callback. | |
| 451 | +/// The [`Normal`] context is the default [`DeviceContext`] of any [`Device`]. | |
| 452 | +/// | |
| 453 | +/// The normal context does not indicate any specific context. Any `Device<Ctx>` is also a valid | |
| 454 | +/// [`Device<Normal>`]. It is the only [`DeviceContext`] for which it is valid to implement | |
| 455 | +/// [`AlwaysRefCounted`] for. | |
| 456 | +/// | |
| 457 | +/// [`AlwaysRefCounted`]: kernel::types::AlwaysRefCounted | |
| 324 | 458 | pub struct Normal; |
| 325 | 459 | |
| 326 | −/// The [`Core`] context is the context of a bus specific device when it is supplied as argument of | |
| 327 | −/// any of the bus callbacks, such as `probe()`. | |
| 460 | +/// The [`Core`] context is the context of a bus specific device when it appears as argument of | |
| 461 | +/// any bus specific callback, such as `probe()`. | |
| 462 | +/// | |
| 463 | +/// The core context indicates that the [`Device<Core>`] reference's scope is limited to the bus | |
| 464 | +/// callback it appears in. It is intended to be used for synchronization purposes. Bus device | |
| 465 | +/// implementations can implement methods for [`Device<Core>`], such that they can only be called | |
| 466 | +/// from bus callbacks. | |
| 328 | 467 | pub struct Core; |
| 329 | 468 | |
| 330 | −/// Semantically the same as [`Core`] but reserved for internal usage of the corresponding bus | |
| 469 | +/// Semantically the same as [`Core`], but reserved for internal usage of the corresponding bus | |
| 331 | 470 | /// abstraction. |
| 471 | +/// | |
| 472 | +/// The internal core context is intended to be used in exactly the same way as the [`Core`] | |
| 473 | +/// context, with the difference that this [`DeviceContext`] is internal to the corresponding bus | |
| 474 | +/// abstraction. | |
| 475 | +/// | |
| 476 | +/// This context mainly exists to share generic [`Device`] infrastructure that should only be called | |
| 477 | +/// from bus callbacks with bus abstractions, but without making them accessible for drivers. | |
| 332 | 478 | pub struct CoreInternal; |
| 333 | 479 | |
| 334 | −/// The [`Bound`] context is the context of a bus specific device reference when it is guaranteed to | |
| 335 | −/// be bound for the duration of its lifetime. | |
| 480 | +/// The [`Bound`] context is the [`DeviceContext`] of a bus specific device when it is guaranteed to | |
| 481 | +/// be bound to a driver. | |
| 482 | +/// | |
| 483 | +/// The bound context indicates that for the entire duration of the lifetime of a [`Device<Bound>`] | |
| 484 | +/// reference, the [`Device`] is guaranteed to be bound to a driver. | |
| 485 | +/// | |
| 486 | +/// Some APIs, such as [`dma::CoherentAllocation`] or [`Devres`] rely on the [`Device`] to be bound, | |
| 487 | +/// which can be proven with the [`Bound`] device context. | |
| 488 | +/// | |
| 489 | +/// Any abstraction that can guarantee a scope where the corresponding bus device is bound, should | |
| 490 | +/// provide a [`Device<Bound>`] reference to its users for this scope. This allows users to benefit | |
| 491 | +/// from optimizations for accessing device resources, see also [`Devres::access`]. | |
| 492 | +/// | |
| 493 | +/// [`Devres`]: kernel::devres::Devres | |
| 494 | +/// [`Devres::access`]: kernel::devres::Devres::access | |
| 495 | +/// [`dma::CoherentAllocation`]: kernel::dma::CoherentAllocation | |
| 336 | 496 | pub struct Bound; |
| 337 | 497 | |
| 338 | 498 | mod private { |
| @@ -115,10 +115,11 @@ pub struct Devres<T: Send> { · 114 unmodified lines | ||
| 115 | 115 | /// Contains all the fields shared with [`Self::callback`]. |
| 116 | 116 | // TODO: Replace with `UnsafePinned`, once available. |
| 117 | 117 | // |
| 118 | − // Subsequently, the `drop_in_place()` in `Devres::drop` and the explicit `Send` and `Sync' | |
| 119 | − // impls can be removed. | |
| 118 | + // Subsequently, the `drop_in_place()` in `Devres::drop` and `Devres::new` as well as the | |
| 119 | + // explicit `Send` and `Sync' impls can be removed. | |
| 120 | 120 | #[pin] |
| 121 | 121 | inner: Opaque<Inner<T>>, |
| 122 | + _add_action: (), | |
| 122 | 123 | } |
| 123 | 124 | |
| 124 | 125 | impl<T: Send> Devres<T> { |
| @@ -140,7 +141,15 @@ impl<T: Send> Devres<T> { · 15 unmodified lines | ||
| 140 | 141 | dev: dev.into(), |
| 141 | 142 | callback, |
| 142 | 143 | // INVARIANT: `inner` is properly initialized. |
| 143 | − inner <- { | |
| 144 | + inner <- Opaque::pin_init(try_pin_init!(Inner { | |
| 145 | + devm <- Completion::new(), | |
| 146 | + revoke <- Completion::new(), | |
| 147 | + data <- Revocable::new(data), | |
| 148 | + })), | |
| 149 | + // TODO: Replace with "initializer code blocks" [1] once available. | |
| 150 | + // | |
| 151 | + // [1] https://github.com/Rust-for-Linux/pin-init/pull/69 | |
| 152 | + _add_action: { | |
| 144 | 153 | // SAFETY: `this` is a valid pointer to uninitialized memory. |
| 145 | 154 | let inner = unsafe { &raw mut (*this.as_ptr()).inner }; |
| 146 | 155 | |
| @@ -152,13 +161,13 @@ impl<T: Send> Devres<T> { · 5 unmodified lines | ||
| 152 | 161 | // live at least as long as the returned `impl PinInit<Self, Error>`. |
| 153 | 162 | to_result(unsafe { |
| 154 | 163 | bindings::devm_add_action(dev.as_raw(), Some(callback), inner.cast()) |
| 155 | − })?; | |
| 164 | + }).inspect_err(|_| { | |
| 165 | + let inner = Opaque::cast_into(inner); | |
| 156 | 166 | |
| 157 | − Opaque::pin_init(try_pin_init!(Inner { | |
| 158 | − devm <- Completion::new(), | |
| 159 | − revoke <- Completion::new(), | |
| 160 | − data <- Revocable::new(data), | |
| 161 | − })) | |
| 167 | + // SAFETY: `inner` is a valid pointer to an `Inner<T>` and valid for both reads | |
| 168 | + // and writes. | |
| 169 | + unsafe { core::ptr::drop_in_place(inner) }; | |
| 170 | + })?; | |
| 162 | 171 | }, |
| 163 | 172 | }) |
| 164 | 173 | } |
| @@ -2,8 +2,93 @@ · 1 unmodified line | ||
| 2 | 2 | |
| 3 | 3 | //! Generic support for drivers of different buses (e.g., PCI, Platform, Amba, etc.). |
| 4 | 4 | //! |
| 5 | −//! Each bus / subsystem is expected to implement [`RegistrationOps`], which allows drivers to | |
| 6 | −//! register using the [`Registration`] class. | |
| 5 | +//! This documentation describes how to implement a bus specific driver API and how to align it with | |
| 6 | +//! the design of (bus specific) devices. | |
| 7 | +//! | |
| 8 | +//! Note: Readers are expected to know the content of the documentation of [`Device`] and | |
| 9 | +//! [`DeviceContext`]. | |
| 10 | +//! | |
| 11 | +//! # Driver Trait | |
| 12 | +//! | |
| 13 | +//! The main driver interface is defined by a bus specific driver trait. For instance: | |
| 14 | +//! | |
| 15 | +//! ```ignore | |
| 16 | +//! pub trait Driver: Send { | |
| 17 | +//! /// The type holding information about each device ID supported by the driver. | |
| 18 | +//! type IdInfo: 'static; | |
| 19 | +//! | |
| 20 | +//! /// The table of OF device ids supported by the driver. | |
| 21 | +//! const OF_ID_TABLE: Option<of::IdTable<Self::IdInfo>> = None; | |
| 22 | +//! | |
| 23 | +//! /// The table of ACPI device ids supported by the driver. | |
| 24 | +//! const ACPI_ID_TABLE: Option<acpi::IdTable<Self::IdInfo>> = None; | |
| 25 | +//! | |
| 26 | +//! /// Driver probe. | |
| 27 | +//! fn probe(dev: &Device<device::Core>, id_info: &Self::IdInfo) -> Result<Pin<KBox<Self>>>; | |
| 28 | +//! | |
| 29 | +//! /// Driver unbind (optional). | |
| 30 | +//! fn unbind(dev: &Device<device::Core>, this: Pin<&Self>) { | |
| 31 | +//! let _ = (dev, this); | |
| 32 | +//! } | |
| 33 | +//! } | |
| 34 | +//! ``` | |
| 35 | +//! | |
| 36 | +//! For specific examples see [`auxiliary::Driver`], [`pci::Driver`] and [`platform::Driver`]. | |
| 37 | +//! | |
| 38 | +//! The `probe()` callback should return a `Result<Pin<KBox<Self>>>`, i.e. the driver's private | |
| 39 | +//! data. The bus abstraction should store the pointer in the corresponding bus device. The generic | |
| 40 | +//! [`Device`] infrastructure provides common helpers for this purpose on its | |
| 41 | +//! [`Device<CoreInternal>`] implementation. | |
| 42 | +//! | |
| 43 | +//! All driver callbacks should provide a reference to the driver's private data. Once the driver | |
| 44 | +//! is unbound from the device, the bus abstraction should take back the ownership of the driver's | |
| 45 | +//! private data from the corresponding [`Device`] and [`drop`] it. | |
| 46 | +//! | |
| 47 | +//! All driver callbacks should provide a [`Device<Core>`] reference (see also [`device::Core`]). | |
| 48 | +//! | |
| 49 | +//! # Adapter | |
| 50 | +//! | |
| 51 | +//! The adapter implementation of a bus represents the abstraction layer between the C bus | |
| 52 | +//! callbacks and the Rust bus callbacks. It therefore has to be generic over an implementation of | |
| 53 | +//! the [driver trait](#driver-trait). | |
| 54 | +//! | |
| 55 | +//! ```ignore | |
| 56 | +//! pub struct Adapter<T: Driver>; | |
| 57 | +//! ``` | |
| 58 | +//! | |
| 59 | +//! There's a common [`Adapter`] trait that can be implemented to inherit common driver | |
| 60 | +//! infrastructure, such as finding the ID info from an [`of::IdTable`] or [`acpi::IdTable`]. | |
| 61 | +//! | |
| 62 | +//! # Driver Registration | |
| 63 | +//! | |
| 64 | +//! In order to register C driver types (such as `struct platform_driver`) the [adapter](#adapter) | |
| 65 | +//! should implement the [`RegistrationOps`] trait. | |
| 66 | +//! | |
| 67 | +//! This trait implementation can be used to create the actual registration with the common | |
| 68 | +//! [`Registration`] type. | |
| 69 | +//! | |
| 70 | +//! Typically, bus abstractions want to provide a bus specific `module_bus_driver!` macro, which | |
| 71 | +//! creates a kernel module with exactly one [`Registration`] for the bus specific adapter. | |
| 72 | +//! | |
| 73 | +//! The generic driver infrastructure provides a helper for this with the [`module_driver`] macro. | |
| 74 | +//! | |
| 75 | +//! # Device IDs | |
| 76 | +//! | |
| 77 | +//! Besides the common device ID types, such as [`of::DeviceId`] and [`acpi::DeviceId`], most buses | |
| 78 | +//! may need to implement their own device ID types. | |
| 79 | +//! | |
| 80 | +//! For this purpose the generic infrastructure in [`device_id`] should be used. | |
| 81 | +//! | |
| 82 | +//! [`auxiliary::Driver`]: kernel::auxiliary::Driver | |
| 83 | +//! [`Core`]: device::Core | |
| 84 | +//! [`Device`]: device::Device | |
| 85 | +//! [`Device<Core>`]: device::Device<device::Core> | |
| 86 | +//! [`Device<CoreInternal>`]: device::Device<device::CoreInternal> | |
| 87 | +//! [`DeviceContext`]: device::DeviceContext | |
| 88 | +//! [`device_id`]: kernel::device_id | |
| 89 | +//! [`module_driver`]: kernel::module_driver | |
| 90 | +//! [`pci::Driver`]: kernel::pci::Driver | |
| 91 | +//! [`platform::Driver`]: kernel::platform::Driver | |
| 7 | 92 | |
| 8 | 93 | use crate::error::{Error, Result}; |
| 9 | 94 | use crate::{acpi, device, of, str::CStr, try_pin_init, types::Opaque, ThisModule}; |
| @@ -5,6 +5,7 @@ · 4 unmodified lines | ||
| 5 | 5 | //! C header: [`include/linux/drm/drm_device.h`](srctree/include/linux/drm/drm_device.h) |
| 6 | 6 | |
| 7 | 7 | use crate::{ |
| 8 | + alloc::allocator::Kmalloc, | |
| 8 | 9 | bindings, device, drm, |
| 9 | 10 | drm::driver::AllocImpl, |
| 10 | 11 | error::from_err_ptr, |
| @@ -12,7 +13,7 @@ use crate::{ · 1 unmodified line | ||
| 12 | 13 | prelude::*, |
| 13 | 14 | types::{ARef, AlwaysRefCounted, Opaque}, |
| 14 | 15 | }; |
| 15 | −use core::{mem, ops::Deref, ptr, ptr::NonNull}; | |
| 16 | +use core::{alloc::Layout, mem, ops::Deref, ptr, ptr::NonNull}; | |
| 16 | 17 | |
| 17 | 18 | #[cfg(CONFIG_DRM_LEGACY)] |
| 18 | 19 | macro_rules! drm_legacy_fields { |
| @@ -53,10 +54,8 @@ macro_rules! drm_legacy_fields { · 34 unmodified lines | ||
| 53 | 54 | /// |
| 54 | 55 | /// `self.dev` is a valid instance of a `struct device`. |
| 55 | 56 | #[repr(C)] |
| 56 | −#[pin_data] | |
| 57 | 57 | pub struct Device<T: drm::Driver> { |
| 58 | 58 | dev: Opaque<bindings::drm_device>, |
| 59 | − #[pin] | |
| 60 | 59 | data: T::Data, |
| 61 | 60 | } |
| 62 | 61 | |
| @@ -96,6 +95,10 @@ impl<T: drm::Driver> Device<T> { · 33 unmodified lines | ||
| 96 | 95 | |
| 97 | 96 | /// Create a new `drm::Device` for a `drm::Driver`. |
| 98 | 97 | pub fn new(dev: &device::Device, data: impl PinInit<T::Data, Error>) -> Result<ARef<Self>> { |
| 98 | + // `__drm_dev_alloc` uses `kmalloc()` to allocate memory, hence ensure a `kmalloc()` | |
| 99 | + // compatible `Layout`. | |
| 100 | + let layout = Kmalloc::aligned_layout(Layout::new::<Self>()); | |
| 101 | + | |
| 99 | 102 | // SAFETY: |
| 100 | 103 | // - `VTABLE`, as a `const` is pinned to the read-only section of the compilation, |
| 101 | 104 | // - `dev` is valid by its type invarants, |
| @@ -103,7 +106,7 @@ impl<T: drm::Driver> Device<T> { · 1 unmodified line | ||
| 103 | 106 | bindings::__drm_dev_alloc( |
| 104 | 107 | dev.as_raw(), |
| 105 | 108 | &Self::VTABLE, |
| 106 | − mem::size_of::<Self>(), | |
| 109 | + layout.size(), | |
| 107 | 110 | mem::offset_of!(Self, dev), |
| 108 | 111 | ) |
| 109 | 112 | } |
| @@ -117,9 +120,13 @@ impl<T: drm::Driver> Device<T> { · 7 unmodified lines | ||
| 117 | 120 | // - `raw_data` is a valid pointer to uninitialized memory. |
| 118 | 121 | // - `raw_data` will not move until it is dropped. |
| 119 | 122 | unsafe { data.__pinned_init(raw_data) }.inspect_err(|_| { |
| 120 | − // SAFETY: `__drm_dev_alloc()` was successful, hence `raw_drm` must be valid and the | |
| 123 | + // SAFETY: `raw_drm` is a valid pointer to `Self`, given that `__drm_dev_alloc` was | |
| 124 | + // successful. | |
| 125 | + let drm_dev = unsafe { Self::into_drm_device(raw_drm) }; | |
| 126 | + | |
| 127 | + // SAFETY: `__drm_dev_alloc()` was successful, hence `drm_dev` must be valid and the | |
| 121 | 128 | // refcount must be non-zero. |
| 122 | − unsafe { bindings::drm_dev_put(ptr::addr_of_mut!((*raw_drm.as_ptr()).dev).cast()) }; | |
| 129 | + unsafe { bindings::drm_dev_put(drm_dev) }; | |
| 123 | 130 | })?; |
| 124 | 131 | |
| 125 | 132 | // SAFETY: The reference count is one, and now we take ownership of that reference as a |
| @@ -140,6 +147,14 @@ impl<T: drm::Driver> Device<T> { · 14 unmodified lines | ||
| 140 | 147 | unsafe { crate::container_of!(Opaque::cast_from(ptr), Self, dev) }.cast_mut() |
| 141 | 148 | } |
| 142 | 149 | |
| 150 | + /// # Safety | |
| 151 | + /// | |
| 152 | + /// `ptr` must be a valid pointer to `Self`. | |
| 153 | + unsafe fn into_drm_device(ptr: NonNull<Self>) -> *mut bindings::drm_device { | |
| 154 | + // SAFETY: By the safety requirements of this function, `ptr` is a valid pointer to `Self`. | |
| 155 | + unsafe { &raw mut (*ptr.as_ptr()).dev }.cast() | |
| 156 | + } | |
| 157 | + | |
| 143 | 158 | /// Not intended to be called externally, except via declare_drm_ioctls!() |
| 144 | 159 | /// |
| 145 | 160 | /// # Safety |
| @@ -189,8 +204,11 @@ unsafe impl<T: drm::Driver> AlwaysRefCounted for Device<T> { · 43 unmodified lines | ||
| 189 | 204 | } |
| 190 | 205 | |
| 191 | 206 | unsafe fn dec_ref(obj: NonNull<Self>) { |
| 207 | + // SAFETY: `obj` is a valid pointer to `Self`. | |
| 208 | + let drm_dev = unsafe { Self::into_drm_device(obj) }; | |
| 209 | + | |
| 192 | 210 | // SAFETY: The safety requirements guarantee that the refcount is non-zero. |
| 193 | − unsafe { bindings::drm_dev_put(obj.cast().as_ptr()) }; | |
| 211 | + unsafe { bindings::drm_dev_put(drm_dev) }; | |
| 194 | 212 | } |
| 195 | 213 | } |
| 196 | 214 | |
| @@ -4,7 +4,7 @@ · 3 unmodified lines | ||
| 4 | 4 | //! |
| 5 | 5 | //! This module provides bindings for working with faux devices in kernel modules. |
| 6 | 6 | //! |
| 7 | −//! C header: [`include/linux/device/faux.h`] | |
| 7 | +//! C header: [`include/linux/device/faux.h`](srctree/include/linux/device/faux.h) | |
| 8 | 8 | |
| 9 | 9 | use crate::{bindings, device, error::code::*, prelude::*}; |
| 10 | 10 | use core::ptr::{addr_of_mut, null, null_mut, NonNull}; |
| @@ -2139,14 +2139,14 @@ static int snd_utimer_create(struct snd_timer_uinfo *utimer_info, · 2138 unmodified lines | ||
| 2139 | 2139 | goto err_take_id; |
| 2140 | 2140 | } |
| 2141 | 2141 | |
| 2142 | + utimer->id = utimer_id; | |
| 2143 | + | |
| 2142 | 2144 | utimer->name = kasprintf(GFP_KERNEL, "snd-utimer%d", utimer_id); |
| 2143 | 2145 | if (!utimer->name) { |
| 2144 | 2146 | err = -ENOMEM; |
| 2145 | 2147 | goto err_get_name; |
| 2146 | 2148 | } |
| 2147 | 2149 | |
| 2148 | − utimer->id = utimer_id; | |
| 2149 | − | |
| 2150 | 2150 | tid.dev_sclass = SNDRV_TIMER_SCLASS_APPLICATION; |
| 2151 | 2151 | tid.dev_class = SNDRV_TIMER_CLASS_GLOBAL; |
| 2152 | 2152 | tid.card = -1; |
| @@ -510,6 +510,15 @@ static void alc256_shutup(struct hda_codec *codec) · 509 unmodified lines | ||
| 510 | 510 | hp_pin = 0x21; |
| 511 | 511 | |
| 512 | 512 | alc_update_coefex_idx(codec, 0x57, 0x04, 0x0007, 0x1); /* Low power */ |
| 513 | + | |
| 514 | + /* 3k pull low control for Headset jack. */ | |
| 515 | + /* NOTE: call this before clearing the pin, otherwise codec stalls */ | |
| 516 | + /* If disable 3k pulldown control for alc257, the Mic detection will not work correctly | |
| 517 | + * when booting with headset plugged. So skip setting it for the codec alc257 | |
| 518 | + */ | |
| 519 | + if (spec->en_3kpull_low) | |
| 520 | + alc_update_coef_idx(codec, 0x46, 0, 3 << 12); | |
| 521 | + | |
| 513 | 522 | hp_pin_sense = snd_hda_jack_detect(codec, hp_pin); |
| 514 | 523 | |
| 515 | 524 | if (hp_pin_sense) { |
| @@ -520,14 +529,6 @@ static void alc256_shutup(struct hda_codec *codec) · 4 unmodified lines | ||
| 520 | 529 | |
| 521 | 530 | msleep(75); |
| 522 | 531 | |
| 523 | − /* 3k pull low control for Headset jack. */ | |
| 524 | − /* NOTE: call this before clearing the pin, otherwise codec stalls */ | |
| 525 | − /* If disable 3k pulldown control for alc257, the Mic detection will not work correctly | |
| 526 | − * when booting with headset plugged. So skip setting it for the codec alc257 | |
| 527 | − */ | |
| 528 | − if (spec->en_3kpull_low) | |
| 529 | − alc_update_coef_idx(codec, 0x46, 0, 3 << 12); | |
| 530 | − | |
| 531 | 532 | if (!spec->no_shutup_pins) |
| 532 | 533 | snd_hda_codec_write(codec, hp_pin, 0, |
| 533 | 534 | AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0); |
| @@ -3579,6 +3580,7 @@ enum { · 3045 unmodified lines | ||
| 3579 | 3580 | ALC286_FIXUP_ACER_AIO_MIC_NO_PRESENCE, |
| 3580 | 3581 | ALC294_FIXUP_ASUS_MIC, |
| 3581 | 3582 | ALC294_FIXUP_ASUS_HEADSET_MIC, |
| 3583 | + ALC294_FIXUP_ASUS_I2C_HEADSET_MIC, | |
| 3582 | 3584 | ALC294_FIXUP_ASUS_SPK, |
| 3583 | 3585 | ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE, |
| 3584 | 3586 | ALC285_FIXUP_LENOVO_PC_BEEP_IN_NOISE, |
| @@ -4889,6 +4891,15 @@ static const struct hda_fixup alc269_fixups[] = { · 1304 unmodified lines | ||
| 4889 | 4891 | .chained = true, |
| 4890 | 4892 | .chain_id = ALC269_FIXUP_HEADSET_MIC |
| 4891 | 4893 | }, |
| 4894 | + [ALC294_FIXUP_ASUS_I2C_HEADSET_MIC] = { | |
| 4895 | + .type = HDA_FIXUP_PINS, | |
| 4896 | + .v.pins = (const struct hda_pintbl[]) { | |
| 4897 | + { 0x19, 0x03a19020 }, /* use as headset mic */ | |
| 4898 | + { } | |
| 4899 | + }, | |
| 4900 | + .chained = true, | |
| 4901 | + .chain_id = ALC287_FIXUP_CS35L41_I2C_2 | |
| 4902 | + }, | |
| 4892 | 4903 | [ALC294_FIXUP_ASUS_SPK] = { |
| 4893 | 4904 | .type = HDA_FIXUP_VERBS, |
| 4894 | 4905 | .v.verbs = (const struct hda_verb[]) { |
| @@ -6368,6 +6379,8 @@ static const struct hda_quirk alc269_fixup_tbl[] = { · 1473 unmodified lines | ||
| 6368 | 6379 | SND_PCI_QUIRK(0x103c, 0x84e7, "HP Pavilion 15", ALC269_FIXUP_HP_MUTE_LED_MIC3), |
| 6369 | 6380 | SND_PCI_QUIRK(0x103c, 0x8519, "HP Spectre x360 15-df0xxx", ALC285_FIXUP_HP_SPECTRE_X360), |
| 6370 | 6381 | SND_PCI_QUIRK(0x103c, 0x8537, "HP ProBook 440 G6", ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF), |
| 6382 | + SND_PCI_QUIRK(0x103c, 0x8548, "HP EliteBook x360 830 G6", ALC285_FIXUP_HP_GPIO_LED), | |
| 6383 | + SND_PCI_QUIRK(0x103c, 0x854a, "HP EliteBook 830 G6", ALC285_FIXUP_HP_GPIO_LED), | |
| 6371 | 6384 | SND_PCI_QUIRK(0x103c, 0x85c6, "HP Pavilion x360 Convertible 14-dy1xxx", ALC295_FIXUP_HP_MUTE_LED_COEFBIT11), |
| 6372 | 6385 | SND_PCI_QUIRK(0x103c, 0x85de, "HP Envy x360 13-ar0xxx", ALC285_FIXUP_HP_ENVY_X360), |
| 6373 | 6386 | SND_PCI_QUIRK(0x103c, 0x860f, "HP ZBook 15 G6", ALC285_FIXUP_HP_GPIO_AMP_INIT), |
| @@ -6728,7 +6741,7 @@ static const struct hda_quirk alc269_fixup_tbl[] = { · 354 unmodified lines | ||
| 6728 | 6741 | SND_PCI_QUIRK(0x1043, 0x1b13, "ASUS U41SV/GA403U", ALC285_FIXUP_ASUS_GA403U_HEADSET_MIC), |
| 6729 | 6742 | SND_PCI_QUIRK(0x1043, 0x1b93, "ASUS G614JVR/JIR", ALC245_FIXUP_CS35L41_SPI_2), |
| 6730 | 6743 | SND_PCI_QUIRK(0x1043, 0x1bbd, "ASUS Z550MA", ALC255_FIXUP_ASUS_MIC_NO_PRESENCE), |
| 6731 | − SND_PCI_QUIRK(0x1043, 0x1c03, "ASUS UM3406HA", ALC287_FIXUP_CS35L41_I2C_2), | |
| 6744 | + SND_PCI_QUIRK(0x1043, 0x1c03, "ASUS UM3406HA", ALC294_FIXUP_ASUS_I2C_HEADSET_MIC), | |
| 6732 | 6745 | SND_PCI_QUIRK(0x1043, 0x1c23, "Asus X55U", ALC269_FIXUP_LIMIT_INT_MIC_BOOST), |
| 6733 | 6746 | SND_PCI_QUIRK(0x1043, 0x1c33, "ASUS UX5304MA", ALC245_FIXUP_CS35L41_SPI_2), |
| 6734 | 6747 | SND_PCI_QUIRK(0x1043, 0x1c43, "ASUS UX8406MA", ALC245_FIXUP_CS35L41_SPI_2), |
| @@ -267,7 +267,7 @@ static const struct snd_kcontrol_new tas2770_snd_controls[] = { · 266 unmodified lines | ||
| 267 | 267 | static const struct snd_kcontrol_new tas2781_snd_controls[] = { |
| 268 | 268 | ACARD_SINGLE_RANGE_EXT_TLV("Speaker Analog Volume", TAS2781_AMP_LEVEL, |
| 269 | 269 | 1, 0, 20, 0, tas2781_amp_getvol, |
| 270 | − tas2781_amp_putvol, amp_vol_tlv), | |
| 270 | + tas2781_amp_putvol, tas2781_amp_tlv), | |
| 271 | 271 | ACARD_SINGLE_BOOL_EXT("Speaker Force Firmware Load", 0, |
| 272 | 272 | tas2781_force_fwload_get, tas2781_force_fwload_put), |
| 273 | 273 | }; |
| @@ -305,7 +305,7 @@ static int tas2563_save_calibration(struct tas2781_hda *h) · 31 unmodified lines | ||
| 305 | 305 | efi_char16_t efi_name[TAS2563_CAL_VAR_NAME_MAX]; |
| 306 | 306 | unsigned long max_size = TAS2563_CAL_DATA_SIZE; |
| 307 | 307 | unsigned char var8[TAS2563_CAL_VAR_NAME_MAX]; |
| 308 | − struct tasdevice_priv *p = h->hda_priv; | |
| 308 | + struct tasdevice_priv *p = h->priv; | |
| 309 | 309 | struct calidata *cd = &p->cali_data; |
| 310 | 310 | struct cali_reg *r = &cd->cali_reg_array; |
| 311 | 311 | unsigned int offset = 0; |
| @@ -494,9 +494,11 @@ static int tas2781_force_fwload_put(struct snd_kcontrol *kcontrol, · 493 unmodified lines | ||
| 494 | 494 | |
| 495 | 495 | static struct snd_kcontrol_new tas2781_snd_ctls[] = { |
| 496 | 496 | ACARD_SINGLE_RANGE_EXT_TLV(NULL, TAS2781_AMP_LEVEL, 1, 0, 20, 0, |
| 497 | − tas2781_amp_getvol, tas2781_amp_putvol, amp_vol_tlv), | |
| 497 | + tas2781_amp_getvol, tas2781_amp_putvol, | |
| 498 | + tas2781_amp_tlv), | |
| 498 | 499 | ACARD_SINGLE_RANGE_EXT_TLV(NULL, TAS2781_DVC_LVL, 0, 0, 200, 1, |
| 499 | − tas2781_digital_getvol, tas2781_digital_putvol, dvc_tlv), | |
| 500 | + tas2781_digital_getvol, tas2781_digital_putvol, | |
| 501 | + tas2781_dvc_tlv), | |
| 500 | 502 | ACARD_SINGLE_BOOL_EXT(NULL, 0, tas2781_force_fwload_get, |
| 501 | 503 | tas2781_force_fwload_put), |
| 502 | 504 | }; |
| @@ -393,74 +393,6 @@ static int cs35l56_sdw_update_status(struct sdw_slave *peripheral, · 392 unmodified lines | ||
| 393 | 393 | return 0; |
| 394 | 394 | } |
| 395 | 395 | |
| 396 | −static int cs35l63_sdw_kick_divider(struct cs35l56_private *cs35l56, | |
| 397 | − struct sdw_slave *peripheral) | |
| 398 | −{ | |
| 399 | − unsigned int curr_scale_reg, next_scale_reg; | |
| 400 | − int curr_scale, next_scale, ret; | |
| 401 | − | |
| 402 | − if (!cs35l56->base.init_done) | |
| 403 | − return 0; | |
| 404 | − | |
| 405 | − if (peripheral->bus->params.curr_bank) { | |
| 406 | − curr_scale_reg = SDW_SCP_BUSCLOCK_SCALE_B1; | |
| 407 | − next_scale_reg = SDW_SCP_BUSCLOCK_SCALE_B0; | |
| 408 | − } else { | |
| 409 | − curr_scale_reg = SDW_SCP_BUSCLOCK_SCALE_B0; | |
| 410 | − next_scale_reg = SDW_SCP_BUSCLOCK_SCALE_B1; | |
| 411 | − } | |
| 412 | − | |
| 413 | − /* | |
| 414 | − * Current clock scale value must be different to new value. | |
| 415 | − * Modify current to guarantee this. If next still has the dummy | |
| 416 | − * value we wrote when it was current, the core code has not set | |
| 417 | − * a new scale so restore its original good value | |
| 418 | − */ | |
| 419 | − curr_scale = sdw_read_no_pm(peripheral, curr_scale_reg); | |
| 420 | − if (curr_scale < 0) { | |
| 421 | − dev_err(cs35l56->base.dev, "Failed to read current clock scale: %d\n", curr_scale); | |
| 422 | − return curr_scale; | |
| 423 | − } | |
| 424 | − | |
| 425 | − next_scale = sdw_read_no_pm(peripheral, next_scale_reg); | |
| 426 | − if (next_scale < 0) { | |
| 427 | − dev_err(cs35l56->base.dev, "Failed to read next clock scale: %d\n", next_scale); | |
| 428 | − return next_scale; | |
| 429 | − } | |
| 430 | − | |
| 431 | − if (next_scale == CS35L56_SDW_INVALID_BUS_SCALE) { | |
| 432 | − next_scale = cs35l56->old_sdw_clock_scale; | |
| 433 | − ret = sdw_write_no_pm(peripheral, next_scale_reg, next_scale); | |
| 434 | − if (ret < 0) { | |
| 435 | − dev_err(cs35l56->base.dev, "Failed to modify current clock scale: %d\n", | |
| 436 | − ret); | |
| 437 | − return ret; | |
| 438 | − } | |
| 439 | − } | |
| 440 | − | |
| 441 | − cs35l56->old_sdw_clock_scale = curr_scale; | |
| 442 | − ret = sdw_write_no_pm(peripheral, curr_scale_reg, CS35L56_SDW_INVALID_BUS_SCALE); | |
| 443 | − if (ret < 0) { | |
| 444 | − dev_err(cs35l56->base.dev, "Failed to modify current clock scale: %d\n", ret); | |
| 445 | − return ret; | |
| 446 | − } | |
| 447 | − | |
| 448 | − dev_dbg(cs35l56->base.dev, "Next bus scale: %#x\n", next_scale); | |
| 449 | − | |
| 450 | − return 0; | |
| 451 | −} | |
| 452 | − | |
| 453 | −static int cs35l56_sdw_bus_config(struct sdw_slave *peripheral, | |
| 454 | − struct sdw_bus_params *params) | |
| 455 | −{ | |
| 456 | − struct cs35l56_private *cs35l56 = dev_get_drvdata(&peripheral->dev); | |
| 457 | − | |
| 458 | − if ((cs35l56->base.type == 0x63) && (cs35l56->base.rev < 0xa1)) | |
| 459 | − return cs35l63_sdw_kick_divider(cs35l56, peripheral); | |
| 460 | − | |
| 461 | − return 0; | |
| 462 | −} | |
| 463 | − | |
| 464 | 396 | static int __maybe_unused cs35l56_sdw_clk_stop(struct sdw_slave *peripheral, |
| 465 | 397 | enum sdw_clk_stop_mode mode, |
| 466 | 398 | enum sdw_clk_stop_type type) |
| @@ -476,7 +408,6 @@ static const struct sdw_slave_ops cs35l56_sdw_ops = { · 9 unmodified lines | ||
| 476 | 408 | .read_prop = cs35l56_sdw_read_prop, |
| 477 | 409 | .interrupt_callback = cs35l56_sdw_interrupt, |
| 478 | 410 | .update_status = cs35l56_sdw_update_status, |
| 479 | − .bus_config = cs35l56_sdw_bus_config, | |
| 480 | 411 | #ifdef DEBUG |
| 481 | 412 | .clk_stop = cs35l56_sdw_clk_stop, |
| 482 | 413 | #endif |
| @@ -838,6 +838,15 @@ const struct cirrus_amp_cal_controls cs35l56_calibration_controls = { · 837 unmodified lines | ||
| 838 | 838 | }; |
| 839 | 839 | EXPORT_SYMBOL_NS_GPL(cs35l56_calibration_controls, "SND_SOC_CS35L56_SHARED"); |
| 840 | 840 | |
| 841 | +static const struct cirrus_amp_cal_controls cs35l63_calibration_controls = { | |
| 842 | + .alg_id = 0xbf210, | |
| 843 | + .mem_region = WMFW_ADSP2_YM, | |
| 844 | + .ambient = "CAL_AMBIENT", | |
| 845 | + .calr = "CAL_R", | |
| 846 | + .status = "CAL_STATUS", | |
| 847 | + .checksum = "CAL_CHECKSUM", | |
| 848 | +}; | |
| 849 | + | |
| 841 | 850 | int cs35l56_get_calibration(struct cs35l56_base *cs35l56_base) |
| 842 | 851 | { |
| 843 | 852 | u64 silicon_uid = 0; |
| @@ -912,19 +921,31 @@ EXPORT_SYMBOL_NS_GPL(cs35l56_read_prot_status, "SND_SOC_CS35L56_SHARED"); · 68 unmodified lines | ||
| 912 | 921 | void cs35l56_log_tuning(struct cs35l56_base *cs35l56_base, struct cs_dsp *cs_dsp) |
| 913 | 922 | { |
| 914 | 923 | __be32 pid, sid, tid; |
| 924 | + unsigned int alg_id; | |
| 915 | 925 | int ret; |
| 916 | 926 | |
| 927 | + switch (cs35l56_base->type) { | |
| 928 | + case 0x54: | |
| 929 | + case 0x56: | |
| 930 | + case 0x57: | |
| 931 | + alg_id = 0x9f212; | |
| 932 | + break; | |
| 933 | + default: | |
| 934 | + alg_id = 0xbf212; | |
| 935 | + break; | |
| 936 | + } | |
| 937 | + | |
| 917 | 938 | scoped_guard(mutex, &cs_dsp->pwr_lock) { |
| 918 | 939 | ret = cs_dsp_coeff_read_ctrl(cs_dsp_get_ctl(cs_dsp, "AS_PRJCT_ID", |
| 919 | − WMFW_ADSP2_XM, 0x9f212), | |
| 940 | + WMFW_ADSP2_XM, alg_id), | |
| 920 | 941 | 0, &pid, sizeof(pid)); |
| 921 | 942 | if (!ret) |
| 922 | 943 | ret = cs_dsp_coeff_read_ctrl(cs_dsp_get_ctl(cs_dsp, "AS_CHNNL_ID", |
| 923 | − WMFW_ADSP2_XM, 0x9f212), | |
| 944 | + WMFW_ADSP2_XM, alg_id), | |
| 924 | 945 | 0, &sid, sizeof(sid)); |
| 925 | 946 | if (!ret) |
| 926 | 947 | ret = cs_dsp_coeff_read_ctrl(cs_dsp_get_ctl(cs_dsp, "AS_SNPSHT_ID", |
| 927 | − WMFW_ADSP2_XM, 0x9f212), | |
| 948 | + WMFW_ADSP2_XM, alg_id), | |
| 928 | 949 | 0, &tid, sizeof(tid)); |
| 929 | 950 | } |
| 930 | 951 | |
| @@ -974,8 +995,10 @@ int cs35l56_hw_init(struct cs35l56_base *cs35l56_base) · 43 unmodified lines | ||
| 974 | 995 | case 0x35A54: |
| 975 | 996 | case 0x35A56: |
| 976 | 997 | case 0x35A57: |
| 998 | + cs35l56_base->calibration_controls = &cs35l56_calibration_controls; | |
| 977 | 999 | break; |
| 978 | 1000 | case 0x35A630: |
| 1001 | + cs35l56_base->calibration_controls = &cs35l63_calibration_controls; | |
| 979 | 1002 | devid = devid >> 4; |
| 980 | 1003 | break; |
| 981 | 1004 | default: |
| @@ -695,7 +695,7 @@ static int cs35l56_write_cal(struct cs35l56_private *cs35l56) · 694 unmodified lines | ||
| 695 | 695 | return ret; |
| 696 | 696 | |
| 697 | 697 | ret = cs_amp_write_cal_coeffs(&cs35l56->dsp.cs_dsp, |
| 698 | − &cs35l56_calibration_controls, | |
| 698 | + cs35l56->base.calibration_controls, | |
| 699 | 699 | &cs35l56->base.cal_data); |
| 700 | 700 | |
| 701 | 701 | wm_adsp_stop(&cs35l56->dsp); |
| @@ -20,8 +20,6 @@ · 19 unmodified lines | ||
| 20 | 20 | #define CS35L56_SDW_GEN_INT_MASK_1 0xc1 |
| 21 | 21 | #define CS35L56_SDW_INT_MASK_CODEC_IRQ BIT(0) |
| 22 | 22 | |
| 23 | −#define CS35L56_SDW_INVALID_BUS_SCALE 0xf | |
| 24 | − | |
| 25 | 23 | #define CS35L56_RX_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE) |
| 26 | 24 | #define CS35L56_TX_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE \ |
| 27 | 25 | | SNDRV_PCM_FMTBIT_S32_LE) |
| @@ -52,7 +50,6 @@ struct cs35l56_private { · 24 unmodified lines | ||
| 52 | 50 | u8 asp_slot_count; |
| 53 | 51 | bool tdm_mode; |
| 54 | 52 | bool sysclk_set; |
| 55 | − u8 old_sdw_clock_scale; | |
| 56 | 53 | u8 sdw_link_num; |
| 57 | 54 | u8 sdw_unique_id; |
| 58 | 55 | }; |
| @@ -636,7 +636,7 @@ static int es8389_set_bias_level(struct snd_soc_component *component, · 635 unmodified lines | ||
| 636 | 636 | regmap_write(es8389->regmap, ES8389_ANA_CTL1, 0x59); |
| 637 | 637 | regmap_write(es8389->regmap, ES8389_ADC_EN, 0x00); |
| 638 | 638 | regmap_write(es8389->regmap, ES8389_CLK_OFF1, 0x00); |
| 639 | − regmap_write(es8389->regmap, ES8389_RESET, 0x7E); | |
| 639 | + regmap_write(es8389->regmap, ES8389_RESET, 0x3E); | |
| 640 | 640 | regmap_update_bits(es8389->regmap, ES8389_DAC_INV, 0x80, 0x80); |
| 641 | 641 | usleep_range(8000, 8500); |
| 642 | 642 | regmap_update_bits(es8389->regmap, ES8389_DAC_INV, 0x80, 0x00); |
| @@ -910,10 +910,10 @@ static const struct snd_kcontrol_new tasdevice_cali_controls[] = { · 909 unmodified lines | ||
| 910 | 910 | static const struct snd_kcontrol_new tas2781_snd_controls[] = { |
| 911 | 911 | SOC_SINGLE_RANGE_EXT_TLV("Speaker Analog Volume", TAS2781_AMP_LEVEL, |
| 912 | 912 | 1, 0, 20, 0, tas2781_amp_getvol, |
| 913 | − tas2781_amp_putvol, amp_vol_tlv), | |
| 913 | + tas2781_amp_putvol, tas2781_amp_tlv), | |
| 914 | 914 | SOC_SINGLE_RANGE_EXT_TLV("Speaker Digital Volume", TAS2781_DVC_LVL, |
| 915 | 915 | 0, 0, 200, 1, tas2781_digital_getvol, |
| 916 | − tas2781_digital_putvol, dvc_tlv), | |
| 916 | + tas2781_digital_putvol, tas2781_dvc_tlv), | |
| 917 | 917 | }; |
| 918 | 918 | |
| 919 | 919 | static const struct snd_kcontrol_new tas2781_cali_controls[] = { |
| @@ -349,7 +349,7 @@ snd_pcm_chmap_elem *convert_chmap_v3(struct uac3_cluster_header_descriptor · 348 unmodified lines | ||
| 349 | 349 | u16 cs_len; |
| 350 | 350 | u8 cs_type; |
| 351 | 351 | |
| 352 | − if (len < sizeof(*p)) | |
| 352 | + if (len < sizeof(*cs_desc)) | |
| 353 | 353 | break; |
| 354 | 354 | cs_len = le16_to_cpu(cs_desc->wLength); |
| 355 | 355 | if (len < cs_len) |
| @@ -285,7 +285,7 @@ static const struct usb_desc_validator audio_validators[] = { · 284 unmodified lines | ||
| 285 | 285 | /* UAC_VERSION_3, UAC3_EXTENDED_TERMINAL: not implemented yet */ |
| 286 | 286 | FUNC(UAC_VERSION_3, UAC3_MIXER_UNIT, validate_mixer_unit), |
| 287 | 287 | FUNC(UAC_VERSION_3, UAC3_SELECTOR_UNIT, validate_selector_unit), |
| 288 | − FUNC(UAC_VERSION_3, UAC_FEATURE_UNIT, validate_uac3_feature_unit), | |
| 288 | + FUNC(UAC_VERSION_3, UAC3_FEATURE_UNIT, validate_uac3_feature_unit), | |
| 289 | 289 | /* UAC_VERSION_3, UAC3_EFFECT_UNIT: not implemented yet */ |
| 290 | 290 | FUNC(UAC_VERSION_3, UAC3_PROCESSING_UNIT, validate_processing_unit), |
| 291 | 291 | FUNC(UAC_VERSION_3, UAC3_EXTENSION_UNIT, validate_processing_unit), |
| @@ -193,7 +193,7 @@ static int load_xbc_from_initrd(int fd, char **buf) · 192 unmodified lines | ||
| 193 | 193 | if (stat.st_size < BOOTCONFIG_FOOTER_SIZE) |
| 194 | 194 | return 0; |
| 195 | 195 | |
| 196 | − if (lseek(fd, -BOOTCONFIG_MAGIC_LEN, SEEK_END) < 0) | |
| 196 | + if (lseek(fd, -(off_t)BOOTCONFIG_MAGIC_LEN, SEEK_END) < 0) | |
| 197 | 197 | return pr_errno("Failed to lseek for magic", -errno); |
| 198 | 198 | |
| 199 | 199 | if (read(fd, magic, BOOTCONFIG_MAGIC_LEN) < 0) |
| @@ -203,7 +203,7 @@ static int load_xbc_from_initrd(int fd, char **buf) · 3 unmodified lines | ||
| 203 | 203 | if (memcmp(magic, BOOTCONFIG_MAGIC, BOOTCONFIG_MAGIC_LEN) != 0) |
| 204 | 204 | return 0; |
| 205 | 205 | |
| 206 | − if (lseek(fd, -BOOTCONFIG_FOOTER_SIZE, SEEK_END) < 0) | |
| 206 | + if (lseek(fd, -(off_t)BOOTCONFIG_FOOTER_SIZE, SEEK_END) < 0) | |
| 207 | 207 | return pr_errno("Failed to lseek for size", -errno); |
| 208 | 208 | |
| 209 | 209 | if (read(fd, &size, sizeof(uint32_t)) < 0) |
| @@ -0,0 +1,28 @@ | ||
| 1 | +/* SPDX-License-Identifier: GPL-2.0 */ | |
| 2 | + | |
| 3 | +#ifndef _LINUX_ARGS_H | |
| 4 | +#define _LINUX_ARGS_H | |
| 5 | + | |
| 6 | +/* | |
| 7 | + * How do these macros work? | |
| 8 | + * | |
| 9 | + * In __COUNT_ARGS() _0 to _12 are just placeholders from the start | |
| 10 | + * in order to make sure _n is positioned over the correct number | |
| 11 | + * from 12 to 0 (depending on X, which is a variadic argument list). | |
| 12 | + * They serve no purpose other than occupying a position. Since each | |
| 13 | + * macro parameter must have a distinct identifier, those identifiers | |
| 14 | + * are as good as any. | |
| 15 | + * | |
| 16 | + * In COUNT_ARGS() we use actual integers, so __COUNT_ARGS() returns | |
| 17 | + * that as _n. | |
| 18 | + */ | |
| 19 | + | |
| 20 | +/* This counts to 15. Any more, it will return 16th argument. */ | |
| 21 | +#define __COUNT_ARGS(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _n, X...) _n | |
| 22 | +#define COUNT_ARGS(X...) __COUNT_ARGS(, ##X, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0) | |
| 23 | + | |
| 24 | +/* Concatenate two parameters, but allow them to be expanded beforehand. */ | |
| 25 | +#define __CONCAT(a, b) a ## b | |
| 26 | +#define CONCATENATE(a, b) __CONCAT(a, b) | |
| 27 | + | |
| 28 | +#endif /* _LINUX_ARGS_H */ | |
| @@ -27,6 +27,7 @@ static void get_rodata_table_size_by_table_annotate(struct objtool_file *file, · 26 unmodified lines | ||
| 27 | 27 | struct table_info *next_table; |
| 28 | 28 | unsigned long tmp_insn_offset; |
| 29 | 29 | unsigned long tmp_rodata_offset; |
| 30 | + bool is_valid_list = false; | |
| 30 | 31 | |
| 31 | 32 | rsec = find_section_by_name(file->elf, ".rela.discard.tablejump_annotate"); |
| 32 | 33 | if (!rsec) |
| @@ -35,6 +36,12 @@ static void get_rodata_table_size_by_table_annotate(struct objtool_file *file, · 2 unmodified lines | ||
| 35 | 36 | INIT_LIST_HEAD(&table_list); |
| 36 | 37 | |
| 37 | 38 | for_each_reloc(rsec, reloc) { |
| 39 | + if (reloc->sym->sec->rodata) | |
| 40 | + continue; | |
| 41 | + | |
| 42 | + if (strcmp(insn->sec->name, reloc->sym->sec->name)) | |
| 43 | + continue; | |
| 44 | + | |
| 38 | 45 | orig_table = malloc(sizeof(struct table_info)); |
| 39 | 46 | if (!orig_table) { |
| 40 | 47 | WARN("malloc failed"); |
| @@ -49,6 +56,22 @@ static void get_rodata_table_size_by_table_annotate(struct objtool_file *file, · 8 unmodified lines | ||
| 49 | 56 | |
| 50 | 57 | if (reloc_idx(reloc) + 1 == sec_num_entries(rsec)) |
| 51 | 58 | break; |
| 59 | + | |
| 60 | + if (strcmp(insn->sec->name, (reloc + 1)->sym->sec->name)) { | |
| 61 | + list_for_each_entry(orig_table, &table_list, jump_info) { | |
| 62 | + if (orig_table->insn_offset == insn->offset) { | |
| 63 | + is_valid_list = true; | |
| 64 | + break; | |
| 65 | + } | |
| 66 | + } | |
| 67 | + | |
| 68 | + if (!is_valid_list) { | |
| 69 | + list_del_init(&table_list); | |
| 70 | + continue; | |
| 71 | + } | |
| 72 | + | |
| 73 | + break; | |
| 74 | + } | |
| 52 | 75 | } |
| 53 | 76 | |
| 54 | 77 | list_for_each_entry(orig_table, &table_list, jump_info) { |
| @@ -81,10 +81,11 @@ Refer to the AMD P-State kernel documentation for further information. · 80 unmodified lines | ||
| 81 | 81 | .RE |
| 82 | 82 | |
| 83 | 83 | .PP |
| 84 | −\-\-turbo\-boost, \-t | |
| 84 | +\-\-turbo\-boost, \-\-boost, \-t | |
| 85 | 85 | .RS 4 |
| 86 | −This option is used to enable or disable the turbo boost feature on | |
| 87 | −supported Intel and AMD processors. | |
| 86 | +This option is used to enable or disable the boost feature on | |
| 87 | +supported Intel and AMD processors, and other boost supported systems. | |
| 88 | +(The --boost option is an alias for the --turbo-boost option) | |
| 88 | 89 | |
| 89 | 90 | This option takes as parameter either \fB1\fP to enable, or \fB0\fP to disable the feature. |
| 90 | 91 | |
| @@ -128,7 +128,7 @@ static int get_boost_mode_x86(unsigned int cpu) · 127 unmodified lines | ||
| 128 | 128 | /* ToDo: Make this more global */ |
| 129 | 129 | unsigned long pstates[MAX_HW_PSTATES] = {0,}; |
| 130 | 130 | |
| 131 | − ret = cpufreq_has_boost_support(cpu, &support, &active, &b_states); | |
| 131 | + ret = cpufreq_has_x86_boost_support(cpu, &support, &active, &b_states); | |
| 132 | 132 | if (ret) { |
| 133 | 133 | printf(_("Error while evaluating Boost Capabilities" |
| 134 | 134 | " on CPU %d -- are you root?\n"), cpu); |
| @@ -204,6 +204,18 @@ static int get_boost_mode_x86(unsigned int cpu) · 69 unmodified lines | ||
| 204 | 204 | return 0; |
| 205 | 205 | } |
| 206 | 206 | |
| 207 | +static int get_boost_mode_generic(unsigned int cpu) | |
| 208 | +{ | |
| 209 | + bool active; | |
| 210 | + | |
| 211 | + if (!cpufreq_has_generic_boost_support(&active)) { | |
| 212 | + printf(_(" boost state support:\n")); | |
| 213 | + printf(_(" Active: %s\n"), active ? _("yes") : _("no")); | |
| 214 | + } | |
| 215 | + | |
| 216 | + return 0; | |
| 217 | +} | |
| 218 | + | |
| 207 | 219 | /* --boost / -b */ |
| 208 | 220 | |
| 209 | 221 | static int get_boost_mode(unsigned int cpu) |
| @@ -214,6 +226,8 @@ static int get_boost_mode(unsigned int cpu) · 4 unmodified lines | ||
| 214 | 226 | cpupower_cpu_info.vendor == X86_VENDOR_HYGON || |
| 215 | 227 | cpupower_cpu_info.vendor == X86_VENDOR_INTEL) |
| 216 | 228 | return get_boost_mode_x86(cpu); |
| 229 | + else | |
| 230 | + get_boost_mode_generic(cpu); | |
| 217 | 231 | |
| 218 | 232 | freqs = cpufreq_get_boost_frequencies(cpu); |
| 219 | 233 | if (freqs) { |
| @@ -21,6 +21,7 @@ static struct option set_opts[] = { · 20 unmodified lines | ||
| 21 | 21 | {"epp", required_argument, NULL, 'e'}, |
| 22 | 22 | {"amd-pstate-mode", required_argument, NULL, 'm'}, |
| 23 | 23 | {"turbo-boost", required_argument, NULL, 't'}, |
| 24 | + {"boost", required_argument, NULL, 't'}, | |
| 24 | 25 | { }, |
| 25 | 26 | }; |
| 26 | 27 | |
| @@ -62,8 +63,8 @@ int cmd_set(int argc, char **argv) · 35 unmodified lines | ||
| 62 | 63 | |
| 63 | 64 | params.params = 0; |
| 64 | 65 | /* parameter parsing */ |
| 65 | − while ((ret = getopt_long(argc, argv, "b:e:m:", | |
| 66 | − set_opts, NULL)) != -1) { | |
| 66 | + while ((ret = getopt_long(argc, argv, "b:e:m:t:", | |
| 67 | + set_opts, NULL)) != -1) { | |
| 67 | 68 | switch (ret) { |
| 68 | 69 | case 'b': |
| 69 | 70 | if (params.perf_bias) |
| @@ -103,6 +103,9 @@ extern struct cpupower_cpu_info cpupower_cpu_info; · 102 unmodified lines | ||
| 103 | 103 | |
| 104 | 104 | /* cpuid and cpuinfo helpers **************************/ |
| 105 | 105 | |
| 106 | +int cpufreq_has_generic_boost_support(bool *active); | |
| 107 | +int cpupower_set_turbo_boost(int turbo_boost); | |
| 108 | + | |
| 106 | 109 | /* X86 ONLY ****************************************/ |
| 107 | 110 | #if defined(__i386__) || defined(__x86_64__) |
| 108 | 111 | |
| @@ -118,7 +121,6 @@ extern unsigned long long msr_intel_get_turbo_ratio(unsigned int cpu); · 9 unmodified lines | ||
| 118 | 121 | |
| 119 | 122 | extern int cpupower_set_epp(unsigned int cpu, char *epp); |
| 120 | 123 | extern int cpupower_set_amd_pstate_mode(char *mode); |
| 121 | −extern int cpupower_set_turbo_boost(int turbo_boost); | |
| 122 | 124 | |
| 123 | 125 | /* Read/Write msr ****************************/ |
| 124 | 126 | |
| @@ -139,8 +141,8 @@ extern int decode_pstates(unsigned int cpu, int boost_states, · 14 unmodified lines | ||
| 139 | 141 | |
| 140 | 142 | /* AMD HW pstate decoding **************************/ |
| 141 | 143 | |
| 142 | −extern int cpufreq_has_boost_support(unsigned int cpu, int *support, | |
| 143 | − int *active, int * states); | |
| 144 | +int cpufreq_has_x86_boost_support(unsigned int cpu, int *support, | |
| 145 | + int *active, int *states); | |
| 144 | 146 | |
| 145 | 147 | /* AMD P-State stuff **************************/ |
| 146 | 148 | bool cpupower_amd_pstate_enabled(void); |
| @@ -181,13 +183,11 @@ static inline int cpupower_set_epp(unsigned int cpu, char *epp) · 34 unmodified lines | ||
| 181 | 183 | { return -1; }; |
| 182 | 184 | static inline int cpupower_set_amd_pstate_mode(char *mode) |
| 183 | 185 | { return -1; }; |
| 184 | −static inline int cpupower_set_turbo_boost(int turbo_boost) | |
| 185 | −{ return -1; }; | |
| 186 | 186 | |
| 187 | 187 | /* Read/Write msr ****************************/ |
| 188 | 188 | |
| 189 | −static inline int cpufreq_has_boost_support(unsigned int cpu, int *support, | |
| 190 | − int *active, int * states) | |
| 189 | +static inline int cpufreq_has_x86_boost_support(unsigned int cpu, int *support, | |
| 190 | + int *active, int *states) | |
| 191 | 191 | { return -1; } |
| 192 | 192 | |
| 193 | 193 | static inline bool cpupower_amd_pstate_enabled(void) |
| @@ -8,15 +8,14 @@ · 7 unmodified lines | ||
| 8 | 8 | #include "helpers/helpers.h" |
| 9 | 9 | #include "helpers/sysfs.h" |
| 10 | 10 | #include "cpufreq.h" |
| 11 | +#include "cpupower_intern.h" | |
| 11 | 12 | |
| 12 | 13 | #if defined(__i386__) || defined(__x86_64__) |
| 13 | 14 | |
| 14 | −#include "cpupower_intern.h" | |
| 15 | − | |
| 16 | 15 | #define MSR_AMD_HWCR 0xc0010015 |
| 17 | 16 | |
| 18 | −int cpufreq_has_boost_support(unsigned int cpu, int *support, int *active, | |
| 19 | − int *states) | |
| 17 | +int cpufreq_has_x86_boost_support(unsigned int cpu, int *support, int *active, | |
| 18 | + int *states) | |
| 20 | 19 | { |
| 21 | 20 | int ret; |
| 22 | 21 | unsigned long long val; |
| @@ -124,24 +123,6 @@ int cpupower_set_amd_pstate_mode(char *mode) · 101 unmodified lines | ||
| 124 | 123 | return 0; |
| 125 | 124 | } |
| 126 | 125 | |
| 127 | −int cpupower_set_turbo_boost(int turbo_boost) | |
| 128 | −{ | |
| 129 | − char path[SYSFS_PATH_MAX]; | |
| 130 | − char linebuf[2] = {}; | |
| 131 | − | |
| 132 | − snprintf(path, sizeof(path), PATH_TO_CPU "cpufreq/boost"); | |
| 133 | − | |
| 134 | − if (!is_valid_path(path)) | |
| 135 | − return -1; | |
| 136 | − | |
| 137 | − snprintf(linebuf, sizeof(linebuf), "%d", turbo_boost); | |
| 138 | − | |
| 139 | − if (cpupower_write_sysfs(path, linebuf, 2) <= 0) | |
| 140 | − return -1; | |
| 141 | − | |
| 142 | − return 0; | |
| 143 | −} | |
| 144 | − | |
| 145 | 126 | bool cpupower_amd_pstate_enabled(void) |
| 146 | 127 | { |
| 147 | 128 | char *driver = cpufreq_get_driver(0); |
| @@ -160,6 +141,39 @@ bool cpupower_amd_pstate_enabled(void) · 12 unmodified lines | ||
| 160 | 141 | |
| 161 | 142 | #endif /* #if defined(__i386__) || defined(__x86_64__) */ |
| 162 | 143 | |
| 144 | +int cpufreq_has_generic_boost_support(bool *active) | |
| 145 | +{ | |
| 146 | + char path[SYSFS_PATH_MAX]; | |
| 147 | + char linebuf[2] = {}; | |
| 148 | + unsigned long val; | |
| 149 | + char *endp; | |
| 150 | + | |
| 151 | + snprintf(path, sizeof(path), PATH_TO_CPU "cpufreq/boost"); | |
| 152 | + | |
| 153 | + if (!is_valid_path(path)) | |
| 154 | + return -EACCES; | |
| 155 | + | |
| 156 | + if (cpupower_read_sysfs(path, linebuf, 2) <= 0) | |
| 157 | + return -EINVAL; | |
| 158 | + | |
| 159 | + val = strtoul(linebuf, &endp, 0); | |
| 160 | + if (endp == linebuf || errno == ERANGE) | |
| 161 | + return -EINVAL; | |
| 162 | + | |
| 163 | + switch (val) { | |
| 164 | + case 0: | |
| 165 | + *active = false; | |
| 166 | + break; | |
| 167 | + case 1: | |
| 168 | + *active = true; | |
| 169 | + break; | |
| 170 | + default: | |
| 171 | + return -EINVAL; | |
| 172 | + } | |
| 173 | + | |
| 174 | + return 0; | |
| 175 | +} | |
| 176 | + | |
| 163 | 177 | /* get_cpustate |
| 164 | 178 | * |
| 165 | 179 | * Gather the information of all online CPUs into bitmask struct |
| @@ -259,3 +273,21 @@ void print_speed(unsigned long speed, int no_rounding) · 93 unmodified lines | ||
| 259 | 273 | } |
| 260 | 274 | } |
| 261 | 275 | } |
| 276 | + | |
| 277 | +int cpupower_set_turbo_boost(int turbo_boost) | |
| 278 | +{ | |
| 279 | + char path[SYSFS_PATH_MAX]; | |
| 280 | + char linebuf[2] = {}; | |
| 281 | + | |
| 282 | + snprintf(path, sizeof(path), PATH_TO_CPU "cpufreq/boost"); | |
| 283 | + | |
| 284 | + if (!is_valid_path(path)) | |
| 285 | + return -1; | |
| 286 | + | |
| 287 | + snprintf(linebuf, sizeof(linebuf), "%d", turbo_boost); | |
| 288 | + | |
| 289 | + if (cpupower_write_sysfs(path, linebuf, 2) <= 0) | |
| 290 | + return -1; | |
| 291 | + | |
| 292 | + return 0; | |
| 293 | +} | |
| @@ -446,9 +446,6 @@ TEST_F(coredump, socket_detect_userspace_client) · 445 unmodified lines | ||
| 446 | 446 | if (info.coredump_mask & PIDFD_COREDUMPED) |
| 447 | 447 | goto out; |
| 448 | 448 | |
| 449 | − if (read(fd_coredump, &c, 1) < 1) | |
| 450 | − goto out; | |
| 451 | − | |
| 452 | 449 | exit_code = EXIT_SUCCESS; |
| 453 | 450 | out: |
| 454 | 451 | if (fd_peer_pidfd >= 0) |
| @@ -4,6 +4,7 @@ · 3 unmodified lines | ||
| 4 | 4 | TEST_GEN_FILES += access_memory access_memory_even |
| 5 | 5 | |
| 6 | 6 | TEST_FILES = _damon_sysfs.py |
| 7 | +TEST_FILES += drgn_dump_damon_status.py | |
| 7 | 8 | |
| 8 | 9 | # functionality tests |
| 9 | 10 | TEST_PROGS += sysfs.sh |
| @@ -10,7 +10,8 @@ TEST_PROGS := \ · 9 unmodified lines | ||
| 10 | 10 | mode-2-recovery-updelay.sh \ |
| 11 | 11 | bond_options.sh \ |
| 12 | 12 | bond-eth-type-change.sh \ |
| 13 | − bond_macvlan_ipvlan.sh | |
| 13 | + bond_macvlan_ipvlan.sh \ | |
| 14 | + bond_passive_lacp.sh | |
| 14 | 15 | |
| 15 | 16 | TEST_FILES := \ |
| 16 | 17 | lag_lib.sh \ |
| @@ -0,0 +1,105 @@ | ||
| 1 | +#!/bin/bash | |
| 2 | +# SPDX-License-Identifier: GPL-2.0 | |
| 3 | +# | |
| 4 | +# Test if a bond interface works with lacp_active=off. | |
| 5 | + | |
| 6 | +# shellcheck disable=SC2034 | |
| 7 | +REQUIRE_MZ=no | |
| 8 | +NUM_NETIFS=0 | |
| 9 | +lib_dir=$(dirname "$0") | |
| 10 | +# shellcheck disable=SC1091 | |
| 11 | +source "$lib_dir"/../../../net/forwarding/lib.sh | |
| 12 | + | |
| 13 | +# shellcheck disable=SC2317 | |
| 14 | +check_port_state() | |
| 15 | +{ | |
| 16 | + local netns=$1 | |
| 17 | + local port=$2 | |
| 18 | + local state=$3 | |
| 19 | + | |
| 20 | + ip -n "${netns}" -d -j link show "$port" | \ | |
| 21 | + jq -e ".[].linkinfo.info_slave_data.ad_actor_oper_port_state_str | index(\"${state}\") != null" > /dev/null | |
| 22 | +} | |
| 23 | + | |
| 24 | +check_pkt_count() | |
| 25 | +{ | |
| 26 | + RET=0 | |
| 27 | + local ns="$1" | |
| 28 | + local iface="$2" | |
| 29 | + | |
| 30 | + # wait 65s, one per 30s | |
| 31 | + slowwait_for_counter 65 2 tc_rule_handle_stats_get \ | |
| 32 | + "dev ${iface} egress" 101 ".packets" "-n ${ns}" &> /dev/null | |
| 33 | +} | |
| 34 | + | |
| 35 | +setup() { | |
| 36 | + setup_ns c_ns s_ns | |
| 37 | + | |
| 38 | + # shellcheck disable=SC2154 | |
| 39 | + ip -n "${c_ns}" link add eth0 type veth peer name eth0 netns "${s_ns}" | |
| 40 | + ip -n "${c_ns}" link add eth1 type veth peer name eth1 netns "${s_ns}" | |
| 41 | + | |
| 42 | + # Add tc filter to count the pkts | |
| 43 | + tc -n "${c_ns}" qdisc add dev eth0 clsact | |
| 44 | + tc -n "${c_ns}" filter add dev eth0 egress handle 101 protocol 0x8809 matchall action pass | |
| 45 | + tc -n "${s_ns}" qdisc add dev eth1 clsact | |
| 46 | + tc -n "${s_ns}" filter add dev eth1 egress handle 101 protocol 0x8809 matchall action pass | |
| 47 | + | |
| 48 | + ip -n "${s_ns}" link add bond0 type bond mode 802.3ad lacp_active on lacp_rate fast | |
| 49 | + ip -n "${s_ns}" link set eth0 master bond0 | |
| 50 | + ip -n "${s_ns}" link set eth1 master bond0 | |
| 51 | + | |
| 52 | + ip -n "${c_ns}" link add bond0 type bond mode 802.3ad lacp_active off lacp_rate fast | |
| 53 | + ip -n "${c_ns}" link set eth0 master bond0 | |
| 54 | + ip -n "${c_ns}" link set eth1 master bond0 | |
| 55 | + | |
| 56 | +} | |
| 57 | + | |
| 58 | +trap cleanup_all_ns EXIT | |
| 59 | +setup | |
| 60 | + | |
| 61 | +# The bond will send 2 lacpdu pkts during init time, let's wait at least 2s | |
| 62 | +# after interface up | |
| 63 | +ip -n "${c_ns}" link set bond0 up | |
| 64 | +sleep 2 | |
| 65 | + | |
| 66 | +# 1. The passive side shouldn't send LACPDU. | |
| 67 | +check_pkt_count "${c_ns}" "eth0" && RET=1 | |
| 68 | +log_test "802.3ad lacp_active off" "init port" | |
| 69 | + | |
| 70 | +ip -n "${s_ns}" link set bond0 up | |
| 71 | +# 2. The passive side should not have the 'active' flag. | |
| 72 | +RET=0 | |
| 73 | +slowwait 2 check_port_state "${c_ns}" "eth0" "active" && RET=1 | |
| 74 | +log_test "802.3ad lacp_active off" "port state active" | |
| 75 | + | |
| 76 | +# 3. The active side should have the 'active' flag. | |
| 77 | +RET=0 | |
| 78 | +slowwait 2 check_port_state "${s_ns}" "eth0" "active" || RET=1 | |
| 79 | +log_test "802.3ad lacp_active on" "port state active" | |
| 80 | + | |
| 81 | +# 4. Make sure the connection is not expired. | |
| 82 | +RET=0 | |
| 83 | +slowwait 5 check_port_state "${s_ns}" "eth0" "distributing" | |
| 84 | +slowwait 10 check_port_state "${s_ns}" "eth0" "expired" && RET=1 | |
| 85 | +log_test "bond 802.3ad lacp_active off" "port connection" | |
| 86 | + | |
| 87 | +# After testing, disconnect one port on each side to check the state. | |
| 88 | +ip -n "${s_ns}" link set eth0 nomaster | |
| 89 | +ip -n "${s_ns}" link set eth0 up | |
| 90 | +ip -n "${c_ns}" link set eth1 nomaster | |
| 91 | +ip -n "${c_ns}" link set eth1 up | |
| 92 | +# Due to Periodic Machine and Rx Machine state change, the bond will still | |
| 93 | +# send lacpdu pkts in a few seconds. sleep at lease 5s to make sure | |
| 94 | +# negotiation finished | |
| 95 | +sleep 5 | |
| 96 | + | |
| 97 | +# 5. The active side should keep sending LACPDU. | |
| 98 | +check_pkt_count "${s_ns}" "eth1" || RET=1 | |
| 99 | +log_test "bond 802.3ad lacp_active on" "port pkt after disconnect" | |
| 100 | + | |
| 101 | +# 6. The passive side shouldn't send LACPDU anymore. | |
| 102 | +check_pkt_count "${c_ns}" "eth0" && RET=1 | |
| 103 | +log_test "bond 802.3ad lacp_active off" "port pkt after disconnect" | |
| 104 | + | |
| 105 | +exit "$EXIT_STATUS" | |
| @@ -6,6 +6,7 @@ CONFIG_MACVLAN=y · 5 unmodified lines | ||
| 6 | 6 | CONFIG_IPVLAN=y |
| 7 | 7 | CONFIG_NET_ACT_GACT=y |
| 8 | 8 | CONFIG_NET_CLS_FLOWER=y |
| 9 | +CONFIG_NET_CLS_MATCHALL=m | |
| 9 | 10 | CONFIG_NET_SCH_INGRESS=y |
| 10 | 11 | CONFIG_NLMON=y |
| 11 | 12 | CONFIG_VETH=y |
| @@ -5,10 +5,14 @@ · 4 unmodified lines | ||
| 5 | 5 | #define _GNU_SOURCE |
| 6 | 6 | |
| 7 | 7 | #include <errno.h> |
| 8 | +#include <fcntl.h> | |
| 9 | +#include <linux/userfaultfd.h> | |
| 8 | 10 | #include <stdlib.h> |
| 9 | 11 | #include <stdio.h> |
| 10 | 12 | #include <string.h> |
| 13 | +#include <sys/ioctl.h> | |
| 11 | 14 | #include <sys/mman.h> |
| 15 | +#include <syscall.h> | |
| 12 | 16 | #include <time.h> |
| 13 | 17 | #include <stdbool.h> |
| 14 | 18 | |
| @@ -168,6 +172,7 @@ static bool is_range_mapped(FILE *maps_fp, unsigned long start, · 153 unmodified lines | ||
| 168 | 172 | |
| 169 | 173 | if (first_val <= start && second_val >= end) { |
| 170 | 174 | success = true; |
| 175 | + fflush(maps_fp); | |
| 171 | 176 | break; |
| 172 | 177 | } |
| 173 | 178 | } |
| @@ -175,6 +180,15 @@ static bool is_range_mapped(FILE *maps_fp, unsigned long start, · 1 unmodified line | ||
| 175 | 180 | return success; |
| 176 | 181 | } |
| 177 | 182 | |
| 183 | +/* Check if [ptr, ptr + size) mapped in /proc/self/maps. */ | |
| 184 | +static bool is_ptr_mapped(FILE *maps_fp, void *ptr, unsigned long size) | |
| 185 | +{ | |
| 186 | + unsigned long start = (unsigned long)ptr; | |
| 187 | + unsigned long end = start + size; | |
| 188 | + | |
| 189 | + return is_range_mapped(maps_fp, start, end); | |
| 190 | +} | |
| 191 | + | |
| 178 | 192 | /* |
| 179 | 193 | * Returns the start address of the mapping on success, else returns |
| 180 | 194 | * NULL on failure. |
| @@ -733,6 +747,249 @@ out: · 552 unmodified lines | ||
| 733 | 747 | dont_unmap ? " [dontunnmap]" : ""); |
| 734 | 748 | } |
| 735 | 749 | |
| 750 | +#ifdef __NR_userfaultfd | |
| 751 | +static void mremap_move_multi_invalid_vmas(FILE *maps_fp, | |
| 752 | + unsigned long page_size) | |
| 753 | +{ | |
| 754 | + char *test_name = "mremap move multiple invalid vmas"; | |
| 755 | + const size_t size = 10 * page_size; | |
| 756 | + bool success = true; | |
| 757 | + char *ptr, *tgt_ptr; | |
| 758 | + int uffd, err, i; | |
| 759 | + void *res; | |
| 760 | + struct uffdio_api api = { | |
| 761 | + .api = UFFD_API, | |
| 762 | + .features = UFFD_EVENT_PAGEFAULT, | |
| 763 | + }; | |
| 764 | + | |
| 765 | + uffd = syscall(__NR_userfaultfd, O_NONBLOCK); | |
| 766 | + if (uffd == -1) { | |
| 767 | + err = errno; | |
| 768 | + perror("userfaultfd"); | |
| 769 | + if (err == EPERM) { | |
| 770 | + ksft_test_result_skip("%s - missing uffd", test_name); | |
| 771 | + return; | |
| 772 | + } | |
| 773 | + success = false; | |
| 774 | + goto out; | |
| 775 | + } | |
| 776 | + if (ioctl(uffd, UFFDIO_API, &api)) { | |
| 777 | + perror("ioctl UFFDIO_API"); | |
| 778 | + success = false; | |
| 779 | + goto out_close_uffd; | |
| 780 | + } | |
| 781 | + | |
| 782 | + ptr = mmap(NULL, size, PROT_READ | PROT_WRITE, | |
| 783 | + MAP_PRIVATE | MAP_ANON, -1, 0); | |
| 784 | + if (ptr == MAP_FAILED) { | |
| 785 | + perror("mmap"); | |
| 786 | + success = false; | |
| 787 | + goto out_close_uffd; | |
| 788 | + } | |
| 789 | + | |
| 790 | + tgt_ptr = mmap(NULL, size, PROT_NONE, MAP_PRIVATE | MAP_ANON, -1, 0); | |
| 791 | + if (tgt_ptr == MAP_FAILED) { | |
| 792 | + perror("mmap"); | |
| 793 | + success = false; | |
| 794 | + goto out_close_uffd; | |
| 795 | + } | |
| 796 | + if (munmap(tgt_ptr, size)) { | |
| 797 | + perror("munmap"); | |
| 798 | + success = false; | |
| 799 | + goto out_unmap; | |
| 800 | + } | |
| 801 | + | |
| 802 | + /* | |
| 803 | + * Unmap so we end up with: | |
| 804 | + * | |
| 805 | + * 0 2 4 6 8 10 offset in buffer | |
| 806 | + * |*| |*| |*| |*| |*| | |
| 807 | + * |*| |*| |*| |*| |*| | |
| 808 | + * | |
| 809 | + * Additionally, register each with UFFD. | |
| 810 | + */ | |
| 811 | + for (i = 0; i < 10; i += 2) { | |
| 812 | + void *unmap_ptr = &ptr[(i + 1) * page_size]; | |
| 813 | + unsigned long start = (unsigned long)&ptr[i * page_size]; | |
| 814 | + struct uffdio_register reg = { | |
| 815 | + .range = { | |
| 816 | + .start = start, | |
| 817 | + .len = page_size, | |
| 818 | + }, | |
| 819 | + .mode = UFFDIO_REGISTER_MODE_MISSING, | |
| 820 | + }; | |
| 821 | + | |
| 822 | + if (ioctl(uffd, UFFDIO_REGISTER, ®) == -1) { | |
| 823 | + perror("ioctl UFFDIO_REGISTER"); | |
| 824 | + success = false; | |
| 825 | + goto out_unmap; | |
| 826 | + } | |
| 827 | + if (munmap(unmap_ptr, page_size)) { | |
| 828 | + perror("munmap"); | |
| 829 | + success = false; | |
| 830 | + goto out_unmap; | |
| 831 | + } | |
| 832 | + } | |
| 833 | + | |
| 834 | + /* | |
| 835 | + * Now try to move the entire range which is invalid for multi VMA move. | |
| 836 | + * | |
| 837 | + * This will fail, and no VMA should be moved, as we check this ahead of | |
| 838 | + * time. | |
| 839 | + */ | |
| 840 | + res = mremap(ptr, size, size, MREMAP_MAYMOVE | MREMAP_FIXED, tgt_ptr); | |
| 841 | + err = errno; | |
| 842 | + if (res != MAP_FAILED) { | |
| 843 | + fprintf(stderr, "mremap() succeeded for multi VMA uffd armed\n"); | |
| 844 | + success = false; | |
| 845 | + goto out_unmap; | |
| 846 | + } | |
| 847 | + if (err != EFAULT) { | |
| 848 | + errno = err; | |
| 849 | + perror("mrmeap() unexpected error"); | |
| 850 | + success = false; | |
| 851 | + goto out_unmap; | |
| 852 | + } | |
| 853 | + if (is_ptr_mapped(maps_fp, tgt_ptr, page_size)) { | |
| 854 | + fprintf(stderr, | |
| 855 | + "Invalid uffd-armed VMA at start of multi range moved\n"); | |
| 856 | + success = false; | |
| 857 | + goto out_unmap; | |
| 858 | + } | |
| 859 | + | |
| 860 | + /* | |
| 861 | + * Now try to move a single VMA, this should succeed as not multi VMA | |
| 862 | + * move. | |
| 863 | + */ | |
| 864 | + res = mremap(ptr, page_size, page_size, | |
| 865 | + MREMAP_MAYMOVE | MREMAP_FIXED, tgt_ptr); | |
| 866 | + if (res == MAP_FAILED) { | |
| 867 | + perror("mremap single invalid-multi VMA"); | |
| 868 | + success = false; | |
| 869 | + goto out_unmap; | |
| 870 | + } | |
| 871 | + | |
| 872 | + /* | |
| 873 | + * Unmap the VMA, and remap a non-uffd registered (therefore, multi VMA | |
| 874 | + * move valid) VMA at the start of ptr range. | |
| 875 | + */ | |
| 876 | + if (munmap(tgt_ptr, page_size)) { | |
| 877 | + perror("munmap"); | |
| 878 | + success = false; | |
| 879 | + goto out_unmap; | |
| 880 | + } | |
| 881 | + res = mmap(ptr, page_size, PROT_READ | PROT_WRITE, | |
| 882 | + MAP_PRIVATE | MAP_ANON | MAP_FIXED, -1, 0); | |
| 883 | + if (res == MAP_FAILED) { | |
| 884 | + perror("mmap"); | |
| 885 | + success = false; | |
| 886 | + goto out_unmap; | |
| 887 | + } | |
| 888 | + | |
| 889 | + /* | |
| 890 | + * Now try to move the entire range, we should succeed in moving the | |
| 891 | + * first VMA, but no others, and report a failure. | |
| 892 | + */ | |
| 893 | + res = mremap(ptr, size, size, MREMAP_MAYMOVE | MREMAP_FIXED, tgt_ptr); | |
| 894 | + err = errno; | |
| 895 | + if (res != MAP_FAILED) { | |
| 896 | + fprintf(stderr, "mremap() succeeded for multi VMA uffd armed\n"); | |
| 897 | + success = false; | |
| 898 | + goto out_unmap; | |
| 899 | + } | |
| 900 | + if (err != EFAULT) { | |
| 901 | + errno = err; | |
| 902 | + perror("mrmeap() unexpected error"); | |
| 903 | + success = false; | |
| 904 | + goto out_unmap; | |
| 905 | + } | |
| 906 | + if (!is_ptr_mapped(maps_fp, tgt_ptr, page_size)) { | |
| 907 | + fprintf(stderr, "Valid VMA not moved\n"); | |
| 908 | + success = false; | |
| 909 | + goto out_unmap; | |
| 910 | + } | |
| 911 | + | |
| 912 | + /* | |
| 913 | + * Unmap the VMA, and map valid VMA at start of ptr range, and replace | |
| 914 | + * all existing multi-move invalid VMAs, except the last, with valid | |
| 915 | + * multi-move VMAs. | |
| 916 | + */ | |
| 917 | + if (munmap(tgt_ptr, page_size)) { | |
| 918 | + perror("munmap"); | |
| 919 | + success = false; | |
| 920 | + goto out_unmap; | |
| 921 | + } | |
| 922 | + if (munmap(ptr, size - 2 * page_size)) { | |
| 923 | + perror("munmap"); | |
| 924 | + success = false; | |
| 925 | + goto out_unmap; | |
| 926 | + } | |
| 927 | + for (i = 0; i < 8; i += 2) { | |
| 928 | + res = mmap(&ptr[i * page_size], page_size, | |
| 929 | + PROT_READ | PROT_WRITE, | |
| 930 | + MAP_PRIVATE | MAP_ANON | MAP_FIXED, -1, 0); | |
| 931 | + if (res == MAP_FAILED) { | |
| 932 | + perror("mmap"); | |
| 933 | + success = false; | |
| 934 | + goto out_unmap; | |
| 935 | + } | |
| 936 | + } | |
| 937 | + | |
| 938 | + /* | |
| 939 | + * Now try to move the entire range, we should succeed in moving all but | |
| 940 | + * the last VMA, and report a failure. | |
| 941 | + */ | |
| 942 | + res = mremap(ptr, size, size, MREMAP_MAYMOVE | MREMAP_FIXED, tgt_ptr); | |
| 943 | + err = errno; | |
| 944 | + if (res != MAP_FAILED) { | |
| 945 | + fprintf(stderr, "mremap() succeeded for multi VMA uffd armed\n"); | |
| 946 | + success = false; | |
| 947 | + goto out_unmap; | |
| 948 | + } | |
| 949 | + if (err != EFAULT) { | |
| 950 | + errno = err; | |
| 951 | + perror("mrmeap() unexpected error"); | |
| 952 | + success = false; | |
| 953 | + goto out_unmap; | |
| 954 | + } | |
| 955 | + | |
| 956 | + for (i = 0; i < 10; i += 2) { | |
| 957 | + bool is_mapped = is_ptr_mapped(maps_fp, | |
| 958 | + &tgt_ptr[i * page_size], page_size); | |
| 959 | + | |
| 960 | + if (i < 8 && !is_mapped) { | |
| 961 | + fprintf(stderr, "Valid VMA not moved at %d\n", i); | |
| 962 | + success = false; | |
| 963 | + goto out_unmap; | |
| 964 | + } else if (i == 8 && is_mapped) { | |
| 965 | + fprintf(stderr, "Invalid VMA moved at %d\n", i); | |
| 966 | + success = false; | |
| 967 | + goto out_unmap; | |
| 968 | + } | |
| 969 | + } | |
| 970 | + | |
| 971 | +out_unmap: | |
| 972 | + if (munmap(tgt_ptr, size)) | |
| 973 | + perror("munmap tgt"); | |
| 974 | + if (munmap(ptr, size)) | |
| 975 | + perror("munmap src"); | |
| 976 | +out_close_uffd: | |
| 977 | + close(uffd); | |
| 978 | +out: | |
| 979 | + if (success) | |
| 980 | + ksft_test_result_pass("%s\n", test_name); | |
| 981 | + else | |
| 982 | + ksft_test_result_fail("%s\n", test_name); | |
| 983 | +} | |
| 984 | +#else | |
| 985 | +static void mremap_move_multi_invalid_vmas(FILE *maps_fp, unsigned long page_size) | |
| 986 | +{ | |
| 987 | + char *test_name = "mremap move multiple invalid vmas"; | |
| 988 | + | |
| 989 | + ksft_test_result_skip("%s - missing uffd", test_name); | |
| 990 | +} | |
| 991 | +#endif /* __NR_userfaultfd */ | |
| 992 | + | |
| 736 | 993 | /* Returns the time taken for the remap on success else returns -1. */ |
| 737 | 994 | static long long remap_region(struct config c, unsigned int threshold_mb, |
| 738 | 995 | char *rand_addr) |
| @@ -1074,7 +1331,7 @@ int main(int argc, char **argv) · 335 unmodified lines | ||
| 1074 | 1331 | char *rand_addr; |
| 1075 | 1332 | size_t rand_size; |
| 1076 | 1333 | int num_expand_tests = 2; |
| 1077 | − int num_misc_tests = 8; | |
| 1334 | + int num_misc_tests = 9; | |
| 1078 | 1335 | struct test test_cases[MAX_TEST] = {}; |
| 1079 | 1336 | struct test perf_test_cases[MAX_PERF_TEST]; |
| 1080 | 1337 | int page_size; |
| @@ -1197,8 +1454,6 @@ int main(int argc, char **argv) · 116 unmodified lines | ||
| 1197 | 1454 | mremap_expand_merge(maps_fp, page_size); |
| 1198 | 1455 | mremap_expand_merge_offset(maps_fp, page_size); |
| 1199 | 1456 | |
| 1200 | − fclose(maps_fp); | |
| 1201 | − | |
| 1202 | 1457 | mremap_move_within_range(pattern_seed, rand_addr); |
| 1203 | 1458 | mremap_move_1mb_from_start(pattern_seed, rand_addr); |
| 1204 | 1459 | mremap_shrink_multiple_vmas(page_size, /* inplace= */true); |
| @@ -1207,6 +1462,9 @@ int main(int argc, char **argv) · 2 unmodified lines | ||
| 1207 | 1462 | mremap_move_multiple_vmas(pattern_seed, page_size, /* dontunmap= */ true); |
| 1208 | 1463 | mremap_move_multiple_vmas_split(pattern_seed, page_size, /* dontunmap= */ false); |
| 1209 | 1464 | mremap_move_multiple_vmas_split(pattern_seed, page_size, /* dontunmap= */ true); |
| 1465 | + mremap_move_multi_invalid_vmas(maps_fp, page_size); | |
| 1466 | + | |
| 1467 | + fclose(maps_fp); | |
| 1210 | 1468 | |
| 1211 | 1469 | if (run_perf_tests) { |
| 1212 | 1470 | ksft_print_msg("\n%s\n", |
| @@ -107,6 +107,26 @@ · 106 unmodified lines | ||
| 107 | 107 | #endif |
| 108 | 108 | #endif |
| 109 | 109 | |
| 110 | +#ifndef __NR_open_tree_attr | |
| 111 | + #if defined __alpha__ | |
| 112 | + #define __NR_open_tree_attr 577 | |
| 113 | + #elif defined _MIPS_SIM | |
| 114 | + #if _MIPS_SIM == _MIPS_SIM_ABI32 /* o32 */ | |
| 115 | + #define __NR_open_tree_attr (467 + 4000) | |
| 116 | + #endif | |
| 117 | + #if _MIPS_SIM == _MIPS_SIM_NABI32 /* n32 */ | |
| 118 | + #define __NR_open_tree_attr (467 + 6000) | |
| 119 | + #endif | |
| 120 | + #if _MIPS_SIM == _MIPS_SIM_ABI64 /* n64 */ | |
| 121 | + #define __NR_open_tree_attr (467 + 5000) | |
| 122 | + #endif | |
| 123 | + #elif defined __ia64__ | |
| 124 | + #define __NR_open_tree_attr (467 + 1024) | |
| 125 | + #else | |
| 126 | + #define __NR_open_tree_attr 467 | |
| 127 | + #endif | |
| 128 | +#endif | |
| 129 | + | |
| 110 | 130 | #ifndef MOUNT_ATTR_IDMAP |
| 111 | 131 | #define MOUNT_ATTR_IDMAP 0x00100000 |
| 112 | 132 | #endif |
| @@ -121,6 +141,12 @@ static inline int sys_mount_setattr(int dfd, const char *path, unsigned int flag · 8 unmodified lines | ||
| 121 | 141 | return syscall(__NR_mount_setattr, dfd, path, flags, attr, size); |
| 122 | 142 | } |
| 123 | 143 | |
| 144 | +static inline int sys_open_tree_attr(int dfd, const char *path, unsigned int flags, | |
| 145 | + struct mount_attr *attr, size_t size) | |
| 146 | +{ | |
| 147 | + return syscall(__NR_open_tree_attr, dfd, path, flags, attr, size); | |
| 148 | +} | |
| 149 | + | |
| 124 | 150 | static ssize_t write_nointr(int fd, const void *buf, size_t count) |
| 125 | 151 | { |
| 126 | 152 | ssize_t ret; |
| @@ -1222,6 +1248,12 @@ TEST_F(mount_setattr_idmapped, attached_mount_inside_current_mount_namespace) · 1095 unmodified lines | ||
| 1222 | 1248 | attr.userns_fd = get_userns_fd(0, 10000, 10000); |
| 1223 | 1249 | ASSERT_GE(attr.userns_fd, 0); |
| 1224 | 1250 | ASSERT_NE(sys_mount_setattr(open_tree_fd, "", AT_EMPTY_PATH, &attr, sizeof(attr)), 0); |
| 1251 | + /* | |
| 1252 | + * Make sure that open_tree_attr() without OPEN_TREE_CLONE is not a way | |
| 1253 | + * to bypass this mount_setattr() restriction. | |
| 1254 | + */ | |
| 1255 | + ASSERT_LT(sys_open_tree_attr(open_tree_fd, "", AT_EMPTY_PATH, &attr, sizeof(attr)), 0); | |
| 1256 | + | |
| 1225 | 1257 | ASSERT_EQ(close(attr.userns_fd), 0); |
| 1226 | 1258 | ASSERT_EQ(close(open_tree_fd), 0); |
| 1227 | 1259 | } |
| @@ -1255,6 +1287,12 @@ TEST_F(mount_setattr_idmapped, attached_mount_outside_current_mount_namespace) · 27 unmodified lines | ||
| 1255 | 1287 | ASSERT_GE(attr.userns_fd, 0); |
| 1256 | 1288 | ASSERT_NE(sys_mount_setattr(open_tree_fd, "", AT_EMPTY_PATH, &attr, |
| 1257 | 1289 | sizeof(attr)), 0); |
| 1290 | + /* | |
| 1291 | + * Make sure that open_tree_attr() without OPEN_TREE_CLONE is not a way | |
| 1292 | + * to bypass this mount_setattr() restriction. | |
| 1293 | + */ | |
| 1294 | + ASSERT_LT(sys_open_tree_attr(open_tree_fd, "", AT_EMPTY_PATH, &attr, sizeof(attr)), 0); | |
| 1295 | + | |
| 1258 | 1296 | ASSERT_EQ(close(attr.userns_fd), 0); |
| 1259 | 1297 | ASSERT_EQ(close(open_tree_fd), 0); |
| 1260 | 1298 | } |
| @@ -1321,6 +1359,19 @@ TEST_F(mount_setattr_idmapped, detached_mount_outside_current_mount_namespace) · 60 unmodified lines | ||
| 1321 | 1359 | ASSERT_EQ(close(open_tree_fd), 0); |
| 1322 | 1360 | } |
| 1323 | 1361 | |
| 1362 | +static bool expected_uid_gid(int dfd, const char *path, int flags, | |
| 1363 | + uid_t expected_uid, gid_t expected_gid) | |
| 1364 | +{ | |
| 1365 | + int ret; | |
| 1366 | + struct stat st; | |
| 1367 | + | |
| 1368 | + ret = fstatat(dfd, path, &st, flags); | |
| 1369 | + if (ret < 0) | |
| 1370 | + return false; | |
| 1371 | + | |
| 1372 | + return st.st_uid == expected_uid && st.st_gid == expected_gid; | |
| 1373 | +} | |
| 1374 | + | |
| 1324 | 1375 | /** |
| 1325 | 1376 | * Validate that currently changing the idmapping of an idmapped mount fails. |
| 1326 | 1377 | */ |
| @@ -1331,6 +1382,8 @@ TEST_F(mount_setattr_idmapped, change_idmapping) · 4 unmodified lines | ||
| 1331 | 1382 | .attr_set = MOUNT_ATTR_IDMAP, |
| 1332 | 1383 | }; |
| 1333 | 1384 | |
| 1385 | + ASSERT_TRUE(expected_uid_gid(-EBADF, "/mnt/D", 0, 0, 0)); | |
| 1386 | + | |
| 1334 | 1387 | if (!mount_setattr_supported()) |
| 1335 | 1388 | SKIP(return, "mount_setattr syscall not supported"); |
| 1336 | 1389 | |
| @@ -1348,27 +1401,25 @@ TEST_F(mount_setattr_idmapped, change_idmapping) · 11 unmodified lines | ||
| 1348 | 1401 | AT_EMPTY_PATH, &attr, sizeof(attr)), 0); |
| 1349 | 1402 | ASSERT_EQ(close(attr.userns_fd), 0); |
| 1350 | 1403 | |
| 1404 | + EXPECT_FALSE(expected_uid_gid(open_tree_fd, ".", 0, 0, 0)); | |
| 1405 | + EXPECT_TRUE(expected_uid_gid(open_tree_fd, ".", 0, 10000, 10000)); | |
| 1406 | + | |
| 1351 | 1407 | /* Change idmapping on a detached mount that is already idmapped. */ |
| 1352 | 1408 | attr.userns_fd = get_userns_fd(0, 20000, 10000); |
| 1353 | 1409 | ASSERT_GE(attr.userns_fd, 0); |
| 1354 | 1410 | ASSERT_NE(sys_mount_setattr(open_tree_fd, "", AT_EMPTY_PATH, &attr, sizeof(attr)), 0); |
| 1411 | + /* | |
| 1412 | + * Make sure that open_tree_attr() without OPEN_TREE_CLONE is not a way | |
| 1413 | + * to bypass this mount_setattr() restriction. | |
| 1414 | + */ | |
| 1415 | + EXPECT_LT(sys_open_tree_attr(open_tree_fd, "", AT_EMPTY_PATH, &attr, sizeof(attr)), 0); | |
| 1416 | + EXPECT_FALSE(expected_uid_gid(open_tree_fd, ".", 0, 20000, 20000)); | |
| 1417 | + EXPECT_TRUE(expected_uid_gid(open_tree_fd, ".", 0, 10000, 10000)); | |
| 1418 | + | |
| 1355 | 1419 | ASSERT_EQ(close(attr.userns_fd), 0); |
| 1356 | 1420 | ASSERT_EQ(close(open_tree_fd), 0); |
| 1357 | 1421 | } |
| 1358 | 1422 | |
| 1359 | −static bool expected_uid_gid(int dfd, const char *path, int flags, | |
| 1360 | − uid_t expected_uid, gid_t expected_gid) | |
| 1361 | −{ | |
| 1362 | − int ret; | |
| 1363 | − struct stat st; | |
| 1364 | − | |
| 1365 | − ret = fstatat(dfd, path, &st, flags); | |
| 1366 | − if (ret < 0) | |
| 1367 | − return false; | |
| 1368 | − | |
| 1369 | − return st.st_uid == expected_uid && st.st_gid == expected_gid; | |
| 1370 | −} | |
| 1371 | − | |
| 1372 | 1423 | TEST_F(mount_setattr_idmapped, idmap_mount_tree_invalid) |
| 1373 | 1424 | { |
| 1374 | 1425 | int open_tree_fd = -EBADF; |
| @@ -18,6 +18,8 @@ · 17 unmodified lines | ||
| 18 | 18 | # | 2001:db8:1::1/64 2001:db8:2::1/64 | |
| 19 | 19 | # | | |
| 20 | 20 | # +-----------------------------------------------------------------+ |
| 21 | +# | |
| 22 | +#shellcheck disable=SC2034 # SC doesn't see our uses of global variables | |
| 21 | 23 | |
| 22 | 24 | ALL_TESTS=" |
| 23 | 25 | ping_ipv4 |
| @@ -27,6 +29,7 @@ ALL_TESTS=" · 3 unmodified lines | ||
| 27 | 29 | ipv4_sip_equal_dip |
| 28 | 30 | ipv6_sip_equal_dip |
| 29 | 31 | ipv4_dip_link_local |
| 32 | + ipv4_sip_link_local | |
| 30 | 33 | " |
| 31 | 34 | |
| 32 | 35 | NUM_NETIFS=4 |
| @@ -330,6 +333,32 @@ ipv4_dip_link_local() · 297 unmodified lines | ||
| 330 | 333 | tc filter del dev $rp2 egress protocol ip pref 1 handle 101 flower |
| 331 | 334 | } |
| 332 | 335 | |
| 336 | +ipv4_sip_link_local() | |
| 337 | +{ | |
| 338 | + local sip=169.254.1.1 | |
| 339 | + | |
| 340 | + RET=0 | |
| 341 | + | |
| 342 | + # Disable rpfilter to prevent packets to be dropped because of it. | |
| 343 | + sysctl_set net.ipv4.conf.all.rp_filter 0 | |
| 344 | + sysctl_set net.ipv4.conf."$rp1".rp_filter 0 | |
| 345 | + | |
| 346 | + tc filter add dev "$rp2" egress protocol ip pref 1 handle 101 \ | |
| 347 | + flower src_ip "$sip" action pass | |
| 348 | + | |
| 349 | + $MZ "$h1" -t udp "sp=54321,dp=12345" -c 5 -d 1msec -b "$rp1mac" \ | |
| 350 | + -A "$sip" -B 198.51.100.2 -q | |
| 351 | + | |
| 352 | + tc_check_packets "dev $rp2 egress" 101 5 | |
| 353 | + check_err $? "Packets were dropped" | |
| 354 | + | |
| 355 | + log_test "IPv4 source IP is link-local" | |
| 356 | + | |
| 357 | + tc filter del dev "$rp2" egress protocol ip pref 1 handle 101 flower | |
| 358 | + sysctl_restore net.ipv4.conf."$rp1".rp_filter | |
| 359 | + sysctl_restore net.ipv4.conf.all.rp_filter | |
| 360 | +} | |
| 361 | + | |
| 333 | 362 | trap cleanup EXIT |
| 334 | 363 | |
| 335 | 364 | setup_prepare |
| @@ -183,9 +183,10 @@ static void xgetaddrinfo(const char *node, const char *service, · 182 unmodified lines | ||
| 183 | 183 | struct addrinfo *hints, |
| 184 | 184 | struct addrinfo **res) |
| 185 | 185 | { |
| 186 | −again: | |
| 187 | − int err = getaddrinfo(node, service, hints, res); | |
| 186 | + int err; | |
| 188 | 187 | |
| 188 | +again: | |
| 189 | + err = getaddrinfo(node, service, hints, res); | |
| 189 | 190 | if (err) { |
| 190 | 191 | const char *errstr; |
| 191 | 192 | |
| @@ -75,9 +75,10 @@ static void xgetaddrinfo(const char *node, const char *service, · 74 unmodified lines | ||
| 75 | 75 | struct addrinfo *hints, |
| 76 | 76 | struct addrinfo **res) |
| 77 | 77 | { |
| 78 | −again: | |
| 79 | − int err = getaddrinfo(node, service, hints, res); | |
| 78 | + int err; | |
| 80 | 79 | |
| 80 | +again: | |
| 81 | + err = getaddrinfo(node, service, hints, res); | |
| 81 | 82 | if (err) { |
| 82 | 83 | const char *errstr; |
| 83 | 84 | |
| @@ -3842,6 +3842,7 @@ endpoint_tests() · 3841 unmodified lines | ||
| 3842 | 3842 | # remove and re-add |
| 3843 | 3843 | if reset_with_events "delete re-add signal" && |
| 3844 | 3844 | mptcp_lib_kallsyms_has "subflow_rebuild_header$"; then |
| 3845 | + ip netns exec $ns1 sysctl -q net.mptcp.add_addr_timeout=0 | |
| 3845 | 3846 | pm_nl_set_limits $ns1 0 3 |
| 3846 | 3847 | pm_nl_set_limits $ns2 3 3 |
| 3847 | 3848 | pm_nl_add_endpoint $ns1 10.0.2.1 id 1 flags signal |
| @@ -162,9 +162,10 @@ static void xgetaddrinfo(const char *node, const char *service, · 161 unmodified lines | ||
| 162 | 162 | struct addrinfo *hints, |
| 163 | 163 | struct addrinfo **res) |
| 164 | 164 | { |
| 165 | −again: | |
| 166 | − int err = getaddrinfo(node, service, hints, res); | |
| 165 | + int err; | |
| 167 | 166 | |
| 167 | +again: | |
| 168 | + err = getaddrinfo(node, service, hints, res); | |
| 168 | 169 | if (err) { |
| 169 | 170 | const char *errstr; |
| 170 | 171 | |
| @@ -198,6 +198,7 @@ set_limits 1 9 2>/dev/null · 197 unmodified lines | ||
| 198 | 198 | check "get_limits" "${default_limits}" "subflows above hard limit" |
| 199 | 199 | |
| 200 | 200 | set_limits 8 8 |
| 201 | +flush_endpoint ## to make sure it doesn't affect the limits | |
| 201 | 202 | check "get_limits" "$(format_limits 8 8)" "set limits" |
| 202 | 203 | |
| 203 | 204 | flush_endpoint |
| @@ -181,13 +181,12 @@ static int tls_send_cmsg(int fd, unsigned char record_type, · 180 unmodified lines | ||
| 181 | 181 | return sendmsg(fd, &msg, flags); |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | −static int tls_recv_cmsg(struct __test_metadata *_metadata, | |
| 185 | − int fd, unsigned char record_type, | |
| 186 | − void *data, size_t len, int flags) | |
| 184 | +static int __tls_recv_cmsg(struct __test_metadata *_metadata, | |
| 185 | + int fd, unsigned char *ctype, | |
| 186 | + void *data, size_t len, int flags) | |
| 187 | 187 | { |
| 188 | 188 | char cbuf[CMSG_SPACE(sizeof(char))]; |
| 189 | 189 | struct cmsghdr *cmsg; |
| 190 | − unsigned char ctype; | |
| 191 | 190 | struct msghdr msg; |
| 192 | 191 | struct iovec vec; |
| 193 | 192 | int n; |
| @@ -206,7 +205,20 @@ static int tls_recv_cmsg(struct __test_metadata *_metadata, · 12 unmodified lines | ||
| 206 | 205 | EXPECT_NE(cmsg, NULL); |
| 207 | 206 | EXPECT_EQ(cmsg->cmsg_level, SOL_TLS); |
| 208 | 207 | EXPECT_EQ(cmsg->cmsg_type, TLS_GET_RECORD_TYPE); |
| 209 | − ctype = *((unsigned char *)CMSG_DATA(cmsg)); | |
| 208 | + if (ctype) | |
| 209 | + *ctype = *((unsigned char *)CMSG_DATA(cmsg)); | |
| 210 | + | |
| 211 | + return n; | |
| 212 | +} | |
| 213 | + | |
| 214 | +static int tls_recv_cmsg(struct __test_metadata *_metadata, | |
| 215 | + int fd, unsigned char record_type, | |
| 216 | + void *data, size_t len, int flags) | |
| 217 | +{ | |
| 218 | + unsigned char ctype; | |
| 219 | + int n; | |
| 220 | + | |
| 221 | + n = __tls_recv_cmsg(_metadata, fd, &ctype, data, len, flags); | |
| 210 | 222 | EXPECT_EQ(ctype, record_type); |
| 211 | 223 | |
| 212 | 224 | return n; |
| @@ -2164,6 +2176,284 @@ TEST_F(tls, rekey_poll_delay) · 1951 unmodified lines | ||
| 2164 | 2176 | } |
| 2165 | 2177 | } |
| 2166 | 2178 | |
| 2179 | +struct raw_rec { | |
| 2180 | + unsigned int plain_len; | |
| 2181 | + unsigned char plain_data[100]; | |
| 2182 | + unsigned int cipher_len; | |
| 2183 | + unsigned char cipher_data[128]; | |
| 2184 | +}; | |
| 2185 | + | |
| 2186 | +/* TLS 1.2, AES_CCM, data, seqno:0, plaintext: 'Hello world' */ | |
| 2187 | +static const struct raw_rec id0_data_l11 = { | |
| 2188 | + .plain_len = 11, | |
| 2189 | + .plain_data = { | |
| 2190 | + 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x77, 0x6f, | |
| 2191 | + 0x72, 0x6c, 0x64, | |
| 2192 | + }, | |
| 2193 | + .cipher_len = 40, | |
| 2194 | + .cipher_data = { | |
| 2195 | + 0x17, 0x03, 0x03, 0x00, 0x23, 0x00, 0x00, 0x00, | |
| 2196 | + 0x00, 0x00, 0x00, 0x00, 0x00, 0x26, 0xa2, 0x33, | |
| 2197 | + 0xde, 0x8d, 0x94, 0xf0, 0x29, 0x6c, 0xb1, 0xaf, | |
| 2198 | + 0x6a, 0x75, 0xb2, 0x93, 0xad, 0x45, 0xd5, 0xfd, | |
| 2199 | + 0x03, 0x51, 0x57, 0x8f, 0xf9, 0xcc, 0x3b, 0x42, | |
| 2200 | + }, | |
| 2201 | +}; | |
| 2202 | + | |
| 2203 | +/* TLS 1.2, AES_CCM, ctrl, seqno:0, plaintext: '' */ | |
| 2204 | +static const struct raw_rec id0_ctrl_l0 = { | |
| 2205 | + .plain_len = 0, | |
| 2206 | + .plain_data = { | |
| 2207 | + }, | |
| 2208 | + .cipher_len = 29, | |
| 2209 | + .cipher_data = { | |
| 2210 | + 0x16, 0x03, 0x03, 0x00, 0x18, 0x00, 0x00, 0x00, | |
| 2211 | + 0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0x38, 0x7b, | |
| 2212 | + 0xa6, 0x1c, 0xdd, 0xa7, 0x19, 0x33, 0xab, 0xae, | |
| 2213 | + 0x88, 0xe1, 0xd2, 0x08, 0x4f, | |
| 2214 | + }, | |
| 2215 | +}; | |
| 2216 | + | |
| 2217 | +/* TLS 1.2, AES_CCM, data, seqno:0, plaintext: '' */ | |
| 2218 | +static const struct raw_rec id0_data_l0 = { | |
| 2219 | + .plain_len = 0, | |
| 2220 | + .plain_data = { | |
| 2221 | + }, | |
| 2222 | + .cipher_len = 29, | |
| 2223 | + .cipher_data = { | |
| 2224 | + 0x17, 0x03, 0x03, 0x00, 0x18, 0x00, 0x00, 0x00, | |
| 2225 | + 0x00, 0x00, 0x00, 0x00, 0x00, 0xc5, 0x37, 0x90, | |
| 2226 | + 0x70, 0x45, 0x89, 0xfb, 0x5c, 0xc7, 0x89, 0x03, | |
| 2227 | + 0x68, 0x80, 0xd3, 0xd8, 0xcc, | |
| 2228 | + }, | |
| 2229 | +}; | |
| 2230 | + | |
| 2231 | +/* TLS 1.2, AES_CCM, data, seqno:1, plaintext: 'Hello world' */ | |
| 2232 | +static const struct raw_rec id1_data_l11 = { | |
| 2233 | + .plain_len = 11, | |
| 2234 | + .plain_data = { | |
| 2235 | + 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x77, 0x6f, | |
| 2236 | + 0x72, 0x6c, 0x64, | |
| 2237 | + }, | |
| 2238 | + .cipher_len = 40, | |
| 2239 | + .cipher_data = { | |
| 2240 | + 0x17, 0x03, 0x03, 0x00, 0x23, 0x00, 0x00, 0x00, | |
| 2241 | + 0x00, 0x00, 0x00, 0x00, 0x01, 0x3a, 0x1a, 0x9c, | |
| 2242 | + 0xd0, 0xa8, 0x9a, 0xd6, 0x69, 0xd6, 0x1a, 0xe3, | |
| 2243 | + 0xb5, 0x1f, 0x0d, 0x2c, 0xe2, 0x97, 0x46, 0xff, | |
| 2244 | + 0x2b, 0xcc, 0x5a, 0xc4, 0xa3, 0xb9, 0xef, 0xba, | |
| 2245 | + }, | |
| 2246 | +}; | |
| 2247 | + | |
| 2248 | +/* TLS 1.2, AES_CCM, ctrl, seqno:1, plaintext: '' */ | |
| 2249 | +static const struct raw_rec id1_ctrl_l0 = { | |
| 2250 | + .plain_len = 0, | |
| 2251 | + .plain_data = { | |
| 2252 | + }, | |
| 2253 | + .cipher_len = 29, | |
| 2254 | + .cipher_data = { | |
| 2255 | + 0x16, 0x03, 0x03, 0x00, 0x18, 0x00, 0x00, 0x00, | |
| 2256 | + 0x00, 0x00, 0x00, 0x00, 0x01, 0x3e, 0xf0, 0xfe, | |
| 2257 | + 0xee, 0xd9, 0xe2, 0x5d, 0xc7, 0x11, 0x4c, 0xe6, | |
| 2258 | + 0xb4, 0x7e, 0xef, 0x40, 0x2b, | |
| 2259 | + }, | |
| 2260 | +}; | |
| 2261 | + | |
| 2262 | +/* TLS 1.2, AES_CCM, data, seqno:1, plaintext: '' */ | |
| 2263 | +static const struct raw_rec id1_data_l0 = { | |
| 2264 | + .plain_len = 0, | |
| 2265 | + .plain_data = { | |
| 2266 | + }, | |
| 2267 | + .cipher_len = 29, | |
| 2268 | + .cipher_data = { | |
| 2269 | + 0x17, 0x03, 0x03, 0x00, 0x18, 0x00, 0x00, 0x00, | |
| 2270 | + 0x00, 0x00, 0x00, 0x00, 0x01, 0xce, 0xfc, 0x86, | |
| 2271 | + 0xc8, 0xf0, 0x55, 0xf9, 0x47, 0x3f, 0x74, 0xdc, | |
| 2272 | + 0xc9, 0xbf, 0xfe, 0x5b, 0xb1, | |
| 2273 | + }, | |
| 2274 | +}; | |
| 2275 | + | |
| 2276 | +/* TLS 1.2, AES_CCM, ctrl, seqno:2, plaintext: 'Hello world' */ | |
| 2277 | +static const struct raw_rec id2_ctrl_l11 = { | |
| 2278 | + .plain_len = 11, | |
| 2279 | + .plain_data = { | |
| 2280 | + 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x77, 0x6f, | |
| 2281 | + 0x72, 0x6c, 0x64, | |
| 2282 | + }, | |
| 2283 | + .cipher_len = 40, | |
| 2284 | + .cipher_data = { | |
| 2285 | + 0x16, 0x03, 0x03, 0x00, 0x23, 0x00, 0x00, 0x00, | |
| 2286 | + 0x00, 0x00, 0x00, 0x00, 0x02, 0xe5, 0x3d, 0x19, | |
| 2287 | + 0x3d, 0xca, 0xb8, 0x16, 0xb6, 0xff, 0x79, 0x87, | |
| 2288 | + 0x2a, 0x04, 0x11, 0x3d, 0xf8, 0x64, 0x5f, 0x36, | |
| 2289 | + 0x8b, 0xa8, 0xee, 0x4c, 0x6d, 0x62, 0xa5, 0x00, | |
| 2290 | + }, | |
| 2291 | +}; | |
| 2292 | + | |
| 2293 | +/* TLS 1.2, AES_CCM, data, seqno:2, plaintext: 'Hello world' */ | |
| 2294 | +static const struct raw_rec id2_data_l11 = { | |
| 2295 | + .plain_len = 11, | |
| 2296 | + .plain_data = { | |
| 2297 | + 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x77, 0x6f, | |
| 2298 | + 0x72, 0x6c, 0x64, | |
| 2299 | + }, | |
| 2300 | + .cipher_len = 40, | |
| 2301 | + .cipher_data = { | |
| 2302 | + 0x17, 0x03, 0x03, 0x00, 0x23, 0x00, 0x00, 0x00, | |
| 2303 | + 0x00, 0x00, 0x00, 0x00, 0x02, 0xe5, 0x3d, 0x19, | |
| 2304 | + 0x3d, 0xca, 0xb8, 0x16, 0xb6, 0xff, 0x79, 0x87, | |
| 2305 | + 0x8e, 0xa1, 0xd0, 0xcd, 0x33, 0xb5, 0x86, 0x2b, | |
| 2306 | + 0x17, 0xf1, 0x52, 0x2a, 0x55, 0x62, 0x65, 0x11, | |
| 2307 | + }, | |
| 2308 | +}; | |
| 2309 | + | |
| 2310 | +/* TLS 1.2, AES_CCM, ctrl, seqno:2, plaintext: '' */ | |
| 2311 | +static const struct raw_rec id2_ctrl_l0 = { | |
| 2312 | + .plain_len = 0, | |
| 2313 | + .plain_data = { | |
| 2314 | + }, | |
| 2315 | + .cipher_len = 29, | |
| 2316 | + .cipher_data = { | |
| 2317 | + 0x16, 0x03, 0x03, 0x00, 0x18, 0x00, 0x00, 0x00, | |
| 2318 | + 0x00, 0x00, 0x00, 0x00, 0x02, 0xdc, 0x5c, 0x0e, | |
| 2319 | + 0x41, 0xdd, 0xba, 0xd3, 0xcc, 0xcf, 0x6d, 0xd9, | |
| 2320 | + 0x06, 0xdb, 0x79, 0xe5, 0x5d, | |
| 2321 | + }, | |
| 2322 | +}; | |
| 2323 | + | |
| 2324 | +/* TLS 1.2, AES_CCM, data, seqno:2, plaintext: '' */ | |
| 2325 | +static const struct raw_rec id2_data_l0 = { | |
| 2326 | + .plain_len = 0, | |
| 2327 | + .plain_data = { | |
| 2328 | + }, | |
| 2329 | + .cipher_len = 29, | |
| 2330 | + .cipher_data = { | |
| 2331 | + 0x17, 0x03, 0x03, 0x00, 0x18, 0x00, 0x00, 0x00, | |
| 2332 | + 0x00, 0x00, 0x00, 0x00, 0x02, 0xc3, 0xca, 0x26, | |
| 2333 | + 0x22, 0xe4, 0x25, 0xfb, 0x5f, 0x6d, 0xbf, 0x83, | |
| 2334 | + 0x30, 0x48, 0x69, 0x1a, 0x47, | |
| 2335 | + }, | |
| 2336 | +}; | |
| 2337 | + | |
| 2338 | +FIXTURE(zero_len) | |
| 2339 | +{ | |
| 2340 | + int fd, cfd; | |
| 2341 | + bool notls; | |
| 2342 | +}; | |
| 2343 | + | |
| 2344 | +FIXTURE_VARIANT(zero_len) | |
| 2345 | +{ | |
| 2346 | + const struct raw_rec *recs[4]; | |
| 2347 | + ssize_t recv_ret[4]; | |
| 2348 | +}; | |
| 2349 | + | |
| 2350 | +FIXTURE_VARIANT_ADD(zero_len, data_data_data) | |
| 2351 | +{ | |
| 2352 | + .recs = { &id0_data_l11, &id1_data_l11, &id2_data_l11, }, | |
| 2353 | + .recv_ret = { 33, -EAGAIN, }, | |
| 2354 | +}; | |
| 2355 | + | |
| 2356 | +FIXTURE_VARIANT_ADD(zero_len, data_0ctrl_data) | |
| 2357 | +{ | |
| 2358 | + .recs = { &id0_data_l11, &id1_ctrl_l0, &id2_data_l11, }, | |
| 2359 | + .recv_ret = { 11, 0, 11, -EAGAIN, }, | |
| 2360 | +}; | |
| 2361 | + | |
| 2362 | +FIXTURE_VARIANT_ADD(zero_len, 0data_0data_0data) | |
| 2363 | +{ | |
| 2364 | + .recs = { &id0_data_l0, &id1_data_l0, &id2_data_l0, }, | |
| 2365 | + .recv_ret = { -EAGAIN, }, | |
| 2366 | +}; | |
| 2367 | + | |
| 2368 | +FIXTURE_VARIANT_ADD(zero_len, 0data_0data_ctrl) | |
| 2369 | +{ | |
| 2370 | + .recs = { &id0_data_l0, &id1_data_l0, &id2_ctrl_l11, }, | |
| 2371 | + .recv_ret = { 0, 11, -EAGAIN, }, | |
| 2372 | +}; | |
| 2373 | + | |
| 2374 | +FIXTURE_VARIANT_ADD(zero_len, 0data_0data_0ctrl) | |
| 2375 | +{ | |
| 2376 | + .recs = { &id0_data_l0, &id1_data_l0, &id2_ctrl_l0, }, | |
| 2377 | + .recv_ret = { 0, 0, -EAGAIN, }, | |
| 2378 | +}; | |
| 2379 | + | |
| 2380 | +FIXTURE_VARIANT_ADD(zero_len, 0ctrl_0ctrl_0ctrl) | |
| 2381 | +{ | |
| 2382 | + .recs = { &id0_ctrl_l0, &id1_ctrl_l0, &id2_ctrl_l0, }, | |
| 2383 | + .recv_ret = { 0, 0, 0, -EAGAIN, }, | |
| 2384 | +}; | |
| 2385 | + | |
| 2386 | +FIXTURE_VARIANT_ADD(zero_len, 0data_0data_data) | |
| 2387 | +{ | |
| 2388 | + .recs = { &id0_data_l0, &id1_data_l0, &id2_data_l11, }, | |
| 2389 | + .recv_ret = { 11, -EAGAIN, }, | |
| 2390 | +}; | |
| 2391 | + | |
| 2392 | +FIXTURE_VARIANT_ADD(zero_len, data_0data_0data) | |
| 2393 | +{ | |
| 2394 | + .recs = { &id0_data_l11, &id1_data_l0, &id2_data_l0, }, | |
| 2395 | + .recv_ret = { 11, -EAGAIN, }, | |
| 2396 | +}; | |
| 2397 | + | |
| 2398 | +FIXTURE_SETUP(zero_len) | |
| 2399 | +{ | |
| 2400 | + struct tls_crypto_info_keys tls12; | |
| 2401 | + int ret; | |
| 2402 | + | |
| 2403 | + tls_crypto_info_init(TLS_1_2_VERSION, TLS_CIPHER_AES_CCM_128, | |
| 2404 | + &tls12, 0); | |
| 2405 | + | |
| 2406 | + ulp_sock_pair(_metadata, &self->fd, &self->cfd, &self->notls); | |
| 2407 | + if (self->notls) | |
| 2408 | + return; | |
| 2409 | + | |
| 2410 | + /* Don't install keys on fd, we'll send raw records */ | |
| 2411 | + ret = setsockopt(self->cfd, SOL_TLS, TLS_RX, &tls12, tls12.len); | |
| 2412 | + ASSERT_EQ(ret, 0); | |
| 2413 | +} | |
| 2414 | + | |
| 2415 | +FIXTURE_TEARDOWN(zero_len) | |
| 2416 | +{ | |
| 2417 | + close(self->fd); | |
| 2418 | + close(self->cfd); | |
| 2419 | +} | |
| 2420 | + | |
| 2421 | +TEST_F(zero_len, test) | |
| 2422 | +{ | |
| 2423 | + const struct raw_rec *const *rec; | |
| 2424 | + unsigned char buf[128]; | |
| 2425 | + int rec_off; | |
| 2426 | + int i; | |
| 2427 | + | |
| 2428 | + for (i = 0; i < 4 && variant->recs[i]; i++) | |
| 2429 | + EXPECT_EQ(send(self->fd, variant->recs[i]->cipher_data, | |
| 2430 | + variant->recs[i]->cipher_len, 0), | |
| 2431 | + variant->recs[i]->cipher_len); | |
| 2432 | + | |
| 2433 | + rec = &variant->recs[0]; | |
| 2434 | + rec_off = 0; | |
| 2435 | + for (i = 0; i < 4; i++) { | |
| 2436 | + int j, ret; | |
| 2437 | + | |
| 2438 | + ret = variant->recv_ret[i] >= 0 ? variant->recv_ret[i] : -1; | |
| 2439 | + EXPECT_EQ(__tls_recv_cmsg(_metadata, self->cfd, NULL, | |
| 2440 | + buf, sizeof(buf), MSG_DONTWAIT), ret); | |
| 2441 | + if (ret == -1) | |
| 2442 | + EXPECT_EQ(errno, -variant->recv_ret[i]); | |
| 2443 | + if (variant->recv_ret[i] == -EAGAIN) | |
| 2444 | + break; | |
| 2445 | + | |
| 2446 | + for (j = 0; j < ret; j++) { | |
| 2447 | + while (rec_off == (*rec)->plain_len) { | |
| 2448 | + rec++; | |
| 2449 | + rec_off = 0; | |
| 2450 | + } | |
| 2451 | + EXPECT_EQ(buf[j], (*rec)->plain_data[rec_off]); | |
| 2452 | + rec_off++; | |
| 2453 | + } | |
| 2454 | + } | |
| 2455 | +}; | |
| 2456 | + | |
| 2167 | 2457 | FIXTURE(tls_err) |
| 2168 | 2458 | { |
| 2169 | 2459 | int fd, cfd; |
| @@ -2748,17 +3038,18 @@ TEST(data_steal) { · 578 unmodified lines | ||
| 2748 | 3038 | pid = fork(); |
| 2749 | 3039 | ASSERT_GE(pid, 0); |
| 2750 | 3040 | if (!pid) { |
| 2751 | − EXPECT_EQ(recv(cfd, buf, sizeof(buf), MSG_WAITALL), | |
| 2752 | − sizeof(buf)); | |
| 3041 | + EXPECT_EQ(recv(cfd, buf, sizeof(buf) / 2, MSG_WAITALL), | |
| 3042 | + sizeof(buf) / 2); | |
| 2753 | 3043 | exit(!__test_passed(_metadata)); |
| 2754 | 3044 | } |
| 2755 | 3045 | |
| 2756 | − usleep(2000); | |
| 3046 | + usleep(10000); | |
| 2757 | 3047 | ASSERT_EQ(setsockopt(fd, SOL_TLS, TLS_TX, &tls, tls.len), 0); |
| 2758 | 3048 | ASSERT_EQ(setsockopt(cfd, SOL_TLS, TLS_RX, &tls, tls.len), 0); |
| 2759 | 3049 | |
| 2760 | 3050 | EXPECT_EQ(send(fd, buf, sizeof(buf), 0), sizeof(buf)); |
| 2761 | − usleep(2000); | |
| 3051 | + EXPECT_EQ(wait(&status), pid); | |
| 3052 | + EXPECT_EQ(status, 0); | |
| 2762 | 3053 | EXPECT_EQ(recv(cfd, buf2, sizeof(buf2), MSG_DONTWAIT), -1); |
| 2763 | 3054 | /* Don't check errno, the error will be different depending |
| 2764 | 3055 | * on what random bytes TLS interpreted as the record length. |
| @@ -2766,9 +3057,6 @@ TEST(data_steal) { · 1 unmodified line | ||
| 2766 | 3057 | |
| 2767 | 3058 | close(fd); |
| 2768 | 3059 | close(cfd); |
| 2769 | − | |
| 2770 | − EXPECT_EQ(wait(&status), pid); | |
| 2771 | − EXPECT_EQ(status, 0); | |
| 2772 | 3060 | } |
| 2773 | 3061 | |
| 2774 | 3062 | static void __attribute__((constructor)) fips_check(void) { |
| @@ -6,7 +6,6 @@ · 5 unmodified lines | ||
| 6 | 6 | #include <bpf/bpf.h> |
| 7 | 7 | #include <sched.h> |
| 8 | 8 | #include <scx/common.h> |
| 9 | −#include <sched.h> | |
| 10 | 9 | #include <sys/wait.h> |
| 11 | 10 | #include <unistd.h> |
| 12 | 11 | |
| @@ -185,6 +185,204 @@ · 184 unmodified lines | ||
| 185 | 185 | "$IP addr del 10.10.10.10/24 dev $DUMMY || true" |
| 186 | 186 | ] |
| 187 | 187 | }, |
| 188 | + { | |
| 189 | + "id": "34c0", | |
| 190 | + "name": "Test TBF with HHF Backlog Accounting in gso_skb case against underflow", | |
| 191 | + "category": [ | |
| 192 | + "qdisc", | |
| 193 | + "tbf", | |
| 194 | + "hhf" | |
| 195 | + ], | |
| 196 | + "plugins": { | |
| 197 | + "requires": [ | |
| 198 | + "nsPlugin" | |
| 199 | + ] | |
| 200 | + }, | |
| 201 | + "setup": [ | |
| 202 | + "$IP link set dev $DUMMY up || true", | |
| 203 | + "$IP addr add 10.10.11.10/24 dev $DUMMY || true", | |
| 204 | + "$TC qdisc add dev $DUMMY root handle 1: tbf rate 8bit burst 100b latency 100ms", | |
| 205 | + "$TC qdisc replace dev $DUMMY handle 2: parent 1:1 hhf limit 1000", | |
| 206 | + [ | |
| 207 | + "ping -I $DUMMY -c2 10.10.11.11", | |
| 208 | + 1 | |
| 209 | + ], | |
| 210 | + "$TC qdisc change dev $DUMMY handle 2: parent 1:1 hhf limit 1" | |
| 211 | + ], | |
| 212 | + "cmdUnderTest": "$TC qdisc del dev $DUMMY handle 2: parent 1:1", | |
| 213 | + "expExitCode": "0", | |
| 214 | + "verifyCmd": "$TC -s qdisc show dev $DUMMY", | |
| 215 | + "matchPattern": "backlog 0b 0p", | |
| 216 | + "matchCount": "1", | |
| 217 | + "teardown": [ | |
| 218 | + "$TC qdisc del dev $DUMMY handle 1: root" | |
| 219 | + ] | |
| 220 | + }, | |
| 221 | + { | |
| 222 | + "id": "fd68", | |
| 223 | + "name": "Test TBF with CODEL Backlog Accounting in gso_skb case against underflow", | |
| 224 | + "category": [ | |
| 225 | + "qdisc", | |
| 226 | + "tbf", | |
| 227 | + "codel" | |
| 228 | + ], | |
| 229 | + "plugins": { | |
| 230 | + "requires": [ | |
| 231 | + "nsPlugin" | |
| 232 | + ] | |
| 233 | + }, | |
| 234 | + "setup": [ | |
| 235 | + "$IP link set dev $DUMMY up || true", | |
| 236 | + "$IP addr add 10.10.11.10/24 dev $DUMMY || true", | |
| 237 | + "$TC qdisc add dev $DUMMY root handle 1: tbf rate 8bit burst 100b latency 100ms", | |
| 238 | + "$TC qdisc replace dev $DUMMY handle 2: parent 1:1 codel limit 1000", | |
| 239 | + [ | |
| 240 | + "ping -I $DUMMY -c2 10.10.11.11", | |
| 241 | + 1 | |
| 242 | + ], | |
| 243 | + "$TC qdisc change dev $DUMMY handle 2: parent 1:1 codel limit 1" | |
| 244 | + ], | |
| 245 | + "cmdUnderTest": "$TC qdisc del dev $DUMMY handle 2: parent 1:1", | |
| 246 | + "expExitCode": "0", | |
| 247 | + "verifyCmd": "$TC -s qdisc show dev $DUMMY", | |
| 248 | + "matchPattern": "backlog 0b 0p", | |
| 249 | + "matchCount": "1", | |
| 250 | + "teardown": [ | |
| 251 | + "$TC qdisc del dev $DUMMY handle 1: root" | |
| 252 | + ] | |
| 253 | + }, | |
| 254 | + { | |
| 255 | + "id": "514e", | |
| 256 | + "name": "Test TBF with PIE Backlog Accounting in gso_skb case against underflow", | |
| 257 | + "category": [ | |
| 258 | + "qdisc", | |
| 259 | + "tbf", | |
| 260 | + "pie" | |
| 261 | + ], | |
| 262 | + "plugins": { | |
| 263 | + "requires": [ | |
| 264 | + "nsPlugin" | |
| 265 | + ] | |
| 266 | + }, | |
| 267 | + "setup": [ | |
| 268 | + "$IP link set dev $DUMMY up || true", | |
| 269 | + "$IP addr add 10.10.11.10/24 dev $DUMMY || true", | |
| 270 | + "$TC qdisc add dev $DUMMY root handle 1: tbf rate 8bit burst 100b latency 100ms", | |
| 271 | + "$TC qdisc replace dev $DUMMY handle 2: parent 1:1 pie limit 1000", | |
| 272 | + [ | |
| 273 | + "ping -I $DUMMY -c2 10.10.11.11", | |
| 274 | + 1 | |
| 275 | + ], | |
| 276 | + "$TC qdisc change dev $DUMMY handle 2: parent 1:1 pie limit 1" | |
| 277 | + ], | |
| 278 | + "cmdUnderTest": "$TC qdisc del dev $DUMMY handle 2: parent 1:1", | |
| 279 | + "expExitCode": "0", | |
| 280 | + "verifyCmd": "$TC -s qdisc show dev $DUMMY", | |
| 281 | + "matchPattern": "backlog 0b 0p", | |
| 282 | + "matchCount": "1", | |
| 283 | + "teardown": [ | |
| 284 | + "$TC qdisc del dev $DUMMY handle 1: root" | |
| 285 | + ] | |
| 286 | + }, | |
| 287 | + { | |
| 288 | + "id": "6c97", | |
| 289 | + "name": "Test TBF with FQ Backlog Accounting in gso_skb case against underflow", | |
| 290 | + "category": [ | |
| 291 | + "qdisc", | |
| 292 | + "tbf", | |
| 293 | + "fq" | |
| 294 | + ], | |
| 295 | + "plugins": { | |
| 296 | + "requires": [ | |
| 297 | + "nsPlugin" | |
| 298 | + ] | |
| 299 | + }, | |
| 300 | + "setup": [ | |
| 301 | + "$IP link set dev $DUMMY up || true", | |
| 302 | + "$IP addr add 10.10.11.10/24 dev $DUMMY || true", | |
| 303 | + "$TC qdisc add dev $DUMMY root handle 1: tbf rate 8bit burst 100b latency 100ms", | |
| 304 | + "$TC qdisc replace dev $DUMMY handle 2: parent 1:1 fq limit 1000", | |
| 305 | + [ | |
| 306 | + "ping -I $DUMMY -c2 10.10.11.11", | |
| 307 | + 1 | |
| 308 | + ], | |
| 309 | + "$TC qdisc change dev $DUMMY handle 2: parent 1:1 fq limit 1" | |
| 310 | + ], | |
| 311 | + "cmdUnderTest": "$TC qdisc del dev $DUMMY handle 2: parent 1:1", | |
| 312 | + "expExitCode": "0", | |
| 313 | + "verifyCmd": "$TC -s qdisc show dev $DUMMY", | |
| 314 | + "matchPattern": "backlog 0b 0p", | |
| 315 | + "matchCount": "1", | |
| 316 | + "teardown": [ | |
| 317 | + "$TC qdisc del dev $DUMMY handle 1: root" | |
| 318 | + ] | |
| 319 | + }, | |
| 320 | + { | |
| 321 | + "id": "5d0b", | |
| 322 | + "name": "Test TBF with FQ_CODEL Backlog Accounting in gso_skb case against underflow", | |
| 323 | + "category": [ | |
| 324 | + "qdisc", | |
| 325 | + "tbf", | |
| 326 | + "fq_codel" | |
| 327 | + ], | |
| 328 | + "plugins": { | |
| 329 | + "requires": [ | |
| 330 | + "nsPlugin" | |
| 331 | + ] | |
| 332 | + }, | |
| 333 | + "setup": [ | |
| 334 | + "$IP link set dev $DUMMY up || true", | |
| 335 | + "$IP addr add 10.10.11.10/24 dev $DUMMY || true", | |
| 336 | + "$TC qdisc add dev $DUMMY root handle 1: tbf rate 8bit burst 100b latency 100ms", | |
| 337 | + "$TC qdisc replace dev $DUMMY handle 2: parent 1:1 fq_codel limit 1000", | |
| 338 | + [ | |
| 339 | + "ping -I $DUMMY -c2 10.10.11.11", | |
| 340 | + 1 | |
| 341 | + ], | |
| 342 | + "$TC qdisc change dev $DUMMY handle 2: parent 1:1 fq_codel limit 1" | |
| 343 | + ], | |
| 344 | + "cmdUnderTest": "$TC qdisc del dev $DUMMY handle 2: parent 1:1", | |
| 345 | + "expExitCode": "0", | |
| 346 | + "verifyCmd": "$TC -s qdisc show dev $DUMMY", | |
| 347 | + "matchPattern": "backlog 0b 0p", | |
| 348 | + "matchCount": "1", | |
| 349 | + "teardown": [ | |
| 350 | + "$TC qdisc del dev $DUMMY handle 1: root" | |
| 351 | + ] | |
| 352 | + }, | |
| 353 | + { | |
| 354 | + "id": "21c3", | |
| 355 | + "name": "Test TBF with FQ_PIE Backlog Accounting in gso_skb case against underflow", | |
| 356 | + "category": [ | |
| 357 | + "qdisc", | |
| 358 | + "tbf", | |
| 359 | + "fq_pie" | |
| 360 | + ], | |
| 361 | + "plugins": { | |
| 362 | + "requires": [ | |
| 363 | + "nsPlugin" | |
| 364 | + ] | |
| 365 | + }, | |
| 366 | + "setup": [ | |
| 367 | + "$IP link set dev $DUMMY up || true", | |
| 368 | + "$IP addr add 10.10.11.10/24 dev $DUMMY || true", | |
| 369 | + "$TC qdisc add dev $DUMMY root handle 1: tbf rate 8bit burst 100b latency 100ms", | |
| 370 | + "$TC qdisc replace dev $DUMMY handle 2: parent 1:1 fq_pie limit 1000", | |
| 371 | + [ | |
| 372 | + "ping -I $DUMMY -c2 10.10.11.11", | |
| 373 | + 1 | |
| 374 | + ], | |
| 375 | + "$TC qdisc change dev $DUMMY handle 2: parent 1:1 fq_pie limit 1" | |
| 376 | + ], | |
| 377 | + "cmdUnderTest": "$TC qdisc del dev $DUMMY handle 2: parent 1:1", | |
| 378 | + "expExitCode": "0", | |
| 379 | + "verifyCmd": "$TC -s qdisc show dev $DUMMY", | |
| 380 | + "matchPattern": "backlog 0b 0p", | |
| 381 | + "matchCount": "1", | |
| 382 | + "teardown": [ | |
| 383 | + "$TC qdisc del dev $DUMMY handle 1: root" | |
| 384 | + ] | |
| 385 | + }, | |
| 188 | 386 | { |
| 189 | 387 | "id": "a4bb", |
| 190 | 388 | "name": "Test FQ_CODEL with HTB parent - force packet drop with empty queue", |
| @@ -1400,7 +1400,7 @@ static int cmd_dev_get_features(void) · 1399 unmodified lines | ||
| 1400 | 1400 | |
| 1401 | 1401 | if (!((1ULL << i) & features)) |
| 1402 | 1402 | continue; |
| 1403 | − if (i < sizeof(feat_map) / sizeof(feat_map[0])) | |
| 1403 | + if (i < ARRAY_SIZE(feat_map)) | |
| 1404 | 1404 | feat = feat_map[i]; |
| 1405 | 1405 | else |
| 1406 | 1406 | feat = "unknown"; |
| @@ -1477,7 +1477,7 @@ static void __cmd_create_help(char *exe, bool recovery) · 70 unmodified lines | ||
| 1477 | 1477 | printf("\tdefault: nr_queues=2(max 32), depth=128(max 1024), dev_id=-1(auto allocation)\n"); |
| 1478 | 1478 | printf("\tdefault: nthreads=nr_queues"); |
| 1479 | 1479 | |
| 1480 | − for (i = 0; i < sizeof(tgt_ops_list) / sizeof(tgt_ops_list[0]); i++) { | |
| 1480 | + for (i = 0; i < ARRAY_SIZE(tgt_ops_list); i++) { | |
| 1481 | 1481 | const struct ublk_tgt_ops *ops = tgt_ops_list[i]; |
| 1482 | 1482 | |
| 1483 | 1483 | if (ops->usage) |
| @@ -1 +1,5 @@ | ||
| 1 | +/* Avoid duplicate definitions due to system headers. */ | |
| 2 | +#ifdef __CONCAT | |
| 3 | +#undef __CONCAT | |
| 4 | +#endif | |
| 1 | 5 | #include "../../../../include/linux/idr.h" |
| @@ -1,7 +1,15 @@ | ||
| 1 | 1 | # SPDX-License-Identifier: GPL-2.0-only |
| 2 | 2 | |
| 3 | +include $(srctree)/tools/scripts/utilities.mak | |
| 4 | + | |
| 3 | 5 | STOP_ERROR := |
| 4 | 6 | |
| 7 | +ifndef ($(NO_LIBTRACEEVENT),1) | |
| 8 | + ifeq ($(call get-executable,$(PKG_CONFIG)),) | |
| 9 | + $(error Error: $(PKG_CONFIG) needed by libtraceevent/libtracefs is missing on this system, please install it) | |
| 10 | + endif | |
| 11 | +endif | |
| 12 | + | |
| 5 | 13 | define lib_setup |
| 6 | 14 | $(eval LIB_INCLUDES += $(shell sh -c "$(PKG_CONFIG) --cflags lib$(1)")) |
| 7 | 15 | $(eval LDFLAGS += $(shell sh -c "$(PKG_CONFIG) --libs-only-L lib$(1)")) |
| @@ -1,10 +1,18 @@ | ||
| 1 | 1 | # SPDX-License-Identifier: GPL-2.0-only |
| 2 | 2 | |
| 3 | +include $(srctree)/tools/scripts/utilities.mak | |
| 4 | + | |
| 3 | 5 | STOP_ERROR := |
| 4 | 6 | |
| 5 | 7 | LIBTRACEEVENT_MIN_VERSION = 1.5 |
| 6 | 8 | LIBTRACEFS_MIN_VERSION = 1.6 |
| 7 | 9 | |
| 10 | +ifndef ($(NO_LIBTRACEEVENT),1) | |
| 11 | + ifeq ($(call get-executable,$(PKG_CONFIG)),) | |
| 12 | + $(error Error: $(PKG_CONFIG) needed by libtraceevent/libtracefs is missing on this system, please install it) | |
| 13 | + endif | |
| 14 | +endif | |
| 15 | + | |
| 8 | 16 | define lib_setup |
| 9 | 17 | $(eval LIB_INCLUDES += $(shell sh -c "$(PKG_CONFIG) --cflags lib$(1)")) |
| 10 | 18 | $(eval LDFLAGS += $(shell sh -c "$(PKG_CONFIG) --libs-only-L lib$(1)")) |