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

Merge tag 'kvm-s390-next-5.7-1' of git://git.kernel.org/pub/scm/linux/kernel/git/kvms390/linux into HEAD

KVM: s390: Features and Enhancements for 5.7 part1

1. Allow to disable gisa
2. protected virtual machines
Protected VMs (PVM) are KVM VMs, where KVM can't access the VM's
state like guest memory and guest registers anymore. Instead the
PVMs are mostly managed by a new entity called Ultravisor (UV),
which provides an API, so KVM and the PV can request management
actions.

PVMs are encrypted at rest and protected from hypervisor access
while running. They switch from a normal operation into protected
mode, so we can still use the standard boot process to load a
encrypted blob and then move it into protected mode.

Rebooting is only possible by passing through the unprotected/normal
mode and switching to protected again.

One mm related patch will go via Andrews mm tree ( mm/gup/writeback:
add callbacks for inaccessible pages)

+6434 -2589
+5
Documentation/admin-guide/kernel-parameters.txt
··· 3795 3795 before loading. 3796 3796 See Documentation/admin-guide/blockdev/ramdisk.rst. 3797 3797 3798 + prot_virt= [S390] enable hosting protected virtual machines 3799 + isolated from the hypervisor (if hardware supports 3800 + that). 3801 + Format: <bool> 3802 + 3798 3803 psi= [KNL] Enable or disable pressure stall information 3799 3804 tracking. 3800 3805 Format: <bool>
+2 -1
Documentation/devicetree/bindings/input/ilitek,ili2xxx.txt
··· 1 - Ilitek ILI210x/ILI2117/ILI251x touchscreen controller 1 + Ilitek ILI210x/ILI2117/ILI2120/ILI251x touchscreen controller 2 2 3 3 Required properties: 4 4 - compatible: 5 5 ilitek,ili210x for ILI210x 6 6 ilitek,ili2117 for ILI2117 7 + ilitek,ili2120 for ILI2120 7 8 ilitek,ili251x for ILI251x 8 9 9 10 - reg: The I2C address of the device
+4
Documentation/driver-api/ipmb.rst
··· 71 71 ipmb@10 { 72 72 compatible = "ipmb-dev"; 73 73 reg = <0x10>; 74 + i2c-protocol; 74 75 }; 75 76 }; 77 + 78 + If xmit of data to be done using raw i2c block vs smbus 79 + then "i2c-protocol" needs to be defined as above. 76 80 77 81 2) Manually from Linux:: 78 82
+63 -2
Documentation/virt/kvm/api.rst
··· 2110 2110 2111 2111 ====== ============================================================ 2112 2112  ENOENT   no such register 2113 -  EINVAL   invalid register ID, or no such register 2113 +  EINVAL   invalid register ID, or no such register or used with VMs in 2114 + protected virtualization mode on s390 2114 2115  EPERM    (arm64) register access not allowed before vcpu finalization 2115 2116 ====== ============================================================ 2116 2117 ··· 2546 2545 2547 2546 ======== ============================================================ 2548 2547  ENOENT   no such register 2549 -  EINVAL   invalid register ID, or no such register 2548 +  EINVAL   invalid register ID, or no such register or used with VMs in 2549 + protected virtualization mode on s390 2550 2550  EPERM    (arm64) register access not allowed before vcpu finalization 2551 2551 ======== ============================================================ 2552 2552 ··· 4637 4635 into ESA mode. This reset is a superset of the initial reset. 4638 4636 4639 4637 4638 + 4.125 KVM_S390_PV_COMMAND 4639 + ------------------------- 4640 + 4641 + :Capability: KVM_CAP_S390_PROTECTED 4642 + :Architectures: s390 4643 + :Type: vm ioctl 4644 + :Parameters: struct kvm_pv_cmd 4645 + :Returns: 0 on success, < 0 on error 4646 + 4647 + :: 4648 + 4649 + struct kvm_pv_cmd { 4650 + __u32 cmd; /* Command to be executed */ 4651 + __u16 rc; /* Ultravisor return code */ 4652 + __u16 rrc; /* Ultravisor return reason code */ 4653 + __u64 data; /* Data or address */ 4654 + __u32 flags; /* flags for future extensions. Must be 0 for now */ 4655 + __u32 reserved[3]; 4656 + }; 4657 + 4658 + cmd values: 4659 + 4660 + KVM_PV_ENABLE 4661 + Allocate memory and register the VM with the Ultravisor, thereby 4662 + donating memory to the Ultravisor that will become inaccessible to 4663 + KVM. All existing CPUs are converted to protected ones. After this 4664 + command has succeeded, any CPU added via hotplug will become 4665 + protected during its creation as well. 4666 + 4667 + KVM_PV_DISABLE 4668 + 4669 + Deregister the VM from the Ultravisor and reclaim the memory that 4670 + had been donated to the Ultravisor, making it usable by the kernel 4671 + again. All registered VCPUs are converted back to non-protected 4672 + ones. 4673 + 4674 + KVM_PV_VM_SET_SEC_PARMS 4675 + Pass the image header from VM memory to the Ultravisor in 4676 + preparation of image unpacking and verification. 4677 + 4678 + KVM_PV_VM_UNPACK 4679 + Unpack (protect and decrypt) a page of the encrypted boot image. 4680 + 4681 + KVM_PV_VM_VERIFY 4682 + Verify the integrity of the unpacked image. Only if this succeeds, 4683 + KVM is allowed to start protected VCPUs. 4684 + 4685 + 4640 4686 5. The kvm_run structure 4641 4687 ======================== 4642 4688 ··· 6075 6025 6076 6026 This capability indicates that the KVM_S390_NORMAL_RESET and 6077 6027 KVM_S390_CLEAR_RESET ioctls are available. 6028 + 6029 + 8.23 KVM_CAP_S390_PROTECTED 6030 + 6031 + Architecture: s390 6032 + 6033 + 6034 + This capability indicates that the Ultravisor has been initialized and 6035 + KVM can therefore start protected VMs. 6036 + This capability governs the KVM_S390_PV_COMMAND ioctl and the 6037 + KVM_MP_STATE_LOAD MP_STATE. KVM_SET_MP_STATE can fail for protected 6038 + guests when the state change is invalid.
+2 -9
Documentation/virt/kvm/devices/s390_flic.rst
··· 108 108 mask or unmask the adapter, as specified in mask 109 109 110 110 KVM_S390_IO_ADAPTER_MAP 111 - perform a gmap translation for the guest address provided in addr, 112 - pin a userspace page for the translated address and add it to the 113 - list of mappings 114 - 115 - .. note:: A new mapping will be created unconditionally; therefore, 116 - the calling code should avoid making duplicate mappings. 117 - 111 + This is now a no-op. The mapping is purely done by the irq route. 118 112 KVM_S390_IO_ADAPTER_UNMAP 119 - release a userspace page for the translated address specified in addr 120 - from the list of mappings 113 + This is now a no-op. The mapping is purely done by the irq route. 121 114 122 115 KVM_DEV_FLIC_AISM 123 116 modify the adapter-interruption-suppression mode for a given isc if the
+2
Documentation/virt/kvm/index.rst
··· 18 18 nested-vmx 19 19 ppc-pv 20 20 s390-diag 21 + s390-pv 22 + s390-pv-boot 21 23 timekeeping 22 24 vcpu-requests 23 25
+84
Documentation/virt/kvm/s390-pv-boot.rst
··· 1 + .. SPDX-License-Identifier: GPL-2.0 2 + 3 + ====================================== 4 + s390 (IBM Z) Boot/IPL of Protected VMs 5 + ====================================== 6 + 7 + Summary 8 + ------- 9 + The memory of Protected Virtual Machines (PVMs) is not accessible to 10 + I/O or the hypervisor. In those cases where the hypervisor needs to 11 + access the memory of a PVM, that memory must be made accessible. 12 + Memory made accessible to the hypervisor will be encrypted. See 13 + :doc:`s390-pv` for details." 14 + 15 + On IPL (boot) a small plaintext bootloader is started, which provides 16 + information about the encrypted components and necessary metadata to 17 + KVM to decrypt the protected virtual machine. 18 + 19 + Based on this data, KVM will make the protected virtual machine known 20 + to the Ultravisor (UV) and instruct it to secure the memory of the 21 + PVM, decrypt the components and verify the data and address list 22 + hashes, to ensure integrity. Afterwards KVM can run the PVM via the 23 + SIE instruction which the UV will intercept and execute on KVM's 24 + behalf. 25 + 26 + As the guest image is just like an opaque kernel image that does the 27 + switch into PV mode itself, the user can load encrypted guest 28 + executables and data via every available method (network, dasd, scsi, 29 + direct kernel, ...) without the need to change the boot process. 30 + 31 + 32 + Diag308 33 + ------- 34 + This diagnose instruction is the basic mechanism to handle IPL and 35 + related operations for virtual machines. The VM can set and retrieve 36 + IPL information blocks, that specify the IPL method/devices and 37 + request VM memory and subsystem resets, as well as IPLs. 38 + 39 + For PVMs this concept has been extended with new subcodes: 40 + 41 + Subcode 8: Set an IPL Information Block of type 5 (information block 42 + for PVMs) 43 + Subcode 9: Store the saved block in guest memory 44 + Subcode 10: Move into Protected Virtualization mode 45 + 46 + The new PV load-device-specific-parameters field specifies all data 47 + that is necessary to move into PV mode. 48 + 49 + * PV Header origin 50 + * PV Header length 51 + * List of Components composed of 52 + * AES-XTS Tweak prefix 53 + * Origin 54 + * Size 55 + 56 + The PV header contains the keys and hashes, which the UV will use to 57 + decrypt and verify the PV, as well as control flags and a start PSW. 58 + 59 + The components are for instance an encrypted kernel, kernel parameters 60 + and initrd. The components are decrypted by the UV. 61 + 62 + After the initial import of the encrypted data, all defined pages will 63 + contain the guest content. All non-specified pages will start out as 64 + zero pages on first access. 65 + 66 + 67 + When running in protected virtualization mode, some subcodes will result in 68 + exceptions or return error codes. 69 + 70 + Subcodes 4 and 7, which specify operations that do not clear the guest 71 + memory, will result in specification exceptions. This is because the 72 + UV will clear all memory when a secure VM is removed, and therefore 73 + non-clearing IPL subcodes are not allowed. 74 + 75 + Subcodes 8, 9, 10 will result in specification exceptions. 76 + Re-IPL into a protected mode is only possible via a detour into non 77 + protected mode. 78 + 79 + Keys 80 + ---- 81 + Every CEC will have a unique public key to enable tooling to build 82 + encrypted images. 83 + See `s390-tools <https://github.com/ibm-s390-tools/s390-tools/>`_ 84 + for the tooling.
+116
Documentation/virt/kvm/s390-pv.rst
··· 1 + .. SPDX-License-Identifier: GPL-2.0 2 + 3 + ========================================= 4 + s390 (IBM Z) Ultravisor and Protected VMs 5 + ========================================= 6 + 7 + Summary 8 + ------- 9 + Protected virtual machines (PVM) are KVM VMs that do not allow KVM to 10 + access VM state like guest memory or guest registers. Instead, the 11 + PVMs are mostly managed by a new entity called Ultravisor (UV). The UV 12 + provides an API that can be used by PVMs and KVM to request management 13 + actions. 14 + 15 + Each guest starts in non-protected mode and then may make a request to 16 + transition into protected mode. On transition, KVM registers the guest 17 + and its VCPUs with the Ultravisor and prepares everything for running 18 + it. 19 + 20 + The Ultravisor will secure and decrypt the guest's boot memory 21 + (i.e. kernel/initrd). It will safeguard state changes like VCPU 22 + starts/stops and injected interrupts while the guest is running. 23 + 24 + As access to the guest's state, such as the SIE state description, is 25 + normally needed to be able to run a VM, some changes have been made in 26 + the behavior of the SIE instruction. A new format 4 state description 27 + has been introduced, where some fields have different meanings for a 28 + PVM. SIE exits are minimized as much as possible to improve speed and 29 + reduce exposed guest state. 30 + 31 + 32 + Interrupt injection 33 + ------------------- 34 + Interrupt injection is safeguarded by the Ultravisor. As KVM doesn't 35 + have access to the VCPUs' lowcores, injection is handled via the 36 + format 4 state description. 37 + 38 + Machine check, external, IO and restart interruptions each can be 39 + injected on SIE entry via a bit in the interrupt injection control 40 + field (offset 0x54). If the guest cpu is not enabled for the interrupt 41 + at the time of injection, a validity interception is recognized. The 42 + format 4 state description contains fields in the interception data 43 + block where data associated with the interrupt can be transported. 44 + 45 + Program and Service Call exceptions have another layer of 46 + safeguarding; they can only be injected for instructions that have 47 + been intercepted into KVM. The exceptions need to be a valid outcome 48 + of an instruction emulation by KVM, e.g. we can never inject a 49 + addressing exception as they are reported by SIE since KVM has no 50 + access to the guest memory. 51 + 52 + 53 + Mask notification interceptions 54 + ------------------------------- 55 + KVM cannot intercept lctl(g) and lpsw(e) anymore in order to be 56 + notified when a PVM enables a certain class of interrupt. As a 57 + replacement, two new interception codes have been introduced: One 58 + indicating that the contents of CRs 0, 6, or 14 have been changed, 59 + indicating different interruption subclasses; and one indicating that 60 + PSW bit 13 has been changed, indicating that a machine check 61 + intervention was requested and those are now enabled. 62 + 63 + Instruction emulation 64 + --------------------- 65 + With the format 4 state description for PVMs, the SIE instruction already 66 + interprets more instructions than it does with format 2. It is not able 67 + to interpret every instruction, but needs to hand some tasks to KVM; 68 + therefore, the SIE and the ultravisor safeguard emulation inputs and outputs. 69 + 70 + The control structures associated with SIE provide the Secure 71 + Instruction Data Area (SIDA), the Interception Parameters (IP) and the 72 + Secure Interception General Register Save Area. Guest GRs and most of 73 + the instruction data, such as I/O data structures, are filtered. 74 + Instruction data is copied to and from the SIDA when needed. Guest 75 + GRs are put into / retrieved from the Secure Interception General 76 + Register Save Area. 77 + 78 + Only GR values needed to emulate an instruction will be copied into this 79 + save area and the real register numbers will be hidden. 80 + 81 + The Interception Parameters state description field still contains the 82 + the bytes of the instruction text, but with pre-set register values 83 + instead of the actual ones. I.e. each instruction always uses the same 84 + instruction text, in order not to leak guest instruction text. 85 + This also implies that the register content that a guest had in r<n> 86 + may be in r<m> from the hypervisor's point of view. 87 + 88 + The Secure Instruction Data Area contains instruction storage 89 + data. Instruction data, i.e. data being referenced by an instruction 90 + like the SCCB for sclp, is moved via the SIDA. When an instruction is 91 + intercepted, the SIE will only allow data and program interrupts for 92 + this instruction to be moved to the guest via the two data areas 93 + discussed before. Other data is either ignored or results in validity 94 + interceptions. 95 + 96 + 97 + Instruction emulation interceptions 98 + ----------------------------------- 99 + There are two types of SIE secure instruction intercepts: the normal 100 + and the notification type. Normal secure instruction intercepts will 101 + make the guest pending for instruction completion of the intercepted 102 + instruction type, i.e. on SIE entry it is attempted to complete 103 + emulation of the instruction with the data provided by KVM. That might 104 + be a program exception or instruction completion. 105 + 106 + The notification type intercepts inform KVM about guest environment 107 + changes due to guest instruction interpretation. Such an interception 108 + is recognized, for example, for the store prefix instruction to provide 109 + the new lowcore location. On SIE reentry, any KVM data in the data areas 110 + is ignored and execution continues as if the guest instruction had 111 + completed. For that reason KVM is not allowed to inject a program 112 + interrupt. 113 + 114 + Links 115 + ----- 116 + `KVM Forum 2019 presentation <https://static.sched.com/hosted_files/kvmforum2019/3b/ibm_protected_vms_s390x.pdf>`_
+15 -14
MAINTAINERS
··· 2796 2796 2797 2797 ATHEROS 71XX/9XXX GPIO DRIVER 2798 2798 M: Alban Bedel <albeu@free.fr> 2799 + S: Maintained 2799 2800 W: https://github.com/AlbanBedel/linux 2800 2801 T: git git://github.com/AlbanBedel/linux 2801 - S: Maintained 2802 - F: drivers/gpio/gpio-ath79.c 2803 2802 F: Documentation/devicetree/bindings/gpio/gpio-ath79.txt 2803 + F: drivers/gpio/gpio-ath79.c 2804 2804 2805 2805 ATHEROS 71XX/9XXX USB PHY DRIVER 2806 2806 M: Alban Bedel <albeu@free.fr> ··· 3422 3422 M: Gregory Fong <gregory.0xf0@gmail.com> 3423 3423 L: bcm-kernel-feedback-list@broadcom.com 3424 3424 S: Supported 3425 - F: drivers/gpio/gpio-brcmstb.c 3426 3425 F: Documentation/devicetree/bindings/gpio/brcm,brcmstb-gpio.txt 3426 + F: drivers/gpio/gpio-brcmstb.c 3427 3427 3428 3428 BROADCOM BRCMSTB I2C DRIVER 3429 3429 M: Kamal Dasu <kdasu.kdev@gmail.com> ··· 3481 3481 M: Ray Jui <rjui@broadcom.com> 3482 3482 L: bcm-kernel-feedback-list@broadcom.com 3483 3483 S: Supported 3484 - F: drivers/gpio/gpio-bcm-kona.c 3485 3484 F: Documentation/devicetree/bindings/gpio/brcm,kona-gpio.txt 3485 + F: drivers/gpio/gpio-bcm-kona.c 3486 3486 3487 3487 BROADCOM NETXTREME-E ROCE DRIVER 3488 3488 M: Selvin Xavier <selvin.xavier@broadcom.com> ··· 3597 3597 3598 3598 BT8XXGPIO DRIVER 3599 3599 M: Michael Buesch <m@bues.ch> 3600 - W: http://bu3sch.de/btgpio.php 3601 3600 S: Maintained 3601 + W: http://bu3sch.de/btgpio.php 3602 3602 F: drivers/gpio/gpio-bt8xx.c 3603 3603 3604 3604 BTRFS FILE SYSTEM ··· 7143 7143 M: Linus Walleij <linus.walleij@linaro.org> 7144 7144 M: Bartosz Golaszewski <bgolaszewski@baylibre.com> 7145 7145 L: linux-gpio@vger.kernel.org 7146 - T: git git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio.git 7147 7146 S: Maintained 7147 + T: git git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio.git 7148 + F: Documentation/ABI/obsolete/sysfs-gpio 7149 + F: Documentation/ABI/testing/gpio-cdev 7150 + F: Documentation/admin-guide/gpio/ 7148 7151 F: Documentation/devicetree/bindings/gpio/ 7149 7152 F: Documentation/driver-api/gpio/ 7150 - F: Documentation/admin-guide/gpio/ 7151 - F: Documentation/ABI/testing/gpio-cdev 7152 - F: Documentation/ABI/obsolete/sysfs-gpio 7153 7153 F: drivers/gpio/ 7154 + F: include/asm-generic/gpio.h 7154 7155 F: include/linux/gpio/ 7155 7156 F: include/linux/gpio.h 7156 7157 F: include/linux/of_gpio.h 7157 - F: include/asm-generic/gpio.h 7158 7158 F: include/uapi/linux/gpio.h 7159 7159 F: tools/gpio/ 7160 7160 ··· 8055 8055 ICH LPC AND GPIO DRIVER 8056 8056 M: Peter Tyser <ptyser@xes-inc.com> 8057 8057 S: Maintained 8058 - F: drivers/mfd/lpc_ich.c 8059 8058 F: drivers/gpio/gpio-ich.c 8059 + F: drivers/mfd/lpc_ich.c 8060 8060 8061 8061 ICY I2C DRIVER 8062 8062 M: Max Staudt <max@enpas.org> ··· 9209 9209 W: http://www.ibm.com/developerworks/linux/linux390/ 9210 9210 T: git git://git.kernel.org/pub/scm/linux/kernel/git/kvms390/linux.git 9211 9211 S: Supported 9212 + F: Documentation/virt/kvm/s390* 9212 9213 F: arch/s390/include/uapi/asm/kvm* 9213 9214 F: arch/s390/include/asm/gmap.h 9214 9215 F: arch/s390/include/asm/kvm* ··· 16076 16075 SYNOPSYS CREG GPIO DRIVER 16077 16076 M: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com> 16078 16077 S: Maintained 16079 - F: drivers/gpio/gpio-creg-snps.c 16080 16078 F: Documentation/devicetree/bindings/gpio/snps,creg-gpio.txt 16079 + F: drivers/gpio/gpio-creg-snps.c 16081 16080 16082 16081 SYNOPSYS DESIGNWARE 8250 UART DRIVER 16083 16082 R: Andy Shevchenko <andriy.shevchenko@linux.intel.com> ··· 16088 16087 M: Hoan Tran <hoan@os.amperecomputing.com> 16089 16088 L: linux-gpio@vger.kernel.org 16090 16089 S: Maintained 16091 - F: drivers/gpio/gpio-dwapb.c 16092 16090 F: Documentation/devicetree/bindings/gpio/snps-dwapb-gpio.txt 16091 + F: drivers/gpio/gpio-dwapb.c 16093 16092 16094 16093 SYNOPSYS DESIGNWARE AXI DMAC DRIVER 16095 16094 M: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com> ··· 18415 18414 M: Semi Malinen <semi.malinen@ge.com> 18416 18415 L: linux-gpio@vger.kernel.org 18417 18416 S: Maintained 18418 - F: drivers/gpio/gpio-xra1403.c 18419 18417 F: Documentation/devicetree/bindings/gpio/gpio-xra1403.txt 18418 + F: drivers/gpio/gpio-xra1403.c 18420 18419 18421 18420 XTENSA XTFPGA PLATFORM SUPPORT 18422 18421 M: Max Filippov <jcmvbkbc@gmail.com>
+1 -1
Makefile
··· 2 2 VERSION = 5 3 3 PATCHLEVEL = 6 4 4 SUBLEVEL = 0 5 - EXTRAVERSION = -rc1 5 + EXTRAVERSION = -rc2 6 6 NAME = Kleptomaniac Octopus 7 7 8 8 # *DOCUMENTATION*
-3
arch/arm/boot/dts/stih410-b2260.dts
··· 178 178 phy-mode = "rgmii"; 179 179 pinctrl-0 = <&pinctrl_rgmii1 &pinctrl_rgmii1_mdio_1>; 180 180 181 - snps,phy-bus-name = "stmmac"; 182 - snps,phy-bus-id = <0>; 183 - snps,phy-addr = <0>; 184 181 snps,reset-gpio = <&pio0 7 0>; 185 182 snps,reset-active-low; 186 183 snps,reset-delays-us = <0 10000 1000000>;
+1 -1
arch/arm/boot/dts/stihxxx-b2120.dtsi
··· 46 46 /* DAC */ 47 47 format = "i2s"; 48 48 mclk-fs = <256>; 49 - frame-inversion = <1>; 49 + frame-inversion; 50 50 cpu { 51 51 sound-dai = <&sti_uni_player2>; 52 52 };
-2
arch/arm/configs/am200epdkit_defconfig
··· 11 11 CONFIG_MODULES=y 12 12 CONFIG_MODULE_UNLOAD=y 13 13 # CONFIG_BLK_DEV_BSG is not set 14 - # CONFIG_IOSCHED_DEADLINE is not set 15 - # CONFIG_IOSCHED_CFQ is not set 16 14 CONFIG_ARCH_PXA=y 17 15 CONFIG_ARCH_GUMSTIX=y 18 16 CONFIG_PCCARD=y
-1
arch/arm/configs/axm55xx_defconfig
··· 25 25 CONFIG_PROFILING=y 26 26 CONFIG_MODULES=y 27 27 CONFIG_MODULE_UNLOAD=y 28 - # CONFIG_IOSCHED_DEADLINE is not set 29 28 CONFIG_ARCH_AXXIA=y 30 29 CONFIG_GPIO_PCA953X=y 31 30 CONFIG_ARM_LPAE=y
-1
arch/arm/configs/clps711x_defconfig
··· 7 7 CONFIG_SLOB=y 8 8 CONFIG_JUMP_LABEL=y 9 9 CONFIG_PARTITION_ADVANCED=y 10 - # CONFIG_IOSCHED_CFQ is not set 11 10 CONFIG_ARCH_CLPS711X=y 12 11 CONFIG_ARCH_AUTCPU12=y 13 12 CONFIG_ARCH_CDB89712=y
+1 -1
arch/arm/configs/cns3420vb_defconfig
··· 17 17 CONFIG_MODULE_FORCE_UNLOAD=y 18 18 CONFIG_MODVERSIONS=y 19 19 # CONFIG_BLK_DEV_BSG is not set 20 - CONFIG_IOSCHED_CFQ=m 20 + CONFIG_IOSCHED_BFQ=m 21 21 CONFIG_ARCH_MULTI_V6=y 22 22 #CONFIG_ARCH_MULTI_V7 is not set 23 23 CONFIG_ARCH_CNS3XXX=y
-1
arch/arm/configs/colibri_pxa300_defconfig
··· 43 43 CONFIG_USB_MON=y 44 44 CONFIG_USB_STORAGE=y 45 45 CONFIG_MMC=y 46 - # CONFIG_MMC_BLOCK_BOUNCE is not set 47 46 CONFIG_MMC_PXA=y 48 47 CONFIG_EXT3_FS=y 49 48 CONFIG_NFS_FS=y
-2
arch/arm/configs/collie_defconfig
··· 7 7 # CONFIG_BASE_FULL is not set 8 8 # CONFIG_EPOLL is not set 9 9 CONFIG_SLOB=y 10 - # CONFIG_IOSCHED_DEADLINE is not set 11 - # CONFIG_IOSCHED_CFQ is not set 12 10 CONFIG_ARCH_SA1100=y 13 11 CONFIG_SA1100_COLLIE=y 14 12 CONFIG_PCCARD=y
-2
arch/arm/configs/davinci_all_defconfig
··· 15 15 CONFIG_MODULE_FORCE_UNLOAD=y 16 16 CONFIG_MODVERSIONS=y 17 17 CONFIG_PARTITION_ADVANCED=y 18 - # CONFIG_IOSCHED_DEADLINE is not set 19 - # CONFIG_IOSCHED_CFQ is not set 20 18 CONFIG_ARCH_MULTIPLATFORM=y 21 19 CONFIG_ARCH_MULTI_V7=n 22 20 CONFIG_ARCH_MULTI_V5=y
-2
arch/arm/configs/efm32_defconfig
··· 12 12 # CONFIG_VM_EVENT_COUNTERS is not set 13 13 # CONFIG_SLUB_DEBUG is not set 14 14 # CONFIG_BLK_DEV_BSG is not set 15 - # CONFIG_IOSCHED_DEADLINE is not set 16 - # CONFIG_IOSCHED_CFQ is not set 17 15 # CONFIG_MMU is not set 18 16 CONFIG_ARM_SINGLE_ARMV7M=y 19 17 CONFIG_ARCH_EFM32=y
-1
arch/arm/configs/ep93xx_defconfig
··· 11 11 CONFIG_MODULE_FORCE_UNLOAD=y 12 12 # CONFIG_BLK_DEV_BSG is not set 13 13 CONFIG_PARTITION_ADVANCED=y 14 - # CONFIG_IOSCHED_CFQ is not set 15 14 CONFIG_ARCH_EP93XX=y 16 15 CONFIG_CRUNCH=y 17 16 CONFIG_MACH_ADSSPHERE=y
-2
arch/arm/configs/eseries_pxa_defconfig
··· 9 9 CONFIG_MODULE_UNLOAD=y 10 10 CONFIG_MODULE_FORCE_UNLOAD=y 11 11 # CONFIG_BLK_DEV_BSG is not set 12 - # CONFIG_IOSCHED_DEADLINE is not set 13 - # CONFIG_IOSCHED_CFQ is not set 14 12 CONFIG_ARCH_PXA=y 15 13 CONFIG_ARCH_PXA_ESERIES=y 16 14 # CONFIG_ARM_THUMB is not set
-1
arch/arm/configs/ezx_defconfig
··· 14 14 CONFIG_MODULE_FORCE_UNLOAD=y 15 15 CONFIG_MODVERSIONS=y 16 16 # CONFIG_BLK_DEV_BSG is not set 17 - # CONFIG_IOSCHED_CFQ is not set 18 17 CONFIG_ARCH_PXA=y 19 18 CONFIG_PXA_EZX=y 20 19 CONFIG_NO_HZ=y
-2
arch/arm/configs/h3600_defconfig
··· 5 5 CONFIG_BLK_DEV_INITRD=y 6 6 CONFIG_MODULES=y 7 7 # CONFIG_BLK_DEV_BSG is not set 8 - # CONFIG_IOSCHED_DEADLINE is not set 9 - # CONFIG_IOSCHED_CFQ is not set 10 8 CONFIG_ARCH_SA1100=y 11 9 CONFIG_SA1100_H3600=y 12 10 CONFIG_PCCARD=y
-1
arch/arm/configs/h5000_defconfig
··· 10 10 CONFIG_MODULE_UNLOAD=y 11 11 CONFIG_MODULE_FORCE_UNLOAD=y 12 12 # CONFIG_BLK_DEV_BSG is not set 13 - # CONFIG_IOSCHED_CFQ is not set 14 13 CONFIG_ARCH_PXA=y 15 14 CONFIG_MACH_H5000=y 16 15 CONFIG_AEABI=y
-1
arch/arm/configs/imote2_defconfig
··· 13 13 CONFIG_MODULE_FORCE_UNLOAD=y 14 14 CONFIG_MODVERSIONS=y 15 15 # CONFIG_BLK_DEV_BSG is not set 16 - # CONFIG_IOSCHED_CFQ is not set 17 16 CONFIG_ARCH_PXA=y 18 17 CONFIG_MACH_INTELMOTE2=y 19 18 CONFIG_NO_HZ=y
-2
arch/arm/configs/imx_v4_v5_defconfig
··· 32 32 CONFIG_MODULES=y 33 33 CONFIG_MODULE_UNLOAD=y 34 34 # CONFIG_BLK_DEV_BSG is not set 35 - # CONFIG_IOSCHED_DEADLINE is not set 36 - # CONFIG_IOSCHED_CFQ is not set 37 35 CONFIG_NET=y 38 36 CONFIG_PACKET=y 39 37 CONFIG_UNIX=y
-4
arch/arm/configs/lpc18xx_defconfig
··· 1 - CONFIG_CROSS_COMPILE="arm-linux-gnueabihf-" 2 1 CONFIG_HIGH_RES_TIMERS=y 3 2 CONFIG_PREEMPT=y 4 3 CONFIG_BLK_DEV_INITRD=y ··· 27 28 CONFIG_ZBOOT_ROM_TEXT=0x0 28 29 CONFIG_ZBOOT_ROM_BSS=0x0 29 30 CONFIG_ARM_APPENDED_DTB=y 30 - # CONFIG_LBDAF is not set 31 31 # CONFIG_BLK_DEV_BSG is not set 32 - # CONFIG_IOSCHED_DEADLINE is not set 33 - # CONFIG_IOSCHED_CFQ is not set 34 32 CONFIG_BINFMT_FLAT=y 35 33 CONFIG_BINFMT_ZFLAT=y 36 34 CONFIG_BINFMT_SHARED_FLAT=y
-2
arch/arm/configs/magician_defconfig
··· 9 9 CONFIG_MODULES=y 10 10 CONFIG_MODULE_UNLOAD=y 11 11 # CONFIG_BLK_DEV_BSG is not set 12 - # CONFIG_IOSCHED_DEADLINE is not set 13 - # CONFIG_IOSCHED_CFQ is not set 14 12 CONFIG_ARCH_PXA=y 15 13 CONFIG_MACH_H4700=y 16 14 CONFIG_MACH_MAGICIAN=y
-1
arch/arm/configs/moxart_defconfig
··· 15 15 # CONFIG_SLUB_DEBUG is not set 16 16 # CONFIG_COMPAT_BRK is not set 17 17 # CONFIG_BLK_DEV_BSG is not set 18 - # CONFIG_IOSCHED_DEADLINE is not set 19 18 CONFIG_ARCH_MULTI_V4=y 20 19 # CONFIG_ARCH_MULTI_V7 is not set 21 20 CONFIG_ARCH_MOXART=y
-2
arch/arm/configs/mxs_defconfig
··· 25 25 CONFIG_MODULE_FORCE_UNLOAD=y 26 26 CONFIG_MODVERSIONS=y 27 27 CONFIG_BLK_DEV_INTEGRITY=y 28 - # CONFIG_IOSCHED_DEADLINE is not set 29 - # CONFIG_IOSCHED_CFQ is not set 30 28 CONFIG_NET=y 31 29 CONFIG_PACKET=y 32 30 CONFIG_UNIX=y
-2
arch/arm/configs/omap1_defconfig
··· 18 18 CONFIG_MODULE_UNLOAD=y 19 19 CONFIG_MODULE_FORCE_UNLOAD=y 20 20 # CONFIG_BLK_DEV_BSG is not set 21 - # CONFIG_IOSCHED_DEADLINE is not set 22 - # CONFIG_IOSCHED_CFQ is not set 23 21 CONFIG_ARCH_OMAP=y 24 22 CONFIG_ARCH_OMAP1=y 25 23 CONFIG_OMAP_RESET_CLOCKS=y
-2
arch/arm/configs/palmz72_defconfig
··· 7 7 CONFIG_MODULES=y 8 8 CONFIG_MODULE_UNLOAD=y 9 9 # CONFIG_BLK_DEV_BSG is not set 10 - # CONFIG_IOSCHED_DEADLINE is not set 11 - # CONFIG_IOSCHED_CFQ is not set 12 10 CONFIG_ARCH_PXA=y 13 11 CONFIG_ARCH_PXA_PALM=y 14 12 # CONFIG_MACH_PALMTX is not set
-2
arch/arm/configs/pcm027_defconfig
··· 13 13 CONFIG_MODULE_UNLOAD=y 14 14 CONFIG_MODULE_FORCE_UNLOAD=y 15 15 # CONFIG_BLK_DEV_BSG is not set 16 - # CONFIG_IOSCHED_DEADLINE is not set 17 - # CONFIG_IOSCHED_CFQ is not set 18 16 CONFIG_ARCH_PXA=y 19 17 CONFIG_MACH_PCM027=y 20 18 CONFIG_MACH_PCM990_BASEBOARD=y
-2
arch/arm/configs/pleb_defconfig
··· 6 6 # CONFIG_HOTPLUG is not set 7 7 # CONFIG_SHMEM is not set 8 8 CONFIG_MODULES=y 9 - # CONFIG_IOSCHED_DEADLINE is not set 10 - # CONFIG_IOSCHED_CFQ is not set 11 9 CONFIG_ARCH_SA1100=y 12 10 CONFIG_SA1100_PLEB=y 13 11 CONFIG_ZBOOT_ROM_TEXT=0x0
-1
arch/arm/configs/realview_defconfig
··· 8 8 CONFIG_MODULES=y 9 9 CONFIG_MODULE_UNLOAD=y 10 10 # CONFIG_BLK_DEV_BSG is not set 11 - # CONFIG_IOSCHED_CFQ is not set 12 11 CONFIG_ARCH_MULTI_V6=y 13 12 CONFIG_ARCH_REALVIEW=y 14 13 CONFIG_MACH_REALVIEW_EB=y
-3
arch/arm/configs/sama5_defconfig
··· 14 14 CONFIG_MODULE_UNLOAD=y 15 15 CONFIG_MODULE_FORCE_UNLOAD=y 16 16 # CONFIG_BLK_DEV_BSG is not set 17 - # CONFIG_IOSCHED_DEADLINE is not set 18 - # CONFIG_IOSCHED_CFQ is not set 19 17 CONFIG_ARCH_AT91=y 20 18 CONFIG_SOC_SAMA5D2=y 21 19 CONFIG_SOC_SAMA5D3=y ··· 180 182 CONFIG_USB_ATMEL_USBA=y 181 183 CONFIG_USB_G_SERIAL=y 182 184 CONFIG_MMC=y 183 - # CONFIG_MMC_BLOCK_BOUNCE is not set 184 185 CONFIG_MMC_SDHCI=y 185 186 CONFIG_MMC_SDHCI_PLTFM=y 186 187 CONFIG_MMC_SDHCI_OF_AT91=y
-2
arch/arm/configs/stm32_defconfig
··· 14 14 # CONFIG_VM_EVENT_COUNTERS is not set 15 15 # CONFIG_SLUB_DEBUG is not set 16 16 # CONFIG_BLK_DEV_BSG is not set 17 - # CONFIG_IOSCHED_DEADLINE is not set 18 - # CONFIG_IOSCHED_CFQ is not set 19 17 # CONFIG_MMU is not set 20 18 CONFIG_ARCH_STM32=y 21 19 CONFIG_CPU_V7M_NUM_IRQ=240
+1
arch/arm/configs/sunxi_defconfig
··· 85 85 CONFIG_AXP20X_POWER=y 86 86 CONFIG_THERMAL=y 87 87 CONFIG_CPU_THERMAL=y 88 + CONFIG_SUN8I_THERMAL=y 88 89 CONFIG_WATCHDOG=y 89 90 CONFIG_SUNXI_WATCHDOG=y 90 91 CONFIG_MFD_AC100=y
-2
arch/arm/configs/u300_defconfig
··· 11 11 CONFIG_MODULE_UNLOAD=y 12 12 # CONFIG_BLK_DEV_BSG is not set 13 13 CONFIG_PARTITION_ADVANCED=y 14 - # CONFIG_IOSCHED_CFQ is not set 15 14 # CONFIG_ARCH_MULTI_V7 is not set 16 15 CONFIG_ARCH_U300=y 17 16 CONFIG_MACH_U300_SPIDUMMY=y ··· 45 46 CONFIG_BACKLIGHT_CLASS_DEVICE=y 46 47 # CONFIG_USB_SUPPORT is not set 47 48 CONFIG_MMC=y 48 - # CONFIG_MMC_BLOCK_BOUNCE is not set 49 49 CONFIG_MMC_ARMMMCI=y 50 50 CONFIG_RTC_CLASS=y 51 51 # CONFIG_RTC_HCTOSYS is not set
-2
arch/arm/configs/vexpress_defconfig
··· 15 15 CONFIG_MODULES=y 16 16 CONFIG_MODULE_UNLOAD=y 17 17 # CONFIG_BLK_DEV_BSG is not set 18 - # CONFIG_IOSCHED_DEADLINE is not set 19 - # CONFIG_IOSCHED_CFQ is not set 20 18 CONFIG_ARCH_VEXPRESS=y 21 19 CONFIG_ARCH_VEXPRESS_DCSCB=y 22 20 CONFIG_ARCH_VEXPRESS_TC2_PM=y
-1
arch/arm/configs/viper_defconfig
··· 9 9 CONFIG_MODULES=y 10 10 CONFIG_MODULE_UNLOAD=y 11 11 # CONFIG_BLK_DEV_BSG is not set 12 - # CONFIG_IOSCHED_CFQ is not set 13 12 CONFIG_ARCH_PXA=y 14 13 CONFIG_ARCH_VIPER=y 15 14 CONFIG_IWMMXT=y
-2
arch/arm/configs/zeus_defconfig
··· 4 4 CONFIG_MODULES=y 5 5 CONFIG_MODULE_UNLOAD=y 6 6 # CONFIG_BLK_DEV_BSG is not set 7 - # CONFIG_IOSCHED_CFQ is not set 8 7 CONFIG_ARCH_PXA=y 9 8 CONFIG_MACH_ARCOM_ZEUS=y 10 9 CONFIG_PCCARD=m ··· 136 137 CONFIG_USB_G_SERIAL=m 137 138 CONFIG_USB_G_PRINTER=m 138 139 CONFIG_MMC=y 139 - # CONFIG_MMC_BLOCK_BOUNCE is not set 140 140 CONFIG_MMC_PXA=y 141 141 CONFIG_NEW_LEDS=y 142 142 CONFIG_LEDS_CLASS=m
-1
arch/arm/configs/zx_defconfig
··· 16 16 CONFIG_PERF_EVENTS=y 17 17 CONFIG_SLAB=y 18 18 # CONFIG_BLK_DEV_BSG is not set 19 - # CONFIG_IOSCHED_CFQ is not set 20 19 CONFIG_ARCH_ZX=y 21 20 CONFIG_SOC_ZX296702=y 22 21 # CONFIG_SWP_EMULATE is not set
+2 -5
arch/arm/kernel/ftrace.c
··· 78 78 { 79 79 unsigned long replaced; 80 80 81 - if (IS_ENABLED(CONFIG_THUMB2_KERNEL)) { 81 + if (IS_ENABLED(CONFIG_THUMB2_KERNEL)) 82 82 old = __opcode_to_mem_thumb32(old); 83 - new = __opcode_to_mem_thumb32(new); 84 - } else { 83 + else 85 84 old = __opcode_to_mem_arm(old); 86 - new = __opcode_to_mem_arm(new); 87 - } 88 85 89 86 if (validate) { 90 87 if (probe_kernel_read(&replaced, (void *)pc, MCOUNT_INSN_SIZE))
+9 -10
arch/arm/kernel/patch.c
··· 16 16 unsigned int insn; 17 17 }; 18 18 19 + #ifdef CONFIG_MMU 19 20 static DEFINE_RAW_SPINLOCK(patch_lock); 20 21 21 22 static void __kprobes *patch_map(void *addr, int fixmap, unsigned long *flags) 22 - __acquires(&patch_lock) 23 23 { 24 24 unsigned int uintaddr = (uintptr_t) addr; 25 25 bool module = !core_kernel_text(uintaddr); ··· 34 34 35 35 if (flags) 36 36 raw_spin_lock_irqsave(&patch_lock, *flags); 37 - else 38 - __acquire(&patch_lock); 39 37 40 38 set_fixmap(fixmap, page_to_phys(page)); 41 39 ··· 41 43 } 42 44 43 45 static void __kprobes patch_unmap(int fixmap, unsigned long *flags) 44 - __releases(&patch_lock) 45 46 { 46 47 clear_fixmap(fixmap); 47 48 48 49 if (flags) 49 50 raw_spin_unlock_irqrestore(&patch_lock, *flags); 50 - else 51 - __release(&patch_lock); 52 51 } 52 + #else 53 + static void __kprobes *patch_map(void *addr, int fixmap, unsigned long *flags) 54 + { 55 + return addr; 56 + } 57 + static void __kprobes patch_unmap(int fixmap, unsigned long *flags) { } 58 + #endif 53 59 54 60 void __kprobes __patch_text_real(void *addr, unsigned int insn, bool remap) 55 61 { ··· 66 64 67 65 if (remap) 68 66 waddr = patch_map(addr, FIX_TEXT_POKE0, &flags); 69 - else 70 - __acquire(&patch_lock); 71 67 72 68 if (thumb2 && __opcode_is_thumb16(insn)) { 73 69 *(u16 *)waddr = __opcode_to_mem_thumb16(insn); ··· 102 102 if (waddr != addr) { 103 103 flush_kernel_vmap_range(waddr, twopage ? size / 2 : size); 104 104 patch_unmap(FIX_TEXT_POKE0, &flags); 105 - } else 106 - __release(&patch_lock); 105 + } 107 106 108 107 flush_icache_range((uintptr_t)(addr), 109 108 (uintptr_t)(addr) + size);
+1 -1
arch/arm/mach-npcm/Kconfig
··· 11 11 depends on ARCH_MULTI_V7 12 12 select PINCTRL_NPCM7XX 13 13 select NPCM7XX_TIMER 14 - select ARCH_REQUIRE_GPIOLIB 14 + select GPIOLIB 15 15 select CACHE_L2X0 16 16 select ARM_GIC 17 17 select HAVE_ARM_TWD if SMP
+4 -4
arch/arm64/boot/dts/arm/fvp-base-revc.dts
··· 161 161 bus-range = <0x0 0x1>; 162 162 reg = <0x0 0x40000000 0x0 0x10000000>; 163 163 ranges = <0x2000000 0x0 0x50000000 0x0 0x50000000 0x0 0x10000000>; 164 - interrupt-map = <0 0 0 1 &gic GIC_SPI 168 IRQ_TYPE_LEVEL_HIGH>, 165 - <0 0 0 2 &gic GIC_SPI 169 IRQ_TYPE_LEVEL_HIGH>, 166 - <0 0 0 3 &gic GIC_SPI 170 IRQ_TYPE_LEVEL_HIGH>, 167 - <0 0 0 4 &gic GIC_SPI 171 IRQ_TYPE_LEVEL_HIGH>; 164 + interrupt-map = <0 0 0 1 &gic 0 0 GIC_SPI 168 IRQ_TYPE_LEVEL_HIGH>, 165 + <0 0 0 2 &gic 0 0 GIC_SPI 169 IRQ_TYPE_LEVEL_HIGH>, 166 + <0 0 0 3 &gic 0 0 GIC_SPI 170 IRQ_TYPE_LEVEL_HIGH>, 167 + <0 0 0 4 &gic 0 0 GIC_SPI 171 IRQ_TYPE_LEVEL_HIGH>; 168 168 interrupt-map-mask = <0x0 0x0 0x0 0x7>; 169 169 msi-map = <0x0 &its 0x0 0x10000>; 170 170 iommu-map = <0x0 &smmu 0x0 0x10000>;
+3 -1
arch/arm64/configs/defconfig
··· 452 452 CONFIG_CPU_THERMAL=y 453 453 CONFIG_THERMAL_EMULATION=y 454 454 CONFIG_QORIQ_THERMAL=m 455 + CONFIG_SUN8I_THERMAL=y 455 456 CONFIG_ROCKCHIP_THERMAL=m 456 457 CONFIG_RCAR_THERMAL=y 457 458 CONFIG_RCAR_GEN3_THERMAL=y ··· 548 547 CONFIG_ROCKCHIP_INNO_HDMI=y 549 548 CONFIG_DRM_RCAR_DU=m 550 549 CONFIG_DRM_SUN4I=m 550 + CONFIG_DRM_SUN6I_DSI=m 551 551 CONFIG_DRM_SUN8I_DW_HDMI=m 552 552 CONFIG_DRM_SUN8I_MIXER=m 553 553 CONFIG_DRM_MSM=m ··· 683 681 CONFIG_RTC_DRV_IMX_SC=m 684 682 CONFIG_RTC_DRV_XGENE=y 685 683 CONFIG_DMADEVICES=y 686 - CONFIG_DMA_BCM2835=m 684 + CONFIG_DMA_BCM2835=y 687 685 CONFIG_DMA_SUN6I=m 688 686 CONFIG_FSL_EDMA=y 689 687 CONFIG_IMX_SDMA=y
-4
arch/arm64/include/asm/exception.h
··· 33 33 34 34 asmlinkage void enter_from_user_mode(void); 35 35 void do_mem_abort(unsigned long addr, unsigned int esr, struct pt_regs *regs); 36 - void do_sp_pc_abort(unsigned long addr, unsigned int esr, struct pt_regs *regs); 37 36 void do_undefinstr(struct pt_regs *regs); 38 37 asmlinkage void bad_mode(struct pt_regs *regs, int reason, unsigned int esr); 39 38 void do_debug_exception(unsigned long addr_if_watchpoint, unsigned int esr, ··· 46 47 void do_cp15instr(unsigned int esr, struct pt_regs *regs); 47 48 void do_el0_svc(struct pt_regs *regs); 48 49 void do_el0_svc_compat(struct pt_regs *regs); 49 - void do_el0_ia_bp_hardening(unsigned long addr, unsigned int esr, 50 - struct pt_regs *regs); 51 - 52 50 #endif /* __ASM_EXCEPTION_H */
+5 -1
arch/arm64/include/asm/spinlock.h
··· 18 18 * See: 19 19 * https://lore.kernel.org/lkml/20200110100612.GC2827@hirez.programming.kicks-ass.net 20 20 */ 21 - #define vcpu_is_preempted(cpu) false 21 + #define vcpu_is_preempted vcpu_is_preempted 22 + static inline bool vcpu_is_preempted(int cpu) 23 + { 24 + return false; 25 + } 22 26 23 27 #endif /* __ASM_SPINLOCK_H */
+1
arch/arm64/kernel/kaslr.c
··· 11 11 #include <linux/sched.h> 12 12 #include <linux/types.h> 13 13 14 + #include <asm/archrandom.h> 14 15 #include <asm/cacheflush.h> 15 16 #include <asm/fixmap.h> 16 17 #include <asm/kernel-pgtable.h>
+9 -4
arch/arm64/kernel/process.c
··· 466 466 if (unlikely(next->flags & PF_KTHREAD)) 467 467 return; 468 468 469 + /* 470 + * If all CPUs implement the SSBS extension, then we just need to 471 + * context-switch the PSTATE field. 472 + */ 473 + if (cpu_have_feature(cpu_feature(SSBS))) 474 + return; 475 + 469 476 /* If the mitigation is enabled, then we leave SSBS clear. */ 470 477 if ((arm64_get_ssbd_state() == ARM64_SSBD_FORCE_ENABLE) || 471 478 test_tsk_thread_flag(next, TIF_SSBD)) ··· 615 608 * only prevents the tagged address ABI enabling via prctl() and does not 616 609 * disable it for tasks that already opted in to the relaxed ABI. 617 610 */ 618 - static int zero; 619 - static int one = 1; 620 611 621 612 static struct ctl_table tagged_addr_sysctl_table[] = { 622 613 { ··· 623 618 .data = &tagged_addr_disabled, 624 619 .maxlen = sizeof(int), 625 620 .proc_handler = proc_dointvec_minmax, 626 - .extra1 = &zero, 627 - .extra2 = &one, 621 + .extra1 = SYSCTL_ZERO, 622 + .extra2 = SYSCTL_ONE, 628 623 }, 629 624 { } 630 625 };
+1 -1
arch/arm64/kernel/time.c
··· 23 23 #include <linux/irq.h> 24 24 #include <linux/delay.h> 25 25 #include <linux/clocksource.h> 26 - #include <linux/clk-provider.h> 26 + #include <linux/of_clk.h> 27 27 #include <linux/acpi.h> 28 28 29 29 #include <clocksource/arm_arch_timer.h>
+1 -1
arch/s390/boot/Makefile
··· 37 37 obj-y := head.o als.o startup.o mem_detect.o ipl_parm.o ipl_report.o 38 38 obj-y += string.o ebcdic.o sclp_early_core.o mem.o ipl_vmparm.o cmdline.o 39 39 obj-y += version.o pgm_check_info.o ctype.o text_dma.o 40 - obj-$(CONFIG_PROTECTED_VIRTUALIZATION_GUEST) += uv.o 40 + obj-$(findstring y, $(CONFIG_PROTECTED_VIRTUALIZATION_GUEST) $(CONFIG_PGSTE)) += uv.o 41 41 obj-$(CONFIG_RELOCATABLE) += machine_kexec_reloc.o 42 42 obj-$(CONFIG_RANDOMIZE_BASE) += kaslr.o 43 43 targets := bzImage startup.a section_cmp.boot.data section_cmp.boot.preserved.data $(obj-y)
+22 -1
arch/s390/boot/uv.c
··· 3 3 #include <asm/facility.h> 4 4 #include <asm/sections.h> 5 5 6 + /* will be used in arch/s390/kernel/uv.c */ 7 + #ifdef CONFIG_PROTECTED_VIRTUALIZATION_GUEST 6 8 int __bootdata_preserved(prot_virt_guest); 9 + #endif 10 + #if IS_ENABLED(CONFIG_KVM) 11 + struct uv_info __bootdata_preserved(uv_info); 12 + #endif 7 13 8 14 void uv_query_info(void) 9 15 { ··· 21 15 if (!test_facility(158)) 22 16 return; 23 17 24 - if (uv_call(0, (uint64_t)&uvcb)) 18 + /* rc==0x100 means that there is additional data we do not process */ 19 + if (uv_call(0, (uint64_t)&uvcb) && uvcb.header.rc != 0x100) 25 20 return; 26 21 22 + if (IS_ENABLED(CONFIG_KVM)) { 23 + memcpy(uv_info.inst_calls_list, uvcb.inst_calls_list, sizeof(uv_info.inst_calls_list)); 24 + uv_info.uv_base_stor_len = uvcb.uv_base_stor_len; 25 + uv_info.guest_base_stor_len = uvcb.conf_base_phys_stor_len; 26 + uv_info.guest_virt_base_stor_len = uvcb.conf_base_virt_stor_len; 27 + uv_info.guest_virt_var_stor_len = uvcb.conf_virt_var_stor_len; 28 + uv_info.guest_cpu_stor_len = uvcb.cpu_stor_len; 29 + uv_info.max_sec_stor_addr = ALIGN(uvcb.max_guest_stor_addr, PAGE_SIZE); 30 + uv_info.max_num_sec_conf = uvcb.max_num_sec_conf; 31 + uv_info.max_guest_cpus = uvcb.max_guest_cpus; 32 + } 33 + 34 + #ifdef CONFIG_PROTECTED_VIRTUALIZATION_GUEST 27 35 if (test_bit_inv(BIT_UVC_CMD_SET_SHARED_ACCESS, (unsigned long *)uvcb.inst_calls_list) && 28 36 test_bit_inv(BIT_UVC_CMD_REMOVE_SHARED_ACCESS, (unsigned long *)uvcb.inst_calls_list)) 29 37 prot_virt_guest = 1; 38 + #endif 30 39 }
+6
arch/s390/include/asm/gmap.h
··· 9 9 #ifndef _ASM_S390_GMAP_H 10 10 #define _ASM_S390_GMAP_H 11 11 12 + #include <linux/radix-tree.h> 12 13 #include <linux/refcount.h> 13 14 14 15 /* Generic bits for GMAP notification on DAT table entry changes. */ ··· 32 31 * @table: pointer to the page directory 33 32 * @asce: address space control element for gmap page table 34 33 * @pfault_enabled: defines if pfaults are applicable for the guest 34 + * @guest_handle: protected virtual machine handle for the ultravisor 35 35 * @host_to_rmap: radix tree with gmap_rmap lists 36 36 * @children: list of shadow gmap structures 37 37 * @pt_list: list of all page tables used in the shadow guest address space ··· 56 54 unsigned long asce_end; 57 55 void *private; 58 56 bool pfault_enabled; 57 + /* only set for protected virtual machines */ 58 + unsigned long guest_handle; 59 59 /* Additional data for shadow guest address spaces */ 60 60 struct radix_tree_root host_to_rmap; 61 61 struct list_head children; ··· 148 144 149 145 void gmap_sync_dirty_log_pmd(struct gmap *gmap, unsigned long dirty_bitmap[4], 150 146 unsigned long gaddr, unsigned long vmaddr); 147 + int gmap_mark_unmergeable(void); 148 + void s390_reset_acc(struct mm_struct *mm); 151 149 #endif /* _ASM_S390_GMAP_H */
+94 -19
arch/s390/include/asm/kvm_host.h
··· 127 127 #define CR14_INITIAL_MASK (CR14_UNUSED_32 | CR14_UNUSED_33 | \ 128 128 CR14_EXTERNAL_DAMAGE_SUBMASK) 129 129 130 + #define SIDAD_SIZE_MASK 0xff 131 + #define sida_origin(sie_block) \ 132 + ((sie_block)->sidad & PAGE_MASK) 133 + #define sida_size(sie_block) \ 134 + ((((sie_block)->sidad & SIDAD_SIZE_MASK) + 1) * PAGE_SIZE) 135 + 130 136 #define CPUSTAT_STOPPED 0x80000000 131 137 #define CPUSTAT_WAIT 0x10000000 132 138 #define CPUSTAT_ECALL_PEND 0x08000000 ··· 166 160 __u8 reserved08[4]; /* 0x0008 */ 167 161 #define PROG_IN_SIE (1<<0) 168 162 __u32 prog0c; /* 0x000c */ 169 - __u8 reserved10[16]; /* 0x0010 */ 163 + union { 164 + __u8 reserved10[16]; /* 0x0010 */ 165 + struct { 166 + __u64 pv_handle_cpu; 167 + __u64 pv_handle_config; 168 + }; 169 + }; 170 170 #define PROG_BLOCK_SIE (1<<0) 171 171 #define PROG_REQUEST (1<<1) 172 172 atomic_t prog20; /* 0x0020 */ ··· 221 209 #define ICPT_PARTEXEC 0x38 222 210 #define ICPT_IOINST 0x40 223 211 #define ICPT_KSS 0x5c 212 + #define ICPT_MCHKREQ 0x60 213 + #define ICPT_INT_ENABLE 0x64 214 + #define ICPT_PV_INSTR 0x68 215 + #define ICPT_PV_NOTIFY 0x6c 216 + #define ICPT_PV_PREF 0x70 224 217 __u8 icptcode; /* 0x0050 */ 225 218 __u8 icptstatus; /* 0x0051 */ 226 219 __u16 ihcpu; /* 0x0052 */ 227 - __u8 reserved54[2]; /* 0x0054 */ 220 + __u8 reserved54; /* 0x0054 */ 221 + #define IICTL_CODE_NONE 0x00 222 + #define IICTL_CODE_MCHK 0x01 223 + #define IICTL_CODE_EXT 0x02 224 + #define IICTL_CODE_IO 0x03 225 + #define IICTL_CODE_RESTART 0x04 226 + #define IICTL_CODE_SPECIFICATION 0x10 227 + #define IICTL_CODE_OPERAND 0x11 228 + __u8 iictl; /* 0x0055 */ 228 229 __u16 ipa; /* 0x0056 */ 229 230 __u32 ipb; /* 0x0058 */ 230 231 __u32 scaoh; /* 0x005c */ ··· 258 233 #define ECB3_RI 0x01 259 234 __u8 ecb3; /* 0x0063 */ 260 235 __u32 scaol; /* 0x0064 */ 261 - __u8 reserved68; /* 0x0068 */ 236 + __u8 sdf; /* 0x0068 */ 262 237 __u8 epdx; /* 0x0069 */ 263 238 __u8 reserved6a[2]; /* 0x006a */ 264 239 __u32 todpr; /* 0x006c */ ··· 274 249 #define HPID_KVM 0x4 275 250 #define HPID_VSIE 0x5 276 251 __u8 hpid; /* 0x00b8 */ 277 - __u8 reservedb9[11]; /* 0x00b9 */ 278 - __u16 extcpuaddr; /* 0x00c4 */ 279 - __u16 eic; /* 0x00c6 */ 252 + __u8 reservedb9[7]; /* 0x00b9 */ 253 + union { 254 + struct { 255 + __u32 eiparams; /* 0x00c0 */ 256 + __u16 extcpuaddr; /* 0x00c4 */ 257 + __u16 eic; /* 0x00c6 */ 258 + }; 259 + __u64 mcic; /* 0x00c0 */ 260 + } __packed; 280 261 __u32 reservedc8; /* 0x00c8 */ 281 - __u16 pgmilc; /* 0x00cc */ 282 - __u16 iprcc; /* 0x00ce */ 283 - __u32 dxc; /* 0x00d0 */ 284 - __u16 mcn; /* 0x00d4 */ 285 - __u8 perc; /* 0x00d6 */ 286 - __u8 peratmid; /* 0x00d7 */ 262 + union { 263 + struct { 264 + __u16 pgmilc; /* 0x00cc */ 265 + __u16 iprcc; /* 0x00ce */ 266 + }; 267 + __u32 edc; /* 0x00cc */ 268 + } __packed; 269 + union { 270 + struct { 271 + __u32 dxc; /* 0x00d0 */ 272 + __u16 mcn; /* 0x00d4 */ 273 + __u8 perc; /* 0x00d6 */ 274 + __u8 peratmid; /* 0x00d7 */ 275 + }; 276 + __u64 faddr; /* 0x00d0 */ 277 + } __packed; 287 278 __u64 peraddr; /* 0x00d8 */ 288 279 __u8 eai; /* 0x00e0 */ 289 280 __u8 peraid; /* 0x00e1 */ 290 281 __u8 oai; /* 0x00e2 */ 291 282 __u8 armid; /* 0x00e3 */ 292 283 __u8 reservede4[4]; /* 0x00e4 */ 293 - __u64 tecmc; /* 0x00e8 */ 294 - __u8 reservedf0[12]; /* 0x00f0 */ 284 + union { 285 + __u64 tecmc; /* 0x00e8 */ 286 + struct { 287 + __u16 subchannel_id; /* 0x00e8 */ 288 + __u16 subchannel_nr; /* 0x00ea */ 289 + __u32 io_int_parm; /* 0x00ec */ 290 + __u32 io_int_word; /* 0x00f0 */ 291 + }; 292 + } __packed; 293 + __u8 reservedf4[8]; /* 0x00f4 */ 295 294 #define CRYCB_FORMAT_MASK 0x00000003 296 295 #define CRYCB_FORMAT0 0x00000000 297 296 #define CRYCB_FORMAT1 0x00000001 298 297 #define CRYCB_FORMAT2 0x00000003 299 298 __u32 crycbd; /* 0x00fc */ 300 299 __u64 gcr[16]; /* 0x0100 */ 301 - __u64 gbea; /* 0x0180 */ 300 + union { 301 + __u64 gbea; /* 0x0180 */ 302 + __u64 sidad; 303 + }; 302 304 __u8 reserved188[8]; /* 0x0188 */ 303 305 __u64 sdnxo; /* 0x0190 */ 304 306 __u8 reserved198[8]; /* 0x0198 */ ··· 353 301 struct sie_page { 354 302 struct kvm_s390_sie_block sie_block; 355 303 struct mcck_volatile_info mcck_info; /* 0x0200 */ 356 - __u8 reserved218[1000]; /* 0x0218 */ 304 + __u8 reserved218[360]; /* 0x0218 */ 305 + __u64 pv_grregs[16]; /* 0x0380 */ 306 + __u8 reserved400[512]; /* 0x0400 */ 357 307 struct kvm_s390_itdb itdb; /* 0x0600 */ 358 308 __u8 reserved700[2304]; /* 0x0700 */ 359 309 }; ··· 530 476 IRQ_PEND_PFAULT_INIT, 531 477 IRQ_PEND_EXT_HOST, 532 478 IRQ_PEND_EXT_SERVICE, 479 + IRQ_PEND_EXT_SERVICE_EV, 533 480 IRQ_PEND_EXT_TIMING, 534 481 IRQ_PEND_EXT_CPU_TIMER, 535 482 IRQ_PEND_EXT_CLOCK_COMP, ··· 575 520 (1UL << IRQ_PEND_EXT_TIMING) | \ 576 521 (1UL << IRQ_PEND_EXT_HOST) | \ 577 522 (1UL << IRQ_PEND_EXT_SERVICE) | \ 523 + (1UL << IRQ_PEND_EXT_SERVICE_EV) | \ 578 524 (1UL << IRQ_PEND_VIRTIO) | \ 579 525 (1UL << IRQ_PEND_PFAULT_INIT) | \ 580 526 (1UL << IRQ_PEND_PFAULT_DONE)) ··· 591 535 592 536 #define IRQ_PEND_MCHK_MASK ((1UL << IRQ_PEND_MCHK_REP) | \ 593 537 (1UL << IRQ_PEND_MCHK_EX)) 538 + 539 + #define IRQ_PEND_EXT_II_MASK ((1UL << IRQ_PEND_EXT_CPU_TIMER) | \ 540 + (1UL << IRQ_PEND_EXT_CLOCK_COMP) | \ 541 + (1UL << IRQ_PEND_EXT_EMERGENCY) | \ 542 + (1UL << IRQ_PEND_EXT_EXTERNAL) | \ 543 + (1UL << IRQ_PEND_EXT_SERVICE) | \ 544 + (1UL << IRQ_PEND_EXT_SERVICE_EV)) 594 545 595 546 struct kvm_s390_interrupt_info { 596 547 struct list_head list; ··· 657 594 658 595 struct kvm_s390_float_interrupt { 659 596 unsigned long pending_irqs; 597 + unsigned long masked_irqs; 660 598 spinlock_t lock; 661 599 struct list_head lists[FIRQ_LIST_COUNT]; 662 600 int counters[FIRQ_MAX_COUNT]; ··· 709 645 unsigned long last_bp; 710 646 }; 711 647 648 + struct kvm_s390_pv_vcpu { 649 + u64 handle; 650 + unsigned long stor_base; 651 + }; 652 + 712 653 struct kvm_vcpu_arch { 713 654 struct kvm_s390_sie_block *sie_block; 714 655 /* if vsie is active, currently executed shadow sie control block */ ··· 742 673 __u64 cputm_start; 743 674 bool gs_enabled; 744 675 bool skey_enabled; 676 + struct kvm_s390_pv_vcpu pv; 745 677 }; 746 678 747 679 struct kvm_vm_stat { ··· 771 701 bool masked; 772 702 bool swap; 773 703 bool suppressible; 774 - struct rw_semaphore maps_lock; 775 - struct list_head maps; 776 - atomic_t nr_maps; 777 704 }; 778 705 779 706 #define MAX_S390_IO_ADAPTERS ((MAX_ISC + 1) * 8) ··· 913 846 DECLARE_BITMAP(kicked_mask, KVM_MAX_VCPUS); 914 847 }; 915 848 849 + struct kvm_s390_pv { 850 + u64 handle; 851 + u64 guest_len; 852 + unsigned long stor_base; 853 + void *stor_var; 854 + }; 855 + 916 856 struct kvm_arch{ 917 857 void *sca; 918 858 int use_esca; ··· 955 881 DECLARE_BITMAP(cpu_feat, KVM_S390_VM_CPU_FEAT_NR_BITS); 956 882 DECLARE_BITMAP(idle_mask, KVM_MAX_VCPUS); 957 883 struct kvm_s390_gisa_interrupt gisa_int; 884 + struct kvm_s390_pv pv; 958 885 }; 959 886 960 887 #define KVM_HVA_ERR_BAD (-1UL)
+2
arch/s390/include/asm/mmu.h
··· 16 16 unsigned long asce; 17 17 unsigned long asce_limit; 18 18 unsigned long vdso_base; 19 + /* The mmu context belongs to a secure guest. */ 20 + atomic_t is_protected; 19 21 /* 20 22 * The following bitfields need a down_write on the mm 21 23 * semaphore when they are written to. As they are only
+1
arch/s390/include/asm/mmu_context.h
··· 23 23 INIT_LIST_HEAD(&mm->context.gmap_list); 24 24 cpumask_clear(&mm->context.cpu_attach_mask); 25 25 atomic_set(&mm->context.flush_count, 0); 26 + atomic_set(&mm->context.is_protected, 0); 26 27 mm->context.gmap_asce = 0; 27 28 mm->context.flush_mm = 0; 28 29 mm->context.compat_mm = test_thread_flag(TIF_31BIT);
+5
arch/s390/include/asm/page.h
··· 153 153 #define HAVE_ARCH_FREE_PAGE 154 154 #define HAVE_ARCH_ALLOC_PAGE 155 155 156 + #if IS_ENABLED(CONFIG_PGSTE) 157 + int arch_make_page_accessible(struct page *page); 158 + #define HAVE_ARCH_MAKE_PAGE_ACCESSIBLE 159 + #endif 160 + 156 161 #endif /* !__ASSEMBLY__ */ 157 162 158 163 #define __PAGE_OFFSET 0x0UL
+30 -5
arch/s390/include/asm/pgtable.h
··· 19 19 #include <linux/atomic.h> 20 20 #include <asm/bug.h> 21 21 #include <asm/page.h> 22 + #include <asm/uv.h> 22 23 23 24 extern pgd_t swapper_pg_dir[]; 24 25 extern void paging_init(void); ··· 516 515 { 517 516 #ifdef CONFIG_PGSTE 518 517 if (unlikely(mm->context.has_pgste)) 518 + return 1; 519 + #endif 520 + return 0; 521 + } 522 + 523 + static inline int mm_is_protected(struct mm_struct *mm) 524 + { 525 + #ifdef CONFIG_PGSTE 526 + if (unlikely(atomic_read(&mm->context.is_protected))) 519 527 return 1; 520 528 #endif 521 529 return 0; ··· 1071 1061 static inline pte_t ptep_get_and_clear(struct mm_struct *mm, 1072 1062 unsigned long addr, pte_t *ptep) 1073 1063 { 1074 - return ptep_xchg_lazy(mm, addr, ptep, __pte(_PAGE_INVALID)); 1064 + pte_t res; 1065 + 1066 + res = ptep_xchg_lazy(mm, addr, ptep, __pte(_PAGE_INVALID)); 1067 + if (mm_is_protected(mm) && pte_present(res)) 1068 + uv_convert_from_secure(pte_val(res) & PAGE_MASK); 1069 + return res; 1075 1070 } 1076 1071 1077 1072 #define __HAVE_ARCH_PTEP_MODIFY_PROT_TRANSACTION ··· 1088 1073 static inline pte_t ptep_clear_flush(struct vm_area_struct *vma, 1089 1074 unsigned long addr, pte_t *ptep) 1090 1075 { 1091 - return ptep_xchg_direct(vma->vm_mm, addr, ptep, __pte(_PAGE_INVALID)); 1076 + pte_t res; 1077 + 1078 + res = ptep_xchg_direct(vma->vm_mm, addr, ptep, __pte(_PAGE_INVALID)); 1079 + if (mm_is_protected(vma->vm_mm) && pte_present(res)) 1080 + uv_convert_from_secure(pte_val(res) & PAGE_MASK); 1081 + return res; 1092 1082 } 1093 1083 1094 1084 /* ··· 1108 1088 unsigned long addr, 1109 1089 pte_t *ptep, int full) 1110 1090 { 1091 + pte_t res; 1092 + 1111 1093 if (full) { 1112 - pte_t pte = *ptep; 1094 + res = *ptep; 1113 1095 *ptep = __pte(_PAGE_INVALID); 1114 - return pte; 1096 + } else { 1097 + res = ptep_xchg_lazy(mm, addr, ptep, __pte(_PAGE_INVALID)); 1115 1098 } 1116 - return ptep_xchg_lazy(mm, addr, ptep, __pte(_PAGE_INVALID)); 1099 + if (mm_is_protected(mm) && pte_present(res)) 1100 + uv_convert_from_secure(pte_val(res) & PAGE_MASK); 1101 + return res; 1117 1102 } 1118 1103 1119 1104 #define __HAVE_ARCH_PTEP_SET_WRPROTECT
+1 -1
arch/s390/include/asm/timex.h
··· 155 155 156 156 static inline unsigned long long get_tod_clock(void) 157 157 { 158 - unsigned char clk[STORE_CLOCK_EXT_SIZE]; 158 + char clk[STORE_CLOCK_EXT_SIZE]; 159 159 160 160 get_tod_clock_ext(clk); 161 161 return *((unsigned long long *)&clk[1]);
+244 -7
arch/s390/include/asm/uv.h
··· 14 14 #include <linux/types.h> 15 15 #include <linux/errno.h> 16 16 #include <linux/bug.h> 17 + #include <linux/sched.h> 17 18 #include <asm/page.h> 19 + #include <asm/gmap.h> 18 20 19 21 #define UVC_RC_EXECUTED 0x0001 20 22 #define UVC_RC_INV_CMD 0x0002 21 23 #define UVC_RC_INV_STATE 0x0003 22 24 #define UVC_RC_INV_LEN 0x0005 23 25 #define UVC_RC_NO_RESUME 0x0007 26 + #define UVC_RC_NEED_DESTROY 0x8000 24 27 25 28 #define UVC_CMD_QUI 0x0001 29 + #define UVC_CMD_INIT_UV 0x000f 30 + #define UVC_CMD_CREATE_SEC_CONF 0x0100 31 + #define UVC_CMD_DESTROY_SEC_CONF 0x0101 32 + #define UVC_CMD_CREATE_SEC_CPU 0x0120 33 + #define UVC_CMD_DESTROY_SEC_CPU 0x0121 34 + #define UVC_CMD_CONV_TO_SEC_STOR 0x0200 35 + #define UVC_CMD_CONV_FROM_SEC_STOR 0x0201 36 + #define UVC_CMD_SET_SEC_CONF_PARAMS 0x0300 37 + #define UVC_CMD_UNPACK_IMG 0x0301 38 + #define UVC_CMD_VERIFY_IMG 0x0302 39 + #define UVC_CMD_CPU_RESET 0x0310 40 + #define UVC_CMD_CPU_RESET_INITIAL 0x0311 41 + #define UVC_CMD_PREPARE_RESET 0x0320 42 + #define UVC_CMD_CPU_RESET_CLEAR 0x0321 43 + #define UVC_CMD_CPU_SET_STATE 0x0330 44 + #define UVC_CMD_SET_UNSHARE_ALL 0x0340 45 + #define UVC_CMD_PIN_PAGE_SHARED 0x0341 46 + #define UVC_CMD_UNPIN_PAGE_SHARED 0x0342 26 47 #define UVC_CMD_SET_SHARED_ACCESS 0x1000 27 48 #define UVC_CMD_REMOVE_SHARED_ACCESS 0x1001 28 49 29 50 /* Bits in installed uv calls */ 30 51 enum uv_cmds_inst { 31 52 BIT_UVC_CMD_QUI = 0, 53 + BIT_UVC_CMD_INIT_UV = 1, 54 + BIT_UVC_CMD_CREATE_SEC_CONF = 2, 55 + BIT_UVC_CMD_DESTROY_SEC_CONF = 3, 56 + BIT_UVC_CMD_CREATE_SEC_CPU = 4, 57 + BIT_UVC_CMD_DESTROY_SEC_CPU = 5, 58 + BIT_UVC_CMD_CONV_TO_SEC_STOR = 6, 59 + BIT_UVC_CMD_CONV_FROM_SEC_STOR = 7, 32 60 BIT_UVC_CMD_SET_SHARED_ACCESS = 8, 33 61 BIT_UVC_CMD_REMOVE_SHARED_ACCESS = 9, 62 + BIT_UVC_CMD_SET_SEC_PARMS = 11, 63 + BIT_UVC_CMD_UNPACK_IMG = 13, 64 + BIT_UVC_CMD_VERIFY_IMG = 14, 65 + BIT_UVC_CMD_CPU_RESET = 15, 66 + BIT_UVC_CMD_CPU_RESET_INITIAL = 16, 67 + BIT_UVC_CMD_CPU_SET_STATE = 17, 68 + BIT_UVC_CMD_PREPARE_RESET = 18, 69 + BIT_UVC_CMD_CPU_PERFORM_CLEAR_RESET = 19, 70 + BIT_UVC_CMD_UNSHARE_ALL = 20, 71 + BIT_UVC_CMD_PIN_PAGE_SHARED = 21, 72 + BIT_UVC_CMD_UNPIN_PAGE_SHARED = 22, 34 73 }; 35 74 36 75 struct uv_cb_header { ··· 79 40 u16 rrc; /* Return Reason Code */ 80 41 } __packed __aligned(8); 81 42 43 + /* Query Ultravisor Information */ 82 44 struct uv_cb_qui { 83 45 struct uv_cb_header header; 84 46 u64 reserved08; 85 47 u64 inst_calls_list[4]; 86 - u64 reserved30[15]; 48 + u64 reserved30[2]; 49 + u64 uv_base_stor_len; 50 + u64 reserved48; 51 + u64 conf_base_phys_stor_len; 52 + u64 conf_base_virt_stor_len; 53 + u64 conf_virt_var_stor_len; 54 + u64 cpu_stor_len; 55 + u32 reserved70[3]; 56 + u32 max_num_sec_conf; 57 + u64 max_guest_stor_addr; 58 + u8 reserved88[158 - 136]; 59 + u16 max_guest_cpus; 60 + u8 reserveda0[200 - 160]; 87 61 } __packed __aligned(8); 88 62 63 + /* Initialize Ultravisor */ 64 + struct uv_cb_init { 65 + struct uv_cb_header header; 66 + u64 reserved08[2]; 67 + u64 stor_origin; 68 + u64 stor_len; 69 + u64 reserved28[4]; 70 + } __packed __aligned(8); 71 + 72 + /* Create Guest Configuration */ 73 + struct uv_cb_cgc { 74 + struct uv_cb_header header; 75 + u64 reserved08[2]; 76 + u64 guest_handle; 77 + u64 conf_base_stor_origin; 78 + u64 conf_virt_stor_origin; 79 + u64 reserved30; 80 + u64 guest_stor_origin; 81 + u64 guest_stor_len; 82 + u64 guest_sca; 83 + u64 guest_asce; 84 + u64 reserved58[5]; 85 + } __packed __aligned(8); 86 + 87 + /* Create Secure CPU */ 88 + struct uv_cb_csc { 89 + struct uv_cb_header header; 90 + u64 reserved08[2]; 91 + u64 cpu_handle; 92 + u64 guest_handle; 93 + u64 stor_origin; 94 + u8 reserved30[6]; 95 + u16 num; 96 + u64 state_origin; 97 + u64 reserved40[4]; 98 + } __packed __aligned(8); 99 + 100 + /* Convert to Secure */ 101 + struct uv_cb_cts { 102 + struct uv_cb_header header; 103 + u64 reserved08[2]; 104 + u64 guest_handle; 105 + u64 gaddr; 106 + } __packed __aligned(8); 107 + 108 + /* Convert from Secure / Pin Page Shared */ 109 + struct uv_cb_cfs { 110 + struct uv_cb_header header; 111 + u64 reserved08[2]; 112 + u64 paddr; 113 + } __packed __aligned(8); 114 + 115 + /* Set Secure Config Parameter */ 116 + struct uv_cb_ssc { 117 + struct uv_cb_header header; 118 + u64 reserved08[2]; 119 + u64 guest_handle; 120 + u64 sec_header_origin; 121 + u32 sec_header_len; 122 + u32 reserved2c; 123 + u64 reserved30[4]; 124 + } __packed __aligned(8); 125 + 126 + /* Unpack */ 127 + struct uv_cb_unp { 128 + struct uv_cb_header header; 129 + u64 reserved08[2]; 130 + u64 guest_handle; 131 + u64 gaddr; 132 + u64 tweak[2]; 133 + u64 reserved38[3]; 134 + } __packed __aligned(8); 135 + 136 + #define PV_CPU_STATE_OPR 1 137 + #define PV_CPU_STATE_STP 2 138 + #define PV_CPU_STATE_CHKSTP 3 139 + #define PV_CPU_STATE_OPR_LOAD 5 140 + 141 + struct uv_cb_cpu_set_state { 142 + struct uv_cb_header header; 143 + u64 reserved08[2]; 144 + u64 cpu_handle; 145 + u8 reserved20[7]; 146 + u8 state; 147 + u64 reserved28[5]; 148 + }; 149 + 150 + /* 151 + * A common UV call struct for calls that take no payload 152 + * Examples: 153 + * Destroy cpu/config 154 + * Verify 155 + */ 156 + struct uv_cb_nodata { 157 + struct uv_cb_header header; 158 + u64 reserved08[2]; 159 + u64 handle; 160 + u64 reserved20[4]; 161 + } __packed __aligned(8); 162 + 163 + /* Set Shared Access */ 89 164 struct uv_cb_share { 90 165 struct uv_cb_header header; 91 166 u64 reserved08[3]; ··· 207 54 u64 reserved28; 208 55 } __packed __aligned(8); 209 56 210 - static inline int uv_call(unsigned long r1, unsigned long r2) 57 + static inline int __uv_call(unsigned long r1, unsigned long r2) 211 58 { 212 59 int cc; 213 60 214 61 asm volatile( 215 - "0: .insn rrf,0xB9A40000,%[r1],%[r2],0,0\n" 216 - " brc 3,0b\n" 217 - " ipm %[cc]\n" 218 - " srl %[cc],28\n" 62 + " .insn rrf,0xB9A40000,%[r1],%[r2],0,0\n" 63 + " ipm %[cc]\n" 64 + " srl %[cc],28\n" 219 65 : [cc] "=d" (cc) 220 66 : [r1] "a" (r1), [r2] "a" (r2) 221 67 : "memory", "cc"); 222 68 return cc; 223 69 } 70 + 71 + static inline int uv_call(unsigned long r1, unsigned long r2) 72 + { 73 + int cc; 74 + 75 + do { 76 + cc = __uv_call(r1, r2); 77 + } while (cc > 1); 78 + return cc; 79 + } 80 + 81 + /* Low level uv_call that avoids stalls for long running busy conditions */ 82 + static inline int uv_call_sched(unsigned long r1, unsigned long r2) 83 + { 84 + int cc; 85 + 86 + do { 87 + cc = __uv_call(r1, r2); 88 + cond_resched(); 89 + } while (cc > 1); 90 + return cc; 91 + } 92 + 93 + /* 94 + * special variant of uv_call that only transports the cpu or guest 95 + * handle and the command, like destroy or verify. 96 + */ 97 + static inline int uv_cmd_nodata(u64 handle, u16 cmd, u16 *rc, u16 *rrc) 98 + { 99 + struct uv_cb_nodata uvcb = { 100 + .header.cmd = cmd, 101 + .header.len = sizeof(uvcb), 102 + .handle = handle, 103 + }; 104 + int cc; 105 + 106 + WARN(!handle, "No handle provided to Ultravisor call cmd %x\n", cmd); 107 + cc = uv_call_sched(0, (u64)&uvcb); 108 + *rc = uvcb.header.rc; 109 + *rrc = uvcb.header.rrc; 110 + return cc ? -EINVAL : 0; 111 + } 112 + 113 + struct uv_info { 114 + unsigned long inst_calls_list[4]; 115 + unsigned long uv_base_stor_len; 116 + unsigned long guest_base_stor_len; 117 + unsigned long guest_virt_base_stor_len; 118 + unsigned long guest_virt_var_stor_len; 119 + unsigned long guest_cpu_stor_len; 120 + unsigned long max_sec_stor_addr; 121 + unsigned int max_num_sec_conf; 122 + unsigned short max_guest_cpus; 123 + }; 124 + 125 + extern struct uv_info uv_info; 224 126 225 127 #ifdef CONFIG_PROTECTED_VIRTUALIZATION_GUEST 226 128 extern int prot_virt_guest; ··· 329 121 return share(addr, UVC_CMD_REMOVE_SHARED_ACCESS); 330 122 } 331 123 332 - void uv_query_info(void); 333 124 #else 334 125 #define is_prot_virt_guest() 0 335 126 static inline int uv_set_shared(unsigned long addr) { return 0; } 336 127 static inline int uv_remove_shared(unsigned long addr) { return 0; } 128 + #endif 129 + 130 + #if IS_ENABLED(CONFIG_KVM) 131 + extern int prot_virt_host; 132 + 133 + static inline int is_prot_virt_host(void) 134 + { 135 + return prot_virt_host; 136 + } 137 + 138 + int gmap_make_secure(struct gmap *gmap, unsigned long gaddr, void *uvcb); 139 + int uv_convert_from_secure(unsigned long paddr); 140 + int gmap_convert_to_secure(struct gmap *gmap, unsigned long gaddr); 141 + 142 + void setup_uv(void); 143 + void adjust_to_uv_max(unsigned long *vmax); 144 + #else 145 + #define is_prot_virt_host() 0 146 + static inline void setup_uv(void) {} 147 + static inline void adjust_to_uv_max(unsigned long *vmax) {} 148 + 149 + static inline int uv_convert_from_secure(unsigned long paddr) 150 + { 151 + return 0; 152 + } 153 + #endif 154 + 155 + #if defined(CONFIG_PROTECTED_VIRTUALIZATION_GUEST) || IS_ENABLED(CONFIG_KVM) 156 + void uv_query_info(void); 157 + #else 337 158 static inline void uv_query_info(void) {} 338 159 #endif 339 160
+1
arch/s390/kernel/Makefile
··· 78 78 obj-$(CONFIG_PERF_EVENTS) += perf_cpum_cf_diag.o 79 79 80 80 obj-$(CONFIG_TRACEPOINTS) += trace.o 81 + obj-$(findstring y, $(CONFIG_PROTECTED_VIRTUALIZATION_GUEST) $(CONFIG_PGSTE)) += uv.o 81 82 82 83 # vdso 83 84 obj-y += vdso64/
+2
arch/s390/kernel/entry.h
··· 24 24 25 25 void do_protection_exception(struct pt_regs *regs); 26 26 void do_dat_exception(struct pt_regs *regs); 27 + void do_secure_storage_access(struct pt_regs *regs); 28 + void do_non_secure_storage_access(struct pt_regs *regs); 27 29 28 30 void addressing_exception(struct pt_regs *regs); 29 31 void data_exception(struct pt_regs *regs);
+2 -2
arch/s390/kernel/pgm_check.S
··· 78 78 PGM_CHECK(do_dat_exception) /* 3a */ 79 79 PGM_CHECK(do_dat_exception) /* 3b */ 80 80 PGM_CHECK_DEFAULT /* 3c */ 81 - PGM_CHECK_DEFAULT /* 3d */ 82 - PGM_CHECK_DEFAULT /* 3e */ 81 + PGM_CHECK(do_secure_storage_access) /* 3d */ 82 + PGM_CHECK(do_non_secure_storage_access) /* 3e */ 83 83 PGM_CHECK_DEFAULT /* 3f */ 84 84 PGM_CHECK(monitor_event_exception) /* 40 */ 85 85 PGM_CHECK_DEFAULT /* 41 */
+5 -4
arch/s390/kernel/setup.c
··· 92 92 93 93 unsigned long int_hwcap = 0; 94 94 95 - #ifdef CONFIG_PROTECTED_VIRTUALIZATION_GUEST 96 - int __bootdata_preserved(prot_virt_guest); 97 - #endif 98 - 99 95 int __bootdata(noexec_disabled); 100 96 int __bootdata(memory_end_set); 101 97 unsigned long __bootdata(memory_end); ··· 559 563 else 560 564 vmax = _REGION1_SIZE; /* 4-level kernel page table */ 561 565 } 566 + 567 + if (is_prot_virt_host()) 568 + adjust_to_uv_max(&vmax); 562 569 563 570 /* module area is at the end of the kernel address space. */ 564 571 MODULES_END = vmax; ··· 1137 1138 */ 1138 1139 memblock_trim_memory(1UL << (MAX_ORDER - 1 + PAGE_SHIFT)); 1139 1140 1141 + if (is_prot_virt_host()) 1142 + setup_uv(); 1140 1143 setup_memory_end(); 1141 1144 setup_memory(); 1142 1145 dma_contiguous_reserve(memory_end);
+414
arch/s390/kernel/uv.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* 3 + * Common Ultravisor functions and initialization 4 + * 5 + * Copyright IBM Corp. 2019, 2020 6 + */ 7 + #define KMSG_COMPONENT "prot_virt" 8 + #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt 9 + 10 + #include <linux/kernel.h> 11 + #include <linux/types.h> 12 + #include <linux/sizes.h> 13 + #include <linux/bitmap.h> 14 + #include <linux/memblock.h> 15 + #include <linux/pagemap.h> 16 + #include <linux/swap.h> 17 + #include <asm/facility.h> 18 + #include <asm/sections.h> 19 + #include <asm/uv.h> 20 + 21 + /* the bootdata_preserved fields come from ones in arch/s390/boot/uv.c */ 22 + #ifdef CONFIG_PROTECTED_VIRTUALIZATION_GUEST 23 + int __bootdata_preserved(prot_virt_guest); 24 + #endif 25 + 26 + #if IS_ENABLED(CONFIG_KVM) 27 + int prot_virt_host; 28 + EXPORT_SYMBOL(prot_virt_host); 29 + struct uv_info __bootdata_preserved(uv_info); 30 + EXPORT_SYMBOL(uv_info); 31 + 32 + static int __init prot_virt_setup(char *val) 33 + { 34 + bool enabled; 35 + int rc; 36 + 37 + rc = kstrtobool(val, &enabled); 38 + if (!rc && enabled) 39 + prot_virt_host = 1; 40 + 41 + if (is_prot_virt_guest() && prot_virt_host) { 42 + prot_virt_host = 0; 43 + pr_warn("Protected virtualization not available in protected guests."); 44 + } 45 + 46 + if (prot_virt_host && !test_facility(158)) { 47 + prot_virt_host = 0; 48 + pr_warn("Protected virtualization not supported by the hardware."); 49 + } 50 + 51 + return rc; 52 + } 53 + early_param("prot_virt", prot_virt_setup); 54 + 55 + static int __init uv_init(unsigned long stor_base, unsigned long stor_len) 56 + { 57 + struct uv_cb_init uvcb = { 58 + .header.cmd = UVC_CMD_INIT_UV, 59 + .header.len = sizeof(uvcb), 60 + .stor_origin = stor_base, 61 + .stor_len = stor_len, 62 + }; 63 + 64 + if (uv_call(0, (uint64_t)&uvcb)) { 65 + pr_err("Ultravisor init failed with rc: 0x%x rrc: 0%x\n", 66 + uvcb.header.rc, uvcb.header.rrc); 67 + return -1; 68 + } 69 + return 0; 70 + } 71 + 72 + void __init setup_uv(void) 73 + { 74 + unsigned long uv_stor_base; 75 + 76 + uv_stor_base = (unsigned long)memblock_alloc_try_nid( 77 + uv_info.uv_base_stor_len, SZ_1M, SZ_2G, 78 + MEMBLOCK_ALLOC_ACCESSIBLE, NUMA_NO_NODE); 79 + if (!uv_stor_base) { 80 + pr_warn("Failed to reserve %lu bytes for ultravisor base storage\n", 81 + uv_info.uv_base_stor_len); 82 + goto fail; 83 + } 84 + 85 + if (uv_init(uv_stor_base, uv_info.uv_base_stor_len)) { 86 + memblock_free(uv_stor_base, uv_info.uv_base_stor_len); 87 + goto fail; 88 + } 89 + 90 + pr_info("Reserving %luMB as ultravisor base storage\n", 91 + uv_info.uv_base_stor_len >> 20); 92 + return; 93 + fail: 94 + pr_info("Disabling support for protected virtualization"); 95 + prot_virt_host = 0; 96 + } 97 + 98 + void adjust_to_uv_max(unsigned long *vmax) 99 + { 100 + *vmax = min_t(unsigned long, *vmax, uv_info.max_sec_stor_addr); 101 + } 102 + 103 + /* 104 + * Requests the Ultravisor to pin the page in the shared state. This will 105 + * cause an intercept when the guest attempts to unshare the pinned page. 106 + */ 107 + static int uv_pin_shared(unsigned long paddr) 108 + { 109 + struct uv_cb_cfs uvcb = { 110 + .header.cmd = UVC_CMD_PIN_PAGE_SHARED, 111 + .header.len = sizeof(uvcb), 112 + .paddr = paddr, 113 + }; 114 + 115 + if (uv_call(0, (u64)&uvcb)) 116 + return -EINVAL; 117 + return 0; 118 + } 119 + 120 + /* 121 + * Requests the Ultravisor to encrypt a guest page and make it 122 + * accessible to the host for paging (export). 123 + * 124 + * @paddr: Absolute host address of page to be exported 125 + */ 126 + int uv_convert_from_secure(unsigned long paddr) 127 + { 128 + struct uv_cb_cfs uvcb = { 129 + .header.cmd = UVC_CMD_CONV_FROM_SEC_STOR, 130 + .header.len = sizeof(uvcb), 131 + .paddr = paddr 132 + }; 133 + 134 + if (uv_call(0, (u64)&uvcb)) 135 + return -EINVAL; 136 + return 0; 137 + } 138 + 139 + /* 140 + * Calculate the expected ref_count for a page that would otherwise have no 141 + * further pins. This was cribbed from similar functions in other places in 142 + * the kernel, but with some slight modifications. We know that a secure 143 + * page can not be a huge page for example. 144 + */ 145 + static int expected_page_refs(struct page *page) 146 + { 147 + int res; 148 + 149 + res = page_mapcount(page); 150 + if (PageSwapCache(page)) { 151 + res++; 152 + } else if (page_mapping(page)) { 153 + res++; 154 + if (page_has_private(page)) 155 + res++; 156 + } 157 + return res; 158 + } 159 + 160 + static int make_secure_pte(pte_t *ptep, unsigned long addr, 161 + struct page *exp_page, struct uv_cb_header *uvcb) 162 + { 163 + pte_t entry = READ_ONCE(*ptep); 164 + struct page *page; 165 + int expected, rc = 0; 166 + 167 + if (!pte_present(entry)) 168 + return -ENXIO; 169 + if (pte_val(entry) & _PAGE_INVALID) 170 + return -ENXIO; 171 + 172 + page = pte_page(entry); 173 + if (page != exp_page) 174 + return -ENXIO; 175 + if (PageWriteback(page)) 176 + return -EAGAIN; 177 + expected = expected_page_refs(page); 178 + if (!page_ref_freeze(page, expected)) 179 + return -EBUSY; 180 + set_bit(PG_arch_1, &page->flags); 181 + rc = uv_call(0, (u64)uvcb); 182 + page_ref_unfreeze(page, expected); 183 + /* Return -ENXIO if the page was not mapped, -EINVAL otherwise */ 184 + if (rc) 185 + rc = uvcb->rc == 0x10a ? -ENXIO : -EINVAL; 186 + return rc; 187 + } 188 + 189 + /* 190 + * Requests the Ultravisor to make a page accessible to a guest. 191 + * If it's brought in the first time, it will be cleared. If 192 + * it has been exported before, it will be decrypted and integrity 193 + * checked. 194 + */ 195 + int gmap_make_secure(struct gmap *gmap, unsigned long gaddr, void *uvcb) 196 + { 197 + struct vm_area_struct *vma; 198 + bool local_drain = false; 199 + spinlock_t *ptelock; 200 + unsigned long uaddr; 201 + struct page *page; 202 + pte_t *ptep; 203 + int rc; 204 + 205 + again: 206 + rc = -EFAULT; 207 + down_read(&gmap->mm->mmap_sem); 208 + 209 + uaddr = __gmap_translate(gmap, gaddr); 210 + if (IS_ERR_VALUE(uaddr)) 211 + goto out; 212 + vma = find_vma(gmap->mm, uaddr); 213 + if (!vma) 214 + goto out; 215 + /* 216 + * Secure pages cannot be huge and userspace should not combine both. 217 + * In case userspace does it anyway this will result in an -EFAULT for 218 + * the unpack. The guest is thus never reaching secure mode. If 219 + * userspace is playing dirty tricky with mapping huge pages later 220 + * on this will result in a segmentation fault. 221 + */ 222 + if (is_vm_hugetlb_page(vma)) 223 + goto out; 224 + 225 + rc = -ENXIO; 226 + page = follow_page(vma, uaddr, FOLL_WRITE); 227 + if (IS_ERR_OR_NULL(page)) 228 + goto out; 229 + 230 + lock_page(page); 231 + ptep = get_locked_pte(gmap->mm, uaddr, &ptelock); 232 + rc = make_secure_pte(ptep, uaddr, page, uvcb); 233 + pte_unmap_unlock(ptep, ptelock); 234 + unlock_page(page); 235 + out: 236 + up_read(&gmap->mm->mmap_sem); 237 + 238 + if (rc == -EAGAIN) { 239 + wait_on_page_writeback(page); 240 + } else if (rc == -EBUSY) { 241 + /* 242 + * If we have tried a local drain and the page refcount 243 + * still does not match our expected safe value, try with a 244 + * system wide drain. This is needed if the pagevecs holding 245 + * the page are on a different CPU. 246 + */ 247 + if (local_drain) { 248 + lru_add_drain_all(); 249 + /* We give up here, and let the caller try again */ 250 + return -EAGAIN; 251 + } 252 + /* 253 + * We are here if the page refcount does not match the 254 + * expected safe value. The main culprits are usually 255 + * pagevecs. With lru_add_drain() we drain the pagevecs 256 + * on the local CPU so that hopefully the refcount will 257 + * reach the expected safe value. 258 + */ 259 + lru_add_drain(); 260 + local_drain = true; 261 + /* And now we try again immediately after draining */ 262 + goto again; 263 + } else if (rc == -ENXIO) { 264 + if (gmap_fault(gmap, gaddr, FAULT_FLAG_WRITE)) 265 + return -EFAULT; 266 + return -EAGAIN; 267 + } 268 + return rc; 269 + } 270 + EXPORT_SYMBOL_GPL(gmap_make_secure); 271 + 272 + int gmap_convert_to_secure(struct gmap *gmap, unsigned long gaddr) 273 + { 274 + struct uv_cb_cts uvcb = { 275 + .header.cmd = UVC_CMD_CONV_TO_SEC_STOR, 276 + .header.len = sizeof(uvcb), 277 + .guest_handle = gmap->guest_handle, 278 + .gaddr = gaddr, 279 + }; 280 + 281 + return gmap_make_secure(gmap, gaddr, &uvcb); 282 + } 283 + EXPORT_SYMBOL_GPL(gmap_convert_to_secure); 284 + 285 + /* 286 + * To be called with the page locked or with an extra reference! This will 287 + * prevent gmap_make_secure from touching the page concurrently. Having 2 288 + * parallel make_page_accessible is fine, as the UV calls will become a 289 + * no-op if the page is already exported. 290 + */ 291 + int arch_make_page_accessible(struct page *page) 292 + { 293 + int rc = 0; 294 + 295 + /* Hugepage cannot be protected, so nothing to do */ 296 + if (PageHuge(page)) 297 + return 0; 298 + 299 + /* 300 + * PG_arch_1 is used in 3 places: 301 + * 1. for kernel page tables during early boot 302 + * 2. for storage keys of huge pages and KVM 303 + * 3. As an indication that this page might be secure. This can 304 + * overindicate, e.g. we set the bit before calling 305 + * convert_to_secure. 306 + * As secure pages are never huge, all 3 variants can co-exists. 307 + */ 308 + if (!test_bit(PG_arch_1, &page->flags)) 309 + return 0; 310 + 311 + rc = uv_pin_shared(page_to_phys(page)); 312 + if (!rc) { 313 + clear_bit(PG_arch_1, &page->flags); 314 + return 0; 315 + } 316 + 317 + rc = uv_convert_from_secure(page_to_phys(page)); 318 + if (!rc) { 319 + clear_bit(PG_arch_1, &page->flags); 320 + return 0; 321 + } 322 + 323 + return rc; 324 + } 325 + EXPORT_SYMBOL_GPL(arch_make_page_accessible); 326 + 327 + #endif 328 + 329 + #if defined(CONFIG_PROTECTED_VIRTUALIZATION_GUEST) || IS_ENABLED(CONFIG_KVM) 330 + static ssize_t uv_query_facilities(struct kobject *kobj, 331 + struct kobj_attribute *attr, char *page) 332 + { 333 + return snprintf(page, PAGE_SIZE, "%lx\n%lx\n%lx\n%lx\n", 334 + uv_info.inst_calls_list[0], 335 + uv_info.inst_calls_list[1], 336 + uv_info.inst_calls_list[2], 337 + uv_info.inst_calls_list[3]); 338 + } 339 + 340 + static struct kobj_attribute uv_query_facilities_attr = 341 + __ATTR(facilities, 0444, uv_query_facilities, NULL); 342 + 343 + static ssize_t uv_query_max_guest_cpus(struct kobject *kobj, 344 + struct kobj_attribute *attr, char *page) 345 + { 346 + return snprintf(page, PAGE_SIZE, "%d\n", 347 + uv_info.max_guest_cpus); 348 + } 349 + 350 + static struct kobj_attribute uv_query_max_guest_cpus_attr = 351 + __ATTR(max_cpus, 0444, uv_query_max_guest_cpus, NULL); 352 + 353 + static ssize_t uv_query_max_guest_vms(struct kobject *kobj, 354 + struct kobj_attribute *attr, char *page) 355 + { 356 + return snprintf(page, PAGE_SIZE, "%d\n", 357 + uv_info.max_num_sec_conf); 358 + } 359 + 360 + static struct kobj_attribute uv_query_max_guest_vms_attr = 361 + __ATTR(max_guests, 0444, uv_query_max_guest_vms, NULL); 362 + 363 + static ssize_t uv_query_max_guest_addr(struct kobject *kobj, 364 + struct kobj_attribute *attr, char *page) 365 + { 366 + return snprintf(page, PAGE_SIZE, "%lx\n", 367 + uv_info.max_sec_stor_addr); 368 + } 369 + 370 + static struct kobj_attribute uv_query_max_guest_addr_attr = 371 + __ATTR(max_address, 0444, uv_query_max_guest_addr, NULL); 372 + 373 + static struct attribute *uv_query_attrs[] = { 374 + &uv_query_facilities_attr.attr, 375 + &uv_query_max_guest_cpus_attr.attr, 376 + &uv_query_max_guest_vms_attr.attr, 377 + &uv_query_max_guest_addr_attr.attr, 378 + NULL, 379 + }; 380 + 381 + static struct attribute_group uv_query_attr_group = { 382 + .attrs = uv_query_attrs, 383 + }; 384 + 385 + static struct kset *uv_query_kset; 386 + static struct kobject *uv_kobj; 387 + 388 + static int __init uv_info_init(void) 389 + { 390 + int rc = -ENOMEM; 391 + 392 + if (!test_facility(158)) 393 + return 0; 394 + 395 + uv_kobj = kobject_create_and_add("uv", firmware_kobj); 396 + if (!uv_kobj) 397 + return -ENOMEM; 398 + 399 + uv_query_kset = kset_create_and_add("query", NULL, uv_kobj); 400 + if (!uv_query_kset) 401 + goto out_kobj; 402 + 403 + rc = sysfs_create_group(&uv_query_kset->kobj, &uv_query_attr_group); 404 + if (!rc) 405 + return 0; 406 + 407 + kset_unregister(uv_query_kset); 408 + out_kobj: 409 + kobject_del(uv_kobj); 410 + kobject_put(uv_kobj); 411 + return rc; 412 + } 413 + device_initcall(uv_info_init); 414 + #endif
+1 -1
arch/s390/kvm/Makefile
··· 9 9 ccflags-y := -Ivirt/kvm -Iarch/s390/kvm 10 10 11 11 kvm-objs := $(common-objs) kvm-s390.o intercept.o interrupt.o priv.o sigp.o 12 - kvm-objs += diag.o gaccess.o guestdbg.o vsie.o 12 + kvm-objs += diag.o gaccess.o guestdbg.o vsie.o pv.o 13 13 14 14 obj-$(CONFIG_KVM) += kvm.o
+5 -1
arch/s390/kvm/diag.c
··· 2 2 /* 3 3 * handling diagnose instructions 4 4 * 5 - * Copyright IBM Corp. 2008, 2011 5 + * Copyright IBM Corp. 2008, 2020 6 6 * 7 7 * Author(s): Carsten Otte <cotte@de.ibm.com> 8 8 * Christian Borntraeger <borntraeger@de.ibm.com> ··· 201 201 return -EOPNOTSUPP; 202 202 } 203 203 204 + /* 205 + * no need to check the return value of vcpu_stop as it can only have 206 + * an error for protvirt, but protvirt means user cpu state 207 + */ 204 208 if (!kvm_s390_user_cpu_state_ctrl(vcpu->kvm)) 205 209 kvm_s390_vcpu_stop(vcpu); 206 210 vcpu->run->s390_reset_flags |= KVM_S390_RESET_SUBSYSTEM;
+116 -6
arch/s390/kvm/intercept.c
··· 2 2 /* 3 3 * in-kernel handling for sie intercepts 4 4 * 5 - * Copyright IBM Corp. 2008, 2014 5 + * Copyright IBM Corp. 2008, 2020 6 6 * 7 7 * Author(s): Carsten Otte <cotte@de.ibm.com> 8 8 * Christian Borntraeger <borntraeger@de.ibm.com> ··· 15 15 #include <asm/asm-offsets.h> 16 16 #include <asm/irq.h> 17 17 #include <asm/sysinfo.h> 18 + #include <asm/uv.h> 18 19 19 20 #include "kvm-s390.h" 20 21 #include "gaccess.h" ··· 79 78 return rc; 80 79 } 81 80 81 + /* 82 + * no need to check the return value of vcpu_stop as it can only have 83 + * an error for protvirt, but protvirt means user cpu state 84 + */ 82 85 if (!kvm_s390_user_cpu_state_ctrl(vcpu->kvm)) 83 86 kvm_s390_vcpu_stop(vcpu); 84 87 return -EOPNOTSUPP; ··· 234 229 int rc; 235 230 236 231 vcpu->stat.exit_program_interruption++; 232 + 233 + /* 234 + * Intercept 8 indicates a loop of specification exceptions 235 + * for protected guests. 236 + */ 237 + if (kvm_s390_pv_cpu_is_protected(vcpu)) 238 + return -EOPNOTSUPP; 237 239 238 240 if (guestdbg_enabled(vcpu) && per_event(vcpu)) { 239 241 rc = kvm_s390_handle_per_event(vcpu); ··· 395 383 goto out; 396 384 } 397 385 398 - if (addr & ~PAGE_MASK) 386 + if (!kvm_s390_pv_cpu_is_protected(vcpu) && (addr & ~PAGE_MASK)) 399 387 return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION); 400 388 401 389 sctns = (void *)get_zeroed_page(GFP_KERNEL); ··· 406 394 407 395 out: 408 396 if (!cc) { 409 - r = write_guest(vcpu, addr, reg2, sctns, PAGE_SIZE); 410 - if (r) { 411 - free_page((unsigned long)sctns); 412 - return kvm_s390_inject_prog_cond(vcpu, r); 397 + if (kvm_s390_pv_cpu_is_protected(vcpu)) { 398 + memcpy((void *)(sida_origin(vcpu->arch.sie_block)), 399 + sctns, PAGE_SIZE); 400 + } else { 401 + r = write_guest(vcpu, addr, reg2, sctns, PAGE_SIZE); 402 + if (r) { 403 + free_page((unsigned long)sctns); 404 + return kvm_s390_inject_prog_cond(vcpu, r); 405 + } 413 406 } 414 407 } 415 408 ··· 460 443 return kvm_s390_inject_program_int(vcpu, PGM_OPERATION); 461 444 } 462 445 446 + static int handle_pv_spx(struct kvm_vcpu *vcpu) 447 + { 448 + u32 pref = *(u32 *)vcpu->arch.sie_block->sidad; 449 + 450 + kvm_s390_set_prefix(vcpu, pref); 451 + trace_kvm_s390_handle_prefix(vcpu, 1, pref); 452 + return 0; 453 + } 454 + 455 + static int handle_pv_sclp(struct kvm_vcpu *vcpu) 456 + { 457 + struct kvm_s390_float_interrupt *fi = &vcpu->kvm->arch.float_int; 458 + 459 + spin_lock(&fi->lock); 460 + /* 461 + * 2 cases: 462 + * a: an sccb answering interrupt was already pending or in flight. 463 + * As the sccb value is not known we can simply set some value to 464 + * trigger delivery of a saved SCCB. UV will then use its saved 465 + * copy of the SCCB value. 466 + * b: an error SCCB interrupt needs to be injected so we also inject 467 + * a fake SCCB address. Firmware will use the proper one. 468 + * This makes sure, that both errors and real sccb returns will only 469 + * be delivered after a notification intercept (instruction has 470 + * finished) but not after others. 471 + */ 472 + fi->srv_signal.ext_params |= 0x43000; 473 + set_bit(IRQ_PEND_EXT_SERVICE, &fi->pending_irqs); 474 + clear_bit(IRQ_PEND_EXT_SERVICE, &fi->masked_irqs); 475 + spin_unlock(&fi->lock); 476 + return 0; 477 + } 478 + 479 + static int handle_pv_uvc(struct kvm_vcpu *vcpu) 480 + { 481 + struct uv_cb_share *guest_uvcb = (void *)vcpu->arch.sie_block->sidad; 482 + struct uv_cb_cts uvcb = { 483 + .header.cmd = UVC_CMD_UNPIN_PAGE_SHARED, 484 + .header.len = sizeof(uvcb), 485 + .guest_handle = kvm_s390_pv_get_handle(vcpu->kvm), 486 + .gaddr = guest_uvcb->paddr, 487 + }; 488 + int rc; 489 + 490 + if (guest_uvcb->header.cmd != UVC_CMD_REMOVE_SHARED_ACCESS) { 491 + WARN_ONCE(1, "Unexpected notification intercept for UVC 0x%x\n", 492 + guest_uvcb->header.cmd); 493 + return 0; 494 + } 495 + rc = gmap_make_secure(vcpu->arch.gmap, uvcb.gaddr, &uvcb); 496 + /* 497 + * If the unpin did not succeed, the guest will exit again for the UVC 498 + * and we will retry the unpin. 499 + */ 500 + if (rc == -EINVAL) 501 + return 0; 502 + return rc; 503 + } 504 + 505 + static int handle_pv_notification(struct kvm_vcpu *vcpu) 506 + { 507 + if (vcpu->arch.sie_block->ipa == 0xb210) 508 + return handle_pv_spx(vcpu); 509 + if (vcpu->arch.sie_block->ipa == 0xb220) 510 + return handle_pv_sclp(vcpu); 511 + if (vcpu->arch.sie_block->ipa == 0xb9a4) 512 + return handle_pv_uvc(vcpu); 513 + 514 + return handle_instruction(vcpu); 515 + } 516 + 463 517 int kvm_handle_sie_intercept(struct kvm_vcpu *vcpu) 464 518 { 465 519 int rc, per_rc = 0; ··· 566 478 break; 567 479 case ICPT_KSS: 568 480 rc = kvm_s390_skey_check_enable(vcpu); 481 + break; 482 + case ICPT_MCHKREQ: 483 + case ICPT_INT_ENABLE: 484 + /* 485 + * PSW bit 13 or a CR (0, 6, 14) changed and we might 486 + * now be able to deliver interrupts. The pre-run code 487 + * will take care of this. 488 + */ 489 + rc = 0; 490 + break; 491 + case ICPT_PV_INSTR: 492 + rc = handle_instruction(vcpu); 493 + break; 494 + case ICPT_PV_NOTIFY: 495 + rc = handle_pv_notification(vcpu); 496 + break; 497 + case ICPT_PV_PREF: 498 + rc = 0; 499 + gmap_convert_to_secure(vcpu->arch.gmap, 500 + kvm_s390_get_prefix(vcpu)); 501 + gmap_convert_to_secure(vcpu->arch.gmap, 502 + kvm_s390_get_prefix(vcpu) + PAGE_SIZE); 569 503 break; 570 504 default: 571 505 return -EOPNOTSUPP;
+233 -166
arch/s390/kvm/interrupt.c
··· 2 2 /* 3 3 * handling kvm guest interrupts 4 4 * 5 - * Copyright IBM Corp. 2008, 2015 5 + * Copyright IBM Corp. 2008, 2020 6 6 * 7 7 * Author(s): Carsten Otte <cotte@de.ibm.com> 8 8 */ ··· 324 324 325 325 static inline unsigned long pending_irqs_no_gisa(struct kvm_vcpu *vcpu) 326 326 { 327 - return vcpu->kvm->arch.float_int.pending_irqs | 328 - vcpu->arch.local_int.pending_irqs; 327 + unsigned long pending = vcpu->kvm->arch.float_int.pending_irqs | 328 + vcpu->arch.local_int.pending_irqs; 329 + 330 + pending &= ~vcpu->kvm->arch.float_int.masked_irqs; 331 + return pending; 329 332 } 330 333 331 334 static inline unsigned long pending_irqs(struct kvm_vcpu *vcpu) ··· 386 383 __clear_bit(IRQ_PEND_EXT_CLOCK_COMP, &active_mask); 387 384 if (!(vcpu->arch.sie_block->gcr[0] & CR0_CPU_TIMER_SUBMASK)) 388 385 __clear_bit(IRQ_PEND_EXT_CPU_TIMER, &active_mask); 389 - if (!(vcpu->arch.sie_block->gcr[0] & CR0_SERVICE_SIGNAL_SUBMASK)) 386 + if (!(vcpu->arch.sie_block->gcr[0] & CR0_SERVICE_SIGNAL_SUBMASK)) { 390 387 __clear_bit(IRQ_PEND_EXT_SERVICE, &active_mask); 388 + __clear_bit(IRQ_PEND_EXT_SERVICE_EV, &active_mask); 389 + } 391 390 if (psw_mchk_disabled(vcpu)) 392 391 active_mask &= ~IRQ_PEND_MCHK_MASK; 392 + /* PV guest cpus can have a single interruption injected at a time. */ 393 + if (kvm_s390_pv_cpu_is_protected(vcpu) && 394 + vcpu->arch.sie_block->iictl != IICTL_CODE_NONE) 395 + active_mask &= ~(IRQ_PEND_EXT_II_MASK | 396 + IRQ_PEND_IO_MASK | 397 + IRQ_PEND_MCHK_MASK); 393 398 /* 394 399 * Check both floating and local interrupt's cr14 because 395 400 * bit IRQ_PEND_MCHK_REP could be set in both cases. ··· 490 479 static int __must_check __deliver_cpu_timer(struct kvm_vcpu *vcpu) 491 480 { 492 481 struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int; 493 - int rc; 482 + int rc = 0; 494 483 495 484 vcpu->stat.deliver_cputm++; 496 485 trace_kvm_s390_deliver_interrupt(vcpu->vcpu_id, KVM_S390_INT_CPU_TIMER, 497 486 0, 0); 498 - 499 - rc = put_guest_lc(vcpu, EXT_IRQ_CPU_TIMER, 500 - (u16 *)__LC_EXT_INT_CODE); 501 - rc |= put_guest_lc(vcpu, 0, (u16 *)__LC_EXT_CPU_ADDR); 502 - rc |= write_guest_lc(vcpu, __LC_EXT_OLD_PSW, 503 - &vcpu->arch.sie_block->gpsw, sizeof(psw_t)); 504 - rc |= read_guest_lc(vcpu, __LC_EXT_NEW_PSW, 505 - &vcpu->arch.sie_block->gpsw, sizeof(psw_t)); 487 + if (kvm_s390_pv_cpu_is_protected(vcpu)) { 488 + vcpu->arch.sie_block->iictl = IICTL_CODE_EXT; 489 + vcpu->arch.sie_block->eic = EXT_IRQ_CPU_TIMER; 490 + } else { 491 + rc = put_guest_lc(vcpu, EXT_IRQ_CPU_TIMER, 492 + (u16 *)__LC_EXT_INT_CODE); 493 + rc |= put_guest_lc(vcpu, 0, (u16 *)__LC_EXT_CPU_ADDR); 494 + rc |= write_guest_lc(vcpu, __LC_EXT_OLD_PSW, 495 + &vcpu->arch.sie_block->gpsw, sizeof(psw_t)); 496 + rc |= read_guest_lc(vcpu, __LC_EXT_NEW_PSW, 497 + &vcpu->arch.sie_block->gpsw, sizeof(psw_t)); 498 + } 506 499 clear_bit(IRQ_PEND_EXT_CPU_TIMER, &li->pending_irqs); 507 500 return rc ? -EFAULT : 0; 508 501 } ··· 514 499 static int __must_check __deliver_ckc(struct kvm_vcpu *vcpu) 515 500 { 516 501 struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int; 517 - int rc; 502 + int rc = 0; 518 503 519 504 vcpu->stat.deliver_ckc++; 520 505 trace_kvm_s390_deliver_interrupt(vcpu->vcpu_id, KVM_S390_INT_CLOCK_COMP, 521 506 0, 0); 522 - 523 - rc = put_guest_lc(vcpu, EXT_IRQ_CLK_COMP, 524 - (u16 __user *)__LC_EXT_INT_CODE); 525 - rc |= put_guest_lc(vcpu, 0, (u16 *)__LC_EXT_CPU_ADDR); 526 - rc |= write_guest_lc(vcpu, __LC_EXT_OLD_PSW, 527 - &vcpu->arch.sie_block->gpsw, sizeof(psw_t)); 528 - rc |= read_guest_lc(vcpu, __LC_EXT_NEW_PSW, 529 - &vcpu->arch.sie_block->gpsw, sizeof(psw_t)); 507 + if (kvm_s390_pv_cpu_is_protected(vcpu)) { 508 + vcpu->arch.sie_block->iictl = IICTL_CODE_EXT; 509 + vcpu->arch.sie_block->eic = EXT_IRQ_CLK_COMP; 510 + } else { 511 + rc = put_guest_lc(vcpu, EXT_IRQ_CLK_COMP, 512 + (u16 __user *)__LC_EXT_INT_CODE); 513 + rc |= put_guest_lc(vcpu, 0, (u16 *)__LC_EXT_CPU_ADDR); 514 + rc |= write_guest_lc(vcpu, __LC_EXT_OLD_PSW, 515 + &vcpu->arch.sie_block->gpsw, sizeof(psw_t)); 516 + rc |= read_guest_lc(vcpu, __LC_EXT_NEW_PSW, 517 + &vcpu->arch.sie_block->gpsw, sizeof(psw_t)); 518 + } 530 519 clear_bit(IRQ_PEND_EXT_CLOCK_COMP, &li->pending_irqs); 531 520 return rc ? -EFAULT : 0; 532 521 } ··· 571 552 freg_t fprs[NUM_FPRS]; 572 553 union mci mci; 573 554 int rc; 555 + 556 + /* 557 + * All other possible payload for a machine check (e.g. the register 558 + * contents in the save area) will be handled by the ultravisor, as 559 + * the hypervisor does not not have the needed information for 560 + * protected guests. 561 + */ 562 + if (kvm_s390_pv_cpu_is_protected(vcpu)) { 563 + vcpu->arch.sie_block->iictl = IICTL_CODE_MCHK; 564 + vcpu->arch.sie_block->mcic = mchk->mcic; 565 + vcpu->arch.sie_block->faddr = mchk->failing_storage_address; 566 + vcpu->arch.sie_block->edc = mchk->ext_damage_code; 567 + return 0; 568 + } 574 569 575 570 mci.val = mchk->mcic; 576 571 /* take care of lazy register loading */ ··· 729 696 static int __must_check __deliver_restart(struct kvm_vcpu *vcpu) 730 697 { 731 698 struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int; 732 - int rc; 699 + int rc = 0; 733 700 734 701 VCPU_EVENT(vcpu, 3, "%s", "deliver: cpu restart"); 735 702 vcpu->stat.deliver_restart_signal++; 736 703 trace_kvm_s390_deliver_interrupt(vcpu->vcpu_id, KVM_S390_RESTART, 0, 0); 737 704 738 - rc = write_guest_lc(vcpu, 739 - offsetof(struct lowcore, restart_old_psw), 740 - &vcpu->arch.sie_block->gpsw, sizeof(psw_t)); 741 - rc |= read_guest_lc(vcpu, offsetof(struct lowcore, restart_psw), 742 - &vcpu->arch.sie_block->gpsw, sizeof(psw_t)); 705 + if (kvm_s390_pv_cpu_is_protected(vcpu)) { 706 + vcpu->arch.sie_block->iictl = IICTL_CODE_RESTART; 707 + } else { 708 + rc = write_guest_lc(vcpu, 709 + offsetof(struct lowcore, restart_old_psw), 710 + &vcpu->arch.sie_block->gpsw, sizeof(psw_t)); 711 + rc |= read_guest_lc(vcpu, offsetof(struct lowcore, restart_psw), 712 + &vcpu->arch.sie_block->gpsw, sizeof(psw_t)); 713 + } 743 714 clear_bit(IRQ_PEND_RESTART, &li->pending_irqs); 744 715 return rc ? -EFAULT : 0; 745 716 } ··· 785 748 vcpu->stat.deliver_emergency_signal++; 786 749 trace_kvm_s390_deliver_interrupt(vcpu->vcpu_id, KVM_S390_INT_EMERGENCY, 787 750 cpu_addr, 0); 751 + if (kvm_s390_pv_cpu_is_protected(vcpu)) { 752 + vcpu->arch.sie_block->iictl = IICTL_CODE_EXT; 753 + vcpu->arch.sie_block->eic = EXT_IRQ_EMERGENCY_SIG; 754 + vcpu->arch.sie_block->extcpuaddr = cpu_addr; 755 + return 0; 756 + } 788 757 789 758 rc = put_guest_lc(vcpu, EXT_IRQ_EMERGENCY_SIG, 790 759 (u16 *)__LC_EXT_INT_CODE); ··· 819 776 trace_kvm_s390_deliver_interrupt(vcpu->vcpu_id, 820 777 KVM_S390_INT_EXTERNAL_CALL, 821 778 extcall.code, 0); 779 + if (kvm_s390_pv_cpu_is_protected(vcpu)) { 780 + vcpu->arch.sie_block->iictl = IICTL_CODE_EXT; 781 + vcpu->arch.sie_block->eic = EXT_IRQ_EXTERNAL_CALL; 782 + vcpu->arch.sie_block->extcpuaddr = extcall.code; 783 + return 0; 784 + } 822 785 823 786 rc = put_guest_lc(vcpu, EXT_IRQ_EXTERNAL_CALL, 824 787 (u16 *)__LC_EXT_INT_CODE); ··· 834 785 rc |= read_guest_lc(vcpu, __LC_EXT_NEW_PSW, &vcpu->arch.sie_block->gpsw, 835 786 sizeof(psw_t)); 836 787 return rc ? -EFAULT : 0; 788 + } 789 + 790 + static int __deliver_prog_pv(struct kvm_vcpu *vcpu, u16 code) 791 + { 792 + switch (code) { 793 + case PGM_SPECIFICATION: 794 + vcpu->arch.sie_block->iictl = IICTL_CODE_SPECIFICATION; 795 + break; 796 + case PGM_OPERAND: 797 + vcpu->arch.sie_block->iictl = IICTL_CODE_OPERAND; 798 + break; 799 + default: 800 + return -EINVAL; 801 + } 802 + return 0; 837 803 } 838 804 839 805 static int __must_check __deliver_prog(struct kvm_vcpu *vcpu) ··· 870 806 vcpu->stat.deliver_program++; 871 807 trace_kvm_s390_deliver_interrupt(vcpu->vcpu_id, KVM_S390_PROGRAM_INT, 872 808 pgm_info.code, 0); 809 + 810 + /* PER is handled by the ultravisor */ 811 + if (kvm_s390_pv_cpu_is_protected(vcpu)) 812 + return __deliver_prog_pv(vcpu, pgm_info.code & ~PGM_PER); 873 813 874 814 switch (pgm_info.code & ~PGM_PER) { 875 815 case PGM_AFX_TRANSLATION: ··· 970 902 return rc ? -EFAULT : 0; 971 903 } 972 904 905 + #define SCCB_MASK 0xFFFFFFF8 906 + #define SCCB_EVENT_PENDING 0x3 907 + 908 + static int write_sclp(struct kvm_vcpu *vcpu, u32 parm) 909 + { 910 + int rc; 911 + 912 + if (kvm_s390_pv_cpu_get_handle(vcpu)) { 913 + vcpu->arch.sie_block->iictl = IICTL_CODE_EXT; 914 + vcpu->arch.sie_block->eic = EXT_IRQ_SERVICE_SIG; 915 + vcpu->arch.sie_block->eiparams = parm; 916 + return 0; 917 + } 918 + 919 + rc = put_guest_lc(vcpu, EXT_IRQ_SERVICE_SIG, (u16 *)__LC_EXT_INT_CODE); 920 + rc |= put_guest_lc(vcpu, 0, (u16 *)__LC_EXT_CPU_ADDR); 921 + rc |= write_guest_lc(vcpu, __LC_EXT_OLD_PSW, 922 + &vcpu->arch.sie_block->gpsw, sizeof(psw_t)); 923 + rc |= read_guest_lc(vcpu, __LC_EXT_NEW_PSW, 924 + &vcpu->arch.sie_block->gpsw, sizeof(psw_t)); 925 + rc |= put_guest_lc(vcpu, parm, 926 + (u32 *)__LC_EXT_PARAMS); 927 + 928 + return rc ? -EFAULT : 0; 929 + } 930 + 973 931 static int __must_check __deliver_service(struct kvm_vcpu *vcpu) 974 932 { 975 933 struct kvm_s390_float_interrupt *fi = &vcpu->kvm->arch.float_int; 976 934 struct kvm_s390_ext_info ext; 977 - int rc = 0; 978 935 979 936 spin_lock(&fi->lock); 980 - if (!(test_bit(IRQ_PEND_EXT_SERVICE, &fi->pending_irqs))) { 937 + if (test_bit(IRQ_PEND_EXT_SERVICE, &fi->masked_irqs) || 938 + !(test_bit(IRQ_PEND_EXT_SERVICE, &fi->pending_irqs))) { 981 939 spin_unlock(&fi->lock); 982 940 return 0; 983 941 } 984 942 ext = fi->srv_signal; 985 943 memset(&fi->srv_signal, 0, sizeof(ext)); 986 944 clear_bit(IRQ_PEND_EXT_SERVICE, &fi->pending_irqs); 945 + clear_bit(IRQ_PEND_EXT_SERVICE_EV, &fi->pending_irqs); 946 + if (kvm_s390_pv_cpu_is_protected(vcpu)) 947 + set_bit(IRQ_PEND_EXT_SERVICE, &fi->masked_irqs); 987 948 spin_unlock(&fi->lock); 988 949 989 950 VCPU_EVENT(vcpu, 4, "deliver: sclp parameter 0x%x", ··· 1021 924 trace_kvm_s390_deliver_interrupt(vcpu->vcpu_id, KVM_S390_INT_SERVICE, 1022 925 ext.ext_params, 0); 1023 926 1024 - rc = put_guest_lc(vcpu, EXT_IRQ_SERVICE_SIG, (u16 *)__LC_EXT_INT_CODE); 1025 - rc |= put_guest_lc(vcpu, 0, (u16 *)__LC_EXT_CPU_ADDR); 1026 - rc |= write_guest_lc(vcpu, __LC_EXT_OLD_PSW, 1027 - &vcpu->arch.sie_block->gpsw, sizeof(psw_t)); 1028 - rc |= read_guest_lc(vcpu, __LC_EXT_NEW_PSW, 1029 - &vcpu->arch.sie_block->gpsw, sizeof(psw_t)); 1030 - rc |= put_guest_lc(vcpu, ext.ext_params, 1031 - (u32 *)__LC_EXT_PARAMS); 927 + return write_sclp(vcpu, ext.ext_params); 928 + } 1032 929 1033 - return rc ? -EFAULT : 0; 930 + static int __must_check __deliver_service_ev(struct kvm_vcpu *vcpu) 931 + { 932 + struct kvm_s390_float_interrupt *fi = &vcpu->kvm->arch.float_int; 933 + struct kvm_s390_ext_info ext; 934 + 935 + spin_lock(&fi->lock); 936 + if (!(test_bit(IRQ_PEND_EXT_SERVICE_EV, &fi->pending_irqs))) { 937 + spin_unlock(&fi->lock); 938 + return 0; 939 + } 940 + ext = fi->srv_signal; 941 + /* only clear the event bit */ 942 + fi->srv_signal.ext_params &= ~SCCB_EVENT_PENDING; 943 + clear_bit(IRQ_PEND_EXT_SERVICE_EV, &fi->pending_irqs); 944 + spin_unlock(&fi->lock); 945 + 946 + VCPU_EVENT(vcpu, 4, "%s", "deliver: sclp parameter event"); 947 + vcpu->stat.deliver_service_signal++; 948 + trace_kvm_s390_deliver_interrupt(vcpu->vcpu_id, KVM_S390_INT_SERVICE, 949 + ext.ext_params, 0); 950 + 951 + return write_sclp(vcpu, SCCB_EVENT_PENDING); 1034 952 } 1035 953 1036 954 static int __must_check __deliver_pfault_done(struct kvm_vcpu *vcpu) ··· 1139 1027 static int __do_deliver_io(struct kvm_vcpu *vcpu, struct kvm_s390_io_info *io) 1140 1028 { 1141 1029 int rc; 1030 + 1031 + if (kvm_s390_pv_cpu_is_protected(vcpu)) { 1032 + vcpu->arch.sie_block->iictl = IICTL_CODE_IO; 1033 + vcpu->arch.sie_block->subchannel_id = io->subchannel_id; 1034 + vcpu->arch.sie_block->subchannel_nr = io->subchannel_nr; 1035 + vcpu->arch.sie_block->io_int_parm = io->io_int_parm; 1036 + vcpu->arch.sie_block->io_int_word = io->io_int_word; 1037 + return 0; 1038 + } 1142 1039 1143 1040 rc = put_guest_lc(vcpu, io->subchannel_id, (u16 *)__LC_SUBCHANNEL_ID); 1144 1041 rc |= put_guest_lc(vcpu, io->subchannel_nr, (u16 *)__LC_SUBCHANNEL_NR); ··· 1450 1329 case IRQ_PEND_EXT_SERVICE: 1451 1330 rc = __deliver_service(vcpu); 1452 1331 break; 1332 + case IRQ_PEND_EXT_SERVICE_EV: 1333 + rc = __deliver_service_ev(vcpu); 1334 + break; 1453 1335 case IRQ_PEND_PFAULT_DONE: 1454 1336 rc = __deliver_pfault_done(vcpu); 1455 1337 break; ··· 1545 1421 if (kvm_get_vcpu_by_id(vcpu->kvm, src_id) == NULL) 1546 1422 return -EINVAL; 1547 1423 1548 - if (sclp.has_sigpif) 1424 + if (sclp.has_sigpif && !kvm_s390_pv_cpu_get_handle(vcpu)) 1549 1425 return sca_inject_ext_call(vcpu, src_id); 1550 1426 1551 1427 if (test_and_set_bit(IRQ_PEND_EXT_EXTERNAL, &li->pending_irqs)) ··· 1805 1681 return inti; 1806 1682 } 1807 1683 1808 - #define SCCB_MASK 0xFFFFFFF8 1809 - #define SCCB_EVENT_PENDING 0x3 1810 - 1811 1684 static int __inject_service(struct kvm *kvm, 1812 1685 struct kvm_s390_interrupt_info *inti) 1813 1686 { ··· 1813 1692 kvm->stat.inject_service_signal++; 1814 1693 spin_lock(&fi->lock); 1815 1694 fi->srv_signal.ext_params |= inti->ext.ext_params & SCCB_EVENT_PENDING; 1695 + 1696 + /* We always allow events, track them separately from the sccb ints */ 1697 + if (fi->srv_signal.ext_params & SCCB_EVENT_PENDING) 1698 + set_bit(IRQ_PEND_EXT_SERVICE_EV, &fi->pending_irqs); 1699 + 1816 1700 /* 1817 1701 * Early versions of the QEMU s390 bios will inject several 1818 1702 * service interrupts after another without handling a ··· 1899 1773 kvm->stat.inject_io++; 1900 1774 isc = int_word_to_isc(inti->io.io_int_word); 1901 1775 1902 - if (gi->origin && inti->type & KVM_S390_INT_IO_AI_MASK) { 1776 + /* 1777 + * Do not make use of gisa in protected mode. We do not use the lock 1778 + * checking variant as this is just a performance optimization and we 1779 + * do not hold the lock here. This is ok as the code will pick 1780 + * interrupts from both "lists" for delivery. 1781 + */ 1782 + if (!kvm_s390_pv_get_handle(kvm) && 1783 + gi->origin && inti->type & KVM_S390_INT_IO_AI_MASK) { 1903 1784 VM_EVENT(kvm, 4, "%s isc %1u", "inject: I/O (AI/gisa)", isc); 1904 1785 gisa_set_ipm_gisc(gi->origin, isc); 1905 1786 kfree(inti); ··· 1967 1834 break; 1968 1835 case KVM_S390_INT_IO_MIN...KVM_S390_INT_IO_MAX: 1969 1836 if (!(type & KVM_S390_INT_IO_AI_MASK && 1970 - kvm->arch.gisa_int.origin)) 1837 + kvm->arch.gisa_int.origin) || 1838 + kvm_s390_pv_cpu_get_handle(dst_vcpu)) 1971 1839 kvm_s390_set_cpuflags(dst_vcpu, CPUSTAT_IO_INT); 1972 1840 break; 1973 1841 default: ··· 2214 2080 struct kvm_s390_float_interrupt *fi = &kvm->arch.float_int; 2215 2081 int i; 2216 2082 2083 + mutex_lock(&kvm->lock); 2084 + if (!kvm_s390_pv_is_protected(kvm)) 2085 + fi->masked_irqs = 0; 2086 + mutex_unlock(&kvm->lock); 2217 2087 spin_lock(&fi->lock); 2218 2088 fi->pending_irqs = 0; 2219 2089 memset(&fi->srv_signal, 0, sizeof(fi->srv_signal)); ··· 2284 2146 n++; 2285 2147 } 2286 2148 } 2287 - if (test_bit(IRQ_PEND_EXT_SERVICE, &fi->pending_irqs)) { 2149 + if (test_bit(IRQ_PEND_EXT_SERVICE, &fi->pending_irqs) || 2150 + test_bit(IRQ_PEND_EXT_SERVICE_EV, &fi->pending_irqs)) { 2288 2151 if (n == max_irqs) { 2289 2152 /* signal userspace to try again */ 2290 2153 ret = -ENOMEM; ··· 2466 2327 if (!adapter) 2467 2328 return -ENOMEM; 2468 2329 2469 - INIT_LIST_HEAD(&adapter->maps); 2470 - init_rwsem(&adapter->maps_lock); 2471 - atomic_set(&adapter->nr_maps, 0); 2472 2330 adapter->id = adapter_info.id; 2473 2331 adapter->isc = adapter_info.isc; 2474 2332 adapter->maskable = adapter_info.maskable; ··· 2490 2354 return ret; 2491 2355 } 2492 2356 2493 - static int kvm_s390_adapter_map(struct kvm *kvm, unsigned int id, __u64 addr) 2494 - { 2495 - struct s390_io_adapter *adapter = get_io_adapter(kvm, id); 2496 - struct s390_map_info *map; 2497 - int ret; 2498 - 2499 - if (!adapter || !addr) 2500 - return -EINVAL; 2501 - 2502 - map = kzalloc(sizeof(*map), GFP_KERNEL); 2503 - if (!map) { 2504 - ret = -ENOMEM; 2505 - goto out; 2506 - } 2507 - INIT_LIST_HEAD(&map->list); 2508 - map->guest_addr = addr; 2509 - map->addr = gmap_translate(kvm->arch.gmap, addr); 2510 - if (map->addr == -EFAULT) { 2511 - ret = -EFAULT; 2512 - goto out; 2513 - } 2514 - ret = get_user_pages_fast(map->addr, 1, FOLL_WRITE, &map->page); 2515 - if (ret < 0) 2516 - goto out; 2517 - BUG_ON(ret != 1); 2518 - down_write(&adapter->maps_lock); 2519 - if (atomic_inc_return(&adapter->nr_maps) < MAX_S390_ADAPTER_MAPS) { 2520 - list_add_tail(&map->list, &adapter->maps); 2521 - ret = 0; 2522 - } else { 2523 - put_page(map->page); 2524 - ret = -EINVAL; 2525 - } 2526 - up_write(&adapter->maps_lock); 2527 - out: 2528 - if (ret) 2529 - kfree(map); 2530 - return ret; 2531 - } 2532 - 2533 - static int kvm_s390_adapter_unmap(struct kvm *kvm, unsigned int id, __u64 addr) 2534 - { 2535 - struct s390_io_adapter *adapter = get_io_adapter(kvm, id); 2536 - struct s390_map_info *map, *tmp; 2537 - int found = 0; 2538 - 2539 - if (!adapter || !addr) 2540 - return -EINVAL; 2541 - 2542 - down_write(&adapter->maps_lock); 2543 - list_for_each_entry_safe(map, tmp, &adapter->maps, list) { 2544 - if (map->guest_addr == addr) { 2545 - found = 1; 2546 - atomic_dec(&adapter->nr_maps); 2547 - list_del(&map->list); 2548 - put_page(map->page); 2549 - kfree(map); 2550 - break; 2551 - } 2552 - } 2553 - up_write(&adapter->maps_lock); 2554 - 2555 - return found ? 0 : -EINVAL; 2556 - } 2557 - 2558 2357 void kvm_s390_destroy_adapters(struct kvm *kvm) 2559 2358 { 2560 2359 int i; 2561 - struct s390_map_info *map, *tmp; 2562 2360 2563 - for (i = 0; i < MAX_S390_IO_ADAPTERS; i++) { 2564 - if (!kvm->arch.adapters[i]) 2565 - continue; 2566 - list_for_each_entry_safe(map, tmp, 2567 - &kvm->arch.adapters[i]->maps, list) { 2568 - list_del(&map->list); 2569 - put_page(map->page); 2570 - kfree(map); 2571 - } 2361 + for (i = 0; i < MAX_S390_IO_ADAPTERS; i++) 2572 2362 kfree(kvm->arch.adapters[i]); 2573 - } 2574 2363 } 2575 2364 2576 2365 static int modify_io_adapter(struct kvm_device *dev, ··· 2517 2456 if (ret > 0) 2518 2457 ret = 0; 2519 2458 break; 2459 + /* 2460 + * The following operations are no longer needed and therefore no-ops. 2461 + * The gpa to hva translation is done when an IRQ route is set up. The 2462 + * set_irq code uses get_user_pages_remote() to do the actual write. 2463 + */ 2520 2464 case KVM_S390_IO_ADAPTER_MAP: 2521 - ret = kvm_s390_adapter_map(dev->kvm, req.id, req.addr); 2522 - break; 2523 2465 case KVM_S390_IO_ADAPTER_UNMAP: 2524 - ret = kvm_s390_adapter_unmap(dev->kvm, req.id, req.addr); 2466 + ret = 0; 2525 2467 break; 2526 2468 default: 2527 2469 ret = -EINVAL; ··· 2763 2699 return swap ? (bit ^ (BITS_PER_LONG - 1)) : bit; 2764 2700 } 2765 2701 2766 - static struct s390_map_info *get_map_info(struct s390_io_adapter *adapter, 2767 - u64 addr) 2702 + static struct page *get_map_page(struct kvm *kvm, u64 uaddr) 2768 2703 { 2769 - struct s390_map_info *map; 2704 + struct page *page = NULL; 2770 2705 2771 - if (!adapter) 2772 - return NULL; 2773 - 2774 - list_for_each_entry(map, &adapter->maps, list) { 2775 - if (map->guest_addr == addr) 2776 - return map; 2777 - } 2778 - return NULL; 2706 + down_read(&kvm->mm->mmap_sem); 2707 + get_user_pages_remote(NULL, kvm->mm, uaddr, 1, FOLL_WRITE, 2708 + &page, NULL, NULL); 2709 + up_read(&kvm->mm->mmap_sem); 2710 + return page; 2779 2711 } 2780 2712 2781 2713 static int adapter_indicators_set(struct kvm *kvm, ··· 2780 2720 { 2781 2721 unsigned long bit; 2782 2722 int summary_set, idx; 2783 - struct s390_map_info *info; 2723 + struct page *ind_page, *summary_page; 2784 2724 void *map; 2785 2725 2786 - info = get_map_info(adapter, adapter_int->ind_addr); 2787 - if (!info) 2726 + ind_page = get_map_page(kvm, adapter_int->ind_addr); 2727 + if (!ind_page) 2788 2728 return -1; 2789 - map = page_address(info->page); 2790 - bit = get_ind_bit(info->addr, adapter_int->ind_offset, adapter->swap); 2791 - set_bit(bit, map); 2792 - idx = srcu_read_lock(&kvm->srcu); 2793 - mark_page_dirty(kvm, info->guest_addr >> PAGE_SHIFT); 2794 - set_page_dirty_lock(info->page); 2795 - info = get_map_info(adapter, adapter_int->summary_addr); 2796 - if (!info) { 2797 - srcu_read_unlock(&kvm->srcu, idx); 2729 + summary_page = get_map_page(kvm, adapter_int->summary_addr); 2730 + if (!summary_page) { 2731 + put_page(ind_page); 2798 2732 return -1; 2799 2733 } 2800 - map = page_address(info->page); 2801 - bit = get_ind_bit(info->addr, adapter_int->summary_offset, 2802 - adapter->swap); 2734 + 2735 + idx = srcu_read_lock(&kvm->srcu); 2736 + map = page_address(ind_page); 2737 + bit = get_ind_bit(adapter_int->ind_addr, 2738 + adapter_int->ind_offset, adapter->swap); 2739 + set_bit(bit, map); 2740 + mark_page_dirty(kvm, adapter_int->ind_addr >> PAGE_SHIFT); 2741 + set_page_dirty_lock(ind_page); 2742 + map = page_address(summary_page); 2743 + bit = get_ind_bit(adapter_int->summary_addr, 2744 + adapter_int->summary_offset, adapter->swap); 2803 2745 summary_set = test_and_set_bit(bit, map); 2804 - mark_page_dirty(kvm, info->guest_addr >> PAGE_SHIFT); 2805 - set_page_dirty_lock(info->page); 2746 + mark_page_dirty(kvm, adapter_int->summary_addr >> PAGE_SHIFT); 2747 + set_page_dirty_lock(summary_page); 2806 2748 srcu_read_unlock(&kvm->srcu, idx); 2749 + 2750 + put_page(ind_page); 2751 + put_page(summary_page); 2807 2752 return summary_set ? 0 : 1; 2808 2753 } 2809 2754 ··· 2830 2765 adapter = get_io_adapter(kvm, e->adapter.adapter_id); 2831 2766 if (!adapter) 2832 2767 return -1; 2833 - down_read(&adapter->maps_lock); 2834 2768 ret = adapter_indicators_set(kvm, adapter, &e->adapter); 2835 - up_read(&adapter->maps_lock); 2836 2769 if ((ret > 0) && !adapter->masked) { 2837 2770 ret = kvm_s390_inject_airq(kvm, adapter); 2838 2771 if (ret == 0) ··· 2881 2818 struct kvm_kernel_irq_routing_entry *e, 2882 2819 const struct kvm_irq_routing_entry *ue) 2883 2820 { 2884 - int ret; 2821 + u64 uaddr; 2885 2822 2886 2823 switch (ue->type) { 2824 + /* we store the userspace addresses instead of the guest addresses */ 2887 2825 case KVM_IRQ_ROUTING_S390_ADAPTER: 2888 2826 e->set = set_adapter_int; 2889 - e->adapter.summary_addr = ue->u.adapter.summary_addr; 2890 - e->adapter.ind_addr = ue->u.adapter.ind_addr; 2827 + uaddr = gmap_translate(kvm->arch.gmap, ue->u.adapter.summary_addr); 2828 + if (uaddr == -EFAULT) 2829 + return -EFAULT; 2830 + e->adapter.summary_addr = uaddr; 2831 + uaddr = gmap_translate(kvm->arch.gmap, ue->u.adapter.ind_addr); 2832 + if (uaddr == -EFAULT) 2833 + return -EFAULT; 2834 + e->adapter.ind_addr = uaddr; 2891 2835 e->adapter.summary_offset = ue->u.adapter.summary_offset; 2892 2836 e->adapter.ind_offset = ue->u.adapter.ind_offset; 2893 2837 e->adapter.adapter_id = ue->u.adapter.adapter_id; 2894 - ret = 0; 2895 - break; 2838 + return 0; 2896 2839 default: 2897 - ret = -EINVAL; 2840 + return -EINVAL; 2898 2841 } 2899 - 2900 - return ret; 2901 2842 } 2902 2843 2903 2844 int kvm_set_msi(struct kvm_kernel_irq_routing_entry *e, struct kvm *kvm,
+499 -68
arch/s390/kvm/kvm-s390.c
··· 2 2 /* 3 3 * hosting IBM Z kernel virtual machines (s390x) 4 4 * 5 - * Copyright IBM Corp. 2008, 2018 5 + * Copyright IBM Corp. 2008, 2020 6 6 * 7 7 * Author(s): Carsten Otte <cotte@de.ibm.com> 8 8 * Christian Borntraeger <borntraeger@de.ibm.com> ··· 44 44 #include <asm/cpacf.h> 45 45 #include <asm/timex.h> 46 46 #include <asm/ap.h> 47 + #include <asm/uv.h> 47 48 #include "kvm-s390.h" 48 49 #include "gaccess.h" 49 50 ··· 185 184 module_param(halt_poll_max_steal, byte, 0644); 186 185 MODULE_PARM_DESC(halt_poll_max_steal, "Maximum percentage of steal time to allow polling"); 187 186 187 + /* if set to true, the GISA will be initialized and used if available */ 188 + static bool use_gisa = true; 189 + module_param(use_gisa, bool, 0644); 190 + MODULE_PARM_DESC(use_gisa, "Use the GISA if the host supports it."); 191 + 188 192 /* 189 193 * For now we handle at most 16 double words as this is what the s390 base 190 194 * kernel handles and stores in the prefix page. If we ever need to go beyond ··· 226 220 static struct gmap_notifier gmap_notifier; 227 221 static struct gmap_notifier vsie_gmap_notifier; 228 222 debug_info_t *kvm_s390_dbf; 223 + debug_info_t *kvm_s390_dbf_uv; 229 224 230 225 /* Section: not file related */ 231 226 int kvm_arch_hardware_enable(void) ··· 240 233 return 0; 241 234 } 242 235 236 + /* forward declarations */ 243 237 static void kvm_gmap_notifier(struct gmap *gmap, unsigned long start, 244 238 unsigned long end); 239 + static int sca_switch_to_extended(struct kvm *kvm); 245 240 246 241 static void kvm_clock_sync_scb(struct kvm_s390_sie_block *scb, u64 delta) 247 242 { ··· 469 460 if (!kvm_s390_dbf) 470 461 return -ENOMEM; 471 462 472 - if (debug_register_view(kvm_s390_dbf, &debug_sprintf_view)) 463 + kvm_s390_dbf_uv = debug_register("kvm-uv", 32, 1, 7 * sizeof(long)); 464 + if (!kvm_s390_dbf_uv) 465 + goto out; 466 + 467 + if (debug_register_view(kvm_s390_dbf, &debug_sprintf_view) || 468 + debug_register_view(kvm_s390_dbf_uv, &debug_sprintf_view)) 473 469 goto out; 474 470 475 471 kvm_s390_cpu_feat_init(); ··· 501 487 { 502 488 kvm_s390_gib_destroy(); 503 489 debug_unregister(kvm_s390_dbf); 490 + debug_unregister(kvm_s390_dbf_uv); 504 491 } 505 492 506 493 /* Section: device related */ ··· 578 563 break; 579 564 case KVM_CAP_S390_BPB: 580 565 r = test_facility(82); 566 + break; 567 + case KVM_CAP_S390_PROTECTED: 568 + r = is_prot_virt_host(); 581 569 break; 582 570 default: 583 571 r = 0; ··· 2167 2149 return r; 2168 2150 } 2169 2151 2152 + static int kvm_s390_cpus_from_pv(struct kvm *kvm, u16 *rcp, u16 *rrcp) 2153 + { 2154 + struct kvm_vcpu *vcpu; 2155 + u16 rc, rrc; 2156 + int ret = 0; 2157 + int i; 2158 + 2159 + /* 2160 + * We ignore failures and try to destroy as many CPUs as possible. 2161 + * At the same time we must not free the assigned resources when 2162 + * this fails, as the ultravisor has still access to that memory. 2163 + * So kvm_s390_pv_destroy_cpu can leave a "wanted" memory leak 2164 + * behind. 2165 + * We want to return the first failure rc and rrc, though. 2166 + */ 2167 + kvm_for_each_vcpu(i, vcpu, kvm) { 2168 + mutex_lock(&vcpu->mutex); 2169 + if (kvm_s390_pv_destroy_cpu(vcpu, &rc, &rrc) && !ret) { 2170 + *rcp = rc; 2171 + *rrcp = rrc; 2172 + ret = -EIO; 2173 + } 2174 + mutex_unlock(&vcpu->mutex); 2175 + } 2176 + return ret; 2177 + } 2178 + 2179 + static int kvm_s390_cpus_to_pv(struct kvm *kvm, u16 *rc, u16 *rrc) 2180 + { 2181 + int i, r = 0; 2182 + u16 dummy; 2183 + 2184 + struct kvm_vcpu *vcpu; 2185 + 2186 + kvm_for_each_vcpu(i, vcpu, kvm) { 2187 + mutex_lock(&vcpu->mutex); 2188 + r = kvm_s390_pv_create_cpu(vcpu, rc, rrc); 2189 + mutex_unlock(&vcpu->mutex); 2190 + if (r) 2191 + break; 2192 + } 2193 + if (r) 2194 + kvm_s390_cpus_from_pv(kvm, &dummy, &dummy); 2195 + return r; 2196 + } 2197 + 2198 + static int kvm_s390_handle_pv(struct kvm *kvm, struct kvm_pv_cmd *cmd) 2199 + { 2200 + int r = 0; 2201 + u16 dummy; 2202 + void __user *argp = (void __user *)cmd->data; 2203 + 2204 + switch (cmd->cmd) { 2205 + case KVM_PV_ENABLE: { 2206 + r = -EINVAL; 2207 + if (kvm_s390_pv_is_protected(kvm)) 2208 + break; 2209 + 2210 + /* 2211 + * FMT 4 SIE needs esca. As we never switch back to bsca from 2212 + * esca, we need no cleanup in the error cases below 2213 + */ 2214 + r = sca_switch_to_extended(kvm); 2215 + if (r) 2216 + break; 2217 + 2218 + down_write(&current->mm->mmap_sem); 2219 + r = gmap_mark_unmergeable(); 2220 + up_write(&current->mm->mmap_sem); 2221 + if (r) 2222 + break; 2223 + 2224 + r = kvm_s390_pv_init_vm(kvm, &cmd->rc, &cmd->rrc); 2225 + if (r) 2226 + break; 2227 + 2228 + r = kvm_s390_cpus_to_pv(kvm, &cmd->rc, &cmd->rrc); 2229 + if (r) 2230 + kvm_s390_pv_deinit_vm(kvm, &dummy, &dummy); 2231 + 2232 + /* we need to block service interrupts from now on */ 2233 + set_bit(IRQ_PEND_EXT_SERVICE, &kvm->arch.float_int.masked_irqs); 2234 + break; 2235 + } 2236 + case KVM_PV_DISABLE: { 2237 + r = -EINVAL; 2238 + if (!kvm_s390_pv_is_protected(kvm)) 2239 + break; 2240 + 2241 + r = kvm_s390_cpus_from_pv(kvm, &cmd->rc, &cmd->rrc); 2242 + /* 2243 + * If a CPU could not be destroyed, destroy VM will also fail. 2244 + * There is no point in trying to destroy it. Instead return 2245 + * the rc and rrc from the first CPU that failed destroying. 2246 + */ 2247 + if (r) 2248 + break; 2249 + r = kvm_s390_pv_deinit_vm(kvm, &cmd->rc, &cmd->rrc); 2250 + 2251 + /* no need to block service interrupts any more */ 2252 + clear_bit(IRQ_PEND_EXT_SERVICE, &kvm->arch.float_int.masked_irqs); 2253 + break; 2254 + } 2255 + case KVM_PV_SET_SEC_PARMS: { 2256 + struct kvm_s390_pv_sec_parm parms = {}; 2257 + void *hdr; 2258 + 2259 + r = -EINVAL; 2260 + if (!kvm_s390_pv_is_protected(kvm)) 2261 + break; 2262 + 2263 + r = -EFAULT; 2264 + if (copy_from_user(&parms, argp, sizeof(parms))) 2265 + break; 2266 + 2267 + /* Currently restricted to 8KB */ 2268 + r = -EINVAL; 2269 + if (parms.length > PAGE_SIZE * 2) 2270 + break; 2271 + 2272 + r = -ENOMEM; 2273 + hdr = vmalloc(parms.length); 2274 + if (!hdr) 2275 + break; 2276 + 2277 + r = -EFAULT; 2278 + if (!copy_from_user(hdr, (void __user *)parms.origin, 2279 + parms.length)) 2280 + r = kvm_s390_pv_set_sec_parms(kvm, hdr, parms.length, 2281 + &cmd->rc, &cmd->rrc); 2282 + 2283 + vfree(hdr); 2284 + break; 2285 + } 2286 + case KVM_PV_UNPACK: { 2287 + struct kvm_s390_pv_unp unp = {}; 2288 + 2289 + r = -EINVAL; 2290 + if (!kvm_s390_pv_is_protected(kvm)) 2291 + break; 2292 + 2293 + r = -EFAULT; 2294 + if (copy_from_user(&unp, argp, sizeof(unp))) 2295 + break; 2296 + 2297 + r = kvm_s390_pv_unpack(kvm, unp.addr, unp.size, unp.tweak, 2298 + &cmd->rc, &cmd->rrc); 2299 + break; 2300 + } 2301 + case KVM_PV_VERIFY: { 2302 + r = -EINVAL; 2303 + if (!kvm_s390_pv_is_protected(kvm)) 2304 + break; 2305 + 2306 + r = uv_cmd_nodata(kvm_s390_pv_get_handle(kvm), 2307 + UVC_CMD_VERIFY_IMG, &cmd->rc, &cmd->rrc); 2308 + KVM_UV_EVENT(kvm, 3, "PROTVIRT VERIFY: rc %x rrc %x", cmd->rc, 2309 + cmd->rrc); 2310 + break; 2311 + } 2312 + case KVM_PV_PREP_RESET: { 2313 + r = -EINVAL; 2314 + if (!kvm_s390_pv_is_protected(kvm)) 2315 + break; 2316 + 2317 + r = uv_cmd_nodata(kvm_s390_pv_get_handle(kvm), 2318 + UVC_CMD_PREPARE_RESET, &cmd->rc, &cmd->rrc); 2319 + KVM_UV_EVENT(kvm, 3, "PROTVIRT PREP RESET: rc %x rrc %x", 2320 + cmd->rc, cmd->rrc); 2321 + break; 2322 + } 2323 + case KVM_PV_UNSHARE_ALL: { 2324 + r = -EINVAL; 2325 + if (!kvm_s390_pv_is_protected(kvm)) 2326 + break; 2327 + 2328 + r = uv_cmd_nodata(kvm_s390_pv_get_handle(kvm), 2329 + UVC_CMD_SET_UNSHARE_ALL, &cmd->rc, &cmd->rrc); 2330 + KVM_UV_EVENT(kvm, 3, "PROTVIRT UNSHARE: rc %x rrc %x", 2331 + cmd->rc, cmd->rrc); 2332 + break; 2333 + } 2334 + default: 2335 + r = -ENOTTY; 2336 + } 2337 + return r; 2338 + } 2339 + 2170 2340 long kvm_arch_vm_ioctl(struct file *filp, 2171 2341 unsigned int ioctl, unsigned long arg) 2172 2342 { ··· 2450 2244 mutex_lock(&kvm->slots_lock); 2451 2245 r = kvm_s390_set_cmma_bits(kvm, &args); 2452 2246 mutex_unlock(&kvm->slots_lock); 2247 + break; 2248 + } 2249 + case KVM_S390_PV_COMMAND: { 2250 + struct kvm_pv_cmd args; 2251 + 2252 + /* protvirt means user sigp */ 2253 + kvm->arch.user_cpu_state_ctrl = 1; 2254 + r = 0; 2255 + if (!is_prot_virt_host()) { 2256 + r = -EINVAL; 2257 + break; 2258 + } 2259 + if (copy_from_user(&args, argp, sizeof(args))) { 2260 + r = -EFAULT; 2261 + break; 2262 + } 2263 + if (args.flags) { 2264 + r = -EINVAL; 2265 + break; 2266 + } 2267 + mutex_lock(&kvm->lock); 2268 + r = kvm_s390_handle_pv(kvm, &args); 2269 + mutex_unlock(&kvm->lock); 2270 + if (copy_to_user(argp, &args, sizeof(args))) { 2271 + r = -EFAULT; 2272 + break; 2273 + } 2453 2274 break; 2454 2275 } 2455 2276 default: ··· 2728 2495 kvm->arch.use_skf = sclp.has_skey; 2729 2496 spin_lock_init(&kvm->arch.start_stop_lock); 2730 2497 kvm_s390_vsie_init(kvm); 2731 - kvm_s390_gisa_init(kvm); 2498 + if (use_gisa) 2499 + kvm_s390_gisa_init(kvm); 2732 2500 KVM_EVENT(3, "vm 0x%pK created by pid %u", kvm, current->pid); 2733 2501 2734 2502 return 0; ··· 2743 2509 2744 2510 void kvm_arch_vcpu_destroy(struct kvm_vcpu *vcpu) 2745 2511 { 2512 + u16 rc, rrc; 2513 + 2746 2514 VCPU_EVENT(vcpu, 3, "%s", "free cpu"); 2747 2515 trace_kvm_s390_destroy_vcpu(vcpu->vcpu_id); 2748 2516 kvm_s390_clear_local_irqs(vcpu); ··· 2757 2521 2758 2522 if (vcpu->kvm->arch.use_cmma) 2759 2523 kvm_s390_vcpu_unsetup_cmma(vcpu); 2524 + /* We can not hold the vcpu mutex here, we are already dying */ 2525 + if (kvm_s390_pv_cpu_get_handle(vcpu)) 2526 + kvm_s390_pv_destroy_cpu(vcpu, &rc, &rrc); 2760 2527 free_page((unsigned long)(vcpu->arch.sie_block)); 2761 2528 } 2762 2529 ··· 2781 2542 2782 2543 void kvm_arch_destroy_vm(struct kvm *kvm) 2783 2544 { 2545 + u16 rc, rrc; 2546 + 2784 2547 kvm_free_vcpus(kvm); 2785 2548 sca_dispose(kvm); 2786 - debug_unregister(kvm->arch.dbf); 2787 2549 kvm_s390_gisa_destroy(kvm); 2550 + /* 2551 + * We are already at the end of life and kvm->lock is not taken. 2552 + * This is ok as the file descriptor is closed by now and nobody 2553 + * can mess with the pv state. To avoid lockdep_assert_held from 2554 + * complaining we do not use kvm_s390_pv_is_protected. 2555 + */ 2556 + if (kvm_s390_pv_get_handle(kvm)) 2557 + kvm_s390_pv_deinit_vm(kvm, &rc, &rrc); 2558 + debug_unregister(kvm->arch.dbf); 2788 2559 free_page((unsigned long)kvm->arch.sie_page2); 2789 2560 if (!kvm_is_ucontrol(kvm)) 2790 2561 gmap_remove(kvm->arch.gmap); ··· 2889 2640 struct kvm_vcpu *vcpu; 2890 2641 unsigned int vcpu_idx; 2891 2642 u32 scaol, scaoh; 2643 + 2644 + if (kvm->arch.use_esca) 2645 + return 0; 2892 2646 2893 2647 new_sca = alloc_pages_exact(sizeof(*new_sca), GFP_KERNEL|__GFP_ZERO); 2894 2648 if (!new_sca) ··· 3144 2892 static int kvm_s390_vcpu_setup(struct kvm_vcpu *vcpu) 3145 2893 { 3146 2894 int rc = 0; 2895 + u16 uvrc, uvrrc; 3147 2896 3148 2897 atomic_set(&vcpu->arch.sie_block->cpuflags, CPUSTAT_ZARCH | 3149 2898 CPUSTAT_SM | ··· 3211 2958 vcpu->arch.sie_block->hpid = HPID_KVM; 3212 2959 3213 2960 kvm_s390_vcpu_crypto_setup(vcpu); 2961 + 2962 + mutex_lock(&vcpu->kvm->lock); 2963 + if (kvm_s390_pv_is_protected(vcpu->kvm)) { 2964 + rc = kvm_s390_pv_create_cpu(vcpu, &uvrc, &uvrrc); 2965 + if (rc) 2966 + kvm_s390_vcpu_unsetup_cmma(vcpu); 2967 + } 2968 + mutex_unlock(&vcpu->kvm->lock); 3214 2969 3215 2970 return rc; 3216 2971 } ··· 3526 3265 kvm_s390_set_prefix(vcpu, 0); 3527 3266 kvm_s390_set_cpu_timer(vcpu, 0); 3528 3267 vcpu->arch.sie_block->ckc = 0; 3529 - vcpu->arch.sie_block->todpr = 0; 3530 3268 memset(vcpu->arch.sie_block->gcr, 0, sizeof(vcpu->arch.sie_block->gcr)); 3531 3269 vcpu->arch.sie_block->gcr[0] = CR0_INITIAL_MASK; 3532 3270 vcpu->arch.sie_block->gcr[14] = CR14_INITIAL_MASK; 3533 3271 vcpu->run->s.regs.fpc = 0; 3534 - vcpu->arch.sie_block->gbea = 1; 3535 - vcpu->arch.sie_block->pp = 0; 3536 - vcpu->arch.sie_block->fpf &= ~FPF_BPBC; 3272 + /* 3273 + * Do not reset these registers in the protected case, as some of 3274 + * them are overlayed and they are not accessible in this case 3275 + * anyway. 3276 + */ 3277 + if (!kvm_s390_pv_cpu_is_protected(vcpu)) { 3278 + vcpu->arch.sie_block->gbea = 1; 3279 + vcpu->arch.sie_block->pp = 0; 3280 + vcpu->arch.sie_block->fpf &= ~FPF_BPBC; 3281 + vcpu->arch.sie_block->todpr = 0; 3282 + } 3537 3283 } 3538 3284 3539 3285 static void kvm_arch_vcpu_ioctl_clear_reset(struct kvm_vcpu *vcpu) ··· 3730 3462 3731 3463 switch (mp_state->mp_state) { 3732 3464 case KVM_MP_STATE_STOPPED: 3733 - kvm_s390_vcpu_stop(vcpu); 3465 + rc = kvm_s390_vcpu_stop(vcpu); 3734 3466 break; 3735 3467 case KVM_MP_STATE_OPERATING: 3736 - kvm_s390_vcpu_start(vcpu); 3468 + rc = kvm_s390_vcpu_start(vcpu); 3737 3469 break; 3738 3470 case KVM_MP_STATE_LOAD: 3471 + if (!kvm_s390_pv_cpu_is_protected(vcpu)) { 3472 + rc = -ENXIO; 3473 + break; 3474 + } 3475 + rc = kvm_s390_pv_set_cpu_state(vcpu, PV_CPU_STATE_OPR_LOAD); 3476 + break; 3739 3477 case KVM_MP_STATE_CHECK_STOP: 3740 3478 /* fall through - CHECK_STOP and LOAD are not supported yet */ 3741 3479 default: ··· 4093 3819 return vcpu_post_run_fault_in_sie(vcpu); 4094 3820 } 4095 3821 3822 + #define PSW_INT_MASK (PSW_MASK_EXT | PSW_MASK_IO | PSW_MASK_MCHECK) 4096 3823 static int __vcpu_run(struct kvm_vcpu *vcpu) 4097 3824 { 4098 3825 int rc, exit_reason; 3826 + struct sie_page *sie_page = (struct sie_page *)vcpu->arch.sie_block; 4099 3827 4100 3828 /* 4101 3829 * We try to hold kvm->srcu during most of vcpu_run (except when run- ··· 4119 3843 guest_enter_irqoff(); 4120 3844 __disable_cpu_timer_accounting(vcpu); 4121 3845 local_irq_enable(); 3846 + if (kvm_s390_pv_cpu_is_protected(vcpu)) { 3847 + memcpy(sie_page->pv_grregs, 3848 + vcpu->run->s.regs.gprs, 3849 + sizeof(sie_page->pv_grregs)); 3850 + } 4122 3851 exit_reason = sie64a(vcpu->arch.sie_block, 4123 3852 vcpu->run->s.regs.gprs); 3853 + if (kvm_s390_pv_cpu_is_protected(vcpu)) { 3854 + memcpy(vcpu->run->s.regs.gprs, 3855 + sie_page->pv_grregs, 3856 + sizeof(sie_page->pv_grregs)); 3857 + /* 3858 + * We're not allowed to inject interrupts on intercepts 3859 + * that leave the guest state in an "in-between" state 3860 + * where the next SIE entry will do a continuation. 3861 + * Fence interrupts in our "internal" PSW. 3862 + */ 3863 + if (vcpu->arch.sie_block->icptcode == ICPT_PV_INSTR || 3864 + vcpu->arch.sie_block->icptcode == ICPT_PV_PREF) { 3865 + vcpu->arch.sie_block->gpsw.mask &= ~PSW_INT_MASK; 3866 + } 3867 + } 4124 3868 local_irq_disable(); 4125 3869 __enable_cpu_timer_accounting(vcpu); 4126 3870 guest_exit_irqoff(); ··· 4154 3858 return rc; 4155 3859 } 4156 3860 4157 - static void sync_regs(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) 3861 + static void sync_regs_fmt2(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) 4158 3862 { 4159 3863 struct runtime_instr_cb *riccb; 4160 3864 struct gs_cb *gscb; ··· 4163 3867 gscb = (struct gs_cb *) &kvm_run->s.regs.gscb; 4164 3868 vcpu->arch.sie_block->gpsw.mask = kvm_run->psw_mask; 4165 3869 vcpu->arch.sie_block->gpsw.addr = kvm_run->psw_addr; 4166 - if (kvm_run->kvm_dirty_regs & KVM_SYNC_PREFIX) 4167 - kvm_s390_set_prefix(vcpu, kvm_run->s.regs.prefix); 4168 - if (kvm_run->kvm_dirty_regs & KVM_SYNC_CRS) { 4169 - memcpy(&vcpu->arch.sie_block->gcr, &kvm_run->s.regs.crs, 128); 4170 - /* some control register changes require a tlb flush */ 4171 - kvm_make_request(KVM_REQ_TLB_FLUSH, vcpu); 4172 - } 4173 3870 if (kvm_run->kvm_dirty_regs & KVM_SYNC_ARCH0) { 4174 - kvm_s390_set_cpu_timer(vcpu, kvm_run->s.regs.cputm); 4175 - vcpu->arch.sie_block->ckc = kvm_run->s.regs.ckc; 4176 3871 vcpu->arch.sie_block->todpr = kvm_run->s.regs.todpr; 4177 3872 vcpu->arch.sie_block->pp = kvm_run->s.regs.pp; 4178 3873 vcpu->arch.sie_block->gbea = kvm_run->s.regs.gbea; ··· 4204 3917 vcpu->arch.sie_block->fpf &= ~FPF_BPBC; 4205 3918 vcpu->arch.sie_block->fpf |= kvm_run->s.regs.bpbc ? FPF_BPBC : 0; 4206 3919 } 4207 - save_access_regs(vcpu->arch.host_acrs); 4208 - restore_access_regs(vcpu->run->s.regs.acrs); 4209 - /* save host (userspace) fprs/vrs */ 4210 - save_fpu_regs(); 4211 - vcpu->arch.host_fpregs.fpc = current->thread.fpu.fpc; 4212 - vcpu->arch.host_fpregs.regs = current->thread.fpu.regs; 4213 - if (MACHINE_HAS_VX) 4214 - current->thread.fpu.regs = vcpu->run->s.regs.vrs; 4215 - else 4216 - current->thread.fpu.regs = vcpu->run->s.regs.fprs; 4217 - current->thread.fpu.fpc = vcpu->run->s.regs.fpc; 4218 - if (test_fp_ctl(current->thread.fpu.fpc)) 4219 - /* User space provided an invalid FPC, let's clear it */ 4220 - current->thread.fpu.fpc = 0; 4221 3920 if (MACHINE_HAS_GS) { 4222 3921 preempt_disable(); 4223 3922 __ctl_set_bit(2, 4); ··· 4219 3946 preempt_enable(); 4220 3947 } 4221 3948 /* SIE will load etoken directly from SDNX and therefore kvm_run */ 3949 + } 3950 + 3951 + static void sync_regs(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) 3952 + { 3953 + if (kvm_run->kvm_dirty_regs & KVM_SYNC_PREFIX) 3954 + kvm_s390_set_prefix(vcpu, kvm_run->s.regs.prefix); 3955 + if (kvm_run->kvm_dirty_regs & KVM_SYNC_CRS) { 3956 + memcpy(&vcpu->arch.sie_block->gcr, &kvm_run->s.regs.crs, 128); 3957 + /* some control register changes require a tlb flush */ 3958 + kvm_make_request(KVM_REQ_TLB_FLUSH, vcpu); 3959 + } 3960 + if (kvm_run->kvm_dirty_regs & KVM_SYNC_ARCH0) { 3961 + kvm_s390_set_cpu_timer(vcpu, kvm_run->s.regs.cputm); 3962 + vcpu->arch.sie_block->ckc = kvm_run->s.regs.ckc; 3963 + } 3964 + save_access_regs(vcpu->arch.host_acrs); 3965 + restore_access_regs(vcpu->run->s.regs.acrs); 3966 + /* save host (userspace) fprs/vrs */ 3967 + save_fpu_regs(); 3968 + vcpu->arch.host_fpregs.fpc = current->thread.fpu.fpc; 3969 + vcpu->arch.host_fpregs.regs = current->thread.fpu.regs; 3970 + if (MACHINE_HAS_VX) 3971 + current->thread.fpu.regs = vcpu->run->s.regs.vrs; 3972 + else 3973 + current->thread.fpu.regs = vcpu->run->s.regs.fprs; 3974 + current->thread.fpu.fpc = vcpu->run->s.regs.fpc; 3975 + if (test_fp_ctl(current->thread.fpu.fpc)) 3976 + /* User space provided an invalid FPC, let's clear it */ 3977 + current->thread.fpu.fpc = 0; 3978 + 3979 + /* Sync fmt2 only data */ 3980 + if (likely(!kvm_s390_pv_cpu_is_protected(vcpu))) { 3981 + sync_regs_fmt2(vcpu, kvm_run); 3982 + } else { 3983 + /* 3984 + * In several places we have to modify our internal view to 3985 + * not do things that are disallowed by the ultravisor. For 3986 + * example we must not inject interrupts after specific exits 3987 + * (e.g. 112 prefix page not secure). We do this by turning 3988 + * off the machine check, external and I/O interrupt bits 3989 + * of our PSW copy. To avoid getting validity intercepts, we 3990 + * do only accept the condition code from userspace. 3991 + */ 3992 + vcpu->arch.sie_block->gpsw.mask &= ~PSW_MASK_CC; 3993 + vcpu->arch.sie_block->gpsw.mask |= kvm_run->psw_mask & 3994 + PSW_MASK_CC; 3995 + } 4222 3996 4223 3997 kvm_run->kvm_dirty_regs = 0; 4224 3998 } 4225 3999 4226 - static void store_regs(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) 4000 + static void store_regs_fmt2(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) 4227 4001 { 4228 - kvm_run->psw_mask = vcpu->arch.sie_block->gpsw.mask; 4229 - kvm_run->psw_addr = vcpu->arch.sie_block->gpsw.addr; 4230 - kvm_run->s.regs.prefix = kvm_s390_get_prefix(vcpu); 4231 - memcpy(&kvm_run->s.regs.crs, &vcpu->arch.sie_block->gcr, 128); 4232 - kvm_run->s.regs.cputm = kvm_s390_get_cpu_timer(vcpu); 4233 - kvm_run->s.regs.ckc = vcpu->arch.sie_block->ckc; 4234 4002 kvm_run->s.regs.todpr = vcpu->arch.sie_block->todpr; 4235 4003 kvm_run->s.regs.pp = vcpu->arch.sie_block->pp; 4236 4004 kvm_run->s.regs.gbea = vcpu->arch.sie_block->gbea; 4237 - kvm_run->s.regs.pft = vcpu->arch.pfault_token; 4238 - kvm_run->s.regs.pfs = vcpu->arch.pfault_select; 4239 - kvm_run->s.regs.pfc = vcpu->arch.pfault_compare; 4240 4005 kvm_run->s.regs.bpbc = (vcpu->arch.sie_block->fpf & FPF_BPBC) == FPF_BPBC; 4241 - save_access_regs(vcpu->run->s.regs.acrs); 4242 - restore_access_regs(vcpu->arch.host_acrs); 4243 - /* Save guest register state */ 4244 - save_fpu_regs(); 4245 - vcpu->run->s.regs.fpc = current->thread.fpu.fpc; 4246 - /* Restore will be done lazily at return */ 4247 - current->thread.fpu.fpc = vcpu->arch.host_fpregs.fpc; 4248 - current->thread.fpu.regs = vcpu->arch.host_fpregs.regs; 4249 4006 if (MACHINE_HAS_GS) { 4250 4007 __ctl_set_bit(2, 4); 4251 4008 if (vcpu->arch.gs_enabled) ··· 4289 3986 vcpu->arch.host_gscb = NULL; 4290 3987 } 4291 3988 /* SIE will save etoken directly into SDNX and therefore kvm_run */ 3989 + } 3990 + 3991 + static void store_regs(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) 3992 + { 3993 + kvm_run->psw_mask = vcpu->arch.sie_block->gpsw.mask; 3994 + kvm_run->psw_addr = vcpu->arch.sie_block->gpsw.addr; 3995 + kvm_run->s.regs.prefix = kvm_s390_get_prefix(vcpu); 3996 + memcpy(&kvm_run->s.regs.crs, &vcpu->arch.sie_block->gcr, 128); 3997 + kvm_run->s.regs.cputm = kvm_s390_get_cpu_timer(vcpu); 3998 + kvm_run->s.regs.ckc = vcpu->arch.sie_block->ckc; 3999 + kvm_run->s.regs.pft = vcpu->arch.pfault_token; 4000 + kvm_run->s.regs.pfs = vcpu->arch.pfault_select; 4001 + kvm_run->s.regs.pfc = vcpu->arch.pfault_compare; 4002 + save_access_regs(vcpu->run->s.regs.acrs); 4003 + restore_access_regs(vcpu->arch.host_acrs); 4004 + /* Save guest register state */ 4005 + save_fpu_regs(); 4006 + vcpu->run->s.regs.fpc = current->thread.fpu.fpc; 4007 + /* Restore will be done lazily at return */ 4008 + current->thread.fpu.fpc = vcpu->arch.host_fpregs.fpc; 4009 + current->thread.fpu.regs = vcpu->arch.host_fpregs.regs; 4010 + if (likely(!kvm_s390_pv_cpu_is_protected(vcpu))) 4011 + store_regs_fmt2(vcpu, kvm_run); 4292 4012 } 4293 4013 4294 4014 int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) ··· 4335 4009 4336 4010 kvm_sigset_activate(vcpu); 4337 4011 4012 + /* 4013 + * no need to check the return value of vcpu_start as it can only have 4014 + * an error for protvirt, but protvirt means user cpu state 4015 + */ 4338 4016 if (!kvm_s390_user_cpu_state_ctrl(vcpu->kvm)) { 4339 4017 kvm_s390_vcpu_start(vcpu); 4340 4018 } else if (is_vcpu_stopped(vcpu)) { ··· 4476 4146 kvm_s390_sync_request(KVM_REQ_ENABLE_IBS, vcpu); 4477 4147 } 4478 4148 4479 - void kvm_s390_vcpu_start(struct kvm_vcpu *vcpu) 4149 + int kvm_s390_vcpu_start(struct kvm_vcpu *vcpu) 4480 4150 { 4481 - int i, online_vcpus, started_vcpus = 0; 4151 + int i, online_vcpus, r = 0, started_vcpus = 0; 4482 4152 4483 4153 if (!is_vcpu_stopped(vcpu)) 4484 - return; 4154 + return 0; 4485 4155 4486 4156 trace_kvm_s390_vcpu_start_stop(vcpu->vcpu_id, 1); 4487 4157 /* Only one cpu at a time may enter/leave the STOPPED state. */ 4488 4158 spin_lock(&vcpu->kvm->arch.start_stop_lock); 4489 4159 online_vcpus = atomic_read(&vcpu->kvm->online_vcpus); 4160 + 4161 + /* Let's tell the UV that we want to change into the operating state */ 4162 + if (kvm_s390_pv_cpu_is_protected(vcpu)) { 4163 + r = kvm_s390_pv_set_cpu_state(vcpu, PV_CPU_STATE_OPR); 4164 + if (r) { 4165 + spin_unlock(&vcpu->kvm->arch.start_stop_lock); 4166 + return r; 4167 + } 4168 + } 4490 4169 4491 4170 for (i = 0; i < online_vcpus; i++) { 4492 4171 if (!is_vcpu_stopped(vcpu->kvm->vcpus[i])) ··· 4516 4177 4517 4178 kvm_s390_clear_cpuflags(vcpu, CPUSTAT_STOPPED); 4518 4179 /* 4180 + * The real PSW might have changed due to a RESTART interpreted by the 4181 + * ultravisor. We block all interrupts and let the next sie exit 4182 + * refresh our view. 4183 + */ 4184 + if (kvm_s390_pv_cpu_is_protected(vcpu)) 4185 + vcpu->arch.sie_block->gpsw.mask &= ~PSW_INT_MASK; 4186 + /* 4519 4187 * Another VCPU might have used IBS while we were offline. 4520 4188 * Let's play safe and flush the VCPU at startup. 4521 4189 */ 4522 4190 kvm_make_request(KVM_REQ_TLB_FLUSH, vcpu); 4523 4191 spin_unlock(&vcpu->kvm->arch.start_stop_lock); 4524 - return; 4192 + return 0; 4525 4193 } 4526 4194 4527 - void kvm_s390_vcpu_stop(struct kvm_vcpu *vcpu) 4195 + int kvm_s390_vcpu_stop(struct kvm_vcpu *vcpu) 4528 4196 { 4529 - int i, online_vcpus, started_vcpus = 0; 4197 + int i, online_vcpus, r = 0, started_vcpus = 0; 4530 4198 struct kvm_vcpu *started_vcpu = NULL; 4531 4199 4532 4200 if (is_vcpu_stopped(vcpu)) 4533 - return; 4201 + return 0; 4534 4202 4535 4203 trace_kvm_s390_vcpu_start_stop(vcpu->vcpu_id, 0); 4536 4204 /* Only one cpu at a time may enter/leave the STOPPED state. */ 4537 4205 spin_lock(&vcpu->kvm->arch.start_stop_lock); 4538 4206 online_vcpus = atomic_read(&vcpu->kvm->online_vcpus); 4207 + 4208 + /* Let's tell the UV that we want to change into the stopped state */ 4209 + if (kvm_s390_pv_cpu_is_protected(vcpu)) { 4210 + r = kvm_s390_pv_set_cpu_state(vcpu, PV_CPU_STATE_STP); 4211 + if (r) { 4212 + spin_unlock(&vcpu->kvm->arch.start_stop_lock); 4213 + return r; 4214 + } 4215 + } 4539 4216 4540 4217 /* SIGP STOP and SIGP STOP AND STORE STATUS has been fully processed */ 4541 4218 kvm_s390_clear_stop_irq(vcpu); ··· 4575 4220 } 4576 4221 4577 4222 spin_unlock(&vcpu->kvm->arch.start_stop_lock); 4578 - return; 4223 + return 0; 4579 4224 } 4580 4225 4581 4226 static int kvm_vcpu_ioctl_enable_cap(struct kvm_vcpu *vcpu, ··· 4602 4247 return r; 4603 4248 } 4604 4249 4250 + static long kvm_s390_guest_sida_op(struct kvm_vcpu *vcpu, 4251 + struct kvm_s390_mem_op *mop) 4252 + { 4253 + void __user *uaddr = (void __user *)mop->buf; 4254 + int r = 0; 4255 + 4256 + if (mop->flags || !mop->size) 4257 + return -EINVAL; 4258 + if (mop->size + mop->sida_offset < mop->size) 4259 + return -EINVAL; 4260 + if (mop->size + mop->sida_offset > sida_size(vcpu->arch.sie_block)) 4261 + return -E2BIG; 4262 + 4263 + switch (mop->op) { 4264 + case KVM_S390_MEMOP_SIDA_READ: 4265 + if (copy_to_user(uaddr, (void *)(sida_origin(vcpu->arch.sie_block) + 4266 + mop->sida_offset), mop->size)) 4267 + r = -EFAULT; 4268 + 4269 + break; 4270 + case KVM_S390_MEMOP_SIDA_WRITE: 4271 + if (copy_from_user((void *)(sida_origin(vcpu->arch.sie_block) + 4272 + mop->sida_offset), uaddr, mop->size)) 4273 + r = -EFAULT; 4274 + break; 4275 + } 4276 + return r; 4277 + } 4605 4278 static long kvm_s390_guest_mem_op(struct kvm_vcpu *vcpu, 4606 4279 struct kvm_s390_mem_op *mop) 4607 4280 { 4608 4281 void __user *uaddr = (void __user *)mop->buf; 4609 4282 void *tmpbuf = NULL; 4610 - int r, srcu_idx; 4283 + int r = 0; 4611 4284 const u64 supported_flags = KVM_S390_MEMOP_F_INJECT_EXCEPTION 4612 4285 | KVM_S390_MEMOP_F_CHECK_ONLY; 4613 4286 ··· 4645 4262 if (mop->size > MEM_OP_MAX_SIZE) 4646 4263 return -E2BIG; 4647 4264 4265 + if (kvm_s390_pv_cpu_is_protected(vcpu)) 4266 + return -EINVAL; 4267 + 4648 4268 if (!(mop->flags & KVM_S390_MEMOP_F_CHECK_ONLY)) { 4649 4269 tmpbuf = vmalloc(mop->size); 4650 4270 if (!tmpbuf) 4651 4271 return -ENOMEM; 4652 4272 } 4653 - 4654 - srcu_idx = srcu_read_lock(&vcpu->kvm->srcu); 4655 4273 4656 4274 switch (mop->op) { 4657 4275 case KVM_S390_MEMOP_LOGICAL_READ: ··· 4679 4295 } 4680 4296 r = write_guest(vcpu, mop->gaddr, mop->ar, tmpbuf, mop->size); 4681 4297 break; 4682 - default: 4683 - r = -EINVAL; 4684 4298 } 4685 - 4686 - srcu_read_unlock(&vcpu->kvm->srcu, srcu_idx); 4687 4299 4688 4300 if (r > 0 && (mop->flags & KVM_S390_MEMOP_F_INJECT_EXCEPTION) != 0) 4689 4301 kvm_s390_inject_prog_irq(vcpu, &vcpu->arch.pgm); 4690 4302 4691 4303 vfree(tmpbuf); 4304 + return r; 4305 + } 4306 + 4307 + static long kvm_s390_guest_memsida_op(struct kvm_vcpu *vcpu, 4308 + struct kvm_s390_mem_op *mop) 4309 + { 4310 + int r, srcu_idx; 4311 + 4312 + srcu_idx = srcu_read_lock(&vcpu->kvm->srcu); 4313 + 4314 + switch (mop->op) { 4315 + case KVM_S390_MEMOP_LOGICAL_READ: 4316 + case KVM_S390_MEMOP_LOGICAL_WRITE: 4317 + r = kvm_s390_guest_mem_op(vcpu, mop); 4318 + break; 4319 + case KVM_S390_MEMOP_SIDA_READ: 4320 + case KVM_S390_MEMOP_SIDA_WRITE: 4321 + /* we are locked against sida going away by the vcpu->mutex */ 4322 + r = kvm_s390_guest_sida_op(vcpu, mop); 4323 + break; 4324 + default: 4325 + r = -EINVAL; 4326 + } 4327 + 4328 + srcu_read_unlock(&vcpu->kvm->srcu, srcu_idx); 4692 4329 return r; 4693 4330 } 4694 4331 ··· 4748 4343 void __user *argp = (void __user *)arg; 4749 4344 int idx; 4750 4345 long r; 4346 + u16 rc, rrc; 4751 4347 4752 4348 vcpu_load(vcpu); 4753 4349 ··· 4770 4364 case KVM_S390_CLEAR_RESET: 4771 4365 r = 0; 4772 4366 kvm_arch_vcpu_ioctl_clear_reset(vcpu); 4367 + if (kvm_s390_pv_cpu_is_protected(vcpu)) { 4368 + r = uv_cmd_nodata(kvm_s390_pv_cpu_get_handle(vcpu), 4369 + UVC_CMD_CPU_RESET_CLEAR, &rc, &rrc); 4370 + VCPU_EVENT(vcpu, 3, "PROTVIRT RESET CLEAR VCPU: rc %x rrc %x", 4371 + rc, rrc); 4372 + } 4773 4373 break; 4774 4374 case KVM_S390_INITIAL_RESET: 4775 4375 r = 0; 4776 4376 kvm_arch_vcpu_ioctl_initial_reset(vcpu); 4377 + if (kvm_s390_pv_cpu_is_protected(vcpu)) { 4378 + r = uv_cmd_nodata(kvm_s390_pv_cpu_get_handle(vcpu), 4379 + UVC_CMD_CPU_RESET_INITIAL, 4380 + &rc, &rrc); 4381 + VCPU_EVENT(vcpu, 3, "PROTVIRT RESET INITIAL VCPU: rc %x rrc %x", 4382 + rc, rrc); 4383 + } 4777 4384 break; 4778 4385 case KVM_S390_NORMAL_RESET: 4779 4386 r = 0; 4780 4387 kvm_arch_vcpu_ioctl_normal_reset(vcpu); 4388 + if (kvm_s390_pv_cpu_is_protected(vcpu)) { 4389 + r = uv_cmd_nodata(kvm_s390_pv_cpu_get_handle(vcpu), 4390 + UVC_CMD_CPU_RESET, &rc, &rrc); 4391 + VCPU_EVENT(vcpu, 3, "PROTVIRT RESET NORMAL VCPU: rc %x rrc %x", 4392 + rc, rrc); 4393 + } 4781 4394 break; 4782 4395 case KVM_SET_ONE_REG: 4783 4396 case KVM_GET_ONE_REG: { 4784 4397 struct kvm_one_reg reg; 4398 + r = -EINVAL; 4399 + if (kvm_s390_pv_cpu_is_protected(vcpu)) 4400 + break; 4785 4401 r = -EFAULT; 4786 4402 if (copy_from_user(&reg, argp, sizeof(reg))) 4787 4403 break; ··· 4866 4438 struct kvm_s390_mem_op mem_op; 4867 4439 4868 4440 if (copy_from_user(&mem_op, argp, sizeof(mem_op)) == 0) 4869 - r = kvm_s390_guest_mem_op(vcpu, &mem_op); 4441 + r = kvm_s390_guest_memsida_op(vcpu, &mem_op); 4870 4442 else 4871 4443 r = -EFAULT; 4872 4444 break; ··· 4946 4518 if (mem->guest_phys_addr + mem->memory_size > kvm->arch.mem_limit) 4947 4519 return -EINVAL; 4948 4520 4521 + /* When we are protected, we should not change the memory slots */ 4522 + if (kvm_s390_pv_get_handle(kvm)) 4523 + return -EINVAL; 4949 4524 return 0; 4950 4525 } 4951 4526
+48 -3
arch/s390/kvm/kvm-s390.h
··· 2 2 /* 3 3 * definition for kvm on s390 4 4 * 5 - * Copyright IBM Corp. 2008, 2009 5 + * Copyright IBM Corp. 2008, 2020 6 6 * 7 7 * Author(s): Carsten Otte <cotte@de.ibm.com> 8 8 * Christian Borntraeger <borntraeger@de.ibm.com> ··· 15 15 #include <linux/hrtimer.h> 16 16 #include <linux/kvm.h> 17 17 #include <linux/kvm_host.h> 18 + #include <linux/lockdep.h> 18 19 #include <asm/facility.h> 19 20 #include <asm/processor.h> 20 21 #include <asm/sclp.h> ··· 26 25 #define IS_ITDB_VALID(vcpu) ((*(char *)vcpu->arch.sie_block->itdba == TDB_FORMAT1)) 27 26 28 27 extern debug_info_t *kvm_s390_dbf; 28 + extern debug_info_t *kvm_s390_dbf_uv; 29 + 30 + #define KVM_UV_EVENT(d_kvm, d_loglevel, d_string, d_args...)\ 31 + do { \ 32 + debug_sprintf_event((d_kvm)->arch.dbf, d_loglevel, d_string "\n", \ 33 + d_args); \ 34 + debug_sprintf_event(kvm_s390_dbf_uv, d_loglevel, \ 35 + "%d: " d_string "\n", (d_kvm)->userspace_pid, \ 36 + d_args); \ 37 + } while (0) 38 + 29 39 #define KVM_EVENT(d_loglevel, d_string, d_args...)\ 30 40 do { \ 31 41 debug_sprintf_event(kvm_s390_dbf, d_loglevel, d_string "\n", \ ··· 208 196 return kvm->arch.user_cpu_state_ctrl != 0; 209 197 } 210 198 199 + /* implemented in pv.c */ 200 + int kvm_s390_pv_destroy_cpu(struct kvm_vcpu *vcpu, u16 *rc, u16 *rrc); 201 + int kvm_s390_pv_create_cpu(struct kvm_vcpu *vcpu, u16 *rc, u16 *rrc); 202 + int kvm_s390_pv_deinit_vm(struct kvm *kvm, u16 *rc, u16 *rrc); 203 + int kvm_s390_pv_init_vm(struct kvm *kvm, u16 *rc, u16 *rrc); 204 + int kvm_s390_pv_set_sec_parms(struct kvm *kvm, void *hdr, u64 length, u16 *rc, 205 + u16 *rrc); 206 + int kvm_s390_pv_unpack(struct kvm *kvm, unsigned long addr, unsigned long size, 207 + unsigned long tweak, u16 *rc, u16 *rrc); 208 + int kvm_s390_pv_set_cpu_state(struct kvm_vcpu *vcpu, u8 state); 209 + 210 + static inline u64 kvm_s390_pv_get_handle(struct kvm *kvm) 211 + { 212 + return kvm->arch.pv.handle; 213 + } 214 + 215 + static inline u64 kvm_s390_pv_cpu_get_handle(struct kvm_vcpu *vcpu) 216 + { 217 + return vcpu->arch.pv.handle; 218 + } 219 + 220 + static inline bool kvm_s390_pv_is_protected(struct kvm *kvm) 221 + { 222 + lockdep_assert_held(&kvm->lock); 223 + return !!kvm_s390_pv_get_handle(kvm); 224 + } 225 + 226 + static inline bool kvm_s390_pv_cpu_is_protected(struct kvm_vcpu *vcpu) 227 + { 228 + lockdep_assert_held(&vcpu->mutex); 229 + return !!kvm_s390_pv_cpu_get_handle(vcpu); 230 + } 231 + 211 232 /* implemented in interrupt.c */ 212 233 int kvm_s390_handle_wait(struct kvm_vcpu *vcpu); 213 234 void kvm_s390_vcpu_wakeup(struct kvm_vcpu *vcpu); ··· 331 286 long kvm_arch_fault_in_page(struct kvm_vcpu *vcpu, gpa_t gpa, int writable); 332 287 int kvm_s390_store_status_unloaded(struct kvm_vcpu *vcpu, unsigned long addr); 333 288 int kvm_s390_vcpu_store_status(struct kvm_vcpu *vcpu, unsigned long addr); 334 - void kvm_s390_vcpu_start(struct kvm_vcpu *vcpu); 335 - void kvm_s390_vcpu_stop(struct kvm_vcpu *vcpu); 289 + int kvm_s390_vcpu_start(struct kvm_vcpu *vcpu); 290 + int kvm_s390_vcpu_stop(struct kvm_vcpu *vcpu); 336 291 void kvm_s390_vcpu_block(struct kvm_vcpu *vcpu); 337 292 void kvm_s390_vcpu_unblock(struct kvm_vcpu *vcpu); 338 293 bool kvm_s390_vcpu_sie_inhibited(struct kvm_vcpu *vcpu);
+9 -4
arch/s390/kvm/priv.c
··· 2 2 /* 3 3 * handling privileged instructions 4 4 * 5 - * Copyright IBM Corp. 2008, 2018 5 + * Copyright IBM Corp. 2008, 2020 6 6 * 7 7 * Author(s): Carsten Otte <cotte@de.ibm.com> 8 8 * Christian Borntraeger <borntraeger@de.ibm.com> ··· 872 872 873 873 operand2 = kvm_s390_get_base_disp_s(vcpu, &ar); 874 874 875 - if (operand2 & 0xfff) 875 + if (!kvm_s390_pv_cpu_is_protected(vcpu) && (operand2 & 0xfff)) 876 876 return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION); 877 877 878 878 switch (fc) { ··· 893 893 handle_stsi_3_2_2(vcpu, (void *) mem); 894 894 break; 895 895 } 896 - 897 - rc = write_guest(vcpu, operand2, ar, (void *)mem, PAGE_SIZE); 896 + if (kvm_s390_pv_cpu_is_protected(vcpu)) { 897 + memcpy((void *)sida_origin(vcpu->arch.sie_block), (void *)mem, 898 + PAGE_SIZE); 899 + rc = 0; 900 + } else { 901 + rc = write_guest(vcpu, operand2, ar, (void *)mem, PAGE_SIZE); 902 + } 898 903 if (rc) { 899 904 rc = kvm_s390_inject_prog_cond(vcpu, rc); 900 905 goto out;
+303
arch/s390/kvm/pv.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* 3 + * Hosting Protected Virtual Machines 4 + * 5 + * Copyright IBM Corp. 2019, 2020 6 + * Author(s): Janosch Frank <frankja@linux.ibm.com> 7 + */ 8 + #include <linux/kvm.h> 9 + #include <linux/kvm_host.h> 10 + #include <linux/pagemap.h> 11 + #include <linux/sched/signal.h> 12 + #include <asm/pgalloc.h> 13 + #include <asm/gmap.h> 14 + #include <asm/uv.h> 15 + #include <asm/mman.h> 16 + #include "kvm-s390.h" 17 + 18 + int kvm_s390_pv_destroy_cpu(struct kvm_vcpu *vcpu, u16 *rc, u16 *rrc) 19 + { 20 + int cc = 0; 21 + 22 + if (kvm_s390_pv_cpu_get_handle(vcpu)) { 23 + cc = uv_cmd_nodata(kvm_s390_pv_cpu_get_handle(vcpu), 24 + UVC_CMD_DESTROY_SEC_CPU, rc, rrc); 25 + 26 + KVM_UV_EVENT(vcpu->kvm, 3, 27 + "PROTVIRT DESTROY VCPU %d: rc %x rrc %x", 28 + vcpu->vcpu_id, *rc, *rrc); 29 + WARN_ONCE(cc, "protvirt destroy cpu failed rc %x rrc %x", 30 + *rc, *rrc); 31 + } 32 + /* Intended memory leak for something that should never happen. */ 33 + if (!cc) 34 + free_pages(vcpu->arch.pv.stor_base, 35 + get_order(uv_info.guest_cpu_stor_len)); 36 + 37 + free_page(sida_origin(vcpu->arch.sie_block)); 38 + vcpu->arch.sie_block->pv_handle_cpu = 0; 39 + vcpu->arch.sie_block->pv_handle_config = 0; 40 + memset(&vcpu->arch.pv, 0, sizeof(vcpu->arch.pv)); 41 + vcpu->arch.sie_block->sdf = 0; 42 + /* 43 + * The sidad field (for sdf == 2) is now the gbea field (for sdf == 0). 44 + * Use the reset value of gbea to avoid leaking the kernel pointer of 45 + * the just freed sida. 46 + */ 47 + vcpu->arch.sie_block->gbea = 1; 48 + kvm_make_request(KVM_REQ_TLB_FLUSH, vcpu); 49 + 50 + return cc ? EIO : 0; 51 + } 52 + 53 + int kvm_s390_pv_create_cpu(struct kvm_vcpu *vcpu, u16 *rc, u16 *rrc) 54 + { 55 + struct uv_cb_csc uvcb = { 56 + .header.cmd = UVC_CMD_CREATE_SEC_CPU, 57 + .header.len = sizeof(uvcb), 58 + }; 59 + int cc; 60 + 61 + if (kvm_s390_pv_cpu_get_handle(vcpu)) 62 + return -EINVAL; 63 + 64 + vcpu->arch.pv.stor_base = __get_free_pages(GFP_KERNEL, 65 + get_order(uv_info.guest_cpu_stor_len)); 66 + if (!vcpu->arch.pv.stor_base) 67 + return -ENOMEM; 68 + 69 + /* Input */ 70 + uvcb.guest_handle = kvm_s390_pv_get_handle(vcpu->kvm); 71 + uvcb.num = vcpu->arch.sie_block->icpua; 72 + uvcb.state_origin = (u64)vcpu->arch.sie_block; 73 + uvcb.stor_origin = (u64)vcpu->arch.pv.stor_base; 74 + 75 + /* Alloc Secure Instruction Data Area Designation */ 76 + vcpu->arch.sie_block->sidad = __get_free_page(GFP_KERNEL | __GFP_ZERO); 77 + if (!vcpu->arch.sie_block->sidad) { 78 + free_pages(vcpu->arch.pv.stor_base, 79 + get_order(uv_info.guest_cpu_stor_len)); 80 + return -ENOMEM; 81 + } 82 + 83 + cc = uv_call(0, (u64)&uvcb); 84 + *rc = uvcb.header.rc; 85 + *rrc = uvcb.header.rrc; 86 + KVM_UV_EVENT(vcpu->kvm, 3, 87 + "PROTVIRT CREATE VCPU: cpu %d handle %llx rc %x rrc %x", 88 + vcpu->vcpu_id, uvcb.cpu_handle, uvcb.header.rc, 89 + uvcb.header.rrc); 90 + 91 + if (cc) { 92 + u16 dummy; 93 + 94 + kvm_s390_pv_destroy_cpu(vcpu, &dummy, &dummy); 95 + return -EIO; 96 + } 97 + 98 + /* Output */ 99 + vcpu->arch.pv.handle = uvcb.cpu_handle; 100 + vcpu->arch.sie_block->pv_handle_cpu = uvcb.cpu_handle; 101 + vcpu->arch.sie_block->pv_handle_config = kvm_s390_pv_get_handle(vcpu->kvm); 102 + vcpu->arch.sie_block->sdf = 2; 103 + kvm_make_request(KVM_REQ_TLB_FLUSH, vcpu); 104 + return 0; 105 + } 106 + 107 + /* only free resources when the destroy was successful */ 108 + static void kvm_s390_pv_dealloc_vm(struct kvm *kvm) 109 + { 110 + vfree(kvm->arch.pv.stor_var); 111 + free_pages(kvm->arch.pv.stor_base, 112 + get_order(uv_info.guest_base_stor_len)); 113 + memset(&kvm->arch.pv, 0, sizeof(kvm->arch.pv)); 114 + } 115 + 116 + static int kvm_s390_pv_alloc_vm(struct kvm *kvm) 117 + { 118 + unsigned long base = uv_info.guest_base_stor_len; 119 + unsigned long virt = uv_info.guest_virt_var_stor_len; 120 + unsigned long npages = 0, vlen = 0; 121 + struct kvm_memory_slot *memslot; 122 + 123 + kvm->arch.pv.stor_var = NULL; 124 + kvm->arch.pv.stor_base = __get_free_pages(GFP_KERNEL, get_order(base)); 125 + if (!kvm->arch.pv.stor_base) 126 + return -ENOMEM; 127 + 128 + /* 129 + * Calculate current guest storage for allocation of the 130 + * variable storage, which is based on the length in MB. 131 + * 132 + * Slots are sorted by GFN 133 + */ 134 + mutex_lock(&kvm->slots_lock); 135 + memslot = kvm_memslots(kvm)->memslots; 136 + npages = memslot->base_gfn + memslot->npages; 137 + mutex_unlock(&kvm->slots_lock); 138 + 139 + kvm->arch.pv.guest_len = npages * PAGE_SIZE; 140 + 141 + /* Allocate variable storage */ 142 + vlen = ALIGN(virt * ((npages * PAGE_SIZE) / HPAGE_SIZE), PAGE_SIZE); 143 + vlen += uv_info.guest_virt_base_stor_len; 144 + kvm->arch.pv.stor_var = vzalloc(vlen); 145 + if (!kvm->arch.pv.stor_var) 146 + goto out_err; 147 + return 0; 148 + 149 + out_err: 150 + kvm_s390_pv_dealloc_vm(kvm); 151 + return -ENOMEM; 152 + } 153 + 154 + /* this should not fail, but if it does, we must not free the donated memory */ 155 + int kvm_s390_pv_deinit_vm(struct kvm *kvm, u16 *rc, u16 *rrc) 156 + { 157 + int cc; 158 + 159 + /* make all pages accessible before destroying the guest */ 160 + s390_reset_acc(kvm->mm); 161 + 162 + cc = uv_cmd_nodata(kvm_s390_pv_get_handle(kvm), 163 + UVC_CMD_DESTROY_SEC_CONF, rc, rrc); 164 + WRITE_ONCE(kvm->arch.gmap->guest_handle, 0); 165 + atomic_set(&kvm->mm->context.is_protected, 0); 166 + KVM_UV_EVENT(kvm, 3, "PROTVIRT DESTROY VM: rc %x rrc %x", *rc, *rrc); 167 + WARN_ONCE(cc, "protvirt destroy vm failed rc %x rrc %x", *rc, *rrc); 168 + /* Inteded memory leak on "impossible" error */ 169 + if (!cc) 170 + kvm_s390_pv_dealloc_vm(kvm); 171 + return cc ? -EIO : 0; 172 + } 173 + 174 + int kvm_s390_pv_init_vm(struct kvm *kvm, u16 *rc, u16 *rrc) 175 + { 176 + struct uv_cb_cgc uvcb = { 177 + .header.cmd = UVC_CMD_CREATE_SEC_CONF, 178 + .header.len = sizeof(uvcb) 179 + }; 180 + int cc, ret; 181 + u16 dummy; 182 + 183 + ret = kvm_s390_pv_alloc_vm(kvm); 184 + if (ret) 185 + return ret; 186 + 187 + /* Inputs */ 188 + uvcb.guest_stor_origin = 0; /* MSO is 0 for KVM */ 189 + uvcb.guest_stor_len = kvm->arch.pv.guest_len; 190 + uvcb.guest_asce = kvm->arch.gmap->asce; 191 + uvcb.guest_sca = (unsigned long)kvm->arch.sca; 192 + uvcb.conf_base_stor_origin = (u64)kvm->arch.pv.stor_base; 193 + uvcb.conf_virt_stor_origin = (u64)kvm->arch.pv.stor_var; 194 + 195 + cc = uv_call(0, (u64)&uvcb); 196 + *rc = uvcb.header.rc; 197 + *rrc = uvcb.header.rrc; 198 + KVM_UV_EVENT(kvm, 3, "PROTVIRT CREATE VM: handle %llx len %llx rc %x rrc %x", 199 + uvcb.guest_handle, uvcb.guest_stor_len, *rc, *rrc); 200 + 201 + /* Outputs */ 202 + kvm->arch.pv.handle = uvcb.guest_handle; 203 + 204 + if (cc) { 205 + if (uvcb.header.rc & UVC_RC_NEED_DESTROY) 206 + kvm_s390_pv_deinit_vm(kvm, &dummy, &dummy); 207 + else 208 + kvm_s390_pv_dealloc_vm(kvm); 209 + return -EIO; 210 + } 211 + kvm->arch.gmap->guest_handle = uvcb.guest_handle; 212 + atomic_set(&kvm->mm->context.is_protected, 1); 213 + return 0; 214 + } 215 + 216 + int kvm_s390_pv_set_sec_parms(struct kvm *kvm, void *hdr, u64 length, u16 *rc, 217 + u16 *rrc) 218 + { 219 + struct uv_cb_ssc uvcb = { 220 + .header.cmd = UVC_CMD_SET_SEC_CONF_PARAMS, 221 + .header.len = sizeof(uvcb), 222 + .sec_header_origin = (u64)hdr, 223 + .sec_header_len = length, 224 + .guest_handle = kvm_s390_pv_get_handle(kvm), 225 + }; 226 + int cc = uv_call(0, (u64)&uvcb); 227 + 228 + *rc = uvcb.header.rc; 229 + *rrc = uvcb.header.rrc; 230 + KVM_UV_EVENT(kvm, 3, "PROTVIRT VM SET PARMS: rc %x rrc %x", 231 + *rc, *rrc); 232 + return cc ? -EINVAL : 0; 233 + } 234 + 235 + static int unpack_one(struct kvm *kvm, unsigned long addr, u64 tweak, 236 + u64 offset, u16 *rc, u16 *rrc) 237 + { 238 + struct uv_cb_unp uvcb = { 239 + .header.cmd = UVC_CMD_UNPACK_IMG, 240 + .header.len = sizeof(uvcb), 241 + .guest_handle = kvm_s390_pv_get_handle(kvm), 242 + .gaddr = addr, 243 + .tweak[0] = tweak, 244 + .tweak[1] = offset, 245 + }; 246 + int ret = gmap_make_secure(kvm->arch.gmap, addr, &uvcb); 247 + 248 + *rc = uvcb.header.rc; 249 + *rrc = uvcb.header.rrc; 250 + 251 + if (ret && ret != -EAGAIN) 252 + KVM_UV_EVENT(kvm, 3, "PROTVIRT VM UNPACK: failed addr %llx with rc %x rrc %x", 253 + uvcb.gaddr, *rc, *rrc); 254 + return ret; 255 + } 256 + 257 + int kvm_s390_pv_unpack(struct kvm *kvm, unsigned long addr, unsigned long size, 258 + unsigned long tweak, u16 *rc, u16 *rrc) 259 + { 260 + u64 offset = 0; 261 + int ret = 0; 262 + 263 + if (addr & ~PAGE_MASK || !size || size & ~PAGE_MASK) 264 + return -EINVAL; 265 + 266 + KVM_UV_EVENT(kvm, 3, "PROTVIRT VM UNPACK: start addr %lx size %lx", 267 + addr, size); 268 + 269 + while (offset < size) { 270 + ret = unpack_one(kvm, addr, tweak, offset, rc, rrc); 271 + if (ret == -EAGAIN) { 272 + cond_resched(); 273 + if (fatal_signal_pending(current)) 274 + break; 275 + continue; 276 + } 277 + if (ret) 278 + break; 279 + addr += PAGE_SIZE; 280 + offset += PAGE_SIZE; 281 + } 282 + if (!ret) 283 + KVM_UV_EVENT(kvm, 3, "%s", "PROTVIRT VM UNPACK: successful"); 284 + return ret; 285 + } 286 + 287 + int kvm_s390_pv_set_cpu_state(struct kvm_vcpu *vcpu, u8 state) 288 + { 289 + struct uv_cb_cpu_set_state uvcb = { 290 + .header.cmd = UVC_CMD_CPU_SET_STATE, 291 + .header.len = sizeof(uvcb), 292 + .cpu_handle = kvm_s390_pv_cpu_get_handle(vcpu), 293 + .state = state, 294 + }; 295 + int cc; 296 + 297 + cc = uv_call(0, (u64)&uvcb); 298 + KVM_UV_EVENT(vcpu->kvm, 3, "PROTVIRT SET CPU %d STATE %d rc %x rrc %x", 299 + vcpu->vcpu_id, state, uvcb.header.rc, uvcb.header.rrc); 300 + if (cc) 301 + return -EINVAL; 302 + return 0; 303 + }
+78
arch/s390/mm/fault.c
··· 38 38 #include <asm/irq.h> 39 39 #include <asm/mmu_context.h> 40 40 #include <asm/facility.h> 41 + #include <asm/uv.h> 41 42 #include "../kernel/entry.h" 42 43 43 44 #define __FAIL_ADDR_MASK -4096L ··· 817 816 early_initcall(pfault_irq_init); 818 817 819 818 #endif /* CONFIG_PFAULT */ 819 + 820 + #if IS_ENABLED(CONFIG_PGSTE) 821 + void do_secure_storage_access(struct pt_regs *regs) 822 + { 823 + unsigned long addr = regs->int_parm_long & __FAIL_ADDR_MASK; 824 + struct vm_area_struct *vma; 825 + struct mm_struct *mm; 826 + struct page *page; 827 + int rc; 828 + 829 + switch (get_fault_type(regs)) { 830 + case USER_FAULT: 831 + mm = current->mm; 832 + down_read(&mm->mmap_sem); 833 + vma = find_vma(mm, addr); 834 + if (!vma) { 835 + up_read(&mm->mmap_sem); 836 + do_fault_error(regs, VM_READ | VM_WRITE, VM_FAULT_BADMAP); 837 + break; 838 + } 839 + page = follow_page(vma, addr, FOLL_WRITE | FOLL_GET); 840 + if (IS_ERR_OR_NULL(page)) { 841 + up_read(&mm->mmap_sem); 842 + break; 843 + } 844 + if (arch_make_page_accessible(page)) 845 + send_sig(SIGSEGV, current, 0); 846 + put_page(page); 847 + up_read(&mm->mmap_sem); 848 + break; 849 + case KERNEL_FAULT: 850 + page = phys_to_page(addr); 851 + if (unlikely(!try_get_page(page))) 852 + break; 853 + rc = arch_make_page_accessible(page); 854 + put_page(page); 855 + if (rc) 856 + BUG(); 857 + break; 858 + case VDSO_FAULT: 859 + /* fallthrough */ 860 + case GMAP_FAULT: 861 + /* fallthrough */ 862 + default: 863 + do_fault_error(regs, VM_READ | VM_WRITE, VM_FAULT_BADMAP); 864 + WARN_ON_ONCE(1); 865 + } 866 + } 867 + NOKPROBE_SYMBOL(do_secure_storage_access); 868 + 869 + void do_non_secure_storage_access(struct pt_regs *regs) 870 + { 871 + unsigned long gaddr = regs->int_parm_long & __FAIL_ADDR_MASK; 872 + struct gmap *gmap = (struct gmap *)S390_lowcore.gmap; 873 + 874 + if (get_fault_type(regs) != GMAP_FAULT) { 875 + do_fault_error(regs, VM_READ | VM_WRITE, VM_FAULT_BADMAP); 876 + WARN_ON_ONCE(1); 877 + return; 878 + } 879 + 880 + if (gmap_convert_to_secure(gmap, gaddr) == -EINVAL) 881 + send_sig(SIGSEGV, current, 0); 882 + } 883 + NOKPROBE_SYMBOL(do_non_secure_storage_access); 884 + 885 + #else 886 + void do_secure_storage_access(struct pt_regs *regs) 887 + { 888 + default_trap_handler(regs); 889 + } 890 + 891 + void do_non_secure_storage_access(struct pt_regs *regs) 892 + { 893 + default_trap_handler(regs); 894 + } 895 + #endif
+55 -10
arch/s390/mm/gmap.c
··· 2548 2548 } 2549 2549 EXPORT_SYMBOL_GPL(s390_enable_sie); 2550 2550 2551 + int gmap_mark_unmergeable(void) 2552 + { 2553 + struct mm_struct *mm = current->mm; 2554 + struct vm_area_struct *vma; 2555 + 2556 + for (vma = mm->mmap; vma; vma = vma->vm_next) { 2557 + if (ksm_madvise(vma, vma->vm_start, vma->vm_end, 2558 + MADV_UNMERGEABLE, &vma->vm_flags)) { 2559 + return -ENOMEM; 2560 + } 2561 + } 2562 + mm->def_flags &= ~VM_MERGEABLE; 2563 + return 0; 2564 + } 2565 + EXPORT_SYMBOL_GPL(gmap_mark_unmergeable); 2566 + 2551 2567 /* 2552 2568 * Enable storage key handling from now on and initialize the storage 2553 2569 * keys with the default key. ··· 2609 2593 int s390_enable_skey(void) 2610 2594 { 2611 2595 struct mm_struct *mm = current->mm; 2612 - struct vm_area_struct *vma; 2613 2596 int rc = 0; 2614 2597 2615 2598 down_write(&mm->mmap_sem); ··· 2616 2601 goto out_up; 2617 2602 2618 2603 mm->context.uses_skeys = 1; 2619 - for (vma = mm->mmap; vma; vma = vma->vm_next) { 2620 - if (ksm_madvise(vma, vma->vm_start, vma->vm_end, 2621 - MADV_UNMERGEABLE, &vma->vm_flags)) { 2622 - mm->context.uses_skeys = 0; 2623 - rc = -ENOMEM; 2624 - goto out_up; 2625 - } 2604 + rc = gmap_mark_unmergeable(); 2605 + if (rc) { 2606 + mm->context.uses_skeys = 0; 2607 + goto out_up; 2626 2608 } 2627 - mm->def_flags &= ~VM_MERGEABLE; 2628 - 2629 2609 walk_page_range(mm, 0, TASK_SIZE, &enable_skey_walk_ops, NULL); 2630 2610 2631 2611 out_up: ··· 2650 2640 up_write(&mm->mmap_sem); 2651 2641 } 2652 2642 EXPORT_SYMBOL_GPL(s390_reset_cmma); 2643 + 2644 + /* 2645 + * make inaccessible pages accessible again 2646 + */ 2647 + static int __s390_reset_acc(pte_t *ptep, unsigned long addr, 2648 + unsigned long next, struct mm_walk *walk) 2649 + { 2650 + pte_t pte = READ_ONCE(*ptep); 2651 + 2652 + if (pte_present(pte)) 2653 + WARN_ON_ONCE(uv_convert_from_secure(pte_val(pte) & PAGE_MASK)); 2654 + return 0; 2655 + } 2656 + 2657 + static const struct mm_walk_ops reset_acc_walk_ops = { 2658 + .pte_entry = __s390_reset_acc, 2659 + }; 2660 + 2661 + #include <linux/sched/mm.h> 2662 + void s390_reset_acc(struct mm_struct *mm) 2663 + { 2664 + /* 2665 + * we might be called during 2666 + * reset: we walk the pages and clear 2667 + * close of all kvm file descriptors: we walk the pages and clear 2668 + * exit of process on fd closure: vma already gone, do nothing 2669 + */ 2670 + if (!mmget_not_zero(mm)) 2671 + return; 2672 + down_read(&mm->mmap_sem); 2673 + walk_page_range(mm, 0, TASK_SIZE, &reset_acc_walk_ops, NULL); 2674 + up_read(&mm->mmap_sem); 2675 + mmput(mm); 2676 + } 2677 + EXPORT_SYMBOL_GPL(s390_reset_acc);
+1
arch/x86/events/amd/core.c
··· 250 250 [PERF_COUNT_HW_CPU_CYCLES] = 0x0076, 251 251 [PERF_COUNT_HW_INSTRUCTIONS] = 0x00c0, 252 252 [PERF_COUNT_HW_CACHE_REFERENCES] = 0xff60, 253 + [PERF_COUNT_HW_CACHE_MISSES] = 0x0964, 253 254 [PERF_COUNT_HW_BRANCH_INSTRUCTIONS] = 0x00c2, 254 255 [PERF_COUNT_HW_BRANCH_MISSES] = 0x00c3, 255 256 [PERF_COUNT_HW_STALLED_CYCLES_FRONTEND] = 0x0287,
+1
arch/x86/events/intel/core.c
··· 4765 4765 break; 4766 4766 4767 4767 case INTEL_FAM6_ATOM_TREMONT_D: 4768 + case INTEL_FAM6_ATOM_TREMONT: 4768 4769 x86_pmu.late_ack = true; 4769 4770 memcpy(hw_cache_event_ids, glp_hw_cache_event_ids, 4770 4771 sizeof(hw_cache_event_ids));
+13 -9
arch/x86/events/intel/cstate.c
··· 40 40 * Model specific counters: 41 41 * MSR_CORE_C1_RES: CORE C1 Residency Counter 42 42 * perf code: 0x00 43 - * Available model: SLM,AMT,GLM,CNL 43 + * Available model: SLM,AMT,GLM,CNL,TNT 44 44 * Scope: Core (each processor core has a MSR) 45 45 * MSR_CORE_C3_RESIDENCY: CORE C3 Residency Counter 46 46 * perf code: 0x01 47 47 * Available model: NHM,WSM,SNB,IVB,HSW,BDW,SKL,GLM, 48 - * CNL,KBL,CML 48 + * CNL,KBL,CML,TNT 49 49 * Scope: Core 50 50 * MSR_CORE_C6_RESIDENCY: CORE C6 Residency Counter 51 51 * perf code: 0x02 52 52 * Available model: SLM,AMT,NHM,WSM,SNB,IVB,HSW,BDW, 53 - * SKL,KNL,GLM,CNL,KBL,CML,ICL,TGL 53 + * SKL,KNL,GLM,CNL,KBL,CML,ICL,TGL, 54 + * TNT 54 55 * Scope: Core 55 56 * MSR_CORE_C7_RESIDENCY: CORE C7 Residency Counter 56 57 * perf code: 0x03 ··· 61 60 * MSR_PKG_C2_RESIDENCY: Package C2 Residency Counter. 62 61 * perf code: 0x00 63 62 * Available model: SNB,IVB,HSW,BDW,SKL,KNL,GLM,CNL, 64 - * KBL,CML,ICL,TGL 63 + * KBL,CML,ICL,TGL,TNT 65 64 * Scope: Package (physical package) 66 65 * MSR_PKG_C3_RESIDENCY: Package C3 Residency Counter. 67 66 * perf code: 0x01 68 67 * Available model: NHM,WSM,SNB,IVB,HSW,BDW,SKL,KNL, 69 - * GLM,CNL,KBL,CML,ICL,TGL 68 + * GLM,CNL,KBL,CML,ICL,TGL,TNT 70 69 * Scope: Package (physical package) 71 70 * MSR_PKG_C6_RESIDENCY: Package C6 Residency Counter. 72 71 * perf code: 0x02 73 - * Available model: SLM,AMT,NHM,WSM,SNB,IVB,HSW,BDW 74 - * SKL,KNL,GLM,CNL,KBL,CML,ICL,TGL 72 + * Available model: SLM,AMT,NHM,WSM,SNB,IVB,HSW,BDW, 73 + * SKL,KNL,GLM,CNL,KBL,CML,ICL,TGL, 74 + * TNT 75 75 * Scope: Package (physical package) 76 76 * MSR_PKG_C7_RESIDENCY: Package C7 Residency Counter. 77 77 * perf code: 0x03 ··· 89 87 * Scope: Package (physical package) 90 88 * MSR_PKG_C10_RESIDENCY: Package C10 Residency Counter. 91 89 * perf code: 0x06 92 - * Available model: HSW ULT,KBL,GLM,CNL,CML,ICL,TGL 90 + * Available model: HSW ULT,KBL,GLM,CNL,CML,ICL,TGL, 91 + * TNT 93 92 * Scope: Package (physical package) 94 93 * 95 94 */ ··· 643 640 644 641 X86_CSTATES_MODEL(INTEL_FAM6_ATOM_GOLDMONT, glm_cstates), 645 642 X86_CSTATES_MODEL(INTEL_FAM6_ATOM_GOLDMONT_D, glm_cstates), 646 - 647 643 X86_CSTATES_MODEL(INTEL_FAM6_ATOM_GOLDMONT_PLUS, glm_cstates), 644 + X86_CSTATES_MODEL(INTEL_FAM6_ATOM_TREMONT_D, glm_cstates), 645 + X86_CSTATES_MODEL(INTEL_FAM6_ATOM_TREMONT, glm_cstates), 648 646 649 647 X86_CSTATES_MODEL(INTEL_FAM6_ICELAKE_L, icl_cstates), 650 648 X86_CSTATES_MODEL(INTEL_FAM6_ICELAKE, icl_cstates),
+2
arch/x86/events/intel/ds.c
··· 1714 1714 old = ((s64)(prev_raw_count << shift) >> shift); 1715 1715 local64_add(new - old + count * period, &event->count); 1716 1716 1717 + local64_set(&hwc->period_left, -new); 1718 + 1717 1719 perf_event_update_userpage(event); 1718 1720 1719 1721 return 0;
+2 -1
arch/x86/events/msr.c
··· 75 75 76 76 case INTEL_FAM6_ATOM_GOLDMONT: 77 77 case INTEL_FAM6_ATOM_GOLDMONT_D: 78 - 79 78 case INTEL_FAM6_ATOM_GOLDMONT_PLUS: 79 + case INTEL_FAM6_ATOM_TREMONT_D: 80 + case INTEL_FAM6_ATOM_TREMONT: 80 81 81 82 case INTEL_FAM6_XEON_PHI_KNL: 82 83 case INTEL_FAM6_XEON_PHI_KNM:
-4
crypto/Kconfig
··· 136 136 Userspace configuration for cryptographic instantiations such as 137 137 cbc(aes). 138 138 139 - if CRYPTO_MANAGER2 140 - 141 139 config CRYPTO_MANAGER_DISABLE_TESTS 142 140 bool "Disable run-time self tests" 143 141 default y ··· 152 154 153 155 This is intended for developer use only, as these tests take much 154 156 longer to run than the normal self tests. 155 - 156 - endif # if CRYPTO_MANAGER2 157 157 158 158 config CRYPTO_GF128MUL 159 159 tristate
+36
crypto/testmgr.c
··· 4436 4436 .cipher = __VECS(tf_cbc_tv_template) 4437 4437 }, 4438 4438 }, { 4439 + #if IS_ENABLED(CONFIG_CRYPTO_PAES_S390) 4440 + .alg = "cbc-paes-s390", 4441 + .fips_allowed = 1, 4442 + .test = alg_test_skcipher, 4443 + .suite = { 4444 + .cipher = __VECS(aes_cbc_tv_template) 4445 + } 4446 + }, { 4447 + #endif 4439 4448 .alg = "cbcmac(aes)", 4440 4449 .fips_allowed = 1, 4441 4450 .test = alg_test_hash, ··· 4596 4587 .cipher = __VECS(tf_ctr_tv_template) 4597 4588 } 4598 4589 }, { 4590 + #if IS_ENABLED(CONFIG_CRYPTO_PAES_S390) 4591 + .alg = "ctr-paes-s390", 4592 + .fips_allowed = 1, 4593 + .test = alg_test_skcipher, 4594 + .suite = { 4595 + .cipher = __VECS(aes_ctr_tv_template) 4596 + } 4597 + }, { 4598 + #endif 4599 4599 .alg = "cts(cbc(aes))", 4600 4600 .test = alg_test_skcipher, 4601 4601 .fips_allowed = 1, ··· 4897 4879 .cipher = __VECS(xtea_tv_template) 4898 4880 } 4899 4881 }, { 4882 + #if IS_ENABLED(CONFIG_CRYPTO_PAES_S390) 4883 + .alg = "ecb-paes-s390", 4884 + .fips_allowed = 1, 4885 + .test = alg_test_skcipher, 4886 + .suite = { 4887 + .cipher = __VECS(aes_tv_template) 4888 + } 4889 + }, { 4890 + #endif 4900 4891 .alg = "ecdh", 4901 4892 .test = alg_test_kpp, 4902 4893 .fips_allowed = 1, ··· 5492 5465 .cipher = __VECS(tf_xts_tv_template) 5493 5466 } 5494 5467 }, { 5468 + #if IS_ENABLED(CONFIG_CRYPTO_PAES_S390) 5469 + .alg = "xts-paes-s390", 5470 + .fips_allowed = 1, 5471 + .test = alg_test_skcipher, 5472 + .suite = { 5473 + .cipher = __VECS(aes_xts_tv_template) 5474 + } 5475 + }, { 5476 + #endif 5495 5477 .alg = "xts4096(paes)", 5496 5478 .test = alg_test_null, 5497 5479 .fips_allowed = 1,
+2
drivers/acpi/acpica/achware.h
··· 101 101 102 102 acpi_status acpi_hw_enable_all_wakeup_gpes(void); 103 103 104 + u8 acpi_hw_check_all_gpes(void); 105 + 104 106 acpi_status 105 107 acpi_hw_enable_runtime_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info, 106 108 struct acpi_gpe_block_info *gpe_block,
+32
drivers/acpi/acpica/evxfgpe.c
··· 795 795 796 796 ACPI_EXPORT_SYMBOL(acpi_enable_all_wakeup_gpes) 797 797 798 + /****************************************************************************** 799 + * 800 + * FUNCTION: acpi_any_gpe_status_set 801 + * 802 + * PARAMETERS: None 803 + * 804 + * RETURN: Whether or not the status bit is set for any GPE 805 + * 806 + * DESCRIPTION: Check the status bits of all enabled GPEs and return TRUE if any 807 + * of them is set or FALSE otherwise. 808 + * 809 + ******************************************************************************/ 810 + u32 acpi_any_gpe_status_set(void) 811 + { 812 + acpi_status status; 813 + u8 ret; 814 + 815 + ACPI_FUNCTION_TRACE(acpi_any_gpe_status_set); 816 + 817 + status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS); 818 + if (ACPI_FAILURE(status)) { 819 + return (FALSE); 820 + } 821 + 822 + ret = acpi_hw_check_all_gpes(); 823 + (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS); 824 + 825 + return (ret); 826 + } 827 + 828 + ACPI_EXPORT_SYMBOL(acpi_any_gpe_status_set) 829 + 798 830 /******************************************************************************* 799 831 * 800 832 * FUNCTION: acpi_install_gpe_block
+71
drivers/acpi/acpica/hwgpe.c
··· 446 446 447 447 /****************************************************************************** 448 448 * 449 + * FUNCTION: acpi_hw_get_gpe_block_status 450 + * 451 + * PARAMETERS: gpe_xrupt_info - GPE Interrupt info 452 + * gpe_block - Gpe Block info 453 + * 454 + * RETURN: Success 455 + * 456 + * DESCRIPTION: Produce a combined GPE status bits mask for the given block. 457 + * 458 + ******************************************************************************/ 459 + 460 + static acpi_status 461 + acpi_hw_get_gpe_block_status(struct acpi_gpe_xrupt_info *gpe_xrupt_info, 462 + struct acpi_gpe_block_info *gpe_block, 463 + void *ret_ptr) 464 + { 465 + struct acpi_gpe_register_info *gpe_register_info; 466 + u64 in_enable, in_status; 467 + acpi_status status; 468 + u8 *ret = ret_ptr; 469 + u32 i; 470 + 471 + /* Examine each GPE Register within the block */ 472 + 473 + for (i = 0; i < gpe_block->register_count; i++) { 474 + gpe_register_info = &gpe_block->register_info[i]; 475 + 476 + status = acpi_hw_read(&in_enable, 477 + &gpe_register_info->enable_address); 478 + if (ACPI_FAILURE(status)) { 479 + continue; 480 + } 481 + 482 + status = acpi_hw_read(&in_status, 483 + &gpe_register_info->status_address); 484 + if (ACPI_FAILURE(status)) { 485 + continue; 486 + } 487 + 488 + *ret |= in_enable & in_status; 489 + } 490 + 491 + return (AE_OK); 492 + } 493 + 494 + /****************************************************************************** 495 + * 449 496 * FUNCTION: acpi_hw_disable_all_gpes 450 497 * 451 498 * PARAMETERS: None ··· 555 508 556 509 status = acpi_ev_walk_gpe_list(acpi_hw_enable_wakeup_gpe_block, NULL); 557 510 return_ACPI_STATUS(status); 511 + } 512 + 513 + /****************************************************************************** 514 + * 515 + * FUNCTION: acpi_hw_check_all_gpes 516 + * 517 + * PARAMETERS: None 518 + * 519 + * RETURN: Combined status of all GPEs 520 + * 521 + * DESCRIPTION: Check all enabled GPEs in all GPE blocks and return TRUE if the 522 + * status bit is set for at least one of them of FALSE otherwise. 523 + * 524 + ******************************************************************************/ 525 + 526 + u8 acpi_hw_check_all_gpes(void) 527 + { 528 + u8 ret = 0; 529 + 530 + ACPI_FUNCTION_TRACE(acpi_hw_check_all_gpes); 531 + 532 + (void)acpi_ev_walk_gpe_list(acpi_hw_get_gpe_block_status, &ret); 533 + 534 + return (ret != 0); 558 535 } 559 536 560 537 #endif /* !ACPI_REDUCED_HARDWARE */
+26 -18
drivers/acpi/ec.c
··· 179 179 180 180 static struct acpi_ec *boot_ec; 181 181 static bool boot_ec_is_ecdt = false; 182 + static struct workqueue_struct *ec_wq; 182 183 static struct workqueue_struct *ec_query_wq; 183 184 184 185 static int EC_FLAGS_QUERY_HANDSHAKE; /* Needs QR_EC issued when SCI_EVT set */ ··· 470 469 ec_dbg_evt("Command(%s) submitted/blocked", 471 470 acpi_ec_cmd_string(ACPI_EC_COMMAND_QUERY)); 472 471 ec->nr_pending_queries++; 473 - schedule_work(&ec->work); 472 + queue_work(ec_wq, &ec->work); 474 473 } 475 474 } 476 475 ··· 536 535 #ifdef CONFIG_PM_SLEEP 537 536 static void __acpi_ec_flush_work(void) 538 537 { 539 - flush_scheduled_work(); /* flush ec->work */ 538 + drain_workqueue(ec_wq); /* flush ec->work */ 540 539 flush_workqueue(ec_query_wq); /* flush queries */ 541 540 } 542 541 ··· 557 556 558 557 void acpi_ec_flush_work(void) 559 558 { 560 - /* Without ec_query_wq there is nothing to flush. */ 561 - if (!ec_query_wq) 559 + /* Without ec_wq there is nothing to flush. */ 560 + if (!ec_wq) 562 561 return; 563 562 564 563 __acpi_ec_flush_work(); ··· 2108 2107 .drv.pm = &acpi_ec_pm, 2109 2108 }; 2110 2109 2111 - static inline int acpi_ec_query_init(void) 2110 + static void acpi_ec_destroy_workqueues(void) 2112 2111 { 2113 - if (!ec_query_wq) { 2114 - ec_query_wq = alloc_workqueue("kec_query", 0, 2115 - ec_max_queries); 2116 - if (!ec_query_wq) 2117 - return -ENODEV; 2112 + if (ec_wq) { 2113 + destroy_workqueue(ec_wq); 2114 + ec_wq = NULL; 2118 2115 } 2119 - return 0; 2120 - } 2121 - 2122 - static inline void acpi_ec_query_exit(void) 2123 - { 2124 2116 if (ec_query_wq) { 2125 2117 destroy_workqueue(ec_query_wq); 2126 2118 ec_query_wq = NULL; 2127 2119 } 2120 + } 2121 + 2122 + static int acpi_ec_init_workqueues(void) 2123 + { 2124 + if (!ec_wq) 2125 + ec_wq = alloc_ordered_workqueue("kec", 0); 2126 + 2127 + if (!ec_query_wq) 2128 + ec_query_wq = alloc_workqueue("kec_query", 0, ec_max_queries); 2129 + 2130 + if (!ec_wq || !ec_query_wq) { 2131 + acpi_ec_destroy_workqueues(); 2132 + return -ENODEV; 2133 + } 2134 + return 0; 2128 2135 } 2129 2136 2130 2137 static const struct dmi_system_id acpi_ec_no_wakeup[] = { ··· 2165 2156 int result; 2166 2157 int ecdt_fail, dsdt_fail; 2167 2158 2168 - /* register workqueue for _Qxx evaluations */ 2169 - result = acpi_ec_query_init(); 2159 + result = acpi_ec_init_workqueues(); 2170 2160 if (result) 2171 2161 return result; 2172 2162 ··· 2196 2188 { 2197 2189 2198 2190 acpi_bus_unregister_driver(&acpi_ec_driver); 2199 - acpi_ec_query_exit(); 2191 + acpi_ec_destroy_workqueues(); 2200 2192 } 2201 2193 #endif /* 0 */
+37 -13
drivers/acpi/sleep.c
··· 990 990 acpi_os_wait_events_complete(); /* synchronize Notify handling */ 991 991 } 992 992 993 - static void acpi_s2idle_wake(void) 993 + static bool acpi_s2idle_wake(void) 994 994 { 995 - /* 996 - * If IRQD_WAKEUP_ARMED is set for the SCI at this point, the SCI has 997 - * not triggered while suspended, so bail out. 998 - */ 999 - if (!acpi_sci_irq_valid() || 1000 - irqd_is_wakeup_armed(irq_get_irq_data(acpi_sci_irq))) 1001 - return; 995 + if (!acpi_sci_irq_valid()) 996 + return pm_wakeup_pending(); 1002 997 1003 - /* 1004 - * If there are EC events to process, the wakeup may be a spurious one 1005 - * coming from the EC. 1006 - */ 1007 - if (acpi_ec_dispatch_gpe()) { 998 + while (pm_wakeup_pending()) { 999 + /* 1000 + * If IRQD_WAKEUP_ARMED is set for the SCI at this point, the 1001 + * SCI has not triggered while suspended, so bail out (the 1002 + * wakeup is pending anyway and the SCI is not the source of 1003 + * it). 1004 + */ 1005 + if (irqd_is_wakeup_armed(irq_get_irq_data(acpi_sci_irq))) 1006 + return true; 1007 + 1008 + /* 1009 + * If there are no EC events to process and at least one of the 1010 + * other enabled GPEs is active, the wakeup is regarded as a 1011 + * genuine one. 1012 + * 1013 + * Note that the checks below must be carried out in this order 1014 + * to avoid returning prematurely due to a change of the EC GPE 1015 + * status bit from unset to set between the checks with the 1016 + * status bits of all the other GPEs unset. 1017 + */ 1018 + if (acpi_any_gpe_status_set() && !acpi_ec_dispatch_gpe()) 1019 + return true; 1020 + 1008 1021 /* 1009 1022 * Cancel the wakeup and process all pending events in case 1010 1023 * there are any wakeup ones in there. ··· 1030 1017 1031 1018 acpi_s2idle_sync(); 1032 1019 1020 + /* 1021 + * The SCI is in the "suspended" state now and it cannot produce 1022 + * new wakeup events till the rearming below, so if any of them 1023 + * are pending here, they must be resulting from the processing 1024 + * of EC events above or coming from somewhere else. 1025 + */ 1026 + if (pm_wakeup_pending()) 1027 + return true; 1028 + 1033 1029 rearm_wake_irq(acpi_sci_irq); 1034 1030 } 1031 + 1032 + return false; 1035 1033 } 1036 1034 1037 1035 static void acpi_s2idle_restore_early(void)
+1 -1
drivers/bus/moxtet.c
··· 465 465 { 466 466 struct moxtet *moxtet = file->private_data; 467 467 u8 bin[TURRIS_MOX_MAX_MODULES]; 468 - u8 hex[sizeof(buf) * 2 + 1]; 468 + u8 hex[sizeof(bin) * 2 + 1]; 469 469 int ret, n; 470 470 471 471 ret = moxtet_spi_read(moxtet, bin);
+31 -2
drivers/char/ipmi/ipmb_dev_int.c
··· 19 19 #include <linux/spinlock.h> 20 20 #include <linux/wait.h> 21 21 22 - #define MAX_MSG_LEN 128 22 + #define MAX_MSG_LEN 240 23 23 #define IPMB_REQUEST_LEN_MIN 7 24 24 #define NETFN_RSP_BIT_MASK 0x4 25 25 #define REQUEST_QUEUE_MAX_LEN 256 ··· 63 63 spinlock_t lock; 64 64 wait_queue_head_t wait_queue; 65 65 struct mutex file_mutex; 66 + bool is_i2c_protocol; 66 67 }; 67 68 68 69 static inline struct ipmb_dev *to_ipmb_dev(struct file *file) ··· 113 112 return ret < 0 ? ret : count; 114 113 } 115 114 115 + static int ipmb_i2c_write(struct i2c_client *client, u8 *msg, u8 addr) 116 + { 117 + struct i2c_msg i2c_msg; 118 + 119 + /* 120 + * subtract 1 byte (rq_sa) from the length of the msg passed to 121 + * raw i2c_transfer 122 + */ 123 + i2c_msg.len = msg[IPMB_MSG_LEN_IDX] - 1; 124 + 125 + /* Assign message to buffer except first 2 bytes (length and address) */ 126 + i2c_msg.buf = msg + 2; 127 + 128 + i2c_msg.addr = addr; 129 + i2c_msg.flags = client->flags & I2C_CLIENT_PEC; 130 + 131 + return i2c_transfer(client->adapter, &i2c_msg, 1); 132 + } 133 + 116 134 static ssize_t ipmb_write(struct file *file, const char __user *buf, 117 135 size_t count, loff_t *ppos) 118 136 { ··· 152 132 153 133 rq_sa = GET_7BIT_ADDR(msg[RQ_SA_8BIT_IDX]); 154 134 netf_rq_lun = msg[NETFN_LUN_IDX]; 135 + 136 + /* Check i2c block transfer vs smbus */ 137 + if (ipmb_dev->is_i2c_protocol) { 138 + ret = ipmb_i2c_write(ipmb_dev->client, msg, rq_sa); 139 + return (ret == 1) ? count : ret; 140 + } 155 141 156 142 /* 157 143 * subtract rq_sa and netf_rq_lun from the length of the msg passed to ··· 279 253 break; 280 254 281 255 case I2C_SLAVE_WRITE_RECEIVED: 282 - if (ipmb_dev->msg_idx >= sizeof(struct ipmb_msg)) 256 + if (ipmb_dev->msg_idx >= sizeof(struct ipmb_msg) - 1) 283 257 break; 284 258 285 259 buf[++ipmb_dev->msg_idx] = *val; ··· 327 301 ret = misc_register(&ipmb_dev->miscdev); 328 302 if (ret) 329 303 return ret; 304 + 305 + ipmb_dev->is_i2c_protocol 306 + = device_property_read_bool(&client->dev, "i2c-protocol"); 330 307 331 308 ipmb_dev->client = client; 332 309 i2c_set_clientdata(client, ipmb_dev);
+7 -3
drivers/char/ipmi/ipmi_ssif.c
··· 775 775 flags = ipmi_ssif_lock_cond(ssif_info, &oflags); 776 776 msg = ssif_info->curr_msg; 777 777 if (msg) { 778 + if (data) { 779 + if (len > IPMI_MAX_MSG_LENGTH) 780 + len = IPMI_MAX_MSG_LENGTH; 781 + memcpy(msg->rsp, data, len); 782 + } else { 783 + len = 0; 784 + } 778 785 msg->rsp_size = len; 779 - if (msg->rsp_size > IPMI_MAX_MSG_LENGTH) 780 - msg->rsp_size = IPMI_MAX_MSG_LENGTH; 781 - memcpy(msg->rsp, data, msg->rsp_size); 782 786 ssif_info->curr_msg = NULL; 783 787 } 784 788
+2 -3
drivers/cpufreq/cpufreq.c
··· 105 105 } 106 106 EXPORT_SYMBOL_GPL(have_governor_per_policy); 107 107 108 + static struct kobject *cpufreq_global_kobject; 109 + 108 110 struct kobject *get_governor_parent_kobj(struct cpufreq_policy *policy) 109 111 { 110 112 if (have_governor_per_policy()) ··· 2746 2744 return 0; 2747 2745 } 2748 2746 EXPORT_SYMBOL_GPL(cpufreq_unregister_driver); 2749 - 2750 - struct kobject *cpufreq_global_kobject; 2751 - EXPORT_SYMBOL(cpufreq_global_kobject); 2752 2747 2753 2748 static int __init cpufreq_core_init(void) 2754 2749 {
+1 -1
drivers/dax/super.c
··· 61 61 { 62 62 if (!blk_queue_dax(bdev->bd_queue)) 63 63 return NULL; 64 - return fs_dax_get_by_host(bdev->bd_disk->disk_name); 64 + return dax_get_by_host(bdev->bd_disk->disk_name); 65 65 } 66 66 EXPORT_SYMBOL_GPL(fs_dax_get_by_bdev); 67 67 #endif
+3 -9
drivers/edac/edac_mc.c
··· 505 505 { 506 506 edac_dbg(1, "\n"); 507 507 508 - /* If we're not yet registered with sysfs free only what was allocated 509 - * in edac_mc_alloc(). 510 - */ 511 - if (!device_is_registered(&mci->dev)) { 512 - _edac_mc_free(mci); 513 - return; 514 - } 508 + if (device_is_registered(&mci->dev)) 509 + edac_unregister_sysfs(mci); 515 510 516 - /* the mci instance is freed here, when the sysfs object is dropped */ 517 - edac_unregister_sysfs(mci); 511 + _edac_mc_free(mci); 518 512 } 519 513 EXPORT_SYMBOL_GPL(edac_mc_free); 520 514
+4 -14
drivers/edac/edac_mc_sysfs.c
··· 276 276 277 277 static void csrow_attr_release(struct device *dev) 278 278 { 279 - struct csrow_info *csrow = container_of(dev, struct csrow_info, dev); 280 - 281 - edac_dbg(1, "device %s released\n", dev_name(dev)); 282 - kfree(csrow); 279 + /* release device with _edac_mc_free() */ 283 280 } 284 281 285 282 static const struct device_type csrow_attr_type = { ··· 444 447 csrow = mci->csrows[i]; 445 448 if (!nr_pages_per_csrow(csrow)) 446 449 continue; 447 - 448 - device_del(&mci->csrows[i]->dev); 450 + device_unregister(&mci->csrows[i]->dev); 449 451 } 450 452 451 453 return err; ··· 604 608 605 609 static void dimm_attr_release(struct device *dev) 606 610 { 607 - struct dimm_info *dimm = container_of(dev, struct dimm_info, dev); 608 - 609 - edac_dbg(1, "device %s released\n", dev_name(dev)); 610 - kfree(dimm); 611 + /* release device with _edac_mc_free() */ 611 612 } 612 613 613 614 static const struct device_type dimm_attr_type = { ··· 886 893 887 894 static void mci_attr_release(struct device *dev) 888 895 { 889 - struct mem_ctl_info *mci = container_of(dev, struct mem_ctl_info, dev); 890 - 891 - edac_dbg(1, "device %s released\n", dev_name(dev)); 892 - kfree(mci); 896 + /* release device with _edac_mc_free() */ 893 897 } 894 898 895 899 static const struct device_type mci_attr_type = {
-10
drivers/gpio/gpio-bd71828.c
··· 10 10 #define GPIO_OUT_REG(off) (BD71828_REG_GPIO_CTRL1 + (off)) 11 11 #define HALL_GPIO_OFFSET 3 12 12 13 - /* 14 - * These defines can be removed when 15 - * "gpio: Add definition for GPIO direction" 16 - * (9208b1e77d6e8e9776f34f46ef4079ecac9c3c25 in GPIO tree) gets merged, 17 - */ 18 - #ifndef GPIO_LINE_DIRECTION_IN 19 - #define GPIO_LINE_DIRECTION_IN 1 20 - #define GPIO_LINE_DIRECTION_OUT 0 21 - #endif 22 - 23 13 struct bd71828_gpio { 24 14 struct rohm_regmap_dev chip; 25 15 struct gpio_chip gpio;
+3 -3
drivers/gpio/gpio-sifive.c
··· 35 35 void __iomem *base; 36 36 struct gpio_chip gc; 37 37 struct regmap *regs; 38 - u32 irq_state; 38 + unsigned long irq_state; 39 39 unsigned int trigger[SIFIVE_GPIO_MAX]; 40 40 unsigned int irq_parent[SIFIVE_GPIO_MAX]; 41 41 }; ··· 94 94 spin_unlock_irqrestore(&gc->bgpio_lock, flags); 95 95 96 96 /* Enable interrupts */ 97 - assign_bit(offset, (unsigned long *)&chip->irq_state, 1); 97 + assign_bit(offset, &chip->irq_state, 1); 98 98 sifive_gpio_set_ie(chip, offset); 99 99 } 100 100 ··· 104 104 struct sifive_gpio *chip = gpiochip_get_data(gc); 105 105 int offset = irqd_to_hwirq(d) % SIFIVE_GPIO_MAX; 106 106 107 - assign_bit(offset, (unsigned long *)&chip->irq_state, 0); 107 + assign_bit(offset, &chip->irq_state, 0); 108 108 sifive_gpio_set_ie(chip, offset); 109 109 irq_chip_disable_parent(d); 110 110 }
+3 -2
drivers/gpio/gpio-xilinx.c
··· 147 147 for (i = 0; i < gc->ngpio; i++) { 148 148 if (*mask == 0) 149 149 break; 150 + /* Once finished with an index write it out to the register */ 150 151 if (index != xgpio_index(chip, i)) { 151 152 xgpio_writereg(chip->regs + XGPIO_DATA_OFFSET + 152 - xgpio_regoffset(chip, i), 153 + index * XGPIO_CHANNEL_OFFSET, 153 154 chip->gpio_state[index]); 154 155 spin_unlock_irqrestore(&chip->gpio_lock[index], flags); 155 156 index = xgpio_index(chip, i); ··· 166 165 } 167 166 168 167 xgpio_writereg(chip->regs + XGPIO_DATA_OFFSET + 169 - xgpio_regoffset(chip, i), chip->gpio_state[index]); 168 + index * XGPIO_CHANNEL_OFFSET, chip->gpio_state[index]); 170 169 171 170 spin_unlock_irqrestore(&chip->gpio_lock[index], flags); 172 171 }
+25 -5
drivers/gpio/gpiolib.c
··· 3035 3035 * rely on gpio_request() having been called beforehand. 3036 3036 */ 3037 3037 3038 - static int gpio_set_config(struct gpio_chip *gc, unsigned int offset, 3039 - enum pin_config_param mode) 3038 + static int gpio_do_set_config(struct gpio_chip *gc, unsigned int offset, 3039 + unsigned long config) 3040 3040 { 3041 3041 if (!gc->set_config) 3042 3042 return -ENOTSUPP; 3043 3043 3044 - return gc->set_config(gc, offset, mode); 3044 + return gc->set_config(gc, offset, config); 3045 + } 3046 + 3047 + static int gpio_set_config(struct gpio_chip *gc, unsigned int offset, 3048 + enum pin_config_param mode) 3049 + { 3050 + unsigned long config; 3051 + unsigned arg; 3052 + 3053 + switch (mode) { 3054 + case PIN_CONFIG_BIAS_PULL_DOWN: 3055 + case PIN_CONFIG_BIAS_PULL_UP: 3056 + arg = 1; 3057 + break; 3058 + 3059 + default: 3060 + arg = 0; 3061 + } 3062 + 3063 + config = PIN_CONF_PACKED(mode, arg); 3064 + return gpio_do_set_config(gc, offset, config); 3045 3065 } 3046 3066 3047 3067 static int gpio_set_bias(struct gpio_chip *chip, struct gpio_desc *desc) ··· 3297 3277 chip = desc->gdev->chip; 3298 3278 3299 3279 config = pinconf_to_config_packed(PIN_CONFIG_INPUT_DEBOUNCE, debounce); 3300 - return gpio_set_config(chip, gpio_chip_hwgpio(desc), config); 3280 + return gpio_do_set_config(chip, gpio_chip_hwgpio(desc), config); 3301 3281 } 3302 3282 EXPORT_SYMBOL_GPL(gpiod_set_debounce); 3303 3283 ··· 3331 3311 packed = pinconf_to_config_packed(PIN_CONFIG_PERSIST_STATE, 3332 3312 !transitory); 3333 3313 gpio = gpio_chip_hwgpio(desc); 3334 - rc = gpio_set_config(chip, gpio, packed); 3314 + rc = gpio_do_set_config(chip, gpio, packed); 3335 3315 if (rc == -ENOTSUPP) { 3336 3316 dev_dbg(&desc->gdev->dev, "Persistence not supported for GPIO %d\n", 3337 3317 gpio);
+8 -7
drivers/gpu/drm/amd/amdgpu/amdgpu_pmu.c
··· 52 52 return -ENOENT; 53 53 54 54 /* update the hw_perf_event struct with config data */ 55 - hwc->conf = event->attr.config; 55 + hwc->config = event->attr.config; 56 56 57 57 return 0; 58 58 } ··· 74 74 switch (pe->pmu_perf_type) { 75 75 case PERF_TYPE_AMDGPU_DF: 76 76 if (!(flags & PERF_EF_RELOAD)) 77 - pe->adev->df.funcs->pmc_start(pe->adev, hwc->conf, 1); 77 + pe->adev->df.funcs->pmc_start(pe->adev, hwc->config, 1); 78 78 79 - pe->adev->df.funcs->pmc_start(pe->adev, hwc->conf, 0); 79 + pe->adev->df.funcs->pmc_start(pe->adev, hwc->config, 0); 80 80 break; 81 81 default: 82 82 break; ··· 101 101 102 102 switch (pe->pmu_perf_type) { 103 103 case PERF_TYPE_AMDGPU_DF: 104 - pe->adev->df.funcs->pmc_get_count(pe->adev, hwc->conf, 104 + pe->adev->df.funcs->pmc_get_count(pe->adev, hwc->config, 105 105 &count); 106 106 break; 107 107 default: ··· 126 126 127 127 switch (pe->pmu_perf_type) { 128 128 case PERF_TYPE_AMDGPU_DF: 129 - pe->adev->df.funcs->pmc_stop(pe->adev, hwc->conf, 0); 129 + pe->adev->df.funcs->pmc_stop(pe->adev, hwc->config, 0); 130 130 break; 131 131 default: 132 132 break; ··· 156 156 157 157 switch (pe->pmu_perf_type) { 158 158 case PERF_TYPE_AMDGPU_DF: 159 - retval = pe->adev->df.funcs->pmc_start(pe->adev, hwc->conf, 1); 159 + retval = pe->adev->df.funcs->pmc_start(pe->adev, 160 + hwc->config, 1); 160 161 break; 161 162 default: 162 163 return 0; ··· 185 184 186 185 switch (pe->pmu_perf_type) { 187 186 case PERF_TYPE_AMDGPU_DF: 188 - pe->adev->df.funcs->pmc_stop(pe->adev, hwc->conf, 1); 187 + pe->adev->df.funcs->pmc_stop(pe->adev, hwc->config, 1); 189 188 break; 190 189 default: 191 190 break;
+1 -2
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h
··· 179 179 struct amdgpu_irq_src irq; 180 180 struct amdgpu_vcn_reg external; 181 181 struct amdgpu_bo *dpg_sram_bo; 182 + struct dpg_pause_state pause_state; 182 183 void *dpg_sram_cpu_addr; 183 184 uint64_t dpg_sram_gpu_addr; 184 185 uint32_t *dpg_sram_curr_addr; ··· 191 190 const struct firmware *fw; /* VCN firmware */ 192 191 unsigned num_enc_rings; 193 192 enum amd_powergating_state cur_state; 194 - struct dpg_pause_state pause_state; 195 - 196 193 bool indirect_sram; 197 194 198 195 uint8_t num_vcn_inst;
+11 -3
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
··· 4374 4374 struct amdgpu_device *adev = (struct amdgpu_device *)handle; 4375 4375 int r; 4376 4376 4377 - r = gfx_v9_0_do_edc_gds_workarounds(adev); 4378 - if (r) 4379 - return r; 4377 + /* 4378 + * Temp workaround to fix the issue that CP firmware fails to 4379 + * update read pointer when CPDMA is writing clearing operation 4380 + * to GDS in suspend/resume sequence on several cards. So just 4381 + * limit this operation in cold boot sequence. 4382 + */ 4383 + if (!adev->in_suspend) { 4384 + r = gfx_v9_0_do_edc_gds_workarounds(adev); 4385 + if (r) 4386 + return r; 4387 + } 4380 4388 4381 4389 /* requires IBs so do in late init after IB pool is initialized */ 4382 4390 r = gfx_v9_0_do_edc_gpr_workarounds(adev);
+8 -6
drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c
··· 1207 1207 struct amdgpu_ring *ring; 1208 1208 1209 1209 /* pause/unpause if state is changed */ 1210 - if (adev->vcn.pause_state.fw_based != new_state->fw_based) { 1210 + if (adev->vcn.inst[inst_idx].pause_state.fw_based != new_state->fw_based) { 1211 1211 DRM_DEBUG("dpg pause state changed %d:%d -> %d:%d", 1212 - adev->vcn.pause_state.fw_based, adev->vcn.pause_state.jpeg, 1212 + adev->vcn.inst[inst_idx].pause_state.fw_based, 1213 + adev->vcn.inst[inst_idx].pause_state.jpeg, 1213 1214 new_state->fw_based, new_state->jpeg); 1214 1215 1215 1216 reg_data = RREG32_SOC15(UVD, 0, mmUVD_DPG_PAUSE) & ··· 1259 1258 reg_data &= ~UVD_DPG_PAUSE__NJ_PAUSE_DPG_REQ_MASK; 1260 1259 WREG32_SOC15(UVD, 0, mmUVD_DPG_PAUSE, reg_data); 1261 1260 } 1262 - adev->vcn.pause_state.fw_based = new_state->fw_based; 1261 + adev->vcn.inst[inst_idx].pause_state.fw_based = new_state->fw_based; 1263 1262 } 1264 1263 1265 1264 /* pause/unpause if state is changed */ 1266 - if (adev->vcn.pause_state.jpeg != new_state->jpeg) { 1265 + if (adev->vcn.inst[inst_idx].pause_state.jpeg != new_state->jpeg) { 1267 1266 DRM_DEBUG("dpg pause state changed %d:%d -> %d:%d", 1268 - adev->vcn.pause_state.fw_based, adev->vcn.pause_state.jpeg, 1267 + adev->vcn.inst[inst_idx].pause_state.fw_based, 1268 + adev->vcn.inst[inst_idx].pause_state.jpeg, 1269 1269 new_state->fw_based, new_state->jpeg); 1270 1270 1271 1271 reg_data = RREG32_SOC15(UVD, 0, mmUVD_DPG_PAUSE) & ··· 1320 1318 reg_data &= ~UVD_DPG_PAUSE__JPEG_PAUSE_DPG_REQ_MASK; 1321 1319 WREG32_SOC15(UVD, 0, mmUVD_DPG_PAUSE, reg_data); 1322 1320 } 1323 - adev->vcn.pause_state.jpeg = new_state->jpeg; 1321 + adev->vcn.inst[inst_idx].pause_state.jpeg = new_state->jpeg; 1324 1322 } 1325 1323 1326 1324 return 0;
+3 -3
drivers/gpu/drm/amd/amdgpu/vcn_v2_0.c
··· 1137 1137 int ret_code; 1138 1138 1139 1139 /* pause/unpause if state is changed */ 1140 - if (adev->vcn.pause_state.fw_based != new_state->fw_based) { 1140 + if (adev->vcn.inst[inst_idx].pause_state.fw_based != new_state->fw_based) { 1141 1141 DRM_DEBUG("dpg pause state changed %d -> %d", 1142 - adev->vcn.pause_state.fw_based, new_state->fw_based); 1142 + adev->vcn.inst[inst_idx].pause_state.fw_based, new_state->fw_based); 1143 1143 reg_data = RREG32_SOC15(UVD, 0, mmUVD_DPG_PAUSE) & 1144 1144 (~UVD_DPG_PAUSE__NJ_PAUSE_DPG_ACK_MASK); 1145 1145 ··· 1185 1185 reg_data &= ~UVD_DPG_PAUSE__NJ_PAUSE_DPG_REQ_MASK; 1186 1186 WREG32_SOC15(UVD, 0, mmUVD_DPG_PAUSE, reg_data); 1187 1187 } 1188 - adev->vcn.pause_state.fw_based = new_state->fw_based; 1188 + adev->vcn.inst[inst_idx].pause_state.fw_based = new_state->fw_based; 1189 1189 } 1190 1190 1191 1191 return 0;
+4 -4
drivers/gpu/drm/amd/amdgpu/vcn_v2_5.c
··· 1367 1367 int ret_code; 1368 1368 1369 1369 /* pause/unpause if state is changed */ 1370 - if (adev->vcn.pause_state.fw_based != new_state->fw_based) { 1370 + if (adev->vcn.inst[inst_idx].pause_state.fw_based != new_state->fw_based) { 1371 1371 DRM_DEBUG("dpg pause state changed %d -> %d", 1372 - adev->vcn.pause_state.fw_based, new_state->fw_based); 1372 + adev->vcn.inst[inst_idx].pause_state.fw_based, new_state->fw_based); 1373 1373 reg_data = RREG32_SOC15(UVD, inst_idx, mmUVD_DPG_PAUSE) & 1374 1374 (~UVD_DPG_PAUSE__NJ_PAUSE_DPG_ACK_MASK); 1375 1375 ··· 1407 1407 RREG32_SOC15(UVD, inst_idx, mmUVD_SCRATCH2) & 0x7FFFFFFF); 1408 1408 1409 1409 SOC15_WAIT_ON_RREG(UVD, inst_idx, mmUVD_POWER_STATUS, 1410 - 0x0, UVD_POWER_STATUS__UVD_POWER_STATUS_MASK, ret_code); 1410 + UVD_PGFSM_CONFIG__UVDM_UVDU_PWR_ON, UVD_POWER_STATUS__UVD_POWER_STATUS_MASK, ret_code); 1411 1411 } 1412 1412 } else { 1413 1413 /* unpause dpg, no need to wait */ 1414 1414 reg_data &= ~UVD_DPG_PAUSE__NJ_PAUSE_DPG_REQ_MASK; 1415 1415 WREG32_SOC15(UVD, inst_idx, mmUVD_DPG_PAUSE, reg_data); 1416 1416 } 1417 - adev->vcn.pause_state.fw_based = new_state->fw_based; 1417 + adev->vcn.inst[inst_idx].pause_state.fw_based = new_state->fw_based; 1418 1418 } 1419 1419 1420 1420 return 0;
+3 -2
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
··· 8408 8408 /* Calculate number of static frames before generating interrupt to 8409 8409 * enter PSR. 8410 8410 */ 8411 - unsigned int frame_time_microsec = 1000000 / vsync_rate_hz; 8412 8411 // Init fail safe of 2 frames static 8413 8412 unsigned int num_frames_static = 2; 8414 8413 ··· 8422 8423 * Calculate number of frames such that at least 30 ms of time has 8423 8424 * passed. 8424 8425 */ 8425 - if (vsync_rate_hz != 0) 8426 + if (vsync_rate_hz != 0) { 8427 + unsigned int frame_time_microsec = 1000000 / vsync_rate_hz; 8426 8428 num_frames_static = (30000 / frame_time_microsec) + 1; 8429 + } 8427 8430 8428 8431 params.triggers.cursor_update = true; 8429 8432 params.triggers.overlay_update = true;
-4
drivers/gpu/drm/amd/display/dc/bios/command_table2.c
··· 711 711 power_gating.header.sub_type = DMUB_CMD__VBIOS_ENABLE_DISP_POWER_GATING; 712 712 power_gating.power_gating.pwr = *pwr; 713 713 714 - /* ATOM_ENABLE is old API in DMUB */ 715 - if (power_gating.power_gating.pwr.enable == ATOM_ENABLE) 716 - power_gating.power_gating.pwr.enable = ATOM_INIT; 717 - 718 714 dc_dmub_srv_cmd_queue(dmcub, &power_gating.header); 719 715 dc_dmub_srv_cmd_execute(dmcub); 720 716 dc_dmub_srv_wait_idle(dmcub);
+6
drivers/gpu/drm/amd/display/dc/clk_mgr/Makefile
··· 87 87 ############################################################################### 88 88 CLK_MGR_DCN21 = rn_clk_mgr.o rn_clk_mgr_vbios_smu.o 89 89 90 + # prevent build errors regarding soft-float vs hard-float FP ABI tags 91 + # this code is currently unused on ppc64, as it applies to Renoir APUs only 92 + ifdef CONFIG_PPC64 93 + CFLAGS_$(AMDDALPATH)/dc/clk_mgr/dcn21/rn_clk_mgr.o := $(call cc-option,-mno-gnu-attribute) 94 + endif 95 + 90 96 AMD_DAL_CLK_MGR_DCN21 = $(addprefix $(AMDDALPATH)/dc/clk_mgr/dcn21/,$(CLK_MGR_DCN21)) 91 97 92 98 AMD_DISPLAY_FILES += $(AMD_DAL_CLK_MGR_DCN21)
+1 -1
drivers/gpu/drm/amd/display/dc/clk_mgr/dcn20/dcn20_clk_mgr.c
··· 117 117 118 118 prev_dppclk_khz = clk_mgr->base.ctx->dc->current_state->res_ctx.pipe_ctx[i].plane_res.bw.dppclk_khz; 119 119 120 - if (safe_to_lower || prev_dppclk_khz < dppclk_khz) { 120 + if ((prev_dppclk_khz > dppclk_khz && safe_to_lower) || prev_dppclk_khz < dppclk_khz) { 121 121 clk_mgr->dccg->funcs->update_dpp_dto( 122 122 clk_mgr->dccg, dpp_inst, dppclk_khz); 123 123 }
+13 -7
drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr.c
··· 151 151 rn_vbios_smu_set_min_deep_sleep_dcfclk(clk_mgr, clk_mgr_base->clks.dcfclk_deep_sleep_khz); 152 152 } 153 153 154 + // workaround: Limit dppclk to 100Mhz to avoid lower eDP panel switch to plus 4K monitor underflow. 155 + if (!IS_DIAG_DC(dc->ctx->dce_environment)) { 156 + if (new_clocks->dppclk_khz < 100000) 157 + new_clocks->dppclk_khz = 100000; 158 + } 159 + 154 160 if (should_set_clock(safe_to_lower, new_clocks->dppclk_khz, clk_mgr->base.clks.dppclk_khz)) { 155 161 if (clk_mgr->base.clks.dppclk_khz > new_clocks->dppclk_khz) 156 162 dpp_clock_lowered = true; ··· 418 412 419 413 ranges->reader_wm_sets[num_valid_sets].wm_inst = bw_params->wm_table.entries[i].wm_inst; 420 414 ranges->reader_wm_sets[num_valid_sets].wm_type = bw_params->wm_table.entries[i].wm_type; 421 - /* We will not select WM based on dcfclk, so leave it as unconstrained */ 422 - ranges->reader_wm_sets[num_valid_sets].min_drain_clk_mhz = PP_SMU_WM_SET_RANGE_CLK_UNCONSTRAINED_MIN; 423 - ranges->reader_wm_sets[num_valid_sets].max_drain_clk_mhz = PP_SMU_WM_SET_RANGE_CLK_UNCONSTRAINED_MAX; 424 - /* fclk wil be used to select WM*/ 415 + /* We will not select WM based on fclk, so leave it as unconstrained */ 416 + ranges->reader_wm_sets[num_valid_sets].min_fill_clk_mhz = PP_SMU_WM_SET_RANGE_CLK_UNCONSTRAINED_MIN; 417 + ranges->reader_wm_sets[num_valid_sets].max_fill_clk_mhz = PP_SMU_WM_SET_RANGE_CLK_UNCONSTRAINED_MAX; 418 + /* dcfclk wil be used to select WM*/ 425 419 426 420 if (ranges->reader_wm_sets[num_valid_sets].wm_type == WM_TYPE_PSTATE_CHG) { 427 421 if (i == 0) 428 - ranges->reader_wm_sets[num_valid_sets].min_fill_clk_mhz = 0; 422 + ranges->reader_wm_sets[num_valid_sets].min_drain_clk_mhz = 0; 429 423 else { 430 424 /* add 1 to make it non-overlapping with next lvl */ 431 - ranges->reader_wm_sets[num_valid_sets].min_fill_clk_mhz = bw_params->clk_table.entries[i - 1].fclk_mhz + 1; 425 + ranges->reader_wm_sets[num_valid_sets].min_drain_clk_mhz = bw_params->clk_table.entries[i - 1].dcfclk_mhz + 1; 432 426 } 433 - ranges->reader_wm_sets[num_valid_sets].max_fill_clk_mhz = bw_params->clk_table.entries[i].fclk_mhz; 427 + ranges->reader_wm_sets[num_valid_sets].max_drain_clk_mhz = bw_params->clk_table.entries[i].dcfclk_mhz; 434 428 435 429 } else { 436 430 /* unconstrained for memory retraining */
+1 -1
drivers/gpu/drm/amd/display/dc/dce/dce_aux.c
··· 400 400 { 401 401 enum gpio_result result; 402 402 403 - if (!is_engine_available(engine)) 403 + if ((engine == NULL) || !is_engine_available(engine)) 404 404 return false; 405 405 406 406 result = dal_ddc_open(ddc, GPIO_MODE_HARDWARE,
-1
drivers/gpu/drm/amd/display/dc/dcn20/dcn20_hwseq.c
··· 572 572 dpp->funcs->dpp_dppclk_control(dpp, false, false); 573 573 574 574 hubp->power_gated = true; 575 - dc->optimized_required = false; /* We're powering off, no need to optimize */ 576 575 577 576 hws->funcs.plane_atomic_power_down(dc, 578 577 pipe_ctx->plane_res.dpp,
+6
drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c
··· 60 60 #include "dcn20/dcn20_dccg.h" 61 61 #include "dcn21_hubbub.h" 62 62 #include "dcn10/dcn10_resource.h" 63 + #include "dce110/dce110_resource.h" 63 64 64 65 #include "dcn20/dcn20_dwb.h" 65 66 #include "dcn20/dcn20_mmhubbub.h" ··· 857 856 enum dcn20_clk_src_array_id { 858 857 DCN20_CLK_SRC_PLL0, 859 858 DCN20_CLK_SRC_PLL1, 859 + DCN20_CLK_SRC_PLL2, 860 860 DCN20_CLK_SRC_TOTAL_DCN21 861 861 }; 862 862 ··· 1720 1718 dcn21_clock_source_create(ctx, ctx->dc_bios, 1721 1719 CLOCK_SOURCE_COMBO_PHY_PLL1, 1722 1720 &clk_src_regs[1], false); 1721 + pool->base.clock_sources[DCN20_CLK_SRC_PLL2] = 1722 + dcn21_clock_source_create(ctx, ctx->dc_bios, 1723 + CLOCK_SOURCE_COMBO_PHY_PLL2, 1724 + &clk_src_regs[2], false); 1723 1725 1724 1726 pool->base.clk_src_count = DCN20_CLK_SRC_TOTAL_DCN21; 1725 1727
+32 -14
drivers/gpu/drm/amd/powerplay/inc/smu_v11_0_pptable.h
··· 39 39 #define SMU_11_0_PP_OVERDRIVE_VERSION 0x0800 40 40 #define SMU_11_0_PP_POWERSAVINGCLOCK_VERSION 0x0100 41 41 42 + enum SMU_11_0_ODFEATURE_CAP { 43 + SMU_11_0_ODCAP_GFXCLK_LIMITS = 0, 44 + SMU_11_0_ODCAP_GFXCLK_CURVE, 45 + SMU_11_0_ODCAP_UCLK_MAX, 46 + SMU_11_0_ODCAP_POWER_LIMIT, 47 + SMU_11_0_ODCAP_FAN_ACOUSTIC_LIMIT, 48 + SMU_11_0_ODCAP_FAN_SPEED_MIN, 49 + SMU_11_0_ODCAP_TEMPERATURE_FAN, 50 + SMU_11_0_ODCAP_TEMPERATURE_SYSTEM, 51 + SMU_11_0_ODCAP_MEMORY_TIMING_TUNE, 52 + SMU_11_0_ODCAP_FAN_ZERO_RPM_CONTROL, 53 + SMU_11_0_ODCAP_AUTO_UV_ENGINE, 54 + SMU_11_0_ODCAP_AUTO_OC_ENGINE, 55 + SMU_11_0_ODCAP_AUTO_OC_MEMORY, 56 + SMU_11_0_ODCAP_FAN_CURVE, 57 + SMU_11_0_ODCAP_COUNT, 58 + }; 59 + 42 60 enum SMU_11_0_ODFEATURE_ID { 43 - SMU_11_0_ODFEATURE_GFXCLK_LIMITS = 1 << 0, //GFXCLK Limit feature 44 - SMU_11_0_ODFEATURE_GFXCLK_CURVE = 1 << 1, //GFXCLK Curve feature 45 - SMU_11_0_ODFEATURE_UCLK_MAX = 1 << 2, //UCLK Limit feature 46 - SMU_11_0_ODFEATURE_POWER_LIMIT = 1 << 3, //Power Limit feature 47 - SMU_11_0_ODFEATURE_FAN_ACOUSTIC_LIMIT = 1 << 4, //Fan Acoustic RPM feature 48 - SMU_11_0_ODFEATURE_FAN_SPEED_MIN = 1 << 5, //Minimum Fan Speed feature 49 - SMU_11_0_ODFEATURE_TEMPERATURE_FAN = 1 << 6, //Fan Target Temperature Limit feature 50 - SMU_11_0_ODFEATURE_TEMPERATURE_SYSTEM = 1 << 7, //Operating Temperature Limit feature 51 - SMU_11_0_ODFEATURE_MEMORY_TIMING_TUNE = 1 << 8, //AC Timing Tuning feature 52 - SMU_11_0_ODFEATURE_FAN_ZERO_RPM_CONTROL = 1 << 9, //Zero RPM feature 53 - SMU_11_0_ODFEATURE_AUTO_UV_ENGINE = 1 << 10, //Auto Under Volt GFXCLK feature 54 - SMU_11_0_ODFEATURE_AUTO_OC_ENGINE = 1 << 11, //Auto Over Clock GFXCLK feature 55 - SMU_11_0_ODFEATURE_AUTO_OC_MEMORY = 1 << 12, //Auto Over Clock MCLK feature 56 - SMU_11_0_ODFEATURE_FAN_CURVE = 1 << 13, //VICTOR TODO 61 + SMU_11_0_ODFEATURE_GFXCLK_LIMITS = 1 << SMU_11_0_ODCAP_GFXCLK_LIMITS, //GFXCLK Limit feature 62 + SMU_11_0_ODFEATURE_GFXCLK_CURVE = 1 << SMU_11_0_ODCAP_GFXCLK_CURVE, //GFXCLK Curve feature 63 + SMU_11_0_ODFEATURE_UCLK_MAX = 1 << SMU_11_0_ODCAP_UCLK_MAX, //UCLK Limit feature 64 + SMU_11_0_ODFEATURE_POWER_LIMIT = 1 << SMU_11_0_ODCAP_POWER_LIMIT, //Power Limit feature 65 + SMU_11_0_ODFEATURE_FAN_ACOUSTIC_LIMIT = 1 << SMU_11_0_ODCAP_FAN_ACOUSTIC_LIMIT, //Fan Acoustic RPM feature 66 + SMU_11_0_ODFEATURE_FAN_SPEED_MIN = 1 << SMU_11_0_ODCAP_FAN_SPEED_MIN, //Minimum Fan Speed feature 67 + SMU_11_0_ODFEATURE_TEMPERATURE_FAN = 1 << SMU_11_0_ODCAP_TEMPERATURE_FAN, //Fan Target Temperature Limit feature 68 + SMU_11_0_ODFEATURE_TEMPERATURE_SYSTEM = 1 << SMU_11_0_ODCAP_TEMPERATURE_SYSTEM, //Operating Temperature Limit feature 69 + SMU_11_0_ODFEATURE_MEMORY_TIMING_TUNE = 1 << SMU_11_0_ODCAP_MEMORY_TIMING_TUNE, //AC Timing Tuning feature 70 + SMU_11_0_ODFEATURE_FAN_ZERO_RPM_CONTROL = 1 << SMU_11_0_ODCAP_FAN_ZERO_RPM_CONTROL, //Zero RPM feature 71 + SMU_11_0_ODFEATURE_AUTO_UV_ENGINE = 1 << SMU_11_0_ODCAP_AUTO_UV_ENGINE, //Auto Under Volt GFXCLK feature 72 + SMU_11_0_ODFEATURE_AUTO_OC_ENGINE = 1 << SMU_11_0_ODCAP_AUTO_OC_ENGINE, //Auto Over Clock GFXCLK feature 73 + SMU_11_0_ODFEATURE_AUTO_OC_MEMORY = 1 << SMU_11_0_ODCAP_AUTO_OC_MEMORY, //Auto Over Clock MCLK feature 74 + SMU_11_0_ODFEATURE_FAN_CURVE = 1 << SMU_11_0_ODCAP_FAN_CURVE, //Fan Curve feature 57 75 SMU_11_0_ODFEATURE_COUNT = 14, 58 76 }; 59 77 #define SMU_11_0_MAX_ODFEATURE 32 //Maximum Number of OD Features
+11 -11
drivers/gpu/drm/amd/powerplay/navi10_ppt.c
··· 736 736 return dpm_desc->SnapToDiscrete == 0 ? true : false; 737 737 } 738 738 739 - static inline bool navi10_od_feature_is_supported(struct smu_11_0_overdrive_table *od_table, enum SMU_11_0_ODFEATURE_ID feature) 739 + static inline bool navi10_od_feature_is_supported(struct smu_11_0_overdrive_table *od_table, enum SMU_11_0_ODFEATURE_CAP cap) 740 740 { 741 - return od_table->cap[feature]; 741 + return od_table->cap[cap]; 742 742 } 743 743 744 744 static void navi10_od_setting_get_range(struct smu_11_0_overdrive_table *od_table, ··· 846 846 case SMU_OD_SCLK: 847 847 if (!smu->od_enabled || !od_table || !od_settings) 848 848 break; 849 - if (!navi10_od_feature_is_supported(od_settings, SMU_11_0_ODFEATURE_GFXCLK_LIMITS)) 849 + if (!navi10_od_feature_is_supported(od_settings, SMU_11_0_ODCAP_GFXCLK_LIMITS)) 850 850 break; 851 851 size += sprintf(buf + size, "OD_SCLK:\n"); 852 852 size += sprintf(buf + size, "0: %uMhz\n1: %uMhz\n", od_table->GfxclkFmin, od_table->GfxclkFmax); ··· 854 854 case SMU_OD_MCLK: 855 855 if (!smu->od_enabled || !od_table || !od_settings) 856 856 break; 857 - if (!navi10_od_feature_is_supported(od_settings, SMU_11_0_ODFEATURE_UCLK_MAX)) 857 + if (!navi10_od_feature_is_supported(od_settings, SMU_11_0_ODCAP_UCLK_MAX)) 858 858 break; 859 859 size += sprintf(buf + size, "OD_MCLK:\n"); 860 860 size += sprintf(buf + size, "1: %uMHz\n", od_table->UclkFmax); ··· 862 862 case SMU_OD_VDDC_CURVE: 863 863 if (!smu->od_enabled || !od_table || !od_settings) 864 864 break; 865 - if (!navi10_od_feature_is_supported(od_settings, SMU_11_0_ODFEATURE_GFXCLK_CURVE)) 865 + if (!navi10_od_feature_is_supported(od_settings, SMU_11_0_ODCAP_GFXCLK_CURVE)) 866 866 break; 867 867 size += sprintf(buf + size, "OD_VDDC_CURVE:\n"); 868 868 for (i = 0; i < 3; i++) { ··· 887 887 break; 888 888 size = sprintf(buf, "%s:\n", "OD_RANGE"); 889 889 890 - if (navi10_od_feature_is_supported(od_settings, SMU_11_0_ODFEATURE_GFXCLK_LIMITS)) { 890 + if (navi10_od_feature_is_supported(od_settings, SMU_11_0_ODCAP_GFXCLK_LIMITS)) { 891 891 navi10_od_setting_get_range(od_settings, SMU_11_0_ODSETTING_GFXCLKFMIN, 892 892 &min_value, NULL); 893 893 navi10_od_setting_get_range(od_settings, SMU_11_0_ODSETTING_GFXCLKFMAX, ··· 896 896 min_value, max_value); 897 897 } 898 898 899 - if (navi10_od_feature_is_supported(od_settings, SMU_11_0_ODFEATURE_UCLK_MAX)) { 899 + if (navi10_od_feature_is_supported(od_settings, SMU_11_0_ODCAP_UCLK_MAX)) { 900 900 navi10_od_setting_get_range(od_settings, SMU_11_0_ODSETTING_UCLKFMAX, 901 901 &min_value, &max_value); 902 902 size += sprintf(buf + size, "MCLK: %7uMhz %10uMhz\n", 903 903 min_value, max_value); 904 904 } 905 905 906 - if (navi10_od_feature_is_supported(od_settings, SMU_11_0_ODFEATURE_GFXCLK_CURVE)) { 906 + if (navi10_od_feature_is_supported(od_settings, SMU_11_0_ODCAP_GFXCLK_CURVE)) { 907 907 navi10_od_setting_get_range(od_settings, SMU_11_0_ODSETTING_VDDGFXCURVEFREQ_P1, 908 908 &min_value, &max_value); 909 909 size += sprintf(buf + size, "VDDC_CURVE_SCLK[0]: %7uMhz %10uMhz\n", ··· 2056 2056 2057 2057 switch (type) { 2058 2058 case PP_OD_EDIT_SCLK_VDDC_TABLE: 2059 - if (!navi10_od_feature_is_supported(od_settings, SMU_11_0_ODFEATURE_GFXCLK_LIMITS)) { 2059 + if (!navi10_od_feature_is_supported(od_settings, SMU_11_0_ODCAP_GFXCLK_LIMITS)) { 2060 2060 pr_warn("GFXCLK_LIMITS not supported!\n"); 2061 2061 return -ENOTSUPP; 2062 2062 } ··· 2102 2102 } 2103 2103 break; 2104 2104 case PP_OD_EDIT_MCLK_VDDC_TABLE: 2105 - if (!navi10_od_feature_is_supported(od_settings, SMU_11_0_ODFEATURE_UCLK_MAX)) { 2105 + if (!navi10_od_feature_is_supported(od_settings, SMU_11_0_ODCAP_UCLK_MAX)) { 2106 2106 pr_warn("UCLK_MAX not supported!\n"); 2107 2107 return -ENOTSUPP; 2108 2108 } ··· 2143 2143 } 2144 2144 break; 2145 2145 case PP_OD_EDIT_VDDC_CURVE: 2146 - if (!navi10_od_feature_is_supported(od_settings, SMU_11_0_ODFEATURE_GFXCLK_CURVE)) { 2146 + if (!navi10_od_feature_is_supported(od_settings, SMU_11_0_ODCAP_GFXCLK_CURVE)) { 2147 2147 pr_warn("GFXCLK_CURVE not supported!\n"); 2148 2148 return -ENOTSUPP; 2149 2149 }
+2 -1
drivers/gpu/drm/drm_dp_mst_topology.c
··· 3838 3838 else if (msg->req_type == DP_RESOURCE_STATUS_NOTIFY) 3839 3839 guid = msg->u.resource_stat.guid; 3840 3840 3841 - mstb = drm_dp_get_mst_branch_device_by_guid(mgr, guid); 3841 + if (guid) 3842 + mstb = drm_dp_get_mst_branch_device_by_guid(mgr, guid); 3842 3843 } else { 3843 3844 mstb = drm_dp_get_mst_branch_device(mgr, hdr->lct, hdr->rad); 3844 3845 }
+1 -1
drivers/gpu/drm/drm_edid.c
··· 3211 3211 return cea; 3212 3212 } 3213 3213 3214 - static const struct drm_display_mode *cea_mode_for_vic(u8 vic) 3214 + static __always_inline const struct drm_display_mode *cea_mode_for_vic(u8 vic) 3215 3215 { 3216 3216 BUILD_BUG_ON(1 + ARRAY_SIZE(edid_cea_modes_1) - 1 != 127); 3217 3217 BUILD_BUG_ON(193 + ARRAY_SIZE(edid_cea_modes_193) - 1 != 219);
+4 -2
drivers/gpu/drm/i915/display/intel_bios.c
··· 357 357 panel_fixed_mode->hdisplay + dtd->hfront_porch; 358 358 panel_fixed_mode->hsync_end = 359 359 panel_fixed_mode->hsync_start + dtd->hsync; 360 - panel_fixed_mode->htotal = panel_fixed_mode->hsync_end; 360 + panel_fixed_mode->htotal = 361 + panel_fixed_mode->hdisplay + dtd->hblank; 361 362 362 363 panel_fixed_mode->vdisplay = dtd->vactive; 363 364 panel_fixed_mode->vsync_start = 364 365 panel_fixed_mode->vdisplay + dtd->vfront_porch; 365 366 panel_fixed_mode->vsync_end = 366 367 panel_fixed_mode->vsync_start + dtd->vsync; 367 - panel_fixed_mode->vtotal = panel_fixed_mode->vsync_end; 368 + panel_fixed_mode->vtotal = 369 + panel_fixed_mode->vdisplay + dtd->vblank; 368 370 369 371 panel_fixed_mode->clock = dtd->pixel_clock; 370 372 panel_fixed_mode->width_mm = dtd->width_mm;
+18 -26
drivers/gpu/drm/i915/display/intel_display.c
··· 12366 12366 /* Copy parameters to slave plane */ 12367 12367 linked_state->ctl = plane_state->ctl | PLANE_CTL_YUV420_Y_PLANE; 12368 12368 linked_state->color_ctl = plane_state->color_ctl; 12369 + linked_state->view = plane_state->view; 12369 12370 memcpy(linked_state->color_plane, plane_state->color_plane, 12370 12371 sizeof(linked_state->color_plane)); 12371 12372 ··· 14477 14476 return 0; 14478 14477 } 14479 14478 14480 - static bool intel_cpu_transcoder_needs_modeset(struct intel_atomic_state *state, 14481 - enum transcoder transcoder) 14479 + static bool intel_cpu_transcoders_need_modeset(struct intel_atomic_state *state, 14480 + u8 transcoders) 14482 14481 { 14483 - struct intel_crtc_state *new_crtc_state; 14482 + const struct intel_crtc_state *new_crtc_state; 14484 14483 struct intel_crtc *crtc; 14485 14484 int i; 14486 14485 14487 - for_each_new_intel_crtc_in_state(state, crtc, new_crtc_state, i) 14488 - if (new_crtc_state->cpu_transcoder == transcoder) 14489 - return needs_modeset(new_crtc_state); 14486 + for_each_new_intel_crtc_in_state(state, crtc, new_crtc_state, i) { 14487 + if (new_crtc_state->hw.enable && 14488 + transcoders & BIT(new_crtc_state->cpu_transcoder) && 14489 + needs_modeset(new_crtc_state)) 14490 + return true; 14491 + } 14490 14492 14491 14493 return false; 14492 - } 14493 - 14494 - static void 14495 - intel_modeset_synced_crtcs(struct intel_atomic_state *state, 14496 - u8 transcoders) 14497 - { 14498 - struct intel_crtc_state *new_crtc_state; 14499 - struct intel_crtc *crtc; 14500 - int i; 14501 - 14502 - for_each_new_intel_crtc_in_state(state, crtc, 14503 - new_crtc_state, i) { 14504 - if (transcoders & BIT(new_crtc_state->cpu_transcoder)) { 14505 - new_crtc_state->uapi.mode_changed = true; 14506 - new_crtc_state->update_pipe = false; 14507 - } 14508 - } 14509 14494 } 14510 14495 14511 14496 static int ··· 14649 14662 if (intel_dp_mst_is_slave_trans(new_crtc_state)) { 14650 14663 enum transcoder master = new_crtc_state->mst_master_transcoder; 14651 14664 14652 - if (intel_cpu_transcoder_needs_modeset(state, master)) { 14665 + if (intel_cpu_transcoders_need_modeset(state, BIT(master))) { 14653 14666 new_crtc_state->uapi.mode_changed = true; 14654 14667 new_crtc_state->update_pipe = false; 14655 14668 } 14656 - } else if (is_trans_port_sync_mode(new_crtc_state)) { 14669 + } 14670 + 14671 + if (is_trans_port_sync_mode(new_crtc_state)) { 14657 14672 u8 trans = new_crtc_state->sync_mode_slaves_mask | 14658 14673 BIT(new_crtc_state->master_transcoder); 14659 14674 14660 - intel_modeset_synced_crtcs(state, trans); 14675 + if (intel_cpu_transcoders_need_modeset(state, trans)) { 14676 + new_crtc_state->uapi.mode_changed = true; 14677 + new_crtc_state->update_pipe = false; 14678 + } 14661 14679 } 14662 14680 } 14663 14681
+33 -19
drivers/gpu/drm/i915/display/intel_dsi_vbt.c
··· 384 384 return data; 385 385 } 386 386 387 + #ifdef CONFIG_ACPI 387 388 static int i2c_adapter_lookup(struct acpi_resource *ares, void *data) 388 389 { 389 390 struct i2c_adapter_lookup *lookup = data; ··· 394 393 acpi_handle adapter_handle; 395 394 acpi_status status; 396 395 397 - if (intel_dsi->i2c_bus_num >= 0 || 398 - !i2c_acpi_get_i2c_resource(ares, &sb)) 396 + if (!i2c_acpi_get_i2c_resource(ares, &sb)) 399 397 return 1; 400 398 401 399 if (lookup->slave_addr != sb->slave_address) ··· 413 413 return 1; 414 414 } 415 415 416 + static void i2c_acpi_find_adapter(struct intel_dsi *intel_dsi, 417 + const u16 slave_addr) 418 + { 419 + struct drm_device *drm_dev = intel_dsi->base.base.dev; 420 + struct device *dev = &drm_dev->pdev->dev; 421 + struct acpi_device *acpi_dev; 422 + struct list_head resource_list; 423 + struct i2c_adapter_lookup lookup; 424 + 425 + acpi_dev = ACPI_COMPANION(dev); 426 + if (acpi_dev) { 427 + memset(&lookup, 0, sizeof(lookup)); 428 + lookup.slave_addr = slave_addr; 429 + lookup.intel_dsi = intel_dsi; 430 + lookup.dev_handle = acpi_device_handle(acpi_dev); 431 + 432 + INIT_LIST_HEAD(&resource_list); 433 + acpi_dev_get_resources(acpi_dev, &resource_list, 434 + i2c_adapter_lookup, 435 + &lookup); 436 + acpi_dev_free_resource_list(&resource_list); 437 + } 438 + } 439 + #else 440 + static inline void i2c_acpi_find_adapter(struct intel_dsi *intel_dsi, 441 + const u16 slave_addr) 442 + { 443 + } 444 + #endif 445 + 416 446 static const u8 *mipi_exec_i2c(struct intel_dsi *intel_dsi, const u8 *data) 417 447 { 418 448 struct drm_device *drm_dev = intel_dsi->base.base.dev; 419 449 struct device *dev = &drm_dev->pdev->dev; 420 450 struct i2c_adapter *adapter; 421 - struct acpi_device *acpi_dev; 422 - struct list_head resource_list; 423 - struct i2c_adapter_lookup lookup; 424 451 struct i2c_msg msg; 425 452 int ret; 426 453 u8 vbt_i2c_bus_num = *(data + 2); ··· 458 431 459 432 if (intel_dsi->i2c_bus_num < 0) { 460 433 intel_dsi->i2c_bus_num = vbt_i2c_bus_num; 461 - 462 - acpi_dev = ACPI_COMPANION(dev); 463 - if (acpi_dev) { 464 - memset(&lookup, 0, sizeof(lookup)); 465 - lookup.slave_addr = slave_addr; 466 - lookup.intel_dsi = intel_dsi; 467 - lookup.dev_handle = acpi_device_handle(acpi_dev); 468 - 469 - INIT_LIST_HEAD(&resource_list); 470 - acpi_dev_get_resources(acpi_dev, &resource_list, 471 - i2c_adapter_lookup, 472 - &lookup); 473 - acpi_dev_free_resource_list(&resource_list); 474 - } 434 + i2c_acpi_find_adapter(intel_dsi, slave_addr); 475 435 } 476 436 477 437 adapter = i2c_get_adapter(intel_dsi->i2c_bus_num);
+36 -1
drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
··· 1981 1981 pw->trampoline); 1982 1982 } 1983 1983 1984 + static void __eb_parse_release(struct dma_fence_work *work) 1985 + { 1986 + struct eb_parse_work *pw = container_of(work, typeof(*pw), base); 1987 + 1988 + if (pw->trampoline) 1989 + i915_active_release(&pw->trampoline->active); 1990 + i915_active_release(&pw->shadow->active); 1991 + i915_active_release(&pw->batch->active); 1992 + } 1993 + 1984 1994 static const struct dma_fence_work_ops eb_parse_ops = { 1985 1995 .name = "eb_parse", 1986 1996 .work = __eb_parse, 1997 + .release = __eb_parse_release, 1987 1998 }; 1988 1999 1989 2000 static int eb_parse_pipeline(struct i915_execbuffer *eb, ··· 2008 1997 if (!pw) 2009 1998 return -ENOMEM; 2010 1999 2000 + err = i915_active_acquire(&eb->batch->active); 2001 + if (err) 2002 + goto err_free; 2003 + 2004 + err = i915_active_acquire(&shadow->active); 2005 + if (err) 2006 + goto err_batch; 2007 + 2008 + if (trampoline) { 2009 + err = i915_active_acquire(&trampoline->active); 2010 + if (err) 2011 + goto err_shadow; 2012 + } 2013 + 2011 2014 dma_fence_work_init(&pw->base, &eb_parse_ops); 2012 2015 2013 2016 pw->engine = eb->engine; ··· 2031 2006 pw->shadow = shadow; 2032 2007 pw->trampoline = trampoline; 2033 2008 2034 - dma_resv_lock(pw->batch->resv, NULL); 2009 + err = dma_resv_lock_interruptible(pw->batch->resv, NULL); 2010 + if (err) 2011 + goto err_trampoline; 2035 2012 2036 2013 err = dma_resv_reserve_shared(pw->batch->resv, 1); 2037 2014 if (err) ··· 2061 2034 2062 2035 err_batch_unlock: 2063 2036 dma_resv_unlock(pw->batch->resv); 2037 + err_trampoline: 2038 + if (trampoline) 2039 + i915_active_release(&trampoline->active); 2040 + err_shadow: 2041 + i915_active_release(&shadow->active); 2042 + err_batch: 2043 + i915_active_release(&eb->batch->active); 2044 + err_free: 2064 2045 kfree(pw); 2065 2046 return err; 2066 2047 }
+87 -42
drivers/gpu/drm/i915/gem/i915_gem_mman.c
··· 455 455 456 456 void i915_gem_object_release_mmap_offset(struct drm_i915_gem_object *obj) 457 457 { 458 - struct i915_mmap_offset *mmo; 458 + struct i915_mmap_offset *mmo, *mn; 459 459 460 460 spin_lock(&obj->mmo.lock); 461 - list_for_each_entry(mmo, &obj->mmo.offsets, offset) { 461 + rbtree_postorder_for_each_entry_safe(mmo, mn, 462 + &obj->mmo.offsets, offset) { 462 463 /* 463 464 * vma_node_unmap for GTT mmaps handled already in 464 465 * __i915_gem_object_release_mmap_gtt ··· 489 488 } 490 489 491 490 static struct i915_mmap_offset * 491 + lookup_mmo(struct drm_i915_gem_object *obj, 492 + enum i915_mmap_type mmap_type) 493 + { 494 + struct rb_node *rb; 495 + 496 + spin_lock(&obj->mmo.lock); 497 + rb = obj->mmo.offsets.rb_node; 498 + while (rb) { 499 + struct i915_mmap_offset *mmo = 500 + rb_entry(rb, typeof(*mmo), offset); 501 + 502 + if (mmo->mmap_type == mmap_type) { 503 + spin_unlock(&obj->mmo.lock); 504 + return mmo; 505 + } 506 + 507 + if (mmo->mmap_type < mmap_type) 508 + rb = rb->rb_right; 509 + else 510 + rb = rb->rb_left; 511 + } 512 + spin_unlock(&obj->mmo.lock); 513 + 514 + return NULL; 515 + } 516 + 517 + static struct i915_mmap_offset * 518 + insert_mmo(struct drm_i915_gem_object *obj, struct i915_mmap_offset *mmo) 519 + { 520 + struct rb_node *rb, **p; 521 + 522 + spin_lock(&obj->mmo.lock); 523 + rb = NULL; 524 + p = &obj->mmo.offsets.rb_node; 525 + while (*p) { 526 + struct i915_mmap_offset *pos; 527 + 528 + rb = *p; 529 + pos = rb_entry(rb, typeof(*pos), offset); 530 + 531 + if (pos->mmap_type == mmo->mmap_type) { 532 + spin_unlock(&obj->mmo.lock); 533 + drm_vma_offset_remove(obj->base.dev->vma_offset_manager, 534 + &mmo->vma_node); 535 + kfree(mmo); 536 + return pos; 537 + } 538 + 539 + if (pos->mmap_type < mmo->mmap_type) 540 + p = &rb->rb_right; 541 + else 542 + p = &rb->rb_left; 543 + } 544 + rb_link_node(&mmo->offset, rb, p); 545 + rb_insert_color(&mmo->offset, &obj->mmo.offsets); 546 + spin_unlock(&obj->mmo.lock); 547 + 548 + return mmo; 549 + } 550 + 551 + static struct i915_mmap_offset * 492 552 mmap_offset_attach(struct drm_i915_gem_object *obj, 493 553 enum i915_mmap_type mmap_type, 494 554 struct drm_file *file) ··· 558 496 struct i915_mmap_offset *mmo; 559 497 int err; 560 498 499 + mmo = lookup_mmo(obj, mmap_type); 500 + if (mmo) 501 + goto out; 502 + 561 503 mmo = kmalloc(sizeof(*mmo), GFP_KERNEL); 562 504 if (!mmo) 563 505 return ERR_PTR(-ENOMEM); 564 506 565 507 mmo->obj = obj; 566 - mmo->dev = obj->base.dev; 567 - mmo->file = file; 568 508 mmo->mmap_type = mmap_type; 569 509 drm_vma_node_reset(&mmo->vma_node); 570 510 571 - err = drm_vma_offset_add(mmo->dev->vma_offset_manager, &mmo->vma_node, 572 - obj->base.size / PAGE_SIZE); 511 + err = drm_vma_offset_add(obj->base.dev->vma_offset_manager, 512 + &mmo->vma_node, obj->base.size / PAGE_SIZE); 573 513 if (likely(!err)) 574 - goto out; 514 + goto insert; 575 515 576 516 /* Attempt to reap some mmap space from dead objects */ 577 517 err = intel_gt_retire_requests_timeout(&i915->gt, MAX_SCHEDULE_TIMEOUT); ··· 581 517 goto err; 582 518 583 519 i915_gem_drain_freed_objects(i915); 584 - err = drm_vma_offset_add(mmo->dev->vma_offset_manager, &mmo->vma_node, 585 - obj->base.size / PAGE_SIZE); 520 + err = drm_vma_offset_add(obj->base.dev->vma_offset_manager, 521 + &mmo->vma_node, obj->base.size / PAGE_SIZE); 586 522 if (err) 587 523 goto err; 588 524 525 + insert: 526 + mmo = insert_mmo(obj, mmo); 527 + GEM_BUG_ON(lookup_mmo(obj, mmap_type) != mmo); 589 528 out: 590 529 if (file) 591 530 drm_vma_node_allow(&mmo->vma_node, file); 592 - 593 - spin_lock(&obj->mmo.lock); 594 - list_add(&mmo->offset, &obj->mmo.offsets); 595 - spin_unlock(&obj->mmo.lock); 596 - 597 531 return mmo; 598 532 599 533 err: ··· 807 745 struct drm_vma_offset_node *node; 808 746 struct drm_file *priv = filp->private_data; 809 747 struct drm_device *dev = priv->minor->dev; 748 + struct drm_i915_gem_object *obj = NULL; 810 749 struct i915_mmap_offset *mmo = NULL; 811 - struct drm_gem_object *obj = NULL; 812 750 struct file *anon; 813 751 814 752 if (drm_dev_is_unplugged(dev)) 815 753 return -ENODEV; 816 754 755 + rcu_read_lock(); 817 756 drm_vma_offset_lock_lookup(dev->vma_offset_manager); 818 757 node = drm_vma_offset_exact_lookup_locked(dev->vma_offset_manager, 819 758 vma->vm_pgoff, 820 759 vma_pages(vma)); 821 - if (likely(node)) { 822 - mmo = container_of(node, struct i915_mmap_offset, 823 - vma_node); 824 - /* 825 - * In our dependency chain, the drm_vma_offset_node 826 - * depends on the validity of the mmo, which depends on 827 - * the gem object. However the only reference we have 828 - * at this point is the mmo (as the parent of the node). 829 - * Try to check if the gem object was at least cleared. 830 - */ 831 - if (!mmo || !mmo->obj) { 832 - drm_vma_offset_unlock_lookup(dev->vma_offset_manager); 833 - return -EINVAL; 834 - } 760 + if (node && drm_vma_node_is_allowed(node, priv)) { 835 761 /* 836 762 * Skip 0-refcnted objects as it is in the process of being 837 763 * destroyed and will be invalid when the vma manager lock 838 764 * is released. 839 765 */ 840 - obj = &mmo->obj->base; 841 - if (!kref_get_unless_zero(&obj->refcount)) 842 - obj = NULL; 766 + mmo = container_of(node, struct i915_mmap_offset, vma_node); 767 + obj = i915_gem_object_get_rcu(mmo->obj); 843 768 } 844 769 drm_vma_offset_unlock_lookup(dev->vma_offset_manager); 770 + rcu_read_unlock(); 845 771 if (!obj) 846 - return -EINVAL; 772 + return node ? -EACCES : -EINVAL; 847 773 848 - if (!drm_vma_node_is_allowed(node, priv)) { 849 - drm_gem_object_put_unlocked(obj); 850 - return -EACCES; 851 - } 852 - 853 - if (i915_gem_object_is_readonly(to_intel_bo(obj))) { 774 + if (i915_gem_object_is_readonly(obj)) { 854 775 if (vma->vm_flags & VM_WRITE) { 855 - drm_gem_object_put_unlocked(obj); 776 + i915_gem_object_put(obj); 856 777 return -EINVAL; 857 778 } 858 779 vma->vm_flags &= ~VM_MAYWRITE; 859 780 } 860 781 861 - anon = mmap_singleton(to_i915(obj->dev)); 782 + anon = mmap_singleton(to_i915(dev)); 862 783 if (IS_ERR(anon)) { 863 - drm_gem_object_put_unlocked(obj); 784 + i915_gem_object_put(obj); 864 785 return PTR_ERR(anon); 865 786 } 866 787
+7 -11
drivers/gpu/drm/i915/gem/i915_gem_object.c
··· 63 63 INIT_LIST_HEAD(&obj->lut_list); 64 64 65 65 spin_lock_init(&obj->mmo.lock); 66 - INIT_LIST_HEAD(&obj->mmo.offsets); 66 + obj->mmo.offsets = RB_ROOT; 67 67 68 68 init_rcu_head(&obj->rcu); 69 69 ··· 100 100 { 101 101 struct drm_i915_gem_object *obj = to_intel_bo(gem); 102 102 struct drm_i915_file_private *fpriv = file->driver_priv; 103 + struct i915_mmap_offset *mmo, *mn; 103 104 struct i915_lut_handle *lut, *ln; 104 - struct i915_mmap_offset *mmo; 105 105 LIST_HEAD(close); 106 106 107 107 i915_gem_object_lock(obj); ··· 117 117 i915_gem_object_unlock(obj); 118 118 119 119 spin_lock(&obj->mmo.lock); 120 - list_for_each_entry(mmo, &obj->mmo.offsets, offset) { 121 - if (mmo->file != file) 122 - continue; 123 - 124 - spin_unlock(&obj->mmo.lock); 120 + rbtree_postorder_for_each_entry_safe(mmo, mn, &obj->mmo.offsets, offset) 125 121 drm_vma_node_revoke(&mmo->vma_node, file); 126 - spin_lock(&obj->mmo.lock); 127 - } 128 122 spin_unlock(&obj->mmo.lock); 129 123 130 124 list_for_each_entry_safe(lut, ln, &close, obj_link) { ··· 197 203 198 204 i915_gem_object_release_mmap(obj); 199 205 200 - list_for_each_entry_safe(mmo, mn, &obj->mmo.offsets, offset) { 206 + rbtree_postorder_for_each_entry_safe(mmo, mn, 207 + &obj->mmo.offsets, 208 + offset) { 201 209 drm_vma_offset_remove(obj->base.dev->vma_offset_manager, 202 210 &mmo->vma_node); 203 211 kfree(mmo); 204 212 } 205 - INIT_LIST_HEAD(&obj->mmo.offsets); 213 + obj->mmo.offsets = RB_ROOT; 206 214 207 215 GEM_BUG_ON(atomic_read(&obj->bind_count)); 208 216 GEM_BUG_ON(obj->userfault_count);
+10 -2
drivers/gpu/drm/i915/gem/i915_gem_object.h
··· 70 70 } 71 71 72 72 static inline struct drm_i915_gem_object * 73 + i915_gem_object_get_rcu(struct drm_i915_gem_object *obj) 74 + { 75 + if (obj && !kref_get_unless_zero(&obj->base.refcount)) 76 + obj = NULL; 77 + 78 + return obj; 79 + } 80 + 81 + static inline struct drm_i915_gem_object * 73 82 i915_gem_object_lookup(struct drm_file *file, u32 handle) 74 83 { 75 84 struct drm_i915_gem_object *obj; 76 85 77 86 rcu_read_lock(); 78 87 obj = i915_gem_object_lookup_rcu(file, handle); 79 - if (obj && !kref_get_unless_zero(&obj->base.refcount)) 80 - obj = NULL; 88 + obj = i915_gem_object_get_rcu(obj); 81 89 rcu_read_unlock(); 82 90 83 91 return obj;
+2 -4
drivers/gpu/drm/i915/gem/i915_gem_object_types.h
··· 71 71 }; 72 72 73 73 struct i915_mmap_offset { 74 - struct drm_device *dev; 75 74 struct drm_vma_offset_node vma_node; 76 75 struct drm_i915_gem_object *obj; 77 - struct drm_file *file; 78 76 enum i915_mmap_type mmap_type; 79 77 80 - struct list_head offset; 78 + struct rb_node offset; 81 79 }; 82 80 83 81 struct drm_i915_gem_object { ··· 135 137 136 138 struct { 137 139 spinlock_t lock; /* Protects access to mmo offsets */ 138 - struct list_head offsets; 140 + struct rb_root offsets; 139 141 } mmo; 140 142 141 143 I915_SELFTEST_DECLARE(struct list_head st_link);
+25 -21
drivers/gpu/drm/i915/gt/intel_context.c
··· 67 67 { 68 68 int err; 69 69 70 - err = i915_active_acquire(&ce->active); 71 - if (err) 72 - return err; 70 + __i915_active_acquire(&ce->active); 71 + 72 + if (intel_context_is_barrier(ce)) 73 + return 0; 73 74 74 75 /* Preallocate tracking nodes */ 75 - if (!intel_context_is_barrier(ce)) { 76 - err = i915_active_acquire_preallocate_barrier(&ce->active, 77 - ce->engine); 78 - if (err) { 79 - i915_active_release(&ce->active); 80 - return err; 81 - } 82 - } 76 + err = i915_active_acquire_preallocate_barrier(&ce->active, 77 + ce->engine); 78 + if (err) 79 + i915_active_release(&ce->active); 83 80 84 - return 0; 81 + return err; 85 82 } 86 83 87 84 static void intel_context_active_release(struct intel_context *ce) ··· 98 101 return err; 99 102 } 100 103 101 - if (mutex_lock_interruptible(&ce->pin_mutex)) 102 - return -EINTR; 104 + err = i915_active_acquire(&ce->active); 105 + if (err) 106 + return err; 103 107 104 - if (likely(!atomic_read(&ce->pin_count))) { 108 + if (mutex_lock_interruptible(&ce->pin_mutex)) { 109 + err = -EINTR; 110 + goto out_release; 111 + } 112 + 113 + if (likely(!atomic_add_unless(&ce->pin_count, 1, 0))) { 105 114 err = intel_context_active_acquire(ce); 106 115 if (unlikely(err)) 107 - goto err; 116 + goto out_unlock; 108 117 109 118 err = ce->ops->pin(ce); 110 119 if (unlikely(err)) ··· 120 117 ce->ring->head, ce->ring->tail); 121 118 122 119 smp_mb__before_atomic(); /* flush pin before it is visible */ 120 + atomic_inc(&ce->pin_count); 123 121 } 124 122 125 - atomic_inc(&ce->pin_count); 126 123 GEM_BUG_ON(!intel_context_is_pinned(ce)); /* no overflow! */ 127 - 128 - mutex_unlock(&ce->pin_mutex); 129 - return 0; 124 + GEM_BUG_ON(i915_active_is_idle(&ce->active)); 125 + goto out_unlock; 130 126 131 127 err_active: 132 128 intel_context_active_release(ce); 133 - err: 129 + out_unlock: 134 130 mutex_unlock(&ce->pin_mutex); 131 + out_release: 132 + i915_active_release(&ce->active); 135 133 return err; 136 134 } 137 135
+13
drivers/gpu/drm/i915/gt/intel_engine_cs.c
··· 671 671 intel_engine_init_active(struct intel_engine_cs *engine, unsigned int subclass) 672 672 { 673 673 INIT_LIST_HEAD(&engine->active.requests); 674 + INIT_LIST_HEAD(&engine->active.hold); 674 675 675 676 spin_lock_init(&engine->active.lock); 676 677 lockdep_set_subclass(&engine->active.lock, subclass); ··· 1423 1422 } 1424 1423 } 1425 1424 1425 + static unsigned long list_count(struct list_head *list) 1426 + { 1427 + struct list_head *pos; 1428 + unsigned long count = 0; 1429 + 1430 + list_for_each(pos, list) 1431 + count++; 1432 + 1433 + return count; 1434 + } 1435 + 1426 1436 void intel_engine_dump(struct intel_engine_cs *engine, 1427 1437 struct drm_printer *m, 1428 1438 const char *header, ...) ··· 1503 1491 hexdump(m, rq->context->lrc_reg_state, PAGE_SIZE); 1504 1492 } 1505 1493 } 1494 + drm_printf(m, "\tOn hold?: %lu\n", list_count(&engine->active.hold)); 1506 1495 spin_unlock_irqrestore(&engine->active.lock, flags); 1507 1496 1508 1497 drm_printf(m, "\tMMIO base: 0x%08x\n", engine->mmio_base);
+1
drivers/gpu/drm/i915/gt/intel_engine_types.h
··· 295 295 struct { 296 296 spinlock_t lock; 297 297 struct list_head requests; 298 + struct list_head hold; /* ready requests, but on hold */ 298 299 } active; 299 300 300 301 struct llist_head barrier_tasks;
+341 -13
drivers/gpu/drm/i915/gt/intel_lrc.c
··· 985 985 GEM_BUG_ON(RB_EMPTY_ROOT(&engine->execlists.queue.rb_root)); 986 986 987 987 list_move(&rq->sched.link, pl); 988 + set_bit(I915_FENCE_FLAG_PQUEUE, &rq->fence.flags); 989 + 988 990 active = rq; 989 991 } else { 990 992 struct intel_engine_cs *owner = rq->context->engine; ··· 1537 1535 return true; 1538 1536 1539 1537 if (unlikely((prev->fence.flags ^ next->fence.flags) & 1540 - (I915_FENCE_FLAG_NOPREEMPT | I915_FENCE_FLAG_SENTINEL))) 1538 + (BIT(I915_FENCE_FLAG_NOPREEMPT) | 1539 + BIT(I915_FENCE_FLAG_SENTINEL)))) 1541 1540 return false; 1542 1541 1543 1542 if (!can_merge_ctx(prev->context, next->context)) ··· 1635 1632 !i915_request_completed(rq)); 1636 1633 1637 1634 GEM_BUG_ON(i915_request_is_active(w)); 1638 - if (list_empty(&w->sched.link)) 1639 - continue; /* Not yet submitted; unready */ 1635 + if (!i915_request_is_ready(w)) 1636 + continue; 1640 1637 1641 1638 if (rq_prio(w) < rq_prio(rq)) 1642 1639 continue; ··· 2354 2351 } 2355 2352 } 2356 2353 2354 + static void __execlists_hold(struct i915_request *rq) 2355 + { 2356 + LIST_HEAD(list); 2357 + 2358 + do { 2359 + struct i915_dependency *p; 2360 + 2361 + if (i915_request_is_active(rq)) 2362 + __i915_request_unsubmit(rq); 2363 + 2364 + RQ_TRACE(rq, "on hold\n"); 2365 + clear_bit(I915_FENCE_FLAG_PQUEUE, &rq->fence.flags); 2366 + list_move_tail(&rq->sched.link, &rq->engine->active.hold); 2367 + i915_request_set_hold(rq); 2368 + 2369 + list_for_each_entry(p, &rq->sched.waiters_list, wait_link) { 2370 + struct i915_request *w = 2371 + container_of(p->waiter, typeof(*w), sched); 2372 + 2373 + /* Leave semaphores spinning on the other engines */ 2374 + if (w->engine != rq->engine) 2375 + continue; 2376 + 2377 + if (!i915_request_is_ready(w)) 2378 + continue; 2379 + 2380 + if (i915_request_completed(w)) 2381 + continue; 2382 + 2383 + if (i915_request_on_hold(rq)) 2384 + continue; 2385 + 2386 + list_move_tail(&w->sched.link, &list); 2387 + } 2388 + 2389 + rq = list_first_entry_or_null(&list, typeof(*rq), sched.link); 2390 + } while (rq); 2391 + } 2392 + 2393 + static bool execlists_hold(struct intel_engine_cs *engine, 2394 + struct i915_request *rq) 2395 + { 2396 + spin_lock_irq(&engine->active.lock); 2397 + 2398 + if (i915_request_completed(rq)) { /* too late! */ 2399 + rq = NULL; 2400 + goto unlock; 2401 + } 2402 + 2403 + if (rq->engine != engine) { /* preempted virtual engine */ 2404 + struct virtual_engine *ve = to_virtual_engine(rq->engine); 2405 + 2406 + /* 2407 + * intel_context_inflight() is only protected by virtue 2408 + * of process_csb() being called only by the tasklet (or 2409 + * directly from inside reset while the tasklet is suspended). 2410 + * Assert that neither of those are allowed to run while we 2411 + * poke at the request queues. 2412 + */ 2413 + GEM_BUG_ON(!reset_in_progress(&engine->execlists)); 2414 + 2415 + /* 2416 + * An unsubmitted request along a virtual engine will 2417 + * remain on the active (this) engine until we are able 2418 + * to process the context switch away (and so mark the 2419 + * context as no longer in flight). That cannot have happened 2420 + * yet, otherwise we would not be hanging! 2421 + */ 2422 + spin_lock(&ve->base.active.lock); 2423 + GEM_BUG_ON(intel_context_inflight(rq->context) != engine); 2424 + GEM_BUG_ON(ve->request != rq); 2425 + ve->request = NULL; 2426 + spin_unlock(&ve->base.active.lock); 2427 + i915_request_put(rq); 2428 + 2429 + rq->engine = engine; 2430 + } 2431 + 2432 + /* 2433 + * Transfer this request onto the hold queue to prevent it 2434 + * being resumbitted to HW (and potentially completed) before we have 2435 + * released it. Since we may have already submitted following 2436 + * requests, we need to remove those as well. 2437 + */ 2438 + GEM_BUG_ON(i915_request_on_hold(rq)); 2439 + GEM_BUG_ON(rq->engine != engine); 2440 + __execlists_hold(rq); 2441 + 2442 + unlock: 2443 + spin_unlock_irq(&engine->active.lock); 2444 + return rq; 2445 + } 2446 + 2447 + static bool hold_request(const struct i915_request *rq) 2448 + { 2449 + struct i915_dependency *p; 2450 + 2451 + /* 2452 + * If one of our ancestors is on hold, we must also be on hold, 2453 + * otherwise we will bypass it and execute before it. 2454 + */ 2455 + list_for_each_entry(p, &rq->sched.signalers_list, signal_link) { 2456 + const struct i915_request *s = 2457 + container_of(p->signaler, typeof(*s), sched); 2458 + 2459 + if (s->engine != rq->engine) 2460 + continue; 2461 + 2462 + if (i915_request_on_hold(s)) 2463 + return true; 2464 + } 2465 + 2466 + return false; 2467 + } 2468 + 2469 + static void __execlists_unhold(struct i915_request *rq) 2470 + { 2471 + LIST_HEAD(list); 2472 + 2473 + do { 2474 + struct i915_dependency *p; 2475 + 2476 + GEM_BUG_ON(!i915_request_on_hold(rq)); 2477 + GEM_BUG_ON(!i915_sw_fence_signaled(&rq->submit)); 2478 + 2479 + i915_request_clear_hold(rq); 2480 + list_move_tail(&rq->sched.link, 2481 + i915_sched_lookup_priolist(rq->engine, 2482 + rq_prio(rq))); 2483 + set_bit(I915_FENCE_FLAG_PQUEUE, &rq->fence.flags); 2484 + RQ_TRACE(rq, "hold release\n"); 2485 + 2486 + /* Also release any children on this engine that are ready */ 2487 + list_for_each_entry(p, &rq->sched.waiters_list, wait_link) { 2488 + struct i915_request *w = 2489 + container_of(p->waiter, typeof(*w), sched); 2490 + 2491 + if (w->engine != rq->engine) 2492 + continue; 2493 + 2494 + if (!i915_request_on_hold(rq)) 2495 + continue; 2496 + 2497 + /* Check that no other parents are also on hold */ 2498 + if (hold_request(rq)) 2499 + continue; 2500 + 2501 + list_move_tail(&w->sched.link, &list); 2502 + } 2503 + 2504 + rq = list_first_entry_or_null(&list, typeof(*rq), sched.link); 2505 + } while (rq); 2506 + } 2507 + 2508 + static void execlists_unhold(struct intel_engine_cs *engine, 2509 + struct i915_request *rq) 2510 + { 2511 + spin_lock_irq(&engine->active.lock); 2512 + 2513 + /* 2514 + * Move this request back to the priority queue, and all of its 2515 + * children and grandchildren that were suspended along with it. 2516 + */ 2517 + __execlists_unhold(rq); 2518 + 2519 + if (rq_prio(rq) > engine->execlists.queue_priority_hint) { 2520 + engine->execlists.queue_priority_hint = rq_prio(rq); 2521 + tasklet_hi_schedule(&engine->execlists.tasklet); 2522 + } 2523 + 2524 + spin_unlock_irq(&engine->active.lock); 2525 + } 2526 + 2527 + struct execlists_capture { 2528 + struct work_struct work; 2529 + struct i915_request *rq; 2530 + struct i915_gpu_coredump *error; 2531 + }; 2532 + 2533 + static void execlists_capture_work(struct work_struct *work) 2534 + { 2535 + struct execlists_capture *cap = container_of(work, typeof(*cap), work); 2536 + const gfp_t gfp = GFP_KERNEL | __GFP_RETRY_MAYFAIL | __GFP_NOWARN; 2537 + struct intel_engine_cs *engine = cap->rq->engine; 2538 + struct intel_gt_coredump *gt = cap->error->gt; 2539 + struct intel_engine_capture_vma *vma; 2540 + 2541 + /* Compress all the objects attached to the request, slow! */ 2542 + vma = intel_engine_coredump_add_request(gt->engine, cap->rq, gfp); 2543 + if (vma) { 2544 + struct i915_vma_compress *compress = 2545 + i915_vma_capture_prepare(gt); 2546 + 2547 + intel_engine_coredump_add_vma(gt->engine, vma, compress); 2548 + i915_vma_capture_finish(gt, compress); 2549 + } 2550 + 2551 + gt->simulated = gt->engine->simulated; 2552 + cap->error->simulated = gt->simulated; 2553 + 2554 + /* Publish the error state, and announce it to the world */ 2555 + i915_error_state_store(cap->error); 2556 + i915_gpu_coredump_put(cap->error); 2557 + 2558 + /* Return this request and all that depend upon it for signaling */ 2559 + execlists_unhold(engine, cap->rq); 2560 + i915_request_put(cap->rq); 2561 + 2562 + kfree(cap); 2563 + } 2564 + 2565 + static struct execlists_capture *capture_regs(struct intel_engine_cs *engine) 2566 + { 2567 + const gfp_t gfp = GFP_ATOMIC | __GFP_NOWARN; 2568 + struct execlists_capture *cap; 2569 + 2570 + cap = kmalloc(sizeof(*cap), gfp); 2571 + if (!cap) 2572 + return NULL; 2573 + 2574 + cap->error = i915_gpu_coredump_alloc(engine->i915, gfp); 2575 + if (!cap->error) 2576 + goto err_cap; 2577 + 2578 + cap->error->gt = intel_gt_coredump_alloc(engine->gt, gfp); 2579 + if (!cap->error->gt) 2580 + goto err_gpu; 2581 + 2582 + cap->error->gt->engine = intel_engine_coredump_alloc(engine, gfp); 2583 + if (!cap->error->gt->engine) 2584 + goto err_gt; 2585 + 2586 + return cap; 2587 + 2588 + err_gt: 2589 + kfree(cap->error->gt); 2590 + err_gpu: 2591 + kfree(cap->error); 2592 + err_cap: 2593 + kfree(cap); 2594 + return NULL; 2595 + } 2596 + 2597 + static bool execlists_capture(struct intel_engine_cs *engine) 2598 + { 2599 + struct execlists_capture *cap; 2600 + 2601 + if (!IS_ENABLED(CONFIG_DRM_I915_CAPTURE_ERROR)) 2602 + return true; 2603 + 2604 + /* 2605 + * We need to _quickly_ capture the engine state before we reset. 2606 + * We are inside an atomic section (softirq) here and we are delaying 2607 + * the forced preemption event. 2608 + */ 2609 + cap = capture_regs(engine); 2610 + if (!cap) 2611 + return true; 2612 + 2613 + cap->rq = execlists_active(&engine->execlists); 2614 + GEM_BUG_ON(!cap->rq); 2615 + 2616 + rcu_read_lock(); 2617 + cap->rq = active_request(cap->rq->context->timeline, cap->rq); 2618 + cap->rq = i915_request_get_rcu(cap->rq); 2619 + rcu_read_unlock(); 2620 + if (!cap->rq) 2621 + goto err_free; 2622 + 2623 + /* 2624 + * Remove the request from the execlists queue, and take ownership 2625 + * of the request. We pass it to our worker who will _slowly_ compress 2626 + * all the pages the _user_ requested for debugging their batch, after 2627 + * which we return it to the queue for signaling. 2628 + * 2629 + * By removing them from the execlists queue, we also remove the 2630 + * requests from being processed by __unwind_incomplete_requests() 2631 + * during the intel_engine_reset(), and so they will *not* be replayed 2632 + * afterwards. 2633 + * 2634 + * Note that because we have not yet reset the engine at this point, 2635 + * it is possible for the request that we have identified as being 2636 + * guilty, did in fact complete and we will then hit an arbitration 2637 + * point allowing the outstanding preemption to succeed. The likelihood 2638 + * of that is very low (as capturing of the engine registers should be 2639 + * fast enough to run inside an irq-off atomic section!), so we will 2640 + * simply hold that request accountable for being non-preemptible 2641 + * long enough to force the reset. 2642 + */ 2643 + if (!execlists_hold(engine, cap->rq)) 2644 + goto err_rq; 2645 + 2646 + INIT_WORK(&cap->work, execlists_capture_work); 2647 + schedule_work(&cap->work); 2648 + return true; 2649 + 2650 + err_rq: 2651 + i915_request_put(cap->rq); 2652 + err_free: 2653 + i915_gpu_coredump_put(cap->error); 2654 + kfree(cap); 2655 + return false; 2656 + } 2657 + 2357 2658 static noinline void preempt_reset(struct intel_engine_cs *engine) 2358 2659 { 2359 2660 const unsigned int bit = I915_RESET_ENGINE + engine->id; ··· 2675 2368 ENGINE_TRACE(engine, "preempt timeout %lu+%ums\n", 2676 2369 READ_ONCE(engine->props.preempt_timeout_ms), 2677 2370 jiffies_to_msecs(jiffies - engine->execlists.preempt.expires)); 2678 - intel_engine_reset(engine, "preemption time out"); 2371 + 2372 + ring_set_paused(engine, 1); /* Freeze the current request in place */ 2373 + if (execlists_capture(engine)) 2374 + intel_engine_reset(engine, "preemption time out"); 2375 + else 2376 + ring_set_paused(engine, 0); 2679 2377 2680 2378 tasklet_enable(&engine->execlists.tasklet); 2681 2379 clear_and_wake_up_bit(bit, lock); ··· 2742 2430 } 2743 2431 2744 2432 static void queue_request(struct intel_engine_cs *engine, 2745 - struct i915_sched_node *node, 2746 - int prio) 2433 + struct i915_request *rq) 2747 2434 { 2748 - GEM_BUG_ON(!list_empty(&node->link)); 2749 - list_add_tail(&node->link, i915_sched_lookup_priolist(engine, prio)); 2435 + GEM_BUG_ON(!list_empty(&rq->sched.link)); 2436 + list_add_tail(&rq->sched.link, 2437 + i915_sched_lookup_priolist(engine, rq_prio(rq))); 2438 + set_bit(I915_FENCE_FLAG_PQUEUE, &rq->fence.flags); 2750 2439 } 2751 2440 2752 2441 static void __submit_queue_imm(struct intel_engine_cs *engine) ··· 2775 2462 __submit_queue_imm(engine); 2776 2463 } 2777 2464 2465 + static bool ancestor_on_hold(const struct intel_engine_cs *engine, 2466 + const struct i915_request *rq) 2467 + { 2468 + GEM_BUG_ON(i915_request_on_hold(rq)); 2469 + return !list_empty(&engine->active.hold) && hold_request(rq); 2470 + } 2471 + 2778 2472 static void execlists_submit_request(struct i915_request *request) 2779 2473 { 2780 2474 struct intel_engine_cs *engine = request->engine; ··· 2790 2470 /* Will be called from irq-context when using foreign fences. */ 2791 2471 spin_lock_irqsave(&engine->active.lock, flags); 2792 2472 2793 - queue_request(engine, &request->sched, rq_prio(request)); 2473 + if (unlikely(ancestor_on_hold(engine, request))) { 2474 + list_add_tail(&request->sched.link, &engine->active.hold); 2475 + i915_request_set_hold(request); 2476 + } else { 2477 + queue_request(engine, request); 2794 2478 2795 - GEM_BUG_ON(RB_EMPTY_ROOT(&engine->execlists.queue.rb_root)); 2796 - GEM_BUG_ON(list_empty(&request->sched.link)); 2479 + GEM_BUG_ON(RB_EMPTY_ROOT(&engine->execlists.queue.rb_root)); 2480 + GEM_BUG_ON(list_empty(&request->sched.link)); 2797 2481 2798 - submit_queue(engine, request); 2482 + submit_queue(engine, request); 2483 + } 2799 2484 2800 2485 spin_unlock_irqrestore(&engine->active.lock, flags); 2801 2486 } ··· 2856 2531 ce->engine); 2857 2532 2858 2533 i915_gem_object_unpin_map(ce->state->obj); 2859 - intel_ring_reset(ce->ring, ce->ring->tail); 2860 2534 } 2861 2535 2862 2536 static void ··· 3648 3324 rb_erase_cached(&p->node, &execlists->queue); 3649 3325 i915_priolist_free(p); 3650 3326 } 3327 + 3328 + /* On-hold requests will be flushed to timeline upon their release */ 3329 + list_for_each_entry(rq, &engine->active.hold, sched.link) 3330 + mark_eio(rq); 3651 3331 3652 3332 /* Cancel all attached virtual engines */ 3653 3333 while ((rb = rb_first_cached(&execlists->virtual))) {
+16 -1
drivers/gpu/drm/i915/gt/mock_engine.c
··· 59 59 ring->vaddr = (void *)(ring + 1); 60 60 atomic_set(&ring->pin_count, 1); 61 61 62 + ring->vma = i915_vma_alloc(); 63 + if (!ring->vma) { 64 + kfree(ring); 65 + return NULL; 66 + } 67 + i915_active_init(&ring->vma->active, NULL, NULL); 68 + 62 69 intel_ring_update_space(ring); 63 70 64 71 return ring; 72 + } 73 + 74 + static void mock_ring_free(struct intel_ring *ring) 75 + { 76 + i915_active_fini(&ring->vma->active); 77 + i915_vma_free(ring->vma); 78 + 79 + kfree(ring); 65 80 } 66 81 67 82 static struct i915_request *first_request(struct mock_engine *engine) ··· 136 121 GEM_BUG_ON(intel_context_is_pinned(ce)); 137 122 138 123 if (test_bit(CONTEXT_ALLOC_BIT, &ce->flags)) { 139 - kfree(ce->ring); 124 + mock_ring_free(ce->ring); 140 125 mock_timeline_unpin(ce->timeline); 141 126 } 142 127
+258
drivers/gpu/drm/i915/gt/selftest_lrc.c
··· 285 285 return live_unlite_restore(arg, I915_USER_PRIORITY(I915_PRIORITY_MAX)); 286 286 } 287 287 288 + static int live_hold_reset(void *arg) 289 + { 290 + struct intel_gt *gt = arg; 291 + struct intel_engine_cs *engine; 292 + enum intel_engine_id id; 293 + struct igt_spinner spin; 294 + int err = 0; 295 + 296 + /* 297 + * In order to support offline error capture for fast preempt reset, 298 + * we need to decouple the guilty request and ensure that it and its 299 + * descendents are not executed while the capture is in progress. 300 + */ 301 + 302 + if (!intel_has_reset_engine(gt)) 303 + return 0; 304 + 305 + if (igt_spinner_init(&spin, gt)) 306 + return -ENOMEM; 307 + 308 + for_each_engine(engine, gt, id) { 309 + struct intel_context *ce; 310 + unsigned long heartbeat; 311 + struct i915_request *rq; 312 + 313 + ce = intel_context_create(engine); 314 + if (IS_ERR(ce)) { 315 + err = PTR_ERR(ce); 316 + break; 317 + } 318 + 319 + engine_heartbeat_disable(engine, &heartbeat); 320 + 321 + rq = igt_spinner_create_request(&spin, ce, MI_ARB_CHECK); 322 + if (IS_ERR(rq)) { 323 + err = PTR_ERR(rq); 324 + goto out; 325 + } 326 + i915_request_add(rq); 327 + 328 + if (!igt_wait_for_spinner(&spin, rq)) { 329 + intel_gt_set_wedged(gt); 330 + err = -ETIME; 331 + goto out; 332 + } 333 + 334 + /* We have our request executing, now remove it and reset */ 335 + 336 + if (test_and_set_bit(I915_RESET_ENGINE + id, 337 + &gt->reset.flags)) { 338 + intel_gt_set_wedged(gt); 339 + err = -EBUSY; 340 + goto out; 341 + } 342 + tasklet_disable(&engine->execlists.tasklet); 343 + 344 + engine->execlists.tasklet.func(engine->execlists.tasklet.data); 345 + GEM_BUG_ON(execlists_active(&engine->execlists) != rq); 346 + 347 + i915_request_get(rq); 348 + execlists_hold(engine, rq); 349 + GEM_BUG_ON(!i915_request_on_hold(rq)); 350 + 351 + intel_engine_reset(engine, NULL); 352 + GEM_BUG_ON(rq->fence.error != -EIO); 353 + 354 + tasklet_enable(&engine->execlists.tasklet); 355 + clear_and_wake_up_bit(I915_RESET_ENGINE + id, 356 + &gt->reset.flags); 357 + 358 + /* Check that we do not resubmit the held request */ 359 + if (!i915_request_wait(rq, 0, HZ / 5)) { 360 + pr_err("%s: on hold request completed!\n", 361 + engine->name); 362 + i915_request_put(rq); 363 + err = -EIO; 364 + goto out; 365 + } 366 + GEM_BUG_ON(!i915_request_on_hold(rq)); 367 + 368 + /* But is resubmitted on release */ 369 + execlists_unhold(engine, rq); 370 + if (i915_request_wait(rq, 0, HZ / 5) < 0) { 371 + pr_err("%s: held request did not complete!\n", 372 + engine->name); 373 + intel_gt_set_wedged(gt); 374 + err = -ETIME; 375 + } 376 + i915_request_put(rq); 377 + 378 + out: 379 + engine_heartbeat_enable(engine, heartbeat); 380 + intel_context_put(ce); 381 + if (err) 382 + break; 383 + } 384 + 385 + igt_spinner_fini(&spin); 386 + return err; 387 + } 388 + 288 389 static int 289 390 emit_semaphore_chain(struct i915_request *rq, struct i915_vma *vma, int idx) 290 391 { ··· 3410 3309 return 0; 3411 3310 } 3412 3311 3312 + static int reset_virtual_engine(struct intel_gt *gt, 3313 + struct intel_engine_cs **siblings, 3314 + unsigned int nsibling) 3315 + { 3316 + struct intel_engine_cs *engine; 3317 + struct intel_context *ve; 3318 + unsigned long *heartbeat; 3319 + struct igt_spinner spin; 3320 + struct i915_request *rq; 3321 + unsigned int n; 3322 + int err = 0; 3323 + 3324 + /* 3325 + * In order to support offline error capture for fast preempt reset, 3326 + * we need to decouple the guilty request and ensure that it and its 3327 + * descendents are not executed while the capture is in progress. 3328 + */ 3329 + 3330 + heartbeat = kmalloc_array(nsibling, sizeof(*heartbeat), GFP_KERNEL); 3331 + if (!heartbeat) 3332 + return -ENOMEM; 3333 + 3334 + if (igt_spinner_init(&spin, gt)) { 3335 + err = -ENOMEM; 3336 + goto out_free; 3337 + } 3338 + 3339 + ve = intel_execlists_create_virtual(siblings, nsibling); 3340 + if (IS_ERR(ve)) { 3341 + err = PTR_ERR(ve); 3342 + goto out_spin; 3343 + } 3344 + 3345 + for (n = 0; n < nsibling; n++) 3346 + engine_heartbeat_disable(siblings[n], &heartbeat[n]); 3347 + 3348 + rq = igt_spinner_create_request(&spin, ve, MI_ARB_CHECK); 3349 + if (IS_ERR(rq)) { 3350 + err = PTR_ERR(rq); 3351 + goto out_heartbeat; 3352 + } 3353 + i915_request_add(rq); 3354 + 3355 + if (!igt_wait_for_spinner(&spin, rq)) { 3356 + intel_gt_set_wedged(gt); 3357 + err = -ETIME; 3358 + goto out_heartbeat; 3359 + } 3360 + 3361 + engine = rq->engine; 3362 + GEM_BUG_ON(engine == ve->engine); 3363 + 3364 + /* Take ownership of the reset and tasklet */ 3365 + if (test_and_set_bit(I915_RESET_ENGINE + engine->id, 3366 + &gt->reset.flags)) { 3367 + intel_gt_set_wedged(gt); 3368 + err = -EBUSY; 3369 + goto out_heartbeat; 3370 + } 3371 + tasklet_disable(&engine->execlists.tasklet); 3372 + 3373 + engine->execlists.tasklet.func(engine->execlists.tasklet.data); 3374 + GEM_BUG_ON(execlists_active(&engine->execlists) != rq); 3375 + 3376 + /* Fake a preemption event; failed of course */ 3377 + spin_lock_irq(&engine->active.lock); 3378 + __unwind_incomplete_requests(engine); 3379 + spin_unlock_irq(&engine->active.lock); 3380 + GEM_BUG_ON(rq->engine != ve->engine); 3381 + 3382 + /* Reset the engine while keeping our active request on hold */ 3383 + execlists_hold(engine, rq); 3384 + GEM_BUG_ON(!i915_request_on_hold(rq)); 3385 + 3386 + intel_engine_reset(engine, NULL); 3387 + GEM_BUG_ON(rq->fence.error != -EIO); 3388 + 3389 + /* Release our grasp on the engine, letting CS flow again */ 3390 + tasklet_enable(&engine->execlists.tasklet); 3391 + clear_and_wake_up_bit(I915_RESET_ENGINE + engine->id, &gt->reset.flags); 3392 + 3393 + /* Check that we do not resubmit the held request */ 3394 + i915_request_get(rq); 3395 + if (!i915_request_wait(rq, 0, HZ / 5)) { 3396 + pr_err("%s: on hold request completed!\n", 3397 + engine->name); 3398 + intel_gt_set_wedged(gt); 3399 + err = -EIO; 3400 + goto out_rq; 3401 + } 3402 + GEM_BUG_ON(!i915_request_on_hold(rq)); 3403 + 3404 + /* But is resubmitted on release */ 3405 + execlists_unhold(engine, rq); 3406 + if (i915_request_wait(rq, 0, HZ / 5) < 0) { 3407 + pr_err("%s: held request did not complete!\n", 3408 + engine->name); 3409 + intel_gt_set_wedged(gt); 3410 + err = -ETIME; 3411 + } 3412 + 3413 + out_rq: 3414 + i915_request_put(rq); 3415 + out_heartbeat: 3416 + for (n = 0; n < nsibling; n++) 3417 + engine_heartbeat_enable(siblings[n], heartbeat[n]); 3418 + 3419 + intel_context_put(ve); 3420 + out_spin: 3421 + igt_spinner_fini(&spin); 3422 + out_free: 3423 + kfree(heartbeat); 3424 + return err; 3425 + } 3426 + 3427 + static int live_virtual_reset(void *arg) 3428 + { 3429 + struct intel_gt *gt = arg; 3430 + struct intel_engine_cs *siblings[MAX_ENGINE_INSTANCE + 1]; 3431 + unsigned int class, inst; 3432 + 3433 + /* 3434 + * Check that we handle a reset event within a virtual engine. 3435 + * Only the physical engine is reset, but we have to check the flow 3436 + * of the virtual requests around the reset, and make sure it is not 3437 + * forgotten. 3438 + */ 3439 + 3440 + if (USES_GUC_SUBMISSION(gt->i915)) 3441 + return 0; 3442 + 3443 + if (!intel_has_reset_engine(gt)) 3444 + return 0; 3445 + 3446 + for (class = 0; class <= MAX_ENGINE_CLASS; class++) { 3447 + int nsibling, err; 3448 + 3449 + nsibling = 0; 3450 + for (inst = 0; inst <= MAX_ENGINE_INSTANCE; inst++) { 3451 + if (!gt->engine_class[class][inst]) 3452 + continue; 3453 + 3454 + siblings[nsibling++] = gt->engine_class[class][inst]; 3455 + } 3456 + if (nsibling < 2) 3457 + continue; 3458 + 3459 + err = reset_virtual_engine(gt, siblings, nsibling); 3460 + if (err) 3461 + return err; 3462 + } 3463 + 3464 + return 0; 3465 + } 3466 + 3413 3467 int intel_execlists_live_selftests(struct drm_i915_private *i915) 3414 3468 { 3415 3469 static const struct i915_subtest tests[] = { 3416 3470 SUBTEST(live_sanitycheck), 3417 3471 SUBTEST(live_unlite_switch), 3418 3472 SUBTEST(live_unlite_preempt), 3473 + SUBTEST(live_hold_reset), 3419 3474 SUBTEST(live_timeslice_preempt), 3420 3475 SUBTEST(live_timeslice_queue), 3421 3476 SUBTEST(live_busywait_preempt), ··· 3590 3333 SUBTEST(live_virtual_mask), 3591 3334 SUBTEST(live_virtual_preserved), 3592 3335 SUBTEST(live_virtual_bond), 3336 + SUBTEST(live_virtual_reset), 3593 3337 }; 3594 3338 3595 3339 if (!HAS_EXECLISTS(i915))
+2 -2
drivers/gpu/drm/i915/gvt/firmware.c
··· 146 146 clean_firmware_sysfs(gvt); 147 147 148 148 kfree(gvt->firmware.cfg_space); 149 - kfree(gvt->firmware.mmio); 149 + vfree(gvt->firmware.mmio); 150 150 } 151 151 152 152 static int verify_firmware(struct intel_gvt *gvt, ··· 229 229 230 230 firmware->cfg_space = mem; 231 231 232 - mem = kmalloc(info->mmio_size, GFP_KERNEL); 232 + mem = vmalloc(info->mmio_size); 233 233 if (!mem) { 234 234 kfree(path); 235 235 kfree(firmware->cfg_space);
+4
drivers/gpu/drm/i915/gvt/gtt.c
··· 1956 1956 1957 1957 if (mm->type == INTEL_GVT_MM_PPGTT) { 1958 1958 list_del(&mm->ppgtt_mm.list); 1959 + 1960 + mutex_lock(&mm->vgpu->gvt->gtt.ppgtt_mm_lock); 1959 1961 list_del(&mm->ppgtt_mm.lru_list); 1962 + mutex_unlock(&mm->vgpu->gvt->gtt.ppgtt_mm_lock); 1963 + 1960 1964 invalidate_ppgtt_mm(mm); 1961 1965 } else { 1962 1966 vfree(mm->ggtt_mm.virtual_ggtt);
+19 -16
drivers/gpu/drm/i915/i915_active.c
··· 416 416 if (err) 417 417 return err; 418 418 419 - if (!atomic_read(&ref->count) && ref->active) 420 - err = ref->active(ref); 421 - if (!err) { 422 - spin_lock_irq(&ref->tree_lock); /* vs __active_retire() */ 423 - debug_active_activate(ref); 424 - atomic_inc(&ref->count); 425 - spin_unlock_irq(&ref->tree_lock); 419 + if (likely(!i915_active_acquire_if_busy(ref))) { 420 + if (ref->active) 421 + err = ref->active(ref); 422 + if (!err) { 423 + spin_lock_irq(&ref->tree_lock); /* __active_retire() */ 424 + debug_active_activate(ref); 425 + atomic_inc(&ref->count); 426 + spin_unlock_irq(&ref->tree_lock); 427 + } 426 428 } 427 429 428 430 mutex_unlock(&ref->mutex); ··· 607 605 struct intel_engine_cs *engine) 608 606 { 609 607 intel_engine_mask_t tmp, mask = engine->mask; 610 - struct llist_node *pos = NULL, *next; 608 + struct llist_node *first = NULL, *last = NULL; 611 609 struct intel_gt *gt = engine->gt; 612 610 int err; 613 611 ··· 625 623 */ 626 624 for_each_engine_masked(engine, gt, mask, tmp) { 627 625 u64 idx = engine->kernel_context->timeline->fence_context; 626 + struct llist_node *prev = first; 628 627 struct active_node *node; 629 628 630 629 node = reuse_idle_barrier(ref, idx); ··· 659 656 GEM_BUG_ON(rcu_access_pointer(node->base.fence) != ERR_PTR(-EAGAIN)); 660 657 661 658 GEM_BUG_ON(barrier_to_engine(node) != engine); 662 - next = barrier_to_ll(node); 663 - next->next = pos; 664 - if (!pos) 665 - pos = next; 659 + first = barrier_to_ll(node); 660 + first->next = prev; 661 + if (!last) 662 + last = first; 666 663 intel_engine_pm_get(engine); 667 664 } 668 665 669 666 GEM_BUG_ON(!llist_empty(&ref->preallocated_barriers)); 670 - llist_add_batch(next, pos, &ref->preallocated_barriers); 667 + llist_add_batch(first, last, &ref->preallocated_barriers); 671 668 672 669 return 0; 673 670 674 671 unwind: 675 - while (pos) { 676 - struct active_node *node = barrier_from_ll(pos); 672 + while (first) { 673 + struct active_node *node = barrier_from_ll(first); 677 674 678 - pos = pos->next; 675 + first = first->next; 679 676 680 677 atomic_dec(&ref->count); 681 678 intel_engine_pm_put(barrier_to_engine(node));
+6
drivers/gpu/drm/i915/i915_active.h
··· 188 188 bool i915_active_acquire_if_busy(struct i915_active *ref); 189 189 void i915_active_release(struct i915_active *ref); 190 190 191 + static inline void __i915_active_acquire(struct i915_active *ref) 192 + { 193 + GEM_BUG_ON(!atomic_read(&ref->count)); 194 + atomic_inc(&ref->count); 195 + } 196 + 191 197 static inline bool 192 198 i915_active_is_idle(const struct i915_active *ref) 193 199 {
+4 -1
drivers/gpu/drm/i915/i915_gem.c
··· 265 265 DRM_FORMAT_MOD_LINEAR)) 266 266 args->pitch = ALIGN(args->pitch, 4096); 267 267 268 - args->size = args->pitch * args->height; 268 + if (args->pitch < args->width) 269 + return -EINVAL; 270 + 271 + args->size = mul_u32_u32(args->pitch, args->height); 269 272 270 273 mem_type = INTEL_MEMORY_SYSTEM; 271 274 if (HAS_LMEM(to_i915(dev)))
+1 -1
drivers/gpu/drm/i915/i915_gpu_error.c
··· 1681 1681 "GPU HANG: ecode %d:%x:%08x", 1682 1682 INTEL_GEN(error->i915), engines, 1683 1683 generate_ecode(first)); 1684 - if (first) { 1684 + if (first && first->context.pid) { 1685 1685 /* Just show the first executing process, more is confusing */ 1686 1686 len += scnprintf(error->error_msg + len, 1687 1687 sizeof(error->error_msg) - len,
+5 -2
drivers/gpu/drm/i915/i915_gpu_error.h
··· 314 314 } 315 315 316 316 static inline void 317 - i915_error_state_store(struct drm_i915_private *i915, 318 - struct i915_gpu_coredump *error) 317 + i915_error_state_store(struct i915_gpu_coredump *error) 318 + { 319 + } 320 + 321 + static inline void i915_gpu_coredump_put(struct i915_gpu_coredump *gpu) 319 322 { 320 323 } 321 324
+12
drivers/gpu/drm/i915/i915_pmu.c
··· 637 637 container_of(event->pmu, typeof(*i915), pmu.base); 638 638 unsigned int bit = event_enabled_bit(event); 639 639 struct i915_pmu *pmu = &i915->pmu; 640 + intel_wakeref_t wakeref; 640 641 unsigned long flags; 641 642 643 + wakeref = intel_runtime_pm_get(&i915->runtime_pm); 642 644 spin_lock_irqsave(&pmu->lock, flags); 643 645 644 646 /* ··· 650 648 BUILD_BUG_ON(ARRAY_SIZE(pmu->enable_count) != I915_PMU_MASK_BITS); 651 649 GEM_BUG_ON(bit >= ARRAY_SIZE(pmu->enable_count)); 652 650 GEM_BUG_ON(pmu->enable_count[bit] == ~0); 651 + 652 + if (pmu->enable_count[bit] == 0 && 653 + config_enabled_mask(I915_PMU_RC6_RESIDENCY) & BIT_ULL(bit)) { 654 + pmu->sample[__I915_SAMPLE_RC6_LAST_REPORTED].cur = 0; 655 + pmu->sample[__I915_SAMPLE_RC6].cur = __get_rc6(&i915->gt); 656 + pmu->sleep_last = ktime_get(); 657 + } 658 + 653 659 pmu->enable |= BIT_ULL(bit); 654 660 pmu->enable_count[bit]++; 655 661 ··· 698 688 * an existing non-zero value. 699 689 */ 700 690 local64_set(&event->hw.prev_count, __i915_pmu_event_read(event)); 691 + 692 + intel_runtime_pm_put(&i915->runtime_pm, wakeref); 701 693 } 702 694 703 695 static void i915_pmu_disable(struct perf_event *event)
+5 -1
drivers/gpu/drm/i915/i915_request.c
··· 221 221 locked = engine; 222 222 } 223 223 list_del_init(&rq->sched.link); 224 + clear_bit(I915_FENCE_FLAG_PQUEUE, &rq->fence.flags); 225 + clear_bit(I915_FENCE_FLAG_HOLD, &rq->fence.flags); 224 226 spin_unlock_irq(&locked->active.lock); 225 227 } 226 228 ··· 410 408 xfer: /* We may be recursing from the signal callback of another i915 fence */ 411 409 spin_lock_nested(&request->lock, SINGLE_DEPTH_NESTING); 412 410 413 - if (!test_and_set_bit(I915_FENCE_FLAG_ACTIVE, &request->fence.flags)) 411 + if (!test_and_set_bit(I915_FENCE_FLAG_ACTIVE, &request->fence.flags)) { 414 412 list_move_tail(&request->sched.link, &engine->active.requests); 413 + clear_bit(I915_FENCE_FLAG_PQUEUE, &request->fence.flags); 414 + } 415 415 416 416 if (test_bit(DMA_FENCE_FLAG_ENABLE_SIGNAL_BIT, &request->fence.flags) && 417 417 !test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &request->fence.flags) &&
+60
drivers/gpu/drm/i915/i915_request.h
··· 71 71 I915_FENCE_FLAG_ACTIVE = DMA_FENCE_FLAG_USER_BITS, 72 72 73 73 /* 74 + * I915_FENCE_FLAG_PQUEUE - this request is ready for execution 75 + * 76 + * Using the scheduler, when a request is ready for execution it is put 77 + * into the priority queue, and removed from that queue when transferred 78 + * to the HW runlists. We want to track its membership within the 79 + * priority queue so that we can easily check before rescheduling. 80 + * 81 + * See i915_request_in_priority_queue() 82 + */ 83 + I915_FENCE_FLAG_PQUEUE, 84 + 85 + /* 74 86 * I915_FENCE_FLAG_SIGNAL - this request is currently on signal_list 75 87 * 76 88 * Internal bookkeeping used by the breadcrumb code to track when 77 89 * a request is on the various signal_list. 78 90 */ 79 91 I915_FENCE_FLAG_SIGNAL, 92 + 93 + /* 94 + * I915_FENCE_FLAG_HOLD - this request is currently on hold 95 + * 96 + * This request has been suspended, pending an ongoing investigation. 97 + */ 98 + I915_FENCE_FLAG_HOLD, 80 99 81 100 /* 82 101 * I915_FENCE_FLAG_NOPREEMPT - this request should not be preempted ··· 380 361 return test_bit(I915_FENCE_FLAG_ACTIVE, &rq->fence.flags); 381 362 } 382 363 364 + static inline bool i915_request_in_priority_queue(const struct i915_request *rq) 365 + { 366 + return test_bit(I915_FENCE_FLAG_PQUEUE, &rq->fence.flags); 367 + } 368 + 383 369 /** 384 370 * Returns true if seq1 is later than seq2. 385 371 */ ··· 478 454 return __i915_request_has_started(rq); 479 455 } 480 456 457 + /** 458 + * i915_request_is_running - check if the request is ready for execution 459 + * @rq: the request 460 + * 461 + * Upon construction, the request is instructed to wait upon various 462 + * signals before it is ready to be executed by the HW. That is, we do 463 + * not want to start execution and read data before it is written. In practice, 464 + * this is controlled with a mixture of interrupts and semaphores. Once 465 + * the submit fence is completed, the backend scheduler will place the 466 + * request into its queue and from there submit it for execution. So we 467 + * can detect when a request is eligible for execution (and is under control 468 + * of the scheduler) by querying where it is in any of the scheduler's lists. 469 + * 470 + * Returns true if the request is ready for execution (it may be inflight), 471 + * false otherwise. 472 + */ 473 + static inline bool i915_request_is_ready(const struct i915_request *rq) 474 + { 475 + return !list_empty(&rq->sched.link); 476 + } 477 + 481 478 static inline bool i915_request_completed(const struct i915_request *rq) 482 479 { 483 480 if (i915_request_signaled(rq)) ··· 526 481 static inline bool i915_request_has_sentinel(const struct i915_request *rq) 527 482 { 528 483 return unlikely(test_bit(I915_FENCE_FLAG_SENTINEL, &rq->fence.flags)); 484 + } 485 + 486 + static inline bool i915_request_on_hold(const struct i915_request *rq) 487 + { 488 + return unlikely(test_bit(I915_FENCE_FLAG_HOLD, &rq->fence.flags)); 489 + } 490 + 491 + static inline void i915_request_set_hold(struct i915_request *rq) 492 + { 493 + set_bit(I915_FENCE_FLAG_HOLD, &rq->fence.flags); 494 + } 495 + 496 + static inline void i915_request_clear_hold(struct i915_request *rq) 497 + { 498 + clear_bit(I915_FENCE_FLAG_HOLD, &rq->fence.flags); 529 499 } 530 500 531 501 static inline struct intel_timeline *
+10 -12
drivers/gpu/drm/i915/i915_scheduler.c
··· 326 326 327 327 node->attr.priority = prio; 328 328 329 - if (list_empty(&node->link)) { 330 - /* 331 - * If the request is not in the priolist queue because 332 - * it is not yet runnable, then it doesn't contribute 333 - * to our preemption decisions. On the other hand, 334 - * if the request is on the HW, it too is not in the 335 - * queue; but in that case we may still need to reorder 336 - * the inflight requests. 337 - */ 329 + /* 330 + * Once the request is ready, it will be placed into the 331 + * priority lists and then onto the HW runlist. Before the 332 + * request is ready, it does not contribute to our preemption 333 + * decisions and we can safely ignore it, as it will, and 334 + * any preemption required, be dealt with upon submission. 335 + * See engine->submit_request() 336 + */ 337 + if (list_empty(&node->link)) 338 338 continue; 339 - } 340 339 341 - if (!intel_engine_is_virtual(engine) && 342 - !i915_request_is_active(node_to_request(node))) { 340 + if (i915_request_in_priority_queue(node_to_request(node))) { 343 341 if (!cache.priolist) 344 342 cache.priolist = 345 343 i915_sched_lookup_priolist(engine,
+12 -2
drivers/gpu/drm/i915/i915_vma.c
··· 1202 1202 if (ret) 1203 1203 return ret; 1204 1204 1205 - GEM_BUG_ON(i915_vma_is_active(vma)); 1206 1205 if (i915_vma_is_pinned(vma)) { 1207 1206 vma_print_allocator(vma, "is pinned"); 1208 1207 return -EAGAIN; 1209 1208 } 1210 1209 1211 - GEM_BUG_ON(i915_vma_is_active(vma)); 1210 + /* 1211 + * After confirming that no one else is pinning this vma, wait for 1212 + * any laggards who may have crept in during the wait (through 1213 + * a residual pin skipping the vm->mutex) to complete. 1214 + */ 1215 + ret = i915_vma_sync(vma); 1216 + if (ret) 1217 + return ret; 1218 + 1212 1219 if (!drm_mm_node_allocated(&vma->node)) 1213 1220 return 0; 1221 + 1222 + GEM_BUG_ON(i915_vma_is_pinned(vma)); 1223 + GEM_BUG_ON(i915_vma_is_active(vma)); 1214 1224 1215 1225 if (i915_vma_is_map_and_fenceable(vma)) { 1216 1226 /*
+8
drivers/gpu/drm/msm/msm_drv.c
··· 441 441 if (ret) 442 442 goto err_msm_uninit; 443 443 444 + if (!dev->dma_parms) { 445 + dev->dma_parms = devm_kzalloc(dev, sizeof(*dev->dma_parms), 446 + GFP_KERNEL); 447 + if (!dev->dma_parms) 448 + return -ENOMEM; 449 + } 450 + dma_set_max_seg_size(dev, DMA_BIT_MASK(32)); 451 + 444 452 msm_gem_shrinker_init(ddev); 445 453 446 454 switch (get_mdp_ver(pdev)) {
+1
drivers/gpu/drm/panfrost/panfrost_drv.c
··· 166 166 break; 167 167 } 168 168 169 + atomic_inc(&bo->gpu_usecount); 169 170 job->mappings[i] = mapping; 170 171 } 171 172
+6
drivers/gpu/drm/panfrost/panfrost_gem.h
··· 30 30 struct mutex lock; 31 31 } mappings; 32 32 33 + /* 34 + * Count the number of jobs referencing this BO so we don't let the 35 + * shrinker reclaim this object prematurely. 36 + */ 37 + atomic_t gpu_usecount; 38 + 33 39 bool noexec :1; 34 40 bool is_heap :1; 35 41 };
+3
drivers/gpu/drm/panfrost/panfrost_gem_shrinker.c
··· 41 41 struct drm_gem_shmem_object *shmem = to_drm_gem_shmem_obj(obj); 42 42 struct panfrost_gem_object *bo = to_panfrost_bo(obj); 43 43 44 + if (atomic_read(&bo->gpu_usecount)) 45 + return false; 46 + 44 47 if (!mutex_trylock(&shmem->pages_lock)) 45 48 return false; 46 49
+6 -1
drivers/gpu/drm/panfrost/panfrost_job.c
··· 269 269 dma_fence_put(job->render_done_fence); 270 270 271 271 if (job->mappings) { 272 - for (i = 0; i < job->bo_count; i++) 272 + for (i = 0; i < job->bo_count; i++) { 273 + if (!job->mappings[i]) 274 + break; 275 + 276 + atomic_dec(&job->mappings[i]->obj->gpu_usecount); 273 277 panfrost_gem_mapping_put(job->mappings[i]); 278 + } 274 279 kvfree(job->mappings); 275 280 } 276 281
-1
drivers/gpu/drm/sun4i/sun4i_drv.c
··· 85 85 } 86 86 87 87 drm_mode_config_init(drm); 88 - drm->mode_config.allow_fb_modifiers = true; 89 88 90 89 ret = component_bind_all(drm->dev, drm); 91 90 if (ret) {
+6 -3
drivers/gpu/drm/vgem/vgem_drv.c
··· 196 196 return ERR_CAST(obj); 197 197 198 198 ret = drm_gem_handle_create(file, &obj->base, handle); 199 - drm_gem_object_put_unlocked(&obj->base); 200 - if (ret) 199 + if (ret) { 200 + drm_gem_object_put_unlocked(&obj->base); 201 201 return ERR_PTR(ret); 202 + } 202 203 203 204 return &obj->base; 204 205 } ··· 222 221 args->size = gem_object->size; 223 222 args->pitch = pitch; 224 223 225 - DRM_DEBUG("Created object of size %lld\n", size); 224 + drm_gem_object_put_unlocked(gem_object); 225 + 226 + DRM_DEBUG("Created object of size %llu\n", args->size); 226 227 227 228 return 0; 228 229 }
+2 -2
drivers/hwmon/pmbus/ltc2978.c
··· 82 82 83 83 #define LTC_POLL_TIMEOUT 100 /* in milli-seconds */ 84 84 85 - #define LTC_NOT_BUSY BIT(5) 86 - #define LTC_NOT_PENDING BIT(4) 85 + #define LTC_NOT_BUSY BIT(6) 86 + #define LTC_NOT_PENDING BIT(5) 87 87 88 88 /* 89 89 * LTC2978 clears peak data whenever the CLEAR_FAULTS command is executed, which
+2 -2
drivers/hwmon/pmbus/xdpe12284.c
··· 94 94 MODULE_DEVICE_TABLE(i2c, xdpe122_id); 95 95 96 96 static const struct of_device_id __maybe_unused xdpe122_of_match[] = { 97 - {.compatible = "infineon, xdpe12254"}, 98 - {.compatible = "infineon, xdpe12284"}, 97 + {.compatible = "infineon,xdpe12254"}, 98 + {.compatible = "infineon,xdpe12284"}, 99 99 {} 100 100 }; 101 101 MODULE_DEVICE_TABLE(of, xdpe122_of_match);
+9 -15
drivers/infiniband/core/security.c
··· 339 339 if (!new_pps) 340 340 return NULL; 341 341 342 - if (qp_attr_mask & (IB_QP_PKEY_INDEX | IB_QP_PORT)) { 343 - if (!qp_pps) { 344 - new_pps->main.port_num = qp_attr->port_num; 345 - new_pps->main.pkey_index = qp_attr->pkey_index; 346 - } else { 347 - new_pps->main.port_num = (qp_attr_mask & IB_QP_PORT) ? 348 - qp_attr->port_num : 349 - qp_pps->main.port_num; 350 - 351 - new_pps->main.pkey_index = 352 - (qp_attr_mask & IB_QP_PKEY_INDEX) ? 353 - qp_attr->pkey_index : 354 - qp_pps->main.pkey_index; 355 - } 342 + if (qp_attr_mask & IB_QP_PORT) 343 + new_pps->main.port_num = 344 + (qp_pps) ? qp_pps->main.port_num : qp_attr->port_num; 345 + if (qp_attr_mask & IB_QP_PKEY_INDEX) 346 + new_pps->main.pkey_index = (qp_pps) ? qp_pps->main.pkey_index : 347 + qp_attr->pkey_index; 348 + if ((qp_attr_mask & IB_QP_PKEY_INDEX) && (qp_attr_mask & IB_QP_PORT)) 356 349 new_pps->main.state = IB_PORT_PKEY_VALID; 357 - } else if (qp_pps) { 350 + 351 + if (!(qp_attr_mask & (IB_QP_PKEY_INDEX || IB_QP_PORT)) && qp_pps) { 358 352 new_pps->main.port_num = qp_pps->main.port_num; 359 353 new_pps->main.pkey_index = qp_pps->main.pkey_index; 360 354 if (qp_pps->main.state != IB_PORT_PKEY_NOT_VALID)
+3 -2
drivers/infiniband/core/user_mad.c
··· 1312 1312 struct ib_umad_file *file; 1313 1313 int id; 1314 1314 1315 + cdev_device_del(&port->sm_cdev, &port->sm_dev); 1316 + cdev_device_del(&port->cdev, &port->dev); 1317 + 1315 1318 mutex_lock(&port->file_mutex); 1316 1319 1317 1320 /* Mark ib_dev NULL and block ioctl or other file ops to progress ··· 1334 1331 1335 1332 mutex_unlock(&port->file_mutex); 1336 1333 1337 - cdev_device_del(&port->sm_cdev, &port->sm_dev); 1338 - cdev_device_del(&port->cdev, &port->dev); 1339 1334 ida_free(&umad_ida, port->dev_num); 1340 1335 1341 1336 /* balances device_initialize() */
+7 -8
drivers/infiniband/core/uverbs_cmd.c
··· 2745 2745 return 0; 2746 2746 } 2747 2747 2748 - static size_t kern_spec_filter_sz(const struct ib_uverbs_flow_spec_hdr *spec) 2749 - { 2750 - /* Returns user space filter size, includes padding */ 2751 - return (spec->size - sizeof(struct ib_uverbs_flow_spec_hdr)) / 2; 2752 - } 2753 - 2754 2748 static ssize_t spec_filter_size(const void *kern_spec_filter, u16 kern_filter_size, 2755 2749 u16 ib_real_filter_sz) 2756 2750 { ··· 2888 2894 static int kern_spec_to_ib_spec_filter(struct ib_uverbs_flow_spec *kern_spec, 2889 2895 union ib_flow_spec *ib_spec) 2890 2896 { 2891 - ssize_t kern_filter_sz; 2897 + size_t kern_filter_sz; 2892 2898 void *kern_spec_mask; 2893 2899 void *kern_spec_val; 2894 2900 2895 - kern_filter_sz = kern_spec_filter_sz(&kern_spec->hdr); 2901 + if (check_sub_overflow((size_t)kern_spec->hdr.size, 2902 + sizeof(struct ib_uverbs_flow_spec_hdr), 2903 + &kern_filter_sz)) 2904 + return -EINVAL; 2905 + 2906 + kern_filter_sz /= 2; 2896 2907 2897 2908 kern_spec_val = (void *)kern_spec + 2898 2909 sizeof(struct ib_uverbs_flow_spec_hdr);
+1
drivers/infiniband/core/uverbs_std_types.c
··· 220 220 list_for_each_entry_safe(entry, tmp, &event_queue->event_list, list) { 221 221 if (entry->counter) 222 222 list_del(&entry->obj_list); 223 + list_del(&entry->list); 223 224 kfree(entry); 224 225 } 225 226 spin_unlock_irq(&event_queue->lock);
+4
drivers/infiniband/hw/cxgb4/cm.c
··· 3036 3036 C4IW_QP_ATTR_NEXT_STATE, &attrs, 1); 3037 3037 } 3038 3038 3039 + /* As per draft-hilland-iwarp-verbs-v1.0, sec 6.2.3, 3040 + * when entering the TERM state the RNIC MUST initiate a CLOSE. 3041 + */ 3042 + c4iw_ep_disconnect(ep, 1, GFP_KERNEL); 3039 3043 c4iw_put_ep(&ep->com); 3040 3044 } else 3041 3045 pr_warn("TERM received tid %u no ep/qp\n", tid);
+2 -2
drivers/infiniband/hw/cxgb4/qp.c
··· 1948 1948 qhp->attr.layer_etype = attrs->layer_etype; 1949 1949 qhp->attr.ecode = attrs->ecode; 1950 1950 ep = qhp->ep; 1951 - c4iw_get_ep(&ep->com); 1952 - disconnect = 1; 1953 1951 if (!internal) { 1952 + c4iw_get_ep(&ep->com); 1954 1953 terminate = 1; 1954 + disconnect = 1; 1955 1955 } else { 1956 1956 terminate = qhp->attr.send_term; 1957 1957 ret = rdma_fini(rhp, qhp, ep);
+2
drivers/infiniband/hw/hfi1/affinity.c
··· 479 479 rvt_get_ibdev_name(&(dd)->verbs_dev.rdi), i, cpu); 480 480 } 481 481 482 + free_cpumask_var(available_cpus); 483 + free_cpumask_var(non_intr_cpus); 482 484 return 0; 483 485 484 486 fail:
+32 -20
drivers/infiniband/hw/hfi1/file_ops.c
··· 200 200 201 201 fd = kzalloc(sizeof(*fd), GFP_KERNEL); 202 202 203 - if (fd) { 204 - fd->rec_cpu_num = -1; /* no cpu affinity by default */ 205 - fd->mm = current->mm; 206 - mmgrab(fd->mm); 207 - fd->dd = dd; 208 - kobject_get(&fd->dd->kobj); 209 - fp->private_data = fd; 210 - } else { 211 - fp->private_data = NULL; 212 - 213 - if (atomic_dec_and_test(&dd->user_refcount)) 214 - complete(&dd->user_comp); 215 - 216 - return -ENOMEM; 217 - } 218 - 203 + if (!fd || init_srcu_struct(&fd->pq_srcu)) 204 + goto nomem; 205 + spin_lock_init(&fd->pq_rcu_lock); 206 + spin_lock_init(&fd->tid_lock); 207 + spin_lock_init(&fd->invalid_lock); 208 + fd->rec_cpu_num = -1; /* no cpu affinity by default */ 209 + fd->mm = current->mm; 210 + mmgrab(fd->mm); 211 + fd->dd = dd; 212 + kobject_get(&fd->dd->kobj); 213 + fp->private_data = fd; 219 214 return 0; 215 + nomem: 216 + kfree(fd); 217 + fp->private_data = NULL; 218 + if (atomic_dec_and_test(&dd->user_refcount)) 219 + complete(&dd->user_comp); 220 + return -ENOMEM; 220 221 } 221 222 222 223 static long hfi1_file_ioctl(struct file *fp, unsigned int cmd, ··· 302 301 static ssize_t hfi1_write_iter(struct kiocb *kiocb, struct iov_iter *from) 303 302 { 304 303 struct hfi1_filedata *fd = kiocb->ki_filp->private_data; 305 - struct hfi1_user_sdma_pkt_q *pq = fd->pq; 304 + struct hfi1_user_sdma_pkt_q *pq; 306 305 struct hfi1_user_sdma_comp_q *cq = fd->cq; 307 306 int done = 0, reqs = 0; 308 307 unsigned long dim = from->nr_segs; 308 + int idx; 309 309 310 - if (!cq || !pq) 310 + idx = srcu_read_lock(&fd->pq_srcu); 311 + pq = srcu_dereference(fd->pq, &fd->pq_srcu); 312 + if (!cq || !pq) { 313 + srcu_read_unlock(&fd->pq_srcu, idx); 311 314 return -EIO; 315 + } 312 316 313 - if (!iter_is_iovec(from) || !dim) 317 + if (!iter_is_iovec(from) || !dim) { 318 + srcu_read_unlock(&fd->pq_srcu, idx); 314 319 return -EINVAL; 320 + } 315 321 316 322 trace_hfi1_sdma_request(fd->dd, fd->uctxt->ctxt, fd->subctxt, dim); 317 323 318 - if (atomic_read(&pq->n_reqs) == pq->n_max_reqs) 324 + if (atomic_read(&pq->n_reqs) == pq->n_max_reqs) { 325 + srcu_read_unlock(&fd->pq_srcu, idx); 319 326 return -ENOSPC; 327 + } 320 328 321 329 while (dim) { 322 330 int ret; ··· 343 333 reqs++; 344 334 } 345 335 336 + srcu_read_unlock(&fd->pq_srcu, idx); 346 337 return reqs; 347 338 } 348 339 ··· 718 707 if (atomic_dec_and_test(&dd->user_refcount)) 719 708 complete(&dd->user_comp); 720 709 710 + cleanup_srcu_struct(&fdata->pq_srcu); 721 711 kfree(fdata); 722 712 return 0; 723 713 }
+4 -1
drivers/infiniband/hw/hfi1/hfi.h
··· 1444 1444 1445 1445 /* Private data for file operations */ 1446 1446 struct hfi1_filedata { 1447 + struct srcu_struct pq_srcu; 1447 1448 struct hfi1_devdata *dd; 1448 1449 struct hfi1_ctxtdata *uctxt; 1449 1450 struct hfi1_user_sdma_comp_q *cq; 1450 - struct hfi1_user_sdma_pkt_q *pq; 1451 + /* update side lock for SRCU */ 1452 + spinlock_t pq_rcu_lock; 1453 + struct hfi1_user_sdma_pkt_q __rcu *pq; 1451 1454 u16 subctxt; 1452 1455 /* for cpu affinity; -1 if none */ 1453 1456 int rec_cpu_num;
+2 -3
drivers/infiniband/hw/hfi1/user_exp_rcv.c
··· 87 87 { 88 88 int ret = 0; 89 89 90 - spin_lock_init(&fd->tid_lock); 91 - spin_lock_init(&fd->invalid_lock); 92 - 93 90 fd->entry_to_rb = kcalloc(uctxt->expected_count, 94 91 sizeof(struct rb_node *), 95 92 GFP_KERNEL); ··· 139 142 { 140 143 struct hfi1_ctxtdata *uctxt = fd->uctxt; 141 144 145 + mutex_lock(&uctxt->exp_mutex); 142 146 if (!EXP_TID_SET_EMPTY(uctxt->tid_full_list)) 143 147 unlock_exp_tids(uctxt, &uctxt->tid_full_list, fd); 144 148 if (!EXP_TID_SET_EMPTY(uctxt->tid_used_list)) 145 149 unlock_exp_tids(uctxt, &uctxt->tid_used_list, fd); 150 + mutex_unlock(&uctxt->exp_mutex); 146 151 147 152 kfree(fd->invalid_tids); 148 153 fd->invalid_tids = NULL;
+12 -5
drivers/infiniband/hw/hfi1/user_sdma.c
··· 179 179 pq = kzalloc(sizeof(*pq), GFP_KERNEL); 180 180 if (!pq) 181 181 return -ENOMEM; 182 - 183 182 pq->dd = dd; 184 183 pq->ctxt = uctxt->ctxt; 185 184 pq->subctxt = fd->subctxt; ··· 235 236 goto pq_mmu_fail; 236 237 } 237 238 238 - fd->pq = pq; 239 + rcu_assign_pointer(fd->pq, pq); 239 240 fd->cq = cq; 240 241 241 242 return 0; ··· 263 264 264 265 trace_hfi1_sdma_user_free_queues(uctxt->dd, uctxt->ctxt, fd->subctxt); 265 266 266 - pq = fd->pq; 267 + spin_lock(&fd->pq_rcu_lock); 268 + pq = srcu_dereference_check(fd->pq, &fd->pq_srcu, 269 + lockdep_is_held(&fd->pq_rcu_lock)); 267 270 if (pq) { 271 + rcu_assign_pointer(fd->pq, NULL); 272 + spin_unlock(&fd->pq_rcu_lock); 273 + synchronize_srcu(&fd->pq_srcu); 274 + /* at this point there can be no more new requests */ 268 275 if (pq->handler) 269 276 hfi1_mmu_rb_unregister(pq->handler); 270 277 iowait_sdma_drain(&pq->busy); ··· 282 277 kfree(pq->req_in_use); 283 278 kmem_cache_destroy(pq->txreq_cache); 284 279 kfree(pq); 285 - fd->pq = NULL; 280 + } else { 281 + spin_unlock(&fd->pq_rcu_lock); 286 282 } 287 283 if (fd->cq) { 288 284 vfree(fd->cq->comps); ··· 327 321 { 328 322 int ret = 0, i; 329 323 struct hfi1_ctxtdata *uctxt = fd->uctxt; 330 - struct hfi1_user_sdma_pkt_q *pq = fd->pq; 324 + struct hfi1_user_sdma_pkt_q *pq = 325 + srcu_dereference(fd->pq, &fd->pq_srcu); 331 326 struct hfi1_user_sdma_comp_q *cq = fd->cq; 332 327 struct hfi1_devdata *dd = pq->dd; 333 328 unsigned long idx = 0;
+28 -23
drivers/infiniband/hw/mlx5/devx.c
··· 2319 2319 2320 2320 if (ev_file->omit_data) { 2321 2321 spin_lock_irqsave(&ev_file->lock, flags); 2322 - if (!list_empty(&event_sub->event_list)) { 2322 + if (!list_empty(&event_sub->event_list) || 2323 + ev_file->is_destroyed) { 2323 2324 spin_unlock_irqrestore(&ev_file->lock, flags); 2324 2325 return 0; 2325 2326 } 2326 2327 2327 - /* is_destroyed is ignored here because we don't have any memory 2328 - * allocation to clean up for the omit_data case 2329 - */ 2330 2328 list_add_tail(&event_sub->event_list, &ev_file->event_list); 2331 2329 spin_unlock_irqrestore(&ev_file->lock, flags); 2332 2330 wake_up_interruptible(&ev_file->poll_wait); ··· 2471 2473 return -ERESTARTSYS; 2472 2474 } 2473 2475 2474 - if (list_empty(&ev_queue->event_list) && 2475 - ev_queue->is_destroyed) 2476 - return -EIO; 2477 - 2478 2476 spin_lock_irq(&ev_queue->lock); 2477 + if (ev_queue->is_destroyed) { 2478 + spin_unlock_irq(&ev_queue->lock); 2479 + return -EIO; 2480 + } 2479 2481 } 2480 2482 2481 2483 event = list_entry(ev_queue->event_list.next, ··· 2549 2551 return -EOVERFLOW; 2550 2552 } 2551 2553 2552 - if (ev_file->is_destroyed) { 2553 - spin_unlock_irq(&ev_file->lock); 2554 - return -EIO; 2555 - } 2556 2554 2557 2555 while (list_empty(&ev_file->event_list)) { 2558 2556 spin_unlock_irq(&ev_file->lock); ··· 2661 2667 2662 2668 spin_lock_irq(&comp_ev_file->ev_queue.lock); 2663 2669 list_for_each_entry_safe(entry, tmp, 2664 - &comp_ev_file->ev_queue.event_list, list) 2670 + &comp_ev_file->ev_queue.event_list, list) { 2671 + list_del(&entry->list); 2665 2672 kvfree(entry); 2673 + } 2666 2674 spin_unlock_irq(&comp_ev_file->ev_queue.lock); 2667 2675 return 0; 2668 2676 }; ··· 2676 2680 container_of(uobj, struct devx_async_event_file, 2677 2681 uobj); 2678 2682 struct devx_event_subscription *event_sub, *event_sub_tmp; 2679 - struct devx_async_event_data *entry, *tmp; 2680 2683 struct mlx5_ib_dev *dev = ev_file->dev; 2681 2684 2682 2685 spin_lock_irq(&ev_file->lock); 2683 2686 ev_file->is_destroyed = 1; 2687 + 2688 + /* free the pending events allocation */ 2689 + if (ev_file->omit_data) { 2690 + struct devx_event_subscription *event_sub, *tmp; 2691 + 2692 + list_for_each_entry_safe(event_sub, tmp, &ev_file->event_list, 2693 + event_list) 2694 + list_del_init(&event_sub->event_list); 2695 + 2696 + } else { 2697 + struct devx_async_event_data *entry, *tmp; 2698 + 2699 + list_for_each_entry_safe(entry, tmp, &ev_file->event_list, 2700 + list) { 2701 + list_del(&entry->list); 2702 + kfree(entry); 2703 + } 2704 + } 2705 + 2684 2706 spin_unlock_irq(&ev_file->lock); 2685 2707 wake_up_interruptible(&ev_file->poll_wait); 2686 2708 ··· 2712 2698 call_rcu(&event_sub->rcu, devx_free_subscription); 2713 2699 } 2714 2700 mutex_unlock(&dev->devx_event_table.event_xa_lock); 2715 - 2716 - /* free the pending events allocation */ 2717 - if (!ev_file->omit_data) { 2718 - spin_lock_irq(&ev_file->lock); 2719 - list_for_each_entry_safe(entry, tmp, 2720 - &ev_file->event_list, list) 2721 - kfree(entry); /* read can't come any more */ 2722 - spin_unlock_irq(&ev_file->lock); 2723 - } 2724 2701 2725 2702 put_device(&dev->ib_dev.dev); 2726 2703 return 0;
+3 -3
drivers/infiniband/hw/mlx5/main.c
··· 2283 2283 2284 2284 static u64 mlx5_entry_to_mmap_offset(struct mlx5_user_mmap_entry *entry) 2285 2285 { 2286 - u16 cmd = entry->rdma_entry.start_pgoff >> 16; 2287 - u16 index = entry->rdma_entry.start_pgoff & 0xFFFF; 2286 + u64 cmd = (entry->rdma_entry.start_pgoff >> 16) & 0xFFFF; 2287 + u64 index = entry->rdma_entry.start_pgoff & 0xFFFF; 2288 2288 2289 2289 return (((index >> 8) << 16) | (cmd << MLX5_IB_MMAP_CMD_SHIFT) | 2290 2290 (index & 0xFF)) << PAGE_SHIFT; ··· 6545 6545 doorbell_bar_offset); 6546 6546 bar_size = (1ULL << log_doorbell_bar_size) * 4096; 6547 6547 var_table->stride_size = 1ULL << log_doorbell_stride; 6548 - var_table->num_var_hw_entries = bar_size / var_table->stride_size; 6548 + var_table->num_var_hw_entries = div64_u64(bar_size, var_table->stride_size); 6549 6549 mutex_init(&var_table->bitmap_lock); 6550 6550 var_table->bitmap = bitmap_zalloc(var_table->num_var_hw_entries, 6551 6551 GFP_KERNEL);
+6 -3
drivers/infiniband/hw/mlx5/qp.c
··· 3441 3441 struct mlx5_ib_qp_base *base; 3442 3442 u32 set_id; 3443 3443 3444 - if (!MLX5_CAP_GEN(dev->mdev, rts2rts_qp_counters_set_id)) 3445 - return 0; 3446 - 3447 3444 if (counter) 3448 3445 set_id = counter->id; 3449 3446 else ··· 6573 6576 */ 6574 6577 int mlx5_ib_qp_set_counter(struct ib_qp *qp, struct rdma_counter *counter) 6575 6578 { 6579 + struct mlx5_ib_dev *dev = to_mdev(qp->device); 6576 6580 struct mlx5_ib_qp *mqp = to_mqp(qp); 6577 6581 int err = 0; 6578 6582 6579 6583 mutex_lock(&mqp->mutex); 6580 6584 if (mqp->state == IB_QPS_RESET) { 6581 6585 qp->counter = counter; 6586 + goto out; 6587 + } 6588 + 6589 + if (!MLX5_CAP_GEN(dev->mdev, rts2rts_qp_counters_set_id)) { 6590 + err = -EOPNOTSUPP; 6582 6591 goto out; 6583 6592 } 6584 6593
+51 -33
drivers/infiniband/sw/rdmavt/qp.c
··· 61 61 #define RVT_RWQ_COUNT_THRESHOLD 16 62 62 63 63 static void rvt_rc_timeout(struct timer_list *t); 64 + static void rvt_reset_qp(struct rvt_dev_info *rdi, struct rvt_qp *qp, 65 + enum ib_qp_type type); 64 66 65 67 /* 66 68 * Convert the AETH RNR timeout code into the number of microseconds. ··· 454 452 } 455 453 456 454 /** 457 - * free_all_qps - check for QPs still in use 455 + * rvt_free_qp_cb - callback function to reset a qp 456 + * @qp: the qp to reset 457 + * @v: a 64-bit value 458 + * 459 + * This function resets the qp and removes it from the 460 + * qp hash table. 461 + */ 462 + static void rvt_free_qp_cb(struct rvt_qp *qp, u64 v) 463 + { 464 + unsigned int *qp_inuse = (unsigned int *)v; 465 + struct rvt_dev_info *rdi = ib_to_rvt(qp->ibqp.device); 466 + 467 + /* Reset the qp and remove it from the qp hash list */ 468 + rvt_reset_qp(rdi, qp, qp->ibqp.qp_type); 469 + 470 + /* Increment the qp_inuse count */ 471 + (*qp_inuse)++; 472 + } 473 + 474 + /** 475 + * rvt_free_all_qps - check for QPs still in use 458 476 * @rdi: rvt device info structure 459 477 * 460 478 * There should not be any QPs still in use. 461 479 * Free memory for table. 480 + * Return the number of QPs still in use. 462 481 */ 463 482 static unsigned rvt_free_all_qps(struct rvt_dev_info *rdi) 464 483 { 465 - unsigned long flags; 466 - struct rvt_qp *qp; 467 - unsigned n, qp_inuse = 0; 468 - spinlock_t *ql; /* work around too long line below */ 469 - 470 - if (rdi->driver_f.free_all_qps) 471 - qp_inuse = rdi->driver_f.free_all_qps(rdi); 484 + unsigned int qp_inuse = 0; 472 485 473 486 qp_inuse += rvt_mcast_tree_empty(rdi); 474 487 475 - if (!rdi->qp_dev) 476 - return qp_inuse; 488 + rvt_qp_iter(rdi, (u64)&qp_inuse, rvt_free_qp_cb); 477 489 478 - ql = &rdi->qp_dev->qpt_lock; 479 - spin_lock_irqsave(ql, flags); 480 - for (n = 0; n < rdi->qp_dev->qp_table_size; n++) { 481 - qp = rcu_dereference_protected(rdi->qp_dev->qp_table[n], 482 - lockdep_is_held(ql)); 483 - RCU_INIT_POINTER(rdi->qp_dev->qp_table[n], NULL); 484 - 485 - for (; qp; qp = rcu_dereference_protected(qp->next, 486 - lockdep_is_held(ql))) 487 - qp_inuse++; 488 - } 489 - spin_unlock_irqrestore(ql, flags); 490 - synchronize_rcu(); 491 490 return qp_inuse; 492 491 } 493 492 ··· 905 902 } 906 903 907 904 /** 908 - * rvt_reset_qp - initialize the QP state to the reset state 905 + * _rvt_reset_qp - initialize the QP state to the reset state 909 906 * @qp: the QP to reset 910 907 * @type: the QP type 911 908 * 912 909 * r_lock, s_hlock, and s_lock are required to be held by the caller 913 910 */ 914 - static void rvt_reset_qp(struct rvt_dev_info *rdi, struct rvt_qp *qp, 915 - enum ib_qp_type type) 911 + static void _rvt_reset_qp(struct rvt_dev_info *rdi, struct rvt_qp *qp, 912 + enum ib_qp_type type) 916 913 __must_hold(&qp->s_lock) 917 914 __must_hold(&qp->s_hlock) 918 915 __must_hold(&qp->r_lock) ··· 956 953 lockdep_assert_held(&qp->r_lock); 957 954 lockdep_assert_held(&qp->s_hlock); 958 955 lockdep_assert_held(&qp->s_lock); 956 + } 957 + 958 + /** 959 + * rvt_reset_qp - initialize the QP state to the reset state 960 + * @rdi: the device info 961 + * @qp: the QP to reset 962 + * @type: the QP type 963 + * 964 + * This is the wrapper function to acquire the r_lock, s_hlock, and s_lock 965 + * before calling _rvt_reset_qp(). 966 + */ 967 + static void rvt_reset_qp(struct rvt_dev_info *rdi, struct rvt_qp *qp, 968 + enum ib_qp_type type) 969 + { 970 + spin_lock_irq(&qp->r_lock); 971 + spin_lock(&qp->s_hlock); 972 + spin_lock(&qp->s_lock); 973 + _rvt_reset_qp(rdi, qp, type); 974 + spin_unlock(&qp->s_lock); 975 + spin_unlock(&qp->s_hlock); 976 + spin_unlock_irq(&qp->r_lock); 959 977 } 960 978 961 979 /** rvt_free_qpn - Free a qpn from the bit map ··· 1570 1546 switch (new_state) { 1571 1547 case IB_QPS_RESET: 1572 1548 if (qp->state != IB_QPS_RESET) 1573 - rvt_reset_qp(rdi, qp, ibqp->qp_type); 1549 + _rvt_reset_qp(rdi, qp, ibqp->qp_type); 1574 1550 break; 1575 1551 1576 1552 case IB_QPS_RTR: ··· 1719 1695 struct rvt_qp *qp = ibqp_to_rvtqp(ibqp); 1720 1696 struct rvt_dev_info *rdi = ib_to_rvt(ibqp->device); 1721 1697 1722 - spin_lock_irq(&qp->r_lock); 1723 - spin_lock(&qp->s_hlock); 1724 - spin_lock(&qp->s_lock); 1725 1698 rvt_reset_qp(rdi, qp, ibqp->qp_type); 1726 - spin_unlock(&qp->s_lock); 1727 - spin_unlock(&qp->s_hlock); 1728 - spin_unlock_irq(&qp->r_lock); 1729 1699 1730 1700 wait_event(qp->wait, !atomic_read(&qp->refcount)); 1731 1701 /* qpn is now available for use again */
+4 -4
drivers/infiniband/sw/rxe/rxe_comp.c
··· 329 329 qp->comp.psn = pkt->psn; 330 330 if (qp->req.wait_psn) { 331 331 qp->req.wait_psn = 0; 332 - rxe_run_task(&qp->req.task, 1); 332 + rxe_run_task(&qp->req.task, 0); 333 333 } 334 334 } 335 335 return COMPST_ERROR_RETRY; ··· 463 463 */ 464 464 if (qp->req.wait_fence) { 465 465 qp->req.wait_fence = 0; 466 - rxe_run_task(&qp->req.task, 1); 466 + rxe_run_task(&qp->req.task, 0); 467 467 } 468 468 } 469 469 ··· 479 479 if (qp->req.need_rd_atomic) { 480 480 qp->comp.timeout_retry = 0; 481 481 qp->req.need_rd_atomic = 0; 482 - rxe_run_task(&qp->req.task, 1); 482 + rxe_run_task(&qp->req.task, 0); 483 483 } 484 484 } 485 485 ··· 725 725 RXE_CNT_COMP_RETRY); 726 726 qp->req.need_retry = 1; 727 727 qp->comp.started_retry = 1; 728 - rxe_run_task(&qp->req.task, 1); 728 + rxe_run_task(&qp->req.task, 0); 729 729 } 730 730 731 731 if (pkt) {
+2 -3
drivers/infiniband/sw/siw/siw_cm.c
··· 1225 1225 read_lock(&sk->sk_callback_lock); 1226 1226 1227 1227 cep = sk_to_cep(sk); 1228 - if (!cep) { 1229 - WARN_ON(1); 1228 + if (!cep) 1230 1229 goto out; 1231 - } 1230 + 1232 1231 siw_dbg_cep(cep, "state: %d\n", cep->state); 1233 1232 1234 1233 switch (cep->state) {
+1 -1
drivers/input/keyboard/goldfish_events.c
··· 30 30 struct input_dev *input; 31 31 int irq; 32 32 void __iomem *addr; 33 - char name[0]; 33 + char name[]; 34 34 }; 35 35 36 36 static irqreturn_t events_interrupt(int irq, void *dev_id)
+1 -1
drivers/input/keyboard/gpio_keys.c
··· 55 55 struct input_dev *input; 56 56 struct mutex disable_lock; 57 57 unsigned short *keymap; 58 - struct gpio_button_data data[0]; 58 + struct gpio_button_data data[]; 59 59 }; 60 60 61 61 /*
+1 -1
drivers/input/keyboard/gpio_keys_polled.c
··· 38 38 const struct gpio_keys_platform_data *pdata; 39 39 unsigned long rel_axis_seen[BITS_TO_LONGS(REL_CNT)]; 40 40 unsigned long abs_axis_seen[BITS_TO_LONGS(ABS_CNT)]; 41 - struct gpio_keys_button_data data[0]; 41 + struct gpio_keys_button_data data[]; 42 42 }; 43 43 44 44 static void gpio_keys_button_event(struct input_dev *input,
+2 -2
drivers/input/keyboard/tca6416-keypad.c
··· 33 33 34 34 struct tca6416_drv_data { 35 35 struct input_dev *input; 36 - struct tca6416_button data[0]; 36 + struct tca6416_button data[]; 37 37 }; 38 38 39 39 struct tca6416_keypad_chip { ··· 48 48 int irqnum; 49 49 u16 pinmask; 50 50 bool use_polling; 51 - struct tca6416_button buttons[0]; 51 + struct tca6416_button buttons[]; 52 52 }; 53 53 54 54 static int tca6416_write_reg(struct tca6416_keypad_chip *chip, int reg, u16 val)
+4 -4
drivers/input/mouse/cyapa_gen5.c
··· 250 250 251 251 struct cyapa_tsg_bin_image { 252 252 struct cyapa_tsg_bin_image_head image_head; 253 - struct cyapa_tsg_bin_image_data_record records[0]; 253 + struct cyapa_tsg_bin_image_data_record records[]; 254 254 } __packed; 255 255 256 256 struct pip_bl_packet_start { ··· 271 271 u8 report_id; /* Bootloader output report id, must be 40h */ 272 272 u8 rsvd; /* Reserved, must be 0 */ 273 273 struct pip_bl_packet_start packet_start; 274 - u8 data[0]; /* Command data variable based on commands */ 274 + u8 data[]; /* Command data variable based on commands */ 275 275 } __packed; 276 276 277 277 /* Initiate bootload command data structure. */ ··· 300 300 struct tsg_bl_flash_row_head { 301 301 u8 flash_array_id; 302 302 __le16 flash_row_id; 303 - u8 flash_data[0]; 303 + u8 flash_data[]; 304 304 } __packed; 305 305 306 306 struct pip_app_cmd_head { ··· 314 314 * Bit 6-0: command code. 315 315 */ 316 316 u8 cmd_code; 317 - u8 parameter_data[0]; /* Parameter data variable based on cmd_code */ 317 + u8 parameter_data[]; /* Parameter data variable based on cmd_code */ 318 318 } __packed; 319 319 320 320 /* Application get/set parameter command data structure */
+5 -3
drivers/input/mouse/psmouse-smbus.c
··· 190 190 struct psmouse_smbus_dev *smbdev = data; 191 191 unsigned short addr_list[] = { smbdev->board.addr, I2C_CLIENT_END }; 192 192 struct i2c_adapter *adapter; 193 + struct i2c_client *client; 193 194 194 195 adapter = i2c_verify_adapter(dev); 195 196 if (!adapter) ··· 199 198 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_HOST_NOTIFY)) 200 199 return 0; 201 200 202 - smbdev->client = i2c_new_probed_device(adapter, &smbdev->board, 203 - addr_list, NULL); 204 - if (!smbdev->client) 201 + client = i2c_new_scanned_device(adapter, &smbdev->board, 202 + addr_list, NULL); 203 + if (IS_ERR(client)) 205 204 return 0; 206 205 207 206 /* We have our(?) device, stop iterating i2c bus. */ 207 + smbdev->client = client; 208 208 return 1; 209 209 } 210 210
+3 -1
drivers/input/mouse/synaptics.c
··· 146 146 "LEN0042", /* Yoga */ 147 147 "LEN0045", 148 148 "LEN0047", 149 - "LEN0049", 150 149 "LEN2000", /* S540 */ 151 150 "LEN2001", /* Edge E431 */ 152 151 "LEN2002", /* Edge E531 */ ··· 165 166 /* all of the topbuttonpad_pnp_ids are valid, we just add some extras */ 166 167 "LEN0048", /* X1 Carbon 3 */ 167 168 "LEN0046", /* X250 */ 169 + "LEN0049", /* Yoga 11e */ 168 170 "LEN004a", /* W541 */ 169 171 "LEN005b", /* P50 */ 170 172 "LEN005e", /* T560 */ 173 + "LEN006c", /* T470s */ 171 174 "LEN0071", /* T480 */ 172 175 "LEN0072", /* X1 Carbon Gen 5 (2017) - Elan/ALPS trackpoint */ 173 176 "LEN0073", /* X1 Carbon G5 (Elantech) */ ··· 180 179 "LEN0097", /* X280 -> ALPS trackpoint */ 181 180 "LEN009b", /* T580 */ 182 181 "LEN200f", /* T450s */ 182 + "LEN2044", /* L470 */ 183 183 "LEN2054", /* E480 */ 184 184 "LEN2055", /* E580 */ 185 185 "SYN3052", /* HP EliteBook 840 G4 */
+33 -1
drivers/input/touchscreen/ili210x.c
··· 167 167 .resolution = 2048, 168 168 }; 169 169 170 + static bool ili212x_touchdata_to_coords(const u8 *touchdata, 171 + unsigned int finger, 172 + unsigned int *x, unsigned int *y) 173 + { 174 + u16 val; 175 + 176 + val = get_unaligned_be16(touchdata + 3 + (finger * 5) + 0); 177 + if (!(val & BIT(15))) /* Touch indication */ 178 + return false; 179 + 180 + *x = val & 0x3fff; 181 + *y = get_unaligned_be16(touchdata + 3 + (finger * 5) + 2); 182 + 183 + return true; 184 + } 185 + 186 + static bool ili212x_check_continue_polling(const u8 *data, bool touch) 187 + { 188 + return touch; 189 + } 190 + 191 + static const struct ili2xxx_chip ili212x_chip = { 192 + .read_reg = ili210x_read_reg, 193 + .get_touch_data = ili210x_read_touch_data, 194 + .parse_touch_data = ili212x_touchdata_to_coords, 195 + .continue_polling = ili212x_check_continue_polling, 196 + .max_touches = 10, 197 + .has_calibrate_reg = true, 198 + }; 199 + 170 200 static int ili251x_read_reg(struct i2c_client *client, 171 201 u8 reg, void *buf, size_t len) 172 202 { ··· 351 321 struct i2c_client *client = to_i2c_client(dev); 352 322 struct ili210x *priv = i2c_get_clientdata(client); 353 323 354 - return priv->chip->has_calibrate_reg; 324 + return priv->chip->has_calibrate_reg ? attr->mode : 0; 355 325 } 356 326 357 327 static const struct attribute_group ili210x_attr_group = { ··· 477 447 static const struct i2c_device_id ili210x_i2c_id[] = { 478 448 { "ili210x", (long)&ili210x_chip }, 479 449 { "ili2117", (long)&ili211x_chip }, 450 + { "ili2120", (long)&ili212x_chip }, 480 451 { "ili251x", (long)&ili251x_chip }, 481 452 { } 482 453 }; ··· 486 455 static const struct of_device_id ili210x_dt_ids[] = { 487 456 { .compatible = "ilitek,ili210x", .data = &ili210x_chip }, 488 457 { .compatible = "ilitek,ili2117", .data = &ili211x_chip }, 458 + { .compatible = "ilitek,ili2120", .data = &ili212x_chip }, 489 459 { .compatible = "ilitek,ili251x", .data = &ili251x_chip }, 490 460 { } 491 461 };
+16 -2
drivers/md/bcache/alloc.c
··· 67 67 #include <linux/blkdev.h> 68 68 #include <linux/kthread.h> 69 69 #include <linux/random.h> 70 + #include <linux/sched/signal.h> 70 71 #include <trace/events/bcache.h> 71 72 72 73 #define MAX_OPEN_BUCKETS 128 ··· 734 733 735 734 int bch_cache_allocator_start(struct cache *ca) 736 735 { 737 - struct task_struct *k = kthread_run(bch_allocator_thread, 738 - ca, "bcache_allocator"); 736 + struct task_struct *k; 737 + 738 + /* 739 + * In case previous btree check operation occupies too many 740 + * system memory for bcache btree node cache, and the 741 + * registering process is selected by OOM killer. Here just 742 + * ignore the SIGKILL sent by OOM killer if there is, to 743 + * avoid kthread_run() being failed by pending signals. The 744 + * bcache registering process will exit after the registration 745 + * done. 746 + */ 747 + if (signal_pending(current)) 748 + flush_signals(current); 749 + 750 + k = kthread_run(bch_allocator_thread, ca, "bcache_allocator"); 739 751 if (IS_ERR(k)) 740 752 return PTR_ERR(k); 741 753
+13
drivers/md/bcache/btree.c
··· 34 34 #include <linux/random.h> 35 35 #include <linux/rcupdate.h> 36 36 #include <linux/sched/clock.h> 37 + #include <linux/sched/signal.h> 37 38 #include <linux/rculist.h> 38 39 #include <linux/delay.h> 39 40 #include <trace/events/bcache.h> ··· 1914 1913 1915 1914 int bch_gc_thread_start(struct cache_set *c) 1916 1915 { 1916 + /* 1917 + * In case previous btree check operation occupies too many 1918 + * system memory for bcache btree node cache, and the 1919 + * registering process is selected by OOM killer. Here just 1920 + * ignore the SIGKILL sent by OOM killer if there is, to 1921 + * avoid kthread_run() being failed by pending signals. The 1922 + * bcache registering process will exit after the registration 1923 + * done. 1924 + */ 1925 + if (signal_pending(current)) 1926 + flush_signals(current); 1927 + 1917 1928 c->gc_thread = kthread_run(bch_gc_thread, c, "bcache_gc"); 1918 1929 return PTR_ERR_OR_ZERO(c->gc_thread); 1919 1930 }
+2 -5
drivers/md/bcache/journal.c
··· 417 417 418 418 /* Journalling */ 419 419 420 - #define nr_to_fifo_front(p, front_p, mask) (((p) - (front_p)) & (mask)) 421 - 422 420 static void btree_flush_write(struct cache_set *c) 423 421 { 424 422 struct btree *b, *t, *btree_nodes[BTREE_FLUSH_NR]; ··· 508 510 * journal entry can be reclaimed). These selected nodes 509 511 * will be ignored and skipped in the folowing for-loop. 510 512 */ 511 - if (nr_to_fifo_front(btree_current_write(b)->journal, 512 - fifo_front_p, 513 - mask) != 0) { 513 + if (((btree_current_write(b)->journal - fifo_front_p) & 514 + mask) != 0) { 514 515 mutex_unlock(&b->write_lock); 515 516 continue; 516 517 }
-17
drivers/md/bcache/super.c
··· 1917 1917 if (bch_btree_check(c)) 1918 1918 goto err; 1919 1919 1920 - /* 1921 - * bch_btree_check() may occupy too much system memory which 1922 - * has negative effects to user space application (e.g. data 1923 - * base) performance. Shrink the mca cache memory proactively 1924 - * here to avoid competing memory with user space workloads.. 1925 - */ 1926 - if (!c->shrinker_disabled) { 1927 - struct shrink_control sc; 1928 - 1929 - sc.gfp_mask = GFP_KERNEL; 1930 - sc.nr_to_scan = c->btree_cache_used * c->btree_pages; 1931 - /* first run to clear b->accessed tag */ 1932 - c->shrink.scan_objects(&c->shrink, &sc); 1933 - /* second run to reap non-accessed nodes */ 1934 - c->shrink.scan_objects(&c->shrink, &sc); 1935 - } 1936 - 1937 1920 bch_journal_mark(c, &journal); 1938 1921 bch_initial_gc_finish(c); 1939 1922 pr_debug("btree_check() done");
+6 -6
drivers/net/dsa/mv88e6xxx/chip.h
··· 236 236 bool mirror_ingress; 237 237 bool mirror_egress; 238 238 unsigned int serdes_irq; 239 - char serdes_irq_name[32]; 239 + char serdes_irq_name[64]; 240 240 }; 241 241 242 242 struct mv88e6xxx_chip { ··· 293 293 struct mv88e6xxx_irq g1_irq; 294 294 struct mv88e6xxx_irq g2_irq; 295 295 int irq; 296 - char irq_name[32]; 296 + char irq_name[64]; 297 297 int device_irq; 298 - char device_irq_name[32]; 298 + char device_irq_name[64]; 299 299 int watchdog_irq; 300 - char watchdog_irq_name[32]; 300 + char watchdog_irq_name[64]; 301 301 302 302 int atu_prob_irq; 303 - char atu_prob_irq_name[32]; 303 + char atu_prob_irq_name[64]; 304 304 int vtu_prob_irq; 305 - char vtu_prob_irq_name[32]; 305 + char vtu_prob_irq_name[64]; 306 306 struct kthread_worker *kworker; 307 307 struct kthread_delayed_work irq_poll_work; 308 308
+58 -38
drivers/net/ethernet/amazon/ena/ena_com.c
··· 200 200 static struct ena_comp_ctx *get_comp_ctxt(struct ena_com_admin_queue *queue, 201 201 u16 command_id, bool capture) 202 202 { 203 + if (unlikely(!queue->comp_ctx)) { 204 + pr_err("Completion context is NULL\n"); 205 + return NULL; 206 + } 207 + 203 208 if (unlikely(command_id >= queue->q_depth)) { 204 209 pr_err("command id is larger than the queue size. cmd_id: %u queue size %d\n", 205 210 command_id, queue->q_depth); ··· 1046 1041 feature_ver); 1047 1042 } 1048 1043 1044 + int ena_com_get_current_hash_function(struct ena_com_dev *ena_dev) 1045 + { 1046 + return ena_dev->rss.hash_func; 1047 + } 1048 + 1049 + static void ena_com_hash_key_fill_default_key(struct ena_com_dev *ena_dev) 1050 + { 1051 + struct ena_admin_feature_rss_flow_hash_control *hash_key = 1052 + (ena_dev->rss).hash_key; 1053 + 1054 + netdev_rss_key_fill(&hash_key->key, sizeof(hash_key->key)); 1055 + /* The key is stored in the device in u32 array 1056 + * as well as the API requires the key to be passed in this 1057 + * format. Thus the size of our array should be divided by 4 1058 + */ 1059 + hash_key->keys_num = sizeof(hash_key->key) / sizeof(u32); 1060 + } 1061 + 1049 1062 static int ena_com_hash_key_allocate(struct ena_com_dev *ena_dev) 1050 1063 { 1051 1064 struct ena_rss *rss = &ena_dev->rss; 1065 + struct ena_admin_feature_rss_flow_hash_control *hash_key; 1066 + struct ena_admin_get_feat_resp get_resp; 1067 + int rc; 1068 + 1069 + hash_key = (ena_dev->rss).hash_key; 1070 + 1071 + rc = ena_com_get_feature_ex(ena_dev, &get_resp, 1072 + ENA_ADMIN_RSS_HASH_FUNCTION, 1073 + ena_dev->rss.hash_key_dma_addr, 1074 + sizeof(ena_dev->rss.hash_key), 0); 1075 + if (unlikely(rc)) { 1076 + hash_key = NULL; 1077 + return -EOPNOTSUPP; 1078 + } 1052 1079 1053 1080 rss->hash_key = 1054 1081 dma_alloc_coherent(ena_dev->dmadev, sizeof(*rss->hash_key), ··· 1286 1249 return -EINVAL; 1287 1250 1288 1251 rss->rss_ind_tbl[i].cq_idx = io_sq->idx; 1289 - } 1290 - 1291 - return 0; 1292 - } 1293 - 1294 - static int ena_com_ind_tbl_convert_from_device(struct ena_com_dev *ena_dev) 1295 - { 1296 - u16 dev_idx_to_host_tbl[ENA_TOTAL_NUM_QUEUES] = { (u16)-1 }; 1297 - struct ena_rss *rss = &ena_dev->rss; 1298 - u8 idx; 1299 - u16 i; 1300 - 1301 - for (i = 0; i < ENA_TOTAL_NUM_QUEUES; i++) 1302 - dev_idx_to_host_tbl[ena_dev->io_sq_queues[i].idx] = i; 1303 - 1304 - for (i = 0; i < 1 << rss->tbl_log_size; i++) { 1305 - if (rss->rss_ind_tbl[i].cq_idx > ENA_TOTAL_NUM_QUEUES) 1306 - return -EINVAL; 1307 - idx = (u8)rss->rss_ind_tbl[i].cq_idx; 1308 - 1309 - if (dev_idx_to_host_tbl[idx] > ENA_TOTAL_NUM_QUEUES) 1310 - return -EINVAL; 1311 - 1312 - rss->host_rss_ind_tbl[i] = dev_idx_to_host_tbl[idx]; 1313 1252 } 1314 1253 1315 1254 return 0; ··· 2310 2297 2311 2298 switch (func) { 2312 2299 case ENA_ADMIN_TOEPLITZ: 2313 - if (key_len > sizeof(hash_key->key)) { 2314 - pr_err("key len (%hu) is bigger than the max supported (%zu)\n", 2315 - key_len, sizeof(hash_key->key)); 2316 - return -EINVAL; 2300 + if (key) { 2301 + if (key_len != sizeof(hash_key->key)) { 2302 + pr_err("key len (%hu) doesn't equal the supported size (%zu)\n", 2303 + key_len, sizeof(hash_key->key)); 2304 + return -EINVAL; 2305 + } 2306 + memcpy(hash_key->key, key, key_len); 2307 + rss->hash_init_val = init_val; 2308 + hash_key->keys_num = key_len >> 2; 2317 2309 } 2318 - 2319 - memcpy(hash_key->key, key, key_len); 2320 - rss->hash_init_val = init_val; 2321 - hash_key->keys_num = key_len >> 2; 2322 2310 break; 2323 2311 case ENA_ADMIN_CRC32: 2324 2312 rss->hash_init_val = init_val; ··· 2356 2342 if (unlikely(rc)) 2357 2343 return rc; 2358 2344 2359 - rss->hash_func = get_resp.u.flow_hash_func.selected_func; 2345 + /* ffs() returns 1 in case the lsb is set */ 2346 + rss->hash_func = ffs(get_resp.u.flow_hash_func.selected_func); 2347 + if (rss->hash_func) 2348 + rss->hash_func--; 2349 + 2360 2350 if (func) 2361 2351 *func = rss->hash_func; 2362 2352 ··· 2624 2606 if (!ind_tbl) 2625 2607 return 0; 2626 2608 2627 - rc = ena_com_ind_tbl_convert_from_device(ena_dev); 2628 - if (unlikely(rc)) 2629 - return rc; 2630 - 2631 2609 for (i = 0; i < (1 << rss->tbl_log_size); i++) 2632 2610 ind_tbl[i] = rss->host_rss_ind_tbl[i]; 2633 2611 ··· 2640 2626 if (unlikely(rc)) 2641 2627 goto err_indr_tbl; 2642 2628 2629 + /* The following function might return unsupported in case the 2630 + * device doesn't support setting the key / hash function. We can safely 2631 + * ignore this error and have indirection table support only. 2632 + */ 2643 2633 rc = ena_com_hash_key_allocate(ena_dev); 2644 - if (unlikely(rc)) 2634 + if (unlikely(rc) && rc != -EOPNOTSUPP) 2645 2635 goto err_hash_key; 2636 + else if (rc != -EOPNOTSUPP) 2637 + ena_com_hash_key_fill_default_key(ena_dev); 2646 2638 2647 2639 rc = ena_com_hash_ctrl_init(ena_dev); 2648 2640 if (unlikely(rc))
+9
drivers/net/ethernet/amazon/ena/ena_com.h
··· 44 44 #include <linux/spinlock.h> 45 45 #include <linux/types.h> 46 46 #include <linux/wait.h> 47 + #include <linux/netdevice.h> 47 48 48 49 #include "ena_common_defs.h" 49 50 #include "ena_admin_defs.h" ··· 655 654 * Free all the RSS/RFS resources. 656 655 */ 657 656 void ena_com_rss_destroy(struct ena_com_dev *ena_dev); 657 + 658 + /* ena_com_get_current_hash_function - Get RSS hash function 659 + * @ena_dev: ENA communication layer struct 660 + * 661 + * Return the current hash function. 662 + * @return: 0 or one of the ena_admin_hash_functions values. 663 + */ 664 + int ena_com_get_current_hash_function(struct ena_com_dev *ena_dev); 658 665 659 666 /* ena_com_fill_hash_function - Fill RSS hash function 660 667 * @ena_dev: ENA communication layer struct
+43 -3
drivers/net/ethernet/amazon/ena/ena_ethtool.c
··· 636 636 return ENA_HASH_KEY_SIZE; 637 637 } 638 638 639 + static int ena_indirection_table_get(struct ena_adapter *adapter, u32 *indir) 640 + { 641 + struct ena_com_dev *ena_dev = adapter->ena_dev; 642 + int i, rc; 643 + 644 + if (!indir) 645 + return 0; 646 + 647 + rc = ena_com_indirect_table_get(ena_dev, indir); 648 + if (rc) 649 + return rc; 650 + 651 + /* Our internal representation of the indices is: even indices 652 + * for Tx and uneven indices for Rx. We need to convert the Rx 653 + * indices to be consecutive 654 + */ 655 + for (i = 0; i < ENA_RX_RSS_TABLE_SIZE; i++) 656 + indir[i] = ENA_IO_RXQ_IDX_TO_COMBINED_IDX(indir[i]); 657 + 658 + return rc; 659 + } 660 + 639 661 static int ena_get_rxfh(struct net_device *netdev, u32 *indir, u8 *key, 640 662 u8 *hfunc) 641 663 { ··· 666 644 u8 func; 667 645 int rc; 668 646 669 - rc = ena_com_indirect_table_get(adapter->ena_dev, indir); 647 + rc = ena_indirection_table_get(adapter, indir); 670 648 if (rc) 671 649 return rc; 672 650 651 + /* We call this function in order to check if the device 652 + * supports getting/setting the hash function. 653 + */ 673 654 rc = ena_com_get_hash_function(adapter->ena_dev, &ena_func, key); 655 + 656 + if (rc) { 657 + if (rc == -EOPNOTSUPP) { 658 + key = NULL; 659 + hfunc = NULL; 660 + rc = 0; 661 + } 662 + 663 + return rc; 664 + } 665 + 674 666 if (rc) 675 667 return rc; 676 668 ··· 693 657 func = ETH_RSS_HASH_TOP; 694 658 break; 695 659 case ENA_ADMIN_CRC32: 696 - func = ETH_RSS_HASH_XOR; 660 + func = ETH_RSS_HASH_CRC32; 697 661 break; 698 662 default: 699 663 netif_err(adapter, drv, netdev, ··· 736 700 } 737 701 738 702 switch (hfunc) { 703 + case ETH_RSS_HASH_NO_CHANGE: 704 + func = ena_com_get_current_hash_function(ena_dev); 705 + break; 739 706 case ETH_RSS_HASH_TOP: 740 707 func = ENA_ADMIN_TOEPLITZ; 741 708 break; 742 - case ETH_RSS_HASH_XOR: 709 + case ETH_RSS_HASH_CRC32: 743 710 func = ENA_ADMIN_CRC32; 744 711 break; 745 712 default: ··· 853 814 .set_channels = ena_set_channels, 854 815 .get_tunable = ena_get_tunable, 855 816 .set_tunable = ena_set_tunable, 817 + .get_ts_info = ethtool_op_get_ts_info, 856 818 }; 857 819 858 820 void ena_set_ethtool_ops(struct net_device *netdev)
+3 -3
drivers/net/ethernet/amazon/ena/ena_netdev.c
··· 3706 3706 if (adapter->keep_alive_timeout == ENA_HW_HINTS_NO_TIMEOUT) 3707 3707 return; 3708 3708 3709 - keep_alive_expired = round_jiffies(adapter->last_keep_alive_jiffies + 3710 - adapter->keep_alive_timeout); 3709 + keep_alive_expired = adapter->last_keep_alive_jiffies + 3710 + adapter->keep_alive_timeout; 3711 3711 if (unlikely(time_is_before_jiffies(keep_alive_expired))) { 3712 3712 netif_err(adapter, drv, adapter->netdev, 3713 3713 "Keep alive watchdog timeout.\n"); ··· 3809 3809 } 3810 3810 3811 3811 /* Reset the timer */ 3812 - mod_timer(&adapter->timer_service, jiffies + HZ); 3812 + mod_timer(&adapter->timer_service, round_jiffies(jiffies + HZ)); 3813 3813 } 3814 3814 3815 3815 static int ena_calc_max_io_queue_num(struct pci_dev *pdev,
+2
drivers/net/ethernet/amazon/ena/ena_netdev.h
··· 130 130 131 131 #define ENA_IO_TXQ_IDX(q) (2 * (q)) 132 132 #define ENA_IO_RXQ_IDX(q) (2 * (q) + 1) 133 + #define ENA_IO_TXQ_IDX_TO_COMBINED_IDX(q) ((q) / 2) 134 + #define ENA_IO_RXQ_IDX_TO_COMBINED_IDX(q) (((q) - 1) / 2) 133 135 134 136 #define ENA_MGMNT_IRQ_IDX 0 135 137 #define ENA_IO_IRQ_FIRST_IDX 1
+1 -1
drivers/net/ethernet/cisco/enic/enic_main.c
··· 2013 2013 napi_disable(&enic->napi[i]); 2014 2014 2015 2015 netif_carrier_off(netdev); 2016 - netif_tx_disable(netdev); 2017 2016 if (vnic_dev_get_intr_mode(enic->vdev) == VNIC_DEV_INTR_MODE_MSIX) 2018 2017 for (i = 0; i < enic->wq_count; i++) 2019 2018 napi_disable(&enic->napi[enic_cq_wq(enic, i)]); 2019 + netif_tx_disable(netdev); 2020 2020 2021 2021 if (!enic_is_dynamic(enic) && !enic_is_sriov_vf(enic)) 2022 2022 enic_dev_del_station_addr(enic);
+16 -6
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
··· 6113 6113 static void hclge_fd_get_flow_tuples(const struct flow_keys *fkeys, 6114 6114 struct hclge_fd_rule_tuples *tuples) 6115 6115 { 6116 + #define flow_ip6_src fkeys->addrs.v6addrs.src.in6_u.u6_addr32 6117 + #define flow_ip6_dst fkeys->addrs.v6addrs.dst.in6_u.u6_addr32 6118 + 6116 6119 tuples->ether_proto = be16_to_cpu(fkeys->basic.n_proto); 6117 6120 tuples->ip_proto = fkeys->basic.ip_proto; 6118 6121 tuples->dst_port = be16_to_cpu(fkeys->ports.dst); ··· 6124 6121 tuples->src_ip[3] = be32_to_cpu(fkeys->addrs.v4addrs.src); 6125 6122 tuples->dst_ip[3] = be32_to_cpu(fkeys->addrs.v4addrs.dst); 6126 6123 } else { 6127 - memcpy(tuples->src_ip, 6128 - fkeys->addrs.v6addrs.src.in6_u.u6_addr32, 6129 - sizeof(tuples->src_ip)); 6130 - memcpy(tuples->dst_ip, 6131 - fkeys->addrs.v6addrs.dst.in6_u.u6_addr32, 6132 - sizeof(tuples->dst_ip)); 6124 + int i; 6125 + 6126 + for (i = 0; i < IPV6_SIZE; i++) { 6127 + tuples->src_ip[i] = be32_to_cpu(flow_ip6_src[i]); 6128 + tuples->dst_ip[i] = be32_to_cpu(flow_ip6_dst[i]); 6129 + } 6133 6130 } 6134 6131 } 6135 6132 ··· 9834 9831 ret = hclge_rss_init_hw(hdev); 9835 9832 if (ret) { 9836 9833 dev_err(&pdev->dev, "Rss init fail, ret =%d\n", ret); 9834 + return ret; 9835 + } 9836 + 9837 + ret = init_mgr_tbl(hdev); 9838 + if (ret) { 9839 + dev_err(&pdev->dev, 9840 + "failed to reinit manager table, ret = %d\n", ret); 9837 9841 return ret; 9838 9842 } 9839 9843
+1 -1
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c
··· 566 566 */ 567 567 kinfo->num_tc = vport->vport_id ? 1 : 568 568 min_t(u16, vport->alloc_tqps, hdev->tm_info.num_tc); 569 - vport->qs_offset = (vport->vport_id ? hdev->tm_info.num_tc : 0) + 569 + vport->qs_offset = (vport->vport_id ? HNAE3_MAX_TC : 0) + 570 570 (vport->vport_id ? (vport->vport_id - 1) : 0); 571 571 572 572 max_rss_size = min_t(u16, hdev->rss_size_max,
+2 -2
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
··· 2362 2362 goto error_param; 2363 2363 } 2364 2364 2365 - if (i40e_vc_validate_vqs_bitmaps(vqs)) { 2365 + if (!i40e_vc_validate_vqs_bitmaps(vqs)) { 2366 2366 aq_ret = I40E_ERR_PARAM; 2367 2367 goto error_param; 2368 2368 } ··· 2424 2424 goto error_param; 2425 2425 } 2426 2426 2427 - if (i40e_vc_validate_vqs_bitmaps(vqs)) { 2427 + if (!i40e_vc_validate_vqs_bitmaps(vqs)) { 2428 2428 aq_ret = I40E_ERR_PARAM; 2429 2429 goto error_param; 2430 2430 }
+1
drivers/net/ethernet/intel/ice/ice_adminq_cmd.h
··· 1660 1660 __le32 count; 1661 1661 struct ice_aqc_get_pkg_info pkg_info[1]; 1662 1662 }; 1663 + 1663 1664 /** 1664 1665 * struct ice_aq_desc - Admin Queue (AQ) descriptor 1665 1666 * @flags: ICE_AQ_FLAG_* flags
+12 -23
drivers/net/ethernet/intel/ice/ice_base.c
··· 324 324 if (err) 325 325 return err; 326 326 327 - dev_info(&vsi->back->pdev->dev, "Registered XDP mem model MEM_TYPE_ZERO_COPY on Rx ring %d\n", 327 + dev_info(ice_pf_to_dev(vsi->back), "Registered XDP mem model MEM_TYPE_ZERO_COPY on Rx ring %d\n", 328 328 ring->q_index); 329 329 } else { 330 330 ring->zca.free = NULL; ··· 405 405 /* Absolute queue number out of 2K needs to be passed */ 406 406 err = ice_write_rxq_ctx(hw, &rlan_ctx, pf_q); 407 407 if (err) { 408 - dev_err(&vsi->back->pdev->dev, 409 - "Failed to set LAN Rx queue context for absolute Rx queue %d error: %d\n", 408 + dev_err(ice_pf_to_dev(vsi->back), "Failed to set LAN Rx queue context for absolute Rx queue %d error: %d\n", 410 409 pf_q, err); 411 410 return -EIO; 412 411 } ··· 427 428 ice_alloc_rx_bufs_slow_zc(ring, ICE_DESC_UNUSED(ring)) : 428 429 ice_alloc_rx_bufs(ring, ICE_DESC_UNUSED(ring)); 429 430 if (err) 430 - dev_info(&vsi->back->pdev->dev, 431 - "Failed allocate some buffers on %sRx ring %d (pf_q %d)\n", 431 + dev_info(ice_pf_to_dev(vsi->back), "Failed allocate some buffers on %sRx ring %d (pf_q %d)\n", 432 432 ring->xsk_umem ? "UMEM enabled " : "", 433 433 ring->q_index, pf_q); 434 434 ··· 488 490 /* wait for the change to finish */ 489 491 ret = ice_pf_rxq_wait(pf, pf_q, ena); 490 492 if (ret) 491 - dev_err(ice_pf_to_dev(pf), 492 - "VSI idx %d Rx ring %d %sable timeout\n", 493 + dev_err(ice_pf_to_dev(pf), "VSI idx %d Rx ring %d %sable timeout\n", 493 494 vsi->idx, pf_q, (ena ? "en" : "dis")); 494 495 495 496 return ret; ··· 503 506 */ 504 507 int ice_vsi_alloc_q_vectors(struct ice_vsi *vsi) 505 508 { 506 - struct ice_pf *pf = vsi->back; 507 - int v_idx = 0, num_q_vectors; 508 - struct device *dev; 509 - int err; 509 + struct device *dev = ice_pf_to_dev(vsi->back); 510 + int v_idx, err; 510 511 511 - dev = ice_pf_to_dev(pf); 512 512 if (vsi->q_vectors[0]) { 513 513 dev_dbg(dev, "VSI %d has existing q_vectors\n", vsi->vsi_num); 514 514 return -EEXIST; 515 515 } 516 516 517 - num_q_vectors = vsi->num_q_vectors; 518 - 519 - for (v_idx = 0; v_idx < num_q_vectors; v_idx++) { 517 + for (v_idx = 0; v_idx < vsi->num_q_vectors; v_idx++) { 520 518 err = ice_vsi_alloc_q_vector(vsi, v_idx); 521 519 if (err) 522 520 goto err_out; ··· 640 648 status = ice_ena_vsi_txq(vsi->port_info, vsi->idx, tc, ring->q_handle, 641 649 1, qg_buf, buf_len, NULL); 642 650 if (status) { 643 - dev_err(ice_pf_to_dev(pf), 644 - "Failed to set LAN Tx queue context, error: %d\n", 651 + dev_err(ice_pf_to_dev(pf), "Failed to set LAN Tx queue context, error: %d\n", 645 652 status); 646 653 return -ENODEV; 647 654 } ··· 806 815 * queues at the hardware level anyway. 807 816 */ 808 817 if (status == ICE_ERR_RESET_ONGOING) { 809 - dev_dbg(&vsi->back->pdev->dev, 810 - "Reset in progress. LAN Tx queues already disabled\n"); 818 + dev_dbg(ice_pf_to_dev(vsi->back), "Reset in progress. LAN Tx queues already disabled\n"); 811 819 } else if (status == ICE_ERR_DOES_NOT_EXIST) { 812 - dev_dbg(&vsi->back->pdev->dev, 813 - "LAN Tx queues do not exist, nothing to disable\n"); 820 + dev_dbg(ice_pf_to_dev(vsi->back), "LAN Tx queues do not exist, nothing to disable\n"); 814 821 } else if (status) { 815 - dev_err(&vsi->back->pdev->dev, 816 - "Failed to disable LAN Tx queues, error: %d\n", status); 822 + dev_err(ice_pf_to_dev(vsi->back), "Failed to disable LAN Tx queues, error: %d\n", 823 + status); 817 824 return -ENODEV; 818 825 } 819 826
+14 -23
drivers/net/ethernet/intel/ice/ice_common.c
··· 25 25 } 26 26 27 27 /** 28 - * ice_dev_onetime_setup - Temporary HW/FW workarounds 29 - * @hw: pointer to the HW structure 30 - * 31 - * This function provides temporary workarounds for certain issues 32 - * that are expected to be fixed in the HW/FW. 33 - */ 34 - void ice_dev_onetime_setup(struct ice_hw *hw) 35 - { 36 - #define MBX_PF_VT_PFALLOC 0x00231E80 37 - /* set VFs per PF */ 38 - wr32(hw, MBX_PF_VT_PFALLOC, rd32(hw, PF_VT_PFALLOC_HIF)); 39 - } 40 - 41 - /** 42 28 * ice_clear_pf_cfg - Clear PF configuration 43 29 * @hw: pointer to the hardware structure 44 30 * ··· 588 602 } 589 603 590 604 /** 591 - * ice_get_itr_intrl_gran - determine int/intrl granularity 605 + * ice_get_itr_intrl_gran 592 606 * @hw: pointer to the HW struct 593 607 * 594 - * Determines the ITR/intrl granularities based on the maximum aggregate 608 + * Determines the ITR/INTRL granularities based on the maximum aggregate 595 609 * bandwidth according to the device's configuration during power-on. 596 610 */ 597 611 static void ice_get_itr_intrl_gran(struct ice_hw *hw) ··· 749 763 if (status) 750 764 goto err_unroll_sched; 751 765 752 - ice_dev_onetime_setup(hw); 753 - 754 766 /* Get MAC information */ 755 767 /* A single port can report up to two (LAN and WoL) addresses */ 756 768 mac_buf = devm_kcalloc(ice_hw_to_dev(hw), 2, ··· 818 834 */ 819 835 enum ice_status ice_check_reset(struct ice_hw *hw) 820 836 { 821 - u32 cnt, reg = 0, grst_delay; 837 + u32 cnt, reg = 0, grst_delay, uld_mask; 822 838 823 839 /* Poll for Device Active state in case a recent CORER, GLOBR, 824 840 * or EMPR has occurred. The grst delay value is in 100ms units. ··· 840 856 return ICE_ERR_RESET_FAILED; 841 857 } 842 858 843 - #define ICE_RESET_DONE_MASK (GLNVM_ULD_CORER_DONE_M | \ 844 - GLNVM_ULD_GLOBR_DONE_M) 859 + #define ICE_RESET_DONE_MASK (GLNVM_ULD_PCIER_DONE_M |\ 860 + GLNVM_ULD_PCIER_DONE_1_M |\ 861 + GLNVM_ULD_CORER_DONE_M |\ 862 + GLNVM_ULD_GLOBR_DONE_M |\ 863 + GLNVM_ULD_POR_DONE_M |\ 864 + GLNVM_ULD_POR_DONE_1_M |\ 865 + GLNVM_ULD_PCIER_DONE_2_M) 866 + 867 + uld_mask = ICE_RESET_DONE_MASK; 845 868 846 869 /* Device is Active; check Global Reset processes are done */ 847 870 for (cnt = 0; cnt < ICE_PF_RESET_WAIT_COUNT; cnt++) { 848 - reg = rd32(hw, GLNVM_ULD) & ICE_RESET_DONE_MASK; 849 - if (reg == ICE_RESET_DONE_MASK) { 871 + reg = rd32(hw, GLNVM_ULD) & uld_mask; 872 + if (reg == uld_mask) { 850 873 ice_debug(hw, ICE_DBG_INIT, 851 874 "Global reset processes done. %d\n", cnt); 852 875 break;
-2
drivers/net/ethernet/intel/ice/ice_common.h
··· 54 54 55 55 void ice_set_safe_mode_caps(struct ice_hw *hw); 56 56 57 - void ice_dev_onetime_setup(struct ice_hw *hw); 58 - 59 57 enum ice_status 60 58 ice_write_rxq_ctx(struct ice_hw *hw, struct ice_rlan_ctx *rlan_ctx, 61 59 u32 rxq_index);
+4 -4
drivers/net/ethernet/intel/ice/ice_dcb.c
··· 1323 1323 } 1324 1324 1325 1325 /** 1326 - * ice_aq_query_port_ets - query port ets configuration 1326 + * ice_aq_query_port_ets - query port ETS configuration 1327 1327 * @pi: port information structure 1328 1328 * @buf: pointer to buffer 1329 1329 * @buf_size: buffer size in bytes 1330 1330 * @cd: pointer to command details structure or NULL 1331 1331 * 1332 - * query current port ets configuration 1332 + * query current port ETS configuration 1333 1333 */ 1334 1334 static enum ice_status 1335 1335 ice_aq_query_port_ets(struct ice_port_info *pi, ··· 1416 1416 } 1417 1417 1418 1418 /** 1419 - * ice_query_port_ets - query port ets configuration 1419 + * ice_query_port_ets - query port ETS configuration 1420 1420 * @pi: port information structure 1421 1421 * @buf: pointer to buffer 1422 1422 * @buf_size: buffer size in bytes 1423 1423 * @cd: pointer to command details structure or NULL 1424 1424 * 1425 - * query current port ets configuration and update the 1425 + * query current port ETS configuration and update the 1426 1426 * SW DB with the TC changes 1427 1427 */ 1428 1428 enum ice_status
+40 -59
drivers/net/ethernet/intel/ice/ice_dcb_lib.c
··· 315 315 */ 316 316 void ice_dcb_rebuild(struct ice_pf *pf) 317 317 { 318 - struct ice_dcbx_cfg *local_dcbx_cfg, *desired_dcbx_cfg, *prev_cfg; 319 318 struct ice_aqc_port_ets_elem buf = { 0 }; 320 319 struct device *dev = ice_pf_to_dev(pf); 320 + struct ice_dcbx_cfg *err_cfg; 321 321 enum ice_status ret; 322 322 323 323 ret = ice_query_port_ets(pf->hw.port_info, &buf, sizeof(buf), NULL); ··· 330 330 if (!test_bit(ICE_FLAG_DCB_ENA, pf->flags)) 331 331 return; 332 332 333 - local_dcbx_cfg = &pf->hw.port_info->local_dcbx_cfg; 334 - desired_dcbx_cfg = &pf->hw.port_info->desired_dcbx_cfg; 333 + mutex_lock(&pf->tc_mutex); 335 334 336 - /* Save current willing state and force FW to unwilling */ 337 - local_dcbx_cfg->etscfg.willing = 0x0; 338 - local_dcbx_cfg->pfc.willing = 0x0; 339 - local_dcbx_cfg->app_mode = ICE_DCBX_APPS_NON_WILLING; 335 + if (!pf->hw.port_info->is_sw_lldp) 336 + ice_cfg_etsrec_defaults(pf->hw.port_info); 340 337 341 - ice_cfg_etsrec_defaults(pf->hw.port_info); 342 338 ret = ice_set_dcb_cfg(pf->hw.port_info); 343 339 if (ret) { 344 - dev_err(dev, "Failed to set DCB to unwilling\n"); 340 + dev_err(dev, "Failed to set DCB config in rebuild\n"); 345 341 goto dcb_error; 346 342 } 347 343 348 - /* Retrieve DCB config and ensure same as current in SW */ 349 - prev_cfg = kmemdup(local_dcbx_cfg, sizeof(*prev_cfg), GFP_KERNEL); 350 - if (!prev_cfg) 351 - goto dcb_error; 352 - 353 - ice_init_dcb(&pf->hw, true); 354 - if (pf->hw.port_info->dcbx_status == ICE_DCBX_STATUS_DIS) 355 - pf->hw.port_info->is_sw_lldp = true; 356 - else 357 - pf->hw.port_info->is_sw_lldp = false; 358 - 359 - if (ice_dcb_need_recfg(pf, prev_cfg, local_dcbx_cfg)) { 360 - /* difference in cfg detected - disable DCB till next MIB */ 361 - dev_err(dev, "Set local MIB not accurate\n"); 362 - kfree(prev_cfg); 363 - goto dcb_error; 344 + if (!pf->hw.port_info->is_sw_lldp) { 345 + ret = ice_cfg_lldp_mib_change(&pf->hw, true); 346 + if (ret && !pf->hw.port_info->is_sw_lldp) { 347 + dev_err(dev, "Failed to register for MIB changes\n"); 348 + goto dcb_error; 349 + } 364 350 } 365 351 366 - /* fetched config congruent to previous configuration */ 367 - kfree(prev_cfg); 368 - 369 - /* Set the local desired config */ 370 - if (local_dcbx_cfg->dcbx_mode == ICE_DCBX_MODE_CEE) 371 - memcpy(local_dcbx_cfg, desired_dcbx_cfg, 372 - sizeof(*local_dcbx_cfg)); 373 - 374 - ice_cfg_etsrec_defaults(pf->hw.port_info); 375 - ret = ice_set_dcb_cfg(pf->hw.port_info); 376 - if (ret) { 377 - dev_err(dev, "Failed to set desired config\n"); 378 - goto dcb_error; 379 - } 380 352 dev_info(dev, "DCB restored after reset\n"); 381 353 ret = ice_query_port_ets(pf->hw.port_info, &buf, sizeof(buf), NULL); 382 354 if (ret) { ··· 356 384 goto dcb_error; 357 385 } 358 386 387 + mutex_unlock(&pf->tc_mutex); 388 + 359 389 return; 360 390 361 391 dcb_error: 362 392 dev_err(dev, "Disabling DCB until new settings occur\n"); 363 - prev_cfg = kzalloc(sizeof(*prev_cfg), GFP_KERNEL); 364 - if (!prev_cfg) 393 + err_cfg = kzalloc(sizeof(*err_cfg), GFP_KERNEL); 394 + if (!err_cfg) { 395 + mutex_unlock(&pf->tc_mutex); 365 396 return; 397 + } 366 398 367 - prev_cfg->etscfg.willing = true; 368 - prev_cfg->etscfg.tcbwtable[0] = ICE_TC_MAX_BW; 369 - prev_cfg->etscfg.tsatable[0] = ICE_IEEE_TSA_ETS; 370 - memcpy(&prev_cfg->etsrec, &prev_cfg->etscfg, sizeof(prev_cfg->etsrec)); 399 + err_cfg->etscfg.willing = true; 400 + err_cfg->etscfg.tcbwtable[0] = ICE_TC_MAX_BW; 401 + err_cfg->etscfg.tsatable[0] = ICE_IEEE_TSA_ETS; 402 + memcpy(&err_cfg->etsrec, &err_cfg->etscfg, sizeof(err_cfg->etsrec)); 371 403 /* Coverity warns the return code of ice_pf_dcb_cfg() is not checked 372 404 * here as is done for other calls to that function. That check is 373 405 * not necessary since this is in this function's error cleanup path. 374 406 * Suppress the Coverity warning with the following comment... 375 407 */ 376 408 /* coverity[check_return] */ 377 - ice_pf_dcb_cfg(pf, prev_cfg, false); 378 - kfree(prev_cfg); 409 + ice_pf_dcb_cfg(pf, err_cfg, false); 410 + kfree(err_cfg); 411 + 412 + mutex_unlock(&pf->tc_mutex); 379 413 } 380 414 381 415 /** ··· 412 434 } 413 435 414 436 /** 415 - * ice_dcb_sw_default_config - Apply a default DCB config 437 + * ice_dcb_sw_dflt_cfg - Apply a default DCB config 416 438 * @pf: PF to apply config to 417 - * @ets_willing: configure ets willing 439 + * @ets_willing: configure ETS willing 418 440 * @locked: was this function called with RTNL held 419 441 */ 420 442 static int ice_dcb_sw_dflt_cfg(struct ice_pf *pf, bool ets_willing, bool locked) ··· 577 599 goto dcb_init_err; 578 600 } 579 601 580 - dev_info(dev, 581 - "DCB is enabled in the hardware, max number of TCs supported on this port are %d\n", 602 + dev_info(dev, "DCB is enabled in the hardware, max number of TCs supported on this port are %d\n", 582 603 pf->hw.func_caps.common_cap.maxtc); 583 604 if (err) { 584 605 struct ice_vsi *pf_vsi; ··· 587 610 clear_bit(ICE_FLAG_FW_LLDP_AGENT, pf->flags); 588 611 err = ice_dcb_sw_dflt_cfg(pf, true, locked); 589 612 if (err) { 590 - dev_err(dev, 591 - "Failed to set local DCB config %d\n", err); 613 + dev_err(dev, "Failed to set local DCB config %d\n", 614 + err); 592 615 err = -EIO; 593 616 goto dcb_init_err; 594 617 } ··· 754 777 } 755 778 } 756 779 780 + mutex_lock(&pf->tc_mutex); 781 + 757 782 /* store the old configuration */ 758 783 tmp_dcbx_cfg = pf->hw.port_info->local_dcbx_cfg; 759 784 ··· 766 787 ret = ice_get_dcb_cfg(pf->hw.port_info); 767 788 if (ret) { 768 789 dev_err(dev, "Failed to get DCB config\n"); 769 - return; 790 + goto out; 770 791 } 771 792 772 793 /* No change detected in DCBX configs */ 773 794 if (!memcmp(&tmp_dcbx_cfg, &pi->local_dcbx_cfg, sizeof(tmp_dcbx_cfg))) { 774 795 dev_dbg(dev, "No change detected in DCBX configuration.\n"); 775 - return; 796 + goto out; 776 797 } 777 798 778 799 need_reconfig = ice_dcb_need_recfg(pf, &tmp_dcbx_cfg, 779 800 &pi->local_dcbx_cfg); 780 801 ice_dcbnl_flush_apps(pf, &tmp_dcbx_cfg, &pi->local_dcbx_cfg); 781 802 if (!need_reconfig) 782 - return; 803 + goto out; 783 804 784 805 /* Enable DCB tagging only when more than one TC */ 785 806 if (ice_dcb_get_num_tc(&pi->local_dcbx_cfg) > 1) { ··· 793 814 pf_vsi = ice_get_main_vsi(pf); 794 815 if (!pf_vsi) { 795 816 dev_dbg(dev, "PF VSI doesn't exist\n"); 796 - return; 817 + goto out; 797 818 } 798 819 799 820 rtnl_lock(); ··· 802 823 ret = ice_query_port_ets(pf->hw.port_info, &buf, sizeof(buf), NULL); 803 824 if (ret) { 804 825 dev_err(dev, "Query Port ETS failed\n"); 805 - rtnl_unlock(); 806 - return; 826 + goto unlock_rtnl; 807 827 } 808 828 809 829 /* changes in configuration update VSI */ 810 830 ice_pf_dcb_recfg(pf); 811 831 812 832 ice_ena_vsi(pf_vsi, true); 833 + unlock_rtnl: 813 834 rtnl_unlock(); 835 + out: 836 + mutex_unlock(&pf->tc_mutex); 814 837 }
+9 -11
drivers/net/ethernet/intel/ice/ice_dcb_nl.c
··· 297 297 return; 298 298 299 299 *setting = (pi->local_dcbx_cfg.pfc.pfcena >> prio) & 0x1; 300 - dev_dbg(ice_pf_to_dev(pf), 301 - "Get PFC Config up=%d, setting=%d, pfcenable=0x%x\n", 300 + dev_dbg(ice_pf_to_dev(pf), "Get PFC Config up=%d, setting=%d, pfcenable=0x%x\n", 302 301 prio, *setting, pi->local_dcbx_cfg.pfc.pfcena); 303 302 } 304 303 ··· 417 418 return; 418 419 419 420 *pgid = pi->local_dcbx_cfg.etscfg.prio_table[prio]; 420 - dev_dbg(ice_pf_to_dev(pf), 421 - "Get PG config prio=%d tc=%d\n", prio, *pgid); 421 + dev_dbg(ice_pf_to_dev(pf), "Get PG config prio=%d tc=%d\n", prio, 422 + *pgid); 422 423 } 423 424 424 425 /** ··· 712 713 return -EINVAL; 713 714 714 715 mutex_lock(&pf->tc_mutex); 715 - ret = dcb_ieee_delapp(netdev, app); 716 - if (ret) 717 - goto delapp_out; 718 - 719 716 old_cfg = &pf->hw.port_info->local_dcbx_cfg; 720 717 721 - if (old_cfg->numapps == 1) 718 + if (old_cfg->numapps <= 1) 719 + goto delapp_out; 720 + 721 + ret = dcb_ieee_delapp(netdev, app); 722 + if (ret) 722 723 goto delapp_out; 723 724 724 725 new_cfg = &pf->hw.port_info->desired_dcbx_cfg; ··· 881 882 sapp.protocol = app->prot_id; 882 883 sapp.priority = app->priority; 883 884 err = ice_dcbnl_delapp(vsi->netdev, &sapp); 884 - dev_dbg(&vsi->back->pdev->dev, 885 - "Deleting app for VSI idx=%d err=%d sel=%d proto=0x%x, prio=%d\n", 885 + dev_dbg(ice_pf_to_dev(vsi->back), "Deleting app for VSI idx=%d err=%d sel=%d proto=0x%x, prio=%d\n", 886 886 vsi->idx, err, app->selector, app->prot_id, app->priority); 887 887 } 888 888
+37 -318
drivers/net/ethernet/intel/ice/ice_ethtool.c
··· 166 166 ice_get_drvinfo(struct net_device *netdev, struct ethtool_drvinfo *drvinfo) 167 167 { 168 168 struct ice_netdev_priv *np = netdev_priv(netdev); 169 + u8 oem_ver, oem_patch, nvm_ver_hi, nvm_ver_lo; 169 170 struct ice_vsi *vsi = np->vsi; 170 171 struct ice_pf *pf = vsi->back; 172 + struct ice_hw *hw = &pf->hw; 173 + u16 oem_build; 171 174 172 175 strlcpy(drvinfo->driver, KBUILD_MODNAME, sizeof(drvinfo->driver)); 173 176 strlcpy(drvinfo->version, ice_drv_ver, sizeof(drvinfo->version)); 174 - strlcpy(drvinfo->fw_version, ice_nvm_version_str(&pf->hw), 175 - sizeof(drvinfo->fw_version)); 177 + 178 + /* Display NVM version (from which the firmware version can be 179 + * determined) which contains more pertinent information. 180 + */ 181 + ice_get_nvm_version(hw, &oem_ver, &oem_build, &oem_patch, 182 + &nvm_ver_hi, &nvm_ver_lo); 183 + snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version), 184 + "%x.%02x 0x%x %d.%d.%d", nvm_ver_hi, nvm_ver_lo, 185 + hw->nvm.eetrack, oem_ver, oem_build, oem_patch); 186 + 176 187 strlcpy(drvinfo->bus_info, pci_name(pf->pdev), 177 188 sizeof(drvinfo->bus_info)); 178 189 drvinfo->n_priv_flags = ICE_PRIV_FLAG_ARRAY_SIZE; ··· 374 363 val = rd32(hw, reg); 375 364 if (val == pattern) 376 365 continue; 377 - dev_err(dev, 378 - "%s: reg pattern test failed - reg 0x%08x pat 0x%08x val 0x%08x\n" 366 + dev_err(dev, "%s: reg pattern test failed - reg 0x%08x pat 0x%08x val 0x%08x\n" 379 367 , __func__, reg, pattern, val); 380 368 return 1; 381 369 } ··· 382 372 wr32(hw, reg, orig_val); 383 373 val = rd32(hw, reg); 384 374 if (val != orig_val) { 385 - dev_err(dev, 386 - "%s: reg restore test failed - reg 0x%08x orig 0x%08x val 0x%08x\n" 375 + dev_err(dev, "%s: reg restore test failed - reg 0x%08x orig 0x%08x val 0x%08x\n" 387 376 , __func__, reg, orig_val, val); 388 377 return 1; 389 378 } ··· 800 791 set_bit(__ICE_TESTING, pf->state); 801 792 802 793 if (ice_active_vfs(pf)) { 803 - dev_warn(dev, 804 - "Please take active VFs and Netqueues offline and restart the adapter before running NIC diagnostics\n"); 794 + dev_warn(dev, "Please take active VFs and Netqueues offline and restart the adapter before running NIC diagnostics\n"); 805 795 data[ICE_ETH_TEST_REG] = 1; 806 796 data[ICE_ETH_TEST_EEPROM] = 1; 807 797 data[ICE_ETH_TEST_INTR] = 1; ··· 1055 1047 fec = ICE_FEC_NONE; 1056 1048 break; 1057 1049 default: 1058 - dev_warn(&vsi->back->pdev->dev, "Unsupported FEC mode: %d\n", 1050 + dev_warn(ice_pf_to_dev(vsi->back), "Unsupported FEC mode: %d\n", 1059 1051 fecparam->fec); 1060 1052 return -EINVAL; 1061 1053 } ··· 1208 1200 * events to respond to. 1209 1201 */ 1210 1202 if (status) 1211 - dev_info(dev, 1212 - "Failed to unreg for LLDP events\n"); 1203 + dev_info(dev, "Failed to unreg for LLDP events\n"); 1213 1204 1214 1205 /* The AQ call to stop the FW LLDP agent will generate 1215 1206 * an error if the agent is already stopped. ··· 1263 1256 /* Register for MIB change events */ 1264 1257 status = ice_cfg_lldp_mib_change(&pf->hw, true); 1265 1258 if (status) 1266 - dev_dbg(dev, 1267 - "Fail to enable MIB change events\n"); 1259 + dev_dbg(dev, "Fail to enable MIB change events\n"); 1268 1260 } 1269 1261 } 1270 1262 if (test_bit(ICE_FLAG_LEGACY_RX, change_flags)) { ··· 1716 1710 { 1717 1711 struct ice_netdev_priv *np = netdev_priv(netdev); 1718 1712 struct ice_port_info *pi = np->vsi->port_info; 1719 - struct ethtool_link_ksettings cap_ksettings; 1720 1713 struct ice_link_status *link_info; 1721 1714 struct ice_vsi *vsi = np->vsi; 1722 - bool unrecog_phy_high = false; 1723 - bool unrecog_phy_low = false; 1724 1715 1725 1716 link_info = &vsi->port_info->phy.link_info; 1726 1717 1727 - /* Initialize supported and advertised settings based on PHY settings */ 1728 - switch (link_info->phy_type_low) { 1729 - case ICE_PHY_TYPE_LOW_100BASE_TX: 1730 - ethtool_link_ksettings_add_link_mode(ks, supported, Autoneg); 1731 - ethtool_link_ksettings_add_link_mode(ks, supported, 1732 - 100baseT_Full); 1733 - ethtool_link_ksettings_add_link_mode(ks, advertising, Autoneg); 1734 - ethtool_link_ksettings_add_link_mode(ks, advertising, 1735 - 100baseT_Full); 1736 - break; 1737 - case ICE_PHY_TYPE_LOW_100M_SGMII: 1738 - ethtool_link_ksettings_add_link_mode(ks, supported, 1739 - 100baseT_Full); 1740 - break; 1741 - case ICE_PHY_TYPE_LOW_1000BASE_T: 1742 - ethtool_link_ksettings_add_link_mode(ks, supported, Autoneg); 1743 - ethtool_link_ksettings_add_link_mode(ks, supported, 1744 - 1000baseT_Full); 1745 - ethtool_link_ksettings_add_link_mode(ks, advertising, Autoneg); 1746 - ethtool_link_ksettings_add_link_mode(ks, advertising, 1747 - 1000baseT_Full); 1748 - break; 1749 - case ICE_PHY_TYPE_LOW_1G_SGMII: 1750 - ethtool_link_ksettings_add_link_mode(ks, supported, 1751 - 1000baseT_Full); 1752 - break; 1753 - case ICE_PHY_TYPE_LOW_1000BASE_SX: 1754 - case ICE_PHY_TYPE_LOW_1000BASE_LX: 1755 - ethtool_link_ksettings_add_link_mode(ks, supported, 1756 - 1000baseX_Full); 1757 - break; 1758 - case ICE_PHY_TYPE_LOW_1000BASE_KX: 1759 - ethtool_link_ksettings_add_link_mode(ks, supported, Autoneg); 1760 - ethtool_link_ksettings_add_link_mode(ks, supported, 1761 - 1000baseKX_Full); 1762 - ethtool_link_ksettings_add_link_mode(ks, advertising, Autoneg); 1763 - ethtool_link_ksettings_add_link_mode(ks, advertising, 1764 - 1000baseKX_Full); 1765 - break; 1766 - case ICE_PHY_TYPE_LOW_2500BASE_T: 1767 - ethtool_link_ksettings_add_link_mode(ks, supported, Autoneg); 1768 - ethtool_link_ksettings_add_link_mode(ks, advertising, Autoneg); 1769 - ethtool_link_ksettings_add_link_mode(ks, supported, 1770 - 2500baseT_Full); 1771 - ethtool_link_ksettings_add_link_mode(ks, advertising, 1772 - 2500baseT_Full); 1773 - break; 1774 - case ICE_PHY_TYPE_LOW_2500BASE_X: 1775 - ethtool_link_ksettings_add_link_mode(ks, supported, 1776 - 2500baseX_Full); 1777 - break; 1778 - case ICE_PHY_TYPE_LOW_2500BASE_KX: 1779 - ethtool_link_ksettings_add_link_mode(ks, supported, Autoneg); 1780 - ethtool_link_ksettings_add_link_mode(ks, supported, 1781 - 2500baseX_Full); 1782 - ethtool_link_ksettings_add_link_mode(ks, advertising, Autoneg); 1783 - ethtool_link_ksettings_add_link_mode(ks, advertising, 1784 - 2500baseX_Full); 1785 - break; 1786 - case ICE_PHY_TYPE_LOW_5GBASE_T: 1787 - case ICE_PHY_TYPE_LOW_5GBASE_KR: 1788 - ethtool_link_ksettings_add_link_mode(ks, supported, Autoneg); 1789 - ethtool_link_ksettings_add_link_mode(ks, supported, 1790 - 5000baseT_Full); 1791 - ethtool_link_ksettings_add_link_mode(ks, advertising, Autoneg); 1792 - ethtool_link_ksettings_add_link_mode(ks, advertising, 1793 - 5000baseT_Full); 1794 - break; 1795 - case ICE_PHY_TYPE_LOW_10GBASE_T: 1796 - ethtool_link_ksettings_add_link_mode(ks, supported, Autoneg); 1797 - ethtool_link_ksettings_add_link_mode(ks, supported, 1798 - 10000baseT_Full); 1799 - ethtool_link_ksettings_add_link_mode(ks, advertising, Autoneg); 1800 - ethtool_link_ksettings_add_link_mode(ks, advertising, 1801 - 10000baseT_Full); 1802 - break; 1803 - case ICE_PHY_TYPE_LOW_10G_SFI_DA: 1804 - case ICE_PHY_TYPE_LOW_10G_SFI_AOC_ACC: 1805 - case ICE_PHY_TYPE_LOW_10G_SFI_C2C: 1806 - ethtool_link_ksettings_add_link_mode(ks, supported, 1807 - 10000baseT_Full); 1808 - break; 1809 - case ICE_PHY_TYPE_LOW_10GBASE_SR: 1810 - ethtool_link_ksettings_add_link_mode(ks, supported, 1811 - 10000baseSR_Full); 1812 - break; 1813 - case ICE_PHY_TYPE_LOW_10GBASE_LR: 1814 - ethtool_link_ksettings_add_link_mode(ks, supported, 1815 - 10000baseLR_Full); 1816 - break; 1817 - case ICE_PHY_TYPE_LOW_10GBASE_KR_CR1: 1818 - ethtool_link_ksettings_add_link_mode(ks, supported, Autoneg); 1819 - ethtool_link_ksettings_add_link_mode(ks, supported, 1820 - 10000baseKR_Full); 1821 - ethtool_link_ksettings_add_link_mode(ks, advertising, Autoneg); 1822 - ethtool_link_ksettings_add_link_mode(ks, advertising, 1823 - 10000baseKR_Full); 1824 - break; 1825 - case ICE_PHY_TYPE_LOW_25GBASE_T: 1826 - case ICE_PHY_TYPE_LOW_25GBASE_CR: 1827 - case ICE_PHY_TYPE_LOW_25GBASE_CR_S: 1828 - case ICE_PHY_TYPE_LOW_25GBASE_CR1: 1829 - ethtool_link_ksettings_add_link_mode(ks, supported, Autoneg); 1830 - ethtool_link_ksettings_add_link_mode(ks, supported, 1831 - 25000baseCR_Full); 1832 - ethtool_link_ksettings_add_link_mode(ks, advertising, Autoneg); 1833 - ethtool_link_ksettings_add_link_mode(ks, advertising, 1834 - 25000baseCR_Full); 1835 - break; 1836 - case ICE_PHY_TYPE_LOW_25G_AUI_AOC_ACC: 1837 - case ICE_PHY_TYPE_LOW_25G_AUI_C2C: 1838 - ethtool_link_ksettings_add_link_mode(ks, supported, 1839 - 25000baseCR_Full); 1840 - break; 1841 - case ICE_PHY_TYPE_LOW_25GBASE_SR: 1842 - case ICE_PHY_TYPE_LOW_25GBASE_LR: 1843 - ethtool_link_ksettings_add_link_mode(ks, supported, 1844 - 25000baseSR_Full); 1845 - break; 1846 - case ICE_PHY_TYPE_LOW_25GBASE_KR: 1847 - case ICE_PHY_TYPE_LOW_25GBASE_KR1: 1848 - case ICE_PHY_TYPE_LOW_25GBASE_KR_S: 1849 - ethtool_link_ksettings_add_link_mode(ks, supported, Autoneg); 1850 - ethtool_link_ksettings_add_link_mode(ks, supported, 1851 - 25000baseKR_Full); 1852 - ethtool_link_ksettings_add_link_mode(ks, advertising, Autoneg); 1853 - ethtool_link_ksettings_add_link_mode(ks, advertising, 1854 - 25000baseKR_Full); 1855 - break; 1856 - case ICE_PHY_TYPE_LOW_40GBASE_CR4: 1857 - ethtool_link_ksettings_add_link_mode(ks, supported, Autoneg); 1858 - ethtool_link_ksettings_add_link_mode(ks, supported, 1859 - 40000baseCR4_Full); 1860 - ethtool_link_ksettings_add_link_mode(ks, advertising, Autoneg); 1861 - ethtool_link_ksettings_add_link_mode(ks, advertising, 1862 - 40000baseCR4_Full); 1863 - break; 1864 - case ICE_PHY_TYPE_LOW_40G_XLAUI_AOC_ACC: 1865 - case ICE_PHY_TYPE_LOW_40G_XLAUI: 1866 - ethtool_link_ksettings_add_link_mode(ks, supported, 1867 - 40000baseCR4_Full); 1868 - break; 1869 - case ICE_PHY_TYPE_LOW_40GBASE_SR4: 1870 - ethtool_link_ksettings_add_link_mode(ks, supported, 1871 - 40000baseSR4_Full); 1872 - break; 1873 - case ICE_PHY_TYPE_LOW_40GBASE_LR4: 1874 - ethtool_link_ksettings_add_link_mode(ks, supported, 1875 - 40000baseLR4_Full); 1876 - break; 1877 - case ICE_PHY_TYPE_LOW_40GBASE_KR4: 1878 - ethtool_link_ksettings_add_link_mode(ks, supported, Autoneg); 1879 - ethtool_link_ksettings_add_link_mode(ks, supported, 1880 - 40000baseKR4_Full); 1881 - ethtool_link_ksettings_add_link_mode(ks, advertising, Autoneg); 1882 - ethtool_link_ksettings_add_link_mode(ks, advertising, 1883 - 40000baseKR4_Full); 1884 - break; 1885 - case ICE_PHY_TYPE_LOW_50GBASE_CR2: 1886 - case ICE_PHY_TYPE_LOW_50GBASE_CP: 1887 - ethtool_link_ksettings_add_link_mode(ks, supported, Autoneg); 1888 - ethtool_link_ksettings_add_link_mode(ks, supported, 1889 - 50000baseCR2_Full); 1890 - ethtool_link_ksettings_add_link_mode(ks, advertising, Autoneg); 1891 - ethtool_link_ksettings_add_link_mode(ks, advertising, 1892 - 50000baseCR2_Full); 1893 - break; 1894 - case ICE_PHY_TYPE_LOW_50G_LAUI2_AOC_ACC: 1895 - case ICE_PHY_TYPE_LOW_50G_LAUI2: 1896 - case ICE_PHY_TYPE_LOW_50G_AUI2_AOC_ACC: 1897 - case ICE_PHY_TYPE_LOW_50G_AUI2: 1898 - case ICE_PHY_TYPE_LOW_50GBASE_SR: 1899 - case ICE_PHY_TYPE_LOW_50G_AUI1_AOC_ACC: 1900 - case ICE_PHY_TYPE_LOW_50G_AUI1: 1901 - ethtool_link_ksettings_add_link_mode(ks, supported, 1902 - 50000baseCR2_Full); 1903 - break; 1904 - case ICE_PHY_TYPE_LOW_50GBASE_KR2: 1905 - case ICE_PHY_TYPE_LOW_50GBASE_KR_PAM4: 1906 - ethtool_link_ksettings_add_link_mode(ks, supported, Autoneg); 1907 - ethtool_link_ksettings_add_link_mode(ks, supported, 1908 - 50000baseKR2_Full); 1909 - ethtool_link_ksettings_add_link_mode(ks, advertising, Autoneg); 1910 - ethtool_link_ksettings_add_link_mode(ks, advertising, 1911 - 50000baseKR2_Full); 1912 - break; 1913 - case ICE_PHY_TYPE_LOW_50GBASE_SR2: 1914 - case ICE_PHY_TYPE_LOW_50GBASE_LR2: 1915 - case ICE_PHY_TYPE_LOW_50GBASE_FR: 1916 - case ICE_PHY_TYPE_LOW_50GBASE_LR: 1917 - ethtool_link_ksettings_add_link_mode(ks, supported, 1918 - 50000baseSR2_Full); 1919 - break; 1920 - case ICE_PHY_TYPE_LOW_100GBASE_CR4: 1921 - ethtool_link_ksettings_add_link_mode(ks, supported, Autoneg); 1922 - ethtool_link_ksettings_add_link_mode(ks, supported, 1923 - 100000baseCR4_Full); 1924 - ethtool_link_ksettings_add_link_mode(ks, advertising, Autoneg); 1925 - ethtool_link_ksettings_add_link_mode(ks, advertising, 1926 - 100000baseCR4_Full); 1927 - break; 1928 - case ICE_PHY_TYPE_LOW_100G_CAUI4_AOC_ACC: 1929 - case ICE_PHY_TYPE_LOW_100G_CAUI4: 1930 - case ICE_PHY_TYPE_LOW_100G_AUI4_AOC_ACC: 1931 - case ICE_PHY_TYPE_LOW_100G_AUI4: 1932 - case ICE_PHY_TYPE_LOW_100GBASE_CR_PAM4: 1933 - ethtool_link_ksettings_add_link_mode(ks, supported, 1934 - 100000baseCR4_Full); 1935 - break; 1936 - case ICE_PHY_TYPE_LOW_100GBASE_CP2: 1937 - ethtool_link_ksettings_add_link_mode(ks, supported, Autoneg); 1938 - ethtool_link_ksettings_add_link_mode(ks, supported, 1939 - 100000baseCR4_Full); 1940 - ethtool_link_ksettings_add_link_mode(ks, advertising, Autoneg); 1941 - ethtool_link_ksettings_add_link_mode(ks, advertising, 1942 - 100000baseCR4_Full); 1943 - break; 1944 - case ICE_PHY_TYPE_LOW_100GBASE_SR4: 1945 - case ICE_PHY_TYPE_LOW_100GBASE_SR2: 1946 - ethtool_link_ksettings_add_link_mode(ks, supported, 1947 - 100000baseSR4_Full); 1948 - break; 1949 - case ICE_PHY_TYPE_LOW_100GBASE_LR4: 1950 - case ICE_PHY_TYPE_LOW_100GBASE_DR: 1951 - ethtool_link_ksettings_add_link_mode(ks, supported, 1952 - 100000baseLR4_ER4_Full); 1953 - break; 1954 - case ICE_PHY_TYPE_LOW_100GBASE_KR4: 1955 - case ICE_PHY_TYPE_LOW_100GBASE_KR_PAM4: 1956 - ethtool_link_ksettings_add_link_mode(ks, supported, Autoneg); 1957 - ethtool_link_ksettings_add_link_mode(ks, supported, 1958 - 100000baseKR4_Full); 1959 - ethtool_link_ksettings_add_link_mode(ks, advertising, Autoneg); 1960 - ethtool_link_ksettings_add_link_mode(ks, advertising, 1961 - 100000baseKR4_Full); 1962 - break; 1963 - default: 1964 - unrecog_phy_low = true; 1965 - } 1966 - 1967 - switch (link_info->phy_type_high) { 1968 - case ICE_PHY_TYPE_HIGH_100GBASE_KR2_PAM4: 1969 - ethtool_link_ksettings_add_link_mode(ks, supported, Autoneg); 1970 - ethtool_link_ksettings_add_link_mode(ks, supported, 1971 - 100000baseKR4_Full); 1972 - ethtool_link_ksettings_add_link_mode(ks, advertising, Autoneg); 1973 - ethtool_link_ksettings_add_link_mode(ks, advertising, 1974 - 100000baseKR4_Full); 1975 - break; 1976 - case ICE_PHY_TYPE_HIGH_100G_CAUI2_AOC_ACC: 1977 - case ICE_PHY_TYPE_HIGH_100G_CAUI2: 1978 - case ICE_PHY_TYPE_HIGH_100G_AUI2_AOC_ACC: 1979 - case ICE_PHY_TYPE_HIGH_100G_AUI2: 1980 - ethtool_link_ksettings_add_link_mode(ks, supported, 1981 - 100000baseCR4_Full); 1982 - break; 1983 - default: 1984 - unrecog_phy_high = true; 1985 - } 1986 - 1987 - if (unrecog_phy_low && unrecog_phy_high) { 1988 - /* if we got here and link is up something bad is afoot */ 1989 - netdev_info(netdev, 1990 - "WARNING: Unrecognized PHY_Low (0x%llx).\n", 1991 - (u64)link_info->phy_type_low); 1992 - netdev_info(netdev, 1993 - "WARNING: Unrecognized PHY_High (0x%llx).\n", 1994 - (u64)link_info->phy_type_high); 1995 - } 1996 - 1997 - /* Now that we've worked out everything that could be supported by the 1998 - * current PHY type, get what is supported by the NVM and intersect 1999 - * them to get what is truly supported 2000 - */ 2001 - memset(&cap_ksettings, 0, sizeof(cap_ksettings)); 2002 - ice_phy_type_to_ethtool(netdev, &cap_ksettings); 2003 - ethtool_intersect_link_masks(ks, &cap_ksettings); 1718 + /* Get supported and advertised settings from PHY ability with media */ 1719 + ice_phy_type_to_ethtool(netdev, ks); 2004 1720 2005 1721 switch (link_info->link_speed) { 2006 1722 case ICE_AQ_LINK_SPEED_100GB: ··· 1756 2028 ks->base.speed = SPEED_100; 1757 2029 break; 1758 2030 default: 1759 - netdev_info(netdev, 1760 - "WARNING: Unrecognized link_speed (0x%x).\n", 2031 + netdev_info(netdev, "WARNING: Unrecognized link_speed (0x%x).\n", 1761 2032 link_info->link_speed); 1762 2033 break; 1763 2034 } ··· 2572 2845 2573 2846 new_tx_cnt = ALIGN(ring->tx_pending, ICE_REQ_DESC_MULTIPLE); 2574 2847 if (new_tx_cnt != ring->tx_pending) 2575 - netdev_info(netdev, 2576 - "Requested Tx descriptor count rounded up to %d\n", 2848 + netdev_info(netdev, "Requested Tx descriptor count rounded up to %d\n", 2577 2849 new_tx_cnt); 2578 2850 new_rx_cnt = ALIGN(ring->rx_pending, ICE_REQ_DESC_MULTIPLE); 2579 2851 if (new_rx_cnt != ring->rx_pending) 2580 - netdev_info(netdev, 2581 - "Requested Rx descriptor count rounded up to %d\n", 2852 + netdev_info(netdev, "Requested Rx descriptor count rounded up to %d\n", 2582 2853 new_rx_cnt); 2583 2854 2584 2855 /* if nothing to do return success */ ··· 3443 3718 if (ec->rx_coalesce_usecs_high > ICE_MAX_INTRL || 3444 3719 (ec->rx_coalesce_usecs_high && 3445 3720 ec->rx_coalesce_usecs_high < pf->hw.intrl_gran)) { 3446 - netdev_info(vsi->netdev, 3447 - "Invalid value, %s-usecs-high valid values are 0 (disabled), %d-%d\n", 3721 + netdev_info(vsi->netdev, "Invalid value, %s-usecs-high valid values are 0 (disabled), %d-%d\n", 3448 3722 c_type_str, pf->hw.intrl_gran, 3449 3723 ICE_MAX_INTRL); 3450 3724 return -EINVAL; ··· 3461 3737 break; 3462 3738 case ICE_TX_CONTAINER: 3463 3739 if (ec->tx_coalesce_usecs_high) { 3464 - netdev_info(vsi->netdev, 3465 - "setting %s-usecs-high is not supported\n", 3740 + netdev_info(vsi->netdev, "setting %s-usecs-high is not supported\n", 3466 3741 c_type_str); 3467 3742 return -EINVAL; 3468 3743 } ··· 3478 3755 3479 3756 itr_setting = rc->itr_setting & ~ICE_ITR_DYNAMIC; 3480 3757 if (coalesce_usecs != itr_setting && use_adaptive_coalesce) { 3481 - netdev_info(vsi->netdev, 3482 - "%s interrupt throttling cannot be changed if adaptive-%s is enabled\n", 3758 + netdev_info(vsi->netdev, "%s interrupt throttling cannot be changed if adaptive-%s is enabled\n", 3483 3759 c_type_str, c_type_str); 3484 3760 return -EINVAL; 3485 3761 } 3486 3762 3487 3763 if (coalesce_usecs > ICE_ITR_MAX) { 3488 - netdev_info(vsi->netdev, 3489 - "Invalid value, %s-usecs range is 0-%d\n", 3764 + netdev_info(vsi->netdev, "Invalid value, %s-usecs range is 0-%d\n", 3490 3765 c_type_str, ICE_ITR_MAX); 3491 3766 return -EINVAL; 3492 3767 } 3493 3768 3494 3769 /* hardware only supports an ITR granularity of 2us */ 3495 3770 if (coalesce_usecs % 2 != 0) { 3496 - netdev_info(vsi->netdev, 3497 - "Invalid value, %s-usecs must be even\n", 3771 + netdev_info(vsi->netdev, "Invalid value, %s-usecs must be even\n", 3498 3772 c_type_str); 3499 3773 return -EINVAL; 3500 3774 } ··· 3732 4012 } 3733 4013 break; 3734 4014 default: 3735 - netdev_warn(netdev, 3736 - "SFF Module Type not recognized.\n"); 4015 + netdev_warn(netdev, "SFF Module Type not recognized.\n"); 3737 4016 return -EINVAL; 3738 4017 } 3739 4018 return 0; ··· 3800 4081 static const struct ethtool_ops ice_ethtool_ops = { 3801 4082 .get_link_ksettings = ice_get_link_ksettings, 3802 4083 .set_link_ksettings = ice_set_link_ksettings, 3803 - .get_drvinfo = ice_get_drvinfo, 3804 - .get_regs_len = ice_get_regs_len, 3805 - .get_regs = ice_get_regs, 3806 - .get_msglevel = ice_get_msglevel, 3807 - .set_msglevel = ice_set_msglevel, 4084 + .get_drvinfo = ice_get_drvinfo, 4085 + .get_regs_len = ice_get_regs_len, 4086 + .get_regs = ice_get_regs, 4087 + .get_msglevel = ice_get_msglevel, 4088 + .set_msglevel = ice_set_msglevel, 3808 4089 .self_test = ice_self_test, 3809 4090 .get_link = ethtool_op_get_link, 3810 4091 .get_eeprom_len = ice_get_eeprom_len, ··· 3831 4112 .get_channels = ice_get_channels, 3832 4113 .set_channels = ice_set_channels, 3833 4114 .get_ts_info = ethtool_op_get_ts_info, 3834 - .get_per_queue_coalesce = ice_get_per_q_coalesce, 3835 - .set_per_queue_coalesce = ice_set_per_q_coalesce, 4115 + .get_per_queue_coalesce = ice_get_per_q_coalesce, 4116 + .set_per_queue_coalesce = ice_set_per_q_coalesce, 3836 4117 .get_fecparam = ice_get_fecparam, 3837 4118 .set_fecparam = ice_set_fecparam, 3838 4119 .get_module_info = ice_get_module_info,
+6 -1
drivers/net/ethernet/intel/ice/ice_hw_autogen.h
··· 267 267 #define GLNVM_GENS_SR_SIZE_S 5 268 268 #define GLNVM_GENS_SR_SIZE_M ICE_M(0x7, 5) 269 269 #define GLNVM_ULD 0x000B6008 270 + #define GLNVM_ULD_PCIER_DONE_M BIT(0) 271 + #define GLNVM_ULD_PCIER_DONE_1_M BIT(1) 270 272 #define GLNVM_ULD_CORER_DONE_M BIT(3) 271 273 #define GLNVM_ULD_GLOBR_DONE_M BIT(4) 274 + #define GLNVM_ULD_POR_DONE_M BIT(5) 275 + #define GLNVM_ULD_POR_DONE_1_M BIT(8) 276 + #define GLNVM_ULD_PCIER_DONE_2_M BIT(9) 277 + #define GLNVM_ULD_PE_DONE_M BIT(10) 272 278 #define GLPCI_CNF2 0x000BE004 273 279 #define GLPCI_CNF2_CACHELINE_SIZE_M BIT(1) 274 280 #define PF_FUNC_RID 0x0009E880 ··· 337 331 #define GLV_TEPC(_VSI) (0x00312000 + ((_VSI) * 4)) 338 332 #define GLV_UPRCL(_i) (0x003B2000 + ((_i) * 8)) 339 333 #define GLV_UPTCL(_i) (0x0030A000 + ((_i) * 8)) 340 - #define PF_VT_PFALLOC_HIF 0x0009DD80 341 334 #define VSIQF_HKEY_MAX_INDEX 12 342 335 #define VSIQF_HLUT_MAX_INDEX 15 343 336 #define VFINT_DYN_CTLN(_i) (0x00003800 + ((_i) * 4))
+20 -51
drivers/net/ethernet/intel/ice/ice_lib.c
··· 117 117 vsi->num_tx_desc = ICE_DFLT_NUM_TX_DESC; 118 118 break; 119 119 default: 120 - dev_dbg(&vsi->back->pdev->dev, 121 - "Not setting number of Tx/Rx descriptors for VSI type %d\n", 120 + dev_dbg(ice_pf_to_dev(vsi->back), "Not setting number of Tx/Rx descriptors for VSI type %d\n", 122 121 vsi->type); 123 122 break; 124 123 } ··· 723 724 vsi->num_txq = tx_count; 724 725 725 726 if (vsi->type == ICE_VSI_VF && vsi->num_txq != vsi->num_rxq) { 726 - dev_dbg(&vsi->back->pdev->dev, "VF VSI should have same number of Tx and Rx queues. Hence making them equal\n"); 727 + dev_dbg(ice_pf_to_dev(vsi->back), "VF VSI should have same number of Tx and Rx queues. Hence making them equal\n"); 727 728 /* since there is a chance that num_rxq could have been changed 728 729 * in the above for loop, make num_txq equal to num_rxq. 729 730 */ ··· 928 929 vsi->base_vector = ice_get_res(pf, pf->irq_tracker, num_q_vectors, 929 930 vsi->idx); 930 931 if (vsi->base_vector < 0) { 931 - dev_err(dev, 932 - "Failed to get tracking for %d vectors for VSI %d, err=%d\n", 932 + dev_err(dev, "Failed to get tracking for %d vectors for VSI %d, err=%d\n", 933 933 num_q_vectors, vsi->vsi_num, vsi->base_vector); 934 934 return -ENOENT; 935 935 } ··· 1230 1232 * 1231 1233 * Returns 0 on success or ENOMEM on failure. 1232 1234 */ 1233 - int ice_add_mac_to_list(struct ice_vsi *vsi, struct list_head *add_list, 1234 - const u8 *macaddr) 1235 + int 1236 + ice_add_mac_to_list(struct ice_vsi *vsi, struct list_head *add_list, 1237 + const u8 *macaddr) 1235 1238 { 1236 1239 struct ice_fltr_list_entry *tmp; 1237 1240 struct ice_pf *pf = vsi->back; ··· 1391 1392 1392 1393 status = ice_remove_vlan(&pf->hw, &tmp_add_list); 1393 1394 if (status == ICE_ERR_DOES_NOT_EXIST) { 1394 - dev_dbg(dev, 1395 - "Failed to remove VLAN %d on VSI %i, it does not exist, status: %d\n", 1395 + dev_dbg(dev, "Failed to remove VLAN %d on VSI %i, it does not exist, status: %d\n", 1396 1396 vid, vsi->vsi_num, status); 1397 1397 } else if (status) { 1398 - dev_err(dev, 1399 - "Error removing VLAN %d on vsi %i error: %d\n", 1398 + dev_err(dev, "Error removing VLAN %d on vsi %i error: %d\n", 1400 1399 vid, vsi->vsi_num, status); 1401 1400 err = -EIO; 1402 1401 } ··· 1450 1453 1451 1454 err = ice_setup_rx_ctx(vsi->rx_rings[i]); 1452 1455 if (err) { 1453 - dev_err(&vsi->back->pdev->dev, 1454 - "ice_setup_rx_ctx failed for RxQ %d, err %d\n", 1456 + dev_err(ice_pf_to_dev(vsi->back), "ice_setup_rx_ctx failed for RxQ %d, err %d\n", 1455 1457 i, err); 1456 1458 return err; 1457 1459 } ··· 1619 1623 1620 1624 status = ice_update_vsi(hw, vsi->idx, ctxt, NULL); 1621 1625 if (status) { 1622 - dev_err(&vsi->back->pdev->dev, "update VSI for VLAN insert failed, err %d aq_err %d\n", 1626 + dev_err(ice_pf_to_dev(vsi->back), "update VSI for VLAN insert failed, err %d aq_err %d\n", 1623 1627 status, hw->adminq.sq_last_status); 1624 1628 ret = -EIO; 1625 1629 goto out; ··· 1665 1669 1666 1670 status = ice_update_vsi(hw, vsi->idx, ctxt, NULL); 1667 1671 if (status) { 1668 - dev_err(&vsi->back->pdev->dev, "update VSI for VLAN strip failed, ena = %d err %d aq_err %d\n", 1672 + dev_err(ice_pf_to_dev(vsi->back), "update VSI for VLAN strip failed, ena = %d err %d aq_err %d\n", 1669 1673 ena, status, hw->adminq.sq_last_status); 1670 1674 ret = -EIO; 1671 1675 goto out; ··· 1830 1834 struct ice_q_vector *q_vector = vsi->q_vectors[i]; 1831 1835 1832 1836 if (!q_vector) { 1833 - dev_err(&vsi->back->pdev->dev, 1834 - "Failed to set reg_idx on q_vector %d VSI %d\n", 1837 + dev_err(ice_pf_to_dev(vsi->back), "Failed to set reg_idx on q_vector %d VSI %d\n", 1835 1838 i, vsi->vsi_num); 1836 1839 goto clear_reg_idx; 1837 1840 } ··· 1893 1898 status = ice_remove_eth_mac(&pf->hw, &tmp_add_list); 1894 1899 1895 1900 if (status) 1896 - dev_err(dev, 1897 - "Failure Adding or Removing Ethertype on VSI %i error: %d\n", 1901 + dev_err(dev, "Failure Adding or Removing Ethertype on VSI %i error: %d\n", 1898 1902 vsi->vsi_num, status); 1899 1903 1900 1904 ice_free_fltr_list(dev, &tmp_add_list); ··· 2378 2384 return -EINVAL; 2379 2385 2380 2386 if (!needed || needed > res->num_entries || id >= ICE_RES_VALID_BIT) { 2381 - dev_err(ice_pf_to_dev(pf), 2382 - "param err: needed=%d, num_entries = %d id=0x%04x\n", 2387 + dev_err(ice_pf_to_dev(pf), "param err: needed=%d, num_entries = %d id=0x%04x\n", 2383 2388 needed, res->num_entries, id); 2384 2389 return -EINVAL; 2385 2390 } ··· 2679 2686 ice_vsi_put_qs(vsi); 2680 2687 ice_vsi_clear_rings(vsi); 2681 2688 ice_vsi_free_arrays(vsi); 2682 - ice_dev_onetime_setup(&pf->hw); 2683 2689 if (vsi->type == ICE_VSI_VF) 2684 2690 ice_vsi_set_num_qs(vsi, vf->vf_id); 2685 2691 else ··· 2757 2765 status = ice_cfg_vsi_lan(vsi->port_info, vsi->idx, vsi->tc_cfg.ena_tc, 2758 2766 max_txqs); 2759 2767 if (status) { 2760 - dev_err(ice_pf_to_dev(pf), 2761 - "VSI %d failed lan queue config, error %d\n", 2768 + dev_err(ice_pf_to_dev(pf), "VSI %d failed lan queue config, error %d\n", 2762 2769 vsi->vsi_num, status); 2763 2770 if (init_vsi) { 2764 2771 ret = -EIO; ··· 2825 2834 int ice_vsi_cfg_tc(struct ice_vsi *vsi, u8 ena_tc) 2826 2835 { 2827 2836 u16 max_txqs[ICE_MAX_TRAFFIC_CLASS] = { 0 }; 2828 - struct ice_vsi_ctx *ctx; 2829 2837 struct ice_pf *pf = vsi->back; 2838 + struct ice_vsi_ctx *ctx; 2830 2839 enum ice_status status; 2831 2840 struct device *dev; 2832 2841 int i, ret = 0; ··· 2881 2890 return ret; 2882 2891 } 2883 2892 #endif /* CONFIG_DCB */ 2884 - 2885 - /** 2886 - * ice_nvm_version_str - format the NVM version strings 2887 - * @hw: ptr to the hardware info 2888 - */ 2889 - char *ice_nvm_version_str(struct ice_hw *hw) 2890 - { 2891 - u8 oem_ver, oem_patch, ver_hi, ver_lo; 2892 - static char buf[ICE_NVM_VER_LEN]; 2893 - u16 oem_build; 2894 - 2895 - ice_get_nvm_version(hw, &oem_ver, &oem_build, &oem_patch, &ver_hi, 2896 - &ver_lo); 2897 - 2898 - snprintf(buf, sizeof(buf), "%x.%02x 0x%x %d.%d.%d", ver_hi, ver_lo, 2899 - hw->nvm.eetrack, oem_ver, oem_build, oem_patch); 2900 - 2901 - return buf; 2902 - } 2903 2893 2904 2894 /** 2905 2895 * ice_update_ring_stats - Update ring statistics ··· 2953 2981 status = ice_remove_mac(&vsi->back->hw, &tmp_add_list); 2954 2982 2955 2983 cfg_mac_fltr_exit: 2956 - ice_free_fltr_list(&vsi->back->pdev->dev, &tmp_add_list); 2984 + ice_free_fltr_list(ice_pf_to_dev(vsi->back), &tmp_add_list); 2957 2985 return status; 2958 2986 } 2959 2987 ··· 3015 3043 3016 3044 /* another VSI is already the default VSI for this switch */ 3017 3045 if (ice_is_dflt_vsi_in_use(sw)) { 3018 - dev_err(dev, 3019 - "Default forwarding VSI %d already in use, disable it and try again\n", 3046 + dev_err(dev, "Default forwarding VSI %d already in use, disable it and try again\n", 3020 3047 sw->dflt_vsi->vsi_num); 3021 3048 return -EEXIST; 3022 3049 } 3023 3050 3024 3051 status = ice_cfg_dflt_vsi(&vsi->back->hw, vsi->idx, true, ICE_FLTR_RX); 3025 3052 if (status) { 3026 - dev_err(dev, 3027 - "Failed to set VSI %d as the default forwarding VSI, error %d\n", 3053 + dev_err(dev, "Failed to set VSI %d as the default forwarding VSI, error %d\n", 3028 3054 vsi->vsi_num, status); 3029 3055 return -EIO; 3030 3056 } ··· 3061 3091 status = ice_cfg_dflt_vsi(&dflt_vsi->back->hw, dflt_vsi->idx, false, 3062 3092 ICE_FLTR_RX); 3063 3093 if (status) { 3064 - dev_err(dev, 3065 - "Failed to clear the default forwarding VSI %d, error %d\n", 3094 + dev_err(dev, "Failed to clear the default forwarding VSI %d, error %d\n", 3066 3095 dflt_vsi->vsi_num, status); 3067 3096 return -EIO; 3068 3097 }
-2
drivers/net/ethernet/intel/ice/ice_lib.h
··· 97 97 98 98 u32 ice_intrl_usec_to_reg(u8 intrl, u8 gran); 99 99 100 - char *ice_nvm_version_str(struct ice_hw *hw); 101 - 102 100 enum ice_status 103 101 ice_vsi_cfg_mac_fltr(struct ice_vsi *vsi, const u8 *macaddr, bool set); 104 102
+71 -124
drivers/net/ethernet/intel/ice/ice_main.c
··· 162 162 * had an error 163 163 */ 164 164 if (status && vsi->netdev->reg_state == NETREG_REGISTERED) { 165 - dev_err(ice_pf_to_dev(pf), 166 - "Could not add MAC filters error %d. Unregistering device\n", 165 + dev_err(ice_pf_to_dev(pf), "Could not add MAC filters error %d. Unregistering device\n", 167 166 status); 168 167 unregister_netdev(vsi->netdev); 169 168 free_netdev(vsi->netdev); ··· 268 269 */ 269 270 static int ice_vsi_sync_fltr(struct ice_vsi *vsi) 270 271 { 271 - struct device *dev = &vsi->back->pdev->dev; 272 + struct device *dev = ice_pf_to_dev(vsi->back); 272 273 struct net_device *netdev = vsi->netdev; 273 274 bool promisc_forced_on = false; 274 275 struct ice_pf *pf = vsi->back; ··· 334 335 !test_and_set_bit(__ICE_FLTR_OVERFLOW_PROMISC, 335 336 vsi->state)) { 336 337 promisc_forced_on = true; 337 - netdev_warn(netdev, 338 - "Reached MAC filter limit, forcing promisc mode on VSI %d\n", 338 + netdev_warn(netdev, "Reached MAC filter limit, forcing promisc mode on VSI %d\n", 339 339 vsi->vsi_num); 340 340 } else { 341 341 err = -EIO; ··· 380 382 if (!ice_is_dflt_vsi_in_use(pf->first_sw)) { 381 383 err = ice_set_dflt_vsi(pf->first_sw, vsi); 382 384 if (err && err != -EEXIST) { 383 - netdev_err(netdev, 384 - "Error %d setting default VSI %i Rx rule\n", 385 + netdev_err(netdev, "Error %d setting default VSI %i Rx rule\n", 385 386 err, vsi->vsi_num); 386 387 vsi->current_netdev_flags &= 387 388 ~IFF_PROMISC; ··· 392 395 if (ice_is_vsi_dflt_vsi(pf->first_sw, vsi)) { 393 396 err = ice_clear_dflt_vsi(pf->first_sw); 394 397 if (err) { 395 - netdev_err(netdev, 396 - "Error %d clearing default VSI %i Rx rule\n", 398 + netdev_err(netdev, "Error %d clearing default VSI %i Rx rule\n", 397 399 err, vsi->vsi_num); 398 400 vsi->current_netdev_flags |= 399 401 IFF_PROMISC; ··· 748 752 kfree(caps); 749 753 750 754 done: 751 - netdev_info(vsi->netdev, "NIC Link is up %sbps, Requested FEC: %s, FEC: %s, Autoneg: %s, Flow Control: %s\n", 755 + netdev_info(vsi->netdev, "NIC Link is up %sbps Full Duplex, Requested FEC: %s, Negotiated FEC: %s, Autoneg: %s, Flow Control: %s\n", 752 756 speed, fec_req, fec, an, fc); 753 757 ice_print_topo_conflict(vsi); 754 758 } ··· 811 815 */ 812 816 result = ice_update_link_info(pi); 813 817 if (result) 814 - dev_dbg(dev, 815 - "Failed to update link status and re-enable link events for port %d\n", 818 + dev_dbg(dev, "Failed to update link status and re-enable link events for port %d\n", 816 819 pi->lport); 817 820 818 821 /* if the old link up/down and speed is the same as the new */ ··· 829 834 830 835 result = ice_aq_set_link_restart_an(pi, false, NULL); 831 836 if (result) { 832 - dev_dbg(dev, 833 - "Failed to set link down, VSI %d error %d\n", 837 + dev_dbg(dev, "Failed to set link down, VSI %d error %d\n", 834 838 vsi->vsi_num, result); 835 839 return result; 836 840 } 837 841 } 838 842 843 + ice_dcb_rebuild(pf); 839 844 ice_vsi_link_event(vsi, link_up); 840 845 ice_print_link_msg(vsi, link_up); 841 846 ··· 887 892 ICE_AQ_LINK_EVENT_MODULE_QUAL_FAIL)); 888 893 889 894 if (ice_aq_set_event_mask(pi->hw, pi->lport, mask, NULL)) { 890 - dev_dbg(ice_hw_to_dev(pi->hw), 891 - "Failed to set link event mask for port %d\n", 895 + dev_dbg(ice_hw_to_dev(pi->hw), "Failed to set link event mask for port %d\n", 892 896 pi->lport); 893 897 return -EIO; 894 898 } 895 899 896 900 if (ice_aq_get_link_info(pi, true, NULL, NULL)) { 897 - dev_dbg(ice_hw_to_dev(pi->hw), 898 - "Failed to enable link events for port %d\n", 901 + dev_dbg(ice_hw_to_dev(pi->hw), "Failed to enable link events for port %d\n", 899 902 pi->lport); 900 903 return -EIO; 901 904 } ··· 922 929 !!(link_data->link_info & ICE_AQ_LINK_UP), 923 930 le16_to_cpu(link_data->link_speed)); 924 931 if (status) 925 - dev_dbg(ice_pf_to_dev(pf), 926 - "Could not process link event, error %d\n", status); 932 + dev_dbg(ice_pf_to_dev(pf), "Could not process link event, error %d\n", 933 + status); 927 934 928 935 return status; 929 936 } ··· 972 979 dev_dbg(dev, "%s Receive Queue VF Error detected\n", 973 980 qtype); 974 981 if (val & PF_FW_ARQLEN_ARQOVFL_M) { 975 - dev_dbg(dev, 976 - "%s Receive Queue Overflow Error detected\n", 982 + dev_dbg(dev, "%s Receive Queue Overflow Error detected\n", 977 983 qtype); 978 984 } 979 985 if (val & PF_FW_ARQLEN_ARQCRIT_M) 980 - dev_dbg(dev, 981 - "%s Receive Queue Critical Error detected\n", 986 + dev_dbg(dev, "%s Receive Queue Critical Error detected\n", 982 987 qtype); 983 988 val &= ~(PF_FW_ARQLEN_ARQVFE_M | PF_FW_ARQLEN_ARQOVFL_M | 984 989 PF_FW_ARQLEN_ARQCRIT_M); ··· 989 998 PF_FW_ATQLEN_ATQCRIT_M)) { 990 999 oldval = val; 991 1000 if (val & PF_FW_ATQLEN_ATQVFE_M) 992 - dev_dbg(dev, 993 - "%s Send Queue VF Error detected\n", qtype); 1001 + dev_dbg(dev, "%s Send Queue VF Error detected\n", 1002 + qtype); 994 1003 if (val & PF_FW_ATQLEN_ATQOVFL_M) { 995 1004 dev_dbg(dev, "%s Send Queue Overflow Error detected\n", 996 1005 qtype); ··· 1039 1048 ice_dcb_process_lldp_set_mib_change(pf, &event); 1040 1049 break; 1041 1050 default: 1042 - dev_dbg(dev, 1043 - "%s Receive Queue unknown event 0x%04x ignored\n", 1051 + dev_dbg(dev, "%s Receive Queue unknown event 0x%04x ignored\n", 1044 1052 qtype, opcode); 1045 1053 break; 1046 1054 } ··· 1228 1238 u16 queue = ((reg & GL_MDET_TX_TCLAN_QNUM_M) >> 1229 1239 GL_MDET_TX_TCLAN_QNUM_S); 1230 1240 1231 - if (netif_msg_rx_err(pf)) 1241 + if (netif_msg_tx_err(pf)) 1232 1242 dev_info(dev, "Malicious Driver Detection event %d on TX queue %d PF# %d VF# %d\n", 1233 1243 event, queue, pf_num, vf_num); 1234 1244 wr32(hw, GL_MDET_TX_TCLAN, 0xffffffff); ··· 1325 1335 vf->num_mdd_events++; 1326 1336 if (vf->num_mdd_events && 1327 1337 vf->num_mdd_events <= ICE_MDD_EVENTS_THRESHOLD) 1328 - dev_info(dev, 1329 - "VF %d has had %llu MDD events since last boot, Admin might need to reload AVF driver with this number of events\n", 1338 + dev_info(dev, "VF %d has had %llu MDD events since last boot, Admin might need to reload AVF driver with this number of events\n", 1330 1339 i, vf->num_mdd_events); 1331 1340 } 1332 1341 } ··· 1356 1367 if (vsi->type != ICE_VSI_PF) 1357 1368 return 0; 1358 1369 1359 - dev = &vsi->back->pdev->dev; 1370 + dev = ice_pf_to_dev(vsi->back); 1360 1371 1361 1372 pi = vsi->port_info; 1362 1373 ··· 1367 1378 retcode = ice_aq_get_phy_caps(pi, false, ICE_AQC_REPORT_SW_CFG, pcaps, 1368 1379 NULL); 1369 1380 if (retcode) { 1370 - dev_err(dev, 1371 - "Failed to get phy capabilities, VSI %d error %d\n", 1381 + dev_err(dev, "Failed to get phy capabilities, VSI %d error %d\n", 1372 1382 vsi->vsi_num, retcode); 1373 1383 retcode = -EIO; 1374 1384 goto out; ··· 1637 1649 err = devm_request_irq(dev, irq_num, vsi->irq_handler, 0, 1638 1650 q_vector->name, q_vector); 1639 1651 if (err) { 1640 - netdev_err(vsi->netdev, 1641 - "MSIX request_irq failed, error: %d\n", err); 1652 + netdev_err(vsi->netdev, "MSIX request_irq failed, error: %d\n", 1653 + err); 1642 1654 goto free_q_irqs; 1643 1655 } 1644 1656 ··· 1673 1685 */ 1674 1686 static int ice_xdp_alloc_setup_rings(struct ice_vsi *vsi) 1675 1687 { 1676 - struct device *dev = &vsi->back->pdev->dev; 1688 + struct device *dev = ice_pf_to_dev(vsi->back); 1677 1689 int i; 1678 1690 1679 1691 for (i = 0; i < vsi->num_xdp_txq; i++) { ··· 2652 2664 clear_bit(ICE_FLAG_DCB_CAPABLE, pf->flags); 2653 2665 if (func_caps->common_cap.dcb) 2654 2666 set_bit(ICE_FLAG_DCB_CAPABLE, pf->flags); 2655 - #ifdef CONFIG_PCI_IOV 2656 2667 clear_bit(ICE_FLAG_SRIOV_CAPABLE, pf->flags); 2657 2668 if (func_caps->common_cap.sr_iov_1_1) { 2658 2669 set_bit(ICE_FLAG_SRIOV_CAPABLE, pf->flags); 2659 2670 pf->num_vfs_supported = min_t(int, func_caps->num_allocd_vfs, 2660 2671 ICE_MAX_VF_COUNT); 2661 2672 } 2662 - #endif /* CONFIG_PCI_IOV */ 2663 2673 clear_bit(ICE_FLAG_RSS_ENA, pf->flags); 2664 2674 if (func_caps->common_cap.rss_table_size) 2665 2675 set_bit(ICE_FLAG_RSS_ENA, pf->flags); ··· 2750 2764 } 2751 2765 2752 2766 if (v_actual < v_budget) { 2753 - dev_warn(dev, 2754 - "not enough OS MSI-X vectors. requested = %d, obtained = %d\n", 2767 + dev_warn(dev, "not enough OS MSI-X vectors. requested = %d, obtained = %d\n", 2755 2768 v_budget, v_actual); 2756 2769 /* 2 vectors for LAN (traffic + OICR) */ 2757 2770 #define ICE_MIN_LAN_VECS 2 ··· 2772 2787 goto exit_err; 2773 2788 2774 2789 no_hw_vecs_left_err: 2775 - dev_err(dev, 2776 - "not enough device MSI-X vectors. requested = %d, available = %d\n", 2790 + dev_err(dev, "not enough device MSI-X vectors. requested = %d, available = %d\n", 2777 2791 needed, v_left); 2778 2792 err = -ERANGE; 2779 2793 exit_err: ··· 2905 2921 !memcmp(hw->pkg_name, hw->active_pkg_name, 2906 2922 sizeof(hw->pkg_name))) { 2907 2923 if (hw->pkg_dwnld_status == ICE_AQ_RC_EEXIST) 2908 - dev_info(dev, 2909 - "DDP package already present on device: %s version %d.%d.%d.%d\n", 2924 + dev_info(dev, "DDP package already present on device: %s version %d.%d.%d.%d\n", 2910 2925 hw->active_pkg_name, 2911 2926 hw->active_pkg_ver.major, 2912 2927 hw->active_pkg_ver.minor, 2913 2928 hw->active_pkg_ver.update, 2914 2929 hw->active_pkg_ver.draft); 2915 2930 else 2916 - dev_info(dev, 2917 - "The DDP package was successfully loaded: %s version %d.%d.%d.%d\n", 2931 + dev_info(dev, "The DDP package was successfully loaded: %s version %d.%d.%d.%d\n", 2918 2932 hw->active_pkg_name, 2919 2933 hw->active_pkg_ver.major, 2920 2934 hw->active_pkg_ver.minor, ··· 2920 2938 hw->active_pkg_ver.draft); 2921 2939 } else if (hw->active_pkg_ver.major != ICE_PKG_SUPP_VER_MAJ || 2922 2940 hw->active_pkg_ver.minor != ICE_PKG_SUPP_VER_MNR) { 2923 - dev_err(dev, 2924 - "The device has a DDP package that is not supported by the driver. The device has package '%s' version %d.%d.x.x. The driver requires version %d.%d.x.x. Entering Safe Mode.\n", 2941 + dev_err(dev, "The device has a DDP package that is not supported by the driver. The device has package '%s' version %d.%d.x.x. The driver requires version %d.%d.x.x. Entering Safe Mode.\n", 2925 2942 hw->active_pkg_name, 2926 2943 hw->active_pkg_ver.major, 2927 2944 hw->active_pkg_ver.minor, ··· 2928 2947 *status = ICE_ERR_NOT_SUPPORTED; 2929 2948 } else if (hw->active_pkg_ver.major == ICE_PKG_SUPP_VER_MAJ && 2930 2949 hw->active_pkg_ver.minor == ICE_PKG_SUPP_VER_MNR) { 2931 - dev_info(dev, 2932 - "The driver could not load the DDP package file because a compatible DDP package is already present on the device. The device has package '%s' version %d.%d.%d.%d. The package file found by the driver: '%s' version %d.%d.%d.%d.\n", 2950 + dev_info(dev, "The driver could not load the DDP package file because a compatible DDP package is already present on the device. The device has package '%s' version %d.%d.%d.%d. The package file found by the driver: '%s' version %d.%d.%d.%d.\n", 2933 2951 hw->active_pkg_name, 2934 2952 hw->active_pkg_ver.major, 2935 2953 hw->active_pkg_ver.minor, ··· 2940 2960 hw->pkg_ver.update, 2941 2961 hw->pkg_ver.draft); 2942 2962 } else { 2943 - dev_err(dev, 2944 - "An unknown error occurred when loading the DDP package, please reboot the system. If the problem persists, update the NVM. Entering Safe Mode.\n"); 2963 + dev_err(dev, "An unknown error occurred when loading the DDP package, please reboot the system. If the problem persists, update the NVM. Entering Safe Mode.\n"); 2945 2964 *status = ICE_ERR_NOT_SUPPORTED; 2946 2965 } 2947 2966 break; 2948 2967 case ICE_ERR_BUF_TOO_SHORT: 2949 2968 /* fall-through */ 2950 2969 case ICE_ERR_CFG: 2951 - dev_err(dev, 2952 - "The DDP package file is invalid. Entering Safe Mode.\n"); 2970 + dev_err(dev, "The DDP package file is invalid. Entering Safe Mode.\n"); 2953 2971 break; 2954 2972 case ICE_ERR_NOT_SUPPORTED: 2955 2973 /* Package File version not supported */ 2956 2974 if (hw->pkg_ver.major > ICE_PKG_SUPP_VER_MAJ || 2957 2975 (hw->pkg_ver.major == ICE_PKG_SUPP_VER_MAJ && 2958 2976 hw->pkg_ver.minor > ICE_PKG_SUPP_VER_MNR)) 2959 - dev_err(dev, 2960 - "The DDP package file version is higher than the driver supports. Please use an updated driver. Entering Safe Mode.\n"); 2977 + dev_err(dev, "The DDP package file version is higher than the driver supports. Please use an updated driver. Entering Safe Mode.\n"); 2961 2978 else if (hw->pkg_ver.major < ICE_PKG_SUPP_VER_MAJ || 2962 2979 (hw->pkg_ver.major == ICE_PKG_SUPP_VER_MAJ && 2963 2980 hw->pkg_ver.minor < ICE_PKG_SUPP_VER_MNR)) 2964 - dev_err(dev, 2965 - "The DDP package file version is lower than the driver supports. The driver requires version %d.%d.x.x. Please use an updated DDP Package file. Entering Safe Mode.\n", 2981 + dev_err(dev, "The DDP package file version is lower than the driver supports. The driver requires version %d.%d.x.x. Please use an updated DDP Package file. Entering Safe Mode.\n", 2966 2982 ICE_PKG_SUPP_VER_MAJ, ICE_PKG_SUPP_VER_MNR); 2967 2983 break; 2968 2984 case ICE_ERR_AQ_ERROR: 2969 2985 switch (hw->pkg_dwnld_status) { 2970 2986 case ICE_AQ_RC_ENOSEC: 2971 2987 case ICE_AQ_RC_EBADSIG: 2972 - dev_err(dev, 2973 - "The DDP package could not be loaded because its signature is not valid. Please use a valid DDP Package. Entering Safe Mode.\n"); 2988 + dev_err(dev, "The DDP package could not be loaded because its signature is not valid. Please use a valid DDP Package. Entering Safe Mode.\n"); 2974 2989 return; 2975 2990 case ICE_AQ_RC_ESVN: 2976 - dev_err(dev, 2977 - "The DDP Package could not be loaded because its security revision is too low. Please use an updated DDP Package. Entering Safe Mode.\n"); 2991 + dev_err(dev, "The DDP Package could not be loaded because its security revision is too low. Please use an updated DDP Package. Entering Safe Mode.\n"); 2978 2992 return; 2979 2993 case ICE_AQ_RC_EBADMAN: 2980 2994 case ICE_AQ_RC_EBADBUF: 2981 - dev_err(dev, 2982 - "An error occurred on the device while loading the DDP package. The device will be reset.\n"); 2995 + dev_err(dev, "An error occurred on the device while loading the DDP package. The device will be reset.\n"); 2983 2996 return; 2984 2997 default: 2985 2998 break; 2986 2999 } 2987 3000 /* fall-through */ 2988 3001 default: 2989 - dev_err(dev, 2990 - "An unknown error (%d) occurred when loading the DDP package. Entering Safe Mode.\n", 3002 + dev_err(dev, "An unknown error (%d) occurred when loading the DDP package. Entering Safe Mode.\n", 2991 3003 *status); 2992 3004 break; 2993 3005 } ··· 3010 3038 status = ice_init_pkg(hw, hw->pkg_copy, hw->pkg_size); 3011 3039 ice_log_pkg_init(hw, &status); 3012 3040 } else { 3013 - dev_err(dev, 3014 - "The DDP package file failed to load. Entering Safe Mode.\n"); 3041 + dev_err(dev, "The DDP package file failed to load. Entering Safe Mode.\n"); 3015 3042 } 3016 3043 3017 3044 if (status) { ··· 3036 3065 static void ice_verify_cacheline_size(struct ice_pf *pf) 3037 3066 { 3038 3067 if (rd32(&pf->hw, GLPCI_CNF2) & GLPCI_CNF2_CACHELINE_SIZE_M) 3039 - dev_warn(ice_pf_to_dev(pf), 3040 - "%d Byte cache line assumption is invalid, driver may have Tx timeouts!\n", 3068 + dev_warn(ice_pf_to_dev(pf), "%d Byte cache line assumption is invalid, driver may have Tx timeouts!\n", 3041 3069 ICE_CACHE_LINE_BYTES); 3042 3070 } 3043 3071 ··· 3129 3159 dflt_pkg_load: 3130 3160 err = request_firmware(&firmware, ICE_DDP_PKG_FILE, dev); 3131 3161 if (err) { 3132 - dev_err(dev, 3133 - "The DDP package file was not found or could not be read. Entering Safe Mode\n"); 3162 + dev_err(dev, "The DDP package file was not found or could not be read. Entering Safe Mode\n"); 3134 3163 return; 3135 3164 } 3136 3165 ··· 3153 3184 struct ice_hw *hw; 3154 3185 int err; 3155 3186 3156 - /* this driver uses devres, see Documentation/driver-api/driver-model/devres.rst */ 3187 + /* this driver uses devres, see 3188 + * Documentation/driver-api/driver-model/devres.rst 3189 + */ 3157 3190 err = pcim_enable_device(pdev); 3158 3191 if (err) 3159 3192 return err; ··· 3216 3245 goto err_exit_unroll; 3217 3246 } 3218 3247 3219 - dev_info(dev, "firmware %d.%d.%d api %d.%d.%d nvm %s build 0x%08x\n", 3220 - hw->fw_maj_ver, hw->fw_min_ver, hw->fw_patch, 3221 - hw->api_maj_ver, hw->api_min_ver, hw->api_patch, 3222 - ice_nvm_version_str(hw), hw->fw_build); 3223 - 3224 3248 ice_request_fw(pf); 3225 3249 3226 3250 /* if ice_request_fw fails, ICE_FLAG_ADV_FEATURES bit won't be ··· 3223 3257 * true 3224 3258 */ 3225 3259 if (ice_is_safe_mode(pf)) { 3226 - dev_err(dev, 3227 - "Package download failed. Advanced features disabled - Device now in Safe Mode\n"); 3260 + dev_err(dev, "Package download failed. Advanced features disabled - Device now in Safe Mode\n"); 3228 3261 /* we already got function/device capabilities but these don't 3229 3262 * reflect what the driver needs to do in safe mode. Instead of 3230 3263 * adding conditional logic everywhere to ignore these ··· 3300 3335 /* tell the firmware we are up */ 3301 3336 err = ice_send_version(pf); 3302 3337 if (err) { 3303 - dev_err(dev, 3304 - "probe failed sending driver version %s. error: %d\n", 3338 + dev_err(dev, "probe failed sending driver version %s. error: %d\n", 3305 3339 ice_drv_ver, err); 3306 3340 goto err_alloc_sw_unroll; 3307 3341 } ··· 3441 3477 3442 3478 err = pci_enable_device_mem(pdev); 3443 3479 if (err) { 3444 - dev_err(&pdev->dev, 3445 - "Cannot re-enable PCI device after reset, error %d\n", 3480 + dev_err(&pdev->dev, "Cannot re-enable PCI device after reset, error %d\n", 3446 3481 err); 3447 3482 result = PCI_ERS_RESULT_DISCONNECT; 3448 3483 } else { ··· 3460 3497 3461 3498 err = pci_cleanup_aer_uncorrect_error_status(pdev); 3462 3499 if (err) 3463 - dev_dbg(&pdev->dev, 3464 - "pci_cleanup_aer_uncorrect_error_status failed, error %d\n", 3500 + dev_dbg(&pdev->dev, "pci_cleanup_aer_uncorrect_error_status failed, error %d\n", 3465 3501 err); 3466 3502 /* non-fatal, continue */ 3467 3503 ··· 3479 3517 struct ice_pf *pf = pci_get_drvdata(pdev); 3480 3518 3481 3519 if (!pf) { 3482 - dev_err(&pdev->dev, 3483 - "%s failed, device is unrecoverable\n", __func__); 3520 + dev_err(&pdev->dev, "%s failed, device is unrecoverable\n", 3521 + __func__); 3484 3522 return; 3485 3523 } 3486 3524 ··· 3728 3766 3729 3767 /* Validate maxrate requested is within permitted range */ 3730 3768 if (maxrate && (maxrate > (ICE_SCHED_MAX_BW / 1000))) { 3731 - netdev_err(netdev, 3732 - "Invalid max rate %d specified for the queue %d\n", 3769 + netdev_err(netdev, "Invalid max rate %d specified for the queue %d\n", 3733 3770 maxrate, queue_index); 3734 3771 return -EINVAL; 3735 3772 } ··· 3744 3783 status = ice_cfg_q_bw_lmt(vsi->port_info, vsi->idx, tc, 3745 3784 q_handle, ICE_MAX_BW, maxrate * 1000); 3746 3785 if (status) { 3747 - netdev_err(netdev, 3748 - "Unable to set Tx max rate, error %d\n", status); 3786 + netdev_err(netdev, "Unable to set Tx max rate, error %d\n", 3787 + status); 3749 3788 return -EIO; 3750 3789 } 3751 3790 ··· 3837 3876 3838 3877 /* Don't set any netdev advanced features with device in Safe Mode */ 3839 3878 if (ice_is_safe_mode(vsi->back)) { 3840 - dev_err(&vsi->back->pdev->dev, 3841 - "Device is in Safe Mode - not enabling advanced netdev features\n"); 3879 + dev_err(ice_pf_to_dev(vsi->back), "Device is in Safe Mode - not enabling advanced netdev features\n"); 3842 3880 return ret; 3843 3881 } 3844 3882 3845 3883 /* Do not change setting during reset */ 3846 3884 if (ice_is_reset_in_progress(pf->state)) { 3847 - dev_err(&vsi->back->pdev->dev, 3848 - "Device is resetting, changing advanced netdev features temporarily unavailable.\n"); 3885 + dev_err(ice_pf_to_dev(vsi->back), "Device is resetting, changing advanced netdev features temporarily unavailable.\n"); 3849 3886 return -EBUSY; 3850 3887 } 3851 3888 ··· 4331 4372 4332 4373 tx_err = ice_vsi_stop_lan_tx_rings(vsi, ICE_NO_RESET, 0); 4333 4374 if (tx_err) 4334 - netdev_err(vsi->netdev, 4335 - "Failed stop Tx rings, VSI %d error %d\n", 4375 + netdev_err(vsi->netdev, "Failed stop Tx rings, VSI %d error %d\n", 4336 4376 vsi->vsi_num, tx_err); 4337 4377 if (!tx_err && ice_is_xdp_ena_vsi(vsi)) { 4338 4378 tx_err = ice_vsi_stop_xdp_tx_rings(vsi); 4339 4379 if (tx_err) 4340 - netdev_err(vsi->netdev, 4341 - "Failed stop XDP rings, VSI %d error %d\n", 4380 + netdev_err(vsi->netdev, "Failed stop XDP rings, VSI %d error %d\n", 4342 4381 vsi->vsi_num, tx_err); 4343 4382 } 4344 4383 4345 4384 rx_err = ice_vsi_stop_rx_rings(vsi); 4346 4385 if (rx_err) 4347 - netdev_err(vsi->netdev, 4348 - "Failed stop Rx rings, VSI %d error %d\n", 4386 + netdev_err(vsi->netdev, "Failed stop Rx rings, VSI %d error %d\n", 4349 4387 vsi->vsi_num, rx_err); 4350 4388 4351 4389 ice_napi_disable_all(vsi); ··· 4350 4394 if (test_bit(ICE_FLAG_LINK_DOWN_ON_CLOSE_ENA, vsi->back->flags)) { 4351 4395 link_err = ice_force_phys_link_state(vsi, false); 4352 4396 if (link_err) 4353 - netdev_err(vsi->netdev, 4354 - "Failed to set physical link down, VSI %d error %d\n", 4397 + netdev_err(vsi->netdev, "Failed to set physical link down, VSI %d error %d\n", 4355 4398 vsi->vsi_num, link_err); 4356 4399 } 4357 4400 ··· 4361 4406 ice_clean_rx_ring(vsi->rx_rings[i]); 4362 4407 4363 4408 if (tx_err || rx_err || link_err) { 4364 - netdev_err(vsi->netdev, 4365 - "Failed to close VSI 0x%04X on switch 0x%04X\n", 4409 + netdev_err(vsi->netdev, "Failed to close VSI 0x%04X on switch 0x%04X\n", 4366 4410 vsi->vsi_num, vsi->vsw->sw_id); 4367 4411 return -EIO; 4368 4412 } ··· 4380 4426 int i, err = 0; 4381 4427 4382 4428 if (!vsi->num_txq) { 4383 - dev_err(&vsi->back->pdev->dev, "VSI %d has 0 Tx queues\n", 4429 + dev_err(ice_pf_to_dev(vsi->back), "VSI %d has 0 Tx queues\n", 4384 4430 vsi->vsi_num); 4385 4431 return -EINVAL; 4386 4432 } ··· 4411 4457 int i, err = 0; 4412 4458 4413 4459 if (!vsi->num_rxq) { 4414 - dev_err(&vsi->back->pdev->dev, "VSI %d has 0 Rx queues\n", 4460 + dev_err(ice_pf_to_dev(vsi->back), "VSI %d has 0 Rx queues\n", 4415 4461 vsi->vsi_num); 4416 4462 return -EINVAL; 4417 4463 } ··· 4508 4554 4509 4555 err = ice_vsi_release(pf->vsi[i]); 4510 4556 if (err) 4511 - dev_dbg(ice_pf_to_dev(pf), 4512 - "Failed to release pf->vsi[%d], err %d, vsi_num = %d\n", 4557 + dev_dbg(ice_pf_to_dev(pf), "Failed to release pf->vsi[%d], err %d, vsi_num = %d\n", 4513 4558 i, err, pf->vsi[i]->vsi_num); 4514 4559 } 4515 4560 } ··· 4535 4582 /* rebuild the VSI */ 4536 4583 err = ice_vsi_rebuild(vsi, true); 4537 4584 if (err) { 4538 - dev_err(dev, 4539 - "rebuild VSI failed, err %d, VSI index %d, type %s\n", 4585 + dev_err(dev, "rebuild VSI failed, err %d, VSI index %d, type %s\n", 4540 4586 err, vsi->idx, ice_vsi_type_str(type)); 4541 4587 return err; 4542 4588 } ··· 4543 4591 /* replay filters for the VSI */ 4544 4592 status = ice_replay_vsi(&pf->hw, vsi->idx); 4545 4593 if (status) { 4546 - dev_err(dev, 4547 - "replay VSI failed, status %d, VSI index %d, type %s\n", 4594 + dev_err(dev, "replay VSI failed, status %d, VSI index %d, type %s\n", 4548 4595 status, vsi->idx, ice_vsi_type_str(type)); 4549 4596 return -EIO; 4550 4597 } ··· 4556 4605 /* enable the VSI */ 4557 4606 err = ice_ena_vsi(vsi, false); 4558 4607 if (err) { 4559 - dev_err(dev, 4560 - "enable VSI failed, err %d, VSI index %d, type %s\n", 4608 + dev_err(dev, "enable VSI failed, err %d, VSI index %d, type %s\n", 4561 4609 err, vsi->idx, ice_vsi_type_str(type)); 4562 4610 return err; 4563 4611 } ··· 4634 4684 } 4635 4685 4636 4686 if (pf->first_sw->dflt_vsi_ena) 4637 - dev_info(dev, 4638 - "Clearing default VSI, re-enable after reset completes\n"); 4687 + dev_info(dev, "Clearing default VSI, re-enable after reset completes\n"); 4639 4688 /* clear the default VSI configuration if it exists */ 4640 4689 pf->first_sw->dflt_vsi = NULL; 4641 4690 pf->first_sw->dflt_vsi_ena = false; ··· 4685 4736 /* tell the firmware we are up */ 4686 4737 ret = ice_send_version(pf); 4687 4738 if (ret) { 4688 - dev_err(dev, 4689 - "Rebuild failed due to error sending driver version: %d\n", 4739 + dev_err(dev, "Rebuild failed due to error sending driver version: %d\n", 4690 4740 ret); 4691 4741 goto err_vsi_rebuild; 4692 4742 } ··· 4941 4993 4942 4994 status = ice_update_vsi(hw, vsi->idx, ctxt, NULL); 4943 4995 if (status) { 4944 - dev_err(&vsi->back->pdev->dev, "update VSI for bridge mode failed, bmode = %d err %d aq_err %d\n", 4996 + dev_err(ice_pf_to_dev(vsi->back), "update VSI for bridge mode failed, bmode = %d err %d aq_err %d\n", 4945 4997 bmode, status, hw->adminq.sq_last_status); 4946 4998 ret = -EIO; 4947 4999 goto out; ··· 5133 5185 if (pi->phy.link_info.link_info & ICE_AQ_MEDIA_AVAILABLE) { 5134 5186 err = ice_force_phys_link_state(vsi, true); 5135 5187 if (err) { 5136 - netdev_err(netdev, 5137 - "Failed to set physical link up, error %d\n", 5188 + netdev_err(netdev, "Failed to set physical link up, error %d\n", 5138 5189 err); 5139 5190 return err; 5140 5191 }
+4 -7
drivers/net/ethernet/intel/ice/ice_txrx.c
··· 644 644 * Update the offset within page so that Rx buf will be ready to be reused. 645 645 * For systems with PAGE_SIZE < 8192 this function will flip the page offset 646 646 * so the second half of page assigned to Rx buffer will be used, otherwise 647 - * the offset is moved by the @size bytes 647 + * the offset is moved by "size" bytes 648 648 */ 649 649 static void 650 650 ice_rx_buf_adjust_pg_offset(struct ice_rx_buf *rx_buf, unsigned int size) ··· 1078 1078 skb = ice_build_skb(rx_ring, rx_buf, &xdp); 1079 1079 else 1080 1080 skb = ice_construct_skb(rx_ring, rx_buf, &xdp); 1081 - } else { 1082 - skb = ice_construct_skb(rx_ring, rx_buf, &xdp); 1083 1081 } 1084 1082 /* exit if we failed to retrieve a buffer */ 1085 1083 if (!skb) { ··· 1619 1621 { 1620 1622 u64 td_offset, td_tag, td_cmd; 1621 1623 u16 i = tx_ring->next_to_use; 1622 - skb_frag_t *frag; 1623 1624 unsigned int data_len, size; 1624 1625 struct ice_tx_desc *tx_desc; 1625 1626 struct ice_tx_buf *tx_buf; 1626 1627 struct sk_buff *skb; 1628 + skb_frag_t *frag; 1627 1629 dma_addr_t dma; 1628 1630 1629 1631 td_tag = off->td_l2tag1; ··· 1736 1738 ice_maybe_stop_tx(tx_ring, DESC_NEEDED); 1737 1739 1738 1740 /* notify HW of packet */ 1739 - if (netif_xmit_stopped(txring_txq(tx_ring)) || !netdev_xmit_more()) { 1741 + if (netif_xmit_stopped(txring_txq(tx_ring)) || !netdev_xmit_more()) 1740 1742 writel(i, tx_ring->tail); 1741 - } 1742 1743 1743 1744 return; 1744 1745 ··· 2075 2078 frag = &skb_shinfo(skb)->frags[0]; 2076 2079 2077 2080 /* Initialize size to the negative value of gso_size minus 1. We 2078 - * use this as the worst case scenerio in which the frag ahead 2081 + * use this as the worst case scenario in which the frag ahead 2079 2082 * of us only provides one byte which is why we are limited to 6 2080 2083 * descriptors for a single transmit as the header and previous 2081 2084 * fragment are already consuming 2 descriptors.
+2 -2
drivers/net/ethernet/intel/ice/ice_txrx.h
··· 33 33 * frame. 34 34 * 35 35 * Note: For cache line sizes 256 or larger this value is going to end 36 - * up negative. In these cases we should fall back to the legacy 37 - * receive path. 36 + * up negative. In these cases we should fall back to the legacy 37 + * receive path. 38 38 */ 39 39 #if (PAGE_SIZE < 8192) 40 40 #define ICE_2K_TOO_SMALL_WITH_PADDING \
+1 -1
drivers/net/ethernet/intel/ice/ice_txrx_lib.c
··· 10 10 */ 11 11 void ice_release_rx_desc(struct ice_ring *rx_ring, u32 val) 12 12 { 13 - u16 prev_ntu = rx_ring->next_to_use; 13 + u16 prev_ntu = rx_ring->next_to_use & ~0x7; 14 14 15 15 rx_ring->next_to_use = val; 16 16
+1 -1
drivers/net/ethernet/intel/ice/ice_type.h
··· 517 517 struct ice_fw_log_cfg fw_log; 518 518 519 519 /* Device max aggregate bandwidths corresponding to the GL_PWR_MODE_CTL 520 - * register. Used for determining the ITR/intrl granularity during 520 + * register. Used for determining the ITR/INTRL granularity during 521 521 * initialization. 522 522 */ 523 523 #define ICE_MAX_AGG_BW_200G 0x0
+23 -44
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c
··· 199 199 if (vsi->rx_mapping_mode == ICE_VSI_MAP_CONTIG) 200 200 wr32(hw, VPLAN_RX_QBASE(vf->vf_id), 0); 201 201 else 202 - dev_err(dev, 203 - "Scattered mode for VF Rx queues is not yet implemented\n"); 202 + dev_err(dev, "Scattered mode for VF Rx queues is not yet implemented\n"); 204 203 } 205 204 206 205 /** ··· 401 402 if ((reg & VF_TRANS_PENDING_M) == 0) 402 403 break; 403 404 404 - dev_err(dev, 405 - "VF %d PCI transactions stuck\n", vf->vf_id); 405 + dev_err(dev, "VF %d PCI transactions stuck\n", vf->vf_id); 406 406 udelay(ICE_PCI_CIAD_WAIT_DELAY_US); 407 407 } 408 408 } ··· 460 462 461 463 status = ice_update_vsi(hw, vsi->idx, ctxt, NULL); 462 464 if (status) { 463 - dev_info(&vsi->back->pdev->dev, "update VSI for port VLAN failed, err %d aq_err %d\n", 465 + dev_info(ice_pf_to_dev(vsi->back), "update VSI for port VLAN failed, err %d aq_err %d\n", 464 466 status, hw->adminq.sq_last_status); 465 467 ret = -EIO; 466 468 goto out; ··· 1093 1095 * finished resetting. 1094 1096 */ 1095 1097 for (i = 0, v = 0; i < 10 && v < pf->num_alloc_vfs; i++) { 1096 - 1097 1098 /* Check each VF in sequence */ 1098 1099 while (v < pf->num_alloc_vfs) { 1099 1100 u32 reg; ··· 1550 1553 dev_info(dev, "VF %d failed opcode %d, retval: %d\n", vf->vf_id, 1551 1554 v_opcode, v_retval); 1552 1555 if (vf->num_inval_msgs > ICE_DFLT_NUM_INVAL_MSGS_ALLOWED) { 1553 - dev_err(dev, 1554 - "Number of invalid messages exceeded for VF %d\n", 1556 + dev_err(dev, "Number of invalid messages exceeded for VF %d\n", 1555 1557 vf->vf_id); 1556 1558 dev_err(dev, "Use PF Control I/F to enable the VF\n"); 1557 1559 set_bit(ICE_VF_STATE_DIS, vf->vf_states); ··· 1565 1569 aq_ret = ice_aq_send_msg_to_vf(&pf->hw, vf->vf_id, v_opcode, v_retval, 1566 1570 msg, msglen, NULL); 1567 1571 if (aq_ret && pf->hw.mailboxq.sq_last_status != ICE_AQ_RC_ENOSYS) { 1568 - dev_info(dev, 1569 - "Unable to send the message to VF %d ret %d aq_err %d\n", 1572 + dev_info(dev, "Unable to send the message to VF %d ret %d aq_err %d\n", 1570 1573 vf->vf_id, aq_ret, pf->hw.mailboxq.sq_last_status); 1571 1574 return -EIO; 1572 1575 } ··· 1909 1914 } 1910 1915 1911 1916 if (vf_vsi->type != ICE_VSI_VF) { 1912 - netdev_err(netdev, 1913 - "Type %d of VSI %d for VF %d is no ICE_VSI_VF\n", 1917 + netdev_err(netdev, "Type %d of VSI %d for VF %d is no ICE_VSI_VF\n", 1914 1918 vf_vsi->type, vf_vsi->vsi_num, vf->vf_id); 1915 1919 return -ENODEV; 1916 1920 } ··· 1939 1945 1940 1946 status = ice_update_vsi(&pf->hw, vf_vsi->idx, ctx, NULL); 1941 1947 if (status) { 1942 - dev_err(dev, 1943 - "Failed to %sable spoofchk on VF %d VSI %d\n error %d", 1948 + dev_err(dev, "Failed to %sable spoofchk on VF %d VSI %d\n error %d", 1944 1949 ena ? "en" : "dis", vf->vf_id, vf_vsi->vsi_num, status); 1945 1950 ret = -EIO; 1946 1951 goto out; ··· 2056 2063 continue; 2057 2064 2058 2065 if (ice_vsi_ctrl_rx_ring(vsi, true, vf_q_id)) { 2059 - dev_err(&vsi->back->pdev->dev, 2060 - "Failed to enable Rx ring %d on VSI %d\n", 2066 + dev_err(ice_pf_to_dev(vsi->back), "Failed to enable Rx ring %d on VSI %d\n", 2061 2067 vf_q_id, vsi->vsi_num); 2062 2068 v_ret = VIRTCHNL_STATUS_ERR_PARAM; 2063 2069 goto error_param; ··· 2158 2166 2159 2167 if (ice_vsi_stop_tx_ring(vsi, ICE_NO_RESET, vf->vf_id, 2160 2168 ring, &txq_meta)) { 2161 - dev_err(&vsi->back->pdev->dev, 2162 - "Failed to stop Tx ring %d on VSI %d\n", 2169 + dev_err(ice_pf_to_dev(vsi->back), "Failed to stop Tx ring %d on VSI %d\n", 2163 2170 vf_q_id, vsi->vsi_num); 2164 2171 v_ret = VIRTCHNL_STATUS_ERR_PARAM; 2165 2172 goto error_param; ··· 2184 2193 continue; 2185 2194 2186 2195 if (ice_vsi_ctrl_rx_ring(vsi, false, vf_q_id)) { 2187 - dev_err(&vsi->back->pdev->dev, 2188 - "Failed to stop Rx ring %d on VSI %d\n", 2196 + dev_err(ice_pf_to_dev(vsi->back), "Failed to stop Rx ring %d on VSI %d\n", 2189 2197 vf_q_id, vsi->vsi_num); 2190 2198 v_ret = VIRTCHNL_STATUS_ERR_PARAM; 2191 2199 goto error_param; ··· 2347 2357 2348 2358 if (qci->num_queue_pairs > ICE_MAX_BASE_QS_PER_VF || 2349 2359 qci->num_queue_pairs > min_t(u16, vsi->alloc_txq, vsi->alloc_rxq)) { 2350 - dev_err(ice_pf_to_dev(pf), 2351 - "VF-%d requesting more than supported number of queues: %d\n", 2360 + dev_err(ice_pf_to_dev(pf), "VF-%d requesting more than supported number of queues: %d\n", 2352 2361 vf->vf_id, min_t(u16, vsi->alloc_txq, vsi->alloc_rxq)); 2353 2362 v_ret = VIRTCHNL_STATUS_ERR_PARAM; 2354 2363 goto error_param; ··· 2559 2570 */ 2560 2571 if (set && !ice_is_vf_trusted(vf) && 2561 2572 (vf->num_mac + al->num_elements) > ICE_MAX_MACADDR_PER_VF) { 2562 - dev_err(ice_pf_to_dev(pf), 2563 - "Can't add more MAC addresses, because VF-%d is not trusted, switch the VF to trusted mode in order to add more functionalities\n", 2573 + dev_err(ice_pf_to_dev(pf), "Can't add more MAC addresses, because VF-%d is not trusted, switch the VF to trusted mode in order to add more functionalities\n", 2564 2574 vf->vf_id); 2565 2575 v_ret = VIRTCHNL_STATUS_ERR_PARAM; 2566 2576 goto handle_mac_exit; ··· 2636 2648 struct ice_pf *pf = vf->pf; 2637 2649 u16 max_allowed_vf_queues; 2638 2650 u16 tx_rx_queue_left; 2639 - u16 cur_queues; 2640 2651 struct device *dev; 2652 + u16 cur_queues; 2641 2653 2642 2654 dev = ice_pf_to_dev(pf); 2643 2655 if (!test_bit(ICE_VF_STATE_ACTIVE, vf->vf_states)) { ··· 2658 2670 vfres->num_queue_pairs = ICE_MAX_BASE_QS_PER_VF; 2659 2671 } else if (req_queues > cur_queues && 2660 2672 req_queues - cur_queues > tx_rx_queue_left) { 2661 - dev_warn(dev, 2662 - "VF %d requested %u more queues, but only %u left.\n", 2673 + dev_warn(dev, "VF %d requested %u more queues, but only %u left.\n", 2663 2674 vf->vf_id, req_queues - cur_queues, tx_rx_queue_left); 2664 2675 vfres->num_queue_pairs = min_t(u16, max_allowed_vf_queues, 2665 2676 ICE_MAX_BASE_QS_PER_VF); ··· 2808 2821 for (i = 0; i < vfl->num_elements; i++) { 2809 2822 if (vfl->vlan_id[i] > ICE_MAX_VLANID) { 2810 2823 v_ret = VIRTCHNL_STATUS_ERR_PARAM; 2811 - dev_err(dev, 2812 - "invalid VF VLAN id %d\n", vfl->vlan_id[i]); 2824 + dev_err(dev, "invalid VF VLAN id %d\n", 2825 + vfl->vlan_id[i]); 2813 2826 goto error_param; 2814 2827 } 2815 2828 } ··· 2823 2836 2824 2837 if (add_v && !ice_is_vf_trusted(vf) && 2825 2838 vsi->num_vlan >= ICE_MAX_VLAN_PER_VF) { 2826 - dev_info(dev, 2827 - "VF-%d is not trusted, switch the VF to trusted mode, in order to add more VLAN addresses\n", 2839 + dev_info(dev, "VF-%d is not trusted, switch the VF to trusted mode, in order to add more VLAN addresses\n", 2828 2840 vf->vf_id); 2829 2841 /* There is no need to let VF know about being not trusted, 2830 2842 * so we can just return success message here ··· 2846 2860 2847 2861 if (!ice_is_vf_trusted(vf) && 2848 2862 vsi->num_vlan >= ICE_MAX_VLAN_PER_VF) { 2849 - dev_info(dev, 2850 - "VF-%d is not trusted, switch the VF to trusted mode, in order to add more VLAN addresses\n", 2863 + dev_info(dev, "VF-%d is not trusted, switch the VF to trusted mode, in order to add more VLAN addresses\n", 2851 2864 vf->vf_id); 2852 2865 /* There is no need to let VF know about being 2853 2866 * not trusted, so we can just return success ··· 2874 2889 status = ice_cfg_vlan_pruning(vsi, true, false); 2875 2890 if (status) { 2876 2891 v_ret = VIRTCHNL_STATUS_ERR_PARAM; 2877 - dev_err(dev, 2878 - "Enable VLAN pruning on VLAN ID: %d failed error-%d\n", 2892 + dev_err(dev, "Enable VLAN pruning on VLAN ID: %d failed error-%d\n", 2879 2893 vid, status); 2880 2894 goto error_param; 2881 2895 } ··· 2887 2903 promisc_m, vid); 2888 2904 if (status) { 2889 2905 v_ret = VIRTCHNL_STATUS_ERR_PARAM; 2890 - dev_err(dev, 2891 - "Enable Unicast/multicast promiscuous mode on VLAN ID:%d failed error-%d\n", 2906 + dev_err(dev, "Enable Unicast/multicast promiscuous mode on VLAN ID:%d failed error-%d\n", 2892 2907 vid, status); 2893 2908 } 2894 2909 } ··· 3123 3140 case VIRTCHNL_OP_GET_VF_RESOURCES: 3124 3141 err = ice_vc_get_vf_res_msg(vf, msg); 3125 3142 if (ice_vf_init_vlan_stripping(vf)) 3126 - dev_err(dev, 3127 - "Failed to initialize VLAN stripping for VF %d\n", 3143 + dev_err(dev, "Failed to initialize VLAN stripping for VF %d\n", 3128 3144 vf->vf_id); 3129 3145 ice_vc_notify_vf_link_state(vf); 3130 3146 break; ··· 3295 3313 */ 3296 3314 ether_addr_copy(vf->dflt_lan_addr.addr, mac); 3297 3315 vf->pf_set_mac = true; 3298 - netdev_info(netdev, 3299 - "MAC on VF %d set to %pM. VF driver will be reinitialized\n", 3316 + netdev_info(netdev, "MAC on VF %d set to %pM. VF driver will be reinitialized\n", 3300 3317 vf_id, mac); 3301 3318 3302 3319 ice_vc_reset_vf(vf); ··· 3313 3332 int ice_set_vf_trust(struct net_device *netdev, int vf_id, bool trusted) 3314 3333 { 3315 3334 struct ice_pf *pf = ice_netdev_to_pf(netdev); 3316 - struct device *dev; 3317 3335 struct ice_vf *vf; 3318 3336 3319 - dev = ice_pf_to_dev(pf); 3320 3337 if (ice_validate_vf_id(pf, vf_id)) 3321 3338 return -EINVAL; 3322 3339 ··· 3337 3358 3338 3359 vf->trusted = trusted; 3339 3360 ice_vc_reset_vf(vf); 3340 - dev_info(dev, "VF %u is now %strusted\n", 3361 + dev_info(ice_pf_to_dev(pf), "VF %u is now %strusted\n", 3341 3362 vf_id, trusted ? "" : "un"); 3342 3363 3343 3364 return 0;
+2 -2
drivers/net/ethernet/intel/ice/ice_xsk.c
··· 338 338 DMA_BIDIRECTIONAL, 339 339 ICE_RX_DMA_ATTR); 340 340 if (dma_mapping_error(dev, dma)) { 341 - dev_dbg(dev, 342 - "XSK UMEM DMA mapping error on page num %d", i); 341 + dev_dbg(dev, "XSK UMEM DMA mapping error on page num %d\n", 342 + i); 343 343 goto out_unmap; 344 344 } 345 345
+9
drivers/net/ethernet/socionext/sni_ave.c
··· 1810 1810 break; 1811 1811 case PHY_INTERFACE_MODE_MII: 1812 1812 case PHY_INTERFACE_MODE_RGMII: 1813 + case PHY_INTERFACE_MODE_RGMII_ID: 1814 + case PHY_INTERFACE_MODE_RGMII_RXID: 1815 + case PHY_INTERFACE_MODE_RGMII_TXID: 1813 1816 priv->pinmode_val = 0; 1814 1817 break; 1815 1818 default: ··· 1857 1854 priv->pinmode_val = SG_ETPINMODE_RMII(0); 1858 1855 break; 1859 1856 case PHY_INTERFACE_MODE_RGMII: 1857 + case PHY_INTERFACE_MODE_RGMII_ID: 1858 + case PHY_INTERFACE_MODE_RGMII_RXID: 1859 + case PHY_INTERFACE_MODE_RGMII_TXID: 1860 1860 priv->pinmode_val = 0; 1861 1861 break; 1862 1862 default: ··· 1882 1876 priv->pinmode_val = SG_ETPINMODE_RMII(arg); 1883 1877 break; 1884 1878 case PHY_INTERFACE_MODE_RGMII: 1879 + case PHY_INTERFACE_MODE_RGMII_ID: 1880 + case PHY_INTERFACE_MODE_RGMII_RXID: 1881 + case PHY_INTERFACE_MODE_RGMII_TXID: 1885 1882 priv->pinmode_val = 0; 1886 1883 break; 1887 1884 default:
+4 -19
drivers/net/ethernet/sun/sunvnet_common.c
··· 1350 1350 if (vio_version_after_eq(&port->vio, 1, 3)) 1351 1351 localmtu -= VLAN_HLEN; 1352 1352 1353 - if (skb->protocol == htons(ETH_P_IP)) { 1354 - struct flowi4 fl4; 1355 - struct rtable *rt = NULL; 1356 - 1357 - memset(&fl4, 0, sizeof(fl4)); 1358 - fl4.flowi4_oif = dev->ifindex; 1359 - fl4.flowi4_tos = RT_TOS(ip_hdr(skb)->tos); 1360 - fl4.daddr = ip_hdr(skb)->daddr; 1361 - fl4.saddr = ip_hdr(skb)->saddr; 1362 - 1363 - rt = ip_route_output_key(dev_net(dev), &fl4); 1364 - if (!IS_ERR(rt)) { 1365 - skb_dst_set(skb, &rt->dst); 1366 - icmp_send(skb, ICMP_DEST_UNREACH, 1367 - ICMP_FRAG_NEEDED, 1368 - htonl(localmtu)); 1369 - } 1370 - } 1353 + if (skb->protocol == htons(ETH_P_IP)) 1354 + icmp_ndo_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED, 1355 + htonl(localmtu)); 1371 1356 #if IS_ENABLED(CONFIG_IPV6) 1372 1357 else if (skb->protocol == htons(ETH_P_IPV6)) 1373 - icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, localmtu); 1358 + icmpv6_ndo_send(skb, ICMPV6_PKT_TOOBIG, 0, localmtu); 1374 1359 #endif 1375 1360 goto out_dropped; 1376 1361 }
+2 -2
drivers/net/gtp.c
··· 546 546 mtu < ntohs(iph->tot_len)) { 547 547 netdev_dbg(dev, "packet too big, fragmentation needed\n"); 548 548 memset(IPCB(skb), 0, sizeof(*IPCB(skb))); 549 - icmp_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED, 550 - htonl(mtu)); 549 + icmp_ndo_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED, 550 + htonl(mtu)); 551 551 goto err_rt; 552 552 } 553 553
+16 -27
drivers/net/usb/qmi_wwan.c
··· 61 61 62 62 enum qmi_wwan_quirks { 63 63 QMI_WWAN_QUIRK_DTR = 1 << 0, /* needs "set DTR" request */ 64 - QMI_WWAN_QUIRK_QUECTEL_DYNCFG = 1 << 1, /* check num. endpoints */ 65 64 }; 66 65 67 66 struct qmimux_hdr { ··· 915 916 .data = QMI_WWAN_QUIRK_DTR, 916 917 }; 917 918 918 - static const struct driver_info qmi_wwan_info_quirk_quectel_dyncfg = { 919 - .description = "WWAN/QMI device", 920 - .flags = FLAG_WWAN | FLAG_SEND_ZLP, 921 - .bind = qmi_wwan_bind, 922 - .unbind = qmi_wwan_unbind, 923 - .manage_power = qmi_wwan_manage_power, 924 - .rx_fixup = qmi_wwan_rx_fixup, 925 - .data = QMI_WWAN_QUIRK_DTR | QMI_WWAN_QUIRK_QUECTEL_DYNCFG, 926 - }; 927 - 928 919 #define HUAWEI_VENDOR_ID 0x12D1 929 920 930 921 /* map QMI/wwan function by a fixed interface number */ ··· 935 946 #define QMI_GOBI_DEVICE(vend, prod) \ 936 947 QMI_FIXED_INTF(vend, prod, 0) 937 948 938 - /* Quectel does not use fixed interface numbers on at least some of their 939 - * devices. We need to check the number of endpoints to ensure that we bind to 940 - * the correct interface. 949 + /* Many devices have QMI and DIAG functions which are distinguishable 950 + * from other vendor specific functions by class, subclass and 951 + * protocol all being 0xff. The DIAG function has exactly 2 endpoints 952 + * and is silently rejected when probed. 953 + * 954 + * This makes it possible to match dynamically numbered QMI functions 955 + * as seen on e.g. many Quectel modems. 941 956 */ 942 - #define QMI_QUIRK_QUECTEL_DYNCFG(vend, prod) \ 957 + #define QMI_MATCH_FF_FF_FF(vend, prod) \ 943 958 USB_DEVICE_AND_INTERFACE_INFO(vend, prod, USB_CLASS_VENDOR_SPEC, \ 944 959 USB_SUBCLASS_VENDOR_SPEC, 0xff), \ 945 - .driver_info = (unsigned long)&qmi_wwan_info_quirk_quectel_dyncfg 960 + .driver_info = (unsigned long)&qmi_wwan_info_quirk_dtr 946 961 947 962 static const struct usb_device_id products[] = { 948 963 /* 1. CDC ECM like devices match on the control interface */ ··· 1052 1059 USB_DEVICE_AND_INTERFACE_INFO(0x03f0, 0x581d, USB_CLASS_VENDOR_SPEC, 1, 7), 1053 1060 .driver_info = (unsigned long)&qmi_wwan_info, 1054 1061 }, 1055 - {QMI_QUIRK_QUECTEL_DYNCFG(0x2c7c, 0x0125)}, /* Quectel EC25, EC20 R2.0 Mini PCIe */ 1056 - {QMI_QUIRK_QUECTEL_DYNCFG(0x2c7c, 0x0306)}, /* Quectel EP06/EG06/EM06 */ 1057 - {QMI_QUIRK_QUECTEL_DYNCFG(0x2c7c, 0x0512)}, /* Quectel EG12/EM12 */ 1058 - {QMI_QUIRK_QUECTEL_DYNCFG(0x2c7c, 0x0800)}, /* Quectel RM500Q-GL */ 1062 + {QMI_MATCH_FF_FF_FF(0x2c7c, 0x0125)}, /* Quectel EC25, EC20 R2.0 Mini PCIe */ 1063 + {QMI_MATCH_FF_FF_FF(0x2c7c, 0x0306)}, /* Quectel EP06/EG06/EM06 */ 1064 + {QMI_MATCH_FF_FF_FF(0x2c7c, 0x0512)}, /* Quectel EG12/EM12 */ 1065 + {QMI_MATCH_FF_FF_FF(0x2c7c, 0x0800)}, /* Quectel RM500Q-GL */ 1059 1066 1060 1067 /* 3. Combined interface devices matching on interface number */ 1061 1068 {QMI_FIXED_INTF(0x0408, 0xea42, 4)}, /* Yota / Megafon M100-1 */ ··· 1356 1363 {QMI_FIXED_INTF(0x413c, 0x81b6, 8)}, /* Dell Wireless 5811e */ 1357 1364 {QMI_FIXED_INTF(0x413c, 0x81b6, 10)}, /* Dell Wireless 5811e */ 1358 1365 {QMI_FIXED_INTF(0x413c, 0x81d7, 0)}, /* Dell Wireless 5821e */ 1366 + {QMI_FIXED_INTF(0x413c, 0x81d7, 1)}, /* Dell Wireless 5821e preproduction config */ 1359 1367 {QMI_FIXED_INTF(0x413c, 0x81e0, 0)}, /* Dell Wireless 5821e with eSIM support*/ 1360 1368 {QMI_FIXED_INTF(0x03f0, 0x4e1d, 8)}, /* HP lt4111 LTE/EV-DO/HSPA+ Gobi 4G Module */ 1361 1369 {QMI_FIXED_INTF(0x03f0, 0x9d1d, 1)}, /* HP lt4120 Snapdragon X5 LTE */ ··· 1448 1454 { 1449 1455 struct usb_device_id *id = (struct usb_device_id *)prod; 1450 1456 struct usb_interface_descriptor *desc = &intf->cur_altsetting->desc; 1451 - const struct driver_info *info; 1452 1457 1453 1458 /* Workaround to enable dynamic IDs. This disables usbnet 1454 1459 * blacklisting functionality. Which, if required, can be ··· 1483 1490 * different. Ignore the current interface if the number of endpoints 1484 1491 * equals the number for the diag interface (two). 1485 1492 */ 1486 - info = (void *)id->driver_info; 1487 - 1488 - if (info->data & QMI_WWAN_QUIRK_QUECTEL_DYNCFG) { 1489 - if (desc->bNumEndpoints == 2) 1490 - return -ENODEV; 1491 - } 1493 + if (desc->bNumEndpoints == 2) 1494 + return -ENODEV; 1492 1495 1493 1496 return usbnet_probe(intf, id); 1494 1497 }
+2 -2
drivers/net/wireguard/device.c
··· 203 203 err: 204 204 ++dev->stats.tx_errors; 205 205 if (skb->protocol == htons(ETH_P_IP)) 206 - icmp_send(skb, ICMP_DEST_UNREACH, ICMP_HOST_UNREACH, 0); 206 + icmp_ndo_send(skb, ICMP_DEST_UNREACH, ICMP_HOST_UNREACH, 0); 207 207 else if (skb->protocol == htons(ETH_P_IPV6)) 208 - icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_ADDR_UNREACH, 0); 208 + icmpv6_ndo_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_ADDR_UNREACH, 0); 209 209 kfree_skb(skb); 210 210 return ret; 211 211 }
+6 -6
drivers/nvme/host/core.c
··· 66 66 * nvme_reset_wq - hosts nvme reset works 67 67 * nvme_delete_wq - hosts nvme delete works 68 68 * 69 - * nvme_wq will host works such are scan, aen handling, fw activation, 70 - * keep-alive error recovery, periodic reconnects etc. nvme_reset_wq 69 + * nvme_wq will host works such as scan, aen handling, fw activation, 70 + * keep-alive, periodic reconnects etc. nvme_reset_wq 71 71 * runs reset works which also flush works hosted on nvme_wq for 72 72 * serialization purposes. nvme_delete_wq host controller deletion 73 73 * works which flush reset works for serialization. ··· 976 976 startka = true; 977 977 spin_unlock_irqrestore(&ctrl->lock, flags); 978 978 if (startka) 979 - schedule_delayed_work(&ctrl->ka_work, ctrl->kato * HZ); 979 + queue_delayed_work(nvme_wq, &ctrl->ka_work, ctrl->kato * HZ); 980 980 } 981 981 982 982 static int nvme_keep_alive(struct nvme_ctrl *ctrl) ··· 1006 1006 dev_dbg(ctrl->device, 1007 1007 "reschedule traffic based keep-alive timer\n"); 1008 1008 ctrl->comp_seen = false; 1009 - schedule_delayed_work(&ctrl->ka_work, ctrl->kato * HZ); 1009 + queue_delayed_work(nvme_wq, &ctrl->ka_work, ctrl->kato * HZ); 1010 1010 return; 1011 1011 } 1012 1012 ··· 1023 1023 if (unlikely(ctrl->kato == 0)) 1024 1024 return; 1025 1025 1026 - schedule_delayed_work(&ctrl->ka_work, ctrl->kato * HZ); 1026 + queue_delayed_work(nvme_wq, &ctrl->ka_work, ctrl->kato * HZ); 1027 1027 } 1028 1028 1029 1029 void nvme_stop_keep_alive(struct nvme_ctrl *ctrl) ··· 3867 3867 if (!log) 3868 3868 return; 3869 3869 3870 - if (nvme_get_log(ctrl, NVME_NSID_ALL, 0, NVME_LOG_FW_SLOT, log, 3870 + if (nvme_get_log(ctrl, NVME_NSID_ALL, NVME_LOG_FW_SLOT, 0, log, 3871 3871 sizeof(*log), 0)) 3872 3872 dev_warn(ctrl->device, "Get FW SLOT INFO log error\n"); 3873 3873 kfree(log);
+18 -5
drivers/nvme/host/pci.c
··· 1401 1401 nvme_poll_irqdisable(nvmeq, -1); 1402 1402 } 1403 1403 1404 + /* 1405 + * Called only on a device that has been disabled and after all other threads 1406 + * that can check this device's completion queues have synced. This is the 1407 + * last chance for the driver to see a natural completion before 1408 + * nvme_cancel_request() terminates all incomplete requests. 1409 + */ 1410 + static void nvme_reap_pending_cqes(struct nvme_dev *dev) 1411 + { 1412 + u16 start, end; 1413 + int i; 1414 + 1415 + for (i = dev->ctrl.queue_count - 1; i > 0; i--) { 1416 + nvme_process_cq(&dev->queues[i], &start, &end, -1); 1417 + nvme_complete_cqes(&dev->queues[i], start, end); 1418 + } 1419 + } 1420 + 1404 1421 static int nvme_cmb_qdepth(struct nvme_dev *dev, int nr_io_queues, 1405 1422 int entry_size) 1406 1423 { ··· 2252 2235 if (timeout == 0) 2253 2236 return false; 2254 2237 2255 - /* handle any remaining CQEs */ 2256 - if (opcode == nvme_admin_delete_cq && 2257 - !test_bit(NVMEQ_DELETE_ERROR, &nvmeq->flags)) 2258 - nvme_poll_irqdisable(nvmeq, -1); 2259 - 2260 2238 sent--; 2261 2239 if (nr_queues) 2262 2240 goto retry; ··· 2440 2428 nvme_suspend_io_queues(dev); 2441 2429 nvme_suspend_queue(&dev->queues[0]); 2442 2430 nvme_pci_disable(dev); 2431 + nvme_reap_pending_cqes(dev); 2443 2432 2444 2433 blk_mq_tagset_busy_iter(&dev->tagset, nvme_cancel_request, &dev->ctrl); 2445 2434 blk_mq_tagset_busy_iter(&dev->admin_tagset, nvme_cancel_request, &dev->ctrl);
+1 -1
drivers/nvme/host/rdma.c
··· 1088 1088 if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_RESETTING)) 1089 1089 return; 1090 1090 1091 - queue_work(nvme_wq, &ctrl->err_work); 1091 + queue_work(nvme_reset_wq, &ctrl->err_work); 1092 1092 } 1093 1093 1094 1094 static void nvme_rdma_wr_error(struct ib_cq *cq, struct ib_wc *wc,
+7 -2
drivers/nvme/host/tcp.c
··· 422 422 if (!nvme_change_ctrl_state(ctrl, NVME_CTRL_RESETTING)) 423 423 return; 424 424 425 - queue_work(nvme_wq, &to_tcp_ctrl(ctrl)->err_work); 425 + queue_work(nvme_reset_wq, &to_tcp_ctrl(ctrl)->err_work); 426 426 } 427 427 428 428 static int nvme_tcp_process_nvme_cqe(struct nvme_tcp_queue *queue, ··· 1054 1054 } else if (unlikely(result < 0)) { 1055 1055 dev_err(queue->ctrl->ctrl.device, 1056 1056 "failed to send request %d\n", result); 1057 - if (result != -EPIPE) 1057 + 1058 + /* 1059 + * Fail the request unless peer closed the connection, 1060 + * in which case error recovery flow will complete all. 1061 + */ 1062 + if ((result != -EPIPE) && (result != -ECONNRESET)) 1058 1063 nvme_tcp_fail_request(queue->request); 1059 1064 nvme_tcp_done_send_req(queue); 1060 1065 return;
+1 -1
drivers/perf/arm_smmuv3_pmu.c
··· 771 771 smmu_pmu->reloc_base = smmu_pmu->reg_base; 772 772 } 773 773 774 - irq = platform_get_irq(pdev, 0); 774 + irq = platform_get_irq_optional(pdev, 0); 775 775 if (irq > 0) 776 776 smmu_pmu->irq = irq; 777 777
+1 -3
drivers/s390/cio/qdio.h
··· 182 182 }; 183 183 184 184 struct qdio_input_q { 185 - /* input buffer acknowledgement flag */ 186 - int polling; 187 185 /* first ACK'ed buffer */ 188 186 int ack_start; 189 - /* how much sbals are acknowledged with qebsm */ 187 + /* how many SBALs are acknowledged */ 190 188 int ack_count; 191 189 /* last time of noticing incoming data */ 192 190 u64 timestamp;
+2 -3
drivers/s390/cio/qdio_debug.c
··· 124 124 seq_printf(m, "nr_used: %d ftc: %d\n", 125 125 atomic_read(&q->nr_buf_used), q->first_to_check); 126 126 if (q->is_input_q) { 127 - seq_printf(m, "polling: %d ack start: %d ack count: %d\n", 128 - q->u.in.polling, q->u.in.ack_start, 129 - q->u.in.ack_count); 127 + seq_printf(m, "ack start: %d ack count: %d\n", 128 + q->u.in.ack_start, q->u.in.ack_count); 130 129 seq_printf(m, "DSCI: %x IRQs disabled: %u\n", 131 130 *(u8 *)q->irq_ptr->dsci, 132 131 test_bit(QDIO_QUEUE_IRQS_DISABLED,
+11 -18
drivers/s390/cio/qdio_main.c
··· 393 393 394 394 static inline void qdio_stop_polling(struct qdio_q *q) 395 395 { 396 - if (!q->u.in.polling) 396 + if (!q->u.in.ack_count) 397 397 return; 398 398 399 - q->u.in.polling = 0; 400 399 qperf_inc(q, stop_polling); 401 400 402 401 /* show the card that we are not polling anymore */ 403 - if (is_qebsm(q)) { 404 - set_buf_states(q, q->u.in.ack_start, SLSB_P_INPUT_NOT_INIT, 405 - q->u.in.ack_count); 406 - q->u.in.ack_count = 0; 407 - } else 408 - set_buf_state(q, q->u.in.ack_start, SLSB_P_INPUT_NOT_INIT); 402 + set_buf_states(q, q->u.in.ack_start, SLSB_P_INPUT_NOT_INIT, 403 + q->u.in.ack_count); 404 + q->u.in.ack_count = 0; 409 405 } 410 406 411 407 static inline void account_sbals(struct qdio_q *q, unsigned int count) ··· 447 451 448 452 /* for QEBSM the ACK was already set by EQBS */ 449 453 if (is_qebsm(q)) { 450 - if (!q->u.in.polling) { 451 - q->u.in.polling = 1; 454 + if (!q->u.in.ack_count) { 452 455 q->u.in.ack_count = count; 453 456 q->u.in.ack_start = start; 454 457 return; ··· 466 471 * or by the next inbound run. 467 472 */ 468 473 new = add_buf(start, count - 1); 469 - if (q->u.in.polling) { 474 + if (q->u.in.ack_count) { 470 475 /* reset the previous ACK but first set the new one */ 471 476 set_buf_state(q, new, SLSB_P_INPUT_ACK); 472 477 set_buf_state(q, q->u.in.ack_start, SLSB_P_INPUT_NOT_INIT); 473 478 } else { 474 - q->u.in.polling = 1; 479 + q->u.in.ack_count = 1; 475 480 set_buf_state(q, new, SLSB_P_INPUT_ACK); 476 481 } 477 482 ··· 1474 1479 1475 1480 qperf_inc(q, inbound_call); 1476 1481 1477 - if (!q->u.in.polling) 1482 + if (!q->u.in.ack_count) 1478 1483 goto set; 1479 1484 1480 1485 /* protect against stop polling setting an ACK for an emptied slsb */ 1481 1486 if (count == QDIO_MAX_BUFFERS_PER_Q) { 1482 1487 /* overwriting everything, just delete polling status */ 1483 - q->u.in.polling = 0; 1484 1488 q->u.in.ack_count = 0; 1485 1489 goto set; 1486 1490 } else if (buf_in_between(q->u.in.ack_start, bufnr, count)) { ··· 1489 1495 diff = sub_buf(diff, q->u.in.ack_start); 1490 1496 q->u.in.ack_count -= diff; 1491 1497 if (q->u.in.ack_count <= 0) { 1492 - q->u.in.polling = 0; 1493 1498 q->u.in.ack_count = 0; 1494 1499 goto set; 1495 1500 } 1496 1501 q->u.in.ack_start = add_buf(q->u.in.ack_start, diff); 1502 + } else { 1503 + /* the only ACK will be deleted */ 1504 + q->u.in.ack_count = 0; 1497 1505 } 1498 - else 1499 - /* the only ACK will be deleted, so stop polling */ 1500 - q->u.in.polling = 0; 1501 1506 } 1502 1507 1503 1508 set:
+1 -1
drivers/s390/cio/qdio_setup.c
··· 536 536 int qdio_enable_async_operation(struct qdio_output_q *outq) 537 537 { 538 538 outq->aobs = kcalloc(QDIO_MAX_BUFFERS_PER_Q, sizeof(struct qaob *), 539 - GFP_ATOMIC); 539 + GFP_KERNEL); 540 540 if (!outq->aobs) { 541 541 outq->use_cq = 0; 542 542 return -ENOMEM;
+2 -2
drivers/s390/cio/vfio_ccw_trace.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 2 - * Tracepoints for vfio_ccw driver 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + /* Tracepoints for vfio_ccw driver 3 3 * 4 4 * Copyright IBM Corp. 2018 5 5 *
+2 -2
drivers/s390/crypto/ap_bus.h
··· 162 162 unsigned int functions; /* AP device function bitfield. */ 163 163 int queue_depth; /* AP queue depth.*/ 164 164 int id; /* AP card number. */ 165 - atomic_t total_request_count; /* # requests ever for this AP device.*/ 165 + atomic64_t total_request_count; /* # requests ever for this AP device.*/ 166 166 }; 167 167 168 168 #define to_ap_card(x) container_of((x), struct ap_card, ap_dev.device) ··· 179 179 enum ap_state state; /* State of the AP device. */ 180 180 int pendingq_count; /* # requests on pendingq list. */ 181 181 int requestq_count; /* # requests on requestq list. */ 182 - int total_request_count; /* # requests ever for this AP device.*/ 182 + u64 total_request_count; /* # requests ever for this AP device.*/ 183 183 int request_timeout; /* Request timeout in jiffies. */ 184 184 struct timer_list timeout; /* Timer for request timeouts. */ 185 185 struct list_head pendingq; /* List of message sent to AP queue. */
+4 -4
drivers/s390/crypto/ap_card.c
··· 63 63 char *buf) 64 64 { 65 65 struct ap_card *ac = to_ap_card(dev); 66 - unsigned int req_cnt; 66 + u64 req_cnt; 67 67 68 68 req_cnt = 0; 69 69 spin_lock_bh(&ap_list_lock); 70 - req_cnt = atomic_read(&ac->total_request_count); 70 + req_cnt = atomic64_read(&ac->total_request_count); 71 71 spin_unlock_bh(&ap_list_lock); 72 - return snprintf(buf, PAGE_SIZE, "%d\n", req_cnt); 72 + return snprintf(buf, PAGE_SIZE, "%llu\n", req_cnt); 73 73 } 74 74 75 75 static ssize_t request_count_store(struct device *dev, ··· 83 83 for_each_ap_queue(aq, ac) 84 84 aq->total_request_count = 0; 85 85 spin_unlock_bh(&ap_list_lock); 86 - atomic_set(&ac->total_request_count, 0); 86 + atomic64_set(&ac->total_request_count, 0); 87 87 88 88 return count; 89 89 }
+3 -3
drivers/s390/crypto/ap_queue.c
··· 479 479 char *buf) 480 480 { 481 481 struct ap_queue *aq = to_ap_queue(dev); 482 - unsigned int req_cnt; 482 + u64 req_cnt; 483 483 484 484 spin_lock_bh(&aq->lock); 485 485 req_cnt = aq->total_request_count; 486 486 spin_unlock_bh(&aq->lock); 487 - return snprintf(buf, PAGE_SIZE, "%d\n", req_cnt); 487 + return snprintf(buf, PAGE_SIZE, "%llu\n", req_cnt); 488 488 } 489 489 490 490 static ssize_t request_count_store(struct device *dev, ··· 676 676 list_add_tail(&ap_msg->list, &aq->requestq); 677 677 aq->requestq_count++; 678 678 aq->total_request_count++; 679 - atomic_inc(&aq->card->total_request_count); 679 + atomic64_inc(&aq->card->total_request_count); 680 680 /* Send/receive as many request from the queue as possible. */ 681 681 ap_wait(ap_sm_event_loop(aq, AP_EVENT_POLL)); 682 682 spin_unlock_bh(&aq->lock);
+1 -1
drivers/s390/crypto/pkey_api.c
··· 994 994 return -EFAULT; 995 995 rc = cca_sec2protkey(ksp.cardnr, ksp.domain, 996 996 ksp.seckey.seckey, ksp.protkey.protkey, 997 - NULL, &ksp.protkey.type); 997 + &ksp.protkey.len, &ksp.protkey.type); 998 998 DEBUG_DBG("%s cca_sec2protkey()=%d\n", __func__, rc); 999 999 if (rc) 1000 1000 break;
+9 -7
drivers/s390/crypto/zcrypt_api.c
··· 606 606 weight += atomic_read(&zc->load); 607 607 pref_weight += atomic_read(&pref_zc->load); 608 608 if (weight == pref_weight) 609 - return atomic_read(&zc->card->total_request_count) > 610 - atomic_read(&pref_zc->card->total_request_count); 609 + return atomic64_read(&zc->card->total_request_count) > 610 + atomic64_read(&pref_zc->card->total_request_count); 611 611 return weight > pref_weight; 612 612 } 613 613 ··· 1226 1226 spin_unlock(&zcrypt_list_lock); 1227 1227 } 1228 1228 1229 - static void zcrypt_perdev_reqcnt(int reqcnt[], size_t max_adapters) 1229 + static void zcrypt_perdev_reqcnt(u32 reqcnt[], size_t max_adapters) 1230 1230 { 1231 1231 struct zcrypt_card *zc; 1232 1232 struct zcrypt_queue *zq; 1233 1233 int card; 1234 + u64 cnt; 1234 1235 1235 1236 memset(reqcnt, 0, sizeof(int) * max_adapters); 1236 1237 spin_lock(&zcrypt_list_lock); ··· 1243 1242 || card >= max_adapters) 1244 1243 continue; 1245 1244 spin_lock(&zq->queue->lock); 1246 - reqcnt[card] = zq->queue->total_request_count; 1245 + cnt = zq->queue->total_request_count; 1247 1246 spin_unlock(&zq->queue->lock); 1247 + reqcnt[card] = (cnt < UINT_MAX) ? (u32) cnt : UINT_MAX; 1248 1248 } 1249 1249 } 1250 1250 local_bh_enable(); ··· 1423 1421 return 0; 1424 1422 } 1425 1423 case ZCRYPT_PERDEV_REQCNT: { 1426 - int *reqcnt; 1424 + u32 *reqcnt; 1427 1425 1428 - reqcnt = kcalloc(AP_DEVICES, sizeof(int), GFP_KERNEL); 1426 + reqcnt = kcalloc(AP_DEVICES, sizeof(u32), GFP_KERNEL); 1429 1427 if (!reqcnt) 1430 1428 return -ENOMEM; 1431 1429 zcrypt_perdev_reqcnt(reqcnt, AP_DEVICES); ··· 1482 1480 } 1483 1481 case Z90STAT_PERDEV_REQCNT: { 1484 1482 /* the old ioctl supports only 64 adapters */ 1485 - int reqcnt[MAX_ZDEV_CARDIDS]; 1483 + u32 reqcnt[MAX_ZDEV_CARDIDS]; 1486 1484 1487 1485 zcrypt_perdev_reqcnt(reqcnt, MAX_ZDEV_CARDIDS); 1488 1486 if (copy_to_user((int __user *) arg, reqcnt, sizeof(reqcnt)))
+2 -1
drivers/soc/tegra/fuse/fuse-tegra30.c
··· 36 36 defined(CONFIG_ARCH_TEGRA_124_SOC) || \ 37 37 defined(CONFIG_ARCH_TEGRA_132_SOC) || \ 38 38 defined(CONFIG_ARCH_TEGRA_210_SOC) || \ 39 - defined(CONFIG_ARCH_TEGRA_186_SOC) 39 + defined(CONFIG_ARCH_TEGRA_186_SOC) || \ 40 + defined(CONFIG_ARCH_TEGRA_194_SOC) 40 41 static u32 tegra30_fuse_read_early(struct tegra_fuse *fuse, unsigned int offset) 41 42 { 42 43 if (WARN_ON(!fuse->base))
+4
drivers/spmi/spmi-pmic-arb.c
··· 731 731 return 0; 732 732 } 733 733 734 + static struct lock_class_key qpnpint_irq_lock_class, qpnpint_irq_request_class; 734 735 735 736 static void qpnpint_irq_domain_map(struct spmi_pmic_arb *pmic_arb, 736 737 struct irq_domain *domain, unsigned int virq, ··· 747 746 else 748 747 handler = handle_level_irq; 749 748 749 + 750 + irq_set_lockdep_class(virq, &qpnpint_irq_lock_class, 751 + &qpnpint_irq_request_class); 750 752 irq_domain_set_info(domain, virq, hwirq, &pmic_arb_irqchip, pmic_arb, 751 753 handler, NULL, NULL); 752 754 }
+1
fs/btrfs/disk-io.c
··· 3164 3164 /* do not make disk changes in broken FS or nologreplay is given */ 3165 3165 if (btrfs_super_log_root(disk_super) != 0 && 3166 3166 !btrfs_test_opt(fs_info, NOLOGREPLAY)) { 3167 + btrfs_info(fs_info, "start tree-log replay"); 3167 3168 ret = btrfs_replay_log(fs_info, fs_devices); 3168 3169 if (ret) { 3169 3170 err = ret;
+11
fs/btrfs/extent_map.c
··· 237 237 struct extent_map *merge = NULL; 238 238 struct rb_node *rb; 239 239 240 + /* 241 + * We can't modify an extent map that is in the tree and that is being 242 + * used by another task, as it can cause that other task to see it in 243 + * inconsistent state during the merging. We always have 1 reference for 244 + * the tree and 1 for this task (which is unpinning the extent map or 245 + * clearing the logging flag), so anything > 2 means it's being used by 246 + * other tasks too. 247 + */ 248 + if (refcount_read(&em->refs) > 2) 249 + return; 250 + 240 251 if (em->start != 0) { 241 252 rb = rb_prev(&em->rb_node); 242 253 if (rb)
+8
fs/btrfs/inode.c
··· 4085 4085 u64 bytes_deleted = 0; 4086 4086 bool be_nice = false; 4087 4087 bool should_throttle = false; 4088 + const u64 lock_start = ALIGN_DOWN(new_size, fs_info->sectorsize); 4089 + struct extent_state *cached_state = NULL; 4088 4090 4089 4091 BUG_ON(new_size > 0 && min_type != BTRFS_EXTENT_DATA_KEY); 4090 4092 ··· 4102 4100 if (!path) 4103 4101 return -ENOMEM; 4104 4102 path->reada = READA_BACK; 4103 + 4104 + lock_extent_bits(&BTRFS_I(inode)->io_tree, lock_start, (u64)-1, 4105 + &cached_state); 4105 4106 4106 4107 /* 4107 4108 * We want to drop from the next block forward in case this new size is ··· 4371 4366 last_size = new_size; 4372 4367 btrfs_ordered_update_i_size(inode, last_size, NULL); 4373 4368 } 4369 + 4370 + unlock_extent_cached(&BTRFS_I(inode)->io_tree, lock_start, (u64)-1, 4371 + &cached_state); 4374 4372 4375 4373 btrfs_free_path(path); 4376 4374 return ret;
+5
fs/btrfs/ref-verify.c
··· 744 744 */ 745 745 be = add_block_entry(fs_info, bytenr, num_bytes, ref_root); 746 746 if (IS_ERR(be)) { 747 + kfree(ref); 747 748 kfree(ra); 748 749 ret = PTR_ERR(be); 749 750 goto out; ··· 758 757 "re-allocated a block that still has references to it!"); 759 758 dump_block_entry(fs_info, be); 760 759 dump_ref_action(fs_info, ra); 760 + kfree(ref); 761 + kfree(ra); 761 762 goto out_unlock; 762 763 } 763 764 ··· 822 819 "dropping a ref for a existing root that doesn't have a ref on the block"); 823 820 dump_block_entry(fs_info, be); 824 821 dump_ref_action(fs_info, ra); 822 + kfree(ref); 825 823 kfree(ra); 826 824 goto out_unlock; 827 825 } ··· 838 834 "attempting to add another ref for an existing ref on a tree block"); 839 835 dump_block_entry(fs_info, be); 840 836 dump_ref_action(fs_info, ra); 837 + kfree(ref); 841 838 kfree(ra); 842 839 goto out_unlock; 843 840 }
+2
fs/btrfs/super.c
··· 1834 1834 } 1835 1835 1836 1836 if (btrfs_super_log_root(fs_info->super_copy) != 0) { 1837 + btrfs_warn(fs_info, 1838 + "mount required to replay tree-log, cannot remount read-write"); 1837 1839 ret = -EINVAL; 1838 1840 goto restore; 1839 1841 }
+16 -1
fs/btrfs/sysfs.c
··· 901 901 902 902 static void __btrfs_sysfs_remove_fsid(struct btrfs_fs_devices *fs_devs) 903 903 { 904 + if (fs_devs->devinfo_kobj) { 905 + kobject_del(fs_devs->devinfo_kobj); 906 + kobject_put(fs_devs->devinfo_kobj); 907 + fs_devs->devinfo_kobj = NULL; 908 + } 909 + 904 910 if (fs_devs->devices_kobj) { 905 911 kobject_del(fs_devs->devices_kobj); 906 912 kobject_put(fs_devs->devices_kobj); ··· 1295 1289 1296 1290 init_completion(&dev->kobj_unregister); 1297 1291 error = kobject_init_and_add(&dev->devid_kobj, &devid_ktype, 1298 - fs_devices->devices_kobj, "%llu", 1292 + fs_devices->devinfo_kobj, "%llu", 1299 1293 dev->devid); 1300 1294 if (error) { 1301 1295 kobject_put(&dev->devid_kobj); ··· 1372 1366 btrfs_err(fs_devs->fs_info, 1373 1367 "failed to init sysfs device interface"); 1374 1368 kobject_put(&fs_devs->fsid_kobj); 1369 + return -ENOMEM; 1370 + } 1371 + 1372 + fs_devs->devinfo_kobj = kobject_create_and_add("devinfo", 1373 + &fs_devs->fsid_kobj); 1374 + if (!fs_devs->devinfo_kobj) { 1375 + btrfs_err(fs_devs->fs_info, 1376 + "failed to init sysfs devinfo kobject"); 1377 + btrfs_sysfs_remove_fsid(fs_devs); 1375 1378 return -ENOMEM; 1376 1379 } 1377 1380
+1
fs/btrfs/volumes.h
··· 258 258 /* sysfs kobjects */ 259 259 struct kobject fsid_kobj; 260 260 struct kobject *devices_kobj; 261 + struct kobject *devinfo_kobj; 261 262 struct completion kobj_unregister; 262 263 }; 263 264
+11 -6
fs/ceph/file.c
··· 1418 1418 struct ceph_cap_flush *prealloc_cf; 1419 1419 ssize_t count, written = 0; 1420 1420 int err, want, got; 1421 + bool direct_lock = false; 1421 1422 loff_t pos; 1422 1423 loff_t limit = max(i_size_read(inode), fsc->max_file_size); 1423 1424 ··· 1429 1428 if (!prealloc_cf) 1430 1429 return -ENOMEM; 1431 1430 1431 + if ((iocb->ki_flags & (IOCB_DIRECT | IOCB_APPEND)) == IOCB_DIRECT) 1432 + direct_lock = true; 1433 + 1432 1434 retry_snap: 1433 - if (iocb->ki_flags & IOCB_DIRECT) 1435 + if (direct_lock) 1434 1436 ceph_start_io_direct(inode); 1435 1437 else 1436 1438 ceph_start_io_write(inode); ··· 1523 1519 1524 1520 /* we might need to revert back to that point */ 1525 1521 data = *from; 1526 - if (iocb->ki_flags & IOCB_DIRECT) { 1522 + if (iocb->ki_flags & IOCB_DIRECT) 1527 1523 written = ceph_direct_read_write(iocb, &data, snapc, 1528 1524 &prealloc_cf); 1529 - ceph_end_io_direct(inode); 1530 - } else { 1525 + else 1531 1526 written = ceph_sync_write(iocb, &data, pos, snapc); 1527 + if (direct_lock) 1528 + ceph_end_io_direct(inode); 1529 + else 1532 1530 ceph_end_io_write(inode); 1533 - } 1534 1531 if (written > 0) 1535 1532 iov_iter_advance(from, written); 1536 1533 ceph_put_snap_context(snapc); ··· 1582 1577 1583 1578 goto out_unlocked; 1584 1579 out: 1585 - if (iocb->ki_flags & IOCB_DIRECT) 1580 + if (direct_lock) 1586 1581 ceph_end_io_direct(inode); 1587 1582 else 1588 1583 ceph_end_io_write(inode);
+32 -97
fs/ceph/super.c
··· 203 203 }; 204 204 205 205 /* 206 + * Remove adjacent slashes and then the trailing slash, unless it is 207 + * the only remaining character. 208 + * 209 + * E.g. "//dir1////dir2///" --> "/dir1/dir2", "///" --> "/". 210 + */ 211 + static void canonicalize_path(char *path) 212 + { 213 + int i, j = 0; 214 + 215 + for (i = 0; path[i] != '\0'; i++) { 216 + if (path[i] != '/' || j < 1 || path[j - 1] != '/') 217 + path[j++] = path[i]; 218 + } 219 + 220 + if (j > 1 && path[j - 1] == '/') 221 + j--; 222 + path[j] = '\0'; 223 + } 224 + 225 + /* 206 226 * Parse the source parameter. Distinguish the server list from the path. 207 227 * 208 228 * The source will look like: ··· 244 224 245 225 dev_name_end = strchr(dev_name, '/'); 246 226 if (dev_name_end) { 247 - kfree(fsopt->server_path); 248 - 249 227 /* 250 228 * The server_path will include the whole chars from userland 251 229 * including the leading '/'. 252 230 */ 231 + kfree(fsopt->server_path); 253 232 fsopt->server_path = kstrdup(dev_name_end, GFP_KERNEL); 254 233 if (!fsopt->server_path) 255 234 return -ENOMEM; 235 + 236 + canonicalize_path(fsopt->server_path); 256 237 } else { 257 238 dev_name_end = dev_name + strlen(dev_name); 258 239 } ··· 477 456 return strcmp(s1, s2); 478 457 } 479 458 480 - /** 481 - * path_remove_extra_slash - Remove the extra slashes in the server path 482 - * @server_path: the server path and could be NULL 483 - * 484 - * Return NULL if the path is NULL or only consists of "/", or a string 485 - * without any extra slashes including the leading slash(es) and the 486 - * slash(es) at the end of the server path, such as: 487 - * "//dir1////dir2///" --> "dir1/dir2" 488 - */ 489 - static char *path_remove_extra_slash(const char *server_path) 490 - { 491 - const char *path = server_path; 492 - const char *cur, *end; 493 - char *buf, *p; 494 - int len; 495 - 496 - /* if the server path is omitted */ 497 - if (!path) 498 - return NULL; 499 - 500 - /* remove all the leading slashes */ 501 - while (*path == '/') 502 - path++; 503 - 504 - /* if the server path only consists of slashes */ 505 - if (*path == '\0') 506 - return NULL; 507 - 508 - len = strlen(path); 509 - 510 - buf = kmalloc(len + 1, GFP_KERNEL); 511 - if (!buf) 512 - return ERR_PTR(-ENOMEM); 513 - 514 - end = path + len; 515 - p = buf; 516 - do { 517 - cur = strchr(path, '/'); 518 - if (!cur) 519 - cur = end; 520 - 521 - len = cur - path; 522 - 523 - /* including one '/' */ 524 - if (cur != end) 525 - len += 1; 526 - 527 - memcpy(p, path, len); 528 - p += len; 529 - 530 - while (cur <= end && *cur == '/') 531 - cur++; 532 - path = cur; 533 - } while (path < end); 534 - 535 - *p = '\0'; 536 - 537 - /* 538 - * remove the last slash if there has and just to make sure that 539 - * we will get something like "dir1/dir2" 540 - */ 541 - if (*(--p) == '/') 542 - *p = '\0'; 543 - 544 - return buf; 545 - } 546 - 547 459 static int compare_mount_options(struct ceph_mount_options *new_fsopt, 548 460 struct ceph_options *new_opt, 549 461 struct ceph_fs_client *fsc) ··· 484 530 struct ceph_mount_options *fsopt1 = new_fsopt; 485 531 struct ceph_mount_options *fsopt2 = fsc->mount_options; 486 532 int ofs = offsetof(struct ceph_mount_options, snapdir_name); 487 - char *p1, *p2; 488 533 int ret; 489 534 490 535 ret = memcmp(fsopt1, fsopt2, ofs); ··· 493 540 ret = strcmp_null(fsopt1->snapdir_name, fsopt2->snapdir_name); 494 541 if (ret) 495 542 return ret; 543 + 496 544 ret = strcmp_null(fsopt1->mds_namespace, fsopt2->mds_namespace); 497 545 if (ret) 498 546 return ret; 499 547 500 - p1 = path_remove_extra_slash(fsopt1->server_path); 501 - if (IS_ERR(p1)) 502 - return PTR_ERR(p1); 503 - p2 = path_remove_extra_slash(fsopt2->server_path); 504 - if (IS_ERR(p2)) { 505 - kfree(p1); 506 - return PTR_ERR(p2); 507 - } 508 - ret = strcmp_null(p1, p2); 509 - kfree(p1); 510 - kfree(p2); 548 + ret = strcmp_null(fsopt1->server_path, fsopt2->server_path); 511 549 if (ret) 512 550 return ret; 513 551 ··· 901 957 mutex_lock(&fsc->client->mount_mutex); 902 958 903 959 if (!fsc->sb->s_root) { 904 - const char *path, *p; 960 + const char *path = fsc->mount_options->server_path ? 961 + fsc->mount_options->server_path + 1 : ""; 962 + 905 963 err = __ceph_open_session(fsc->client, started); 906 964 if (err < 0) 907 965 goto out; ··· 915 969 goto out; 916 970 } 917 971 918 - p = path_remove_extra_slash(fsc->mount_options->server_path); 919 - if (IS_ERR(p)) { 920 - err = PTR_ERR(p); 921 - goto out; 922 - } 923 - /* if the server path is omitted or just consists of '/' */ 924 - if (!p) 925 - path = ""; 926 - else 927 - path = p; 928 972 dout("mount opening path '%s'\n", path); 929 973 930 974 ceph_fs_debugfs_init(fsc); 931 975 932 976 root = open_root_dentry(fsc, path, started); 933 - kfree(p); 934 977 if (IS_ERR(root)) { 935 978 err = PTR_ERR(root); 936 979 goto out; ··· 1031 1096 1032 1097 if (!fc->source) 1033 1098 return invalfc(fc, "No source"); 1034 - 1035 - #ifdef CONFIG_CEPH_FS_POSIX_ACL 1036 - fc->sb_flags |= SB_POSIXACL; 1037 - #endif 1038 1099 1039 1100 /* create client (which we may/may not use) */ 1040 1101 fsc = create_fs_client(pctx->opts, pctx->copts); ··· 1153 1222 fsopt->max_readdir = CEPH_MAX_READDIR_DEFAULT; 1154 1223 fsopt->max_readdir_bytes = CEPH_MAX_READDIR_BYTES_DEFAULT; 1155 1224 fsopt->congestion_kb = default_congestion_kb(); 1225 + 1226 + #ifdef CONFIG_CEPH_FS_POSIX_ACL 1227 + fc->sb_flags |= SB_POSIXACL; 1228 + #endif 1156 1229 1157 1230 fc->fs_private = pctx; 1158 1231 fc->ops = &ceph_context_ops;
+1 -1
fs/ceph/super.h
··· 91 91 92 92 char *snapdir_name; /* default ".snap" */ 93 93 char *mds_namespace; /* default NULL */ 94 - char *server_path; /* default "/" */ 94 + char *server_path; /* default NULL (means "/") */ 95 95 char *fscache_uniq; /* default NULL */ 96 96 }; 97 97
+2 -2
fs/cifs/cifsacl.c
··· 601 601 ((flags & FILE_EXEC_RIGHTS) == FILE_EXEC_RIGHTS)) 602 602 *pmode |= (S_IXUGO & (*pbits_to_set)); 603 603 604 - cifs_dbg(NOISY, "access flags 0x%x mode now 0x%x\n", flags, *pmode); 604 + cifs_dbg(NOISY, "access flags 0x%x mode now %04o\n", flags, *pmode); 605 605 return; 606 606 } 607 607 ··· 630 630 if (mode & S_IXUGO) 631 631 *pace_flags |= SET_FILE_EXEC_RIGHTS; 632 632 633 - cifs_dbg(NOISY, "mode: 0x%x, access flags now 0x%x\n", 633 + cifs_dbg(NOISY, "mode: %04o, access flags now 0x%x\n", 634 634 mode, *pace_flags); 635 635 return; 636 636 }
+5 -1
fs/cifs/cifsfs.c
··· 414 414 seq_puts(s, "ntlm"); 415 415 break; 416 416 case Kerberos: 417 - seq_printf(s, "krb5,cruid=%u", from_kuid_munged(&init_user_ns,ses->cred_uid)); 417 + seq_puts(s, "krb5"); 418 418 break; 419 419 case RawNTLMSSP: 420 420 seq_puts(s, "ntlmssp"); ··· 427 427 428 428 if (ses->sign) 429 429 seq_puts(s, "i"); 430 + 431 + if (ses->sectype == Kerberos) 432 + seq_printf(s, ",cruid=%u", 433 + from_kuid_munged(&init_user_ns, ses->cred_uid)); 430 434 } 431 435 432 436 static void
+1 -1
fs/cifs/connect.c
··· 4151 4151 cifs_sb->mnt_gid = pvolume_info->linux_gid; 4152 4152 cifs_sb->mnt_file_mode = pvolume_info->file_mode; 4153 4153 cifs_sb->mnt_dir_mode = pvolume_info->dir_mode; 4154 - cifs_dbg(FYI, "file mode: 0x%hx dir mode: 0x%hx\n", 4154 + cifs_dbg(FYI, "file mode: %04ho dir mode: %04ho\n", 4155 4155 cifs_sb->mnt_file_mode, cifs_sb->mnt_dir_mode); 4156 4156 4157 4157 cifs_sb->actimeo = pvolume_info->actimeo;
+1 -1
fs/cifs/inode.c
··· 1648 1648 struct TCP_Server_Info *server; 1649 1649 char *full_path; 1650 1650 1651 - cifs_dbg(FYI, "In cifs_mkdir, mode = 0x%hx inode = 0x%p\n", 1651 + cifs_dbg(FYI, "In cifs_mkdir, mode = %04ho inode = 0x%p\n", 1652 1652 mode, inode); 1653 1653 1654 1654 cifs_sb = CIFS_SB(inode->i_sb);
+35 -1
fs/cifs/smb2ops.c
··· 1116 1116 void *data[1]; 1117 1117 struct smb2_file_full_ea_info *ea = NULL; 1118 1118 struct kvec close_iov[1]; 1119 - int rc; 1119 + struct smb2_query_info_rsp *rsp; 1120 + int rc, used_len = 0; 1120 1121 1121 1122 if (smb3_encryption_required(tcon)) 1122 1123 flags |= CIFS_TRANSFORM_REQ; ··· 1140 1139 cifs_sb); 1141 1140 if (rc == -ENODATA) 1142 1141 goto sea_exit; 1142 + } else { 1143 + /* If we are adding a attribute we should first check 1144 + * if there will be enough space available to store 1145 + * the new EA. If not we should not add it since we 1146 + * would not be able to even read the EAs back. 1147 + */ 1148 + rc = smb2_query_info_compound(xid, tcon, utf16_path, 1149 + FILE_READ_EA, 1150 + FILE_FULL_EA_INFORMATION, 1151 + SMB2_O_INFO_FILE, 1152 + CIFSMaxBufSize - 1153 + MAX_SMB2_CREATE_RESPONSE_SIZE - 1154 + MAX_SMB2_CLOSE_RESPONSE_SIZE, 1155 + &rsp_iov[1], &resp_buftype[1], cifs_sb); 1156 + if (rc == 0) { 1157 + rsp = (struct smb2_query_info_rsp *)rsp_iov[1].iov_base; 1158 + used_len = le32_to_cpu(rsp->OutputBufferLength); 1159 + } 1160 + free_rsp_buf(resp_buftype[1], rsp_iov[1].iov_base); 1161 + resp_buftype[1] = CIFS_NO_BUFFER; 1162 + memset(&rsp_iov[1], 0, sizeof(rsp_iov[1])); 1163 + rc = 0; 1164 + 1165 + /* Use a fudge factor of 256 bytes in case we collide 1166 + * with a different set_EAs command. 1167 + */ 1168 + if(CIFSMaxBufSize - MAX_SMB2_CREATE_RESPONSE_SIZE - 1169 + MAX_SMB2_CLOSE_RESPONSE_SIZE - 256 < 1170 + used_len + ea_name_len + ea_value_len + 1) { 1171 + rc = -ENOSPC; 1172 + goto sea_exit; 1173 + } 1143 1174 } 1144 1175 } 1145 1176 ··· 4828 4795 .wp_retry_size = smb2_wp_retry_size, 4829 4796 .dir_needs_close = smb2_dir_needs_close, 4830 4797 .enum_snapshots = smb3_enum_snapshots, 4798 + .notify = smb3_notify, 4831 4799 .get_dfs_refer = smb2_get_dfs_refer, 4832 4800 .select_sectype = smb2_select_sectype, 4833 4801 #ifdef CONFIG_CIFS_XATTR
+4 -7
fs/dax.c
··· 937 937 * on persistent storage prior to completion of the operation. 938 938 */ 939 939 int dax_writeback_mapping_range(struct address_space *mapping, 940 - struct block_device *bdev, struct writeback_control *wbc) 940 + struct dax_device *dax_dev, struct writeback_control *wbc) 941 941 { 942 942 XA_STATE(xas, &mapping->i_pages, wbc->range_start >> PAGE_SHIFT); 943 943 struct inode *inode = mapping->host; 944 944 pgoff_t end_index = wbc->range_end >> PAGE_SHIFT; 945 - struct dax_device *dax_dev; 946 945 void *entry; 947 946 int ret = 0; 948 947 unsigned int scanned = 0; ··· 951 952 952 953 if (!mapping->nrexceptional || wbc->sync_mode != WB_SYNC_ALL) 953 954 return 0; 954 - 955 - dax_dev = dax_get_by_host(bdev->bd_disk->disk_name); 956 - if (!dax_dev) 957 - return -EIO; 958 955 959 956 trace_dax_writeback_range(inode, xas.xa_index, end_index); 960 957 ··· 972 977 xas_lock_irq(&xas); 973 978 } 974 979 xas_unlock_irq(&xas); 975 - put_dax(dax_dev); 976 980 trace_dax_writeback_range_done(inode, xas.xa_index, end_index); 977 981 return ret; 978 982 } ··· 1200 1206 } else { 1201 1207 lockdep_assert_held(&inode->i_rwsem); 1202 1208 } 1209 + 1210 + if (iocb->ki_flags & IOCB_NOWAIT) 1211 + flags |= IOMAP_NOWAIT; 1203 1212 1204 1213 while (iov_iter_count(iter)) { 1205 1214 ret = iomap_apply(inode, pos, iov_iter_count(iter), flags, ops,
+3 -2
fs/ext2/inode.c
··· 960 960 static int 961 961 ext2_dax_writepages(struct address_space *mapping, struct writeback_control *wbc) 962 962 { 963 - return dax_writeback_mapping_range(mapping, 964 - mapping->host->i_sb->s_bdev, wbc); 963 + struct ext2_sb_info *sbi = EXT2_SB(mapping->host->i_sb); 964 + 965 + return dax_writeback_mapping_range(mapping, sbi->s_daxdev, wbc); 965 966 } 966 967 967 968 const struct address_space_operations ext2_aops = {
+1
fs/ext4/block_validity.c
··· 207 207 return PTR_ERR(inode); 208 208 num = (inode->i_size + sb->s_blocksize - 1) >> sb->s_blocksize_bits; 209 209 while (i < num) { 210 + cond_resched(); 210 211 map.m_lblk = i; 211 212 map.m_len = num - i; 212 213 n = ext4_map_blocks(NULL, inode, &map, 0);
+8 -6
fs/ext4/dir.c
··· 129 129 if (err != ERR_BAD_DX_DIR) { 130 130 return err; 131 131 } 132 - /* 133 - * We don't set the inode dirty flag since it's not 134 - * critical that it get flushed back to the disk. 135 - */ 136 - ext4_clear_inode_flag(file_inode(file), 137 - EXT4_INODE_INDEX); 132 + /* Can we just clear INDEX flag to ignore htree information? */ 133 + if (!ext4_has_metadata_csum(sb)) { 134 + /* 135 + * We don't set the inode dirty flag since it's not 136 + * critical that it gets flushed back to the disk. 137 + */ 138 + ext4_clear_inode_flag(inode, EXT4_INODE_INDEX); 139 + } 138 140 } 139 141 140 142 if (ext4_has_inline_data(inode)) {
+4 -1
fs/ext4/ext4.h
··· 2544 2544 struct ext4_filename *fname); 2545 2545 static inline void ext4_update_dx_flag(struct inode *inode) 2546 2546 { 2547 - if (!ext4_has_feature_dir_index(inode->i_sb)) 2547 + if (!ext4_has_feature_dir_index(inode->i_sb)) { 2548 + /* ext4_iget() should have caught this... */ 2549 + WARN_ON_ONCE(ext4_has_feature_metadata_csum(inode->i_sb)); 2548 2550 ext4_clear_inode_flag(inode, EXT4_INODE_INDEX); 2551 + } 2549 2552 } 2550 2553 static const unsigned char ext4_filetype_table[] = { 2551 2554 DT_UNKNOWN, DT_REG, DT_DIR, DT_CHR, DT_BLK, DT_FIFO, DT_SOCK, DT_LNK
+13 -1
fs/ext4/inode.c
··· 2867 2867 percpu_down_read(&sbi->s_journal_flag_rwsem); 2868 2868 trace_ext4_writepages(inode, wbc); 2869 2869 2870 - ret = dax_writeback_mapping_range(mapping, inode->i_sb->s_bdev, wbc); 2870 + ret = dax_writeback_mapping_range(mapping, sbi->s_daxdev, wbc); 2871 2871 trace_ext4_writepages_result(inode, wbc, ret, 2872 2872 nr_to_write - wbc->nr_to_write); 2873 2873 percpu_up_read(&sbi->s_journal_flag_rwsem); ··· 4641 4641 if ((size = i_size_read(inode)) < 0) { 4642 4642 ext4_error_inode(inode, function, line, 0, 4643 4643 "iget: bad i_size value: %lld", size); 4644 + ret = -EFSCORRUPTED; 4645 + goto bad_inode; 4646 + } 4647 + /* 4648 + * If dir_index is not enabled but there's dir with INDEX flag set, 4649 + * we'd normally treat htree data as empty space. But with metadata 4650 + * checksumming that corrupts checksums so forbid that. 4651 + */ 4652 + if (!ext4_has_feature_dir_index(sb) && ext4_has_metadata_csum(sb) && 4653 + ext4_test_inode_flag(inode, EXT4_INODE_INDEX)) { 4654 + ext4_error_inode(inode, function, line, 0, 4655 + "iget: Dir with htree data on filesystem without dir_index feature."); 4644 4656 ret = -EFSCORRUPTED; 4645 4657 goto bad_inode; 4646 4658 }
+7 -5
fs/ext4/mmp.c
··· 120 120 { 121 121 __ext4_warning(sb, function, line, "%s", msg); 122 122 __ext4_warning(sb, function, line, 123 - "MMP failure info: last update time: %llu, last update " 124 - "node: %s, last update device: %s", 125 - (long long unsigned int) le64_to_cpu(mmp->mmp_time), 126 - mmp->mmp_nodename, mmp->mmp_bdevname); 123 + "MMP failure info: last update time: %llu, last update node: %.*s, last update device: %.*s", 124 + (unsigned long long)le64_to_cpu(mmp->mmp_time), 125 + (int)sizeof(mmp->mmp_nodename), mmp->mmp_nodename, 126 + (int)sizeof(mmp->mmp_bdevname), mmp->mmp_bdevname); 127 127 } 128 128 129 129 /* ··· 154 154 mmp_check_interval = max(EXT4_MMP_CHECK_MULT * mmp_update_interval, 155 155 EXT4_MMP_MIN_CHECK_INTERVAL); 156 156 mmp->mmp_check_interval = cpu_to_le16(mmp_check_interval); 157 + BUILD_BUG_ON(sizeof(mmp->mmp_bdevname) < BDEVNAME_SIZE); 157 158 bdevname(bh->b_bdev, mmp->mmp_bdevname); 158 159 159 160 memcpy(mmp->mmp_nodename, init_utsname()->nodename, ··· 380 379 /* 381 380 * Start a kernel thread to update the MMP block periodically. 382 381 */ 383 - EXT4_SB(sb)->s_mmp_tsk = kthread_run(kmmpd, mmpd_data, "kmmpd-%s", 382 + EXT4_SB(sb)->s_mmp_tsk = kthread_run(kmmpd, mmpd_data, "kmmpd-%.*s", 383 + (int)sizeof(mmp->mmp_bdevname), 384 384 bdevname(bh->b_bdev, 385 385 mmp->mmp_bdevname)); 386 386 if (IS_ERR(EXT4_SB(sb)->s_mmp_tsk)) {
+7
fs/ext4/namei.c
··· 2213 2213 retval = ext4_dx_add_entry(handle, &fname, dir, inode); 2214 2214 if (!retval || (retval != ERR_BAD_DX_DIR)) 2215 2215 goto out; 2216 + /* Can we just ignore htree data? */ 2217 + if (ext4_has_metadata_csum(sb)) { 2218 + EXT4_ERROR_INODE(dir, 2219 + "Directory has corrupted htree index."); 2220 + retval = -EFSCORRUPTED; 2221 + goto out; 2222 + } 2216 2223 ext4_clear_inode_flag(dir, EXT4_INODE_INDEX); 2217 2224 dx_fallback++; 2218 2225 ext4_mark_inode_dirty(handle, dir);
+16 -26
fs/ext4/super.c
··· 3009 3009 return 0; 3010 3010 } 3011 3011 3012 - #ifndef CONFIG_QUOTA 3013 - if (ext4_has_feature_quota(sb) && !readonly) { 3012 + #if !defined(CONFIG_QUOTA) || !defined(CONFIG_QFMT_V2) 3013 + if (!readonly && (ext4_has_feature_quota(sb) || 3014 + ext4_has_feature_project(sb))) { 3014 3015 ext4_msg(sb, KERN_ERR, 3015 - "Filesystem with quota feature cannot be mounted RDWR " 3016 - "without CONFIG_QUOTA"); 3017 - return 0; 3018 - } 3019 - if (ext4_has_feature_project(sb) && !readonly) { 3020 - ext4_msg(sb, KERN_ERR, 3021 - "Filesystem with project quota feature cannot be mounted RDWR " 3022 - "without CONFIG_QUOTA"); 3016 + "The kernel was not built with CONFIG_QUOTA and CONFIG_QFMT_V2"); 3023 3017 return 0; 3024 3018 } 3025 3019 #endif /* CONFIG_QUOTA */ ··· 3808 3814 */ 3809 3815 sbi->s_li_wait_mult = EXT4_DEF_LI_WAIT_MULT; 3810 3816 3817 + blocksize = BLOCK_SIZE << le32_to_cpu(es->s_log_block_size); 3818 + if (blocksize < EXT4_MIN_BLOCK_SIZE || 3819 + blocksize > EXT4_MAX_BLOCK_SIZE) { 3820 + ext4_msg(sb, KERN_ERR, 3821 + "Unsupported filesystem blocksize %d (%d log_block_size)", 3822 + blocksize, le32_to_cpu(es->s_log_block_size)); 3823 + goto failed_mount; 3824 + } 3825 + 3811 3826 if (le32_to_cpu(es->s_rev_level) == EXT4_GOOD_OLD_REV) { 3812 3827 sbi->s_inode_size = EXT4_GOOD_OLD_INODE_SIZE; 3813 3828 sbi->s_first_ino = EXT4_GOOD_OLD_FIRST_INO; ··· 3834 3831 ext4_msg(sb, KERN_ERR, 3835 3832 "unsupported inode size: %d", 3836 3833 sbi->s_inode_size); 3834 + ext4_msg(sb, KERN_ERR, "blocksize: %d", blocksize); 3837 3835 goto failed_mount; 3838 3836 } 3839 3837 /* ··· 4037 4033 if (!ext4_feature_set_ok(sb, (sb_rdonly(sb)))) 4038 4034 goto failed_mount; 4039 4035 4040 - blocksize = BLOCK_SIZE << le32_to_cpu(es->s_log_block_size); 4041 - if (blocksize < EXT4_MIN_BLOCK_SIZE || 4042 - blocksize > EXT4_MAX_BLOCK_SIZE) { 4043 - ext4_msg(sb, KERN_ERR, 4044 - "Unsupported filesystem blocksize %d (%d log_block_size)", 4045 - blocksize, le32_to_cpu(es->s_log_block_size)); 4046 - goto failed_mount; 4047 - } 4048 4036 if (le32_to_cpu(es->s_log_block_size) > 4049 4037 (EXT4_MAX_BLOCK_LOG_SIZE - EXT4_MIN_BLOCK_LOG_SIZE)) { 4050 4038 ext4_msg(sb, KERN_ERR, ··· 5581 5585 return PTR_ERR(dquot); 5582 5586 spin_lock(&dquot->dq_dqb_lock); 5583 5587 5584 - limit = 0; 5585 - if (dquot->dq_dqb.dqb_bsoftlimit && 5586 - (!limit || dquot->dq_dqb.dqb_bsoftlimit < limit)) 5587 - limit = dquot->dq_dqb.dqb_bsoftlimit; 5588 + limit = dquot->dq_dqb.dqb_bsoftlimit; 5588 5589 if (dquot->dq_dqb.dqb_bhardlimit && 5589 5590 (!limit || dquot->dq_dqb.dqb_bhardlimit < limit)) 5590 5591 limit = dquot->dq_dqb.dqb_bhardlimit; ··· 5596 5603 (buf->f_blocks - curblock) : 0; 5597 5604 } 5598 5605 5599 - limit = 0; 5600 - if (dquot->dq_dqb.dqb_isoftlimit && 5601 - (!limit || dquot->dq_dqb.dqb_isoftlimit < limit)) 5602 - limit = dquot->dq_dqb.dqb_isoftlimit; 5606 + limit = dquot->dq_dqb.dqb_isoftlimit; 5603 5607 if (dquot->dq_dqb.dqb_ihardlimit && 5604 5608 (!limit || dquot->dq_dqb.dqb_ihardlimit < limit)) 5605 5609 limit = dquot->dq_dqb.dqb_ihardlimit;
+77 -15
fs/io-wq.c
··· 16 16 #include <linux/slab.h> 17 17 #include <linux/kthread.h> 18 18 #include <linux/rculist_nulls.h> 19 + #include <linux/fs_struct.h> 19 20 20 21 #include "io-wq.h" 21 22 ··· 60 59 const struct cred *cur_creds; 61 60 const struct cred *saved_creds; 62 61 struct files_struct *restore_files; 62 + struct fs_struct *restore_fs; 63 63 }; 64 64 65 65 #if BITS_PER_LONG == 64 ··· 152 150 current->files = worker->restore_files; 153 151 task_unlock(current); 154 152 } 153 + 154 + if (current->fs != worker->restore_fs) 155 + current->fs = worker->restore_fs; 155 156 156 157 /* 157 158 * If we have an active mm, we need to drop the wq lock before unusing ··· 316 311 317 312 worker->flags |= (IO_WORKER_F_UP | IO_WORKER_F_RUNNING); 318 313 worker->restore_files = current->files; 314 + worker->restore_fs = current->fs; 319 315 io_wqe_inc_running(wqe, worker); 320 316 } 321 317 ··· 487 481 current->files = work->files; 488 482 task_unlock(current); 489 483 } 484 + if (work->fs && current->fs != work->fs) 485 + current->fs = work->fs; 490 486 if (work->mm != worker->mm) 491 487 io_wq_switch_mm(worker, work); 492 488 if (worker->cur_creds != work->creds) ··· 699 691 /* create fixed workers */ 700 692 refcount_set(&wq->refs, workers_to_create); 701 693 for_each_node(node) { 694 + if (!node_online(node)) 695 + continue; 702 696 if (!create_io_worker(wq, wq->wqes[node], IO_WQ_ACCT_BOUND)) 703 697 goto err; 704 698 workers_to_create--; 705 699 } 700 + 701 + while (workers_to_create--) 702 + refcount_dec(&wq->refs); 706 703 707 704 complete(&wq->done); 708 705 ··· 715 702 for_each_node(node) { 716 703 struct io_wqe *wqe = wq->wqes[node]; 717 704 bool fork_worker[2] = { false, false }; 705 + 706 + if (!node_online(node)) 707 + continue; 718 708 719 709 spin_lock_irq(&wqe->lock); 720 710 if (io_wqe_need_worker(wqe, IO_WQ_ACCT_BOUND)) ··· 837 821 838 822 list_for_each_entry_rcu(worker, &wqe->all_list, all_list) { 839 823 if (io_worker_get(worker)) { 840 - ret = func(worker, data); 824 + /* no task if node is/was offline */ 825 + if (worker->task) 826 + ret = func(worker, data); 841 827 io_worker_release(worker); 842 828 if (ret) 843 829 break; ··· 947 929 return ret; 948 930 } 949 931 932 + struct work_match { 933 + bool (*fn)(struct io_wq_work *, void *data); 934 + void *data; 935 + }; 936 + 950 937 static bool io_wq_worker_cancel(struct io_worker *worker, void *data) 951 938 { 952 - struct io_wq_work *work = data; 939 + struct work_match *match = data; 953 940 unsigned long flags; 954 941 bool ret = false; 955 942 956 - if (worker->cur_work != work) 957 - return false; 958 - 959 943 spin_lock_irqsave(&worker->lock, flags); 960 - if (worker->cur_work == work && 944 + if (match->fn(worker->cur_work, match->data) && 961 945 !(worker->cur_work->flags & IO_WQ_WORK_NO_CANCEL)) { 962 946 send_sig(SIGINT, worker->task, 1); 963 947 ret = true; ··· 970 950 } 971 951 972 952 static enum io_wq_cancel io_wqe_cancel_work(struct io_wqe *wqe, 973 - struct io_wq_work *cwork) 953 + struct work_match *match) 974 954 { 975 955 struct io_wq_work_node *node, *prev; 976 956 struct io_wq_work *work; 977 957 unsigned long flags; 978 958 bool found = false; 979 - 980 - cwork->flags |= IO_WQ_WORK_CANCEL; 981 959 982 960 /* 983 961 * First check pending list, if we're lucky we can just remove it ··· 986 968 wq_list_for_each(node, prev, &wqe->work_list) { 987 969 work = container_of(node, struct io_wq_work, list); 988 970 989 - if (work == cwork) { 971 + if (match->fn(work, match->data)) { 990 972 wq_node_del(&wqe->work_list, node, prev); 991 973 found = true; 992 974 break; ··· 1007 989 * completion will run normally in this case. 1008 990 */ 1009 991 rcu_read_lock(); 1010 - found = io_wq_for_each_worker(wqe, io_wq_worker_cancel, cwork); 992 + found = io_wq_for_each_worker(wqe, io_wq_worker_cancel, match); 1011 993 rcu_read_unlock(); 1012 994 return found ? IO_WQ_CANCEL_RUNNING : IO_WQ_CANCEL_NOTFOUND; 1013 995 } 1014 996 997 + static bool io_wq_work_match(struct io_wq_work *work, void *data) 998 + { 999 + return work == data; 1000 + } 1001 + 1015 1002 enum io_wq_cancel io_wq_cancel_work(struct io_wq *wq, struct io_wq_work *cwork) 1016 1003 { 1004 + struct work_match match = { 1005 + .fn = io_wq_work_match, 1006 + .data = cwork 1007 + }; 1008 + enum io_wq_cancel ret = IO_WQ_CANCEL_NOTFOUND; 1009 + int node; 1010 + 1011 + cwork->flags |= IO_WQ_WORK_CANCEL; 1012 + 1013 + for_each_node(node) { 1014 + struct io_wqe *wqe = wq->wqes[node]; 1015 + 1016 + ret = io_wqe_cancel_work(wqe, &match); 1017 + if (ret != IO_WQ_CANCEL_NOTFOUND) 1018 + break; 1019 + } 1020 + 1021 + return ret; 1022 + } 1023 + 1024 + static bool io_wq_pid_match(struct io_wq_work *work, void *data) 1025 + { 1026 + pid_t pid = (pid_t) (unsigned long) data; 1027 + 1028 + if (work) 1029 + return work->task_pid == pid; 1030 + return false; 1031 + } 1032 + 1033 + enum io_wq_cancel io_wq_cancel_pid(struct io_wq *wq, pid_t pid) 1034 + { 1035 + struct work_match match = { 1036 + .fn = io_wq_pid_match, 1037 + .data = (void *) (unsigned long) pid 1038 + }; 1017 1039 enum io_wq_cancel ret = IO_WQ_CANCEL_NOTFOUND; 1018 1040 int node; 1019 1041 1020 1042 for_each_node(node) { 1021 1043 struct io_wqe *wqe = wq->wqes[node]; 1022 1044 1023 - ret = io_wqe_cancel_work(wqe, cwork); 1045 + ret = io_wqe_cancel_work(wqe, &match); 1024 1046 if (ret != IO_WQ_CANCEL_NOTFOUND) 1025 1047 break; 1026 1048 } ··· 1094 1036 for_each_node(node) { 1095 1037 struct io_wqe *wqe = wq->wqes[node]; 1096 1038 1039 + if (!node_online(node)) 1040 + continue; 1097 1041 init_completion(&data.done); 1098 1042 INIT_IO_WORK(&data.work, io_wq_flush_func); 1099 1043 data.work.flags |= IO_WQ_WORK_INTERNAL; ··· 1127 1067 1128 1068 for_each_node(node) { 1129 1069 struct io_wqe *wqe; 1070 + int alloc_node = node; 1130 1071 1131 - wqe = kzalloc_node(sizeof(struct io_wqe), GFP_KERNEL, node); 1072 + if (!node_online(alloc_node)) 1073 + alloc_node = NUMA_NO_NODE; 1074 + wqe = kzalloc_node(sizeof(struct io_wqe), GFP_KERNEL, alloc_node); 1132 1075 if (!wqe) 1133 1076 goto err; 1134 1077 wq->wqes[node] = wqe; 1135 - wqe->node = node; 1078 + wqe->node = alloc_node; 1136 1079 wqe->acct[IO_WQ_ACCT_BOUND].max_workers = bounded; 1137 1080 atomic_set(&wqe->acct[IO_WQ_ACCT_BOUND].nr_running, 0); 1138 1081 if (wq->user) { ··· 1143 1080 task_rlimit(current, RLIMIT_NPROC); 1144 1081 } 1145 1082 atomic_set(&wqe->acct[IO_WQ_ACCT_UNBOUND].nr_running, 0); 1146 - wqe->node = node; 1147 1083 wqe->wq = wq; 1148 1084 spin_lock_init(&wqe->lock); 1149 1085 INIT_WQ_LIST(&wqe->work_list);
+5 -1
fs/io-wq.h
··· 74 74 struct files_struct *files; 75 75 struct mm_struct *mm; 76 76 const struct cred *creds; 77 + struct fs_struct *fs; 77 78 unsigned flags; 79 + pid_t task_pid; 78 80 }; 79 81 80 82 #define INIT_IO_WORK(work, _func) \ 81 83 do { \ 82 84 (work)->list.next = NULL; \ 83 85 (work)->func = _func; \ 84 - (work)->flags = 0; \ 85 86 (work)->files = NULL; \ 86 87 (work)->mm = NULL; \ 87 88 (work)->creds = NULL; \ 89 + (work)->fs = NULL; \ 90 + (work)->flags = 0; \ 88 91 } while (0) \ 89 92 90 93 typedef void (get_work_fn)(struct io_wq_work *); ··· 110 107 111 108 void io_wq_cancel_all(struct io_wq *wq); 112 109 enum io_wq_cancel io_wq_cancel_work(struct io_wq *wq, struct io_wq_work *cwork); 110 + enum io_wq_cancel io_wq_cancel_pid(struct io_wq *wq, pid_t pid); 113 111 114 112 typedef bool (work_cancel_fn)(struct io_wq_work *, void *); 115 113
+202 -97
fs/io_uring.c
··· 75 75 #include <linux/fsnotify.h> 76 76 #include <linux/fadvise.h> 77 77 #include <linux/eventpoll.h> 78 + #include <linux/fs_struct.h> 78 79 79 80 #define CREATE_TRACE_POINTS 80 81 #include <trace/events/io_uring.h> ··· 205 204 206 205 struct { 207 206 unsigned int flags; 208 - int compat: 1; 209 - int account_mem: 1; 210 - int cq_overflow_flushed: 1; 211 - int drain_next: 1; 212 - int eventfd_async: 1; 207 + unsigned int compat: 1; 208 + unsigned int account_mem: 1; 209 + unsigned int cq_overflow_flushed: 1; 210 + unsigned int drain_next: 1; 211 + unsigned int eventfd_async: 1; 213 212 214 213 /* 215 214 * Ring buffer of indices into array of io_uring_sqe, which is ··· 442 441 struct iovec *iov; 443 442 struct sockaddr __user *uaddr; 444 443 struct msghdr msg; 444 + struct sockaddr_storage addr; 445 445 }; 446 446 447 447 struct io_async_rw { ··· 452 450 ssize_t size; 453 451 }; 454 452 455 - struct io_async_open { 456 - struct filename *filename; 457 - }; 458 - 459 453 struct io_async_ctx { 460 454 union { 461 455 struct io_async_rw rw; 462 456 struct io_async_msghdr msg; 463 457 struct io_async_connect connect; 464 458 struct io_timeout_data timeout; 465 - struct io_async_open open; 466 459 }; 467 460 }; 468 461 ··· 480 483 REQ_F_MUST_PUNT_BIT, 481 484 REQ_F_TIMEOUT_NOSEQ_BIT, 482 485 REQ_F_COMP_LOCKED_BIT, 486 + REQ_F_NEED_CLEANUP_BIT, 487 + REQ_F_OVERFLOW_BIT, 483 488 }; 484 489 485 490 enum { ··· 520 521 REQ_F_TIMEOUT_NOSEQ = BIT(REQ_F_TIMEOUT_NOSEQ_BIT), 521 522 /* completion under lock */ 522 523 REQ_F_COMP_LOCKED = BIT(REQ_F_COMP_LOCKED_BIT), 524 + /* needs cleanup */ 525 + REQ_F_NEED_CLEANUP = BIT(REQ_F_NEED_CLEANUP_BIT), 526 + /* in overflow list */ 527 + REQ_F_OVERFLOW = BIT(REQ_F_OVERFLOW_BIT), 523 528 }; 524 529 525 530 /* ··· 556 553 * llist_node is only used for poll deferred completions 557 554 */ 558 555 struct llist_node llist_node; 559 - bool has_user; 560 556 bool in_async; 561 557 bool needs_fixed_file; 562 558 u8 opcode; ··· 616 614 unsigned not_supported : 1; 617 615 /* needs file table */ 618 616 unsigned file_table : 1; 617 + /* needs ->fs */ 618 + unsigned needs_fs : 1; 619 619 }; 620 620 621 621 static const struct io_op_def io_op_defs[] = { ··· 660 656 .needs_mm = 1, 661 657 .needs_file = 1, 662 658 .unbound_nonreg_file = 1, 659 + .needs_fs = 1, 663 660 }, 664 661 [IORING_OP_RECVMSG] = { 665 662 .async_ctx = 1, 666 663 .needs_mm = 1, 667 664 .needs_file = 1, 668 665 .unbound_nonreg_file = 1, 666 + .needs_fs = 1, 669 667 }, 670 668 [IORING_OP_TIMEOUT] = { 671 669 .async_ctx = 1, ··· 698 692 .needs_file = 1, 699 693 .fd_non_neg = 1, 700 694 .file_table = 1, 695 + .needs_fs = 1, 701 696 }, 702 697 [IORING_OP_CLOSE] = { 703 698 .needs_file = 1, ··· 712 705 .needs_mm = 1, 713 706 .needs_file = 1, 714 707 .fd_non_neg = 1, 708 + .needs_fs = 1, 715 709 }, 716 710 [IORING_OP_READ] = { 717 711 .needs_mm = 1, ··· 744 736 .needs_file = 1, 745 737 .fd_non_neg = 1, 746 738 .file_table = 1, 739 + .needs_fs = 1, 747 740 }, 748 741 [IORING_OP_EPOLL_CTL] = { 749 742 .unbound_nonreg_file = 1, ··· 763 754 unsigned nr_args); 764 755 static int io_grab_files(struct io_kiocb *req); 765 756 static void io_ring_file_ref_flush(struct fixed_file_data *data); 757 + static void io_cleanup_req(struct io_kiocb *req); 766 758 767 759 static struct kmem_cache *req_cachep; 768 760 ··· 919 909 } 920 910 if (!req->work.creds) 921 911 req->work.creds = get_current_cred(); 912 + if (!req->work.fs && def->needs_fs) { 913 + spin_lock(&current->fs->lock); 914 + if (!current->fs->in_exec) { 915 + req->work.fs = current->fs; 916 + req->work.fs->users++; 917 + } else { 918 + req->work.flags |= IO_WQ_WORK_CANCEL; 919 + } 920 + spin_unlock(&current->fs->lock); 921 + } 922 + if (!req->work.task_pid) 923 + req->work.task_pid = task_pid_vnr(current); 922 924 } 923 925 924 926 static inline void io_req_work_drop_env(struct io_kiocb *req) ··· 942 920 if (req->work.creds) { 943 921 put_cred(req->work.creds); 944 922 req->work.creds = NULL; 923 + } 924 + if (req->work.fs) { 925 + struct fs_struct *fs = req->work.fs; 926 + 927 + spin_lock(&req->work.fs->lock); 928 + if (--fs->users) 929 + fs = NULL; 930 + spin_unlock(&req->work.fs->lock); 931 + if (fs) 932 + free_fs_struct(fs); 945 933 } 946 934 } 947 935 ··· 1106 1074 req = list_first_entry(&ctx->cq_overflow_list, struct io_kiocb, 1107 1075 list); 1108 1076 list_move(&req->list, &list); 1077 + req->flags &= ~REQ_F_OVERFLOW; 1109 1078 if (cqe) { 1110 1079 WRITE_ONCE(cqe->user_data, req->user_data); 1111 1080 WRITE_ONCE(cqe->res, req->result); ··· 1159 1126 set_bit(0, &ctx->sq_check_overflow); 1160 1127 set_bit(0, &ctx->cq_check_overflow); 1161 1128 } 1129 + req->flags |= REQ_F_OVERFLOW; 1162 1130 refcount_inc(&req->refs); 1163 1131 req->result = res; 1164 1132 list_add_tail(&req->list, &ctx->cq_overflow_list); ··· 1274 1240 static void __io_free_req(struct io_kiocb *req) 1275 1241 { 1276 1242 __io_req_aux_free(req); 1243 + 1244 + if (req->flags & REQ_F_NEED_CLEANUP) 1245 + io_cleanup_req(req); 1277 1246 1278 1247 if (req->flags & REQ_F_INFLIGHT) { 1279 1248 struct io_ring_ctx *ctx = req->ctx; ··· 2093 2056 return iorw->size; 2094 2057 } 2095 2058 2096 - if (!req->has_user) 2097 - return -EFAULT; 2098 - 2099 2059 #ifdef CONFIG_COMPAT 2100 2060 if (req->ctx->compat) 2101 2061 return compat_import_iovec(rw, buf, sqe_len, UIO_FASTIOV, ··· 2171 2137 req->io->rw.iov = req->io->rw.fast_iov; 2172 2138 memcpy(req->io->rw.iov, fast_iov, 2173 2139 sizeof(struct iovec) * iter->nr_segs); 2140 + } else { 2141 + req->flags |= REQ_F_NEED_CLEANUP; 2174 2142 } 2175 2143 } 2176 2144 ··· 2182 2146 return 0; 2183 2147 req->io = kmalloc(sizeof(*req->io), GFP_KERNEL); 2184 2148 return req->io == NULL; 2185 - } 2186 - 2187 - static void io_rw_async(struct io_wq_work **workptr) 2188 - { 2189 - struct io_kiocb *req = container_of(*workptr, struct io_kiocb, work); 2190 - struct iovec *iov = NULL; 2191 - 2192 - if (req->io->rw.iov != req->io->rw.fast_iov) 2193 - iov = req->io->rw.iov; 2194 - io_wq_submit_work(workptr); 2195 - kfree(iov); 2196 2149 } 2197 2150 2198 2151 static int io_setup_async_rw(struct io_kiocb *req, ssize_t io_size, ··· 2196 2171 2197 2172 io_req_map_rw(req, io_size, iovec, fast_iov, iter); 2198 2173 } 2199 - req->work.func = io_rw_async; 2200 2174 return 0; 2201 2175 } 2202 2176 ··· 2213 2189 if (unlikely(!(req->file->f_mode & FMODE_READ))) 2214 2190 return -EBADF; 2215 2191 2216 - if (!req->io) 2192 + /* either don't need iovec imported or already have it */ 2193 + if (!req->io || req->flags & REQ_F_NEED_CLEANUP) 2217 2194 return 0; 2218 2195 2219 2196 io = req->io; ··· 2283 2258 } 2284 2259 } 2285 2260 out_free: 2286 - if (!io_wq_current_is_worker()) 2287 - kfree(iovec); 2261 + kfree(iovec); 2262 + req->flags &= ~REQ_F_NEED_CLEANUP; 2288 2263 return ret; 2289 2264 } 2290 2265 ··· 2302 2277 if (unlikely(!(req->file->f_mode & FMODE_WRITE))) 2303 2278 return -EBADF; 2304 2279 2305 - if (!req->io) 2280 + /* either don't need iovec imported or already have it */ 2281 + if (!req->io || req->flags & REQ_F_NEED_CLEANUP) 2306 2282 return 0; 2307 2283 2308 2284 io = req->io; ··· 2378 2352 ret2 = call_write_iter(req->file, kiocb, &iter); 2379 2353 else 2380 2354 ret2 = loop_rw_iter(WRITE, req->file, kiocb, &iter); 2355 + /* 2356 + * Raw bdev writes will -EOPNOTSUPP for IOCB_NOWAIT. Just 2357 + * retry them without IOCB_NOWAIT. 2358 + */ 2359 + if (ret2 == -EOPNOTSUPP && (kiocb->ki_flags & IOCB_NOWAIT)) 2360 + ret2 = -EAGAIN; 2381 2361 if (!force_nonblock || ret2 != -EAGAIN) { 2382 2362 kiocb_done(kiocb, ret2, nxt, req->in_async); 2383 2363 } else { ··· 2396 2364 } 2397 2365 } 2398 2366 out_free: 2399 - if (!io_wq_current_is_worker()) 2400 - kfree(iovec); 2367 + req->flags &= ~REQ_F_NEED_CLEANUP; 2368 + kfree(iovec); 2401 2369 return ret; 2402 2370 } 2403 2371 ··· 2566 2534 2567 2535 if (sqe->ioprio || sqe->buf_index) 2568 2536 return -EINVAL; 2537 + if (sqe->flags & IOSQE_FIXED_FILE) 2538 + return -EBADF; 2539 + if (req->flags & REQ_F_NEED_CLEANUP) 2540 + return 0; 2569 2541 2570 2542 req->open.dfd = READ_ONCE(sqe->fd); 2571 2543 req->open.how.mode = READ_ONCE(sqe->len); ··· 2583 2547 return ret; 2584 2548 } 2585 2549 2550 + req->flags |= REQ_F_NEED_CLEANUP; 2586 2551 return 0; 2587 2552 } 2588 2553 ··· 2596 2559 2597 2560 if (sqe->ioprio || sqe->buf_index) 2598 2561 return -EINVAL; 2562 + if (sqe->flags & IOSQE_FIXED_FILE) 2563 + return -EBADF; 2564 + if (req->flags & REQ_F_NEED_CLEANUP) 2565 + return 0; 2599 2566 2600 2567 req->open.dfd = READ_ONCE(sqe->fd); 2601 2568 fname = u64_to_user_ptr(READ_ONCE(sqe->addr)); ··· 2624 2583 return ret; 2625 2584 } 2626 2585 2586 + req->flags |= REQ_F_NEED_CLEANUP; 2627 2587 return 0; 2628 2588 } 2629 2589 ··· 2656 2614 } 2657 2615 err: 2658 2616 putname(req->open.filename); 2617 + req->flags &= ~REQ_F_NEED_CLEANUP; 2659 2618 if (ret < 0) 2660 2619 req_set_fail_links(req); 2661 2620 io_cqring_add_event(req, ret); ··· 2797 2754 2798 2755 if (sqe->ioprio || sqe->buf_index) 2799 2756 return -EINVAL; 2757 + if (sqe->flags & IOSQE_FIXED_FILE) 2758 + return -EBADF; 2759 + if (req->flags & REQ_F_NEED_CLEANUP) 2760 + return 0; 2800 2761 2801 2762 req->open.dfd = READ_ONCE(sqe->fd); 2802 2763 req->open.mask = READ_ONCE(sqe->len); ··· 2818 2771 return ret; 2819 2772 } 2820 2773 2774 + req->flags |= REQ_F_NEED_CLEANUP; 2821 2775 return 0; 2822 2776 } 2823 2777 ··· 2856 2808 ret = cp_statx(&stat, ctx->buffer); 2857 2809 err: 2858 2810 putname(ctx->filename); 2811 + req->flags &= ~REQ_F_NEED_CLEANUP; 2859 2812 if (ret < 0) 2860 2813 req_set_fail_links(req); 2861 2814 io_cqring_add_event(req, ret); ··· 2876 2827 sqe->rw_flags || sqe->buf_index) 2877 2828 return -EINVAL; 2878 2829 if (sqe->flags & IOSQE_FIXED_FILE) 2879 - return -EINVAL; 2830 + return -EBADF; 2880 2831 2881 2832 req->close.fd = READ_ONCE(sqe->fd); 2882 2833 if (req->file->f_op == &io_uring_fops || ··· 2886 2837 return 0; 2887 2838 } 2888 2839 2840 + /* only called when __close_fd_get_file() is done */ 2841 + static void __io_close_finish(struct io_kiocb *req, struct io_kiocb **nxt) 2842 + { 2843 + int ret; 2844 + 2845 + ret = filp_close(req->close.put_file, req->work.files); 2846 + if (ret < 0) 2847 + req_set_fail_links(req); 2848 + io_cqring_add_event(req, ret); 2849 + fput(req->close.put_file); 2850 + io_put_req_find_next(req, nxt); 2851 + } 2852 + 2889 2853 static void io_close_finish(struct io_wq_work **workptr) 2890 2854 { 2891 2855 struct io_kiocb *req = container_of(*workptr, struct io_kiocb, work); 2892 2856 struct io_kiocb *nxt = NULL; 2893 2857 2894 - /* Invoked with files, we need to do the close */ 2895 - if (req->work.files) { 2896 - int ret; 2897 - 2898 - ret = filp_close(req->close.put_file, req->work.files); 2899 - if (ret < 0) 2900 - req_set_fail_links(req); 2901 - io_cqring_add_event(req, ret); 2902 - } 2903 - 2904 - fput(req->close.put_file); 2905 - 2906 - io_put_req_find_next(req, &nxt); 2858 + __io_close_finish(req, &nxt); 2907 2859 if (nxt) 2908 2860 io_wq_assign_next(workptr, nxt); 2909 2861 } ··· 2927 2877 * No ->flush(), safely close from here and just punt the 2928 2878 * fput() to async context. 2929 2879 */ 2930 - ret = filp_close(req->close.put_file, current->files); 2931 - 2932 - if (ret < 0) 2933 - req_set_fail_links(req); 2934 - io_cqring_add_event(req, ret); 2935 - 2936 - if (io_wq_current_is_worker()) { 2937 - struct io_wq_work *old_work, *work; 2938 - 2939 - old_work = work = &req->work; 2940 - io_close_finish(&work); 2941 - if (work && work != old_work) 2942 - *nxt = container_of(work, struct io_kiocb, work); 2943 - return 0; 2944 - } 2945 - 2880 + __io_close_finish(req, nxt); 2881 + return 0; 2946 2882 eagain: 2947 2883 req->work.func = io_close_finish; 2948 2884 /* ··· 2996 2960 return 0; 2997 2961 } 2998 2962 2999 - #if defined(CONFIG_NET) 3000 - static void io_sendrecv_async(struct io_wq_work **workptr) 3001 - { 3002 - struct io_kiocb *req = container_of(*workptr, struct io_kiocb, work); 3003 - struct iovec *iov = NULL; 3004 - 3005 - if (req->io->rw.iov != req->io->rw.fast_iov) 3006 - iov = req->io->msg.iov; 3007 - io_wq_submit_work(workptr); 3008 - kfree(iov); 3009 - } 3010 - #endif 3011 - 3012 2963 static int io_sendmsg_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) 3013 2964 { 3014 2965 #if defined(CONFIG_NET) 3015 2966 struct io_sr_msg *sr = &req->sr_msg; 3016 2967 struct io_async_ctx *io = req->io; 2968 + int ret; 3017 2969 3018 2970 sr->msg_flags = READ_ONCE(sqe->msg_flags); 3019 2971 sr->msg = u64_to_user_ptr(READ_ONCE(sqe->addr)); ··· 3009 2985 3010 2986 if (!io || req->opcode == IORING_OP_SEND) 3011 2987 return 0; 2988 + /* iovec is already imported */ 2989 + if (req->flags & REQ_F_NEED_CLEANUP) 2990 + return 0; 3012 2991 3013 2992 io->msg.iov = io->msg.fast_iov; 3014 - return sendmsg_copy_msghdr(&io->msg.msg, sr->msg, sr->msg_flags, 2993 + ret = sendmsg_copy_msghdr(&io->msg.msg, sr->msg, sr->msg_flags, 3015 2994 &io->msg.iov); 2995 + if (!ret) 2996 + req->flags |= REQ_F_NEED_CLEANUP; 2997 + return ret; 3016 2998 #else 3017 2999 return -EOPNOTSUPP; 3018 3000 #endif ··· 3038 3008 sock = sock_from_file(req->file, &ret); 3039 3009 if (sock) { 3040 3010 struct io_async_ctx io; 3041 - struct sockaddr_storage addr; 3042 3011 unsigned flags; 3043 3012 3044 3013 if (req->io) { 3045 3014 kmsg = &req->io->msg; 3046 - kmsg->msg.msg_name = &addr; 3015 + kmsg->msg.msg_name = &req->io->msg.addr; 3047 3016 /* if iov is set, it's allocated already */ 3048 3017 if (!kmsg->iov) 3049 3018 kmsg->iov = kmsg->fast_iov; ··· 3051 3022 struct io_sr_msg *sr = &req->sr_msg; 3052 3023 3053 3024 kmsg = &io.msg; 3054 - kmsg->msg.msg_name = &addr; 3025 + kmsg->msg.msg_name = &io.msg.addr; 3055 3026 3056 3027 io.msg.iov = io.msg.fast_iov; 3057 3028 ret = sendmsg_copy_msghdr(&io.msg.msg, sr->msg, ··· 3070 3041 if (force_nonblock && ret == -EAGAIN) { 3071 3042 if (req->io) 3072 3043 return -EAGAIN; 3073 - if (io_alloc_async_ctx(req)) 3044 + if (io_alloc_async_ctx(req)) { 3045 + if (kmsg && kmsg->iov != kmsg->fast_iov) 3046 + kfree(kmsg->iov); 3074 3047 return -ENOMEM; 3048 + } 3049 + req->flags |= REQ_F_NEED_CLEANUP; 3075 3050 memcpy(&req->io->msg, &io.msg, sizeof(io.msg)); 3076 - req->work.func = io_sendrecv_async; 3077 3051 return -EAGAIN; 3078 3052 } 3079 3053 if (ret == -ERESTARTSYS) 3080 3054 ret = -EINTR; 3081 3055 } 3082 3056 3083 - if (!io_wq_current_is_worker() && kmsg && kmsg->iov != kmsg->fast_iov) 3057 + if (kmsg && kmsg->iov != kmsg->fast_iov) 3084 3058 kfree(kmsg->iov); 3059 + req->flags &= ~REQ_F_NEED_CLEANUP; 3085 3060 io_cqring_add_event(req, ret); 3086 3061 if (ret < 0) 3087 3062 req_set_fail_links(req); ··· 3153 3120 #if defined(CONFIG_NET) 3154 3121 struct io_sr_msg *sr = &req->sr_msg; 3155 3122 struct io_async_ctx *io = req->io; 3123 + int ret; 3156 3124 3157 3125 sr->msg_flags = READ_ONCE(sqe->msg_flags); 3158 3126 sr->msg = u64_to_user_ptr(READ_ONCE(sqe->addr)); ··· 3161 3127 3162 3128 if (!io || req->opcode == IORING_OP_RECV) 3163 3129 return 0; 3130 + /* iovec is already imported */ 3131 + if (req->flags & REQ_F_NEED_CLEANUP) 3132 + return 0; 3164 3133 3165 3134 io->msg.iov = io->msg.fast_iov; 3166 - return recvmsg_copy_msghdr(&io->msg.msg, sr->msg, sr->msg_flags, 3135 + ret = recvmsg_copy_msghdr(&io->msg.msg, sr->msg, sr->msg_flags, 3167 3136 &io->msg.uaddr, &io->msg.iov); 3137 + if (!ret) 3138 + req->flags |= REQ_F_NEED_CLEANUP; 3139 + return ret; 3168 3140 #else 3169 3141 return -EOPNOTSUPP; 3170 3142 #endif ··· 3190 3150 sock = sock_from_file(req->file, &ret); 3191 3151 if (sock) { 3192 3152 struct io_async_ctx io; 3193 - struct sockaddr_storage addr; 3194 3153 unsigned flags; 3195 3154 3196 3155 if (req->io) { 3197 3156 kmsg = &req->io->msg; 3198 - kmsg->msg.msg_name = &addr; 3157 + kmsg->msg.msg_name = &req->io->msg.addr; 3199 3158 /* if iov is set, it's allocated already */ 3200 3159 if (!kmsg->iov) 3201 3160 kmsg->iov = kmsg->fast_iov; ··· 3203 3164 struct io_sr_msg *sr = &req->sr_msg; 3204 3165 3205 3166 kmsg = &io.msg; 3206 - kmsg->msg.msg_name = &addr; 3167 + kmsg->msg.msg_name = &io.msg.addr; 3207 3168 3208 3169 io.msg.iov = io.msg.fast_iov; 3209 3170 ret = recvmsg_copy_msghdr(&io.msg.msg, sr->msg, ··· 3224 3185 if (force_nonblock && ret == -EAGAIN) { 3225 3186 if (req->io) 3226 3187 return -EAGAIN; 3227 - if (io_alloc_async_ctx(req)) 3188 + if (io_alloc_async_ctx(req)) { 3189 + if (kmsg && kmsg->iov != kmsg->fast_iov) 3190 + kfree(kmsg->iov); 3228 3191 return -ENOMEM; 3192 + } 3229 3193 memcpy(&req->io->msg, &io.msg, sizeof(io.msg)); 3230 - req->work.func = io_sendrecv_async; 3194 + req->flags |= REQ_F_NEED_CLEANUP; 3231 3195 return -EAGAIN; 3232 3196 } 3233 3197 if (ret == -ERESTARTSYS) 3234 3198 ret = -EINTR; 3235 3199 } 3236 3200 3237 - if (!io_wq_current_is_worker() && kmsg && kmsg->iov != kmsg->fast_iov) 3201 + if (kmsg && kmsg->iov != kmsg->fast_iov) 3238 3202 kfree(kmsg->iov); 3203 + req->flags &= ~REQ_F_NEED_CLEANUP; 3239 3204 io_cqring_add_event(req, ret); 3240 3205 if (ret < 0) 3241 3206 req_set_fail_links(req); ··· 4250 4207 return -EIOCBQUEUED; 4251 4208 } 4252 4209 4210 + static void io_cleanup_req(struct io_kiocb *req) 4211 + { 4212 + struct io_async_ctx *io = req->io; 4213 + 4214 + switch (req->opcode) { 4215 + case IORING_OP_READV: 4216 + case IORING_OP_READ_FIXED: 4217 + case IORING_OP_READ: 4218 + case IORING_OP_WRITEV: 4219 + case IORING_OP_WRITE_FIXED: 4220 + case IORING_OP_WRITE: 4221 + if (io->rw.iov != io->rw.fast_iov) 4222 + kfree(io->rw.iov); 4223 + break; 4224 + case IORING_OP_SENDMSG: 4225 + case IORING_OP_RECVMSG: 4226 + if (io->msg.iov != io->msg.fast_iov) 4227 + kfree(io->msg.iov); 4228 + break; 4229 + case IORING_OP_OPENAT: 4230 + case IORING_OP_OPENAT2: 4231 + case IORING_OP_STATX: 4232 + putname(req->open.filename); 4233 + break; 4234 + } 4235 + 4236 + req->flags &= ~REQ_F_NEED_CLEANUP; 4237 + } 4238 + 4253 4239 static int io_issue_sqe(struct io_kiocb *req, const struct io_uring_sqe *sqe, 4254 4240 struct io_kiocb **nxt, bool force_nonblock) 4255 4241 { ··· 4518 4446 } 4519 4447 4520 4448 if (!ret) { 4521 - req->has_user = (work->flags & IO_WQ_WORK_HAS_MM) != 0; 4522 4449 req->in_async = true; 4523 4450 do { 4524 4451 ret = io_issue_sqe(req, NULL, &nxt, false); ··· 4550 4479 { 4551 4480 if (!io_op_defs[req->opcode].needs_file) 4552 4481 return 0; 4553 - if (fd == -1 && io_op_defs[req->opcode].fd_non_neg) 4482 + if ((fd == -1 || fd == AT_FDCWD) && io_op_defs[req->opcode].fd_non_neg) 4554 4483 return 0; 4555 4484 return 1; 4556 4485 } ··· 5021 4950 for (i = 0; i < nr; i++) { 5022 4951 const struct io_uring_sqe *sqe; 5023 4952 struct io_kiocb *req; 4953 + int err; 5024 4954 5025 4955 req = io_get_req(ctx, statep); 5026 4956 if (unlikely(!req)) { ··· 5038 4966 submitted++; 5039 4967 5040 4968 if (unlikely(req->opcode >= IORING_OP_LAST)) { 5041 - io_cqring_add_event(req, -EINVAL); 4969 + err = -EINVAL; 4970 + fail_req: 4971 + io_cqring_add_event(req, err); 5042 4972 io_double_put_req(req); 5043 4973 break; 5044 4974 } 5045 4975 5046 4976 if (io_op_defs[req->opcode].needs_mm && !*mm) { 5047 4977 mm_fault = mm_fault || !mmget_not_zero(ctx->sqo_mm); 5048 - if (!mm_fault) { 5049 - use_mm(ctx->sqo_mm); 5050 - *mm = ctx->sqo_mm; 4978 + if (unlikely(mm_fault)) { 4979 + err = -EFAULT; 4980 + goto fail_req; 5051 4981 } 4982 + use_mm(ctx->sqo_mm); 4983 + *mm = ctx->sqo_mm; 5052 4984 } 5053 4985 5054 - req->has_user = *mm != NULL; 5055 4986 req->in_async = async; 5056 4987 req->needs_fixed_file = async; 5057 4988 trace_io_uring_submit_sqe(ctx, req->opcode, req->user_data, ··· 6376 6301 if (READ_ONCE(ctx->rings->sq.tail) - ctx->cached_sq_head != 6377 6302 ctx->rings->sq_ring_entries) 6378 6303 mask |= EPOLLOUT | EPOLLWRNORM; 6379 - if (READ_ONCE(ctx->rings->cq.head) != ctx->cached_cq_tail) 6304 + if (io_cqring_events(ctx, false)) 6380 6305 mask |= EPOLLIN | EPOLLRDNORM; 6381 6306 6382 6307 return mask; ··· 6468 6393 if (!cancel_req) 6469 6394 break; 6470 6395 6396 + if (cancel_req->flags & REQ_F_OVERFLOW) { 6397 + spin_lock_irq(&ctx->completion_lock); 6398 + list_del(&cancel_req->list); 6399 + cancel_req->flags &= ~REQ_F_OVERFLOW; 6400 + if (list_empty(&ctx->cq_overflow_list)) { 6401 + clear_bit(0, &ctx->sq_check_overflow); 6402 + clear_bit(0, &ctx->cq_check_overflow); 6403 + } 6404 + spin_unlock_irq(&ctx->completion_lock); 6405 + 6406 + WRITE_ONCE(ctx->rings->cq_overflow, 6407 + atomic_inc_return(&ctx->cached_cq_overflow)); 6408 + 6409 + /* 6410 + * Put inflight ref and overflow ref. If that's 6411 + * all we had, then we're done with this request. 6412 + */ 6413 + if (refcount_sub_and_test(2, &cancel_req->refs)) { 6414 + io_put_req(cancel_req); 6415 + continue; 6416 + } 6417 + } 6418 + 6471 6419 io_wq_cancel_work(ctx->io_wq, &cancel_req->work); 6472 6420 io_put_req(cancel_req); 6473 6421 schedule(); ··· 6503 6405 struct io_ring_ctx *ctx = file->private_data; 6504 6406 6505 6407 io_uring_cancel_files(ctx, data); 6408 + 6409 + /* 6410 + * If the task is going away, cancel work it may have pending 6411 + */ 6412 + if (fatal_signal_pending(current) || (current->flags & PF_EXITING)) 6413 + io_wq_cancel_pid(ctx->io_wq, task_pid_vnr(current)); 6414 + 6506 6415 return 0; 6507 6416 } 6508 6417
+25 -21
fs/jbd2/commit.c
··· 976 976 * it. */ 977 977 978 978 /* 979 - * A buffer which has been freed while still being journaled by 980 - * a previous transaction. 981 - */ 982 - if (buffer_freed(bh)) { 979 + * A buffer which has been freed while still being journaled 980 + * by a previous transaction, refile the buffer to BJ_Forget of 981 + * the running transaction. If the just committed transaction 982 + * contains "add to orphan" operation, we can completely 983 + * invalidate the buffer now. We are rather through in that 984 + * since the buffer may be still accessible when blocksize < 985 + * pagesize and it is attached to the last partial page. 986 + */ 987 + if (buffer_freed(bh) && !jh->b_next_transaction) { 988 + struct address_space *mapping; 989 + 990 + clear_buffer_freed(bh); 991 + clear_buffer_jbddirty(bh); 992 + 983 993 /* 984 - * If the running transaction is the one containing 985 - * "add to orphan" operation (b_next_transaction != 986 - * NULL), we have to wait for that transaction to 987 - * commit before we can really get rid of the buffer. 988 - * So just clear b_modified to not confuse transaction 989 - * credit accounting and refile the buffer to 990 - * BJ_Forget of the running transaction. If the just 991 - * committed transaction contains "add to orphan" 992 - * operation, we can completely invalidate the buffer 993 - * now. We are rather through in that since the 994 - * buffer may be still accessible when blocksize < 995 - * pagesize and it is attached to the last partial 996 - * page. 994 + * Block device buffers need to stay mapped all the 995 + * time, so it is enough to clear buffer_jbddirty and 996 + * buffer_freed bits. For the file mapping buffers (i.e. 997 + * journalled data) we need to unmap buffer and clear 998 + * more bits. We also need to be careful about the check 999 + * because the data page mapping can get cleared under 1000 + * out hands, which alse need not to clear more bits 1001 + * because the page and buffers will be freed and can 1002 + * never be reused once we are done with them. 997 1003 */ 998 - jh->b_modified = 0; 999 - if (!jh->b_next_transaction) { 1000 - clear_buffer_freed(bh); 1001 - clear_buffer_jbddirty(bh); 1004 + mapping = READ_ONCE(bh->b_page->mapping); 1005 + if (mapping && !sb_is_blkdev_sb(mapping->host->i_sb)) { 1002 1006 clear_buffer_mapped(bh); 1003 1007 clear_buffer_new(bh); 1004 1008 clear_buffer_req(bh);
+6 -4
fs/jbd2/transaction.c
··· 2329 2329 return -EBUSY; 2330 2330 } 2331 2331 /* 2332 - * OK, buffer won't be reachable after truncate. We just set 2333 - * j_next_transaction to the running transaction (if there is 2334 - * one) and mark buffer as freed so that commit code knows it 2335 - * should clear dirty bits when it is done with the buffer. 2332 + * OK, buffer won't be reachable after truncate. We just clear 2333 + * b_modified to not confuse transaction credit accounting, and 2334 + * set j_next_transaction to the running transaction (if there 2335 + * is one) and mark buffer as freed so that commit code knows 2336 + * it should clear dirty bits when it is done with the buffer. 2336 2337 */ 2337 2338 set_buffer_freed(bh); 2338 2339 if (journal->j_running_transaction && buffer_jbddirty(bh)) 2339 2340 jh->b_next_transaction = journal->j_running_transaction; 2341 + jh->b_modified = 0; 2340 2342 spin_unlock(&journal->j_list_lock); 2341 2343 spin_unlock(&jh->b_state_lock); 2342 2344 write_unlock(&journal->j_state_lock);
+40 -10
fs/nfs/delegation.c
··· 42 42 if (!test_and_set_bit(NFS_DELEGATION_REVOKED, &delegation->flags)) { 43 43 delegation->stateid.type = NFS4_INVALID_STATEID_TYPE; 44 44 atomic_long_dec(&nfs_active_delegations); 45 + if (!test_bit(NFS_DELEGATION_RETURNING, &delegation->flags)) 46 + nfs_clear_verifier_delegated(delegation->inode); 45 47 } 48 + } 49 + 50 + static struct nfs_delegation *nfs_get_delegation(struct nfs_delegation *delegation) 51 + { 52 + refcount_inc(&delegation->refcount); 53 + return delegation; 54 + } 55 + 56 + static void nfs_put_delegation(struct nfs_delegation *delegation) 57 + { 58 + if (refcount_dec_and_test(&delegation->refcount)) 59 + __nfs_free_delegation(delegation); 46 60 } 47 61 48 62 static void nfs_free_delegation(struct nfs_delegation *delegation) 49 63 { 50 64 nfs_mark_delegation_revoked(delegation); 51 - __nfs_free_delegation(delegation); 65 + nfs_put_delegation(delegation); 52 66 } 53 67 54 68 /** ··· 255 241 256 242 static int nfs_do_return_delegation(struct inode *inode, struct nfs_delegation *delegation, int issync) 257 243 { 244 + const struct cred *cred; 258 245 int res = 0; 259 246 260 - if (!test_bit(NFS_DELEGATION_REVOKED, &delegation->flags)) 261 - res = nfs4_proc_delegreturn(inode, 262 - delegation->cred, 247 + if (!test_bit(NFS_DELEGATION_REVOKED, &delegation->flags)) { 248 + spin_lock(&delegation->lock); 249 + cred = get_cred(delegation->cred); 250 + spin_unlock(&delegation->lock); 251 + res = nfs4_proc_delegreturn(inode, cred, 263 252 &delegation->stateid, 264 253 issync); 254 + put_cred(cred); 255 + } 265 256 return res; 266 257 } 267 258 ··· 292 273 if (delegation == NULL) 293 274 goto out; 294 275 spin_lock(&delegation->lock); 295 - if (!test_and_set_bit(NFS_DELEGATION_RETURNING, &delegation->flags)) 296 - ret = delegation; 276 + if (!test_and_set_bit(NFS_DELEGATION_RETURNING, &delegation->flags)) { 277 + /* Refcount matched in nfs_end_delegation_return() */ 278 + ret = nfs_get_delegation(delegation); 279 + } 297 280 spin_unlock(&delegation->lock); 281 + if (ret) 282 + nfs_clear_verifier_delegated(&nfsi->vfs_inode); 298 283 out: 299 284 return ret; 300 285 } ··· 416 393 if (delegation == NULL) 417 394 return -ENOMEM; 418 395 nfs4_stateid_copy(&delegation->stateid, stateid); 396 + refcount_set(&delegation->refcount, 1); 419 397 delegation->type = type; 420 398 delegation->pagemod_limit = pagemod_limit; 421 399 delegation->change_attr = inode_peek_iversion_raw(inode); ··· 516 492 517 493 err = nfs_do_return_delegation(inode, delegation, issync); 518 494 out: 495 + /* Refcount matched in nfs_start_delegation_return_locked() */ 496 + nfs_put_delegation(delegation); 519 497 return err; 520 498 } 521 499 ··· 712 686 list_empty(&NFS_I(inode)->open_files) && 713 687 !test_and_set_bit(NFS_DELEGATION_RETURNING, &delegation->flags)) { 714 688 clear_bit(NFS_DELEGATION_RETURN_IF_CLOSED, &delegation->flags); 715 - ret = delegation; 689 + /* Refcount matched in nfs_end_delegation_return() */ 690 + ret = nfs_get_delegation(delegation); 716 691 } 717 692 spin_unlock(&delegation->lock); 693 + if (ret) 694 + nfs_clear_verifier_delegated(inode); 718 695 } 719 696 out: 720 697 rcu_read_unlock(); ··· 1117 1088 delegation = nfs_start_delegation_return_locked(NFS_I(inode)); 1118 1089 rcu_read_unlock(); 1119 1090 if (delegation != NULL) { 1120 - delegation = nfs_detach_delegation(NFS_I(inode), 1121 - delegation, server); 1122 - if (delegation != NULL) 1091 + if (nfs_detach_delegation(NFS_I(inode), delegation, 1092 + server) != NULL) 1123 1093 nfs_free_delegation(delegation); 1094 + /* Match nfs_start_delegation_return_locked */ 1095 + nfs_put_delegation(delegation); 1124 1096 } 1125 1097 iput(inode); 1126 1098 nfs_sb_deactive(server->super);
+1
fs/nfs/delegation.h
··· 22 22 unsigned long pagemod_limit; 23 23 __u64 change_attr; 24 24 unsigned long flags; 25 + refcount_t refcount; 25 26 spinlock_t lock; 26 27 struct rcu_head rcu; 27 28 };
+116 -10
fs/nfs/dir.c
··· 155 155 loff_t current_index; 156 156 decode_dirent_t decode; 157 157 158 + unsigned long dir_verifier; 158 159 unsigned long timestamp; 159 160 unsigned long gencount; 160 161 unsigned int cache_entry_index; ··· 354 353 again: 355 354 timestamp = jiffies; 356 355 gencount = nfs_inc_attr_generation_counter(); 356 + desc->dir_verifier = nfs_save_change_attribute(inode); 357 357 error = NFS_PROTO(inode)->readdir(file_dentry(file), cred, entry->cookie, pages, 358 358 NFS_SERVER(inode)->dtsize, desc->plus); 359 359 if (error < 0) { ··· 457 455 } 458 456 459 457 static 460 - void nfs_prime_dcache(struct dentry *parent, struct nfs_entry *entry) 458 + void nfs_prime_dcache(struct dentry *parent, struct nfs_entry *entry, 459 + unsigned long dir_verifier) 461 460 { 462 461 struct qstr filename = QSTR_INIT(entry->name, entry->len); 463 462 DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wq); 464 463 struct dentry *dentry; 465 464 struct dentry *alias; 466 - struct inode *dir = d_inode(parent); 467 465 struct inode *inode; 468 466 int status; 469 467 ··· 502 500 if (nfs_same_file(dentry, entry)) { 503 501 if (!entry->fh->size) 504 502 goto out; 505 - nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); 503 + nfs_set_verifier(dentry, dir_verifier); 506 504 status = nfs_refresh_inode(d_inode(dentry), entry->fattr); 507 505 if (!status) 508 506 nfs_setsecurity(d_inode(dentry), entry->fattr, entry->label); ··· 528 526 dput(dentry); 529 527 dentry = alias; 530 528 } 531 - nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); 529 + nfs_set_verifier(dentry, dir_verifier); 532 530 out: 533 531 dput(dentry); 534 532 } ··· 566 564 count++; 567 565 568 566 if (desc->plus) 569 - nfs_prime_dcache(file_dentry(desc->file), entry); 567 + nfs_prime_dcache(file_dentry(desc->file), entry, 568 + desc->dir_verifier); 570 569 571 570 status = nfs_readdir_add_to_array(entry, page); 572 571 if (status != 0) ··· 986 983 * full lookup on all child dentries of 'dir' whenever a change occurs 987 984 * on the server that might have invalidated our dcache. 988 985 * 986 + * Note that we reserve bit '0' as a tag to let us know when a dentry 987 + * was revalidated while holding a delegation on its inode. 988 + * 989 989 * The caller should be holding dir->i_lock 990 990 */ 991 991 void nfs_force_lookup_revalidate(struct inode *dir) 992 992 { 993 - NFS_I(dir)->cache_change_attribute++; 993 + NFS_I(dir)->cache_change_attribute += 2; 994 994 } 995 995 EXPORT_SYMBOL_GPL(nfs_force_lookup_revalidate); 996 + 997 + /** 998 + * nfs_verify_change_attribute - Detects NFS remote directory changes 999 + * @dir: pointer to parent directory inode 1000 + * @verf: previously saved change attribute 1001 + * 1002 + * Return "false" if the verifiers doesn't match the change attribute. 1003 + * This would usually indicate that the directory contents have changed on 1004 + * the server, and that any dentries need revalidating. 1005 + */ 1006 + static bool nfs_verify_change_attribute(struct inode *dir, unsigned long verf) 1007 + { 1008 + return (verf & ~1UL) == nfs_save_change_attribute(dir); 1009 + } 1010 + 1011 + static void nfs_set_verifier_delegated(unsigned long *verf) 1012 + { 1013 + *verf |= 1UL; 1014 + } 1015 + 1016 + #if IS_ENABLED(CONFIG_NFS_V4) 1017 + static void nfs_unset_verifier_delegated(unsigned long *verf) 1018 + { 1019 + *verf &= ~1UL; 1020 + } 1021 + #endif /* IS_ENABLED(CONFIG_NFS_V4) */ 1022 + 1023 + static bool nfs_test_verifier_delegated(unsigned long verf) 1024 + { 1025 + return verf & 1; 1026 + } 1027 + 1028 + static bool nfs_verifier_is_delegated(struct dentry *dentry) 1029 + { 1030 + return nfs_test_verifier_delegated(dentry->d_time); 1031 + } 1032 + 1033 + static void nfs_set_verifier_locked(struct dentry *dentry, unsigned long verf) 1034 + { 1035 + struct inode *inode = d_inode(dentry); 1036 + 1037 + if (!nfs_verifier_is_delegated(dentry) && 1038 + !nfs_verify_change_attribute(d_inode(dentry->d_parent), verf)) 1039 + goto out; 1040 + if (inode && NFS_PROTO(inode)->have_delegation(inode, FMODE_READ)) 1041 + nfs_set_verifier_delegated(&verf); 1042 + out: 1043 + dentry->d_time = verf; 1044 + } 1045 + 1046 + /** 1047 + * nfs_set_verifier - save a parent directory verifier in the dentry 1048 + * @dentry: pointer to dentry 1049 + * @verf: verifier to save 1050 + * 1051 + * Saves the parent directory verifier in @dentry. If the inode has 1052 + * a delegation, we also tag the dentry as having been revalidated 1053 + * while holding a delegation so that we know we don't have to 1054 + * look it up again after a directory change. 1055 + */ 1056 + void nfs_set_verifier(struct dentry *dentry, unsigned long verf) 1057 + { 1058 + 1059 + spin_lock(&dentry->d_lock); 1060 + nfs_set_verifier_locked(dentry, verf); 1061 + spin_unlock(&dentry->d_lock); 1062 + } 1063 + EXPORT_SYMBOL_GPL(nfs_set_verifier); 1064 + 1065 + #if IS_ENABLED(CONFIG_NFS_V4) 1066 + /** 1067 + * nfs_clear_verifier_delegated - clear the dir verifier delegation tag 1068 + * @inode: pointer to inode 1069 + * 1070 + * Iterates through the dentries in the inode alias list and clears 1071 + * the tag used to indicate that the dentry has been revalidated 1072 + * while holding a delegation. 1073 + * This function is intended for use when the delegation is being 1074 + * returned or revoked. 1075 + */ 1076 + void nfs_clear_verifier_delegated(struct inode *inode) 1077 + { 1078 + struct dentry *alias; 1079 + 1080 + if (!inode) 1081 + return; 1082 + spin_lock(&inode->i_lock); 1083 + hlist_for_each_entry(alias, &inode->i_dentry, d_u.d_alias) { 1084 + spin_lock(&alias->d_lock); 1085 + nfs_unset_verifier_delegated(&alias->d_time); 1086 + spin_unlock(&alias->d_lock); 1087 + } 1088 + spin_unlock(&inode->i_lock); 1089 + } 1090 + EXPORT_SYMBOL_GPL(nfs_clear_verifier_delegated); 1091 + #endif /* IS_ENABLED(CONFIG_NFS_V4) */ 996 1092 997 1093 /* 998 1094 * A check for whether or not the parent directory has changed. ··· 1261 1159 struct nfs_fh *fhandle; 1262 1160 struct nfs_fattr *fattr; 1263 1161 struct nfs4_label *label; 1162 + unsigned long dir_verifier; 1264 1163 int ret; 1265 1164 1266 1165 ret = -ENOMEM; ··· 1271 1168 if (fhandle == NULL || fattr == NULL || IS_ERR(label)) 1272 1169 goto out; 1273 1170 1171 + dir_verifier = nfs_save_change_attribute(dir); 1274 1172 ret = NFS_PROTO(dir)->lookup(dir, dentry, fhandle, fattr, label); 1275 1173 if (ret < 0) { 1276 1174 switch (ret) { ··· 1292 1188 goto out; 1293 1189 1294 1190 nfs_setsecurity(inode, fattr, label); 1295 - nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); 1191 + nfs_set_verifier(dentry, dir_verifier); 1296 1192 1297 1193 /* set a readdirplus hint that we had a cache miss */ 1298 1194 nfs_force_use_readdirplus(dir); ··· 1334 1230 goto out_bad; 1335 1231 } 1336 1232 1337 - if (NFS_PROTO(dir)->have_delegation(inode, FMODE_READ)) 1233 + if (nfs_verifier_is_delegated(dentry)) 1338 1234 return nfs_lookup_revalidate_delegated(dir, dentry, inode); 1339 1235 1340 1236 /* Force a full look up iff the parent directory has changed */ ··· 1519 1415 struct nfs_fh *fhandle = NULL; 1520 1416 struct nfs_fattr *fattr = NULL; 1521 1417 struct nfs4_label *label = NULL; 1418 + unsigned long dir_verifier; 1522 1419 int error; 1523 1420 1524 1421 dfprintk(VFS, "NFS: lookup(%pd2)\n", dentry); ··· 1545 1440 if (IS_ERR(label)) 1546 1441 goto out; 1547 1442 1443 + dir_verifier = nfs_save_change_attribute(dir); 1548 1444 trace_nfs_lookup_enter(dir, dentry, flags); 1549 1445 error = NFS_PROTO(dir)->lookup(dir, dentry, fhandle, fattr, label); 1550 1446 if (error == -ENOENT) ··· 1569 1463 goto out_label; 1570 1464 dentry = res; 1571 1465 } 1572 - nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); 1466 + nfs_set_verifier(dentry, dir_verifier); 1573 1467 out_label: 1574 1468 trace_nfs_lookup_exit(dir, dentry, flags, error); 1575 1469 nfs4_label_free(label); ··· 1774 1668 if (inode == NULL) 1775 1669 goto full_reval; 1776 1670 1777 - if (NFS_PROTO(dir)->have_delegation(inode, FMODE_READ)) 1671 + if (nfs_verifier_is_delegated(dentry)) 1778 1672 return nfs_lookup_revalidate_delegated(dir, dentry, inode); 1779 1673 1780 1674 /* NFS only supports OPEN on regular files */
+1
fs/nfs/inode.c
··· 2114 2114 init_rwsem(&nfsi->rmdir_sem); 2115 2115 mutex_init(&nfsi->commit_mutex); 2116 2116 nfs4_init_once(nfsi); 2117 + nfsi->cache_change_attribute = 0; 2117 2118 } 2118 2119 2119 2120 static int __init nfs_init_inodecache(void)
-1
fs/nfs/nfs4file.c
··· 87 87 if (inode != d_inode(dentry)) 88 88 goto out_drop; 89 89 90 - nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); 91 90 nfs_file_set_open_context(filp, ctx); 92 91 nfs_fscache_open_file(inode, filp); 93 92 err = 0;
+17 -3
fs/nfs/nfs4proc.c
··· 2974 2974 struct dentry *dentry; 2975 2975 struct nfs4_state *state; 2976 2976 fmode_t acc_mode = _nfs4_ctx_to_accessmode(ctx); 2977 + struct inode *dir = d_inode(opendata->dir); 2978 + unsigned long dir_verifier; 2977 2979 unsigned int seq; 2978 2980 int ret; 2979 2981 2980 2982 seq = raw_seqcount_begin(&sp->so_reclaim_seqcount); 2983 + dir_verifier = nfs_save_change_attribute(dir); 2981 2984 2982 2985 ret = _nfs4_proc_open(opendata, ctx); 2983 2986 if (ret != 0) ··· 3008 3005 dput(ctx->dentry); 3009 3006 ctx->dentry = dentry = alias; 3010 3007 } 3011 - nfs_set_verifier(dentry, 3012 - nfs_save_change_attribute(d_inode(opendata->dir))); 3008 + } 3009 + 3010 + switch(opendata->o_arg.claim) { 3011 + default: 3012 + break; 3013 + case NFS4_OPEN_CLAIM_NULL: 3014 + case NFS4_OPEN_CLAIM_DELEGATE_CUR: 3015 + case NFS4_OPEN_CLAIM_DELEGATE_PREV: 3016 + if (!opendata->rpc_done) 3017 + break; 3018 + if (opendata->o_res.delegation_type != 0) 3019 + dir_verifier = nfs_save_change_attribute(dir); 3020 + nfs_set_verifier(dentry, dir_verifier); 3013 3021 } 3014 3022 3015 3023 /* Parse layoutget results before we check for access */ ··· 5336 5322 hdr->timestamp = jiffies; 5337 5323 5338 5324 msg->rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_WRITE]; 5339 - nfs4_init_sequence(&hdr->args.seq_args, &hdr->res.seq_res, 1, 0); 5325 + nfs4_init_sequence(&hdr->args.seq_args, &hdr->res.seq_res, 0, 0); 5340 5326 nfs4_state_protect_write(server->nfs_client, clnt, msg, hdr); 5341 5327 } 5342 5328
+1 -1
fs/xfs/xfs_aops.c
··· 587 587 588 588 xfs_iflags_clear(ip, XFS_ITRUNCATED); 589 589 return dax_writeback_mapping_range(mapping, 590 - xfs_inode_buftarg(ip)->bt_bdev, wbc); 590 + xfs_inode_buftarg(ip)->bt_daxdev, wbc); 591 591 } 592 592 593 593 STATIC sector_t
+1
include/acpi/acpixf.h
··· 752 752 ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status acpi_disable_all_gpes(void)) 753 753 ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status acpi_enable_all_runtime_gpes(void)) 754 754 ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status acpi_enable_all_wakeup_gpes(void)) 755 + ACPI_HW_DEPENDENT_RETURN_UINT32(u32 acpi_any_gpe_status_set(void)) 755 756 756 757 ACPI_HW_DEPENDENT_RETURN_STATUS(acpi_status 757 758 acpi_get_gpe_device(u32 gpe_index,
-3
include/linux/cpufreq.h
··· 201 201 return cpumask_weight(policy->cpus) > 1; 202 202 } 203 203 204 - /* /sys/devices/system/cpu/cpufreq: entry point for global variables */ 205 - extern struct kobject *cpufreq_global_kobject; 206 - 207 204 #ifdef CONFIG_CPU_FREQ 208 205 unsigned int cpufreq_get(unsigned int cpu); 209 206 unsigned int cpufreq_quick_get(unsigned int cpu);
+2 -12
include/linux/dax.h
··· 129 129 sectors); 130 130 } 131 131 132 - static inline struct dax_device *fs_dax_get_by_host(const char *host) 133 - { 134 - return dax_get_by_host(host); 135 - } 136 - 137 132 static inline void fs_put_dax(struct dax_device *dax_dev) 138 133 { 139 134 put_dax(dax_dev); ··· 136 141 137 142 struct dax_device *fs_dax_get_by_bdev(struct block_device *bdev); 138 143 int dax_writeback_mapping_range(struct address_space *mapping, 139 - struct block_device *bdev, struct writeback_control *wbc); 144 + struct dax_device *dax_dev, struct writeback_control *wbc); 140 145 141 146 struct page *dax_layout_busy_page(struct address_space *mapping); 142 147 dax_entry_t dax_lock_page(struct page *page); ··· 155 160 return false; 156 161 } 157 162 158 - static inline struct dax_device *fs_dax_get_by_host(const char *host) 159 - { 160 - return NULL; 161 - } 162 - 163 163 static inline void fs_put_dax(struct dax_device *dax_dev) 164 164 { 165 165 } ··· 170 180 } 171 181 172 182 static inline int dax_writeback_mapping_range(struct address_space *mapping, 173 - struct block_device *bdev, struct writeback_control *wbc) 183 + struct dax_device *dax_dev, struct writeback_control *wbc) 174 184 { 175 185 return -EOPNOTSUPP; 176 186 }
+6
include/linux/icmpv6.h
··· 31 31 } 32 32 #endif 33 33 34 + #if IS_ENABLED(CONFIG_NF_NAT) 35 + void icmpv6_ndo_send(struct sk_buff *skb_in, u8 type, u8 code, __u32 info); 36 + #else 37 + #define icmpv6_ndo_send icmpv6_send 38 + #endif 39 + 34 40 extern int icmpv6_init(void); 35 41 extern int icmpv6_err_convert(u8 type, u8 code, 36 42 int *err);
+15 -1
include/linux/netdevice.h
··· 1616 1616 * and drivers will need to set them appropriately. 1617 1617 * 1618 1618 * @mpls_features: Mask of features inheritable by MPLS 1619 + * @gso_partial_features: value(s) from NETIF_F_GSO\* 1619 1620 * 1620 1621 * @ifindex: interface index 1621 1622 * @group: The group the device belongs to ··· 1641 1640 * @netdev_ops: Includes several pointers to callbacks, 1642 1641 * if one wants to override the ndo_*() functions 1643 1642 * @ethtool_ops: Management operations 1643 + * @l3mdev_ops: Layer 3 master device operations 1644 1644 * @ndisc_ops: Includes callbacks for different IPv6 neighbour 1645 1645 * discovery handling. Necessary for e.g. 6LoWPAN. 1646 + * @xfrmdev_ops: Transformation offload operations 1647 + * @tlsdev_ops: Transport Layer Security offload operations 1646 1648 * @header_ops: Includes callbacks for creating,parsing,caching,etc 1647 1649 * of Layer 2 headers. 1648 1650 * ··· 1684 1680 * @dev_port: Used to differentiate devices that share 1685 1681 * the same function 1686 1682 * @addr_list_lock: XXX: need comments on this one 1683 + * @name_assign_type: network interface name assignment type 1687 1684 * @uc_promisc: Counter that indicates promiscuous mode 1688 1685 * has been enabled due to the need to listen to 1689 1686 * additional unicast addresses in a device that ··· 1707 1702 * @ip6_ptr: IPv6 specific data 1708 1703 * @ax25_ptr: AX.25 specific data 1709 1704 * @ieee80211_ptr: IEEE 802.11 specific data, assign before registering 1705 + * @ieee802154_ptr: IEEE 802.15.4 low-rate Wireless Personal Area Network 1706 + * device struct 1707 + * @mpls_ptr: mpls_dev struct pointer 1710 1708 * 1711 1709 * @dev_addr: Hw address (before bcast, 1712 1710 * because most packets are unicast) ··· 1718 1710 * @num_rx_queues: Number of RX queues 1719 1711 * allocated at register_netdev() time 1720 1712 * @real_num_rx_queues: Number of RX queues currently active in device 1713 + * @xdp_prog: XDP sockets filter program pointer 1714 + * @gro_flush_timeout: timeout for GRO layer in NAPI 1721 1715 * 1722 1716 * @rx_handler: handler for received packets 1723 1717 * @rx_handler_data: XXX: need comments on this one ··· 1741 1731 * @qdisc: Root qdisc from userspace point of view 1742 1732 * @tx_queue_len: Max frames per queue allowed 1743 1733 * @tx_global_lock: XXX: need comments on this one 1734 + * @xdp_bulkq: XDP device bulk queue 1735 + * @xps_cpus_map: all CPUs map for XPS device 1736 + * @xps_rxqs_map: all RXQs map for XPS device 1744 1737 * 1745 1738 * @xps_maps: XXX: need comments on this one 1746 1739 * @miniq_egress: clsact qdisc specific data for 1747 1740 * egress processing 1741 + * @qdisc_hash: qdisc hash table 1748 1742 * @watchdog_timeo: Represents the timeout that is used by 1749 1743 * the watchdog (see dev_watchdog()) 1750 1744 * @watchdog_timer: List of timers ··· 3562 3548 } 3563 3549 3564 3550 /** 3565 - * netif_attrmask_next_and - get the next CPU/Rx queue in *src1p & *src2p 3551 + * netif_attrmask_next_and - get the next CPU/Rx queue in \*src1p & \*src2p 3566 3552 * @n: CPU/Rx queue index 3567 3553 * @src1p: the first CPUs/Rx queues mask pointer 3568 3554 * @src2p: the second CPUs/Rx queues mask pointer
+6 -20
include/linux/nfs_fs.h
··· 337 337 return NFS_SERVER(inode)->caps & cap; 338 338 } 339 339 340 - static inline void nfs_set_verifier(struct dentry * dentry, unsigned long verf) 341 - { 342 - dentry->d_time = verf; 343 - } 344 - 345 340 /** 346 341 * nfs_save_change_attribute - Returns the inode attribute change cookie 347 342 * @dir - pointer to parent directory inode 348 - * The "change attribute" is updated every time we finish an operation 349 - * that will result in a metadata change on the server. 343 + * The "cache change attribute" is updated when we need to revalidate 344 + * our dentry cache after a directory was seen to change on the server. 350 345 */ 351 346 static inline unsigned long nfs_save_change_attribute(struct inode *dir) 352 347 { 353 348 return NFS_I(dir)->cache_change_attribute; 354 - } 355 - 356 - /** 357 - * nfs_verify_change_attribute - Detects NFS remote directory changes 358 - * @dir - pointer to parent directory inode 359 - * @chattr - previously saved change attribute 360 - * Return "false" if the verifiers doesn't match the change attribute. 361 - * This would usually indicate that the directory contents have changed on 362 - * the server, and that any dentries need revalidating. 363 - */ 364 - static inline int nfs_verify_change_attribute(struct inode *dir, unsigned long chattr) 365 - { 366 - return chattr == NFS_I(dir)->cache_change_attribute; 367 349 } 368 350 369 351 /* ··· 477 495 extern const struct dentry_operations nfs_dentry_operations; 478 496 479 497 extern void nfs_force_lookup_revalidate(struct inode *dir); 498 + extern void nfs_set_verifier(struct dentry * dentry, unsigned long verf); 499 + #if IS_ENABLED(CONFIG_NFS_V4) 500 + extern void nfs_clear_verifier_delegated(struct inode *inode); 501 + #endif /* IS_ENABLED(CONFIG_NFS_V4) */ 480 502 extern struct dentry *nfs_add_or_obtain(struct dentry *dentry, 481 503 struct nfs_fh *fh, struct nfs_fattr *fattr, 482 504 struct nfs4_label *label);
+2 -1
include/linux/pipe_fs_i.h
··· 29 29 /** 30 30 * struct pipe_inode_info - a linux kernel pipe 31 31 * @mutex: mutex protecting the whole thing 32 - * @wait: reader/writer wait point in case of empty/full pipe 32 + * @rd_wait: reader wait point in case of empty pipe 33 + * @wr_wait: writer wait point in case of full pipe 33 34 * @head: The point of buffer production 34 35 * @tail: The point of buffer consumption 35 36 * @max_usage: The maximum number of slots that may be used in the ring
+2
include/linux/sched/nohz.h
··· 15 15 16 16 #ifdef CONFIG_NO_HZ_COMMON 17 17 void calc_load_nohz_start(void); 18 + void calc_load_nohz_remote(struct rq *rq); 18 19 void calc_load_nohz_stop(void); 19 20 #else 20 21 static inline void calc_load_nohz_start(void) { } 22 + static inline void calc_load_nohz_remote(struct rq *rq) { } 21 23 static inline void calc_load_nohz_stop(void) { } 22 24 #endif /* CONFIG_NO_HZ_COMMON */ 23 25
+1 -1
include/linux/suspend.h
··· 191 191 int (*begin)(void); 192 192 int (*prepare)(void); 193 193 int (*prepare_late)(void); 194 - void (*wake)(void); 194 + bool (*wake)(void); 195 195 void (*restore_early)(void); 196 196 void (*restore)(void); 197 197 void (*end)(void);
+1 -1
include/linux/trace_events.h
··· 440 440 struct synth_event *event; 441 441 unsigned int cur_field; 442 442 unsigned int n_u64; 443 - bool enabled; 443 + bool disabled; 444 444 bool add_next; 445 445 bool add_name; 446 446 };
-1
include/net/flow_dissector.h
··· 33 33 34 34 /** 35 35 * struct flow_dissector_key_basic: 36 - * @thoff: Transport header offset 37 36 * @n_proto: Network header protocol (eg. IPv4/IPv6) 38 37 * @ip_proto: Transport header protocol (eg. TCP/UDP) 39 38 */
+6
include/net/icmp.h
··· 43 43 __icmp_send(skb_in, type, code, info, &IPCB(skb_in)->opt); 44 44 } 45 45 46 + #if IS_ENABLED(CONFIG_NF_NAT) 47 + void icmp_ndo_send(struct sk_buff *skb_in, int type, int code, __be32 info); 48 + #else 49 + #define icmp_ndo_send icmp_send 50 + #endif 51 + 46 52 int icmp_rcv(struct sk_buff *skb); 47 53 int icmp_err(struct sk_buff *skb, u32 info); 48 54 int icmp_init(void);
+5 -6
include/net/mac80211.h
··· 1004 1004 struct ieee80211_tx_info { 1005 1005 /* common information */ 1006 1006 u32 flags; 1007 - u8 band; 1008 - 1009 - u8 hw_queue; 1010 - 1011 - u16 ack_frame_id:6; 1012 - u16 tx_time_est:10; 1007 + u32 band:3, 1008 + ack_frame_id:13, 1009 + hw_queue:4, 1010 + tx_time_est:10; 1011 + /* 2 free bits */ 1013 1012 1014 1013 union { 1015 1014 struct {
+41 -2
include/uapi/linux/kvm.h
··· 474 474 __u32 size; /* amount of bytes */ 475 475 __u32 op; /* type of operation */ 476 476 __u64 buf; /* buffer in userspace */ 477 - __u8 ar; /* the access register number */ 478 - __u8 reserved[31]; /* should be set to 0 */ 477 + union { 478 + __u8 ar; /* the access register number */ 479 + __u32 sida_offset; /* offset into the sida */ 480 + __u8 reserved[32]; /* should be set to 0 */ 481 + }; 479 482 }; 480 483 /* types for kvm_s390_mem_op->op */ 481 484 #define KVM_S390_MEMOP_LOGICAL_READ 0 482 485 #define KVM_S390_MEMOP_LOGICAL_WRITE 1 486 + #define KVM_S390_MEMOP_SIDA_READ 2 487 + #define KVM_S390_MEMOP_SIDA_WRITE 3 483 488 /* flags for kvm_s390_mem_op->flags */ 484 489 #define KVM_S390_MEMOP_F_CHECK_ONLY (1ULL << 0) 485 490 #define KVM_S390_MEMOP_F_INJECT_EXCEPTION (1ULL << 1) ··· 1015 1010 #define KVM_CAP_ARM_NISV_TO_USER 177 1016 1011 #define KVM_CAP_ARM_INJECT_EXT_DABT 178 1017 1012 #define KVM_CAP_S390_VCPU_RESETS 179 1013 + #define KVM_CAP_S390_PROTECTED 180 1018 1014 1019 1015 #ifdef KVM_CAP_IRQ_ROUTING 1020 1016 ··· 1483 1477 /* Available with KVM_CAP_S390_VCPU_RESETS */ 1484 1478 #define KVM_S390_NORMAL_RESET _IO(KVMIO, 0xc3) 1485 1479 #define KVM_S390_CLEAR_RESET _IO(KVMIO, 0xc4) 1480 + 1481 + struct kvm_s390_pv_sec_parm { 1482 + __u64 origin; 1483 + __u64 length; 1484 + }; 1485 + 1486 + struct kvm_s390_pv_unp { 1487 + __u64 addr; 1488 + __u64 size; 1489 + __u64 tweak; 1490 + }; 1491 + 1492 + enum pv_cmd_id { 1493 + KVM_PV_ENABLE, 1494 + KVM_PV_DISABLE, 1495 + KVM_PV_SET_SEC_PARMS, 1496 + KVM_PV_UNPACK, 1497 + KVM_PV_VERIFY, 1498 + KVM_PV_PREP_RESET, 1499 + KVM_PV_UNSHARE_ALL, 1500 + }; 1501 + 1502 + struct kvm_pv_cmd { 1503 + __u32 cmd; /* Command to be executed */ 1504 + __u16 rc; /* Ultravisor return code */ 1505 + __u16 rrc; /* Ultravisor return reason code */ 1506 + __u64 data; /* Data or address */ 1507 + __u32 flags; /* flags for future extensions. Must be 0 for now */ 1508 + __u32 reserved[3]; 1509 + }; 1510 + 1511 + /* Available with KVM_CAP_S390_PROTECTED */ 1512 + #define KVM_S390_PV_COMMAND _IOWR(KVMIO, 0xc5, struct kvm_pv_cmd) 1486 1513 1487 1514 /* Secure Encrypted Virtualization command */ 1488 1515 enum sev_cmd_id {
-1
init/Kconfig
··· 1227 1227 config BOOT_CONFIG 1228 1228 bool "Boot config support" 1229 1229 depends on BLK_DEV_INITRD 1230 - select LIBXBC 1231 1230 default y 1232 1231 help 1233 1232 Extra boot config allows system admin to pass a config file as
+30 -7
init/main.c
··· 142 142 /* Extra init arguments */ 143 143 static char *extra_init_args; 144 144 145 + #ifdef CONFIG_BOOT_CONFIG 146 + /* Is bootconfig on command line? */ 147 + static bool bootconfig_found; 148 + static bool initargs_found; 149 + #else 150 + # define bootconfig_found false 151 + # define initargs_found false 152 + #endif 153 + 145 154 static char *execute_command; 146 155 static char *ramdisk_execute_command; 147 156 ··· 345 336 return ret; 346 337 } 347 338 339 + static int __init bootconfig_params(char *param, char *val, 340 + const char *unused, void *arg) 341 + { 342 + if (strcmp(param, "bootconfig") == 0) { 343 + bootconfig_found = true; 344 + } else if (strcmp(param, "--") == 0) { 345 + initargs_found = true; 346 + } 347 + return 0; 348 + } 349 + 348 350 static void __init setup_boot_config(const char *cmdline) 349 351 { 352 + static char tmp_cmdline[COMMAND_LINE_SIZE] __initdata; 350 353 u32 size, csum; 351 354 char *data, *copy; 352 - const char *p; 353 355 u32 *hdr; 354 356 int ret; 355 357 356 - p = strstr(cmdline, "bootconfig"); 357 - if (!p || (p != cmdline && !isspace(*(p-1))) || 358 - (p[10] && !isspace(p[10]))) 358 + strlcpy(tmp_cmdline, boot_command_line, COMMAND_LINE_SIZE); 359 + parse_args("bootconfig", tmp_cmdline, NULL, 0, 0, 0, NULL, 360 + bootconfig_params); 361 + 362 + if (!bootconfig_found) 359 363 return; 360 364 361 365 if (!initrd_end) ··· 584 562 * to init. 585 563 */ 586 564 len = strlen(saved_command_line); 587 - if (!strstr(boot_command_line, " -- ")) { 565 + if (initargs_found) { 566 + saved_command_line[len++] = ' '; 567 + } else { 588 568 strcpy(saved_command_line + len, " -- "); 589 569 len += 4; 590 - } else 591 - saved_command_line[len++] = ' '; 570 + } 592 571 593 572 strcpy(saved_command_line + len, extra_init_args); 594 573 }
+8 -5
kernel/cgroup/cgroup.c
··· 5927 5927 5928 5928 spin_lock_irq(&css_set_lock); 5929 5929 5930 - WARN_ON_ONCE(!list_empty(&child->cg_list)); 5931 - cset = task_css_set(current); /* current is @child's parent */ 5932 - get_css_set(cset); 5933 - cset->nr_tasks++; 5934 - css_set_move_task(child, NULL, cset, false); 5930 + /* init tasks are special, only link regular threads */ 5931 + if (likely(child->pid)) { 5932 + WARN_ON_ONCE(!list_empty(&child->cg_list)); 5933 + cset = task_css_set(current); /* current is @child's parent */ 5934 + get_css_set(cset); 5935 + cset->nr_tasks++; 5936 + css_set_move_task(child, NULL, cset, false); 5937 + } 5935 5938 5936 5939 /* 5937 5940 * If the cgroup has to be frozen, the new task has too. Let's set
+5 -4
kernel/power/suspend.c
··· 131 131 * to avoid them upfront. 132 132 */ 133 133 for (;;) { 134 - if (s2idle_ops && s2idle_ops->wake) 135 - s2idle_ops->wake(); 136 - 137 - if (pm_wakeup_pending()) 134 + if (s2idle_ops && s2idle_ops->wake) { 135 + if (s2idle_ops->wake()) 136 + break; 137 + } else if (pm_wakeup_pending()) { 138 138 break; 139 + } 139 140 140 141 pm_wakeup_clear(false); 141 142
+34 -29
kernel/sched/core.c
··· 552 552 */ 553 553 int get_nohz_timer_target(void) 554 554 { 555 - int i, cpu = smp_processor_id(); 555 + int i, cpu = smp_processor_id(), default_cpu = -1; 556 556 struct sched_domain *sd; 557 557 558 - if (!idle_cpu(cpu) && housekeeping_cpu(cpu, HK_FLAG_TIMER)) 559 - return cpu; 558 + if (housekeeping_cpu(cpu, HK_FLAG_TIMER)) { 559 + if (!idle_cpu(cpu)) 560 + return cpu; 561 + default_cpu = cpu; 562 + } 560 563 561 564 rcu_read_lock(); 562 565 for_each_domain(cpu, sd) { 563 - for_each_cpu(i, sched_domain_span(sd)) { 566 + for_each_cpu_and(i, sched_domain_span(sd), 567 + housekeeping_cpumask(HK_FLAG_TIMER)) { 564 568 if (cpu == i) 565 569 continue; 566 570 567 - if (!idle_cpu(i) && housekeeping_cpu(i, HK_FLAG_TIMER)) { 571 + if (!idle_cpu(i)) { 568 572 cpu = i; 569 573 goto unlock; 570 574 } 571 575 } 572 576 } 573 577 574 - if (!housekeeping_cpu(cpu, HK_FLAG_TIMER)) 575 - cpu = housekeeping_any_cpu(HK_FLAG_TIMER); 578 + if (default_cpu == -1) 579 + default_cpu = housekeeping_any_cpu(HK_FLAG_TIMER); 580 + cpu = default_cpu; 576 581 unlock: 577 582 rcu_read_unlock(); 578 583 return cpu; ··· 1446 1441 } 1447 1442 1448 1443 #ifdef CONFIG_SMP 1449 - 1450 - static inline bool is_per_cpu_kthread(struct task_struct *p) 1451 - { 1452 - if (!(p->flags & PF_KTHREAD)) 1453 - return false; 1454 - 1455 - if (p->nr_cpus_allowed != 1) 1456 - return false; 1457 - 1458 - return true; 1459 - } 1460 1444 1461 1445 /* 1462 1446 * Per-CPU kthreads are allowed to run on !active && online CPUs, see ··· 3663 3669 * statistics and checks timeslices in a time-independent way, regardless 3664 3670 * of when exactly it is running. 3665 3671 */ 3666 - if (idle_cpu(cpu) || !tick_nohz_tick_stopped_cpu(cpu)) 3672 + if (!tick_nohz_tick_stopped_cpu(cpu)) 3667 3673 goto out_requeue; 3668 3674 3669 3675 rq_lock_irq(rq, &rf); 3670 3676 curr = rq->curr; 3671 - if (is_idle_task(curr) || cpu_is_offline(cpu)) 3677 + if (cpu_is_offline(cpu)) 3672 3678 goto out_unlock; 3673 3679 3680 + curr = rq->curr; 3674 3681 update_rq_clock(rq); 3675 - delta = rq_clock_task(rq) - curr->se.exec_start; 3676 3682 3677 - /* 3678 - * Make sure the next tick runs within a reasonable 3679 - * amount of time. 3680 - */ 3681 - WARN_ON_ONCE(delta > (u64)NSEC_PER_SEC * 3); 3683 + if (!is_idle_task(curr)) { 3684 + /* 3685 + * Make sure the next tick runs within a reasonable 3686 + * amount of time. 3687 + */ 3688 + delta = rq_clock_task(rq) - curr->se.exec_start; 3689 + WARN_ON_ONCE(delta > (u64)NSEC_PER_SEC * 3); 3690 + } 3682 3691 curr->sched_class->task_tick(rq, curr, 0); 3683 3692 3693 + calc_load_nohz_remote(rq); 3684 3694 out_unlock: 3685 3695 rq_unlock_irq(rq, &rf); 3686 - 3687 3696 out_requeue: 3697 + 3688 3698 /* 3689 3699 * Run the remote tick once per second (1Hz). This arbitrary 3690 3700 * frequency is large enough to avoid overload but short enough ··· 7061 7063 7062 7064 if (queued) 7063 7065 enqueue_task(rq, tsk, queue_flags); 7064 - if (running) 7066 + if (running) { 7065 7067 set_next_task(rq, tsk); 7068 + /* 7069 + * After changing group, the running task may have joined a 7070 + * throttled one but it's still the running task. Trigger a 7071 + * resched to make sure that task can still run. 7072 + */ 7073 + resched_curr(rq); 7074 + } 7066 7075 7067 7076 task_rq_unlock(rq, tsk, &rf); 7068 7077 } ··· 7265 7260 &req.percent); 7266 7261 if (req.ret) 7267 7262 return req; 7268 - if (req.percent > UCLAMP_PERCENT_SCALE) { 7263 + if ((u64)req.percent > UCLAMP_PERCENT_SCALE) { 7269 7264 req.ret = -ERANGE; 7270 7265 return req; 7271 7266 }
+43 -13
kernel/sched/fair.c
··· 3516 3516 * attach_entity_load_avg - attach this entity to its cfs_rq load avg 3517 3517 * @cfs_rq: cfs_rq to attach to 3518 3518 * @se: sched_entity to attach 3519 - * @flags: migration hints 3520 3519 * 3521 3520 * Must call update_cfs_rq_load_avg() before this, since we rely on 3522 3521 * cfs_rq->avg.last_update_time being current. ··· 5910 5911 if (prev != target && cpus_share_cache(prev, target) && 5911 5912 (available_idle_cpu(prev) || sched_idle_cpu(prev))) 5912 5913 return prev; 5914 + 5915 + /* 5916 + * Allow a per-cpu kthread to stack with the wakee if the 5917 + * kworker thread and the tasks previous CPUs are the same. 5918 + * The assumption is that the wakee queued work for the 5919 + * per-cpu kthread that is now complete and the wakeup is 5920 + * essentially a sync wakeup. An obvious example of this 5921 + * pattern is IO completions. 5922 + */ 5923 + if (is_per_cpu_kthread(current) && 5924 + prev == smp_processor_id() && 5925 + this_rq()->nr_running <= 1) { 5926 + return prev; 5927 + } 5913 5928 5914 5929 /* Check a recently used CPU as a potential idle candidate: */ 5915 5930 recent_used_cpu = p->recent_used_cpu; ··· 8671 8658 /* 8672 8659 * Try to use spare capacity of local group without overloading it or 8673 8660 * emptying busiest. 8674 - * XXX Spreading tasks across NUMA nodes is not always the best policy 8675 - * and special care should be taken for SD_NUMA domain level before 8676 - * spreading the tasks. For now, load_balance() fully relies on 8677 - * NUMA_BALANCING and fbq_classify_group/rq to override the decision. 8678 8661 */ 8679 8662 if (local->group_type == group_has_spare) { 8680 8663 if (busiest->group_type > group_fully_busy) { ··· 8710 8701 env->migration_type = migrate_task; 8711 8702 lsub_positive(&nr_diff, local->sum_nr_running); 8712 8703 env->imbalance = nr_diff >> 1; 8713 - return; 8704 + } else { 8705 + 8706 + /* 8707 + * If there is no overload, we just want to even the number of 8708 + * idle cpus. 8709 + */ 8710 + env->migration_type = migrate_task; 8711 + env->imbalance = max_t(long, 0, (local->idle_cpus - 8712 + busiest->idle_cpus) >> 1); 8714 8713 } 8715 8714 8716 - /* 8717 - * If there is no overload, we just want to even the number of 8718 - * idle cpus. 8719 - */ 8720 - env->migration_type = migrate_task; 8721 - env->imbalance = max_t(long, 0, (local->idle_cpus - 8722 - busiest->idle_cpus) >> 1); 8715 + /* Consider allowing a small imbalance between NUMA groups */ 8716 + if (env->sd->flags & SD_NUMA) { 8717 + unsigned int imbalance_min; 8718 + 8719 + /* 8720 + * Compute an allowed imbalance based on a simple 8721 + * pair of communicating tasks that should remain 8722 + * local and ignore them. 8723 + * 8724 + * NOTE: Generally this would have been based on 8725 + * the domain size and this was evaluated. However, 8726 + * the benefit is similar across a range of workloads 8727 + * and machines but scaling by the domain size adds 8728 + * the risk that lower domains have to be rebalanced. 8729 + */ 8730 + imbalance_min = 2; 8731 + if (busiest->sum_nr_running <= imbalance_min) 8732 + env->imbalance = 0; 8733 + } 8734 + 8723 8735 return; 8724 8736 } 8725 8737
+23 -10
kernel/sched/loadavg.c
··· 231 231 return calc_load_idx & 1; 232 232 } 233 233 234 - void calc_load_nohz_start(void) 234 + static void calc_load_nohz_fold(struct rq *rq) 235 235 { 236 - struct rq *this_rq = this_rq(); 237 236 long delta; 238 237 239 - /* 240 - * We're going into NO_HZ mode, if there's any pending delta, fold it 241 - * into the pending NO_HZ delta. 242 - */ 243 - delta = calc_load_fold_active(this_rq, 0); 238 + delta = calc_load_fold_active(rq, 0); 244 239 if (delta) { 245 240 int idx = calc_load_write_idx(); 246 241 247 242 atomic_long_add(delta, &calc_load_nohz[idx]); 248 243 } 244 + } 245 + 246 + void calc_load_nohz_start(void) 247 + { 248 + /* 249 + * We're going into NO_HZ mode, if there's any pending delta, fold it 250 + * into the pending NO_HZ delta. 251 + */ 252 + calc_load_nohz_fold(this_rq()); 253 + } 254 + 255 + /* 256 + * Keep track of the load for NOHZ_FULL, must be called between 257 + * calc_load_nohz_{start,stop}(). 258 + */ 259 + void calc_load_nohz_remote(struct rq *rq) 260 + { 261 + calc_load_nohz_fold(rq); 249 262 } 250 263 251 264 void calc_load_nohz_stop(void) ··· 281 268 this_rq->calc_load_update += LOAD_FREQ; 282 269 } 283 270 284 - static long calc_load_nohz_fold(void) 271 + static long calc_load_nohz_read(void) 285 272 { 286 273 int idx = calc_load_read_idx(); 287 274 long delta = 0; ··· 336 323 } 337 324 #else /* !CONFIG_NO_HZ_COMMON */ 338 325 339 - static inline long calc_load_nohz_fold(void) { return 0; } 326 + static inline long calc_load_nohz_read(void) { return 0; } 340 327 static inline void calc_global_nohz(void) { } 341 328 342 329 #endif /* CONFIG_NO_HZ_COMMON */ ··· 359 346 /* 360 347 * Fold the 'old' NO_HZ-delta to include all NO_HZ CPUs. 361 348 */ 362 - delta = calc_load_nohz_fold(); 349 + delta = calc_load_nohz_read(); 363 350 if (delta) 364 351 atomic_long_add(delta, &calc_load_tasks); 365 352
+3
kernel/sched/psi.c
··· 1199 1199 if (static_branch_likely(&psi_disabled)) 1200 1200 return -EOPNOTSUPP; 1201 1201 1202 + if (!nbytes) 1203 + return -EINVAL; 1204 + 1202 1205 buf_size = min(nbytes, sizeof(buf)); 1203 1206 if (copy_from_user(buf, user_buf, buf_size)) 1204 1207 return -EFAULT;
+14 -1
kernel/sched/sched.h
··· 896 896 */ 897 897 unsigned long nr_uninterruptible; 898 898 899 - struct task_struct *curr; 899 + struct task_struct __rcu *curr; 900 900 struct task_struct *idle; 901 901 struct task_struct *stop; 902 902 unsigned long next_balance; ··· 2477 2477 struct mm_struct *prev_mm, 2478 2478 struct mm_struct *next_mm) 2479 2479 { 2480 + } 2481 + #endif 2482 + 2483 + #ifdef CONFIG_SMP 2484 + static inline bool is_per_cpu_kthread(struct task_struct *p) 2485 + { 2486 + if (!(p->flags & PF_KTHREAD)) 2487 + return false; 2488 + 2489 + if (p->nr_cpus_allowed != 1) 2490 + return false; 2491 + 2492 + return true; 2480 2493 } 2481 2494 #endif
+86 -141
kernel/trace/trace_events_hist.c
··· 1798 1798 } 1799 1799 EXPORT_SYMBOL_GPL(synth_event_cmd_init); 1800 1800 1801 + static inline int 1802 + __synth_event_trace_start(struct trace_event_file *file, 1803 + struct synth_event_trace_state *trace_state) 1804 + { 1805 + int entry_size, fields_size = 0; 1806 + int ret = 0; 1807 + 1808 + /* 1809 + * Normal event tracing doesn't get called at all unless the 1810 + * ENABLED bit is set (which attaches the probe thus allowing 1811 + * this code to be called, etc). Because this is called 1812 + * directly by the user, we don't have that but we still need 1813 + * to honor not logging when disabled. For the the iterated 1814 + * trace case, we save the enabed state upon start and just 1815 + * ignore the following data calls. 1816 + */ 1817 + if (!(file->flags & EVENT_FILE_FL_ENABLED) || 1818 + trace_trigger_soft_disabled(file)) { 1819 + trace_state->disabled = true; 1820 + ret = -ENOENT; 1821 + goto out; 1822 + } 1823 + 1824 + trace_state->event = file->event_call->data; 1825 + 1826 + fields_size = trace_state->event->n_u64 * sizeof(u64); 1827 + 1828 + /* 1829 + * Avoid ring buffer recursion detection, as this event 1830 + * is being performed within another event. 1831 + */ 1832 + trace_state->buffer = file->tr->array_buffer.buffer; 1833 + ring_buffer_nest_start(trace_state->buffer); 1834 + 1835 + entry_size = sizeof(*trace_state->entry) + fields_size; 1836 + trace_state->entry = trace_event_buffer_reserve(&trace_state->fbuffer, 1837 + file, 1838 + entry_size); 1839 + if (!trace_state->entry) { 1840 + ring_buffer_nest_end(trace_state->buffer); 1841 + ret = -EINVAL; 1842 + } 1843 + out: 1844 + return ret; 1845 + } 1846 + 1847 + static inline void 1848 + __synth_event_trace_end(struct synth_event_trace_state *trace_state) 1849 + { 1850 + trace_event_buffer_commit(&trace_state->fbuffer); 1851 + 1852 + ring_buffer_nest_end(trace_state->buffer); 1853 + } 1854 + 1801 1855 /** 1802 1856 * synth_event_trace - Trace a synthetic event 1803 1857 * @file: The trace_event_file representing the synthetic event ··· 1873 1819 */ 1874 1820 int synth_event_trace(struct trace_event_file *file, unsigned int n_vals, ...) 1875 1821 { 1876 - struct trace_event_buffer fbuffer; 1877 - struct synth_trace_event *entry; 1878 - struct trace_buffer *buffer; 1879 - struct synth_event *event; 1822 + struct synth_event_trace_state state; 1880 1823 unsigned int i, n_u64; 1881 - int fields_size = 0; 1882 1824 va_list args; 1883 - int ret = 0; 1825 + int ret; 1884 1826 1885 - /* 1886 - * Normal event generation doesn't get called at all unless 1887 - * the ENABLED bit is set (which attaches the probe thus 1888 - * allowing this code to be called, etc). Because this is 1889 - * called directly by the user, we don't have that but we 1890 - * still need to honor not logging when disabled. 1891 - */ 1892 - if (!(file->flags & EVENT_FILE_FL_ENABLED)) 1893 - return 0; 1894 - 1895 - event = file->event_call->data; 1896 - 1897 - if (n_vals != event->n_fields) 1898 - return -EINVAL; 1899 - 1900 - if (trace_trigger_soft_disabled(file)) 1901 - return -EINVAL; 1902 - 1903 - fields_size = event->n_u64 * sizeof(u64); 1904 - 1905 - /* 1906 - * Avoid ring buffer recursion detection, as this event 1907 - * is being performed within another event. 1908 - */ 1909 - buffer = file->tr->array_buffer.buffer; 1910 - ring_buffer_nest_start(buffer); 1911 - 1912 - entry = trace_event_buffer_reserve(&fbuffer, file, 1913 - sizeof(*entry) + fields_size); 1914 - if (!entry) { 1915 - ret = -EINVAL; 1916 - goto out; 1827 + ret = __synth_event_trace_start(file, &state); 1828 + if (ret) { 1829 + if (ret == -ENOENT) 1830 + ret = 0; /* just disabled, not really an error */ 1831 + return ret; 1917 1832 } 1918 1833 1919 1834 va_start(args, n_vals); 1920 - for (i = 0, n_u64 = 0; i < event->n_fields; i++) { 1835 + for (i = 0, n_u64 = 0; i < state.event->n_fields; i++) { 1921 1836 u64 val; 1922 1837 1923 1838 val = va_arg(args, u64); 1924 1839 1925 - if (event->fields[i]->is_string) { 1840 + if (state.event->fields[i]->is_string) { 1926 1841 char *str_val = (char *)(long)val; 1927 - char *str_field = (char *)&entry->fields[n_u64]; 1842 + char *str_field = (char *)&state.entry->fields[n_u64]; 1928 1843 1929 1844 strscpy(str_field, str_val, STR_VAR_LEN_MAX); 1930 1845 n_u64 += STR_VAR_LEN_MAX / sizeof(u64); 1931 1846 } else { 1932 - entry->fields[n_u64] = val; 1847 + state.entry->fields[n_u64] = val; 1933 1848 n_u64++; 1934 1849 } 1935 1850 } 1936 1851 va_end(args); 1937 1852 1938 - trace_event_buffer_commit(&fbuffer); 1939 - out: 1940 - ring_buffer_nest_end(buffer); 1853 + __synth_event_trace_end(&state); 1941 1854 1942 1855 return ret; 1943 1856 } ··· 1931 1910 int synth_event_trace_array(struct trace_event_file *file, u64 *vals, 1932 1911 unsigned int n_vals) 1933 1912 { 1934 - struct trace_event_buffer fbuffer; 1935 - struct synth_trace_event *entry; 1936 - struct trace_buffer *buffer; 1937 - struct synth_event *event; 1913 + struct synth_event_trace_state state; 1938 1914 unsigned int i, n_u64; 1939 - int fields_size = 0; 1940 - int ret = 0; 1915 + int ret; 1941 1916 1942 - /* 1943 - * Normal event generation doesn't get called at all unless 1944 - * the ENABLED bit is set (which attaches the probe thus 1945 - * allowing this code to be called, etc). Because this is 1946 - * called directly by the user, we don't have that but we 1947 - * still need to honor not logging when disabled. 1948 - */ 1949 - if (!(file->flags & EVENT_FILE_FL_ENABLED)) 1950 - return 0; 1951 - 1952 - event = file->event_call->data; 1953 - 1954 - if (n_vals != event->n_fields) 1955 - return -EINVAL; 1956 - 1957 - if (trace_trigger_soft_disabled(file)) 1958 - return -EINVAL; 1959 - 1960 - fields_size = event->n_u64 * sizeof(u64); 1961 - 1962 - /* 1963 - * Avoid ring buffer recursion detection, as this event 1964 - * is being performed within another event. 1965 - */ 1966 - buffer = file->tr->array_buffer.buffer; 1967 - ring_buffer_nest_start(buffer); 1968 - 1969 - entry = trace_event_buffer_reserve(&fbuffer, file, 1970 - sizeof(*entry) + fields_size); 1971 - if (!entry) { 1972 - ret = -EINVAL; 1973 - goto out; 1917 + ret = __synth_event_trace_start(file, &state); 1918 + if (ret) { 1919 + if (ret == -ENOENT) 1920 + ret = 0; /* just disabled, not really an error */ 1921 + return ret; 1974 1922 } 1975 1923 1976 - for (i = 0, n_u64 = 0; i < event->n_fields; i++) { 1977 - if (event->fields[i]->is_string) { 1924 + for (i = 0, n_u64 = 0; i < state.event->n_fields; i++) { 1925 + if (state.event->fields[i]->is_string) { 1978 1926 char *str_val = (char *)(long)vals[i]; 1979 - char *str_field = (char *)&entry->fields[n_u64]; 1927 + char *str_field = (char *)&state.entry->fields[n_u64]; 1980 1928 1981 1929 strscpy(str_field, str_val, STR_VAR_LEN_MAX); 1982 1930 n_u64 += STR_VAR_LEN_MAX / sizeof(u64); 1983 1931 } else { 1984 - entry->fields[n_u64] = vals[i]; 1932 + state.entry->fields[n_u64] = vals[i]; 1985 1933 n_u64++; 1986 1934 } 1987 1935 } 1988 1936 1989 - trace_event_buffer_commit(&fbuffer); 1990 - out: 1991 - ring_buffer_nest_end(buffer); 1937 + __synth_event_trace_end(&state); 1992 1938 1993 1939 return ret; 1994 1940 } ··· 1992 2004 int synth_event_trace_start(struct trace_event_file *file, 1993 2005 struct synth_event_trace_state *trace_state) 1994 2006 { 1995 - struct synth_trace_event *entry; 1996 - int fields_size = 0; 1997 - int ret = 0; 2007 + int ret; 1998 2008 1999 - if (!trace_state) { 2000 - ret = -EINVAL; 2001 - goto out; 2002 - } 2009 + if (!trace_state) 2010 + return -EINVAL; 2003 2011 2004 2012 memset(trace_state, '\0', sizeof(*trace_state)); 2005 2013 2006 - /* 2007 - * Normal event tracing doesn't get called at all unless the 2008 - * ENABLED bit is set (which attaches the probe thus allowing 2009 - * this code to be called, etc). Because this is called 2010 - * directly by the user, we don't have that but we still need 2011 - * to honor not logging when disabled. For the the iterated 2012 - * trace case, we save the enabed state upon start and just 2013 - * ignore the following data calls. 2014 - */ 2015 - if (!(file->flags & EVENT_FILE_FL_ENABLED)) { 2016 - trace_state->enabled = false; 2017 - goto out; 2018 - } 2014 + ret = __synth_event_trace_start(file, trace_state); 2015 + if (ret == -ENOENT) 2016 + ret = 0; /* just disabled, not really an error */ 2019 2017 2020 - trace_state->enabled = true; 2021 - 2022 - trace_state->event = file->event_call->data; 2023 - 2024 - if (trace_trigger_soft_disabled(file)) { 2025 - ret = -EINVAL; 2026 - goto out; 2027 - } 2028 - 2029 - fields_size = trace_state->event->n_u64 * sizeof(u64); 2030 - 2031 - /* 2032 - * Avoid ring buffer recursion detection, as this event 2033 - * is being performed within another event. 2034 - */ 2035 - trace_state->buffer = file->tr->array_buffer.buffer; 2036 - ring_buffer_nest_start(trace_state->buffer); 2037 - 2038 - entry = trace_event_buffer_reserve(&trace_state->fbuffer, file, 2039 - sizeof(*entry) + fields_size); 2040 - if (!entry) { 2041 - ret = -EINVAL; 2042 - goto out; 2043 - } 2044 - 2045 - trace_state->entry = entry; 2046 - out: 2047 2018 return ret; 2048 2019 } 2049 2020 EXPORT_SYMBOL_GPL(synth_event_trace_start); ··· 2035 2088 trace_state->add_next = true; 2036 2089 } 2037 2090 2038 - if (!trace_state->enabled) 2091 + if (trace_state->disabled) 2039 2092 goto out; 2040 2093 2041 2094 event = trace_state->event; ··· 2170 2223 if (!trace_state) 2171 2224 return -EINVAL; 2172 2225 2173 - trace_event_buffer_commit(&trace_state->fbuffer); 2174 - 2175 - ring_buffer_nest_end(trace_state->buffer); 2226 + __synth_event_trace_end(trace_state); 2176 2227 2177 2228 return 0; 2178 2229 }
+1 -1
kernel/trace/trace_kprobe.c
··· 1012 1012 { 1013 1013 struct dynevent_arg arg; 1014 1014 va_list args; 1015 - int ret; 1015 + int ret = 0; 1016 1016 1017 1017 if (cmd->type != DYNEVENT_TYPE_KPROBE) 1018 1018 return -EINVAL;
-3
lib/Kconfig
··· 573 573 config LIBFDT 574 574 bool 575 575 576 - config LIBXBC 577 - bool 578 - 579 576 config OID_REGISTRY 580 577 tristate 581 578 help
+1 -1
lib/Makefile
··· 230 230 $(eval CFLAGS_$(file) = -I $(srctree)/scripts/dtc/libfdt)) 231 231 lib-$(CONFIG_LIBFDT) += $(libfdt_files) 232 232 233 - lib-$(CONFIG_LIBXBC) += bootconfig.o 233 + lib-$(CONFIG_BOOT_CONFIG) += bootconfig.o 234 234 235 235 obj-$(CONFIG_RBTREE_TEST) += rbtree_test.o 236 236 obj-$(CONFIG_INTERVAL_TREE_TEST) += interval_tree_test.o
+12 -3
lib/bootconfig.c
··· 6 6 7 7 #define pr_fmt(fmt) "bootconfig: " fmt 8 8 9 + #include <linux/bootconfig.h> 9 10 #include <linux/bug.h> 10 11 #include <linux/ctype.h> 11 12 #include <linux/errno.h> 12 13 #include <linux/kernel.h> 14 + #include <linux/memblock.h> 13 15 #include <linux/printk.h> 14 - #include <linux/bootconfig.h> 15 16 #include <linux/string.h> 16 17 17 18 /* ··· 24 23 * node (for array). 25 24 */ 26 25 27 - static struct xbc_node xbc_nodes[XBC_NODE_MAX] __initdata; 26 + static struct xbc_node *xbc_nodes __initdata; 28 27 static int xbc_node_num __initdata; 29 28 static char *xbc_data __initdata; 30 29 static size_t xbc_data_size __initdata; ··· 720 719 xbc_data = NULL; 721 720 xbc_data_size = 0; 722 721 xbc_node_num = 0; 723 - memset(xbc_nodes, 0, sizeof(xbc_nodes)); 722 + memblock_free(__pa(xbc_nodes), sizeof(struct xbc_node) * XBC_NODE_MAX); 723 + xbc_nodes = NULL; 724 724 } 725 725 726 726 /** ··· 750 748 return -ERANGE; 751 749 } 752 750 751 + xbc_nodes = memblock_alloc(sizeof(struct xbc_node) * XBC_NODE_MAX, 752 + SMP_CACHE_BYTES); 753 + if (!xbc_nodes) { 754 + pr_err("Failed to allocate memory for bootconfig nodes.\n"); 755 + return -ENOMEM; 756 + } 757 + memset(xbc_nodes, 0, sizeof(struct xbc_node) * XBC_NODE_MAX); 753 758 xbc_data = buf; 754 759 xbc_data_size = ret + 1; 755 760 last_parent = NULL;
+2 -2
net/core/dev.c
··· 4527 4527 /* Reinjected packets coming from act_mirred or similar should 4528 4528 * not get XDP generic processing. 4529 4529 */ 4530 - if (skb_cloned(skb) || skb_is_tc_redirected(skb)) 4530 + if (skb_is_tc_redirected(skb)) 4531 4531 return XDP_PASS; 4532 4532 4533 4533 /* XDP packets must be linear and must have sufficient headroom 4534 4534 * of XDP_PACKET_HEADROOM bytes. This is the guarantee that also 4535 4535 * native XDP provides, thus we need to do it here as well. 4536 4536 */ 4537 - if (skb_is_nonlinear(skb) || 4537 + if (skb_cloned(skb) || skb_is_nonlinear(skb) || 4538 4538 skb_headroom(skb) < XDP_PACKET_HEADROOM) { 4539 4539 int hroom = XDP_PACKET_HEADROOM - skb_headroom(skb); 4540 4540 int troom = skb->tail + skb->data_len - skb->end;
+8 -14
net/core/page_pool.c
··· 99 99 static void __page_pool_return_page(struct page_pool *pool, struct page *page); 100 100 101 101 noinline 102 - static struct page *page_pool_refill_alloc_cache(struct page_pool *pool, 103 - bool refill) 102 + static struct page *page_pool_refill_alloc_cache(struct page_pool *pool) 104 103 { 105 104 struct ptr_ring *r = &pool->ring; 106 105 struct page *page; ··· 140 141 page = NULL; 141 142 break; 142 143 } 143 - } while (pool->alloc.count < PP_ALLOC_CACHE_REFILL && 144 - refill); 144 + } while (pool->alloc.count < PP_ALLOC_CACHE_REFILL); 145 145 146 146 /* Return last page */ 147 147 if (likely(pool->alloc.count > 0)) ··· 153 155 /* fast path */ 154 156 static struct page *__page_pool_get_cached(struct page_pool *pool) 155 157 { 156 - bool refill = false; 157 158 struct page *page; 158 159 159 - /* Test for safe-context, caller should provide this guarantee */ 160 - if (likely(in_serving_softirq())) { 161 - if (likely(pool->alloc.count)) { 162 - /* Fast-path */ 163 - page = pool->alloc.cache[--pool->alloc.count]; 164 - return page; 165 - } 166 - refill = true; 160 + /* Caller MUST guarantee safe non-concurrent access, e.g. softirq */ 161 + if (likely(pool->alloc.count)) { 162 + /* Fast-path */ 163 + page = pool->alloc.cache[--pool->alloc.count]; 164 + } else { 165 + page = page_pool_refill_alloc_cache(pool); 167 166 } 168 167 169 - page = page_pool_refill_alloc_cache(pool, refill); 170 168 return page; 171 169 } 172 170
+1 -1
net/dsa/tag_ar9331.c
··· 31 31 __le16 *phdr; 32 32 u16 hdr; 33 33 34 - if (skb_cow_head(skb, 0) < 0) 34 + if (skb_cow_head(skb, AR9331_HDR_LEN) < 0) 35 35 return NULL; 36 36 37 37 phdr = skb_push(skb, AR9331_HDR_LEN);
+1 -1
net/dsa/tag_qca.c
··· 33 33 struct dsa_port *dp = dsa_slave_to_port(dev); 34 34 u16 *phdr, hdr; 35 35 36 - if (skb_cow_head(skb, 0) < 0) 36 + if (skb_cow_head(skb, QCA_HDR_LEN) < 0) 37 37 return NULL; 38 38 39 39 skb_push(skb, QCA_HDR_LEN);
+33
net/ipv4/icmp.c
··· 748 748 } 749 749 EXPORT_SYMBOL(__icmp_send); 750 750 751 + #if IS_ENABLED(CONFIG_NF_NAT) 752 + #include <net/netfilter/nf_conntrack.h> 753 + void icmp_ndo_send(struct sk_buff *skb_in, int type, int code, __be32 info) 754 + { 755 + struct sk_buff *cloned_skb = NULL; 756 + enum ip_conntrack_info ctinfo; 757 + struct nf_conn *ct; 758 + __be32 orig_ip; 759 + 760 + ct = nf_ct_get(skb_in, &ctinfo); 761 + if (!ct || !(ct->status & IPS_SRC_NAT)) { 762 + icmp_send(skb_in, type, code, info); 763 + return; 764 + } 765 + 766 + if (skb_shared(skb_in)) 767 + skb_in = cloned_skb = skb_clone(skb_in, GFP_ATOMIC); 768 + 769 + if (unlikely(!skb_in || skb_network_header(skb_in) < skb_in->head || 770 + (skb_network_header(skb_in) + sizeof(struct iphdr)) > 771 + skb_tail_pointer(skb_in) || skb_ensure_writable(skb_in, 772 + skb_network_offset(skb_in) + sizeof(struct iphdr)))) 773 + goto out; 774 + 775 + orig_ip = ip_hdr(skb_in)->saddr; 776 + ip_hdr(skb_in)->saddr = ct->tuplehash[0].tuple.src.u3.ip; 777 + icmp_send(skb_in, type, code, info); 778 + ip_hdr(skb_in)->saddr = orig_ip; 779 + out: 780 + consume_skb(cloned_skb); 781 + } 782 + EXPORT_SYMBOL(icmp_ndo_send); 783 + #endif 751 784 752 785 static void icmp_socket_deliver(struct sk_buff *skb, u32 info) 753 786 {
+34
net/ipv6/ip6_icmp.c
··· 45 45 rcu_read_unlock(); 46 46 } 47 47 EXPORT_SYMBOL(icmpv6_send); 48 + 49 + #if IS_ENABLED(CONFIG_NF_NAT) 50 + #include <net/netfilter/nf_conntrack.h> 51 + void icmpv6_ndo_send(struct sk_buff *skb_in, u8 type, u8 code, __u32 info) 52 + { 53 + struct sk_buff *cloned_skb = NULL; 54 + enum ip_conntrack_info ctinfo; 55 + struct in6_addr orig_ip; 56 + struct nf_conn *ct; 57 + 58 + ct = nf_ct_get(skb_in, &ctinfo); 59 + if (!ct || !(ct->status & IPS_SRC_NAT)) { 60 + icmpv6_send(skb_in, type, code, info); 61 + return; 62 + } 63 + 64 + if (skb_shared(skb_in)) 65 + skb_in = cloned_skb = skb_clone(skb_in, GFP_ATOMIC); 66 + 67 + if (unlikely(!skb_in || skb_network_header(skb_in) < skb_in->head || 68 + (skb_network_header(skb_in) + sizeof(struct ipv6hdr)) > 69 + skb_tail_pointer(skb_in) || skb_ensure_writable(skb_in, 70 + skb_network_offset(skb_in) + sizeof(struct ipv6hdr)))) 71 + goto out; 72 + 73 + orig_ip = ipv6_hdr(skb_in)->saddr; 74 + ipv6_hdr(skb_in)->saddr = ct->tuplehash[0].tuple.src.u3.in6; 75 + icmpv6_send(skb_in, type, code, info); 76 + ipv6_hdr(skb_in)->saddr = orig_ip; 77 + out: 78 + consume_skb(cloned_skb); 79 + } 80 + EXPORT_SYMBOL(icmpv6_ndo_send); 81 + #endif 48 82 #endif
+47 -21
net/ipv6/ip6_tunnel.c
··· 121 121 122 122 /** 123 123 * ip6_tnl_lookup - fetch tunnel matching the end-point addresses 124 + * @link: ifindex of underlying interface 124 125 * @remote: the address of the tunnel exit-point 125 126 * @local: the address of the tunnel entry-point 126 127 * ··· 135 134 for (t = rcu_dereference(start); t; t = rcu_dereference(t->next)) 136 135 137 136 static struct ip6_tnl * 138 - ip6_tnl_lookup(struct net *net, const struct in6_addr *remote, const struct in6_addr *local) 137 + ip6_tnl_lookup(struct net *net, int link, 138 + const struct in6_addr *remote, const struct in6_addr *local) 139 139 { 140 140 unsigned int hash = HASH(remote, local); 141 - struct ip6_tnl *t; 141 + struct ip6_tnl *t, *cand = NULL; 142 142 struct ip6_tnl_net *ip6n = net_generic(net, ip6_tnl_net_id); 143 143 struct in6_addr any; 144 144 145 145 for_each_ip6_tunnel_rcu(ip6n->tnls_r_l[hash]) { 146 - if (ipv6_addr_equal(local, &t->parms.laddr) && 147 - ipv6_addr_equal(remote, &t->parms.raddr) && 148 - (t->dev->flags & IFF_UP)) 146 + if (!ipv6_addr_equal(local, &t->parms.laddr) || 147 + !ipv6_addr_equal(remote, &t->parms.raddr) || 148 + !(t->dev->flags & IFF_UP)) 149 + continue; 150 + 151 + if (link == t->parms.link) 149 152 return t; 153 + else 154 + cand = t; 150 155 } 151 156 152 157 memset(&any, 0, sizeof(any)); 153 158 hash = HASH(&any, local); 154 159 for_each_ip6_tunnel_rcu(ip6n->tnls_r_l[hash]) { 155 - if (ipv6_addr_equal(local, &t->parms.laddr) && 156 - ipv6_addr_any(&t->parms.raddr) && 157 - (t->dev->flags & IFF_UP)) 160 + if (!ipv6_addr_equal(local, &t->parms.laddr) || 161 + !ipv6_addr_any(&t->parms.raddr) || 162 + !(t->dev->flags & IFF_UP)) 163 + continue; 164 + 165 + if (link == t->parms.link) 158 166 return t; 167 + else if (!cand) 168 + cand = t; 159 169 } 160 170 161 171 hash = HASH(remote, &any); 162 172 for_each_ip6_tunnel_rcu(ip6n->tnls_r_l[hash]) { 163 - if (ipv6_addr_equal(remote, &t->parms.raddr) && 164 - ipv6_addr_any(&t->parms.laddr) && 165 - (t->dev->flags & IFF_UP)) 173 + if (!ipv6_addr_equal(remote, &t->parms.raddr) || 174 + !ipv6_addr_any(&t->parms.laddr) || 175 + !(t->dev->flags & IFF_UP)) 176 + continue; 177 + 178 + if (link == t->parms.link) 166 179 return t; 180 + else if (!cand) 181 + cand = t; 167 182 } 183 + 184 + if (cand) 185 + return cand; 168 186 169 187 t = rcu_dereference(ip6n->collect_md_tun); 170 188 if (t && t->dev->flags & IFF_UP) ··· 371 351 (t = rtnl_dereference(*tp)) != NULL; 372 352 tp = &t->next) { 373 353 if (ipv6_addr_equal(local, &t->parms.laddr) && 374 - ipv6_addr_equal(remote, &t->parms.raddr)) { 354 + ipv6_addr_equal(remote, &t->parms.raddr) && 355 + p->link == t->parms.link) { 375 356 if (create) 376 357 return ERR_PTR(-EEXIST); 377 358 ··· 506 485 processing of the error. */ 507 486 508 487 rcu_read_lock(); 509 - t = ip6_tnl_lookup(dev_net(skb->dev), &ipv6h->daddr, &ipv6h->saddr); 488 + t = ip6_tnl_lookup(dev_net(skb->dev), skb->dev->ifindex, &ipv6h->daddr, &ipv6h->saddr); 510 489 if (!t) 511 490 goto out; 512 491 ··· 908 887 int ret = -1; 909 888 910 889 rcu_read_lock(); 911 - t = ip6_tnl_lookup(dev_net(skb->dev), &ipv6h->saddr, &ipv6h->daddr); 890 + t = ip6_tnl_lookup(dev_net(skb->dev), skb->dev->ifindex, &ipv6h->saddr, &ipv6h->daddr); 912 891 913 892 if (t) { 914 893 u8 tproto = READ_ONCE(t->parms.proto); ··· 1441 1420 static void ip6_tnl_link_config(struct ip6_tnl *t) 1442 1421 { 1443 1422 struct net_device *dev = t->dev; 1423 + struct net_device *tdev = NULL; 1444 1424 struct __ip6_tnl_parm *p = &t->parms; 1445 1425 struct flowi6 *fl6 = &t->fl.u.ip6; 1426 + unsigned int mtu; 1446 1427 int t_hlen; 1447 1428 1448 1429 memcpy(dev->dev_addr, &p->laddr, sizeof(struct in6_addr)); ··· 1480 1457 struct rt6_info *rt = rt6_lookup(t->net, 1481 1458 &p->raddr, &p->laddr, 1482 1459 p->link, NULL, strict); 1460 + if (rt) { 1461 + tdev = rt->dst.dev; 1462 + ip6_rt_put(rt); 1463 + } 1483 1464 1484 - if (!rt) 1485 - return; 1465 + if (!tdev && p->link) 1466 + tdev = __dev_get_by_index(t->net, p->link); 1486 1467 1487 - if (rt->dst.dev) { 1488 - dev->hard_header_len = rt->dst.dev->hard_header_len + 1489 - t_hlen; 1468 + if (tdev) { 1469 + dev->hard_header_len = tdev->hard_header_len + t_hlen; 1470 + mtu = min_t(unsigned int, tdev->mtu, IP6_MAX_MTU); 1490 1471 1491 - dev->mtu = rt->dst.dev->mtu - t_hlen; 1472 + dev->mtu = mtu - t_hlen; 1492 1473 if (!(t->parms.flags & IP6_TNL_F_IGN_ENCAP_LIMIT)) 1493 1474 dev->mtu -= 8; 1494 1475 1495 1476 if (dev->mtu < IPV6_MIN_MTU) 1496 1477 dev->mtu = IPV6_MIN_MTU; 1497 1478 } 1498 - ip6_rt_put(rt); 1499 1479 } 1500 1480 } 1501 1481
+1 -1
net/mac80211/cfg.c
··· 3450 3450 3451 3451 spin_lock_irqsave(&local->ack_status_lock, spin_flags); 3452 3452 id = idr_alloc(&local->ack_status_frames, ack_skb, 3453 - 1, 0x40, GFP_ATOMIC); 3453 + 1, 0x2000, GFP_ATOMIC); 3454 3454 spin_unlock_irqrestore(&local->ack_status_lock, spin_flags); 3455 3455 3456 3456 if (id < 0) {
+4 -4
net/mac80211/mlme.c
··· 8 8 * Copyright 2007, Michael Wu <flamingice@sourmilk.net> 9 9 * Copyright 2013-2014 Intel Mobile Communications GmbH 10 10 * Copyright (C) 2015 - 2017 Intel Deutschland GmbH 11 - * Copyright (C) 2018 - 2019 Intel Corporation 11 + * Copyright (C) 2018 - 2020 Intel Corporation 12 12 */ 13 13 14 14 #include <linux/delay.h> ··· 1311 1311 if (!res) { 1312 1312 ch_switch.timestamp = timestamp; 1313 1313 ch_switch.device_timestamp = device_timestamp; 1314 - ch_switch.block_tx = beacon ? csa_ie.mode : 0; 1314 + ch_switch.block_tx = csa_ie.mode; 1315 1315 ch_switch.chandef = csa_ie.chandef; 1316 1316 ch_switch.count = csa_ie.count; 1317 1317 ch_switch.delay = csa_ie.max_switch_time; ··· 1404 1404 1405 1405 sdata->vif.csa_active = true; 1406 1406 sdata->csa_chandef = csa_ie.chandef; 1407 - sdata->csa_block_tx = ch_switch.block_tx; 1407 + sdata->csa_block_tx = csa_ie.mode; 1408 1408 ifmgd->csa_ignored_same_chan = false; 1409 1409 1410 1410 if (sdata->csa_block_tx) ··· 1438 1438 * reset when the disconnection worker runs. 1439 1439 */ 1440 1440 sdata->vif.csa_active = true; 1441 - sdata->csa_block_tx = ch_switch.block_tx; 1441 + sdata->csa_block_tx = csa_ie.mode; 1442 1442 1443 1443 ieee80211_queue_work(&local->hw, &ifmgd->csa_connection_drop_work); 1444 1444 mutex_unlock(&local->chanctx_mtx);
+1 -1
net/mac80211/tx.c
··· 2442 2442 2443 2443 spin_lock_irqsave(&local->ack_status_lock, flags); 2444 2444 id = idr_alloc(&local->ack_status_frames, ack_skb, 2445 - 1, 0x40, GFP_ATOMIC); 2445 + 1, 0x2000, GFP_ATOMIC); 2446 2446 spin_unlock_irqrestore(&local->ack_status_lock, flags); 2447 2447 2448 2448 if (id >= 0) {
+26 -8
net/mac80211/util.c
··· 1063 1063 elem_parse_failed = true; 1064 1064 break; 1065 1065 case WLAN_EID_VHT_OPERATION: 1066 - if (elen >= sizeof(struct ieee80211_vht_operation)) 1066 + if (elen >= sizeof(struct ieee80211_vht_operation)) { 1067 1067 elems->vht_operation = (void *)pos; 1068 - else 1069 - elem_parse_failed = true; 1068 + if (calc_crc) 1069 + crc = crc32_be(crc, pos - 2, elen + 2); 1070 + break; 1071 + } 1072 + elem_parse_failed = true; 1070 1073 break; 1071 1074 case WLAN_EID_OPMODE_NOTIF: 1072 - if (elen > 0) 1075 + if (elen > 0) { 1073 1076 elems->opmode_notif = pos; 1074 - else 1075 - elem_parse_failed = true; 1077 + if (calc_crc) 1078 + crc = crc32_be(crc, pos - 2, elen + 2); 1079 + break; 1080 + } 1081 + elem_parse_failed = true; 1076 1082 break; 1077 1083 case WLAN_EID_MESH_ID: 1078 1084 elems->mesh_id = pos; ··· 2993 2987 int cf0, cf1; 2994 2988 int ccfs0, ccfs1, ccfs2; 2995 2989 int ccf0, ccf1; 2990 + u32 vht_cap; 2991 + bool support_80_80 = false; 2992 + bool support_160 = false; 2996 2993 2997 2994 if (!oper || !htop) 2998 2995 return false; 2999 2996 2997 + vht_cap = hw->wiphy->bands[chandef->chan->band]->vht_cap.cap; 2998 + support_160 = (vht_cap & (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_MASK | 2999 + IEEE80211_VHT_CAP_EXT_NSS_BW_MASK)); 3000 + support_80_80 = ((vht_cap & 3001 + IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ) || 3002 + (vht_cap & IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ && 3003 + vht_cap & IEEE80211_VHT_CAP_EXT_NSS_BW_MASK) || 3004 + ((vht_cap & IEEE80211_VHT_CAP_EXT_NSS_BW_MASK) >> 3005 + IEEE80211_VHT_CAP_EXT_NSS_BW_SHIFT > 1)); 3000 3006 ccfs0 = oper->center_freq_seg0_idx; 3001 3007 ccfs1 = oper->center_freq_seg1_idx; 3002 3008 ccfs2 = (le16_to_cpu(htop->operation_mode) & ··· 3036 3018 unsigned int diff; 3037 3019 3038 3020 diff = abs(ccf1 - ccf0); 3039 - if (diff == 8) { 3021 + if ((diff == 8) && support_160) { 3040 3022 new.width = NL80211_CHAN_WIDTH_160; 3041 3023 new.center_freq1 = cf1; 3042 - } else if (diff > 8) { 3024 + } else if ((diff > 8) && support_80_80) { 3043 3025 new.width = NL80211_CHAN_WIDTH_80P80; 3044 3026 new.center_freq2 = cf1; 3045 3027 }
+1 -1
net/mptcp/protocol.c
··· 643 643 } 644 644 #endif 645 645 646 - struct sock *mptcp_sk_clone_lock(const struct sock *sk) 646 + static struct sock *mptcp_sk_clone_lock(const struct sock *sk) 647 647 { 648 648 struct sock *nsk = sk_clone_lock(sk, GFP_ATOMIC); 649 649
+1
net/sched/cls_flower.c
··· 691 691 .len = 128 / BITS_PER_BYTE }, 692 692 [TCA_FLOWER_KEY_CT_LABELS_MASK] = { .type = NLA_BINARY, 693 693 .len = 128 / BITS_PER_BYTE }, 694 + [TCA_FLOWER_FLAGS] = { .type = NLA_U32 }, 694 695 }; 695 696 696 697 static const struct nla_policy
+1
net/sched/cls_matchall.c
··· 157 157 static const struct nla_policy mall_policy[TCA_MATCHALL_MAX + 1] = { 158 158 [TCA_MATCHALL_UNSPEC] = { .type = NLA_UNSPEC }, 159 159 [TCA_MATCHALL_CLASSID] = { .type = NLA_U32 }, 160 + [TCA_MATCHALL_FLAGS] = { .type = NLA_U32 }, 160 161 }; 161 162 162 163 static int mall_set_parms(struct net *net, struct tcf_proto *tp,
+2
net/smc/af_smc.c
··· 470 470 if (smc->sk.sk_socket && smc->sk.sk_socket->file) { 471 471 smc->clcsock->file = smc->sk.sk_socket->file; 472 472 smc->clcsock->file->private_data = smc->clcsock; 473 + smc->clcsock->wq.fasync_list = 474 + smc->sk.sk_socket->wq.fasync_list; 473 475 } 474 476 } 475 477
+3 -1
net/smc/smc_clc.c
··· 372 372 dclc.hdr.length = htons(sizeof(struct smc_clc_msg_decline)); 373 373 dclc.hdr.version = SMC_CLC_V1; 374 374 dclc.hdr.flag = (peer_diag_info == SMC_CLC_DECL_SYNCERR) ? 1 : 0; 375 - memcpy(dclc.id_for_peer, local_systemid, sizeof(local_systemid)); 375 + if (smc->conn.lgr && !smc->conn.lgr->is_smcd) 376 + memcpy(dclc.id_for_peer, local_systemid, 377 + sizeof(local_systemid)); 376 378 dclc.peer_diagnosis = htonl(peer_diag_info); 377 379 memcpy(dclc.trl.eyecatcher, SMC_EYECATCHER, sizeof(SMC_EYECATCHER)); 378 380
+2 -3
net/smc/smc_diag.c
··· 39 39 { 40 40 struct smc_sock *smc = smc_sk(sk); 41 41 42 + memset(r, 0, sizeof(*r)); 42 43 r->diag_family = sk->sk_family; 44 + sock_diag_save_cookie(sk, r->id.idiag_cookie); 43 45 if (!smc->clcsock) 44 46 return; 45 47 r->id.idiag_sport = htons(smc->clcsock->sk->sk_num); 46 48 r->id.idiag_dport = smc->clcsock->sk->sk_dport; 47 49 r->id.idiag_if = smc->clcsock->sk->sk_bound_dev_if; 48 - sock_diag_save_cookie(sk, r->id.idiag_cookie); 49 50 if (sk->sk_protocol == SMCPROTO_SMC) { 50 - memset(&r->id.idiag_src, 0, sizeof(r->id.idiag_src)); 51 - memset(&r->id.idiag_dst, 0, sizeof(r->id.idiag_dst)); 52 51 r->id.idiag_src[0] = smc->clcsock->sk->sk_rcv_saddr; 53 52 r->id.idiag_dst[0] = smc->clcsock->sk->sk_daddr; 54 53 #if IS_ENABLED(CONFIG_IPV6)
+7 -6
net/sunrpc/xprtrdma/frwr_ops.c
··· 288 288 { 289 289 struct rpcrdma_ia *ia = &r_xprt->rx_ia; 290 290 struct ib_reg_wr *reg_wr; 291 + int i, n, dma_nents; 291 292 struct ib_mr *ibmr; 292 - int i, n; 293 293 u8 key; 294 294 295 295 if (nsegs > ia->ri_max_frwr_depth) ··· 313 313 break; 314 314 } 315 315 mr->mr_dir = rpcrdma_data_dir(writing); 316 + mr->mr_nents = i; 316 317 317 - mr->mr_nents = 318 - ib_dma_map_sg(ia->ri_id->device, mr->mr_sg, i, mr->mr_dir); 319 - if (!mr->mr_nents) 318 + dma_nents = ib_dma_map_sg(ia->ri_id->device, mr->mr_sg, mr->mr_nents, 319 + mr->mr_dir); 320 + if (!dma_nents) 320 321 goto out_dmamap_err; 321 322 322 323 ibmr = mr->frwr.fr_mr; 323 - n = ib_map_mr_sg(ibmr, mr->mr_sg, mr->mr_nents, NULL, PAGE_SIZE); 324 - if (unlikely(n != mr->mr_nents)) 324 + n = ib_map_mr_sg(ibmr, mr->mr_sg, dma_nents, NULL, PAGE_SIZE); 325 + if (n != dma_nents) 325 326 goto out_mapmr_err; 326 327 327 328 ibmr->iova &= 0x00000000ffffffff;
+4 -3
net/tipc/node.c
··· 278 278 } 279 279 #endif 280 280 281 - void tipc_node_free(struct rcu_head *rp) 281 + static void tipc_node_free(struct rcu_head *rp) 282 282 { 283 283 struct tipc_node *n = container_of(rp, struct tipc_node, rcu); 284 284 ··· 2798 2798 return 0; 2799 2799 } 2800 2800 2801 - int __tipc_nl_node_set_key(struct sk_buff *skb, struct genl_info *info) 2801 + static int __tipc_nl_node_set_key(struct sk_buff *skb, struct genl_info *info) 2802 2802 { 2803 2803 struct nlattr *attrs[TIPC_NLA_NODE_MAX + 1]; 2804 2804 struct net *net = sock_net(skb->sk); ··· 2875 2875 return err; 2876 2876 } 2877 2877 2878 - int __tipc_nl_node_flush_key(struct sk_buff *skb, struct genl_info *info) 2878 + static int __tipc_nl_node_flush_key(struct sk_buff *skb, 2879 + struct genl_info *info) 2879 2880 { 2880 2881 struct net *net = sock_net(skb->sk); 2881 2882 struct tipc_net *tn = tipc_net(net);
+2
net/tipc/socket.c
··· 2441 2441 return -ETIMEDOUT; 2442 2442 if (signal_pending(current)) 2443 2443 return sock_intr_errno(*timeo_p); 2444 + if (sk->sk_state == TIPC_DISCONNECTING) 2445 + break; 2444 2446 2445 2447 add_wait_queue(sk_sleep(sk), &wait); 2446 2448 done = sk_wait_event(sk, timeo_p, tipc_sk_connected(sk),
+6 -2
net/wireless/ethtool.c
··· 7 7 void cfg80211_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) 8 8 { 9 9 struct wireless_dev *wdev = dev->ieee80211_ptr; 10 + struct device *pdev = wiphy_dev(wdev->wiphy); 10 11 11 - strlcpy(info->driver, wiphy_dev(wdev->wiphy)->driver->name, 12 - sizeof(info->driver)); 12 + if (pdev->driver) 13 + strlcpy(info->driver, pdev->driver->name, 14 + sizeof(info->driver)); 15 + else 16 + strlcpy(info->driver, "N/A", sizeof(info->driver)); 13 17 14 18 strlcpy(info->version, init_utsname()->release, sizeof(info->version)); 15 19
+1
net/wireless/nl80211.c
··· 437 437 [NL80211_ATTR_CONTROL_PORT_NO_ENCRYPT] = { .type = NLA_FLAG }, 438 438 [NL80211_ATTR_CONTROL_PORT_OVER_NL80211] = { .type = NLA_FLAG }, 439 439 [NL80211_ATTR_PRIVACY] = { .type = NLA_FLAG }, 440 + [NL80211_ATTR_STATUS_CODE] = { .type = NLA_U16 }, 440 441 [NL80211_ATTR_CIPHER_SUITE_GROUP] = { .type = NLA_U32 }, 441 442 [NL80211_ATTR_WPA_VERSIONS] = { .type = NLA_U32 }, 442 443 [NL80211_ATTR_PID] = { .type = NLA_U32 },
+3 -3
net/xfrm/xfrm_interface.c
··· 300 300 if (mtu < IPV6_MIN_MTU) 301 301 mtu = IPV6_MIN_MTU; 302 302 303 - icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu); 303 + icmpv6_ndo_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu); 304 304 } else { 305 - icmp_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED, 306 - htonl(mtu)); 305 + icmp_ndo_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED, 306 + htonl(mtu)); 307 307 } 308 308 309 309 dst_release(dst);
+2 -2
scripts/kallsyms.c
··· 210 210 211 211 len = strlen(name) + 1; 212 212 213 - sym = malloc(sizeof(*sym) + len); 213 + sym = malloc(sizeof(*sym) + len + 1); 214 214 if (!sym) { 215 215 fprintf(stderr, "kallsyms failure: " 216 216 "unable to allocate required amount of memory\n"); ··· 219 219 sym->addr = addr; 220 220 sym->len = len; 221 221 sym->sym[0] = type; 222 - memcpy(sym_name(sym), name, len); 222 + strcpy(sym_name(sym), name); 223 223 sym->percpu_absolute = 0; 224 224 225 225 return sym;
+1 -1
security/selinux/hooks.c
··· 698 698 699 699 if (!strcmp(sb->s_type->name, "debugfs") || 700 700 !strcmp(sb->s_type->name, "tracefs") || 701 - !strcmp(sb->s_type->name, "binderfs") || 701 + !strcmp(sb->s_type->name, "binder") || 702 702 !strcmp(sb->s_type->name, "pstore")) 703 703 sbsec->flags |= SE_SBGENFS; 704 704
+3 -9
security/selinux/ss/sidtab.c
··· 518 518 const char *str, u32 str_len) 519 519 { 520 520 struct sidtab_str_cache *cache, *victim = NULL; 521 + unsigned long flags; 521 522 522 523 /* do not cache invalid contexts */ 523 524 if (entry->context.len) 524 525 return; 525 526 526 - /* 527 - * Skip the put operation when in non-task context to avoid the need 528 - * to disable interrupts while holding s->cache_lock. 529 - */ 530 - if (!in_task()) 531 - return; 532 - 533 - spin_lock(&s->cache_lock); 527 + spin_lock_irqsave(&s->cache_lock, flags); 534 528 535 529 cache = rcu_dereference_protected(entry->cache, 536 530 lockdep_is_held(&s->cache_lock)); ··· 555 561 rcu_assign_pointer(entry->cache, cache); 556 562 557 563 out_unlock: 558 - spin_unlock(&s->cache_lock); 564 + spin_unlock_irqrestore(&s->cache_lock, flags); 559 565 kfree_rcu(victim, rcu_member); 560 566 } 561 567
+2 -1
sound/core/pcm_native.c
··· 2594 2594 2595 2595 snd_pcm_drop(substream); 2596 2596 if (substream->hw_opened) { 2597 - do_hw_free(substream); 2597 + if (substream->runtime->status->state != SNDRV_PCM_STATE_OPEN) 2598 + do_hw_free(substream); 2598 2599 substream->ops->close(substream); 2599 2600 substream->hw_opened = 0; 2600 2601 }
+4
sound/pci/hda/patch_realtek.c
··· 2447 2447 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC882_FIXUP_EAPD), 2448 2448 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte EP45-DS3/Z87X-UD3H", ALC889_FIXUP_FRONT_HP_NO_PRESENCE), 2449 2449 SND_PCI_QUIRK(0x1458, 0xa0b8, "Gigabyte AZ370-Gaming", ALC1220_FIXUP_GB_DUAL_CODECS), 2450 + SND_PCI_QUIRK(0x1462, 0x1276, "MSI-GL73", ALC1220_FIXUP_CLEVO_P950), 2450 2451 SND_PCI_QUIRK(0x1462, 0x7350, "MSI-7350", ALC889_FIXUP_CD), 2451 2452 SND_PCI_QUIRK(0x1462, 0xda57, "MSI Z270-Gaming", ALC1220_FIXUP_GB_DUAL_CODECS), 2452 2453 SND_PCI_QUIRK_VENDOR(0x1462, "MSI", ALC882_FIXUP_GPIO3), ··· 5702 5701 break; 5703 5702 case HDA_FIXUP_ACT_INIT: 5704 5703 switch (codec->core.vendor_id) { 5704 + case 0x10ec0215: 5705 5705 case 0x10ec0225: 5706 + case 0x10ec0285: 5706 5707 case 0x10ec0295: 5708 + case 0x10ec0289: 5707 5709 case 0x10ec0299: 5708 5710 alc_write_coef_idx(codec, 0x48, 0xd011); 5709 5711 alc_update_coef_idx(codec, 0x49, 0x007f, 0x0045);
+63 -28
sound/usb/clock.c
··· 151 151 return ret; 152 152 } 153 153 154 + /* 155 + * Assume the clock is valid if clock source supports only one single sample 156 + * rate, the terminal is connected directly to it (there is no clock selector) 157 + * and clock type is internal. This is to deal with some Denon DJ controllers 158 + * that always reports that clock is invalid. 159 + */ 160 + static bool uac_clock_source_is_valid_quirk(struct snd_usb_audio *chip, 161 + struct audioformat *fmt, 162 + int source_id) 163 + { 164 + if (fmt->protocol == UAC_VERSION_2) { 165 + struct uac_clock_source_descriptor *cs_desc = 166 + snd_usb_find_clock_source(chip->ctrl_intf, source_id); 167 + 168 + if (!cs_desc) 169 + return false; 170 + 171 + return (fmt->nr_rates == 1 && 172 + (fmt->clock & 0xff) == cs_desc->bClockID && 173 + (cs_desc->bmAttributes & 0x3) != 174 + UAC_CLOCK_SOURCE_TYPE_EXT); 175 + } 176 + 177 + return false; 178 + } 179 + 154 180 static bool uac_clock_source_is_valid(struct snd_usb_audio *chip, 155 - int protocol, 181 + struct audioformat *fmt, 156 182 int source_id) 157 183 { 158 184 int err; ··· 186 160 struct usb_device *dev = chip->dev; 187 161 u32 bmControls; 188 162 189 - if (protocol == UAC_VERSION_3) { 163 + if (fmt->protocol == UAC_VERSION_3) { 190 164 struct uac3_clock_source_descriptor *cs_desc = 191 165 snd_usb_find_clock_source_v3(chip->ctrl_intf, source_id); 192 166 ··· 220 194 return false; 221 195 } 222 196 223 - return data ? true : false; 197 + if (data) 198 + return true; 199 + else 200 + return uac_clock_source_is_valid_quirk(chip, fmt, source_id); 224 201 } 225 202 226 - static int __uac_clock_find_source(struct snd_usb_audio *chip, int entity_id, 203 + static int __uac_clock_find_source(struct snd_usb_audio *chip, 204 + struct audioformat *fmt, int entity_id, 227 205 unsigned long *visited, bool validate) 228 206 { 229 207 struct uac_clock_source_descriptor *source; ··· 247 217 source = snd_usb_find_clock_source(chip->ctrl_intf, entity_id); 248 218 if (source) { 249 219 entity_id = source->bClockID; 250 - if (validate && !uac_clock_source_is_valid(chip, UAC_VERSION_2, 220 + if (validate && !uac_clock_source_is_valid(chip, fmt, 251 221 entity_id)) { 252 222 usb_audio_err(chip, 253 223 "clock source %d is not valid, cannot use\n", ··· 278 248 } 279 249 280 250 cur = ret; 281 - ret = __uac_clock_find_source(chip, selector->baCSourceID[ret - 1], 282 - visited, validate); 251 + ret = __uac_clock_find_source(chip, fmt, 252 + selector->baCSourceID[ret - 1], 253 + visited, validate); 283 254 if (!validate || ret > 0 || !chip->autoclock) 284 255 return ret; 285 256 ··· 291 260 if (i == cur) 292 261 continue; 293 262 294 - ret = __uac_clock_find_source(chip, selector->baCSourceID[i - 1], 295 - visited, true); 263 + ret = __uac_clock_find_source(chip, fmt, 264 + selector->baCSourceID[i - 1], 265 + visited, true); 296 266 if (ret < 0) 297 267 continue; 298 268 ··· 313 281 /* FIXME: multipliers only act as pass-thru element for now */ 314 282 multiplier = snd_usb_find_clock_multiplier(chip->ctrl_intf, entity_id); 315 283 if (multiplier) 316 - return __uac_clock_find_source(chip, multiplier->bCSourceID, 317 - visited, validate); 284 + return __uac_clock_find_source(chip, fmt, 285 + multiplier->bCSourceID, 286 + visited, validate); 318 287 319 288 return -EINVAL; 320 289 } 321 290 322 - static int __uac3_clock_find_source(struct snd_usb_audio *chip, int entity_id, 323 - unsigned long *visited, bool validate) 291 + static int __uac3_clock_find_source(struct snd_usb_audio *chip, 292 + struct audioformat *fmt, int entity_id, 293 + unsigned long *visited, bool validate) 324 294 { 325 295 struct uac3_clock_source_descriptor *source; 326 296 struct uac3_clock_selector_descriptor *selector; ··· 341 307 source = snd_usb_find_clock_source_v3(chip->ctrl_intf, entity_id); 342 308 if (source) { 343 309 entity_id = source->bClockID; 344 - if (validate && !uac_clock_source_is_valid(chip, UAC_VERSION_3, 310 + if (validate && !uac_clock_source_is_valid(chip, fmt, 345 311 entity_id)) { 346 312 usb_audio_err(chip, 347 313 "clock source %d is not valid, cannot use\n", ··· 372 338 } 373 339 374 340 cur = ret; 375 - ret = __uac3_clock_find_source(chip, selector->baCSourceID[ret - 1], 341 + ret = __uac3_clock_find_source(chip, fmt, 342 + selector->baCSourceID[ret - 1], 376 343 visited, validate); 377 344 if (!validate || ret > 0 || !chip->autoclock) 378 345 return ret; ··· 385 350 if (i == cur) 386 351 continue; 387 352 388 - ret = __uac3_clock_find_source(chip, selector->baCSourceID[i - 1], 389 - visited, true); 353 + ret = __uac3_clock_find_source(chip, fmt, 354 + selector->baCSourceID[i - 1], 355 + visited, true); 390 356 if (ret < 0) 391 357 continue; 392 358 ··· 408 372 multiplier = snd_usb_find_clock_multiplier_v3(chip->ctrl_intf, 409 373 entity_id); 410 374 if (multiplier) 411 - return __uac3_clock_find_source(chip, multiplier->bCSourceID, 375 + return __uac3_clock_find_source(chip, fmt, 376 + multiplier->bCSourceID, 412 377 visited, validate); 413 378 414 379 return -EINVAL; ··· 426 389 * 427 390 * Returns the clock source UnitID (>=0) on success, or an error. 428 391 */ 429 - int snd_usb_clock_find_source(struct snd_usb_audio *chip, int protocol, 430 - int entity_id, bool validate) 392 + int snd_usb_clock_find_source(struct snd_usb_audio *chip, 393 + struct audioformat *fmt, bool validate) 431 394 { 432 395 DECLARE_BITMAP(visited, 256); 433 396 memset(visited, 0, sizeof(visited)); 434 397 435 - switch (protocol) { 398 + switch (fmt->protocol) { 436 399 case UAC_VERSION_2: 437 - return __uac_clock_find_source(chip, entity_id, visited, 400 + return __uac_clock_find_source(chip, fmt, fmt->clock, visited, 438 401 validate); 439 402 case UAC_VERSION_3: 440 - return __uac3_clock_find_source(chip, entity_id, visited, 403 + return __uac3_clock_find_source(chip, fmt, fmt->clock, visited, 441 404 validate); 442 405 default: 443 406 return -EINVAL; ··· 538 501 * automatic clock selection if the current clock is not 539 502 * valid. 540 503 */ 541 - clock = snd_usb_clock_find_source(chip, fmt->protocol, 542 - fmt->clock, true); 504 + clock = snd_usb_clock_find_source(chip, fmt, true); 543 505 if (clock < 0) { 544 506 /* We did not find a valid clock, but that might be 545 507 * because the current sample rate does not match an ··· 546 510 * and we will do another validation after setting the 547 511 * rate. 548 512 */ 549 - clock = snd_usb_clock_find_source(chip, fmt->protocol, 550 - fmt->clock, false); 513 + clock = snd_usb_clock_find_source(chip, fmt, false); 551 514 if (clock < 0) 552 515 return clock; 553 516 } ··· 612 577 613 578 validation: 614 579 /* validate clock after rate change */ 615 - if (!uac_clock_source_is_valid(chip, fmt->protocol, clock)) 580 + if (!uac_clock_source_is_valid(chip, fmt, clock)) 616 581 return -ENXIO; 617 582 return 0; 618 583 }
+2 -2
sound/usb/clock.h
··· 6 6 struct usb_host_interface *alts, 7 7 struct audioformat *fmt, int rate); 8 8 9 - int snd_usb_clock_find_source(struct snd_usb_audio *chip, int protocol, 10 - int entity_id, bool validate); 9 + int snd_usb_clock_find_source(struct snd_usb_audio *chip, 10 + struct audioformat *fmt, bool validate); 11 11 12 12 #endif /* __USBAUDIO_CLOCK_H */
+23 -13
sound/usb/format.c
··· 151 151 return pcm_formats; 152 152 } 153 153 154 + static int set_fixed_rate(struct audioformat *fp, int rate, int rate_bits) 155 + { 156 + kfree(fp->rate_table); 157 + fp->rate_table = kmalloc(sizeof(int), GFP_KERNEL); 158 + if (!fp->rate_table) 159 + return -ENOMEM; 160 + fp->nr_rates = 1; 161 + fp->rate_min = rate; 162 + fp->rate_max = rate; 163 + fp->rates = rate_bits; 164 + fp->rate_table[0] = rate; 165 + return 0; 166 + } 154 167 155 168 /* 156 169 * parse the format descriptor and stores the possible sample rates ··· 236 223 fp->rate_min = combine_triple(&fmt[offset + 1]); 237 224 fp->rate_max = combine_triple(&fmt[offset + 4]); 238 225 } 226 + 227 + /* Jabra Evolve 65 headset */ 228 + if (chip->usb_id == USB_ID(0x0b0e, 0x030b)) { 229 + /* only 48kHz for playback while keeping 16kHz for capture */ 230 + if (fp->nr_rates != 1) 231 + return set_fixed_rate(fp, 48000, SNDRV_PCM_RATE_48000); 232 + } 233 + 239 234 return 0; 240 235 } 241 236 ··· 320 299 case USB_ID(0x0e41, 0x4248): /* Line6 Helix >= fw 2.82 */ 321 300 case USB_ID(0x0e41, 0x4249): /* Line6 Helix Rack >= fw 2.82 */ 322 301 case USB_ID(0x0e41, 0x424a): /* Line6 Helix LT >= fw 2.82 */ 323 - /* supported rates: 48Khz */ 324 - kfree(fp->rate_table); 325 - fp->rate_table = kmalloc(sizeof(int), GFP_KERNEL); 326 - if (!fp->rate_table) 327 - return -ENOMEM; 328 - fp->nr_rates = 1; 329 - fp->rate_min = 48000; 330 - fp->rate_max = 48000; 331 - fp->rates = SNDRV_PCM_RATE_48000; 332 - fp->rate_table[0] = 48000; 333 - return 0; 302 + return set_fixed_rate(fp, 48000, SNDRV_PCM_RATE_48000); 334 303 } 335 304 336 305 return -ENODEV; ··· 336 325 struct usb_device *dev = chip->dev; 337 326 unsigned char tmp[2], *data; 338 327 int nr_triplets, data_size, ret = 0, ret_l6; 339 - int clock = snd_usb_clock_find_source(chip, fp->protocol, 340 - fp->clock, false); 328 + int clock = snd_usb_clock_find_source(chip, fp, false); 341 329 342 330 if (clock < 0) { 343 331 dev_err(&dev->dev,
+10 -2
sound/usb/mixer.c
··· 897 897 return 0; 898 898 } 899 899 900 + static int parse_term_effect_unit(struct mixer_build *state, 901 + struct usb_audio_term *term, 902 + void *p1, int id) 903 + { 904 + term->type = UAC3_EFFECT_UNIT << 16; /* virtual type */ 905 + term->id = id; 906 + return 0; 907 + } 908 + 900 909 static int parse_term_uac2_clock_source(struct mixer_build *state, 901 910 struct usb_audio_term *term, 902 911 void *p1, int id) ··· 990 981 UAC3_PROCESSING_UNIT); 991 982 case PTYPE(UAC_VERSION_2, UAC2_EFFECT_UNIT): 992 983 case PTYPE(UAC_VERSION_3, UAC3_EFFECT_UNIT): 993 - return parse_term_proc_unit(state, term, p1, id, 994 - UAC3_EFFECT_UNIT); 984 + return parse_term_effect_unit(state, term, p1, id); 995 985 case PTYPE(UAC_VERSION_1, UAC1_EXTENSION_UNIT): 996 986 case PTYPE(UAC_VERSION_2, UAC2_EXTENSION_UNIT_V2): 997 987 case PTYPE(UAC_VERSION_3, UAC3_EXTENSION_UNIT):
+1
sound/usb/quirks.c
··· 1440 1440 case USB_ID(0x1395, 0x740a): /* Sennheiser DECT */ 1441 1441 case USB_ID(0x1901, 0x0191): /* GE B850V3 CP2114 audio interface */ 1442 1442 case USB_ID(0x21b4, 0x0081): /* AudioQuest DragonFly */ 1443 + case USB_ID(0x2912, 0x30c8): /* Audioengine D1 */ 1443 1444 return true; 1444 1445 } 1445 1446
+10 -2
tools/arch/arm64/include/uapi/asm/kvm.h
··· 220 220 #define KVM_REG_ARM_PTIMER_CVAL ARM64_SYS_REG(3, 3, 14, 2, 2) 221 221 #define KVM_REG_ARM_PTIMER_CNT ARM64_SYS_REG(3, 3, 14, 0, 1) 222 222 223 - /* EL0 Virtual Timer Registers */ 223 + /* 224 + * EL0 Virtual Timer Registers 225 + * 226 + * WARNING: 227 + * KVM_REG_ARM_TIMER_CVAL and KVM_REG_ARM_TIMER_CNT are not defined 228 + * with the appropriate register encodings. Their values have been 229 + * accidentally swapped. As this is set API, the definitions here 230 + * must be used, rather than ones derived from the encodings. 231 + */ 224 232 #define KVM_REG_ARM_TIMER_CTL ARM64_SYS_REG(3, 3, 14, 3, 1) 225 - #define KVM_REG_ARM_TIMER_CNT ARM64_SYS_REG(3, 3, 14, 3, 2) 226 233 #define KVM_REG_ARM_TIMER_CVAL ARM64_SYS_REG(3, 3, 14, 0, 2) 234 + #define KVM_REG_ARM_TIMER_CNT ARM64_SYS_REG(3, 3, 14, 3, 2) 227 235 228 236 /* KVM-as-firmware specific pseudo-registers */ 229 237 #define KVM_REG_ARM_FW (0x0014 << KVM_REG_ARM_COPROC_SHIFT)
+1
tools/arch/arm64/include/uapi/asm/unistd.h
··· 19 19 #define __ARCH_WANT_NEW_STAT 20 20 #define __ARCH_WANT_SET_GET_RLIMIT 21 21 #define __ARCH_WANT_TIME32_SYSCALLS 22 + #define __ARCH_WANT_SYS_CLONE3 22 23 23 24 #include <asm-generic/unistd.h>
+2
tools/arch/x86/include/asm/cpufeatures.h
··· 220 220 #define X86_FEATURE_ZEN ( 7*32+28) /* "" CPU is AMD family 0x17 (Zen) */ 221 221 #define X86_FEATURE_L1TF_PTEINV ( 7*32+29) /* "" L1TF workaround PTE inversion */ 222 222 #define X86_FEATURE_IBRS_ENHANCED ( 7*32+30) /* Enhanced IBRS */ 223 + #define X86_FEATURE_MSR_IA32_FEAT_CTL ( 7*32+31) /* "" MSR IA32_FEAT_CTL configured */ 223 224 224 225 /* Virtualization flags: Linux defined, word 8 */ 225 226 #define X86_FEATURE_TPR_SHADOW ( 8*32+ 0) /* Intel TPR Shadow */ ··· 358 357 /* Intel-defined CPU features, CPUID level 0x00000007:0 (EDX), word 18 */ 359 358 #define X86_FEATURE_AVX512_4VNNIW (18*32+ 2) /* AVX-512 Neural Network Instructions */ 360 359 #define X86_FEATURE_AVX512_4FMAPS (18*32+ 3) /* AVX-512 Multiply Accumulation Single precision */ 360 + #define X86_FEATURE_FSRM (18*32+ 4) /* Fast Short Rep Mov */ 361 361 #define X86_FEATURE_AVX512_VP2INTERSECT (18*32+ 8) /* AVX-512 Intersect for D/Q */ 362 362 #define X86_FEATURE_MD_CLEAR (18*32+10) /* VERW clears CPU buffers */ 363 363 #define X86_FEATURE_TSX_FORCE_ABORT (18*32+13) /* "" TSX_FORCE_ABORT */
+1 -7
tools/arch/x86/include/asm/disabled-features.h
··· 10 10 * cpu_feature_enabled(). 11 11 */ 12 12 13 - #ifdef CONFIG_X86_INTEL_MPX 14 - # define DISABLE_MPX 0 15 - #else 16 - # define DISABLE_MPX (1<<(X86_FEATURE_MPX & 31)) 17 - #endif 18 - 19 13 #ifdef CONFIG_X86_SMAP 20 14 # define DISABLE_SMAP 0 21 15 #else ··· 68 74 #define DISABLED_MASK6 0 69 75 #define DISABLED_MASK7 (DISABLE_PTI) 70 76 #define DISABLED_MASK8 0 71 - #define DISABLED_MASK9 (DISABLE_MPX|DISABLE_SMAP) 77 + #define DISABLED_MASK9 (DISABLE_SMAP) 72 78 #define DISABLED_MASK10 0 73 79 #define DISABLED_MASK11 0 74 80 #define DISABLED_MASK12 0
+12
tools/bootconfig/include/linux/memblock.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + #ifndef _XBC_LINUX_MEMBLOCK_H 3 + #define _XBC_LINUX_MEMBLOCK_H 4 + 5 + #include <stdlib.h> 6 + 7 + #define __pa(addr) (addr) 8 + #define SMP_CACHE_BYTES 0 9 + #define memblock_alloc(size, align) malloc(size) 10 + #define memblock_free(paddr, size) free(paddr) 11 + 12 + #endif
+1 -1
tools/bootconfig/include/linux/printk.h
··· 7 7 /* controllable printf */ 8 8 extern int pr_output; 9 9 #define printk(fmt, ...) \ 10 - (pr_output ? printf(fmt, __VA_ARGS__) : 0) 10 + (pr_output ? printf(fmt, ##__VA_ARGS__) : 0) 11 11 12 12 #define pr_err printk 13 13 #define pr_warn printk
+14 -14
tools/bootconfig/main.c
··· 140 140 return 0; 141 141 142 142 if (lseek(fd, -8, SEEK_END) < 0) { 143 - printf("Failed to lseek: %d\n", -errno); 143 + pr_err("Failed to lseek: %d\n", -errno); 144 144 return -errno; 145 145 } 146 146 ··· 155 155 return 0; 156 156 157 157 if (lseek(fd, stat.st_size - 8 - size, SEEK_SET) < 0) { 158 - printf("Failed to lseek: %d\n", -errno); 158 + pr_err("Failed to lseek: %d\n", -errno); 159 159 return -errno; 160 160 } 161 161 ··· 166 166 /* Wrong Checksum, maybe no boot config here */ 167 167 rcsum = checksum((unsigned char *)*buf, size); 168 168 if (csum != rcsum) { 169 - printf("checksum error: %d != %d\n", csum, rcsum); 169 + pr_err("checksum error: %d != %d\n", csum, rcsum); 170 170 return 0; 171 171 } 172 172 ··· 185 185 186 186 fd = open(path, O_RDONLY); 187 187 if (fd < 0) { 188 - printf("Failed to open initrd %s: %d\n", path, fd); 188 + pr_err("Failed to open initrd %s: %d\n", path, fd); 189 189 return -errno; 190 190 } 191 191 192 192 ret = load_xbc_from_initrd(fd, &buf); 193 193 if (ret < 0) 194 - printf("Failed to load a boot config from initrd: %d\n", ret); 194 + pr_err("Failed to load a boot config from initrd: %d\n", ret); 195 195 else 196 196 xbc_show_compact_tree(); 197 197 ··· 209 209 210 210 fd = open(path, O_RDWR); 211 211 if (fd < 0) { 212 - printf("Failed to open initrd %s: %d\n", path, fd); 212 + pr_err("Failed to open initrd %s: %d\n", path, fd); 213 213 return -errno; 214 214 } 215 215 ··· 222 222 pr_output = 1; 223 223 if (size < 0) { 224 224 ret = size; 225 - printf("Failed to load a boot config from initrd: %d\n", ret); 225 + pr_err("Failed to load a boot config from initrd: %d\n", ret); 226 226 } else if (size > 0) { 227 227 ret = fstat(fd, &stat); 228 228 if (!ret) ··· 245 245 246 246 ret = load_xbc_file(xbc_path, &buf); 247 247 if (ret < 0) { 248 - printf("Failed to load %s : %d\n", xbc_path, ret); 248 + pr_err("Failed to load %s : %d\n", xbc_path, ret); 249 249 return ret; 250 250 } 251 251 size = strlen(buf) + 1; ··· 262 262 /* Check the data format */ 263 263 ret = xbc_init(buf); 264 264 if (ret < 0) { 265 - printf("Failed to parse %s: %d\n", xbc_path, ret); 265 + pr_err("Failed to parse %s: %d\n", xbc_path, ret); 266 266 free(data); 267 267 free(buf); 268 268 return ret; ··· 279 279 /* Remove old boot config if exists */ 280 280 ret = delete_xbc(path); 281 281 if (ret < 0) { 282 - printf("Failed to delete previous boot config: %d\n", ret); 282 + pr_err("Failed to delete previous boot config: %d\n", ret); 283 283 return ret; 284 284 } 285 285 286 286 /* Apply new one */ 287 287 fd = open(path, O_RDWR | O_APPEND); 288 288 if (fd < 0) { 289 - printf("Failed to open %s: %d\n", path, fd); 289 + pr_err("Failed to open %s: %d\n", path, fd); 290 290 return fd; 291 291 } 292 292 /* TODO: Ensure the @path is initramfs/initrd image */ 293 293 ret = write(fd, data, size + 8); 294 294 if (ret < 0) { 295 - printf("Failed to apply a boot config: %d\n", ret); 295 + pr_err("Failed to apply a boot config: %d\n", ret); 296 296 return ret; 297 297 } 298 298 close(fd); ··· 334 334 } 335 335 336 336 if (apply && delete) { 337 - printf("Error: You can not specify both -a and -d at once.\n"); 337 + pr_err("Error: You can not specify both -a and -d at once.\n"); 338 338 return usage(); 339 339 } 340 340 341 341 if (optind >= argc) { 342 - printf("Error: No initrd is specified.\n"); 342 + pr_err("Error: No initrd is specified.\n"); 343 343 return usage(); 344 344 } 345 345
+9
tools/bootconfig/test-bootconfig.sh
··· 64 64 new_size=$(stat -c %s $INITRD) 65 65 xpass test $new_size -eq $initrd_size 66 66 67 + echo "No error messge while applying" 68 + OUTFILE=`mktemp tempout-XXXX` 69 + dd if=/dev/zero of=$INITRD bs=4096 count=1 70 + printf " \0\0\0 \0\0\0" >> $INITRD 71 + $BOOTCONF -a $TEMPCONF $INITRD > $OUTFILE 2>&1 72 + xfail grep -i "failed" $OUTFILE 73 + xfail grep -i "error" $OUTFILE 74 + rm $OUTFILE 75 + 67 76 echo "Max node number check" 68 77 69 78 echo -n > $TEMPCONF
+2
tools/include/uapi/asm-generic/mman-common.h
··· 11 11 #define PROT_WRITE 0x2 /* page can be written */ 12 12 #define PROT_EXEC 0x4 /* page can be executed */ 13 13 #define PROT_SEM 0x8 /* page may be used for atomic ops */ 14 + /* 0x10 reserved for arch-specific use */ 15 + /* 0x20 reserved for arch-specific use */ 14 16 #define PROT_NONE 0x0 /* page can not be accessed */ 15 17 #define PROT_GROWSDOWN 0x01000000 /* mprotect flag: extend change to start of growsdown vma */ 16 18 #define PROT_GROWSUP 0x02000000 /* mprotect flag: extend change to end of growsup vma */
+6 -1
tools/include/uapi/asm-generic/unistd.h
··· 851 851 __SYSCALL(__NR_clone3, sys_clone3) 852 852 #endif 853 853 854 + #define __NR_openat2 437 855 + __SYSCALL(__NR_openat2, sys_openat2) 856 + #define __NR_pidfd_getfd 438 857 + __SYSCALL(__NR_pidfd_getfd, sys_pidfd_getfd) 858 + 854 859 #undef __NR_syscalls 855 - #define __NR_syscalls 436 860 + #define __NR_syscalls 439 856 861 857 862 /* 858 863 * 32 bit systems traditionally used different
+32
tools/include/uapi/drm/i915_drm.h
··· 395 395 #define DRM_IOCTL_I915_GEM_PWRITE DRM_IOW (DRM_COMMAND_BASE + DRM_I915_GEM_PWRITE, struct drm_i915_gem_pwrite) 396 396 #define DRM_IOCTL_I915_GEM_MMAP DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_MMAP, struct drm_i915_gem_mmap) 397 397 #define DRM_IOCTL_I915_GEM_MMAP_GTT DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_MMAP_GTT, struct drm_i915_gem_mmap_gtt) 398 + #define DRM_IOCTL_I915_GEM_MMAP_OFFSET DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_MMAP_GTT, struct drm_i915_gem_mmap_offset) 398 399 #define DRM_IOCTL_I915_GEM_SET_DOMAIN DRM_IOW (DRM_COMMAND_BASE + DRM_I915_GEM_SET_DOMAIN, struct drm_i915_gem_set_domain) 399 400 #define DRM_IOCTL_I915_GEM_SW_FINISH DRM_IOW (DRM_COMMAND_BASE + DRM_I915_GEM_SW_FINISH, struct drm_i915_gem_sw_finish) 400 401 #define DRM_IOCTL_I915_GEM_SET_TILING DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_SET_TILING, struct drm_i915_gem_set_tiling) ··· 792 791 * This is a fixed-size type for 32/64 compatibility. 793 792 */ 794 793 __u64 offset; 794 + }; 795 + 796 + struct drm_i915_gem_mmap_offset { 797 + /** Handle for the object being mapped. */ 798 + __u32 handle; 799 + __u32 pad; 800 + /** 801 + * Fake offset to use for subsequent mmap call 802 + * 803 + * This is a fixed-size type for 32/64 compatibility. 804 + */ 805 + __u64 offset; 806 + 807 + /** 808 + * Flags for extended behaviour. 809 + * 810 + * It is mandatory that one of the MMAP_OFFSET types 811 + * (GTT, WC, WB, UC, etc) should be included. 812 + */ 813 + __u64 flags; 814 + #define I915_MMAP_OFFSET_GTT 0 815 + #define I915_MMAP_OFFSET_WC 1 816 + #define I915_MMAP_OFFSET_WB 2 817 + #define I915_MMAP_OFFSET_UC 3 818 + 819 + /* 820 + * Zero-terminated chain of extensions. 821 + * 822 + * No current extensions defined; mbz. 823 + */ 824 + __u64 extensions; 795 825 }; 796 826 797 827 struct drm_i915_gem_set_domain {
+1 -1
tools/include/uapi/linux/fcntl.h
··· 3 3 #define _UAPI_LINUX_FCNTL_H 4 4 5 5 #include <asm/fcntl.h> 6 + #include <linux/openat2.h> 6 7 7 8 #define F_SETLEASE (F_LINUX_SPECIFIC_BASE + 0) 8 9 #define F_GETLEASE (F_LINUX_SPECIFIC_BASE + 1) ··· 100 99 #define AT_STATX_DONT_SYNC 0x4000 /* - Don't sync attributes with the server */ 101 100 102 101 #define AT_RECURSIVE 0x8000 /* Apply to the entire subtree */ 103 - 104 102 105 103 #endif /* _UAPI_LINUX_FCNTL_H */
+13 -1
tools/include/uapi/linux/fscrypt.h
··· 8 8 #ifndef _UAPI_LINUX_FSCRYPT_H 9 9 #define _UAPI_LINUX_FSCRYPT_H 10 10 11 + #include <linux/ioctl.h> 11 12 #include <linux/types.h> 12 13 13 14 /* Encryption policy flags */ ··· 110 109 } u; 111 110 }; 112 111 112 + /* 113 + * Payload of Linux keyring key of type "fscrypt-provisioning", referenced by 114 + * fscrypt_add_key_arg::key_id as an alternative to fscrypt_add_key_arg::raw. 115 + */ 116 + struct fscrypt_provisioning_key_payload { 117 + __u32 type; 118 + __u32 __reserved; 119 + __u8 raw[]; 120 + }; 121 + 113 122 /* Struct passed to FS_IOC_ADD_ENCRYPTION_KEY */ 114 123 struct fscrypt_add_key_arg { 115 124 struct fscrypt_key_specifier key_spec; 116 125 __u32 raw_size; 117 - __u32 __reserved[9]; 126 + __u32 key_id; 127 + __u32 __reserved[8]; 118 128 __u8 raw[]; 119 129 }; 120 130
+5
tools/include/uapi/linux/kvm.h
··· 1009 1009 #define KVM_CAP_PPC_GUEST_DEBUG_SSTEP 176 1010 1010 #define KVM_CAP_ARM_NISV_TO_USER 177 1011 1011 #define KVM_CAP_ARM_INJECT_EXT_DABT 178 1012 + #define KVM_CAP_S390_VCPU_RESETS 179 1012 1013 1013 1014 #ifdef KVM_CAP_IRQ_ROUTING 1014 1015 ··· 1473 1472 1474 1473 /* Available with KVM_CAP_ARM_SVE */ 1475 1474 #define KVM_ARM_VCPU_FINALIZE _IOW(KVMIO, 0xc2, int) 1475 + 1476 + /* Available with KVM_CAP_S390_VCPU_RESETS */ 1477 + #define KVM_S390_NORMAL_RESET _IO(KVMIO, 0xc3) 1478 + #define KVM_S390_CLEAR_RESET _IO(KVMIO, 0xc4) 1476 1479 1477 1480 /* Secure Encrypted Virtualization command */ 1478 1481 enum sev_cmd_id {
+39
tools/include/uapi/linux/openat2.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 + #ifndef _UAPI_LINUX_OPENAT2_H 3 + #define _UAPI_LINUX_OPENAT2_H 4 + 5 + #include <linux/types.h> 6 + 7 + /* 8 + * Arguments for how openat2(2) should open the target path. If only @flags and 9 + * @mode are non-zero, then openat2(2) operates very similarly to openat(2). 10 + * 11 + * However, unlike openat(2), unknown or invalid bits in @flags result in 12 + * -EINVAL rather than being silently ignored. @mode must be zero unless one of 13 + * {O_CREAT, O_TMPFILE} are set. 14 + * 15 + * @flags: O_* flags. 16 + * @mode: O_CREAT/O_TMPFILE file mode. 17 + * @resolve: RESOLVE_* flags. 18 + */ 19 + struct open_how { 20 + __u64 flags; 21 + __u64 mode; 22 + __u64 resolve; 23 + }; 24 + 25 + /* how->resolve flags for openat2(2). */ 26 + #define RESOLVE_NO_XDEV 0x01 /* Block mount-point crossings 27 + (includes bind-mounts). */ 28 + #define RESOLVE_NO_MAGICLINKS 0x02 /* Block traversal through procfs-style 29 + "magic-links". */ 30 + #define RESOLVE_NO_SYMLINKS 0x04 /* Block traversal through all symlinks 31 + (implies OEXT_NO_MAGICLINKS) */ 32 + #define RESOLVE_BENEATH 0x08 /* Block "lexical" trickery like 33 + "..", symlinks, and absolute 34 + paths which escape the dirfd. */ 35 + #define RESOLVE_IN_ROOT 0x10 /* Make all jumps to "/" and ".." 36 + be scoped inside the dirfd 37 + (similar to chroot(2)). */ 38 + 39 + #endif /* _UAPI_LINUX_OPENAT2_H */
+4
tools/include/uapi/linux/prctl.h
··· 234 234 #define PR_GET_TAGGED_ADDR_CTRL 56 235 235 # define PR_TAGGED_ADDR_ENABLE (1UL << 0) 236 236 237 + /* Control reclaim behavior when allocating memory */ 238 + #define PR_SET_IO_FLUSHER 57 239 + #define PR_GET_IO_FLUSHER 58 240 + 237 241 #endif /* _LINUX_PRCTL_H */
+6
tools/include/uapi/linux/sched.h
··· 36 36 /* Flags for the clone3() syscall. */ 37 37 #define CLONE_CLEAR_SIGHAND 0x100000000ULL /* Clear any signal handler and reset to SIG_DFL. */ 38 38 39 + /* 40 + * cloning flags intersect with CSIGNAL so can be used with unshare and clone3 41 + * syscalls only: 42 + */ 43 + #define CLONE_NEWTIME 0x00000080 /* New time namespace */ 44 + 39 45 #ifndef __ASSEMBLY__ 40 46 /** 41 47 * struct clone_args - arguments for the clone3 syscall
+132 -23
tools/include/uapi/sound/asound.h
··· 26 26 27 27 #if defined(__KERNEL__) || defined(__linux__) 28 28 #include <linux/types.h> 29 + #include <asm/byteorder.h> 29 30 #else 31 + #include <endian.h> 30 32 #include <sys/ioctl.h> 31 33 #endif 32 34 ··· 156 154 * * 157 155 *****************************************************************************/ 158 156 159 - #define SNDRV_PCM_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 14) 157 + #define SNDRV_PCM_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 15) 160 158 161 159 typedef unsigned long snd_pcm_uframes_t; 162 160 typedef signed long snd_pcm_sframes_t; ··· 303 301 #define SNDRV_PCM_INFO_DRAIN_TRIGGER 0x40000000 /* internal kernel flag - trigger in drain */ 304 302 #define SNDRV_PCM_INFO_FIFO_IN_FRAMES 0x80000000 /* internal kernel flag - FIFO size is in frames */ 305 303 306 - 304 + #if (__BITS_PER_LONG == 32 && defined(__USE_TIME_BITS64)) || defined __KERNEL__ 305 + #define __SND_STRUCT_TIME64 306 + #endif 307 307 308 308 typedef int __bitwise snd_pcm_state_t; 309 309 #define SNDRV_PCM_STATE_OPEN ((__force snd_pcm_state_t) 0) /* stream is open */ ··· 321 317 322 318 enum { 323 319 SNDRV_PCM_MMAP_OFFSET_DATA = 0x00000000, 324 - SNDRV_PCM_MMAP_OFFSET_STATUS = 0x80000000, 325 - SNDRV_PCM_MMAP_OFFSET_CONTROL = 0x81000000, 320 + SNDRV_PCM_MMAP_OFFSET_STATUS_OLD = 0x80000000, 321 + SNDRV_PCM_MMAP_OFFSET_CONTROL_OLD = 0x81000000, 322 + SNDRV_PCM_MMAP_OFFSET_STATUS_NEW = 0x82000000, 323 + SNDRV_PCM_MMAP_OFFSET_CONTROL_NEW = 0x83000000, 324 + #ifdef __SND_STRUCT_TIME64 325 + SNDRV_PCM_MMAP_OFFSET_STATUS = SNDRV_PCM_MMAP_OFFSET_STATUS_NEW, 326 + SNDRV_PCM_MMAP_OFFSET_CONTROL = SNDRV_PCM_MMAP_OFFSET_CONTROL_NEW, 327 + #else 328 + SNDRV_PCM_MMAP_OFFSET_STATUS = SNDRV_PCM_MMAP_OFFSET_STATUS_OLD, 329 + SNDRV_PCM_MMAP_OFFSET_CONTROL = SNDRV_PCM_MMAP_OFFSET_CONTROL_OLD, 330 + #endif 326 331 }; 327 332 328 333 union snd_pcm_sync_id { ··· 469 456 SNDRV_PCM_AUDIO_TSTAMP_TYPE_LAST = SNDRV_PCM_AUDIO_TSTAMP_TYPE_LINK_SYNCHRONIZED 470 457 }; 471 458 459 + #ifndef __KERNEL__ 460 + /* explicit padding avoids incompatibility between i386 and x86-64 */ 461 + typedef struct { unsigned char pad[sizeof(time_t) - sizeof(int)]; } __time_pad; 462 + 472 463 struct snd_pcm_status { 473 464 snd_pcm_state_t state; /* stream state */ 465 + __time_pad pad1; /* align to timespec */ 474 466 struct timespec trigger_tstamp; /* time when stream was started/stopped/paused */ 475 467 struct timespec tstamp; /* reference timestamp */ 476 468 snd_pcm_uframes_t appl_ptr; /* appl ptr */ ··· 491 473 __u32 audio_tstamp_accuracy; /* in ns units, only valid if indicated in audio_tstamp_data */ 492 474 unsigned char reserved[52-2*sizeof(struct timespec)]; /* must be filled with zero */ 493 475 }; 476 + #endif 494 477 495 - struct snd_pcm_mmap_status { 478 + /* 479 + * For mmap operations, we need the 64-bit layout, both for compat mode, 480 + * and for y2038 compatibility. For 64-bit applications, the two definitions 481 + * are identical, so we keep the traditional version. 482 + */ 483 + #ifdef __SND_STRUCT_TIME64 484 + #define __snd_pcm_mmap_status64 snd_pcm_mmap_status 485 + #define __snd_pcm_mmap_control64 snd_pcm_mmap_control 486 + #define __snd_pcm_sync_ptr64 snd_pcm_sync_ptr 487 + #ifdef __KERNEL__ 488 + #define __snd_timespec64 __kernel_timespec 489 + #else 490 + #define __snd_timespec64 timespec 491 + #endif 492 + struct __snd_timespec { 493 + __s32 tv_sec; 494 + __s32 tv_nsec; 495 + }; 496 + #else 497 + #define __snd_pcm_mmap_status snd_pcm_mmap_status 498 + #define __snd_pcm_mmap_control snd_pcm_mmap_control 499 + #define __snd_pcm_sync_ptr snd_pcm_sync_ptr 500 + #define __snd_timespec timespec 501 + struct __snd_timespec64 { 502 + __s64 tv_sec; 503 + __s64 tv_nsec; 504 + }; 505 + 506 + #endif 507 + 508 + struct __snd_pcm_mmap_status { 496 509 snd_pcm_state_t state; /* RO: state - SNDRV_PCM_STATE_XXXX */ 497 510 int pad1; /* Needed for 64 bit alignment */ 498 511 snd_pcm_uframes_t hw_ptr; /* RO: hw ptr (0...boundary-1) */ 499 - struct timespec tstamp; /* Timestamp */ 512 + struct __snd_timespec tstamp; /* Timestamp */ 500 513 snd_pcm_state_t suspended_state; /* RO: suspended stream state */ 501 - struct timespec audio_tstamp; /* from sample counter or wall clock */ 514 + struct __snd_timespec audio_tstamp; /* from sample counter or wall clock */ 502 515 }; 503 516 504 - struct snd_pcm_mmap_control { 517 + struct __snd_pcm_mmap_control { 505 518 snd_pcm_uframes_t appl_ptr; /* RW: appl ptr (0...boundary-1) */ 506 519 snd_pcm_uframes_t avail_min; /* RW: min available frames for wakeup */ 507 520 }; ··· 541 492 #define SNDRV_PCM_SYNC_PTR_APPL (1<<1) /* get appl_ptr from driver (r/w op) */ 542 493 #define SNDRV_PCM_SYNC_PTR_AVAIL_MIN (1<<2) /* get avail_min from driver */ 543 494 544 - struct snd_pcm_sync_ptr { 495 + struct __snd_pcm_sync_ptr { 545 496 unsigned int flags; 546 497 union { 547 - struct snd_pcm_mmap_status status; 498 + struct __snd_pcm_mmap_status status; 548 499 unsigned char reserved[64]; 549 500 } s; 550 501 union { 551 - struct snd_pcm_mmap_control control; 502 + struct __snd_pcm_mmap_control control; 503 + unsigned char reserved[64]; 504 + } c; 505 + }; 506 + 507 + #if defined(__BYTE_ORDER) ? __BYTE_ORDER == __BIG_ENDIAN : defined(__BIG_ENDIAN) 508 + typedef char __pad_before_uframe[sizeof(__u64) - sizeof(snd_pcm_uframes_t)]; 509 + typedef char __pad_after_uframe[0]; 510 + #endif 511 + 512 + #if defined(__BYTE_ORDER) ? __BYTE_ORDER == __LITTLE_ENDIAN : defined(__LITTLE_ENDIAN) 513 + typedef char __pad_before_uframe[0]; 514 + typedef char __pad_after_uframe[sizeof(__u64) - sizeof(snd_pcm_uframes_t)]; 515 + #endif 516 + 517 + struct __snd_pcm_mmap_status64 { 518 + snd_pcm_state_t state; /* RO: state - SNDRV_PCM_STATE_XXXX */ 519 + __u32 pad1; /* Needed for 64 bit alignment */ 520 + __pad_before_uframe __pad1; 521 + snd_pcm_uframes_t hw_ptr; /* RO: hw ptr (0...boundary-1) */ 522 + __pad_after_uframe __pad2; 523 + struct __snd_timespec64 tstamp; /* Timestamp */ 524 + snd_pcm_state_t suspended_state;/* RO: suspended stream state */ 525 + __u32 pad3; /* Needed for 64 bit alignment */ 526 + struct __snd_timespec64 audio_tstamp; /* sample counter or wall clock */ 527 + }; 528 + 529 + struct __snd_pcm_mmap_control64 { 530 + __pad_before_uframe __pad1; 531 + snd_pcm_uframes_t appl_ptr; /* RW: appl ptr (0...boundary-1) */ 532 + __pad_before_uframe __pad2; 533 + 534 + __pad_before_uframe __pad3; 535 + snd_pcm_uframes_t avail_min; /* RW: min available frames for wakeup */ 536 + __pad_after_uframe __pad4; 537 + }; 538 + 539 + struct __snd_pcm_sync_ptr64 { 540 + __u32 flags; 541 + __u32 pad1; 542 + union { 543 + struct __snd_pcm_mmap_status64 status; 544 + unsigned char reserved[64]; 545 + } s; 546 + union { 547 + struct __snd_pcm_mmap_control64 control; 552 548 unsigned char reserved[64]; 553 549 } c; 554 550 }; ··· 678 584 #define SNDRV_PCM_IOCTL_STATUS _IOR('A', 0x20, struct snd_pcm_status) 679 585 #define SNDRV_PCM_IOCTL_DELAY _IOR('A', 0x21, snd_pcm_sframes_t) 680 586 #define SNDRV_PCM_IOCTL_HWSYNC _IO('A', 0x22) 587 + #define __SNDRV_PCM_IOCTL_SYNC_PTR _IOWR('A', 0x23, struct __snd_pcm_sync_ptr) 588 + #define __SNDRV_PCM_IOCTL_SYNC_PTR64 _IOWR('A', 0x23, struct __snd_pcm_sync_ptr64) 681 589 #define SNDRV_PCM_IOCTL_SYNC_PTR _IOWR('A', 0x23, struct snd_pcm_sync_ptr) 682 590 #define SNDRV_PCM_IOCTL_STATUS_EXT _IOWR('A', 0x24, struct snd_pcm_status) 683 591 #define SNDRV_PCM_IOCTL_CHANNEL_INFO _IOR('A', 0x32, struct snd_pcm_channel_info) ··· 710 614 * Raw MIDI section - /dev/snd/midi?? 711 615 */ 712 616 713 - #define SNDRV_RAWMIDI_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 0) 617 + #define SNDRV_RAWMIDI_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 1) 714 618 715 619 enum { 716 620 SNDRV_RAWMIDI_STREAM_OUTPUT = 0, ··· 744 648 unsigned char reserved[16]; /* reserved for future use */ 745 649 }; 746 650 651 + #ifndef __KERNEL__ 747 652 struct snd_rawmidi_status { 748 653 int stream; 654 + __time_pad pad1; 749 655 struct timespec tstamp; /* Timestamp */ 750 656 size_t avail; /* available bytes */ 751 657 size_t xruns; /* count of overruns since last status (in bytes) */ 752 658 unsigned char reserved[16]; /* reserved for future use */ 753 659 }; 660 + #endif 754 661 755 662 #define SNDRV_RAWMIDI_IOCTL_PVERSION _IOR('W', 0x00, int) 756 663 #define SNDRV_RAWMIDI_IOCTL_INFO _IOR('W', 0x01, struct snd_rawmidi_info) ··· 766 667 * Timer section - /dev/snd/timer 767 668 */ 768 669 769 - #define SNDRV_TIMER_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 6) 670 + #define SNDRV_TIMER_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 7) 770 671 771 672 enum { 772 673 SNDRV_TIMER_CLASS_NONE = -1, ··· 860 761 unsigned char reserved[60]; /* reserved */ 861 762 }; 862 763 764 + #ifndef __KERNEL__ 863 765 struct snd_timer_status { 864 766 struct timespec tstamp; /* Timestamp - last update */ 865 767 unsigned int resolution; /* current period resolution in ns */ ··· 869 769 unsigned int queue; /* used queue size */ 870 770 unsigned char reserved[64]; /* reserved */ 871 771 }; 772 + #endif 872 773 873 774 #define SNDRV_TIMER_IOCTL_PVERSION _IOR('T', 0x00, int) 874 775 #define SNDRV_TIMER_IOCTL_NEXT_DEVICE _IOWR('T', 0x01, struct snd_timer_id) 875 - #define SNDRV_TIMER_IOCTL_TREAD _IOW('T', 0x02, int) 776 + #define SNDRV_TIMER_IOCTL_TREAD_OLD _IOW('T', 0x02, int) 876 777 #define SNDRV_TIMER_IOCTL_GINFO _IOWR('T', 0x03, struct snd_timer_ginfo) 877 778 #define SNDRV_TIMER_IOCTL_GPARAMS _IOW('T', 0x04, struct snd_timer_gparams) 878 779 #define SNDRV_TIMER_IOCTL_GSTATUS _IOWR('T', 0x05, struct snd_timer_gstatus) ··· 886 785 #define SNDRV_TIMER_IOCTL_STOP _IO('T', 0xa1) 887 786 #define SNDRV_TIMER_IOCTL_CONTINUE _IO('T', 0xa2) 888 787 #define SNDRV_TIMER_IOCTL_PAUSE _IO('T', 0xa3) 788 + #define SNDRV_TIMER_IOCTL_TREAD64 _IOW('T', 0xa4, int) 789 + 790 + #if __BITS_PER_LONG == 64 791 + #define SNDRV_TIMER_IOCTL_TREAD SNDRV_TIMER_IOCTL_TREAD_OLD 792 + #else 793 + #define SNDRV_TIMER_IOCTL_TREAD ((sizeof(__kernel_long_t) >= sizeof(time_t)) ? \ 794 + SNDRV_TIMER_IOCTL_TREAD_OLD : \ 795 + SNDRV_TIMER_IOCTL_TREAD64) 796 + #endif 889 797 890 798 struct snd_timer_read { 891 799 unsigned int resolution; ··· 920 810 SNDRV_TIMER_EVENT_MRESUME = SNDRV_TIMER_EVENT_RESUME + 10, 921 811 }; 922 812 813 + #ifndef __KERNEL__ 923 814 struct snd_timer_tread { 924 815 int event; 816 + __time_pad pad1; 925 817 struct timespec tstamp; 926 818 unsigned int val; 819 + __time_pad pad2; 927 820 }; 821 + #endif 928 822 929 823 /**************************************************************************** 930 824 * * ··· 936 822 * * 937 823 ****************************************************************************/ 938 824 939 - #define SNDRV_CTL_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 7) 825 + #define SNDRV_CTL_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 8) 940 826 941 827 struct snd_ctl_card_info { 942 828 int card; /* card number */ ··· 974 860 #define SNDRV_CTL_ELEM_ACCESS_WRITE (1<<1) 975 861 #define SNDRV_CTL_ELEM_ACCESS_READWRITE (SNDRV_CTL_ELEM_ACCESS_READ|SNDRV_CTL_ELEM_ACCESS_WRITE) 976 862 #define SNDRV_CTL_ELEM_ACCESS_VOLATILE (1<<2) /* control value may be changed without a notification */ 977 - #define SNDRV_CTL_ELEM_ACCESS_TIMESTAMP (1<<3) /* when was control changed */ 863 + // (1 << 3) is unused. 978 864 #define SNDRV_CTL_ELEM_ACCESS_TLV_READ (1<<4) /* TLV read is possible */ 979 865 #define SNDRV_CTL_ELEM_ACCESS_TLV_WRITE (1<<5) /* TLV write is possible */ 980 866 #define SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE (SNDRV_CTL_ELEM_ACCESS_TLV_READ|SNDRV_CTL_ELEM_ACCESS_TLV_WRITE) ··· 1040 926 } enumerated; 1041 927 unsigned char reserved[128]; 1042 928 } value; 1043 - union { 1044 - unsigned short d[4]; /* dimensions */ 1045 - unsigned short *d_ptr; /* indirect - obsoleted */ 1046 - } dimen; 1047 - unsigned char reserved[64-4*sizeof(unsigned short)]; 929 + unsigned char reserved[64]; 1048 930 }; 1049 931 1050 932 struct snd_ctl_elem_value { ··· 1065 955 } bytes; 1066 956 struct snd_aes_iec958 iec958; 1067 957 } value; /* RO */ 1068 - struct timespec tstamp; 1069 - unsigned char reserved[128-sizeof(struct timespec)]; 958 + unsigned char reserved[128]; 1070 959 }; 1071 960 1072 961 struct snd_ctl_tlv {
+48 -15
tools/perf/arch/arm64/util/header.c
··· 1 1 #include <stdio.h> 2 2 #include <stdlib.h> 3 3 #include <perf/cpumap.h> 4 + #include <util/cpumap.h> 4 5 #include <internal/cpumap.h> 5 6 #include <api/fs/fs.h> 7 + #include <errno.h> 6 8 #include "debug.h" 7 9 #include "header.h" 8 10 ··· 14 12 #define MIDR_VARIANT_SHIFT 20 15 13 #define MIDR_VARIANT_MASK (0xf << MIDR_VARIANT_SHIFT) 16 14 17 - char *get_cpuid_str(struct perf_pmu *pmu) 15 + static int _get_cpuid(char *buf, size_t sz, struct perf_cpu_map *cpus) 18 16 { 19 - char *buf = NULL; 20 - char path[PATH_MAX]; 21 17 const char *sysfs = sysfs__mountpoint(); 22 - int cpu; 23 18 u64 midr = 0; 24 - struct perf_cpu_map *cpus; 25 - FILE *file; 19 + int cpu; 26 20 27 - if (!sysfs || !pmu || !pmu->cpus) 28 - return NULL; 21 + if (!sysfs || sz < MIDR_SIZE) 22 + return EINVAL; 29 23 30 - buf = malloc(MIDR_SIZE); 31 - if (!buf) 32 - return NULL; 24 + cpus = perf_cpu_map__get(cpus); 33 25 34 - /* read midr from list of cpus mapped to this pmu */ 35 - cpus = perf_cpu_map__get(pmu->cpus); 36 26 for (cpu = 0; cpu < perf_cpu_map__nr(cpus); cpu++) { 27 + char path[PATH_MAX]; 28 + FILE *file; 29 + 37 30 scnprintf(path, PATH_MAX, "%s/devices/system/cpu/cpu%d"MIDR, 38 31 sysfs, cpus->map[cpu]); 39 32 ··· 54 57 break; 55 58 } 56 59 57 - if (!midr) { 60 + perf_cpu_map__put(cpus); 61 + 62 + if (!midr) 63 + return EINVAL; 64 + 65 + return 0; 66 + } 67 + 68 + int get_cpuid(char *buf, size_t sz) 69 + { 70 + struct perf_cpu_map *cpus = perf_cpu_map__new(NULL); 71 + int ret; 72 + 73 + if (!cpus) 74 + return EINVAL; 75 + 76 + ret = _get_cpuid(buf, sz, cpus); 77 + 78 + perf_cpu_map__put(cpus); 79 + 80 + return ret; 81 + } 82 + 83 + char *get_cpuid_str(struct perf_pmu *pmu) 84 + { 85 + char *buf = NULL; 86 + int res; 87 + 88 + if (!pmu || !pmu->cpus) 89 + return NULL; 90 + 91 + buf = malloc(MIDR_SIZE); 92 + if (!buf) 93 + return NULL; 94 + 95 + /* read midr from list of cpus mapped to this pmu */ 96 + res = _get_cpuid(buf, MIDR_SIZE, pmu->cpus); 97 + if (res) { 58 98 pr_err("failed to get cpuid string for PMU %s\n", pmu->name); 59 99 free(buf); 60 100 buf = NULL; 61 101 } 62 102 63 - perf_cpu_map__put(cpus); 64 103 return buf; 65 104 }
+2
tools/perf/arch/x86/entry/syscalls/syscall_64.tbl
··· 357 357 433 common fspick __x64_sys_fspick 358 358 434 common pidfd_open __x64_sys_pidfd_open 359 359 435 common clone3 __x64_sys_clone3/ptregs 360 + 437 common openat2 __x64_sys_openat2 361 + 438 common pidfd_getfd __x64_sys_pidfd_getfd 360 362 361 363 # 362 364 # x32-specific system call numbers start at 512 to avoid cache impact
+3 -1
tools/perf/builtin-trace.c
··· 1065 1065 { .name = "poll", .timeout = true, }, 1066 1066 { .name = "ppoll", .timeout = true, }, 1067 1067 { .name = "prctl", 1068 - .arg = { [0] = { .scnprintf = SCA_PRCTL_OPTION, /* option */ }, 1068 + .arg = { [0] = { .scnprintf = SCA_PRCTL_OPTION, /* option */ 1069 + .strtoul = STUL_STRARRAY, 1070 + .parm = &strarray__prctl_options, }, 1069 1071 [1] = { .scnprintf = SCA_PRCTL_ARG2, /* arg2 */ }, 1070 1072 [2] = { .scnprintf = SCA_PRCTL_ARG3, /* arg3 */ }, }, }, 1071 1073 { .name = "pread", .alias = "pread64", },
+1
tools/perf/check-headers.sh
··· 13 13 include/uapi/linux/kvm.h 14 14 include/uapi/linux/in.h 15 15 include/uapi/linux/mount.h 16 + include/uapi/linux/openat2.h 16 17 include/uapi/linux/perf_event.h 17 18 include/uapi/linux/prctl.h 18 19 include/uapi/linux/sched.h
+2
tools/perf/trace/beauty/beauty.h
··· 213 213 size_t syscall_arg__scnprintf_prctl_option(char *bf, size_t size, struct syscall_arg *arg); 214 214 #define SCA_PRCTL_OPTION syscall_arg__scnprintf_prctl_option 215 215 216 + extern struct strarray strarray__prctl_options; 217 + 216 218 size_t syscall_arg__scnprintf_prctl_arg2(char *bf, size_t size, struct syscall_arg *arg); 217 219 #define SCA_PRCTL_ARG2 syscall_arg__scnprintf_prctl_arg2 218 220
+2 -1
tools/perf/trace/beauty/prctl.c
··· 11 11 12 12 #include "trace/beauty/generated/prctl_option_array.c" 13 13 14 + DEFINE_STRARRAY(prctl_options, "PR_"); 15 + 14 16 static size_t prctl__scnprintf_option(int option, char *bf, size_t size, bool show_prefix) 15 17 { 16 - static DEFINE_STRARRAY(prctl_options, "PR_"); 17 18 return strarray__scnprintf(&strarray__prctl_options, bf, size, "%d", show_prefix, option); 18 19 } 19 20
+1
tools/perf/util/llvm-utils.c
··· 288 288 "obj-y := dummy.o\n" 289 289 "\\$(obj)/%.o: \\$(src)/%.c\n" 290 290 "\t@echo -n \"\\$(NOSTDINC_FLAGS) \\$(LINUXINCLUDE) \\$(EXTRA_CFLAGS)\"\n" 291 + "\t\\$(CC) -c -o \\$@ \\$<\n" 291 292 "EOF\n" 292 293 "touch $TMPDIR/dummy.c\n" 293 294 "make -s -C $KBUILD_DIR M=$TMPDIR $KBUILD_OPTS dummy.o 2>/dev/null\n"
+12 -14
tools/perf/util/machine.c
··· 686 686 687 687 dso__set_module_info(dso, m, machine); 688 688 dso__set_long_name(dso, strdup(filename), true); 689 + dso->kernel = DSO_TYPE_KERNEL; 689 690 } 690 691 691 692 dso__get(dso); ··· 727 726 struct map *map = maps__find(&machine->kmaps, event->ksymbol.addr); 728 727 729 728 if (!map) { 730 - map = dso__new_map(event->ksymbol.name); 731 - if (!map) 729 + struct dso *dso = dso__new(event->ksymbol.name); 730 + 731 + if (dso) { 732 + dso->kernel = DSO_TYPE_KERNEL; 733 + map = map__new2(0, dso); 734 + } 735 + 736 + if (!dso || !map) { 737 + dso__put(dso); 732 738 return -ENOMEM; 739 + } 733 740 734 741 map->start = event->ksymbol.addr; 735 742 map->end = map->start + event->ksymbol.len; ··· 981 972 982 973 kmap = map__kmap(map); 983 974 984 - kmap->kmaps = &machine->kmaps; 985 975 strlcpy(kmap->name, xm->name, KMAP_NAME_LEN); 986 976 987 977 maps__insert(&machine->kmaps, map); ··· 1090 1082 static int 1091 1083 __machine__create_kernel_maps(struct machine *machine, struct dso *kernel) 1092 1084 { 1093 - struct kmap *kmap; 1094 - struct map *map; 1095 - 1096 1085 /* In case of renewal the kernel map, destroy previous one */ 1097 1086 machine__destroy_kernel_maps(machine); 1098 1087 ··· 1098 1093 return -1; 1099 1094 1100 1095 machine->vmlinux_map->map_ip = machine->vmlinux_map->unmap_ip = identity__map_ip; 1101 - map = machine__kernel_map(machine); 1102 - kmap = map__kmap(map); 1103 - if (!kmap) 1104 - return -1; 1105 - 1106 - kmap->kmaps = &machine->kmaps; 1107 - maps__insert(&machine->kmaps, map); 1108 - 1096 + maps__insert(&machine->kmaps, machine->vmlinux_map); 1109 1097 return 0; 1110 1098 } 1111 1099
+16 -1
tools/perf/util/map.c
··· 375 375 376 376 struct map *map__clone(struct map *from) 377 377 { 378 - struct map *map = memdup(from, sizeof(*map)); 378 + size_t size = sizeof(struct map); 379 + struct map *map; 379 380 381 + if (from->dso && from->dso->kernel) 382 + size += sizeof(struct kmap); 383 + 384 + map = memdup(from, size); 380 385 if (map != NULL) { 381 386 refcount_set(&map->refcnt, 1); 382 387 RB_CLEAR_NODE(&map->rb_node); ··· 542 537 down_write(&maps->lock); 543 538 __maps__insert(maps, map); 544 539 ++maps->nr_maps; 540 + 541 + if (map->dso && map->dso->kernel) { 542 + struct kmap *kmap = map__kmap(map); 543 + 544 + if (kmap) 545 + kmap->kmaps = maps; 546 + else 547 + pr_err("Internal error: kernel dso with non kernel map\n"); 548 + } 549 + 545 550 546 551 /* 547 552 * If we already performed some search by name, then we need to add the just
-6
tools/perf/util/stat-shadow.c
··· 18 18 * AGGR_NONE: Use matching CPU 19 19 * AGGR_THREAD: Not supported? 20 20 */ 21 - static bool have_frontend_stalled; 22 21 23 22 struct runtime_stat rt_stat; 24 23 struct stats walltime_nsecs_stats; ··· 143 144 144 145 void perf_stat__init_shadow_stats(void) 145 146 { 146 - have_frontend_stalled = pmu_have_event("cpu", "stalled-cycles-frontend"); 147 147 runtime_stat__init(&rt_stat); 148 148 } 149 149 ··· 851 853 print_metric(config, ctxp, NULL, "%7.2f ", 852 854 "stalled cycles per insn", 853 855 ratio); 854 - } else if (have_frontend_stalled) { 855 - out->new_line(config, ctxp); 856 - print_metric(config, ctxp, NULL, "%7.2f ", 857 - "stalled cycles per insn", 0); 858 856 } 859 857 } else if (perf_evsel__match(evsel, HARDWARE, HW_BRANCH_MISSES)) { 860 858 if (runtime_stat_n(st, STAT_BRANCHES, ctx, cpu) != 0)
+12 -5
tools/perf/util/symbol.c
··· 635 635 static bool symbol__is_idle(const char *name) 636 636 { 637 637 const char * const idle_symbols[] = { 638 + "acpi_idle_do_entry", 639 + "acpi_processor_ffh_cstate_enter", 638 640 "arch_cpu_idle", 639 641 "cpu_idle", 640 642 "cpu_startup_entry", 643 + "idle_cpu", 641 644 "intel_idle", 642 645 "default_idle", 643 646 "native_safe_halt", ··· 654 651 NULL 655 652 }; 656 653 int i; 654 + static struct strlist *idle_symbols_list; 657 655 658 - for (i = 0; idle_symbols[i]; i++) { 659 - if (!strcmp(idle_symbols[i], name)) 660 - return true; 661 - } 656 + if (idle_symbols_list) 657 + return strlist__has_entry(idle_symbols_list, name); 662 658 663 - return false; 659 + idle_symbols_list = strlist__new(NULL, NULL); 660 + 661 + for (i = 0; idle_symbols[i]; i++) 662 + strlist__add(idle_symbols_list, idle_symbols[i]); 663 + 664 + return strlist__has_entry(idle_symbols_list, name); 664 665 } 665 666 666 667 static int map__process_kallsym_symbol(void *arg, const char *name,
+11
tools/testing/selftests/wireguard/netns.sh
··· 24 24 set -e 25 25 26 26 exec 3>&1 27 + export LANG=C 27 28 export WG_HIDE_KEYS=never 28 29 netns0="wg-test-$$-0" 29 30 netns1="wg-test-$$-1" ··· 298 297 n1 ping -W 1 -c 100 -f 192.168.99.7 299 298 n1 ping -W 1 -c 100 -f abab::1111 300 299 300 + # Have ns2 NAT into wg0 packets from ns0, but return an icmp error along the right route. 301 + n2 iptables -t nat -A POSTROUTING -s 10.0.0.0/24 -d 192.168.241.0/24 -j SNAT --to 192.168.241.2 302 + n0 iptables -t filter -A INPUT \! -s 10.0.0.0/24 -i vethrs -j DROP # Manual rpfilter just to be explicit. 303 + n2 bash -c 'printf 1 > /proc/sys/net/ipv4/ip_forward' 304 + ip0 -4 route add 192.168.241.1 via 10.0.0.100 305 + n2 wg set wg0 peer "$pub1" remove 306 + [[ $(! n0 ping -W 1 -c 1 192.168.241.1 || false) == *"From 10.0.0.100 icmp_seq=1 Destination Host Unreachable"* ]] 307 + 301 308 n0 iptables -t nat -F 309 + n0 iptables -t filter -F 310 + n2 iptables -t nat -F 302 311 ip0 link del vethrc 303 312 ip0 link del vethrs 304 313 ip1 link del wg0