Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net

Cross-merge networking fixes after downstream PR.

No conflicts or adjacent changes.

Link: https://patch.msgid.link/20240808170148.3629934-1-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+3040 -1783
+1
.mailmap
··· 166 166 Daniel Borkmann <daniel@iogearbox.net> <dxchgb@gmail.com> 167 167 David Brownell <david-b@pacbell.net> 168 168 David Collins <quic_collinsd@quicinc.com> <collinsd@codeaurora.org> 169 + David Heidelberg <david@ixit.cz> <d.okias@gmail.com> 169 170 David Rheinsberg <david@readahead.eu> <dh.herrmann@gmail.com> 170 171 David Rheinsberg <david@readahead.eu> <dh.herrmann@googlemail.com> 171 172 David Rheinsberg <david@readahead.eu> <david.rheinsberg@gmail.com>
+1 -3
Documentation/admin-guide/kernel-parameters.txt
··· 4798 4798 4799 4799 profile= [KNL] Enable kernel profiling via /proc/profile 4800 4800 Format: [<profiletype>,]<number> 4801 - Param: <profiletype>: "schedule", "sleep", or "kvm" 4801 + Param: <profiletype>: "schedule" or "kvm" 4802 4802 [defaults to kernel profiling] 4803 4803 Param: "schedule" - profile schedule points. 4804 - Param: "sleep" - profile D-state sleeping (millisecs). 4805 - Requires CONFIG_SCHEDSTATS 4806 4804 Param: "kvm" - profile VM exits. 4807 4805 Param: <number> - step/bucket size as a power of 2 for 4808 4806 statistical time based profiling.
+18
Documentation/arch/arm64/silicon-errata.rst
··· 122 122 +----------------+-----------------+-----------------+-----------------------------+ 123 123 | ARM | Cortex-A76 | #1490853 | N/A | 124 124 +----------------+-----------------+-----------------+-----------------------------+ 125 + | ARM | Cortex-A76 | #3324349 | ARM64_ERRATUM_3194386 | 126 + +----------------+-----------------+-----------------+-----------------------------+ 125 127 | ARM | Cortex-A77 | #1491015 | N/A | 126 128 +----------------+-----------------+-----------------+-----------------------------+ 127 129 | ARM | Cortex-A77 | #1508412 | ARM64_ERRATUM_1508412 | 130 + +----------------+-----------------+-----------------+-----------------------------+ 131 + | ARM | Cortex-A77 | #3324348 | ARM64_ERRATUM_3194386 | 132 + +----------------+-----------------+-----------------+-----------------------------+ 133 + | ARM | Cortex-A78 | #3324344 | ARM64_ERRATUM_3194386 | 134 + +----------------+-----------------+-----------------+-----------------------------+ 135 + | ARM | Cortex-A78C | #3324346,3324347| ARM64_ERRATUM_3194386 | 128 136 +----------------+-----------------+-----------------+-----------------------------+ 129 137 | ARM | Cortex-A710 | #2119858 | ARM64_ERRATUM_2119858 | 130 138 +----------------+-----------------+-----------------+-----------------------------+ ··· 146 138 +----------------+-----------------+-----------------+-----------------------------+ 147 139 | ARM | Cortex-A720 | #3456091 | ARM64_ERRATUM_3194386 | 148 140 +----------------+-----------------+-----------------+-----------------------------+ 141 + | ARM | Cortex-A725 | #3456106 | ARM64_ERRATUM_3194386 | 142 + +----------------+-----------------+-----------------+-----------------------------+ 149 143 | ARM | Cortex-X1 | #1502854 | N/A | 144 + +----------------+-----------------+-----------------+-----------------------------+ 145 + | ARM | Cortex-X1 | #3324344 | ARM64_ERRATUM_3194386 | 146 + +----------------+-----------------+-----------------+-----------------------------+ 147 + | ARM | Cortex-X1C | #3324346 | ARM64_ERRATUM_3194386 | 150 148 +----------------+-----------------+-----------------+-----------------------------+ 151 149 | ARM | Cortex-X2 | #2119858 | ARM64_ERRATUM_2119858 | 152 150 +----------------+-----------------+-----------------+-----------------------------+ ··· 174 160 +----------------+-----------------+-----------------+-----------------------------+ 175 161 | ARM | Neoverse-N1 | #1542419 | ARM64_ERRATUM_1542419 | 176 162 +----------------+-----------------+-----------------+-----------------------------+ 163 + | ARM | Neoverse-N1 | #3324349 | ARM64_ERRATUM_3194386 | 164 + +----------------+-----------------+-----------------+-----------------------------+ 177 165 | ARM | Neoverse-N2 | #2139208 | ARM64_ERRATUM_2139208 | 178 166 +----------------+-----------------+-----------------+-----------------------------+ 179 167 | ARM | Neoverse-N2 | #2067961 | ARM64_ERRATUM_2067961 | ··· 185 169 | ARM | Neoverse-N2 | #3324339 | ARM64_ERRATUM_3194386 | 186 170 +----------------+-----------------+-----------------+-----------------------------+ 187 171 | ARM | Neoverse-V1 | #1619801 | N/A | 172 + +----------------+-----------------+-----------------+-----------------------------+ 173 + | ARM | Neoverse-V1 | #3324341 | ARM64_ERRATUM_3194386 | 188 174 +----------------+-----------------+-----------------+-----------------------------+ 189 175 | ARM | Neoverse-V2 | #3324336 | ARM64_ERRATUM_3194386 | 190 176 +----------------+-----------------+-----------------+-----------------------------+
+3
Documentation/devicetree/bindings/ata/rockchip,dwc-ahci.yaml
··· 35 35 ports-implemented: 36 36 const: 1 37 37 38 + power-domains: 39 + maxItems: 1 40 + 38 41 sata-port@0: 39 42 $ref: /schemas/ata/snps,dwc-ahci-common.yaml#/$defs/dwc-ahci-port 40 43
+30 -35
Documentation/driver-api/thermal/sysfs-api.rst
··· 4 4 5 5 Written by Sujith Thomas <sujith.thomas@intel.com>, Zhang Rui <rui.zhang@intel.com> 6 6 7 - Updated: 2 January 2008 8 - 9 7 Copyright (c) 2008 Intel Corporation 10 8 11 9 ··· 36 38 37 39 :: 38 40 39 - struct thermal_zone_device 40 - *thermal_zone_device_register(char *type, 41 - int trips, int mask, void *devdata, 42 - struct thermal_zone_device_ops *ops, 43 - const struct thermal_zone_params *tzp, 44 - int passive_delay, int polling_delay)) 41 + struct thermal_zone_device * 42 + thermal_zone_device_register_with_trips(const char *type, 43 + const struct thermal_trip *trips, 44 + int num_trips, void *devdata, 45 + const struct thermal_zone_device_ops *ops, 46 + const struct thermal_zone_params *tzp, 47 + unsigned int passive_delay, 48 + unsigned int polling_delay) 45 49 46 - This interface function adds a new thermal zone device (sensor) to 50 + This interface function adds a new thermal zone device (sensor) to the 47 51 /sys/class/thermal folder as `thermal_zone[0-*]`. It tries to bind all the 48 - thermal cooling devices registered at the same time. 52 + thermal cooling devices registered to it at the same time. 49 53 50 54 type: 51 55 the thermal zone type. 52 56 trips: 53 - the total number of trip points this thermal zone supports. 54 - mask: 55 - Bit string: If 'n'th bit is set, then trip point 'n' is writable. 57 + the table of trip points for this thermal zone. 56 58 devdata: 57 59 device private data 58 60 ops: ··· 65 67 .get_temp: 66 68 get the current temperature of the thermal zone. 67 69 .set_trips: 68 - set the trip points window. Whenever the current temperature 69 - is updated, the trip points immediately below and above the 70 - current temperature are found. 71 - .get_mode: 72 - get the current mode (enabled/disabled) of the thermal zone. 73 - 74 - - "enabled" means the kernel thermal management is 75 - enabled. 76 - - "disabled" will prevent kernel thermal driver action 77 - upon trip points so that user applications can take 78 - charge of thermal management. 79 - .set_mode: 80 - set the mode (enabled/disabled) of the thermal zone. 81 - .get_trip_type: 82 - get the type of certain trip point. 83 - .get_trip_temp: 84 - get the temperature above which the certain trip point 85 - will be fired. 70 + set the trip points window. Whenever the current temperature 71 + is updated, the trip points immediately below and above the 72 + current temperature are found. 73 + .change_mode: 74 + change the mode (enabled/disabled) of the thermal zone. 75 + .set_trip_temp: 76 + set the temperature of a given trip point. 77 + .get_crit_temp: 78 + get the critical temperature for this thermal zone. 86 79 .set_emul_temp: 87 - set the emulation temperature which helps in debugging 88 - different threshold temperature points. 80 + set the emulation temperature which helps in debugging 81 + different threshold temperature points. 82 + .get_trend: 83 + get the trend of most recent zone temperature changes. 84 + .hot: 85 + hot trip point crossing handler. 86 + .critical: 87 + critical trip point crossing handler. 89 88 tzp: 90 89 thermal zone platform parameters. 91 90 passive_delay: 92 - number of milliseconds to wait between polls when 93 - performing passive cooling. 91 + number of milliseconds to wait between polls when performing passive 92 + cooling. 94 93 polling_delay: 95 94 number of milliseconds to wait between polls when checking 96 95 whether trip points have been crossed (0 for interrupt driven systems).
+2 -2
Documentation/userspace-api/media/v4l/pixfmt-yuv-luma.rst
··· 21 21 22 22 .. raw:: latex 23 23 24 - \scriptsize 24 + \tiny 25 25 26 - .. tabularcolumns:: |p{3.6cm}|p{3.0cm}|p{1.3cm}|p{2.6cm}|p{1.3cm}|p{1.3cm}|p{1.3cm}| 26 + .. tabularcolumns:: |p{3.6cm}|p{2.4cm}|p{1.3cm}|p{1.3cm}|p{1.3cm}|p{1.3cm}|p{1.3cm}|p{1.3cm}|p{1.3cm}| 27 27 28 28 .. flat-table:: Luma-Only Image Formats 29 29 :header-rows: 1
+7 -1
Documentation/virt/kvm/api.rst
··· 6368 6368 See KVM_SET_USER_MEMORY_REGION2 for additional details. 6369 6369 6370 6370 4.143 KVM_PRE_FAULT_MEMORY 6371 - ------------------------ 6371 + --------------------------- 6372 6372 6373 6373 :Capability: KVM_CAP_PRE_FAULT_MEMORY 6374 6374 :Architectures: none ··· 6404 6404 for the current vCPU state. KVM maps memory as if the vCPU generated a 6405 6405 stage-2 read page fault, e.g. faults in memory as needed, but doesn't break 6406 6406 CoW. However, KVM does not mark any newly created stage-2 PTE as Accessed. 6407 + 6408 + In the case of confidential VM types where there is an initial set up of 6409 + private guest memory before the guest is 'finalized'/measured, this ioctl 6410 + should only be issued after completing all the necessary setup to put the 6411 + guest into a 'finalized' state so that the above semantics can be reliably 6412 + ensured. 6407 6413 6408 6414 In some cases, multiple vCPUs might share the page tables. In this 6409 6415 case, the ioctl can be called in parallel.
+3 -3
Documentation/wmi/devices/msi-wmi-platform.rst
··· 130 130 131 131 Due to a peculiarity in how Windows handles the ``CreateByteField()`` ACPI operator (errors only 132 132 happen when a invalid byte field is ultimately accessed), all methods require a 32 byte input 133 - buffer, even if the Binay MOF says otherwise. 133 + buffer, even if the Binary MOF says otherwise. 134 134 135 135 The input buffer contains a single byte to select the subfeature to be accessed and 31 bytes of 136 136 input data, the meaning of which depends on the subfeature being accessed. 137 137 138 - The output buffer contains a singe byte which signals success or failure (``0x00`` on failure) 138 + The output buffer contains a single byte which signals success or failure (``0x00`` on failure) 139 139 and 31 bytes of output data, the meaning if which depends on the subfeature being accessed. 140 140 141 141 WMI method Get_EC() ··· 147 147 The first 4 bits of the flag byte contain the minor version of the embedded controller interface, 148 148 with the next 2 bits containing the major version of the embedded controller interface. 149 149 150 - The 7th bit signals if the embedded controller page chaged (exact meaning is unknown), and the 150 + The 7th bit signals if the embedded controller page changed (exact meaning is unknown), and the 151 151 last bit signals if the platform is a Tigerlake platform. 152 152 153 153 The MSI software seems to only use this interface when the last bit is set.
+4 -2
MAINTAINERS
··· 13324 13324 F: drivers/i2c/muxes/i2c-mux-ltc4306.c 13325 13325 13326 13326 LTP (Linux Test Project) 13327 + M: Andrea Cervesato <andrea.cervesato@suse.com> 13327 13328 M: Cyril Hrubis <chrubis@suse.cz> 13328 13329 M: Jan Stancek <jstancek@redhat.com> 13329 13330 M: Petr Vorel <pvorel@suse.cz> 13330 13331 M: Li Wang <liwang@redhat.com> 13331 13332 M: Yang Xu <xuyang2018.jy@fujitsu.com> 13333 + M: Xiao Yang <yangx.jy@fujitsu.com> 13332 13334 L: ltp@lists.linux.it (subscribers-only) 13333 13335 S: Maintained 13334 - W: http://linux-test-project.github.io/ 13336 + W: https://linux-test-project.readthedocs.io/ 13335 13337 T: git https://github.com/linux-test-project/ltp.git 13336 13338 13337 13339 LTR390 AMBIENT/UV LIGHT SENSOR DRIVER ··· 13541 13539 M: Mirko Lindner <mlindner@marvell.com> 13542 13540 M: Stephen Hemminger <stephen@networkplumber.org> 13543 13541 L: netdev@vger.kernel.org 13544 - S: Maintained 13542 + S: Odd fixes 13545 13543 F: drivers/net/ethernet/marvell/sk* 13546 13544 13547 13545 MARVELL LIBERTAS WIRELESS DRIVER
+1 -1
Makefile
··· 2 2 VERSION = 6 3 3 PATCHLEVEL = 11 4 4 SUBLEVEL = 0 5 - EXTRAVERSION = -rc1 5 + EXTRAVERSION = -rc2 6 6 NAME = Baby Opossum Posse 7 7 8 8 # *DOCUMENTATION*
+2 -2
arch/alpha/include/asm/io.h
··· 534 534 535 535 #define ioread16be(p) swab16(ioread16(p)) 536 536 #define ioread32be(p) swab32(ioread32(p)) 537 + #define ioread64be(p) swab64(ioread64(p)) 537 538 #define iowrite16be(v,p) iowrite16(swab16(v), (p)) 538 539 #define iowrite32be(v,p) iowrite32(swab32(v), (p)) 540 + #define iowrite64be(v,p) iowrite64(swab64(v), (p)) 539 541 540 542 #define inb_p inb 541 543 #define inw_p inw ··· 636 634 */ 637 635 #define ioread64 ioread64 638 636 #define iowrite64 iowrite64 639 - #define ioread64be ioread64be 640 - #define iowrite64be iowrite64be 641 637 #define ioread8_rep ioread8_rep 642 638 #define ioread16_rep ioread16_rep 643 639 #define ioread32_rep ioread32_rep
+1 -1
arch/arm/boot/dts/arm/versatile-ab.dts
··· 157 157 clocks = <&xtal24mhz>; 158 158 }; 159 159 160 - pclk: clock-24000000 { 160 + pclk: clock-pclk { 161 161 #clock-cells = <0>; 162 162 compatible = "fixed-factor-clock"; 163 163 clock-div = <1>;
+16 -6
arch/arm64/Kconfig
··· 1069 1069 If unsure, say Y. 1070 1070 1071 1071 config ARM64_ERRATUM_3194386 1072 - bool "Cortex-{A720,X4,X925}/Neoverse-V3: workaround for MSR SSBS not self-synchronizing" 1072 + bool "Cortex-*/Neoverse-*: workaround for MSR SSBS not self-synchronizing" 1073 1073 default y 1074 1074 help 1075 1075 This option adds the workaround for the following errata: 1076 1076 1077 + * ARM Cortex-A76 erratum 3324349 1078 + * ARM Cortex-A77 erratum 3324348 1079 + * ARM Cortex-A78 erratum 3324344 1080 + * ARM Cortex-A78C erratum 3324346 1081 + * ARM Cortex-A78C erratum 3324347 1077 1082 * ARM Cortex-A710 erratam 3324338 1078 1083 * ARM Cortex-A720 erratum 3456091 1084 + * ARM Cortex-A725 erratum 3456106 1085 + * ARM Cortex-X1 erratum 3324344 1086 + * ARM Cortex-X1C erratum 3324346 1079 1087 * ARM Cortex-X2 erratum 3324338 1080 1088 * ARM Cortex-X3 erratum 3324335 1081 1089 * ARM Cortex-X4 erratum 3194386 1082 1090 * ARM Cortex-X925 erratum 3324334 1091 + * ARM Neoverse-N1 erratum 3324349 1083 1092 * ARM Neoverse N2 erratum 3324339 1093 + * ARM Neoverse-V1 erratum 3324341 1084 1094 * ARM Neoverse V2 erratum 3324336 1085 1095 * ARM Neoverse-V3 erratum 3312417 1086 1096 ··· 1098 1088 subsequent speculative instructions, which may permit unexepected 1099 1089 speculative store bypassing. 1100 1090 1101 - Work around this problem by placing a speculation barrier after 1102 - kernel changes to SSBS. The presence of the SSBS special-purpose 1103 - register is hidden from hwcaps and EL0 reads of ID_AA64PFR1_EL1, such 1104 - that userspace will use the PR_SPEC_STORE_BYPASS prctl to change 1105 - SSBS. 1091 + Work around this problem by placing a Speculation Barrier (SB) or 1092 + Instruction Synchronization Barrier (ISB) after kernel changes to 1093 + SSBS. The presence of the SSBS special-purpose register is hidden 1094 + from hwcaps and EL0 reads of ID_AA64PFR1_EL1, such that userspace 1095 + will use the PR_SPEC_STORE_BYPASS prctl to change SSBS. 1106 1096 1107 1097 If unsure, say Y. 1108 1098
+4
arch/arm64/include/asm/cputype.h
··· 86 86 #define ARM_CPU_PART_CORTEX_X2 0xD48 87 87 #define ARM_CPU_PART_NEOVERSE_N2 0xD49 88 88 #define ARM_CPU_PART_CORTEX_A78C 0xD4B 89 + #define ARM_CPU_PART_CORTEX_X1C 0xD4C 89 90 #define ARM_CPU_PART_CORTEX_X3 0xD4E 90 91 #define ARM_CPU_PART_NEOVERSE_V2 0xD4F 91 92 #define ARM_CPU_PART_CORTEX_A720 0xD81 92 93 #define ARM_CPU_PART_CORTEX_X4 0xD82 93 94 #define ARM_CPU_PART_NEOVERSE_V3 0xD84 94 95 #define ARM_CPU_PART_CORTEX_X925 0xD85 96 + #define ARM_CPU_PART_CORTEX_A725 0xD87 95 97 96 98 #define APM_CPU_PART_XGENE 0x000 97 99 #define APM_CPU_VAR_POTENZA 0x00 ··· 167 165 #define MIDR_CORTEX_X2 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_X2) 168 166 #define MIDR_NEOVERSE_N2 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_NEOVERSE_N2) 169 167 #define MIDR_CORTEX_A78C MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A78C) 168 + #define MIDR_CORTEX_X1C MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_X1C) 170 169 #define MIDR_CORTEX_X3 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_X3) 171 170 #define MIDR_NEOVERSE_V2 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_NEOVERSE_V2) 172 171 #define MIDR_CORTEX_A720 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A720) 173 172 #define MIDR_CORTEX_X4 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_X4) 174 173 #define MIDR_NEOVERSE_V3 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_NEOVERSE_V3) 175 174 #define MIDR_CORTEX_X925 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_X925) 175 + #define MIDR_CORTEX_A725 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A725) 176 176 #define MIDR_THUNDERX MIDR_CPU_MODEL(ARM_CPU_IMP_CAVIUM, CAVIUM_CPU_PART_THUNDERX) 177 177 #define MIDR_THUNDERX_81XX MIDR_CPU_MODEL(ARM_CPU_IMP_CAVIUM, CAVIUM_CPU_PART_THUNDERX_81XX) 178 178 #define MIDR_THUNDERX_83XX MIDR_CPU_MODEL(ARM_CPU_IMP_CAVIUM, CAVIUM_CPU_PART_THUNDERX_83XX)
+1
arch/arm64/include/asm/jump_label.h
··· 13 13 #include <linux/types.h> 14 14 #include <asm/insn.h> 15 15 16 + #define HAVE_JUMP_LABEL_BATCH 16 17 #define JUMP_LABEL_NOP_SIZE AARCH64_INSN_SIZE 17 18 18 19 #define JUMP_TABLE_ENTRY(key, label) \
+1 -1
arch/arm64/kernel/Makefile.syscalls
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 2 3 3 syscall_abis_32 += 4 - syscall_abis_64 += renameat newstat rlimit memfd_secret 4 + syscall_abis_64 += renameat rlimit memfd_secret 5 5 6 6 syscalltbl = arch/arm64/tools/syscall_%.tbl
+10 -1
arch/arm64/kernel/cpu_errata.c
··· 434 434 435 435 #ifdef CONFIG_ARM64_ERRATUM_3194386 436 436 static const struct midr_range erratum_spec_ssbs_list[] = { 437 + MIDR_ALL_VERSIONS(MIDR_CORTEX_A76), 438 + MIDR_ALL_VERSIONS(MIDR_CORTEX_A77), 439 + MIDR_ALL_VERSIONS(MIDR_CORTEX_A78), 440 + MIDR_ALL_VERSIONS(MIDR_CORTEX_A78C), 437 441 MIDR_ALL_VERSIONS(MIDR_CORTEX_A710), 438 442 MIDR_ALL_VERSIONS(MIDR_CORTEX_A720), 443 + MIDR_ALL_VERSIONS(MIDR_CORTEX_A725), 444 + MIDR_ALL_VERSIONS(MIDR_CORTEX_X1), 445 + MIDR_ALL_VERSIONS(MIDR_CORTEX_X1C), 439 446 MIDR_ALL_VERSIONS(MIDR_CORTEX_X2), 440 447 MIDR_ALL_VERSIONS(MIDR_CORTEX_X3), 441 448 MIDR_ALL_VERSIONS(MIDR_CORTEX_X4), 442 449 MIDR_ALL_VERSIONS(MIDR_CORTEX_X925), 450 + MIDR_ALL_VERSIONS(MIDR_NEOVERSE_N1), 443 451 MIDR_ALL_VERSIONS(MIDR_NEOVERSE_N2), 444 - MIDR_ALL_VERSIONS(MIDR_NEOVERSE_V3), 452 + MIDR_ALL_VERSIONS(MIDR_NEOVERSE_V1), 445 453 MIDR_ALL_VERSIONS(MIDR_NEOVERSE_V2), 454 + MIDR_ALL_VERSIONS(MIDR_NEOVERSE_V3), 446 455 {} 447 456 }; 448 457 #endif
+9 -2
arch/arm64/kernel/jump_label.c
··· 7 7 */ 8 8 #include <linux/kernel.h> 9 9 #include <linux/jump_label.h> 10 + #include <linux/smp.h> 10 11 #include <asm/insn.h> 11 12 #include <asm/patching.h> 12 13 13 - void arch_jump_label_transform(struct jump_entry *entry, 14 - enum jump_label_type type) 14 + bool arch_jump_label_transform_queue(struct jump_entry *entry, 15 + enum jump_label_type type) 15 16 { 16 17 void *addr = (void *)jump_entry_code(entry); 17 18 u32 insn; ··· 26 25 } 27 26 28 27 aarch64_insn_patch_text_nosync(addr, insn); 28 + return true; 29 + } 30 + 31 + void arch_jump_label_transform_apply(void) 32 + { 33 + kick_all_cpus_sync(); 29 34 }
+2 -2
arch/loongarch/include/asm/hugetlb.h
··· 34 34 unsigned long addr, pte_t *ptep) 35 35 { 36 36 pte_t clear; 37 - pte_t pte = *ptep; 37 + pte_t pte = ptep_get(ptep); 38 38 39 39 pte_val(clear) = (unsigned long)invalid_pte_table; 40 40 set_pte_at(mm, addr, ptep, clear); ··· 65 65 pte_t *ptep, pte_t pte, 66 66 int dirty) 67 67 { 68 - int changed = !pte_same(*ptep, pte); 68 + int changed = !pte_same(ptep_get(ptep), pte); 69 69 70 70 if (changed) { 71 71 set_pte_at(vma->vm_mm, addr, ptep, pte);
+3 -3
arch/loongarch/include/asm/kfence.h
··· 53 53 { 54 54 pte_t *pte = virt_to_kpte(addr); 55 55 56 - if (WARN_ON(!pte) || pte_none(*pte)) 56 + if (WARN_ON(!pte) || pte_none(ptep_get(pte))) 57 57 return false; 58 58 59 59 if (protect) 60 - set_pte(pte, __pte(pte_val(*pte) & ~(_PAGE_VALID | _PAGE_PRESENT))); 60 + set_pte(pte, __pte(pte_val(ptep_get(pte)) & ~(_PAGE_VALID | _PAGE_PRESENT))); 61 61 else 62 - set_pte(pte, __pte(pte_val(*pte) | (_PAGE_VALID | _PAGE_PRESENT))); 62 + set_pte(pte, __pte(pte_val(ptep_get(pte)) | (_PAGE_VALID | _PAGE_PRESENT))); 63 63 64 64 preempt_disable(); 65 65 local_flush_tlb_one(addr);
-2
arch/loongarch/include/asm/kvm_host.h
··· 26 26 27 27 #define KVM_MAX_VCPUS 256 28 28 #define KVM_MAX_CPUCFG_REGS 21 29 - /* memory slots that does not exposed to userspace */ 30 - #define KVM_PRIVATE_MEM_SLOTS 0 31 29 32 30 #define KVM_HALT_POLL_NS_DEFAULT 500000 33 31 #define KVM_REQ_TLB_FLUSH_GPA KVM_ARCH_REQ(0)
+2 -2
arch/loongarch/include/asm/kvm_para.h
··· 39 39 * Hypercall interface for KVM hypervisor 40 40 * 41 41 * a0: function identifier 42 - * a1-a6: args 42 + * a1-a5: args 43 43 * Return value will be placed in a0. 44 - * Up to 6 arguments are passed in a1, a2, a3, a4, a5, a6. 44 + * Up to 5 arguments are passed in a1, a2, a3, a4, a5. 45 45 */ 46 46 static __always_inline long kvm_hypercall0(u64 fid) 47 47 {
+30 -20
arch/loongarch/include/asm/pgtable.h
··· 106 106 #define KFENCE_AREA_START (VMEMMAP_END + 1) 107 107 #define KFENCE_AREA_END (KFENCE_AREA_START + KFENCE_AREA_SIZE - 1) 108 108 109 + #define ptep_get(ptep) READ_ONCE(*(ptep)) 110 + #define pmdp_get(pmdp) READ_ONCE(*(pmdp)) 111 + 109 112 #define pte_ERROR(e) \ 110 113 pr_err("%s:%d: bad pte %016lx.\n", __FILE__, __LINE__, pte_val(e)) 111 114 #ifndef __PAGETABLE_PMD_FOLDED ··· 150 147 return p4d_val(p4d) != (unsigned long)invalid_pud_table; 151 148 } 152 149 153 - static inline void p4d_clear(p4d_t *p4dp) 154 - { 155 - p4d_val(*p4dp) = (unsigned long)invalid_pud_table; 156 - } 157 - 158 150 static inline pud_t *p4d_pgtable(p4d_t p4d) 159 151 { 160 152 return (pud_t *)p4d_val(p4d); ··· 157 159 158 160 static inline void set_p4d(p4d_t *p4d, p4d_t p4dval) 159 161 { 160 - *p4d = p4dval; 162 + WRITE_ONCE(*p4d, p4dval); 163 + } 164 + 165 + static inline void p4d_clear(p4d_t *p4dp) 166 + { 167 + set_p4d(p4dp, __p4d((unsigned long)invalid_pud_table)); 161 168 } 162 169 163 170 #define p4d_phys(p4d) PHYSADDR(p4d_val(p4d)) ··· 196 193 return pud_val(pud) != (unsigned long)invalid_pmd_table; 197 194 } 198 195 199 - static inline void pud_clear(pud_t *pudp) 200 - { 201 - pud_val(*pudp) = ((unsigned long)invalid_pmd_table); 202 - } 203 - 204 196 static inline pmd_t *pud_pgtable(pud_t pud) 205 197 { 206 198 return (pmd_t *)pud_val(pud); 207 199 } 208 200 209 - #define set_pud(pudptr, pudval) do { *(pudptr) = (pudval); } while (0) 201 + static inline void set_pud(pud_t *pud, pud_t pudval) 202 + { 203 + WRITE_ONCE(*pud, pudval); 204 + } 205 + 206 + static inline void pud_clear(pud_t *pudp) 207 + { 208 + set_pud(pudp, __pud((unsigned long)invalid_pmd_table)); 209 + } 210 210 211 211 #define pud_phys(pud) PHYSADDR(pud_val(pud)) 212 212 #define pud_page(pud) (pfn_to_page(pud_phys(pud) >> PAGE_SHIFT)) ··· 237 231 return pmd_val(pmd) != (unsigned long)invalid_pte_table; 238 232 } 239 233 240 - static inline void pmd_clear(pmd_t *pmdp) 234 + static inline void set_pmd(pmd_t *pmd, pmd_t pmdval) 241 235 { 242 - pmd_val(*pmdp) = ((unsigned long)invalid_pte_table); 236 + WRITE_ONCE(*pmd, pmdval); 243 237 } 244 238 245 - #define set_pmd(pmdptr, pmdval) do { *(pmdptr) = (pmdval); } while (0) 239 + static inline void pmd_clear(pmd_t *pmdp) 240 + { 241 + set_pmd(pmdp, __pmd((unsigned long)invalid_pte_table)); 242 + } 246 243 247 244 #define pmd_phys(pmd) PHYSADDR(pmd_val(pmd)) 248 245 ··· 323 314 324 315 static inline void set_pte(pte_t *ptep, pte_t pteval) 325 316 { 326 - *ptep = pteval; 317 + WRITE_ONCE(*ptep, pteval); 318 + 327 319 if (pte_val(pteval) & _PAGE_GLOBAL) { 328 320 pte_t *buddy = ptep_buddy(ptep); 329 321 /* ··· 351 341 : [buddy] "+m" (buddy->pte), [tmp] "=&r" (tmp) 352 342 : [global] "r" (page_global)); 353 343 #else /* !CONFIG_SMP */ 354 - if (pte_none(*buddy)) 355 - pte_val(*buddy) = pte_val(*buddy) | _PAGE_GLOBAL; 344 + if (pte_none(ptep_get(buddy))) 345 + WRITE_ONCE(*buddy, __pte(pte_val(ptep_get(buddy)) | _PAGE_GLOBAL)); 356 346 #endif /* CONFIG_SMP */ 357 347 } 358 348 } ··· 360 350 static inline void pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep) 361 351 { 362 352 /* Preserve global status for the pair */ 363 - if (pte_val(*ptep_buddy(ptep)) & _PAGE_GLOBAL) 353 + if (pte_val(ptep_get(ptep_buddy(ptep))) & _PAGE_GLOBAL) 364 354 set_pte(ptep, __pte(_PAGE_GLOBAL)); 365 355 else 366 356 set_pte(ptep, __pte(0)); ··· 613 603 static inline pmd_t pmdp_huge_get_and_clear(struct mm_struct *mm, 614 604 unsigned long address, pmd_t *pmdp) 615 605 { 616 - pmd_t old = *pmdp; 606 + pmd_t old = pmdp_get(pmdp); 617 607 618 608 pmd_clear(pmdp); 619 609
+2 -1
arch/loongarch/kernel/Makefile.syscalls
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 2 3 - syscall_abis_64 += newstat 3 + # No special ABIs on loongarch so far 4 + syscall_abis_64 +=
+6
arch/loongarch/kernel/efi.c
··· 66 66 set_bit(EFI_RUNTIME_SERVICES, &efi.flags); 67 67 } 68 68 69 + bool efi_poweroff_required(void) 70 + { 71 + return efi_enabled(EFI_RUNTIME_SERVICES) && 72 + (acpi_gbl_reduced_hardware || acpi_no_s5); 73 + } 74 + 69 75 unsigned long __initdata screen_info_table = EFI_INVALID_TABLE_ADDR; 70 76 71 77 #if defined(CONFIG_SYSFB) || defined(CONFIG_EFI_EARLYCON)
+4 -4
arch/loongarch/kvm/mmu.c
··· 714 714 * value) and then p*d_offset() walks into the target huge page instead 715 715 * of the old page table (sees the new value). 716 716 */ 717 - pgd = READ_ONCE(*pgd_offset(kvm->mm, hva)); 717 + pgd = pgdp_get(pgd_offset(kvm->mm, hva)); 718 718 if (pgd_none(pgd)) 719 719 goto out; 720 720 721 - p4d = READ_ONCE(*p4d_offset(&pgd, hva)); 721 + p4d = p4dp_get(p4d_offset(&pgd, hva)); 722 722 if (p4d_none(p4d) || !p4d_present(p4d)) 723 723 goto out; 724 724 725 - pud = READ_ONCE(*pud_offset(&p4d, hva)); 725 + pud = pudp_get(pud_offset(&p4d, hva)); 726 726 if (pud_none(pud) || !pud_present(pud)) 727 727 goto out; 728 728 729 - pmd = READ_ONCE(*pmd_offset(&pud, hva)); 729 + pmd = pmdp_get(pmd_offset(&pud, hva)); 730 730 if (pmd_none(pmd) || !pmd_present(pmd)) 731 731 goto out; 732 732
+3 -3
arch/loongarch/mm/hugetlbpage.c
··· 39 39 pmd_t *pmd = NULL; 40 40 41 41 pgd = pgd_offset(mm, addr); 42 - if (pgd_present(*pgd)) { 42 + if (pgd_present(pgdp_get(pgd))) { 43 43 p4d = p4d_offset(pgd, addr); 44 - if (p4d_present(*p4d)) { 44 + if (p4d_present(p4dp_get(p4d))) { 45 45 pud = pud_offset(p4d, addr); 46 - if (pud_present(*pud)) 46 + if (pud_present(pudp_get(pud))) 47 47 pmd = pmd_offset(pud, addr); 48 48 } 49 49 }
+5 -5
arch/loongarch/mm/init.c
··· 141 141 int __meminit vmemmap_check_pmd(pmd_t *pmd, int node, 142 142 unsigned long addr, unsigned long next) 143 143 { 144 - int huge = pmd_val(*pmd) & _PAGE_HUGE; 144 + int huge = pmd_val(pmdp_get(pmd)) & _PAGE_HUGE; 145 145 146 146 if (huge) 147 147 vmemmap_verify((pte_t *)pmd, node, addr, next); ··· 173 173 pud_t *pud; 174 174 pmd_t *pmd; 175 175 176 - if (p4d_none(*p4d)) { 176 + if (p4d_none(p4dp_get(p4d))) { 177 177 pud = memblock_alloc(PAGE_SIZE, PAGE_SIZE); 178 178 if (!pud) 179 179 panic("%s: Failed to allocate memory\n", __func__); ··· 184 184 } 185 185 186 186 pud = pud_offset(p4d, addr); 187 - if (pud_none(*pud)) { 187 + if (pud_none(pudp_get(pud))) { 188 188 pmd = memblock_alloc(PAGE_SIZE, PAGE_SIZE); 189 189 if (!pmd) 190 190 panic("%s: Failed to allocate memory\n", __func__); ··· 195 195 } 196 196 197 197 pmd = pmd_offset(pud, addr); 198 - if (!pmd_present(*pmd)) { 198 + if (!pmd_present(pmdp_get(pmd))) { 199 199 pte_t *pte; 200 200 201 201 pte = memblock_alloc(PAGE_SIZE, PAGE_SIZE); ··· 216 216 BUG_ON(idx <= FIX_HOLE || idx >= __end_of_fixed_addresses); 217 217 218 218 ptep = populate_kernel_pte(addr); 219 - if (!pte_none(*ptep)) { 219 + if (!pte_none(ptep_get(ptep))) { 220 220 pte_ERROR(*ptep); 221 221 return; 222 222 }
+5 -5
arch/loongarch/mm/kasan_init.c
··· 105 105 106 106 static pte_t *__init kasan_pte_offset(pmd_t *pmdp, unsigned long addr, int node, bool early) 107 107 { 108 - if (__pmd_none(early, READ_ONCE(*pmdp))) { 108 + if (__pmd_none(early, pmdp_get(pmdp))) { 109 109 phys_addr_t pte_phys = early ? 110 110 __pa_symbol(kasan_early_shadow_pte) : kasan_alloc_zeroed_page(node); 111 111 if (!early) ··· 118 118 119 119 static pmd_t *__init kasan_pmd_offset(pud_t *pudp, unsigned long addr, int node, bool early) 120 120 { 121 - if (__pud_none(early, READ_ONCE(*pudp))) { 121 + if (__pud_none(early, pudp_get(pudp))) { 122 122 phys_addr_t pmd_phys = early ? 123 123 __pa_symbol(kasan_early_shadow_pmd) : kasan_alloc_zeroed_page(node); 124 124 if (!early) ··· 131 131 132 132 static pud_t *__init kasan_pud_offset(p4d_t *p4dp, unsigned long addr, int node, bool early) 133 133 { 134 - if (__p4d_none(early, READ_ONCE(*p4dp))) { 134 + if (__p4d_none(early, p4dp_get(p4dp))) { 135 135 phys_addr_t pud_phys = early ? 136 136 __pa_symbol(kasan_early_shadow_pud) : kasan_alloc_zeroed_page(node); 137 137 if (!early) ··· 154 154 : kasan_alloc_zeroed_page(node); 155 155 next = addr + PAGE_SIZE; 156 156 set_pte(ptep, pfn_pte(__phys_to_pfn(page_phys), PAGE_KERNEL)); 157 - } while (ptep++, addr = next, addr != end && __pte_none(early, READ_ONCE(*ptep))); 157 + } while (ptep++, addr = next, addr != end && __pte_none(early, ptep_get(ptep))); 158 158 } 159 159 160 160 static void __init kasan_pmd_populate(pud_t *pudp, unsigned long addr, ··· 166 166 do { 167 167 next = pmd_addr_end(addr, end); 168 168 kasan_pte_populate(pmdp, addr, next, node, early); 169 - } while (pmdp++, addr = next, addr != end && __pmd_none(early, READ_ONCE(*pmdp))); 169 + } while (pmdp++, addr = next, addr != end && __pmd_none(early, pmdp_get(pmdp))); 170 170 } 171 171 172 172 static void __init kasan_pud_populate(p4d_t *p4dp, unsigned long addr,
+1 -1
arch/loongarch/mm/pgtable.c
··· 128 128 void set_pmd_at(struct mm_struct *mm, unsigned long addr, 129 129 pmd_t *pmdp, pmd_t pmd) 130 130 { 131 - *pmdp = pmd; 131 + WRITE_ONCE(*pmdp, pmd); 132 132 flush_tlb_all(); 133 133 } 134 134
+1
arch/parisc/Kconfig
··· 20 20 select ARCH_SUPPORTS_HUGETLBFS if PA20 21 21 select ARCH_SUPPORTS_MEMORY_FAILURE 22 22 select ARCH_STACKWALK 23 + select ARCH_HAS_CACHE_LINE_SIZE 23 24 select ARCH_HAS_DEBUG_VM_PGTABLE 24 25 select HAVE_RELIABLE_STACKTRACE 25 26 select DMA_OPS
+10 -1
arch/parisc/include/asm/cache.h
··· 20 20 21 21 #define SMP_CACHE_BYTES L1_CACHE_BYTES 22 22 23 - #define ARCH_DMA_MINALIGN L1_CACHE_BYTES 23 + #ifdef CONFIG_PA20 24 + #define ARCH_DMA_MINALIGN 128 25 + #else 26 + #define ARCH_DMA_MINALIGN 32 27 + #endif 28 + #define ARCH_KMALLOC_MINALIGN 16 /* ldcw requires 16-byte alignment */ 29 + 30 + #define arch_slab_minalign() ((unsigned)dcache_stride) 31 + #define cache_line_size() dcache_stride 32 + #define dma_get_cache_alignment cache_line_size 24 33 25 34 #define __read_mostly __section(".data..read_mostly") 26 35
+1 -1
arch/parisc/net/bpf_jit_core.c
··· 114 114 jit_data->header = 115 115 bpf_jit_binary_alloc(prog_size + extable_size, 116 116 &jit_data->image, 117 - sizeof(u32), 117 + sizeof(long), 118 118 bpf_fill_ill_insns); 119 119 if (!jit_data->header) { 120 120 prog = orig_prog;
+1 -1
arch/riscv/kernel/Makefile.syscalls
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 2 3 3 syscall_abis_32 += riscv memfd_secret 4 - syscall_abis_64 += riscv newstat rlimit memfd_secret 4 + syscall_abis_64 += riscv rlimit memfd_secret
+6 -8
arch/riscv/kernel/cpufeature.c
··· 432 432 bitmap_copy(prev_resolved_isa, resolved_isa, RISCV_ISA_EXT_MAX); 433 433 for_each_set_bit(bit, source_isa, RISCV_ISA_EXT_MAX) { 434 434 ext = riscv_get_isa_ext_data(bit); 435 - if (!ext) 436 - continue; 437 435 438 - if (ext->validate) { 436 + if (ext && ext->validate) { 439 437 ret = ext->validate(ext, resolved_isa); 440 438 if (ret == -EPROBE_DEFER) { 441 439 loop = true; 442 440 continue; 443 441 } else if (ret) { 444 442 /* Disable the extension entirely */ 445 - clear_bit(ext->id, source_isa); 443 + clear_bit(bit, source_isa); 446 444 continue; 447 445 } 448 446 } 449 447 450 - set_bit(ext->id, resolved_isa); 448 + set_bit(bit, resolved_isa); 451 449 /* No need to keep it in source isa now that it is enabled */ 452 - clear_bit(ext->id, source_isa); 450 + clear_bit(bit, source_isa); 453 451 454 452 /* Single letter extensions get set in hwcap */ 455 - if (ext->id < RISCV_ISA_EXT_BASE) 456 - *this_hwcap |= isa2hwcap[ext->id]; 453 + if (bit < RISCV_ISA_EXT_BASE) 454 + *this_hwcap |= isa2hwcap[bit]; 457 455 } 458 456 } while (loop && memcmp(prev_resolved_isa, resolved_isa, sizeof(prev_resolved_isa))); 459 457 }
+1 -1
arch/riscv/kernel/sbi-ipi.c
··· 71 71 * the masking/unmasking of virtual IPIs is done 72 72 * via generic IPI-Mux 73 73 */ 74 - cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, 74 + cpuhp_setup_state(CPUHP_AP_IRQ_RISCV_SBI_IPI_STARTING, 75 75 "irqchip/sbi-ipi:starting", 76 76 sbi_ipi_starting_cpu, NULL); 77 77
+9 -8
arch/riscv/mm/fault.c
··· 61 61 62 62 static inline void mm_fault_error(struct pt_regs *regs, unsigned long addr, vm_fault_t fault) 63 63 { 64 + if (!user_mode(regs)) { 65 + no_context(regs, addr); 66 + return; 67 + } 68 + 64 69 if (fault & VM_FAULT_OOM) { 65 70 /* 66 71 * We ran out of memory, call the OOM killer, and return the userspace 67 72 * (which will retry the fault, or kill us if we got oom-killed). 68 73 */ 69 - if (!user_mode(regs)) { 70 - no_context(regs, addr); 71 - return; 72 - } 73 74 pagefault_out_of_memory(); 74 75 return; 75 76 } else if (fault & (VM_FAULT_SIGBUS | VM_FAULT_HWPOISON | VM_FAULT_HWPOISON_LARGE)) { 76 77 /* Kernel mode? Handle exceptions or die */ 77 - if (!user_mode(regs)) { 78 - no_context(regs, addr); 79 - return; 80 - } 81 78 do_trap(regs, SIGBUS, BUS_ADRERR, addr); 82 79 return; 80 + } else if (fault & VM_FAULT_SIGSEGV) { 81 + do_trap(regs, SIGSEGV, SEGV_MAPERR, addr); 82 + return; 83 83 } 84 + 84 85 BUG(); 85 86 } 86 87
+11 -4
arch/riscv/mm/init.c
··· 234 234 */ 235 235 memblock_reserve(vmlinux_start, vmlinux_end - vmlinux_start); 236 236 237 - phys_ram_end = memblock_end_of_DRAM(); 238 - 239 237 /* 240 238 * Make sure we align the start of the memory on a PMD boundary so that 241 239 * at worst, we map the linear mapping with PMD mappings. ··· 247 249 */ 248 250 if (IS_ENABLED(CONFIG_64BIT) && IS_ENABLED(CONFIG_MMU)) 249 251 kernel_map.va_pa_offset = PAGE_OFFSET - phys_ram_base; 252 + 253 + /* 254 + * The size of the linear page mapping may restrict the amount of 255 + * usable RAM. 256 + */ 257 + if (IS_ENABLED(CONFIG_64BIT)) { 258 + max_mapped_addr = __pa(PAGE_OFFSET) + KERN_VIRT_SIZE; 259 + memblock_cap_memory_range(phys_ram_base, 260 + max_mapped_addr - phys_ram_base); 261 + } 250 262 251 263 /* 252 264 * Reserve physical address space that would be mapped to virtual ··· 274 266 memblock_reserve(max_mapped_addr, (phys_addr_t)-max_mapped_addr); 275 267 } 276 268 269 + phys_ram_end = memblock_end_of_DRAM(); 277 270 min_low_pfn = PFN_UP(phys_ram_base); 278 271 max_low_pfn = max_pfn = PFN_DOWN(phys_ram_end); 279 272 high_memory = (void *)(__va(PFN_PHYS(max_low_pfn))); ··· 1293 1284 if (start <= __pa(PAGE_OFFSET) && 1294 1285 __pa(PAGE_OFFSET) < end) 1295 1286 start = __pa(PAGE_OFFSET); 1296 - if (end >= __pa(PAGE_OFFSET) + memory_limit) 1297 - end = __pa(PAGE_OFFSET) + memory_limit; 1298 1287 1299 1288 create_linear_mapping_range(start, end, 0, NULL); 1300 1289 }
+2
arch/riscv/purgatory/entry.S
··· 7 7 * Author: Li Zhengyu (lizhengyu3@huawei.com) 8 8 * 9 9 */ 10 + #include <asm/asm.h> 10 11 #include <linux/linkage.h> 11 12 12 13 .text ··· 35 34 36 35 .data 37 36 37 + .align LGREG 38 38 SYM_DATA(riscv_kernel_entry, .quad 0) 39 39 40 40 .end
arch/s390/kernel/alternative.h
+1 -1
arch/s390/kernel/fpu.c
··· 113 113 int mask; 114 114 115 115 if (flags & KERNEL_FPC) 116 - fpu_lfpc(&state->fpc); 116 + fpu_lfpc_safe(&state->fpc); 117 117 if (!cpu_has_vx()) { 118 118 if (flags & KERNEL_VXR_V0V7) 119 119 load_fp_regs_vx(state->vxrs);
+9 -8
arch/s390/kernel/vmlinux.lds.S
··· 59 59 } :text = 0x0700 60 60 61 61 RO_DATA(PAGE_SIZE) 62 - .data.rel.ro : { 63 - *(.data.rel.ro .data.rel.ro.*) 64 - } 65 - .got : { 66 - __got_start = .; 67 - *(.got) 68 - __got_end = .; 69 - } 70 62 71 63 . = ALIGN(PAGE_SIZE); 72 64 _sdata = .; /* Start of data section */ ··· 71 79 } :data 72 80 . = ALIGN(PAGE_SIZE); 73 81 __end_ro_after_init = .; 82 + 83 + .data.rel.ro : { 84 + *(.data.rel.ro .data.rel.ro.*) 85 + } 86 + .got : { 87 + __got_start = .; 88 + *(.got) 89 + __got_end = .; 90 + } 74 91 75 92 RW_DATA(0x100, PAGE_SIZE, THREAD_SIZE) 76 93 .data.rel : {
+79 -61
arch/s390/mm/dump_pagetables.c
··· 3 3 #include <linux/ptdump.h> 4 4 #include <linux/seq_file.h> 5 5 #include <linux/debugfs.h> 6 + #include <linux/sort.h> 6 7 #include <linux/mm.h> 7 8 #include <linux/kfence.h> 8 9 #include <linux/kasan.h> ··· 16 15 static unsigned long max_addr; 17 16 18 17 struct addr_marker { 18 + int is_start; 19 19 unsigned long start_address; 20 20 const char *name; 21 21 }; 22 22 23 23 enum address_markers_idx { 24 - IDENTITY_BEFORE_NR = 0, 25 - IDENTITY_BEFORE_END_NR, 24 + KVA_NR = 0, 25 + LOWCORE_START_NR, 26 + LOWCORE_END_NR, 26 27 AMODE31_START_NR, 27 28 AMODE31_END_NR, 28 29 KERNEL_START_NR, ··· 33 30 KFENCE_START_NR, 34 31 KFENCE_END_NR, 35 32 #endif 36 - IDENTITY_AFTER_NR, 37 - IDENTITY_AFTER_END_NR, 33 + IDENTITY_START_NR, 34 + IDENTITY_END_NR, 38 35 VMEMMAP_NR, 39 36 VMEMMAP_END_NR, 40 37 VMALLOC_NR, ··· 62 59 }; 63 60 64 61 static struct addr_marker address_markers[] = { 65 - [IDENTITY_BEFORE_NR] = {0, "Identity Mapping Start"}, 66 - [IDENTITY_BEFORE_END_NR] = {(unsigned long)_stext, "Identity Mapping End"}, 67 - [AMODE31_START_NR] = {0, "Amode31 Area Start"}, 68 - [AMODE31_END_NR] = {0, "Amode31 Area End"}, 69 - [KERNEL_START_NR] = {(unsigned long)_stext, "Kernel Image Start"}, 70 - [KERNEL_END_NR] = {(unsigned long)_end, "Kernel Image End"}, 62 + [KVA_NR] = {0, 0, "Kernel Virtual Address Space"}, 63 + [LOWCORE_START_NR] = {1, 0, "Lowcore Start"}, 64 + [LOWCORE_END_NR] = {0, 0, "Lowcore End"}, 65 + [IDENTITY_START_NR] = {1, 0, "Identity Mapping Start"}, 66 + [IDENTITY_END_NR] = {0, 0, "Identity Mapping End"}, 67 + [AMODE31_START_NR] = {1, 0, "Amode31 Area Start"}, 68 + [AMODE31_END_NR] = {0, 0, "Amode31 Area End"}, 69 + [KERNEL_START_NR] = {1, (unsigned long)_stext, "Kernel Image Start"}, 70 + [KERNEL_END_NR] = {0, (unsigned long)_end, "Kernel Image End"}, 71 71 #ifdef CONFIG_KFENCE 72 - [KFENCE_START_NR] = {0, "KFence Pool Start"}, 73 - [KFENCE_END_NR] = {0, "KFence Pool End"}, 72 + [KFENCE_START_NR] = {1, 0, "KFence Pool Start"}, 73 + [KFENCE_END_NR] = {0, 0, "KFence Pool End"}, 74 74 #endif 75 - [IDENTITY_AFTER_NR] = {(unsigned long)_end, "Identity Mapping Start"}, 76 - [IDENTITY_AFTER_END_NR] = {0, "Identity Mapping End"}, 77 - [VMEMMAP_NR] = {0, "vmemmap Area Start"}, 78 - [VMEMMAP_END_NR] = {0, "vmemmap Area End"}, 79 - [VMALLOC_NR] = {0, "vmalloc Area Start"}, 80 - [VMALLOC_END_NR] = {0, "vmalloc Area End"}, 75 + [VMEMMAP_NR] = {1, 0, "vmemmap Area Start"}, 76 + [VMEMMAP_END_NR] = {0, 0, "vmemmap Area End"}, 77 + [VMALLOC_NR] = {1, 0, "vmalloc Area Start"}, 78 + [VMALLOC_END_NR] = {0, 0, "vmalloc Area End"}, 81 79 #ifdef CONFIG_KMSAN 82 - [KMSAN_VMALLOC_SHADOW_START_NR] = {0, "Kmsan vmalloc Shadow Start"}, 83 - [KMSAN_VMALLOC_SHADOW_END_NR] = {0, "Kmsan vmalloc Shadow End"}, 84 - [KMSAN_VMALLOC_ORIGIN_START_NR] = {0, "Kmsan vmalloc Origins Start"}, 85 - [KMSAN_VMALLOC_ORIGIN_END_NR] = {0, "Kmsan vmalloc Origins End"}, 86 - [KMSAN_MODULES_SHADOW_START_NR] = {0, "Kmsan Modules Shadow Start"}, 87 - [KMSAN_MODULES_SHADOW_END_NR] = {0, "Kmsan Modules Shadow End"}, 88 - [KMSAN_MODULES_ORIGIN_START_NR] = {0, "Kmsan Modules Origins Start"}, 89 - [KMSAN_MODULES_ORIGIN_END_NR] = {0, "Kmsan Modules Origins End"}, 80 + [KMSAN_VMALLOC_SHADOW_START_NR] = {1, 0, "Kmsan vmalloc Shadow Start"}, 81 + [KMSAN_VMALLOC_SHADOW_END_NR] = {0, 0, "Kmsan vmalloc Shadow End"}, 82 + [KMSAN_VMALLOC_ORIGIN_START_NR] = {1, 0, "Kmsan vmalloc Origins Start"}, 83 + [KMSAN_VMALLOC_ORIGIN_END_NR] = {0, 0, "Kmsan vmalloc Origins End"}, 84 + [KMSAN_MODULES_SHADOW_START_NR] = {1, 0, "Kmsan Modules Shadow Start"}, 85 + [KMSAN_MODULES_SHADOW_END_NR] = {0, 0, "Kmsan Modules Shadow End"}, 86 + [KMSAN_MODULES_ORIGIN_START_NR] = {1, 0, "Kmsan Modules Origins Start"}, 87 + [KMSAN_MODULES_ORIGIN_END_NR] = {0, 0, "Kmsan Modules Origins End"}, 90 88 #endif 91 - [MODULES_NR] = {0, "Modules Area Start"}, 92 - [MODULES_END_NR] = {0, "Modules Area End"}, 93 - [ABS_LOWCORE_NR] = {0, "Lowcore Area Start"}, 94 - [ABS_LOWCORE_END_NR] = {0, "Lowcore Area End"}, 95 - [MEMCPY_REAL_NR] = {0, "Real Memory Copy Area Start"}, 96 - [MEMCPY_REAL_END_NR] = {0, "Real Memory Copy Area End"}, 89 + [MODULES_NR] = {1, 0, "Modules Area Start"}, 90 + [MODULES_END_NR] = {0, 0, "Modules Area End"}, 91 + [ABS_LOWCORE_NR] = {1, 0, "Lowcore Area Start"}, 92 + [ABS_LOWCORE_END_NR] = {0, 0, "Lowcore Area End"}, 93 + [MEMCPY_REAL_NR] = {1, 0, "Real Memory Copy Area Start"}, 94 + [MEMCPY_REAL_END_NR] = {0, 0, "Real Memory Copy Area End"}, 97 95 #ifdef CONFIG_KASAN 98 - [KASAN_SHADOW_START_NR] = {KASAN_SHADOW_START, "Kasan Shadow Start"}, 99 - [KASAN_SHADOW_END_NR] = {KASAN_SHADOW_END, "Kasan Shadow End"}, 96 + [KASAN_SHADOW_START_NR] = {1, KASAN_SHADOW_START, "Kasan Shadow Start"}, 97 + [KASAN_SHADOW_END_NR] = {0, KASAN_SHADOW_END, "Kasan Shadow End"}, 100 98 #endif 101 - { -1, NULL } 99 + {1, -1UL, NULL} 102 100 }; 103 101 104 102 struct pg_state { ··· 167 163 st->wx_pages += (addr - st->start_address) / PAGE_SIZE; 168 164 } 169 165 166 + static void note_page_update_state(struct pg_state *st, unsigned long addr, unsigned int prot, int level) 167 + { 168 + struct seq_file *m = st->seq; 169 + 170 + while (addr >= st->marker[1].start_address) { 171 + st->marker++; 172 + pt_dump_seq_printf(m, "---[ %s ]---\n", st->marker->name); 173 + } 174 + st->start_address = addr; 175 + st->current_prot = prot; 176 + st->level = level; 177 + } 178 + 170 179 static void note_page(struct ptdump_state *pt_st, unsigned long addr, int level, u64 val) 171 180 { 172 181 int width = sizeof(unsigned long) * 2; ··· 203 186 addr = max_addr; 204 187 if (st->level == -1) { 205 188 pt_dump_seq_printf(m, "---[ %s ]---\n", st->marker->name); 206 - st->start_address = addr; 207 - st->current_prot = prot; 208 - st->level = level; 189 + note_page_update_state(st, addr, prot, level); 209 190 } else if (prot != st->current_prot || level != st->level || 210 191 addr >= st->marker[1].start_address) { 211 192 note_prot_wx(st, addr); ··· 217 202 } 218 203 pt_dump_seq_printf(m, "%9lu%c ", delta, *unit); 219 204 print_prot(m, st->current_prot, st->level); 220 - while (addr >= st->marker[1].start_address) { 221 - st->marker++; 222 - pt_dump_seq_printf(m, "---[ %s ]---\n", st->marker->name); 223 - } 224 - st->start_address = addr; 225 - st->current_prot = prot; 226 - st->level = level; 205 + note_page_update_state(st, addr, prot, level); 227 206 } 228 207 } 229 208 ··· 289 280 DEFINE_SHOW_ATTRIBUTE(ptdump); 290 281 #endif /* CONFIG_PTDUMP_DEBUGFS */ 291 282 292 - /* 293 - * Heapsort from lib/sort.c is not a stable sorting algorithm, do a simple 294 - * insertion sort to preserve the original order of markers with the same 295 - * start address. 296 - */ 297 - static void sort_address_markers(void) 283 + static int ptdump_cmp(const void *a, const void *b) 298 284 { 299 - struct addr_marker tmp; 300 - int i, j; 285 + const struct addr_marker *ama = a; 286 + const struct addr_marker *amb = b; 301 287 302 - for (i = 1; i < ARRAY_SIZE(address_markers) - 1; i++) { 303 - tmp = address_markers[i]; 304 - for (j = i - 1; j >= 0 && address_markers[j].start_address > tmp.start_address; j--) 305 - address_markers[j + 1] = address_markers[j]; 306 - address_markers[j + 1] = tmp; 307 - } 288 + if (ama->start_address > amb->start_address) 289 + return 1; 290 + if (ama->start_address < amb->start_address) 291 + return -1; 292 + /* 293 + * If the start addresses of two markers are identical consider the 294 + * marker which defines the start of an area higher than the one which 295 + * defines the end of an area. This keeps pairs of markers sorted. 296 + */ 297 + if (ama->is_start) 298 + return 1; 299 + if (amb->is_start) 300 + return -1; 301 + return 0; 308 302 } 309 303 310 304 static int pt_dump_init(void) ··· 315 303 #ifdef CONFIG_KFENCE 316 304 unsigned long kfence_start = (unsigned long)__kfence_pool; 317 305 #endif 306 + unsigned long lowcore = (unsigned long)get_lowcore(); 307 + 318 308 /* 319 309 * Figure out the maximum virtual address being accessible with the 320 310 * kernel ASCE. We need this to keep the page table walker functions ··· 324 310 */ 325 311 max_addr = (get_lowcore()->kernel_asce.val & _REGION_ENTRY_TYPE_MASK) >> 2; 326 312 max_addr = 1UL << (max_addr * 11 + 31); 327 - address_markers[IDENTITY_AFTER_END_NR].start_address = ident_map_size; 313 + address_markers[LOWCORE_START_NR].start_address = lowcore; 314 + address_markers[LOWCORE_END_NR].start_address = lowcore + sizeof(struct lowcore); 315 + address_markers[IDENTITY_START_NR].start_address = __identity_base; 316 + address_markers[IDENTITY_END_NR].start_address = __identity_base + ident_map_size; 328 317 address_markers[AMODE31_START_NR].start_address = (unsigned long)__samode31; 329 318 address_markers[AMODE31_END_NR].start_address = (unsigned long)__eamode31; 330 319 address_markers[MODULES_NR].start_address = MODULES_VADDR; ··· 354 337 address_markers[KMSAN_MODULES_ORIGIN_START_NR].start_address = KMSAN_MODULES_ORIGIN_START; 355 338 address_markers[KMSAN_MODULES_ORIGIN_END_NR].start_address = KMSAN_MODULES_ORIGIN_END; 356 339 #endif 357 - sort_address_markers(); 340 + sort(address_markers, ARRAY_SIZE(address_markers) - 1, 341 + sizeof(address_markers[0]), ptdump_cmp, NULL); 358 342 #ifdef CONFIG_PTDUMP_DEBUGFS 359 343 debugfs_create_file("kernel_page_tables", 0400, NULL, NULL, &ptdump_fops); 360 344 #endif /* CONFIG_PTDUMP_DEBUGFS */
+2 -7
arch/s390/mm/init.c
··· 108 108 { 109 109 unsigned long size = __end_ro_after_init - __start_ro_after_init; 110 110 111 + if (MACHINE_HAS_NX) 112 + system_ctl_set_bit(0, CR0_INSTRUCTION_EXEC_PROTECTION_BIT); 111 113 __set_memory_ro(__start_ro_after_init, __end_ro_after_init); 112 114 pr_info("Write protected read-only-after-init data: %luk\n", size >> 10); 113 115 } ··· 170 168 /* this will put all low memory onto the freelists */ 171 169 memblock_free_all(); 172 170 setup_zero_pages(); /* Setup zeroed pages. */ 173 - } 174 - 175 - void free_initmem(void) 176 - { 177 - set_memory_rwnx((unsigned long)_sinittext, 178 - (unsigned long)(_einittext - _sinittext) >> PAGE_SHIFT); 179 - free_initmem_default(POISON_FREE_INITMEM); 180 171 } 181 172 182 173 unsigned long memory_block_size_bytes(void)
+2 -11
arch/s390/mm/vmem.c
··· 661 661 { 662 662 __set_memory_rox(_stext, _etext); 663 663 __set_memory_ro(_etext, __end_rodata); 664 - __set_memory_rox(_sinittext, _einittext); 665 664 __set_memory_rox(__stext_amode31, __etext_amode31); 666 665 /* 667 666 * If the BEAR-enhancement facility is not installed the first ··· 669 670 */ 670 671 if (!static_key_enabled(&cpu_has_bear)) 671 672 set_memory_x(0, 1); 672 - if (debug_pagealloc_enabled()) { 673 - /* 674 - * Use RELOC_HIDE() as long as __va(0) translates to NULL, 675 - * since performing pointer arithmetic on a NULL pointer 676 - * has undefined behavior and generates compiler warnings. 677 - */ 678 - __set_memory_4k(__va(0), RELOC_HIDE(__va(0), ident_map_size)); 679 - } 680 - if (MACHINE_HAS_NX) 681 - system_ctl_set_bit(0, CR0_INSTRUCTION_EXEC_PROTECTION_BIT); 673 + if (debug_pagealloc_enabled()) 674 + __set_memory_4k(__va(0), __va(0) + ident_map_size); 682 675 pr_info("Write protected kernel read-only data: %luk\n", 683 676 (unsigned long)(__end_rodata - _stext) >> 10); 684 677 }
+1 -1
arch/x86/coco/sev/core.c
··· 163 163 */ 164 164 use_cas : 1, 165 165 166 - __reserved : 62; 166 + __reserved : 61; 167 167 }; 168 168 169 169 static struct sev_config sev_cfg __read_mostly;
+1 -1
arch/x86/entry/syscalls/syscall_64.tbl
··· 344 344 332 common statx sys_statx 345 345 333 common io_pgetevents sys_io_pgetevents 346 346 334 common rseq sys_rseq 347 + 335 common uretprobe sys_uretprobe 347 348 # don't use numbers 387 through 423, add new calls after the last 348 349 # 'common' entry 349 350 424 common pidfd_send_signal sys_pidfd_send_signal ··· 386 385 460 common lsm_set_self_attr sys_lsm_set_self_attr 387 386 461 common lsm_list_modules sys_lsm_list_modules 388 387 462 common mseal sys_mseal 389 - 467 common uretprobe sys_uretprobe 390 388 391 389 # 392 390 # Due to a historical design error, certain syscalls are numbered differently
+12 -10
arch/x86/events/core.c
··· 1520 1520 void perf_event_print_debug(void) 1521 1521 { 1522 1522 u64 ctrl, status, overflow, pmc_ctrl, pmc_count, prev_left, fixed; 1523 + unsigned long *cntr_mask, *fixed_cntr_mask; 1524 + struct event_constraint *pebs_constraints; 1525 + struct cpu_hw_events *cpuc; 1523 1526 u64 pebs, debugctl; 1524 - int cpu = smp_processor_id(); 1525 - struct cpu_hw_events *cpuc = &per_cpu(cpu_hw_events, cpu); 1526 - unsigned long *cntr_mask = hybrid(cpuc->pmu, cntr_mask); 1527 - unsigned long *fixed_cntr_mask = hybrid(cpuc->pmu, fixed_cntr_mask); 1528 - struct event_constraint *pebs_constraints = hybrid(cpuc->pmu, pebs_constraints); 1529 - unsigned long flags; 1530 - int idx; 1527 + int cpu, idx; 1528 + 1529 + guard(irqsave)(); 1530 + 1531 + cpu = smp_processor_id(); 1532 + cpuc = &per_cpu(cpu_hw_events, cpu); 1533 + cntr_mask = hybrid(cpuc->pmu, cntr_mask); 1534 + fixed_cntr_mask = hybrid(cpuc->pmu, fixed_cntr_mask); 1535 + pebs_constraints = hybrid(cpuc->pmu, pebs_constraints); 1531 1536 1532 1537 if (!*(u64 *)cntr_mask) 1533 1538 return; 1534 - 1535 - local_irq_save(flags); 1536 1539 1537 1540 if (x86_pmu.version >= 2) { 1538 1541 rdmsrl(MSR_CORE_PERF_GLOBAL_CTRL, ctrl); ··· 1580 1577 pr_info("CPU#%d: fixed-PMC%d count: %016llx\n", 1581 1578 cpu, idx, pmc_count); 1582 1579 } 1583 - local_irq_restore(flags); 1584 1580 } 1585 1581 1586 1582 void x86_pmu_stop(struct perf_event *event, int flags)
+3 -2
arch/x86/events/intel/cstate.c
··· 64 64 * perf code: 0x00 65 65 * Available model: SNB,IVB,HSW,BDW,SKL,KNL,GLM,CNL, 66 66 * KBL,CML,ICL,ICX,TGL,TNT,RKL,ADL, 67 - * RPL,SPR,MTL,ARL,LNL 67 + * RPL,SPR,MTL,ARL,LNL,SRF 68 68 * Scope: Package (physical package) 69 69 * MSR_PKG_C3_RESIDENCY: Package C3 Residency Counter. 70 70 * perf code: 0x01 ··· 693 693 .core_events = BIT(PERF_CSTATE_CORE_C1_RES) | 694 694 BIT(PERF_CSTATE_CORE_C6_RES), 695 695 696 - .pkg_events = BIT(PERF_CSTATE_PKG_C6_RES), 696 + .pkg_events = BIT(PERF_CSTATE_PKG_C2_RES) | 697 + BIT(PERF_CSTATE_PKG_C6_RES), 697 698 698 699 .module_events = BIT(PERF_CSTATE_MODULE_C6_RES), 699 700 };
+4
arch/x86/include/asm/cmdline.h
··· 2 2 #ifndef _ASM_X86_CMDLINE_H 3 3 #define _ASM_X86_CMDLINE_H 4 4 5 + #include <asm/setup.h> 6 + 7 + extern char builtin_cmdline[COMMAND_LINE_SIZE]; 8 + 5 9 int cmdline_find_option_bool(const char *cmdline_ptr, const char *option); 6 10 int cmdline_find_option(const char *cmdline_ptr, const char *option, 7 11 char *buffer, int bufsize);
+1
arch/x86/include/asm/kvm_host.h
··· 1305 1305 u8 vm_type; 1306 1306 bool has_private_mem; 1307 1307 bool has_protected_state; 1308 + bool pre_fault_allowed; 1308 1309 struct hlist_head mmu_page_hash[KVM_NUM_MMU_PAGES]; 1309 1310 struct list_head active_mmu_pages; 1310 1311 struct list_head zapped_obsolete_pages;
+1 -1
arch/x86/kernel/cpu/amd.c
··· 462 462 switch (c->x86_model) { 463 463 case 0x00 ... 0x2f: 464 464 case 0x40 ... 0x4f: 465 - case 0x70 ... 0x7f: 465 + case 0x60 ... 0x7f: 466 466 setup_force_cpu_cap(X86_FEATURE_ZEN5); 467 467 break; 468 468 default:
+4 -2
arch/x86/kernel/cpu/aperfmperf.c
··· 306 306 WARN_ON_ONCE(1); 307 307 return; 308 308 } 309 - static_branch_enable(&arch_scale_freq_key); 309 + static_branch_enable_cpuslocked(&arch_scale_freq_key); 310 310 register_freq_invariance_syscore_ops(); 311 311 pr_info("Estimated ratio of average max frequency by base frequency (times 1024): %llu\n", arch_max_freq_ratio); 312 312 } ··· 323 323 if (boot_cpu_data.x86_vendor != X86_VENDOR_INTEL) 324 324 return; 325 325 326 - if (intel_set_max_freq_ratio()) 326 + if (intel_set_max_freq_ratio()) { 327 + guard(cpus_read_lock)(); 327 328 freq_invariance_enable(); 329 + } 328 330 } 329 331 330 332 static void disable_freq_invariance_workfn(struct work_struct *work)
+1 -1
arch/x86/kernel/setup.c
··· 164 164 165 165 static char __initdata command_line[COMMAND_LINE_SIZE]; 166 166 #ifdef CONFIG_CMDLINE_BOOL 167 - static char __initdata builtin_cmdline[COMMAND_LINE_SIZE] = CONFIG_CMDLINE; 167 + char builtin_cmdline[COMMAND_LINE_SIZE] = CONFIG_CMDLINE; 168 168 bool builtin_cmdline_added __ro_after_init; 169 169 #endif 170 170
+2 -2
arch/x86/kvm/Kconfig
··· 141 141 depends on CRYPTO_DEV_SP_PSP && !(KVM_AMD=y && CRYPTO_DEV_CCP_DD=m) 142 142 select ARCH_HAS_CC_PLATFORM 143 143 select KVM_GENERIC_PRIVATE_MEM 144 - select HAVE_KVM_GMEM_PREPARE 145 - select HAVE_KVM_GMEM_INVALIDATE 144 + select HAVE_KVM_ARCH_GMEM_PREPARE 145 + select HAVE_KVM_ARCH_GMEM_INVALIDATE 146 146 help 147 147 Provides support for launching Encrypted VMs (SEV) and Encrypted VMs 148 148 with Encrypted State (SEV-ES) on AMD processors.
+1 -1
arch/x86/kvm/lapic.c
··· 1743 1743 s64 min_period = min_timer_period_us * 1000LL; 1744 1744 1745 1745 if (apic->lapic_timer.period < min_period) { 1746 - pr_info_ratelimited( 1746 + pr_info_once( 1747 1747 "vcpu %i: requested %lld ns " 1748 1748 "lapic timer period limited to %lld ns\n", 1749 1749 apic->vcpu->vcpu_id,
+5 -2
arch/x86/kvm/mmu/mmu.c
··· 4335 4335 if (req_max_level) 4336 4336 max_level = min(max_level, req_max_level); 4337 4337 4338 - return req_max_level; 4338 + return max_level; 4339 4339 } 4340 4340 4341 4341 static int kvm_faultin_pfn_private(struct kvm_vcpu *vcpu, ··· 4742 4742 u8 level = PG_LEVEL_4K; 4743 4743 u64 end; 4744 4744 int r; 4745 + 4746 + if (!vcpu->kvm->arch.pre_fault_allowed) 4747 + return -EOPNOTSUPP; 4745 4748 4746 4749 /* 4747 4750 * reload is efficient when called repeatedly, so we can do it on ··· 7513 7510 const unsigned long end = start + KVM_PAGES_PER_HPAGE(level); 7514 7511 7515 7512 if (level == PG_LEVEL_2M) 7516 - return kvm_range_has_memory_attributes(kvm, start, end, attrs); 7513 + return kvm_range_has_memory_attributes(kvm, start, end, ~0, attrs); 7517 7514 7518 7515 for (gfn = start; gfn < end; gfn += KVM_PAGES_PER_HPAGE(level - 1)) { 7519 7516 if (hugepage_test_mixed(slot, gfn, level - 1) ||
+9 -8
arch/x86/kvm/svm/sev.c
··· 2279 2279 bool assigned; 2280 2280 int level; 2281 2281 2282 - if (!kvm_mem_is_private(kvm, gfn)) { 2283 - pr_debug("%s: Failed to ensure GFN 0x%llx has private memory attribute set\n", 2284 - __func__, gfn); 2285 - ret = -EINVAL; 2286 - goto err; 2287 - } 2288 - 2289 2282 ret = snp_lookup_rmpentry((u64)pfn + i, &assigned, &level); 2290 2283 if (ret || assigned) { 2291 2284 pr_debug("%s: Failed to ensure GFN 0x%llx RMP entry is initial shared state, ret: %d assigned: %d\n", 2292 2285 __func__, gfn, ret, assigned); 2293 - ret = -EINVAL; 2286 + ret = ret ? -EINVAL : -EEXIST; 2294 2287 goto err; 2295 2288 } 2296 2289 ··· 2541 2548 memcpy(data->host_data, params.host_data, KVM_SEV_SNP_FINISH_DATA_SIZE); 2542 2549 data->gctx_paddr = __psp_pa(sev->snp_context); 2543 2550 ret = sev_issue_cmd(kvm, SEV_CMD_SNP_LAUNCH_FINISH, data, &argp->error); 2551 + 2552 + /* 2553 + * Now that there will be no more SNP_LAUNCH_UPDATE ioctls, private pages 2554 + * can be given to the guest simply by marking the RMP entry as private. 2555 + * This can happen on first access and also with KVM_PRE_FAULT_MEMORY. 2556 + */ 2557 + if (!ret) 2558 + kvm->arch.pre_fault_allowed = true; 2544 2559 2545 2560 kfree(id_auth); 2546 2561
+1
arch/x86/kvm/svm/svm.c
··· 4949 4949 to_kvm_sev_info(kvm)->need_init = true; 4950 4950 4951 4951 kvm->arch.has_private_mem = (type == KVM_X86_SNP_VM); 4952 + kvm->arch.pre_fault_allowed = !kvm->arch.has_private_mem; 4952 4953 } 4953 4954 4954 4955 if (!pause_filter_count || !pause_filter_thresh)
+5 -7
arch/x86/kvm/x86.c
··· 12646 12646 kvm->arch.vm_type = type; 12647 12647 kvm->arch.has_private_mem = 12648 12648 (type == KVM_X86_SW_PROTECTED_VM); 12649 + /* Decided by the vendor code for other VM types. */ 12650 + kvm->arch.pre_fault_allowed = 12651 + type == KVM_X86_DEFAULT_VM || type == KVM_X86_SW_PROTECTED_VM; 12649 12652 12650 12653 ret = kvm_page_track_init(kvm); 12651 12654 if (ret) ··· 13644 13641 } 13645 13642 EXPORT_SYMBOL_GPL(kvm_arch_no_poll); 13646 13643 13647 - #ifdef CONFIG_HAVE_KVM_GMEM_PREPARE 13648 - bool kvm_arch_gmem_prepare_needed(struct kvm *kvm) 13649 - { 13650 - return kvm->arch.vm_type == KVM_X86_SNP_VM; 13651 - } 13652 - 13644 + #ifdef CONFIG_HAVE_KVM_ARCH_GMEM_PREPARE 13653 13645 int kvm_arch_gmem_prepare(struct kvm *kvm, gfn_t gfn, kvm_pfn_t pfn, int max_order) 13654 13646 { 13655 13647 return kvm_x86_call(gmem_prepare)(kvm, pfn, gfn, max_order); 13656 13648 } 13657 13649 #endif 13658 13650 13659 - #ifdef CONFIG_HAVE_KVM_GMEM_INVALIDATE 13651 + #ifdef CONFIG_HAVE_KVM_ARCH_GMEM_INVALIDATE 13660 13652 void kvm_arch_gmem_invalidate(kvm_pfn_t start, kvm_pfn_t end) 13661 13653 { 13662 13654 kvm_x86_call(gmem_invalidate)(start, end);
+18 -7
arch/x86/lib/cmdline.c
··· 207 207 208 208 int cmdline_find_option_bool(const char *cmdline, const char *option) 209 209 { 210 - if (IS_ENABLED(CONFIG_CMDLINE_BOOL)) 211 - WARN_ON_ONCE(!builtin_cmdline_added); 210 + int ret; 212 211 213 - return __cmdline_find_option_bool(cmdline, COMMAND_LINE_SIZE, option); 212 + ret = __cmdline_find_option_bool(cmdline, COMMAND_LINE_SIZE, option); 213 + if (ret > 0) 214 + return ret; 215 + 216 + if (IS_ENABLED(CONFIG_CMDLINE_BOOL) && !builtin_cmdline_added) 217 + return __cmdline_find_option_bool(builtin_cmdline, COMMAND_LINE_SIZE, option); 218 + 219 + return ret; 214 220 } 215 221 216 222 int cmdline_find_option(const char *cmdline, const char *option, char *buffer, 217 223 int bufsize) 218 224 { 219 - if (IS_ENABLED(CONFIG_CMDLINE_BOOL)) 220 - WARN_ON_ONCE(!builtin_cmdline_added); 225 + int ret; 221 226 222 - return __cmdline_find_option(cmdline, COMMAND_LINE_SIZE, option, 223 - buffer, bufsize); 227 + ret = __cmdline_find_option(cmdline, COMMAND_LINE_SIZE, option, buffer, bufsize); 228 + if (ret > 0) 229 + return ret; 230 + 231 + if (IS_ENABLED(CONFIG_CMDLINE_BOOL) && !builtin_cmdline_added) 232 + return __cmdline_find_option(builtin_cmdline, COMMAND_LINE_SIZE, option, buffer, bufsize); 233 + 234 + return ret; 224 235 }
+3 -1
arch/x86/lib/getuser.S
··· 88 88 EXPORT_SYMBOL(__get_user_4) 89 89 90 90 SYM_FUNC_START(__get_user_8) 91 + #ifndef CONFIG_X86_64 92 + xor %ecx,%ecx 93 + #endif 91 94 check_range size=8 92 95 ASM_STAC 93 96 #ifdef CONFIG_X86_64 94 97 UACCESS movq (%_ASM_AX),%rdx 95 98 #else 96 - xor %ecx,%ecx 97 99 UACCESS movl (%_ASM_AX),%edx 98 100 UACCESS movl 4(%_ASM_AX),%ecx 99 101 #endif
+4 -4
arch/x86/mm/pti.c
··· 374 374 */ 375 375 *target_pmd = *pmd; 376 376 377 - addr += PMD_SIZE; 377 + addr = round_up(addr + 1, PMD_SIZE); 378 378 379 379 } else if (level == PTI_CLONE_PTE) { 380 380 381 381 /* Walk the page-table down to the pte level */ 382 382 pte = pte_offset_kernel(pmd, addr); 383 383 if (pte_none(*pte)) { 384 - addr += PAGE_SIZE; 384 + addr = round_up(addr + 1, PAGE_SIZE); 385 385 continue; 386 386 } 387 387 ··· 401 401 /* Clone the PTE */ 402 402 *target_pte = *pte; 403 403 404 - addr += PAGE_SIZE; 404 + addr = round_up(addr + 1, PAGE_SIZE); 405 405 406 406 } else { 407 407 BUG(); ··· 496 496 { 497 497 pti_clone_pgtable((unsigned long) __entry_text_start, 498 498 (unsigned long) __entry_text_end, 499 - PTI_CLONE_PMD); 499 + PTI_LEVEL_KERNEL_IMAGE); 500 500 } 501 501 502 502 /*
+9 -10
drivers/bluetooth/hci_qca.c
··· 2160 2160 qcadev = serdev_device_get_drvdata(hu->serdev); 2161 2161 power = qcadev->bt_power; 2162 2162 2163 - if (power->pwrseq) { 2163 + if (power && power->pwrseq) { 2164 2164 pwrseq_power_off(power->pwrseq); 2165 2165 set_bit(QCA_BT_OFF, &qca->flags); 2166 2166 return; ··· 2185 2185 sw_ctrl_state = gpiod_get_value_cansleep(qcadev->sw_ctrl); 2186 2186 bt_dev_dbg(hu->hdev, "SW_CTRL is %d", sw_ctrl_state); 2187 2187 } 2188 - break; 2189 - 2190 - case QCA_QCA6390: 2191 - pwrseq_power_off(qcadev->bt_power->pwrseq); 2192 2188 break; 2193 2189 2194 2190 default: ··· 2412 2416 break; 2413 2417 2414 2418 case QCA_QCA6390: 2415 - qcadev->bt_power->pwrseq = devm_pwrseq_get(&serdev->dev, 2416 - "bluetooth"); 2417 - if (IS_ERR(qcadev->bt_power->pwrseq)) 2418 - return PTR_ERR(qcadev->bt_power->pwrseq); 2419 - break; 2419 + if (dev_of_node(&serdev->dev)) { 2420 + qcadev->bt_power->pwrseq = devm_pwrseq_get(&serdev->dev, 2421 + "bluetooth"); 2422 + if (IS_ERR(qcadev->bt_power->pwrseq)) 2423 + return PTR_ERR(qcadev->bt_power->pwrseq); 2424 + break; 2425 + } 2426 + fallthrough; 2420 2427 2421 2428 default: 2422 2429 qcadev->bt_en = devm_gpiod_get_optional(&serdev->dev, "enable",
+1
drivers/cache/Kconfig
··· 18 18 bool "StarFive StarLink Cache controller" 19 19 depends on RISCV 20 20 depends on ARCH_STARFIVE 21 + depends on 64BIT 21 22 select RISCV_DMA_NONCOHERENT 22 23 select RISCV_NONSTANDARD_CACHE_OPS 23 24 help
+1
drivers/gpu/drm/Kconfig
··· 268 268 config DRM_GPUVM 269 269 tristate 270 270 depends on DRM 271 + select DRM_EXEC 271 272 help 272 273 GPU-VM representation providing helpers to manage a GPUs virtual 273 274 address space
+8 -8
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
··· 1778 1778 struct ttm_operation_ctx ctx = { false, false }; 1779 1779 struct amdgpu_vm *vm = &fpriv->vm; 1780 1780 struct amdgpu_bo_va_mapping *mapping; 1781 - int r; 1781 + int i, r; 1782 1782 1783 1783 addr /= AMDGPU_GPU_PAGE_SIZE; 1784 1784 ··· 1793 1793 if (dma_resv_locking_ctx((*bo)->tbo.base.resv) != &parser->exec.ticket) 1794 1794 return -EINVAL; 1795 1795 1796 - if (!((*bo)->flags & AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS)) { 1797 - (*bo)->flags |= AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS; 1798 - amdgpu_bo_placement_from_domain(*bo, (*bo)->allowed_domains); 1799 - r = ttm_bo_validate(&(*bo)->tbo, &(*bo)->placement, &ctx); 1800 - if (r) 1801 - return r; 1802 - } 1796 + (*bo)->flags |= AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS; 1797 + amdgpu_bo_placement_from_domain(*bo, (*bo)->allowed_domains); 1798 + for (i = 0; i < (*bo)->placement.num_placement; i++) 1799 + (*bo)->placements[i].flags |= TTM_PL_FLAG_CONTIGUOUS; 1800 + r = ttm_bo_validate(&(*bo)->tbo, &(*bo)->placement, &ctx); 1801 + if (r) 1802 + return r; 1803 1803 1804 1804 return amdgpu_ttm_alloc_gart(&(*bo)->tbo); 1805 1805 }
+3 -3
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c
··· 103 103 if (!amdgpu_mes_log_enable) 104 104 return 0; 105 105 106 - r = amdgpu_bo_create_kernel(adev, AMDGPU_MES_LOG_BUFFER_SIZE, PAGE_SIZE, 106 + r = amdgpu_bo_create_kernel(adev, adev->mes.event_log_size, PAGE_SIZE, 107 107 AMDGPU_GEM_DOMAIN_GTT, 108 108 &adev->mes.event_log_gpu_obj, 109 109 &adev->mes.event_log_gpu_addr, ··· 113 113 return r; 114 114 } 115 115 116 - memset(adev->mes.event_log_cpu_addr, 0, PAGE_SIZE); 116 + memset(adev->mes.event_log_cpu_addr, 0, adev->mes.event_log_size); 117 117 118 118 return 0; 119 119 ··· 1573 1573 uint32_t *mem = (uint32_t *)(adev->mes.event_log_cpu_addr); 1574 1574 1575 1575 seq_hex_dump(m, "", DUMP_PREFIX_OFFSET, 32, 4, 1576 - mem, AMDGPU_MES_LOG_BUFFER_SIZE, false); 1576 + mem, adev->mes.event_log_size, false); 1577 1577 1578 1578 return 0; 1579 1579 }
+3 -3
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.h
··· 52 52 53 53 #define AMDGPU_MES_PROC_CTX_SIZE 0x1000 /* one page area */ 54 54 #define AMDGPU_MES_GANG_CTX_SIZE 0x1000 /* one page area */ 55 - #define AMDGPU_MES_LOG_BUFFER_SIZE 0x4000 /* Maximu log buffer size for MES */ 56 55 57 56 struct amdgpu_mes_funcs; 58 57 ··· 134 135 unsigned long *doorbell_bitmap; 135 136 136 137 /* MES event log buffer */ 137 - struct amdgpu_bo *event_log_gpu_obj; 138 - uint64_t event_log_gpu_addr; 138 + uint32_t event_log_size; 139 + struct amdgpu_bo *event_log_gpu_obj; 140 + uint64_t event_log_gpu_addr; 139 141 void *event_log_cpu_addr; 140 142 141 143 /* ip specific functions */
+2
drivers/gpu/drm/amd/amdgpu/mes_v11_0.c
··· 1163 1163 adev->mes.kiq_hw_init = &mes_v11_0_kiq_hw_init; 1164 1164 adev->mes.kiq_hw_fini = &mes_v11_0_kiq_hw_fini; 1165 1165 1166 + adev->mes.event_log_size = AMDGPU_MES_LOG_BUFFER_SIZE; 1167 + 1166 1168 r = amdgpu_mes_init(adev); 1167 1169 if (r) 1168 1170 return r;
+6 -2
drivers/gpu/drm/amd/amdgpu/mes_v12_0.c
··· 551 551 mes_set_hw_res_pkt.oversubscription_timer = 50; 552 552 mes_set_hw_res_pkt.unmapped_doorbell_handling = 1; 553 553 554 - mes_set_hw_res_pkt.enable_mes_event_int_logging = 0; 555 - mes_set_hw_res_pkt.event_intr_history_gpu_mc_ptr = mes->event_log_gpu_addr; 554 + if (amdgpu_mes_log_enable) { 555 + mes_set_hw_res_pkt.enable_mes_event_int_logging = 1; 556 + mes_set_hw_res_pkt.event_intr_history_gpu_mc_ptr = mes->event_log_gpu_addr; 557 + } 556 558 557 559 return mes_v12_0_submit_pkt_and_poll_completion(mes, 558 560 &mes_set_hw_res_pkt, sizeof(mes_set_hw_res_pkt), ··· 1238 1236 adev->mes.funcs = &mes_v12_0_funcs; 1239 1237 adev->mes.kiq_hw_init = &mes_v12_0_kiq_hw_init; 1240 1238 adev->mes.kiq_hw_fini = &mes_v12_0_kiq_hw_fini; 1239 + 1240 + adev->mes.event_log_size = AMDGPU_MES_LOG_BUFFER_SIZE; 1241 1241 1242 1242 r = amdgpu_mes_init(adev); 1243 1243 if (r)
+3
drivers/gpu/drm/amd/include/mes_v11_api_def.h
··· 28 28 29 29 #define MES_API_VERSION 1 30 30 31 + /* Maximum log buffer size for MES. Needs to be updated if MES expands MES_EVT_INTR_HIST_LOG */ 32 + #define AMDGPU_MES_LOG_BUFFER_SIZE 0x4000 33 + 31 34 /* Driver submits one API(cmd) as a single Frame and this command size is same 32 35 * for all API to ease the debugging and parsing of ring buffer. 33 36 */
+3
drivers/gpu/drm/amd/include/mes_v12_api_def.h
··· 28 28 29 29 #define MES_API_VERSION 0x14 30 30 31 + /* Maximum log buffer size for MES. Needs to be updated if MES expands MES_EVT_INTR_HIST_LOG_12 */ 32 + #define AMDGPU_MES_LOG_BUFFER_SIZE 0xC000 33 + 31 34 /* Driver submits one API(cmd) as a single Frame and this command size is same for all API 32 35 * to ease the debugging and parsing of ring buffer. 33 36 */
+2 -1
drivers/gpu/drm/amd/pm/amdgpu_dpm.c
··· 618 618 const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs; 619 619 int r = 0; 620 620 621 - if (!pp_funcs || !pp_funcs->load_firmware || adev->flags & AMD_IS_APU) 621 + if (!pp_funcs || !pp_funcs->load_firmware || 622 + (is_support_sw_smu(adev) && (adev->flags & AMD_IS_APU))) 622 623 return 0; 623 624 624 625 mutex_lock(&adev->pm.mutex);
+84 -2
drivers/gpu/drm/amd/pm/swsmu/smu14/smu_v14_0_2_ppt.c
··· 66 66 67 67 #define MP0_MP1_DATA_REGION_SIZE_COMBOPPTABLE 0x4000 68 68 #define DEBUGSMC_MSG_Mode1Reset 2 69 + #define LINK_SPEED_MAX 3 69 70 70 71 static struct cmn2asic_msg_mapping smu_v14_0_2_message_map[SMU_MSG_MAX_COUNT] = { 71 72 MSG_MAP(TestMessage, PPSMC_MSG_TestMessage, 1), ··· 222 221 WORKLOAD_MAP(PP_SMC_POWER_PROFILE_WINDOW3D, WORKLOAD_PPLIB_WINDOW_3D_BIT), 223 222 }; 224 223 225 - #if 0 226 224 static const uint8_t smu_v14_0_2_throttler_map[] = { 227 225 [THROTTLER_PPT0_BIT] = (SMU_THROTTLER_PPT0_BIT), 228 226 [THROTTLER_PPT1_BIT] = (SMU_THROTTLER_PPT1_BIT), ··· 241 241 [THROTTLER_GFX_APCC_PLUS_BIT] = (SMU_THROTTLER_APCC_BIT), 242 242 [THROTTLER_FIT_BIT] = (SMU_THROTTLER_FIT_BIT), 243 243 }; 244 - #endif 245 244 246 245 static int 247 246 smu_v14_0_2_get_allowed_feature_mask(struct smu_context *smu, ··· 1868 1869 return ret; 1869 1870 } 1870 1871 1872 + static ssize_t smu_v14_0_2_get_gpu_metrics(struct smu_context *smu, 1873 + void **table) 1874 + { 1875 + struct smu_table_context *smu_table = &smu->smu_table; 1876 + struct gpu_metrics_v1_3 *gpu_metrics = 1877 + (struct gpu_metrics_v1_3 *)smu_table->gpu_metrics_table; 1878 + SmuMetricsExternal_t metrics_ext; 1879 + SmuMetrics_t *metrics = &metrics_ext.SmuMetrics; 1880 + int ret = 0; 1881 + 1882 + ret = smu_cmn_get_metrics_table(smu, 1883 + &metrics_ext, 1884 + true); 1885 + if (ret) 1886 + return ret; 1887 + 1888 + smu_cmn_init_soft_gpu_metrics(gpu_metrics, 1, 3); 1889 + 1890 + gpu_metrics->temperature_edge = metrics->AvgTemperature[TEMP_EDGE]; 1891 + gpu_metrics->temperature_hotspot = metrics->AvgTemperature[TEMP_HOTSPOT]; 1892 + gpu_metrics->temperature_mem = metrics->AvgTemperature[TEMP_MEM]; 1893 + gpu_metrics->temperature_vrgfx = metrics->AvgTemperature[TEMP_VR_GFX]; 1894 + gpu_metrics->temperature_vrsoc = metrics->AvgTemperature[TEMP_VR_SOC]; 1895 + gpu_metrics->temperature_vrmem = max(metrics->AvgTemperature[TEMP_VR_MEM0], 1896 + metrics->AvgTemperature[TEMP_VR_MEM1]); 1897 + 1898 + gpu_metrics->average_gfx_activity = metrics->AverageGfxActivity; 1899 + gpu_metrics->average_umc_activity = metrics->AverageUclkActivity; 1900 + gpu_metrics->average_mm_activity = max(metrics->Vcn0ActivityPercentage, 1901 + metrics->Vcn1ActivityPercentage); 1902 + 1903 + gpu_metrics->average_socket_power = metrics->AverageSocketPower; 1904 + gpu_metrics->energy_accumulator = metrics->EnergyAccumulator; 1905 + 1906 + if (metrics->AverageGfxActivity <= SMU_14_0_2_BUSY_THRESHOLD) 1907 + gpu_metrics->average_gfxclk_frequency = metrics->AverageGfxclkFrequencyPostDs; 1908 + else 1909 + gpu_metrics->average_gfxclk_frequency = metrics->AverageGfxclkFrequencyPreDs; 1910 + 1911 + if (metrics->AverageUclkActivity <= SMU_14_0_2_BUSY_THRESHOLD) 1912 + gpu_metrics->average_uclk_frequency = metrics->AverageMemclkFrequencyPostDs; 1913 + else 1914 + gpu_metrics->average_uclk_frequency = metrics->AverageMemclkFrequencyPreDs; 1915 + 1916 + gpu_metrics->average_vclk0_frequency = metrics->AverageVclk0Frequency; 1917 + gpu_metrics->average_dclk0_frequency = metrics->AverageDclk0Frequency; 1918 + gpu_metrics->average_vclk1_frequency = metrics->AverageVclk1Frequency; 1919 + gpu_metrics->average_dclk1_frequency = metrics->AverageDclk1Frequency; 1920 + 1921 + gpu_metrics->current_gfxclk = gpu_metrics->average_gfxclk_frequency; 1922 + gpu_metrics->current_socclk = metrics->CurrClock[PPCLK_SOCCLK]; 1923 + gpu_metrics->current_uclk = metrics->CurrClock[PPCLK_UCLK]; 1924 + gpu_metrics->current_vclk0 = metrics->CurrClock[PPCLK_VCLK_0]; 1925 + gpu_metrics->current_dclk0 = metrics->CurrClock[PPCLK_DCLK_0]; 1926 + gpu_metrics->current_vclk1 = metrics->CurrClock[PPCLK_VCLK_0]; 1927 + gpu_metrics->current_dclk1 = metrics->CurrClock[PPCLK_DCLK_0]; 1928 + 1929 + gpu_metrics->throttle_status = 1930 + smu_v14_0_2_get_throttler_status(metrics); 1931 + gpu_metrics->indep_throttle_status = 1932 + smu_cmn_get_indep_throttler_status(gpu_metrics->throttle_status, 1933 + smu_v14_0_2_throttler_map); 1934 + 1935 + gpu_metrics->current_fan_speed = metrics->AvgFanRpm; 1936 + 1937 + gpu_metrics->pcie_link_width = metrics->PcieWidth; 1938 + if ((metrics->PcieRate - 1) > LINK_SPEED_MAX) 1939 + gpu_metrics->pcie_link_speed = pcie_gen_to_speed(1); 1940 + else 1941 + gpu_metrics->pcie_link_speed = pcie_gen_to_speed(metrics->PcieRate); 1942 + 1943 + gpu_metrics->system_clock_counter = ktime_get_boottime_ns(); 1944 + 1945 + gpu_metrics->voltage_gfx = metrics->AvgVoltage[SVI_PLANE_VDD_GFX]; 1946 + gpu_metrics->voltage_soc = metrics->AvgVoltage[SVI_PLANE_VDD_SOC]; 1947 + gpu_metrics->voltage_mem = metrics->AvgVoltage[SVI_PLANE_VDDIO_MEM]; 1948 + 1949 + *table = (void *)gpu_metrics; 1950 + 1951 + return sizeof(struct gpu_metrics_v1_3); 1952 + } 1953 + 1871 1954 static const struct pptable_funcs smu_v14_0_2_ppt_funcs = { 1872 1955 .get_allowed_feature_mask = smu_v14_0_2_get_allowed_feature_mask, 1873 1956 .set_default_dpm_table = smu_v14_0_2_set_default_dpm_table, ··· 1986 1905 .enable_thermal_alert = smu_v14_0_enable_thermal_alert, 1987 1906 .disable_thermal_alert = smu_v14_0_disable_thermal_alert, 1988 1907 .notify_memory_pool_location = smu_v14_0_notify_memory_pool_location, 1908 + .get_gpu_metrics = smu_v14_0_2_get_gpu_metrics, 1989 1909 .set_soft_freq_limited_range = smu_v14_0_set_soft_freq_limited_range, 1990 1910 .init_pptable_microcode = smu_v14_0_init_pptable_microcode, 1991 1911 .populate_umd_state_clk = smu_v14_0_2_populate_umd_state_clk,
+7
drivers/gpu/drm/ast/ast_dp.c
··· 158 158 ASTDP_HOST_EDID_READ_DONE); 159 159 } 160 160 161 + bool ast_dp_power_is_on(struct ast_device *ast) 162 + { 163 + u8 vgacre3; 161 164 165 + vgacre3 = ast_get_index_reg(ast, AST_IO_VGACRI, 0xe3); 166 + 167 + return !(vgacre3 & AST_DP_PHY_SLEEP); 168 + } 162 169 163 170 void ast_dp_power_on_off(struct drm_device *dev, bool on) 164 171 {
+5
drivers/gpu/drm/ast/ast_drv.c
··· 391 391 392 392 static int ast_drm_thaw(struct drm_device *dev) 393 393 { 394 + struct ast_device *ast = to_ast_device(dev); 395 + 396 + ast_enable_vga(ast->ioregs); 397 + ast_open_key(ast->ioregs); 398 + ast_enable_mmio(dev->dev, ast->ioregs); 394 399 ast_post_gpu(dev); 395 400 396 401 return drm_mode_config_helper_resume(dev);
+1
drivers/gpu/drm/ast/ast_drv.h
··· 472 472 bool ast_astdp_is_connected(struct ast_device *ast); 473 473 int ast_astdp_read_edid(struct drm_device *dev, u8 *ediddata); 474 474 void ast_dp_launch(struct drm_device *dev); 475 + bool ast_dp_power_is_on(struct ast_device *ast); 475 476 void ast_dp_power_on_off(struct drm_device *dev, bool no); 476 477 void ast_dp_set_on_off(struct drm_device *dev, bool no); 477 478 void ast_dp_set_mode(struct drm_crtc *crtc, struct ast_vbios_mode_info *vbios_mode);
+27 -2
drivers/gpu/drm/ast/ast_mode.c
··· 28 28 * Authors: Dave Airlie <airlied@redhat.com> 29 29 */ 30 30 31 + #include <linux/delay.h> 31 32 #include <linux/export.h> 32 33 #include <linux/pci.h> 33 34 ··· 1688 1687 struct drm_modeset_acquire_ctx *ctx, 1689 1688 bool force) 1690 1689 { 1690 + struct drm_device *dev = connector->dev; 1691 1691 struct ast_device *ast = to_ast_device(connector->dev); 1692 + enum drm_connector_status status = connector_status_disconnected; 1693 + struct drm_connector_state *connector_state = connector->state; 1694 + bool is_active = false; 1695 + 1696 + mutex_lock(&ast->modeset_lock); 1697 + 1698 + if (connector_state && connector_state->crtc) { 1699 + struct drm_crtc_state *crtc_state = connector_state->crtc->state; 1700 + 1701 + if (crtc_state && crtc_state->active) 1702 + is_active = true; 1703 + } 1704 + 1705 + if (!is_active && !ast_dp_power_is_on(ast)) { 1706 + ast_dp_power_on_off(dev, true); 1707 + msleep(50); 1708 + } 1692 1709 1693 1710 if (ast_astdp_is_connected(ast)) 1694 - return connector_status_connected; 1695 - return connector_status_disconnected; 1711 + status = connector_status_connected; 1712 + 1713 + if (!is_active && status == connector_status_disconnected) 1714 + ast_dp_power_on_off(dev, false); 1715 + 1716 + mutex_unlock(&ast->modeset_lock); 1717 + 1718 + return status; 1696 1719 } 1697 1720 1698 1721 static const struct drm_connector_helper_funcs ast_astdp_connector_helper_funcs = {
+4 -1
drivers/gpu/drm/drm_atomic_uapi.c
··· 1070 1070 break; 1071 1071 } 1072 1072 1073 - if (async_flip && prop != config->prop_fb_id) { 1073 + if (async_flip && 1074 + prop != config->prop_fb_id && 1075 + prop != config->prop_in_fence_fd && 1076 + prop != config->prop_fb_damage_clips) { 1074 1077 ret = drm_atomic_plane_get_property(plane, plane_state, 1075 1078 prop, &old_val); 1076 1079 ret = drm_atomic_check_prop_changes(ret, old_val, prop_value, prop);
+1 -1
drivers/gpu/drm/drm_client.c
··· 355 355 356 356 err_drm_gem_vmap_unlocked: 357 357 drm_gem_unlock(gem); 358 - return 0; 358 + return ret; 359 359 } 360 360 EXPORT_SYMBOL(drm_client_buffer_vmap_local); 361 361
+11
drivers/gpu/drm/drm_fb_helper.c
··· 624 624 static void drm_fb_helper_damage(struct drm_fb_helper *helper, u32 x, u32 y, 625 625 u32 width, u32 height) 626 626 { 627 + /* 628 + * This function may be invoked by panic() to flush the frame 629 + * buffer, where all CPUs except the panic CPU are stopped. 630 + * During the following schedule_work(), the panic CPU needs 631 + * the worker_pool lock, which might be held by a stopped CPU, 632 + * causing schedule_work() and panic() to block. Return early on 633 + * oops_in_progress to prevent this blocking. 634 + */ 635 + if (oops_in_progress) 636 + return; 637 + 627 638 drm_fb_helper_add_damage_clip(helper, x, y, width, height); 628 639 629 640 schedule_work(&helper->damage_work);
+6
drivers/gpu/drm/drm_panel_orientation_quirks.c
··· 414 414 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "ONE XPLAYER"), 415 415 }, 416 416 .driver_data = (void *)&lcd1600x2560_leftside_up, 417 + }, { /* OrangePi Neo */ 418 + .matches = { 419 + DMI_EXACT_MATCH(DMI_SYS_VENDOR, "OrangePi"), 420 + DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "NEO-01"), 421 + }, 422 + .driver_data = (void *)&lcd1200x1920_rightside_up, 417 423 }, { /* Samsung GalaxyBook 10.6 */ 418 424 .matches = { 419 425 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
+3 -3
drivers/gpu/drm/i915/display/intel_dpll_mgr.c
··· 1658 1658 } 1659 1659 1660 1660 static int 1661 - skl_ddi_calculate_wrpll(int clock /* in Hz */, 1661 + skl_ddi_calculate_wrpll(int clock, 1662 1662 int ref_clock, 1663 1663 struct skl_wrpll_params *wrpll_params) 1664 1664 { ··· 1683 1683 }; 1684 1684 unsigned int dco, d, i; 1685 1685 unsigned int p0, p1, p2; 1686 - u64 afe_clock = clock * 5; /* AFE Clock is 5x Pixel clock */ 1686 + u64 afe_clock = (u64)clock * 1000 * 5; /* AFE Clock is 5x Pixel clock, in Hz */ 1687 1687 1688 1688 for (d = 0; d < ARRAY_SIZE(dividers); d++) { 1689 1689 for (dco = 0; dco < ARRAY_SIZE(dco_central_freq); dco++) { ··· 1808 1808 struct skl_wrpll_params wrpll_params = {}; 1809 1809 int ret; 1810 1810 1811 - ret = skl_ddi_calculate_wrpll(crtc_state->port_clock * 1000, 1811 + ret = skl_ddi_calculate_wrpll(crtc_state->port_clock, 1812 1812 i915->display.dpll.ref_clks.nssc, &wrpll_params); 1813 1813 if (ret) 1814 1814 return ret;
+1 -1
drivers/gpu/drm/i915/display/intel_hdcp_regs.h
··· 251 251 #define HDCP2_STREAM_STATUS(dev_priv, trans, port) \ 252 252 (TRANS_HDCP(dev_priv) ? \ 253 253 TRANS_HDCP2_STREAM_STATUS(trans) : \ 254 - PIPE_HDCP2_STREAM_STATUS(pipe)) 254 + PIPE_HDCP2_STREAM_STATUS(port)) 255 255 256 256 #define _PORTA_HDCP2_AUTH_STREAM 0x66F00 257 257 #define _PORTB_HDCP2_AUTH_STREAM 0x66F04
-33
drivers/gpu/drm/i915/i915_perf.c
··· 2749 2749 } 2750 2750 2751 2751 static int 2752 - gen12_configure_all_contexts(struct i915_perf_stream *stream, 2753 - const struct i915_oa_config *oa_config, 2754 - struct i915_active *active) 2755 - { 2756 - struct flex regs[] = { 2757 - { 2758 - GEN8_R_PWR_CLK_STATE(RENDER_RING_BASE), 2759 - CTX_R_PWR_CLK_STATE, 2760 - }, 2761 - }; 2762 - 2763 - if (stream->engine->class != RENDER_CLASS) 2764 - return 0; 2765 - 2766 - return oa_configure_all_contexts(stream, 2767 - regs, ARRAY_SIZE(regs), 2768 - active); 2769 - } 2770 - 2771 - static int 2772 2752 lrc_configure_all_contexts(struct i915_perf_stream *stream, 2773 2753 const struct i915_oa_config *oa_config, 2774 2754 struct i915_active *active) ··· 2854 2874 { 2855 2875 struct drm_i915_private *i915 = stream->perf->i915; 2856 2876 struct intel_uncore *uncore = stream->uncore; 2857 - struct i915_oa_config *oa_config = stream->oa_config; 2858 2877 bool periodic = stream->periodic; 2859 2878 u32 period_exponent = stream->period_exponent; 2860 2879 u32 sqcnt1; ··· 2896 2917 (HAS_OA_BPC_REPORTING(i915) ? GEN12_SQCNT1_OABPC : 0); 2897 2918 2898 2919 intel_uncore_rmw(uncore, GEN12_SQCNT1, 0, sqcnt1); 2899 - 2900 - /* 2901 - * Update all contexts prior writing the mux configurations as we need 2902 - * to make sure all slices/subslices are ON before writing to NOA 2903 - * registers. 2904 - */ 2905 - ret = gen12_configure_all_contexts(stream, oa_config, active); 2906 - if (ret) 2907 - return ret; 2908 2920 2909 2921 /* 2910 2922 * For Gen12, performance counters are context ··· 2949 2979 intel_uncore_write(uncore, GEN7_ROW_CHICKEN2, 2950 2980 _MASKED_BIT_DISABLE(GEN12_DISABLE_DOP_GATING)); 2951 2981 } 2952 - 2953 - /* Reset all contexts' slices/subslices configurations. */ 2954 - gen12_configure_all_contexts(stream, NULL, NULL); 2955 2982 2956 2983 /* disable the context save/restore or OAR counters */ 2957 2984 if (stream->ctx)
+1 -1
drivers/gpu/drm/nouveau/nouveau_bo.c
··· 898 898 * Without this the operation can timeout and we'll fallback to a 899 899 * software copy, which might take several minutes to finish. 900 900 */ 901 - nouveau_fence_wait(fence, false); 901 + nouveau_fence_wait(fence, false, false); 902 902 ret = ttm_bo_move_accel_cleanup(bo, &fence->base, evict, false, 903 903 new_reg); 904 904 nouveau_fence_unref(&fence);
+1 -1
drivers/gpu/drm/nouveau/nouveau_chan.c
··· 72 72 73 73 ret = nouveau_fence_new(&fence, chan); 74 74 if (!ret) { 75 - ret = nouveau_fence_wait(fence, false); 75 + ret = nouveau_fence_wait(fence, false, false); 76 76 nouveau_fence_unref(&fence); 77 77 } 78 78
+1 -1
drivers/gpu/drm/nouveau/nouveau_dmem.c
··· 128 128 static void nouveau_dmem_fence_done(struct nouveau_fence **fence) 129 129 { 130 130 if (fence) { 131 - nouveau_fence_wait(*fence, false); 131 + nouveau_fence_wait(*fence, true, false); 132 132 nouveau_fence_unref(fence); 133 133 } else { 134 134 /*
+29 -1
drivers/gpu/drm/nouveau/nouveau_fence.c
··· 311 311 return timeout - t; 312 312 } 313 313 314 + static int 315 + nouveau_fence_wait_busy(struct nouveau_fence *fence, bool intr) 316 + { 317 + int ret = 0; 318 + 319 + while (!nouveau_fence_done(fence)) { 320 + if (time_after_eq(jiffies, fence->timeout)) { 321 + ret = -EBUSY; 322 + break; 323 + } 324 + 325 + __set_current_state(intr ? 326 + TASK_INTERRUPTIBLE : 327 + TASK_UNINTERRUPTIBLE); 328 + 329 + if (intr && signal_pending(current)) { 330 + ret = -ERESTARTSYS; 331 + break; 332 + } 333 + } 334 + 335 + __set_current_state(TASK_RUNNING); 336 + return ret; 337 + } 338 + 314 339 int 315 - nouveau_fence_wait(struct nouveau_fence *fence, bool intr) 340 + nouveau_fence_wait(struct nouveau_fence *fence, bool lazy, bool intr) 316 341 { 317 342 long ret; 343 + 344 + if (!lazy) 345 + return nouveau_fence_wait_busy(fence, intr); 318 346 319 347 ret = dma_fence_wait_timeout(&fence->base, intr, 15 * HZ); 320 348 if (ret < 0)
+1 -1
drivers/gpu/drm/nouveau/nouveau_fence.h
··· 23 23 24 24 int nouveau_fence_emit(struct nouveau_fence *); 25 25 bool nouveau_fence_done(struct nouveau_fence *); 26 - int nouveau_fence_wait(struct nouveau_fence *, bool intr); 26 + int nouveau_fence_wait(struct nouveau_fence *, bool lazy, bool intr); 27 27 int nouveau_fence_sync(struct nouveau_bo *, struct nouveau_channel *, bool exclusive, bool intr); 28 28 29 29 struct nouveau_fence_chan {
+1 -1
drivers/gpu/drm/nouveau/nouveau_gem.c
··· 928 928 } 929 929 930 930 if (sync) { 931 - if (!(ret = nouveau_fence_wait(fence, false))) { 931 + if (!(ret = nouveau_fence_wait(fence, false, false))) { 932 932 if ((ret = dma_fence_get_status(&fence->base)) == 1) 933 933 ret = 0; 934 934 }
+2 -1
drivers/gpu/drm/nouveau/nouveau_prime.c
··· 64 64 * to the caller, instead of a normal nouveau_bo ttm reference. */ 65 65 ret = drm_gem_object_init(dev, &nvbo->bo.base, size); 66 66 if (ret) { 67 - nouveau_bo_ref(NULL, &nvbo); 67 + drm_gem_object_release(&nvbo->bo.base); 68 + kfree(nvbo); 68 69 obj = ERR_PTR(-ENOMEM); 69 70 goto unlock; 70 71 }
+1
drivers/gpu/drm/nouveau/nouveau_uvmm.c
··· 1803 1803 { 1804 1804 struct nouveau_bo *nvbo = nouveau_gem_object(vm_bo->obj); 1805 1805 1806 + nouveau_bo_placement_set(nvbo, nvbo->valid_domains, 0); 1806 1807 return nouveau_bo_validate(nvbo, true, false); 1807 1808 } 1808 1809
+4
drivers/gpu/drm/v3d/v3d_drv.h
··· 565 565 void v3d_mmu_remove_ptes(struct v3d_bo *bo); 566 566 567 567 /* v3d_sched.c */ 568 + void v3d_timestamp_query_info_free(struct v3d_timestamp_query_info *query_info, 569 + unsigned int count); 570 + void v3d_performance_query_info_free(struct v3d_performance_query_info *query_info, 571 + unsigned int count); 568 572 void v3d_job_update_stats(struct v3d_job *job, enum v3d_queue queue); 569 573 int v3d_sched_init(struct v3d_dev *v3d); 570 574 void v3d_sched_fini(struct v3d_dev *v3d);
+32 -12
drivers/gpu/drm/v3d/v3d_sched.c
··· 73 73 v3d_job_cleanup(job); 74 74 } 75 75 76 + void 77 + v3d_timestamp_query_info_free(struct v3d_timestamp_query_info *query_info, 78 + unsigned int count) 79 + { 80 + if (query_info->queries) { 81 + unsigned int i; 82 + 83 + for (i = 0; i < count; i++) 84 + drm_syncobj_put(query_info->queries[i].syncobj); 85 + 86 + kvfree(query_info->queries); 87 + } 88 + } 89 + 90 + void 91 + v3d_performance_query_info_free(struct v3d_performance_query_info *query_info, 92 + unsigned int count) 93 + { 94 + if (query_info->queries) { 95 + unsigned int i; 96 + 97 + for (i = 0; i < count; i++) 98 + drm_syncobj_put(query_info->queries[i].syncobj); 99 + 100 + kvfree(query_info->queries); 101 + } 102 + } 103 + 76 104 static void 77 105 v3d_cpu_job_free(struct drm_sched_job *sched_job) 78 106 { 79 107 struct v3d_cpu_job *job = to_cpu_job(sched_job); 80 - struct v3d_timestamp_query_info *timestamp_query = &job->timestamp_query; 81 - struct v3d_performance_query_info *performance_query = &job->performance_query; 82 108 83 - if (timestamp_query->queries) { 84 - for (int i = 0; i < timestamp_query->count; i++) 85 - drm_syncobj_put(timestamp_query->queries[i].syncobj); 86 - kvfree(timestamp_query->queries); 87 - } 109 + v3d_timestamp_query_info_free(&job->timestamp_query, 110 + job->timestamp_query.count); 88 111 89 - if (performance_query->queries) { 90 - for (int i = 0; i < performance_query->count; i++) 91 - drm_syncobj_put(performance_query->queries[i].syncobj); 92 - kvfree(performance_query->queries); 93 - } 112 + v3d_performance_query_info_free(&job->performance_query, 113 + job->performance_query.count); 94 114 95 115 v3d_job_cleanup(&job->base); 96 116 }
+88 -33
drivers/gpu/drm/v3d/v3d_submit.c
··· 452 452 { 453 453 u32 __user *offsets, *syncs; 454 454 struct drm_v3d_timestamp_query timestamp; 455 + unsigned int i; 456 + int err; 455 457 456 458 if (!job) { 457 459 DRM_DEBUG("CPU job extension was attached to a GPU job.\n"); ··· 482 480 offsets = u64_to_user_ptr(timestamp.offsets); 483 481 syncs = u64_to_user_ptr(timestamp.syncs); 484 482 485 - for (int i = 0; i < timestamp.count; i++) { 483 + for (i = 0; i < timestamp.count; i++) { 486 484 u32 offset, sync; 487 485 488 486 if (copy_from_user(&offset, offsets++, sizeof(offset))) { 489 - kvfree(job->timestamp_query.queries); 490 - return -EFAULT; 487 + err = -EFAULT; 488 + goto error; 491 489 } 492 490 493 491 job->timestamp_query.queries[i].offset = offset; 494 492 495 493 if (copy_from_user(&sync, syncs++, sizeof(sync))) { 496 - kvfree(job->timestamp_query.queries); 497 - return -EFAULT; 494 + err = -EFAULT; 495 + goto error; 498 496 } 499 497 500 498 job->timestamp_query.queries[i].syncobj = drm_syncobj_find(file_priv, sync); 499 + if (!job->timestamp_query.queries[i].syncobj) { 500 + err = -ENOENT; 501 + goto error; 502 + } 501 503 } 502 504 job->timestamp_query.count = timestamp.count; 503 505 504 506 return 0; 507 + 508 + error: 509 + v3d_timestamp_query_info_free(&job->timestamp_query, i); 510 + return err; 505 511 } 506 512 507 513 static int ··· 519 509 { 520 510 u32 __user *syncs; 521 511 struct drm_v3d_reset_timestamp_query reset; 512 + unsigned int i; 513 + int err; 522 514 523 515 if (!job) { 524 516 DRM_DEBUG("CPU job extension was attached to a GPU job.\n"); ··· 545 533 546 534 syncs = u64_to_user_ptr(reset.syncs); 547 535 548 - for (int i = 0; i < reset.count; i++) { 536 + for (i = 0; i < reset.count; i++) { 549 537 u32 sync; 550 538 551 539 job->timestamp_query.queries[i].offset = reset.offset + 8 * i; 552 540 553 541 if (copy_from_user(&sync, syncs++, sizeof(sync))) { 554 - kvfree(job->timestamp_query.queries); 555 - return -EFAULT; 542 + err = -EFAULT; 543 + goto error; 556 544 } 557 545 558 546 job->timestamp_query.queries[i].syncobj = drm_syncobj_find(file_priv, sync); 547 + if (!job->timestamp_query.queries[i].syncobj) { 548 + err = -ENOENT; 549 + goto error; 550 + } 559 551 } 560 552 job->timestamp_query.count = reset.count; 561 553 562 554 return 0; 555 + 556 + error: 557 + v3d_timestamp_query_info_free(&job->timestamp_query, i); 558 + return err; 563 559 } 564 560 565 561 /* Get data for the copy timestamp query results job submission. */ ··· 578 558 { 579 559 u32 __user *offsets, *syncs; 580 560 struct drm_v3d_copy_timestamp_query copy; 581 - int i; 561 + unsigned int i; 562 + int err; 582 563 583 564 if (!job) { 584 565 DRM_DEBUG("CPU job extension was attached to a GPU job.\n"); ··· 612 591 u32 offset, sync; 613 592 614 593 if (copy_from_user(&offset, offsets++, sizeof(offset))) { 615 - kvfree(job->timestamp_query.queries); 616 - return -EFAULT; 594 + err = -EFAULT; 595 + goto error; 617 596 } 618 597 619 598 job->timestamp_query.queries[i].offset = offset; 620 599 621 600 if (copy_from_user(&sync, syncs++, sizeof(sync))) { 622 - kvfree(job->timestamp_query.queries); 623 - return -EFAULT; 601 + err = -EFAULT; 602 + goto error; 624 603 } 625 604 626 605 job->timestamp_query.queries[i].syncobj = drm_syncobj_find(file_priv, sync); 606 + if (!job->timestamp_query.queries[i].syncobj) { 607 + err = -ENOENT; 608 + goto error; 609 + } 627 610 } 628 611 job->timestamp_query.count = copy.count; 629 612 ··· 638 613 job->copy.stride = copy.stride; 639 614 640 615 return 0; 616 + 617 + error: 618 + v3d_timestamp_query_info_free(&job->timestamp_query, i); 619 + return err; 641 620 } 642 621 643 622 static int ··· 652 623 u32 __user *syncs; 653 624 u64 __user *kperfmon_ids; 654 625 struct drm_v3d_reset_performance_query reset; 626 + unsigned int i, j; 627 + int err; 655 628 656 629 if (!job) { 657 630 DRM_DEBUG("CPU job extension was attached to a GPU job.\n"); ··· 668 637 if (copy_from_user(&reset, ext, sizeof(reset))) 669 638 return -EFAULT; 670 639 640 + if (reset.nperfmons > V3D_MAX_PERFMONS) 641 + return -EINVAL; 642 + 671 643 job->job_type = V3D_CPU_JOB_TYPE_RESET_PERFORMANCE_QUERY; 672 644 673 645 job->performance_query.queries = kvmalloc_array(reset.count, ··· 682 648 syncs = u64_to_user_ptr(reset.syncs); 683 649 kperfmon_ids = u64_to_user_ptr(reset.kperfmon_ids); 684 650 685 - for (int i = 0; i < reset.count; i++) { 651 + for (i = 0; i < reset.count; i++) { 686 652 u32 sync; 687 653 u64 ids; 688 654 u32 __user *ids_pointer; 689 655 u32 id; 690 656 691 657 if (copy_from_user(&sync, syncs++, sizeof(sync))) { 692 - kvfree(job->performance_query.queries); 693 - return -EFAULT; 658 + err = -EFAULT; 659 + goto error; 694 660 } 695 661 696 - job->performance_query.queries[i].syncobj = drm_syncobj_find(file_priv, sync); 697 - 698 662 if (copy_from_user(&ids, kperfmon_ids++, sizeof(ids))) { 699 - kvfree(job->performance_query.queries); 700 - return -EFAULT; 663 + err = -EFAULT; 664 + goto error; 701 665 } 702 666 703 667 ids_pointer = u64_to_user_ptr(ids); 704 668 705 - for (int j = 0; j < reset.nperfmons; j++) { 669 + for (j = 0; j < reset.nperfmons; j++) { 706 670 if (copy_from_user(&id, ids_pointer++, sizeof(id))) { 707 - kvfree(job->performance_query.queries); 708 - return -EFAULT; 671 + err = -EFAULT; 672 + goto error; 709 673 } 710 674 711 675 job->performance_query.queries[i].kperfmon_ids[j] = id; 676 + } 677 + 678 + job->performance_query.queries[i].syncobj = drm_syncobj_find(file_priv, sync); 679 + if (!job->performance_query.queries[i].syncobj) { 680 + err = -ENOENT; 681 + goto error; 712 682 } 713 683 } 714 684 job->performance_query.count = reset.count; 715 685 job->performance_query.nperfmons = reset.nperfmons; 716 686 717 687 return 0; 688 + 689 + error: 690 + v3d_performance_query_info_free(&job->performance_query, i); 691 + return err; 718 692 } 719 693 720 694 static int ··· 733 691 u32 __user *syncs; 734 692 u64 __user *kperfmon_ids; 735 693 struct drm_v3d_copy_performance_query copy; 694 + unsigned int i, j; 695 + int err; 736 696 737 697 if (!job) { 738 698 DRM_DEBUG("CPU job extension was attached to a GPU job.\n"); ··· 752 708 if (copy.pad) 753 709 return -EINVAL; 754 710 711 + if (copy.nperfmons > V3D_MAX_PERFMONS) 712 + return -EINVAL; 713 + 755 714 job->job_type = V3D_CPU_JOB_TYPE_COPY_PERFORMANCE_QUERY; 756 715 757 716 job->performance_query.queries = kvmalloc_array(copy.count, ··· 766 719 syncs = u64_to_user_ptr(copy.syncs); 767 720 kperfmon_ids = u64_to_user_ptr(copy.kperfmon_ids); 768 721 769 - for (int i = 0; i < copy.count; i++) { 722 + for (i = 0; i < copy.count; i++) { 770 723 u32 sync; 771 724 u64 ids; 772 725 u32 __user *ids_pointer; 773 726 u32 id; 774 727 775 728 if (copy_from_user(&sync, syncs++, sizeof(sync))) { 776 - kvfree(job->performance_query.queries); 777 - return -EFAULT; 729 + err = -EFAULT; 730 + goto error; 778 731 } 779 732 780 - job->performance_query.queries[i].syncobj = drm_syncobj_find(file_priv, sync); 781 - 782 733 if (copy_from_user(&ids, kperfmon_ids++, sizeof(ids))) { 783 - kvfree(job->performance_query.queries); 784 - return -EFAULT; 734 + err = -EFAULT; 735 + goto error; 785 736 } 786 737 787 738 ids_pointer = u64_to_user_ptr(ids); 788 739 789 - for (int j = 0; j < copy.nperfmons; j++) { 740 + for (j = 0; j < copy.nperfmons; j++) { 790 741 if (copy_from_user(&id, ids_pointer++, sizeof(id))) { 791 - kvfree(job->performance_query.queries); 792 - return -EFAULT; 742 + err = -EFAULT; 743 + goto error; 793 744 } 794 745 795 746 job->performance_query.queries[i].kperfmon_ids[j] = id; 747 + } 748 + 749 + job->performance_query.queries[i].syncobj = drm_syncobj_find(file_priv, sync); 750 + if (!job->performance_query.queries[i].syncobj) { 751 + err = -ENOENT; 752 + goto error; 796 753 } 797 754 } 798 755 job->performance_query.count = copy.count; ··· 810 759 job->copy.stride = copy.stride; 811 760 812 761 return 0; 762 + 763 + error: 764 + v3d_performance_query_info_free(&job->performance_query, i); 765 + return err; 813 766 } 814 767 815 768 /* Whenever userspace sets ioctl extensions, v3d_get_extensions parses data
+1 -1
drivers/gpu/drm/virtio/virtgpu_submit.c
··· 48 48 static int virtio_gpu_do_fence_wait(struct virtio_gpu_submit *submit, 49 49 struct dma_fence *in_fence) 50 50 { 51 - u32 context = submit->fence_ctx + submit->ring_idx; 51 + u64 context = submit->fence_ctx + submit->ring_idx; 52 52 53 53 if (dma_fence_match_context(in_fence, context)) 54 54 return 0;
+8 -2
drivers/gpu/drm/vmwgfx/vmw_surface_cache.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 OR MIT */ 1 2 /********************************************************** 2 - * Copyright 2021 VMware, Inc. 3 - * SPDX-License-Identifier: GPL-2.0 OR MIT 3 + * 4 + * Copyright (c) 2021-2024 Broadcom. All Rights Reserved. The term 5 + * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. 4 6 * 5 7 * Permission is hereby granted, free of charge, to any person 6 8 * obtaining a copy of this software and associated documentation ··· 32 30 #include "device_include/svga3d_surfacedefs.h" 33 31 34 32 #include <drm/vmwgfx_drm.h> 33 + 34 + #define SVGA3D_FLAGS_UPPER_32(svga3d_flags) ((svga3d_flags) >> 32) 35 + #define SVGA3D_FLAGS_LOWER_32(svga3d_flags) \ 36 + ((svga3d_flags) & ((uint64_t)U32_MAX)) 35 37 36 38 static inline u32 clamped_umul32(u32 a, u32 b) 37 39 {
+76 -51
drivers/gpu/drm/vmwgfx/vmwgfx_bo.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 OR MIT 2 2 /************************************************************************** 3 3 * 4 - * Copyright © 2011-2023 VMware, Inc., Palo Alto, CA., USA 5 - * All Rights Reserved. 4 + * Copyright (c) 2011-2024 Broadcom. All Rights Reserved. The term 5 + * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. 6 6 * 7 7 * Permission is hereby granted, free of charge, to any person obtaining a 8 8 * copy of this software and associated documentation files (the ··· 28 28 29 29 #include "vmwgfx_bo.h" 30 30 #include "vmwgfx_drv.h" 31 - 31 + #include "vmwgfx_resource_priv.h" 32 32 33 33 #include <drm/ttm/ttm_placement.h> 34 34 35 35 static void vmw_bo_release(struct vmw_bo *vbo) 36 36 { 37 + struct vmw_resource *res; 38 + 37 39 WARN_ON(vbo->tbo.base.funcs && 38 40 kref_read(&vbo->tbo.base.refcount) != 0); 39 41 vmw_bo_unmap(vbo); 42 + 43 + xa_destroy(&vbo->detached_resources); 44 + WARN_ON(vbo->is_dumb && !vbo->dumb_surface); 45 + if (vbo->is_dumb && vbo->dumb_surface) { 46 + res = &vbo->dumb_surface->res; 47 + WARN_ON(vbo != res->guest_memory_bo); 48 + WARN_ON(!res->guest_memory_bo); 49 + if (res->guest_memory_bo) { 50 + /* Reserve and switch the backing mob. */ 51 + mutex_lock(&res->dev_priv->cmdbuf_mutex); 52 + (void)vmw_resource_reserve(res, false, true); 53 + vmw_resource_mob_detach(res); 54 + if (res->coherent) 55 + vmw_bo_dirty_release(res->guest_memory_bo); 56 + res->guest_memory_bo = NULL; 57 + res->guest_memory_offset = 0; 58 + vmw_resource_unreserve(res, false, false, false, NULL, 59 + 0); 60 + mutex_unlock(&res->dev_priv->cmdbuf_mutex); 61 + } 62 + vmw_surface_unreference(&vbo->dumb_surface); 63 + } 40 64 drm_gem_object_release(&vbo->tbo.base); 41 65 } 42 66 ··· 350 326 */ 351 327 void *vmw_bo_map_and_cache(struct vmw_bo *vbo) 352 328 { 329 + return vmw_bo_map_and_cache_size(vbo, vbo->tbo.base.size); 330 + } 331 + 332 + void *vmw_bo_map_and_cache_size(struct vmw_bo *vbo, size_t size) 333 + { 353 334 struct ttm_buffer_object *bo = &vbo->tbo; 354 335 bool not_used; 355 336 void *virtual; ··· 364 335 if (virtual) 365 336 return virtual; 366 337 367 - ret = ttm_bo_kmap(bo, 0, PFN_UP(bo->base.size), &vbo->map); 338 + ret = ttm_bo_kmap(bo, 0, PFN_UP(size), &vbo->map); 368 339 if (ret) 369 - DRM_ERROR("Buffer object map failed: %d.\n", ret); 340 + DRM_ERROR("Buffer object map failed: %d (size: bo = %zu, map = %zu).\n", 341 + ret, bo->base.size, size); 370 342 371 343 return ttm_kmap_obj_virtual(&vbo->map, &not_used); 372 344 } ··· 420 390 BUILD_BUG_ON(TTM_MAX_BO_PRIORITY <= 3); 421 391 vmw_bo->tbo.priority = 3; 422 392 vmw_bo->res_tree = RB_ROOT; 393 + xa_init(&vmw_bo->detached_resources); 423 394 424 395 params->size = ALIGN(params->size, PAGE_SIZE); 425 396 drm_gem_private_object_init(vdev, &vmw_bo->tbo.base, params->size); ··· 685 654 dma_fence_put(&fence->base); 686 655 } 687 656 688 - 689 - /** 690 - * vmw_dumb_create - Create a dumb kms buffer 691 - * 692 - * @file_priv: Pointer to a struct drm_file identifying the caller. 693 - * @dev: Pointer to the drm device. 694 - * @args: Pointer to a struct drm_mode_create_dumb structure 695 - * Return: Zero on success, negative error code on failure. 696 - * 697 - * This is a driver callback for the core drm create_dumb functionality. 698 - * Note that this is very similar to the vmw_bo_alloc ioctl, except 699 - * that the arguments have a different format. 700 - */ 701 - int vmw_dumb_create(struct drm_file *file_priv, 702 - struct drm_device *dev, 703 - struct drm_mode_create_dumb *args) 704 - { 705 - struct vmw_private *dev_priv = vmw_priv(dev); 706 - struct vmw_bo *vbo; 707 - int cpp = DIV_ROUND_UP(args->bpp, 8); 708 - int ret; 709 - 710 - switch (cpp) { 711 - case 1: /* DRM_FORMAT_C8 */ 712 - case 2: /* DRM_FORMAT_RGB565 */ 713 - case 4: /* DRM_FORMAT_XRGB8888 */ 714 - break; 715 - default: 716 - /* 717 - * Dumb buffers don't allow anything else. 718 - * This is tested via IGT's dumb_buffers 719 - */ 720 - return -EINVAL; 721 - } 722 - 723 - args->pitch = args->width * cpp; 724 - args->size = ALIGN(args->pitch * args->height, PAGE_SIZE); 725 - 726 - ret = vmw_gem_object_create_with_handle(dev_priv, file_priv, 727 - args->size, &args->handle, 728 - &vbo); 729 - /* drop reference from allocate - handle holds it now */ 730 - drm_gem_object_put(&vbo->tbo.base); 731 - return ret; 732 - } 733 - 734 657 /** 735 658 * vmw_bo_swap_notify - swapout notify callback. 736 659 * ··· 837 852 domain = VMW_BO_DOMAIN_MOB; 838 853 839 854 vmw_bo_placement_set(bo, domain, domain); 855 + } 856 + 857 + void vmw_bo_add_detached_resource(struct vmw_bo *vbo, struct vmw_resource *res) 858 + { 859 + xa_store(&vbo->detached_resources, (unsigned long)res, res, GFP_KERNEL); 860 + } 861 + 862 + void vmw_bo_del_detached_resource(struct vmw_bo *vbo, struct vmw_resource *res) 863 + { 864 + xa_erase(&vbo->detached_resources, (unsigned long)res); 865 + } 866 + 867 + struct vmw_surface *vmw_bo_surface(struct vmw_bo *vbo) 868 + { 869 + unsigned long index; 870 + struct vmw_resource *res = NULL; 871 + struct vmw_surface *surf = NULL; 872 + struct rb_node *rb_itr = vbo->res_tree.rb_node; 873 + 874 + if (vbo->is_dumb && vbo->dumb_surface) { 875 + res = &vbo->dumb_surface->res; 876 + goto out; 877 + } 878 + 879 + xa_for_each(&vbo->detached_resources, index, res) { 880 + if (res->func->res_type == vmw_res_surface) 881 + goto out; 882 + } 883 + 884 + for (rb_itr = rb_first(&vbo->res_tree); rb_itr; 885 + rb_itr = rb_next(rb_itr)) { 886 + res = rb_entry(rb_itr, struct vmw_resource, mob_node); 887 + if (res->func->res_type == vmw_res_surface) 888 + goto out; 889 + } 890 + 891 + out: 892 + if (res) 893 + surf = vmw_res_to_srf(res); 894 + return surf; 840 895 }
+14 -1
drivers/gpu/drm/vmwgfx/vmwgfx_bo.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0 OR MIT */ 2 2 /************************************************************************** 3 3 * 4 - * Copyright 2023 VMware, Inc., Palo Alto, CA., USA 4 + * Copyright (c) 2023-2024 Broadcom. All Rights Reserved. The term 5 + * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. 5 6 * 6 7 * Permission is hereby granted, free of charge, to any person obtaining a 7 8 * copy of this software and associated documentation files (the ··· 36 35 37 36 #include <linux/rbtree_types.h> 38 37 #include <linux/types.h> 38 + #include <linux/xarray.h> 39 39 40 40 struct vmw_bo_dirty; 41 41 struct vmw_fence_obj; 42 42 struct vmw_private; 43 43 struct vmw_resource; 44 + struct vmw_surface; 44 45 45 46 enum vmw_bo_domain { 46 47 VMW_BO_DOMAIN_SYS = BIT(0), ··· 88 85 89 86 struct rb_root res_tree; 90 87 u32 res_prios[TTM_MAX_BO_PRIORITY]; 88 + struct xarray detached_resources; 91 89 92 90 atomic_t cpu_writers; 93 91 /* Not ref-counted. Protected by binding_mutex */ 94 92 struct vmw_resource *dx_query_ctx; 95 93 struct vmw_bo_dirty *dirty; 94 + 95 + bool is_dumb; 96 + struct vmw_surface *dumb_surface; 96 97 }; 97 98 98 99 void vmw_bo_placement_set(struct vmw_bo *bo, u32 domain, u32 busy_domain); ··· 131 124 struct vmw_fence_obj *fence); 132 125 133 126 void *vmw_bo_map_and_cache(struct vmw_bo *vbo); 127 + void *vmw_bo_map_and_cache_size(struct vmw_bo *vbo, size_t size); 134 128 void vmw_bo_unmap(struct vmw_bo *vbo); 135 129 136 130 void vmw_bo_move_notify(struct ttm_buffer_object *bo, 137 131 struct ttm_resource *mem); 138 132 void vmw_bo_swap_notify(struct ttm_buffer_object *bo); 139 133 134 + void vmw_bo_add_detached_resource(struct vmw_bo *vbo, struct vmw_resource *res); 135 + void vmw_bo_del_detached_resource(struct vmw_bo *vbo, struct vmw_resource *res); 136 + struct vmw_surface *vmw_bo_surface(struct vmw_bo *vbo); 137 + 140 138 int vmw_user_bo_lookup(struct drm_file *filp, 141 139 u32 handle, 142 140 struct vmw_bo **out); 141 + 143 142 /** 144 143 * vmw_bo_adjust_prio - Adjust the buffer object eviction priority 145 144 * according to attached resources
+31 -9
drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0 OR MIT */ 2 2 /************************************************************************** 3 3 * 4 - * Copyright 2009-2023 VMware, Inc., Palo Alto, CA., USA 4 + * Copyright (c) 2009-2024 Broadcom. All Rights Reserved. The term 5 + * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. 5 6 * 6 7 * Permission is hereby granted, free of charge, to any person obtaining a 7 8 * copy of this software and associated documentation files (the ··· 764 763 extern void vmw_gmr_unbind(struct vmw_private *dev_priv, int gmr_id); 765 764 766 765 /** 766 + * User handles 767 + */ 768 + struct vmw_user_object { 769 + struct vmw_surface *surface; 770 + struct vmw_bo *buffer; 771 + }; 772 + 773 + int vmw_user_object_lookup(struct vmw_private *dev_priv, struct drm_file *filp, 774 + u32 handle, struct vmw_user_object *uo); 775 + struct vmw_user_object *vmw_user_object_ref(struct vmw_user_object *uo); 776 + void vmw_user_object_unref(struct vmw_user_object *uo); 777 + bool vmw_user_object_is_null(struct vmw_user_object *uo); 778 + struct vmw_surface *vmw_user_object_surface(struct vmw_user_object *uo); 779 + struct vmw_bo *vmw_user_object_buffer(struct vmw_user_object *uo); 780 + void *vmw_user_object_map(struct vmw_user_object *uo); 781 + void *vmw_user_object_map_size(struct vmw_user_object *uo, size_t size); 782 + void vmw_user_object_unmap(struct vmw_user_object *uo); 783 + bool vmw_user_object_is_mapped(struct vmw_user_object *uo); 784 + 785 + /** 767 786 * Resource utilities - vmwgfx_resource.c 768 787 */ 769 788 struct vmw_user_resource_conv; ··· 797 776 extern int vmw_resource_reserve(struct vmw_resource *res, bool interruptible, 798 777 bool no_backup); 799 778 extern bool vmw_resource_needs_backup(const struct vmw_resource *res); 800 - extern int vmw_user_lookup_handle(struct vmw_private *dev_priv, 801 - struct drm_file *filp, 802 - uint32_t handle, 803 - struct vmw_surface **out_surf, 804 - struct vmw_bo **out_buf); 805 779 extern int vmw_user_resource_lookup_handle( 806 780 struct vmw_private *dev_priv, 807 781 struct ttm_object_file *tfile, ··· 1073 1057 int vmw_kms_resume(struct drm_device *dev); 1074 1058 void vmw_kms_lost_device(struct drm_device *dev); 1075 1059 1076 - int vmw_dumb_create(struct drm_file *file_priv, 1077 - struct drm_device *dev, 1078 - struct drm_mode_create_dumb *args); 1079 1060 extern int vmw_resource_pin(struct vmw_resource *res, bool interruptible); 1080 1061 extern void vmw_resource_unpin(struct vmw_resource *res); 1081 1062 extern enum vmw_res_type vmw_res_type(const struct vmw_resource *res); ··· 1189 1176 int vmw_gb_surface_define(struct vmw_private *dev_priv, 1190 1177 const struct vmw_surface_metadata *req, 1191 1178 struct vmw_surface **srf_out); 1179 + struct vmw_surface *vmw_lookup_surface_for_buffer(struct vmw_private *vmw, 1180 + struct vmw_bo *bo, 1181 + u32 handle); 1182 + u32 vmw_lookup_surface_handle_for_buffer(struct vmw_private *vmw, 1183 + struct vmw_bo *bo, 1184 + u32 handle); 1185 + int vmw_dumb_create(struct drm_file *file_priv, 1186 + struct drm_device *dev, 1187 + struct drm_mode_create_dumb *args); 1192 1188 1193 1189 /* 1194 1190 * Shader management - vmwgfx_shader.c
+7 -10
drivers/gpu/drm/vmwgfx/vmwgfx_fence.c
··· 32 32 #define VMW_FENCE_WRAP (1 << 31) 33 33 34 34 struct vmw_fence_manager { 35 - int num_fence_objects; 36 35 struct vmw_private *dev_priv; 37 36 spinlock_t lock; 38 37 struct list_head fence_list; ··· 123 124 { 124 125 struct vmw_fence_obj *fence = 125 126 container_of(f, struct vmw_fence_obj, base); 126 - 127 127 struct vmw_fence_manager *fman = fman_from_fence(fence); 128 128 129 - spin_lock(&fman->lock); 130 - list_del_init(&fence->head); 131 - --fman->num_fence_objects; 132 - spin_unlock(&fman->lock); 129 + if (!list_empty(&fence->head)) { 130 + spin_lock(&fman->lock); 131 + list_del_init(&fence->head); 132 + spin_unlock(&fman->lock); 133 + } 133 134 fence->destroy(fence); 134 135 } 135 136 ··· 256 257 .release = vmw_fence_obj_destroy, 257 258 }; 258 259 259 - 260 260 /* 261 261 * Execute signal actions on fences recently signaled. 262 262 * This is done from a workqueue so we don't have to execute ··· 353 355 goto out_unlock; 354 356 } 355 357 list_add_tail(&fence->head, &fman->fence_list); 356 - ++fman->num_fence_objects; 357 358 358 359 out_unlock: 359 360 spin_unlock(&fman->lock); ··· 400 403 u32 passed_seqno) 401 404 { 402 405 u32 goal_seqno; 403 - struct vmw_fence_obj *fence; 406 + struct vmw_fence_obj *fence, *next_fence; 404 407 405 408 if (likely(!fman->seqno_valid)) 406 409 return false; ··· 410 413 return false; 411 414 412 415 fman->seqno_valid = false; 413 - list_for_each_entry(fence, &fman->fence_list, head) { 416 + list_for_each_entry_safe(fence, next_fence, &fman->fence_list, head) { 414 417 if (!list_empty(&fence->seq_passed_actions)) { 415 418 fman->seqno_valid = true; 416 419 vmw_fence_goal_write(fman->dev_priv,
+58 -4
drivers/gpu/drm/vmwgfx/vmwgfx_gem.c
··· 1 1 /* SPDX-License-Identifier: GPL-2.0 OR MIT */ 2 2 /* 3 - * Copyright 2021-2023 VMware, Inc. 3 + * Copyright (c) 2021-2024 Broadcom. All Rights Reserved. The term 4 + * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. 4 5 * 5 6 * Permission is hereby granted, free of charge, to any person 6 7 * obtaining a copy of this software and associated documentation ··· 79 78 return drm_prime_pages_to_sg(obj->dev, vmw_tt->dma_ttm.pages, vmw_tt->dma_ttm.num_pages); 80 79 } 81 80 81 + static int vmw_gem_vmap(struct drm_gem_object *obj, struct iosys_map *map) 82 + { 83 + struct ttm_buffer_object *bo = drm_gem_ttm_of_gem(obj); 84 + int ret; 85 + 86 + if (obj->import_attach) { 87 + ret = dma_buf_vmap(obj->import_attach->dmabuf, map); 88 + if (!ret) { 89 + if (drm_WARN_ON(obj->dev, map->is_iomem)) { 90 + dma_buf_vunmap(obj->import_attach->dmabuf, map); 91 + return -EIO; 92 + } 93 + } 94 + } else { 95 + ret = ttm_bo_vmap(bo, map); 96 + } 97 + 98 + return ret; 99 + } 100 + 101 + static void vmw_gem_vunmap(struct drm_gem_object *obj, struct iosys_map *map) 102 + { 103 + if (obj->import_attach) 104 + dma_buf_vunmap(obj->import_attach->dmabuf, map); 105 + else 106 + drm_gem_ttm_vunmap(obj, map); 107 + } 108 + 109 + static int vmw_gem_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma) 110 + { 111 + int ret; 112 + 113 + if (obj->import_attach) { 114 + /* 115 + * Reset both vm_ops and vm_private_data, so we don't end up with 116 + * vm_ops pointing to our implementation if the dma-buf backend 117 + * doesn't set those fields. 118 + */ 119 + vma->vm_private_data = NULL; 120 + vma->vm_ops = NULL; 121 + 122 + ret = dma_buf_mmap(obj->dma_buf, vma, 0); 123 + 124 + /* Drop the reference drm_gem_mmap_obj() acquired.*/ 125 + if (!ret) 126 + drm_gem_object_put(obj); 127 + 128 + return ret; 129 + } 130 + 131 + return drm_gem_ttm_mmap(obj, vma); 132 + } 133 + 82 134 static const struct vm_operations_struct vmw_vm_ops = { 83 135 .pfn_mkwrite = vmw_bo_vm_mkwrite, 84 136 .page_mkwrite = vmw_bo_vm_mkwrite, ··· 148 94 .pin = vmw_gem_object_pin, 149 95 .unpin = vmw_gem_object_unpin, 150 96 .get_sg_table = vmw_gem_object_get_sg_table, 151 - .vmap = drm_gem_ttm_vmap, 152 - .vunmap = drm_gem_ttm_vunmap, 153 - .mmap = drm_gem_ttm_mmap, 97 + .vmap = vmw_gem_vmap, 98 + .vunmap = vmw_gem_vunmap, 99 + .mmap = vmw_gem_mmap, 154 100 .vm_ops = &vmw_vm_ops, 155 101 }; 156 102
+204 -300
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 OR MIT 2 2 /************************************************************************** 3 3 * 4 - * Copyright 2009-2023 VMware, Inc., Palo Alto, CA., USA 4 + * Copyright (c) 2009-2024 Broadcom. All Rights Reserved. The term 5 + * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. 5 6 * 6 7 * Permission is hereby granted, free of charge, to any person obtaining a 7 8 * copy of this software and associated documentation files (the ··· 194 193 */ 195 194 static u32 *vmw_du_cursor_plane_acquire_image(struct vmw_plane_state *vps) 196 195 { 197 - if (vps->surf) { 198 - if (vps->surf_mapped) 199 - return vmw_bo_map_and_cache(vps->surf->res.guest_memory_bo); 200 - return vps->surf->snooper.image; 201 - } else if (vps->bo) 202 - return vmw_bo_map_and_cache(vps->bo); 203 - return NULL; 196 + struct vmw_surface *surf; 197 + 198 + if (vmw_user_object_is_null(&vps->uo)) 199 + return NULL; 200 + 201 + surf = vmw_user_object_surface(&vps->uo); 202 + if (surf && !vmw_user_object_is_mapped(&vps->uo)) 203 + return surf->snooper.image; 204 + 205 + return vmw_user_object_map(&vps->uo); 204 206 } 205 207 206 208 static bool vmw_du_cursor_plane_has_changed(struct vmw_plane_state *old_vps, ··· 540 536 * vmw_du_plane_unpin_surf - unpins resource associated with a framebuffer surface 541 537 * 542 538 * @vps: plane state associated with the display surface 543 - * @unreference: true if we also want to unreference the display. 544 539 */ 545 - void vmw_du_plane_unpin_surf(struct vmw_plane_state *vps, 546 - bool unreference) 540 + void vmw_du_plane_unpin_surf(struct vmw_plane_state *vps) 547 541 { 548 - if (vps->surf) { 549 - if (vps->pinned) { 550 - vmw_resource_unpin(&vps->surf->res); 551 - vps->pinned--; 552 - } 542 + struct vmw_surface *surf = vmw_user_object_surface(&vps->uo); 553 543 554 - if (unreference) { 555 - if (vps->pinned) 556 - DRM_ERROR("Surface still pinned\n"); 557 - vmw_surface_unreference(&vps->surf); 544 + if (surf) { 545 + if (vps->pinned) { 546 + vmw_resource_unpin(&surf->res); 547 + vps->pinned--; 558 548 } 559 549 } 560 550 } ··· 570 572 { 571 573 struct vmw_plane_state *vps = vmw_plane_state_to_vps(old_state); 572 574 573 - vmw_du_plane_unpin_surf(vps, false); 575 + vmw_du_plane_unpin_surf(vps); 574 576 } 575 577 576 578 ··· 659 661 struct vmw_cursor_plane *vcp = vmw_plane_to_vcp(plane); 660 662 struct vmw_plane_state *vps = vmw_plane_state_to_vps(old_state); 661 663 662 - if (vps->surf_mapped) { 663 - vmw_bo_unmap(vps->surf->res.guest_memory_bo); 664 - vps->surf_mapped = false; 665 - } 664 + if (!vmw_user_object_is_null(&vps->uo)) 665 + vmw_user_object_unmap(&vps->uo); 666 666 667 667 vmw_du_cursor_plane_unmap_cm(vps); 668 668 vmw_du_put_cursor_mob(vcp, vps); 669 669 670 - vmw_du_plane_unpin_surf(vps, false); 671 - 672 - if (vps->surf) { 673 - vmw_surface_unreference(&vps->surf); 674 - vps->surf = NULL; 675 - } 676 - 677 - if (vps->bo) { 678 - vmw_bo_unreference(&vps->bo); 679 - vps->bo = NULL; 680 - } 670 + vmw_du_plane_unpin_surf(vps); 671 + vmw_user_object_unref(&vps->uo); 681 672 } 682 673 683 674 ··· 685 698 struct drm_framebuffer *fb = new_state->fb; 686 699 struct vmw_cursor_plane *vcp = vmw_plane_to_vcp(plane); 687 700 struct vmw_plane_state *vps = vmw_plane_state_to_vps(new_state); 701 + struct vmw_bo *bo = NULL; 688 702 int ret = 0; 689 703 690 - if (vps->surf) { 691 - if (vps->surf_mapped) { 692 - vmw_bo_unmap(vps->surf->res.guest_memory_bo); 693 - vps->surf_mapped = false; 694 - } 695 - vmw_surface_unreference(&vps->surf); 696 - vps->surf = NULL; 697 - } 698 - 699 - if (vps->bo) { 700 - vmw_bo_unreference(&vps->bo); 701 - vps->bo = NULL; 704 + if (!vmw_user_object_is_null(&vps->uo)) { 705 + vmw_user_object_unmap(&vps->uo); 706 + vmw_user_object_unref(&vps->uo); 702 707 } 703 708 704 709 if (fb) { 705 710 if (vmw_framebuffer_to_vfb(fb)->bo) { 706 - vps->bo = vmw_framebuffer_to_vfbd(fb)->buffer; 707 - vmw_bo_reference(vps->bo); 711 + vps->uo.buffer = vmw_framebuffer_to_vfbd(fb)->buffer; 712 + vps->uo.surface = NULL; 708 713 } else { 709 - vps->surf = vmw_framebuffer_to_vfbs(fb)->surface; 710 - vmw_surface_reference(vps->surf); 714 + memcpy(&vps->uo, &vmw_framebuffer_to_vfbs(fb)->uo, sizeof(vps->uo)); 711 715 } 716 + vmw_user_object_ref(&vps->uo); 712 717 } 713 718 714 - if (!vps->surf && vps->bo) { 715 - const u32 size = new_state->crtc_w * new_state->crtc_h * sizeof(u32); 719 + bo = vmw_user_object_buffer(&vps->uo); 720 + if (bo) { 721 + struct ttm_operation_ctx ctx = {false, false}; 716 722 717 - /* 718 - * Not using vmw_bo_map_and_cache() helper here as we need to 719 - * reserve the ttm_buffer_object first which 720 - * vmw_bo_map_and_cache() omits. 721 - */ 722 - ret = ttm_bo_reserve(&vps->bo->tbo, true, false, NULL); 723 - 724 - if (unlikely(ret != 0)) 723 + ret = ttm_bo_reserve(&bo->tbo, true, false, NULL); 724 + if (ret != 0) 725 725 return -ENOMEM; 726 726 727 - ret = ttm_bo_kmap(&vps->bo->tbo, 0, PFN_UP(size), &vps->bo->map); 728 - 729 - ttm_bo_unreserve(&vps->bo->tbo); 730 - 731 - if (unlikely(ret != 0)) 727 + ret = ttm_bo_validate(&bo->tbo, &bo->placement, &ctx); 728 + if (ret != 0) 732 729 return -ENOMEM; 733 - } else if (vps->surf && !vps->bo && vps->surf->res.guest_memory_bo) { 734 730 735 - WARN_ON(vps->surf->snooper.image); 736 - ret = ttm_bo_reserve(&vps->surf->res.guest_memory_bo->tbo, true, false, 737 - NULL); 738 - if (unlikely(ret != 0)) 739 - return -ENOMEM; 740 - vmw_bo_map_and_cache(vps->surf->res.guest_memory_bo); 741 - ttm_bo_unreserve(&vps->surf->res.guest_memory_bo->tbo); 742 - vps->surf_mapped = true; 731 + vmw_bo_pin_reserved(bo, true); 732 + if (vmw_framebuffer_to_vfb(fb)->bo) { 733 + const u32 size = new_state->crtc_w * new_state->crtc_h * sizeof(u32); 734 + 735 + (void)vmw_bo_map_and_cache_size(bo, size); 736 + } else { 737 + vmw_bo_map_and_cache(bo); 738 + } 739 + ttm_bo_unreserve(&bo->tbo); 743 740 } 744 741 745 - if (vps->surf || vps->bo) { 742 + if (!vmw_user_object_is_null(&vps->uo)) { 746 743 vmw_du_get_cursor_mob(vcp, vps); 747 744 vmw_du_cursor_plane_map_cm(vps); 748 745 } ··· 748 777 struct vmw_display_unit *du = vmw_crtc_to_du(crtc); 749 778 struct vmw_plane_state *vps = vmw_plane_state_to_vps(new_state); 750 779 struct vmw_plane_state *old_vps = vmw_plane_state_to_vps(old_state); 780 + struct vmw_bo *old_bo = NULL; 781 + struct vmw_bo *new_bo = NULL; 751 782 s32 hotspot_x, hotspot_y; 783 + int ret; 752 784 753 785 hotspot_x = du->hotspot_x + new_state->hotspot_x; 754 786 hotspot_y = du->hotspot_y + new_state->hotspot_y; 755 787 756 - du->cursor_surface = vps->surf; 788 + du->cursor_surface = vmw_user_object_surface(&vps->uo); 757 789 758 - if (!vps->surf && !vps->bo) { 790 + if (vmw_user_object_is_null(&vps->uo)) { 759 791 vmw_cursor_update_position(dev_priv, false, 0, 0); 760 792 return; 761 793 } ··· 766 792 vps->cursor.hotspot_x = hotspot_x; 767 793 vps->cursor.hotspot_y = hotspot_y; 768 794 769 - if (vps->surf) { 795 + if (du->cursor_surface) 770 796 du->cursor_age = du->cursor_surface->snooper.age; 797 + 798 + if (!vmw_user_object_is_null(&old_vps->uo)) { 799 + old_bo = vmw_user_object_buffer(&old_vps->uo); 800 + ret = ttm_bo_reserve(&old_bo->tbo, false, false, NULL); 801 + if (ret != 0) 802 + return; 771 803 } 772 804 805 + if (!vmw_user_object_is_null(&vps->uo)) { 806 + new_bo = vmw_user_object_buffer(&vps->uo); 807 + if (old_bo != new_bo) { 808 + ret = ttm_bo_reserve(&new_bo->tbo, false, false, NULL); 809 + if (ret != 0) 810 + return; 811 + } else { 812 + new_bo = NULL; 813 + } 814 + } 773 815 if (!vmw_du_cursor_plane_has_changed(old_vps, vps)) { 774 816 /* 775 817 * If it hasn't changed, avoid making the device do extra ··· 802 812 new_state->crtc_h, 803 813 hotspot_x, hotspot_y); 804 814 } 815 + 816 + if (old_bo) 817 + ttm_bo_unreserve(&old_bo->tbo); 818 + if (new_bo) 819 + ttm_bo_unreserve(&new_bo->tbo); 805 820 806 821 du->cursor_x = new_state->crtc_x + du->set_gui_x; 807 822 du->cursor_y = new_state->crtc_y + du->set_gui_y; ··· 908 913 } 909 914 910 915 if (!vmw_framebuffer_to_vfb(fb)->bo) { 911 - surface = vmw_framebuffer_to_vfbs(fb)->surface; 916 + surface = vmw_user_object_surface(&vmw_framebuffer_to_vfbs(fb)->uo); 912 917 913 918 WARN_ON(!surface); 914 919 ··· 1069 1074 memset(&vps->cursor, 0, sizeof(vps->cursor)); 1070 1075 1071 1076 /* Each ref counted resource needs to be acquired again */ 1072 - if (vps->surf) 1073 - (void) vmw_surface_reference(vps->surf); 1074 - 1075 - if (vps->bo) 1076 - (void) vmw_bo_reference(vps->bo); 1077 - 1077 + vmw_user_object_ref(&vps->uo); 1078 1078 state = &vps->base; 1079 1079 1080 1080 __drm_atomic_helper_plane_duplicate_state(plane, state); ··· 1118 1128 struct vmw_plane_state *vps = vmw_plane_state_to_vps(state); 1119 1129 1120 1130 /* Should have been freed by cleanup_fb */ 1121 - if (vps->surf) 1122 - vmw_surface_unreference(&vps->surf); 1123 - 1124 - if (vps->bo) 1125 - vmw_bo_unreference(&vps->bo); 1131 + vmw_user_object_unref(&vps->uo); 1126 1132 1127 1133 drm_atomic_helper_plane_destroy_state(plane, state); 1128 1134 } ··· 1213 1227 vmw_framebuffer_to_vfbs(framebuffer); 1214 1228 1215 1229 drm_framebuffer_cleanup(framebuffer); 1216 - vmw_surface_unreference(&vfbs->surface); 1230 + vmw_user_object_unref(&vfbs->uo); 1217 1231 1218 1232 kfree(vfbs); 1219 1233 } ··· 1258 1272 return -ENOSYS; 1259 1273 } 1260 1274 1275 + static int vmw_framebuffer_surface_create_handle(struct drm_framebuffer *fb, 1276 + struct drm_file *file_priv, 1277 + unsigned int *handle) 1278 + { 1279 + struct vmw_framebuffer_surface *vfbs = vmw_framebuffer_to_vfbs(fb); 1280 + struct vmw_bo *bo = vmw_user_object_buffer(&vfbs->uo); 1281 + 1282 + return drm_gem_handle_create(file_priv, &bo->tbo.base, handle); 1283 + } 1261 1284 1262 1285 static const struct drm_framebuffer_funcs vmw_framebuffer_surface_funcs = { 1286 + .create_handle = vmw_framebuffer_surface_create_handle, 1263 1287 .destroy = vmw_framebuffer_surface_destroy, 1264 1288 .dirty = drm_atomic_helper_dirtyfb, 1265 1289 }; 1266 1290 1267 1291 static int vmw_kms_new_framebuffer_surface(struct vmw_private *dev_priv, 1268 - struct vmw_surface *surface, 1292 + struct vmw_user_object *uo, 1269 1293 struct vmw_framebuffer **out, 1270 1294 const struct drm_mode_fb_cmd2 1271 - *mode_cmd, 1272 - bool is_bo_proxy) 1295 + *mode_cmd) 1273 1296 1274 1297 { 1275 1298 struct drm_device *dev = &dev_priv->drm; 1276 1299 struct vmw_framebuffer_surface *vfbs; 1277 1300 enum SVGA3dSurfaceFormat format; 1301 + struct vmw_surface *surface; 1278 1302 int ret; 1279 1303 1280 1304 /* 3D is only supported on HWv8 and newer hosts */ 1281 1305 if (dev_priv->active_display_unit == vmw_du_legacy) 1282 1306 return -ENOSYS; 1307 + 1308 + surface = vmw_user_object_surface(uo); 1283 1309 1284 1310 /* 1285 1311 * Sanity checks. ··· 1355 1357 } 1356 1358 1357 1359 drm_helper_mode_fill_fb_struct(dev, &vfbs->base.base, mode_cmd); 1358 - vfbs->surface = vmw_surface_reference(surface); 1359 - vfbs->is_bo_proxy = is_bo_proxy; 1360 + memcpy(&vfbs->uo, uo, sizeof(vfbs->uo)); 1361 + vmw_user_object_ref(&vfbs->uo); 1360 1362 1361 1363 *out = &vfbs->base; 1362 1364 ··· 1368 1370 return 0; 1369 1371 1370 1372 out_err2: 1371 - vmw_surface_unreference(&surface); 1373 + vmw_user_object_unref(&vfbs->uo); 1372 1374 kfree(vfbs); 1373 1375 out_err1: 1374 1376 return ret; ··· 1384 1386 { 1385 1387 struct vmw_framebuffer_bo *vfbd = 1386 1388 vmw_framebuffer_to_vfbd(fb); 1387 - 1388 1389 return drm_gem_handle_create(file_priv, &vfbd->buffer->tbo.base, handle); 1389 1390 } 1390 1391 ··· 1403 1406 .destroy = vmw_framebuffer_bo_destroy, 1404 1407 .dirty = drm_atomic_helper_dirtyfb, 1405 1408 }; 1406 - 1407 - /** 1408 - * vmw_create_bo_proxy - create a proxy surface for the buffer object 1409 - * 1410 - * @dev: DRM device 1411 - * @mode_cmd: parameters for the new surface 1412 - * @bo_mob: MOB backing the buffer object 1413 - * @srf_out: newly created surface 1414 - * 1415 - * When the content FB is a buffer object, we create a surface as a proxy to the 1416 - * same buffer. This way we can do a surface copy rather than a surface DMA. 1417 - * This is a more efficient approach 1418 - * 1419 - * RETURNS: 1420 - * 0 on success, error code otherwise 1421 - */ 1422 - static int vmw_create_bo_proxy(struct drm_device *dev, 1423 - const struct drm_mode_fb_cmd2 *mode_cmd, 1424 - struct vmw_bo *bo_mob, 1425 - struct vmw_surface **srf_out) 1426 - { 1427 - struct vmw_surface_metadata metadata = {0}; 1428 - uint32_t format; 1429 - struct vmw_resource *res; 1430 - unsigned int bytes_pp; 1431 - int ret; 1432 - 1433 - switch (mode_cmd->pixel_format) { 1434 - case DRM_FORMAT_ARGB8888: 1435 - case DRM_FORMAT_XRGB8888: 1436 - format = SVGA3D_X8R8G8B8; 1437 - bytes_pp = 4; 1438 - break; 1439 - 1440 - case DRM_FORMAT_RGB565: 1441 - case DRM_FORMAT_XRGB1555: 1442 - format = SVGA3D_R5G6B5; 1443 - bytes_pp = 2; 1444 - break; 1445 - 1446 - case 8: 1447 - format = SVGA3D_P8; 1448 - bytes_pp = 1; 1449 - break; 1450 - 1451 - default: 1452 - DRM_ERROR("Invalid framebuffer format %p4cc\n", 1453 - &mode_cmd->pixel_format); 1454 - return -EINVAL; 1455 - } 1456 - 1457 - metadata.format = format; 1458 - metadata.mip_levels[0] = 1; 1459 - metadata.num_sizes = 1; 1460 - metadata.base_size.width = mode_cmd->pitches[0] / bytes_pp; 1461 - metadata.base_size.height = mode_cmd->height; 1462 - metadata.base_size.depth = 1; 1463 - metadata.scanout = true; 1464 - 1465 - ret = vmw_gb_surface_define(vmw_priv(dev), &metadata, srf_out); 1466 - if (ret) { 1467 - DRM_ERROR("Failed to allocate proxy content buffer\n"); 1468 - return ret; 1469 - } 1470 - 1471 - res = &(*srf_out)->res; 1472 - 1473 - /* Reserve and switch the backing mob. */ 1474 - mutex_lock(&res->dev_priv->cmdbuf_mutex); 1475 - (void) vmw_resource_reserve(res, false, true); 1476 - vmw_user_bo_unref(&res->guest_memory_bo); 1477 - res->guest_memory_bo = vmw_user_bo_ref(bo_mob); 1478 - res->guest_memory_offset = 0; 1479 - vmw_resource_unreserve(res, false, false, false, NULL, 0); 1480 - mutex_unlock(&res->dev_priv->cmdbuf_mutex); 1481 - 1482 - return 0; 1483 - } 1484 - 1485 - 1486 1409 1487 1410 static int vmw_kms_new_framebuffer_bo(struct vmw_private *dev_priv, 1488 1411 struct vmw_bo *bo, ··· 1482 1565 * vmw_kms_new_framebuffer - Create a new framebuffer. 1483 1566 * 1484 1567 * @dev_priv: Pointer to device private struct. 1485 - * @bo: Pointer to buffer object to wrap the kms framebuffer around. 1486 - * Either @bo or @surface must be NULL. 1487 - * @surface: Pointer to a surface to wrap the kms framebuffer around. 1488 - * Either @bo or @surface must be NULL. 1489 - * @only_2d: No presents will occur to this buffer object based framebuffer. 1490 - * This helps the code to do some important optimizations. 1568 + * @uo: Pointer to user object to wrap the kms framebuffer around. 1569 + * Either the buffer or surface inside the user object must be NULL. 1491 1570 * @mode_cmd: Frame-buffer metadata. 1492 1571 */ 1493 1572 struct vmw_framebuffer * 1494 1573 vmw_kms_new_framebuffer(struct vmw_private *dev_priv, 1495 - struct vmw_bo *bo, 1496 - struct vmw_surface *surface, 1497 - bool only_2d, 1574 + struct vmw_user_object *uo, 1498 1575 const struct drm_mode_fb_cmd2 *mode_cmd) 1499 1576 { 1500 1577 struct vmw_framebuffer *vfb = NULL; 1501 - bool is_bo_proxy = false; 1502 1578 int ret; 1503 1579 1504 - /* 1505 - * We cannot use the SurfaceDMA command in an non-accelerated VM, 1506 - * therefore, wrap the buffer object in a surface so we can use the 1507 - * SurfaceCopy command. 1508 - */ 1509 - if (vmw_kms_srf_ok(dev_priv, mode_cmd->width, mode_cmd->height) && 1510 - bo && only_2d && 1511 - mode_cmd->width > 64 && /* Don't create a proxy for cursor */ 1512 - dev_priv->active_display_unit == vmw_du_screen_target) { 1513 - ret = vmw_create_bo_proxy(&dev_priv->drm, mode_cmd, 1514 - bo, &surface); 1515 - if (ret) 1516 - return ERR_PTR(ret); 1517 - 1518 - is_bo_proxy = true; 1519 - } 1520 - 1521 1580 /* Create the new framebuffer depending one what we have */ 1522 - if (surface) { 1523 - ret = vmw_kms_new_framebuffer_surface(dev_priv, surface, &vfb, 1524 - mode_cmd, 1525 - is_bo_proxy); 1526 - /* 1527 - * vmw_create_bo_proxy() adds a reference that is no longer 1528 - * needed 1529 - */ 1530 - if (is_bo_proxy) 1531 - vmw_surface_unreference(&surface); 1532 - } else if (bo) { 1533 - ret = vmw_kms_new_framebuffer_bo(dev_priv, bo, &vfb, 1581 + if (vmw_user_object_surface(uo)) { 1582 + ret = vmw_kms_new_framebuffer_surface(dev_priv, uo, &vfb, 1583 + mode_cmd); 1584 + } else if (uo->buffer) { 1585 + ret = vmw_kms_new_framebuffer_bo(dev_priv, uo->buffer, &vfb, 1534 1586 mode_cmd); 1535 1587 } else { 1536 1588 BUG(); ··· 1521 1635 { 1522 1636 struct vmw_private *dev_priv = vmw_priv(dev); 1523 1637 struct vmw_framebuffer *vfb = NULL; 1524 - struct vmw_surface *surface = NULL; 1525 - struct vmw_bo *bo = NULL; 1638 + struct vmw_user_object uo = {0}; 1526 1639 int ret; 1527 1640 1528 1641 /* returns either a bo or surface */ 1529 - ret = vmw_user_lookup_handle(dev_priv, file_priv, 1530 - mode_cmd->handles[0], 1531 - &surface, &bo); 1642 + ret = vmw_user_object_lookup(dev_priv, file_priv, mode_cmd->handles[0], 1643 + &uo); 1532 1644 if (ret) { 1533 1645 DRM_ERROR("Invalid buffer object handle %u (0x%x).\n", 1534 1646 mode_cmd->handles[0], mode_cmd->handles[0]); ··· 1534 1650 } 1535 1651 1536 1652 1537 - if (!bo && 1653 + if (vmw_user_object_surface(&uo) && 1538 1654 !vmw_kms_srf_ok(dev_priv, mode_cmd->width, mode_cmd->height)) { 1539 1655 DRM_ERROR("Surface size cannot exceed %dx%d\n", 1540 1656 dev_priv->texture_max_width, ··· 1543 1659 } 1544 1660 1545 1661 1546 - vfb = vmw_kms_new_framebuffer(dev_priv, bo, surface, 1547 - !(dev_priv->capabilities & SVGA_CAP_3D), 1548 - mode_cmd); 1662 + vfb = vmw_kms_new_framebuffer(dev_priv, &uo, mode_cmd); 1549 1663 if (IS_ERR(vfb)) { 1550 1664 ret = PTR_ERR(vfb); 1551 1665 goto err_out; 1552 1666 } 1553 1667 1554 1668 err_out: 1555 - /* vmw_user_lookup_handle takes one ref so does new_fb */ 1556 - if (bo) 1557 - vmw_user_bo_unref(&bo); 1558 - if (surface) 1559 - vmw_surface_unreference(&surface); 1669 + /* vmw_user_object_lookup takes one ref so does new_fb */ 1670 + vmw_user_object_unref(&uo); 1560 1671 1561 1672 if (ret) { 1562 1673 DRM_ERROR("failed to create vmw_framebuffer: %i\n", ret); ··· 2464 2585 } 2465 2586 2466 2587 /** 2467 - * vmw_kms_update_proxy - Helper function to update a proxy surface from 2468 - * its backing MOB. 2469 - * 2470 - * @res: Pointer to the surface resource 2471 - * @clips: Clip rects in framebuffer (surface) space. 2472 - * @num_clips: Number of clips in @clips. 2473 - * @increment: Integer with which to increment the clip counter when looping. 2474 - * Used to skip a predetermined number of clip rects. 2475 - * 2476 - * This function makes sure the proxy surface is updated from its backing MOB 2477 - * using the region given by @clips. The surface resource @res and its backing 2478 - * MOB needs to be reserved and validated on call. 2479 - */ 2480 - int vmw_kms_update_proxy(struct vmw_resource *res, 2481 - const struct drm_clip_rect *clips, 2482 - unsigned num_clips, 2483 - int increment) 2484 - { 2485 - struct vmw_private *dev_priv = res->dev_priv; 2486 - struct drm_vmw_size *size = &vmw_res_to_srf(res)->metadata.base_size; 2487 - struct { 2488 - SVGA3dCmdHeader header; 2489 - SVGA3dCmdUpdateGBImage body; 2490 - } *cmd; 2491 - SVGA3dBox *box; 2492 - size_t copy_size = 0; 2493 - int i; 2494 - 2495 - if (!clips) 2496 - return 0; 2497 - 2498 - cmd = VMW_CMD_RESERVE(dev_priv, sizeof(*cmd) * num_clips); 2499 - if (!cmd) 2500 - return -ENOMEM; 2501 - 2502 - for (i = 0; i < num_clips; ++i, clips += increment, ++cmd) { 2503 - box = &cmd->body.box; 2504 - 2505 - cmd->header.id = SVGA_3D_CMD_UPDATE_GB_IMAGE; 2506 - cmd->header.size = sizeof(cmd->body); 2507 - cmd->body.image.sid = res->id; 2508 - cmd->body.image.face = 0; 2509 - cmd->body.image.mipmap = 0; 2510 - 2511 - if (clips->x1 > size->width || clips->x2 > size->width || 2512 - clips->y1 > size->height || clips->y2 > size->height) { 2513 - DRM_ERROR("Invalid clips outsize of framebuffer.\n"); 2514 - return -EINVAL; 2515 - } 2516 - 2517 - box->x = clips->x1; 2518 - box->y = clips->y1; 2519 - box->z = 0; 2520 - box->w = clips->x2 - clips->x1; 2521 - box->h = clips->y2 - clips->y1; 2522 - box->d = 1; 2523 - 2524 - copy_size += sizeof(*cmd); 2525 - } 2526 - 2527 - vmw_cmd_commit(dev_priv, copy_size); 2528 - 2529 - return 0; 2530 - } 2531 - 2532 - /** 2533 2588 * vmw_kms_create_implicit_placement_property - Set up the implicit placement 2534 2589 * property. 2535 2590 * ··· 2597 2784 } else { 2598 2785 struct vmw_framebuffer_surface *vfbs = 2599 2786 container_of(update->vfb, typeof(*vfbs), base); 2787 + struct vmw_surface *surf = vmw_user_object_surface(&vfbs->uo); 2600 2788 2601 - ret = vmw_validation_add_resource(&val_ctx, &vfbs->surface->res, 2789 + ret = vmw_validation_add_resource(&val_ctx, &surf->res, 2602 2790 0, VMW_RES_DIRTY_NONE, NULL, 2603 2791 NULL); 2604 2792 } ··· 2754 2940 num_modes = 1 + drm_add_modes_noedid(connector, max_width, max_height); 2755 2941 2756 2942 return num_modes; 2943 + } 2944 + 2945 + struct vmw_user_object *vmw_user_object_ref(struct vmw_user_object *uo) 2946 + { 2947 + if (uo->buffer) 2948 + vmw_user_bo_ref(uo->buffer); 2949 + else if (uo->surface) 2950 + vmw_surface_reference(uo->surface); 2951 + return uo; 2952 + } 2953 + 2954 + void vmw_user_object_unref(struct vmw_user_object *uo) 2955 + { 2956 + if (uo->buffer) 2957 + vmw_user_bo_unref(&uo->buffer); 2958 + else if (uo->surface) 2959 + vmw_surface_unreference(&uo->surface); 2960 + } 2961 + 2962 + struct vmw_bo * 2963 + vmw_user_object_buffer(struct vmw_user_object *uo) 2964 + { 2965 + if (uo->buffer) 2966 + return uo->buffer; 2967 + else if (uo->surface) 2968 + return uo->surface->res.guest_memory_bo; 2969 + return NULL; 2970 + } 2971 + 2972 + struct vmw_surface * 2973 + vmw_user_object_surface(struct vmw_user_object *uo) 2974 + { 2975 + if (uo->buffer) 2976 + return uo->buffer->dumb_surface; 2977 + return uo->surface; 2978 + } 2979 + 2980 + void *vmw_user_object_map(struct vmw_user_object *uo) 2981 + { 2982 + struct vmw_bo *bo = vmw_user_object_buffer(uo); 2983 + 2984 + WARN_ON(!bo); 2985 + return vmw_bo_map_and_cache(bo); 2986 + } 2987 + 2988 + void *vmw_user_object_map_size(struct vmw_user_object *uo, size_t size) 2989 + { 2990 + struct vmw_bo *bo = vmw_user_object_buffer(uo); 2991 + 2992 + WARN_ON(!bo); 2993 + return vmw_bo_map_and_cache_size(bo, size); 2994 + } 2995 + 2996 + void vmw_user_object_unmap(struct vmw_user_object *uo) 2997 + { 2998 + struct vmw_bo *bo = vmw_user_object_buffer(uo); 2999 + int ret; 3000 + 3001 + WARN_ON(!bo); 3002 + 3003 + /* Fence the mob creation so we are guarateed to have the mob */ 3004 + ret = ttm_bo_reserve(&bo->tbo, false, false, NULL); 3005 + if (ret != 0) 3006 + return; 3007 + 3008 + vmw_bo_unmap(bo); 3009 + vmw_bo_pin_reserved(bo, false); 3010 + 3011 + ttm_bo_unreserve(&bo->tbo); 3012 + } 3013 + 3014 + bool vmw_user_object_is_mapped(struct vmw_user_object *uo) 3015 + { 3016 + struct vmw_bo *bo; 3017 + 3018 + if (!uo || vmw_user_object_is_null(uo)) 3019 + return false; 3020 + 3021 + bo = vmw_user_object_buffer(uo); 3022 + 3023 + if (WARN_ON(!bo)) 3024 + return false; 3025 + 3026 + WARN_ON(bo->map.bo && !bo->map.virtual); 3027 + return bo->map.virtual; 3028 + } 3029 + 3030 + bool vmw_user_object_is_null(struct vmw_user_object *uo) 3031 + { 3032 + return !uo->buffer && !uo->surface; 2757 3033 }
+6 -11
drivers/gpu/drm/vmwgfx/vmwgfx_kms.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0 OR MIT */ 2 2 /************************************************************************** 3 3 * 4 - * Copyright 2009-2023 VMware, Inc., Palo Alto, CA., USA 4 + * Copyright (c) 2009-2024 Broadcom. All Rights Reserved. The term 5 + * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. 5 6 * 6 7 * Permission is hereby granted, free of charge, to any person obtaining a 7 8 * copy of this software and associated documentation files (the ··· 222 221 223 222 struct vmw_framebuffer_surface { 224 223 struct vmw_framebuffer base; 225 - struct vmw_surface *surface; 226 - bool is_bo_proxy; /* true if this is proxy surface for DMA buf */ 224 + struct vmw_user_object uo; 227 225 }; 228 - 229 226 230 227 struct vmw_framebuffer_bo { 231 228 struct vmw_framebuffer base; ··· 276 277 */ 277 278 struct vmw_plane_state { 278 279 struct drm_plane_state base; 279 - struct vmw_surface *surf; 280 - struct vmw_bo *bo; 280 + struct vmw_user_object uo; 281 281 282 282 int content_fb_type; 283 283 unsigned long bo_size; ··· 455 457 uint32_t num_clips); 456 458 struct vmw_framebuffer * 457 459 vmw_kms_new_framebuffer(struct vmw_private *dev_priv, 458 - struct vmw_bo *bo, 459 - struct vmw_surface *surface, 460 - bool only_2d, 460 + struct vmw_user_object *uo, 461 461 const struct drm_mode_fb_cmd2 *mode_cmd); 462 462 void vmw_guess_mode_timing(struct drm_display_mode *mode); 463 463 void vmw_kms_update_implicit_fb(struct vmw_private *dev_priv); ··· 482 486 struct drm_plane_state *vmw_du_plane_duplicate_state(struct drm_plane *plane); 483 487 void vmw_du_plane_destroy_state(struct drm_plane *plane, 484 488 struct drm_plane_state *state); 485 - void vmw_du_plane_unpin_surf(struct vmw_plane_state *vps, 486 - bool unreference); 489 + void vmw_du_plane_unpin_surf(struct vmw_plane_state *vps); 487 490 488 491 int vmw_du_crtc_atomic_check(struct drm_crtc *crtc, 489 492 struct drm_atomic_state *state);
+9 -5
drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 OR MIT 2 2 /************************************************************************** 3 3 * 4 - * Copyright 2009-2023 VMware, Inc., Palo Alto, CA., USA 4 + * Copyright (c) 2009-2024 Broadcom. All Rights Reserved. The term 5 + * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. 5 6 * 6 7 * Permission is hereby granted, free of charge, to any person obtaining a 7 8 * copy of this software and associated documentation files (the ··· 148 147 struct vmw_bo *buf; 149 148 int ret; 150 149 151 - buf = vfb->bo ? vmw_framebuffer_to_vfbd(&vfb->base)->buffer : 152 - vmw_framebuffer_to_vfbs(&vfb->base)->surface->res.guest_memory_bo; 150 + buf = vfb->bo ? 151 + vmw_framebuffer_to_vfbd(&vfb->base)->buffer : 152 + vmw_user_object_buffer(&vmw_framebuffer_to_vfbs(&vfb->base)->uo); 153 153 154 154 if (!buf) 155 155 return 0; ··· 171 169 struct vmw_private *dev_priv = vmw_priv(vfb->base.dev); 172 170 struct vmw_bo *buf; 173 171 174 - buf = vfb->bo ? vmw_framebuffer_to_vfbd(&vfb->base)->buffer : 175 - vmw_framebuffer_to_vfbs(&vfb->base)->surface->res.guest_memory_bo; 172 + buf = vfb->bo ? 173 + vmw_framebuffer_to_vfbd(&vfb->base)->buffer : 174 + vmw_user_object_buffer(&vmw_framebuffer_to_vfbs(&vfb->base)->uo); 175 + 176 176 177 177 if (WARN_ON(!buf)) 178 178 return 0;
+1 -1
drivers/gpu/drm/vmwgfx/vmwgfx_overlay.c
··· 92 92 { 93 93 struct vmw_escape_video_flush *flush; 94 94 size_t fifo_size; 95 - bool have_so = (dev_priv->active_display_unit == vmw_du_screen_object); 95 + bool have_so = (dev_priv->active_display_unit != vmw_du_legacy); 96 96 int i, num_items; 97 97 SVGAGuestPtr ptr; 98 98
+28 -4
drivers/gpu/drm/vmwgfx/vmwgfx_prime.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 OR MIT 2 2 /************************************************************************** 3 3 * 4 - * Copyright 2013 VMware, Inc., Palo Alto, CA., USA 4 + * Copyright (c) 2013-2024 Broadcom. All Rights Reserved. The term 5 + * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. 5 6 * 6 7 * Permission is hereby granted, free of charge, to any person obtaining a 7 8 * copy of this software and associated documentation files (the ··· 32 31 */ 33 32 34 33 #include "vmwgfx_drv.h" 34 + #include "vmwgfx_bo.h" 35 35 #include "ttm_object.h" 36 36 #include <linux/dma-buf.h> 37 37 ··· 90 88 uint32_t handle, uint32_t flags, 91 89 int *prime_fd) 92 90 { 91 + struct vmw_private *vmw = vmw_priv(dev); 93 92 struct ttm_object_file *tfile = vmw_fpriv(file_priv)->tfile; 93 + struct vmw_bo *vbo; 94 94 int ret; 95 + int surf_handle; 95 96 96 - if (handle > VMWGFX_NUM_MOB) 97 + if (handle > VMWGFX_NUM_MOB) { 97 98 ret = ttm_prime_handle_to_fd(tfile, handle, flags, prime_fd); 98 - else 99 - ret = drm_gem_prime_handle_to_fd(dev, file_priv, handle, flags, prime_fd); 99 + } else { 100 + ret = vmw_user_bo_lookup(file_priv, handle, &vbo); 101 + if (ret) 102 + return ret; 103 + if (vbo && vbo->is_dumb) { 104 + ret = drm_gem_prime_handle_to_fd(dev, file_priv, handle, 105 + flags, prime_fd); 106 + } else { 107 + surf_handle = vmw_lookup_surface_handle_for_buffer(vmw, 108 + vbo, 109 + handle); 110 + if (surf_handle > 0) 111 + ret = ttm_prime_handle_to_fd(tfile, surf_handle, 112 + flags, prime_fd); 113 + else 114 + ret = drm_gem_prime_handle_to_fd(dev, file_priv, 115 + handle, flags, 116 + prime_fd); 117 + } 118 + vmw_user_bo_unref(&vbo); 119 + } 100 120 101 121 return ret; 102 122 }
+18 -9
drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 OR MIT 2 2 /************************************************************************** 3 3 * 4 - * Copyright 2009-2023 VMware, Inc., Palo Alto, CA., USA 4 + * Copyright (c) 2009-2024 Broadcom. All Rights Reserved. The term 5 + * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. 5 6 * 6 7 * Permission is hereby granted, free of charge, to any person obtaining a 7 8 * copy of this software and associated documentation files (the ··· 59 58 60 59 rb_link_node(&res->mob_node, parent, new); 61 60 rb_insert_color(&res->mob_node, &gbo->res_tree); 61 + vmw_bo_del_detached_resource(gbo, res); 62 62 63 63 vmw_bo_prio_add(gbo, res->used_prio); 64 64 } ··· 289 287 * 290 288 * The pointer this pointed at by out_surf and out_buf needs to be null. 291 289 */ 292 - int vmw_user_lookup_handle(struct vmw_private *dev_priv, 290 + int vmw_user_object_lookup(struct vmw_private *dev_priv, 293 291 struct drm_file *filp, 294 - uint32_t handle, 295 - struct vmw_surface **out_surf, 296 - struct vmw_bo **out_buf) 292 + u32 handle, 293 + struct vmw_user_object *uo) 297 294 { 298 295 struct ttm_object_file *tfile = vmw_fpriv(filp)->tfile; 299 296 struct vmw_resource *res; 300 297 int ret; 301 298 302 - BUG_ON(*out_surf || *out_buf); 299 + WARN_ON(uo->surface || uo->buffer); 303 300 304 301 ret = vmw_user_resource_lookup_handle(dev_priv, tfile, handle, 305 302 user_surface_converter, 306 303 &res); 307 304 if (!ret) { 308 - *out_surf = vmw_res_to_srf(res); 305 + uo->surface = vmw_res_to_srf(res); 309 306 return 0; 310 307 } 311 308 312 - *out_surf = NULL; 313 - ret = vmw_user_bo_lookup(filp, handle, out_buf); 309 + uo->surface = NULL; 310 + ret = vmw_user_bo_lookup(filp, handle, &uo->buffer); 311 + if (!ret && !uo->buffer->is_dumb) { 312 + uo->surface = vmw_lookup_surface_for_buffer(dev_priv, 313 + uo->buffer, 314 + handle); 315 + if (uo->surface) 316 + vmw_user_bo_unref(&uo->buffer); 317 + } 318 + 314 319 return ret; 315 320 } 316 321
+19 -14
drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 OR MIT 2 2 /************************************************************************** 3 3 * 4 - * Copyright 2011-2023 VMware, Inc., Palo Alto, CA., USA 4 + * Copyright (c) 2011-2024 Broadcom. All Rights Reserved. The term 5 + * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. 5 6 * 6 7 * Permission is hereby granted, free of charge, to any person obtaining a 7 8 * copy of this software and associated documentation files (the ··· 241 240 struct vmw_connector_state *vmw_conn_state; 242 241 int x, y; 243 242 244 - sou->buffer = vps->bo; 243 + sou->buffer = vmw_user_object_buffer(&vps->uo); 245 244 246 245 conn_state = sou->base.connector.state; 247 246 vmw_conn_state = vmw_connector_state_to_vcs(conn_state); ··· 377 376 struct vmw_plane_state *vps = vmw_plane_state_to_vps(old_state); 378 377 struct drm_crtc *crtc = plane->state->crtc ? 379 378 plane->state->crtc : old_state->crtc; 379 + struct vmw_bo *bo = vmw_user_object_buffer(&vps->uo); 380 380 381 - if (vps->bo) 382 - vmw_bo_unpin(vmw_priv(crtc->dev), vps->bo, false); 383 - vmw_bo_unreference(&vps->bo); 381 + if (bo) 382 + vmw_bo_unpin(vmw_priv(crtc->dev), bo, false); 383 + vmw_user_object_unref(&vps->uo); 384 384 vps->bo_size = 0; 385 385 386 386 vmw_du_plane_cleanup_fb(plane, old_state); ··· 413 411 .bo_type = ttm_bo_type_device, 414 412 .pin = true 415 413 }; 414 + struct vmw_bo *bo = NULL; 416 415 417 416 if (!new_fb) { 418 - vmw_bo_unreference(&vps->bo); 417 + vmw_user_object_unref(&vps->uo); 419 418 vps->bo_size = 0; 420 419 421 420 return 0; ··· 425 422 bo_params.size = new_state->crtc_w * new_state->crtc_h * 4; 426 423 dev_priv = vmw_priv(crtc->dev); 427 424 428 - if (vps->bo) { 425 + bo = vmw_user_object_buffer(&vps->uo); 426 + if (bo) { 429 427 if (vps->bo_size == bo_params.size) { 430 428 /* 431 429 * Note that this might temporarily up the pin-count 432 430 * to 2, until cleanup_fb() is called. 433 431 */ 434 - return vmw_bo_pin_in_vram(dev_priv, vps->bo, 435 - true); 432 + return vmw_bo_pin_in_vram(dev_priv, bo, true); 436 433 } 437 434 438 - vmw_bo_unreference(&vps->bo); 435 + vmw_user_object_unref(&vps->uo); 439 436 vps->bo_size = 0; 440 437 } 441 438 ··· 445 442 * resume the overlays, this is preferred to failing to alloc. 446 443 */ 447 444 vmw_overlay_pause_all(dev_priv); 448 - ret = vmw_bo_create(dev_priv, &bo_params, &vps->bo); 445 + ret = vmw_gem_object_create(dev_priv, &bo_params, &vps->uo.buffer); 449 446 vmw_overlay_resume_all(dev_priv); 450 447 if (ret) 451 448 return ret; ··· 456 453 * TTM already thinks the buffer is pinned, but make sure the 457 454 * pin_count is upped. 458 455 */ 459 - return vmw_bo_pin_in_vram(dev_priv, vps->bo, true); 456 + return vmw_bo_pin_in_vram(dev_priv, vps->uo.buffer, true); 460 457 } 461 458 462 459 static uint32_t vmw_sou_bo_fifo_size(struct vmw_du_update_plane *update, ··· 583 580 { 584 581 struct vmw_kms_sou_dirty_cmd *blit = cmd; 585 582 struct vmw_framebuffer_surface *vfbs; 583 + struct vmw_surface *surf = NULL; 586 584 587 585 vfbs = container_of(update->vfb, typeof(*vfbs), base); 588 586 ··· 591 587 blit->header.size = sizeof(blit->body) + sizeof(SVGASignedRect) * 592 588 num_hits; 593 589 594 - blit->body.srcImage.sid = vfbs->surface->res.id; 590 + surf = vmw_user_object_surface(&vfbs->uo); 591 + blit->body.srcImage.sid = surf->res.id; 595 592 blit->body.destScreenId = update->du->unit; 596 593 597 594 /* Update the source and destination bounding box later in post_clip */ ··· 1109 1104 int ret; 1110 1105 1111 1106 if (!srf) 1112 - srf = &vfbs->surface->res; 1107 + srf = &vmw_user_object_surface(&vfbs->uo)->res; 1113 1108 1114 1109 ret = vmw_validation_add_resource(&val_ctx, srf, 0, VMW_RES_DIRTY_NONE, 1115 1110 NULL, NULL);
+85 -89
drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 OR MIT 2 2 /****************************************************************************** 3 3 * 4 - * COPYRIGHT (C) 2014-2023 VMware, Inc., Palo Alto, CA., USA 4 + * Copyright (c) 2014-2024 Broadcom. All Rights Reserved. The term 5 + * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. 5 6 * 6 7 * Permission is hereby granted, free of charge, to any person obtaining a 7 8 * copy of this software and associated documentation files (the ··· 30 29 #include "vmwgfx_kms.h" 31 30 #include "vmwgfx_vkms.h" 32 31 #include "vmw_surface_cache.h" 32 + #include <linux/fsnotify.h> 33 33 34 34 #include <drm/drm_atomic.h> 35 35 #include <drm/drm_atomic_helper.h> ··· 737 735 int ret; 738 736 739 737 if (!srf) 740 - srf = &vfbs->surface->res; 738 + srf = &vmw_user_object_surface(&vfbs->uo)->res; 741 739 742 740 ret = vmw_validation_add_resource(&val_ctx, srf, 0, VMW_RES_DIRTY_NONE, 743 741 NULL, NULL); ··· 747 745 ret = vmw_validation_prepare(&val_ctx, &dev_priv->cmdbuf_mutex, true); 748 746 if (ret) 749 747 goto out_unref; 750 - 751 - if (vfbs->is_bo_proxy) { 752 - ret = vmw_kms_update_proxy(srf, clips, num_clips, inc); 753 - if (ret) 754 - goto out_finish; 755 - } 756 748 757 749 sdirty.base.fifo_commit = vmw_kms_stdu_surface_fifo_commit; 758 750 sdirty.base.clip = vmw_kms_stdu_surface_clip; ··· 761 765 ret = vmw_kms_helper_dirty(dev_priv, framebuffer, clips, vclips, 762 766 dest_x, dest_y, num_clips, inc, 763 767 &sdirty.base); 764 - out_finish: 768 + 765 769 vmw_kms_helper_validation_finish(dev_priv, NULL, &val_ctx, out_fence, 766 770 NULL); 767 771 ··· 873 877 return MODE_OK; 874 878 } 875 879 880 + /* 881 + * Trigger a modeset if the X,Y position of the Screen Target changes. 882 + * This is needed when multi-mon is cycled. The original Screen Target will have 883 + * the same mode but its relative X,Y position in the topology will change. 884 + */ 885 + static int vmw_stdu_connector_atomic_check(struct drm_connector *conn, 886 + struct drm_atomic_state *state) 887 + { 888 + struct drm_connector_state *conn_state; 889 + struct vmw_screen_target_display_unit *du; 890 + struct drm_crtc_state *new_crtc_state; 891 + 892 + conn_state = drm_atomic_get_connector_state(state, conn); 893 + du = vmw_connector_to_stdu(conn); 894 + 895 + if (!conn_state->crtc) 896 + return 0; 897 + 898 + new_crtc_state = drm_atomic_get_new_crtc_state(state, conn_state->crtc); 899 + if (du->base.gui_x != du->base.set_gui_x || 900 + du->base.gui_y != du->base.set_gui_y) 901 + new_crtc_state->mode_changed = true; 902 + 903 + return 0; 904 + } 905 + 876 906 static const struct drm_connector_funcs vmw_stdu_connector_funcs = { 877 907 .dpms = vmw_du_connector_dpms, 878 908 .detect = vmw_du_connector_detect, ··· 913 891 static const struct 914 892 drm_connector_helper_funcs vmw_stdu_connector_helper_funcs = { 915 893 .get_modes = vmw_connector_get_modes, 916 - .mode_valid = vmw_stdu_connector_mode_valid 894 + .mode_valid = vmw_stdu_connector_mode_valid, 895 + .atomic_check = vmw_stdu_connector_atomic_check, 917 896 }; 918 897 919 898 ··· 941 918 { 942 919 struct vmw_plane_state *vps = vmw_plane_state_to_vps(old_state); 943 920 944 - if (vps->surf) 921 + if (vmw_user_object_surface(&vps->uo)) 945 922 WARN_ON(!vps->pinned); 946 - 947 923 vmw_du_plane_cleanup_fb(plane, old_state); 948 924 949 925 vps->content_fb_type = SAME_AS_DISPLAY; 950 926 vps->cpp = 0; 951 927 } 952 - 953 928 954 929 955 930 /** ··· 973 952 enum stdu_content_type new_content_type; 974 953 struct vmw_framebuffer_surface *new_vfbs; 975 954 uint32_t hdisplay = new_state->crtc_w, vdisplay = new_state->crtc_h; 955 + struct drm_plane_state *old_state = plane->state; 956 + struct drm_rect rect; 976 957 int ret; 977 958 978 959 /* No FB to prepare */ 979 960 if (!new_fb) { 980 - if (vps->surf) { 961 + if (vmw_user_object_surface(&vps->uo)) { 981 962 WARN_ON(vps->pinned != 0); 982 - vmw_surface_unreference(&vps->surf); 963 + vmw_user_object_unref(&vps->uo); 983 964 } 984 965 985 966 return 0; ··· 991 968 new_vfbs = (vfb->bo) ? NULL : vmw_framebuffer_to_vfbs(new_fb); 992 969 993 970 if (new_vfbs && 994 - new_vfbs->surface->metadata.base_size.width == hdisplay && 995 - new_vfbs->surface->metadata.base_size.height == vdisplay) 971 + vmw_user_object_surface(&new_vfbs->uo)->metadata.base_size.width == hdisplay && 972 + vmw_user_object_surface(&new_vfbs->uo)->metadata.base_size.height == vdisplay) 996 973 new_content_type = SAME_AS_DISPLAY; 997 974 else if (vfb->bo) 998 975 new_content_type = SEPARATE_BO; ··· 1030 1007 metadata.num_sizes = 1; 1031 1008 metadata.scanout = true; 1032 1009 } else { 1033 - metadata = new_vfbs->surface->metadata; 1010 + metadata = vmw_user_object_surface(&new_vfbs->uo)->metadata; 1034 1011 } 1035 1012 1036 1013 metadata.base_size.width = hdisplay; 1037 1014 metadata.base_size.height = vdisplay; 1038 1015 metadata.base_size.depth = 1; 1039 1016 1040 - if (vps->surf) { 1017 + if (vmw_user_object_surface(&vps->uo)) { 1041 1018 struct drm_vmw_size cur_base_size = 1042 - vps->surf->metadata.base_size; 1019 + vmw_user_object_surface(&vps->uo)->metadata.base_size; 1043 1020 1044 1021 if (cur_base_size.width != metadata.base_size.width || 1045 1022 cur_base_size.height != metadata.base_size.height || 1046 - vps->surf->metadata.format != metadata.format) { 1023 + vmw_user_object_surface(&vps->uo)->metadata.format != metadata.format) { 1047 1024 WARN_ON(vps->pinned != 0); 1048 - vmw_surface_unreference(&vps->surf); 1025 + vmw_user_object_unref(&vps->uo); 1049 1026 } 1050 1027 1051 1028 } 1052 1029 1053 - if (!vps->surf) { 1030 + if (!vmw_user_object_surface(&vps->uo)) { 1054 1031 ret = vmw_gb_surface_define(dev_priv, &metadata, 1055 - &vps->surf); 1032 + &vps->uo.surface); 1056 1033 if (ret != 0) { 1057 1034 DRM_ERROR("Couldn't allocate STDU surface.\n"); 1058 1035 return ret; ··· 1065 1042 * The only time we add a reference in prepare_fb is if the 1066 1043 * state object doesn't have a reference to begin with 1067 1044 */ 1068 - if (vps->surf) { 1045 + if (vmw_user_object_surface(&vps->uo)) { 1069 1046 WARN_ON(vps->pinned != 0); 1070 - vmw_surface_unreference(&vps->surf); 1047 + vmw_user_object_unref(&vps->uo); 1071 1048 } 1072 1049 1073 - vps->surf = vmw_surface_reference(new_vfbs->surface); 1050 + memcpy(&vps->uo, &new_vfbs->uo, sizeof(vps->uo)); 1051 + vmw_user_object_ref(&vps->uo); 1074 1052 } 1075 1053 1076 - if (vps->surf) { 1054 + if (vmw_user_object_surface(&vps->uo)) { 1077 1055 1078 1056 /* Pin new surface before flipping */ 1079 - ret = vmw_resource_pin(&vps->surf->res, false); 1057 + ret = vmw_resource_pin(&vmw_user_object_surface(&vps->uo)->res, false); 1080 1058 if (ret) 1081 1059 goto out_srf_unref; 1082 1060 ··· 1085 1061 } 1086 1062 1087 1063 vps->content_fb_type = new_content_type; 1064 + 1065 + /* 1066 + * The drm fb code will do blit's via the vmap interface, which doesn't 1067 + * trigger vmw_bo page dirty tracking due to being kernel side (and thus 1068 + * doesn't require mmap'ing) so we have to update the surface's dirty 1069 + * regions by hand but we want to be careful to not overwrite the 1070 + * resource if it has been written to by the gpu (res_dirty). 1071 + */ 1072 + if (vps->uo.buffer && vps->uo.buffer->is_dumb) { 1073 + struct vmw_surface *surf = vmw_user_object_surface(&vps->uo); 1074 + struct vmw_resource *res = &surf->res; 1075 + 1076 + if (!res->res_dirty && drm_atomic_helper_damage_merged(old_state, 1077 + new_state, 1078 + &rect)) { 1079 + /* 1080 + * At some point it might be useful to actually translate 1081 + * (rect.x1, rect.y1) => start, and (rect.x2, rect.y2) => end, 1082 + * but currently the fb code will just report the entire fb 1083 + * dirty so in practice it doesn't matter. 1084 + */ 1085 + pgoff_t start = res->guest_memory_offset >> PAGE_SHIFT; 1086 + pgoff_t end = __KERNEL_DIV_ROUND_UP(res->guest_memory_offset + 1087 + res->guest_memory_size, 1088 + PAGE_SIZE); 1089 + vmw_resource_dirty_update(res, start, end); 1090 + } 1091 + } 1088 1092 1089 1093 /* 1090 1094 * This should only happen if the buffer object is too large to create a ··· 1124 1072 return 0; 1125 1073 1126 1074 out_srf_unref: 1127 - vmw_surface_unreference(&vps->surf); 1075 + vmw_user_object_unref(&vps->uo); 1128 1076 return ret; 1129 1077 } 1130 1078 ··· 1266 1214 vmw_stdu_surface_fifo_size_same_display(struct vmw_du_update_plane *update, 1267 1215 uint32_t num_hits) 1268 1216 { 1269 - struct vmw_framebuffer_surface *vfbs; 1270 1217 uint32_t size = 0; 1271 - 1272 - vfbs = container_of(update->vfb, typeof(*vfbs), base); 1273 - 1274 - if (vfbs->is_bo_proxy) 1275 - size += sizeof(struct vmw_stdu_update_gb_image) * num_hits; 1276 1218 1277 1219 size += sizeof(struct vmw_stdu_update); 1278 1220 ··· 1276 1230 static uint32_t vmw_stdu_surface_fifo_size(struct vmw_du_update_plane *update, 1277 1231 uint32_t num_hits) 1278 1232 { 1279 - struct vmw_framebuffer_surface *vfbs; 1280 1233 uint32_t size = 0; 1281 - 1282 - vfbs = container_of(update->vfb, typeof(*vfbs), base); 1283 - 1284 - if (vfbs->is_bo_proxy) 1285 - size += sizeof(struct vmw_stdu_update_gb_image) * num_hits; 1286 1234 1287 1235 size += sizeof(struct vmw_stdu_surface_copy) + sizeof(SVGA3dCopyBox) * 1288 1236 num_hits + sizeof(struct vmw_stdu_update); 1289 1237 1290 1238 return size; 1291 - } 1292 - 1293 - static uint32_t 1294 - vmw_stdu_surface_update_proxy(struct vmw_du_update_plane *update, void *cmd) 1295 - { 1296 - struct vmw_framebuffer_surface *vfbs; 1297 - struct drm_plane_state *state = update->plane->state; 1298 - struct drm_plane_state *old_state = update->old_state; 1299 - struct vmw_stdu_update_gb_image *cmd_update = cmd; 1300 - struct drm_atomic_helper_damage_iter iter; 1301 - struct drm_rect clip; 1302 - uint32_t copy_size = 0; 1303 - 1304 - vfbs = container_of(update->vfb, typeof(*vfbs), base); 1305 - 1306 - /* 1307 - * proxy surface is special where a buffer object type fb is wrapped 1308 - * in a surface and need an update gb image command to sync with device. 1309 - */ 1310 - drm_atomic_helper_damage_iter_init(&iter, old_state, state); 1311 - drm_atomic_for_each_plane_damage(&iter, &clip) { 1312 - SVGA3dBox *box = &cmd_update->body.box; 1313 - 1314 - cmd_update->header.id = SVGA_3D_CMD_UPDATE_GB_IMAGE; 1315 - cmd_update->header.size = sizeof(cmd_update->body); 1316 - cmd_update->body.image.sid = vfbs->surface->res.id; 1317 - cmd_update->body.image.face = 0; 1318 - cmd_update->body.image.mipmap = 0; 1319 - 1320 - box->x = clip.x1; 1321 - box->y = clip.y1; 1322 - box->z = 0; 1323 - box->w = drm_rect_width(&clip); 1324 - box->h = drm_rect_height(&clip); 1325 - box->d = 1; 1326 - 1327 - copy_size += sizeof(*cmd_update); 1328 - cmd_update++; 1329 - } 1330 - 1331 - return copy_size; 1332 1239 } 1333 1240 1334 1241 static uint32_t ··· 1298 1299 cmd_copy->header.id = SVGA_3D_CMD_SURFACE_COPY; 1299 1300 cmd_copy->header.size = sizeof(cmd_copy->body) + sizeof(SVGA3dCopyBox) * 1300 1301 num_hits; 1301 - cmd_copy->body.src.sid = vfbs->surface->res.id; 1302 + cmd_copy->body.src.sid = vmw_user_object_surface(&vfbs->uo)->res.id; 1302 1303 cmd_copy->body.dest.sid = stdu->display_srf->res.id; 1303 1304 1304 1305 return sizeof(*cmd_copy); ··· 1369 1370 srf_update.mutex = &dev_priv->cmdbuf_mutex; 1370 1371 srf_update.intr = true; 1371 1372 1372 - if (vfbs->is_bo_proxy) 1373 - srf_update.post_prepare = vmw_stdu_surface_update_proxy; 1374 - 1375 - if (vfbs->surface->res.id != stdu->display_srf->res.id) { 1373 + if (vmw_user_object_surface(&vfbs->uo)->res.id != stdu->display_srf->res.id) { 1376 1374 srf_update.calc_fifo_size = vmw_stdu_surface_fifo_size; 1377 1375 srf_update.pre_clip = vmw_stdu_surface_populate_copy; 1378 1376 srf_update.clip = vmw_stdu_surface_populate_clip; ··· 1413 1417 stdu = vmw_crtc_to_stdu(crtc); 1414 1418 dev_priv = vmw_priv(crtc->dev); 1415 1419 1416 - stdu->display_srf = vps->surf; 1420 + stdu->display_srf = vmw_user_object_surface(&vps->uo); 1417 1421 stdu->content_fb_type = vps->content_fb_type; 1418 1422 stdu->cpp = vps->cpp; 1419 1423
+271 -9
drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 OR MIT 2 2 /************************************************************************** 3 3 * 4 - * Copyright 2009-2023 VMware, Inc., Palo Alto, CA., USA 4 + * Copyright (c) 2009-2024 Broadcom. All Rights Reserved. The term 5 + * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. 5 6 * 6 7 * Permission is hereby granted, free of charge, to any person obtaining a 7 8 * copy of this software and associated documentation files (the ··· 37 36 #include <drm/ttm/ttm_placement.h> 38 37 39 38 #define SVGA3D_FLAGS_64(upper32, lower32) (((uint64_t)upper32 << 32) | lower32) 40 - #define SVGA3D_FLAGS_UPPER_32(svga3d_flags) (svga3d_flags >> 32) 41 - #define SVGA3D_FLAGS_LOWER_32(svga3d_flags) \ 42 - (svga3d_flags & ((uint64_t)U32_MAX)) 43 39 44 40 /** 45 41 * struct vmw_user_surface - User-space visible surface resource ··· 684 686 struct vmw_resource *res = &user_srf->srf.res; 685 687 686 688 *p_base = NULL; 689 + 690 + /* 691 + * Dumb buffers own the resource and they'll unref the 692 + * resource themselves 693 + */ 694 + if (res && res->guest_memory_bo && res->guest_memory_bo->is_dumb) 695 + return; 696 + 687 697 vmw_resource_unreference(&res); 688 698 } 689 699 ··· 818 812 } 819 813 } 820 814 res->guest_memory_size = cur_bo_offset; 821 - if (metadata->scanout && 815 + if (!file_priv->atomic && 816 + metadata->scanout && 822 817 metadata->num_sizes == 1 && 823 818 metadata->sizes[0].width == VMW_CURSOR_SNOOP_WIDTH && 824 819 metadata->sizes[0].height == VMW_CURSOR_SNOOP_HEIGHT && ··· 871 864 vmw_resource_unreference(&res); 872 865 goto out_unlock; 873 866 } 867 + vmw_bo_add_detached_resource(res->guest_memory_bo, res); 874 868 } 875 869 876 870 tmp = vmw_resource_reference(&srf->res); ··· 900 892 return ret; 901 893 } 902 894 895 + static struct vmw_user_surface * 896 + vmw_lookup_user_surface_for_buffer(struct vmw_private *vmw, struct vmw_bo *bo, 897 + u32 handle) 898 + { 899 + struct vmw_user_surface *user_srf = NULL; 900 + struct vmw_surface *surf; 901 + struct ttm_base_object *base; 902 + 903 + surf = vmw_bo_surface(bo); 904 + if (surf) { 905 + rcu_read_lock(); 906 + user_srf = container_of(surf, struct vmw_user_surface, srf); 907 + base = &user_srf->prime.base; 908 + if (base && !kref_get_unless_zero(&base->refcount)) { 909 + drm_dbg_driver(&vmw->drm, 910 + "%s: referencing a stale surface handle %d\n", 911 + __func__, handle); 912 + base = NULL; 913 + user_srf = NULL; 914 + } 915 + rcu_read_unlock(); 916 + } 917 + 918 + return user_srf; 919 + } 920 + 921 + struct vmw_surface *vmw_lookup_surface_for_buffer(struct vmw_private *vmw, 922 + struct vmw_bo *bo, 923 + u32 handle) 924 + { 925 + struct vmw_user_surface *user_srf = 926 + vmw_lookup_user_surface_for_buffer(vmw, bo, handle); 927 + struct vmw_surface *surf = NULL; 928 + struct ttm_base_object *base; 929 + 930 + if (user_srf) { 931 + surf = vmw_surface_reference(&user_srf->srf); 932 + base = &user_srf->prime.base; 933 + ttm_base_object_unref(&base); 934 + } 935 + return surf; 936 + } 937 + 938 + u32 vmw_lookup_surface_handle_for_buffer(struct vmw_private *vmw, 939 + struct vmw_bo *bo, 940 + u32 handle) 941 + { 942 + struct vmw_user_surface *user_srf = 943 + vmw_lookup_user_surface_for_buffer(vmw, bo, handle); 944 + int surf_handle = 0; 945 + struct ttm_base_object *base; 946 + 947 + if (user_srf) { 948 + base = &user_srf->prime.base; 949 + surf_handle = (u32)base->handle; 950 + ttm_base_object_unref(&base); 951 + } 952 + return surf_handle; 953 + } 954 + 955 + static int vmw_buffer_prime_to_surface_base(struct vmw_private *dev_priv, 956 + struct drm_file *file_priv, 957 + u32 fd, u32 *handle, 958 + struct ttm_base_object **base_p) 959 + { 960 + struct ttm_base_object *base; 961 + struct vmw_bo *bo; 962 + struct ttm_object_file *tfile = vmw_fpriv(file_priv)->tfile; 963 + struct vmw_user_surface *user_srf; 964 + int ret; 965 + 966 + ret = drm_gem_prime_fd_to_handle(&dev_priv->drm, file_priv, fd, handle); 967 + if (ret) { 968 + drm_warn(&dev_priv->drm, 969 + "Wasn't able to find user buffer for fd = %u.\n", fd); 970 + return ret; 971 + } 972 + 973 + ret = vmw_user_bo_lookup(file_priv, *handle, &bo); 974 + if (ret) { 975 + drm_warn(&dev_priv->drm, 976 + "Wasn't able to lookup user buffer for handle = %u.\n", *handle); 977 + return ret; 978 + } 979 + 980 + user_srf = vmw_lookup_user_surface_for_buffer(dev_priv, bo, *handle); 981 + if (WARN_ON(!user_srf)) { 982 + drm_warn(&dev_priv->drm, 983 + "User surface fd %d (handle %d) is null.\n", fd, *handle); 984 + ret = -EINVAL; 985 + goto out; 986 + } 987 + 988 + base = &user_srf->prime.base; 989 + ret = ttm_ref_object_add(tfile, base, NULL, false); 990 + if (ret) { 991 + drm_warn(&dev_priv->drm, 992 + "Couldn't add an object ref for the buffer (%d).\n", *handle); 993 + goto out; 994 + } 995 + 996 + *base_p = base; 997 + out: 998 + vmw_user_bo_unref(&bo); 999 + 1000 + return ret; 1001 + } 903 1002 904 1003 static int 905 1004 vmw_surface_handle_reference(struct vmw_private *dev_priv, ··· 1016 901 struct ttm_base_object **base_p) 1017 902 { 1018 903 struct ttm_object_file *tfile = vmw_fpriv(file_priv)->tfile; 1019 - struct vmw_user_surface *user_srf; 904 + struct vmw_user_surface *user_srf = NULL; 1020 905 uint32_t handle; 1021 906 struct ttm_base_object *base; 1022 907 int ret; 1023 908 1024 909 if (handle_type == DRM_VMW_HANDLE_PRIME) { 1025 910 ret = ttm_prime_fd_to_handle(tfile, u_handle, &handle); 1026 - if (unlikely(ret != 0)) 1027 - return ret; 911 + if (ret) 912 + return vmw_buffer_prime_to_surface_base(dev_priv, 913 + file_priv, 914 + u_handle, 915 + &handle, 916 + base_p); 1028 917 } else { 1029 918 handle = u_handle; 1030 919 } ··· 1622 1503 ret = vmw_user_bo_lookup(file_priv, req->base.buffer_handle, 1623 1504 &res->guest_memory_bo); 1624 1505 if (ret == 0) { 1625 - if (res->guest_memory_bo->tbo.base.size < res->guest_memory_size) { 1506 + if (res->guest_memory_bo->is_dumb) { 1507 + VMW_DEBUG_USER("Can't backup surface with a dumb buffer.\n"); 1508 + vmw_user_bo_unref(&res->guest_memory_bo); 1509 + ret = -EINVAL; 1510 + goto out_unlock; 1511 + } else if (res->guest_memory_bo->tbo.base.size < res->guest_memory_size) { 1626 1512 VMW_DEBUG_USER("Surface backup buffer too small.\n"); 1627 1513 vmw_user_bo_unref(&res->guest_memory_bo); 1628 1514 ret = -EINVAL; ··· 1684 1560 rep->handle = user_srf->prime.base.handle; 1685 1561 rep->backup_size = res->guest_memory_size; 1686 1562 if (res->guest_memory_bo) { 1563 + vmw_bo_add_detached_resource(res->guest_memory_bo, res); 1687 1564 rep->buffer_map_handle = 1688 1565 drm_vma_node_offset_addr(&res->guest_memory_bo->tbo.base.vma_node); 1689 1566 rep->buffer_size = res->guest_memory_bo->tbo.base.size; ··· 2223 2098 return ret; 2224 2099 2225 2100 out_unlock: 2101 + return ret; 2102 + } 2103 + 2104 + static SVGA3dSurfaceFormat vmw_format_bpp_to_svga(struct vmw_private *vmw, 2105 + int bpp) 2106 + { 2107 + switch (bpp) { 2108 + case 8: /* DRM_FORMAT_C8 */ 2109 + return SVGA3D_P8; 2110 + case 16: /* DRM_FORMAT_RGB565 */ 2111 + return SVGA3D_R5G6B5; 2112 + case 32: /* DRM_FORMAT_XRGB8888 */ 2113 + if (has_sm4_context(vmw)) 2114 + return SVGA3D_B8G8R8X8_UNORM; 2115 + return SVGA3D_X8R8G8B8; 2116 + default: 2117 + drm_warn(&vmw->drm, "Unsupported format bpp: %d\n", bpp); 2118 + return SVGA3D_X8R8G8B8; 2119 + } 2120 + } 2121 + 2122 + /** 2123 + * vmw_dumb_create - Create a dumb kms buffer 2124 + * 2125 + * @file_priv: Pointer to a struct drm_file identifying the caller. 2126 + * @dev: Pointer to the drm device. 2127 + * @args: Pointer to a struct drm_mode_create_dumb structure 2128 + * Return: Zero on success, negative error code on failure. 2129 + * 2130 + * This is a driver callback for the core drm create_dumb functionality. 2131 + * Note that this is very similar to the vmw_bo_alloc ioctl, except 2132 + * that the arguments have a different format. 2133 + */ 2134 + int vmw_dumb_create(struct drm_file *file_priv, 2135 + struct drm_device *dev, 2136 + struct drm_mode_create_dumb *args) 2137 + { 2138 + struct vmw_private *dev_priv = vmw_priv(dev); 2139 + struct ttm_object_file *tfile = vmw_fpriv(file_priv)->tfile; 2140 + struct vmw_bo *vbo = NULL; 2141 + struct vmw_resource *res = NULL; 2142 + union drm_vmw_gb_surface_create_ext_arg arg = { 0 }; 2143 + struct drm_vmw_gb_surface_create_ext_req *req = &arg.req; 2144 + int ret; 2145 + struct drm_vmw_size drm_size = { 2146 + .width = args->width, 2147 + .height = args->height, 2148 + .depth = 1, 2149 + }; 2150 + SVGA3dSurfaceFormat format = vmw_format_bpp_to_svga(dev_priv, args->bpp); 2151 + const struct SVGA3dSurfaceDesc *desc = vmw_surface_get_desc(format); 2152 + SVGA3dSurfaceAllFlags flags = SVGA3D_SURFACE_HINT_TEXTURE | 2153 + SVGA3D_SURFACE_HINT_RENDERTARGET | 2154 + SVGA3D_SURFACE_SCREENTARGET | 2155 + SVGA3D_SURFACE_BIND_SHADER_RESOURCE | 2156 + SVGA3D_SURFACE_BIND_RENDER_TARGET; 2157 + 2158 + /* 2159 + * Without mob support we're just going to use raw memory buffer 2160 + * because we wouldn't be able to support full surface coherency 2161 + * without mobs 2162 + */ 2163 + if (!dev_priv->has_mob) { 2164 + int cpp = DIV_ROUND_UP(args->bpp, 8); 2165 + 2166 + switch (cpp) { 2167 + case 1: /* DRM_FORMAT_C8 */ 2168 + case 2: /* DRM_FORMAT_RGB565 */ 2169 + case 4: /* DRM_FORMAT_XRGB8888 */ 2170 + break; 2171 + default: 2172 + /* 2173 + * Dumb buffers don't allow anything else. 2174 + * This is tested via IGT's dumb_buffers 2175 + */ 2176 + return -EINVAL; 2177 + } 2178 + 2179 + args->pitch = args->width * cpp; 2180 + args->size = ALIGN(args->pitch * args->height, PAGE_SIZE); 2181 + 2182 + ret = vmw_gem_object_create_with_handle(dev_priv, file_priv, 2183 + args->size, &args->handle, 2184 + &vbo); 2185 + /* drop reference from allocate - handle holds it now */ 2186 + drm_gem_object_put(&vbo->tbo.base); 2187 + return ret; 2188 + } 2189 + 2190 + req->version = drm_vmw_gb_surface_v1; 2191 + req->multisample_pattern = SVGA3D_MS_PATTERN_NONE; 2192 + req->quality_level = SVGA3D_MS_QUALITY_NONE; 2193 + req->buffer_byte_stride = 0; 2194 + req->must_be_zero = 0; 2195 + req->base.svga3d_flags = SVGA3D_FLAGS_LOWER_32(flags); 2196 + req->svga3d_flags_upper_32_bits = SVGA3D_FLAGS_UPPER_32(flags); 2197 + req->base.format = (uint32_t)format; 2198 + req->base.drm_surface_flags = drm_vmw_surface_flag_scanout; 2199 + req->base.drm_surface_flags |= drm_vmw_surface_flag_shareable; 2200 + req->base.drm_surface_flags |= drm_vmw_surface_flag_create_buffer; 2201 + req->base.drm_surface_flags |= drm_vmw_surface_flag_coherent; 2202 + req->base.base_size.width = args->width; 2203 + req->base.base_size.height = args->height; 2204 + req->base.base_size.depth = 1; 2205 + req->base.array_size = 0; 2206 + req->base.mip_levels = 1; 2207 + req->base.multisample_count = 0; 2208 + req->base.buffer_handle = SVGA3D_INVALID_ID; 2209 + req->base.autogen_filter = SVGA3D_TEX_FILTER_NONE; 2210 + ret = vmw_gb_surface_define_ext_ioctl(dev, &arg, file_priv); 2211 + if (ret) { 2212 + drm_warn(dev, "Unable to create a dumb buffer\n"); 2213 + return ret; 2214 + } 2215 + 2216 + args->handle = arg.rep.buffer_handle; 2217 + args->size = arg.rep.buffer_size; 2218 + args->pitch = vmw_surface_calculate_pitch(desc, &drm_size); 2219 + 2220 + ret = vmw_user_resource_lookup_handle(dev_priv, tfile, arg.rep.handle, 2221 + user_surface_converter, 2222 + &res); 2223 + if (ret) { 2224 + drm_err(dev, "Created resource handle doesn't exist!\n"); 2225 + goto err; 2226 + } 2227 + 2228 + vbo = res->guest_memory_bo; 2229 + vbo->is_dumb = true; 2230 + vbo->dumb_surface = vmw_res_to_srf(res); 2231 + 2232 + err: 2233 + if (res) 2234 + vmw_resource_unreference(&res); 2235 + if (ret) 2236 + ttm_ref_object_base_unref(tfile, arg.rep.handle); 2237 + 2226 2238 return ret; 2227 2239 }
+22 -18
drivers/gpu/drm/vmwgfx/vmwgfx_vkms.c
··· 75 75 return ret; 76 76 } 77 77 78 - static int 78 + static void 79 79 compute_crc(struct drm_crtc *crtc, 80 80 struct vmw_surface *surf, 81 81 u32 *crc) ··· 101 101 } 102 102 103 103 vmw_bo_unmap(bo); 104 - 105 - return 0; 106 104 } 107 105 108 106 static void ··· 114 116 u64 frame_start, frame_end; 115 117 u32 crc32 = 0; 116 118 struct vmw_surface *surf = 0; 117 - int ret; 118 119 119 120 spin_lock_irq(&du->vkms.crc_state_lock); 120 121 crc_pending = du->vkms.crc_pending; ··· 127 130 return; 128 131 129 132 spin_lock_irq(&du->vkms.crc_state_lock); 130 - surf = du->vkms.surface; 133 + surf = vmw_surface_reference(du->vkms.surface); 131 134 spin_unlock_irq(&du->vkms.crc_state_lock); 132 135 133 - if (vmw_surface_sync(vmw, surf)) { 134 - drm_warn(crtc->dev, "CRC worker wasn't able to sync the crc surface!\n"); 135 - return; 136 - } 136 + if (surf) { 137 + if (vmw_surface_sync(vmw, surf)) { 138 + drm_warn( 139 + crtc->dev, 140 + "CRC worker wasn't able to sync the crc surface!\n"); 141 + return; 142 + } 137 143 138 - ret = compute_crc(crtc, surf, &crc32); 139 - if (ret) 140 - return; 144 + compute_crc(crtc, surf, &crc32); 145 + vmw_surface_unreference(&surf); 146 + } 141 147 142 148 spin_lock_irq(&du->vkms.crc_state_lock); 143 149 frame_start = du->vkms.frame_start; 144 150 frame_end = du->vkms.frame_end; 145 - crc_pending = du->vkms.crc_pending; 146 151 du->vkms.frame_start = 0; 147 152 du->vkms.frame_end = 0; 148 153 du->vkms.crc_pending = false; ··· 163 164 struct vmw_display_unit *du = container_of(timer, struct vmw_display_unit, vkms.timer); 164 165 struct drm_crtc *crtc = &du->crtc; 165 166 struct vmw_private *vmw = vmw_priv(crtc->dev); 166 - struct vmw_surface *surf = NULL; 167 + bool has_surface = false; 167 168 u64 ret_overrun; 168 169 bool locked, ret; 169 170 ··· 178 179 WARN_ON(!ret); 179 180 if (!locked) 180 181 return HRTIMER_RESTART; 181 - surf = du->vkms.surface; 182 + has_surface = du->vkms.surface != NULL; 182 183 vmw_vkms_unlock(crtc); 183 184 184 - if (du->vkms.crc_enabled && surf) { 185 + if (du->vkms.crc_enabled && has_surface) { 185 186 u64 frame = drm_crtc_accurate_vblank_count(crtc); 186 187 187 188 spin_lock(&du->vkms.crc_state_lock); ··· 335 336 { 336 337 struct vmw_display_unit *du = vmw_crtc_to_du(crtc); 337 338 339 + if (du->vkms.surface) 340 + vmw_surface_unreference(&du->vkms.surface); 338 341 WARN_ON(work_pending(&du->vkms.crc_generator_work)); 339 342 hrtimer_cancel(&du->vkms.timer); 340 343 } ··· 498 497 struct vmw_display_unit *du = vmw_crtc_to_du(crtc); 499 498 struct vmw_private *vmw = vmw_priv(crtc->dev); 500 499 501 - if (vmw->vkms_enabled) { 500 + if (vmw->vkms_enabled && du->vkms.surface != surf) { 502 501 WARN_ON(atomic_read(&du->vkms.atomic_lock) != VMW_VKMS_LOCK_MODESET); 503 - du->vkms.surface = surf; 502 + if (du->vkms.surface) 503 + vmw_surface_unreference(&du->vkms.surface); 504 + if (surf) 505 + du->vkms.surface = vmw_surface_reference(surf); 504 506 } 505 507 } 506 508
+4 -2
drivers/irqchip/irq-loongarch-cpu.c
··· 18 18 19 19 static u32 lpic_gsi_to_irq(u32 gsi) 20 20 { 21 + int irq = 0; 22 + 21 23 /* Only pch irqdomain transferring is required for LoongArch. */ 22 24 if (gsi >= GSI_MIN_PCH_IRQ && gsi <= GSI_MAX_PCH_IRQ) 23 - return acpi_register_gsi(NULL, gsi, ACPI_LEVEL_SENSITIVE, ACPI_ACTIVE_HIGH); 25 + irq = acpi_register_gsi(NULL, gsi, ACPI_LEVEL_SENSITIVE, ACPI_ACTIVE_HIGH); 24 26 25 - return 0; 27 + return (irq > 0) ? irq : 0; 26 28 } 27 29 28 30 static struct fwnode_handle *lpic_get_gsi_domain_id(u32 gsi)
+16 -4
drivers/irqchip/irq-mbigen.c
··· 64 64 void __iomem *base; 65 65 }; 66 66 67 + static inline unsigned int get_mbigen_node_offset(unsigned int nid) 68 + { 69 + unsigned int offset = nid * MBIGEN_NODE_OFFSET; 70 + 71 + /* 72 + * To avoid touched clear register in unexpected way, we need to directly 73 + * skip clear register when access to more than 10 mbigen nodes. 74 + */ 75 + if (nid >= (REG_MBIGEN_CLEAR_OFFSET / MBIGEN_NODE_OFFSET)) 76 + offset += MBIGEN_NODE_OFFSET; 77 + 78 + return offset; 79 + } 80 + 67 81 static inline unsigned int get_mbigen_vec_reg(irq_hw_number_t hwirq) 68 82 { 69 83 unsigned int nid, pin; ··· 86 72 nid = hwirq / IRQS_PER_MBIGEN_NODE + 1; 87 73 pin = hwirq % IRQS_PER_MBIGEN_NODE; 88 74 89 - return pin * 4 + nid * MBIGEN_NODE_OFFSET 90 - + REG_MBIGEN_VEC_OFFSET; 75 + return pin * 4 + get_mbigen_node_offset(nid) + REG_MBIGEN_VEC_OFFSET; 91 76 } 92 77 93 78 static inline void get_mbigen_type_reg(irq_hw_number_t hwirq, ··· 101 88 *mask = 1 << (irq_ofst % 32); 102 89 ofst = irq_ofst / 32 * 4; 103 90 104 - *addr = ofst + nid * MBIGEN_NODE_OFFSET 105 - + REG_MBIGEN_TYPE_OFFSET; 91 + *addr = ofst + get_mbigen_node_offset(nid) + REG_MBIGEN_TYPE_OFFSET; 106 92 } 107 93 108 94 static inline void get_mbigen_clear_reg(irq_hw_number_t hwirq,
+7 -7
drivers/irqchip/irq-meson-gpio.c
··· 178 178 void __iomem *base; 179 179 u32 channel_irqs[MAX_NUM_CHANNEL]; 180 180 DECLARE_BITMAP(channel_map, MAX_NUM_CHANNEL); 181 - spinlock_t lock; 181 + raw_spinlock_t lock; 182 182 }; 183 183 184 184 static void meson_gpio_irq_update_bits(struct meson_gpio_irq_controller *ctl, ··· 187 187 unsigned long flags; 188 188 u32 tmp; 189 189 190 - spin_lock_irqsave(&ctl->lock, flags); 190 + raw_spin_lock_irqsave(&ctl->lock, flags); 191 191 192 192 tmp = readl_relaxed(ctl->base + reg); 193 193 tmp &= ~mask; 194 194 tmp |= val; 195 195 writel_relaxed(tmp, ctl->base + reg); 196 196 197 - spin_unlock_irqrestore(&ctl->lock, flags); 197 + raw_spin_unlock_irqrestore(&ctl->lock, flags); 198 198 } 199 199 200 200 static void meson_gpio_irq_init_dummy(struct meson_gpio_irq_controller *ctl) ··· 244 244 unsigned long flags; 245 245 unsigned int idx; 246 246 247 - spin_lock_irqsave(&ctl->lock, flags); 247 + raw_spin_lock_irqsave(&ctl->lock, flags); 248 248 249 249 /* Find a free channel */ 250 250 idx = find_first_zero_bit(ctl->channel_map, ctl->params->nr_channels); 251 251 if (idx >= ctl->params->nr_channels) { 252 - spin_unlock_irqrestore(&ctl->lock, flags); 252 + raw_spin_unlock_irqrestore(&ctl->lock, flags); 253 253 pr_err("No channel available\n"); 254 254 return -ENOSPC; 255 255 } ··· 257 257 /* Mark the channel as used */ 258 258 set_bit(idx, ctl->channel_map); 259 259 260 - spin_unlock_irqrestore(&ctl->lock, flags); 260 + raw_spin_unlock_irqrestore(&ctl->lock, flags); 261 261 262 262 /* 263 263 * Setup the mux of the channel to route the signal of the pad ··· 567 567 if (!ctl) 568 568 return -ENOMEM; 569 569 570 - spin_lock_init(&ctl->lock); 570 + raw_spin_lock_init(&ctl->lock); 571 571 572 572 ctl->base = of_iomap(node, 0); 573 573 if (!ctl->base) {
+3 -3
drivers/irqchip/irq-pic32-evic.c
··· 161 161 return ret; 162 162 } 163 163 164 - int pic32_irq_domain_xlate(struct irq_domain *d, struct device_node *ctrlr, 165 - const u32 *intspec, unsigned int intsize, 166 - irq_hw_number_t *out_hwirq, unsigned int *out_type) 164 + static int pic32_irq_domain_xlate(struct irq_domain *d, struct device_node *ctrlr, 165 + const u32 *intspec, unsigned int intsize, 166 + irq_hw_number_t *out_hwirq, unsigned int *out_type) 167 167 { 168 168 struct evic_chip_data *priv = d->host_data; 169 169
+2 -1
drivers/media/pci/intel/ipu6/Kconfig
··· 3 3 depends on ACPI || COMPILE_TEST 4 4 depends on VIDEO_DEV 5 5 depends on X86 && X86_64 && HAS_DMA 6 + depends on IPU_BRIDGE || !IPU_BRIDGE 7 + select AUXILIARY_BUS 6 8 select DMA_OPS 7 9 select IOMMU_IOVA 8 10 select VIDEO_V4L2_SUBDEV_API 9 11 select MEDIA_CONTROLLER 10 12 select VIDEOBUF2_DMA_CONTIG 11 13 select V4L2_FWNODE 12 - select IPU_BRIDGE 13 14 help 14 15 This is the 6th Gen Intel Image Processing Unit, found in Intel SoCs 15 16 and used for capturing images and video from camera sensors.
+5 -3
drivers/media/usb/uvc/uvc_ctrl.c
··· 2680 2680 for (i = 0; i < ARRAY_SIZE(uvc_ctrl_mappings); ++i) { 2681 2681 const struct uvc_control_mapping *mapping = &uvc_ctrl_mappings[i]; 2682 2682 2683 + if (!uvc_entity_match_guid(ctrl->entity, mapping->entity) || 2684 + ctrl->info.selector != mapping->selector) 2685 + continue; 2686 + 2683 2687 /* Let the device provide a custom mapping. */ 2684 2688 if (mapping->filter_mapping) { 2685 2689 mapping = mapping->filter_mapping(chain, ctrl); ··· 2691 2687 continue; 2692 2688 } 2693 2689 2694 - if (uvc_entity_match_guid(ctrl->entity, mapping->entity) && 2695 - ctrl->info.selector == mapping->selector) 2696 - __uvc_ctrl_add_mapping(chain, ctrl, mapping); 2690 + __uvc_ctrl_add_mapping(chain, ctrl, mapping); 2697 2691 } 2698 2692 } 2699 2693
+3 -1
drivers/net/dsa/bcm_sf2.c
··· 675 675 of_remove_property(child, prop); 676 676 677 677 phydev = of_phy_find_device(child); 678 - if (phydev) 678 + if (phydev) { 679 679 phy_device_remove(phydev); 680 + phy_device_free(phydev); 681 + } 680 682 } 681 683 682 684 err = mdiobus_register(priv->user_mii_bus);
+16
drivers/net/dsa/microchip/ksz_common.c
··· 2578 2578 if (!port) 2579 2579 return MICREL_KSZ8_P1_ERRATA; 2580 2580 break; 2581 + case KSZ8567_CHIP_ID: 2581 2582 case KSZ9477_CHIP_ID: 2583 + case KSZ9567_CHIP_ID: 2584 + case KSZ9896_CHIP_ID: 2585 + case KSZ9897_CHIP_ID: 2582 2586 /* KSZ9477 Errata DS80000754C 2583 2587 * 2584 2588 * Module 4: Energy Efficient Ethernet (EEE) feature select must ··· 2592 2588 * controls. If not disabled, the PHY ports can auto-negotiate 2593 2589 * to enable EEE, and this feature can cause link drops when 2594 2590 * linked to another device supporting EEE. 2591 + * 2592 + * The same item appears in the errata for the KSZ9567, KSZ9896, 2593 + * and KSZ9897. 2594 + * 2595 + * A similar item appears in the errata for the KSZ8567, but 2596 + * provides an alternative workaround. For now, use the simple 2597 + * workaround of disabling the EEE feature for this device too. 2595 2598 */ 2596 2599 return MICREL_NO_EEE; 2597 2600 } ··· 3774 3763 port); 3775 3764 return -EBUSY; 3776 3765 } 3766 + 3767 + /* Need to initialize variable as the code to fill in settings may 3768 + * not be executed. 3769 + */ 3770 + wol.wolopts = 0; 3777 3771 3778 3772 ksz_get_wol(ds, dp->index, &wol); 3779 3773 if (wol.wolopts & WAKE_MAGIC) {
+7 -6
drivers/net/ethernet/broadcom/bnxt/bnxt.c
··· 7591 7591 int rx = bp->rx_nr_rings, stat; 7592 7592 int vnic, grp = rx; 7593 7593 7594 - if (hw_resc->resv_tx_rings != bp->tx_nr_rings && 7595 - bp->hwrm_spec_code >= 0x10601) 7596 - return true; 7597 - 7598 7594 /* Old firmware does not need RX ring reservations but we still 7599 7595 * need to setup a default RSS map when needed. With new firmware 7600 7596 * we go through RX ring reservations first and then set up the 7601 7597 * RSS map for the successfully reserved RX rings when needed. 7602 7598 */ 7603 - if (!BNXT_NEW_RM(bp)) { 7599 + if (!BNXT_NEW_RM(bp)) 7604 7600 bnxt_check_rss_tbl_no_rmgr(bp); 7601 + 7602 + if (hw_resc->resv_tx_rings != bp->tx_nr_rings && 7603 + bp->hwrm_spec_code >= 0x10601) 7604 + return true; 7605 + 7606 + if (!BNXT_NEW_RM(bp)) 7605 7607 return false; 7606 - } 7607 7608 7608 7609 vnic = bnxt_get_total_vnics(bp, rx); 7609 7610
+1 -1
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
··· 5290 5290 const struct ethtool_ops bnxt_ethtool_ops = { 5291 5291 .cap_link_lanes_supported = 1, 5292 5292 .cap_rss_ctx_supported = 1, 5293 - .rxfh_max_context_id = BNXT_MAX_ETH_RSS_CTX, 5293 + .rxfh_max_num_contexts = BNXT_MAX_ETH_RSS_CTX + 1, 5294 5294 .rxfh_indir_space = BNXT_MAX_RSS_TABLE_ENTRIES_P5, 5295 5295 .rxfh_priv_size = sizeof(struct bnxt_rss_ctx), 5296 5296 .supported_coalesce_params = ETHTOOL_COALESCE_USECS |
+5 -9
drivers/net/ethernet/broadcom/genet/bcmgenet_wol.c
··· 42 42 struct bcmgenet_priv *priv = netdev_priv(dev); 43 43 struct device *kdev = &priv->pdev->dev; 44 44 45 - if (dev->phydev) { 45 + if (dev->phydev) 46 46 phy_ethtool_get_wol(dev->phydev, wol); 47 - if (wol->supported) 48 - return; 49 - } 50 47 51 - if (!device_can_wakeup(kdev)) { 52 - wol->supported = 0; 53 - wol->wolopts = 0; 48 + /* MAC is not wake-up capable, return what the PHY does */ 49 + if (!device_can_wakeup(kdev)) 54 50 return; 55 - } 56 51 57 - wol->supported = WAKE_MAGIC | WAKE_MAGICSECURE | WAKE_FILTER; 52 + /* Overlay MAC capabilities with that of the PHY queried before */ 53 + wol->supported |= WAKE_MAGIC | WAKE_MAGICSECURE | WAKE_FILTER; 58 54 wol->wolopts = priv->wolopts; 59 55 memset(wol->sopass, 0, sizeof(wol->sopass)); 60 56
+3
drivers/net/ethernet/freescale/fec_ptp.c
··· 775 775 struct net_device *ndev = platform_get_drvdata(pdev); 776 776 struct fec_enet_private *fep = netdev_priv(ndev); 777 777 778 + if (fep->pps_enable) 779 + fec_ptp_enable_pps(fep, 0); 780 + 778 781 cancel_delayed_work_sync(&fep->time_keep); 779 782 hrtimer_cancel(&fep->perout_timer); 780 783 if (fep->ptp_clock)
+1 -1
drivers/net/ethernet/google/gve/gve_ethtool.c
··· 495 495 return -EINVAL; 496 496 } 497 497 498 - if (!netif_carrier_ok(netdev)) { 498 + if (!netif_running(netdev)) { 499 499 priv->tx_cfg.num_queues = new_tx; 500 500 priv->rx_cfg.num_queues = new_rx; 501 501 return 0;
+6 -6
drivers/net/ethernet/google/gve/gve_main.c
··· 1566 1566 u32 status; 1567 1567 1568 1568 old_prog = READ_ONCE(priv->xdp_prog); 1569 - if (!netif_carrier_ok(priv->dev)) { 1569 + if (!netif_running(priv->dev)) { 1570 1570 WRITE_ONCE(priv->xdp_prog, prog); 1571 1571 if (old_prog) 1572 1572 bpf_prog_put(old_prog); ··· 1847 1847 rx_alloc_cfg.qcfg = &new_rx_config; 1848 1848 tx_alloc_cfg.num_rings = new_tx_config.num_queues; 1849 1849 1850 - if (netif_carrier_ok(priv->dev)) { 1850 + if (netif_running(priv->dev)) { 1851 1851 err = gve_adjust_config(priv, &tx_alloc_cfg, &rx_alloc_cfg); 1852 1852 return err; 1853 1853 } ··· 2064 2064 2065 2065 if ((netdev->features & NETIF_F_LRO) != (features & NETIF_F_LRO)) { 2066 2066 netdev->features ^= NETIF_F_LRO; 2067 - if (netif_carrier_ok(netdev)) { 2067 + if (netif_running(netdev)) { 2068 2068 err = gve_adjust_config(priv, &tx_alloc_cfg, &rx_alloc_cfg); 2069 2069 if (err) 2070 2070 goto revert_features; ··· 2359 2359 2360 2360 int gve_reset(struct gve_priv *priv, bool attempt_teardown) 2361 2361 { 2362 - bool was_up = netif_carrier_ok(priv->dev); 2362 + bool was_up = netif_running(priv->dev); 2363 2363 int err; 2364 2364 2365 2365 dev_info(&priv->pdev->dev, "Performing reset\n"); ··· 2700 2700 { 2701 2701 struct net_device *netdev = pci_get_drvdata(pdev); 2702 2702 struct gve_priv *priv = netdev_priv(netdev); 2703 - bool was_up = netif_carrier_ok(priv->dev); 2703 + bool was_up = netif_running(priv->dev); 2704 2704 2705 2705 rtnl_lock(); 2706 2706 if (was_up && gve_close(priv->dev)) { ··· 2718 2718 { 2719 2719 struct net_device *netdev = pci_get_drvdata(pdev); 2720 2720 struct gve_priv *priv = netdev_priv(netdev); 2721 - bool was_up = netif_carrier_ok(priv->dev); 2721 + bool was_up = netif_running(priv->dev); 2722 2722 2723 2723 priv->suspend_cnt++; 2724 2724 rtnl_lock();
+4 -4
drivers/net/ethernet/intel/ice/ice_ethtool.c
··· 4673 4673 if (err) 4674 4674 return err; 4675 4675 4676 - fec_stats->uncorrectable_blocks.total = (fec_corr_high_val << 16) + 4677 - fec_corr_low_val; 4678 - fec_stats->corrected_blocks.total = (fec_uncorr_high_val << 16) + 4679 - fec_uncorr_low_val; 4676 + fec_stats->corrected_blocks.total = (fec_corr_high_val << 16) + 4677 + fec_corr_low_val; 4678 + fec_stats->uncorrectable_blocks.total = (fec_uncorr_high_val << 16) + 4679 + fec_uncorr_low_val; 4680 4680 return 0; 4681 4681 } 4682 4682
+2
drivers/net/ethernet/intel/ice/ice_main.c
··· 559 559 if (test_bit(ICE_PREPARED_FOR_RESET, pf->state)) 560 560 return; 561 561 562 + synchronize_irq(pf->oicr_irq.virq); 563 + 562 564 ice_unplug_aux_dev(pf); 563 565 564 566 /* Notify VFs of impending reset */
+4
drivers/net/ethernet/intel/ice/ice_ptp.c
··· 1477 1477 /* Update cached link status for this port immediately */ 1478 1478 ptp_port->link_up = linkup; 1479 1479 1480 + /* Skip HW writes if reset is in progress */ 1481 + if (pf->hw.reset_ongoing) 1482 + return; 1483 + 1480 1484 switch (hw->ptp.phy_model) { 1481 1485 case ICE_PHY_E810: 1482 1486 /* Do not reconfigure E810 PHY */
+24 -24
drivers/net/ethernet/intel/idpf/idpf_lib.c
··· 900 900 901 901 vport->link_up = false; 902 902 idpf_vport_intr_deinit(vport); 903 - idpf_vport_intr_rel(vport); 904 903 idpf_vport_queues_rel(vport); 904 + idpf_vport_intr_rel(vport); 905 905 np->state = __IDPF_VPORT_DOWN; 906 906 } 907 907 ··· 1335 1335 /** 1336 1336 * idpf_vport_open - Bring up a vport 1337 1337 * @vport: vport to bring up 1338 - * @alloc_res: allocate queue resources 1339 1338 */ 1340 - static int idpf_vport_open(struct idpf_vport *vport, bool alloc_res) 1339 + static int idpf_vport_open(struct idpf_vport *vport) 1341 1340 { 1342 1341 struct idpf_netdev_priv *np = netdev_priv(vport->netdev); 1343 1342 struct idpf_adapter *adapter = vport->adapter; ··· 1349 1350 /* we do not allow interface up just yet */ 1350 1351 netif_carrier_off(vport->netdev); 1351 1352 1352 - if (alloc_res) { 1353 - err = idpf_vport_queues_alloc(vport); 1354 - if (err) 1355 - return err; 1356 - } 1357 - 1358 1353 err = idpf_vport_intr_alloc(vport); 1359 1354 if (err) { 1360 1355 dev_err(&adapter->pdev->dev, "Failed to allocate interrupts for vport %u: %d\n", 1361 1356 vport->vport_id, err); 1362 - goto queues_rel; 1357 + return err; 1363 1358 } 1359 + 1360 + err = idpf_vport_queues_alloc(vport); 1361 + if (err) 1362 + goto intr_rel; 1364 1363 1365 1364 err = idpf_vport_queue_ids_init(vport); 1366 1365 if (err) { 1367 1366 dev_err(&adapter->pdev->dev, "Failed to initialize queue ids for vport %u: %d\n", 1368 1367 vport->vport_id, err); 1369 - goto intr_rel; 1368 + goto queues_rel; 1370 1369 } 1371 1370 1372 1371 err = idpf_vport_intr_init(vport); 1373 1372 if (err) { 1374 1373 dev_err(&adapter->pdev->dev, "Failed to initialize interrupts for vport %u: %d\n", 1375 1374 vport->vport_id, err); 1376 - goto intr_rel; 1375 + goto queues_rel; 1377 1376 } 1378 1377 1379 1378 err = idpf_rx_bufs_init_all(vport); 1380 1379 if (err) { 1381 1380 dev_err(&adapter->pdev->dev, "Failed to initialize RX buffers for vport %u: %d\n", 1382 1381 vport->vport_id, err); 1383 - goto intr_rel; 1382 + goto queues_rel; 1384 1383 } 1385 1384 1386 1385 err = idpf_queue_reg_init(vport); 1387 1386 if (err) { 1388 1387 dev_err(&adapter->pdev->dev, "Failed to initialize queue registers for vport %u: %d\n", 1389 1388 vport->vport_id, err); 1390 - goto intr_rel; 1389 + goto queues_rel; 1391 1390 } 1392 1391 1393 1392 idpf_rx_init_buf_tail(vport); ··· 1452 1455 idpf_send_map_unmap_queue_vector_msg(vport, false); 1453 1456 intr_deinit: 1454 1457 idpf_vport_intr_deinit(vport); 1455 - intr_rel: 1456 - idpf_vport_intr_rel(vport); 1457 1458 queues_rel: 1458 1459 idpf_vport_queues_rel(vport); 1460 + intr_rel: 1461 + idpf_vport_intr_rel(vport); 1459 1462 1460 1463 return err; 1461 1464 } ··· 1536 1539 np = netdev_priv(vport->netdev); 1537 1540 np->state = __IDPF_VPORT_DOWN; 1538 1541 if (test_and_clear_bit(IDPF_VPORT_UP_REQUESTED, vport_config->flags)) 1539 - idpf_vport_open(vport, true); 1542 + idpf_vport_open(vport); 1540 1543 1541 1544 /* Spawn and return 'idpf_init_task' work queue until all the 1542 1545 * default vports are created ··· 1895 1898 goto free_vport; 1896 1899 } 1897 1900 1898 - err = idpf_vport_queues_alloc(new_vport); 1899 - if (err) 1900 - goto free_vport; 1901 1901 if (current_state <= __IDPF_VPORT_DOWN) { 1902 1902 idpf_send_delete_queues_msg(vport); 1903 1903 } else { ··· 1926 1932 1927 1933 err = idpf_set_real_num_queues(vport); 1928 1934 if (err) 1929 - goto err_reset; 1935 + goto err_open; 1930 1936 1931 1937 if (current_state == __IDPF_VPORT_UP) 1932 - err = idpf_vport_open(vport, false); 1938 + err = idpf_vport_open(vport); 1933 1939 1934 1940 kfree(new_vport); 1935 1941 1936 1942 return err; 1937 1943 1938 1944 err_reset: 1939 - idpf_vport_queues_rel(new_vport); 1945 + idpf_send_add_queues_msg(vport, vport->num_txq, vport->num_complq, 1946 + vport->num_rxq, vport->num_bufq); 1947 + 1948 + err_open: 1949 + if (current_state == __IDPF_VPORT_UP) 1950 + idpf_vport_open(vport); 1951 + 1940 1952 free_vport: 1941 1953 kfree(new_vport); 1942 1954 ··· 2171 2171 idpf_vport_ctrl_lock(netdev); 2172 2172 vport = idpf_netdev_to_vport(netdev); 2173 2173 2174 - err = idpf_vport_open(vport, true); 2174 + err = idpf_vport_open(vport); 2175 2175 2176 2176 idpf_vport_ctrl_unlock(netdev); 2177 2177
+9 -34
drivers/net/ethernet/intel/idpf/idpf_txrx.c
··· 3576 3576 */ 3577 3577 void idpf_vport_intr_rel(struct idpf_vport *vport) 3578 3578 { 3579 - int i, j, v_idx; 3580 - 3581 - for (v_idx = 0; v_idx < vport->num_q_vectors; v_idx++) { 3579 + for (u32 v_idx = 0; v_idx < vport->num_q_vectors; v_idx++) { 3582 3580 struct idpf_q_vector *q_vector = &vport->q_vectors[v_idx]; 3583 3581 3584 3582 kfree(q_vector->complq); ··· 3590 3592 3591 3593 free_cpumask_var(q_vector->affinity_mask); 3592 3594 } 3593 - 3594 - /* Clean up the mapping of queues to vectors */ 3595 - for (i = 0; i < vport->num_rxq_grp; i++) { 3596 - struct idpf_rxq_group *rx_qgrp = &vport->rxq_grps[i]; 3597 - 3598 - if (idpf_is_queue_model_split(vport->rxq_model)) 3599 - for (j = 0; j < rx_qgrp->splitq.num_rxq_sets; j++) 3600 - rx_qgrp->splitq.rxq_sets[j]->rxq.q_vector = NULL; 3601 - else 3602 - for (j = 0; j < rx_qgrp->singleq.num_rxq; j++) 3603 - rx_qgrp->singleq.rxqs[j]->q_vector = NULL; 3604 - } 3605 - 3606 - if (idpf_is_queue_model_split(vport->txq_model)) 3607 - for (i = 0; i < vport->num_txq_grp; i++) 3608 - vport->txq_grps[i].complq->q_vector = NULL; 3609 - else 3610 - for (i = 0; i < vport->num_txq_grp; i++) 3611 - for (j = 0; j < vport->txq_grps[i].num_txq; j++) 3612 - vport->txq_grps[i].txqs[j]->q_vector = NULL; 3613 3595 3614 3596 kfree(vport->q_vectors); 3615 3597 vport->q_vectors = NULL; ··· 3758 3780 /** 3759 3781 * idpf_vport_intr_req_irq - get MSI-X vectors from the OS for the vport 3760 3782 * @vport: main vport structure 3761 - * @basename: name for the vector 3762 3783 */ 3763 - static int idpf_vport_intr_req_irq(struct idpf_vport *vport, char *basename) 3784 + static int idpf_vport_intr_req_irq(struct idpf_vport *vport) 3764 3785 { 3765 3786 struct idpf_adapter *adapter = vport->adapter; 3787 + const char *drv_name, *if_name, *vec_name; 3766 3788 int vector, err, irq_num, vidx; 3767 - const char *vec_name; 3789 + 3790 + drv_name = dev_driver_string(&adapter->pdev->dev); 3791 + if_name = netdev_name(vport->netdev); 3768 3792 3769 3793 for (vector = 0; vector < vport->num_q_vectors; vector++) { 3770 3794 struct idpf_q_vector *q_vector = &vport->q_vectors[vector]; ··· 3784 3804 else 3785 3805 continue; 3786 3806 3787 - name = kasprintf(GFP_KERNEL, "%s-%s-%d", basename, vec_name, 3788 - vidx); 3807 + name = kasprintf(GFP_KERNEL, "%s-%s-%s-%d", drv_name, if_name, 3808 + vec_name, vidx); 3789 3809 3790 3810 err = request_irq(irq_num, idpf_vport_intr_clean_queues, 0, 3791 3811 name, q_vector); ··· 4306 4326 */ 4307 4327 int idpf_vport_intr_init(struct idpf_vport *vport) 4308 4328 { 4309 - char *int_name; 4310 4329 int err; 4311 4330 4312 4331 err = idpf_vport_intr_init_vec_idx(vport); ··· 4319 4340 if (err) 4320 4341 goto unroll_vectors_alloc; 4321 4342 4322 - int_name = kasprintf(GFP_KERNEL, "%s-%s", 4323 - dev_driver_string(&vport->adapter->pdev->dev), 4324 - vport->netdev->name); 4325 - 4326 - err = idpf_vport_intr_req_irq(vport, int_name); 4343 + err = idpf_vport_intr_req_irq(vport); 4327 4344 if (err) 4328 4345 goto unroll_vectors_alloc; 4329 4346
-2
drivers/net/ethernet/stmicro/stmmac/dwmac4.h
··· 573 573 #define GMAC_PHYIF_CTRLSTATUS_LNKSTS BIT(19) 574 574 #define GMAC_PHYIF_CTRLSTATUS_JABTO BIT(20) 575 575 #define GMAC_PHYIF_CTRLSTATUS_FALSECARDET BIT(21) 576 - /* LNKMOD */ 577 - #define GMAC_PHYIF_CTRLSTATUS_LNKMOD_MASK 0x1 578 576 /* LNKSPEED */ 579 577 #define GMAC_PHYIF_CTRLSTATUS_SPEED_125 0x2 580 578 #define GMAC_PHYIF_CTRLSTATUS_SPEED_25 0x1
+1 -1
drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
··· 786 786 else 787 787 x->pcs_speed = SPEED_10; 788 788 789 - x->pcs_duplex = (status & GMAC_PHYIF_CTRLSTATUS_LNKMOD_MASK); 789 + x->pcs_duplex = (status & GMAC_PHYIF_CTRLSTATUS_LNKMOD); 790 790 791 791 pr_info("Link is Up - %d/%s\n", (int)x->pcs_speed, 792 792 x->pcs_duplex ? "Full" : "Half");
+1
drivers/net/pse-pd/tps23881.c
··· 5 5 * Copyright (c) 2023 Bootlin, Kory Maincent <kory.maincent@bootlin.com> 6 6 */ 7 7 8 + #include <linux/bitfield.h> 8 9 #include <linux/delay.h> 9 10 #include <linux/firmware.h> 10 11 #include <linux/i2c.h>
+2
drivers/net/usb/qmi_wwan.c
··· 201 201 break; 202 202 default: 203 203 /* not ip - do not know what to do */ 204 + kfree_skb(skbn); 204 205 goto skip; 205 206 } 206 207 ··· 1432 1431 {QMI_QUIRK_SET_DTR(0x1546, 0x1312, 4)}, /* u-blox LARA-R6 01B */ 1433 1432 {QMI_QUIRK_SET_DTR(0x1546, 0x1342, 4)}, /* u-blox LARA-L6 */ 1434 1433 {QMI_QUIRK_SET_DTR(0x33f8, 0x0104, 4)}, /* Rolling RW101 RMNET */ 1434 + {QMI_FIXED_INTF(0x2dee, 0x4d22, 5)}, /* MeiG Smart SRM825L */ 1435 1435 1436 1436 /* 4. Gobi 1000 devices */ 1437 1437 {QMI_GOBI1K_DEVICE(0x05c6, 0x9212)}, /* Acer Gobi Modem Device */
+12 -2
drivers/net/virtio_net.c
··· 3658 3658 { 3659 3659 int err; 3660 3660 3661 + if (!virtio_has_feature(vi->vdev, VIRTIO_NET_F_VQ_NOTF_COAL)) 3662 + return -EOPNOTSUPP; 3663 + 3661 3664 err = virtnet_send_ctrl_coal_vq_cmd(vi, rxq2vq(queue), 3662 3665 max_usecs, max_packets); 3663 3666 if (err) ··· 3677 3674 u32 max_packets) 3678 3675 { 3679 3676 int err; 3677 + 3678 + if (!virtio_has_feature(vi->vdev, VIRTIO_NET_F_VQ_NOTF_COAL)) 3679 + return -EOPNOTSUPP; 3680 3680 3681 3681 err = virtnet_send_ctrl_coal_vq_cmd(vi, txq2vq(queue), 3682 3682 max_usecs, max_packets); ··· 3749 3743 err = virtnet_send_tx_ctrl_coal_vq_cmd(vi, i, 3750 3744 vi->intr_coal_tx.max_usecs, 3751 3745 vi->intr_coal_tx.max_packets); 3752 - if (err) 3746 + 3747 + /* Don't break the tx resize action if the vq coalescing is not 3748 + * supported. The same is true for rx resize below. 3749 + */ 3750 + if (err && err != -EOPNOTSUPP) 3753 3751 return err; 3754 3752 } 3755 3753 ··· 3768 3758 vi->intr_coal_rx.max_usecs, 3769 3759 vi->intr_coal_rx.max_packets); 3770 3760 mutex_unlock(&vi->rq[i].dim_lock); 3771 - if (err) 3761 + if (err && err != -EOPNOTSUPP) 3772 3762 return err; 3773 3763 } 3774 3764 }
+3 -1
drivers/pci/hotplug/pciehp_hpc.c
··· 485 485 struct pci_dev *pdev = ctrl_dev(ctrl); 486 486 487 487 pci_config_pm_runtime_get(pdev); 488 - pcie_write_cmd_nowait(ctrl, FIELD_PREP(PCI_EXP_SLTCTL_AIC, status), 488 + 489 + /* Attention and Power Indicator Control bits are supported */ 490 + pcie_write_cmd_nowait(ctrl, FIELD_PREP(PCI_EXP_SLTCTL_AIC | PCI_EXP_SLTCTL_PIC, status), 489 491 PCI_EXP_SLTCTL_AIC | PCI_EXP_SLTCTL_PIC); 490 492 pci_config_pm_runtime_put(pdev); 491 493 return 0;
+8 -7
drivers/pci/pci.c
··· 4477 4477 { 4478 4478 u16 pci_command, new; 4479 4479 4480 - /* Preserve the "hybrid" behavior for backwards compatibility */ 4481 - if (pci_is_managed(pdev)) { 4482 - WARN_ON_ONCE(pcim_intx(pdev, enable) != 0); 4483 - return; 4484 - } 4485 - 4486 4480 pci_read_config_word(pdev, PCI_COMMAND, &pci_command); 4487 4481 4488 4482 if (enable) ··· 4484 4490 else 4485 4491 new = pci_command | PCI_COMMAND_INTX_DISABLE; 4486 4492 4487 - if (new != pci_command) 4493 + if (new != pci_command) { 4494 + /* Preserve the "hybrid" behavior for backwards compatibility */ 4495 + if (pci_is_managed(pdev)) { 4496 + WARN_ON_ONCE(pcim_intx(pdev, enable) != 0); 4497 + return; 4498 + } 4499 + 4488 4500 pci_write_config_word(pdev, PCI_COMMAND, new); 4501 + } 4489 4502 } 4490 4503 EXPORT_SYMBOL_GPL(pci_intx); 4491 4504
+1 -1
drivers/perf/riscv_pmu_sbi.c
··· 416 416 * but not in the user access mode as we want to use the other counters 417 417 * that support sampling/filtering. 418 418 */ 419 - if (hwc->flags & PERF_EVENT_FLAG_LEGACY) { 419 + if ((hwc->flags & PERF_EVENT_FLAG_LEGACY) && (event->attr.type == PERF_TYPE_HARDWARE)) { 420 420 if (event->attr.config == PERF_COUNT_HW_CPU_CYCLES) { 421 421 cflags |= SBI_PMU_CFG_FLAG_SKIP_MATCH; 422 422 cmask = 1;
+2
drivers/platform/x86/amd/pmc/pmc.c
··· 764 764 case AMD_CPU_ID_CB: 765 765 case AMD_CPU_ID_PS: 766 766 case PCI_DEVICE_ID_AMD_1AH_M20H_ROOT: 767 + case PCI_DEVICE_ID_AMD_1AH_M60H_ROOT: 767 768 return MSG_OS_HINT_RN; 768 769 } 769 770 return -EINVAL; ··· 968 967 { PCI_DEVICE(PCI_VENDOR_ID_AMD, AMD_CPU_ID_RV) }, 969 968 { PCI_DEVICE(PCI_VENDOR_ID_AMD, AMD_CPU_ID_SP) }, 970 969 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_1AH_M20H_ROOT) }, 970 + { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_1AH_M60H_ROOT) }, 971 971 { } 972 972 }; 973 973
+1
drivers/platform/x86/amd/pmc/pmc.h
··· 67 67 #define AMD_CPU_ID_PS 0x14E8 68 68 #define AMD_CPU_ID_SP 0x14A4 69 69 #define PCI_DEVICE_ID_AMD_1AH_M20H_ROOT 0x1507 70 + #define PCI_DEVICE_ID_AMD_1AH_M60H_ROOT 0x1122 70 71 #define PCI_DEVICE_ID_AMD_MP2_STB 0x172c 71 72 72 73 #endif /* PMC_H */
+3
drivers/platform/x86/amd/pmf/core.c
··· 41 41 #define AMD_CPU_ID_RMB 0x14b5 42 42 #define AMD_CPU_ID_PS 0x14e8 43 43 #define PCI_DEVICE_ID_AMD_1AH_M20H_ROOT 0x1507 44 + #define PCI_DEVICE_ID_AMD_1AH_M60H_ROOT 0x1122 44 45 45 46 #define PMF_MSG_DELAY_MIN_US 50 46 47 #define RESPONSE_REGISTER_LOOP_MAX 20000 ··· 250 249 { PCI_DEVICE(PCI_VENDOR_ID_AMD, AMD_CPU_ID_RMB) }, 251 250 { PCI_DEVICE(PCI_VENDOR_ID_AMD, AMD_CPU_ID_PS) }, 252 251 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_1AH_M20H_ROOT) }, 252 + { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_1AH_M60H_ROOT) }, 253 253 { } 254 254 }; 255 255 ··· 384 382 {"AMDI0102", 0}, 385 383 {"AMDI0103", 0}, 386 384 {"AMDI0105", 0}, 385 + {"AMDI0107", 0}, 387 386 { } 388 387 }; 389 388 MODULE_DEVICE_TABLE(acpi, amd_pmf_acpi_ids);
+8 -1
drivers/platform/x86/amd/pmf/pmf-quirks.c
··· 29 29 }, 30 30 .driver_data = &quirk_no_sps_bug, 31 31 }, 32 + { 33 + .ident = "ROG Ally X", 34 + .matches = { 35 + DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), 36 + DMI_MATCH(DMI_PRODUCT_NAME, "RC72LA"), 37 + }, 38 + .driver_data = &quirk_no_sps_bug, 39 + }, 32 40 {} 33 41 }; 34 42 ··· 56 48 dmi_id->ident); 57 49 } 58 50 } 59 -
+1 -1
drivers/platform/x86/intel/ifs/runtest.c
··· 221 221 */ 222 222 static void ifs_test_core(int cpu, struct device *dev) 223 223 { 224 + union ifs_status status = {}; 224 225 union ifs_scan activate; 225 - union ifs_status status; 226 226 unsigned long timeout; 227 227 struct ifs_data *ifsd; 228 228 int to_start, to_stop;
+9
drivers/platform/x86/intel/vbtn.c
··· 7 7 */ 8 8 9 9 #include <linux/acpi.h> 10 + #include <linux/cleanup.h> 10 11 #include <linux/dmi.h> 11 12 #include <linux/input.h> 12 13 #include <linux/input/sparse-keymap.h> 13 14 #include <linux/kernel.h> 14 15 #include <linux/module.h> 16 + #include <linux/mutex.h> 15 17 #include <linux/platform_device.h> 16 18 #include <linux/suspend.h> 17 19 #include "../dual_accel_detect.h" ··· 68 66 }; 69 67 70 68 struct intel_vbtn_priv { 69 + struct mutex mutex; /* Avoid notify_handler() racing with itself */ 71 70 struct input_dev *buttons_dev; 72 71 struct input_dev *switches_dev; 73 72 bool dual_accel; ··· 157 154 struct input_dev *input_dev; 158 155 bool autorelease; 159 156 int ret; 157 + 158 + guard(mutex)(&priv->mutex); 160 159 161 160 if ((ke = sparse_keymap_entry_from_scancode(priv->buttons_dev, event))) { 162 161 if (!priv->has_buttons) { ··· 294 289 if (!priv) 295 290 return -ENOMEM; 296 291 dev_set_drvdata(&device->dev, priv); 292 + 293 + err = devm_mutex_init(&device->dev, &priv->mutex); 294 + if (err) 295 + return err; 297 296 298 297 priv->dual_accel = dual_accel; 299 298 priv->has_buttons = has_buttons;
+12 -12
drivers/power/supply/axp288_charger.c
··· 178 178 u8 reg_val; 179 179 int ret; 180 180 181 - if (cv <= CV_4100MV) { 182 - reg_val = CHRG_CCCV_CV_4100MV; 183 - cv = CV_4100MV; 184 - } else if (cv <= CV_4150MV) { 185 - reg_val = CHRG_CCCV_CV_4150MV; 186 - cv = CV_4150MV; 187 - } else if (cv <= CV_4200MV) { 188 - reg_val = CHRG_CCCV_CV_4200MV; 189 - cv = CV_4200MV; 190 - } else { 181 + if (cv >= CV_4350MV) { 191 182 reg_val = CHRG_CCCV_CV_4350MV; 192 183 cv = CV_4350MV; 184 + } else if (cv >= CV_4200MV) { 185 + reg_val = CHRG_CCCV_CV_4200MV; 186 + cv = CV_4200MV; 187 + } else if (cv >= CV_4150MV) { 188 + reg_val = CHRG_CCCV_CV_4150MV; 189 + cv = CV_4150MV; 190 + } else { 191 + reg_val = CHRG_CCCV_CV_4100MV; 192 + cv = CV_4100MV; 193 193 } 194 194 195 195 reg_val = reg_val << CHRG_CCCV_CV_BIT_POS; ··· 337 337 } 338 338 break; 339 339 case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE: 340 - scaled_val = min(val->intval, info->max_cv); 341 - scaled_val = DIV_ROUND_CLOSEST(scaled_val, 1000); 340 + scaled_val = DIV_ROUND_CLOSEST(val->intval, 1000); 341 + scaled_val = min(scaled_val, info->max_cv); 342 342 ret = axp288_charger_set_cv(info, scaled_val); 343 343 if (ret < 0) { 344 344 dev_warn(&info->pdev->dev, "set charge voltage failed\n");
+7 -5
drivers/power/supply/qcom_battmgr.c
··· 486 486 int ret; 487 487 488 488 if (!battmgr->service_up) 489 - return -ENODEV; 489 + return -EAGAIN; 490 490 491 491 if (battmgr->variant == QCOM_BATTMGR_SC8280XP) 492 492 ret = qcom_battmgr_bat_sc8280xp_update(battmgr, psp); ··· 683 683 int ret; 684 684 685 685 if (!battmgr->service_up) 686 - return -ENODEV; 686 + return -EAGAIN; 687 687 688 688 ret = qcom_battmgr_bat_sc8280xp_update(battmgr, psp); 689 689 if (ret) ··· 748 748 int ret; 749 749 750 750 if (!battmgr->service_up) 751 - return -ENODEV; 751 + return -EAGAIN; 752 752 753 753 if (battmgr->variant == QCOM_BATTMGR_SC8280XP) 754 754 ret = qcom_battmgr_bat_sc8280xp_update(battmgr, psp); ··· 867 867 int ret; 868 868 869 869 if (!battmgr->service_up) 870 - return -ENODEV; 870 + return -EAGAIN; 871 871 872 872 if (battmgr->variant == QCOM_BATTMGR_SC8280XP) 873 873 ret = qcom_battmgr_bat_sc8280xp_update(battmgr, psp); ··· 1007 1007 battmgr->error = 0; 1008 1008 break; 1009 1009 case BATTMGR_BAT_INFO: 1010 - if (payload_len != sizeof(resp->info)) { 1010 + /* some firmware versions report an extra __le32 at the end of the payload */ 1011 + if (payload_len != sizeof(resp->info) && 1012 + payload_len != (sizeof(resp->info) + sizeof(__le32))) { 1011 1013 dev_warn(battmgr->dev, 1012 1014 "invalid payload length for battery information request: %zd\n", 1013 1015 payload_len);
+1
drivers/power/supply/rt5033_battery.c
··· 159 159 return -EINVAL; 160 160 } 161 161 162 + i2c_set_clientdata(client, battery); 162 163 psy_cfg.of_node = client->dev.of_node; 163 164 psy_cfg.drv_data = battery; 164 165
+1
drivers/s390/cio/ccwgroup.c
··· 550 550 put_device(&gdev->dev); 551 551 } 552 552 EXPORT_SYMBOL(ccwgroup_remove_ccwdev); 553 + MODULE_DESCRIPTION("ccwgroup bus driver"); 553 554 MODULE_LICENSE("GPL");
+1
drivers/s390/cio/vfio_ccw_drv.c
··· 488 488 module_init(vfio_ccw_sch_init); 489 489 module_exit(vfio_ccw_sch_exit); 490 490 491 + MODULE_DESCRIPTION("VFIO based Subchannel device driver"); 491 492 MODULE_LICENSE("GPL v2");
+11
drivers/scsi/mpi3mr/mpi3mr_os.c
··· 3575 3575 scmd->sc_data_direction); 3576 3576 priv->meta_sg_valid = 1; /* To unmap meta sg DMA */ 3577 3577 } else { 3578 + /* 3579 + * Some firmware versions byte-swap the REPORT ZONES command 3580 + * reply from ATA-ZAC devices by directly accessing in the host 3581 + * buffer. This does not respect the default command DMA 3582 + * direction and causes IOMMU page faults on some architectures 3583 + * with an IOMMU enforcing write mappings (e.g. AMD hosts). 3584 + * Avoid such issue by making the REPORT ZONES buffer mapping 3585 + * bi-directional. 3586 + */ 3587 + if (scmd->cmnd[0] == ZBC_IN && scmd->cmnd[1] == ZI_REPORT_ZONES) 3588 + scmd->sc_data_direction = DMA_BIDIRECTIONAL; 3578 3589 sg_scmd = scsi_sglist(scmd); 3579 3590 sges_left = scsi_dma_map(scmd); 3580 3591 }
+18 -2
drivers/scsi/mpt3sas/mpt3sas_base.c
··· 2671 2671 _base_add_sg_single_ieee(paddr, sgl_flags, 0, 0, -1); 2672 2672 } 2673 2673 2674 + static inline int _base_scsi_dma_map(struct scsi_cmnd *cmd) 2675 + { 2676 + /* 2677 + * Some firmware versions byte-swap the REPORT ZONES command reply from 2678 + * ATA-ZAC devices by directly accessing in the host buffer. This does 2679 + * not respect the default command DMA direction and causes IOMMU page 2680 + * faults on some architectures with an IOMMU enforcing write mappings 2681 + * (e.g. AMD hosts). Avoid such issue by making the report zones buffer 2682 + * mapping bi-directional. 2683 + */ 2684 + if (cmd->cmnd[0] == ZBC_IN && cmd->cmnd[1] == ZI_REPORT_ZONES) 2685 + cmd->sc_data_direction = DMA_BIDIRECTIONAL; 2686 + 2687 + return scsi_dma_map(cmd); 2688 + } 2689 + 2674 2690 /** 2675 2691 * _base_build_sg_scmd - main sg creation routine 2676 2692 * pcie_device is unused here! ··· 2733 2717 sgl_flags = sgl_flags << MPI2_SGE_FLAGS_SHIFT; 2734 2718 2735 2719 sg_scmd = scsi_sglist(scmd); 2736 - sges_left = scsi_dma_map(scmd); 2720 + sges_left = _base_scsi_dma_map(scmd); 2737 2721 if (sges_left < 0) 2738 2722 return -ENOMEM; 2739 2723 ··· 2877 2861 } 2878 2862 2879 2863 sg_scmd = scsi_sglist(scmd); 2880 - sges_left = scsi_dma_map(scmd); 2864 + sges_left = _base_scsi_dma_map(scmd); 2881 2865 if (sges_left < 0) 2882 2866 return -ENOMEM; 2883 2867
+3 -2
drivers/scsi/sd.c
··· 4205 4205 { 4206 4206 struct scsi_disk *sdkp = dev_get_drvdata(dev); 4207 4207 4208 + sd_printk(KERN_NOTICE, sdkp, "Starting disk\n"); 4209 + 4208 4210 if (opal_unlock_from_suspend(sdkp->opal_dev)) { 4209 4211 sd_printk(KERN_NOTICE, sdkp, "OPAL unlock failed\n"); 4210 4212 return -EIO; ··· 4223 4221 if (!sdkp) /* E.g.: runtime resume at the start of sd_probe() */ 4224 4222 return 0; 4225 4223 4226 - sd_printk(KERN_NOTICE, sdkp, "Starting disk\n"); 4227 - 4228 4224 if (!sd_do_start_stop(sdkp->device, runtime)) { 4229 4225 sdkp->suspended = false; 4230 4226 return 0; 4231 4227 } 4232 4228 4229 + sd_printk(KERN_NOTICE, sdkp, "Starting disk\n"); 4233 4230 ret = sd_start_stop_device(sdkp, 1); 4234 4231 if (!ret) { 4235 4232 sd_resume(dev);
+22 -7
drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c
··· 278 278 279 279 static bool msi_irq; 280 280 281 + static void proc_thermal_free_msi(struct pci_dev *pdev, struct proc_thermal_pci *pci_info) 282 + { 283 + int i; 284 + 285 + for (i = 0; i < MSI_THERMAL_MAX; i++) { 286 + if (proc_thermal_msi_map[i]) 287 + devm_free_irq(&pdev->dev, proc_thermal_msi_map[i], pci_info); 288 + } 289 + 290 + pci_free_irq_vectors(pdev); 291 + } 292 + 281 293 static int proc_thermal_setup_msi(struct pci_dev *pdev, struct proc_thermal_pci *pci_info) 282 294 { 283 - int ret, i, irq; 295 + int ret, i, irq, count; 284 296 285 - ret = pci_alloc_irq_vectors(pdev, 1, MSI_THERMAL_MAX, PCI_IRQ_MSI | PCI_IRQ_MSIX); 286 - if (ret < 0) { 297 + count = pci_alloc_irq_vectors(pdev, 1, MSI_THERMAL_MAX, PCI_IRQ_MSI | PCI_IRQ_MSIX); 298 + if (count < 0) { 287 299 dev_err(&pdev->dev, "Failed to allocate vectors!\n"); 288 - return ret; 300 + return count; 289 301 } 290 302 291 303 dev_info(&pdev->dev, "msi enabled:%d msix enabled:%d\n", pdev->msi_enabled, 292 304 pdev->msix_enabled); 293 305 294 - for (i = 0; i < MSI_THERMAL_MAX; i++) { 306 + for (i = 0; i < count; i++) { 295 307 irq = pci_irq_vector(pdev, i); 296 308 297 309 ret = devm_request_threaded_irq(&pdev->dev, irq, proc_thermal_irq_handler, ··· 322 310 return 0; 323 311 324 312 err_free_msi_vectors: 325 - pci_free_irq_vectors(pdev); 313 + proc_thermal_free_msi(pdev, pci_info); 326 314 327 315 return ret; 328 316 } ··· 409 397 410 398 err_free_vectors: 411 399 if (msi_irq) 412 - pci_free_irq_vectors(pdev); 400 + proc_thermal_free_msi(pdev, pci_info); 413 401 err_ret_tzone: 414 402 thermal_zone_device_unregister(pci_info->tzone); 415 403 err_del_legacy: ··· 430 418 431 419 proc_thermal_mmio_write(pci_info, PROC_THERMAL_MMIO_THRES_0, 0); 432 420 proc_thermal_mmio_write(pci_info, PROC_THERMAL_MMIO_INT_ENABLE_0, 0); 421 + 422 + if (msi_irq) 423 + proc_thermal_free_msi(pdev, pci_info); 433 424 434 425 thermal_zone_device_unregister(pci_info->tzone); 435 426 proc_thermal_mmio_remove(pdev, pci_info->proc_priv);
+2 -2
drivers/thermal/thermal_trip.c
··· 88 88 return; 89 89 90 90 for_each_trip_desc(tz, td) { 91 - if (td->threshold < tz->temperature && td->threshold > low) 91 + if (td->threshold <= tz->temperature && td->threshold > low) 92 92 low = td->threshold; 93 93 94 - if (td->threshold > tz->temperature && td->threshold < high) 94 + if (td->threshold >= tz->temperature && td->threshold < high) 95 95 high = td->threshold; 96 96 } 97 97
+5
drivers/ufs/core/ufshcd-priv.h
··· 316 316 return pm_runtime_get_sync(&hba->ufs_device_wlun->sdev_gendev); 317 317 } 318 318 319 + static inline int ufshcd_rpm_get_if_active(struct ufs_hba *hba) 320 + { 321 + return pm_runtime_get_if_active(&hba->ufs_device_wlun->sdev_gendev); 322 + } 323 + 319 324 static inline int ufshcd_rpm_put_sync(struct ufs_hba *hba) 320 325 { 321 326 return pm_runtime_put_sync(&hba->ufs_device_wlun->sdev_gendev);
+22 -5
drivers/ufs/core/ufshcd.c
··· 2416 2416 return err; 2417 2417 } 2418 2418 2419 + /* 2420 + * The UFSHCI 3.0 specification does not define MCQ_SUPPORT and 2421 + * LSDB_SUPPORT, but [31:29] as reserved bits with reset value 0s, which 2422 + * means we can simply read values regardless of version. 2423 + */ 2419 2424 hba->mcq_sup = FIELD_GET(MASK_MCQ_SUPPORT, hba->capabilities); 2425 + /* 2426 + * 0h: legacy single doorbell support is available 2427 + * 1h: indicate that legacy single doorbell support has been removed 2428 + */ 2429 + hba->lsdb_sup = !FIELD_GET(MASK_LSDB_SUPPORT, hba->capabilities); 2420 2430 if (!hba->mcq_sup) 2421 2431 return 0; 2422 2432 ··· 6563 6553 if (ufshcd_err_handling_should_stop(hba)) 6564 6554 goto skip_err_handling; 6565 6555 6566 - if (hba->dev_quirks & UFS_DEVICE_QUIRK_RECOVERY_FROM_DL_NAC_ERRORS) { 6556 + if ((hba->dev_quirks & UFS_DEVICE_QUIRK_RECOVERY_FROM_DL_NAC_ERRORS) && 6557 + !hba->force_reset) { 6567 6558 bool ret; 6568 6559 6569 6560 spin_unlock_irqrestore(hba->host->host_lock, flags); ··· 8222 8211 */ 8223 8212 val = ts64.tv_sec - hba->dev_info.rtc_time_baseline; 8224 8213 8225 - ufshcd_rpm_get_sync(hba); 8214 + /* Skip update RTC if RPM state is not RPM_ACTIVE */ 8215 + if (ufshcd_rpm_get_if_active(hba) <= 0) 8216 + return; 8217 + 8226 8218 err = ufshcd_query_attr(hba, UPIU_QUERY_OPCODE_WRITE_ATTR, QUERY_ATTR_IDN_SECONDS_PASSED, 8227 8219 0, 0, &val); 8228 8220 ufshcd_rpm_put_sync(hba); ··· 10279 10265 */ 10280 10266 ufshcd_readl(hba, REG_UTP_TASK_REQ_LIST_BASE_H); 10281 10267 10282 - /* Resuming from hibernate, assume that link was OFF */ 10283 - ufshcd_set_link_off(hba); 10284 - 10285 10268 return 0; 10286 10269 10287 10270 } ··· 10507 10496 } 10508 10497 10509 10498 if (!is_mcq_supported(hba)) { 10499 + if (!hba->lsdb_sup) { 10500 + dev_err(hba->dev, "%s: failed to initialize (legacy doorbell mode not supported)\n", 10501 + __func__); 10502 + err = -EINVAL; 10503 + goto out_disable; 10504 + } 10510 10505 err = scsi_add_host(host, hba->dev); 10511 10506 if (err) { 10512 10507 dev_err(hba->dev, "scsi_add_host failed\n");
+3
drivers/ufs/host/ufs-exynos.c
··· 1293 1293 { 1294 1294 struct arm_smccc_res res; 1295 1295 1296 + if (!(hba->caps & UFSHCD_CAP_CRYPTO)) 1297 + return; 1298 + 1296 1299 arm_smccc_smc(SMC_CMD_FMP_SECURITY, 0, SMU_EMBEDDED, CFG_DESCTYPE_3, 1297 1300 0, 0, 0, 0, &res); 1298 1301 if (res.a0)
+1 -7
drivers/vhost/vdpa.c
··· 1481 1481 1482 1482 notify = ops->get_vq_notification(vdpa, index); 1483 1483 1484 - vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); 1485 - if (remap_pfn_range(vma, vmf->address & PAGE_MASK, 1486 - PFN_DOWN(notify.addr), PAGE_SIZE, 1487 - vma->vm_page_prot)) 1488 - return VM_FAULT_SIGBUS; 1489 - 1490 - return VM_FAULT_NOPAGE; 1484 + return vmf_insert_pfn(vma, vmf->address & PAGE_MASK, PFN_DOWN(notify.addr)); 1491 1485 } 1492 1486 1493 1487 static const struct vm_operations_struct vhost_vdpa_vm_ops = {
+10 -2
fs/bcachefs/alloc_background.h
··· 82 82 bucket_data_type(bucket) != bucket_data_type(ptr); 83 83 } 84 84 85 + /* 86 + * It is my general preference to use unsigned types for unsigned quantities - 87 + * however, these helpers are used in disk accounting calculations run by 88 + * triggers where the output will be negated and added to an s64. unsigned is 89 + * right out even though all these quantities will fit in 32 bits, since it 90 + * won't be sign extended correctly; u64 will negate "correctly", but s64 is the 91 + * simpler option here. 92 + */ 85 93 static inline s64 bch2_bucket_sectors_total(struct bch_alloc_v4 a) 86 94 { 87 95 return a.stripe_sectors + a.dirty_sectors + a.cached_sectors; ··· 174 166 * avoid overflowing LRU_TIME_BITS on a corrupted fs, when 175 167 * bucket_sectors_dirty is (much) bigger than bucket_size 176 168 */ 177 - u64 d = min(bch2_bucket_sectors_dirty(a), 178 - ca->mi.bucket_size); 169 + u64 d = min_t(s64, bch2_bucket_sectors_dirty(a), 170 + ca->mi.bucket_size); 179 171 180 172 return div_u64(d * (1ULL << 31), ca->mi.bucket_size); 181 173 }
+28 -4
fs/bcachefs/alloc_foreground.c
··· 1603 1603 prt_newline(out); 1604 1604 } 1605 1605 1606 - void bch2_open_buckets_to_text(struct printbuf *out, struct bch_fs *c) 1606 + void bch2_open_buckets_to_text(struct printbuf *out, struct bch_fs *c, 1607 + struct bch_dev *ca) 1607 1608 { 1608 1609 struct open_bucket *ob; 1609 1610 ··· 1614 1613 ob < c->open_buckets + ARRAY_SIZE(c->open_buckets); 1615 1614 ob++) { 1616 1615 spin_lock(&ob->lock); 1617 - if (ob->valid && !ob->on_partial_list) 1616 + if (ob->valid && !ob->on_partial_list && 1617 + (!ca || ob->dev == ca->dev_idx)) 1618 1618 bch2_open_bucket_to_text(out, c, ob); 1619 1619 spin_unlock(&ob->lock); 1620 1620 } ··· 1758 1756 prt_printf(out, "buckets to invalidate\t%llu\r\n", should_invalidate_buckets(ca, stats)); 1759 1757 } 1760 1758 1761 - void bch2_print_allocator_stuck(struct bch_fs *c) 1759 + static noinline void bch2_print_allocator_stuck(struct bch_fs *c) 1762 1760 { 1763 1761 struct printbuf buf = PRINTBUF; 1764 1762 1765 - prt_printf(&buf, "Allocator stuck? Waited for 10 seconds\n"); 1763 + prt_printf(&buf, "Allocator stuck? Waited for %u seconds\n", 1764 + c->opts.allocator_stuck_timeout); 1766 1765 1767 1766 prt_printf(&buf, "Allocator debug:\n"); 1768 1767 printbuf_indent_add(&buf, 2); ··· 1792 1789 1793 1790 bch2_print_string_as_lines(KERN_ERR, buf.buf); 1794 1791 printbuf_exit(&buf); 1792 + } 1793 + 1794 + static inline unsigned allocator_wait_timeout(struct bch_fs *c) 1795 + { 1796 + if (c->allocator_last_stuck && 1797 + time_after(c->allocator_last_stuck + HZ * 60 * 2, jiffies)) 1798 + return 0; 1799 + 1800 + return c->opts.allocator_stuck_timeout * HZ; 1801 + } 1802 + 1803 + void __bch2_wait_on_allocator(struct bch_fs *c, struct closure *cl) 1804 + { 1805 + unsigned t = allocator_wait_timeout(c); 1806 + 1807 + if (t && closure_sync_timeout(cl, t)) { 1808 + c->allocator_last_stuck = jiffies; 1809 + bch2_print_allocator_stuck(c); 1810 + } 1811 + 1812 + closure_sync(cl); 1795 1813 }
+7 -2
fs/bcachefs/alloc_foreground.h
··· 223 223 void bch2_fs_allocator_foreground_init(struct bch_fs *); 224 224 225 225 void bch2_open_bucket_to_text(struct printbuf *, struct bch_fs *, struct open_bucket *); 226 - void bch2_open_buckets_to_text(struct printbuf *, struct bch_fs *); 226 + void bch2_open_buckets_to_text(struct printbuf *, struct bch_fs *, struct bch_dev *); 227 227 void bch2_open_buckets_partial_to_text(struct printbuf *, struct bch_fs *); 228 228 229 229 void bch2_write_points_to_text(struct printbuf *, struct bch_fs *); ··· 231 231 void bch2_fs_alloc_debug_to_text(struct printbuf *, struct bch_fs *); 232 232 void bch2_dev_alloc_debug_to_text(struct printbuf *, struct bch_dev *); 233 233 234 - void bch2_print_allocator_stuck(struct bch_fs *); 234 + void __bch2_wait_on_allocator(struct bch_fs *, struct closure *); 235 + static inline void bch2_wait_on_allocator(struct bch_fs *c, struct closure *cl) 236 + { 237 + if (cl->closure_get_happened) 238 + __bch2_wait_on_allocator(c, cl); 239 + } 235 240 236 241 #endif /* _BCACHEFS_ALLOC_FOREGROUND_H */
+2
fs/bcachefs/bcachefs.h
··· 893 893 struct bch_fs_usage_base __percpu *usage; 894 894 u64 __percpu *online_reserved; 895 895 896 + unsigned long allocator_last_stuck; 897 + 896 898 struct io_clock io_clock[2]; 897 899 898 900 /* JOURNAL SEQ BLACKLIST */
+2
fs/bcachefs/bcachefs_format.h
··· 836 836 837 837 LE64_BITMASK(BCH_SB_VERSION_UPGRADE_COMPLETE, 838 838 struct bch_sb, flags[5], 0, 16); 839 + LE64_BITMASK(BCH_SB_ALLOCATOR_STUCK_TIMEOUT, 840 + struct bch_sb, flags[5], 16, 32); 839 841 840 842 static inline __u64 BCH_SB_COMPRESSION_TYPE(const struct bch_sb *sb) 841 843 {
+5
fs/bcachefs/btree_iter.c
··· 1921 1921 bch2_trans_verify_not_in_restart(trans); 1922 1922 bch2_btree_iter_verify(iter); 1923 1923 1924 + ret = bch2_btree_path_traverse(trans, iter->path, iter->flags); 1925 + if (ret) 1926 + goto err; 1927 + 1928 + 1924 1929 struct btree_path *path = btree_iter_path(trans, iter); 1925 1930 1926 1931 /* already at end? */
+1 -1
fs/bcachefs/btree_update_interior.c
··· 1264 1264 ret = bch2_btree_reserve_get(trans, as, nr_nodes, flags, &cl); 1265 1265 1266 1266 bch2_trans_unlock(trans); 1267 - closure_sync(&cl); 1267 + bch2_wait_on_allocator(c, &cl); 1268 1268 } while (bch2_err_matches(ret, BCH_ERR_operation_blocked)); 1269 1269 } 1270 1270
+23 -11
fs/bcachefs/ec.c
··· 1809 1809 BUG_ON(v->nr_blocks != h->s->nr_data + h->s->nr_parity); 1810 1810 BUG_ON(v->nr_redundant != h->s->nr_parity); 1811 1811 1812 + /* * We bypass the sector allocator which normally does this: */ 1813 + bitmap_and(devs.d, devs.d, c->rw_devs[BCH_DATA_user].d, BCH_SB_MEMBERS_MAX); 1814 + 1812 1815 for_each_set_bit(i, h->s->blocks_gotten, v->nr_blocks) { 1813 1816 __clear_bit(v->ptrs[i].dev, devs.d); 1814 1817 if (i < h->s->nr_data) ··· 2238 2235 mutex_unlock(&c->ec_stripes_heap_lock); 2239 2236 } 2240 2237 2238 + static void bch2_new_stripe_to_text(struct printbuf *out, struct bch_fs *c, 2239 + struct ec_stripe_new *s) 2240 + { 2241 + prt_printf(out, "\tidx %llu blocks %u+%u allocated %u ref %u %u %s obs", 2242 + s->idx, s->nr_data, s->nr_parity, 2243 + bitmap_weight(s->blocks_allocated, s->nr_data), 2244 + atomic_read(&s->ref[STRIPE_REF_io]), 2245 + atomic_read(&s->ref[STRIPE_REF_stripe]), 2246 + bch2_watermarks[s->h->watermark]); 2247 + 2248 + struct bch_stripe *v = &bkey_i_to_stripe(&s->new_stripe.key)->v; 2249 + unsigned i; 2250 + for_each_set_bit(i, s->blocks_gotten, v->nr_blocks) 2251 + prt_printf(out, " %u", s->blocks[i]); 2252 + prt_newline(out); 2253 + } 2254 + 2241 2255 void bch2_new_stripes_to_text(struct printbuf *out, struct bch_fs *c) 2242 2256 { 2243 2257 struct ec_stripe_head *h; ··· 2267 2247 bch2_watermarks[h->watermark]); 2268 2248 2269 2249 if (h->s) 2270 - prt_printf(out, "\tidx %llu blocks %u+%u allocated %u\n", 2271 - h->s->idx, h->s->nr_data, h->s->nr_parity, 2272 - bitmap_weight(h->s->blocks_allocated, 2273 - h->s->nr_data)); 2250 + bch2_new_stripe_to_text(out, c, h->s); 2274 2251 } 2275 2252 mutex_unlock(&c->ec_stripe_head_lock); 2276 2253 2277 2254 prt_printf(out, "in flight:\n"); 2278 2255 2279 2256 mutex_lock(&c->ec_stripe_new_lock); 2280 - list_for_each_entry(s, &c->ec_stripe_new_list, list) { 2281 - prt_printf(out, "\tidx %llu blocks %u+%u ref %u %u %s\n", 2282 - s->idx, s->nr_data, s->nr_parity, 2283 - atomic_read(&s->ref[STRIPE_REF_io]), 2284 - atomic_read(&s->ref[STRIPE_REF_stripe]), 2285 - bch2_watermarks[s->h->watermark]); 2286 - } 2257 + list_for_each_entry(s, &c->ec_stripe_new_list, list) 2258 + bch2_new_stripe_to_text(out, c, s); 2287 2259 mutex_unlock(&c->ec_stripe_new_lock); 2288 2260 } 2289 2261
+1 -5
fs/bcachefs/io_misc.c
··· 126 126 127 127 if (closure_nr_remaining(&cl) != 1) { 128 128 bch2_trans_unlock_long(trans); 129 - 130 - if (closure_sync_timeout(&cl, HZ * 10)) { 131 - bch2_print_allocator_stuck(c); 132 - closure_sync(&cl); 133 - } 129 + bch2_wait_on_allocator(c, &cl); 134 130 } 135 131 136 132 return ret;
+1
fs/bcachefs/io_read.c
··· 406 406 bch2_trans_iter_init(trans, &iter, rbio->data_btree, 407 407 rbio->read_pos, BTREE_ITER_slots); 408 408 retry: 409 + bch2_trans_begin(trans); 409 410 rbio->bio.bi_status = 0; 410 411 411 412 k = bch2_btree_iter_peek_slot(&iter);
+1 -4
fs/bcachefs/io_write.c
··· 1503 1503 if ((op->flags & BCH_WRITE_SYNC) || 1504 1504 (!(op->flags & BCH_WRITE_SUBMITTED) && 1505 1505 !(op->flags & BCH_WRITE_IN_WORKER))) { 1506 - if (closure_sync_timeout(&op->cl, HZ * 10)) { 1507 - bch2_print_allocator_stuck(c); 1508 - closure_sync(&op->cl); 1509 - } 1506 + bch2_wait_on_allocator(c, &op->cl); 1510 1507 1511 1508 __bch2_write_index(op); 1512 1509
+5
fs/bcachefs/opts.h
··· 391 391 OPT_BOOL(), \ 392 392 BCH_SB_JOURNAL_TRANSACTION_NAMES, true, \ 393 393 NULL, "Log transaction function names in journal") \ 394 + x(allocator_stuck_timeout, u16, \ 395 + OPT_FS|OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME, \ 396 + OPT_UINT(0, U16_MAX), \ 397 + BCH_SB_ALLOCATOR_STUCK_TIMEOUT, 30, \ 398 + NULL, "Default timeout in seconds for stuck allocator messages")\ 394 399 x(noexcl, u8, \ 395 400 OPT_FS|OPT_MOUNT, \ 396 401 OPT_BOOL(), \
+4
fs/bcachefs/super-io.c
··· 414 414 415 415 if (!BCH_SB_VERSION_UPGRADE_COMPLETE(sb)) 416 416 SET_BCH_SB_VERSION_UPGRADE_COMPLETE(sb, le16_to_cpu(sb->version)); 417 + 418 + if (le16_to_cpu(sb->version) <= bcachefs_metadata_version_disk_accounting_v2 && 419 + !BCH_SB_ALLOCATOR_STUCK_TIMEOUT(sb)) 420 + SET_BCH_SB_ALLOCATOR_STUCK_TIMEOUT(sb, 30); 417 421 } 418 422 419 423 for (opt_id = 0; opt_id < bch2_opts_nr; opt_id++) {
-1
fs/bcachefs/super.c
··· 1193 1193 if (ca->kobj.state_in_sysfs) 1194 1194 kobject_del(&ca->kobj); 1195 1195 1196 - kfree(ca->buckets_nouse); 1197 1196 bch2_free_super(&ca->disk_sb); 1198 1197 bch2_dev_allocator_background_exit(ca); 1199 1198 bch2_dev_journal_exit(ca);
+5 -1
fs/bcachefs/sysfs.c
··· 367 367 bch2_stripes_heap_to_text(out, c); 368 368 369 369 if (attr == &sysfs_open_buckets) 370 - bch2_open_buckets_to_text(out, c); 370 + bch2_open_buckets_to_text(out, c, NULL); 371 371 372 372 if (attr == &sysfs_open_buckets_partial) 373 373 bch2_open_buckets_partial_to_text(out, c); ··· 811 811 if (attr == &sysfs_alloc_debug) 812 812 bch2_dev_alloc_debug_to_text(out, ca); 813 813 814 + if (attr == &sysfs_open_buckets) 815 + bch2_open_buckets_to_text(out, c, ca); 816 + 814 817 return 0; 815 818 } 816 819 ··· 895 892 896 893 /* debug: */ 897 894 &sysfs_alloc_debug, 895 + &sysfs_open_buckets, 898 896 NULL 899 897 }; 900 898
+4 -1
fs/btrfs/file.c
··· 1868 1868 1869 1869 out_release_extents: 1870 1870 btrfs_release_log_ctx_extents(&ctx); 1871 - btrfs_inode_unlock(inode, BTRFS_ILOCK_MMAP); 1871 + if (skip_ilock) 1872 + up_write(&inode->i_mmap_lock); 1873 + else 1874 + btrfs_inode_unlock(inode, BTRFS_ILOCK_MMAP); 1872 1875 goto out; 1873 1876 } 1874 1877
+10
fs/btrfs/inode.c
··· 1585 1585 locked_page, &cached, 1586 1586 clear_bits, 1587 1587 page_ops); 1588 + btrfs_qgroup_free_data(inode, NULL, start, cur_alloc_size, NULL); 1588 1589 start += cur_alloc_size; 1589 1590 } 1590 1591 ··· 1599 1598 clear_bits |= EXTENT_CLEAR_DATA_RESV; 1600 1599 extent_clear_unlock_delalloc(inode, start, end, locked_page, 1601 1600 &cached, clear_bits, page_ops); 1601 + btrfs_qgroup_free_data(inode, NULL, start, cur_alloc_size, NULL); 1602 1602 } 1603 1603 return ret; 1604 1604 } ··· 2261 2259 EXTENT_DO_ACCOUNTING, PAGE_UNLOCK | 2262 2260 PAGE_START_WRITEBACK | 2263 2261 PAGE_END_WRITEBACK); 2262 + btrfs_qgroup_free_data(inode, NULL, cur_offset, end - cur_offset + 1, NULL); 2264 2263 } 2265 2264 btrfs_free_path(path); 2266 2265 return ret; ··· 7205 7202 spin_unlock_irq(&subpage->lock); 7206 7203 } 7207 7204 7205 + static int btrfs_launder_folio(struct folio *folio) 7206 + { 7207 + return btrfs_qgroup_free_data(folio_to_inode(folio), NULL, folio_pos(folio), 7208 + PAGE_SIZE, NULL); 7209 + } 7210 + 7208 7211 static bool __btrfs_release_folio(struct folio *folio, gfp_t gfp_flags) 7209 7212 { 7210 7213 if (try_release_extent_mapping(&folio->page, gfp_flags)) { ··· 10146 10137 .writepages = btrfs_writepages, 10147 10138 .readahead = btrfs_readahead, 10148 10139 .invalidate_folio = btrfs_invalidate_folio, 10140 + .launder_folio = btrfs_launder_folio, 10149 10141 .release_folio = btrfs_release_folio, 10150 10142 .migrate_folio = btrfs_migrate_folio, 10151 10143 .dirty_folio = filemap_dirty_folio,
+1 -1
fs/btrfs/print-tree.c
··· 14 14 15 15 struct root_name_map { 16 16 u64 id; 17 - char name[16]; 17 + const char *name; 18 18 }; 19 19 20 20 static const struct root_name_map root_map[] = {
+19 -6
fs/btrfs/scrub.c
··· 1648 1648 } 1649 1649 } 1650 1650 1651 + static u32 stripe_length(const struct scrub_stripe *stripe) 1652 + { 1653 + ASSERT(stripe->bg); 1654 + 1655 + return min(BTRFS_STRIPE_LEN, 1656 + stripe->bg->start + stripe->bg->length - stripe->logical); 1657 + } 1658 + 1651 1659 static void scrub_submit_extent_sector_read(struct scrub_ctx *sctx, 1652 1660 struct scrub_stripe *stripe) 1653 1661 { 1654 1662 struct btrfs_fs_info *fs_info = stripe->bg->fs_info; 1655 1663 struct btrfs_bio *bbio = NULL; 1656 - unsigned int nr_sectors = min(BTRFS_STRIPE_LEN, stripe->bg->start + 1657 - stripe->bg->length - stripe->logical) >> 1658 - fs_info->sectorsize_bits; 1664 + unsigned int nr_sectors = stripe_length(stripe) >> fs_info->sectorsize_bits; 1659 1665 u64 stripe_len = BTRFS_STRIPE_LEN; 1660 1666 int mirror = stripe->mirror_num; 1661 1667 int i; ··· 1735 1729 { 1736 1730 struct btrfs_fs_info *fs_info = sctx->fs_info; 1737 1731 struct btrfs_bio *bbio; 1738 - unsigned int nr_sectors = min(BTRFS_STRIPE_LEN, stripe->bg->start + 1739 - stripe->bg->length - stripe->logical) >> 1740 - fs_info->sectorsize_bits; 1732 + unsigned int nr_sectors = stripe_length(stripe) >> fs_info->sectorsize_bits; 1741 1733 int mirror = stripe->mirror_num; 1742 1734 1743 1735 ASSERT(stripe->bg); ··· 1875 1871 stripe = &sctx->stripes[i]; 1876 1872 1877 1873 wait_scrub_stripe_io(stripe); 1874 + spin_lock(&sctx->stat_lock); 1875 + sctx->stat.last_physical = stripe->physical + stripe_length(stripe); 1876 + spin_unlock(&sctx->stat_lock); 1878 1877 scrub_reset_stripe(stripe); 1879 1878 } 1880 1879 out: ··· 2146 2139 cur_physical, &found_logical); 2147 2140 if (ret > 0) { 2148 2141 /* No more extent, just update the accounting */ 2142 + spin_lock(&sctx->stat_lock); 2149 2143 sctx->stat.last_physical = physical + logical_length; 2144 + spin_unlock(&sctx->stat_lock); 2150 2145 ret = 0; 2151 2146 break; 2152 2147 } ··· 2345 2336 stripe_logical += chunk_logical; 2346 2337 ret = scrub_raid56_parity_stripe(sctx, scrub_dev, bg, 2347 2338 map, stripe_logical); 2339 + spin_lock(&sctx->stat_lock); 2340 + sctx->stat.last_physical = min(physical + BTRFS_STRIPE_LEN, 2341 + physical_end); 2342 + spin_unlock(&sctx->stat_lock); 2348 2343 if (ret) 2349 2344 goto out; 2350 2345 goto next;
+4 -1
fs/btrfs/super.c
··· 683 683 ret = false; 684 684 685 685 if (!test_bit(BTRFS_FS_STATE_REMOUNTING, &info->fs_state)) { 686 - if (btrfs_raw_test_opt(*mount_opt, SPACE_CACHE)) 686 + if (btrfs_raw_test_opt(*mount_opt, SPACE_CACHE)) { 687 687 btrfs_info(info, "disk space caching is enabled"); 688 + btrfs_warn(info, 689 + "space cache v1 is being deprecated and will be removed in a future release, please use -o space_cache=v2"); 690 + } 688 691 if (btrfs_raw_test_opt(*mount_opt, FREE_SPACE_TREE)) 689 692 btrfs_info(info, "using free-space-tree"); 690 693 }
+24 -11
fs/ceph/caps.c
··· 2016 2016 * CHECK_CAPS_AUTHONLY - we should only check the auth cap 2017 2017 * CHECK_CAPS_FLUSH - we should flush any dirty caps immediately, without 2018 2018 * further delay. 2019 + * CHECK_CAPS_FLUSH_FORCE - we should flush any caps immediately, without 2020 + * further delay. 2019 2021 */ 2020 2022 void ceph_check_caps(struct ceph_inode_info *ci, int flags) 2021 2023 { ··· 2099 2097 } 2100 2098 2101 2099 doutc(cl, "%p %llx.%llx file_want %s used %s dirty %s " 2102 - "flushing %s issued %s revoking %s retain %s %s%s%s\n", 2100 + "flushing %s issued %s revoking %s retain %s %s%s%s%s\n", 2103 2101 inode, ceph_vinop(inode), ceph_cap_string(file_wanted), 2104 2102 ceph_cap_string(used), ceph_cap_string(ci->i_dirty_caps), 2105 2103 ceph_cap_string(ci->i_flushing_caps), ··· 2107 2105 ceph_cap_string(retain), 2108 2106 (flags & CHECK_CAPS_AUTHONLY) ? " AUTHONLY" : "", 2109 2107 (flags & CHECK_CAPS_FLUSH) ? " FLUSH" : "", 2110 - (flags & CHECK_CAPS_NOINVAL) ? " NOINVAL" : ""); 2108 + (flags & CHECK_CAPS_NOINVAL) ? " NOINVAL" : "", 2109 + (flags & CHECK_CAPS_FLUSH_FORCE) ? " FLUSH_FORCE" : ""); 2111 2110 2112 2111 /* 2113 2112 * If we no longer need to hold onto old our caps, and we may ··· 2181 2178 if (S_ISREG(inode->i_mode) && ci->i_wrbuffer_ref && 2182 2179 (revoking & CEPH_CAP_FILE_BUFFER)) 2183 2180 queue_writeback = true; 2181 + } 2182 + 2183 + if (flags & CHECK_CAPS_FLUSH_FORCE) { 2184 + doutc(cl, "force to flush caps\n"); 2185 + goto ack; 2184 2186 } 2185 2187 2186 2188 if (cap == ci->i_auth_cap && ··· 3518 3510 bool queue_invalidate = false; 3519 3511 bool deleted_inode = false; 3520 3512 bool fill_inline = false; 3513 + bool revoke_wait = false; 3514 + int flags = 0; 3521 3515 3522 3516 /* 3523 3517 * If there is at least one crypto block then we'll trust ··· 3715 3705 ceph_cap_string(cap->issued), ceph_cap_string(newcaps), 3716 3706 ceph_cap_string(revoking)); 3717 3707 if (S_ISREG(inode->i_mode) && 3718 - (revoking & used & CEPH_CAP_FILE_BUFFER)) 3708 + (revoking & used & CEPH_CAP_FILE_BUFFER)) { 3719 3709 writeback = true; /* initiate writeback; will delay ack */ 3720 - else if (queue_invalidate && 3710 + revoke_wait = true; 3711 + } else if (queue_invalidate && 3721 3712 revoking == CEPH_CAP_FILE_CACHE && 3722 - (newcaps & CEPH_CAP_FILE_LAZYIO) == 0) 3723 - ; /* do nothing yet, invalidation will be queued */ 3724 - else if (cap == ci->i_auth_cap) 3713 + (newcaps & CEPH_CAP_FILE_LAZYIO) == 0) { 3714 + revoke_wait = true; /* do nothing yet, invalidation will be queued */ 3715 + } else if (cap == ci->i_auth_cap) { 3725 3716 check_caps = 1; /* check auth cap only */ 3726 - else 3717 + } else { 3727 3718 check_caps = 2; /* check all caps */ 3719 + } 3728 3720 /* If there is new caps, try to wake up the waiters */ 3729 3721 if (~cap->issued & newcaps) 3730 3722 wake = true; ··· 3753 3741 BUG_ON(cap->issued & ~cap->implemented); 3754 3742 3755 3743 /* don't let check_caps skip sending a response to MDS for revoke msgs */ 3756 - if (le32_to_cpu(grant->op) == CEPH_CAP_OP_REVOKE) { 3744 + if (!revoke_wait && le32_to_cpu(grant->op) == CEPH_CAP_OP_REVOKE) { 3757 3745 cap->mds_wanted = 0; 3746 + flags |= CHECK_CAPS_FLUSH_FORCE; 3758 3747 if (cap == ci->i_auth_cap) 3759 3748 check_caps = 1; /* check auth cap only */ 3760 3749 else ··· 3811 3798 3812 3799 mutex_unlock(&session->s_mutex); 3813 3800 if (check_caps == 1) 3814 - ceph_check_caps(ci, CHECK_CAPS_AUTHONLY | CHECK_CAPS_NOINVAL); 3801 + ceph_check_caps(ci, flags | CHECK_CAPS_AUTHONLY | CHECK_CAPS_NOINVAL); 3815 3802 else if (check_caps == 2) 3816 - ceph_check_caps(ci, CHECK_CAPS_NOINVAL); 3803 + ceph_check_caps(ci, flags | CHECK_CAPS_NOINVAL); 3817 3804 } 3818 3805 3819 3806 /*
+4 -3
fs/ceph/super.h
··· 200 200 struct list_head caps_item; 201 201 }; 202 202 203 - #define CHECK_CAPS_AUTHONLY 1 /* only check auth cap */ 204 - #define CHECK_CAPS_FLUSH 2 /* flush any dirty caps */ 205 - #define CHECK_CAPS_NOINVAL 4 /* don't invalidate pagecache */ 203 + #define CHECK_CAPS_AUTHONLY 1 /* only check auth cap */ 204 + #define CHECK_CAPS_FLUSH 2 /* flush any dirty caps */ 205 + #define CHECK_CAPS_NOINVAL 4 /* don't invalidate pagecache */ 206 + #define CHECK_CAPS_FLUSH_FORCE 8 /* force flush any caps */ 206 207 207 208 struct ceph_cap_flush { 208 209 u64 tid;
+1
fs/file.c
··· 1248 1248 * tables and this condition does not arise without those. 1249 1249 */ 1250 1250 fdt = files_fdtable(files); 1251 + fd = array_index_nospec(fd, fdt->max_fds); 1251 1252 tofree = fdt->fd[fd]; 1252 1253 if (!tofree && fd_is_open(fd, fdt)) 1253 1254 goto Ebusy;
+2 -2
fs/smb/client/cifsfs.h
··· 147 147 #endif /* CONFIG_CIFS_NFSD_EXPORT */ 148 148 149 149 /* when changing internal version - update following two lines at same time */ 150 - #define SMB3_PRODUCT_BUILD 49 151 - #define CIFS_VERSION "2.49" 150 + #define SMB3_PRODUCT_BUILD 50 151 + #define CIFS_VERSION "2.50" 152 152 #endif /* _CIFSFS_H */
-24
fs/smb/client/cifsglob.h
··· 1471 1471 struct TCP_Server_Info *server; 1472 1472 }; 1473 1473 1474 - struct cifs_aio_ctx { 1475 - struct kref refcount; 1476 - struct list_head list; 1477 - struct mutex aio_mutex; 1478 - struct completion done; 1479 - struct iov_iter iter; 1480 - struct kiocb *iocb; 1481 - struct cifsFileInfo *cfile; 1482 - struct bio_vec *bv; 1483 - loff_t pos; 1484 - unsigned int nr_pinned_pages; 1485 - ssize_t rc; 1486 - unsigned int len; 1487 - unsigned int total_len; 1488 - unsigned int bv_need_unpin; /* If ->bv[] needs unpinning */ 1489 - bool should_dirty; 1490 - /* 1491 - * Indicates if this aio_ctx is for direct_io, 1492 - * If yes, iter is a copy of the user passed iov_iter 1493 - */ 1494 - bool direct_io; 1495 - }; 1496 - 1497 1474 struct cifs_io_request { 1498 1475 struct netfs_io_request rreq; 1499 1476 struct cifsFileInfo *cfile; ··· 1987 2010 * cifsFileInfo->file_info_lock cifsFileInfo->count cifs_new_fileinfo 1988 2011 * ->invalidHandle initiate_cifs_search 1989 2012 * ->oplock_break_cancelled 1990 - * cifs_aio_ctx->aio_mutex cifs_aio_ctx cifs_aio_ctx_alloc 1991 2013 ****************************************************************************/ 1992 2014 1993 2015 #ifdef DECLARE_GLOBALS_HERE
-2
fs/smb/client/cifsproto.h
··· 619 619 struct shash_desc *shash); 620 620 enum securityEnum cifs_select_sectype(struct TCP_Server_Info *, 621 621 enum securityEnum); 622 - struct cifs_aio_ctx *cifs_aio_ctx_alloc(void); 623 - void cifs_aio_ctx_release(struct kref *refcount); 624 622 625 623 int cifs_alloc_hash(const char *name, struct shash_desc **sdesc); 626 624 void cifs_free_hash(struct shash_desc **sdesc);
+15 -2
fs/smb/client/inode.c
··· 1042 1042 } 1043 1043 1044 1044 rc = -EOPNOTSUPP; 1045 - switch ((data->reparse.tag = tag)) { 1046 - case 0: /* SMB1 symlink */ 1045 + data->reparse.tag = tag; 1046 + if (!data->reparse.tag) { 1047 1047 if (server->ops->query_symlink) { 1048 1048 rc = server->ops->query_symlink(xid, tcon, 1049 1049 cifs_sb, full_path, 1050 1050 &data->symlink_target); 1051 + } 1052 + if (rc == -EOPNOTSUPP) 1053 + data->reparse.tag = IO_REPARSE_TAG_INTERNAL; 1054 + } 1055 + 1056 + switch (data->reparse.tag) { 1057 + case 0: /* SMB1 symlink */ 1058 + break; 1059 + case IO_REPARSE_TAG_INTERNAL: 1060 + rc = 0; 1061 + if (le32_to_cpu(data->fi.Attributes) & ATTR_DIRECTORY) { 1062 + cifs_create_junction_fattr(fattr, sb); 1063 + goto out; 1051 1064 } 1052 1065 break; 1053 1066 case IO_REPARSE_TAG_MOUNT_POINT:
+25 -7
fs/smb/client/ioctl.c
··· 170 170 static int cifs_shutdown(struct super_block *sb, unsigned long arg) 171 171 { 172 172 struct cifs_sb_info *sbi = CIFS_SB(sb); 173 + struct tcon_link *tlink; 174 + struct cifs_tcon *tcon; 173 175 __u32 flags; 176 + int rc; 174 177 175 178 if (!capable(CAP_SYS_ADMIN)) 176 179 return -EPERM; ··· 181 178 if (get_user(flags, (__u32 __user *)arg)) 182 179 return -EFAULT; 183 180 184 - if (flags > CIFS_GOING_FLAGS_NOLOGFLUSH) 185 - return -EINVAL; 181 + tlink = cifs_sb_tlink(sbi); 182 + if (IS_ERR(tlink)) 183 + return PTR_ERR(tlink); 184 + tcon = tlink_tcon(tlink); 185 + 186 + trace_smb3_shutdown_enter(flags, tcon->tid); 187 + if (flags > CIFS_GOING_FLAGS_NOLOGFLUSH) { 188 + rc = -EINVAL; 189 + goto shutdown_out_err; 190 + } 186 191 187 192 if (cifs_forced_shutdown(sbi)) 188 - return 0; 193 + goto shutdown_good; 189 194 190 195 cifs_dbg(VFS, "shut down requested (%d)", flags); 191 - /* trace_cifs_shutdown(sb, flags);*/ 192 196 193 197 /* 194 198 * see: ··· 211 201 */ 212 202 case CIFS_GOING_FLAGS_DEFAULT: 213 203 cifs_dbg(FYI, "shutdown with default flag not supported\n"); 214 - return -EINVAL; 204 + rc = -EINVAL; 205 + goto shutdown_out_err; 215 206 /* 216 207 * FLAGS_LOGFLUSH is easy since it asks to write out metadata (not 217 208 * data) but metadata writes are not cached on the client, so can treat ··· 221 210 case CIFS_GOING_FLAGS_LOGFLUSH: 222 211 case CIFS_GOING_FLAGS_NOLOGFLUSH: 223 212 sbi->mnt_cifs_flags |= CIFS_MOUNT_SHUTDOWN; 224 - return 0; 213 + goto shutdown_good; 225 214 default: 226 - return -EINVAL; 215 + rc = -EINVAL; 216 + goto shutdown_out_err; 227 217 } 218 + 219 + shutdown_good: 220 + trace_smb3_shutdown_done(flags, tcon->tid); 228 221 return 0; 222 + shutdown_out_err: 223 + trace_smb3_shutdown_err(rc, flags, tcon->tid); 224 + return rc; 229 225 } 230 226 231 227 static int cifs_dump_full_key(struct cifs_tcon *tcon, struct smb3_full_key_debug_info __user *in)
-54
fs/smb/client/misc.c
··· 995 995 return rc; 996 996 } 997 997 998 - struct cifs_aio_ctx * 999 - cifs_aio_ctx_alloc(void) 1000 - { 1001 - struct cifs_aio_ctx *ctx; 1002 - 1003 - /* 1004 - * Must use kzalloc to initialize ctx->bv to NULL and ctx->direct_io 1005 - * to false so that we know when we have to unreference pages within 1006 - * cifs_aio_ctx_release() 1007 - */ 1008 - ctx = kzalloc(sizeof(struct cifs_aio_ctx), GFP_KERNEL); 1009 - if (!ctx) 1010 - return NULL; 1011 - 1012 - INIT_LIST_HEAD(&ctx->list); 1013 - mutex_init(&ctx->aio_mutex); 1014 - init_completion(&ctx->done); 1015 - kref_init(&ctx->refcount); 1016 - return ctx; 1017 - } 1018 - 1019 - void 1020 - cifs_aio_ctx_release(struct kref *refcount) 1021 - { 1022 - struct cifs_aio_ctx *ctx = container_of(refcount, 1023 - struct cifs_aio_ctx, refcount); 1024 - 1025 - cifsFileInfo_put(ctx->cfile); 1026 - 1027 - /* 1028 - * ctx->bv is only set if setup_aio_ctx_iter() was call successfuly 1029 - * which means that iov_iter_extract_pages() was a success and thus 1030 - * that we may have references or pins on pages that we need to 1031 - * release. 1032 - */ 1033 - if (ctx->bv) { 1034 - if (ctx->should_dirty || ctx->bv_need_unpin) { 1035 - unsigned int i; 1036 - 1037 - for (i = 0; i < ctx->nr_pinned_pages; i++) { 1038 - struct page *page = ctx->bv[i].bv_page; 1039 - 1040 - if (ctx->should_dirty) 1041 - set_page_dirty(page); 1042 - if (ctx->bv_need_unpin) 1043 - unpin_user_page(page); 1044 - } 1045 - } 1046 - kvfree(ctx->bv); 1047 - } 1048 - 1049 - kfree(ctx); 1050 - } 1051 - 1052 998 /** 1053 999 * cifs_alloc_hash - allocate hash and hash context together 1054 1000 * @name: The name of the crypto hash algo
+4
fs/smb/client/reparse.c
··· 505 505 } 506 506 507 507 switch (tag) { 508 + case IO_REPARSE_TAG_INTERNAL: 509 + if (!(fattr->cf_cifsattrs & ATTR_DIRECTORY)) 510 + return false; 511 + fallthrough; 508 512 case IO_REPARSE_TAG_DFS: 509 513 case IO_REPARSE_TAG_DFSR: 510 514 case IO_REPARSE_TAG_MOUNT_POINT:
+17 -2
fs/smb/client/reparse.h
··· 12 12 #include "fs_context.h" 13 13 #include "cifsglob.h" 14 14 15 + /* 16 + * Used only by cifs.ko to ignore reparse points from files when client or 17 + * server doesn't support FSCTL_GET_REPARSE_POINT. 18 + */ 19 + #define IO_REPARSE_TAG_INTERNAL ((__u32)~0U) 20 + 15 21 static inline dev_t reparse_nfs_mkdev(struct reparse_posix_data *buf) 16 22 { 17 23 u64 v = le64_to_cpu(*(__le64 *)buf->DataBuffer); ··· 84 78 static inline bool reparse_inode_match(struct inode *inode, 85 79 struct cifs_fattr *fattr) 86 80 { 81 + struct cifsInodeInfo *cinode = CIFS_I(inode); 87 82 struct timespec64 ctime = inode_get_ctime(inode); 88 83 89 - return (CIFS_I(inode)->cifsAttrs & ATTR_REPARSE) && 90 - CIFS_I(inode)->reparse_tag == fattr->cf_cifstag && 84 + /* 85 + * Do not match reparse tags when client or server doesn't support 86 + * FSCTL_GET_REPARSE_POINT. @fattr->cf_cifstag should contain correct 87 + * reparse tag from query dir response but the client won't be able to 88 + * read the reparse point data anyway. This spares us a revalidation. 89 + */ 90 + if (cinode->reparse_tag != IO_REPARSE_TAG_INTERNAL && 91 + cinode->reparse_tag != fattr->cf_cifstag) 92 + return false; 93 + return (cinode->cifsAttrs & ATTR_REPARSE) && 91 94 timespec64_equal(&ctime, &fattr->cf_ctime); 92 95 } 93 96
+6 -2
fs/smb/client/smb2inode.c
··· 930 930 931 931 switch (rc) { 932 932 case 0: 933 + rc = parse_create_response(data, cifs_sb, &out_iov[0]); 934 + break; 933 935 case -EOPNOTSUPP: 934 936 /* 935 937 * BB TODO: When support for special files added to Samba ··· 950 948 cmds[num_cmds++] = SMB2_OP_GET_REPARSE; 951 949 952 950 oparms = CIFS_OPARMS(cifs_sb, tcon, full_path, 953 - FILE_READ_ATTRIBUTES | FILE_READ_EA, 951 + FILE_READ_ATTRIBUTES | 952 + FILE_READ_EA | SYNCHRONIZE, 954 953 FILE_OPEN, create_options | 955 954 OPEN_REPARSE_POINT, ACL_NO_MODE); 956 955 cifs_get_readable_path(tcon, full_path, &cfile); ··· 1259 1256 cifs_dbg(FYI, "%s: path: %s\n", __func__, full_path); 1260 1257 1261 1258 cifs_get_readable_path(tcon, full_path, &cfile); 1262 - oparms = CIFS_OPARMS(cifs_sb, tcon, full_path, FILE_READ_ATTRIBUTES, 1259 + oparms = CIFS_OPARMS(cifs_sb, tcon, full_path, 1260 + FILE_READ_ATTRIBUTES | FILE_READ_EA | SYNCHRONIZE, 1263 1261 FILE_OPEN, OPEN_REPARSE_POINT, ACL_NO_MODE); 1264 1262 rc = smb2_compound_op(xid, tcon, cifs_sb, 1265 1263 full_path, &oparms, &in_iov,
+50 -1
fs/smb/client/trace.h
··· 1388 1388 __entry->command = command; 1389 1389 ), 1390 1390 TP_printk("xid=%u fid=0x%llx ioctl cmd=0x%x", 1391 - __entry->xid, __entry->fid, __entry->command) 1391 + __entry->xid, __entry->fid, __entry->command) 1392 1392 ) 1393 1393 1394 1394 #define DEFINE_SMB3_IOCTL_EVENT(name) \ ··· 1400 1400 1401 1401 DEFINE_SMB3_IOCTL_EVENT(ioctl); 1402 1402 1403 + DECLARE_EVENT_CLASS(smb3_shutdown_class, 1404 + TP_PROTO(__u32 flags, 1405 + __u32 tid), 1406 + TP_ARGS(flags, tid), 1407 + TP_STRUCT__entry( 1408 + __field(__u32, flags) 1409 + __field(__u32, tid) 1410 + ), 1411 + TP_fast_assign( 1412 + __entry->flags = flags; 1413 + __entry->tid = tid; 1414 + ), 1415 + TP_printk("flags=0x%x tid=0x%x", 1416 + __entry->flags, __entry->tid) 1417 + ) 1403 1418 1419 + #define DEFINE_SMB3_SHUTDOWN_EVENT(name) \ 1420 + DEFINE_EVENT(smb3_shutdown_class, smb3_##name, \ 1421 + TP_PROTO(__u32 flags, \ 1422 + __u32 tid), \ 1423 + TP_ARGS(flags, tid)) 1404 1424 1425 + DEFINE_SMB3_SHUTDOWN_EVENT(shutdown_enter); 1426 + DEFINE_SMB3_SHUTDOWN_EVENT(shutdown_done); 1405 1427 1428 + DECLARE_EVENT_CLASS(smb3_shutdown_err_class, 1429 + TP_PROTO(int rc, 1430 + __u32 flags, 1431 + __u32 tid), 1432 + TP_ARGS(rc, flags, tid), 1433 + TP_STRUCT__entry( 1434 + __field(int, rc) 1435 + __field(__u32, flags) 1436 + __field(__u32, tid) 1437 + ), 1438 + TP_fast_assign( 1439 + __entry->rc = rc; 1440 + __entry->flags = flags; 1441 + __entry->tid = tid; 1442 + ), 1443 + TP_printk("rc=%d flags=0x%x tid=0x%x", 1444 + __entry->rc, __entry->flags, __entry->tid) 1445 + ) 1446 + 1447 + #define DEFINE_SMB3_SHUTDOWN_ERR_EVENT(name) \ 1448 + DEFINE_EVENT(smb3_shutdown_err_class, smb3_##name, \ 1449 + TP_PROTO(int rc, \ 1450 + __u32 flags, \ 1451 + __u32 tid), \ 1452 + TP_ARGS(rc, flags, tid)) 1453 + 1454 + DEFINE_SMB3_SHUTDOWN_ERR_EVENT(shutdown_err); 1406 1455 1407 1456 DECLARE_EVENT_CLASS(smb3_credit_class, 1408 1457 TP_PROTO(__u64 currmid,
+2 -2
fs/tracefs/event_inode.c
··· 112 112 entry->release(entry->name, ei->data); 113 113 } 114 114 115 - call_rcu(&ei->rcu, free_ei_rcu); 115 + call_srcu(&eventfs_srcu, &ei->rcu, free_ei_rcu); 116 116 } 117 117 118 118 static inline void put_ei(struct eventfs_inode *ei) ··· 736 736 /* Was the parent freed? */ 737 737 if (list_empty(&ei->list)) { 738 738 cleanup_ei(ei); 739 - ei = NULL; 739 + ei = ERR_PTR(-EBUSY); 740 740 } 741 741 return ei; 742 742 }
+5 -7
fs/tracefs/inode.c
··· 42 42 struct tracefs_inode *ti; 43 43 unsigned long flags; 44 44 45 - ti = kmem_cache_alloc(tracefs_inode_cachep, GFP_KERNEL); 45 + ti = alloc_inode_sb(sb, tracefs_inode_cachep, GFP_KERNEL); 46 46 if (!ti) 47 47 return NULL; 48 48 ··· 53 53 return &ti->vfs_inode; 54 54 } 55 55 56 - static void tracefs_free_inode_rcu(struct rcu_head *rcu) 56 + static void tracefs_free_inode(struct inode *inode) 57 57 { 58 - struct tracefs_inode *ti; 58 + struct tracefs_inode *ti = get_tracefs(inode); 59 59 60 - ti = container_of(rcu, struct tracefs_inode, rcu); 61 60 kmem_cache_free(tracefs_inode_cachep, ti); 62 61 } 63 62 64 - static void tracefs_free_inode(struct inode *inode) 63 + static void tracefs_destroy_inode(struct inode *inode) 65 64 { 66 65 struct tracefs_inode *ti = get_tracefs(inode); 67 66 unsigned long flags; ··· 68 69 spin_lock_irqsave(&tracefs_inode_lock, flags); 69 70 list_del_rcu(&ti->list); 70 71 spin_unlock_irqrestore(&tracefs_inode_lock, flags); 71 - 72 - call_rcu(&ti->rcu, tracefs_free_inode_rcu); 73 72 } 74 73 75 74 static ssize_t default_read_file(struct file *file, char __user *buf, ··· 434 437 static const struct super_operations tracefs_super_operations = { 435 438 .alloc_inode = tracefs_alloc_inode, 436 439 .free_inode = tracefs_free_inode, 440 + .destroy_inode = tracefs_destroy_inode, 437 441 .drop_inode = tracefs_drop_inode, 438 442 .statfs = simple_statfs, 439 443 .show_options = tracefs_show_options,
+1 -4
fs/tracefs/internal.h
··· 10 10 }; 11 11 12 12 struct tracefs_inode { 13 - union { 14 - struct inode vfs_inode; 15 - struct rcu_head rcu; 16 - }; 13 + struct inode vfs_inode; 17 14 /* The below gets initialized with memset_after(ti, 0, vfs_inode) */ 18 15 struct list_head list; 19 16 unsigned long flags;
+1 -1
fs/xfs/libxfs/xfs_quota_defs.h
··· 56 56 * And, of course, we also need to take into account the dquot log format item 57 57 * used to describe each dquot. 58 58 */ 59 - #define XFS_DQUOT_LOGRES(mp) \ 59 + #define XFS_DQUOT_LOGRES \ 60 60 ((sizeof(struct xfs_dq_logformat) + sizeof(struct xfs_disk_dquot)) * 6) 61 61 62 62 #define XFS_IS_QUOTA_ON(mp) ((mp)->m_qflags & XFS_ALL_QUOTA_ACCT)
+14 -14
fs/xfs/libxfs/xfs_trans_resv.c
··· 338 338 blksz); 339 339 t1 += adj; 340 340 t3 += adj; 341 - return XFS_DQUOT_LOGRES(mp) + max3(t1, t2, t3); 341 + return XFS_DQUOT_LOGRES + max3(t1, t2, t3); 342 342 } 343 343 344 344 t4 = xfs_calc_refcountbt_reservation(mp, 1); 345 - return XFS_DQUOT_LOGRES(mp) + max(t4, max3(t1, t2, t3)); 345 + return XFS_DQUOT_LOGRES + max(t4, max3(t1, t2, t3)); 346 346 } 347 347 348 348 unsigned int ··· 410 410 xfs_refcountbt_block_count(mp, 4), 411 411 blksz); 412 412 413 - return XFS_DQUOT_LOGRES(mp) + max3(t1, t2, t3); 413 + return XFS_DQUOT_LOGRES + max3(t1, t2, t3); 414 414 } 415 415 416 416 t4 = xfs_calc_refcountbt_reservation(mp, 2); 417 - return XFS_DQUOT_LOGRES(mp) + max(t4, max3(t1, t2, t3)); 417 + return XFS_DQUOT_LOGRES + max(t4, max3(t1, t2, t3)); 418 418 } 419 419 420 420 unsigned int ··· 466 466 xfs_calc_rename_reservation( 467 467 struct xfs_mount *mp) 468 468 { 469 - unsigned int overhead = XFS_DQUOT_LOGRES(mp); 469 + unsigned int overhead = XFS_DQUOT_LOGRES; 470 470 struct xfs_trans_resv *resp = M_RES(mp); 471 471 unsigned int t1, t2, t3 = 0; 472 472 ··· 577 577 xfs_calc_link_reservation( 578 578 struct xfs_mount *mp) 579 579 { 580 - unsigned int overhead = XFS_DQUOT_LOGRES(mp); 580 + unsigned int overhead = XFS_DQUOT_LOGRES; 581 581 struct xfs_trans_resv *resp = M_RES(mp); 582 582 unsigned int t1, t2, t3 = 0; 583 583 ··· 641 641 xfs_calc_remove_reservation( 642 642 struct xfs_mount *mp) 643 643 { 644 - unsigned int overhead = XFS_DQUOT_LOGRES(mp); 644 + unsigned int overhead = XFS_DQUOT_LOGRES; 645 645 struct xfs_trans_resv *resp = M_RES(mp); 646 646 unsigned int t1, t2, t3 = 0; 647 647 ··· 729 729 struct xfs_mount *mp) 730 730 { 731 731 struct xfs_trans_resv *resp = M_RES(mp); 732 - unsigned int overhead = XFS_DQUOT_LOGRES(mp); 732 + unsigned int overhead = XFS_DQUOT_LOGRES; 733 733 unsigned int t1, t2, t3 = 0; 734 734 735 735 t1 = xfs_calc_icreate_resv_alloc(mp); ··· 747 747 xfs_calc_create_tmpfile_reservation( 748 748 struct xfs_mount *mp) 749 749 { 750 - uint res = XFS_DQUOT_LOGRES(mp); 750 + uint res = XFS_DQUOT_LOGRES; 751 751 752 752 res += xfs_calc_icreate_resv_alloc(mp); 753 753 return res + xfs_calc_iunlink_add_reservation(mp); ··· 829 829 xfs_calc_ifree_reservation( 830 830 struct xfs_mount *mp) 831 831 { 832 - return XFS_DQUOT_LOGRES(mp) + 832 + return XFS_DQUOT_LOGRES + 833 833 xfs_calc_inode_res(mp, 1) + 834 834 xfs_calc_buf_res(3, mp->m_sb.sb_sectsize) + 835 835 xfs_calc_iunlink_remove_reservation(mp) + ··· 846 846 xfs_calc_ichange_reservation( 847 847 struct xfs_mount *mp) 848 848 { 849 - return XFS_DQUOT_LOGRES(mp) + 849 + return XFS_DQUOT_LOGRES + 850 850 xfs_calc_inode_res(mp, 1) + 851 851 xfs_calc_buf_res(1, mp->m_sb.sb_sectsize); 852 852 ··· 955 955 xfs_calc_addafork_reservation( 956 956 struct xfs_mount *mp) 957 957 { 958 - return XFS_DQUOT_LOGRES(mp) + 958 + return XFS_DQUOT_LOGRES + 959 959 xfs_calc_inode_res(mp, 1) + 960 960 xfs_calc_buf_res(2, mp->m_sb.sb_sectsize) + 961 961 xfs_calc_buf_res(1, mp->m_dir_geo->blksize) + ··· 1003 1003 xfs_calc_attrsetm_reservation( 1004 1004 struct xfs_mount *mp) 1005 1005 { 1006 - return XFS_DQUOT_LOGRES(mp) + 1006 + return XFS_DQUOT_LOGRES + 1007 1007 xfs_calc_inode_res(mp, 1) + 1008 1008 xfs_calc_buf_res(1, mp->m_sb.sb_sectsize) + 1009 1009 xfs_calc_buf_res(XFS_DA_NODE_MAXDEPTH, XFS_FSB_TO_B(mp, 1)); ··· 1043 1043 xfs_calc_attrrm_reservation( 1044 1044 struct xfs_mount *mp) 1045 1045 { 1046 - return XFS_DQUOT_LOGRES(mp) + 1046 + return XFS_DQUOT_LOGRES + 1047 1047 max((xfs_calc_inode_res(mp, 1) + 1048 1048 xfs_calc_buf_res(XFS_DA_NODE_MAXDEPTH, 1049 1049 XFS_FSB_TO_B(mp, 1)) +
+1 -1
fs/xfs/scrub/agheader_repair.c
··· 696 696 * step. 697 697 */ 698 698 xagb_bitmap_init(&af.used_extents); 699 - af.agfl_bno = xfs_buf_to_agfl_bno(agfl_bp), 699 + af.agfl_bno = xfs_buf_to_agfl_bno(agfl_bp); 700 700 xagb_bitmap_walk(agfl_extents, xrep_agfl_fill, &af); 701 701 error = xagb_bitmap_disunion(agfl_extents, &af.used_extents); 702 702 if (error)
+1 -1
fs/xfs/scrub/parent.c
··· 799 799 } 800 800 801 801 if (pp->sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT) 802 - goto out_pp; 802 + goto out_names; 803 803 804 804 /* 805 805 * Complain if the number of parent pointers doesn't match the link
+4 -6
fs/xfs/scrub/trace.h
··· 959 959 TP_STRUCT__entry( 960 960 __field(dev_t, dev) 961 961 __field(unsigned long, ino) 962 - __array(char, pathname, 256) 962 + __array(char, pathname, MAXNAMELEN) 963 963 ), 964 964 TP_fast_assign( 965 - char pathname[257]; 966 965 char *path; 967 966 968 967 __entry->ino = file_inode(xf->file)->i_ino; 969 - memset(pathname, 0, sizeof(pathname)); 970 - path = file_path(xf->file, pathname, sizeof(pathname) - 1); 968 + path = file_path(xf->file, __entry->pathname, MAXNAMELEN); 971 969 if (IS_ERR(path)) 972 - path = "(unknown)"; 973 - strncpy(__entry->pathname, path, sizeof(__entry->pathname)); 970 + strncpy(__entry->pathname, "(unknown)", 971 + sizeof(__entry->pathname)); 974 972 ), 975 973 TP_printk("xfino 0x%lx path '%s'", 976 974 __entry->ino,
+1 -1
fs/xfs/xfs_attr_list.c
··· 139 139 sbp->name = sfe->nameval; 140 140 sbp->namelen = sfe->namelen; 141 141 /* These are bytes, and both on-disk, don't endian-flip */ 142 - sbp->value = &sfe->nameval[sfe->namelen], 142 + sbp->value = &sfe->nameval[sfe->namelen]; 143 143 sbp->valuelen = sfe->valuelen; 144 144 sbp->flags = sfe->flags; 145 145 sbp->hash = xfs_attr_hashval(dp->i_mount, sfe->flags,
+4 -6
fs/xfs/xfs_trace.h
··· 4715 4715 TP_STRUCT__entry( 4716 4716 __field(dev_t, dev) 4717 4717 __field(unsigned long, ino) 4718 - __array(char, pathname, 256) 4718 + __array(char, pathname, MAXNAMELEN) 4719 4719 ), 4720 4720 TP_fast_assign( 4721 - char pathname[257]; 4722 4721 char *path; 4723 4722 struct file *file = btp->bt_file; 4724 4723 4725 4724 __entry->dev = btp->bt_mount->m_super->s_dev; 4726 4725 __entry->ino = file_inode(file)->i_ino; 4727 - memset(pathname, 0, sizeof(pathname)); 4728 - path = file_path(file, pathname, sizeof(pathname) - 1); 4726 + path = file_path(file, __entry->pathname, MAXNAMELEN); 4729 4727 if (IS_ERR(path)) 4730 - path = "(unknown)"; 4731 - strncpy(__entry->pathname, path, sizeof(__entry->pathname)); 4728 + strncpy(__entry->pathname, "(unknown)", 4729 + sizeof(__entry->pathname)); 4732 4730 ), 4733 4731 TP_printk("dev %d:%d xmino 0x%lx path '%s'", 4734 4732 MAJOR(__entry->dev), MINOR(__entry->dev),
+18 -1
fs/xfs/xfs_xattr.c
··· 110 110 args->whichfork = XFS_ATTR_FORK; 111 111 xfs_attr_sethash(args); 112 112 113 - return xfs_attr_set(args, op, args->attr_filter & XFS_ATTR_ROOT); 113 + /* 114 + * Some xattrs must be resistant to allocation failure at ENOSPC, e.g. 115 + * creating an inode with ACLs or security attributes requires the 116 + * allocation of the xattr holding that information to succeed. Hence 117 + * we allow xattrs in the VFS TRUSTED, SYSTEM, POSIX_ACL and SECURITY 118 + * (LSM xattr) namespaces to dip into the reserve block pool to allow 119 + * manipulation of these xattrs when at ENOSPC. These VFS xattr 120 + * namespaces translate to the XFS_ATTR_ROOT and XFS_ATTR_SECURE on-disk 121 + * namespaces. 122 + * 123 + * For most of these cases, these special xattrs will fit in the inode 124 + * itself and so consume no extra space or only require temporary extra 125 + * space while an overwrite is being made. Hence the use of the reserved 126 + * pool is largely to avoid the worst case reservation from preventing 127 + * the xattr from being created at ENOSPC. 128 + */ 129 + return xfs_attr_set(args, op, 130 + args->attr_filter & (XFS_ATTR_ROOT | XFS_ATTR_SECURE)); 114 131 } 115 132 116 133
+5 -6
include/asm-generic/vmlinux.lds.h
··· 911 911 #define CON_INITCALL \ 912 912 BOUNDED_SECTION_POST_LABEL(.con_initcall.init, __con_initcall, _start, _end) 913 913 914 - #define RUNTIME_NAME(t,x) runtime_##t##_##x 914 + #define NAMED_SECTION(name) \ 915 + . = ALIGN(8); \ 916 + name : AT(ADDR(name) - LOAD_OFFSET) \ 917 + { BOUNDED_SECTION_PRE_LABEL(name, name, __start_, __stop_) } 915 918 916 - #define RUNTIME_CONST(t,x) \ 917 - . = ALIGN(8); \ 918 - RUNTIME_NAME(t,x) : AT(ADDR(RUNTIME_NAME(t,x)) - LOAD_OFFSET) { \ 919 - *(RUNTIME_NAME(t,x)); \ 920 - } 919 + #define RUNTIME_CONST(t,x) NAMED_SECTION(runtime_##t##_##x) 921 920 922 921 /* Alignment must be consistent with (kunit_suite *) in include/kunit/test.h */ 923 922 #define KUNIT_TABLE() \
+1
include/linux/cpuhotplug.h
··· 147 147 CPUHP_AP_IRQ_LOONGARCH_STARTING, 148 148 CPUHP_AP_IRQ_SIFIVE_PLIC_STARTING, 149 149 CPUHP_AP_IRQ_RISCV_IMSIC_STARTING, 150 + CPUHP_AP_IRQ_RISCV_SBI_IPI_STARTING, 150 151 CPUHP_AP_ARM_MVEBU_COHERENCY, 151 152 CPUHP_AP_PERF_X86_AMD_UNCORE_STARTING, 152 153 CPUHP_AP_PERF_X86_STARTING,
+5 -5
include/linux/ethtool.h
··· 736 736 * @rxfh_key_space: same as @rxfh_indir_space, but for the key. 737 737 * @rxfh_priv_size: size of the driver private data area the core should 738 738 * allocate for an RSS context (in &struct ethtool_rxfh_context). 739 - * @rxfh_max_context_id: maximum (exclusive) supported RSS context ID. If this 740 - * is zero then the core may choose any (nonzero) ID, otherwise the core 741 - * will only use IDs strictly less than this value, as the @rss_context 742 - * argument to @create_rxfh_context and friends. 739 + * @rxfh_max_num_contexts: maximum (exclusive) supported RSS context ID. 740 + * If this is zero then the core may choose any (nonzero) ID, otherwise 741 + * the core will only use IDs strictly less than this value, as the 742 + * @rss_context argument to @create_rxfh_context and friends. 743 743 * @supported_coalesce_params: supported types of interrupt coalescing. 744 744 * @supported_ring_params: supported ring params. 745 745 * @get_drvinfo: Report driver/device information. Modern drivers no ··· 954 954 u32 rxfh_indir_space; 955 955 u16 rxfh_key_space; 956 956 u16 rxfh_priv_size; 957 - u32 rxfh_max_context_id; 957 + u32 rxfh_max_num_contexts; 958 958 u32 supported_coalesce_params; 959 959 u32 supported_ring_params; 960 960 void (*get_drvinfo)(struct net_device *, struct ethtool_drvinfo *);
+5 -4
include/linux/kvm_host.h
··· 2414 2414 } 2415 2415 2416 2416 bool kvm_range_has_memory_attributes(struct kvm *kvm, gfn_t start, gfn_t end, 2417 - unsigned long attrs); 2417 + unsigned long mask, unsigned long attrs); 2418 2418 bool kvm_arch_pre_set_memory_attributes(struct kvm *kvm, 2419 2419 struct kvm_gfn_range *range); 2420 2420 bool kvm_arch_post_set_memory_attributes(struct kvm *kvm, ··· 2445 2445 } 2446 2446 #endif /* CONFIG_KVM_PRIVATE_MEM */ 2447 2447 2448 - #ifdef CONFIG_HAVE_KVM_GMEM_PREPARE 2448 + #ifdef CONFIG_HAVE_KVM_ARCH_GMEM_PREPARE 2449 2449 int kvm_arch_gmem_prepare(struct kvm *kvm, gfn_t gfn, kvm_pfn_t pfn, int max_order); 2450 - bool kvm_arch_gmem_prepare_needed(struct kvm *kvm); 2451 2450 #endif 2452 2451 2452 + #ifdef CONFIG_KVM_GENERIC_PRIVATE_MEM 2453 2453 /** 2454 2454 * kvm_gmem_populate() - Populate/prepare a GPA range with guest data 2455 2455 * ··· 2476 2476 2477 2477 long kvm_gmem_populate(struct kvm *kvm, gfn_t gfn, void __user *src, long npages, 2478 2478 kvm_gmem_populate_cb post_populate, void *opaque); 2479 + #endif 2479 2480 2480 - #ifdef CONFIG_HAVE_KVM_GMEM_INVALIDATE 2481 + #ifdef CONFIG_HAVE_KVM_ARCH_GMEM_INVALIDATE 2481 2482 void kvm_arch_gmem_invalidate(kvm_pfn_t start, kvm_pfn_t end); 2482 2483 #endif 2483 2484
-1
include/linux/profile.h
··· 10 10 11 11 #define CPU_PROFILING 1 12 12 #define SCHED_PROFILING 2 13 - #define SLEEP_PROFILING 3 14 13 #define KVM_PROFILING 4 15 14 16 15 struct proc_dir_entry;
-1
include/linux/ring_buffer.h
··· 193 193 void ring_buffer_set_time_stamp_abs(struct trace_buffer *buffer, bool abs); 194 194 bool ring_buffer_time_stamp_abs(struct trace_buffer *buffer); 195 195 196 - size_t ring_buffer_nr_pages(struct trace_buffer *buffer, int cpu); 197 196 size_t ring_buffer_nr_dirty_pages(struct trace_buffer *buffer, int cpu); 198 197 199 198 struct buffer_data_read_page;
+1 -1
include/linux/trace_events.h
··· 680 680 * caching and such. Which is mostly OK ;-) 681 681 */ 682 682 unsigned long flags; 683 - atomic_t ref; /* ref count for opened files */ 683 + refcount_t ref; /* ref count for opened files */ 684 684 atomic_t sm_ref; /* soft-mode reference counter */ 685 685 atomic_t tm_ref; /* trigger-mode reference counter */ 686 686 };
+1
include/sound/ump_convert.h
··· 13 13 unsigned char cc_nrpn_msb, cc_nrpn_lsb; 14 14 unsigned char cc_data_msb, cc_data_lsb; 15 15 unsigned char cc_bank_msb, cc_bank_lsb; 16 + bool cc_data_msb_set, cc_data_lsb_set; 16 17 }; 17 18 18 19 /* context for converting from MIDI1 byte stream to UMP packet */
+1 -4
include/uapi/asm-generic/unistd.h
··· 841 841 #define __NR_mseal 462 842 842 __SYSCALL(__NR_mseal, sys_mseal) 843 843 844 - #define __NR_uretprobe 463 845 - __SYSCALL(__NR_uretprobe, sys_uretprobe) 846 - 847 844 #undef __NR_syscalls 848 - #define __NR_syscalls 464 845 + #define __NR_syscalls 463 849 846 850 847 /* 851 848 * 32 bit systems traditionally used different
+1
include/ufs/ufshcd.h
··· 1109 1109 bool ext_iid_sup; 1110 1110 bool scsi_host_added; 1111 1111 bool mcq_sup; 1112 + bool lsdb_sup; 1112 1113 bool mcq_enabled; 1113 1114 struct ufshcd_res_info res[RES_MAX]; 1114 1115 void __iomem *mcq_base;
+1
include/ufs/ufshci.h
··· 77 77 MASK_OUT_OF_ORDER_DATA_DELIVERY_SUPPORT = 0x02000000, 78 78 MASK_UIC_DME_TEST_MODE_SUPPORT = 0x04000000, 79 79 MASK_CRYPTO_SUPPORT = 0x10000000, 80 + MASK_LSDB_SUPPORT = 0x20000000, 80 81 MASK_MCQ_SUPPORT = 0x40000000, 81 82 }; 82 83
+1
init/Kconfig
··· 1902 1902 depends on !MODVERSIONS 1903 1903 depends on !GCC_PLUGINS 1904 1904 depends on !RANDSTRUCT 1905 + depends on !SHADOW_CALL_STACK 1905 1906 depends on !DEBUG_INFO_BTF || PAHOLE_HAS_LANG_EXCLUDE 1906 1907 help 1907 1908 Enables Rust support in the kernel.
-2
io_uring/napi.c
··· 205 205 void io_napi_free(struct io_ring_ctx *ctx) 206 206 { 207 207 struct io_napi_entry *e; 208 - LIST_HEAD(napi_list); 209 208 unsigned int i; 210 209 211 210 spin_lock(&ctx->napi_lock); ··· 314 315 */ 315 316 int io_napi_sqpoll_busy_poll(struct io_ring_ctx *ctx) 316 317 { 317 - LIST_HEAD(napi_list); 318 318 bool is_stale = false; 319 319 320 320 if (!READ_ONCE(ctx->napi_busy_poll_dt))
+1
io_uring/poll.c
··· 347 347 v &= IO_POLL_REF_MASK; 348 348 } while (atomic_sub_return(v, &req->poll_refs) & IO_POLL_REF_MASK); 349 349 350 + io_napi_add(req); 350 351 return IOU_POLL_NO_ACTION; 351 352 } 352 353
+2 -2
kernel/jump_label.c
··· 236 236 } 237 237 238 238 jump_label_lock(); 239 - if (atomic_cmpxchg(&key->enabled, 1, 0)) 239 + if (atomic_cmpxchg(&key->enabled, 1, 0) == 1) 240 240 jump_label_update(key); 241 241 jump_label_unlock(); 242 242 } ··· 289 289 return; 290 290 291 291 guard(mutex)(&jump_label_mutex); 292 - if (atomic_cmpxchg(&key->enabled, 1, 0)) 292 + if (atomic_cmpxchg(&key->enabled, 1, 0) == 1) 293 293 jump_label_update(key); 294 294 else 295 295 WARN_ON_ONCE(!static_key_slow_try_dec(key));
+12 -3
kernel/kcov.c
··· 161 161 kmsan_unpoison_memory(&area->list, sizeof(area->list)); 162 162 } 163 163 164 + /* 165 + * Unlike in_serving_softirq(), this function returns false when called during 166 + * a hardirq or an NMI that happened in the softirq context. 167 + */ 168 + static inline bool in_softirq_really(void) 169 + { 170 + return in_serving_softirq() && !in_hardirq() && !in_nmi(); 171 + } 172 + 164 173 static notrace bool check_kcov_mode(enum kcov_mode needed_mode, struct task_struct *t) 165 174 { 166 175 unsigned int mode; ··· 179 170 * so we ignore code executed in interrupts, unless we are in a remote 180 171 * coverage collection section in a softirq. 181 172 */ 182 - if (!in_task() && !(in_serving_softirq() && t->kcov_softirq)) 173 + if (!in_task() && !(in_softirq_really() && t->kcov_softirq)) 183 174 return false; 184 175 mode = READ_ONCE(t->kcov_mode); 185 176 /* ··· 858 849 859 850 if (WARN_ON(!kcov_check_handle(handle, true, true, true))) 860 851 return; 861 - if (!in_task() && !in_serving_softirq()) 852 + if (!in_task() && !in_softirq_really()) 862 853 return; 863 854 864 855 local_lock_irqsave(&kcov_percpu_data.lock, flags); ··· 1000 991 int sequence; 1001 992 unsigned long flags; 1002 993 1003 - if (!in_task() && !in_serving_softirq()) 994 + if (!in_task() && !in_softirq_really()) 1004 995 return; 1005 996 1006 997 local_lock_irqsave(&kcov_percpu_data.lock, flags);
+6
kernel/locking/lockdep.c
··· 5936 5936 if (DEBUG_LOCKS_WARN_ON(!depth)) 5937 5937 return; 5938 5938 5939 + if (unlikely(lock->key == &__lockdep_no_track__)) 5940 + return; 5941 + 5939 5942 hlock = find_held_lock(curr, lock, depth, &i); 5940 5943 if (!hlock) { 5941 5944 print_lock_contention_bug(curr, lock, ip); ··· 5979 5976 * acquire, how the heck did that happen? 5980 5977 */ 5981 5978 if (DEBUG_LOCKS_WARN_ON(!depth)) 5979 + return; 5980 + 5981 + if (unlikely(lock->key == &__lockdep_no_track__)) 5982 5982 return; 5983 5983 5984 5984 hlock = find_held_lock(curr, lock, depth, &i);
+1 -1
kernel/locking/qspinlock_paravirt.h
··· 357 357 static void pv_kick_node(struct qspinlock *lock, struct mcs_spinlock *node) 358 358 { 359 359 struct pv_node *pn = (struct pv_node *)node; 360 - enum vcpu_state old = vcpu_halted; 360 + u8 old = vcpu_halted; 361 361 /* 362 362 * If the vCPU is indeed halted, advance its state to match that of 363 363 * pv_wait_node(). If OTOH this fails, the vCPU was running and will
+20 -7
kernel/module/main.c
··· 3183 3183 if (!f || !(f->f_mode & FMODE_READ)) 3184 3184 return -EBADF; 3185 3185 3186 - /* See if somebody else is doing the operation? */ 3187 - if (idempotent(&idem, file_inode(f))) { 3188 - wait_for_completion(&idem.complete); 3189 - return idem.ret; 3186 + /* Are we the winners of the race and get to do this? */ 3187 + if (!idempotent(&idem, file_inode(f))) { 3188 + int ret = init_module_from_file(f, uargs, flags); 3189 + return idempotent_complete(&idem, ret); 3190 3190 } 3191 3191 3192 - /* Otherwise, we'll do it and complete others */ 3193 - return idempotent_complete(&idem, 3194 - init_module_from_file(f, uargs, flags)); 3192 + /* 3193 + * Somebody else won the race and is loading the module. 3194 + * 3195 + * We have to wait for it forever, since our 'idem' is 3196 + * on the stack and the list entry stays there until 3197 + * completed (but we could fix it under the idem_lock) 3198 + * 3199 + * It's also unclear what a real timeout might be, 3200 + * but we could maybe at least make this killable 3201 + * and remove the idem entry in that case? 3202 + */ 3203 + for (;;) { 3204 + if (wait_for_completion_timeout(&idem.complete, 10*HZ)) 3205 + return idem.ret; 3206 + pr_warn_once("module '%pD' taking a long time to load", f); 3207 + } 3195 3208 } 3196 3209 3197 3210 SYSCALL_DEFINE3(finit_module, int, fd, const char __user *, uargs, int, flags)
+7
kernel/padata.c
··· 517 517 ps.chunk_size = max(ps.chunk_size, job->min_chunk); 518 518 ps.chunk_size = roundup(ps.chunk_size, job->align); 519 519 520 + /* 521 + * chunk_size can be 0 if the caller sets min_chunk to 0. So force it 522 + * to at least 1 to prevent divide-by-0 panic in padata_mt_helper().` 523 + */ 524 + if (!ps.chunk_size) 525 + ps.chunk_size = 1U; 526 + 520 527 list_for_each_entry(pw, &works, pw_list) 521 528 if (job->numa_aware) { 522 529 int old_node = atomic_read(&last_used_nid);
+1 -10
kernel/profile.c
··· 50 50 int profile_setup(char *str) 51 51 { 52 52 static const char schedstr[] = "schedule"; 53 - static const char sleepstr[] = "sleep"; 54 53 static const char kvmstr[] = "kvm"; 55 54 const char *select = NULL; 56 55 int par; 57 56 58 - if (!strncmp(str, sleepstr, strlen(sleepstr))) { 59 - #ifdef CONFIG_SCHEDSTATS 60 - force_schedstat_enabled(); 61 - prof_on = SLEEP_PROFILING; 62 - select = sleepstr; 63 - #else 64 - pr_warn("kernel sleep profiling requires CONFIG_SCHEDSTATS\n"); 65 - #endif /* CONFIG_SCHEDSTATS */ 66 - } else if (!strncmp(str, schedstr, strlen(schedstr))) { 57 + if (!strncmp(str, schedstr, strlen(schedstr))) { 67 58 prof_on = SCHED_PROFILING; 68 59 select = schedstr; 69 60 } else if (!strncmp(str, kvmstr, strlen(kvmstr))) {
+47 -21
kernel/sched/core.c
··· 7845 7845 } 7846 7846 } 7847 7847 7848 + static inline void sched_set_rq_online(struct rq *rq, int cpu) 7849 + { 7850 + struct rq_flags rf; 7851 + 7852 + rq_lock_irqsave(rq, &rf); 7853 + if (rq->rd) { 7854 + BUG_ON(!cpumask_test_cpu(cpu, rq->rd->span)); 7855 + set_rq_online(rq); 7856 + } 7857 + rq_unlock_irqrestore(rq, &rf); 7858 + } 7859 + 7860 + static inline void sched_set_rq_offline(struct rq *rq, int cpu) 7861 + { 7862 + struct rq_flags rf; 7863 + 7864 + rq_lock_irqsave(rq, &rf); 7865 + if (rq->rd) { 7866 + BUG_ON(!cpumask_test_cpu(cpu, rq->rd->span)); 7867 + set_rq_offline(rq); 7868 + } 7869 + rq_unlock_irqrestore(rq, &rf); 7870 + } 7871 + 7848 7872 /* 7849 7873 * used to mark begin/end of suspend/resume: 7850 7874 */ ··· 7919 7895 return 0; 7920 7896 } 7921 7897 7898 + static inline void sched_smt_present_inc(int cpu) 7899 + { 7900 + #ifdef CONFIG_SCHED_SMT 7901 + if (cpumask_weight(cpu_smt_mask(cpu)) == 2) 7902 + static_branch_inc_cpuslocked(&sched_smt_present); 7903 + #endif 7904 + } 7905 + 7906 + static inline void sched_smt_present_dec(int cpu) 7907 + { 7908 + #ifdef CONFIG_SCHED_SMT 7909 + if (cpumask_weight(cpu_smt_mask(cpu)) == 2) 7910 + static_branch_dec_cpuslocked(&sched_smt_present); 7911 + #endif 7912 + } 7913 + 7922 7914 int sched_cpu_activate(unsigned int cpu) 7923 7915 { 7924 7916 struct rq *rq = cpu_rq(cpu); 7925 - struct rq_flags rf; 7926 7917 7927 7918 /* 7928 7919 * Clear the balance_push callback and prepare to schedule ··· 7945 7906 */ 7946 7907 balance_push_set(cpu, false); 7947 7908 7948 - #ifdef CONFIG_SCHED_SMT 7949 7909 /* 7950 7910 * When going up, increment the number of cores with SMT present. 7951 7911 */ 7952 - if (cpumask_weight(cpu_smt_mask(cpu)) == 2) 7953 - static_branch_inc_cpuslocked(&sched_smt_present); 7954 - #endif 7912 + sched_smt_present_inc(cpu); 7955 7913 set_cpu_active(cpu, true); 7956 7914 7957 7915 if (sched_smp_initialized) { ··· 7966 7930 * 2) At runtime, if cpuset_cpu_active() fails to rebuild the 7967 7931 * domains. 7968 7932 */ 7969 - rq_lock_irqsave(rq, &rf); 7970 - if (rq->rd) { 7971 - BUG_ON(!cpumask_test_cpu(cpu, rq->rd->span)); 7972 - set_rq_online(rq); 7973 - } 7974 - rq_unlock_irqrestore(rq, &rf); 7933 + sched_set_rq_online(rq, cpu); 7975 7934 7976 7935 return 0; 7977 7936 } ··· 7974 7943 int sched_cpu_deactivate(unsigned int cpu) 7975 7944 { 7976 7945 struct rq *rq = cpu_rq(cpu); 7977 - struct rq_flags rf; 7978 7946 int ret; 7979 7947 7980 7948 /* ··· 8004 7974 */ 8005 7975 synchronize_rcu(); 8006 7976 8007 - rq_lock_irqsave(rq, &rf); 8008 - if (rq->rd) { 8009 - BUG_ON(!cpumask_test_cpu(cpu, rq->rd->span)); 8010 - set_rq_offline(rq); 8011 - } 8012 - rq_unlock_irqrestore(rq, &rf); 7977 + sched_set_rq_offline(rq, cpu); 8013 7978 8014 - #ifdef CONFIG_SCHED_SMT 8015 7979 /* 8016 7980 * When going down, decrement the number of cores with SMT present. 8017 7981 */ 8018 - if (cpumask_weight(cpu_smt_mask(cpu)) == 2) 8019 - static_branch_dec_cpuslocked(&sched_smt_present); 7982 + sched_smt_present_dec(cpu); 8020 7983 7984 + #ifdef CONFIG_SCHED_SMT 8021 7985 sched_core_cpu_deactivate(cpu); 8022 7986 #endif 8023 7987 ··· 8021 7997 sched_update_numa(cpu, false); 8022 7998 ret = cpuset_cpu_inactive(cpu); 8023 7999 if (ret) { 8000 + sched_smt_present_inc(cpu); 8001 + sched_set_rq_online(rq, cpu); 8024 8002 balance_push_set(cpu, false); 8025 8003 set_cpu_active(cpu, true); 8026 8004 sched_update_numa(cpu, true);
+6
kernel/sched/cputime.c
··· 582 582 } 583 583 584 584 stime = mul_u64_u64_div_u64(stime, rtime, stime + utime); 585 + /* 586 + * Because mul_u64_u64_div_u64() can approximate on some 587 + * achitectures; enforce the constraint that: a*b/(b+c) <= a. 588 + */ 589 + if (unlikely(stime > rtime)) 590 + stime = rtime; 585 591 586 592 update: 587 593 /*
-10
kernel/sched/stats.c
··· 92 92 93 93 trace_sched_stat_blocked(p, delta); 94 94 95 - /* 96 - * Blocking time is in units of nanosecs, so shift by 97 - * 20 to get a milliseconds-range estimation of the 98 - * amount of time that the task spent sleeping: 99 - */ 100 - if (unlikely(prof_on == SLEEP_PROFILING)) { 101 - profile_hits(SLEEP_PROFILING, 102 - (void *)get_wchan(p), 103 - delta >> 20); 104 - } 105 95 account_scheduler_latency(p, delta >> 10, 0); 106 96 } 107 97 }
+1 -1
kernel/time/clocksource.c
··· 246 246 247 247 wd_delay = cycles_to_nsec_safe(watchdog, *wdnow, wd_end); 248 248 if (wd_delay <= WATCHDOG_MAX_SKEW) { 249 - if (nretries > 1 || nretries >= max_retries) { 249 + if (nretries > 1 && nretries >= max_retries) { 250 250 pr_warn("timekeeping watchdog on CPU%d: %s retried %d times before success\n", 251 251 smp_processor_id(), watchdog->name, nretries); 252 252 }
+2 -1
kernel/time/tick-broadcast.c
··· 1141 1141 #ifdef CONFIG_HOTPLUG_CPU 1142 1142 void hotplug_cpu__broadcast_tick_pull(int deadcpu) 1143 1143 { 1144 - struct tick_device *td = this_cpu_ptr(&tick_cpu_device); 1145 1144 struct clock_event_device *bc; 1146 1145 unsigned long flags; 1147 1146 ··· 1166 1167 * device to avoid the starvation. 1167 1168 */ 1168 1169 if (tick_check_broadcast_expired()) { 1170 + struct tick_device *td = this_cpu_ptr(&tick_cpu_device); 1171 + 1169 1172 cpumask_clear_cpu(smp_processor_id(), tick_broadcast_force_mask); 1170 1173 tick_program_event(td->evtdev->next_event, 1); 1171 1174 }
+1 -1
kernel/trace/fgraph.c
··· 902 902 903 903 i = *idx ? : task->curr_ret_stack; 904 904 while (i > 0) { 905 - ret_stack = get_ret_stack(current, i, &i); 905 + ret_stack = get_ret_stack(task, i, &i); 906 906 if (!ret_stack) 907 907 break; 908 908 /*
-12
kernel/trace/ring_buffer.c
··· 693 693 } 694 694 695 695 /** 696 - * ring_buffer_nr_pages - get the number of buffer pages in the ring buffer 697 - * @buffer: The ring_buffer to get the number of pages from 698 - * @cpu: The cpu of the ring_buffer to get the number of pages from 699 - * 700 - * Returns the number of pages used by a per_cpu buffer of the ring buffer. 701 - */ 702 - size_t ring_buffer_nr_pages(struct trace_buffer *buffer, int cpu) 703 - { 704 - return buffer->buffers[cpu]->nr_pages; 705 - } 706 - 707 - /** 708 696 * ring_buffer_nr_dirty_pages - get the number of used pages in the ring buffer 709 697 * @buffer: The ring_buffer to get the number of pages from 710 698 * @cpu: The cpu of the ring_buffer to get the number of pages from
+23
kernel/trace/trace.h
··· 1634 1634 extern struct mutex event_mutex; 1635 1635 extern struct list_head ftrace_events; 1636 1636 1637 + /* 1638 + * When the trace_event_file is the filp->i_private pointer, 1639 + * it must be taken under the event_mutex lock, and then checked 1640 + * if the EVENT_FILE_FL_FREED flag is set. If it is, then the 1641 + * data pointed to by the trace_event_file can not be trusted. 1642 + * 1643 + * Use the event_file_file() to access the trace_event_file from 1644 + * the filp the first time under the event_mutex and check for 1645 + * NULL. If it is needed to be retrieved again and the event_mutex 1646 + * is still held, then the event_file_data() can be used and it 1647 + * is guaranteed to be valid. 1648 + */ 1649 + static inline struct trace_event_file *event_file_file(struct file *filp) 1650 + { 1651 + struct trace_event_file *file; 1652 + 1653 + lockdep_assert_held(&event_mutex); 1654 + file = READ_ONCE(file_inode(filp)->i_private); 1655 + if (!file || file->flags & EVENT_FILE_FL_FREED) 1656 + return NULL; 1657 + return file; 1658 + } 1659 + 1637 1660 extern const struct file_operations event_trigger_fops; 1638 1661 extern const struct file_operations event_hist_fops; 1639 1662 extern const struct file_operations event_hist_debug_fops;
+24 -17
kernel/trace/trace_events.c
··· 992 992 993 993 void event_file_get(struct trace_event_file *file) 994 994 { 995 - atomic_inc(&file->ref); 995 + refcount_inc(&file->ref); 996 996 } 997 997 998 998 void event_file_put(struct trace_event_file *file) 999 999 { 1000 - if (WARN_ON_ONCE(!atomic_read(&file->ref))) { 1000 + if (WARN_ON_ONCE(!refcount_read(&file->ref))) { 1001 1001 if (file->flags & EVENT_FILE_FL_FREED) 1002 1002 kmem_cache_free(file_cachep, file); 1003 1003 return; 1004 1004 } 1005 1005 1006 - if (atomic_dec_and_test(&file->ref)) { 1006 + if (refcount_dec_and_test(&file->ref)) { 1007 1007 /* Count should only go to zero when it is freed */ 1008 1008 if (WARN_ON_ONCE(!(file->flags & EVENT_FILE_FL_FREED))) 1009 1009 return; ··· 1386 1386 char buf[4] = "0"; 1387 1387 1388 1388 mutex_lock(&event_mutex); 1389 - file = event_file_data(filp); 1389 + file = event_file_file(filp); 1390 1390 if (likely(file)) 1391 1391 flags = file->flags; 1392 1392 mutex_unlock(&event_mutex); 1393 1393 1394 - if (!file || flags & EVENT_FILE_FL_FREED) 1394 + if (!file) 1395 1395 return -ENODEV; 1396 1396 1397 1397 if (flags & EVENT_FILE_FL_ENABLED && ··· 1424 1424 case 1: 1425 1425 ret = -ENODEV; 1426 1426 mutex_lock(&event_mutex); 1427 - file = event_file_data(filp); 1428 - if (likely(file && !(file->flags & EVENT_FILE_FL_FREED))) { 1427 + file = event_file_file(filp); 1428 + if (likely(file)) { 1429 1429 ret = tracing_update_buffers(file->tr); 1430 1430 if (ret < 0) { 1431 1431 mutex_unlock(&event_mutex); ··· 1540 1540 1541 1541 static void *f_next(struct seq_file *m, void *v, loff_t *pos) 1542 1542 { 1543 - struct trace_event_call *call = event_file_data(m->private); 1543 + struct trace_event_file *file = event_file_data(m->private); 1544 + struct trace_event_call *call = file->event_call; 1544 1545 struct list_head *common_head = &ftrace_common_fields; 1545 1546 struct list_head *head = trace_get_fields(call); 1546 1547 struct list_head *node = v; ··· 1573 1572 1574 1573 static int f_show(struct seq_file *m, void *v) 1575 1574 { 1576 - struct trace_event_call *call = event_file_data(m->private); 1575 + struct trace_event_file *file = event_file_data(m->private); 1576 + struct trace_event_call *call = file->event_call; 1577 1577 struct ftrace_event_field *field; 1578 1578 const char *array_descriptor; 1579 1579 ··· 1629 1627 1630 1628 static void *f_start(struct seq_file *m, loff_t *pos) 1631 1629 { 1630 + struct trace_event_file *file; 1632 1631 void *p = (void *)FORMAT_HEADER; 1633 1632 loff_t l = 0; 1634 1633 1635 1634 /* ->stop() is called even if ->start() fails */ 1636 1635 mutex_lock(&event_mutex); 1637 - if (!event_file_data(m->private)) 1636 + file = event_file_file(m->private); 1637 + if (!file) 1638 1638 return ERR_PTR(-ENODEV); 1639 1639 1640 1640 while (l < *pos && p) ··· 1710 1706 trace_seq_init(s); 1711 1707 1712 1708 mutex_lock(&event_mutex); 1713 - file = event_file_data(filp); 1714 - if (file && !(file->flags & EVENT_FILE_FL_FREED)) 1709 + file = event_file_file(filp); 1710 + if (file) 1715 1711 print_event_filter(file, s); 1716 1712 mutex_unlock(&event_mutex); 1717 1713 ··· 1740 1736 return PTR_ERR(buf); 1741 1737 1742 1738 mutex_lock(&event_mutex); 1743 - file = event_file_data(filp); 1744 - if (file) 1745 - err = apply_event_filter(file, buf); 1739 + file = event_file_file(filp); 1740 + if (file) { 1741 + if (file->flags & EVENT_FILE_FL_FREED) 1742 + err = -ENODEV; 1743 + else 1744 + err = apply_event_filter(file, buf); 1745 + } 1746 1746 mutex_unlock(&event_mutex); 1747 1747 1748 1748 kfree(buf); ··· 2493 2485 if (strcmp(name, "format") == 0) { 2494 2486 *mode = TRACE_MODE_READ; 2495 2487 *fops = &ftrace_event_format_fops; 2496 - *data = call; 2497 2488 return 1; 2498 2489 } 2499 2490 ··· 3003 2996 atomic_set(&file->tm_ref, 0); 3004 2997 INIT_LIST_HEAD(&file->triggers); 3005 2998 list_add(&file->list, &tr->events); 3006 - event_file_get(file); 2999 + refcount_set(&file->ref, 1); 3007 3000 3008 3001 return file; 3009 3002 }
+2 -2
kernel/trace/trace_events_hist.c
··· 5601 5601 5602 5602 mutex_lock(&event_mutex); 5603 5603 5604 - event_file = event_file_data(m->private); 5604 + event_file = event_file_file(m->private); 5605 5605 if (unlikely(!event_file)) { 5606 5606 ret = -ENODEV; 5607 5607 goto out_unlock; ··· 5880 5880 5881 5881 mutex_lock(&event_mutex); 5882 5882 5883 - event_file = event_file_data(m->private); 5883 + event_file = event_file_file(m->private); 5884 5884 if (unlikely(!event_file)) { 5885 5885 ret = -ENODEV; 5886 5886 goto out_unlock;
+1 -1
kernel/trace/trace_events_inject.c
··· 299 299 strim(buf); 300 300 301 301 mutex_lock(&event_mutex); 302 - file = event_file_data(filp); 302 + file = event_file_file(filp); 303 303 if (file) { 304 304 call = file->event_call; 305 305 size = parse_entry(buf, call, &entry);
+3 -3
kernel/trace/trace_events_trigger.c
··· 159 159 160 160 /* ->stop() is called even if ->start() fails */ 161 161 mutex_lock(&event_mutex); 162 - event_file = event_file_data(m->private); 162 + event_file = event_file_file(m->private); 163 163 if (unlikely(!event_file)) 164 164 return ERR_PTR(-ENODEV); 165 165 ··· 213 213 214 214 mutex_lock(&event_mutex); 215 215 216 - if (unlikely(!event_file_data(file))) { 216 + if (unlikely(!event_file_file(file))) { 217 217 mutex_unlock(&event_mutex); 218 218 return -ENODEV; 219 219 } ··· 293 293 strim(buf); 294 294 295 295 mutex_lock(&event_mutex); 296 - event_file = event_file_data(file); 296 + event_file = event_file_file(file); 297 297 if (unlikely(!event_file)) { 298 298 mutex_unlock(&event_mutex); 299 299 kfree(buf);
+3 -3
kernel/trace/tracing_map.c
··· 454 454 struct tracing_map_elt *elt = NULL; 455 455 int idx; 456 456 457 - idx = atomic_inc_return(&map->next_elt); 457 + idx = atomic_fetch_add_unless(&map->next_elt, 1, map->max_elts); 458 458 if (idx < map->max_elts) { 459 459 elt = *(TRACING_MAP_ELT(map->elts, idx)); 460 460 if (map->ops && map->ops->elt_init) ··· 699 699 { 700 700 unsigned int i; 701 701 702 - atomic_set(&map->next_elt, -1); 702 + atomic_set(&map->next_elt, 0); 703 703 atomic64_set(&map->hits, 0); 704 704 atomic64_set(&map->drops, 0); 705 705 ··· 783 783 784 784 map->map_bits = map_bits; 785 785 map->max_elts = (1 << map_bits); 786 - atomic_set(&map->next_elt, -1); 786 + atomic_set(&map->next_elt, 0); 787 787 788 788 map->map_size = (1 << (map_bits + 1)); 789 789 map->ops = ops;
+22 -6
mm/list_lru.c
··· 85 85 } 86 86 #endif /* CONFIG_MEMCG */ 87 87 88 + /* The caller must ensure the memcg lifetime. */ 88 89 bool list_lru_add(struct list_lru *lru, struct list_head *item, int nid, 89 90 struct mem_cgroup *memcg) 90 91 { ··· 110 109 111 110 bool list_lru_add_obj(struct list_lru *lru, struct list_head *item) 112 111 { 112 + bool ret; 113 113 int nid = page_to_nid(virt_to_page(item)); 114 - struct mem_cgroup *memcg = list_lru_memcg_aware(lru) ? 115 - mem_cgroup_from_slab_obj(item) : NULL; 116 114 117 - return list_lru_add(lru, item, nid, memcg); 115 + if (list_lru_memcg_aware(lru)) { 116 + rcu_read_lock(); 117 + ret = list_lru_add(lru, item, nid, mem_cgroup_from_slab_obj(item)); 118 + rcu_read_unlock(); 119 + } else { 120 + ret = list_lru_add(lru, item, nid, NULL); 121 + } 122 + 123 + return ret; 118 124 } 119 125 EXPORT_SYMBOL_GPL(list_lru_add_obj); 120 126 127 + /* The caller must ensure the memcg lifetime. */ 121 128 bool list_lru_del(struct list_lru *lru, struct list_head *item, int nid, 122 129 struct mem_cgroup *memcg) 123 130 { ··· 148 139 149 140 bool list_lru_del_obj(struct list_lru *lru, struct list_head *item) 150 141 { 142 + bool ret; 151 143 int nid = page_to_nid(virt_to_page(item)); 152 - struct mem_cgroup *memcg = list_lru_memcg_aware(lru) ? 153 - mem_cgroup_from_slab_obj(item) : NULL; 154 144 155 - return list_lru_del(lru, item, nid, memcg); 145 + if (list_lru_memcg_aware(lru)) { 146 + rcu_read_lock(); 147 + ret = list_lru_del(lru, item, nid, mem_cgroup_from_slab_obj(item)); 148 + rcu_read_unlock(); 149 + } else { 150 + ret = list_lru_del(lru, item, nid, NULL); 151 + } 152 + 153 + return ret; 156 154 } 157 155 EXPORT_SYMBOL_GPL(list_lru_del_obj); 158 156
+20 -2
mm/memcontrol.c
··· 3386 3386 3387 3387 #define MEM_CGROUP_ID_MAX ((1UL << MEM_CGROUP_ID_SHIFT) - 1) 3388 3388 static DEFINE_IDR(mem_cgroup_idr); 3389 + static DEFINE_SPINLOCK(memcg_idr_lock); 3390 + 3391 + static int mem_cgroup_alloc_id(void) 3392 + { 3393 + int ret; 3394 + 3395 + idr_preload(GFP_KERNEL); 3396 + spin_lock(&memcg_idr_lock); 3397 + ret = idr_alloc(&mem_cgroup_idr, NULL, 1, MEM_CGROUP_ID_MAX + 1, 3398 + GFP_NOWAIT); 3399 + spin_unlock(&memcg_idr_lock); 3400 + idr_preload_end(); 3401 + return ret; 3402 + } 3389 3403 3390 3404 static void mem_cgroup_id_remove(struct mem_cgroup *memcg) 3391 3405 { 3392 3406 if (memcg->id.id > 0) { 3407 + spin_lock(&memcg_idr_lock); 3393 3408 idr_remove(&mem_cgroup_idr, memcg->id.id); 3409 + spin_unlock(&memcg_idr_lock); 3410 + 3394 3411 memcg->id.id = 0; 3395 3412 } 3396 3413 } ··· 3541 3524 if (!memcg) 3542 3525 return ERR_PTR(error); 3543 3526 3544 - memcg->id.id = idr_alloc(&mem_cgroup_idr, NULL, 3545 - 1, MEM_CGROUP_ID_MAX + 1, GFP_KERNEL); 3527 + memcg->id.id = mem_cgroup_alloc_id(); 3546 3528 if (memcg->id.id < 0) { 3547 3529 error = memcg->id.id; 3548 3530 goto fail; ··· 3683 3667 * publish it here at the end of onlining. This matches the 3684 3668 * regular ID destruction during offlining. 3685 3669 */ 3670 + spin_lock(&memcg_idr_lock); 3686 3671 idr_replace(&mem_cgroup_idr, memcg, memcg->id.id); 3672 + spin_unlock(&memcg_idr_lock); 3687 3673 3688 3674 return 0; 3689 3675 offline_kmem:
+5 -9
mm/shmem.c
··· 1629 1629 unsigned long mask = READ_ONCE(huge_shmem_orders_always); 1630 1630 unsigned long within_size_orders = READ_ONCE(huge_shmem_orders_within_size); 1631 1631 unsigned long vm_flags = vma->vm_flags; 1632 - /* 1633 - * Check all the (large) orders below HPAGE_PMD_ORDER + 1 that 1634 - * are enabled for this vma. 1635 - */ 1636 - unsigned long orders = BIT(PMD_ORDER + 1) - 1; 1637 1632 loff_t i_size; 1638 1633 int order; 1639 1634 ··· 1673 1678 if (global_huge) 1674 1679 mask |= READ_ONCE(huge_shmem_orders_inherit); 1675 1680 1676 - return orders & mask; 1681 + return THP_ORDERS_ALL_FILE_DEFAULT & mask; 1677 1682 } 1678 1683 1679 1684 static unsigned long shmem_suitable_orders(struct inode *inode, struct vm_fault *vmf, ··· 1681 1686 unsigned long orders) 1682 1687 { 1683 1688 struct vm_area_struct *vma = vmf->vma; 1689 + pgoff_t aligned_index; 1684 1690 unsigned long pages; 1685 1691 int order; 1686 1692 ··· 1693 1697 order = highest_order(orders); 1694 1698 while (orders) { 1695 1699 pages = 1UL << order; 1696 - index = round_down(index, pages); 1697 - if (!xa_find(&mapping->i_pages, &index, 1698 - index + pages - 1, XA_PRESENT)) 1700 + aligned_index = round_down(index, pages); 1701 + if (!xa_find(&mapping->i_pages, &aligned_index, 1702 + aligned_index + pages - 1, XA_PRESENT)) 1699 1703 break; 1700 1704 order = next_order(&orders, order); 1701 1705 }
+3
mm/slub.c
··· 4690 4690 if (!df.slab) 4691 4691 continue; 4692 4692 4693 + if (kfence_free(df.freelist)) 4694 + continue; 4695 + 4693 4696 do_slab_free(df.s, df.slab, df.freelist, df.tail, df.cnt, 4694 4697 _RET_IP_); 4695 4698 } while (likely(size));
+14
net/bluetooth/hci_sync.c
··· 3019 3019 } else if (hci_is_adv_monitoring(hdev)) { 3020 3020 window = hdev->le_scan_window_adv_monitor; 3021 3021 interval = hdev->le_scan_int_adv_monitor; 3022 + 3023 + /* Disable duplicates filter when scanning for advertisement 3024 + * monitor for the following reasons. 3025 + * 3026 + * For HW pattern filtering (ex. MSFT), Realtek and Qualcomm 3027 + * controllers ignore RSSI_Sampling_Period when the duplicates 3028 + * filter is enabled. 3029 + * 3030 + * For SW pattern filtering, when we're not doing interleaved 3031 + * scanning, it is necessary to disable duplicates filter, 3032 + * otherwise hosts can only receive one advertisement and it's 3033 + * impossible to know if a peer is still in range. 3034 + */ 3035 + filter_dups = LE_SCAN_FILTER_DUP_DISABLE; 3022 3036 } else { 3023 3037 window = hdev->le_scan_window; 3024 3038 interval = hdev->le_scan_interval;
+1
net/bluetooth/l2cap_core.c
··· 6774 6774 bt_cb(skb)->l2cap.psm = psm; 6775 6775 6776 6776 if (!chan->ops->recv(chan, skb)) { 6777 + l2cap_chan_unlock(chan); 6777 6778 l2cap_chan_put(chan); 6778 6779 return; 6779 6780 }
+1 -3
net/bridge/br_multicast.c
··· 2045 2045 { 2046 2046 struct net_bridge *br = port->br; 2047 2047 struct net_bridge_port_group *pg; 2048 - HLIST_HEAD(deleted_head); 2049 2048 struct hlist_node *n; 2050 2049 2051 2050 /* Take care of the remaining groups, only perm ones should be left */ 2052 2051 spin_lock_bh(&br->multicast_lock); 2053 2052 hlist_for_each_entry_safe(pg, n, &port->mglist, mglist) 2054 2053 br_multicast_find_del_pg(br, pg); 2055 - hlist_move_list(&br->mcast_gc_list, &deleted_head); 2056 2054 spin_unlock_bh(&br->multicast_lock); 2057 - br_multicast_gc(&deleted_head); 2055 + flush_work(&br->mcast_gc_work); 2058 2056 br_multicast_port_ctx_deinit(&port->multicast_ctx); 2059 2057 free_percpu(port->mcast_stats); 2060 2058 }
+11 -7
net/ethtool/ioctl.c
··· 1369 1369 return -EOPNOTSUPP; 1370 1370 create = rxfh.rss_context == ETH_RXFH_CONTEXT_ALLOC; 1371 1371 1372 - /* If either indir, hash key or function is valid, proceed further. 1373 - * Must request at least one change: indir size, hash key, function 1374 - * or input transformation. 1375 - */ 1376 1372 if ((rxfh.indir_size && 1377 1373 rxfh.indir_size != ETH_RXFH_INDIR_NO_CHANGE && 1378 1374 rxfh.indir_size != dev_indir_size) || 1379 - (rxfh.key_size && (rxfh.key_size != dev_key_size)) || 1375 + (rxfh.key_size && rxfh.key_size != dev_key_size)) 1376 + return -EINVAL; 1377 + 1378 + /* Must request at least one change: indir size, hash key, function 1379 + * or input transformation. 1380 + * There's no need for any of it in case of context creation. 1381 + */ 1382 + if (!create && 1380 1383 (rxfh.indir_size == ETH_RXFH_INDIR_NO_CHANGE && 1381 1384 rxfh.key_size == 0 && rxfh.hfunc == ETH_RSS_HASH_NO_CHANGE && 1382 1385 rxfh.input_xfrm == RXH_XFRM_NO_CHANGE)) ··· 1452 1449 } 1453 1450 1454 1451 if (ops->create_rxfh_context) { 1455 - u32 limit = ops->rxfh_max_context_id ?: U32_MAX; 1452 + u32 limit = ops->rxfh_max_num_contexts ?: U32_MAX; 1456 1453 u32 ctx_id; 1457 1454 1458 1455 /* driver uses new API, core allocates ID */ 1459 1456 ret = xa_alloc(&dev->ethtool->rss_ctx, &ctx_id, ctx, 1460 - XA_LIMIT(1, limit), GFP_KERNEL_ACCOUNT); 1457 + XA_LIMIT(1, limit - 1), 1458 + GFP_KERNEL_ACCOUNT); 1461 1459 if (ret < 0) { 1462 1460 kfree(ctx); 1463 1461 goto out;
+30 -13
net/ipv4/tcp_ao.c
··· 267 267 kfree_sensitive(key); 268 268 } 269 269 270 - void tcp_ao_destroy_sock(struct sock *sk, bool twsk) 270 + static void tcp_ao_info_free_rcu(struct rcu_head *head) 271 271 { 272 - struct tcp_ao_info *ao; 272 + struct tcp_ao_info *ao = container_of(head, struct tcp_ao_info, rcu); 273 273 struct tcp_ao_key *key; 274 274 struct hlist_node *n; 275 275 276 + hlist_for_each_entry_safe(key, n, &ao->head, node) { 277 + hlist_del(&key->node); 278 + tcp_sigpool_release(key->tcp_sigpool_id); 279 + kfree_sensitive(key); 280 + } 281 + kfree(ao); 282 + static_branch_slow_dec_deferred(&tcp_ao_needed); 283 + } 284 + 285 + static void tcp_ao_sk_omem_free(struct sock *sk, struct tcp_ao_info *ao) 286 + { 287 + size_t total_ao_sk_mem = 0; 288 + struct tcp_ao_key *key; 289 + 290 + hlist_for_each_entry(key, &ao->head, node) 291 + total_ao_sk_mem += tcp_ao_sizeof_key(key); 292 + atomic_sub(total_ao_sk_mem, &sk->sk_omem_alloc); 293 + } 294 + 295 + void tcp_ao_destroy_sock(struct sock *sk, bool twsk) 296 + { 297 + struct tcp_ao_info *ao; 298 + 276 299 if (twsk) { 277 300 ao = rcu_dereference_protected(tcp_twsk(sk)->ao_info, 1); 278 - tcp_twsk(sk)->ao_info = NULL; 301 + rcu_assign_pointer(tcp_twsk(sk)->ao_info, NULL); 279 302 } else { 280 303 ao = rcu_dereference_protected(tcp_sk(sk)->ao_info, 1); 281 - tcp_sk(sk)->ao_info = NULL; 304 + rcu_assign_pointer(tcp_sk(sk)->ao_info, NULL); 282 305 } 283 306 284 307 if (!ao || !refcount_dec_and_test(&ao->refcnt)) 285 308 return; 286 309 287 - hlist_for_each_entry_safe(key, n, &ao->head, node) { 288 - hlist_del_rcu(&key->node); 289 - if (!twsk) 290 - atomic_sub(tcp_ao_sizeof_key(key), &sk->sk_omem_alloc); 291 - call_rcu(&key->rcu, tcp_ao_key_free_rcu); 292 - } 293 - 294 - kfree_rcu(ao, rcu); 295 - static_branch_slow_dec_deferred(&tcp_ao_needed); 310 + if (!twsk) 311 + tcp_ao_sk_omem_free(sk, ao); 312 + call_rcu(&ao->rcu, tcp_ao_info_free_rcu); 296 313 } 297 314 298 315 void tcp_ao_time_wait(struct tcp_timewait_sock *tcptw, struct tcp_sock *tp)
+13 -2
net/l2tp/l2tp_core.c
··· 86 86 /* Default trace flags */ 87 87 #define L2TP_DEFAULT_DEBUG_FLAGS 0 88 88 89 + #define L2TP_DEPTH_NESTING 2 90 + #if L2TP_DEPTH_NESTING == SINGLE_DEPTH_NESTING 91 + #error "L2TP requires its own lockdep subclass" 92 + #endif 93 + 89 94 /* Private data stored for received packets in the skb. 90 95 */ 91 96 struct l2tp_skb_cb { ··· 1176 1171 IPCB(skb)->flags &= ~(IPSKB_XFRM_TUNNEL_SIZE | IPSKB_XFRM_TRANSFORMED | IPSKB_REROUTED); 1177 1172 nf_reset_ct(skb); 1178 1173 1179 - bh_lock_sock_nested(sk); 1174 + /* L2TP uses its own lockdep subclass to avoid lockdep splats caused by 1175 + * nested socket calls on the same lockdep socket class. This can 1176 + * happen when data from a user socket is routed over l2tp, which uses 1177 + * another userspace socket. 1178 + */ 1179 + spin_lock_nested(&sk->sk_lock.slock, L2TP_DEPTH_NESTING); 1180 + 1180 1181 if (sock_owned_by_user(sk)) { 1181 1182 kfree_skb(skb); 1182 1183 ret = NET_XMIT_DROP; ··· 1234 1223 ret = l2tp_xmit_queue(tunnel, skb, &inet->cork.fl); 1235 1224 1236 1225 out_unlock: 1237 - bh_unlock_sock(sk); 1226 + spin_unlock(&sk->sk_lock.slock); 1238 1227 1239 1228 return ret; 1240 1229 }
+2 -1
net/mptcp/options.c
··· 958 958 959 959 if (subflow->remote_key_valid && 960 960 (((mp_opt->suboptions & OPTION_MPTCP_DSS) && mp_opt->use_ack) || 961 - ((mp_opt->suboptions & OPTION_MPTCP_ADD_ADDR) && !mp_opt->echo))) { 961 + ((mp_opt->suboptions & OPTION_MPTCP_ADD_ADDR) && 962 + (!mp_opt->echo || subflow->mp_join)))) { 962 963 /* subflows are fully established as soon as we get any 963 964 * additional ack, including ADD_ADDR. 964 965 */
+30 -17
net/mptcp/pm_netlink.c
··· 348 348 add_entry = mptcp_lookup_anno_list_by_saddr(msk, addr); 349 349 350 350 if (add_entry) { 351 - if (mptcp_pm_is_kernel(msk)) 351 + if (WARN_ON_ONCE(mptcp_pm_is_kernel(msk))) 352 352 return false; 353 353 354 354 sk_reset_timer(sk, &add_entry->add_timer, ··· 512 512 513 513 static void mptcp_pm_create_subflow_or_signal_addr(struct mptcp_sock *msk) 514 514 { 515 + struct mptcp_pm_addr_entry *local, *signal_and_subflow = NULL; 515 516 struct sock *sk = (struct sock *)msk; 516 - struct mptcp_pm_addr_entry *local; 517 517 unsigned int add_addr_signal_max; 518 518 unsigned int local_addr_max; 519 519 struct pm_nl_pernet *pernet; ··· 555 555 556 556 /* check first for announce */ 557 557 if (msk->pm.add_addr_signaled < add_addr_signal_max) { 558 - local = select_signal_address(pernet, msk); 559 - 560 558 /* due to racing events on both ends we can reach here while 561 559 * previous add address is still running: if we invoke now 562 560 * mptcp_pm_announce_addr(), that will fail and the ··· 565 567 if (msk->pm.addr_signal & BIT(MPTCP_ADD_ADDR_SIGNAL)) 566 568 return; 567 569 568 - if (local) { 569 - if (mptcp_pm_alloc_anno_list(msk, &local->addr)) { 570 - __clear_bit(local->addr.id, msk->pm.id_avail_bitmap); 571 - msk->pm.add_addr_signaled++; 572 - mptcp_pm_announce_addr(msk, &local->addr, false); 573 - mptcp_pm_nl_addr_send_ack(msk); 574 - } 575 - } 570 + local = select_signal_address(pernet, msk); 571 + if (!local) 572 + goto subflow; 573 + 574 + /* If the alloc fails, we are on memory pressure, not worth 575 + * continuing, and trying to create subflows. 576 + */ 577 + if (!mptcp_pm_alloc_anno_list(msk, &local->addr)) 578 + return; 579 + 580 + __clear_bit(local->addr.id, msk->pm.id_avail_bitmap); 581 + msk->pm.add_addr_signaled++; 582 + mptcp_pm_announce_addr(msk, &local->addr, false); 583 + mptcp_pm_nl_addr_send_ack(msk); 584 + 585 + if (local->flags & MPTCP_PM_ADDR_FLAG_SUBFLOW) 586 + signal_and_subflow = local; 576 587 } 577 588 589 + subflow: 578 590 /* check if should create a new subflow */ 579 591 while (msk->pm.local_addr_used < local_addr_max && 580 592 msk->pm.subflows < subflows_max) { ··· 592 584 bool fullmesh; 593 585 int i, nr; 594 586 595 - local = select_local_address(pernet, msk); 596 - if (!local) 597 - break; 587 + if (signal_and_subflow) { 588 + local = signal_and_subflow; 589 + signal_and_subflow = NULL; 590 + } else { 591 + local = select_local_address(pernet, msk); 592 + if (!local) 593 + break; 594 + } 598 595 599 596 fullmesh = !!(local->flags & MPTCP_PM_ADDR_FLAG_FULLMESH); 600 597 ··· 1341 1328 if (ret < 0) 1342 1329 return ret; 1343 1330 1344 - if (addr.addr.port && !(addr.flags & MPTCP_PM_ADDR_FLAG_SIGNAL)) { 1345 - GENL_SET_ERR_MSG(info, "flags must have signal when using port"); 1331 + if (addr.addr.port && !address_use_port(&addr)) { 1332 + GENL_SET_ERR_MSG(info, "flags must have signal and not subflow when using port"); 1346 1333 return -EINVAL; 1347 1334 } 1348 1335
+11 -8
net/sctp/input.c
··· 735 735 struct sock *sk = ep->base.sk; 736 736 struct net *net = sock_net(sk); 737 737 struct sctp_hashbucket *head; 738 + int err = 0; 738 739 739 740 ep->hashent = sctp_ep_hashfn(net, ep->base.bind_addr.port); 740 741 head = &sctp_ep_hashtable[ep->hashent]; 741 742 743 + write_lock(&head->lock); 742 744 if (sk->sk_reuseport) { 743 745 bool any = sctp_is_ep_boundall(sk); 744 746 struct sctp_endpoint *ep2; 745 747 struct list_head *list; 746 - int cnt = 0, err = 1; 748 + int cnt = 0; 749 + 750 + err = 1; 747 751 748 752 list_for_each(list, &ep->base.bind_addr.address_list) 749 753 cnt++; ··· 765 761 if (!err) { 766 762 err = reuseport_add_sock(sk, sk2, any); 767 763 if (err) 768 - return err; 764 + goto out; 769 765 break; 770 766 } else if (err < 0) { 771 - return err; 767 + goto out; 772 768 } 773 769 } 774 770 775 771 if (err) { 776 772 err = reuseport_alloc(sk, any); 777 773 if (err) 778 - return err; 774 + goto out; 779 775 } 780 776 } 781 777 782 - write_lock(&head->lock); 783 778 hlist_add_head(&ep->node, &head->chain); 779 + out: 784 780 write_unlock(&head->lock); 785 - return 0; 781 + return err; 786 782 } 787 783 788 784 /* Add an endpoint to the hash. Local BH-safe. */ ··· 807 803 808 804 head = &sctp_ep_hashtable[ep->hashent]; 809 805 806 + write_lock(&head->lock); 810 807 if (rcu_access_pointer(sk->sk_reuseport_cb)) 811 808 reuseport_detach_sock(sk); 812 - 813 - write_lock(&head->lock); 814 809 hlist_del_init(&ep->node); 815 810 write_unlock(&head->lock); 816 811 }
+1 -1
net/smc/smc_stats.h
··· 19 19 20 20 #include "smc_clc.h" 21 21 22 - #define SMC_MAX_FBACK_RSN_CNT 30 22 + #define SMC_MAX_FBACK_RSN_CNT 36 23 23 24 24 enum { 25 25 SMC_BUF_8K,
+2 -3
scripts/syscall.tbl
··· 98 98 77 common tee sys_tee 99 99 78 common readlinkat sys_readlinkat 100 100 79 stat64 fstatat64 sys_fstatat64 101 - 79 newstat fstatat sys_newfstatat 101 + 79 64 newfstatat sys_newfstatat 102 102 80 stat64 fstat64 sys_fstat64 103 - 80 newstat fstat sys_newfstat 103 + 80 64 newfstat sys_newfstat 104 104 81 common sync sys_sync 105 105 82 common fsync sys_fsync 106 106 83 common fdatasync sys_fdatasync ··· 402 402 460 common lsm_set_self_attr sys_lsm_set_self_attr 403 403 461 common lsm_list_modules sys_lsm_list_modules 404 404 462 common mseal sys_mseal 405 - 467 common uretprobe sys_uretprobe
+2 -12
sound/core/seq/seq_ports.h
··· 7 7 #define __SND_SEQ_PORTS_H 8 8 9 9 #include <sound/seq_kernel.h> 10 + #include <sound/ump_convert.h> 10 11 #include "seq_lock.h" 11 12 12 13 /* list of 'exported' ports */ ··· 41 40 rwlock_t list_lock; 42 41 int (*open)(void *private_data, struct snd_seq_port_subscribe *info); 43 42 int (*close)(void *private_data, struct snd_seq_port_subscribe *info); 44 - }; 45 - 46 - /* context for converting from legacy control event to UMP packet */ 47 - struct snd_seq_ump_midi2_bank { 48 - bool rpn_set; 49 - bool nrpn_set; 50 - bool bank_set; 51 - unsigned char cc_rpn_msb, cc_rpn_lsb; 52 - unsigned char cc_nrpn_msb, cc_nrpn_lsb; 53 - unsigned char cc_data_msb, cc_data_lsb; 54 - unsigned char cc_bank_msb, cc_bank_lsb; 55 43 }; 56 44 57 45 struct snd_seq_client_port { ··· 78 88 unsigned char ump_group; 79 89 80 90 #if IS_ENABLED(CONFIG_SND_SEQ_UMP) 81 - struct snd_seq_ump_midi2_bank midi2_bank[16]; /* per channel */ 91 + struct ump_cvt_to_ump_bank midi2_bank[16]; /* per channel */ 82 92 #endif 83 93 }; 84 94
+86 -52
sound/core/seq/seq_ump_convert.c
··· 368 368 struct snd_seq_ump_event ev_cvt; 369 369 const union snd_ump_midi1_msg *midi1 = (const union snd_ump_midi1_msg *)event->ump; 370 370 union snd_ump_midi2_msg *midi2 = (union snd_ump_midi2_msg *)ev_cvt.ump; 371 - struct snd_seq_ump_midi2_bank *cc; 371 + struct ump_cvt_to_ump_bank *cc; 372 372 373 373 ev_cvt = *event; 374 374 memset(&ev_cvt.ump, 0, sizeof(ev_cvt.ump)); ··· 789 789 return 1; 790 790 } 791 791 792 - /* set up the MIDI2 RPN/NRPN packet data from the parsed info */ 793 - static void fill_rpn(struct snd_seq_ump_midi2_bank *cc, 794 - union snd_ump_midi2_msg *data, 795 - unsigned char channel) 792 + static void reset_rpn(struct ump_cvt_to_ump_bank *cc) 796 793 { 794 + cc->rpn_set = 0; 795 + cc->nrpn_set = 0; 796 + cc->cc_rpn_msb = cc->cc_rpn_lsb = 0; 797 + cc->cc_data_msb = cc->cc_data_lsb = 0; 798 + cc->cc_data_msb_set = cc->cc_data_lsb_set = 0; 799 + } 800 + 801 + /* set up the MIDI2 RPN/NRPN packet data from the parsed info */ 802 + static int fill_rpn(struct ump_cvt_to_ump_bank *cc, 803 + union snd_ump_midi2_msg *data, 804 + unsigned char channel, 805 + bool flush) 806 + { 807 + if (!(cc->cc_data_lsb_set || cc->cc_data_msb_set)) 808 + return 0; // skip 809 + /* when not flushing, wait for complete data set */ 810 + if (!flush && (!cc->cc_data_lsb_set || !cc->cc_data_msb_set)) 811 + return 0; // skip 812 + 797 813 if (cc->rpn_set) { 798 814 data->rpn.status = UMP_MSG_STATUS_RPN; 799 815 data->rpn.bank = cc->cc_rpn_msb; 800 816 data->rpn.index = cc->cc_rpn_lsb; 801 - cc->rpn_set = 0; 802 - cc->cc_rpn_msb = cc->cc_rpn_lsb = 0; 803 - } else { 817 + } else if (cc->nrpn_set) { 804 818 data->rpn.status = UMP_MSG_STATUS_NRPN; 805 819 data->rpn.bank = cc->cc_nrpn_msb; 806 820 data->rpn.index = cc->cc_nrpn_lsb; 807 - cc->nrpn_set = 0; 808 - cc->cc_nrpn_msb = cc->cc_nrpn_lsb = 0; 821 + } else { 822 + return 0; // skip 809 823 } 824 + 810 825 data->rpn.data = upscale_14_to_32bit((cc->cc_data_msb << 7) | 811 826 cc->cc_data_lsb); 812 827 data->rpn.channel = channel; 813 - cc->cc_data_msb = cc->cc_data_lsb = 0; 828 + 829 + reset_rpn(cc); 830 + return 1; 814 831 } 815 832 816 833 /* convert CC event to MIDI 2.0 UMP */ ··· 839 822 unsigned char channel = event->data.control.channel & 0x0f; 840 823 unsigned char index = event->data.control.param & 0x7f; 841 824 unsigned char val = event->data.control.value & 0x7f; 842 - struct snd_seq_ump_midi2_bank *cc = &dest_port->midi2_bank[channel]; 825 + struct ump_cvt_to_ump_bank *cc = &dest_port->midi2_bank[channel]; 826 + int ret; 843 827 844 828 /* process special CC's (bank/rpn/nrpn) */ 845 829 switch (index) { 846 830 case UMP_CC_RPN_MSB: 831 + ret = fill_rpn(cc, data, channel, true); 847 832 cc->rpn_set = 1; 848 833 cc->cc_rpn_msb = val; 849 - return 0; // skip 834 + if (cc->cc_rpn_msb == 0x7f && cc->cc_rpn_lsb == 0x7f) 835 + reset_rpn(cc); 836 + return ret; 850 837 case UMP_CC_RPN_LSB: 838 + ret = fill_rpn(cc, data, channel, true); 851 839 cc->rpn_set = 1; 852 840 cc->cc_rpn_lsb = val; 853 - return 0; // skip 841 + if (cc->cc_rpn_msb == 0x7f && cc->cc_rpn_lsb == 0x7f) 842 + reset_rpn(cc); 843 + return ret; 854 844 case UMP_CC_NRPN_MSB: 845 + ret = fill_rpn(cc, data, channel, true); 855 846 cc->nrpn_set = 1; 856 847 cc->cc_nrpn_msb = val; 857 - return 0; // skip 848 + return ret; 858 849 case UMP_CC_NRPN_LSB: 850 + ret = fill_rpn(cc, data, channel, true); 859 851 cc->nrpn_set = 1; 860 852 cc->cc_nrpn_lsb = val; 861 - return 0; // skip 853 + return ret; 862 854 case UMP_CC_DATA: 855 + cc->cc_data_msb_set = 1; 863 856 cc->cc_data_msb = val; 864 - return 0; // skip 857 + return fill_rpn(cc, data, channel, false); 865 858 case UMP_CC_BANK_SELECT: 866 859 cc->bank_set = 1; 867 860 cc->cc_bank_msb = val; ··· 881 854 cc->cc_bank_lsb = val; 882 855 return 0; // skip 883 856 case UMP_CC_DATA_LSB: 857 + cc->cc_data_lsb_set = 1; 884 858 cc->cc_data_lsb = val; 885 - if (!(cc->rpn_set || cc->nrpn_set)) 886 - return 0; // skip 887 - fill_rpn(cc, data, channel); 888 - return 1; 859 + return fill_rpn(cc, data, channel, false); 889 860 } 890 861 891 862 data->cc.status = status; ··· 912 887 unsigned char status) 913 888 { 914 889 unsigned char channel = event->data.control.channel & 0x0f; 915 - struct snd_seq_ump_midi2_bank *cc = &dest_port->midi2_bank[channel]; 890 + struct ump_cvt_to_ump_bank *cc = &dest_port->midi2_bank[channel]; 916 891 917 892 data->pg.status = status; 918 893 data->pg.channel = channel; ··· 949 924 { 950 925 unsigned char channel = event->data.control.channel & 0x0f; 951 926 unsigned char index = event->data.control.param & 0x7f; 952 - struct snd_seq_ump_midi2_bank *cc = &dest_port->midi2_bank[channel]; 927 + struct ump_cvt_to_ump_bank *cc = &dest_port->midi2_bank[channel]; 953 928 unsigned char msb, lsb; 929 + int ret; 954 930 955 931 msb = (event->data.control.value >> 7) & 0x7f; 956 932 lsb = event->data.control.value & 0x7f; ··· 965 939 cc->cc_bank_lsb = lsb; 966 940 return 0; // skip 967 941 case UMP_CC_RPN_MSB: 968 - cc->cc_rpn_msb = msb; 969 - fallthrough; 970 942 case UMP_CC_RPN_LSB: 971 - cc->rpn_set = 1; 943 + ret = fill_rpn(cc, data, channel, true); 944 + cc->cc_rpn_msb = msb; 972 945 cc->cc_rpn_lsb = lsb; 973 - return 0; // skip 946 + cc->rpn_set = 1; 947 + if (cc->cc_rpn_msb == 0x7f && cc->cc_rpn_lsb == 0x7f) 948 + reset_rpn(cc); 949 + return ret; 974 950 case UMP_CC_NRPN_MSB: 975 - cc->cc_nrpn_msb = msb; 976 - fallthrough; 977 951 case UMP_CC_NRPN_LSB: 952 + ret = fill_rpn(cc, data, channel, true); 953 + cc->cc_nrpn_msb = msb; 978 954 cc->nrpn_set = 1; 979 955 cc->cc_nrpn_lsb = lsb; 980 - return 0; // skip 956 + return ret; 981 957 case UMP_CC_DATA: 982 - cc->cc_data_msb = msb; 983 - fallthrough; 984 958 case UMP_CC_DATA_LSB: 959 + cc->cc_data_msb_set = cc->cc_data_lsb_set = 1; 960 + cc->cc_data_msb = msb; 985 961 cc->cc_data_lsb = lsb; 986 - if (!(cc->rpn_set || cc->nrpn_set)) 987 - return 0; // skip 988 - fill_rpn(cc, data, channel); 989 - return 1; 962 + return fill_rpn(cc, data, channel, false); 990 963 } 991 964 992 965 data->cc.status = UMP_MSG_STATUS_CC; ··· 1217 1192 { 1218 1193 struct snd_seq_ump_event ev_cvt; 1219 1194 unsigned char status; 1220 - u8 buf[6], *xbuf; 1195 + u8 buf[8], *xbuf; 1221 1196 int offset = 0; 1222 1197 int len, err; 1198 + bool finished = false; 1223 1199 1224 1200 if (!snd_seq_ev_is_variable(event)) 1225 1201 return 0; 1226 1202 1227 1203 setup_ump_event(&ev_cvt, event); 1228 - for (;;) { 1204 + while (!finished) { 1229 1205 len = snd_seq_expand_var_event_at(event, sizeof(buf), buf, offset); 1230 1206 if (len <= 0) 1231 1207 break; 1232 - if (WARN_ON(len > 6)) 1208 + if (WARN_ON(len > sizeof(buf))) 1233 1209 break; 1234 - offset += len; 1210 + 1235 1211 xbuf = buf; 1212 + status = UMP_SYSEX_STATUS_CONTINUE; 1213 + /* truncate the sysex start-marker */ 1236 1214 if (*xbuf == UMP_MIDI1_MSG_SYSEX_START) { 1237 1215 status = UMP_SYSEX_STATUS_START; 1238 - xbuf++; 1239 1216 len--; 1240 - if (len > 0 && xbuf[len - 1] == UMP_MIDI1_MSG_SYSEX_END) { 1241 - status = UMP_SYSEX_STATUS_SINGLE; 1242 - len--; 1243 - } 1244 - } else { 1245 - if (xbuf[len - 1] == UMP_MIDI1_MSG_SYSEX_END) { 1246 - status = UMP_SYSEX_STATUS_END; 1247 - len--; 1248 - } else { 1249 - status = UMP_SYSEX_STATUS_CONTINUE; 1250 - } 1217 + offset++; 1218 + xbuf++; 1251 1219 } 1220 + 1221 + /* if the last of this packet or the 1st byte of the next packet 1222 + * is the end-marker, finish the transfer with this packet 1223 + */ 1224 + if (len > 0 && len < 8 && 1225 + xbuf[len - 1] == UMP_MIDI1_MSG_SYSEX_END) { 1226 + if (status == UMP_SYSEX_STATUS_START) 1227 + status = UMP_SYSEX_STATUS_SINGLE; 1228 + else 1229 + status = UMP_SYSEX_STATUS_END; 1230 + len--; 1231 + finished = true; 1232 + } 1233 + 1234 + len = min(len, 6); 1252 1235 fill_sysex7_ump(dest_port, ev_cvt.ump, status, xbuf, len); 1253 1236 err = __snd_seq_deliver_single_event(dest, dest_port, 1254 1237 (struct snd_seq_event *)&ev_cvt, 1255 1238 atomic, hop); 1256 1239 if (err < 0) 1257 1240 return err; 1241 + offset += len; 1258 1242 } 1259 1243 return 0; 1260 1244 }
+42 -18
sound/core/ump_convert.c
··· 287 287 return 4; 288 288 } 289 289 290 - static void fill_rpn(struct ump_cvt_to_ump_bank *cc, 291 - union snd_ump_midi2_msg *midi2) 290 + static void reset_rpn(struct ump_cvt_to_ump_bank *cc) 292 291 { 292 + cc->rpn_set = 0; 293 + cc->nrpn_set = 0; 294 + cc->cc_rpn_msb = cc->cc_rpn_lsb = 0; 295 + cc->cc_data_msb = cc->cc_data_lsb = 0; 296 + cc->cc_data_msb_set = cc->cc_data_lsb_set = 0; 297 + } 298 + 299 + static int fill_rpn(struct ump_cvt_to_ump_bank *cc, 300 + union snd_ump_midi2_msg *midi2, 301 + bool flush) 302 + { 303 + if (!(cc->cc_data_lsb_set || cc->cc_data_msb_set)) 304 + return 0; // skip 305 + /* when not flushing, wait for complete data set */ 306 + if (!flush && (!cc->cc_data_lsb_set || !cc->cc_data_msb_set)) 307 + return 0; // skip 308 + 293 309 if (cc->rpn_set) { 294 310 midi2->rpn.status = UMP_MSG_STATUS_RPN; 295 311 midi2->rpn.bank = cc->cc_rpn_msb; 296 312 midi2->rpn.index = cc->cc_rpn_lsb; 297 - cc->rpn_set = 0; 298 - cc->cc_rpn_msb = cc->cc_rpn_lsb = 0; 299 - } else { 313 + } else if (cc->nrpn_set) { 300 314 midi2->rpn.status = UMP_MSG_STATUS_NRPN; 301 315 midi2->rpn.bank = cc->cc_nrpn_msb; 302 316 midi2->rpn.index = cc->cc_nrpn_lsb; 303 - cc->nrpn_set = 0; 304 - cc->cc_nrpn_msb = cc->cc_nrpn_lsb = 0; 317 + } else { 318 + return 0; // skip 305 319 } 320 + 306 321 midi2->rpn.data = upscale_14_to_32bit((cc->cc_data_msb << 7) | 307 322 cc->cc_data_lsb); 308 - cc->cc_data_msb = cc->cc_data_lsb = 0; 323 + 324 + reset_rpn(cc); 325 + return 1; 309 326 } 310 327 311 328 /* convert to a MIDI 1.0 Channel Voice message */ ··· 335 318 struct ump_cvt_to_ump_bank *cc; 336 319 union snd_ump_midi2_msg *midi2 = (union snd_ump_midi2_msg *)data; 337 320 unsigned char status, channel; 321 + int ret; 338 322 339 323 BUILD_BUG_ON(sizeof(union snd_ump_midi1_msg) != 4); 340 324 BUILD_BUG_ON(sizeof(union snd_ump_midi2_msg) != 8); ··· 376 358 case UMP_MSG_STATUS_CC: 377 359 switch (buf[1]) { 378 360 case UMP_CC_RPN_MSB: 361 + ret = fill_rpn(cc, midi2, true); 379 362 cc->rpn_set = 1; 380 363 cc->cc_rpn_msb = buf[2]; 381 - return 0; // skip 364 + if (cc->cc_rpn_msb == 0x7f && cc->cc_rpn_lsb == 0x7f) 365 + reset_rpn(cc); 366 + return ret; 382 367 case UMP_CC_RPN_LSB: 368 + ret = fill_rpn(cc, midi2, true); 383 369 cc->rpn_set = 1; 384 370 cc->cc_rpn_lsb = buf[2]; 385 - return 0; // skip 371 + if (cc->cc_rpn_msb == 0x7f && cc->cc_rpn_lsb == 0x7f) 372 + reset_rpn(cc); 373 + return ret; 386 374 case UMP_CC_NRPN_MSB: 375 + ret = fill_rpn(cc, midi2, true); 387 376 cc->nrpn_set = 1; 388 377 cc->cc_nrpn_msb = buf[2]; 389 - return 0; // skip 378 + return ret; 390 379 case UMP_CC_NRPN_LSB: 380 + ret = fill_rpn(cc, midi2, true); 391 381 cc->nrpn_set = 1; 392 382 cc->cc_nrpn_lsb = buf[2]; 393 - return 0; // skip 383 + return ret; 394 384 case UMP_CC_DATA: 385 + cc->cc_data_msb_set = 1; 395 386 cc->cc_data_msb = buf[2]; 396 - return 0; // skip 387 + return fill_rpn(cc, midi2, false); 397 388 case UMP_CC_BANK_SELECT: 398 389 cc->bank_set = 1; 399 390 cc->cc_bank_msb = buf[2]; ··· 412 385 cc->cc_bank_lsb = buf[2]; 413 386 return 0; // skip 414 387 case UMP_CC_DATA_LSB: 388 + cc->cc_data_lsb_set = 1; 415 389 cc->cc_data_lsb = buf[2]; 416 - if (cc->rpn_set || cc->nrpn_set) 417 - fill_rpn(cc, midi2); 418 - else 419 - return 0; // skip 420 - break; 390 + return fill_rpn(cc, midi2, false); 421 391 default: 422 392 midi2->cc.index = buf[1]; 423 393 midi2->cc.data = upscale_7_to_32bit(buf[2]);
+24 -14
sound/firewire/amdtp-stream.c
··· 77 77 // overrun. Actual device can skip more, then this module stops the packet streaming. 78 78 #define IR_JUMBO_PAYLOAD_MAX_SKIP_CYCLES 5 79 79 80 + static void pcm_period_work(struct work_struct *work); 81 + 80 82 /** 81 83 * amdtp_stream_init - initialize an AMDTP stream structure 82 84 * @s: the AMDTP stream to initialize ··· 107 105 s->flags = flags; 108 106 s->context = ERR_PTR(-1); 109 107 mutex_init(&s->mutex); 108 + INIT_WORK(&s->period_work, pcm_period_work); 110 109 s->packet_index = 0; 111 110 112 111 init_waitqueue_head(&s->ready_wait); ··· 350 347 */ 351 348 void amdtp_stream_pcm_prepare(struct amdtp_stream *s) 352 349 { 350 + cancel_work_sync(&s->period_work); 353 351 s->pcm_buffer_pointer = 0; 354 352 s->pcm_period_pointer = 0; 355 353 } ··· 615 611 // The program in user process should periodically check the status of intermediate 616 612 // buffer associated to PCM substream to process PCM frames in the buffer, instead 617 613 // of receiving notification of period elapsed by poll wait. 618 - if (!pcm->runtime->no_period_wakeup) { 619 - if (in_softirq()) { 620 - // In software IRQ context for 1394 OHCI. 621 - snd_pcm_period_elapsed(pcm); 622 - } else { 623 - // In process context of ALSA PCM application under acquired lock of 624 - // PCM substream. 625 - snd_pcm_period_elapsed_under_stream_lock(pcm); 626 - } 627 - } 614 + if (!pcm->runtime->no_period_wakeup) 615 + queue_work(system_highpri_wq, &s->period_work); 628 616 } 617 + } 618 + 619 + static void pcm_period_work(struct work_struct *work) 620 + { 621 + struct amdtp_stream *s = container_of(work, struct amdtp_stream, 622 + period_work); 623 + struct snd_pcm_substream *pcm = READ_ONCE(s->pcm); 624 + 625 + if (pcm) 626 + snd_pcm_period_elapsed(pcm); 629 627 } 630 628 631 629 static int queue_packet(struct amdtp_stream *s, struct fw_iso_packet *params, ··· 1855 1849 { 1856 1850 struct amdtp_stream *irq_target = d->irq_target; 1857 1851 1858 - // Process isochronous packets queued till recent isochronous cycle to handle PCM frames. 1859 1852 if (irq_target && amdtp_stream_running(irq_target)) { 1860 - // In software IRQ context, the call causes dead-lock to disable the tasklet 1861 - // synchronously. 1862 - if (!in_softirq()) 1853 + // use wq to prevent AB/BA deadlock competition for 1854 + // substream lock: 1855 + // fw_iso_context_flush_completions() acquires 1856 + // lock by ohci_flush_iso_completions(), 1857 + // amdtp-stream process_rx_packets() attempts to 1858 + // acquire same lock by snd_pcm_elapsed() 1859 + if (current_work() != &s->period_work) 1863 1860 fw_iso_context_flush_completions(irq_target->context); 1864 1861 } 1865 1862 ··· 1918 1909 return; 1919 1910 } 1920 1911 1912 + cancel_work_sync(&s->period_work); 1921 1913 fw_iso_context_stop(s->context); 1922 1914 fw_iso_context_destroy(s->context); 1923 1915 s->context = ERR_PTR(-1);
+1
sound/firewire/amdtp-stream.h
··· 191 191 192 192 /* For a PCM substream processing. */ 193 193 struct snd_pcm_substream *pcm; 194 + struct work_struct period_work; 194 195 snd_pcm_uframes_t pcm_buffer_pointer; 195 196 unsigned int pcm_period_pointer; 196 197 unsigned int pcm_frame_multiplier;
+1 -1
sound/pci/hda/hda_controller.h
··· 28 28 #else 29 29 #define AZX_DCAPS_I915_COMPONENT 0 /* NOP */ 30 30 #endif 31 - /* 14 unused */ 31 + #define AZX_DCAPS_AMD_ALLOC_FIX (1 << 14) /* AMD allocation workaround */ 32 32 #define AZX_DCAPS_CTX_WORKAROUND (1 << 15) /* X-Fi workaround */ 33 33 #define AZX_DCAPS_POSFIX_LPIB (1 << 16) /* Use LPIB as default */ 34 34 #define AZX_DCAPS_AMD_WORKAROUND (1 << 17) /* AMD-specific workaround */
+63
sound/pci/hda/hda_generic.c
··· 4955 4955 } 4956 4956 EXPORT_SYMBOL_GPL(snd_hda_gen_stream_pm); 4957 4957 4958 + /* forcibly mute the speaker output without caching; return true if updated */ 4959 + static bool force_mute_output_path(struct hda_codec *codec, hda_nid_t nid) 4960 + { 4961 + if (!nid) 4962 + return false; 4963 + if (!nid_has_mute(codec, nid, HDA_OUTPUT)) 4964 + return false; /* no mute, skip */ 4965 + if (snd_hda_codec_amp_read(codec, nid, 0, HDA_OUTPUT, 0) & 4966 + snd_hda_codec_amp_read(codec, nid, 1, HDA_OUTPUT, 0) & 4967 + HDA_AMP_MUTE) 4968 + return false; /* both channels already muted, skip */ 4969 + 4970 + /* direct amp update without caching */ 4971 + snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, 4972 + AC_AMP_SET_OUTPUT | AC_AMP_SET_LEFT | 4973 + AC_AMP_SET_RIGHT | HDA_AMP_MUTE); 4974 + return true; 4975 + } 4976 + 4977 + /** 4978 + * snd_hda_gen_shutup_speakers - Forcibly mute the speaker outputs 4979 + * @codec: the HDA codec 4980 + * 4981 + * Forcibly mute the speaker outputs, to be called at suspend or shutdown. 4982 + * 4983 + * The mute state done by this function isn't cached, hence the original state 4984 + * will be restored at resume. 4985 + * 4986 + * Return true if the mute state has been changed. 4987 + */ 4988 + bool snd_hda_gen_shutup_speakers(struct hda_codec *codec) 4989 + { 4990 + struct hda_gen_spec *spec = codec->spec; 4991 + const int *paths; 4992 + const struct nid_path *path; 4993 + int i, p, num_paths; 4994 + bool updated = false; 4995 + 4996 + /* if already powered off, do nothing */ 4997 + if (!snd_hdac_is_power_on(&codec->core)) 4998 + return false; 4999 + 5000 + if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT) { 5001 + paths = spec->out_paths; 5002 + num_paths = spec->autocfg.line_outs; 5003 + } else { 5004 + paths = spec->speaker_paths; 5005 + num_paths = spec->autocfg.speaker_outs; 5006 + } 5007 + 5008 + for (i = 0; i < num_paths; i++) { 5009 + path = snd_hda_get_path_from_idx(codec, paths[i]); 5010 + if (!path) 5011 + continue; 5012 + for (p = 0; p < path->depth; p++) 5013 + if (force_mute_output_path(codec, path->path[p])) 5014 + updated = true; 5015 + } 5016 + 5017 + return updated; 5018 + } 5019 + EXPORT_SYMBOL_GPL(snd_hda_gen_shutup_speakers); 5020 + 4958 5021 /** 4959 5022 * snd_hda_gen_parse_auto_config - Parse the given BIOS configuration and 4960 5023 * set up the hda_gen_spec
+1
sound/pci/hda/hda_generic.h
··· 353 353 int snd_hda_gen_add_micmute_led_cdev(struct hda_codec *codec, 354 354 int (*callback)(struct led_classdev *, 355 355 enum led_brightness)); 356 + bool snd_hda_gen_shutup_speakers(struct hda_codec *codec); 356 357 357 358 #endif /* __SOUND_HDA_GENERIC_H */
+9 -1
sound/pci/hda/hda_intel.c
··· 40 40 41 41 #ifdef CONFIG_X86 42 42 /* for snoop control */ 43 + #include <linux/dma-map-ops.h> 43 44 #include <asm/set_memory.h> 44 45 #include <asm/cpufeature.h> 45 46 #endif ··· 307 306 308 307 /* quirks for ATI HDMI with snoop off */ 309 308 #define AZX_DCAPS_PRESET_ATI_HDMI_NS \ 310 - (AZX_DCAPS_PRESET_ATI_HDMI | AZX_DCAPS_SNOOP_OFF) 309 + (AZX_DCAPS_PRESET_ATI_HDMI | AZX_DCAPS_AMD_ALLOC_FIX) 311 310 312 311 /* quirks for AMD SB */ 313 312 #define AZX_DCAPS_PRESET_AMD_SB \ ··· 1702 1701 1703 1702 if (chip->driver_caps & AZX_DCAPS_SNOOP_OFF) 1704 1703 snoop = false; 1704 + 1705 + #ifdef CONFIG_X86 1706 + /* check the presence of DMA ops (i.e. IOMMU), disable snoop conditionally */ 1707 + if ((chip->driver_caps & AZX_DCAPS_AMD_ALLOC_FIX) && 1708 + !get_dma_ops(chip->card->dev)) 1709 + snoop = false; 1710 + #endif 1705 1711 1706 1712 chip->snoop = snoop; 1707 1713 if (!snoop) {
+11 -45
sound/pci/hda/patch_conexant.c
··· 21 21 #include "hda_jack.h" 22 22 #include "hda_generic.h" 23 23 24 - enum { 25 - CX_HEADSET_NOPRESENT = 0, 26 - CX_HEADSET_PARTPRESENT, 27 - CX_HEADSET_ALLPRESENT, 28 - }; 29 - 30 24 struct conexant_spec { 31 25 struct hda_gen_spec gen; 32 26 ··· 42 48 unsigned int gpio_led; 43 49 unsigned int gpio_mute_led_mask; 44 50 unsigned int gpio_mic_led_mask; 45 - unsigned int headset_present_flag; 46 51 bool is_cx8070_sn6140; 47 52 }; 48 53 ··· 205 212 { 206 213 struct conexant_spec *spec = codec->spec; 207 214 215 + snd_hda_gen_shutup_speakers(codec); 216 + 208 217 /* Turn the problematic codec into D3 to avoid spurious noises 209 218 from the internal speaker during (and after) reboot */ 210 219 cx_auto_turn_eapd(codec, spec->num_eapds, spec->eapds, false); ··· 245 250 } 246 251 } 247 252 248 - static void cx_update_headset_mic_vref(struct hda_codec *codec, unsigned int res) 253 + static void cx_update_headset_mic_vref(struct hda_codec *codec, struct hda_jack_callback *event) 249 254 { 250 - unsigned int phone_present, mic_persent, phone_tag, mic_tag; 251 - struct conexant_spec *spec = codec->spec; 255 + unsigned int mic_present; 252 256 253 257 /* In cx8070 and sn6140, the node 16 can only be config to headphone or disabled, 254 258 * the node 19 can only be config to microphone or disabled. 255 259 * Check hp&mic tag to process headset pulgin&plugout. 256 260 */ 257 - phone_tag = snd_hda_codec_read(codec, 0x16, 0, AC_VERB_GET_UNSOLICITED_RESPONSE, 0x0); 258 - mic_tag = snd_hda_codec_read(codec, 0x19, 0, AC_VERB_GET_UNSOLICITED_RESPONSE, 0x0); 259 - if ((phone_tag & (res >> AC_UNSOL_RES_TAG_SHIFT)) || 260 - (mic_tag & (res >> AC_UNSOL_RES_TAG_SHIFT))) { 261 - phone_present = snd_hda_codec_read(codec, 0x16, 0, AC_VERB_GET_PIN_SENSE, 0x0); 262 - if (!(phone_present & AC_PINSENSE_PRESENCE)) {/* headphone plugout */ 263 - spec->headset_present_flag = CX_HEADSET_NOPRESENT; 264 - snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20); 265 - return; 266 - } 267 - if (spec->headset_present_flag == CX_HEADSET_NOPRESENT) { 268 - spec->headset_present_flag = CX_HEADSET_PARTPRESENT; 269 - } else if (spec->headset_present_flag == CX_HEADSET_PARTPRESENT) { 270 - mic_persent = snd_hda_codec_read(codec, 0x19, 0, 271 - AC_VERB_GET_PIN_SENSE, 0x0); 272 - /* headset is present */ 273 - if ((phone_present & AC_PINSENSE_PRESENCE) && 274 - (mic_persent & AC_PINSENSE_PRESENCE)) { 275 - cx_process_headset_plugin(codec); 276 - spec->headset_present_flag = CX_HEADSET_ALLPRESENT; 277 - } 278 - } 279 - } 280 - } 281 - 282 - static void cx_jack_unsol_event(struct hda_codec *codec, unsigned int res) 283 - { 284 - struct conexant_spec *spec = codec->spec; 285 - 286 - if (spec->is_cx8070_sn6140) 287 - cx_update_headset_mic_vref(codec, res); 288 - 289 - snd_hda_jack_unsol_event(codec, res); 261 + mic_present = snd_hda_codec_read(codec, 0x19, 0, AC_VERB_GET_PIN_SENSE, 0x0); 262 + if (!(mic_present & AC_PINSENSE_PRESENCE)) /* mic plugout */ 263 + snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20); 264 + else 265 + cx_process_headset_plugin(codec); 290 266 } 291 267 292 268 static int cx_auto_suspend(struct hda_codec *codec) ··· 271 305 .build_pcms = snd_hda_gen_build_pcms, 272 306 .init = cx_auto_init, 273 307 .free = cx_auto_free, 274 - .unsol_event = cx_jack_unsol_event, 308 + .unsol_event = snd_hda_jack_unsol_event, 275 309 .suspend = cx_auto_suspend, 276 310 .check_power_status = snd_hda_gen_check_power_status, 277 311 }; ··· 1129 1163 case 0x14f11f86: 1130 1164 case 0x14f11f87: 1131 1165 spec->is_cx8070_sn6140 = true; 1132 - spec->headset_present_flag = CX_HEADSET_NOPRESENT; 1166 + snd_hda_jack_detect_enable_callback(codec, 0x19, cx_update_headset_mic_vref); 1133 1167 break; 1134 1168 } 1135 1169
+1
sound/pci/hda/patch_realtek.c
··· 9872 9872 SND_PCI_QUIRK(0x1025, 0x079b, "Acer Aspire V5-573G", ALC282_FIXUP_ASPIRE_V5_PINS), 9873 9873 SND_PCI_QUIRK(0x1025, 0x080d, "Acer Aspire V5-122P", ALC269_FIXUP_ASPIRE_HEADSET_MIC), 9874 9874 SND_PCI_QUIRK(0x1025, 0x0840, "Acer Aspire E1", ALC269VB_FIXUP_ASPIRE_E1_COEF), 9875 + SND_PCI_QUIRK(0x1025, 0x100c, "Acer Aspire E5-574G", ALC255_FIXUP_ACER_LIMIT_INT_MIC_BOOST), 9875 9876 SND_PCI_QUIRK(0x1025, 0x101c, "Acer Veriton N2510G", ALC269_FIXUP_LIFEBOOK), 9876 9877 SND_PCI_QUIRK(0x1025, 0x102b, "Acer Aspire C24-860", ALC286_FIXUP_ACER_AIO_MIC_NO_PRESENCE), 9877 9878 SND_PCI_QUIRK(0x1025, 0x1065, "Acer Aspire C20-820", ALC269VC_FIXUP_ACER_HEADSET_MIC),
+2 -2
sound/usb/stream.c
··· 244 244 SNDRV_CHMAP_FR, /* right front */ 245 245 SNDRV_CHMAP_FC, /* center front */ 246 246 SNDRV_CHMAP_LFE, /* LFE */ 247 - SNDRV_CHMAP_SL, /* left surround */ 248 - SNDRV_CHMAP_SR, /* right surround */ 247 + SNDRV_CHMAP_RL, /* left surround */ 248 + SNDRV_CHMAP_RR, /* right surround */ 249 249 SNDRV_CHMAP_FLC, /* left of center */ 250 250 SNDRV_CHMAP_FRC, /* right of center */ 251 251 SNDRV_CHMAP_RC, /* surround */
+1 -1
tools/perf/pmu-events/arch/riscv/andes/ax45/firmware.json
··· 36 36 "ArchStdEvent": "FW_SFENCE_VMA_RECEIVED" 37 37 }, 38 38 { 39 - "ArchStdEvent": "FW_SFENCE_VMA_RECEIVED" 39 + "ArchStdEvent": "FW_SFENCE_VMA_ASID_SENT" 40 40 }, 41 41 { 42 42 "ArchStdEvent": "FW_SFENCE_VMA_ASID_RECEIVED"
+1 -1
tools/perf/pmu-events/arch/riscv/riscv-sbi-firmware.json
··· 74 74 { 75 75 "PublicDescription": "Sent SFENCE.VMA with ASID request to other HART event", 76 76 "ConfigCode": "0x800000000000000c", 77 - "EventName": "FW_SFENCE_VMA_RECEIVED", 77 + "EventName": "FW_SFENCE_VMA_ASID_SENT", 78 78 "BriefDescription": "Sent SFENCE.VMA with ASID request to other HART event" 79 79 }, 80 80 {
+1 -1
tools/perf/pmu-events/arch/riscv/sifive/u74/firmware.json
··· 36 36 "ArchStdEvent": "FW_SFENCE_VMA_RECEIVED" 37 37 }, 38 38 { 39 - "ArchStdEvent": "FW_SFENCE_VMA_RECEIVED" 39 + "ArchStdEvent": "FW_SFENCE_VMA_ASID_SENT" 40 40 }, 41 41 { 42 42 "ArchStdEvent": "FW_SFENCE_VMA_ASID_RECEIVED"
+1 -1
tools/perf/pmu-events/arch/riscv/starfive/dubhe-80/firmware.json
··· 36 36 "ArchStdEvent": "FW_SFENCE_VMA_RECEIVED" 37 37 }, 38 38 { 39 - "ArchStdEvent": "FW_SFENCE_VMA_RECEIVED" 39 + "ArchStdEvent": "FW_SFENCE_VMA_ASID_SENT" 40 40 }, 41 41 { 42 42 "ArchStdEvent": "FW_SFENCE_VMA_ASID_RECEIVED"
+1 -1
tools/perf/pmu-events/arch/riscv/thead/c900-legacy/firmware.json
··· 36 36 "ArchStdEvent": "FW_SFENCE_VMA_RECEIVED" 37 37 }, 38 38 { 39 - "ArchStdEvent": "FW_SFENCE_VMA_RECEIVED" 39 + "ArchStdEvent": "FW_SFENCE_VMA_ASID_SENT" 40 40 }, 41 41 { 42 42 "ArchStdEvent": "FW_SFENCE_VMA_ASID_RECEIVED"
+1 -1
tools/testing/selftests/bpf/prog_tests/uprobe_syscall.c
··· 216 216 } 217 217 218 218 #ifndef __NR_uretprobe 219 - #define __NR_uretprobe 467 219 + #define __NR_uretprobe 335 220 220 #endif 221 221 222 222 __naked unsigned long uretprobe_syscall_call_1(void)
+3 -1
tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c
··· 29 29 version.name = name; 30 30 31 31 ret = ioctl(fd, DRM_IOCTL_VERSION, &version); 32 - if (ret) 32 + if (ret || version.name_len != 4) 33 33 return 0; 34 + 35 + name[4] = '\0'; 34 36 35 37 return !strcmp(name, "vgem"); 36 38 }
+1 -1
tools/testing/selftests/kselftest/ksft.py
··· 70 70 71 71 72 72 def finished(): 73 - if ksft_cnt["pass"] == ksft_num_tests: 73 + if ksft_cnt["pass"] + ksft_cnt["skip"] == ksft_num_tests: 74 74 exit_code = KSFT_PASS 75 75 else: 76 76 exit_code = KSFT_FAIL
+4 -4
tools/testing/selftests/kvm/riscv/get-reg-list.c
··· 961 961 KVM_ISA_EXT_SIMPLE_CONFIG(zbkc, ZBKC); 962 962 KVM_ISA_EXT_SIMPLE_CONFIG(zbkx, ZBKX); 963 963 KVM_ISA_EXT_SIMPLE_CONFIG(zbs, ZBS); 964 - KVM_ISA_EXT_SIMPLE_CONFIG(zca, ZCA), 965 - KVM_ISA_EXT_SIMPLE_CONFIG(zcb, ZCB), 966 - KVM_ISA_EXT_SIMPLE_CONFIG(zcd, ZCD), 967 - KVM_ISA_EXT_SIMPLE_CONFIG(zcf, ZCF), 964 + KVM_ISA_EXT_SIMPLE_CONFIG(zca, ZCA); 965 + KVM_ISA_EXT_SIMPLE_CONFIG(zcb, ZCB); 966 + KVM_ISA_EXT_SIMPLE_CONFIG(zcd, ZCD); 967 + KVM_ISA_EXT_SIMPLE_CONFIG(zcf, ZCF); 968 968 KVM_ISA_EXT_SIMPLE_CONFIG(zcmop, ZCMOP); 969 969 KVM_ISA_EXT_SIMPLE_CONFIG(zfa, ZFA); 970 970 KVM_ISA_EXT_SIMPLE_CONFIG(zfh, ZFH);
+1 -1
tools/testing/selftests/mm/Makefile
··· 110 110 111 111 endif 112 112 113 - ifneq (,$(filter $(ARCH),arm64 ia64 mips64 parisc64 powerpc riscv64 s390x sparc64 x86_64)) 113 + ifneq (,$(filter $(ARCH),arm64 ia64 mips64 parisc64 powerpc riscv64 s390x sparc64 x86_64 s390)) 114 114 TEST_GEN_FILES += va_high_addr_switch 115 115 TEST_GEN_FILES += virtual_address_range 116 116 TEST_GEN_FILES += write_to_hugetlbfs
+41 -14
tools/testing/selftests/net/mptcp/mptcp_join.sh
··· 1415 1415 local add_nr=$1 1416 1416 local echo_nr=$2 1417 1417 local port_nr=${3:-0} 1418 - local syn_nr=${4:-$port_nr} 1419 - local syn_ack_nr=${5:-$port_nr} 1420 - local ack_nr=${6:-$port_nr} 1421 - local mis_syn_nr=${7:-0} 1422 - local mis_ack_nr=${8:-0} 1418 + local ns_invert=${4:-""} 1419 + local syn_nr=$port_nr 1420 + local syn_ack_nr=$port_nr 1421 + local ack_nr=$port_nr 1422 + local mis_syn_nr=0 1423 + local mis_ack_nr=0 1424 + local ns_tx=$ns1 1425 + local ns_rx=$ns2 1426 + local extra_msg="" 1423 1427 local count 1424 1428 local timeout 1425 1429 1426 - timeout=$(ip netns exec $ns1 sysctl -n net.mptcp.add_addr_timeout) 1430 + if [[ $ns_invert = "invert" ]]; then 1431 + ns_tx=$ns2 1432 + ns_rx=$ns1 1433 + extra_msg="invert" 1434 + fi 1435 + 1436 + timeout=$(ip netns exec ${ns_tx} sysctl -n net.mptcp.add_addr_timeout) 1427 1437 1428 1438 print_check "add" 1429 - count=$(mptcp_lib_get_counter ${ns2} "MPTcpExtAddAddr") 1439 + count=$(mptcp_lib_get_counter ${ns_rx} "MPTcpExtAddAddr") 1430 1440 if [ -z "$count" ]; then 1431 1441 print_skip 1432 1442 # if the test configured a short timeout tolerate greater then expected ··· 1448 1438 fi 1449 1439 1450 1440 print_check "echo" 1451 - count=$(mptcp_lib_get_counter ${ns1} "MPTcpExtEchoAdd") 1441 + count=$(mptcp_lib_get_counter ${ns_tx} "MPTcpExtEchoAdd") 1452 1442 if [ -z "$count" ]; then 1453 1443 print_skip 1454 1444 elif [ "$count" != "$echo_nr" ]; then ··· 1459 1449 1460 1450 if [ $port_nr -gt 0 ]; then 1461 1451 print_check "pt" 1462 - count=$(mptcp_lib_get_counter ${ns2} "MPTcpExtPortAdd") 1452 + count=$(mptcp_lib_get_counter ${ns_rx} "MPTcpExtPortAdd") 1463 1453 if [ -z "$count" ]; then 1464 1454 print_skip 1465 1455 elif [ "$count" != "$port_nr" ]; then ··· 1469 1459 fi 1470 1460 1471 1461 print_check "syn" 1472 - count=$(mptcp_lib_get_counter ${ns1} "MPTcpExtMPJoinPortSynRx") 1462 + count=$(mptcp_lib_get_counter ${ns_tx} "MPTcpExtMPJoinPortSynRx") 1473 1463 if [ -z "$count" ]; then 1474 1464 print_skip 1475 1465 elif [ "$count" != "$syn_nr" ]; then ··· 1480 1470 fi 1481 1471 1482 1472 print_check "synack" 1483 - count=$(mptcp_lib_get_counter ${ns2} "MPTcpExtMPJoinPortSynAckRx") 1473 + count=$(mptcp_lib_get_counter ${ns_rx} "MPTcpExtMPJoinPortSynAckRx") 1484 1474 if [ -z "$count" ]; then 1485 1475 print_skip 1486 1476 elif [ "$count" != "$syn_ack_nr" ]; then ··· 1491 1481 fi 1492 1482 1493 1483 print_check "ack" 1494 - count=$(mptcp_lib_get_counter ${ns1} "MPTcpExtMPJoinPortAckRx") 1484 + count=$(mptcp_lib_get_counter ${ns_tx} "MPTcpExtMPJoinPortAckRx") 1495 1485 if [ -z "$count" ]; then 1496 1486 print_skip 1497 1487 elif [ "$count" != "$ack_nr" ]; then ··· 1502 1492 fi 1503 1493 1504 1494 print_check "syn" 1505 - count=$(mptcp_lib_get_counter ${ns1} "MPTcpExtMismatchPortSynRx") 1495 + count=$(mptcp_lib_get_counter ${ns_tx} "MPTcpExtMismatchPortSynRx") 1506 1496 if [ -z "$count" ]; then 1507 1497 print_skip 1508 1498 elif [ "$count" != "$mis_syn_nr" ]; then ··· 1513 1503 fi 1514 1504 1515 1505 print_check "ack" 1516 - count=$(mptcp_lib_get_counter ${ns1} "MPTcpExtMismatchPortAckRx") 1506 + count=$(mptcp_lib_get_counter ${ns_tx} "MPTcpExtMismatchPortAckRx") 1517 1507 if [ -z "$count" ]; then 1518 1508 print_skip 1519 1509 elif [ "$count" != "$mis_ack_nr" ]; then ··· 1523 1513 print_ok 1524 1514 fi 1525 1515 fi 1516 + 1517 + print_info "$extra_msg" 1526 1518 } 1527 1519 1528 1520 chk_add_tx_nr() ··· 1987 1975 run_tests $ns1 $ns2 10.0.1.1 1988 1976 chk_join_nr 2 2 2 1989 1977 chk_add_nr 1 1 1978 + fi 1979 + 1980 + # uncommon: subflow and signal flags on the same endpoint 1981 + # or because the user wrongly picked both, but still expects the client 1982 + # to create additional subflows 1983 + if reset "subflow and signal together"; then 1984 + pm_nl_set_limits $ns1 0 2 1985 + pm_nl_set_limits $ns2 0 2 1986 + pm_nl_add_endpoint $ns2 10.0.3.2 flags signal,subflow 1987 + run_tests $ns1 $ns2 10.0.1.1 1988 + chk_join_nr 1 1 1 1989 + chk_add_nr 1 1 0 invert # only initiated by ns2 1990 + chk_add_nr 0 0 0 # none initiated by ns1 1991 + chk_rst_nr 0 0 invert # no RST sent by the client 1992 + chk_rst_nr 0 0 # no RST sent by the server 1990 1993 fi 1991 1994 1992 1995 # accept and use add_addr with additional subflows
+2 -2
virt/kvm/Kconfig
··· 113 113 select KVM_PRIVATE_MEM 114 114 bool 115 115 116 - config HAVE_KVM_GMEM_PREPARE 116 + config HAVE_KVM_ARCH_GMEM_PREPARE 117 117 bool 118 118 depends on KVM_PRIVATE_MEM 119 119 120 - config HAVE_KVM_GMEM_INVALIDATE 120 + config HAVE_KVM_ARCH_GMEM_INVALIDATE 121 121 bool 122 122 depends on KVM_PRIVATE_MEM
+136 -91
virt/kvm/guest_memfd.c
··· 13 13 struct list_head entry; 14 14 }; 15 15 16 - static int kvm_gmem_prepare_folio(struct inode *inode, pgoff_t index, struct folio *folio) 16 + /** 17 + * folio_file_pfn - like folio_file_page, but return a pfn. 18 + * @folio: The folio which contains this index. 19 + * @index: The index we want to look up. 20 + * 21 + * Return: The pfn for this index. 22 + */ 23 + static inline kvm_pfn_t folio_file_pfn(struct folio *folio, pgoff_t index) 17 24 { 18 - #ifdef CONFIG_HAVE_KVM_GMEM_PREPARE 19 - struct list_head *gmem_list = &inode->i_mapping->i_private_list; 20 - struct kvm_gmem *gmem; 25 + return folio_pfn(folio) + (index & (folio_nr_pages(folio) - 1)); 26 + } 21 27 22 - list_for_each_entry(gmem, gmem_list, entry) { 23 - struct kvm_memory_slot *slot; 24 - struct kvm *kvm = gmem->kvm; 25 - struct page *page; 26 - kvm_pfn_t pfn; 27 - gfn_t gfn; 28 - int rc; 29 - 30 - if (!kvm_arch_gmem_prepare_needed(kvm)) 31 - continue; 32 - 33 - slot = xa_load(&gmem->bindings, index); 34 - if (!slot) 35 - continue; 36 - 37 - page = folio_file_page(folio, index); 38 - pfn = page_to_pfn(page); 39 - gfn = slot->base_gfn + index - slot->gmem.pgoff; 40 - rc = kvm_arch_gmem_prepare(kvm, gfn, pfn, compound_order(compound_head(page))); 41 - if (rc) { 42 - pr_warn_ratelimited("gmem: Failed to prepare folio for index %lx GFN %llx PFN %llx error %d.\n", 43 - index, gfn, pfn, rc); 44 - return rc; 45 - } 28 + static int __kvm_gmem_prepare_folio(struct kvm *kvm, struct kvm_memory_slot *slot, 29 + pgoff_t index, struct folio *folio) 30 + { 31 + #ifdef CONFIG_HAVE_KVM_ARCH_GMEM_PREPARE 32 + kvm_pfn_t pfn = folio_file_pfn(folio, index); 33 + gfn_t gfn = slot->base_gfn + index - slot->gmem.pgoff; 34 + int rc = kvm_arch_gmem_prepare(kvm, gfn, pfn, folio_order(folio)); 35 + if (rc) { 36 + pr_warn_ratelimited("gmem: Failed to prepare folio for index %lx GFN %llx PFN %llx error %d.\n", 37 + index, gfn, pfn, rc); 38 + return rc; 46 39 } 47 - 48 40 #endif 41 + 49 42 return 0; 50 43 } 51 44 52 - static struct folio *kvm_gmem_get_folio(struct inode *inode, pgoff_t index, bool prepare) 45 + static inline void kvm_gmem_mark_prepared(struct folio *folio) 53 46 { 54 - struct folio *folio; 47 + folio_mark_uptodate(folio); 48 + } 55 49 56 - /* TODO: Support huge pages. */ 57 - folio = filemap_grab_folio(inode->i_mapping, index); 58 - if (IS_ERR(folio)) 59 - return folio; 50 + /* 51 + * Process @folio, which contains @gfn, so that the guest can use it. 52 + * The folio must be locked and the gfn must be contained in @slot. 53 + * On successful return the guest sees a zero page so as to avoid 54 + * leaking host data and the up-to-date flag is set. 55 + */ 56 + static int kvm_gmem_prepare_folio(struct kvm *kvm, struct kvm_memory_slot *slot, 57 + gfn_t gfn, struct folio *folio) 58 + { 59 + unsigned long nr_pages, i; 60 + pgoff_t index; 61 + int r; 62 + 63 + nr_pages = folio_nr_pages(folio); 64 + for (i = 0; i < nr_pages; i++) 65 + clear_highpage(folio_page(folio, i)); 60 66 61 67 /* 62 - * Use the up-to-date flag to track whether or not the memory has been 63 - * zeroed before being handed off to the guest. There is no backing 64 - * storage for the memory, so the folio will remain up-to-date until 65 - * it's removed. 68 + * Preparing huge folios should always be safe, since it should 69 + * be possible to split them later if needed. 66 70 * 67 - * TODO: Skip clearing pages when trusted firmware will do it when 68 - * assigning memory to the guest. 71 + * Right now the folio order is always going to be zero, but the 72 + * code is ready for huge folios. The only assumption is that 73 + * the base pgoff of memslots is naturally aligned with the 74 + * requested page order, ensuring that huge folios can also use 75 + * huge page table entries for GPA->HPA mapping. 76 + * 77 + * The order will be passed when creating the guest_memfd, and 78 + * checked when creating memslots. 69 79 */ 70 - if (!folio_test_uptodate(folio)) { 71 - unsigned long nr_pages = folio_nr_pages(folio); 72 - unsigned long i; 80 + WARN_ON(!IS_ALIGNED(slot->gmem.pgoff, 1 << folio_order(folio))); 81 + index = gfn - slot->base_gfn + slot->gmem.pgoff; 82 + index = ALIGN_DOWN(index, 1 << folio_order(folio)); 83 + r = __kvm_gmem_prepare_folio(kvm, slot, index, folio); 84 + if (!r) 85 + kvm_gmem_mark_prepared(folio); 73 86 74 - for (i = 0; i < nr_pages; i++) 75 - clear_highpage(folio_page(folio, i)); 87 + return r; 88 + } 76 89 77 - folio_mark_uptodate(folio); 78 - } 79 - 80 - if (prepare) { 81 - int r = kvm_gmem_prepare_folio(inode, index, folio); 82 - if (r < 0) { 83 - folio_unlock(folio); 84 - folio_put(folio); 85 - return ERR_PTR(r); 86 - } 87 - } 88 - 89 - /* 90 - * Ignore accessed, referenced, and dirty flags. The memory is 91 - * unevictable and there is no storage to write back to. 92 - */ 93 - return folio; 90 + /* 91 + * Returns a locked folio on success. The caller is responsible for 92 + * setting the up-to-date flag before the memory is mapped into the guest. 93 + * There is no backing storage for the memory, so the folio will remain 94 + * up-to-date until it's removed. 95 + * 96 + * Ignore accessed, referenced, and dirty flags. The memory is 97 + * unevictable and there is no storage to write back to. 98 + */ 99 + static struct folio *kvm_gmem_get_folio(struct inode *inode, pgoff_t index) 100 + { 101 + /* TODO: Support huge pages. */ 102 + return filemap_grab_folio(inode->i_mapping, index); 94 103 } 95 104 96 105 static void kvm_gmem_invalidate_begin(struct kvm_gmem *gmem, pgoff_t start, ··· 199 190 break; 200 191 } 201 192 202 - folio = kvm_gmem_get_folio(inode, index, true); 193 + folio = kvm_gmem_get_folio(inode, index); 203 194 if (IS_ERR(folio)) { 204 195 r = PTR_ERR(folio); 205 196 break; ··· 352 343 return MF_DELAYED; 353 344 } 354 345 355 - #ifdef CONFIG_HAVE_KVM_GMEM_INVALIDATE 346 + #ifdef CONFIG_HAVE_KVM_ARCH_GMEM_INVALIDATE 356 347 static void kvm_gmem_free_folio(struct folio *folio) 357 348 { 358 349 struct page *page = folio_page(folio, 0); ··· 367 358 .dirty_folio = noop_dirty_folio, 368 359 .migrate_folio = kvm_gmem_migrate_folio, 369 360 .error_remove_folio = kvm_gmem_error_folio, 370 - #ifdef CONFIG_HAVE_KVM_GMEM_INVALIDATE 361 + #ifdef CONFIG_HAVE_KVM_ARCH_GMEM_INVALIDATE 371 362 .free_folio = kvm_gmem_free_folio, 372 363 #endif 373 364 }; ··· 550 541 fput(file); 551 542 } 552 543 553 - static int __kvm_gmem_get_pfn(struct file *file, struct kvm_memory_slot *slot, 554 - gfn_t gfn, kvm_pfn_t *pfn, int *max_order, bool prepare) 544 + /* Returns a locked folio on success. */ 545 + static struct folio * 546 + __kvm_gmem_get_pfn(struct file *file, struct kvm_memory_slot *slot, 547 + gfn_t gfn, kvm_pfn_t *pfn, bool *is_prepared, 548 + int *max_order) 555 549 { 556 550 pgoff_t index = gfn - slot->base_gfn + slot->gmem.pgoff; 557 551 struct kvm_gmem *gmem = file->private_data; 558 552 struct folio *folio; 559 - struct page *page; 560 - int r; 561 553 562 554 if (file != slot->gmem.file) { 563 555 WARN_ON_ONCE(slot->gmem.file); 564 - return -EFAULT; 556 + return ERR_PTR(-EFAULT); 565 557 } 566 558 567 559 gmem = file->private_data; 568 560 if (xa_load(&gmem->bindings, index) != slot) { 569 561 WARN_ON_ONCE(xa_load(&gmem->bindings, index)); 570 - return -EIO; 562 + return ERR_PTR(-EIO); 571 563 } 572 564 573 - folio = kvm_gmem_get_folio(file_inode(file), index, prepare); 565 + folio = kvm_gmem_get_folio(file_inode(file), index); 574 566 if (IS_ERR(folio)) 575 - return PTR_ERR(folio); 567 + return folio; 576 568 577 569 if (folio_test_hwpoison(folio)) { 578 570 folio_unlock(folio); 579 571 folio_put(folio); 580 - return -EHWPOISON; 572 + return ERR_PTR(-EHWPOISON); 581 573 } 582 574 583 - page = folio_file_page(folio, index); 584 - 585 - *pfn = page_to_pfn(page); 575 + *pfn = folio_file_pfn(folio, index); 586 576 if (max_order) 587 577 *max_order = 0; 588 578 589 - r = 0; 590 - 591 - folio_unlock(folio); 592 - 593 - return r; 579 + *is_prepared = folio_test_uptodate(folio); 580 + return folio; 594 581 } 595 582 596 583 int kvm_gmem_get_pfn(struct kvm *kvm, struct kvm_memory_slot *slot, 597 584 gfn_t gfn, kvm_pfn_t *pfn, int *max_order) 598 585 { 599 586 struct file *file = kvm_gmem_get_file(slot); 600 - int r; 587 + struct folio *folio; 588 + bool is_prepared = false; 589 + int r = 0; 601 590 602 591 if (!file) 603 592 return -EFAULT; 604 593 605 - r = __kvm_gmem_get_pfn(file, slot, gfn, pfn, max_order, true); 594 + folio = __kvm_gmem_get_pfn(file, slot, gfn, pfn, &is_prepared, max_order); 595 + if (IS_ERR(folio)) { 596 + r = PTR_ERR(folio); 597 + goto out; 598 + } 599 + 600 + if (!is_prepared) 601 + r = kvm_gmem_prepare_folio(kvm, slot, gfn, folio); 602 + 603 + folio_unlock(folio); 604 + if (r < 0) 605 + folio_put(folio); 606 + 607 + out: 606 608 fput(file); 607 609 return r; 608 610 } 609 611 EXPORT_SYMBOL_GPL(kvm_gmem_get_pfn); 610 612 613 + #ifdef CONFIG_KVM_GENERIC_PRIVATE_MEM 611 614 long kvm_gmem_populate(struct kvm *kvm, gfn_t start_gfn, void __user *src, long npages, 612 615 kvm_gmem_populate_cb post_populate, void *opaque) 613 616 { ··· 646 625 647 626 npages = min_t(ulong, slot->npages - (start_gfn - slot->base_gfn), npages); 648 627 for (i = 0; i < npages; i += (1 << max_order)) { 628 + struct folio *folio; 649 629 gfn_t gfn = start_gfn + i; 630 + bool is_prepared = false; 650 631 kvm_pfn_t pfn; 651 632 652 633 if (signal_pending(current)) { ··· 656 633 break; 657 634 } 658 635 659 - ret = __kvm_gmem_get_pfn(file, slot, gfn, &pfn, &max_order, false); 660 - if (ret) 636 + folio = __kvm_gmem_get_pfn(file, slot, gfn, &pfn, &is_prepared, &max_order); 637 + if (IS_ERR(folio)) { 638 + ret = PTR_ERR(folio); 661 639 break; 640 + } 662 641 663 - if (!IS_ALIGNED(gfn, (1 << max_order)) || 664 - (npages - i) < (1 << max_order)) 665 - max_order = 0; 642 + if (is_prepared) { 643 + folio_unlock(folio); 644 + folio_put(folio); 645 + ret = -EEXIST; 646 + break; 647 + } 648 + 649 + folio_unlock(folio); 650 + WARN_ON(!IS_ALIGNED(gfn, 1 << max_order) || 651 + (npages - i) < (1 << max_order)); 652 + 653 + ret = -EINVAL; 654 + while (!kvm_range_has_memory_attributes(kvm, gfn, gfn + (1 << max_order), 655 + KVM_MEMORY_ATTRIBUTE_PRIVATE, 656 + KVM_MEMORY_ATTRIBUTE_PRIVATE)) { 657 + if (!max_order) 658 + goto put_folio_and_exit; 659 + max_order--; 660 + } 666 661 667 662 p = src ? src + i * PAGE_SIZE : NULL; 668 663 ret = post_populate(kvm, gfn, pfn, p, max_order, opaque); 664 + if (!ret) 665 + kvm_gmem_mark_prepared(folio); 669 666 670 - put_page(pfn_to_page(pfn)); 667 + put_folio_and_exit: 668 + folio_put(folio); 671 669 if (ret) 672 670 break; 673 671 } ··· 699 655 return ret && !i ? ret : i; 700 656 } 701 657 EXPORT_SYMBOL_GPL(kvm_gmem_populate); 658 + #endif
+36 -37
virt/kvm/kvm_main.c
··· 2398 2398 #endif /* CONFIG_KVM_GENERIC_DIRTYLOG_READ_PROTECT */ 2399 2399 2400 2400 #ifdef CONFIG_KVM_GENERIC_MEMORY_ATTRIBUTES 2401 - /* 2402 - * Returns true if _all_ gfns in the range [@start, @end) have attributes 2403 - * matching @attrs. 2404 - */ 2405 - bool kvm_range_has_memory_attributes(struct kvm *kvm, gfn_t start, gfn_t end, 2406 - unsigned long attrs) 2407 - { 2408 - XA_STATE(xas, &kvm->mem_attr_array, start); 2409 - unsigned long index; 2410 - bool has_attrs; 2411 - void *entry; 2412 - 2413 - rcu_read_lock(); 2414 - 2415 - if (!attrs) { 2416 - has_attrs = !xas_find(&xas, end - 1); 2417 - goto out; 2418 - } 2419 - 2420 - has_attrs = true; 2421 - for (index = start; index < end; index++) { 2422 - do { 2423 - entry = xas_next(&xas); 2424 - } while (xas_retry(&xas, entry)); 2425 - 2426 - if (xas.xa_index != index || xa_to_value(entry) != attrs) { 2427 - has_attrs = false; 2428 - break; 2429 - } 2430 - } 2431 - 2432 - out: 2433 - rcu_read_unlock(); 2434 - return has_attrs; 2435 - } 2436 - 2437 2401 static u64 kvm_supported_mem_attributes(struct kvm *kvm) 2438 2402 { 2439 2403 if (!kvm || kvm_arch_has_private_mem(kvm)) 2440 2404 return KVM_MEMORY_ATTRIBUTE_PRIVATE; 2441 2405 2442 2406 return 0; 2407 + } 2408 + 2409 + /* 2410 + * Returns true if _all_ gfns in the range [@start, @end) have attributes 2411 + * such that the bits in @mask match @attrs. 2412 + */ 2413 + bool kvm_range_has_memory_attributes(struct kvm *kvm, gfn_t start, gfn_t end, 2414 + unsigned long mask, unsigned long attrs) 2415 + { 2416 + XA_STATE(xas, &kvm->mem_attr_array, start); 2417 + unsigned long index; 2418 + void *entry; 2419 + 2420 + mask &= kvm_supported_mem_attributes(kvm); 2421 + if (attrs & ~mask) 2422 + return false; 2423 + 2424 + if (end == start + 1) 2425 + return (kvm_get_memory_attributes(kvm, start) & mask) == attrs; 2426 + 2427 + guard(rcu)(); 2428 + if (!attrs) 2429 + return !xas_find(&xas, end - 1); 2430 + 2431 + for (index = start; index < end; index++) { 2432 + do { 2433 + entry = xas_next(&xas); 2434 + } while (xas_retry(&xas, entry)); 2435 + 2436 + if (xas.xa_index != index || 2437 + (xa_to_value(entry) & mask) != attrs) 2438 + return false; 2439 + } 2440 + 2441 + return true; 2443 2442 } 2444 2443 2445 2444 static __always_inline void kvm_handle_gfn_range(struct kvm *kvm, ··· 2533 2534 mutex_lock(&kvm->slots_lock); 2534 2535 2535 2536 /* Nothing to do if the entire range as the desired attributes. */ 2536 - if (kvm_range_has_memory_attributes(kvm, start, end, attributes)) 2537 + if (kvm_range_has_memory_attributes(kvm, start, end, ~0, attributes)) 2537 2538 goto out_unlock; 2538 2539 2539 2540 /*