We want the fixes in here as well.
Unified · Split
| @@ -184,6 +184,11 @@ API for implementing a new FPGA Manager driver · 183 unmodified lines | ||
| 184 | 184 | API for programming an FPGA |
| 185 | 185 | --------------------------- |
| 186 | 186 | |
| 187 | +FPGA Manager flags | |
| 188 | + | |
| 189 | +.. kernel-doc:: include/linux/fpga/fpga-mgr.h | |
| 190 | + :doc: FPGA Manager flags | |
| 191 | + | |
| 187 | 192 | .. kernel-doc:: include/linux/fpga/fpga-mgr.h |
| 188 | 193 | :functions: fpga_image_info |
| 189 | 194 | |
| @@ -15,7 +15,8 @@ than x86. Check the v86d documentation for a list of currently supported · 14 unmodified lines | ||
| 15 | 15 | arches. |
| 16 | 16 | |
| 17 | 17 | v86d source code can be downloaded from the following website: |
| 18 | − http://dev.gentoo.org/~spock/projects/uvesafb | |
| 18 | + | |
| 19 | + https://github.com/mjanusz/v86d | |
| 19 | 20 | |
| 20 | 21 | Please refer to the v86d documentation for detailed configuration and |
| 21 | 22 | installation instructions. |
| @@ -177,7 +178,7 @@ from the Video BIOS if you set pixclock to 0 in fb_var_screeninfo. · 155 unmodified lines | ||
| 177 | 178 | |
| 178 | 179 | -- |
| 179 | 180 | Michal Januszewski <spock@gentoo.org> |
| 180 | − Last updated: 2009-03-30 | |
| 181 | + Last updated: 2017-10-10 | |
| 181 | 182 | |
| 182 | 183 | Documentation of the uvesafb options is loosely based on vesafb.txt. |
| 183 | 184 | |
| @@ -425,7 +425,7 @@ tcp_mtu_probing - INTEGER · 424 unmodified lines | ||
| 425 | 425 | 1 - Disabled by default, enabled when an ICMP black hole detected |
| 426 | 426 | 2 - Always enabled, use initial MSS of tcp_base_mss. |
| 427 | 427 | |
| 428 | −tcp_probe_interval - INTEGER | |
| 428 | +tcp_probe_interval - UNSIGNED INTEGER | |
| 429 | 429 | Controls how often to start TCP Packetization-Layer Path MTU |
| 430 | 430 | Discovery reprobe. The default is reprobing every 10 minutes as |
| 431 | 431 | per RFC4821. |
| @@ -324,7 +324,6 @@ F: Documentation/ABI/testing/sysfs-bus-acpi · 323 unmodified lines | ||
| 324 | 324 | F: Documentation/ABI/testing/configfs-acpi |
| 325 | 325 | F: drivers/pci/*acpi* |
| 326 | 326 | F: drivers/pci/*/*acpi* |
| 327 | −F: drivers/pci/*/*/*acpi* | |
| 328 | 327 | F: tools/power/acpi/ |
| 329 | 328 | |
| 330 | 329 | ACPI APEI |
| @@ -1251,7 +1250,7 @@ N: meson · 920 unmodified lines | ||
| 1251 | 1250 | |
| 1252 | 1251 | ARM/Annapurna Labs ALPINE ARCHITECTURE |
| 1253 | 1252 | M: Tsahee Zidenberg <tsahee@annapurnalabs.com> |
| 1254 | −M: Antoine Tenart <antoine.tenart@free-electrons.com> | |
| 1253 | +M: Antoine Tenart <antoine.tenart@bootlin.com> | |
| 1255 | 1254 | L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) |
| 1256 | 1255 | S: Maintained |
| 1257 | 1256 | F: arch/arm/mach-alpine/ |
| @@ -2956,7 +2955,6 @@ F: include/linux/bcm963xx_tag.h · 1698 unmodified lines | ||
| 2956 | 2955 | |
| 2957 | 2956 | BROADCOM BNX2 GIGABIT ETHERNET DRIVER |
| 2958 | 2957 | M: Rasesh Mody <rasesh.mody@cavium.com> |
| 2959 | −M: Harish Patil <harish.patil@cavium.com> | |
| 2960 | 2958 | M: Dept-GELinuxNICDev@cavium.com |
| 2961 | 2959 | L: netdev@vger.kernel.org |
| 2962 | 2960 | S: Supported |
| @@ -2977,6 +2975,7 @@ F: drivers/scsi/bnx2i/ · 14 unmodified lines | ||
| 2977 | 2975 | |
| 2978 | 2976 | BROADCOM BNX2X 10 GIGABIT ETHERNET DRIVER |
| 2979 | 2977 | M: Ariel Elior <ariel.elior@cavium.com> |
| 2978 | +M: Sudarsana Kalluru <sudarsana.kalluru@cavium.com> | |
| 2980 | 2979 | M: everest-linux-l2@cavium.com |
| 2981 | 2980 | L: netdev@vger.kernel.org |
| 2982 | 2981 | S: Supported |
| @@ -5470,7 +5469,8 @@ S: Odd Fixes · 2487 unmodified lines | ||
| 5470 | 5469 | F: drivers/net/ethernet/agere/ |
| 5471 | 5470 | |
| 5472 | 5471 | ETHERNET BRIDGE |
| 5473 | −M: Stephen Hemminger <stephen@networkplumber.org> | |
| 5472 | +M: Roopa Prabhu <roopa@cumulusnetworks.com> | |
| 5473 | +M: Nikolay Aleksandrov <nikolay@cumulusnetworks.com> | |
| 5474 | 5474 | L: bridge@lists.linux-foundation.org (moderated for non-subscribers) |
| 5475 | 5475 | L: netdev@vger.kernel.org |
| 5476 | 5476 | W: http://www.linuxfoundation.org/en/Net:Bridge |
| @@ -8598,7 +8598,6 @@ F: include/linux/spinlock*.h · 3121 unmodified lines | ||
| 8598 | 8598 | F: arch/*/include/asm/spinlock*.h |
| 8599 | 8599 | F: include/linux/rwlock*.h |
| 8600 | 8600 | F: include/linux/mutex*.h |
| 8601 | −F: arch/*/include/asm/mutex*.h | |
| 8602 | 8601 | F: include/linux/rwsem*.h |
| 8603 | 8602 | F: arch/*/include/asm/rwsem.h |
| 8604 | 8603 | F: include/linux/seqlock.h |
| @@ -11979,7 +11978,7 @@ F: Documentation/scsi/LICENSE.qla4xxx · 3374 unmodified lines | ||
| 11979 | 11978 | F: drivers/scsi/qla4xxx/ |
| 11980 | 11979 | |
| 11981 | 11980 | QLOGIC QLCNIC (1/10)Gb ETHERNET DRIVER |
| 11982 | −M: Harish Patil <harish.patil@cavium.com> | |
| 11981 | +M: Shahed Shaikh <Shahed.Shaikh@cavium.com> | |
| 11983 | 11982 | M: Manish Chopra <manish.chopra@cavium.com> |
| 11984 | 11983 | M: Dept-GELinuxNICDev@cavium.com |
| 11985 | 11984 | L: netdev@vger.kernel.org |
| @@ -11987,7 +11986,6 @@ S: Supported · 1 unmodified line | ||
| 11987 | 11986 | F: drivers/net/ethernet/qlogic/qlcnic/ |
| 11988 | 11987 | |
| 11989 | 11988 | QLOGIC QLGE 10Gb ETHERNET DRIVER |
| 11990 | −M: Harish Patil <harish.patil@cavium.com> | |
| 11991 | 11989 | M: Manish Chopra <manish.chopra@cavium.com> |
| 11992 | 11990 | M: Dept-GELinuxNICDev@cavium.com |
| 11993 | 11991 | L: netdev@vger.kernel.org |
| @@ -15395,7 +15393,7 @@ S: Maintained · 3401 unmodified lines | ||
| 15395 | 15393 | UVESAFB DRIVER |
| 15396 | 15394 | M: Michal Januszewski <spock@gentoo.org> |
| 15397 | 15395 | L: linux-fbdev@vger.kernel.org |
| 15398 | −W: http://dev.gentoo.org/~spock/projects/uvesafb/ | |
| 15396 | +W: https://github.com/mjanusz/v86d | |
| 15399 | 15397 | S: Maintained |
| 15400 | 15398 | F: Documentation/fb/uvesafb.txt |
| 15401 | 15399 | F: drivers/video/fbdev/uvesafb.* |
| @@ -2,7 +2,7 @@ · 1 unmodified line | ||
| 2 | 2 | VERSION = 4 |
| 3 | 3 | PATCHLEVEL = 19 |
| 4 | 4 | SUBLEVEL = 0 |
| 5 | −EXTRAVERSION = -rc6 | |
| 5 | +EXTRAVERSION = -rc7 | |
| 6 | 6 | NAME = Merciless Moray |
| 7 | 7 | |
| 8 | 8 | # *DOCUMENTATION* |
| @@ -11,6 +11,7 @@ · 10 unmodified lines | ||
| 11 | 11 | #include "sama5d2-pinfunc.h" |
| 12 | 12 | #include <dt-bindings/mfd/atmel-flexcom.h> |
| 13 | 13 | #include <dt-bindings/gpio/gpio.h> |
| 14 | +#include <dt-bindings/pinctrl/at91.h> | |
| 14 | 15 | |
| 15 | 16 | / { |
| 16 | 17 | model = "Atmel SAMA5D2 PTC EK"; |
| @@ -299,6 +300,7 @@ · 282 unmodified lines | ||
| 299 | 300 | <PIN_PA30__NWE_NANDWE>, |
| 300 | 301 | <PIN_PB2__NRD_NANDOE>; |
| 301 | 302 | bias-pull-up; |
| 303 | + atmel,drive-strength = <ATMEL_PIO_DRVSTR_ME>; | |
| 302 | 304 | }; |
| 303 | 305 | |
| 304 | 306 | ale_cle_rdy_cs { |
| @@ -106,21 +106,23 @@ · 105 unmodified lines | ||
| 106 | 106 | global_timer: timer@1e200 { |
| 107 | 107 | compatible = "arm,cortex-a9-global-timer"; |
| 108 | 108 | reg = <0x1e200 0x20>; |
| 109 | − interrupts = <GIC_PPI 11 IRQ_TYPE_LEVEL_HIGH>; | |
| 109 | + interrupts = <GIC_PPI 11 IRQ_TYPE_EDGE_RISING>; | |
| 110 | 110 | clocks = <&axi_clk>; |
| 111 | 111 | }; |
| 112 | 112 | |
| 113 | 113 | local_timer: local-timer@1e600 { |
| 114 | 114 | compatible = "arm,cortex-a9-twd-timer"; |
| 115 | 115 | reg = <0x1e600 0x20>; |
| 116 | − interrupts = <GIC_PPI 13 IRQ_TYPE_LEVEL_HIGH>; | |
| 116 | + interrupts = <GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(2) | | |
| 117 | + IRQ_TYPE_EDGE_RISING)>; | |
| 117 | 118 | clocks = <&axi_clk>; |
| 118 | 119 | }; |
| 119 | 120 | |
| 120 | 121 | twd_watchdog: watchdog@1e620 { |
| 121 | 122 | compatible = "arm,cortex-a9-twd-wdt"; |
| 122 | 123 | reg = <0x1e620 0x20>; |
| 123 | − interrupts = <GIC_PPI 14 IRQ_TYPE_LEVEL_HIGH>; | |
| 124 | + interrupts = <GIC_PPI 14 (GIC_CPU_MASK_SIMPLE(2) | | |
| 125 | + IRQ_TYPE_LEVEL_HIGH)>; | |
| 124 | 126 | }; |
| 125 | 127 | |
| 126 | 128 | armpll: armpll { |
| @@ -158,7 +160,7 @@ · 31 unmodified lines | ||
| 158 | 160 | serial0: serial@600 { |
| 159 | 161 | compatible = "brcm,bcm6345-uart"; |
| 160 | 162 | reg = <0x600 0x1b>; |
| 161 | − interrupts = <GIC_SPI 32 0>; | |
| 163 | + interrupts = <GIC_SPI 32 IRQ_TYPE_LEVEL_HIGH>; | |
| 162 | 164 | clocks = <&periph_clk>; |
| 163 | 165 | clock-names = "periph"; |
| 164 | 166 | status = "disabled"; |
| @@ -167,7 +169,7 @@ · 2 unmodified lines | ||
| 167 | 169 | serial1: serial@620 { |
| 168 | 170 | compatible = "brcm,bcm6345-uart"; |
| 169 | 171 | reg = <0x620 0x1b>; |
| 170 | − interrupts = <GIC_SPI 33 0>; | |
| 172 | + interrupts = <GIC_SPI 33 IRQ_TYPE_LEVEL_HIGH>; | |
| 171 | 173 | clocks = <&periph_clk>; |
| 172 | 174 | clock-names = "periph"; |
| 173 | 175 | status = "disabled"; |
| @@ -180,7 +182,7 @@ · 6 unmodified lines | ||
| 180 | 182 | reg = <0x2000 0x600>, <0xf0 0x10>; |
| 181 | 183 | reg-names = "nand", "nand-int-base"; |
| 182 | 184 | status = "disabled"; |
| 183 | − interrupts = <GIC_SPI 38 0>; | |
| 185 | + interrupts = <GIC_SPI 38 IRQ_TYPE_LEVEL_HIGH>; | |
| 184 | 186 | interrupt-names = "nand"; |
| 185 | 187 | }; |
| 186 | 188 | |
| @@ -1078,8 +1078,8 @@ · 1077 unmodified lines | ||
| 1078 | 1078 | interrupts = <GIC_SPI 86 IRQ_TYPE_LEVEL_HIGH>; |
| 1079 | 1079 | clocks = <&rcc SPI6_K>; |
| 1080 | 1080 | resets = <&rcc SPI6_R>; |
| 1081 | − dmas = <&mdma1 34 0x0 0x40008 0x0 0x0 0>, | |
| 1082 | − <&mdma1 35 0x0 0x40002 0x0 0x0 0>; | |
| 1081 | + dmas = <&mdma1 34 0x0 0x40008 0x0 0x0>, | |
| 1082 | + <&mdma1 35 0x0 0x40002 0x0 0x0>; | |
| 1083 | 1083 | dma-names = "rx", "tx"; |
| 1084 | 1084 | status = "disabled"; |
| 1085 | 1085 | }; |
| @@ -800,8 +800,7 @@ · 799 unmodified lines | ||
| 800 | 800 | }; |
| 801 | 801 | |
| 802 | 802 | hdmi_phy: hdmi-phy@1ef0000 { |
| 803 | − compatible = "allwinner,sun8i-r40-hdmi-phy", | |
| 804 | − "allwinner,sun50i-a64-hdmi-phy"; | |
| 803 | + compatible = "allwinner,sun8i-r40-hdmi-phy"; | |
| 805 | 804 | reg = <0x01ef0000 0x10000>; |
| 806 | 805 | clocks = <&ccu CLK_BUS_HDMI1>, <&ccu CLK_HDMI_SLOW>, |
| 807 | 806 | <&ccu 7>, <&ccu 16>; |
| @@ -473,7 +473,7 @@ void pci_ioremap_set_mem_type(int mem_type) · 472 unmodified lines | ||
| 473 | 473 | |
| 474 | 474 | int pci_ioremap_io(unsigned int offset, phys_addr_t phys_addr) |
| 475 | 475 | { |
| 476 | − BUG_ON(offset + SZ_64K > IO_SPACE_LIMIT); | |
| 476 | + BUG_ON(offset + SZ_64K - 1 > IO_SPACE_LIMIT); | |
| 477 | 477 | |
| 478 | 478 | return ioremap_page_range(PCI_IO_VIRT_BASE + offset, |
| 479 | 479 | PCI_IO_VIRT_BASE + offset + SZ_64K, |
| @@ -413,3 +413,4 @@ · 412 unmodified lines | ||
| 413 | 413 | 396 common pkey_free sys_pkey_free |
| 414 | 414 | 397 common statx sys_statx |
| 415 | 415 | 398 common rseq sys_rseq |
| 416 | +399 common io_pgetevents sys_io_pgetevents | |
| @@ -57,6 +57,45 @@ static u64 core_reg_offset_from_id(u64 id) · 56 unmodified lines | ||
| 57 | 57 | return id & ~(KVM_REG_ARCH_MASK | KVM_REG_SIZE_MASK | KVM_REG_ARM_CORE); |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | +static int validate_core_offset(const struct kvm_one_reg *reg) | |
| 61 | +{ | |
| 62 | + u64 off = core_reg_offset_from_id(reg->id); | |
| 63 | + int size; | |
| 64 | + | |
| 65 | + switch (off) { | |
| 66 | + case KVM_REG_ARM_CORE_REG(regs.regs[0]) ... | |
| 67 | + KVM_REG_ARM_CORE_REG(regs.regs[30]): | |
| 68 | + case KVM_REG_ARM_CORE_REG(regs.sp): | |
| 69 | + case KVM_REG_ARM_CORE_REG(regs.pc): | |
| 70 | + case KVM_REG_ARM_CORE_REG(regs.pstate): | |
| 71 | + case KVM_REG_ARM_CORE_REG(sp_el1): | |
| 72 | + case KVM_REG_ARM_CORE_REG(elr_el1): | |
| 73 | + case KVM_REG_ARM_CORE_REG(spsr[0]) ... | |
| 74 | + KVM_REG_ARM_CORE_REG(spsr[KVM_NR_SPSR - 1]): | |
| 75 | + size = sizeof(__u64); | |
| 76 | + break; | |
| 77 | + | |
| 78 | + case KVM_REG_ARM_CORE_REG(fp_regs.vregs[0]) ... | |
| 79 | + KVM_REG_ARM_CORE_REG(fp_regs.vregs[31]): | |
| 80 | + size = sizeof(__uint128_t); | |
| 81 | + break; | |
| 82 | + | |
| 83 | + case KVM_REG_ARM_CORE_REG(fp_regs.fpsr): | |
| 84 | + case KVM_REG_ARM_CORE_REG(fp_regs.fpcr): | |
| 85 | + size = sizeof(__u32); | |
| 86 | + break; | |
| 87 | + | |
| 88 | + default: | |
| 89 | + return -EINVAL; | |
| 90 | + } | |
| 91 | + | |
| 92 | + if (KVM_REG_SIZE(reg->id) == size && | |
| 93 | + IS_ALIGNED(off, size / sizeof(__u32))) | |
| 94 | + return 0; | |
| 95 | + | |
| 96 | + return -EINVAL; | |
| 97 | +} | |
| 98 | + | |
| 60 | 99 | static int get_core_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg) |
| 61 | 100 | { |
| 62 | 101 | /* |
| @@ -76,6 +115,9 @@ static int get_core_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg) · 13 unmodified lines | ||
| 76 | 115 | (off + (KVM_REG_SIZE(reg->id) / sizeof(__u32))) >= nr_regs) |
| 77 | 116 | return -ENOENT; |
| 78 | 117 | |
| 118 | + if (validate_core_offset(reg)) | |
| 119 | + return -EINVAL; | |
| 120 | + | |
| 79 | 121 | if (copy_to_user(uaddr, ((u32 *)regs) + off, KVM_REG_SIZE(reg->id))) |
| 80 | 122 | return -EFAULT; |
| 81 | 123 | |
| @@ -98,6 +140,9 @@ static int set_core_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg) · 16 unmodified lines | ||
| 98 | 140 | (off + (KVM_REG_SIZE(reg->id) / sizeof(__u32))) >= nr_regs) |
| 99 | 141 | return -ENOENT; |
| 100 | 142 | |
| 143 | + if (validate_core_offset(reg)) | |
| 144 | + return -EINVAL; | |
| 145 | + | |
| 101 | 146 | if (KVM_REG_SIZE(reg->id) > sizeof(tmp)) |
| 102 | 147 | return -EINVAL; |
| 103 | 148 | |
| @@ -107,17 +152,25 @@ static int set_core_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg) · 3 unmodified lines | ||
| 107 | 152 | } |
| 108 | 153 | |
| 109 | 154 | if (off == KVM_REG_ARM_CORE_REG(regs.pstate)) { |
| 110 | − u32 mode = (*(u32 *)valp) & PSR_AA32_MODE_MASK; | |
| 155 | + u64 mode = (*(u64 *)valp) & PSR_AA32_MODE_MASK; | |
| 111 | 156 | switch (mode) { |
| 112 | 157 | case PSR_AA32_MODE_USR: |
| 158 | + if (!system_supports_32bit_el0()) | |
| 159 | + return -EINVAL; | |
| 160 | + break; | |
| 113 | 161 | case PSR_AA32_MODE_FIQ: |
| 114 | 162 | case PSR_AA32_MODE_IRQ: |
| 115 | 163 | case PSR_AA32_MODE_SVC: |
| 116 | 164 | case PSR_AA32_MODE_ABT: |
| 117 | 165 | case PSR_AA32_MODE_UND: |
| 166 | + if (!vcpu_el1_is_32bit(vcpu)) | |
| 167 | + return -EINVAL; | |
| 168 | + break; | |
| 118 | 169 | case PSR_MODE_EL0t: |
| 119 | 170 | case PSR_MODE_EL1t: |
| 120 | 171 | case PSR_MODE_EL1h: |
| 172 | + if (vcpu_el1_is_32bit(vcpu)) | |
| 173 | + return -EINVAL; | |
| 121 | 174 | break; |
| 122 | 175 | default: |
| 123 | 176 | err = -EINVAL; |
| @@ -117,11 +117,14 @@ static pte_t get_clear_flush(struct mm_struct *mm, · 116 unmodified lines | ||
| 117 | 117 | |
| 118 | 118 | /* |
| 119 | 119 | * If HW_AFDBM is enabled, then the HW could turn on |
| 120 | − * the dirty bit for any page in the set, so check | |
| 121 | − * them all. All hugetlb entries are already young. | |
| 120 | + * the dirty or accessed bit for any page in the set, | |
| 121 | + * so check them all. | |
| 122 | 122 | */ |
| 123 | 123 | if (pte_dirty(pte)) |
| 124 | 124 | orig_pte = pte_mkdirty(orig_pte); |
| 125 | + | |
| 126 | + if (pte_young(pte)) | |
| 127 | + orig_pte = pte_mkyoung(orig_pte); | |
| 125 | 128 | } |
| 126 | 129 | |
| 127 | 130 | if (valid) { |
| @@ -320,11 +323,40 @@ pte_t huge_ptep_get_and_clear(struct mm_struct *mm, · 192 unmodified lines | ||
| 320 | 323 | return get_clear_flush(mm, addr, ptep, pgsize, ncontig); |
| 321 | 324 | } |
| 322 | 325 | |
| 326 | +/* | |
| 327 | + * huge_ptep_set_access_flags will update access flags (dirty, accesssed) | |
| 328 | + * and write permission. | |
| 329 | + * | |
| 330 | + * For a contiguous huge pte range we need to check whether or not write | |
| 331 | + * permission has to change only on the first pte in the set. Then for | |
| 332 | + * all the contiguous ptes we need to check whether or not there is a | |
| 333 | + * discrepancy between dirty or young. | |
| 334 | + */ | |
| 335 | +static int __cont_access_flags_changed(pte_t *ptep, pte_t pte, int ncontig) | |
| 336 | +{ | |
| 337 | + int i; | |
| 338 | + | |
| 339 | + if (pte_write(pte) != pte_write(huge_ptep_get(ptep))) | |
| 340 | + return 1; | |
| 341 | + | |
| 342 | + for (i = 0; i < ncontig; i++) { | |
| 343 | + pte_t orig_pte = huge_ptep_get(ptep + i); | |
| 344 | + | |
| 345 | + if (pte_dirty(pte) != pte_dirty(orig_pte)) | |
| 346 | + return 1; | |
| 347 | + | |
| 348 | + if (pte_young(pte) != pte_young(orig_pte)) | |
| 349 | + return 1; | |
| 350 | + } | |
| 351 | + | |
| 352 | + return 0; | |
| 353 | +} | |
| 354 | + | |
| 323 | 355 | int huge_ptep_set_access_flags(struct vm_area_struct *vma, |
| 324 | 356 | unsigned long addr, pte_t *ptep, |
| 325 | 357 | pte_t pte, int dirty) |
| 326 | 358 | { |
| 327 | − int ncontig, i, changed = 0; | |
| 359 | + int ncontig, i; | |
| 328 | 360 | size_t pgsize = 0; |
| 329 | 361 | unsigned long pfn = pte_pfn(pte), dpfn; |
| 330 | 362 | pgprot_t hugeprot; |
| @@ -336,19 +368,23 @@ int huge_ptep_set_access_flags(struct vm_area_struct *vma, · 5 unmodified lines | ||
| 336 | 368 | ncontig = find_num_contig(vma->vm_mm, addr, ptep, &pgsize); |
| 337 | 369 | dpfn = pgsize >> PAGE_SHIFT; |
| 338 | 370 | |
| 371 | + if (!__cont_access_flags_changed(ptep, pte, ncontig)) | |
| 372 | + return 0; | |
| 373 | + | |
| 339 | 374 | orig_pte = get_clear_flush(vma->vm_mm, addr, ptep, pgsize, ncontig); |
| 340 | − if (!pte_same(orig_pte, pte)) | |
| 341 | − changed = 1; | |
| 342 | 375 | |
| 343 | − /* Make sure we don't lose the dirty state */ | |
| 376 | + /* Make sure we don't lose the dirty or young state */ | |
| 344 | 377 | if (pte_dirty(orig_pte)) |
| 345 | 378 | pte = pte_mkdirty(pte); |
| 346 | 379 | |
| 380 | + if (pte_young(orig_pte)) | |
| 381 | + pte = pte_mkyoung(pte); | |
| 382 | + | |
| 347 | 383 | hugeprot = pte_pgprot(pte); |
| 348 | 384 | for (i = 0; i < ncontig; i++, ptep++, addr += pgsize, pfn += dpfn) |
| 349 | 385 | set_pte_at(vma->vm_mm, addr, ptep, pfn_pte(pfn, hugeprot)); |
| 350 | 386 | |
| 351 | − return changed; | |
| 387 | + return 1; | |
| 352 | 388 | } |
| 353 | 389 | |
| 354 | 390 | void huge_ptep_set_wrprotect(struct mm_struct *mm, |
| @@ -1306,6 +1306,16 @@ void show_user_instructions(struct pt_regs *regs) · 1305 unmodified lines | ||
| 1306 | 1306 | |
| 1307 | 1307 | pc = regs->nip - (instructions_to_print * 3 / 4 * sizeof(int)); |
| 1308 | 1308 | |
| 1309 | + /* | |
| 1310 | + * Make sure the NIP points at userspace, not kernel text/data or | |
| 1311 | + * elsewhere. | |
| 1312 | + */ | |
| 1313 | + if (!__access_ok(pc, instructions_to_print * sizeof(int), USER_DS)) { | |
| 1314 | + pr_info("%s[%d]: Bad NIP, not dumping instructions.\n", | |
| 1315 | + current->comm, current->pid); | |
| 1316 | + return; | |
| 1317 | + } | |
| 1318 | + | |
| 1309 | 1319 | pr_info("%s[%d]: code: ", current->comm, current->pid); |
| 1310 | 1320 | |
| 1311 | 1321 | for (i = 0; i < instructions_to_print; i++) { |
| @@ -646,6 +646,16 @@ int kvmppc_book3s_radix_page_fault(struct kvm_run *run, struct kvm_vcpu *vcpu, · 645 unmodified lines | ||
| 646 | 646 | */ |
| 647 | 647 | local_irq_disable(); |
| 648 | 648 | ptep = __find_linux_pte(vcpu->arch.pgdir, hva, NULL, &shift); |
| 649 | + /* | |
| 650 | + * If the PTE disappeared temporarily due to a THP | |
| 651 | + * collapse, just return and let the guest try again. | |
| 652 | + */ | |
| 653 | + if (!ptep) { | |
| 654 | + local_irq_enable(); | |
| 655 | + if (page) | |
| 656 | + put_page(page); | |
| 657 | + return RESUME_GUEST; | |
| 658 | + } | |
| 649 | 659 | pte = *ptep; |
| 650 | 660 | local_irq_enable(); |
| 651 | 661 | |
| @@ -28,12 +28,6 @@ static int __patch_instruction(unsigned int *exec_addr, unsigned int instr, · 27 unmodified lines | ||
| 28 | 28 | { |
| 29 | 29 | int err; |
| 30 | 30 | |
| 31 | − /* Make sure we aren't patching a freed init section */ | |
| 32 | − if (init_mem_is_free && init_section_contains(exec_addr, 4)) { | |
| 33 | − pr_debug("Skipping init section patching addr: 0x%px\n", exec_addr); | |
| 34 | − return 0; | |
| 35 | − } | |
| 36 | − | |
| 37 | 31 | __put_user_size(instr, patch_addr, 4, err); |
| 38 | 32 | if (err) |
| 39 | 33 | return err; |
| @@ -148,7 +142,7 @@ static inline int unmap_patch_area(unsigned long addr) · 108 unmodified lines | ||
| 148 | 142 | return 0; |
| 149 | 143 | } |
| 150 | 144 | |
| 151 | −int patch_instruction(unsigned int *addr, unsigned int instr) | |
| 145 | +static int do_patch_instruction(unsigned int *addr, unsigned int instr) | |
| 152 | 146 | { |
| 153 | 147 | int err; |
| 154 | 148 | unsigned int *patch_addr = NULL; |
| @@ -188,12 +182,22 @@ out: · 33 unmodified lines | ||
| 188 | 182 | } |
| 189 | 183 | #else /* !CONFIG_STRICT_KERNEL_RWX */ |
| 190 | 184 | |
| 191 | −int patch_instruction(unsigned int *addr, unsigned int instr) | |
| 185 | +static int do_patch_instruction(unsigned int *addr, unsigned int instr) | |
| 192 | 186 | { |
| 193 | 187 | return raw_patch_instruction(addr, instr); |
| 194 | 188 | } |
| 195 | 189 | |
| 196 | 190 | #endif /* CONFIG_STRICT_KERNEL_RWX */ |
| 191 | + | |
| 192 | +int patch_instruction(unsigned int *addr, unsigned int instr) | |
| 193 | +{ | |
| 194 | + /* Make sure we aren't patching a freed init section */ | |
| 195 | + if (init_mem_is_free && init_section_contains(addr, 4)) { | |
| 196 | + pr_debug("Skipping init section patching addr: 0x%px\n", addr); | |
| 197 | + return 0; | |
| 198 | + } | |
| 199 | + return do_patch_instruction(addr, instr); | |
| 200 | +} | |
| 197 | 201 | NOKPROBE_SYMBOL(patch_instruction); |
| 198 | 202 | |
| 199 | 203 | int patch_branch(unsigned int *addr, unsigned long target, int flags) |
| @@ -1217,9 +1217,10 @@ int find_and_online_cpu_nid(int cpu) · 1216 unmodified lines | ||
| 1217 | 1217 | * Need to ensure that NODE_DATA is initialized for a node from |
| 1218 | 1218 | * available memory (see memblock_alloc_try_nid). If unable to |
| 1219 | 1219 | * init the node, then default to nearest node that has memory |
| 1220 | − * installed. | |
| 1220 | + * installed. Skip onlining a node if the subsystems are not | |
| 1221 | + * yet initialized. | |
| 1221 | 1222 | */ |
| 1222 | − if (try_online_node(new_nid)) | |
| 1223 | + if (!topology_inited || try_online_node(new_nid)) | |
| 1223 | 1224 | new_nid = first_online_node; |
| 1224 | 1225 | #else |
| 1225 | 1226 | /* |
| @@ -186,7 +186,7 @@ static void __init setup_bootmem(void) · 185 unmodified lines | ||
| 186 | 186 | BUG_ON(mem_size == 0); |
| 187 | 187 | |
| 188 | 188 | set_max_mapnr(PFN_DOWN(mem_size)); |
| 189 | − max_low_pfn = pfn_base + PFN_DOWN(mem_size); | |
| 189 | + max_low_pfn = memblock_end_of_DRAM(); | |
| 190 | 190 | |
| 191 | 191 | #ifdef CONFIG_BLK_DEV_INITRD |
| 192 | 192 | setup_initrd(); |
| @@ -68,7 +68,13 @@ $(obj)/vdso-image-%.c: $(obj)/vdso%.so.dbg $(obj)/vdso%.so $(obj)/vdso2c FORCE · 67 unmodified lines | ||
| 68 | 68 | CFL := $(PROFILING) -mcmodel=small -fPIC -O2 -fasynchronous-unwind-tables -m64 \ |
| 69 | 69 | $(filter -g%,$(KBUILD_CFLAGS)) $(call cc-option, -fno-stack-protector) \ |
| 70 | 70 | -fno-omit-frame-pointer -foptimize-sibling-calls \ |
| 71 | − -DDISABLE_BRANCH_PROFILING -DBUILD_VDSO $(RETPOLINE_VDSO_CFLAGS) | |
| 71 | + -DDISABLE_BRANCH_PROFILING -DBUILD_VDSO | |
| 72 | + | |
| 73 | +ifdef CONFIG_RETPOLINE | |
| 74 | +ifneq ($(RETPOLINE_VDSO_CFLAGS),) | |
| 75 | + CFL += $(RETPOLINE_VDSO_CFLAGS) | |
| 76 | +endif | |
| 77 | +endif | |
| 72 | 78 | |
| 73 | 79 | $(vobjs): KBUILD_CFLAGS := $(filter-out $(GCC_PLUGINS_CFLAGS) $(RETPOLINE_CFLAGS),$(KBUILD_CFLAGS)) $(CFL) |
| 74 | 80 | |
| @@ -138,7 +144,13 @@ KBUILD_CFLAGS_32 += $(call cc-option, -fno-stack-protector) · 63 unmodified lines | ||
| 138 | 144 | KBUILD_CFLAGS_32 += $(call cc-option, -foptimize-sibling-calls) |
| 139 | 145 | KBUILD_CFLAGS_32 += -fno-omit-frame-pointer |
| 140 | 146 | KBUILD_CFLAGS_32 += -DDISABLE_BRANCH_PROFILING |
| 141 | −KBUILD_CFLAGS_32 += $(RETPOLINE_VDSO_CFLAGS) | |
| 147 | + | |
| 148 | +ifdef CONFIG_RETPOLINE | |
| 149 | +ifneq ($(RETPOLINE_VDSO_CFLAGS),) | |
| 150 | + KBUILD_CFLAGS_32 += $(RETPOLINE_VDSO_CFLAGS) | |
| 151 | +endif | |
| 152 | +endif | |
| 153 | + | |
| 142 | 154 | $(obj)/vdso32.so.dbg: KBUILD_CFLAGS = $(KBUILD_CFLAGS_32) |
| 143 | 155 | |
| 144 | 156 | $(obj)/vdso32.so.dbg: FORCE \ |
| @@ -43,8 +43,9 @@ extern u8 hvclock_page · 42 unmodified lines | ||
| 43 | 43 | notrace static long vdso_fallback_gettime(long clock, struct timespec *ts) |
| 44 | 44 | { |
| 45 | 45 | long ret; |
| 46 | − asm("syscall" : "=a" (ret) : | |
| 47 | − "0" (__NR_clock_gettime), "D" (clock), "S" (ts) : "memory"); | |
| 46 | + asm ("syscall" : "=a" (ret), "=m" (*ts) : | |
| 47 | + "0" (__NR_clock_gettime), "D" (clock), "S" (ts) : | |
| 48 | + "memory", "rcx", "r11"); | |
| 48 | 49 | return ret; |
| 49 | 50 | } |
| 50 | 51 | |
| @@ -52,8 +53,9 @@ notrace static long vdso_fallback_gtod(struct timeval *tv, struct timezone *tz) · 1 unmodified line | ||
| 52 | 53 | { |
| 53 | 54 | long ret; |
| 54 | 55 | |
| 55 | − asm("syscall" : "=a" (ret) : | |
| 56 | − "0" (__NR_gettimeofday), "D" (tv), "S" (tz) : "memory"); | |
| 56 | + asm ("syscall" : "=a" (ret), "=m" (*tv), "=m" (*tz) : | |
| 57 | + "0" (__NR_gettimeofday), "D" (tv), "S" (tz) : | |
| 58 | + "memory", "rcx", "r11"); | |
| 57 | 59 | return ret; |
| 58 | 60 | } |
| 59 | 61 | |
| @@ -64,13 +66,13 @@ notrace static long vdso_fallback_gettime(long clock, struct timespec *ts) · 4 unmodified lines | ||
| 64 | 66 | { |
| 65 | 67 | long ret; |
| 66 | 68 | |
| 67 | − asm( | |
| 69 | + asm ( | |
| 68 | 70 | "mov %%ebx, %%edx \n" |
| 69 | − "mov %2, %%ebx \n" | |
| 71 | + "mov %[clock], %%ebx \n" | |
| 70 | 72 | "call __kernel_vsyscall \n" |
| 71 | 73 | "mov %%edx, %%ebx \n" |
| 72 | − : "=a" (ret) | |
| 73 | − : "0" (__NR_clock_gettime), "g" (clock), "c" (ts) | |
| 74 | + : "=a" (ret), "=m" (*ts) | |
| 75 | + : "0" (__NR_clock_gettime), [clock] "g" (clock), "c" (ts) | |
| 74 | 76 | : "memory", "edx"); |
| 75 | 77 | return ret; |
| 76 | 78 | } |
| @@ -79,13 +81,13 @@ notrace static long vdso_fallback_gtod(struct timeval *tv, struct timezone *tz) · 2 unmodified lines | ||
| 79 | 81 | { |
| 80 | 82 | long ret; |
| 81 | 83 | |
| 82 | − asm( | |
| 84 | + asm ( | |
| 83 | 85 | "mov %%ebx, %%edx \n" |
| 84 | − "mov %2, %%ebx \n" | |
| 86 | + "mov %[tv], %%ebx \n" | |
| 85 | 87 | "call __kernel_vsyscall \n" |
| 86 | 88 | "mov %%edx, %%ebx \n" |
| 87 | − : "=a" (ret) | |
| 88 | − : "0" (__NR_gettimeofday), "g" (tv), "c" (tz) | |
| 89 | + : "=a" (ret), "=m" (*tv), "=m" (*tz) | |
| 90 | + : "0" (__NR_gettimeofday), [tv] "g" (tv), "c" (tz) | |
| 89 | 91 | : "memory", "edx"); |
| 90 | 92 | return ret; |
| 91 | 93 | } |
| @@ -36,6 +36,7 @@ · 35 unmodified lines | ||
| 36 | 36 | |
| 37 | 37 | static int num_counters_llc; |
| 38 | 38 | static int num_counters_nb; |
| 39 | +static bool l3_mask; | |
| 39 | 40 | |
| 40 | 41 | static HLIST_HEAD(uncore_unused_list); |
| 41 | 42 | |
| @@ -209,6 +210,13 @@ static int amd_uncore_event_init(struct perf_event *event) · 167 unmodified lines | ||
| 209 | 210 | hwc->config = event->attr.config & AMD64_RAW_EVENT_MASK_NB; |
| 210 | 211 | hwc->idx = -1; |
| 211 | 212 | |
| 213 | + /* | |
| 214 | + * SliceMask and ThreadMask need to be set for certain L3 events in | |
| 215 | + * Family 17h. For other events, the two fields do not affect the count. | |
| 216 | + */ | |
| 217 | + if (l3_mask) | |
| 218 | + hwc->config |= (AMD64_L3_SLICE_MASK | AMD64_L3_THREAD_MASK); | |
| 219 | + | |
| 212 | 220 | if (event->cpu < 0) |
| 213 | 221 | return -EINVAL; |
| 214 | 222 | |
| @@ -525,6 +533,7 @@ static int __init amd_uncore_init(void) · 310 unmodified lines | ||
| 525 | 533 | amd_llc_pmu.name = "amd_l3"; |
| 526 | 534 | format_attr_event_df.show = &event_show_df; |
| 527 | 535 | format_attr_event_l3.show = &event_show_l3; |
| 536 | + l3_mask = true; | |
| 528 | 537 | } else { |
| 529 | 538 | num_counters_nb = NUM_COUNTERS_NB; |
| 530 | 539 | num_counters_llc = NUM_COUNTERS_L2; |
| @@ -532,6 +541,7 @@ static int __init amd_uncore_init(void) · 1 unmodified line | ||
| 532 | 541 | amd_llc_pmu.name = "amd_l2"; |
| 533 | 542 | format_attr_event_df = format_attr_event; |
| 534 | 543 | format_attr_event_l3 = format_attr_event; |
| 544 | + l3_mask = false; | |
| 535 | 545 | } |
| 536 | 546 | |
| 537 | 547 | amd_nb_pmu.attr_groups = amd_uncore_attr_groups_df; |
| @@ -3061,7 +3061,7 @@ static struct event_constraint bdx_uncore_pcu_constraints[] = { · 3060 unmodified lines | ||
| 3061 | 3061 | |
| 3062 | 3062 | void bdx_uncore_cpu_init(void) |
| 3063 | 3063 | { |
| 3064 | − int pkg = topology_phys_to_logical_pkg(0); | |
| 3064 | + int pkg = topology_phys_to_logical_pkg(boot_cpu_data.phys_proc_id); | |
| 3065 | 3065 | |
| 3066 | 3066 | if (bdx_uncore_cbox.num_boxes > boot_cpu_data.x86_max_cores) |
| 3067 | 3067 | bdx_uncore_cbox.num_boxes = boot_cpu_data.x86_max_cores; |
| @@ -3931,16 +3931,16 @@ static const struct pci_device_id skx_uncore_pci_ids[] = { · 863 unmodified lines | ||
| 3931 | 3931 | .driver_data = UNCORE_PCI_DEV_FULL_DATA(21, 5, SKX_PCI_UNCORE_M2PCIE, 3), |
| 3932 | 3932 | }, |
| 3933 | 3933 | { /* M3UPI0 Link 0 */ |
| 3934 | − PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x204C), | |
| 3935 | − .driver_data = UNCORE_PCI_DEV_FULL_DATA(18, 0, SKX_PCI_UNCORE_M3UPI, 0), | |
| 3934 | + PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x204D), | |
| 3935 | + .driver_data = UNCORE_PCI_DEV_FULL_DATA(18, 1, SKX_PCI_UNCORE_M3UPI, 0), | |
| 3936 | 3936 | }, |
| 3937 | 3937 | { /* M3UPI0 Link 1 */ |
| 3938 | − PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x204D), | |
| 3939 | − .driver_data = UNCORE_PCI_DEV_FULL_DATA(18, 1, SKX_PCI_UNCORE_M3UPI, 1), | |
| 3938 | + PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x204E), | |
| 3939 | + .driver_data = UNCORE_PCI_DEV_FULL_DATA(18, 2, SKX_PCI_UNCORE_M3UPI, 1), | |
| 3940 | 3940 | }, |
| 3941 | 3941 | { /* M3UPI1 Link 2 */ |
| 3942 | − PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x204C), | |
| 3943 | − .driver_data = UNCORE_PCI_DEV_FULL_DATA(18, 4, SKX_PCI_UNCORE_M3UPI, 2), | |
| 3942 | + PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x204D), | |
| 3943 | + .driver_data = UNCORE_PCI_DEV_FULL_DATA(18, 5, SKX_PCI_UNCORE_M3UPI, 2), | |
| 3944 | 3944 | }, |
| 3945 | 3945 | { /* end: all zeroes */ } |
| 3946 | 3946 | }; |
| @@ -46,6 +46,14 @@ · 45 unmodified lines | ||
| 46 | 46 | #define INTEL_ARCH_EVENT_MASK \ |
| 47 | 47 | (ARCH_PERFMON_EVENTSEL_UMASK | ARCH_PERFMON_EVENTSEL_EVENT) |
| 48 | 48 | |
| 49 | +#define AMD64_L3_SLICE_SHIFT 48 | |
| 50 | +#define AMD64_L3_SLICE_MASK \ | |
| 51 | + ((0xFULL) << AMD64_L3_SLICE_SHIFT) | |
| 52 | + | |
| 53 | +#define AMD64_L3_THREAD_SHIFT 56 | |
| 54 | +#define AMD64_L3_THREAD_MASK \ | |
| 55 | + ((0xFFULL) << AMD64_L3_THREAD_SHIFT) | |
| 56 | + | |
| 49 | 57 | #define X86_RAW_EVENT_MASK \ |
| 50 | 58 | (ARCH_PERFMON_EVENTSEL_EVENT | \ |
| 51 | 59 | ARCH_PERFMON_EVENTSEL_UMASK | \ |
| @@ -10,8 +10,13 @@ struct cpumask; · 9 unmodified lines | ||
| 10 | 10 | struct mm_struct; |
| 11 | 11 | |
| 12 | 12 | #ifdef CONFIG_X86_UV |
| 13 | +#include <linux/efi.h> | |
| 13 | 14 | |
| 14 | 15 | extern enum uv_system_type get_uv_system_type(void); |
| 16 | +static inline bool is_early_uv_system(void) | |
| 17 | +{ | |
| 18 | + return !((efi.uv_systab == EFI_INVALID_TABLE_ADDR) || !efi.uv_systab); | |
| 19 | +} | |
| 15 | 20 | extern int is_uv_system(void); |
| 16 | 21 | extern int is_uv_hubless(void); |
| 17 | 22 | extern void uv_cpu_init(void); |
| @@ -23,6 +28,7 @@ extern const struct cpumask *uv_flush_tlb_others(const struct cpumask *cpumask, · 5 unmodified lines | ||
| 23 | 28 | #else /* X86_UV */ |
| 24 | 29 | |
| 25 | 30 | static inline enum uv_system_type get_uv_system_type(void) { return UV_NONE; } |
| 31 | +static inline bool is_early_uv_system(void) { return 0; } | |
| 26 | 32 | static inline int is_uv_system(void) { return 0; } |
| 27 | 33 | static inline int is_uv_hubless(void) { return 0; } |
| 28 | 34 | static inline void uv_cpu_init(void) { } |
| @@ -922,7 +922,7 @@ static void init_amd(struct cpuinfo_x86 *c) · 921 unmodified lines | ||
| 922 | 922 | static unsigned int amd_size_cache(struct cpuinfo_x86 *c, unsigned int size) |
| 923 | 923 | { |
| 924 | 924 | /* AMD errata T13 (order #21922) */ |
| 925 | − if ((c->x86 == 6)) { | |
| 925 | + if (c->x86 == 6) { | |
| 926 | 926 | /* Duron Rev A0 */ |
| 927 | 927 | if (c->x86_model == 3 && c->x86_stepping == 0) |
| 928 | 928 | size = 64; |
| @@ -26,6 +26,7 @@ · 25 unmodified lines | ||
| 26 | 26 | #include <asm/apic.h> |
| 27 | 27 | #include <asm/intel-family.h> |
| 28 | 28 | #include <asm/i8259.h> |
| 29 | +#include <asm/uv/uv.h> | |
| 29 | 30 | |
| 30 | 31 | unsigned int __read_mostly cpu_khz; /* TSC clocks / usec, not used here */ |
| 31 | 32 | EXPORT_SYMBOL(cpu_khz); |
| @@ -1433,6 +1434,9 @@ void __init tsc_early_init(void) · 1401 unmodified lines | ||
| 1433 | 1434 | { |
| 1434 | 1435 | if (!boot_cpu_has(X86_FEATURE_TSC)) |
| 1435 | 1436 | return; |
| 1437 | + /* Don't change UV TSC multi-chassis synchronization */ | |
| 1438 | + if (is_early_uv_system()) | |
| 1439 | + return; | |
| 1436 | 1440 | if (!determine_cpu_tsc_frequencies(true)) |
| 1437 | 1441 | return; |
| 1438 | 1442 | loops_per_jiffy = get_loops_per_jiffy(); |
| @@ -249,6 +249,17 @@ static u64 __read_mostly shadow_nonpresent_or_rsvd_mask; · 248 unmodified lines | ||
| 249 | 249 | */ |
| 250 | 250 | static const u64 shadow_nonpresent_or_rsvd_mask_len = 5; |
| 251 | 251 | |
| 252 | +/* | |
| 253 | + * In some cases, we need to preserve the GFN of a non-present or reserved | |
| 254 | + * SPTE when we usurp the upper five bits of the physical address space to | |
| 255 | + * defend against L1TF, e.g. for MMIO SPTEs. To preserve the GFN, we'll | |
| 256 | + * shift bits of the GFN that overlap with shadow_nonpresent_or_rsvd_mask | |
| 257 | + * left into the reserved bits, i.e. the GFN in the SPTE will be split into | |
| 258 | + * high and low parts. This mask covers the lower bits of the GFN. | |
| 259 | + */ | |
| 260 | +static u64 __read_mostly shadow_nonpresent_or_rsvd_lower_gfn_mask; | |
| 261 | + | |
| 262 | + | |
| 252 | 263 | static void mmu_spte_set(u64 *sptep, u64 spte); |
| 253 | 264 | static union kvm_mmu_page_role |
| 254 | 265 | kvm_mmu_calc_root_page_role(struct kvm_vcpu *vcpu); |
| @@ -357,9 +368,7 @@ static bool is_mmio_spte(u64 spte) · 102 unmodified lines | ||
| 357 | 368 | |
| 358 | 369 | static gfn_t get_mmio_spte_gfn(u64 spte) |
| 359 | 370 | { |
| 360 | − u64 mask = generation_mmio_spte_mask(MMIO_GEN_MASK) | shadow_mmio_mask | | |
| 361 | − shadow_nonpresent_or_rsvd_mask; | |
| 362 | − u64 gpa = spte & ~mask; | |
| 371 | + u64 gpa = spte & shadow_nonpresent_or_rsvd_lower_gfn_mask; | |
| 363 | 372 | |
| 364 | 373 | gpa |= (spte >> shadow_nonpresent_or_rsvd_mask_len) |
| 365 | 374 | & shadow_nonpresent_or_rsvd_mask; |
| @@ -423,6 +432,8 @@ EXPORT_SYMBOL_GPL(kvm_mmu_set_mask_ptes); · 57 unmodified lines | ||
| 423 | 432 | |
| 424 | 433 | static void kvm_mmu_reset_all_pte_masks(void) |
| 425 | 434 | { |
| 435 | + u8 low_phys_bits; | |
| 436 | + | |
| 426 | 437 | shadow_user_mask = 0; |
| 427 | 438 | shadow_accessed_mask = 0; |
| 428 | 439 | shadow_dirty_mask = 0; |
| @@ -437,12 +448,17 @@ static void kvm_mmu_reset_all_pte_masks(void) · 8 unmodified lines | ||
| 437 | 448 | * appropriate mask to guard against L1TF attacks. Otherwise, it is |
| 438 | 449 | * assumed that the CPU is not vulnerable to L1TF. |
| 439 | 450 | */ |
| 451 | + low_phys_bits = boot_cpu_data.x86_phys_bits; | |
| 440 | 452 | if (boot_cpu_data.x86_phys_bits < |
| 441 | − 52 - shadow_nonpresent_or_rsvd_mask_len) | |
| 453 | + 52 - shadow_nonpresent_or_rsvd_mask_len) { | |
| 442 | 454 | shadow_nonpresent_or_rsvd_mask = |
| 443 | 455 | rsvd_bits(boot_cpu_data.x86_phys_bits - |
| 444 | 456 | shadow_nonpresent_or_rsvd_mask_len, |
| 445 | 457 | boot_cpu_data.x86_phys_bits - 1); |
| 458 | + low_phys_bits -= shadow_nonpresent_or_rsvd_mask_len; | |
| 459 | + } | |
| 460 | + shadow_nonpresent_or_rsvd_lower_gfn_mask = | |
| 461 | + GENMASK_ULL(low_phys_bits - 1, PAGE_SHIFT); | |
| 446 | 462 | } |
| 447 | 463 | |
| 448 | 464 | static int is_cpuid_PSE36(void) |
| @@ -121,7 +121,6 @@ module_param_named(pml, enable_pml, bool, S_IRUGO); · 120 unmodified lines | ||
| 121 | 121 | |
| 122 | 122 | #define MSR_BITMAP_MODE_X2APIC 1 |
| 123 | 123 | #define MSR_BITMAP_MODE_X2APIC_APICV 2 |
| 124 | −#define MSR_BITMAP_MODE_LM 4 | |
| 125 | 124 | |
| 126 | 125 | #define KVM_VMX_TSC_MULTIPLIER_MAX 0xffffffffffffffffULL |
| 127 | 126 | |
| @@ -857,6 +856,7 @@ struct nested_vmx { · 729 unmodified lines | ||
| 857 | 856 | |
| 858 | 857 | /* to migrate it to L2 if VM_ENTRY_LOAD_DEBUG_CONTROLS is off */ |
| 859 | 858 | u64 vmcs01_debugctl; |
| 859 | + u64 vmcs01_guest_bndcfgs; | |
| 860 | 860 | |
| 861 | 861 | u16 vpid02; |
| 862 | 862 | u16 last_vpid; |
| @@ -2899,8 +2899,7 @@ static void vmx_prepare_switch_to_guest(struct kvm_vcpu *vcpu) · 2036 unmodified lines | ||
| 2899 | 2899 | vmx->msr_host_kernel_gs_base = read_msr(MSR_KERNEL_GS_BASE); |
| 2900 | 2900 | } |
| 2901 | 2901 | |
| 2902 | − if (is_long_mode(&vmx->vcpu)) | |
| 2903 | − wrmsrl(MSR_KERNEL_GS_BASE, vmx->msr_guest_kernel_gs_base); | |
| 2902 | + wrmsrl(MSR_KERNEL_GS_BASE, vmx->msr_guest_kernel_gs_base); | |
| 2904 | 2903 | #else |
| 2905 | 2904 | savesegment(fs, fs_sel); |
| 2906 | 2905 | savesegment(gs, gs_sel); |
| @@ -2951,8 +2950,7 @@ static void vmx_prepare_switch_to_host(struct vcpu_vmx *vmx) · 44 unmodified lines | ||
| 2951 | 2950 | vmx->loaded_cpu_state = NULL; |
| 2952 | 2951 | |
| 2953 | 2952 | #ifdef CONFIG_X86_64 |
| 2954 | − if (is_long_mode(&vmx->vcpu)) | |
| 2955 | − rdmsrl(MSR_KERNEL_GS_BASE, vmx->msr_guest_kernel_gs_base); | |
| 2953 | + rdmsrl(MSR_KERNEL_GS_BASE, vmx->msr_guest_kernel_gs_base); | |
| 2956 | 2954 | #endif |
| 2957 | 2955 | if (host_state->ldt_sel || (host_state->gs_sel & 7)) { |
| 2958 | 2956 | kvm_load_ldt(host_state->ldt_sel); |
| @@ -2980,24 +2978,19 @@ static void vmx_prepare_switch_to_host(struct vcpu_vmx *vmx) · 21 unmodified lines | ||
| 2980 | 2978 | #ifdef CONFIG_X86_64 |
| 2981 | 2979 | static u64 vmx_read_guest_kernel_gs_base(struct vcpu_vmx *vmx) |
| 2982 | 2980 | { |
| 2983 | − if (is_long_mode(&vmx->vcpu)) { | |
| 2984 | − preempt_disable(); | |
| 2985 | − if (vmx->loaded_cpu_state) | |
| 2986 | − rdmsrl(MSR_KERNEL_GS_BASE, | |
| 2987 | − vmx->msr_guest_kernel_gs_base); | |
| 2988 | − preempt_enable(); | |
| 2989 | − } | |
| 2981 | + preempt_disable(); | |
| 2982 | + if (vmx->loaded_cpu_state) | |
| 2983 | + rdmsrl(MSR_KERNEL_GS_BASE, vmx->msr_guest_kernel_gs_base); | |
| 2984 | + preempt_enable(); | |
| 2990 | 2985 | return vmx->msr_guest_kernel_gs_base; |
| 2991 | 2986 | } |
| 2992 | 2987 | |
| 2993 | 2988 | static void vmx_write_guest_kernel_gs_base(struct vcpu_vmx *vmx, u64 data) |
| 2994 | 2989 | { |
| 2995 | − if (is_long_mode(&vmx->vcpu)) { | |
| 2996 | − preempt_disable(); | |
| 2997 | − if (vmx->loaded_cpu_state) | |
| 2998 | − wrmsrl(MSR_KERNEL_GS_BASE, data); | |
| 2999 | − preempt_enable(); | |
| 3000 | − } | |
| 2990 | + preempt_disable(); | |
| 2991 | + if (vmx->loaded_cpu_state) | |
| 2992 | + wrmsrl(MSR_KERNEL_GS_BASE, data); | |
| 2993 | + preempt_enable(); | |
| 3001 | 2994 | vmx->msr_guest_kernel_gs_base = data; |
| 3002 | 2995 | } |
| 3003 | 2996 | #endif |
| @@ -3533,9 +3526,6 @@ static void nested_vmx_setup_ctls_msrs(struct nested_vmx_msrs *msrs, bool apicv) · 529 unmodified lines | ||
| 3533 | 3526 | VM_EXIT_LOAD_IA32_EFER | VM_EXIT_SAVE_IA32_EFER | |
| 3534 | 3527 | VM_EXIT_SAVE_VMX_PREEMPTION_TIMER | VM_EXIT_ACK_INTR_ON_EXIT; |
| 3535 | 3528 | |
| 3536 | − if (kvm_mpx_supported()) | |
| 3537 | − msrs->exit_ctls_high |= VM_EXIT_CLEAR_BNDCFGS; | |
| 3538 | − | |
| 3539 | 3529 | /* We support free control of debug control saving. */ |
| 3540 | 3530 | msrs->exit_ctls_low &= ~VM_EXIT_SAVE_DEBUG_CONTROLS; |
| 3541 | 3531 | |
| @@ -3552,8 +3542,6 @@ static void nested_vmx_setup_ctls_msrs(struct nested_vmx_msrs *msrs, bool apicv) · 10 unmodified lines | ||
| 3552 | 3542 | VM_ENTRY_LOAD_IA32_PAT; |
| 3553 | 3543 | msrs->entry_ctls_high |= |
| 3554 | 3544 | (VM_ENTRY_ALWAYSON_WITHOUT_TRUE_MSR | VM_ENTRY_LOAD_IA32_EFER); |
| 3555 | − if (kvm_mpx_supported()) | |
| 3556 | − msrs->entry_ctls_high |= VM_ENTRY_LOAD_BNDCFGS; | |
| 3557 | 3545 | |
| 3558 | 3546 | /* We support free control of debug control loading. */ |
| 3559 | 3547 | msrs->entry_ctls_low &= ~VM_ENTRY_LOAD_DEBUG_CONTROLS; |
| @@ -3601,12 +3589,12 @@ static void nested_vmx_setup_ctls_msrs(struct nested_vmx_msrs *msrs, bool apicv) · 41 unmodified lines | ||
| 3601 | 3589 | msrs->secondary_ctls_high); |
| 3602 | 3590 | msrs->secondary_ctls_low = 0; |
| 3603 | 3591 | msrs->secondary_ctls_high &= |
| 3604 | − SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES | | |
| 3605 | 3592 | SECONDARY_EXEC_DESC | |
| 3606 | 3593 | SECONDARY_EXEC_VIRTUALIZE_X2APIC_MODE | |
| 3607 | 3594 | SECONDARY_EXEC_APIC_REGISTER_VIRT | |
| 3608 | 3595 | SECONDARY_EXEC_VIRTUAL_INTR_DELIVERY | |
| 3609 | 3596 | SECONDARY_EXEC_WBINVD_EXITING; |
| 3597 | + | |
| 3610 | 3598 | /* |
| 3611 | 3599 | * We can emulate "VMCS shadowing," even if the hardware |
| 3612 | 3600 | * doesn't support it. |
| @@ -3663,6 +3651,10 @@ static void nested_vmx_setup_ctls_msrs(struct nested_vmx_msrs *msrs, bool apicv) · 50 unmodified lines | ||
| 3663 | 3651 | msrs->secondary_ctls_high |= |
| 3664 | 3652 | SECONDARY_EXEC_UNRESTRICTED_GUEST; |
| 3665 | 3653 | |
| 3654 | + if (flexpriority_enabled) | |
| 3655 | + msrs->secondary_ctls_high |= | |
| 3656 | + SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES; | |
| 3657 | + | |
| 3666 | 3658 | /* miscellaneous data */ |
| 3667 | 3659 | rdmsr(MSR_IA32_VMX_MISC, |
| 3668 | 3660 | msrs->misc_low, |
| @@ -5073,19 +5065,6 @@ static void vmx_set_efer(struct kvm_vcpu *vcpu, u64 efer) · 1404 unmodified lines | ||
| 5073 | 5065 | if (!msr) |
| 5074 | 5066 | return; |
| 5075 | 5067 | |
| 5076 | − /* | |
| 5077 | − * MSR_KERNEL_GS_BASE is not intercepted when the guest is in | |
| 5078 | − * 64-bit mode as a 64-bit kernel may frequently access the | |
| 5079 | − * MSR. This means we need to manually save/restore the MSR | |
| 5080 | − * when switching between guest and host state, but only if | |
| 5081 | − * the guest is in 64-bit mode. Sync our cached value if the | |
| 5082 | − * guest is transitioning to 32-bit mode and the CPU contains | |
| 5083 | − * guest state, i.e. the cache is stale. | |
| 5084 | − */ | |
| 5085 | −#ifdef CONFIG_X86_64 | |
| 5086 | − if (!(efer & EFER_LMA)) | |
| 5087 | − (void)vmx_read_guest_kernel_gs_base(vmx); | |
| 5088 | −#endif | |
| 5089 | 5068 | vcpu->arch.efer = efer; |
| 5090 | 5069 | if (efer & EFER_LMA) { |
| 5091 | 5070 | vm_entry_controls_setbit(to_vmx(vcpu), VM_ENTRY_IA32E_MODE); |
| @@ -6078,9 +6057,6 @@ static u8 vmx_msr_bitmap_mode(struct kvm_vcpu *vcpu) · 986 unmodified lines | ||
| 6078 | 6057 | mode |= MSR_BITMAP_MODE_X2APIC_APICV; |
| 6079 | 6058 | } |
| 6080 | 6059 | |
| 6081 | − if (is_long_mode(vcpu)) | |
| 6082 | − mode |= MSR_BITMAP_MODE_LM; | |
| 6083 | − | |
| 6084 | 6060 | return mode; |
| 6085 | 6061 | } |
| 6086 | 6062 | |
| @@ -6121,9 +6097,6 @@ static void vmx_update_msr_bitmap(struct kvm_vcpu *vcpu) · 34 unmodified lines | ||
| 6121 | 6097 | if (!changed) |
| 6122 | 6098 | return; |
| 6123 | 6099 | |
| 6124 | − vmx_set_intercept_for_msr(msr_bitmap, MSR_KERNEL_GS_BASE, MSR_TYPE_RW, | |
| 6125 | − !(mode & MSR_BITMAP_MODE_LM)); | |
| 6126 | − | |
| 6127 | 6100 | if (changed & (MSR_BITMAP_MODE_X2APIC | MSR_BITMAP_MODE_X2APIC_APICV)) |
| 6128 | 6101 | vmx_update_msr_bitmap_x2apic(msr_bitmap, mode); |
| 6129 | 6102 | |
| @@ -6189,6 +6162,11 @@ static void vmx_complete_nested_posted_interrupt(struct kvm_vcpu *vcpu) · 59 unmodified lines | ||
| 6189 | 6162 | nested_mark_vmcs12_pages_dirty(vcpu); |
| 6190 | 6163 | } |
| 6191 | 6164 | |
| 6165 | +static u8 vmx_get_rvi(void) | |
| 6166 | +{ | |
| 6167 | + return vmcs_read16(GUEST_INTR_STATUS) & 0xff; | |
| 6168 | +} | |
| 6169 | + | |
| 6192 | 6170 | static bool vmx_guest_apic_has_interrupt(struct kvm_vcpu *vcpu) |
| 6193 | 6171 | { |
| 6194 | 6172 | struct vcpu_vmx *vmx = to_vmx(vcpu); |
| @@ -6201,7 +6179,7 @@ static bool vmx_guest_apic_has_interrupt(struct kvm_vcpu *vcpu) · 6 unmodified lines | ||
| 6201 | 6179 | WARN_ON_ONCE(!vmx->nested.virtual_apic_page)) |
| 6202 | 6180 | return false; |
| 6203 | 6181 | |
| 6204 | − rvi = vmcs_read16(GUEST_INTR_STATUS) & 0xff; | |
| 6182 | + rvi = vmx_get_rvi(); | |
| 6205 | 6183 | |
| 6206 | 6184 | vapic_page = kmap(vmx->nested.virtual_apic_page); |
| 6207 | 6185 | vppr = *((u32 *)(vapic_page + APIC_PROCPRI)); |
| @@ -10245,15 +10223,16 @@ static void vmx_set_virtual_apic_mode(struct kvm_vcpu *vcpu) · 4037 unmodified lines | ||
| 10245 | 10223 | if (!lapic_in_kernel(vcpu)) |
| 10246 | 10224 | return; |
| 10247 | 10225 | |
| 10226 | + if (!flexpriority_enabled && | |
| 10227 | + !cpu_has_vmx_virtualize_x2apic_mode()) | |
| 10228 | + return; | |
| 10229 | + | |
| 10248 | 10230 | /* Postpone execution until vmcs01 is the current VMCS. */ |
| 10249 | 10231 | if (is_guest_mode(vcpu)) { |
| 10250 | 10232 | to_vmx(vcpu)->nested.change_vmcs01_virtual_apic_mode = true; |
| 10251 | 10233 | return; |
| 10252 | 10234 | } |
| 10253 | 10235 | |
| 10254 | − if (!cpu_need_tpr_shadow(vcpu)) | |
| 10255 | − return; | |
| 10256 | − | |
| 10257 | 10236 | sec_exec_control = vmcs_read32(SECONDARY_VM_EXEC_CONTROL); |
| 10258 | 10237 | sec_exec_control &= ~(SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES | |
| 10259 | 10238 | SECONDARY_EXEC_VIRTUALIZE_X2APIC_MODE); |
| @@ -10375,6 +10354,14 @@ static int vmx_sync_pir_to_irr(struct kvm_vcpu *vcpu) · 115 unmodified lines | ||
| 10375 | 10354 | return max_irr; |
| 10376 | 10355 | } |
| 10377 | 10356 | |
| 10357 | +static u8 vmx_has_apicv_interrupt(struct kvm_vcpu *vcpu) | |
| 10358 | +{ | |
| 10359 | + u8 rvi = vmx_get_rvi(); | |
| 10360 | + u8 vppr = kvm_lapic_get_reg(vcpu->arch.apic, APIC_PROCPRI); | |
| 10361 | + | |
| 10362 | + return ((rvi & 0xf0) > (vppr & 0xf0)); | |
| 10363 | +} | |
| 10364 | + | |
| 10378 | 10365 | static void vmx_load_eoi_exitmap(struct kvm_vcpu *vcpu, u64 *eoi_exit_bitmap) |
| 10379 | 10366 | { |
| 10380 | 10367 | if (!kvm_vcpu_apicv_active(vcpu)) |
| @@ -11264,6 +11251,23 @@ static void nested_vmx_cr_fixed1_bits_update(struct kvm_vcpu *vcpu) · 883 unmodified lines | ||
| 11264 | 11251 | #undef cr4_fixed1_update |
| 11265 | 11252 | } |
| 11266 | 11253 | |
| 11254 | +static void nested_vmx_entry_exit_ctls_update(struct kvm_vcpu *vcpu) | |
| 11255 | +{ | |
| 11256 | + struct vcpu_vmx *vmx = to_vmx(vcpu); | |
| 11257 | + | |
| 11258 | + if (kvm_mpx_supported()) { | |
| 11259 | + bool mpx_enabled = guest_cpuid_has(vcpu, X86_FEATURE_MPX); | |
| 11260 | + | |
| 11261 | + if (mpx_enabled) { | |
| 11262 | + vmx->nested.msrs.entry_ctls_high |= VM_ENTRY_LOAD_BNDCFGS; | |
| 11263 | + vmx->nested.msrs.exit_ctls_high |= VM_EXIT_CLEAR_BNDCFGS; | |
| 11264 | + } else { | |
| 11265 | + vmx->nested.msrs.entry_ctls_high &= ~VM_ENTRY_LOAD_BNDCFGS; | |
| 11266 | + vmx->nested.msrs.exit_ctls_high &= ~VM_EXIT_CLEAR_BNDCFGS; | |
| 11267 | + } | |
| 11268 | + } | |
| 11269 | +} | |
| 11270 | + | |
| 11267 | 11271 | static void vmx_cpuid_update(struct kvm_vcpu *vcpu) |
| 11268 | 11272 | { |
| 11269 | 11273 | struct vcpu_vmx *vmx = to_vmx(vcpu); |
| @@ -11280,8 +11284,10 @@ static void vmx_cpuid_update(struct kvm_vcpu *vcpu) · 10 unmodified lines | ||
| 11280 | 11284 | to_vmx(vcpu)->msr_ia32_feature_control_valid_bits &= |
| 11281 | 11285 | ~FEATURE_CONTROL_VMXON_ENABLED_OUTSIDE_SMX; |
| 11282 | 11286 | |
| 11283 | − if (nested_vmx_allowed(vcpu)) | |
| 11287 | + if (nested_vmx_allowed(vcpu)) { | |
| 11284 | 11288 | nested_vmx_cr_fixed1_bits_update(vcpu); |
| 11289 | + nested_vmx_entry_exit_ctls_update(vcpu); | |
| 11290 | + } | |
| 11285 | 11291 | } |
| 11286 | 11292 | |
| 11287 | 11293 | static void vmx_set_supported_cpuid(u32 func, struct kvm_cpuid_entry2 *entry) |
| @@ -12049,8 +12055,13 @@ static void prepare_vmcs02_full(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12) · 761 unmodified lines | ||
| 12049 | 12055 | |
| 12050 | 12056 | set_cr4_guest_host_mask(vmx); |
| 12051 | 12057 | |
| 12052 | − if (vmx_mpx_supported()) | |
| 12053 | − vmcs_write64(GUEST_BNDCFGS, vmcs12->guest_bndcfgs); | |
| 12058 | + if (kvm_mpx_supported()) { | |
| 12059 | + if (vmx->nested.nested_run_pending && | |
| 12060 | + (vmcs12->vm_entry_controls & VM_ENTRY_LOAD_BNDCFGS)) | |
| 12061 | + vmcs_write64(GUEST_BNDCFGS, vmcs12->guest_bndcfgs); | |
| 12062 | + else | |
| 12063 | + vmcs_write64(GUEST_BNDCFGS, vmx->nested.vmcs01_guest_bndcfgs); | |
| 12064 | + } | |
| 12054 | 12065 | |
| 12055 | 12066 | if (enable_vpid) { |
| 12056 | 12067 | if (nested_cpu_has_vpid(vmcs12) && vmx->nested.vpid02) |
| @@ -12595,15 +12606,21 @@ static int enter_vmx_non_root_mode(struct kvm_vcpu *vcpu, u32 *exit_qual) · 538 unmodified lines | ||
| 12595 | 12606 | struct vmcs12 *vmcs12 = get_vmcs12(vcpu); |
| 12596 | 12607 | bool from_vmentry = !!exit_qual; |
| 12597 | 12608 | u32 dummy_exit_qual; |
| 12598 | − u32 vmcs01_cpu_exec_ctrl; | |
| 12609 | + bool evaluate_pending_interrupts; | |
| 12599 | 12610 | int r = 0; |
| 12600 | 12611 | |
| 12601 | − vmcs01_cpu_exec_ctrl = vmcs_read32(CPU_BASED_VM_EXEC_CONTROL); | |
| 12612 | + evaluate_pending_interrupts = vmcs_read32(CPU_BASED_VM_EXEC_CONTROL) & | |
| 12613 | + (CPU_BASED_VIRTUAL_INTR_PENDING | CPU_BASED_VIRTUAL_NMI_PENDING); | |
| 12614 | + if (likely(!evaluate_pending_interrupts) && kvm_vcpu_apicv_active(vcpu)) | |
| 12615 | + evaluate_pending_interrupts |= vmx_has_apicv_interrupt(vcpu); | |
| 12602 | 12616 | |
| 12603 | 12617 | enter_guest_mode(vcpu); |
| 12604 | 12618 | |
| 12605 | 12619 | if (!(vmcs12->vm_entry_controls & VM_ENTRY_LOAD_DEBUG_CONTROLS)) |
| 12606 | 12620 | vmx->nested.vmcs01_debugctl = vmcs_read64(GUEST_IA32_DEBUGCTL); |
| 12621 | + if (kvm_mpx_supported() && | |
| 12622 | + !(vmcs12->vm_entry_controls & VM_ENTRY_LOAD_BNDCFGS)) | |
| 12623 | + vmx->nested.vmcs01_guest_bndcfgs = vmcs_read64(GUEST_BNDCFGS); | |
| 12607 | 12624 | |
| 12608 | 12625 | vmx_switch_vmcs(vcpu, &vmx->nested.vmcs02); |
| 12609 | 12626 | vmx_segment_cache_clear(vmx); |
| @@ -12643,16 +12660,14 @@ static int enter_vmx_non_root_mode(struct kvm_vcpu *vcpu, u32 *exit_qual) · 33 unmodified lines | ||
| 12643 | 12660 | * to L1 or delivered directly to L2 (e.g. In case L1 don't |
| 12644 | 12661 | * intercept EXTERNAL_INTERRUPT). |
| 12645 | 12662 | * |
| 12646 | − * Usually this would be handled by L0 requesting a | |
| 12647 | − * IRQ/NMI window by setting VMCS accordingly. However, | |
| 12648 | − * this setting was done on VMCS01 and now VMCS02 is active | |
| 12649 | − * instead. Thus, we force L0 to perform pending event | |
| 12650 | − * evaluation by requesting a KVM_REQ_EVENT. | |
| 12651 | − */ | |
| 12652 | − if (vmcs01_cpu_exec_ctrl & | |
| 12653 | − (CPU_BASED_VIRTUAL_INTR_PENDING | CPU_BASED_VIRTUAL_NMI_PENDING)) { | |
| 12663 | + * Usually this would be handled by the processor noticing an | |
| 12664 | + * IRQ/NMI window request, or checking RVI during evaluation of | |
| 12665 | + * pending virtual interrupts. However, this setting was done | |
| 12666 | + * on VMCS01 and now VMCS02 is active instead. Thus, we force L0 | |
| 12667 | + * to perform pending event evaluation by requesting a KVM_REQ_EVENT. | |
| 12668 | + */ | |
| 12669 | + if (unlikely(evaluate_pending_interrupts)) | |
| 12654 | 12670 | kvm_make_request(KVM_REQ_EVENT, vcpu); |
| 12655 | − } | |
| 12656 | 12671 | |
| 12657 | 12672 | /* |
| 12658 | 12673 | * Note no nested_vmx_succeed or nested_vmx_fail here. At this point |
| @@ -4698,7 +4698,7 @@ static void kvm_init_msr_list(void) · 4697 unmodified lines | ||
| 4698 | 4698 | */ |
| 4699 | 4699 | switch (msrs_to_save[i]) { |
| 4700 | 4700 | case MSR_IA32_BNDCFGS: |
| 4701 | − if (!kvm_x86_ops->mpx_supported()) | |
| 4701 | + if (!kvm_mpx_supported()) | |
| 4702 | 4702 | continue; |
| 4703 | 4703 | break; |
| 4704 | 4704 | case MSR_TSC_AUX: |
| @@ -226,8 +226,11 @@ static int alloc_lookup_fw_priv(const char *fw_name, · 225 unmodified lines | ||
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | tmp = __allocate_fw_priv(fw_name, fwc, dbuf, size); |
| 229 | − if (tmp && !(opt_flags & FW_OPT_NOCACHE)) | |
| 230 | − list_add(&tmp->list, &fwc->head); | |
| 229 | + if (tmp) { | |
| 230 | + INIT_LIST_HEAD(&tmp->list); | |
| 231 | + if (!(opt_flags & FW_OPT_NOCACHE)) | |
| 232 | + list_add(&tmp->list, &fwc->head); | |
| 233 | + } | |
| 231 | 234 | spin_unlock(&fwc->lock); |
| 232 | 235 | |
| 233 | 236 | *fw_priv = tmp; |
| @@ -1713,8 +1713,10 @@ static int __device_suspend(struct device *dev, pm_message_t state, bool async) · 1712 unmodified lines | ||
| 1713 | 1713 | |
| 1714 | 1714 | dpm_wait_for_subordinate(dev, async); |
| 1715 | 1715 | |
| 1716 | − if (async_error) | |
| 1716 | + if (async_error) { | |
| 1717 | + dev->power.direct_complete = false; | |
| 1717 | 1718 | goto Complete; |
| 1719 | + } | |
| 1718 | 1720 | |
| 1719 | 1721 | /* |
| 1720 | 1722 | * If a device configured to wake up the system from sleep states |
| @@ -1726,6 +1728,7 @@ static int __device_suspend(struct device *dev, pm_message_t state, bool async) · 5 unmodified lines | ||
| 1726 | 1728 | pm_wakeup_event(dev, 0); |
| 1727 | 1729 | |
| 1728 | 1730 | if (pm_wakeup_pending()) { |
| 1731 | + dev->power.direct_complete = false; | |
| 1729 | 1732 | async_error = -EBUSY; |
| 1730 | 1733 | goto Complete; |
| 1731 | 1734 | } |
| @@ -1553,8 +1553,8 @@ static struct ablkcipher_edesc *ablkcipher_edesc_alloc(struct ablkcipher_request · 1552 unmodified lines | ||
| 1553 | 1553 | edesc->src_nents = src_nents; |
| 1554 | 1554 | edesc->dst_nents = dst_nents; |
| 1555 | 1555 | edesc->sec4_sg_bytes = sec4_sg_bytes; |
| 1556 | − edesc->sec4_sg = (void *)edesc + sizeof(struct ablkcipher_edesc) + | |
| 1557 | − desc_bytes; | |
| 1556 | + edesc->sec4_sg = (struct sec4_sg_entry *)((u8 *)edesc->hw_desc + | |
| 1557 | + desc_bytes); | |
| 1558 | 1558 | edesc->iv_dir = DMA_TO_DEVICE; |
| 1559 | 1559 | |
| 1560 | 1560 | /* Make sure IV is located in a DMAable area */ |
| @@ -1757,8 +1757,8 @@ static struct ablkcipher_edesc *ablkcipher_giv_edesc_alloc( · 196 unmodified lines | ||
| 1757 | 1757 | edesc->src_nents = src_nents; |
| 1758 | 1758 | edesc->dst_nents = dst_nents; |
| 1759 | 1759 | edesc->sec4_sg_bytes = sec4_sg_bytes; |
| 1760 | − edesc->sec4_sg = (void *)edesc + sizeof(struct ablkcipher_edesc) + | |
| 1761 | − desc_bytes; | |
| 1760 | + edesc->sec4_sg = (struct sec4_sg_entry *)((u8 *)edesc->hw_desc + | |
| 1761 | + desc_bytes); | |
| 1762 | 1762 | edesc->iv_dir = DMA_FROM_DEVICE; |
| 1763 | 1763 | |
| 1764 | 1764 | /* Make sure IV is located in a DMAable area */ |
| @@ -367,7 +367,8 @@ static inline void dsgl_walk_init(struct dsgl_walk *walk, · 366 unmodified lines | ||
| 367 | 367 | walk->to = (struct phys_sge_pairs *)(dsgl + 1); |
| 368 | 368 | } |
| 369 | 369 | |
| 370 | −static inline void dsgl_walk_end(struct dsgl_walk *walk, unsigned short qid) | |
| 370 | +static inline void dsgl_walk_end(struct dsgl_walk *walk, unsigned short qid, | |
| 371 | + int pci_chan_id) | |
| 371 | 372 | { |
| 372 | 373 | struct cpl_rx_phys_dsgl *phys_cpl; |
| 373 | 374 | |
| @@ -385,6 +386,7 @@ static inline void dsgl_walk_end(struct dsgl_walk *walk, unsigned short qid) · 11 unmodified lines | ||
| 385 | 386 | phys_cpl->rss_hdr_int.opcode = CPL_RX_PHYS_ADDR; |
| 386 | 387 | phys_cpl->rss_hdr_int.qid = htons(qid); |
| 387 | 388 | phys_cpl->rss_hdr_int.hash_val = 0; |
| 389 | + phys_cpl->rss_hdr_int.channel = pci_chan_id; | |
| 388 | 390 | } |
| 389 | 391 | |
| 390 | 392 | static inline void dsgl_walk_add_page(struct dsgl_walk *walk, |
| @@ -718,7 +720,7 @@ static inline void create_wreq(struct chcr_context *ctx, · 327 unmodified lines | ||
| 718 | 720 | FILL_WR_RX_Q_ID(ctx->dev->rx_channel_id, qid, |
| 719 | 721 | !!lcb, ctx->tx_qidx); |
| 720 | 722 | |
| 721 | − chcr_req->ulptx.cmd_dest = FILL_ULPTX_CMD_DEST(ctx->dev->tx_channel_id, | |
| 723 | + chcr_req->ulptx.cmd_dest = FILL_ULPTX_CMD_DEST(ctx->tx_chan_id, | |
| 722 | 724 | qid); |
| 723 | 725 | chcr_req->ulptx.len = htonl((DIV_ROUND_UP(len16, 16) - |
| 724 | 726 | ((sizeof(chcr_req->wreq)) >> 4))); |
| @@ -1339,16 +1341,23 @@ static int chcr_device_init(struct chcr_context *ctx) · 614 unmodified lines | ||
| 1339 | 1341 | adap->vres.ncrypto_fc); |
| 1340 | 1342 | rxq_perchan = u_ctx->lldi.nrxq / u_ctx->lldi.nchan; |
| 1341 | 1343 | txq_perchan = ntxq / u_ctx->lldi.nchan; |
| 1342 | − rxq_idx = ctx->dev->tx_channel_id * rxq_perchan; | |
| 1343 | − rxq_idx += id % rxq_perchan; | |
| 1344 | − txq_idx = ctx->dev->tx_channel_id * txq_perchan; | |
| 1345 | − txq_idx += id % txq_perchan; | |
| 1346 | 1344 | spin_lock(&ctx->dev->lock_chcr_dev); |
| 1347 | − ctx->rx_qidx = rxq_idx; | |
| 1348 | − ctx->tx_qidx = txq_idx; | |
| 1345 | + ctx->tx_chan_id = ctx->dev->tx_channel_id; | |
| 1349 | 1346 | ctx->dev->tx_channel_id = !ctx->dev->tx_channel_id; |
| 1350 | 1347 | ctx->dev->rx_channel_id = 0; |
| 1351 | 1348 | spin_unlock(&ctx->dev->lock_chcr_dev); |
| 1349 | + rxq_idx = ctx->tx_chan_id * rxq_perchan; | |
| 1350 | + rxq_idx += id % rxq_perchan; | |
| 1351 | + txq_idx = ctx->tx_chan_id * txq_perchan; | |
| 1352 | + txq_idx += id % txq_perchan; | |
| 1353 | + ctx->rx_qidx = rxq_idx; | |
| 1354 | + ctx->tx_qidx = txq_idx; | |
| 1355 | + /* Channel Id used by SGE to forward packet to Host. | |
| 1356 | + * Same value should be used in cpl_fw6_pld RSS_CH field | |
| 1357 | + * by FW. Driver programs PCI channel ID to be used in fw | |
| 1358 | + * at the time of queue allocation with value "pi->tx_chan" | |
| 1359 | + */ | |
| 1360 | + ctx->pci_chan_id = txq_idx / txq_perchan; | |
| 1352 | 1361 | } |
| 1353 | 1362 | out: |
| 1354 | 1363 | return err; |
| @@ -2503,6 +2512,7 @@ void chcr_add_aead_dst_ent(struct aead_request *req, · 1148 unmodified lines | ||
| 2503 | 2512 | struct crypto_aead *tfm = crypto_aead_reqtfm(req); |
| 2504 | 2513 | struct dsgl_walk dsgl_walk; |
| 2505 | 2514 | unsigned int authsize = crypto_aead_authsize(tfm); |
| 2515 | + struct chcr_context *ctx = a_ctx(tfm); | |
| 2506 | 2516 | u32 temp; |
| 2507 | 2517 | |
| 2508 | 2518 | dsgl_walk_init(&dsgl_walk, phys_cpl); |
| @@ -2512,7 +2522,7 @@ void chcr_add_aead_dst_ent(struct aead_request *req, · 3 unmodified lines | ||
| 2512 | 2522 | dsgl_walk_add_page(&dsgl_walk, IV, &reqctx->iv_dma); |
| 2513 | 2523 | temp = req->cryptlen + (reqctx->op ? -authsize : authsize); |
| 2514 | 2524 | dsgl_walk_add_sg(&dsgl_walk, req->dst, temp, req->assoclen); |
| 2515 | − dsgl_walk_end(&dsgl_walk, qid); | |
| 2525 | + dsgl_walk_end(&dsgl_walk, qid, ctx->pci_chan_id); | |
| 2516 | 2526 | } |
| 2517 | 2527 | |
| 2518 | 2528 | void chcr_add_cipher_src_ent(struct ablkcipher_request *req, |
| @@ -2544,6 +2554,8 @@ void chcr_add_cipher_dst_ent(struct ablkcipher_request *req, · 25 unmodified lines | ||
| 2544 | 2554 | unsigned short qid) |
| 2545 | 2555 | { |
| 2546 | 2556 | struct chcr_blkcipher_req_ctx *reqctx = ablkcipher_request_ctx(req); |
| 2557 | + struct crypto_ablkcipher *tfm = crypto_ablkcipher_reqtfm(wrparam->req); | |
| 2558 | + struct chcr_context *ctx = c_ctx(tfm); | |
| 2547 | 2559 | struct dsgl_walk dsgl_walk; |
| 2548 | 2560 | |
| 2549 | 2561 | dsgl_walk_init(&dsgl_walk, phys_cpl); |
| @@ -2552,7 +2564,7 @@ void chcr_add_cipher_dst_ent(struct ablkcipher_request *req, · 2 unmodified lines | ||
| 2552 | 2564 | reqctx->dstsg = dsgl_walk.last_sg; |
| 2553 | 2565 | reqctx->dst_ofst = dsgl_walk.last_sg_len; |
| 2554 | 2566 | |
| 2555 | − dsgl_walk_end(&dsgl_walk, qid); | |
| 2567 | + dsgl_walk_end(&dsgl_walk, qid, ctx->pci_chan_id); | |
| 2556 | 2568 | } |
| 2557 | 2569 | |
| 2558 | 2570 | void chcr_add_hash_src_ent(struct ahash_request *req, |
| @@ -255,6 +255,8 @@ struct chcr_context { · 254 unmodified lines | ||
| 255 | 255 | struct chcr_dev *dev; |
| 256 | 256 | unsigned char tx_qidx; |
| 257 | 257 | unsigned char rx_qidx; |
| 258 | + unsigned char tx_chan_id; | |
| 259 | + unsigned char pci_chan_id; | |
| 258 | 260 | struct __crypto_ctx crypto_ctx[0]; |
| 259 | 261 | }; |
| 260 | 262 | |
| @@ -63,7 +63,7 @@ struct dcp { · 62 unmodified lines | ||
| 63 | 63 | struct dcp_coherent_block *coh; |
| 64 | 64 | |
| 65 | 65 | struct completion completion[DCP_MAX_CHANS]; |
| 66 | − struct mutex mutex[DCP_MAX_CHANS]; | |
| 66 | + spinlock_t lock[DCP_MAX_CHANS]; | |
| 67 | 67 | struct task_struct *thread[DCP_MAX_CHANS]; |
| 68 | 68 | struct crypto_queue queue[DCP_MAX_CHANS]; |
| 69 | 69 | }; |
| @@ -349,13 +349,20 @@ static int dcp_chan_thread_aes(void *data) · 279 unmodified lines | ||
| 349 | 349 | |
| 350 | 350 | int ret; |
| 351 | 351 | |
| 352 | − do { | |
| 353 | − __set_current_state(TASK_INTERRUPTIBLE); | |
| 352 | + while (!kthread_should_stop()) { | |
| 353 | + set_current_state(TASK_INTERRUPTIBLE); | |
| 354 | 354 | |
| 355 | − mutex_lock(&sdcp->mutex[chan]); | |
| 355 | + spin_lock(&sdcp->lock[chan]); | |
| 356 | 356 | backlog = crypto_get_backlog(&sdcp->queue[chan]); |
| 357 | 357 | arq = crypto_dequeue_request(&sdcp->queue[chan]); |
| 358 | − mutex_unlock(&sdcp->mutex[chan]); | |
| 358 | + spin_unlock(&sdcp->lock[chan]); | |
| 359 | + | |
| 360 | + if (!backlog && !arq) { | |
| 361 | + schedule(); | |
| 362 | + continue; | |
| 363 | + } | |
| 364 | + | |
| 365 | + set_current_state(TASK_RUNNING); | |
| 359 | 366 | |
| 360 | 367 | if (backlog) |
| 361 | 368 | backlog->complete(backlog, -EINPROGRESS); |
| @@ -363,11 +370,8 @@ static int dcp_chan_thread_aes(void *data) · 1 unmodified line | ||
| 363 | 370 | if (arq) { |
| 364 | 371 | ret = mxs_dcp_aes_block_crypt(arq); |
| 365 | 372 | arq->complete(arq, ret); |
| 366 | − continue; | |
| 367 | 373 | } |
| 368 | − | |
| 369 | − schedule(); | |
| 370 | − } while (!kthread_should_stop()); | |
| 374 | + } | |
| 371 | 375 | |
| 372 | 376 | return 0; |
| 373 | 377 | } |
| @@ -409,9 +413,9 @@ static int mxs_dcp_aes_enqueue(struct ablkcipher_request *req, int enc, int ecb) · 35 unmodified lines | ||
| 409 | 413 | rctx->ecb = ecb; |
| 410 | 414 | actx->chan = DCP_CHAN_CRYPTO; |
| 411 | 415 | |
| 412 | − mutex_lock(&sdcp->mutex[actx->chan]); | |
| 416 | + spin_lock(&sdcp->lock[actx->chan]); | |
| 413 | 417 | ret = crypto_enqueue_request(&sdcp->queue[actx->chan], &req->base); |
| 414 | − mutex_unlock(&sdcp->mutex[actx->chan]); | |
| 418 | + spin_unlock(&sdcp->lock[actx->chan]); | |
| 415 | 419 | |
| 416 | 420 | wake_up_process(sdcp->thread[actx->chan]); |
| 417 | 421 | |
| @@ -640,13 +644,20 @@ static int dcp_chan_thread_sha(void *data) · 222 unmodified lines | ||
| 640 | 644 | struct ahash_request *req; |
| 641 | 645 | int ret, fini; |
| 642 | 646 | |
| 643 | − do { | |
| 644 | − __set_current_state(TASK_INTERRUPTIBLE); | |
| 647 | + while (!kthread_should_stop()) { | |
| 648 | + set_current_state(TASK_INTERRUPTIBLE); | |
| 645 | 649 | |
| 646 | − mutex_lock(&sdcp->mutex[chan]); | |
| 650 | + spin_lock(&sdcp->lock[chan]); | |
| 647 | 651 | backlog = crypto_get_backlog(&sdcp->queue[chan]); |
| 648 | 652 | arq = crypto_dequeue_request(&sdcp->queue[chan]); |
| 649 | − mutex_unlock(&sdcp->mutex[chan]); | |
| 653 | + spin_unlock(&sdcp->lock[chan]); | |
| 654 | + | |
| 655 | + if (!backlog && !arq) { | |
| 656 | + schedule(); | |
| 657 | + continue; | |
| 658 | + } | |
| 659 | + | |
| 660 | + set_current_state(TASK_RUNNING); | |
| 650 | 661 | |
| 651 | 662 | if (backlog) |
| 652 | 663 | backlog->complete(backlog, -EINPROGRESS); |
| @@ -658,12 +669,8 @@ static int dcp_chan_thread_sha(void *data) · 5 unmodified lines | ||
| 658 | 669 | ret = dcp_sha_req_to_buf(arq); |
| 659 | 670 | fini = rctx->fini; |
| 660 | 671 | arq->complete(arq, ret); |
| 661 | − if (!fini) | |
| 662 | − continue; | |
| 663 | 672 | } |
| 664 | − | |
| 665 | − schedule(); | |
| 666 | − } while (!kthread_should_stop()); | |
| 673 | + } | |
| 667 | 674 | |
| 668 | 675 | return 0; |
| 669 | 676 | } |
| @@ -721,9 +728,9 @@ static int dcp_sha_update_fx(struct ahash_request *req, int fini) · 51 unmodified lines | ||
| 721 | 728 | rctx->init = 1; |
| 722 | 729 | } |
| 723 | 730 | |
| 724 | − mutex_lock(&sdcp->mutex[actx->chan]); | |
| 731 | + spin_lock(&sdcp->lock[actx->chan]); | |
| 725 | 732 | ret = crypto_enqueue_request(&sdcp->queue[actx->chan], &req->base); |
| 726 | − mutex_unlock(&sdcp->mutex[actx->chan]); | |
| 733 | + spin_unlock(&sdcp->lock[actx->chan]); | |
| 727 | 734 | |
| 728 | 735 | wake_up_process(sdcp->thread[actx->chan]); |
| 729 | 736 | mutex_unlock(&actx->mutex); |
| @@ -997,7 +1004,7 @@ static int mxs_dcp_probe(struct platform_device *pdev) · 267 unmodified lines | ||
| 997 | 1004 | platform_set_drvdata(pdev, sdcp); |
| 998 | 1005 | |
| 999 | 1006 | for (i = 0; i < DCP_MAX_CHANS; i++) { |
| 1000 | − mutex_init(&sdcp->mutex[i]); | |
| 1007 | + spin_lock_init(&sdcp->lock[i]); | |
| 1001 | 1008 | init_completion(&sdcp->completion[i]); |
| 1002 | 1009 | crypto_init_queue(&sdcp->queue[i], 50); |
| 1003 | 1010 | } |
| @@ -123,7 +123,8 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · 122 unmodified lines | ||
| 123 | 123 | struct adf_hw_device_data *hw_data; |
| 124 | 124 | char name[ADF_DEVICE_NAME_LENGTH]; |
| 125 | 125 | unsigned int i, bar_nr; |
| 126 | − int ret, bar_mask; | |
| 126 | + unsigned long bar_mask; | |
| 127 | + int ret; | |
| 127 | 128 | |
| 128 | 129 | switch (ent->device) { |
| 129 | 130 | case ADF_C3XXX_PCI_DEVICE_ID: |
| @@ -235,8 +236,7 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · 105 unmodified lines | ||
| 235 | 236 | /* Find and map all the device's BARS */ |
| 236 | 237 | i = 0; |
| 237 | 238 | bar_mask = pci_select_bars(pdev, IORESOURCE_MEM); |
| 238 | − for_each_set_bit(bar_nr, (const unsigned long *)&bar_mask, | |
| 239 | − ADF_PCI_MAX_BARS * 2) { | |
| 239 | + for_each_set_bit(bar_nr, &bar_mask, ADF_PCI_MAX_BARS * 2) { | |
| 240 | 240 | struct adf_bar *bar = &accel_pci_dev->pci_bars[i++]; |
| 241 | 241 | |
| 242 | 242 | bar->base_addr = pci_resource_start(pdev, bar_nr); |
| @@ -125,7 +125,8 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · 124 unmodified lines | ||
| 125 | 125 | struct adf_hw_device_data *hw_data; |
| 126 | 126 | char name[ADF_DEVICE_NAME_LENGTH]; |
| 127 | 127 | unsigned int i, bar_nr; |
| 128 | − int ret, bar_mask; | |
| 128 | + unsigned long bar_mask; | |
| 129 | + int ret; | |
| 129 | 130 | |
| 130 | 131 | switch (ent->device) { |
| 131 | 132 | case ADF_C3XXXIOV_PCI_DEVICE_ID: |
| @@ -215,8 +216,7 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · 83 unmodified lines | ||
| 215 | 216 | /* Find and map all the device's BARS */ |
| 216 | 217 | i = 0; |
| 217 | 218 | bar_mask = pci_select_bars(pdev, IORESOURCE_MEM); |
| 218 | − for_each_set_bit(bar_nr, (const unsigned long *)&bar_mask, | |
| 219 | − ADF_PCI_MAX_BARS * 2) { | |
| 219 | + for_each_set_bit(bar_nr, &bar_mask, ADF_PCI_MAX_BARS * 2) { | |
| 220 | 220 | struct adf_bar *bar = &accel_pci_dev->pci_bars[i++]; |
| 221 | 221 | |
| 222 | 222 | bar->base_addr = pci_resource_start(pdev, bar_nr); |
| @@ -123,7 +123,8 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · 122 unmodified lines | ||
| 123 | 123 | struct adf_hw_device_data *hw_data; |
| 124 | 124 | char name[ADF_DEVICE_NAME_LENGTH]; |
| 125 | 125 | unsigned int i, bar_nr; |
| 126 | − int ret, bar_mask; | |
| 126 | + unsigned long bar_mask; | |
| 127 | + int ret; | |
| 127 | 128 | |
| 128 | 129 | switch (ent->device) { |
| 129 | 130 | case ADF_C62X_PCI_DEVICE_ID: |
| @@ -235,8 +236,7 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · 105 unmodified lines | ||
| 235 | 236 | /* Find and map all the device's BARS */ |
| 236 | 237 | i = (hw_data->fuses & ADF_DEVICE_FUSECTL_MASK) ? 1 : 0; |
| 237 | 238 | bar_mask = pci_select_bars(pdev, IORESOURCE_MEM); |
| 238 | − for_each_set_bit(bar_nr, (const unsigned long *)&bar_mask, | |
| 239 | − ADF_PCI_MAX_BARS * 2) { | |
| 239 | + for_each_set_bit(bar_nr, &bar_mask, ADF_PCI_MAX_BARS * 2) { | |
| 240 | 240 | struct adf_bar *bar = &accel_pci_dev->pci_bars[i++]; |
| 241 | 241 | |
| 242 | 242 | bar->base_addr = pci_resource_start(pdev, bar_nr); |
| @@ -125,7 +125,8 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · 124 unmodified lines | ||
| 125 | 125 | struct adf_hw_device_data *hw_data; |
| 126 | 126 | char name[ADF_DEVICE_NAME_LENGTH]; |
| 127 | 127 | unsigned int i, bar_nr; |
| 128 | − int ret, bar_mask; | |
| 128 | + unsigned long bar_mask; | |
| 129 | + int ret; | |
| 129 | 130 | |
| 130 | 131 | switch (ent->device) { |
| 131 | 132 | case ADF_C62XIOV_PCI_DEVICE_ID: |
| @@ -215,8 +216,7 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · 83 unmodified lines | ||
| 215 | 216 | /* Find and map all the device's BARS */ |
| 216 | 217 | i = 0; |
| 217 | 218 | bar_mask = pci_select_bars(pdev, IORESOURCE_MEM); |
| 218 | − for_each_set_bit(bar_nr, (const unsigned long *)&bar_mask, | |
| 219 | − ADF_PCI_MAX_BARS * 2) { | |
| 219 | + for_each_set_bit(bar_nr, &bar_mask, ADF_PCI_MAX_BARS * 2) { | |
| 220 | 220 | struct adf_bar *bar = &accel_pci_dev->pci_bars[i++]; |
| 221 | 221 | |
| 222 | 222 | bar->base_addr = pci_resource_start(pdev, bar_nr); |
| @@ -123,7 +123,8 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · 122 unmodified lines | ||
| 123 | 123 | struct adf_hw_device_data *hw_data; |
| 124 | 124 | char name[ADF_DEVICE_NAME_LENGTH]; |
| 125 | 125 | unsigned int i, bar_nr; |
| 126 | − int ret, bar_mask; | |
| 126 | + unsigned long bar_mask; | |
| 127 | + int ret; | |
| 127 | 128 | |
| 128 | 129 | switch (ent->device) { |
| 129 | 130 | case ADF_DH895XCC_PCI_DEVICE_ID: |
| @@ -237,8 +238,7 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · 107 unmodified lines | ||
| 237 | 238 | /* Find and map all the device's BARS */ |
| 238 | 239 | i = 0; |
| 239 | 240 | bar_mask = pci_select_bars(pdev, IORESOURCE_MEM); |
| 240 | − for_each_set_bit(bar_nr, (const unsigned long *)&bar_mask, | |
| 241 | − ADF_PCI_MAX_BARS * 2) { | |
| 241 | + for_each_set_bit(bar_nr, &bar_mask, ADF_PCI_MAX_BARS * 2) { | |
| 242 | 242 | struct adf_bar *bar = &accel_pci_dev->pci_bars[i++]; |
| 243 | 243 | |
| 244 | 244 | bar->base_addr = pci_resource_start(pdev, bar_nr); |
| @@ -125,7 +125,8 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · 124 unmodified lines | ||
| 125 | 125 | struct adf_hw_device_data *hw_data; |
| 126 | 126 | char name[ADF_DEVICE_NAME_LENGTH]; |
| 127 | 127 | unsigned int i, bar_nr; |
| 128 | − int ret, bar_mask; | |
| 128 | + unsigned long bar_mask; | |
| 129 | + int ret; | |
| 129 | 130 | |
| 130 | 131 | switch (ent->device) { |
| 131 | 132 | case ADF_DH895XCCIOV_PCI_DEVICE_ID: |
| @@ -215,8 +216,7 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · 83 unmodified lines | ||
| 215 | 216 | /* Find and map all the device's BARS */ |
| 216 | 217 | i = 0; |
| 217 | 218 | bar_mask = pci_select_bars(pdev, IORESOURCE_MEM); |
| 218 | − for_each_set_bit(bar_nr, (const unsigned long *)&bar_mask, | |
| 219 | − ADF_PCI_MAX_BARS * 2) { | |
| 219 | + for_each_set_bit(bar_nr, &bar_mask, ADF_PCI_MAX_BARS * 2) { | |
| 220 | 220 | struct adf_bar *bar = &accel_pci_dev->pci_bars[i++]; |
| 221 | 221 | |
| 222 | 222 | bar->base_addr = pci_resource_start(pdev, bar_nr); |
| @@ -14,6 +14,7 @@ · 13 unmodified lines | ||
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | 16 | #include <linux/module.h> |
| 17 | +#include <linux/fpga/fpga-mgr.h> | |
| 17 | 18 | #include <linux/fpga/fpga-region.h> |
| 18 | 19 | |
| 19 | 20 | #include "dfl-fme-pr.h" |
| @@ -66,9 +67,10 @@ eprobe_mgr_put: · 46 unmodified lines | ||
| 66 | 67 | static int fme_region_remove(struct platform_device *pdev) |
| 67 | 68 | { |
| 68 | 69 | struct fpga_region *region = dev_get_drvdata(&pdev->dev); |
| 70 | + struct fpga_manager *mgr = region->mgr; | |
| 69 | 71 | |
| 70 | 72 | fpga_region_unregister(region); |
| 71 | − fpga_mgr_put(region->mgr); | |
| 73 | + fpga_mgr_put(mgr); | |
| 72 | 74 | |
| 73 | 75 | return 0; |
| 74 | 76 | } |
| @@ -125,7 +125,7 @@ static int fpga_bridge_dev_match(struct device *dev, const void *data) · 124 unmodified lines | ||
| 125 | 125 | * |
| 126 | 126 | * Given a device, get an exclusive reference to a fpga bridge. |
| 127 | 127 | * |
| 128 | − * Return: fpga manager struct or IS_ERR() condition containing error code. | |
| 128 | + * Return: fpga bridge struct or IS_ERR() condition containing error code. | |
| 129 | 129 | */ |
| 130 | 130 | struct fpga_bridge *fpga_bridge_get(struct device *dev, |
| 131 | 131 | struct fpga_image_info *info) |
| @@ -437,9 +437,10 @@ eprobe_mgr_put: · 436 unmodified lines | ||
| 437 | 437 | static int of_fpga_region_remove(struct platform_device *pdev) |
| 438 | 438 | { |
| 439 | 439 | struct fpga_region *region = platform_get_drvdata(pdev); |
| 440 | + struct fpga_manager *mgr = region->mgr; | |
| 440 | 441 | |
| 441 | 442 | fpga_region_unregister(region); |
| 442 | − fpga_mgr_put(region->mgr); | |
| 443 | + fpga_mgr_put(mgr); | |
| 443 | 444 | |
| 444 | 445 | return 0; |
| 445 | 446 | } |
| @@ -571,7 +571,7 @@ static int linehandle_create(struct gpio_device *gdev, void __user *ip) · 570 unmodified lines | ||
| 571 | 571 | if (ret) |
| 572 | 572 | goto out_free_descs; |
| 573 | 573 | lh->descs[i] = desc; |
| 574 | − count = i; | |
| 574 | + count = i + 1; | |
| 575 | 575 | |
| 576 | 576 | if (lflags & GPIOHANDLE_REQUEST_ACTIVE_LOW) |
| 577 | 577 | set_bit(FLAG_ACTIVE_LOW, &desc->flags); |
| @@ -358,8 +358,8 @@ static int create_compute_queue_nocpsch(struct device_queue_manager *dqm, · 357 unmodified lines | ||
| 358 | 358 | struct queue *q, |
| 359 | 359 | struct qcm_process_device *qpd) |
| 360 | 360 | { |
| 361 | − int retval; | |
| 362 | 361 | struct mqd_manager *mqd_mgr; |
| 362 | + int retval; | |
| 363 | 363 | |
| 364 | 364 | mqd_mgr = dqm->ops.get_mqd_manager(dqm, KFD_MQD_TYPE_COMPUTE); |
| 365 | 365 | if (!mqd_mgr) |
| @@ -387,8 +387,12 @@ static int create_compute_queue_nocpsch(struct device_queue_manager *dqm, · 21 unmodified lines | ||
| 387 | 387 | if (!q->properties.is_active) |
| 388 | 388 | return 0; |
| 389 | 389 | |
| 390 | − retval = mqd_mgr->load_mqd(mqd_mgr, q->mqd, q->pipe, q->queue, | |
| 391 | − &q->properties, q->process->mm); | |
| 390 | + if (WARN(q->process->mm != current->mm, | |
| 391 | + "should only run in user thread")) | |
| 392 | + retval = -EFAULT; | |
| 393 | + else | |
| 394 | + retval = mqd_mgr->load_mqd(mqd_mgr, q->mqd, q->pipe, q->queue, | |
| 395 | + &q->properties, current->mm); | |
| 392 | 396 | if (retval) |
| 393 | 397 | goto out_uninit_mqd; |
| 394 | 398 | |
| @@ -545,9 +549,15 @@ static int update_queue(struct device_queue_manager *dqm, struct queue *q) · 150 unmodified lines | ||
| 545 | 549 | retval = map_queues_cpsch(dqm); |
| 546 | 550 | else if (q->properties.is_active && |
| 547 | 551 | (q->properties.type == KFD_QUEUE_TYPE_COMPUTE || |
| 548 | − q->properties.type == KFD_QUEUE_TYPE_SDMA)) | |
| 549 | − retval = mqd_mgr->load_mqd(mqd_mgr, q->mqd, q->pipe, q->queue, | |
| 550 | − &q->properties, q->process->mm); | |
| 552 | + q->properties.type == KFD_QUEUE_TYPE_SDMA)) { | |
| 553 | + if (WARN(q->process->mm != current->mm, | |
| 554 | + "should only run in user thread")) | |
| 555 | + retval = -EFAULT; | |
| 556 | + else | |
| 557 | + retval = mqd_mgr->load_mqd(mqd_mgr, q->mqd, | |
| 558 | + q->pipe, q->queue, | |
| 559 | + &q->properties, current->mm); | |
| 560 | + } | |
| 551 | 561 | |
| 552 | 562 | out_unlock: |
| 553 | 563 | dqm_unlock(dqm); |
| @@ -653,6 +663,7 @@ out: · 99 unmodified lines | ||
| 653 | 663 | static int restore_process_queues_nocpsch(struct device_queue_manager *dqm, |
| 654 | 664 | struct qcm_process_device *qpd) |
| 655 | 665 | { |
| 666 | + struct mm_struct *mm = NULL; | |
| 656 | 667 | struct queue *q; |
| 657 | 668 | struct mqd_manager *mqd_mgr; |
| 658 | 669 | struct kfd_process_device *pdd; |
| @@ -686,6 +697,15 @@ static int restore_process_queues_nocpsch(struct device_queue_manager *dqm, · 27 unmodified lines | ||
| 686 | 697 | kfd_flush_tlb(pdd); |
| 687 | 698 | } |
| 688 | 699 | |
| 700 | + /* Take a safe reference to the mm_struct, which may otherwise | |
| 701 | + * disappear even while the kfd_process is still referenced. | |
| 702 | + */ | |
| 703 | + mm = get_task_mm(pdd->process->lead_thread); | |
| 704 | + if (!mm) { | |
| 705 | + retval = -EFAULT; | |
| 706 | + goto out; | |
| 707 | + } | |
| 708 | + | |
| 689 | 709 | /* activate all active queues on the qpd */ |
| 690 | 710 | list_for_each_entry(q, &qpd->queues_list, list) { |
| 691 | 711 | if (!q->properties.is_evicted) |
| @@ -700,14 +720,15 @@ static int restore_process_queues_nocpsch(struct device_queue_manager *dqm, · 8 unmodified lines | ||
| 700 | 720 | q->properties.is_evicted = false; |
| 701 | 721 | q->properties.is_active = true; |
| 702 | 722 | retval = mqd_mgr->load_mqd(mqd_mgr, q->mqd, q->pipe, |
| 703 | − q->queue, &q->properties, | |
| 704 | − q->process->mm); | |
| 723 | + q->queue, &q->properties, mm); | |
| 705 | 724 | if (retval) |
| 706 | 725 | goto out; |
| 707 | 726 | dqm->queue_count++; |
| 708 | 727 | } |
| 709 | 728 | qpd->evicted = 0; |
| 710 | 729 | out: |
| 730 | + if (mm) | |
| 731 | + mmput(mm); | |
| 711 | 732 | dqm_unlock(dqm); |
| 712 | 733 | return retval; |
| 713 | 734 | } |
| @@ -4633,12 +4633,18 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state) · 4632 unmodified lines | ||
| 4633 | 4633 | } |
| 4634 | 4634 | spin_unlock_irqrestore(&adev->ddev->event_lock, flags); |
| 4635 | 4635 | |
| 4636 | − /* Signal HW programming completion */ | |
| 4637 | − drm_atomic_helper_commit_hw_done(state); | |
| 4638 | 4636 | |
| 4639 | 4637 | if (wait_for_vblank) |
| 4640 | 4638 | drm_atomic_helper_wait_for_flip_done(dev, state); |
| 4641 | 4639 | |
| 4640 | + /* | |
| 4641 | + * FIXME: | |
| 4642 | + * Delay hw_done() until flip_done() is signaled. This is to block | |
| 4643 | + * another commit from freeing the CRTC state while we're still | |
| 4644 | + * waiting on flip_done. | |
| 4645 | + */ | |
| 4646 | + drm_atomic_helper_commit_hw_done(state); | |
| 4647 | + | |
| 4642 | 4648 | drm_atomic_helper_cleanup_planes(dev, state); |
| 4643 | 4649 | |
| 4644 | 4650 | /* Finally, drop a runtime PM reference for each newly disabled CRTC, |
| @@ -63,20 +63,21 @@ static void drm_client_close(struct drm_client_dev *client) · 62 unmodified lines | ||
| 63 | 63 | EXPORT_SYMBOL(drm_client_close); |
| 64 | 64 | |
| 65 | 65 | /** |
| 66 | − * drm_client_new - Create a DRM client | |
| 66 | + * drm_client_init - Initialise a DRM client | |
| 67 | 67 | * @dev: DRM device |
| 68 | 68 | * @client: DRM client |
| 69 | 69 | * @name: Client name |
| 70 | 70 | * @funcs: DRM client functions (optional) |
| 71 | 71 | * |
| 72 | + * This initialises the client and opens a &drm_file. Use drm_client_add() to complete the process. | |
| 72 | 73 | * The caller needs to hold a reference on @dev before calling this function. |
| 73 | 74 | * The client is freed when the &drm_device is unregistered. See drm_client_release(). |
| 74 | 75 | * |
| 75 | 76 | * Returns: |
| 76 | 77 | * Zero on success or negative error code on failure. |
| 77 | 78 | */ |
| 78 | −int drm_client_new(struct drm_device *dev, struct drm_client_dev *client, | |
| 79 | − const char *name, const struct drm_client_funcs *funcs) | |
| 79 | +int drm_client_init(struct drm_device *dev, struct drm_client_dev *client, | |
| 80 | + const char *name, const struct drm_client_funcs *funcs) | |
| 80 | 81 | { |
| 81 | 82 | int ret; |
| 82 | 83 | |
| @@ -95,10 +96,6 @@ int drm_client_new(struct drm_device *dev, struct drm_client_dev *client, · 12 unmodified lines | ||
| 95 | 96 | if (ret) |
| 96 | 97 | goto err_put_module; |
| 97 | 98 | |
| 98 | − mutex_lock(&dev->clientlist_mutex); | |
| 99 | − list_add(&client->list, &dev->clientlist); | |
| 100 | − mutex_unlock(&dev->clientlist_mutex); | |
| 101 | − | |
| 102 | 99 | drm_dev_get(dev); |
| 103 | 100 | |
| 104 | 101 | return 0; |
| @@ -109,13 +106,33 @@ err_put_module: · 4 unmodified lines | ||
| 109 | 106 | |
| 110 | 107 | return ret; |
| 111 | 108 | } |
| 112 | −EXPORT_SYMBOL(drm_client_new); | |
| 109 | +EXPORT_SYMBOL(drm_client_init); | |
| 110 | + | |
| 111 | +/** | |
| 112 | + * drm_client_add - Add client to the device list | |
| 113 | + * @client: DRM client | |
| 114 | + * | |
| 115 | + * Add the client to the &drm_device client list to activate its callbacks. | |
| 116 | + * @client must be initialized by a call to drm_client_init(). After | |
| 117 | + * drm_client_add() it is no longer permissible to call drm_client_release() | |
| 118 | + * directly (outside the unregister callback), instead cleanup will happen | |
| 119 | + * automatically on driver unload. | |
| 120 | + */ | |
| 121 | +void drm_client_add(struct drm_client_dev *client) | |
| 122 | +{ | |
| 123 | + struct drm_device *dev = client->dev; | |
| 124 | + | |
| 125 | + mutex_lock(&dev->clientlist_mutex); | |
| 126 | + list_add(&client->list, &dev->clientlist); | |
| 127 | + mutex_unlock(&dev->clientlist_mutex); | |
| 128 | +} | |
| 129 | +EXPORT_SYMBOL(drm_client_add); | |
| 113 | 130 | |
| 114 | 131 | /** |
| 115 | 132 | * drm_client_release - Release DRM client resources |
| 116 | 133 | * @client: DRM client |
| 117 | 134 | * |
| 118 | − * Releases resources by closing the &drm_file that was opened by drm_client_new(). | |
| 135 | + * Releases resources by closing the &drm_file that was opened by drm_client_init(). | |
| 119 | 136 | * It is called automatically if the &drm_client_funcs.unregister callback is _not_ set. |
| 120 | 137 | * |
| 121 | 138 | * This function should only be called from the unregister callback. An exception |
| @@ -160,7 +160,7 @@ struct drm_fbdev_cma *drm_fbdev_cma_init(struct drm_device *dev, · 159 unmodified lines | ||
| 160 | 160 | |
| 161 | 161 | fb_helper = &fbdev_cma->fb_helper; |
| 162 | 162 | |
| 163 | − ret = drm_client_new(dev, &fb_helper->client, "fbdev", NULL); | |
| 163 | + ret = drm_client_init(dev, &fb_helper->client, "fbdev", NULL); | |
| 164 | 164 | if (ret) |
| 165 | 165 | goto err_free; |
| 166 | 166 | |
| @@ -169,6 +169,8 @@ struct drm_fbdev_cma *drm_fbdev_cma_init(struct drm_device *dev, · 2 unmodified lines | ||
| 169 | 169 | if (ret) |
| 170 | 170 | goto err_client_put; |
| 171 | 171 | |
| 172 | + drm_client_add(&fb_helper->client); | |
| 173 | + | |
| 172 | 174 | return fbdev_cma; |
| 173 | 175 | |
| 174 | 176 | err_client_put: |
| @@ -3218,12 +3218,14 @@ int drm_fbdev_generic_setup(struct drm_device *dev, unsigned int preferred_bpp) · 3217 unmodified lines | ||
| 3218 | 3218 | if (!fb_helper) |
| 3219 | 3219 | return -ENOMEM; |
| 3220 | 3220 | |
| 3221 | − ret = drm_client_new(dev, &fb_helper->client, "fbdev", &drm_fbdev_client_funcs); | |
| 3221 | + ret = drm_client_init(dev, &fb_helper->client, "fbdev", &drm_fbdev_client_funcs); | |
| 3222 | 3222 | if (ret) { |
| 3223 | 3223 | kfree(fb_helper); |
| 3224 | 3224 | return ret; |
| 3225 | 3225 | } |
| 3226 | 3226 | |
| 3227 | + drm_client_add(&fb_helper->client); | |
| 3228 | + | |
| 3227 | 3229 | fb_helper->preferred_bpp = preferred_bpp; |
| 3228 | 3230 | |
| 3229 | 3231 | drm_fbdev_client_hotplug(&fb_helper->client); |
| @@ -566,14 +566,14 @@ int drm_mode_create_lease_ioctl(struct drm_device *dev, · 565 unmodified lines | ||
| 566 | 566 | lessee_priv->is_master = 1; |
| 567 | 567 | lessee_priv->authenticated = 1; |
| 568 | 568 | |
| 569 | − /* Hook up the fd */ | |
| 570 | − fd_install(fd, lessee_file); | |
| 571 | − | |
| 572 | 569 | /* Pass fd back to userspace */ |
| 573 | 570 | DRM_DEBUG_LEASE("Returning fd %d id %d\n", fd, lessee->lessee_id); |
| 574 | 571 | cl->fd = fd; |
| 575 | 572 | cl->lessee_id = lessee->lessee_id; |
| 576 | 573 | |
| 574 | + /* Hook up the fd */ | |
| 575 | + fd_install(fd, lessee_file); | |
| 576 | + | |
| 577 | 577 | DRM_DEBUG_LEASE("drm_mode_create_lease_ioctl succeeded\n"); |
| 578 | 578 | return 0; |
| 579 | 579 | |
| @@ -55,37 +55,12 @@ static inline void __exynos_iommu_detach(struct exynos_drm_private *priv, · 54 unmodified lines | ||
| 55 | 55 | static inline int __exynos_iommu_create_mapping(struct exynos_drm_private *priv, |
| 56 | 56 | unsigned long start, unsigned long size) |
| 57 | 57 | { |
| 58 | − struct iommu_domain *domain; | |
| 59 | − int ret; | |
| 60 | − | |
| 61 | − domain = iommu_domain_alloc(priv->dma_dev->bus); | |
| 62 | − if (!domain) | |
| 63 | − return -ENOMEM; | |
| 64 | − | |
| 65 | − ret = iommu_get_dma_cookie(domain); | |
| 66 | − if (ret) | |
| 67 | − goto free_domain; | |
| 68 | − | |
| 69 | − ret = iommu_dma_init_domain(domain, start, size, NULL); | |
| 70 | − if (ret) | |
| 71 | − goto put_cookie; | |
| 72 | − | |
| 73 | − priv->mapping = domain; | |
| 58 | + priv->mapping = iommu_get_domain_for_dev(priv->dma_dev); | |
| 74 | 59 | return 0; |
| 75 | − | |
| 76 | −put_cookie: | |
| 77 | − iommu_put_dma_cookie(domain); | |
| 78 | −free_domain: | |
| 79 | − iommu_domain_free(domain); | |
| 80 | − return ret; | |
| 81 | 60 | } |
| 82 | 61 | |
| 83 | 62 | static inline void __exynos_iommu_release_mapping(struct exynos_drm_private *priv) |
| 84 | 63 | { |
| 85 | − struct iommu_domain *domain = priv->mapping; | |
| 86 | − | |
| 87 | − iommu_put_dma_cookie(domain); | |
| 88 | − iommu_domain_free(domain); | |
| 89 | 64 | priv->mapping = NULL; |
| 90 | 65 | } |
| 91 | 66 | |
| @@ -94,7 +69,9 @@ static inline int __exynos_iommu_attach(struct exynos_drm_private *priv, · 2 unmodified lines | ||
| 94 | 69 | { |
| 95 | 70 | struct iommu_domain *domain = priv->mapping; |
| 96 | 71 | |
| 97 | − return iommu_attach_device(domain, dev); | |
| 72 | + if (dev != priv->dma_dev) | |
| 73 | + return iommu_attach_device(domain, dev); | |
| 74 | + return 0; | |
| 98 | 75 | } |
| 99 | 76 | |
| 100 | 77 | static inline void __exynos_iommu_detach(struct exynos_drm_private *priv, |
| @@ -102,7 +79,8 @@ static inline void __exynos_iommu_detach(struct exynos_drm_private *priv, · 1 unmodified line | ||
| 102 | 79 | { |
| 103 | 80 | struct iommu_domain *domain = priv->mapping; |
| 104 | 81 | |
| 105 | − iommu_detach_device(domain, dev); | |
| 82 | + if (dev != priv->dma_dev) | |
| 83 | + iommu_detach_device(domain, dev); | |
| 106 | 84 | } |
| 107 | 85 | #else |
| 108 | 86 | #error Unsupported architecture and IOMMU/DMA-mapping glue code |
| @@ -191,7 +191,8 @@ static irqreturn_t tda9950_irq(int irq, void *data) · 190 unmodified lines | ||
| 191 | 191 | break; |
| 192 | 192 | } |
| 193 | 193 | /* TDA9950 executes all retries for us */ |
| 194 | − tx_status |= CEC_TX_STATUS_MAX_RETRIES; | |
| 194 | + if (tx_status != CEC_TX_STATUS_OK) | |
| 195 | + tx_status |= CEC_TX_STATUS_MAX_RETRIES; | |
| 195 | 196 | cec_transmit_done(priv->adap, tx_status, arb_lost_cnt, |
| 196 | 197 | nack_cnt, 0, err_cnt); |
| 197 | 198 | break; |
| @@ -310,7 +311,7 @@ static void tda9950_release(struct tda9950_priv *priv) · 112 unmodified lines | ||
| 310 | 311 | /* Wait up to .5s for it to signal non-busy */ |
| 311 | 312 | do { |
| 312 | 313 | csr = tda9950_read(client, REG_CSR); |
| 313 | − if (!(csr & CSR_BUSY) || --timeout) | |
| 314 | + if (!(csr & CSR_BUSY) || !--timeout) | |
| 314 | 315 | break; |
| 315 | 316 | msleep(10); |
| 316 | 317 | } while (1); |
| @@ -232,6 +232,20 @@ static bool compress_init(struct compress *c) · 231 unmodified lines | ||
| 232 | 232 | return true; |
| 233 | 233 | } |
| 234 | 234 | |
| 235 | +static void *compress_next_page(struct drm_i915_error_object *dst) | |
| 236 | +{ | |
| 237 | + unsigned long page; | |
| 238 | + | |
| 239 | + if (dst->page_count >= dst->num_pages) | |
| 240 | + return ERR_PTR(-ENOSPC); | |
| 241 | + | |
| 242 | + page = __get_free_page(GFP_ATOMIC | __GFP_NOWARN); | |
| 243 | + if (!page) | |
| 244 | + return ERR_PTR(-ENOMEM); | |
| 245 | + | |
| 246 | + return dst->pages[dst->page_count++] = (void *)page; | |
| 247 | +} | |
| 248 | + | |
| 235 | 249 | static int compress_page(struct compress *c, |
| 236 | 250 | void *src, |
| 237 | 251 | struct drm_i915_error_object *dst) |
| @@ -245,19 +259,14 @@ static int compress_page(struct compress *c, · 7 unmodified lines | ||
| 245 | 259 | |
| 246 | 260 | do { |
| 247 | 261 | if (zstream->avail_out == 0) { |
| 248 | − unsigned long page; | |
| 249 | − | |
| 250 | − page = __get_free_page(GFP_ATOMIC | __GFP_NOWARN); | |
| 251 | − if (!page) | |
| 252 | − return -ENOMEM; | |
| 262 | + zstream->next_out = compress_next_page(dst); | |
| 263 | + if (IS_ERR(zstream->next_out)) | |
| 264 | + return PTR_ERR(zstream->next_out); | |
| 253 | 265 | |
| 254 | − dst->pages[dst->page_count++] = (void *)page; | |
| 255 | − | |
| 256 | − zstream->next_out = (void *)page; | |
| 257 | 266 | zstream->avail_out = PAGE_SIZE; |
| 258 | 267 | } |
| 259 | 268 | |
| 260 | − if (zlib_deflate(zstream, Z_SYNC_FLUSH) != Z_OK) | |
| 269 | + if (zlib_deflate(zstream, Z_NO_FLUSH) != Z_OK) | |
| 261 | 270 | return -EIO; |
| 262 | 271 | } while (zstream->avail_in); |
| 263 | 272 | |
| @@ -268,19 +277,42 @@ static int compress_page(struct compress *c, · 4 unmodified lines | ||
| 268 | 277 | return 0; |
| 269 | 278 | } |
| 270 | 279 | |
| 271 | −static void compress_fini(struct compress *c, | |
| 280 | +static int compress_flush(struct compress *c, | |
| 272 | 281 | struct drm_i915_error_object *dst) |
| 273 | 282 | { |
| 274 | 283 | struct z_stream_s *zstream = &c->zstream; |
| 275 | 284 | |
| 276 | − if (dst) { | |
| 277 | − zlib_deflate(zstream, Z_FINISH); | |
| 278 | − dst->unused = zstream->avail_out; | |
| 279 | − } | |
| 285 | + do { | |
| 286 | + switch (zlib_deflate(zstream, Z_FINISH)) { | |
| 287 | + case Z_OK: /* more space requested */ | |
| 288 | + zstream->next_out = compress_next_page(dst); | |
| 289 | + if (IS_ERR(zstream->next_out)) | |
| 290 | + return PTR_ERR(zstream->next_out); | |
| 291 | + | |
| 292 | + zstream->avail_out = PAGE_SIZE; | |
| 293 | + break; | |
| 294 | + | |
| 295 | + case Z_STREAM_END: | |
| 296 | + goto end; | |
| 297 | + | |
| 298 | + default: /* any error */ | |
| 299 | + return -EIO; | |
| 300 | + } | |
| 301 | + } while (1); | |
| 302 | + | |
| 303 | +end: | |
| 304 | + memset(zstream->next_out, 0, zstream->avail_out); | |
| 305 | + dst->unused = zstream->avail_out; | |
| 306 | + return 0; | |
| 307 | +} | |
| 308 | + | |
| 309 | +static void compress_fini(struct compress *c, | |
| 310 | + struct drm_i915_error_object *dst) | |
| 311 | +{ | |
| 312 | + struct z_stream_s *zstream = &c->zstream; | |
| 280 | 313 | |
| 281 | 314 | zlib_deflateEnd(zstream); |
| 282 | 315 | kfree(zstream->workspace); |
| 283 | − | |
| 284 | 316 | if (c->tmp) |
| 285 | 317 | free_page((unsigned long)c->tmp); |
| 286 | 318 | } |
| @@ -319,6 +351,12 @@ static int compress_page(struct compress *c, · 32 unmodified lines | ||
| 319 | 351 | return 0; |
| 320 | 352 | } |
| 321 | 353 | |
| 354 | +static int compress_flush(struct compress *c, | |
| 355 | + struct drm_i915_error_object *dst) | |
| 356 | +{ | |
| 357 | + return 0; | |
| 358 | +} | |
| 359 | + | |
| 322 | 360 | static void compress_fini(struct compress *c, |
| 323 | 361 | struct drm_i915_error_object *dst) |
| 324 | 362 | { |
| @@ -917,6 +955,7 @@ i915_error_object_create(struct drm_i915_private *i915, · 592 unmodified lines | ||
| 917 | 955 | unsigned long num_pages; |
| 918 | 956 | struct sgt_iter iter; |
| 919 | 957 | dma_addr_t dma; |
| 958 | + int ret; | |
| 920 | 959 | |
| 921 | 960 | if (!vma) |
| 922 | 961 | return NULL; |
| @@ -930,6 +969,7 @@ i915_error_object_create(struct drm_i915_private *i915, · 7 unmodified lines | ||
| 930 | 969 | |
| 931 | 970 | dst->gtt_offset = vma->node.start; |
| 932 | 971 | dst->gtt_size = vma->node.size; |
| 972 | + dst->num_pages = num_pages; | |
| 933 | 973 | dst->page_count = 0; |
| 934 | 974 | dst->unused = 0; |
| 935 | 975 | |
| @@ -938,28 +978,26 @@ i915_error_object_create(struct drm_i915_private *i915, · 2 unmodified lines | ||
| 938 | 978 | return NULL; |
| 939 | 979 | } |
| 940 | 980 | |
| 981 | + ret = -EINVAL; | |
| 941 | 982 | for_each_sgt_dma(dma, iter, vma->pages) { |
| 942 | 983 | void __iomem *s; |
| 943 | − int ret; | |
| 944 | 984 | |
| 945 | 985 | ggtt->vm.insert_page(&ggtt->vm, dma, slot, I915_CACHE_NONE, 0); |
| 946 | 986 | |
| 947 | 987 | s = io_mapping_map_atomic_wc(&ggtt->iomap, slot); |
| 948 | 988 | ret = compress_page(&compress, (void __force *)s, dst); |
| 949 | 989 | io_mapping_unmap_atomic(s); |
| 950 | − | |
| 951 | 990 | if (ret) |
| 952 | − goto unwind; | |
| 991 | + break; | |
| 953 | 992 | } |
| 954 | − goto out; | |
| 955 | 993 | |
| 956 | −unwind: | |
| 957 | − while (dst->page_count--) | |
| 958 | − free_page((unsigned long)dst->pages[dst->page_count]); | |
| 959 | − kfree(dst); | |
| 960 | − dst = NULL; | |
| 994 | + if (ret || compress_flush(&compress, dst)) { | |
| 995 | + while (dst->page_count--) | |
| 996 | + free_page((unsigned long)dst->pages[dst->page_count]); | |
| 997 | + kfree(dst); | |
| 998 | + dst = NULL; | |
| 999 | + } | |
| 961 | 1000 | |
| 962 | −out: | |
| 963 | 1001 | compress_fini(&compress, dst); |
| 964 | 1002 | ggtt->vm.clear_range(&ggtt->vm, slot, PAGE_SIZE); |
| 965 | 1003 | return dst; |
| @@ -135,6 +135,7 @@ struct i915_gpu_state { · 134 unmodified lines | ||
| 135 | 135 | struct drm_i915_error_object { |
| 136 | 136 | u64 gtt_offset; |
| 137 | 137 | u64 gtt_size; |
| 138 | + int num_pages; | |
| 138 | 139 | int page_count; |
| 139 | 140 | int unused; |
| 140 | 141 | u32 *pages[0]; |
| @@ -3091,36 +3091,27 @@ gen11_gt_irq_handler(struct drm_i915_private * const i915, · 3090 unmodified lines | ||
| 3091 | 3091 | spin_unlock(&i915->irq_lock); |
| 3092 | 3092 | } |
| 3093 | 3093 | |
| 3094 | −static void | |
| 3095 | −gen11_gu_misc_irq_ack(struct drm_i915_private *dev_priv, const u32 master_ctl, | |
| 3096 | − u32 *iir) | |
| 3094 | +static u32 | |
| 3095 | +gen11_gu_misc_irq_ack(struct drm_i915_private *dev_priv, const u32 master_ctl) | |
| 3097 | 3096 | { |
| 3098 | 3097 | void __iomem * const regs = dev_priv->regs; |
| 3098 | + u32 iir; | |
| 3099 | 3099 | |
| 3100 | 3100 | if (!(master_ctl & GEN11_GU_MISC_IRQ)) |
| 3101 | − return; | |
| 3101 | + return 0; | |
| 3102 | + | |
| 3103 | + iir = raw_reg_read(regs, GEN11_GU_MISC_IIR); | |
| 3104 | + if (likely(iir)) | |
| 3105 | + raw_reg_write(regs, GEN11_GU_MISC_IIR, iir); | |
| 3102 | 3106 | |
| 3103 | − *iir = raw_reg_read(regs, GEN11_GU_MISC_IIR); | |
| 3104 | − if (likely(*iir)) | |
| 3105 | − raw_reg_write(regs, GEN11_GU_MISC_IIR, *iir); | |
| 3107 | + return iir; | |
| 3106 | 3108 | } |
| 3107 | 3109 | |
| 3108 | 3110 | static void |
| 3109 | −gen11_gu_misc_irq_handler(struct drm_i915_private *dev_priv, | |
| 3110 | − const u32 master_ctl, const u32 iir) | |
| 3111 | +gen11_gu_misc_irq_handler(struct drm_i915_private *dev_priv, const u32 iir) | |
| 3111 | 3112 | { |
| 3112 | − if (!(master_ctl & GEN11_GU_MISC_IRQ)) | |
| 3113 | − return; | |
| 3114 | − | |
| 3115 | − if (unlikely(!iir)) { | |
| 3116 | − DRM_ERROR("GU_MISC iir blank!\n"); | |
| 3117 | − return; | |
| 3118 | − } | |
| 3119 | − | |
| 3120 | 3113 | if (iir & GEN11_GU_MISC_GSE) |
| 3121 | 3114 | intel_opregion_asle_intr(dev_priv); |
| 3122 | − else | |
| 3123 | − DRM_ERROR("Unexpected GU_MISC interrupt 0x%x\n", iir); | |
| 3124 | 3115 | } |
| 3125 | 3116 | |
| 3126 | 3117 | static irqreturn_t gen11_irq_handler(int irq, void *arg) |
| @@ -3157,12 +3148,12 @@ static irqreturn_t gen11_irq_handler(int irq, void *arg) · 30 unmodified lines | ||
| 3157 | 3148 | enable_rpm_wakeref_asserts(i915); |
| 3158 | 3149 | } |
| 3159 | 3150 | |
| 3160 | − gen11_gu_misc_irq_ack(i915, master_ctl, &gu_misc_iir); | |
| 3151 | + gu_misc_iir = gen11_gu_misc_irq_ack(i915, master_ctl); | |
| 3161 | 3152 | |
| 3162 | 3153 | /* Acknowledge and enable interrupts. */ |
| 3163 | 3154 | raw_reg_write(regs, GEN11_GFX_MSTR_IRQ, GEN11_MASTER_IRQ | master_ctl); |
| 3164 | 3155 | |
| 3165 | − gen11_gu_misc_irq_handler(i915, master_ctl, gu_misc_iir); | |
| 3156 | + gen11_gu_misc_irq_handler(i915, gu_misc_iir); | |
| 3166 | 3157 | |
| 3167 | 3158 | return IRQ_HANDLED; |
| 3168 | 3159 | } |
| @@ -592,7 +592,6 @@ static const struct intel_device_info intel_cannonlake_info = { · 591 unmodified lines | ||
| 592 | 592 | GEN10_FEATURES, \ |
| 593 | 593 | GEN(11), \ |
| 594 | 594 | .ddb_size = 2048, \ |
| 595 | − .has_csr = 0, \ | |
| 596 | 595 | .has_logical_ring_elsq = 1 |
| 597 | 596 | |
| 598 | 597 | static const struct intel_device_info intel_icelake_11_info = { |
| @@ -976,7 +976,6 @@ · 975 unmodified lines | ||
| 976 | 976 | #define USB_DEVICE_ID_SIS817_TOUCH 0x0817 |
| 977 | 977 | #define USB_DEVICE_ID_SIS_TS 0x1013 |
| 978 | 978 | #define USB_DEVICE_ID_SIS1030_TOUCH 0x1030 |
| 979 | −#define USB_DEVICE_ID_SIS10FB_TOUCH 0x10fb | |
| 980 | 979 | |
| 981 | 980 | #define USB_VENDOR_ID_SKYCABLE 0x1223 |
| 982 | 981 | #define USB_DEVICE_ID_SKYCABLE_WIRELESS_PRESENTER 0x3F07 |
| @@ -47,7 +47,7 @@ · 46 unmodified lines | ||
| 47 | 47 | /* quirks to control the device */ |
| 48 | 48 | #define I2C_HID_QUIRK_SET_PWR_WAKEUP_DEV BIT(0) |
| 49 | 49 | #define I2C_HID_QUIRK_NO_IRQ_AFTER_RESET BIT(1) |
| 50 | −#define I2C_HID_QUIRK_RESEND_REPORT_DESCR BIT(2) | |
| 50 | +#define I2C_HID_QUIRK_NO_RUNTIME_PM BIT(2) | |
| 51 | 51 | |
| 52 | 52 | /* flags */ |
| 53 | 53 | #define I2C_HID_STARTED 0 |
| @@ -169,9 +169,8 @@ static const struct i2c_hid_quirks { · 115 unmodified lines | ||
| 169 | 169 | { USB_VENDOR_ID_WEIDA, USB_DEVICE_ID_WEIDA_8755, |
| 170 | 170 | I2C_HID_QUIRK_SET_PWR_WAKEUP_DEV }, |
| 171 | 171 | { I2C_VENDOR_ID_HANTICK, I2C_PRODUCT_ID_HANTICK_5288, |
| 172 | − I2C_HID_QUIRK_NO_IRQ_AFTER_RESET }, | |
| 173 | − { USB_VENDOR_ID_SIS_TOUCH, USB_DEVICE_ID_SIS10FB_TOUCH, | |
| 174 | − I2C_HID_QUIRK_RESEND_REPORT_DESCR }, | |
| 172 | + I2C_HID_QUIRK_NO_IRQ_AFTER_RESET | | |
| 173 | + I2C_HID_QUIRK_NO_RUNTIME_PM }, | |
| 175 | 174 | { 0, 0 } |
| 176 | 175 | }; |
| 177 | 176 | |
| @@ -1105,7 +1104,9 @@ static int i2c_hid_probe(struct i2c_client *client, · 927 unmodified lines | ||
| 1105 | 1104 | goto err_mem_free; |
| 1106 | 1105 | } |
| 1107 | 1106 | |
| 1108 | − pm_runtime_put(&client->dev); | |
| 1107 | + if (!(ihid->quirks & I2C_HID_QUIRK_NO_RUNTIME_PM)) | |
| 1108 | + pm_runtime_put(&client->dev); | |
| 1109 | + | |
| 1109 | 1110 | return 0; |
| 1110 | 1111 | |
| 1111 | 1112 | err_mem_free: |
| @@ -1130,7 +1131,8 @@ static int i2c_hid_remove(struct i2c_client *client) · 18 unmodified lines | ||
| 1130 | 1131 | struct i2c_hid *ihid = i2c_get_clientdata(client); |
| 1131 | 1132 | struct hid_device *hid; |
| 1132 | 1133 | |
| 1133 | − pm_runtime_get_sync(&client->dev); | |
| 1134 | + if (!(ihid->quirks & I2C_HID_QUIRK_NO_RUNTIME_PM)) | |
| 1135 | + pm_runtime_get_sync(&client->dev); | |
| 1134 | 1136 | pm_runtime_disable(&client->dev); |
| 1135 | 1137 | pm_runtime_set_suspended(&client->dev); |
| 1136 | 1138 | pm_runtime_put_noidle(&client->dev); |
| @@ -1236,22 +1238,13 @@ static int i2c_hid_resume(struct device *dev) · 99 unmodified lines | ||
| 1236 | 1238 | |
| 1237 | 1239 | /* Instead of resetting device, simply powers the device on. This |
| 1238 | 1240 | * solves "incomplete reports" on Raydium devices 2386:3118 and |
| 1239 | − * 2386:4B33 | |
| 1241 | + * 2386:4B33 and fixes various SIS touchscreens no longer sending | |
| 1242 | + * data after a suspend/resume. | |
| 1240 | 1243 | */ |
| 1241 | 1244 | ret = i2c_hid_set_power(client, I2C_HID_PWR_ON); |
| 1242 | 1245 | if (ret) |
| 1243 | 1246 | return ret; |
| 1244 | 1247 | |
| 1245 | − /* Some devices need to re-send report descr cmd | |
| 1246 | − * after resume, after this it will be back normal. | |
| 1247 | − * otherwise it issues too many incomplete reports. | |
| 1248 | − */ | |
| 1249 | − if (ihid->quirks & I2C_HID_QUIRK_RESEND_REPORT_DESCR) { | |
| 1250 | − ret = i2c_hid_command(client, &hid_report_descr_cmd, NULL, 0); | |
| 1251 | − if (ret) | |
| 1252 | − return ret; | |
| 1253 | − } | |
| 1254 | − | |
| 1255 | 1248 | if (hid->driver && hid->driver->reset_resume) { |
| 1256 | 1249 | ret = hid->driver->reset_resume(hid); |
| 1257 | 1250 | return ret; |
| @@ -29,6 +29,7 @@ · 28 unmodified lines | ||
| 29 | 29 | #define CNL_Ax_DEVICE_ID 0x9DFC |
| 30 | 30 | #define GLK_Ax_DEVICE_ID 0x31A2 |
| 31 | 31 | #define CNL_H_DEVICE_ID 0xA37C |
| 32 | +#define ICL_MOBILE_DEVICE_ID 0x34FC | |
| 32 | 33 | #define SPT_H_DEVICE_ID 0xA135 |
| 33 | 34 | |
| 34 | 35 | #define REVISION_ID_CHT_A0 0x6 |
| @@ -38,6 +38,7 @@ static const struct pci_device_id ish_pci_tbl[] = { · 37 unmodified lines | ||
| 38 | 38 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, CNL_Ax_DEVICE_ID)}, |
| 39 | 39 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, GLK_Ax_DEVICE_ID)}, |
| 40 | 40 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, CNL_H_DEVICE_ID)}, |
| 41 | + {PCI_DEVICE(PCI_VENDOR_ID_INTEL, ICL_MOBILE_DEVICE_ID)}, | |
| 41 | 42 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, SPT_H_DEVICE_ID)}, |
| 42 | 43 | {0, } |
| 43 | 44 | }; |
| @@ -76,6 +76,7 @@ static int vmbus_negotiate_version(struct vmbus_channel_msginfo *msginfo, · 75 unmodified lines | ||
| 76 | 76 | __u32 version) |
| 77 | 77 | { |
| 78 | 78 | int ret = 0; |
| 79 | + unsigned int cur_cpu; | |
| 79 | 80 | struct vmbus_channel_initiate_contact *msg; |
| 80 | 81 | unsigned long flags; |
| 81 | 82 | |
| @@ -118,9 +119,10 @@ static int vmbus_negotiate_version(struct vmbus_channel_msginfo *msginfo, · 36 unmodified lines | ||
| 118 | 119 | * the CPU attempting to connect may not be CPU 0. |
| 119 | 120 | */ |
| 120 | 121 | if (version >= VERSION_WIN8_1) { |
| 121 | − msg->target_vcpu = | |
| 122 | − hv_cpu_number_to_vp_number(smp_processor_id()); | |
| 123 | − vmbus_connection.connect_cpu = smp_processor_id(); | |
| 122 | + cur_cpu = get_cpu(); | |
| 123 | + msg->target_vcpu = hv_cpu_number_to_vp_number(cur_cpu); | |
| 124 | + vmbus_connection.connect_cpu = cur_cpu; | |
| 125 | + put_cpu(); | |
| 124 | 126 | } else { |
| 125 | 127 | msg->target_vcpu = 0; |
| 126 | 128 | vmbus_connection.connect_cpu = 0; |
| @@ -34,11 +34,11 @@ static void i2c_dw_configure_fifo_master(struct dw_i2c_dev *dev) · 33 unmodified lines | ||
| 34 | 34 | |
| 35 | 35 | static int i2c_dw_set_timings_master(struct dw_i2c_dev *dev) |
| 36 | 36 | { |
| 37 | − u32 ic_clk = i2c_dw_clk_rate(dev); | |
| 38 | 37 | const char *mode_str, *fp_str = ""; |
| 39 | 38 | u32 comp_param1; |
| 40 | 39 | u32 sda_falling_time, scl_falling_time; |
| 41 | 40 | struct i2c_timings *t = &dev->timings; |
| 41 | + u32 ic_clk; | |
| 42 | 42 | int ret; |
| 43 | 43 | |
| 44 | 44 | ret = i2c_dw_acquire_lock(dev); |
| @@ -53,6 +53,7 @@ static int i2c_dw_set_timings_master(struct dw_i2c_dev *dev) · 8 unmodified lines | ||
| 53 | 53 | |
| 54 | 54 | /* Calculate SCL timing parameters for standard mode if not set */ |
| 55 | 55 | if (!dev->ss_hcnt || !dev->ss_lcnt) { |
| 56 | + ic_clk = i2c_dw_clk_rate(dev); | |
| 56 | 57 | dev->ss_hcnt = |
| 57 | 58 | i2c_dw_scl_hcnt(ic_clk, |
| 58 | 59 | 4000, /* tHD;STA = tHIGH = 4.0 us */ |
| @@ -89,6 +90,7 @@ static int i2c_dw_set_timings_master(struct dw_i2c_dev *dev) · 30 unmodified lines | ||
| 89 | 90 | * needed also in high speed mode. |
| 90 | 91 | */ |
| 91 | 92 | if (!dev->fs_hcnt || !dev->fs_lcnt) { |
| 93 | + ic_clk = i2c_dw_clk_rate(dev); | |
| 92 | 94 | dev->fs_hcnt = |
| 93 | 95 | i2c_dw_scl_hcnt(ic_clk, |
| 94 | 96 | 600, /* tHD;STA = tHIGH = 0.6 us */ |
| @@ -164,7 +164,7 @@ static s32 sch_access(struct i2c_adapter *adap, u16 addr, · 163 unmodified lines | ||
| 164 | 164 | * run ~75 kHz instead which should do no harm. |
| 165 | 165 | */ |
| 166 | 166 | dev_notice(&sch_adapter.dev, |
| 167 | − "Clock divider unitialized. Setting defaults\n"); | |
| 167 | + "Clock divider uninitialized. Setting defaults\n"); | |
| 168 | 168 | outw(backbone_speed / (4 * 100), SMBHSTCLK); |
| 169 | 169 | } |
| 170 | 170 | |
| @@ -367,20 +367,26 @@ static int geni_i2c_rx_one_msg(struct geni_i2c_dev *gi2c, struct i2c_msg *msg, · 366 unmodified lines | ||
| 367 | 367 | dma_addr_t rx_dma; |
| 368 | 368 | enum geni_se_xfer_mode mode; |
| 369 | 369 | unsigned long time_left = XFER_TIMEOUT; |
| 370 | + void *dma_buf; | |
| 370 | 371 | |
| 371 | 372 | gi2c->cur = msg; |
| 372 | − mode = msg->len > 32 ? GENI_SE_DMA : GENI_SE_FIFO; | |
| 373 | + mode = GENI_SE_FIFO; | |
| 374 | + dma_buf = i2c_get_dma_safe_msg_buf(msg, 32); | |
| 375 | + if (dma_buf) | |
| 376 | + mode = GENI_SE_DMA; | |
| 377 | + | |
| 373 | 378 | geni_se_select_mode(&gi2c->se, mode); |
| 374 | 379 | writel_relaxed(msg->len, gi2c->se.base + SE_I2C_RX_TRANS_LEN); |
| 375 | 380 | geni_se_setup_m_cmd(&gi2c->se, I2C_READ, m_param); |
| 376 | 381 | if (mode == GENI_SE_DMA) { |
| 377 | 382 | int ret; |
| 378 | 383 | |
| 379 | − ret = geni_se_rx_dma_prep(&gi2c->se, msg->buf, msg->len, | |
| 384 | + ret = geni_se_rx_dma_prep(&gi2c->se, dma_buf, msg->len, | |
| 380 | 385 | &rx_dma); |
| 381 | 386 | if (ret) { |
| 382 | 387 | mode = GENI_SE_FIFO; |
| 383 | 388 | geni_se_select_mode(&gi2c->se, mode); |
| 389 | + i2c_put_dma_safe_msg_buf(dma_buf, msg, false); | |
| 384 | 390 | } |
| 385 | 391 | } |
| 386 | 392 | |
| @@ -393,6 +399,7 @@ static int geni_i2c_rx_one_msg(struct geni_i2c_dev *gi2c, struct i2c_msg *msg, · 6 unmodified lines | ||
| 393 | 399 | if (gi2c->err) |
| 394 | 400 | geni_i2c_rx_fsm_rst(gi2c); |
| 395 | 401 | geni_se_rx_dma_unprep(&gi2c->se, rx_dma, msg->len); |
| 402 | + i2c_put_dma_safe_msg_buf(dma_buf, msg, !gi2c->err); | |
| 396 | 403 | } |
| 397 | 404 | return gi2c->err; |
| 398 | 405 | } |
| @@ -403,20 +410,26 @@ static int geni_i2c_tx_one_msg(struct geni_i2c_dev *gi2c, struct i2c_msg *msg, · 4 unmodified lines | ||
| 403 | 410 | dma_addr_t tx_dma; |
| 404 | 411 | enum geni_se_xfer_mode mode; |
| 405 | 412 | unsigned long time_left; |
| 413 | + void *dma_buf; | |
| 406 | 414 | |
| 407 | 415 | gi2c->cur = msg; |
| 408 | − mode = msg->len > 32 ? GENI_SE_DMA : GENI_SE_FIFO; | |
| 416 | + mode = GENI_SE_FIFO; | |
| 417 | + dma_buf = i2c_get_dma_safe_msg_buf(msg, 32); | |
| 418 | + if (dma_buf) | |
| 419 | + mode = GENI_SE_DMA; | |
| 420 | + | |
| 409 | 421 | geni_se_select_mode(&gi2c->se, mode); |
| 410 | 422 | writel_relaxed(msg->len, gi2c->se.base + SE_I2C_TX_TRANS_LEN); |
| 411 | 423 | geni_se_setup_m_cmd(&gi2c->se, I2C_WRITE, m_param); |
| 412 | 424 | if (mode == GENI_SE_DMA) { |
| 413 | 425 | int ret; |
| 414 | 426 | |
| 415 | − ret = geni_se_tx_dma_prep(&gi2c->se, msg->buf, msg->len, | |
| 427 | + ret = geni_se_tx_dma_prep(&gi2c->se, dma_buf, msg->len, | |
| 416 | 428 | &tx_dma); |
| 417 | 429 | if (ret) { |
| 418 | 430 | mode = GENI_SE_FIFO; |
| 419 | 431 | geni_se_select_mode(&gi2c->se, mode); |
| 432 | + i2c_put_dma_safe_msg_buf(dma_buf, msg, false); | |
| 420 | 433 | } |
| 421 | 434 | } |
| 422 | 435 | |
| @@ -432,6 +445,7 @@ static int geni_i2c_tx_one_msg(struct geni_i2c_dev *gi2c, struct i2c_msg *msg, · 9 unmodified lines | ||
| 432 | 445 | if (gi2c->err) |
| 433 | 446 | geni_i2c_tx_fsm_rst(gi2c); |
| 434 | 447 | geni_se_tx_dma_unprep(&gi2c->se, tx_dma, msg->len); |
| 448 | + i2c_put_dma_safe_msg_buf(dma_buf, msg, !gi2c->err); | |
| 435 | 449 | } |
| 436 | 450 | return gi2c->err; |
| 437 | 451 | } |
| @@ -152,6 +152,7 @@ acpi_smbus_cmi_access(struct i2c_adapter *adap, u16 addr, unsigned short flags, · 151 unmodified lines | ||
| 152 | 152 | mt_params[3].type = ACPI_TYPE_INTEGER; |
| 153 | 153 | mt_params[3].integer.value = len; |
| 154 | 154 | mt_params[4].type = ACPI_TYPE_BUFFER; |
| 155 | + mt_params[4].buffer.length = len; | |
| 155 | 156 | mt_params[4].buffer.pointer = data->block + 1; |
| 156 | 157 | } |
| 157 | 158 | break; |
| @@ -3069,7 +3069,7 @@ static phys_addr_t amd_iommu_iova_to_phys(struct iommu_domain *dom, · 3068 unmodified lines | ||
| 3069 | 3069 | return 0; |
| 3070 | 3070 | |
| 3071 | 3071 | offset_mask = pte_pgsize - 1; |
| 3072 | − __pte = *pte & PM_ADDR_MASK; | |
| 3072 | + __pte = __sme_clr(*pte & PM_ADDR_MASK); | |
| 3073 | 3073 | |
| 3074 | 3074 | return (__pte & ~offset_mask) | (iova & offset_mask); |
| 3075 | 3075 | } |
| @@ -1455,8 +1455,8 @@ static int __load_mappings(struct dm_cache_metadata *cmd, · 1454 unmodified lines | ||
| 1455 | 1455 | if (hints_valid) { |
| 1456 | 1456 | r = dm_array_cursor_next(&cmd->hint_cursor); |
| 1457 | 1457 | if (r) { |
| 1458 | − DMERR("dm_array_cursor_next for hint failed"); | |
| 1459 | − goto out; | |
| 1458 | + dm_array_cursor_end(&cmd->hint_cursor); | |
| 1459 | + hints_valid = false; | |
| 1460 | 1460 | } |
| 1461 | 1461 | } |
| 1462 | 1462 | |
| @@ -3009,8 +3009,13 @@ static dm_cblock_t get_cache_dev_size(struct cache *cache) · 3008 unmodified lines | ||
| 3009 | 3009 | |
| 3010 | 3010 | static bool can_resize(struct cache *cache, dm_cblock_t new_size) |
| 3011 | 3011 | { |
| 3012 | − if (from_cblock(new_size) > from_cblock(cache->cache_size)) | |
| 3013 | − return true; | |
| 3012 | + if (from_cblock(new_size) > from_cblock(cache->cache_size)) { | |
| 3013 | + if (cache->sized) { | |
| 3014 | + DMERR("%s: unable to extend cache due to missing cache table reload", | |
| 3015 | + cache_device_name(cache)); | |
| 3016 | + return false; | |
| 3017 | + } | |
| 3018 | + } | |
| 3014 | 3019 | |
| 3015 | 3020 | /* |
| 3016 | 3021 | * We can't drop a dirty block when shrinking the cache. |
| @@ -806,19 +806,19 @@ static int parse_path_selector(struct dm_arg_set *as, struct priority_group *pg, · 805 unmodified lines | ||
| 806 | 806 | } |
| 807 | 807 | |
| 808 | 808 | static int setup_scsi_dh(struct block_device *bdev, struct multipath *m, |
| 809 | − const char *attached_handler_name, char **error) | |
| 809 | + const char **attached_handler_name, char **error) | |
| 810 | 810 | { |
| 811 | 811 | struct request_queue *q = bdev_get_queue(bdev); |
| 812 | 812 | int r; |
| 813 | 813 | |
| 814 | 814 | if (test_bit(MPATHF_RETAIN_ATTACHED_HW_HANDLER, &m->flags)) { |
| 815 | 815 | retain: |
| 816 | − if (attached_handler_name) { | |
| 816 | + if (*attached_handler_name) { | |
| 817 | 817 | /* |
| 818 | 818 | * Clear any hw_handler_params associated with a |
| 819 | 819 | * handler that isn't already attached. |
| 820 | 820 | */ |
| 821 | − if (m->hw_handler_name && strcmp(attached_handler_name, m->hw_handler_name)) { | |
| 821 | + if (m->hw_handler_name && strcmp(*attached_handler_name, m->hw_handler_name)) { | |
| 822 | 822 | kfree(m->hw_handler_params); |
| 823 | 823 | m->hw_handler_params = NULL; |
| 824 | 824 | } |
| @@ -830,7 +830,8 @@ retain: · 5 unmodified lines | ||
| 830 | 830 | * handler instead of the original table passed in. |
| 831 | 831 | */ |
| 832 | 832 | kfree(m->hw_handler_name); |
| 833 | − m->hw_handler_name = attached_handler_name; | |
| 833 | + m->hw_handler_name = *attached_handler_name; | |
| 834 | + *attached_handler_name = NULL; | |
| 834 | 835 | } |
| 835 | 836 | } |
| 836 | 837 | |
| @@ -867,7 +868,7 @@ static struct pgpath *parse_path(struct dm_arg_set *as, struct path_selector *ps · 30 unmodified lines | ||
| 867 | 868 | struct pgpath *p; |
| 868 | 869 | struct multipath *m = ti->private; |
| 869 | 870 | struct request_queue *q; |
| 870 | − const char *attached_handler_name; | |
| 871 | + const char *attached_handler_name = NULL; | |
| 871 | 872 | |
| 872 | 873 | /* we need at least a path arg */ |
| 873 | 874 | if (as->argc < 1) { |
| @@ -890,7 +891,7 @@ static struct pgpath *parse_path(struct dm_arg_set *as, struct path_selector *ps · 16 unmodified lines | ||
| 890 | 891 | attached_handler_name = scsi_dh_attached_handler_name(q, GFP_KERNEL); |
| 891 | 892 | if (attached_handler_name || m->hw_handler_name) { |
| 892 | 893 | INIT_DELAYED_WORK(&p->activate_path, activate_path_work); |
| 893 | − r = setup_scsi_dh(p->path.dev->bdev, m, attached_handler_name, &ti->error); | |
| 894 | + r = setup_scsi_dh(p->path.dev->bdev, m, &attached_handler_name, &ti->error); | |
| 894 | 895 | if (r) { |
| 895 | 896 | dm_put_device(ti, p->path.dev); |
| 896 | 897 | goto bad; |
| @@ -905,6 +906,7 @@ static struct pgpath *parse_path(struct dm_arg_set *as, struct path_selector *ps · 8 unmodified lines | ||
| 905 | 906 | |
| 906 | 907 | return p; |
| 907 | 908 | bad: |
| 909 | + kfree(attached_handler_name); | |
| 908 | 910 | free_pgpath(p); |
| 909 | 911 | return ERR_PTR(r); |
| 910 | 912 | } |
| @@ -3353,7 +3353,7 @@ static const char *sync_str(enum sync_state state) · 3352 unmodified lines | ||
| 3353 | 3353 | }; |
| 3354 | 3354 | |
| 3355 | 3355 | /* Return enum sync_state for @mddev derived from @recovery flags */ |
| 3356 | −static const enum sync_state decipher_sync_action(struct mddev *mddev, unsigned long recovery) | |
| 3356 | +static enum sync_state decipher_sync_action(struct mddev *mddev, unsigned long recovery) | |
| 3357 | 3357 | { |
| 3358 | 3358 | if (test_bit(MD_RECOVERY_FROZEN, &recovery)) |
| 3359 | 3359 | return st_frozen; |
| @@ -832,10 +832,8 @@ static void __set_metadata_reserve(struct dm_pool_metadata *pmd) · 831 unmodified lines | ||
| 832 | 832 | if (r) { |
| 833 | 833 | DMERR("could not get size of metadata device"); |
| 834 | 834 | pmd->metadata_reserve = max_blocks; |
| 835 | − } else { | |
| 836 | − sector_div(total, 10); | |
| 837 | − pmd->metadata_reserve = min(max_blocks, total); | |
| 838 | − } | |
| 835 | + } else | |
| 836 | + pmd->metadata_reserve = min(max_blocks, div_u64(total, 10)); | |
| 839 | 837 | } |
| 840 | 838 | |
| 841 | 839 | struct dm_pool_metadata *dm_pool_metadata_open(struct block_device *bdev, |
| @@ -115,14 +115,6 @@ static void __v4l2_event_queue_fh(struct v4l2_fh *fh, const struct v4l2_event *e · 114 unmodified lines | ||
| 115 | 115 | if (sev == NULL) |
| 116 | 116 | return; |
| 117 | 117 | |
| 118 | − /* | |
| 119 | − * If the event has been added to the fh->subscribed list, but its | |
| 120 | − * add op has not completed yet elems will be 0, treat this as | |
| 121 | − * not being subscribed. | |
| 122 | − */ | |
| 123 | − if (!sev->elems) | |
| 124 | − return; | |
| 125 | − | |
| 126 | 118 | /* Increase event sequence number on fh. */ |
| 127 | 119 | fh->sequence++; |
| 128 | 120 | |
| @@ -208,6 +200,7 @@ int v4l2_event_subscribe(struct v4l2_fh *fh, · 79 unmodified lines | ||
| 208 | 200 | struct v4l2_subscribed_event *sev, *found_ev; |
| 209 | 201 | unsigned long flags; |
| 210 | 202 | unsigned i; |
| 203 | + int ret = 0; | |
| 211 | 204 | |
| 212 | 205 | if (sub->type == V4L2_EVENT_ALL) |
| 213 | 206 | return -EINVAL; |
| @@ -225,31 +218,36 @@ int v4l2_event_subscribe(struct v4l2_fh *fh, · 11 unmodified lines | ||
| 225 | 218 | sev->flags = sub->flags; |
| 226 | 219 | sev->fh = fh; |
| 227 | 220 | sev->ops = ops; |
| 221 | + sev->elems = elems; | |
| 222 | + | |
| 223 | + mutex_lock(&fh->subscribe_lock); | |
| 228 | 224 | |
| 229 | 225 | spin_lock_irqsave(&fh->vdev->fh_lock, flags); |
| 230 | 226 | found_ev = v4l2_event_subscribed(fh, sub->type, sub->id); |
| 231 | − if (!found_ev) | |
| 232 | − list_add(&sev->list, &fh->subscribed); | |
| 233 | 227 | spin_unlock_irqrestore(&fh->vdev->fh_lock, flags); |
| 234 | 228 | |
| 235 | 229 | if (found_ev) { |
| 230 | + /* Already listening */ | |
| 236 | 231 | kvfree(sev); |
| 237 | − return 0; /* Already listening */ | |
| 232 | + goto out_unlock; | |
| 238 | 233 | } |
| 239 | 234 | |
| 240 | 235 | if (sev->ops && sev->ops->add) { |
| 241 | − int ret = sev->ops->add(sev, elems); | |
| 236 | + ret = sev->ops->add(sev, elems); | |
| 242 | 237 | if (ret) { |
| 243 | − sev->ops = NULL; | |
| 244 | − v4l2_event_unsubscribe(fh, sub); | |
| 245 | − return ret; | |
| 238 | + kvfree(sev); | |
| 239 | + goto out_unlock; | |
| 246 | 240 | } |
| 247 | 241 | } |
| 248 | 242 | |
| 249 | − /* Mark as ready for use */ | |
| 250 | − sev->elems = elems; | |
| 243 | + spin_lock_irqsave(&fh->vdev->fh_lock, flags); | |
| 244 | + list_add(&sev->list, &fh->subscribed); | |
| 245 | + spin_unlock_irqrestore(&fh->vdev->fh_lock, flags); | |
| 251 | 246 | |
| 252 | − return 0; | |
| 247 | +out_unlock: | |
| 248 | + mutex_unlock(&fh->subscribe_lock); | |
| 249 | + | |
| 250 | + return ret; | |
| 253 | 251 | } |
| 254 | 252 | EXPORT_SYMBOL_GPL(v4l2_event_subscribe); |
| 255 | 253 | |
| @@ -288,6 +286,8 @@ int v4l2_event_unsubscribe(struct v4l2_fh *fh, · 32 unmodified lines | ||
| 288 | 286 | return 0; |
| 289 | 287 | } |
| 290 | 288 | |
| 289 | + mutex_lock(&fh->subscribe_lock); | |
| 290 | + | |
| 291 | 291 | spin_lock_irqsave(&fh->vdev->fh_lock, flags); |
| 292 | 292 | |
| 293 | 293 | sev = v4l2_event_subscribed(fh, sub->type, sub->id); |
| @@ -305,6 +305,8 @@ int v4l2_event_unsubscribe(struct v4l2_fh *fh, · 11 unmodified lines | ||
| 305 | 305 | if (sev && sev->ops && sev->ops->del) |
| 306 | 306 | sev->ops->del(sev); |
| 307 | 307 | |
| 308 | + mutex_unlock(&fh->subscribe_lock); | |
| 309 | + | |
| 308 | 310 | kvfree(sev); |
| 309 | 311 | |
| 310 | 312 | return 0; |
| @@ -45,6 +45,7 @@ void v4l2_fh_init(struct v4l2_fh *fh, struct video_device *vdev) · 44 unmodified lines | ||
| 45 | 45 | INIT_LIST_HEAD(&fh->available); |
| 46 | 46 | INIT_LIST_HEAD(&fh->subscribed); |
| 47 | 47 | fh->sequence = -1; |
| 48 | + mutex_init(&fh->subscribe_lock); | |
| 48 | 49 | } |
| 49 | 50 | EXPORT_SYMBOL_GPL(v4l2_fh_init); |
| 50 | 51 | |
| @@ -90,6 +91,7 @@ void v4l2_fh_exit(struct v4l2_fh *fh) · 39 unmodified lines | ||
| 90 | 91 | return; |
| 91 | 92 | v4l_disable_media_source(fh->vdev); |
| 92 | 93 | v4l2_event_unsubscribe_all(fh); |
| 94 | + mutex_destroy(&fh->subscribe_lock); | |
| 93 | 95 | fh->vdev = NULL; |
| 94 | 96 | } |
| 95 | 97 | EXPORT_SYMBOL_GPL(v4l2_fh_exit); |
| @@ -235,7 +235,7 @@ int mmc_of_parse(struct mmc_host *host) · 234 unmodified lines | ||
| 235 | 235 | host->caps |= MMC_CAP_NEEDS_POLL; |
| 236 | 236 | |
| 237 | 237 | ret = mmc_gpiod_request_cd(host, "cd", 0, true, |
| 238 | − cd_debounce_delay_ms, | |
| 238 | + cd_debounce_delay_ms * 1000, | |
| 239 | 239 | &cd_gpio_invert); |
| 240 | 240 | if (!ret) |
| 241 | 241 | dev_info(host->parent, "Got CD GPIO\n"); |
| @@ -271,7 +271,7 @@ int mmc_gpiod_request_cd(struct mmc_host *host, const char *con_id, · 270 unmodified lines | ||
| 271 | 271 | if (debounce) { |
| 272 | 272 | ret = gpiod_set_debounce(desc, debounce); |
| 273 | 273 | if (ret < 0) |
| 274 | − ctx->cd_debounce_delay_ms = debounce; | |
| 274 | + ctx->cd_debounce_delay_ms = debounce / 1000; | |
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | if (gpio_invert) |
| @@ -498,7 +498,8 @@ static const struct soc_device_attribute gen3_soc_whitelist[] = { · 497 unmodified lines | ||
| 498 | 498 | |
| 499 | 499 | static int renesas_sdhi_sys_dmac_probe(struct platform_device *pdev) |
| 500 | 500 | { |
| 501 | − if (of_device_get_match_data(&pdev->dev) == &of_rcar_gen3_compatible && | |
| 501 | + if ((of_device_get_match_data(&pdev->dev) == &of_rcar_gen3_compatible || | |
| 502 | + of_device_get_match_data(&pdev->dev) == &of_rcar_r8a7795_compatible) && | |
| 502 | 503 | !soc_device_match(gen3_soc_whitelist)) |
| 503 | 504 | return -ENODEV; |
| 504 | 505 | |
| @@ -210,6 +210,7 @@ static void bond_get_stats(struct net_device *bond_dev, · 209 unmodified lines | ||
| 210 | 210 | static void bond_slave_arr_handler(struct work_struct *work); |
| 211 | 211 | static bool bond_time_in_interval(struct bonding *bond, unsigned long last_act, |
| 212 | 212 | int mod); |
| 213 | +static void bond_netdev_notify_work(struct work_struct *work); | |
| 213 | 214 | |
| 214 | 215 | /*---------------------------- General routines -----------------------------*/ |
| 215 | 216 | |
| @@ -1170,9 +1171,27 @@ static rx_handler_result_t bond_handle_frame(struct sk_buff **pskb) · 954 unmodified lines | ||
| 1170 | 1171 | } |
| 1171 | 1172 | } |
| 1172 | 1173 | |
| 1173 | − /* don't change skb->dev for link-local packets */ | |
| 1174 | − if (is_link_local_ether_addr(eth_hdr(skb)->h_dest)) | |
| 1174 | + /* Link-local multicast packets should be passed to the | |
| 1175 | + * stack on the link they arrive as well as pass them to the | |
| 1176 | + * bond-master device. These packets are mostly usable when | |
| 1177 | + * stack receives it with the link on which they arrive | |
| 1178 | + * (e.g. LLDP) they also must be available on master. Some of | |
| 1179 | + * the use cases include (but are not limited to): LLDP agents | |
| 1180 | + * that must be able to operate both on enslaved interfaces as | |
| 1181 | + * well as on bonds themselves; linux bridges that must be able | |
| 1182 | + * to process/pass BPDUs from attached bonds when any kind of | |
| 1183 | + * STP version is enabled on the network. | |
| 1184 | + */ | |
| 1185 | + if (is_link_local_ether_addr(eth_hdr(skb)->h_dest)) { | |
| 1186 | + struct sk_buff *nskb = skb_clone(skb, GFP_ATOMIC); | |
| 1187 | + | |
| 1188 | + if (nskb) { | |
| 1189 | + nskb->dev = bond->dev; | |
| 1190 | + nskb->queue_mapping = 0; | |
| 1191 | + netif_rx(nskb); | |
| 1192 | + } | |
| 1175 | 1193 | return RX_HANDLER_PASS; |
| 1194 | + } | |
| 1176 | 1195 | if (bond_should_deliver_exact_match(skb, slave, bond)) |
| 1177 | 1196 | return RX_HANDLER_EXACT; |
| 1178 | 1197 | |
| @@ -1269,6 +1288,8 @@ static struct slave *bond_alloc_slave(struct bonding *bond) · 90 unmodified lines | ||
| 1269 | 1288 | return NULL; |
| 1270 | 1289 | } |
| 1271 | 1290 | } |
| 1291 | + INIT_DELAYED_WORK(&slave->notify_work, bond_netdev_notify_work); | |
| 1292 | + | |
| 1272 | 1293 | return slave; |
| 1273 | 1294 | } |
| 1274 | 1295 | |
| @@ -1276,6 +1297,7 @@ static void bond_free_slave(struct slave *slave) · 1 unmodified line | ||
| 1276 | 1297 | { |
| 1277 | 1298 | struct bonding *bond = bond_get_bond_by_slave(slave); |
| 1278 | 1299 | |
| 1300 | + cancel_delayed_work_sync(&slave->notify_work); | |
| 1279 | 1301 | if (BOND_MODE(bond) == BOND_MODE_8023AD) |
| 1280 | 1302 | kfree(SLAVE_AD_INFO(slave)); |
| 1281 | 1303 | |
| @@ -1297,39 +1319,26 @@ static void bond_fill_ifslave(struct slave *slave, struct ifslave *info) · 15 unmodified lines | ||
| 1297 | 1319 | info->link_failure_count = slave->link_failure_count; |
| 1298 | 1320 | } |
| 1299 | 1321 | |
| 1300 | −static void bond_netdev_notify(struct net_device *dev, | |
| 1301 | − struct netdev_bonding_info *info) | |
| 1302 | −{ | |
| 1303 | − rtnl_lock(); | |
| 1304 | − netdev_bonding_info_change(dev, info); | |
| 1305 | − rtnl_unlock(); | |
| 1306 | −} | |
| 1307 | − | |
| 1308 | 1322 | static void bond_netdev_notify_work(struct work_struct *_work) |
| 1309 | 1323 | { |
| 1310 | − struct netdev_notify_work *w = | |
| 1311 | − container_of(_work, struct netdev_notify_work, work.work); | |
| 1324 | + struct slave *slave = container_of(_work, struct slave, | |
| 1325 | + notify_work.work); | |
| 1326 | + | |
| 1327 | + if (rtnl_trylock()) { | |
| 1328 | + struct netdev_bonding_info binfo; | |
| 1312 | 1329 | |
| 1313 | − bond_netdev_notify(w->dev, &w->bonding_info); | |
| 1314 | − dev_put(w->dev); | |
| 1315 | − kfree(w); | |
| 1330 | + bond_fill_ifslave(slave, &binfo.slave); | |
| 1331 | + bond_fill_ifbond(slave->bond, &binfo.master); | |
| 1332 | + netdev_bonding_info_change(slave->dev, &binfo); | |
| 1333 | + rtnl_unlock(); | |
| 1334 | + } else { | |
| 1335 | + queue_delayed_work(slave->bond->wq, &slave->notify_work, 1); | |
| 1336 | + } | |
| 1316 | 1337 | } |
| 1317 | 1338 | |
| 1318 | 1339 | void bond_queue_slave_event(struct slave *slave) |
| 1319 | 1340 | { |
| 1320 | − struct bonding *bond = slave->bond; | |
| 1321 | − struct netdev_notify_work *nnw = kzalloc(sizeof(*nnw), GFP_ATOMIC); | |
| 1322 | − | |
| 1323 | − if (!nnw) | |
| 1324 | − return; | |
| 1325 | − | |
| 1326 | − dev_hold(slave->dev); | |
| 1327 | − nnw->dev = slave->dev; | |
| 1328 | − bond_fill_ifslave(slave, &nnw->bonding_info.slave); | |
| 1329 | − bond_fill_ifbond(bond, &nnw->bonding_info.master); | |
| 1330 | − INIT_DELAYED_WORK(&nnw->work, bond_netdev_notify_work); | |
| 1331 | − | |
| 1332 | − queue_delayed_work(slave->bond->wq, &nnw->work, 0); | |
| 1341 | + queue_delayed_work(slave->bond->wq, &slave->notify_work, 0); | |
| 1333 | 1342 | } |
| 1334 | 1343 | |
| 1335 | 1344 | void bond_lower_state_changed(struct slave *slave) |
| @@ -1107,7 +1107,7 @@ void b53_vlan_add(struct dsa_switch *ds, int port, · 1106 unmodified lines | ||
| 1107 | 1107 | b53_get_vlan_entry(dev, vid, vl); |
| 1108 | 1108 | |
| 1109 | 1109 | vl->members |= BIT(port); |
| 1110 | − if (untagged) | |
| 1110 | + if (untagged && !dsa_is_cpu_port(ds, port)) | |
| 1111 | 1111 | vl->untag |= BIT(port); |
| 1112 | 1112 | else |
| 1113 | 1113 | vl->untag &= ~BIT(port); |
| @@ -1149,7 +1149,7 @@ int b53_vlan_del(struct dsa_switch *ds, int port, · 35 unmodified lines | ||
| 1149 | 1149 | pvid = 0; |
| 1150 | 1150 | } |
| 1151 | 1151 | |
| 1152 | − if (untagged) | |
| 1152 | + if (untagged && !dsa_is_cpu_port(ds, port)) | |
| 1153 | 1153 | vl->untag &= ~(BIT(port)); |
| 1154 | 1154 | |
| 1155 | 1155 | b53_set_vlan_entry(dev, vid, vl); |
| @@ -2185,25 +2185,6 @@ error_drop_packet: · 2184 unmodified lines | ||
| 2185 | 2185 | return NETDEV_TX_OK; |
| 2186 | 2186 | } |
| 2187 | 2187 | |
| 2188 | −#ifdef CONFIG_NET_POLL_CONTROLLER | |
| 2189 | −static void ena_netpoll(struct net_device *netdev) | |
| 2190 | −{ | |
| 2191 | − struct ena_adapter *adapter = netdev_priv(netdev); | |
| 2192 | − int i; | |
| 2193 | − | |
| 2194 | − /* Dont schedule NAPI if the driver is in the middle of reset | |
| 2195 | − * or netdev is down. | |
| 2196 | − */ | |
| 2197 | − | |
| 2198 | − if (!test_bit(ENA_FLAG_DEV_UP, &adapter->flags) || | |
| 2199 | − test_bit(ENA_FLAG_TRIGGER_RESET, &adapter->flags)) | |
| 2200 | − return; | |
| 2201 | − | |
| 2202 | − for (i = 0; i < adapter->num_queues; i++) | |
| 2203 | − napi_schedule(&adapter->ena_napi[i].napi); | |
| 2204 | −} | |
| 2205 | −#endif /* CONFIG_NET_POLL_CONTROLLER */ | |
| 2206 | − | |
| 2207 | 2188 | static u16 ena_select_queue(struct net_device *dev, struct sk_buff *skb, |
| 2208 | 2189 | struct net_device *sb_dev, |
| 2209 | 2190 | select_queue_fallback_t fallback) |
| @@ -2369,9 +2350,6 @@ static const struct net_device_ops ena_netdev_ops = { · 159 unmodified lines | ||
| 2369 | 2350 | .ndo_change_mtu = ena_change_mtu, |
| 2370 | 2351 | .ndo_set_mac_address = NULL, |
| 2371 | 2352 | .ndo_validate_addr = eth_validate_addr, |
| 2372 | −#ifdef CONFIG_NET_POLL_CONTROLLER | |
| 2373 | − .ndo_poll_controller = ena_netpoll, | |
| 2374 | −#endif /* CONFIG_NET_POLL_CONTROLLER */ | |
| 2375 | 2353 | }; |
| 2376 | 2354 | |
| 2377 | 2355 | static int ena_device_validate_params(struct ena_adapter *adapter, |
| @@ -1031,6 +1031,7 @@ static int dec_lance_probe(struct device *bdev, const int type) · 1030 unmodified lines | ||
| 1031 | 1031 | int i, ret; |
| 1032 | 1032 | unsigned long esar_base; |
| 1033 | 1033 | unsigned char *esar; |
| 1034 | + const char *desc; | |
| 1034 | 1035 | |
| 1035 | 1036 | if (dec_lance_debug && version_printed++ == 0) |
| 1036 | 1037 | printk(version); |
| @@ -1216,19 +1217,20 @@ static int dec_lance_probe(struct device *bdev, const int type) · 179 unmodified lines | ||
| 1216 | 1217 | */ |
| 1217 | 1218 | switch (type) { |
| 1218 | 1219 | case ASIC_LANCE: |
| 1219 | − printk("%s: IOASIC onboard LANCE", name); | |
| 1220 | + desc = "IOASIC onboard LANCE"; | |
| 1220 | 1221 | break; |
| 1221 | 1222 | case PMAD_LANCE: |
| 1222 | − printk("%s: PMAD-AA", name); | |
| 1223 | + desc = "PMAD-AA"; | |
| 1223 | 1224 | break; |
| 1224 | 1225 | case PMAX_LANCE: |
| 1225 | − printk("%s: PMAX onboard LANCE", name); | |
| 1226 | + desc = "PMAX onboard LANCE"; | |
| 1226 | 1227 | break; |
| 1227 | 1228 | } |
| 1228 | 1229 | for (i = 0; i < 6; i++) |
| 1229 | 1230 | dev->dev_addr[i] = esar[i * 4]; |
| 1230 | 1231 | |
| 1231 | − printk(", addr = %pM, irq = %d\n", dev->dev_addr, dev->irq); | |
| 1232 | + printk("%s: %s, addr = %pM, irq = %d\n", | |
| 1233 | + name, desc, dev->dev_addr, dev->irq); | |
| 1232 | 1234 | |
| 1233 | 1235 | dev->netdev_ops = &lance_netdev_ops; |
| 1234 | 1236 | dev->watchdog_timeo = 5*HZ; |
| @@ -1069,9 +1069,6 @@ static void bcm_sysport_resume_from_wol(struct bcm_sysport_priv *priv) · 1068 unmodified lines | ||
| 1069 | 1069 | { |
| 1070 | 1070 | u32 reg; |
| 1071 | 1071 | |
| 1072 | − /* Stop monitoring MPD interrupt */ | |
| 1073 | − intrl2_0_mask_set(priv, INTRL2_0_MPD | INTRL2_0_BRCM_MATCH_TAG); | |
| 1074 | − | |
| 1075 | 1072 | /* Disable RXCHK, active filters and Broadcom tag matching */ |
| 1076 | 1073 | reg = rxchk_readl(priv, RXCHK_CONTROL); |
| 1077 | 1074 | reg &= ~(RXCHK_BRCM_TAG_MATCH_MASK << |
| @@ -1081,6 +1078,17 @@ static void bcm_sysport_resume_from_wol(struct bcm_sysport_priv *priv) · 3 unmodified lines | ||
| 1081 | 1078 | /* Clear the MagicPacket detection logic */ |
| 1082 | 1079 | mpd_enable_set(priv, false); |
| 1083 | 1080 | |
| 1081 | + reg = intrl2_0_readl(priv, INTRL2_CPU_STATUS); | |
| 1082 | + if (reg & INTRL2_0_MPD) | |
| 1083 | + netdev_info(priv->netdev, "Wake-on-LAN (MPD) interrupt!\n"); | |
| 1084 | + | |
| 1085 | + if (reg & INTRL2_0_BRCM_MATCH_TAG) { | |
| 1086 | + reg = rxchk_readl(priv, RXCHK_BRCM_TAG_MATCH_STATUS) & | |
| 1087 | + RXCHK_BRCM_TAG_MATCH_MASK; | |
| 1088 | + netdev_info(priv->netdev, | |
| 1089 | + "Wake-on-LAN (filters 0x%02x) interrupt!\n", reg); | |
| 1090 | + } | |
| 1091 | + | |
| 1084 | 1092 | netif_dbg(priv, wol, priv->netdev, "resumed from WOL\n"); |
| 1085 | 1093 | } |
| 1086 | 1094 | |
| @@ -1105,7 +1113,6 @@ static irqreturn_t bcm_sysport_rx_isr(int irq, void *dev_id) · 18 unmodified lines | ||
| 1105 | 1113 | struct bcm_sysport_priv *priv = netdev_priv(dev); |
| 1106 | 1114 | struct bcm_sysport_tx_ring *txr; |
| 1107 | 1115 | unsigned int ring, ring_bit; |
| 1108 | − u32 reg; | |
| 1109 | 1116 | |
| 1110 | 1117 | priv->irq0_stat = intrl2_0_readl(priv, INTRL2_CPU_STATUS) & |
| 1111 | 1118 | ~intrl2_0_readl(priv, INTRL2_CPU_MASK_STATUS); |
| @@ -1131,16 +1138,6 @@ static irqreturn_t bcm_sysport_rx_isr(int irq, void *dev_id) · 19 unmodified lines | ||
| 1131 | 1138 | if (priv->irq0_stat & INTRL2_0_TX_RING_FULL) |
| 1132 | 1139 | bcm_sysport_tx_reclaim_all(priv); |
| 1133 | 1140 | |
| 1134 | − if (priv->irq0_stat & INTRL2_0_MPD) | |
| 1135 | − netdev_info(priv->netdev, "Wake-on-LAN (MPD) interrupt!\n"); | |
| 1136 | − | |
| 1137 | − if (priv->irq0_stat & INTRL2_0_BRCM_MATCH_TAG) { | |
| 1138 | − reg = rxchk_readl(priv, RXCHK_BRCM_TAG_MATCH_STATUS) & | |
| 1139 | − RXCHK_BRCM_TAG_MATCH_MASK; | |
| 1140 | − netdev_info(priv->netdev, | |
| 1141 | − "Wake-on-LAN (filters 0x%02x) interrupt!\n", reg); | |
| 1142 | − } | |
| 1143 | − | |
| 1144 | 1141 | if (!priv->is_lite) |
| 1145 | 1142 | goto out; |
| 1146 | 1143 | |
| @@ -2641,9 +2638,6 @@ static int bcm_sysport_suspend_to_wol(struct bcm_sysport_priv *priv) · 1494 unmodified lines | ||
| 2641 | 2638 | /* UniMAC receive needs to be turned on */ |
| 2642 | 2639 | umac_enable_set(priv, CMD_RX_EN, 1); |
| 2643 | 2640 | |
| 2644 | − /* Enable the interrupt wake-up source */ | |
| 2645 | − intrl2_0_mask_clear(priv, INTRL2_0_MPD | INTRL2_0_BRCM_MATCH_TAG); | |
| 2646 | − | |
| 2647 | 2641 | netif_dbg(priv, wol, ndev, "entered WOL mode\n"); |
| 2648 | 2642 | |
| 2649 | 2643 | return 0; |
| @@ -1884,8 +1884,11 @@ static int bnxt_poll_work(struct bnxt *bp, struct bnxt_napi *bnapi, int budget) · 1883 unmodified lines | ||
| 1884 | 1884 | if (TX_CMP_TYPE(txcmp) == CMP_TYPE_TX_L2_CMP) { |
| 1885 | 1885 | tx_pkts++; |
| 1886 | 1886 | /* return full budget so NAPI will complete. */ |
| 1887 | − if (unlikely(tx_pkts > bp->tx_wake_thresh)) | |
| 1887 | + if (unlikely(tx_pkts > bp->tx_wake_thresh)) { | |
| 1888 | 1888 | rx_pkts = budget; |
| 1889 | + raw_cons = NEXT_RAW_CMP(raw_cons); | |
| 1890 | + break; | |
| 1891 | + } | |
| 1889 | 1892 | } else if ((TX_CMP_TYPE(txcmp) & 0x30) == 0x10) { |
| 1890 | 1893 | if (likely(budget)) |
| 1891 | 1894 | rc = bnxt_rx_pkt(bp, bnapi, &raw_cons, &event); |
| @@ -1913,7 +1916,7 @@ static int bnxt_poll_work(struct bnxt *bp, struct bnxt_napi *bnapi, int budget) · 21 unmodified lines | ||
| 1913 | 1916 | } |
| 1914 | 1917 | raw_cons = NEXT_RAW_CMP(raw_cons); |
| 1915 | 1918 | |
| 1916 | − if (rx_pkts == budget) | |
| 1919 | + if (rx_pkts && rx_pkts == budget) | |
| 1917 | 1920 | break; |
| 1918 | 1921 | } |
| 1919 | 1922 | |
| @@ -2027,8 +2030,12 @@ static int bnxt_poll(struct napi_struct *napi, int budget) · 107 unmodified lines | ||
| 2027 | 2030 | while (1) { |
| 2028 | 2031 | work_done += bnxt_poll_work(bp, bnapi, budget - work_done); |
| 2029 | 2032 | |
| 2030 | − if (work_done >= budget) | |
| 2033 | + if (work_done >= budget) { | |
| 2034 | + if (!budget) | |
| 2035 | + BNXT_CP_DB_REARM(cpr->cp_doorbell, | |
| 2036 | + cpr->cp_raw_cons); | |
| 2031 | 2037 | break; |
| 2038 | + } | |
| 2032 | 2039 | |
| 2033 | 2040 | if (!bnxt_has_work(bp, cpr)) { |
| 2034 | 2041 | if (napi_complete_done(napi, work_done)) |
| @@ -3010,10 +3017,11 @@ static void bnxt_free_hwrm_resources(struct bnxt *bp) · 975 unmodified lines | ||
| 3010 | 3017 | { |
| 3011 | 3018 | struct pci_dev *pdev = bp->pdev; |
| 3012 | 3019 | |
| 3013 | − dma_free_coherent(&pdev->dev, PAGE_SIZE, bp->hwrm_cmd_resp_addr, | |
| 3014 | − bp->hwrm_cmd_resp_dma_addr); | |
| 3015 | − | |
| 3016 | − bp->hwrm_cmd_resp_addr = NULL; | |
| 3020 | + if (bp->hwrm_cmd_resp_addr) { | |
| 3021 | + dma_free_coherent(&pdev->dev, PAGE_SIZE, bp->hwrm_cmd_resp_addr, | |
| 3022 | + bp->hwrm_cmd_resp_dma_addr); | |
| 3023 | + bp->hwrm_cmd_resp_addr = NULL; | |
| 3024 | + } | |
| 3017 | 3025 | } |
| 3018 | 3026 | |
| 3019 | 3027 | static int bnxt_alloc_hwrm_resources(struct bnxt *bp) |
| @@ -4643,7 +4651,7 @@ __bnxt_hwrm_reserve_pf_rings(struct bnxt *bp, struct hwrm_func_cfg_input *req, · 1623 unmodified lines | ||
| 4643 | 4651 | FUNC_CFG_REQ_ENABLES_NUM_STAT_CTXS : 0; |
| 4644 | 4652 | enables |= ring_grps ? |
| 4645 | 4653 | FUNC_CFG_REQ_ENABLES_NUM_HW_RING_GRPS : 0; |
| 4646 | − enables |= vnics ? FUNC_VF_CFG_REQ_ENABLES_NUM_VNICS : 0; | |
| 4654 | + enables |= vnics ? FUNC_CFG_REQ_ENABLES_NUM_VNICS : 0; | |
| 4647 | 4655 | |
| 4648 | 4656 | req->num_rx_rings = cpu_to_le16(rx_rings); |
| 4649 | 4657 | req->num_hw_ring_grps = cpu_to_le16(ring_grps); |
| @@ -8614,7 +8622,7 @@ static void _bnxt_get_max_rings(struct bnxt *bp, int *max_rx, int *max_tx, · 3964 unmodified lines | ||
| 8614 | 8622 | *max_tx = hw_resc->max_tx_rings; |
| 8615 | 8623 | *max_rx = hw_resc->max_rx_rings; |
| 8616 | 8624 | *max_cp = min_t(int, bnxt_get_max_func_cp_rings_for_en(bp), |
| 8617 | − hw_resc->max_irqs); | |
| 8625 | + hw_resc->max_irqs - bnxt_get_ulp_msix_num(bp)); | |
| 8618 | 8626 | *max_cp = min_t(int, *max_cp, hw_resc->max_stat_ctxs); |
| 8619 | 8627 | max_ring_grps = hw_resc->max_hw_ring_grps; |
| 8620 | 8628 | if (BNXT_CHIP_TYPE_NITRO_A0(bp) && BNXT_PF(bp)) { |
| @@ -9050,6 +9058,7 @@ init_err_cleanup_tc: · 429 unmodified lines | ||
| 9050 | 9058 | bnxt_clear_int_mode(bp); |
| 9051 | 9059 | |
| 9052 | 9060 | init_err_pci_clean: |
| 9061 | + bnxt_free_hwrm_resources(bp); | |
| 9053 | 9062 | bnxt_cleanup_pci(bp); |
| 9054 | 9063 | |
| 9055 | 9064 | init_err_free: |
| @@ -98,13 +98,13 @@ static int bnxt_hwrm_queue_cos2bw_cfg(struct bnxt *bp, struct ieee_ets *ets, · 97 unmodified lines | ||
| 98 | 98 | |
| 99 | 99 | bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_QUEUE_COS2BW_CFG, -1, -1); |
| 100 | 100 | for (i = 0; i < max_tc; i++) { |
| 101 | − u8 qidx; | |
| 101 | + u8 qidx = bp->tc_to_qidx[i]; | |
| 102 | 102 | |
| 103 | 103 | req.enables |= cpu_to_le32( |
| 104 | − QUEUE_COS2BW_CFG_REQ_ENABLES_COS_QUEUE_ID0_VALID << i); | |
| 104 | + QUEUE_COS2BW_CFG_REQ_ENABLES_COS_QUEUE_ID0_VALID << | |
| 105 | + qidx); | |
| 105 | 106 | |
| 106 | 107 | memset(&cos2bw, 0, sizeof(cos2bw)); |
| 107 | − qidx = bp->tc_to_qidx[i]; | |
| 108 | 108 | cos2bw.queue_id = bp->q_info[qidx].queue_id; |
| 109 | 109 | if (ets->tc_tsa[i] == IEEE_8021QAZ_TSA_STRICT) { |
| 110 | 110 | cos2bw.tsa = |
| @@ -2160,6 +2160,7 @@ static void macb_configure_dma(struct macb *bp) · 2159 unmodified lines | ||
| 2160 | 2160 | else |
| 2161 | 2161 | dmacfg &= ~GEM_BIT(TXCOEN); |
| 2162 | 2162 | |
| 2163 | + dmacfg &= ~GEM_BIT(ADDR64); | |
| 2163 | 2164 | #ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT |
| 2164 | 2165 | if (bp->hw_dma_cap & HW_DMA_CAP_64B) |
| 2165 | 2166 | dmacfg |= GEM_BIT(ADDR64); |
| @@ -2159,6 +2159,8 @@ static int cxgb_extension_ioctl(struct net_device *dev, void __user *useraddr) · 2158 unmodified lines | ||
| 2159 | 2159 | return -EPERM; |
| 2160 | 2160 | if (copy_from_user(&t, useraddr, sizeof(t))) |
| 2161 | 2161 | return -EFAULT; |
| 2162 | + if (t.cmd != CHELSIO_SET_QSET_PARAMS) | |
| 2163 | + return -EINVAL; | |
| 2162 | 2164 | if (t.qset_idx >= SGE_QSETS) |
| 2163 | 2165 | return -EINVAL; |
| 2164 | 2166 | if (!in_range(t.intr_lat, 0, M_NEWTIMER) || |
| @@ -2258,6 +2260,9 @@ static int cxgb_extension_ioctl(struct net_device *dev, void __user *useraddr) · 93 unmodified lines | ||
| 2258 | 2260 | if (copy_from_user(&t, useraddr, sizeof(t))) |
| 2259 | 2261 | return -EFAULT; |
| 2260 | 2262 | |
| 2263 | + if (t.cmd != CHELSIO_GET_QSET_PARAMS) | |
| 2264 | + return -EINVAL; | |
| 2265 | + | |
| 2261 | 2266 | /* Display qsets for all ports when offload enabled */ |
| 2262 | 2267 | if (test_bit(OFFLOAD_DEVMAP_BIT, &adapter->open_device_map)) { |
| 2263 | 2268 | q1 = 0; |
| @@ -2303,6 +2308,8 @@ static int cxgb_extension_ioctl(struct net_device *dev, void __user *useraddr) · 39 unmodified lines | ||
| 2303 | 2308 | return -EBUSY; |
| 2304 | 2309 | if (copy_from_user(&edata, useraddr, sizeof(edata))) |
| 2305 | 2310 | return -EFAULT; |
| 2311 | + if (edata.cmd != CHELSIO_SET_QSET_NUM) | |
| 2312 | + return -EINVAL; | |
| 2306 | 2313 | if (edata.val < 1 || |
| 2307 | 2314 | (edata.val > 1 && !(adapter->flags & USING_MSIX))) |
| 2308 | 2315 | return -EINVAL; |
| @@ -2343,6 +2350,8 @@ static int cxgb_extension_ioctl(struct net_device *dev, void __user *useraddr) · 34 unmodified lines | ||
| 2343 | 2350 | return -EPERM; |
| 2344 | 2351 | if (copy_from_user(&t, useraddr, sizeof(t))) |
| 2345 | 2352 | return -EFAULT; |
| 2353 | + if (t.cmd != CHELSIO_LOAD_FW) | |
| 2354 | + return -EINVAL; | |
| 2346 | 2355 | /* Check t.len sanity ? */ |
| 2347 | 2356 | fw_data = memdup_user(useraddr + sizeof(t), t.len); |
| 2348 | 2357 | if (IS_ERR(fw_data)) |
| @@ -2366,6 +2375,8 @@ static int cxgb_extension_ioctl(struct net_device *dev, void __user *useraddr) · 17 unmodified lines | ||
| 2366 | 2375 | return -EBUSY; |
| 2367 | 2376 | if (copy_from_user(&m, useraddr, sizeof(m))) |
| 2368 | 2377 | return -EFAULT; |
| 2378 | + if (m.cmd != CHELSIO_SETMTUTAB) | |
| 2379 | + return -EINVAL; | |
| 2369 | 2380 | if (m.nmtus != NMTUS) |
| 2370 | 2381 | return -EINVAL; |
| 2371 | 2382 | if (m.mtus[0] < 81) /* accommodate SACK */ |
| @@ -2407,6 +2418,8 @@ static int cxgb_extension_ioctl(struct net_device *dev, void __user *useraddr) · 35 unmodified lines | ||
| 2407 | 2418 | return -EBUSY; |
| 2408 | 2419 | if (copy_from_user(&m, useraddr, sizeof(m))) |
| 2409 | 2420 | return -EFAULT; |
| 2421 | + if (m.cmd != CHELSIO_SET_PM) | |
| 2422 | + return -EINVAL; | |
| 2410 | 2423 | if (!is_power_of_2(m.rx_pg_sz) || |
| 2411 | 2424 | !is_power_of_2(m.tx_pg_sz)) |
| 2412 | 2425 | return -EINVAL; /* not power of 2 */ |
| @@ -2440,6 +2453,8 @@ static int cxgb_extension_ioctl(struct net_device *dev, void __user *useraddr) · 27 unmodified lines | ||
| 2440 | 2453 | return -EIO; /* need the memory controllers */ |
| 2441 | 2454 | if (copy_from_user(&t, useraddr, sizeof(t))) |
| 2442 | 2455 | return -EFAULT; |
| 2456 | + if (t.cmd != CHELSIO_GET_MEM) | |
| 2457 | + return -EINVAL; | |
| 2443 | 2458 | if ((t.addr & 7) || (t.len & 7)) |
| 2444 | 2459 | return -EINVAL; |
| 2445 | 2460 | if (t.mem_id == MEM_CM) |
| @@ -2492,6 +2507,8 @@ static int cxgb_extension_ioctl(struct net_device *dev, void __user *useraddr) · 46 unmodified lines | ||
| 2492 | 2507 | return -EAGAIN; |
| 2493 | 2508 | if (copy_from_user(&t, useraddr, sizeof(t))) |
| 2494 | 2509 | return -EFAULT; |
| 2510 | + if (t.cmd != CHELSIO_SET_TRACE_FILTER) | |
| 2511 | + return -EINVAL; | |
| 2495 | 2512 | |
| 2496 | 2513 | tp = (const struct trace_params *)&t.sip; |
| 2497 | 2514 | if (t.config_tx) |
| @@ -4002,8 +4002,6 @@ static int be_enable_vxlan_offloads(struct be_adapter *adapter) · 4001 unmodified lines | ||
| 4002 | 4002 | netdev->hw_enc_features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | |
| 4003 | 4003 | NETIF_F_TSO | NETIF_F_TSO6 | |
| 4004 | 4004 | NETIF_F_GSO_UDP_TUNNEL; |
| 4005 | − netdev->hw_features |= NETIF_F_GSO_UDP_TUNNEL; | |
| 4006 | − netdev->features |= NETIF_F_GSO_UDP_TUNNEL; | |
| 4007 | 4005 | |
| 4008 | 4006 | dev_info(dev, "Enabled VxLAN offloads for UDP port %d\n", |
| 4009 | 4007 | be16_to_cpu(port)); |
| @@ -4025,8 +4023,6 @@ static void be_disable_vxlan_offloads(struct be_adapter *adapter) · 15 unmodified lines | ||
| 4025 | 4023 | adapter->vxlan_port = 0; |
| 4026 | 4024 | |
| 4027 | 4025 | netdev->hw_enc_features = 0; |
| 4028 | − netdev->hw_features &= ~(NETIF_F_GSO_UDP_TUNNEL); | |
| 4029 | − netdev->features &= ~(NETIF_F_GSO_UDP_TUNNEL); | |
| 4030 | 4026 | } |
| 4031 | 4027 | |
| 4032 | 4028 | static void be_calculate_vf_res(struct be_adapter *adapter, u16 num_vfs, |
| @@ -5320,6 +5316,7 @@ static void be_netdev_init(struct net_device *netdev) · 1287 unmodified lines | ||
| 5320 | 5316 | struct be_adapter *adapter = netdev_priv(netdev); |
| 5321 | 5317 | |
| 5322 | 5318 | netdev->hw_features |= NETIF_F_SG | NETIF_F_TSO | NETIF_F_TSO6 | |
| 5319 | + NETIF_F_GSO_UDP_TUNNEL | | |
| 5323 | 5320 | NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | NETIF_F_RXCSUM | |
| 5324 | 5321 | NETIF_F_HW_VLAN_CTAG_TX; |
| 5325 | 5322 | if ((be_if_cap_flags(adapter) & BE_IF_FLAGS_RSS)) |
| @@ -1158,7 +1158,7 @@ static void fec_enet_timeout_work(struct work_struct *work) · 1157 unmodified lines | ||
| 1158 | 1158 | napi_disable(&fep->napi); |
| 1159 | 1159 | netif_tx_lock_bh(ndev); |
| 1160 | 1160 | fec_restart(ndev); |
| 1161 | − netif_wake_queue(ndev); | |
| 1161 | + netif_tx_wake_all_queues(ndev); | |
| 1162 | 1162 | netif_tx_unlock_bh(ndev); |
| 1163 | 1163 | napi_enable(&fep->napi); |
| 1164 | 1164 | } |
| @@ -1273,7 +1273,7 @@ skb_done: · 108 unmodified lines | ||
| 1273 | 1273 | |
| 1274 | 1274 | /* Since we have freed up a buffer, the ring is no longer full |
| 1275 | 1275 | */ |
| 1276 | − if (netif_queue_stopped(ndev)) { | |
| 1276 | + if (netif_tx_queue_stopped(nq)) { | |
| 1277 | 1277 | entries_free = fec_enet_get_free_txdesc_num(txq); |
| 1278 | 1278 | if (entries_free >= txq->tx_wake_threshold) |
| 1279 | 1279 | netif_tx_wake_queue(nq); |
| @@ -1746,7 +1746,7 @@ static void fec_enet_adjust_link(struct net_device *ndev) · 466 unmodified lines | ||
| 1746 | 1746 | napi_disable(&fep->napi); |
| 1747 | 1747 | netif_tx_lock_bh(ndev); |
| 1748 | 1748 | fec_restart(ndev); |
| 1749 | − netif_wake_queue(ndev); | |
| 1749 | + netif_tx_wake_all_queues(ndev); | |
| 1750 | 1750 | netif_tx_unlock_bh(ndev); |
| 1751 | 1751 | napi_enable(&fep->napi); |
| 1752 | 1752 | } |
| @@ -2247,7 +2247,7 @@ static int fec_enet_set_pauseparam(struct net_device *ndev, · 494 unmodified lines | ||
| 2247 | 2247 | napi_disable(&fep->napi); |
| 2248 | 2248 | netif_tx_lock_bh(ndev); |
| 2249 | 2249 | fec_restart(ndev); |
| 2250 | − netif_wake_queue(ndev); | |
| 2250 | + netif_tx_wake_all_queues(ndev); | |
| 2251 | 2251 | netif_tx_unlock_bh(ndev); |
| 2252 | 2252 | napi_enable(&fep->napi); |
| 2253 | 2253 | } |
| @@ -84,7 +84,7 @@ static void hnae_unmap_buffer(struct hnae_ring *ring, struct hnae_desc_cb *cb) · 83 unmodified lines | ||
| 84 | 84 | if (cb->type == DESC_TYPE_SKB) |
| 85 | 85 | dma_unmap_single(ring_to_dev(ring), cb->dma, cb->length, |
| 86 | 86 | ring_to_dma_dir(ring)); |
| 87 | − else | |
| 87 | + else if (cb->length) | |
| 88 | 88 | dma_unmap_page(ring_to_dev(ring), cb->dma, cb->length, |
| 89 | 89 | ring_to_dma_dir(ring)); |
| 90 | 90 | } |
| @@ -40,9 +40,9 @@ · 39 unmodified lines | ||
| 40 | 40 | #define SKB_TMP_LEN(SKB) \ |
| 41 | 41 | (((SKB)->transport_header - (SKB)->mac_header) + tcp_hdrlen(SKB)) |
| 42 | 42 | |
| 43 | −static void fill_v2_desc(struct hnae_ring *ring, void *priv, | |
| 44 | − int size, dma_addr_t dma, int frag_end, | |
| 45 | − int buf_num, enum hns_desc_type type, int mtu) | |
| 43 | +static void fill_v2_desc_hw(struct hnae_ring *ring, void *priv, int size, | |
| 44 | + int send_sz, dma_addr_t dma, int frag_end, | |
| 45 | + int buf_num, enum hns_desc_type type, int mtu) | |
| 46 | 46 | { |
| 47 | 47 | struct hnae_desc *desc = &ring->desc[ring->next_to_use]; |
| 48 | 48 | struct hnae_desc_cb *desc_cb = &ring->desc_cb[ring->next_to_use]; |
| @@ -64,7 +64,7 @@ static void fill_v2_desc(struct hnae_ring *ring, void *priv, · 15 unmodified lines | ||
| 64 | 64 | desc_cb->type = type; |
| 65 | 65 | |
| 66 | 66 | desc->addr = cpu_to_le64(dma); |
| 67 | − desc->tx.send_size = cpu_to_le16((u16)size); | |
| 67 | + desc->tx.send_size = cpu_to_le16((u16)send_sz); | |
| 68 | 68 | |
| 69 | 69 | /* config bd buffer end */ |
| 70 | 70 | hnae_set_bit(rrcfv, HNSV2_TXD_VLD_B, 1); |
| @@ -133,6 +133,14 @@ static void fill_v2_desc(struct hnae_ring *ring, void *priv, · 62 unmodified lines | ||
| 133 | 133 | ring_ptr_move_fw(ring, next_to_use); |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | +static void fill_v2_desc(struct hnae_ring *ring, void *priv, | |
| 137 | + int size, dma_addr_t dma, int frag_end, | |
| 138 | + int buf_num, enum hns_desc_type type, int mtu) | |
| 139 | +{ | |
| 140 | + fill_v2_desc_hw(ring, priv, size, size, dma, frag_end, | |
| 141 | + buf_num, type, mtu); | |
| 142 | +} | |
| 143 | + | |
| 136 | 144 | static const struct acpi_device_id hns_enet_acpi_match[] = { |
| 137 | 145 | { "HISI00C1", 0 }, |
| 138 | 146 | { "HISI00C2", 0 }, |
| @@ -289,15 +297,15 @@ static void fill_tso_desc(struct hnae_ring *ring, void *priv, · 150 unmodified lines | ||
| 289 | 297 | |
| 290 | 298 | /* when the frag size is bigger than hardware, split this frag */ |
| 291 | 299 | for (k = 0; k < frag_buf_num; k++) |
| 292 | − fill_v2_desc(ring, priv, | |
| 293 | − (k == frag_buf_num - 1) ? | |
| 300 | + fill_v2_desc_hw(ring, priv, k == 0 ? size : 0, | |
| 301 | + (k == frag_buf_num - 1) ? | |
| 294 | 302 | sizeoflast : BD_MAX_SEND_SIZE, |
| 295 | − dma + BD_MAX_SEND_SIZE * k, | |
| 296 | − frag_end && (k == frag_buf_num - 1) ? 1 : 0, | |
| 297 | − buf_num, | |
| 298 | − (type == DESC_TYPE_SKB && !k) ? | |
| 303 | + dma + BD_MAX_SEND_SIZE * k, | |
| 304 | + frag_end && (k == frag_buf_num - 1) ? 1 : 0, | |
| 305 | + buf_num, | |
| 306 | + (type == DESC_TYPE_SKB && !k) ? | |
| 299 | 307 | DESC_TYPE_SKB : DESC_TYPE_PAGE, |
| 300 | − mtu); | |
| 308 | + mtu); | |
| 301 | 309 | } |
| 302 | 310 | |
| 303 | 311 | netdev_tx_t hns_nic_net_xmit_hw(struct net_device *ndev, |
| @@ -1495,21 +1503,6 @@ static int hns_nic_do_ioctl(struct net_device *netdev, struct ifreq *ifr, · 1191 unmodified lines | ||
| 1495 | 1503 | return phy_mii_ioctl(phy_dev, ifr, cmd); |
| 1496 | 1504 | } |
| 1497 | 1505 | |
| 1498 | −/* use only for netconsole to poll with the device without interrupt */ | |
| 1499 | −#ifdef CONFIG_NET_POLL_CONTROLLER | |
| 1500 | −static void hns_nic_poll_controller(struct net_device *ndev) | |
| 1501 | −{ | |
| 1502 | − struct hns_nic_priv *priv = netdev_priv(ndev); | |
| 1503 | − unsigned long flags; | |
| 1504 | − int i; | |
| 1505 | − | |
| 1506 | − local_irq_save(flags); | |
| 1507 | − for (i = 0; i < priv->ae_handle->q_num * 2; i++) | |
| 1508 | − napi_schedule(&priv->ring_data[i].napi); | |
| 1509 | − local_irq_restore(flags); | |
| 1510 | −} | |
| 1511 | −#endif | |
| 1512 | − | |
| 1513 | 1506 | static netdev_tx_t hns_nic_net_xmit(struct sk_buff *skb, |
| 1514 | 1507 | struct net_device *ndev) |
| 1515 | 1508 | { |
| @@ -1962,9 +1955,6 @@ static const struct net_device_ops hns_nic_netdev_ops = { · 446 unmodified lines | ||
| 1962 | 1955 | .ndo_set_features = hns_nic_set_features, |
| 1963 | 1956 | .ndo_fix_features = hns_nic_fix_features, |
| 1964 | 1957 | .ndo_get_stats64 = hns_nic_get_stats64, |
| 1965 | −#ifdef CONFIG_NET_POLL_CONTROLLER | |
| 1966 | − .ndo_poll_controller = hns_nic_poll_controller, | |
| 1967 | −#endif | |
| 1968 | 1958 | .ndo_set_rx_mode = hns_nic_set_rx_mode, |
| 1969 | 1959 | .ndo_select_queue = hns_nic_select_queue, |
| 1970 | 1960 | }; |
| @@ -789,23 +789,6 @@ static void hinic_get_stats64(struct net_device *netdev, · 788 unmodified lines | ||
| 789 | 789 | stats->tx_errors = nic_tx_stats->tx_dropped; |
| 790 | 790 | } |
| 791 | 791 | |
| 792 | −#ifdef CONFIG_NET_POLL_CONTROLLER | |
| 793 | −static void hinic_netpoll(struct net_device *netdev) | |
| 794 | −{ | |
| 795 | − struct hinic_dev *nic_dev = netdev_priv(netdev); | |
| 796 | − int i, num_qps; | |
| 797 | − | |
| 798 | − num_qps = hinic_hwdev_num_qps(nic_dev->hwdev); | |
| 799 | − for (i = 0; i < num_qps; i++) { | |
| 800 | − struct hinic_txq *txq = &nic_dev->txqs[i]; | |
| 801 | − struct hinic_rxq *rxq = &nic_dev->rxqs[i]; | |
| 802 | − | |
| 803 | − napi_schedule(&txq->napi); | |
| 804 | − napi_schedule(&rxq->napi); | |
| 805 | − } | |
| 806 | −} | |
| 807 | −#endif | |
| 808 | − | |
| 809 | 792 | static const struct net_device_ops hinic_netdev_ops = { |
| 810 | 793 | .ndo_open = hinic_open, |
| 811 | 794 | .ndo_stop = hinic_close, |
| @@ -818,9 +801,6 @@ static const struct net_device_ops hinic_netdev_ops = { · 6 unmodified lines | ||
| 818 | 801 | .ndo_start_xmit = hinic_xmit_frame, |
| 819 | 802 | .ndo_tx_timeout = hinic_tx_timeout, |
| 820 | 803 | .ndo_get_stats64 = hinic_get_stats64, |
| 821 | −#ifdef CONFIG_NET_POLL_CONTROLLER | |
| 822 | − .ndo_poll_controller = hinic_netpoll, | |
| 823 | −#endif | |
| 824 | 804 | }; |
| 825 | 805 | |
| 826 | 806 | static void netdev_features_init(struct net_device *netdev) |
| @@ -921,17 +921,6 @@ static int ehea_poll(struct napi_struct *napi, int budget) · 920 unmodified lines | ||
| 921 | 921 | return rx; |
| 922 | 922 | } |
| 923 | 923 | |
| 924 | −#ifdef CONFIG_NET_POLL_CONTROLLER | |
| 925 | −static void ehea_netpoll(struct net_device *dev) | |
| 926 | −{ | |
| 927 | − struct ehea_port *port = netdev_priv(dev); | |
| 928 | − int i; | |
| 929 | − | |
| 930 | − for (i = 0; i < port->num_def_qps; i++) | |
| 931 | − napi_schedule(&port->port_res[i].napi); | |
| 932 | −} | |
| 933 | −#endif | |
| 934 | − | |
| 935 | 924 | static irqreturn_t ehea_recv_irq_handler(int irq, void *param) |
| 936 | 925 | { |
| 937 | 926 | struct ehea_port_res *pr = param; |
| @@ -2953,9 +2942,6 @@ static const struct net_device_ops ehea_netdev_ops = { · 2015 unmodified lines | ||
| 2953 | 2942 | .ndo_open = ehea_open, |
| 2954 | 2943 | .ndo_stop = ehea_stop, |
| 2955 | 2944 | .ndo_start_xmit = ehea_start_xmit, |
| 2956 | −#ifdef CONFIG_NET_POLL_CONTROLLER | |
| 2957 | − .ndo_poll_controller = ehea_netpoll, | |
| 2958 | −#endif | |
| 2959 | 2945 | .ndo_get_stats64 = ehea_get_stats64, |
| 2960 | 2946 | .ndo_set_mac_address = ehea_set_mac_addr, |
| 2961 | 2947 | .ndo_validate_addr = eth_validate_addr, |
| @@ -2207,19 +2207,6 @@ restart_poll: · 2206 unmodified lines | ||
| 2207 | 2207 | return frames_processed; |
| 2208 | 2208 | } |
| 2209 | 2209 | |
| 2210 | −#ifdef CONFIG_NET_POLL_CONTROLLER | |
| 2211 | −static void ibmvnic_netpoll_controller(struct net_device *dev) | |
| 2212 | −{ | |
| 2213 | − struct ibmvnic_adapter *adapter = netdev_priv(dev); | |
| 2214 | − int i; | |
| 2215 | − | |
| 2216 | − replenish_pools(netdev_priv(dev)); | |
| 2217 | − for (i = 0; i < adapter->req_rx_queues; i++) | |
| 2218 | − ibmvnic_interrupt_rx(adapter->rx_scrq[i]->irq, | |
| 2219 | − adapter->rx_scrq[i]); | |
| 2220 | −} | |
| 2221 | −#endif | |
| 2222 | − | |
| 2223 | 2210 | static int wait_for_reset(struct ibmvnic_adapter *adapter) |
| 2224 | 2211 | { |
| 2225 | 2212 | int rc, ret; |
| @@ -2292,9 +2279,6 @@ static const struct net_device_ops ibmvnic_netdev_ops = { · 66 unmodified lines | ||
| 2292 | 2279 | .ndo_set_mac_address = ibmvnic_set_mac, |
| 2293 | 2280 | .ndo_validate_addr = eth_validate_addr, |
| 2294 | 2281 | .ndo_tx_timeout = ibmvnic_tx_timeout, |
| 2295 | −#ifdef CONFIG_NET_POLL_CONTROLLER | |
| 2296 | − .ndo_poll_controller = ibmvnic_netpoll_controller, | |
| 2297 | −#endif | |
| 2298 | 2282 | .ndo_change_mtu = ibmvnic_change_mtu, |
| 2299 | 2283 | .ndo_features_check = ibmvnic_features_check, |
| 2300 | 2284 | }; |
| @@ -3196,11 +3196,13 @@ int ixgbe_poll(struct napi_struct *napi, int budget) · 3195 unmodified lines | ||
| 3196 | 3196 | return budget; |
| 3197 | 3197 | |
| 3198 | 3198 | /* all work done, exit the polling mode */ |
| 3199 | − napi_complete_done(napi, work_done); | |
| 3200 | − if (adapter->rx_itr_setting & 1) | |
| 3201 | − ixgbe_set_itr(q_vector); | |
| 3202 | − if (!test_bit(__IXGBE_DOWN, &adapter->state)) | |
| 3203 | − ixgbe_irq_enable_queues(adapter, BIT_ULL(q_vector->v_idx)); | |
| 3199 | + if (likely(napi_complete_done(napi, work_done))) { | |
| 3200 | + if (adapter->rx_itr_setting & 1) | |
| 3201 | + ixgbe_set_itr(q_vector); | |
| 3202 | + if (!test_bit(__IXGBE_DOWN, &adapter->state)) | |
| 3203 | + ixgbe_irq_enable_queues(adapter, | |
| 3204 | + BIT_ULL(q_vector->v_idx)); | |
| 3205 | + } | |
| 3204 | 3206 | |
| 3205 | 3207 | return min(work_done, budget - 1); |
| 3206 | 3208 | } |
| @@ -1725,7 +1725,7 @@ static void mvpp2_txq_desc_put(struct mvpp2_tx_queue *txq) · 1724 unmodified lines | ||
| 1725 | 1725 | } |
| 1726 | 1726 | |
| 1727 | 1727 | /* Set Tx descriptors fields relevant for CSUM calculation */ |
| 1728 | −static u32 mvpp2_txq_desc_csum(int l3_offs, int l3_proto, | |
| 1728 | +static u32 mvpp2_txq_desc_csum(int l3_offs, __be16 l3_proto, | |
| 1729 | 1729 | int ip_hdr_len, int l4_proto) |
| 1730 | 1730 | { |
| 1731 | 1731 | u32 command; |
| @@ -2600,14 +2600,15 @@ static u32 mvpp2_skb_tx_csum(struct mvpp2_port *port, struct sk_buff *skb) · 868 unmodified lines | ||
| 2600 | 2600 | if (skb->ip_summed == CHECKSUM_PARTIAL) { |
| 2601 | 2601 | int ip_hdr_len = 0; |
| 2602 | 2602 | u8 l4_proto; |
| 2603 | + __be16 l3_proto = vlan_get_protocol(skb); | |
| 2603 | 2604 | |
| 2604 | − if (skb->protocol == htons(ETH_P_IP)) { | |
| 2605 | + if (l3_proto == htons(ETH_P_IP)) { | |
| 2605 | 2606 | struct iphdr *ip4h = ip_hdr(skb); |
| 2606 | 2607 | |
| 2607 | 2608 | /* Calculate IPv4 checksum and L4 checksum */ |
| 2608 | 2609 | ip_hdr_len = ip4h->ihl; |
| 2609 | 2610 | l4_proto = ip4h->protocol; |
| 2610 | − } else if (skb->protocol == htons(ETH_P_IPV6)) { | |
| 2611 | + } else if (l3_proto == htons(ETH_P_IPV6)) { | |
| 2611 | 2612 | struct ipv6hdr *ip6h = ipv6_hdr(skb); |
| 2612 | 2613 | |
| 2613 | 2614 | /* Read l4_protocol from one of IPv6 extra headers */ |
| @@ -2619,7 +2620,7 @@ static u32 mvpp2_skb_tx_csum(struct mvpp2_port *port, struct sk_buff *skb) · 5 unmodified lines | ||
| 2619 | 2620 | } |
| 2620 | 2621 | |
| 2621 | 2622 | return mvpp2_txq_desc_csum(skb_network_offset(skb), |
| 2622 | − skb->protocol, ip_hdr_len, l4_proto); | |
| 2623 | + l3_proto, ip_hdr_len, l4_proto); | |
| 2623 | 2624 | } |
| 2624 | 2625 | |
| 2625 | 2626 | return MVPP2_TXD_L4_CSUM_NOT | MVPP2_TXD_IP_CSUM_DISABLE; |
| @@ -54,6 +54,7 @@ · 53 unmodified lines | ||
| 54 | 54 | #include "en_stats.h" |
| 55 | 55 | #include "en/fs.h" |
| 56 | 56 | |
| 57 | +extern const struct net_device_ops mlx5e_netdev_ops; | |
| 57 | 58 | struct page_pool; |
| 58 | 59 | |
| 59 | 60 | #define MLX5E_METADATA_ETHER_TYPE (0x8CE4) |
| @@ -16,6 +16,8 @@ struct mlx5e_tc_table { · 15 unmodified lines | ||
| 16 | 16 | |
| 17 | 17 | DECLARE_HASHTABLE(mod_hdr_tbl, 8); |
| 18 | 18 | DECLARE_HASHTABLE(hairpin_tbl, 8); |
| 19 | + | |
| 20 | + struct notifier_block netdevice_nb; | |
| 19 | 21 | }; |
| 20 | 22 | |
| 21 | 23 | struct mlx5e_flow_table { |
| @@ -4315,7 +4315,7 @@ static int mlx5e_xdp(struct net_device *dev, struct netdev_bpf *xdp) · 4314 unmodified lines | ||
| 4315 | 4315 | } |
| 4316 | 4316 | } |
| 4317 | 4317 | |
| 4318 | −static const struct net_device_ops mlx5e_netdev_ops = { | |
| 4318 | +const struct net_device_ops mlx5e_netdev_ops = { | |
| 4319 | 4319 | .ndo_open = mlx5e_open, |
| 4320 | 4320 | .ndo_stop = mlx5e_close, |
| 4321 | 4321 | .ndo_start_xmit = mlx5e_xmit, |
| @@ -1368,6 +1368,9 @@ static int __parse_cls_flower(struct mlx5e_priv *priv, · 1367 unmodified lines | ||
| 1368 | 1368 | |
| 1369 | 1369 | *match_level = MLX5_MATCH_L2; |
| 1370 | 1370 | } |
| 1371 | + } else { | |
| 1372 | + MLX5_SET(fte_match_set_lyr_2_4, headers_c, svlan_tag, 1); | |
| 1373 | + MLX5_SET(fte_match_set_lyr_2_4, headers_c, cvlan_tag, 1); | |
| 1371 | 1374 | } |
| 1372 | 1375 | |
| 1373 | 1376 | if (dissector_uses_key(f->dissector, FLOW_DISSECTOR_KEY_CVLAN)) { |
| @@ -2946,14 +2949,71 @@ int mlx5e_stats_flower(struct mlx5e_priv *priv, · 1572 unmodified lines | ||
| 2946 | 2949 | return 0; |
| 2947 | 2950 | } |
| 2948 | 2951 | |
| 2952 | +static void mlx5e_tc_hairpin_update_dead_peer(struct mlx5e_priv *priv, | |
| 2953 | + struct mlx5e_priv *peer_priv) | |
| 2954 | +{ | |
| 2955 | + struct mlx5_core_dev *peer_mdev = peer_priv->mdev; | |
| 2956 | + struct mlx5e_hairpin_entry *hpe; | |
| 2957 | + u16 peer_vhca_id; | |
| 2958 | + int bkt; | |
| 2959 | + | |
| 2960 | + if (!same_hw_devs(priv, peer_priv)) | |
| 2961 | + return; | |
| 2962 | + | |
| 2963 | + peer_vhca_id = MLX5_CAP_GEN(peer_mdev, vhca_id); | |
| 2964 | + | |
| 2965 | + hash_for_each(priv->fs.tc.hairpin_tbl, bkt, hpe, hairpin_hlist) { | |
| 2966 | + if (hpe->peer_vhca_id == peer_vhca_id) | |
| 2967 | + hpe->hp->pair->peer_gone = true; | |
| 2968 | + } | |
| 2969 | +} | |
| 2970 | + | |
| 2971 | +static int mlx5e_tc_netdev_event(struct notifier_block *this, | |
| 2972 | + unsigned long event, void *ptr) | |
| 2973 | +{ | |
| 2974 | + struct net_device *ndev = netdev_notifier_info_to_dev(ptr); | |
| 2975 | + struct mlx5e_flow_steering *fs; | |
| 2976 | + struct mlx5e_priv *peer_priv; | |
| 2977 | + struct mlx5e_tc_table *tc; | |
| 2978 | + struct mlx5e_priv *priv; | |
| 2979 | + | |
| 2980 | + if (ndev->netdev_ops != &mlx5e_netdev_ops || | |
| 2981 | + event != NETDEV_UNREGISTER || | |
| 2982 | + ndev->reg_state == NETREG_REGISTERED) | |
| 2983 | + return NOTIFY_DONE; | |
| 2984 | + | |
| 2985 | + tc = container_of(this, struct mlx5e_tc_table, netdevice_nb); | |
| 2986 | + fs = container_of(tc, struct mlx5e_flow_steering, tc); | |
| 2987 | + priv = container_of(fs, struct mlx5e_priv, fs); | |
| 2988 | + peer_priv = netdev_priv(ndev); | |
| 2989 | + if (priv == peer_priv || | |
| 2990 | + !(priv->netdev->features & NETIF_F_HW_TC)) | |
| 2991 | + return NOTIFY_DONE; | |
| 2992 | + | |
| 2993 | + mlx5e_tc_hairpin_update_dead_peer(priv, peer_priv); | |
| 2994 | + | |
| 2995 | + return NOTIFY_DONE; | |
| 2996 | +} | |
| 2997 | + | |
| 2949 | 2998 | int mlx5e_tc_nic_init(struct mlx5e_priv *priv) |
| 2950 | 2999 | { |
| 2951 | 3000 | struct mlx5e_tc_table *tc = &priv->fs.tc; |
| 3001 | + int err; | |
| 2952 | 3002 | |
| 2953 | 3003 | hash_init(tc->mod_hdr_tbl); |
| 2954 | 3004 | hash_init(tc->hairpin_tbl); |
| 2955 | 3005 | |
| 2956 | − return rhashtable_init(&tc->ht, &tc_ht_params); | |
| 3006 | + err = rhashtable_init(&tc->ht, &tc_ht_params); | |
| 3007 | + if (err) | |
| 3008 | + return err; | |
| 3009 | + | |
| 3010 | + tc->netdevice_nb.notifier_call = mlx5e_tc_netdev_event; | |
| 3011 | + if (register_netdevice_notifier(&tc->netdevice_nb)) { | |
| 3012 | + tc->netdevice_nb.notifier_call = NULL; | |
| 3013 | + mlx5_core_warn(priv->mdev, "Failed to register netdev notifier\n"); | |
| 3014 | + } | |
| 3015 | + | |
| 3016 | + return err; | |
| 2957 | 3017 | } |
| 2958 | 3018 | |
| 2959 | 3019 | static void _mlx5e_tc_del_flow(void *ptr, void *arg) |
| @@ -2969,6 +3029,9 @@ void mlx5e_tc_nic_cleanup(struct mlx5e_priv *priv) · 9 unmodified lines | ||
| 2969 | 3029 | { |
| 2970 | 3030 | struct mlx5e_tc_table *tc = &priv->fs.tc; |
| 2971 | 3031 | |
| 3032 | + if (tc->netdevice_nb.notifier_call) | |
| 3033 | + unregister_netdevice_notifier(&tc->netdevice_nb); | |
| 3034 | + | |
| 2972 | 3035 | rhashtable_free_and_destroy(&tc->ht, _mlx5e_tc_del_flow, NULL); |
| 2973 | 3036 | |
| 2974 | 3037 | if (!IS_ERR_OR_NULL(tc->t)) { |
| @@ -2000,7 +2000,7 @@ static u32 calculate_vports_min_rate_divider(struct mlx5_eswitch *esw) · 1999 unmodified lines | ||
| 2000 | 2000 | u32 max_guarantee = 0; |
| 2001 | 2001 | int i; |
| 2002 | 2002 | |
| 2003 | − for (i = 0; i <= esw->total_vports; i++) { | |
| 2003 | + for (i = 0; i < esw->total_vports; i++) { | |
| 2004 | 2004 | evport = &esw->vports[i]; |
| 2005 | 2005 | if (!evport->enabled || evport->info.min_rate < max_guarantee) |
| 2006 | 2006 | continue; |
| @@ -2020,7 +2020,7 @@ static int normalize_vports_min_rate(struct mlx5_eswitch *esw, u32 divider) · 13 unmodified lines | ||
| 2020 | 2020 | int err; |
| 2021 | 2021 | int i; |
| 2022 | 2022 | |
| 2023 | − for (i = 0; i <= esw->total_vports; i++) { | |
| 2023 | + for (i = 0; i < esw->total_vports; i++) { | |
| 2024 | 2024 | evport = &esw->vports[i]; |
| 2025 | 2025 | if (!evport->enabled) |
| 2026 | 2026 | continue; |
| @@ -475,7 +475,8 @@ static void mlx5_hairpin_destroy_queues(struct mlx5_hairpin *hp) · 474 unmodified lines | ||
| 475 | 475 | |
| 476 | 476 | for (i = 0; i < hp->num_channels; i++) { |
| 477 | 477 | mlx5_core_destroy_rq(hp->func_mdev, hp->rqn[i]); |
| 478 | − mlx5_core_destroy_sq(hp->peer_mdev, hp->sqn[i]); | |
| 478 | + if (!hp->peer_gone) | |
| 479 | + mlx5_core_destroy_sq(hp->peer_mdev, hp->sqn[i]); | |
| 479 | 480 | } |
| 480 | 481 | } |
| 481 | 482 | |
| @@ -567,6 +568,8 @@ static void mlx5_hairpin_unpair_queues(struct mlx5_hairpin *hp) · 85 unmodified lines | ||
| 567 | 568 | MLX5_RQC_STATE_RST, 0, 0); |
| 568 | 569 | |
| 569 | 570 | /* unset peer SQs */ |
| 571 | + if (hp->peer_gone) | |
| 572 | + return; | |
| 570 | 573 | for (i = 0; i < hp->num_channels; i++) |
| 571 | 574 | mlx5_hairpin_modify_sq(hp->peer_mdev, hp->sqn[i], MLX5_SQC_STATE_RDY, |
| 572 | 575 | MLX5_SQC_STATE_RST, 0, 0); |
| @@ -718,14 +718,17 @@ static void mlxsw_pci_eq_tasklet(unsigned long data) · 717 unmodified lines | ||
| 718 | 718 | memset(&active_cqns, 0, sizeof(active_cqns)); |
| 719 | 719 | |
| 720 | 720 | while ((eqe = mlxsw_pci_eq_sw_eqe_get(q))) { |
| 721 | − u8 event_type = mlxsw_pci_eqe_event_type_get(eqe); | |
| 722 | 721 | |
| 723 | − switch (event_type) { | |
| 724 | − case MLXSW_PCI_EQE_EVENT_TYPE_CMD: | |
| 722 | + /* Command interface completion events are always received on | |
| 723 | + * queue MLXSW_PCI_EQ_ASYNC_NUM (EQ0) and completion events | |
| 724 | + * are mapped to queue MLXSW_PCI_EQ_COMP_NUM (EQ1). | |
| 725 | + */ | |
| 726 | + switch (q->num) { | |
| 727 | + case MLXSW_PCI_EQ_ASYNC_NUM: | |
| 725 | 728 | mlxsw_pci_eq_cmd_event(mlxsw_pci, eqe); |
| 726 | 729 | q->u.eq.ev_cmd_count++; |
| 727 | 730 | break; |
| 728 | − case MLXSW_PCI_EQE_EVENT_TYPE_COMP: | |
| 731 | + case MLXSW_PCI_EQ_COMP_NUM: | |
| 729 | 732 | cqn = mlxsw_pci_eqe_cqn_get(eqe); |
| 730 | 733 | set_bit(cqn, active_cqns); |
| 731 | 734 | cq_handle = true; |
| @@ -4845,6 +4845,8 @@ static int mlxsw_sp_netdevice_bridge_event(struct net_device *br_dev, · 4844 unmodified lines | ||
| 4845 | 4845 | upper_dev = info->upper_dev; |
| 4846 | 4846 | if (info->linking) |
| 4847 | 4847 | break; |
| 4848 | + if (is_vlan_dev(upper_dev)) | |
| 4849 | + mlxsw_sp_rif_destroy_by_dev(mlxsw_sp, upper_dev); | |
| 4848 | 4850 | if (netif_is_macvlan(upper_dev)) |
| 4849 | 4851 | mlxsw_sp_rif_macvlan_del(mlxsw_sp, upper_dev); |
| 4850 | 4852 | break; |
| @@ -2077,14 +2077,17 @@ nfp_ctrl_rx_one(struct nfp_net *nn, struct nfp_net_dp *dp, · 2076 unmodified lines | ||
| 2077 | 2077 | return true; |
| 2078 | 2078 | } |
| 2079 | 2079 | |
| 2080 | −static void nfp_ctrl_rx(struct nfp_net_r_vector *r_vec) | |
| 2080 | +static bool nfp_ctrl_rx(struct nfp_net_r_vector *r_vec) | |
| 2081 | 2081 | { |
| 2082 | 2082 | struct nfp_net_rx_ring *rx_ring = r_vec->rx_ring; |
| 2083 | 2083 | struct nfp_net *nn = r_vec->nfp_net; |
| 2084 | 2084 | struct nfp_net_dp *dp = &nn->dp; |
| 2085 | + unsigned int budget = 512; | |
| 2085 | 2086 | |
| 2086 | − while (nfp_ctrl_rx_one(nn, dp, r_vec, rx_ring)) | |
| 2087 | + while (nfp_ctrl_rx_one(nn, dp, r_vec, rx_ring) && budget--) | |
| 2087 | 2088 | continue; |
| 2089 | + | |
| 2090 | + return budget; | |
| 2088 | 2091 | } |
| 2089 | 2092 | |
| 2090 | 2093 | static void nfp_ctrl_poll(unsigned long arg) |
| @@ -2096,9 +2099,13 @@ static void nfp_ctrl_poll(unsigned long arg) · 5 unmodified lines | ||
| 2096 | 2099 | __nfp_ctrl_tx_queued(r_vec); |
| 2097 | 2100 | spin_unlock_bh(&r_vec->lock); |
| 2098 | 2101 | |
| 2099 | − nfp_ctrl_rx(r_vec); | |
| 2100 | − | |
| 2101 | − nfp_net_irq_unmask(r_vec->nfp_net, r_vec->irq_entry); | |
| 2102 | + if (nfp_ctrl_rx(r_vec)) { | |
| 2103 | + nfp_net_irq_unmask(r_vec->nfp_net, r_vec->irq_entry); | |
| 2104 | + } else { | |
| 2105 | + tasklet_schedule(&r_vec->tasklet); | |
| 2106 | + nn_dp_warn(&r_vec->nfp_net->dp, | |
| 2107 | + "control message budget exceeded!\n"); | |
| 2108 | + } | |
| 2102 | 2109 | } |
| 2103 | 2110 | |
| 2104 | 2111 | /* Setup and Configuration |
| @@ -72,9 +72,6 @@ static void netxen_schedule_work(struct netxen_adapter *adapter, · 71 unmodified lines | ||
| 72 | 72 | work_func_t func, int delay); |
| 73 | 73 | static void netxen_cancel_fw_work(struct netxen_adapter *adapter); |
| 74 | 74 | static int netxen_nic_poll(struct napi_struct *napi, int budget); |
| 75 | −#ifdef CONFIG_NET_POLL_CONTROLLER | |
| 76 | −static void netxen_nic_poll_controller(struct net_device *netdev); | |
| 77 | −#endif | |
| 78 | 75 | |
| 79 | 76 | static void netxen_create_sysfs_entries(struct netxen_adapter *adapter); |
| 80 | 77 | static void netxen_remove_sysfs_entries(struct netxen_adapter *adapter); |
| @@ -581,9 +578,6 @@ static const struct net_device_ops netxen_netdev_ops = { · 500 unmodified lines | ||
| 581 | 578 | .ndo_tx_timeout = netxen_tx_timeout, |
| 582 | 579 | .ndo_fix_features = netxen_fix_features, |
| 583 | 580 | .ndo_set_features = netxen_set_features, |
| 584 | −#ifdef CONFIG_NET_POLL_CONTROLLER | |
| 585 | − .ndo_poll_controller = netxen_nic_poll_controller, | |
| 586 | −#endif | |
| 587 | 581 | }; |
| 588 | 582 | |
| 589 | 583 | static inline bool netxen_function_zero(struct pci_dev *pdev) |
| @@ -2402,23 +2396,6 @@ static int netxen_nic_poll(struct napi_struct *napi, int budget) · 1812 unmodified lines | ||
| 2402 | 2396 | return work_done; |
| 2403 | 2397 | } |
| 2404 | 2398 | |
| 2405 | −#ifdef CONFIG_NET_POLL_CONTROLLER | |
| 2406 | −static void netxen_nic_poll_controller(struct net_device *netdev) | |
| 2407 | −{ | |
| 2408 | − int ring; | |
| 2409 | − struct nx_host_sds_ring *sds_ring; | |
| 2410 | − struct netxen_adapter *adapter = netdev_priv(netdev); | |
| 2411 | − struct netxen_recv_context *recv_ctx = &adapter->recv_ctx; | |
| 2412 | − | |
| 2413 | − disable_irq(adapter->irq); | |
| 2414 | − for (ring = 0; ring < adapter->max_sds_rings; ring++) { | |
| 2415 | − sds_ring = &recv_ctx->sds_rings[ring]; | |
| 2416 | − netxen_intr(adapter->irq, sds_ring); | |
| 2417 | − } | |
| 2418 | − enable_irq(adapter->irq); | |
| 2419 | −} | |
| 2420 | −#endif | |
| 2421 | − | |
| 2422 | 2399 | static int |
| 2423 | 2400 | nx_incr_dev_ref_cnt(struct netxen_adapter *adapter) |
| 2424 | 2401 | { |
| @@ -11987,6 +11987,7 @@ struct public_global { · 11986 unmodified lines | ||
| 11987 | 11987 | u32 running_bundle_id; |
| 11988 | 11988 | s32 external_temperature; |
| 11989 | 11989 | u32 mdump_reason; |
| 11990 | + u64 reserved; | |
| 11990 | 11991 | u32 data_ptr; |
| 11991 | 11992 | u32 data_size; |
| 11992 | 11993 | }; |
| @@ -1710,7 +1710,7 @@ qed_iwarp_parse_rx_pkt(struct qed_hwfn *p_hwfn, · 1709 unmodified lines | ||
| 1710 | 1710 | |
| 1711 | 1711 | cm_info->local_ip[0] = ntohl(iph->daddr); |
| 1712 | 1712 | cm_info->remote_ip[0] = ntohl(iph->saddr); |
| 1713 | − cm_info->ip_version = TCP_IPV4; | |
| 1713 | + cm_info->ip_version = QED_TCP_IPV4; | |
| 1714 | 1714 | |
| 1715 | 1715 | ip_hlen = (iph->ihl) * sizeof(u32); |
| 1716 | 1716 | *payload_len = ntohs(iph->tot_len) - ip_hlen; |
| @@ -1730,7 +1730,7 @@ qed_iwarp_parse_rx_pkt(struct qed_hwfn *p_hwfn, · 13 unmodified lines | ||
| 1730 | 1730 | cm_info->remote_ip[i] = |
| 1731 | 1731 | ntohl(ip6h->saddr.in6_u.u6_addr32[i]); |
| 1732 | 1732 | } |
| 1733 | − cm_info->ip_version = TCP_IPV6; | |
| 1733 | + cm_info->ip_version = QED_TCP_IPV6; | |
| 1734 | 1734 | |
| 1735 | 1735 | ip_hlen = sizeof(*ip6h); |
| 1736 | 1736 | *payload_len = ntohs(ip6h->payload_len); |
| @@ -228,7 +228,7 @@ static int qed_rdma_alloc(struct qed_hwfn *p_hwfn, · 227 unmodified lines | ||
| 228 | 228 | num_cons, "Toggle"); |
| 229 | 229 | if (rc) { |
| 230 | 230 | DP_VERBOSE(p_hwfn, QED_MSG_RDMA, |
| 231 | − "Failed to allocate toogle bits, rc = %d\n", rc); | |
| 231 | + "Failed to allocate toggle bits, rc = %d\n", rc); | |
| 232 | 232 | goto free_cq_map; |
| 233 | 233 | } |
| 234 | 234 | |
| @@ -140,23 +140,16 @@ static void qed_rdma_copy_gids(struct qed_rdma_qp *qp, __le32 *src_gid, · 139 unmodified lines | ||
| 140 | 140 | |
| 141 | 141 | static enum roce_flavor qed_roce_mode_to_flavor(enum roce_mode roce_mode) |
| 142 | 142 | { |
| 143 | − enum roce_flavor flavor; | |
| 144 | − | |
| 145 | 143 | switch (roce_mode) { |
| 146 | 144 | case ROCE_V1: |
| 147 | − flavor = PLAIN_ROCE; | |
| 148 | − break; | |
| 145 | + return PLAIN_ROCE; | |
| 149 | 146 | case ROCE_V2_IPV4: |
| 150 | − flavor = RROCE_IPV4; | |
| 151 | − break; | |
| 147 | + return RROCE_IPV4; | |
| 152 | 148 | case ROCE_V2_IPV6: |
| 153 | − flavor = ROCE_V2_IPV6; | |
| 154 | − break; | |
| 149 | + return RROCE_IPV6; | |
| 155 | 150 | default: |
| 156 | − flavor = MAX_ROCE_MODE; | |
| 157 | − break; | |
| 151 | + return MAX_ROCE_FLAVOR; | |
| 158 | 152 | } |
| 159 | − return flavor; | |
| 160 | 153 | } |
| 161 | 154 | |
| 162 | 155 | static void qed_roce_free_cid_pair(struct qed_hwfn *p_hwfn, u16 cid) |
| @@ -154,7 +154,7 @@ qed_set_pf_update_tunn_mode(struct qed_tunnel_info *p_tun, · 153 unmodified lines | ||
| 154 | 154 | static void qed_set_tunn_cls_info(struct qed_tunnel_info *p_tun, |
| 155 | 155 | struct qed_tunnel_info *p_src) |
| 156 | 156 | { |
| 157 | − enum tunnel_clss type; | |
| 157 | + int type; | |
| 158 | 158 | |
| 159 | 159 | p_tun->b_update_rx_cls = p_src->b_update_rx_cls; |
| 160 | 160 | p_tun->b_update_tx_cls = p_src->b_update_tx_cls; |
| @@ -413,7 +413,6 @@ static int qed_vf_pf_acquire(struct qed_hwfn *p_hwfn) · 412 unmodified lines | ||
| 413 | 413 | } |
| 414 | 414 | |
| 415 | 415 | if (!p_iov->b_pre_fp_hsi && |
| 416 | − ETH_HSI_VER_MINOR && | |
| 417 | 416 | (resp->pfdev_info.minor_fp_hsi < ETH_HSI_VER_MINOR)) { |
| 418 | 417 | DP_INFO(p_hwfn, |
| 419 | 418 | "PF is using older fastpath HSI; %02x.%02x is configured\n", |
| @@ -572,7 +571,7 @@ free_p_iov: · 152 unmodified lines | ||
| 572 | 571 | static void |
| 573 | 572 | __qed_vf_prep_tunn_req_tlv(struct vfpf_update_tunn_param_tlv *p_req, |
| 574 | 573 | struct qed_tunn_update_type *p_src, |
| 575 | − enum qed_tunn_clss mask, u8 *p_cls) | |
| 574 | + enum qed_tunn_mode mask, u8 *p_cls) | |
| 576 | 575 | { |
| 577 | 576 | if (p_src->b_update_mode) { |
| 578 | 577 | p_req->tun_mode_update_mask |= BIT(mask); |
| @@ -587,7 +586,7 @@ __qed_vf_prep_tunn_req_tlv(struct vfpf_update_tunn_param_tlv *p_req, · 8 unmodified lines | ||
| 587 | 586 | static void |
| 588 | 587 | qed_vf_prep_tunn_req_tlv(struct vfpf_update_tunn_param_tlv *p_req, |
| 589 | 588 | struct qed_tunn_update_type *p_src, |
| 590 | − enum qed_tunn_clss mask, | |
| 589 | + enum qed_tunn_mode mask, | |
| 591 | 590 | u8 *p_cls, struct qed_tunn_update_udp_port *p_port, |
| 592 | 591 | u8 *p_update_port, u16 *p_udp_port) |
| 593 | 592 | { |
| @@ -1800,7 +1800,8 @@ struct qlcnic_hardware_ops { · 1799 unmodified lines | ||
| 1800 | 1800 | int (*config_loopback) (struct qlcnic_adapter *, u8); |
| 1801 | 1801 | int (*clear_loopback) (struct qlcnic_adapter *, u8); |
| 1802 | 1802 | int (*config_promisc_mode) (struct qlcnic_adapter *, u32); |
| 1803 | − void (*change_l2_filter) (struct qlcnic_adapter *, u64 *, u16); | |
| 1803 | + void (*change_l2_filter)(struct qlcnic_adapter *adapter, u64 *addr, | |
| 1804 | + u16 vlan, struct qlcnic_host_tx_ring *tx_ring); | |
| 1804 | 1805 | int (*get_board_info) (struct qlcnic_adapter *); |
| 1805 | 1806 | void (*set_mac_filter_count) (struct qlcnic_adapter *); |
| 1806 | 1807 | void (*free_mac_list) (struct qlcnic_adapter *); |
| @@ -2064,9 +2065,10 @@ static inline int qlcnic_nic_set_promisc(struct qlcnic_adapter *adapter, · 257 unmodified lines | ||
| 2064 | 2065 | } |
| 2065 | 2066 | |
| 2066 | 2067 | static inline void qlcnic_change_filter(struct qlcnic_adapter *adapter, |
| 2067 | − u64 *addr, u16 id) | |
| 2068 | + u64 *addr, u16 vlan, | |
| 2069 | + struct qlcnic_host_tx_ring *tx_ring) | |
| 2068 | 2070 | { |
| 2069 | − adapter->ahw->hw_ops->change_l2_filter(adapter, addr, id); | |
| 2071 | + adapter->ahw->hw_ops->change_l2_filter(adapter, addr, vlan, tx_ring); | |
| 2070 | 2072 | } |
| 2071 | 2073 | |
| 2072 | 2074 | static inline int qlcnic_get_board_info(struct qlcnic_adapter *adapter) |
| @@ -2135,7 +2135,8 @@ out: · 2134 unmodified lines | ||
| 2135 | 2135 | } |
| 2136 | 2136 | |
| 2137 | 2137 | void qlcnic_83xx_change_l2_filter(struct qlcnic_adapter *adapter, u64 *addr, |
| 2138 | − u16 vlan_id) | |
| 2138 | + u16 vlan_id, | |
| 2139 | + struct qlcnic_host_tx_ring *tx_ring) | |
| 2139 | 2140 | { |
| 2140 | 2141 | u8 mac[ETH_ALEN]; |
| 2141 | 2142 | memcpy(&mac, addr, ETH_ALEN); |
| @@ -550,7 +550,8 @@ int qlcnic_83xx_wrt_reg_indirect(struct qlcnic_adapter *, ulong, u32); · 549 unmodified lines | ||
| 550 | 550 | int qlcnic_83xx_nic_set_promisc(struct qlcnic_adapter *, u32); |
| 551 | 551 | int qlcnic_83xx_config_hw_lro(struct qlcnic_adapter *, int); |
| 552 | 552 | int qlcnic_83xx_config_rss(struct qlcnic_adapter *, int); |
| 553 | −void qlcnic_83xx_change_l2_filter(struct qlcnic_adapter *, u64 *, u16); | |
| 553 | +void qlcnic_83xx_change_l2_filter(struct qlcnic_adapter *adapter, u64 *addr, | |
| 554 | + u16 vlan, struct qlcnic_host_tx_ring *ring); | |
| 554 | 555 | int qlcnic_83xx_get_pci_info(struct qlcnic_adapter *, struct qlcnic_pci_info *); |
| 555 | 556 | int qlcnic_83xx_set_nic_info(struct qlcnic_adapter *, struct qlcnic_info *); |
| 556 | 557 | void qlcnic_83xx_initialize_nic(struct qlcnic_adapter *, int); |
| @@ -173,7 +173,8 @@ int qlcnic_82xx_napi_add(struct qlcnic_adapter *adapter, · 172 unmodified lines | ||
| 173 | 173 | struct net_device *netdev); |
| 174 | 174 | void qlcnic_82xx_get_beacon_state(struct qlcnic_adapter *); |
| 175 | 175 | void qlcnic_82xx_change_filter(struct qlcnic_adapter *adapter, |
| 176 | − u64 *uaddr, u16 vlan_id); | |
| 176 | + u64 *uaddr, u16 vlan_id, | |
| 177 | + struct qlcnic_host_tx_ring *tx_ring); | |
| 177 | 178 | int qlcnic_82xx_config_intr_coalesce(struct qlcnic_adapter *, |
| 178 | 179 | struct ethtool_coalesce *); |
| 179 | 180 | int qlcnic_82xx_set_rx_coalesce(struct qlcnic_adapter *); |
| @@ -268,13 +268,12 @@ static void qlcnic_add_lb_filter(struct qlcnic_adapter *adapter, · 267 unmodified lines | ||
| 268 | 268 | } |
| 269 | 269 | |
| 270 | 270 | void qlcnic_82xx_change_filter(struct qlcnic_adapter *adapter, u64 *uaddr, |
| 271 | − u16 vlan_id) | |
| 271 | + u16 vlan_id, struct qlcnic_host_tx_ring *tx_ring) | |
| 272 | 272 | { |
| 273 | 273 | struct cmd_desc_type0 *hwdesc; |
| 274 | 274 | struct qlcnic_nic_req *req; |
| 275 | 275 | struct qlcnic_mac_req *mac_req; |
| 276 | 276 | struct qlcnic_vlan_req *vlan_req; |
| 277 | − struct qlcnic_host_tx_ring *tx_ring = adapter->tx_ring; | |
| 278 | 277 | u32 producer; |
| 279 | 278 | u64 word; |
| 280 | 279 | |
| @@ -301,7 +300,8 @@ void qlcnic_82xx_change_filter(struct qlcnic_adapter *adapter, u64 *uaddr, · 20 unmodified lines | ||
| 301 | 300 | |
| 302 | 301 | static void qlcnic_send_filter(struct qlcnic_adapter *adapter, |
| 303 | 302 | struct cmd_desc_type0 *first_desc, |
| 304 | − struct sk_buff *skb) | |
| 303 | + struct sk_buff *skb, | |
| 304 | + struct qlcnic_host_tx_ring *tx_ring) | |
| 305 | 305 | { |
| 306 | 306 | struct vlan_ethhdr *vh = (struct vlan_ethhdr *)(skb->data); |
| 307 | 307 | struct ethhdr *phdr = (struct ethhdr *)(skb->data); |
| @@ -335,7 +335,7 @@ static void qlcnic_send_filter(struct qlcnic_adapter *adapter, · 27 unmodified lines | ||
| 335 | 335 | tmp_fil->vlan_id == vlan_id) { |
| 336 | 336 | if (jiffies > (QLCNIC_READD_AGE * HZ + tmp_fil->ftime)) |
| 337 | 337 | qlcnic_change_filter(adapter, &src_addr, |
| 338 | − vlan_id); | |
| 338 | + vlan_id, tx_ring); | |
| 339 | 339 | tmp_fil->ftime = jiffies; |
| 340 | 340 | return; |
| 341 | 341 | } |
| @@ -350,7 +350,7 @@ static void qlcnic_send_filter(struct qlcnic_adapter *adapter, · 8 unmodified lines | ||
| 350 | 350 | if (!fil) |
| 351 | 351 | return; |
| 352 | 352 | |
| 353 | − qlcnic_change_filter(adapter, &src_addr, vlan_id); | |
| 353 | + qlcnic_change_filter(adapter, &src_addr, vlan_id, tx_ring); | |
| 354 | 354 | fil->ftime = jiffies; |
| 355 | 355 | fil->vlan_id = vlan_id; |
| 356 | 356 | memcpy(fil->faddr, &src_addr, ETH_ALEN); |
| @@ -766,7 +766,7 @@ netdev_tx_t qlcnic_xmit_frame(struct sk_buff *skb, struct net_device *netdev) · 409 unmodified lines | ||
| 766 | 766 | } |
| 767 | 767 | |
| 768 | 768 | if (adapter->drv_mac_learn) |
| 769 | − qlcnic_send_filter(adapter, first_desc, skb); | |
| 769 | + qlcnic_send_filter(adapter, first_desc, skb, tx_ring); | |
| 770 | 770 | |
| 771 | 771 | tx_ring->tx_stats.tx_bytes += skb->len; |
| 772 | 772 | tx_ring->tx_stats.xmit_called++; |
| @@ -59,9 +59,6 @@ static int qlcnic_close(struct net_device *netdev); · 58 unmodified lines | ||
| 59 | 59 | static void qlcnic_tx_timeout(struct net_device *netdev); |
| 60 | 60 | static void qlcnic_attach_work(struct work_struct *work); |
| 61 | 61 | static void qlcnic_fwinit_work(struct work_struct *work); |
| 62 | −#ifdef CONFIG_NET_POLL_CONTROLLER | |
| 63 | −static void qlcnic_poll_controller(struct net_device *netdev); | |
| 64 | −#endif | |
| 65 | 62 | |
| 66 | 63 | static void qlcnic_idc_debug_info(struct qlcnic_adapter *adapter, u8 encoding); |
| 67 | 64 | static int qlcnic_can_start_firmware(struct qlcnic_adapter *adapter); |
| @@ -545,9 +542,6 @@ static const struct net_device_ops qlcnic_netdev_ops = { · 477 unmodified lines | ||
| 545 | 542 | .ndo_udp_tunnel_add = qlcnic_add_vxlan_port, |
| 546 | 543 | .ndo_udp_tunnel_del = qlcnic_del_vxlan_port, |
| 547 | 544 | .ndo_features_check = qlcnic_features_check, |
| 548 | −#ifdef CONFIG_NET_POLL_CONTROLLER | |
| 549 | − .ndo_poll_controller = qlcnic_poll_controller, | |
| 550 | −#endif | |
| 551 | 545 | #ifdef CONFIG_QLCNIC_SRIOV |
| 552 | 546 | .ndo_set_vf_mac = qlcnic_sriov_set_vf_mac, |
| 553 | 547 | .ndo_set_vf_rate = qlcnic_sriov_set_vf_tx_rate, |
| @@ -3200,45 +3194,6 @@ static irqreturn_t qlcnic_msix_tx_intr(int irq, void *data) · 2646 unmodified lines | ||
| 3200 | 3194 | return IRQ_HANDLED; |
| 3201 | 3195 | } |
| 3202 | 3196 | |
| 3203 | −#ifdef CONFIG_NET_POLL_CONTROLLER | |
| 3204 | −static void qlcnic_poll_controller(struct net_device *netdev) | |
| 3205 | −{ | |
| 3206 | − struct qlcnic_adapter *adapter = netdev_priv(netdev); | |
| 3207 | − struct qlcnic_host_sds_ring *sds_ring; | |
| 3208 | − struct qlcnic_recv_context *recv_ctx; | |
| 3209 | − struct qlcnic_host_tx_ring *tx_ring; | |
| 3210 | − int ring; | |
| 3211 | − | |
| 3212 | − if (!test_bit(__QLCNIC_DEV_UP, &adapter->state)) | |
| 3213 | − return; | |
| 3214 | − | |
| 3215 | − recv_ctx = adapter->recv_ctx; | |
| 3216 | − | |
| 3217 | − for (ring = 0; ring < adapter->drv_sds_rings; ring++) { | |
| 3218 | − sds_ring = &recv_ctx->sds_rings[ring]; | |
| 3219 | − qlcnic_disable_sds_intr(adapter, sds_ring); | |
| 3220 | − napi_schedule(&sds_ring->napi); | |
| 3221 | − } | |
| 3222 | − | |
| 3223 | − if (adapter->flags & QLCNIC_MSIX_ENABLED) { | |
| 3224 | − /* Only Multi-Tx queue capable devices need to | |
| 3225 | − * schedule NAPI for TX rings | |
| 3226 | − */ | |
| 3227 | − if ((qlcnic_83xx_check(adapter) && | |
| 3228 | − (adapter->flags & QLCNIC_TX_INTR_SHARED)) || | |
| 3229 | − (qlcnic_82xx_check(adapter) && | |
| 3230 | − !qlcnic_check_multi_tx(adapter))) | |
| 3231 | − return; | |
| 3232 | − | |
| 3233 | − for (ring = 0; ring < adapter->drv_tx_rings; ring++) { | |
| 3234 | − tx_ring = &adapter->tx_ring[ring]; | |
| 3235 | − qlcnic_disable_tx_intr(adapter, tx_ring); | |
| 3236 | − napi_schedule(&tx_ring->napi); | |
| 3237 | − } | |
| 3238 | − } | |
| 3239 | −} | |
| 3240 | −#endif | |
| 3241 | − | |
| 3242 | 3197 | static void |
| 3243 | 3198 | qlcnic_idc_debug_info(struct qlcnic_adapter *adapter, u8 encoding) |
| 3244 | 3199 | { |
| @@ -113,7 +113,7 @@ rmnet_map_ingress_handler(struct sk_buff *skb, · 112 unmodified lines | ||
| 113 | 113 | struct sk_buff *skbn; |
| 114 | 114 | |
| 115 | 115 | if (skb->dev->type == ARPHRD_ETHER) { |
| 116 | − if (pskb_expand_head(skb, ETH_HLEN, 0, GFP_KERNEL)) { | |
| 116 | + if (pskb_expand_head(skb, ETH_HLEN, 0, GFP_ATOMIC)) { | |
| 117 | 117 | kfree_skb(skb); |
| 118 | 118 | return; |
| 119 | 119 | } |
| @@ -147,7 +147,7 @@ static int rmnet_map_egress_handler(struct sk_buff *skb, · 27 unmodified lines | ||
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | if (skb_headroom(skb) < required_headroom) { |
| 150 | − if (pskb_expand_head(skb, required_headroom, 0, GFP_KERNEL)) | |
| 150 | + if (pskb_expand_head(skb, required_headroom, 0, GFP_ATOMIC)) | |
| 151 | 151 | return -ENOMEM; |
| 152 | 152 | } |
| 153 | 153 | |
| @@ -189,6 +189,9 @@ rx_handler_result_t rmnet_rx_handler(struct sk_buff **pskb) · 35 unmodified lines | ||
| 189 | 189 | if (!skb) |
| 190 | 190 | goto done; |
| 191 | 191 | |
| 192 | + if (skb->pkt_type == PACKET_LOOPBACK) | |
| 193 | + return RX_HANDLER_PASS; | |
| 194 | + | |
| 192 | 195 | dev = skb->dev; |
| 193 | 196 | port = rmnet_get_port(dev); |
| 194 | 197 | |
| @@ -4072,13 +4072,12 @@ static void rtl8169_init_phy(struct net_device *dev, struct rtl8169_private *tp) · 4071 unmodified lines | ||
| 4072 | 4072 | |
| 4073 | 4073 | genphy_soft_reset(dev->phydev); |
| 4074 | 4074 | |
| 4075 | − /* It was reported that chip version 33 ends up with 10MBit/Half on a | |
| 4075 | + /* It was reported that several chips end up with 10MBit/Half on a | |
| 4076 | 4076 | * 1GBit link after resuming from S3. For whatever reason the PHY on |
| 4077 | − * this chip doesn't properly start a renegotiation when soft-reset. | |
| 4077 | + * these chips doesn't properly start a renegotiation when soft-reset. | |
| 4078 | 4078 | * Explicitly requesting a renegotiation fixes this. |
| 4079 | 4079 | */ |
| 4080 | − if (tp->mac_version == RTL_GIGA_MAC_VER_33 && | |
| 4081 | − dev->phydev->autoneg == AUTONEG_ENABLE) | |
| 4080 | + if (dev->phydev->autoneg == AUTONEG_ENABLE) | |
| 4082 | 4081 | phy_restart_aneg(dev->phydev); |
| 4083 | 4082 | } |
| 4084 | 4083 | |
| @@ -4536,9 +4535,14 @@ static void rtl8169_hw_reset(struct rtl8169_private *tp) · 451 unmodified lines | ||
| 4536 | 4535 | |
| 4537 | 4536 | static void rtl_set_tx_config_registers(struct rtl8169_private *tp) |
| 4538 | 4537 | { |
| 4539 | − /* Set DMA burst size and Interframe Gap Time */ | |
| 4540 | − RTL_W32(tp, TxConfig, (TX_DMA_BURST << TxDMAShift) | | |
| 4541 | − (InterFrameGap << TxInterFrameGapShift)); | |
| 4538 | + u32 val = TX_DMA_BURST << TxDMAShift | | |
| 4539 | + InterFrameGap << TxInterFrameGapShift; | |
| 4540 | + | |
| 4541 | + if (tp->mac_version >= RTL_GIGA_MAC_VER_34 && | |
| 4542 | + tp->mac_version != RTL_GIGA_MAC_VER_39) | |
| 4543 | + val |= TXCFG_AUTO_FIFO; | |
| 4544 | + | |
| 4545 | + RTL_W32(tp, TxConfig, val); | |
| 4542 | 4546 | } |
| 4543 | 4547 | |
| 4544 | 4548 | static void rtl_set_rx_max_size(struct rtl8169_private *tp) |
| @@ -5033,7 +5037,6 @@ static void rtl_hw_start_8168e_2(struct rtl8169_private *tp) · 488 unmodified lines | ||
| 5033 | 5037 | |
| 5034 | 5038 | rtl_disable_clock_request(tp); |
| 5035 | 5039 | |
| 5036 | − RTL_W32(tp, TxConfig, RTL_R32(tp, TxConfig) | TXCFG_AUTO_FIFO); | |
| 5037 | 5040 | RTL_W8(tp, MCU, RTL_R8(tp, MCU) & ~NOW_IS_OOB); |
| 5038 | 5041 | |
| 5039 | 5042 | /* Adjust EEE LED frequency */ |
| @@ -5067,7 +5070,6 @@ static void rtl_hw_start_8168f(struct rtl8169_private *tp) · 27 unmodified lines | ||
| 5067 | 5070 | |
| 5068 | 5071 | rtl_disable_clock_request(tp); |
| 5069 | 5072 | |
| 5070 | − RTL_W32(tp, TxConfig, RTL_R32(tp, TxConfig) | TXCFG_AUTO_FIFO); | |
| 5071 | 5073 | RTL_W8(tp, MCU, RTL_R8(tp, MCU) & ~NOW_IS_OOB); |
| 5072 | 5074 | RTL_W8(tp, DLLPR, RTL_R8(tp, DLLPR) | PFM_EN); |
| 5073 | 5075 | RTL_W32(tp, MISC, RTL_R32(tp, MISC) | PWM_EN); |
| @@ -5112,8 +5114,6 @@ static void rtl_hw_start_8411(struct rtl8169_private *tp) · 38 unmodified lines | ||
| 5112 | 5114 | |
| 5113 | 5115 | static void rtl_hw_start_8168g(struct rtl8169_private *tp) |
| 5114 | 5116 | { |
| 5115 | − RTL_W32(tp, TxConfig, RTL_R32(tp, TxConfig) | TXCFG_AUTO_FIFO); | |
| 5116 | − | |
| 5117 | 5117 | rtl_eri_write(tp, 0xc8, ERIAR_MASK_0101, 0x080002, ERIAR_EXGMAC); |
| 5118 | 5118 | rtl_eri_write(tp, 0xcc, ERIAR_MASK_0001, 0x38, ERIAR_EXGMAC); |
| 5119 | 5119 | rtl_eri_write(tp, 0xd0, ERIAR_MASK_0001, 0x48, ERIAR_EXGMAC); |
| @@ -5211,8 +5211,6 @@ static void rtl_hw_start_8168h_1(struct rtl8169_private *tp) · 91 unmodified lines | ||
| 5211 | 5211 | rtl_hw_aspm_clkreq_enable(tp, false); |
| 5212 | 5212 | rtl_ephy_init(tp, e_info_8168h_1, ARRAY_SIZE(e_info_8168h_1)); |
| 5213 | 5213 | |
| 5214 | − RTL_W32(tp, TxConfig, RTL_R32(tp, TxConfig) | TXCFG_AUTO_FIFO); | |
| 5215 | − | |
| 5216 | 5214 | rtl_eri_write(tp, 0xc8, ERIAR_MASK_0101, 0x00080002, ERIAR_EXGMAC); |
| 5217 | 5215 | rtl_eri_write(tp, 0xcc, ERIAR_MASK_0001, 0x38, ERIAR_EXGMAC); |
| 5218 | 5216 | rtl_eri_write(tp, 0xd0, ERIAR_MASK_0001, 0x48, ERIAR_EXGMAC); |
| @@ -5295,8 +5293,6 @@ static void rtl_hw_start_8168ep(struct rtl8169_private *tp) · 76 unmodified lines | ||
| 5295 | 5293 | { |
| 5296 | 5294 | rtl8168ep_stop_cmac(tp); |
| 5297 | 5295 | |
| 5298 | − RTL_W32(tp, TxConfig, RTL_R32(tp, TxConfig) | TXCFG_AUTO_FIFO); | |
| 5299 | − | |
| 5300 | 5296 | rtl_eri_write(tp, 0xc8, ERIAR_MASK_0101, 0x00080002, ERIAR_EXGMAC); |
| 5301 | 5297 | rtl_eri_write(tp, 0xcc, ERIAR_MASK_0001, 0x2f, ERIAR_EXGMAC); |
| 5302 | 5298 | rtl_eri_write(tp, 0xd0, ERIAR_MASK_0001, 0x5f, ERIAR_EXGMAC); |
| @@ -5618,7 +5614,6 @@ static void rtl_hw_start_8402(struct rtl8169_private *tp) · 315 unmodified lines | ||
| 5618 | 5614 | /* Force LAN exit from ASPM if Rx/Tx are not idle */ |
| 5619 | 5615 | RTL_W32(tp, FuncEvent, RTL_R32(tp, FuncEvent) | 0x002800); |
| 5620 | 5616 | |
| 5621 | − RTL_W32(tp, TxConfig, RTL_R32(tp, TxConfig) | TXCFG_AUTO_FIFO); | |
| 5622 | 5617 | RTL_W8(tp, MCU, RTL_R8(tp, MCU) & ~NOW_IS_OOB); |
| 5623 | 5618 | |
| 5624 | 5619 | rtl_ephy_init(tp, e_info_8402, ARRAY_SIZE(e_info_8402)); |
| @@ -6869,8 +6864,10 @@ static int rtl8169_suspend(struct device *device) · 1244 unmodified lines | ||
| 6869 | 6864 | { |
| 6870 | 6865 | struct pci_dev *pdev = to_pci_dev(device); |
| 6871 | 6866 | struct net_device *dev = pci_get_drvdata(pdev); |
| 6867 | + struct rtl8169_private *tp = netdev_priv(dev); | |
| 6872 | 6868 | |
| 6873 | 6869 | rtl8169_net_suspend(dev); |
| 6870 | + clk_disable_unprepare(tp->clk); | |
| 6874 | 6871 | |
| 6875 | 6872 | return 0; |
| 6876 | 6873 | } |
| @@ -6898,6 +6895,9 @@ static int rtl8169_resume(struct device *device) · 21 unmodified lines | ||
| 6898 | 6895 | { |
| 6899 | 6896 | struct pci_dev *pdev = to_pci_dev(device); |
| 6900 | 6897 | struct net_device *dev = pci_get_drvdata(pdev); |
| 6898 | + struct rtl8169_private *tp = netdev_priv(dev); | |
| 6899 | + | |
| 6900 | + clk_prepare_enable(tp->clk); | |
| 6901 | 6901 | |
| 6902 | 6902 | if (netif_running(dev)) |
| 6903 | 6903 | __rtl8169_resume(dev); |
| @@ -2206,29 +2206,6 @@ static void efx_fini_napi(struct efx_nic *efx) · 2205 unmodified lines | ||
| 2206 | 2206 | efx_fini_napi_channel(channel); |
| 2207 | 2207 | } |
| 2208 | 2208 | |
| 2209 | −/************************************************************************** | |
| 2210 | − * | |
| 2211 | − * Kernel netpoll interface | |
| 2212 | − * | |
| 2213 | − *************************************************************************/ | |
| 2214 | − | |
| 2215 | −#ifdef CONFIG_NET_POLL_CONTROLLER | |
| 2216 | − | |
| 2217 | −/* Although in the common case interrupts will be disabled, this is not | |
| 2218 | − * guaranteed. However, all our work happens inside the NAPI callback, | |
| 2219 | − * so no locking is required. | |
| 2220 | − */ | |
| 2221 | −static void efx_netpoll(struct net_device *net_dev) | |
| 2222 | −{ | |
| 2223 | − struct efx_nic *efx = netdev_priv(net_dev); | |
| 2224 | − struct efx_channel *channel; | |
| 2225 | − | |
| 2226 | − efx_for_each_channel(channel, efx) | |
| 2227 | − efx_schedule_channel(channel); | |
| 2228 | −} | |
| 2229 | − | |
| 2230 | −#endif | |
| 2231 | − | |
| 2232 | 2209 | /************************************************************************** |
| 2233 | 2210 | * |
| 2234 | 2211 | * Kernel net device interface |
| @@ -2509,9 +2486,6 @@ static const struct net_device_ops efx_netdev_ops = { · 274 unmodified lines | ||
| 2509 | 2486 | #endif |
| 2510 | 2487 | .ndo_get_phys_port_id = efx_get_phys_port_id, |
| 2511 | 2488 | .ndo_get_phys_port_name = efx_get_phys_port_name, |
| 2512 | −#ifdef CONFIG_NET_POLL_CONTROLLER | |
| 2513 | − .ndo_poll_controller = efx_netpoll, | |
| 2514 | −#endif | |
| 2515 | 2489 | .ndo_setup_tc = efx_setup_tc, |
| 2516 | 2490 | #ifdef CONFIG_RFS_ACCEL |
| 2517 | 2491 | .ndo_rx_flow_steer = efx_filter_rfs, |
| @@ -2052,29 +2052,6 @@ static void ef4_fini_napi(struct ef4_nic *efx) · 2051 unmodified lines | ||
| 2052 | 2052 | ef4_fini_napi_channel(channel); |
| 2053 | 2053 | } |
| 2054 | 2054 | |
| 2055 | −/************************************************************************** | |
| 2056 | − * | |
| 2057 | − * Kernel netpoll interface | |
| 2058 | − * | |
| 2059 | − *************************************************************************/ | |
| 2060 | − | |
| 2061 | −#ifdef CONFIG_NET_POLL_CONTROLLER | |
| 2062 | − | |
| 2063 | −/* Although in the common case interrupts will be disabled, this is not | |
| 2064 | − * guaranteed. However, all our work happens inside the NAPI callback, | |
| 2065 | − * so no locking is required. | |
| 2066 | − */ | |
| 2067 | −static void ef4_netpoll(struct net_device *net_dev) | |
| 2068 | −{ | |
| 2069 | − struct ef4_nic *efx = netdev_priv(net_dev); | |
| 2070 | − struct ef4_channel *channel; | |
| 2071 | − | |
| 2072 | − ef4_for_each_channel(channel, efx) | |
| 2073 | − ef4_schedule_channel(channel); | |
| 2074 | −} | |
| 2075 | − | |
| 2076 | −#endif | |
| 2077 | − | |
| 2078 | 2055 | /************************************************************************** |
| 2079 | 2056 | * |
| 2080 | 2057 | * Kernel net device interface |
| @@ -2250,9 +2227,6 @@ static const struct net_device_ops ef4_netdev_ops = { · 169 unmodified lines | ||
| 2250 | 2227 | .ndo_set_mac_address = ef4_set_mac_address, |
| 2251 | 2228 | .ndo_set_rx_mode = ef4_set_rx_mode, |
| 2252 | 2229 | .ndo_set_features = ef4_set_features, |
| 2253 | −#ifdef CONFIG_NET_POLL_CONTROLLER | |
| 2254 | − .ndo_poll_controller = ef4_netpoll, | |
| 2255 | −#endif | |
| 2256 | 2230 | .ndo_setup_tc = ef4_setup_tc, |
| 2257 | 2231 | #ifdef CONFIG_RFS_ACCEL |
| 2258 | 2232 | .ndo_rx_flow_steer = ef4_filter_rfs, |
| @@ -966,6 +966,8 @@ static int yam_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) · 965 unmodified lines | ||
| 966 | 966 | sizeof(struct yamdrv_ioctl_mcs)); |
| 967 | 967 | if (IS_ERR(ym)) |
| 968 | 968 | return PTR_ERR(ym); |
| 969 | + if (ym->cmd != SIOCYAMSMCS) | |
| 970 | + return -EINVAL; | |
| 969 | 971 | if (ym->bitrate > YAM_MAXBITRATE) { |
| 970 | 972 | kfree(ym); |
| 971 | 973 | return -EINVAL; |
| @@ -981,6 +983,8 @@ static int yam_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) · 9 unmodified lines | ||
| 981 | 983 | if (copy_from_user(&yi, ifr->ifr_data, sizeof(struct yamdrv_ioctl_cfg))) |
| 982 | 984 | return -EFAULT; |
| 983 | 985 | |
| 986 | + if (yi.cmd != SIOCYAMSCFG) | |
| 987 | + return -EINVAL; | |
| 984 | 988 | if ((yi.cfg.mask & YAM_IOBASE) && netif_running(dev)) |
| 985 | 989 | return -EINVAL; /* Cannot change this parameter when up */ |
| 986 | 990 | if ((yi.cfg.mask & YAM_IRQ) && netif_running(dev)) |
| @@ -1308,8 +1308,7 @@ static int adf7242_remove(struct spi_device *spi) · 1307 unmodified lines | ||
| 1308 | 1308 | { |
| 1309 | 1309 | struct adf7242_local *lp = spi_get_drvdata(spi); |
| 1310 | 1310 | |
| 1311 | − if (!IS_ERR_OR_NULL(lp->debugfs_root)) | |
| 1312 | − debugfs_remove_recursive(lp->debugfs_root); | |
| 1311 | + debugfs_remove_recursive(lp->debugfs_root); | |
| 1313 | 1312 | |
| 1314 | 1313 | cancel_delayed_work_sync(&lp->work); |
| 1315 | 1314 | destroy_workqueue(lp->wqueue); |
| @@ -634,10 +634,9 @@ static int ca8210_test_int_driver_write( · 633 unmodified lines | ||
| 634 | 634 | for (i = 0; i < len; i++) |
| 635 | 635 | dev_dbg(&priv->spi->dev, "%#03x\n", buf[i]); |
| 636 | 636 | |
| 637 | − fifo_buffer = kmalloc(len, GFP_KERNEL); | |
| 637 | + fifo_buffer = kmemdup(buf, len, GFP_KERNEL); | |
| 638 | 638 | if (!fifo_buffer) |
| 639 | 639 | return -ENOMEM; |
| 640 | − memcpy(fifo_buffer, buf, len); | |
| 641 | 640 | kfifo_in(&test->up_fifo, &fifo_buffer, 4); |
| 642 | 641 | wake_up_interruptible(&priv->test.readq); |
| 643 | 642 | |
| @@ -3044,8 +3043,7 @@ static void ca8210_test_interface_clear(struct ca8210_priv *priv) · 2400 unmodified lines | ||
| 3044 | 3043 | { |
| 3045 | 3044 | struct ca8210_test *test = &priv->test; |
| 3046 | 3045 | |
| 3047 | − if (!IS_ERR(test->ca8210_dfs_spi_int)) | |
| 3048 | − debugfs_remove(test->ca8210_dfs_spi_int); | |
| 3046 | + debugfs_remove(test->ca8210_dfs_spi_int); | |
| 3049 | 3047 | kfifo_free(&test->up_fifo); |
| 3050 | 3048 | dev_info(&priv->spi->dev, "Test interface removed\n"); |
| 3051 | 3049 | } |
| @@ -903,19 +903,19 @@ mcr20a_irq_clean_complete(void *context) · 902 unmodified lines | ||
| 903 | 903 | |
| 904 | 904 | switch (seq_state) { |
| 905 | 905 | /* TX IRQ, RX IRQ and SEQ IRQ */ |
| 906 | − case (0x03): | |
| 906 | + case (DAR_IRQSTS1_TXIRQ | DAR_IRQSTS1_SEQIRQ): | |
| 907 | 907 | if (lp->is_tx) { |
| 908 | 908 | lp->is_tx = 0; |
| 909 | 909 | dev_dbg(printdev(lp), "TX is done. No ACK\n"); |
| 910 | 910 | mcr20a_handle_tx_complete(lp); |
| 911 | 911 | } |
| 912 | 912 | break; |
| 913 | − case (0x05): | |
| 913 | + case (DAR_IRQSTS1_RXIRQ | DAR_IRQSTS1_SEQIRQ): | |
| 914 | 914 | /* rx is starting */ |
| 915 | 915 | dev_dbg(printdev(lp), "RX is starting\n"); |
| 916 | 916 | mcr20a_handle_rx(lp); |
| 917 | 917 | break; |
| 918 | − case (0x07): | |
| 918 | + case (DAR_IRQSTS1_RXIRQ | DAR_IRQSTS1_TXIRQ | DAR_IRQSTS1_SEQIRQ): | |
| 919 | 919 | if (lp->is_tx) { |
| 920 | 920 | /* tx is done */ |
| 921 | 921 | lp->is_tx = 0; |
| @@ -927,7 +927,7 @@ mcr20a_irq_clean_complete(void *context) · 5 unmodified lines | ||
| 927 | 927 | mcr20a_handle_rx(lp); |
| 928 | 928 | } |
| 929 | 929 | break; |
| 930 | − case (0x01): | |
| 930 | + case (DAR_IRQSTS1_SEQIRQ): | |
| 931 | 931 | if (lp->is_tx) { |
| 932 | 932 | dev_dbg(printdev(lp), "TX is starting\n"); |
| 933 | 933 | mcr20a_handle_tx(lp); |
| @@ -93,7 +93,12 @@ static bool mdio_bus_phy_may_suspend(struct phy_device *phydev) · 92 unmodified lines | ||
| 93 | 93 | if (!netdev) |
| 94 | 94 | return !phydev->suspended; |
| 95 | 95 | |
| 96 | − /* Don't suspend PHY if the attached netdev parent may wakeup. | |
| 96 | + if (netdev->wol_enabled) | |
| 97 | + return false; | |
| 98 | + | |
| 99 | + /* As long as not all affected network drivers support the | |
| 100 | + * wol_enabled flag, let's check for hints that WoL is enabled. | |
| 101 | + * Don't suspend PHY if the attached netdev parent may wake up. | |
| 97 | 102 | * The parent may point to a PCI device, as in tg3 driver. |
| 98 | 103 | */ |
| 99 | 104 | if (netdev->dev.parent && device_may_wakeup(netdev->dev.parent)) |
| @@ -1132,9 +1137,9 @@ void phy_detach(struct phy_device *phydev) · 1032 unmodified lines | ||
| 1132 | 1137 | sysfs_remove_link(&dev->dev.kobj, "phydev"); |
| 1133 | 1138 | sysfs_remove_link(&phydev->mdio.dev.kobj, "attached_dev"); |
| 1134 | 1139 | } |
| 1140 | + phy_suspend(phydev); | |
| 1135 | 1141 | phydev->attached_dev->phydev = NULL; |
| 1136 | 1142 | phydev->attached_dev = NULL; |
| 1137 | − phy_suspend(phydev); | |
| 1138 | 1143 | phydev->phylink = NULL; |
| 1139 | 1144 | |
| 1140 | 1145 | phy_led_triggers_unregister(phydev); |
| @@ -1168,12 +1173,13 @@ EXPORT_SYMBOL(phy_detach); · 27 unmodified lines | ||
| 1168 | 1173 | int phy_suspend(struct phy_device *phydev) |
| 1169 | 1174 | { |
| 1170 | 1175 | struct phy_driver *phydrv = to_phy_driver(phydev->mdio.dev.driver); |
| 1176 | + struct net_device *netdev = phydev->attached_dev; | |
| 1171 | 1177 | struct ethtool_wolinfo wol = { .cmd = ETHTOOL_GWOL }; |
| 1172 | 1178 | int ret = 0; |
| 1173 | 1179 | |
| 1174 | 1180 | /* If the device has WOL enabled, we cannot suspend the PHY */ |
| 1175 | 1181 | phy_ethtool_get_wol(phydev, &wol); |
| 1176 | − if (wol.wolopts) | |
| 1182 | + if (wol.wolopts || (netdev && netdev->wol_enabled)) | |
| 1177 | 1183 | return -EBUSY; |
| 1178 | 1184 | |
| 1179 | 1185 | if (phydev->drv && phydrv->suspend) |
| @@ -717,6 +717,30 @@ static int phylink_bringup_phy(struct phylink *pl, struct phy_device *phy) · 716 unmodified lines | ||
| 717 | 717 | return 0; |
| 718 | 718 | } |
| 719 | 719 | |
| 720 | +static int __phylink_connect_phy(struct phylink *pl, struct phy_device *phy, | |
| 721 | + phy_interface_t interface) | |
| 722 | +{ | |
| 723 | + int ret; | |
| 724 | + | |
| 725 | + if (WARN_ON(pl->link_an_mode == MLO_AN_FIXED || | |
| 726 | + (pl->link_an_mode == MLO_AN_INBAND && | |
| 727 | + phy_interface_mode_is_8023z(interface)))) | |
| 728 | + return -EINVAL; | |
| 729 | + | |
| 730 | + if (pl->phydev) | |
| 731 | + return -EBUSY; | |
| 732 | + | |
| 733 | + ret = phy_attach_direct(pl->netdev, phy, 0, interface); | |
| 734 | + if (ret) | |
| 735 | + return ret; | |
| 736 | + | |
| 737 | + ret = phylink_bringup_phy(pl, phy); | |
| 738 | + if (ret) | |
| 739 | + phy_detach(phy); | |
| 740 | + | |
| 741 | + return ret; | |
| 742 | +} | |
| 743 | + | |
| 720 | 744 | /** |
| 721 | 745 | * phylink_connect_phy() - connect a PHY to the phylink instance |
| 722 | 746 | * @pl: a pointer to a &struct phylink returned from phylink_create() |
| @@ -734,31 +758,13 @@ static int phylink_bringup_phy(struct phylink *pl, struct phy_device *phy) · 11 unmodified lines | ||
| 734 | 758 | */ |
| 735 | 759 | int phylink_connect_phy(struct phylink *pl, struct phy_device *phy) |
| 736 | 760 | { |
| 737 | − int ret; | |
| 738 | − | |
| 739 | − if (WARN_ON(pl->link_an_mode == MLO_AN_FIXED || | |
| 740 | − (pl->link_an_mode == MLO_AN_INBAND && | |
| 741 | − phy_interface_mode_is_8023z(pl->link_interface)))) | |
| 742 | − return -EINVAL; | |
| 743 | − | |
| 744 | − if (pl->phydev) | |
| 745 | − return -EBUSY; | |
| 746 | − | |
| 747 | 761 | /* Use PHY device/driver interface */ |
| 748 | 762 | if (pl->link_interface == PHY_INTERFACE_MODE_NA) { |
| 749 | 763 | pl->link_interface = phy->interface; |
| 750 | 764 | pl->link_config.interface = pl->link_interface; |
| 751 | 765 | } |
| 752 | 766 | |
| 753 | − ret = phy_attach_direct(pl->netdev, phy, 0, pl->link_interface); | |
| 754 | − if (ret) | |
| 755 | − return ret; | |
| 756 | − | |
| 757 | − ret = phylink_bringup_phy(pl, phy); | |
| 758 | − if (ret) | |
| 759 | − phy_detach(phy); | |
| 760 | − | |
| 761 | − return ret; | |
| 767 | + return __phylink_connect_phy(pl, phy, pl->link_interface); | |
| 762 | 768 | } |
| 763 | 769 | EXPORT_SYMBOL_GPL(phylink_connect_phy); |
| 764 | 770 | |
| @@ -1672,7 +1678,9 @@ static void phylink_sfp_link_up(void *upstream) · 907 unmodified lines | ||
| 1672 | 1678 | |
| 1673 | 1679 | static int phylink_sfp_connect_phy(void *upstream, struct phy_device *phy) |
| 1674 | 1680 | { |
| 1675 | − return phylink_connect_phy(upstream, phy); | |
| 1681 | + struct phylink *pl = upstream; | |
| 1682 | + | |
| 1683 | + return __phylink_connect_phy(upstream, phy, pl->link_config.interface); | |
| 1676 | 1684 | } |
| 1677 | 1685 | |
| 1678 | 1686 | static void phylink_sfp_disconnect_phy(void *upstream) |
| @@ -1098,8 +1098,11 @@ static int sfp_hwmon_insert(struct sfp *sfp) · 1097 unmodified lines | ||
| 1098 | 1098 | |
| 1099 | 1099 | static void sfp_hwmon_remove(struct sfp *sfp) |
| 1100 | 1100 | { |
| 1101 | − hwmon_device_unregister(sfp->hwmon_dev); | |
| 1102 | − kfree(sfp->hwmon_name); | |
| 1101 | + if (!IS_ERR_OR_NULL(sfp->hwmon_dev)) { | |
| 1102 | + hwmon_device_unregister(sfp->hwmon_dev); | |
| 1103 | + sfp->hwmon_dev = NULL; | |
| 1104 | + kfree(sfp->hwmon_name); | |
| 1105 | + } | |
| 1103 | 1106 | } |
| 1104 | 1107 | #else |
| 1105 | 1108 | static int sfp_hwmon_insert(struct sfp *sfp) |
| @@ -1167,6 +1167,12 @@ static int team_port_add(struct team *team, struct net_device *port_dev, · 1166 unmodified lines | ||
| 1167 | 1167 | return -EBUSY; |
| 1168 | 1168 | } |
| 1169 | 1169 | |
| 1170 | + if (dev == port_dev) { | |
| 1171 | + NL_SET_ERR_MSG(extack, "Cannot enslave team device to itself"); | |
| 1172 | + netdev_err(dev, "Cannot enslave team device to itself\n"); | |
| 1173 | + return -EINVAL; | |
| 1174 | + } | |
| 1175 | + | |
| 1170 | 1176 | if (port_dev->features & NETIF_F_VLAN_CHALLENGED && |
| 1171 | 1177 | vlan_uses_dev(dev)) { |
| 1172 | 1178 | NL_SET_ERR_MSG(extack, "Device is VLAN challenged and team device has VLAN set up"); |
| @@ -181,6 +181,7 @@ struct tun_file { · 180 unmodified lines | ||
| 181 | 181 | }; |
| 182 | 182 | struct napi_struct napi; |
| 183 | 183 | bool napi_enabled; |
| 184 | + bool napi_frags_enabled; | |
| 184 | 185 | struct mutex napi_mutex; /* Protects access to the above napi */ |
| 185 | 186 | struct list_head next; |
| 186 | 187 | struct tun_struct *detached; |
| @@ -313,32 +314,32 @@ static int tun_napi_poll(struct napi_struct *napi, int budget) · 126 unmodified lines | ||
| 313 | 314 | } |
| 314 | 315 | |
| 315 | 316 | static void tun_napi_init(struct tun_struct *tun, struct tun_file *tfile, |
| 316 | − bool napi_en) | |
| 317 | + bool napi_en, bool napi_frags) | |
| 317 | 318 | { |
| 318 | 319 | tfile->napi_enabled = napi_en; |
| 320 | + tfile->napi_frags_enabled = napi_en && napi_frags; | |
| 319 | 321 | if (napi_en) { |
| 320 | 322 | netif_napi_add(tun->dev, &tfile->napi, tun_napi_poll, |
| 321 | 323 | NAPI_POLL_WEIGHT); |
| 322 | 324 | napi_enable(&tfile->napi); |
| 323 | − mutex_init(&tfile->napi_mutex); | |
| 324 | 325 | } |
| 325 | 326 | } |
| 326 | 327 | |
| 327 | −static void tun_napi_disable(struct tun_struct *tun, struct tun_file *tfile) | |
| 328 | +static void tun_napi_disable(struct tun_file *tfile) | |
| 328 | 329 | { |
| 329 | 330 | if (tfile->napi_enabled) |
| 330 | 331 | napi_disable(&tfile->napi); |
| 331 | 332 | } |
| 332 | 333 | |
| 333 | −static void tun_napi_del(struct tun_struct *tun, struct tun_file *tfile) | |
| 334 | +static void tun_napi_del(struct tun_file *tfile) | |
| 334 | 335 | { |
| 335 | 336 | if (tfile->napi_enabled) |
| 336 | 337 | netif_napi_del(&tfile->napi); |
| 337 | 338 | } |
| 338 | 339 | |
| 339 | −static bool tun_napi_frags_enabled(const struct tun_struct *tun) | |
| 340 | +static bool tun_napi_frags_enabled(const struct tun_file *tfile) | |
| 340 | 341 | { |
| 341 | − return READ_ONCE(tun->flags) & IFF_NAPI_FRAGS; | |
| 342 | + return tfile->napi_frags_enabled; | |
| 342 | 343 | } |
| 343 | 344 | |
| 344 | 345 | #ifdef CONFIG_TUN_VNET_CROSS_LE |
| @@ -690,8 +691,8 @@ static void __tun_detach(struct tun_file *tfile, bool clean) · 345 unmodified lines | ||
| 690 | 691 | tun = rtnl_dereference(tfile->tun); |
| 691 | 692 | |
| 692 | 693 | if (tun && clean) { |
| 693 | − tun_napi_disable(tun, tfile); | |
| 694 | − tun_napi_del(tun, tfile); | |
| 694 | + tun_napi_disable(tfile); | |
| 695 | + tun_napi_del(tfile); | |
| 695 | 696 | } |
| 696 | 697 | |
| 697 | 698 | if (tun && !tfile->detached) { |
| @@ -758,7 +759,7 @@ static void tun_detach_all(struct net_device *dev) · 60 unmodified lines | ||
| 758 | 759 | for (i = 0; i < n; i++) { |
| 759 | 760 | tfile = rtnl_dereference(tun->tfiles[i]); |
| 760 | 761 | BUG_ON(!tfile); |
| 761 | − tun_napi_disable(tun, tfile); | |
| 762 | + tun_napi_disable(tfile); | |
| 762 | 763 | tfile->socket.sk->sk_shutdown = RCV_SHUTDOWN; |
| 763 | 764 | tfile->socket.sk->sk_data_ready(tfile->socket.sk); |
| 764 | 765 | RCU_INIT_POINTER(tfile->tun, NULL); |
| @@ -774,7 +775,7 @@ static void tun_detach_all(struct net_device *dev) · 9 unmodified lines | ||
| 774 | 775 | synchronize_net(); |
| 775 | 776 | for (i = 0; i < n; i++) { |
| 776 | 777 | tfile = rtnl_dereference(tun->tfiles[i]); |
| 777 | − tun_napi_del(tun, tfile); | |
| 778 | + tun_napi_del(tfile); | |
| 778 | 779 | /* Drop read queue */ |
| 779 | 780 | tun_queue_purge(tfile); |
| 780 | 781 | xdp_rxq_info_unreg(&tfile->xdp_rxq); |
| @@ -793,7 +794,7 @@ static void tun_detach_all(struct net_device *dev) · 12 unmodified lines | ||
| 793 | 794 | } |
| 794 | 795 | |
| 795 | 796 | static int tun_attach(struct tun_struct *tun, struct file *file, |
| 796 | − bool skip_filter, bool napi) | |
| 797 | + bool skip_filter, bool napi, bool napi_frags) | |
| 797 | 798 | { |
| 798 | 799 | struct tun_file *tfile = file->private_data; |
| 799 | 800 | struct net_device *dev = tun->dev; |
| @@ -866,7 +867,7 @@ static int tun_attach(struct tun_struct *tun, struct file *file, · 66 unmodified lines | ||
| 866 | 867 | tun_enable_queue(tfile); |
| 867 | 868 | } else { |
| 868 | 869 | sock_hold(&tfile->sk); |
| 869 | − tun_napi_init(tun, tfile, napi); | |
| 870 | + tun_napi_init(tun, tfile, napi, napi_frags); | |
| 870 | 871 | } |
| 871 | 872 | |
| 872 | 873 | tun_set_real_num_queues(tun); |
| @@ -1709,7 +1710,7 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile, · 836 unmodified lines | ||
| 1709 | 1710 | int err; |
| 1710 | 1711 | u32 rxhash = 0; |
| 1711 | 1712 | int skb_xdp = 1; |
| 1712 | − bool frags = tun_napi_frags_enabled(tun); | |
| 1713 | + bool frags = tun_napi_frags_enabled(tfile); | |
| 1713 | 1714 | |
| 1714 | 1715 | if (!(tun->dev->flags & IFF_UP)) |
| 1715 | 1716 | return -EIO; |
| @@ -2534,7 +2535,8 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr) · 818 unmodified lines | ||
| 2534 | 2535 | return err; |
| 2535 | 2536 | |
| 2536 | 2537 | err = tun_attach(tun, file, ifr->ifr_flags & IFF_NOFILTER, |
| 2537 | − ifr->ifr_flags & IFF_NAPI); | |
| 2538 | + ifr->ifr_flags & IFF_NAPI, | |
| 2539 | + ifr->ifr_flags & IFF_NAPI_FRAGS); | |
| 2538 | 2540 | if (err < 0) |
| 2539 | 2541 | return err; |
| 2540 | 2542 | |
| @@ -2632,7 +2634,8 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr) · 91 unmodified lines | ||
| 2632 | 2634 | (ifr->ifr_flags & TUN_FEATURES); |
| 2633 | 2635 | |
| 2634 | 2636 | INIT_LIST_HEAD(&tun->disabled); |
| 2635 | − err = tun_attach(tun, file, false, ifr->ifr_flags & IFF_NAPI); | |
| 2637 | + err = tun_attach(tun, file, false, ifr->ifr_flags & IFF_NAPI, | |
| 2638 | + ifr->ifr_flags & IFF_NAPI_FRAGS); | |
| 2636 | 2639 | if (err < 0) |
| 2637 | 2640 | goto err_free_flow; |
| 2638 | 2641 | |
| @@ -2781,7 +2784,8 @@ static int tun_set_queue(struct file *file, struct ifreq *ifr) · 142 unmodified lines | ||
| 2781 | 2784 | ret = security_tun_dev_attach_queue(tun->security); |
| 2782 | 2785 | if (ret < 0) |
| 2783 | 2786 | goto unlock; |
| 2784 | − ret = tun_attach(tun, file, false, tun->flags & IFF_NAPI); | |
| 2787 | + ret = tun_attach(tun, file, false, tun->flags & IFF_NAPI, | |
| 2788 | + tun->flags & IFF_NAPI_FRAGS); | |
| 2785 | 2789 | } else if (ifr->ifr_flags & IFF_DETACH_QUEUE) { |
| 2786 | 2790 | tun = rtnl_dereference(tfile->tun); |
| 2787 | 2791 | if (!tun || !(tun->flags & IFF_MULTI_QUEUE) || tfile->detached) |
| @@ -3199,6 +3203,7 @@ static int tun_chr_open(struct inode *inode, struct file * file) · 411 unmodified lines | ||
| 3199 | 3203 | return -ENOMEM; |
| 3200 | 3204 | } |
| 3201 | 3205 | |
| 3206 | + mutex_init(&tfile->napi_mutex); | |
| 3202 | 3207 | RCU_INIT_POINTER(tfile->tun, NULL); |
| 3203 | 3208 | tfile->flags = 0; |
| 3204 | 3209 | tfile->ifindex = 0; |
| @@ -607,6 +607,9 @@ int asix_set_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo) · 606 unmodified lines | ||
| 607 | 607 | struct usbnet *dev = netdev_priv(net); |
| 608 | 608 | u8 opt = 0; |
| 609 | 609 | |
| 610 | + if (wolinfo->wolopts & ~(WAKE_PHY | WAKE_MAGIC)) | |
| 611 | + return -EINVAL; | |
| 612 | + | |
| 610 | 613 | if (wolinfo->wolopts & WAKE_PHY) |
| 611 | 614 | opt |= AX_MONITOR_LINK; |
| 612 | 615 | if (wolinfo->wolopts & WAKE_MAGIC) |
| @@ -566,6 +566,9 @@ ax88179_set_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo) · 565 unmodified lines | ||
| 566 | 566 | struct usbnet *dev = netdev_priv(net); |
| 567 | 567 | u8 opt = 0; |
| 568 | 568 | |
| 569 | + if (wolinfo->wolopts & ~(WAKE_PHY | WAKE_MAGIC)) | |
| 570 | + return -EINVAL; | |
| 571 | + | |
| 569 | 572 | if (wolinfo->wolopts & WAKE_PHY) |
| 570 | 573 | opt |= AX_MONITOR_MODE_RWLC; |
| 571 | 574 | if (wolinfo->wolopts & WAKE_MAGIC) |
| @@ -1401,19 +1401,10 @@ static int lan78xx_set_wol(struct net_device *netdev, · 1400 unmodified lines | ||
| 1401 | 1401 | if (ret < 0) |
| 1402 | 1402 | return ret; |
| 1403 | 1403 | |
| 1404 | − pdata->wol = 0; | |
| 1405 | − if (wol->wolopts & WAKE_UCAST) | |
| 1406 | − pdata->wol |= WAKE_UCAST; | |
| 1407 | − if (wol->wolopts & WAKE_MCAST) | |
| 1408 | − pdata->wol |= WAKE_MCAST; | |
| 1409 | − if (wol->wolopts & WAKE_BCAST) | |
| 1410 | − pdata->wol |= WAKE_BCAST; | |
| 1411 | − if (wol->wolopts & WAKE_MAGIC) | |
| 1412 | − pdata->wol |= WAKE_MAGIC; | |
| 1413 | − if (wol->wolopts & WAKE_PHY) | |
| 1414 | − pdata->wol |= WAKE_PHY; | |
| 1415 | − if (wol->wolopts & WAKE_ARP) | |
| 1416 | − pdata->wol |= WAKE_ARP; | |
| 1404 | + if (wol->wolopts & ~WAKE_ALL) | |
| 1405 | + return -EINVAL; | |
| 1406 | + | |
| 1407 | + pdata->wol = wol->wolopts; | |
| 1417 | 1408 | |
| 1418 | 1409 | device_set_wakeup_enable(&dev->udev->dev, (bool)wol->wolopts); |
| 1419 | 1410 | |
| @@ -4506,6 +4506,9 @@ static int rtl8152_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol) · 4505 unmodified lines | ||
| 4506 | 4506 | if (!rtl_can_wakeup(tp)) |
| 4507 | 4507 | return -EOPNOTSUPP; |
| 4508 | 4508 | |
| 4509 | + if (wol->wolopts & ~WAKE_ANY) | |
| 4510 | + return -EINVAL; | |
| 4511 | + | |
| 4509 | 4512 | ret = usb_autopm_get_interface(tp->intf); |
| 4510 | 4513 | if (ret < 0) |
| 4511 | 4514 | goto out_set_wol; |
| @@ -731,6 +731,9 @@ static int smsc75xx_ethtool_set_wol(struct net_device *net, · 730 unmodified lines | ||
| 731 | 731 | struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]); |
| 732 | 732 | int ret; |
| 733 | 733 | |
| 734 | + if (wolinfo->wolopts & ~SUPPORTED_WAKE) | |
| 735 | + return -EINVAL; | |
| 736 | + | |
| 734 | 737 | pdata->wolopts = wolinfo->wolopts & SUPPORTED_WAKE; |
| 735 | 738 | |
| 736 | 739 | ret = device_set_wakeup_enable(&dev->udev->dev, pdata->wolopts); |
| @@ -1517,6 +1520,7 @@ static void smsc75xx_unbind(struct usbnet *dev, struct usb_interface *intf) · 780 unmodified lines | ||
| 1517 | 1520 | { |
| 1518 | 1521 | struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]); |
| 1519 | 1522 | if (pdata) { |
| 1523 | + cancel_work_sync(&pdata->set_multicast); | |
| 1520 | 1524 | netif_dbg(dev, ifdown, dev->net, "free pdata\n"); |
| 1521 | 1525 | kfree(pdata); |
| 1522 | 1526 | pdata = NULL; |
| @@ -774,6 +774,9 @@ static int smsc95xx_ethtool_set_wol(struct net_device *net, · 773 unmodified lines | ||
| 774 | 774 | struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); |
| 775 | 775 | int ret; |
| 776 | 776 | |
| 777 | + if (wolinfo->wolopts & ~SUPPORTED_WAKE) | |
| 778 | + return -EINVAL; | |
| 779 | + | |
| 777 | 780 | pdata->wolopts = wolinfo->wolopts & SUPPORTED_WAKE; |
| 778 | 781 | |
| 779 | 782 | ret = device_set_wakeup_enable(&dev->udev->dev, pdata->wolopts); |
| @@ -421,6 +421,9 @@ sr_set_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo) · 420 unmodified lines | ||
| 421 | 421 | struct usbnet *dev = netdev_priv(net); |
| 422 | 422 | u8 opt = 0; |
| 423 | 423 | |
| 424 | + if (wolinfo->wolopts & ~(WAKE_PHY | WAKE_MAGIC)) | |
| 425 | + return -EINVAL; | |
| 426 | + | |
| 424 | 427 | if (wolinfo->wolopts & WAKE_PHY) |
| 425 | 428 | opt |= SR_MONITOR_LINK; |
| 426 | 429 | if (wolinfo->wolopts & WAKE_MAGIC) |
| @@ -1699,17 +1699,6 @@ static void virtnet_stats(struct net_device *dev, · 1698 unmodified lines | ||
| 1699 | 1699 | tot->rx_frame_errors = dev->stats.rx_frame_errors; |
| 1700 | 1700 | } |
| 1701 | 1701 | |
| 1702 | −#ifdef CONFIG_NET_POLL_CONTROLLER | |
| 1703 | −static void virtnet_netpoll(struct net_device *dev) | |
| 1704 | −{ | |
| 1705 | − struct virtnet_info *vi = netdev_priv(dev); | |
| 1706 | − int i; | |
| 1707 | − | |
| 1708 | − for (i = 0; i < vi->curr_queue_pairs; i++) | |
| 1709 | − napi_schedule(&vi->rq[i].napi); | |
| 1710 | −} | |
| 1711 | −#endif | |
| 1712 | − | |
| 1713 | 1702 | static void virtnet_ack_link_announce(struct virtnet_info *vi) |
| 1714 | 1703 | { |
| 1715 | 1704 | rtnl_lock(); |
| @@ -2447,9 +2436,6 @@ static const struct net_device_ops virtnet_netdev = { · 731 unmodified lines | ||
| 2447 | 2436 | .ndo_get_stats64 = virtnet_stats, |
| 2448 | 2437 | .ndo_vlan_rx_add_vid = virtnet_vlan_rx_add_vid, |
| 2449 | 2438 | .ndo_vlan_rx_kill_vid = virtnet_vlan_rx_kill_vid, |
| 2450 | −#ifdef CONFIG_NET_POLL_CONTROLLER | |
| 2451 | − .ndo_poll_controller = virtnet_netpoll, | |
| 2452 | −#endif | |
| 2453 | 2439 | .ndo_bpf = virtnet_xdp, |
| 2454 | 2440 | .ndo_xdp_xmit = virtnet_xdp_xmit, |
| 2455 | 2441 | .ndo_features_check = passthru_features_check, |
| @@ -3539,6 +3539,7 @@ static size_t vxlan_get_size(const struct net_device *dev) · 3538 unmodified lines | ||
| 3539 | 3539 | nla_total_size(sizeof(__u32)) + /* IFLA_VXLAN_LINK */ |
| 3540 | 3540 | nla_total_size(sizeof(struct in6_addr)) + /* IFLA_VXLAN_LOCAL{6} */ |
| 3541 | 3541 | nla_total_size(sizeof(__u8)) + /* IFLA_VXLAN_TTL */ |
| 3542 | + nla_total_size(sizeof(__u8)) + /* IFLA_VXLAN_TTL_INHERIT */ | |
| 3542 | 3543 | nla_total_size(sizeof(__u8)) + /* IFLA_VXLAN_TOS */ |
| 3543 | 3544 | nla_total_size(sizeof(__be32)) + /* IFLA_VXLAN_LABEL */ |
| 3544 | 3545 | nla_total_size(sizeof(__u8)) + /* IFLA_VXLAN_LEARNING */ |
| @@ -3603,6 +3604,8 @@ static int vxlan_fill_info(struct sk_buff *skb, const struct net_device *dev) · 58 unmodified lines | ||
| 3603 | 3604 | } |
| 3604 | 3605 | |
| 3605 | 3606 | if (nla_put_u8(skb, IFLA_VXLAN_TTL, vxlan->cfg.ttl) || |
| 3607 | + nla_put_u8(skb, IFLA_VXLAN_TTL_INHERIT, | |
| 3608 | + !!(vxlan->cfg.flags & VXLAN_F_TTL_INHERIT)) || | |
| 3606 | 3609 | nla_put_u8(skb, IFLA_VXLAN_TOS, vxlan->cfg.tos) || |
| 3607 | 3610 | nla_put_be32(skb, IFLA_VXLAN_LABEL, vxlan->cfg.label) || |
| 3608 | 3611 | nla_put_u8(skb, IFLA_VXLAN_LEARNING, |
| @@ -257,7 +257,7 @@ static const struct · 256 unmodified lines | ||
| 257 | 257 | [I2400M_MS_ACCESSIBILITY_ERROR] = { "accesibility error", -EIO }, |
| 258 | 258 | [I2400M_MS_BUSY] = { "busy", -EBUSY }, |
| 259 | 259 | [I2400M_MS_CORRUPTED_TLV] = { "corrupted TLV", -EILSEQ }, |
| 260 | − [I2400M_MS_UNINITIALIZED] = { "not unitialized", -EILSEQ }, | |
| 260 | + [I2400M_MS_UNINITIALIZED] = { "uninitialized", -EILSEQ }, | |
| 261 | 261 | [I2400M_MS_UNKNOWN_ERROR] = { "unknown error", -EIO }, |
| 262 | 262 | [I2400M_MS_PRODUCTION_ERROR] = { "production error", -EIO }, |
| 263 | 263 | [I2400M_MS_NO_RF] = { "no RF", -EIO }, |
| @@ -1518,13 +1518,15 @@ void b43_dma_handle_txstatus(struct b43_wldev *dev, · 1517 unmodified lines | ||
| 1518 | 1518 | } |
| 1519 | 1519 | } else { |
| 1520 | 1520 | /* More than a single header/data pair were missed. |
| 1521 | − * Report this error, and reset the controller to | |
| 1521 | + * Report this error. If running with open-source | |
| 1522 | + * firmware, then reset the controller to | |
| 1522 | 1523 | * revive operation. |
| 1523 | 1524 | */ |
| 1524 | 1525 | b43dbg(dev->wl, |
| 1525 | 1526 | "Out of order TX status report on DMA ring %d. Expected %d, but got %d\n", |
| 1526 | 1527 | ring->index, firstused, slot); |
| 1527 | − b43_controller_restart(dev, "Out of order TX"); | |
| 1528 | + if (dev->fw.opensource) | |
| 1529 | + b43_controller_restart(dev, "Out of order TX"); | |
| 1528 | 1530 | return; |
| 1529 | 1531 | } |
| 1530 | 1532 | } |
| @@ -51,6 +51,7 @@ · 50 unmodified lines | ||
| 51 | 51 | |
| 52 | 52 | static const struct iwl_base_params iwl1000_base_params = { |
| 53 | 53 | .num_of_queues = IWLAGN_NUM_QUEUES, |
| 54 | + .max_tfd_queue_size = 256, | |
| 54 | 55 | .eeprom_size = OTP_LOW_IMAGE_SIZE, |
| 55 | 56 | .pll_cfg = true, |
| 56 | 57 | .max_ll_items = OTP_MAX_LL_ITEMS_1000, |
| @@ -520,7 +520,6 @@ struct mac80211_hwsim_data { · 519 unmodified lines | ||
| 520 | 520 | int channels, idx; |
| 521 | 521 | bool use_chanctx; |
| 522 | 522 | bool destroy_on_close; |
| 523 | − struct work_struct destroy_work; | |
| 524 | 523 | u32 portid; |
| 525 | 524 | char alpha2[2]; |
| 526 | 525 | const struct ieee80211_regdomain *regd; |
| @@ -2935,8 +2934,7 @@ static int mac80211_hwsim_new_radio(struct genl_info *info, · 2408 unmodified lines | ||
| 2935 | 2934 | hwsim_radios_generation++; |
| 2936 | 2935 | spin_unlock_bh(&hwsim_radio_lock); |
| 2937 | 2936 | |
| 2938 | − if (idx > 0) | |
| 2939 | − hwsim_mcast_new_radio(idx, info, param); | |
| 2937 | + hwsim_mcast_new_radio(idx, info, param); | |
| 2940 | 2938 | |
| 2941 | 2939 | return idx; |
| 2942 | 2940 | |
| @@ -3565,30 +3563,27 @@ static struct genl_family hwsim_genl_family __ro_after_init = { · 622 unmodified lines | ||
| 3565 | 3563 | .n_mcgrps = ARRAY_SIZE(hwsim_mcgrps), |
| 3566 | 3564 | }; |
| 3567 | 3565 | |
| 3568 | −static void destroy_radio(struct work_struct *work) | |
| 3569 | −{ | |
| 3570 | − struct mac80211_hwsim_data *data = | |
| 3571 | − container_of(work, struct mac80211_hwsim_data, destroy_work); | |
| 3572 | − | |
| 3573 | − hwsim_radios_generation++; | |
| 3574 | − mac80211_hwsim_del_radio(data, wiphy_name(data->hw->wiphy), NULL); | |
| 3575 | −} | |
| 3576 | − | |
| 3577 | 3566 | static void remove_user_radios(u32 portid) |
| 3578 | 3567 | { |
| 3579 | 3568 | struct mac80211_hwsim_data *entry, *tmp; |
| 3569 | + LIST_HEAD(list); | |
| 3580 | 3570 | |
| 3581 | 3571 | spin_lock_bh(&hwsim_radio_lock); |
| 3582 | 3572 | list_for_each_entry_safe(entry, tmp, &hwsim_radios, list) { |
| 3583 | 3573 | if (entry->destroy_on_close && entry->portid == portid) { |
| 3584 | − list_del(&entry->list); | |
| 3574 | + list_move(&entry->list, &list); | |
| 3585 | 3575 | rhashtable_remove_fast(&hwsim_radios_rht, &entry->rht, |
| 3586 | 3576 | hwsim_rht_params); |
| 3587 | − INIT_WORK(&entry->destroy_work, destroy_radio); | |
| 3588 | − queue_work(hwsim_wq, &entry->destroy_work); | |
| 3577 | + hwsim_radios_generation++; | |
| 3589 | 3578 | } |
| 3590 | 3579 | } |
| 3591 | 3580 | spin_unlock_bh(&hwsim_radio_lock); |
| 3581 | + | |
| 3582 | + list_for_each_entry_safe(entry, tmp, &list, list) { | |
| 3583 | + list_del(&entry->list); | |
| 3584 | + mac80211_hwsim_del_radio(entry, wiphy_name(entry->hw->wiphy), | |
| 3585 | + NULL); | |
| 3586 | + } | |
| 3592 | 3587 | } |
| 3593 | 3588 | |
| 3594 | 3589 | static int mac80211_hwsim_netlink_notify(struct notifier_block *nb, |
| @@ -3646,6 +3641,7 @@ static __net_init int hwsim_init_net(struct net *net) · 51 unmodified lines | ||
| 3646 | 3641 | static void __net_exit hwsim_exit_net(struct net *net) |
| 3647 | 3642 | { |
| 3648 | 3643 | struct mac80211_hwsim_data *data, *tmp; |
| 3644 | + LIST_HEAD(list); | |
| 3649 | 3645 | |
| 3650 | 3646 | spin_lock_bh(&hwsim_radio_lock); |
| 3651 | 3647 | list_for_each_entry_safe(data, tmp, &hwsim_radios, list) { |
| @@ -3656,17 +3652,19 @@ static void __net_exit hwsim_exit_net(struct net *net) · 4 unmodified lines | ||
| 3656 | 3652 | if (data->netgroup == hwsim_net_get_netgroup(&init_net)) |
| 3657 | 3653 | continue; |
| 3658 | 3654 | |
| 3659 | − list_del(&data->list); | |
| 3655 | + list_move(&data->list, &list); | |
| 3660 | 3656 | rhashtable_remove_fast(&hwsim_radios_rht, &data->rht, |
| 3661 | 3657 | hwsim_rht_params); |
| 3662 | 3658 | hwsim_radios_generation++; |
| 3663 | − spin_unlock_bh(&hwsim_radio_lock); | |
| 3659 | + } | |
| 3660 | + spin_unlock_bh(&hwsim_radio_lock); | |
| 3661 | + | |
| 3662 | + list_for_each_entry_safe(data, tmp, &list, list) { | |
| 3663 | + list_del(&data->list); | |
| 3664 | 3664 | mac80211_hwsim_del_radio(data, |
| 3665 | 3665 | wiphy_name(data->hw->wiphy), |
| 3666 | 3666 | NULL); |
| 3667 | − spin_lock_bh(&hwsim_radio_lock); | |
| 3668 | 3667 | } |
| 3669 | − spin_unlock_bh(&hwsim_radio_lock); | |
| 3670 | 3668 | |
| 3671 | 3669 | ida_simple_remove(&hwsim_netgroup_ida, hwsim_net_get_netgroup(net)); |
| 3672 | 3670 | } |
| @@ -77,9 +77,8 @@ static void mt76x0_remove_interface(struct ieee80211_hw *hw, · 76 unmodified lines | ||
| 77 | 77 | { |
| 78 | 78 | struct mt76x0_dev *dev = hw->priv; |
| 79 | 79 | struct mt76_vif *mvif = (struct mt76_vif *) vif->drv_priv; |
| 80 | − unsigned int wcid = mvif->group_wcid.idx; | |
| 81 | 80 | |
| 82 | − dev->wcid_mask[wcid / BITS_PER_LONG] &= ~BIT(wcid % BITS_PER_LONG); | |
| 81 | + dev->vif_mask &= ~BIT(mvif->idx); | |
| 83 | 82 | } |
| 84 | 83 | |
| 85 | 84 | static int mt76x0_config(struct ieee80211_hw *hw, u32 changed) |
| @@ -241,8 +241,9 @@ struct xenvif_hash_cache { · 240 unmodified lines | ||
| 241 | 241 | struct xenvif_hash { |
| 242 | 242 | unsigned int alg; |
| 243 | 243 | u32 flags; |
| 244 | + bool mapping_sel; | |
| 244 | 245 | u8 key[XEN_NETBK_MAX_HASH_KEY_SIZE]; |
| 245 | − u32 mapping[XEN_NETBK_MAX_HASH_MAPPING_SIZE]; | |
| 246 | + u32 mapping[2][XEN_NETBK_MAX_HASH_MAPPING_SIZE]; | |
| 246 | 247 | unsigned int size; |
| 247 | 248 | struct xenvif_hash_cache cache; |
| 248 | 249 | }; |
| @@ -324,7 +324,8 @@ u32 xenvif_set_hash_mapping_size(struct xenvif *vif, u32 size) · 323 unmodified lines | ||
| 324 | 324 | return XEN_NETIF_CTRL_STATUS_INVALID_PARAMETER; |
| 325 | 325 | |
| 326 | 326 | vif->hash.size = size; |
| 327 | − memset(vif->hash.mapping, 0, sizeof(u32) * size); | |
| 327 | + memset(vif->hash.mapping[vif->hash.mapping_sel], 0, | |
| 328 | + sizeof(u32) * size); | |
| 328 | 329 | |
| 329 | 330 | return XEN_NETIF_CTRL_STATUS_SUCCESS; |
| 330 | 331 | } |
| @@ -332,31 +333,49 @@ u32 xenvif_set_hash_mapping_size(struct xenvif *vif, u32 size) · 1 unmodified line | ||
| 332 | 333 | u32 xenvif_set_hash_mapping(struct xenvif *vif, u32 gref, u32 len, |
| 333 | 334 | u32 off) |
| 334 | 335 | { |
| 335 | − u32 *mapping = &vif->hash.mapping[off]; | |
| 336 | − struct gnttab_copy copy_op = { | |
| 336 | + u32 *mapping = vif->hash.mapping[!vif->hash.mapping_sel]; | |
| 337 | + unsigned int nr = 1; | |
| 338 | + struct gnttab_copy copy_op[2] = {{ | |
| 337 | 339 | .source.u.ref = gref, |
| 338 | 340 | .source.domid = vif->domid, |
| 339 | − .dest.u.gmfn = virt_to_gfn(mapping), | |
| 340 | 341 | .dest.domid = DOMID_SELF, |
| 341 | − .dest.offset = xen_offset_in_page(mapping), | |
| 342 | − .len = len * sizeof(u32), | |
| 342 | + .len = len * sizeof(*mapping), | |
| 343 | 343 | .flags = GNTCOPY_source_gref |
| 344 | − }; | |
| 344 | + }}; | |
| 345 | 345 | |
| 346 | − if ((off + len > vif->hash.size) || copy_op.len > XEN_PAGE_SIZE) | |
| 346 | + if ((off + len < off) || (off + len > vif->hash.size) || | |
| 347 | + len > XEN_PAGE_SIZE / sizeof(*mapping)) | |
| 347 | 348 | return XEN_NETIF_CTRL_STATUS_INVALID_PARAMETER; |
| 348 | 349 | |
| 349 | − while (len-- != 0) | |
| 350 | − if (mapping[off++] >= vif->num_queues) | |
| 351 | − return XEN_NETIF_CTRL_STATUS_INVALID_PARAMETER; | |
| 350 | + copy_op[0].dest.u.gmfn = virt_to_gfn(mapping + off); | |
| 351 | + copy_op[0].dest.offset = xen_offset_in_page(mapping + off); | |
| 352 | + if (copy_op[0].dest.offset + copy_op[0].len > XEN_PAGE_SIZE) { | |
| 353 | + copy_op[1] = copy_op[0]; | |
| 354 | + copy_op[1].source.offset = XEN_PAGE_SIZE - copy_op[0].dest.offset; | |
| 355 | + copy_op[1].dest.u.gmfn = virt_to_gfn(mapping + off + len); | |
| 356 | + copy_op[1].dest.offset = 0; | |
| 357 | + copy_op[1].len = copy_op[0].len - copy_op[1].source.offset; | |
| 358 | + copy_op[0].len = copy_op[1].source.offset; | |
| 359 | + nr = 2; | |
| 360 | + } | |
| 352 | 361 | |
| 353 | − if (copy_op.len != 0) { | |
| 354 | − gnttab_batch_copy(©_op, 1); | |
| 362 | + memcpy(mapping, vif->hash.mapping[vif->hash.mapping_sel], | |
| 363 | + vif->hash.size * sizeof(*mapping)); | |
| 355 | 364 | |
| 356 | − if (copy_op.status != GNTST_okay) | |
| 365 | + if (copy_op[0].len != 0) { | |
| 366 | + gnttab_batch_copy(copy_op, nr); | |
| 367 | + | |
| 368 | + if (copy_op[0].status != GNTST_okay || | |
| 369 | + copy_op[nr - 1].status != GNTST_okay) | |
| 357 | 370 | return XEN_NETIF_CTRL_STATUS_INVALID_PARAMETER; |
| 358 | 371 | } |
| 359 | 372 | |
| 373 | + while (len-- != 0) | |
| 374 | + if (mapping[off++] >= vif->num_queues) | |
| 375 | + return XEN_NETIF_CTRL_STATUS_INVALID_PARAMETER; | |
| 376 | + | |
| 377 | + vif->hash.mapping_sel = !vif->hash.mapping_sel; | |
| 378 | + | |
| 360 | 379 | return XEN_NETIF_CTRL_STATUS_SUCCESS; |
| 361 | 380 | } |
| 362 | 381 | |
| @@ -408,6 +427,8 @@ void xenvif_dump_hash_info(struct xenvif *vif, struct seq_file *m) · 45 unmodified lines | ||
| 408 | 427 | } |
| 409 | 428 | |
| 410 | 429 | if (vif->hash.size != 0) { |
| 430 | + const u32 *mapping = vif->hash.mapping[vif->hash.mapping_sel]; | |
| 431 | + | |
| 411 | 432 | seq_puts(m, "\nHash Mapping:\n"); |
| 412 | 433 | |
| 413 | 434 | for (i = 0; i < vif->hash.size; ) { |
| @@ -420,7 +441,7 @@ void xenvif_dump_hash_info(struct xenvif *vif, struct seq_file *m) · 6 unmodified lines | ||
| 420 | 441 | seq_printf(m, "[%4u - %4u]: ", i, i + n - 1); |
| 421 | 442 | |
| 422 | 443 | for (j = 0; j < n; j++, i++) |
| 423 | − seq_printf(m, "%4u ", vif->hash.mapping[i]); | |
| 444 | + seq_printf(m, "%4u ", mapping[i]); | |
| 424 | 445 | |
| 425 | 446 | seq_puts(m, "\n"); |
| 426 | 447 | } |
| @@ -162,7 +162,8 @@ static u16 xenvif_select_queue(struct net_device *dev, struct sk_buff *skb, · 161 unmodified lines | ||
| 162 | 162 | if (size == 0) |
| 163 | 163 | return skb_get_hash_raw(skb) % dev->real_num_tx_queues; |
| 164 | 164 | |
| 165 | − return vif->hash.mapping[skb_get_hash_raw(skb) % size]; | |
| 165 | + return vif->hash.mapping[vif->hash.mapping_sel] | |
| 166 | + [skb_get_hash_raw(skb) % size]; | |
| 166 | 167 | } |
| 167 | 168 | |
| 168 | 169 | static int xenvif_start_xmit(struct sk_buff *skb, struct net_device *dev) |
| @@ -1145,7 +1145,6 @@ static int mvebu_pcie_parse_request_resources(struct mvebu_pcie *pcie) · 1144 unmodified lines | ||
| 1145 | 1145 | { |
| 1146 | 1146 | struct device *dev = &pcie->pdev->dev; |
| 1147 | 1147 | struct device_node *np = dev->of_node; |
| 1148 | − unsigned int i; | |
| 1149 | 1148 | int ret; |
| 1150 | 1149 | |
| 1151 | 1150 | INIT_LIST_HEAD(&pcie->resources); |
| @@ -1179,13 +1178,58 @@ static int mvebu_pcie_parse_request_resources(struct mvebu_pcie *pcie) · 27 unmodified lines | ||
| 1179 | 1178 | resource_size(&pcie->io) - 1); |
| 1180 | 1179 | pcie->realio.name = "PCI I/O"; |
| 1181 | 1180 | |
| 1181 | + pci_add_resource(&pcie->resources, &pcie->realio); | |
| 1182 | + } | |
| 1183 | + | |
| 1184 | + return devm_request_pci_bus_resources(dev, &pcie->resources); | |
| 1185 | +} | |
| 1186 | + | |
| 1187 | +/* | |
| 1188 | + * This is a copy of pci_host_probe(), except that it does the I/O | |
| 1189 | + * remap as the last step, once we are sure we won't fail. | |
| 1190 | + * | |
| 1191 | + * It should be removed once the I/O remap error handling issue has | |
| 1192 | + * been sorted out. | |
| 1193 | + */ | |
| 1194 | +static int mvebu_pci_host_probe(struct pci_host_bridge *bridge) | |
| 1195 | +{ | |
| 1196 | + struct mvebu_pcie *pcie; | |
| 1197 | + struct pci_bus *bus, *child; | |
| 1198 | + int ret; | |
| 1199 | + | |
| 1200 | + ret = pci_scan_root_bus_bridge(bridge); | |
| 1201 | + if (ret < 0) { | |
| 1202 | + dev_err(bridge->dev.parent, "Scanning root bridge failed"); | |
| 1203 | + return ret; | |
| 1204 | + } | |
| 1205 | + | |
| 1206 | + pcie = pci_host_bridge_priv(bridge); | |
| 1207 | + if (resource_size(&pcie->io) != 0) { | |
| 1208 | + unsigned int i; | |
| 1209 | + | |
| 1182 | 1210 | for (i = 0; i < resource_size(&pcie->realio); i += SZ_64K) |
| 1183 | 1211 | pci_ioremap_io(i, pcie->io.start + i); |
| 1212 | + } | |
| 1184 | 1213 | |
| 1185 | − pci_add_resource(&pcie->resources, &pcie->realio); | |
| 1214 | + bus = bridge->bus; | |
| 1215 | + | |
| 1216 | + /* | |
| 1217 | + * We insert PCI resources into the iomem_resource and | |
| 1218 | + * ioport_resource trees in either pci_bus_claim_resources() | |
| 1219 | + * or pci_bus_assign_resources(). | |
| 1220 | + */ | |
| 1221 | + if (pci_has_flag(PCI_PROBE_ONLY)) { | |
| 1222 | + pci_bus_claim_resources(bus); | |
| 1223 | + } else { | |
| 1224 | + pci_bus_size_bridges(bus); | |
| 1225 | + pci_bus_assign_resources(bus); | |
| 1226 | + | |
| 1227 | + list_for_each_entry(child, &bus->children, node) | |
| 1228 | + pcie_bus_configure_settings(child); | |
| 1186 | 1229 | } |
| 1187 | 1230 | |
| 1188 | − return devm_request_pci_bus_resources(dev, &pcie->resources); | |
| 1231 | + pci_bus_add_devices(bus); | |
| 1232 | + return 0; | |
| 1189 | 1233 | } |
| 1190 | 1234 | |
| 1191 | 1235 | static int mvebu_pcie_probe(struct platform_device *pdev) |
| @@ -1268,7 +1312,7 @@ static int mvebu_pcie_probe(struct platform_device *pdev) · 76 unmodified lines | ||
| 1268 | 1312 | bridge->align_resource = mvebu_pcie_align_resource; |
| 1269 | 1313 | bridge->msi = pcie->msi; |
| 1270 | 1314 | |
| 1271 | − return pci_host_probe(bridge); | |
| 1315 | + return mvebu_pci_host_probe(bridge); | |
| 1272 | 1316 | } |
| 1273 | 1317 | |
| 1274 | 1318 | static const struct of_device_id mvebu_pcie_of_match_table[] = { |
| @@ -1289,12 +1289,12 @@ int pci_save_state(struct pci_dev *dev) · 1288 unmodified lines | ||
| 1289 | 1289 | EXPORT_SYMBOL(pci_save_state); |
| 1290 | 1290 | |
| 1291 | 1291 | static void pci_restore_config_dword(struct pci_dev *pdev, int offset, |
| 1292 | − u32 saved_val, int retry) | |
| 1292 | + u32 saved_val, int retry, bool force) | |
| 1293 | 1293 | { |
| 1294 | 1294 | u32 val; |
| 1295 | 1295 | |
| 1296 | 1296 | pci_read_config_dword(pdev, offset, &val); |
| 1297 | − if (val == saved_val) | |
| 1297 | + if (!force && val == saved_val) | |
| 1298 | 1298 | return; |
| 1299 | 1299 | |
| 1300 | 1300 | for (;;) { |
| @@ -1313,25 +1313,36 @@ static void pci_restore_config_dword(struct pci_dev *pdev, int offset, · 12 unmodified lines | ||
| 1313 | 1313 | } |
| 1314 | 1314 | |
| 1315 | 1315 | static void pci_restore_config_space_range(struct pci_dev *pdev, |
| 1316 | − int start, int end, int retry) | |
| 1316 | + int start, int end, int retry, | |
| 1317 | + bool force) | |
| 1317 | 1318 | { |
| 1318 | 1319 | int index; |
| 1319 | 1320 | |
| 1320 | 1321 | for (index = end; index >= start; index--) |
| 1321 | 1322 | pci_restore_config_dword(pdev, 4 * index, |
| 1322 | 1323 | pdev->saved_config_space[index], |
| 1323 | − retry); | |
| 1324 | + retry, force); | |
| 1324 | 1325 | } |
| 1325 | 1326 | |
| 1326 | 1327 | static void pci_restore_config_space(struct pci_dev *pdev) |
| 1327 | 1328 | { |
| 1328 | 1329 | if (pdev->hdr_type == PCI_HEADER_TYPE_NORMAL) { |
| 1329 | − pci_restore_config_space_range(pdev, 10, 15, 0); | |
| 1330 | + pci_restore_config_space_range(pdev, 10, 15, 0, false); | |
| 1330 | 1331 | /* Restore BARs before the command register. */ |
| 1331 | − pci_restore_config_space_range(pdev, 4, 9, 10); | |
| 1332 | − pci_restore_config_space_range(pdev, 0, 3, 0); | |
| 1332 | + pci_restore_config_space_range(pdev, 4, 9, 10, false); | |
| 1333 | + pci_restore_config_space_range(pdev, 0, 3, 0, false); | |
| 1334 | + } else if (pdev->hdr_type == PCI_HEADER_TYPE_BRIDGE) { | |
| 1335 | + pci_restore_config_space_range(pdev, 12, 15, 0, false); | |
| 1336 | + | |
| 1337 | + /* | |
| 1338 | + * Force rewriting of prefetch registers to avoid S3 resume | |
| 1339 | + * issues on Intel PCI bridges that occur when these | |
| 1340 | + * registers are not explicitly written. | |
| 1341 | + */ | |
| 1342 | + pci_restore_config_space_range(pdev, 9, 11, 0, true); | |
| 1343 | + pci_restore_config_space_range(pdev, 0, 8, 0, false); | |
| 1333 | 1344 | } else { |
| 1334 | − pci_restore_config_space_range(pdev, 0, 15, 0); | |
| 1345 | + pci_restore_config_space_range(pdev, 0, 15, 0, false); | |
| 1335 | 1346 | } |
| 1336 | 1347 | } |
| 1337 | 1348 | |
| @@ -610,7 +610,7 @@ static void qeth_put_reply(struct qeth_reply *reply) · 609 unmodified lines | ||
| 610 | 610 | static void qeth_issue_ipa_msg(struct qeth_ipa_cmd *cmd, int rc, |
| 611 | 611 | struct qeth_card *card) |
| 612 | 612 | { |
| 613 | − char *ipa_name; | |
| 613 | + const char *ipa_name; | |
| 614 | 614 | int com = cmd->hdr.command; |
| 615 | 615 | ipa_name = qeth_get_ipa_cmd_name(com); |
| 616 | 616 | if (rc) |
| @@ -148,10 +148,10 @@ EXPORT_SYMBOL_GPL(IPA_PDU_HEADER); · 147 unmodified lines | ||
| 148 | 148 | |
| 149 | 149 | struct ipa_rc_msg { |
| 150 | 150 | enum qeth_ipa_return_codes rc; |
| 151 | − char *msg; | |
| 151 | + const char *msg; | |
| 152 | 152 | }; |
| 153 | 153 | |
| 154 | −static struct ipa_rc_msg qeth_ipa_rc_msg[] = { | |
| 154 | +static const struct ipa_rc_msg qeth_ipa_rc_msg[] = { | |
| 155 | 155 | {IPA_RC_SUCCESS, "success"}, |
| 156 | 156 | {IPA_RC_NOTSUPP, "Command not supported"}, |
| 157 | 157 | {IPA_RC_IP_TABLE_FULL, "Add Addr IP Table Full - ipv6"}, |
| @@ -219,23 +219,23 @@ static struct ipa_rc_msg qeth_ipa_rc_msg[] = { · 61 unmodified lines | ||
| 219 | 219 | |
| 220 | 220 | |
| 221 | 221 | |
| 222 | −char *qeth_get_ipa_msg(enum qeth_ipa_return_codes rc) | |
| 222 | +const char *qeth_get_ipa_msg(enum qeth_ipa_return_codes rc) | |
| 223 | 223 | { |
| 224 | − int x = 0; | |
| 225 | − qeth_ipa_rc_msg[sizeof(qeth_ipa_rc_msg) / | |
| 226 | − sizeof(struct ipa_rc_msg) - 1].rc = rc; | |
| 227 | − while (qeth_ipa_rc_msg[x].rc != rc) | |
| 228 | − x++; | |
| 224 | + int x; | |
| 225 | + | |
| 226 | + for (x = 0; x < ARRAY_SIZE(qeth_ipa_rc_msg) - 1; x++) | |
| 227 | + if (qeth_ipa_rc_msg[x].rc == rc) | |
| 228 | + return qeth_ipa_rc_msg[x].msg; | |
| 229 | 229 | return qeth_ipa_rc_msg[x].msg; |
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | |
| 233 | 233 | struct ipa_cmd_names { |
| 234 | 234 | enum qeth_ipa_cmds cmd; |
| 235 | − char *name; | |
| 235 | + const char *name; | |
| 236 | 236 | }; |
| 237 | 237 | |
| 238 | −static struct ipa_cmd_names qeth_ipa_cmd_names[] = { | |
| 238 | +static const struct ipa_cmd_names qeth_ipa_cmd_names[] = { | |
| 239 | 239 | {IPA_CMD_STARTLAN, "startlan"}, |
| 240 | 240 | {IPA_CMD_STOPLAN, "stoplan"}, |
| 241 | 241 | {IPA_CMD_SETVMAC, "setvmac"}, |
| @@ -267,13 +267,12 @@ static struct ipa_cmd_names qeth_ipa_cmd_names[] = { · 25 unmodified lines | ||
| 267 | 267 | {IPA_CMD_UNKNOWN, "unknown"}, |
| 268 | 268 | }; |
| 269 | 269 | |
| 270 | −char *qeth_get_ipa_cmd_name(enum qeth_ipa_cmds cmd) | |
| 270 | +const char *qeth_get_ipa_cmd_name(enum qeth_ipa_cmds cmd) | |
| 271 | 271 | { |
| 272 | − int x = 0; | |
| 273 | − qeth_ipa_cmd_names[ | |
| 274 | − sizeof(qeth_ipa_cmd_names) / | |
| 275 | − sizeof(struct ipa_cmd_names)-1].cmd = cmd; | |
| 276 | − while (qeth_ipa_cmd_names[x].cmd != cmd) | |
| 277 | − x++; | |
| 272 | + int x; | |
| 273 | + | |
| 274 | + for (x = 0; x < ARRAY_SIZE(qeth_ipa_cmd_names) - 1; x++) | |
| 275 | + if (qeth_ipa_cmd_names[x].cmd == cmd) | |
| 276 | + return qeth_ipa_cmd_names[x].name; | |
| 278 | 277 | return qeth_ipa_cmd_names[x].name; |
| 279 | 278 | } |
| @@ -797,8 +797,8 @@ enum qeth_ipa_arp_return_codes { · 796 unmodified lines | ||
| 797 | 797 | QETH_IPA_ARP_RC_Q_NO_DATA = 0x0008, |
| 798 | 798 | }; |
| 799 | 799 | |
| 800 | −extern char *qeth_get_ipa_msg(enum qeth_ipa_return_codes rc); | |
| 801 | −extern char *qeth_get_ipa_cmd_name(enum qeth_ipa_cmds cmd); | |
| 800 | +extern const char *qeth_get_ipa_msg(enum qeth_ipa_return_codes rc); | |
| 801 | +extern const char *qeth_get_ipa_cmd_name(enum qeth_ipa_cmds cmd); | |
| 802 | 802 | |
| 803 | 803 | #define QETH_SETASS_BASE_LEN (sizeof(struct qeth_ipacmd_hdr) + \ |
| 804 | 804 | sizeof(struct qeth_ipacmd_setassparms_hdr)) |
| @@ -2472,6 +2472,7 @@ static int __qedi_probe(struct pci_dev *pdev, int mode) · 2471 unmodified lines | ||
| 2472 | 2472 | /* start qedi context */ |
| 2473 | 2473 | spin_lock_init(&qedi->hba_lock); |
| 2474 | 2474 | spin_lock_init(&qedi->task_idx_lock); |
| 2475 | + mutex_init(&qedi->stats_lock); | |
| 2475 | 2476 | } |
| 2476 | 2477 | qedi_ops->ll2->register_cb_ops(qedi->cdev, &qedi_ll2_cb_ops, qedi); |
| 2477 | 2478 | qedi_ops->ll2->start(qedi->cdev, ¶ms); |
| @@ -2729,6 +2729,9 @@ static int qman_alloc_range(struct gen_pool *p, u32 *result, u32 cnt) · 2728 unmodified lines | ||
| 2729 | 2729 | { |
| 2730 | 2730 | unsigned long addr; |
| 2731 | 2731 | |
| 2732 | + if (!p) | |
| 2733 | + return -ENODEV; | |
| 2734 | + | |
| 2732 | 2735 | addr = gen_pool_alloc(p, cnt); |
| 2733 | 2736 | if (!addr) |
| 2734 | 2737 | return -ENOMEM; |
| @@ -626,7 +626,7 @@ static u32 ucc_get_tdm_sync_shift(enum comm_dir mode, u32 tdm_num) · 625 unmodified lines | ||
| 626 | 626 | { |
| 627 | 627 | u32 shift; |
| 628 | 628 | |
| 629 | − shift = (mode == COMM_DIR_RX) ? RX_SYNC_SHIFT_BASE : RX_SYNC_SHIFT_BASE; | |
| 629 | + shift = (mode == COMM_DIR_RX) ? RX_SYNC_SHIFT_BASE : TX_SYNC_SHIFT_BASE; | |
| 630 | 630 | shift -= tdm_num * 2; |
| 631 | 631 | |
| 632 | 632 | return shift; |
| @@ -735,14 +735,6 @@ icm_fr_xdomain_connected(struct tb *tb, const struct icm_pkg_header *hdr) · 734 unmodified lines | ||
| 735 | 735 | u8 link, depth; |
| 736 | 736 | u64 route; |
| 737 | 737 | |
| 738 | − /* | |
| 739 | − * After NVM upgrade adding root switch device fails because we | |
| 740 | − * initiated reset. During that time ICM might still send | |
| 741 | − * XDomain connected message which we ignore here. | |
| 742 | − */ | |
| 743 | − if (!tb->root_switch) | |
| 744 | − return; | |
| 745 | − | |
| 746 | 738 | link = pkg->link_info & ICM_LINK_INFO_LINK_MASK; |
| 747 | 739 | depth = (pkg->link_info & ICM_LINK_INFO_DEPTH_MASK) >> |
| 748 | 740 | ICM_LINK_INFO_DEPTH_SHIFT; |
| @@ -1034,14 +1026,6 @@ icm_tr_device_connected(struct tb *tb, const struct icm_pkg_header *hdr) · 285 unmodified lines | ||
| 1034 | 1026 | if (pkg->hdr.packet_id) |
| 1035 | 1027 | return; |
| 1036 | 1028 | |
| 1037 | − /* | |
| 1038 | − * After NVM upgrade adding root switch device fails because we | |
| 1039 | − * initiated reset. During that time ICM might still send device | |
| 1040 | − * connected message which we ignore here. | |
| 1041 | − */ | |
| 1042 | − if (!tb->root_switch) | |
| 1043 | − return; | |
| 1044 | − | |
| 1045 | 1029 | route = get_route(pkg->route_hi, pkg->route_lo); |
| 1046 | 1030 | authorized = pkg->link_info & ICM_LINK_INFO_APPROVED; |
| 1047 | 1031 | security_level = (pkg->hdr.flags & ICM_FLAGS_SLEVEL_MASK) >> |
| @@ -1405,19 +1389,26 @@ static void icm_handle_notification(struct work_struct *work) · 357 unmodified lines | ||
| 1405 | 1389 | |
| 1406 | 1390 | mutex_lock(&tb->lock); |
| 1407 | 1391 | |
| 1408 | − switch (n->pkg->code) { | |
| 1409 | − case ICM_EVENT_DEVICE_CONNECTED: | |
| 1410 | − icm->device_connected(tb, n->pkg); | |
| 1411 | − break; | |
| 1412 | − case ICM_EVENT_DEVICE_DISCONNECTED: | |
| 1413 | − icm->device_disconnected(tb, n->pkg); | |
| 1414 | − break; | |
| 1415 | − case ICM_EVENT_XDOMAIN_CONNECTED: | |
| 1416 | − icm->xdomain_connected(tb, n->pkg); | |
| 1417 | − break; | |
| 1418 | − case ICM_EVENT_XDOMAIN_DISCONNECTED: | |
| 1419 | − icm->xdomain_disconnected(tb, n->pkg); | |
| 1420 | − break; | |
| 1392 | + /* | |
| 1393 | + * When the domain is stopped we flush its workqueue but before | |
| 1394 | + * that the root switch is removed. In that case we should treat | |
| 1395 | + * the queued events as being canceled. | |
| 1396 | + */ | |
| 1397 | + if (tb->root_switch) { | |
| 1398 | + switch (n->pkg->code) { | |
| 1399 | + case ICM_EVENT_DEVICE_CONNECTED: | |
| 1400 | + icm->device_connected(tb, n->pkg); | |
| 1401 | + break; | |
| 1402 | + case ICM_EVENT_DEVICE_DISCONNECTED: | |
| 1403 | + icm->device_disconnected(tb, n->pkg); | |
| 1404 | + break; | |
| 1405 | + case ICM_EVENT_XDOMAIN_CONNECTED: | |
| 1406 | + icm->xdomain_connected(tb, n->pkg); | |
| 1407 | + break; | |
| 1408 | + case ICM_EVENT_XDOMAIN_DISCONNECTED: | |
| 1409 | + icm->xdomain_disconnected(tb, n->pkg); | |
| 1410 | + break; | |
| 1411 | + } | |
| 1421 | 1412 | } |
| 1422 | 1413 | |
| 1423 | 1414 | mutex_unlock(&tb->lock); |
| @@ -1192,5 +1192,5 @@ static void __exit nhi_unload(void) · 1191 unmodified lines | ||
| 1192 | 1192 | tb_domain_exit(); |
| 1193 | 1193 | } |
| 1194 | 1194 | |
| 1195 | −fs_initcall(nhi_init); | |
| 1195 | +rootfs_initcall(nhi_init); | |
| 1196 | 1196 | module_exit(nhi_unload); |
| @@ -630,10 +630,6 @@ static int dw8250_probe(struct platform_device *pdev) · 629 unmodified lines | ||
| 630 | 630 | if (!data->skip_autocfg) |
| 631 | 631 | dw8250_setup_port(p); |
| 632 | 632 | |
| 633 | −#ifdef CONFIG_PM | |
| 634 | − uart.capabilities |= UART_CAP_RPM; | |
| 635 | −#endif | |
| 636 | − | |
| 637 | 633 | /* If we have a valid fifosize, try hooking up DMA */ |
| 638 | 634 | if (p->fifosize) { |
| 639 | 635 | data->dma.rxconf.src_maxburst = p->fifosize / 4; |
| @@ -291,6 +291,33 @@ static const struct sci_port_params sci_port_params[SCIx_NR_REGTYPES] = { · 290 unmodified lines | ||
| 291 | 291 | .error_clear = SCIF_ERROR_CLEAR, |
| 292 | 292 | }, |
| 293 | 293 | |
| 294 | + /* | |
| 295 | + * The "SCIFA" that is in RZ/T and RZ/A2. | |
| 296 | + * It looks like a normal SCIF with FIFO data, but with a | |
| 297 | + * compressed address space. Also, the break out of interrupts | |
| 298 | + * are different: ERI/BRI, RXI, TXI, TEI, DRI. | |
| 299 | + */ | |
| 300 | + [SCIx_RZ_SCIFA_REGTYPE] = { | |
| 301 | + .regs = { | |
| 302 | + [SCSMR] = { 0x00, 16 }, | |
| 303 | + [SCBRR] = { 0x02, 8 }, | |
| 304 | + [SCSCR] = { 0x04, 16 }, | |
| 305 | + [SCxTDR] = { 0x06, 8 }, | |
| 306 | + [SCxSR] = { 0x08, 16 }, | |
| 307 | + [SCxRDR] = { 0x0A, 8 }, | |
| 308 | + [SCFCR] = { 0x0C, 16 }, | |
| 309 | + [SCFDR] = { 0x0E, 16 }, | |
| 310 | + [SCSPTR] = { 0x10, 16 }, | |
| 311 | + [SCLSR] = { 0x12, 16 }, | |
| 312 | + }, | |
| 313 | + .fifosize = 16, | |
| 314 | + .overrun_reg = SCLSR, | |
| 315 | + .overrun_mask = SCLSR_ORER, | |
| 316 | + .sampling_rate_mask = SCI_SR(32), | |
| 317 | + .error_mask = SCIF_DEFAULT_ERROR_MASK, | |
| 318 | + .error_clear = SCIF_ERROR_CLEAR, | |
| 319 | + }, | |
| 320 | + | |
| 294 | 321 | /* |
| 295 | 322 | * Common SH-3 SCIF definitions. |
| 296 | 323 | */ |
| @@ -319,15 +346,15 @@ static const struct sci_port_params sci_port_params[SCIx_NR_REGTYPES] = { · 22 unmodified lines | ||
| 319 | 346 | [SCIx_SH4_SCIF_REGTYPE] = { |
| 320 | 347 | .regs = { |
| 321 | 348 | [SCSMR] = { 0x00, 16 }, |
| 322 | − [SCBRR] = { 0x02, 8 }, | |
| 323 | − [SCSCR] = { 0x04, 16 }, | |
| 324 | − [SCxTDR] = { 0x06, 8 }, | |
| 325 | − [SCxSR] = { 0x08, 16 }, | |
| 326 | − [SCxRDR] = { 0x0a, 8 }, | |
| 327 | − [SCFCR] = { 0x0c, 16 }, | |
| 328 | − [SCFDR] = { 0x0e, 16 }, | |
| 329 | − [SCSPTR] = { 0x10, 16 }, | |
| 330 | − [SCLSR] = { 0x12, 16 }, | |
| 349 | + [SCBRR] = { 0x04, 8 }, | |
| 350 | + [SCSCR] = { 0x08, 16 }, | |
| 351 | + [SCxTDR] = { 0x0c, 8 }, | |
| 352 | + [SCxSR] = { 0x10, 16 }, | |
| 353 | + [SCxRDR] = { 0x14, 8 }, | |
| 354 | + [SCFCR] = { 0x18, 16 }, | |
| 355 | + [SCFDR] = { 0x1c, 16 }, | |
| 356 | + [SCSPTR] = { 0x20, 16 }, | |
| 357 | + [SCLSR] = { 0x24, 16 }, | |
| 331 | 358 | }, |
| 332 | 359 | .fifosize = 16, |
| 333 | 360 | .overrun_reg = SCLSR, |
| @@ -2810,7 +2837,7 @@ static int sci_init_single(struct platform_device *dev, · 2476 unmodified lines | ||
| 2810 | 2837 | { |
| 2811 | 2838 | struct uart_port *port = &sci_port->port; |
| 2812 | 2839 | const struct resource *res; |
| 2813 | − unsigned int i, regtype; | |
| 2840 | + unsigned int i; | |
| 2814 | 2841 | int ret; |
| 2815 | 2842 | |
| 2816 | 2843 | sci_port->cfg = p; |
| @@ -2847,7 +2874,6 @@ static int sci_init_single(struct platform_device *dev, · 30 unmodified lines | ||
| 2847 | 2874 | if (unlikely(sci_port->params == NULL)) |
| 2848 | 2875 | return -EINVAL; |
| 2849 | 2876 | |
| 2850 | − regtype = sci_port->params - sci_port_params; | |
| 2851 | 2877 | switch (p->type) { |
| 2852 | 2878 | case PORT_SCIFB: |
| 2853 | 2879 | sci_port->rx_trigger = 48; |
| @@ -2902,10 +2928,6 @@ static int sci_init_single(struct platform_device *dev, · 48 unmodified lines | ||
| 2902 | 2928 | port->regshift = 1; |
| 2903 | 2929 | } |
| 2904 | 2930 | |
| 2905 | − if (regtype == SCIx_SH4_SCIF_REGTYPE) | |
| 2906 | − if (sci_port->reg_size >= 0x20) | |
| 2907 | − port->regshift = 1; | |
| 2908 | − | |
| 2909 | 2931 | /* |
| 2910 | 2932 | * The UART port needs an IRQ value, so we peg this to the RX IRQ |
| 2911 | 2933 | * for the multi-IRQ ports, which is where we are primarily |
| @@ -3110,6 +3132,10 @@ static const struct of_device_id of_sci_match[] = { · 198 unmodified lines | ||
| 3110 | 3132 | .compatible = "renesas,scif-r7s72100", |
| 3111 | 3133 | .data = SCI_OF_DATA(PORT_SCIF, SCIx_SH2_SCIF_FIFODATA_REGTYPE), |
| 3112 | 3134 | }, |
| 3135 | + { | |
| 3136 | + .compatible = "renesas,scif-r7s9210", | |
| 3137 | + .data = SCI_OF_DATA(PORT_SCIF, SCIx_RZ_SCIFA_REGTYPE), | |
| 3138 | + }, | |
| 3113 | 3139 | /* Family-specific types */ |
| 3114 | 3140 | { |
| 3115 | 3141 | .compatible = "renesas,rcar-gen1-scif", |
| @@ -1514,6 +1514,7 @@ static void acm_disconnect(struct usb_interface *intf) · 1513 unmodified lines | ||
| 1514 | 1514 | { |
| 1515 | 1515 | struct acm *acm = usb_get_intfdata(intf); |
| 1516 | 1516 | struct tty_struct *tty; |
| 1517 | + int i; | |
| 1517 | 1518 | |
| 1518 | 1519 | /* sibling interface is already cleaning up */ |
| 1519 | 1520 | if (!acm) |
| @@ -1544,6 +1545,11 @@ static void acm_disconnect(struct usb_interface *intf) · 24 unmodified lines | ||
| 1544 | 1545 | |
| 1545 | 1546 | tty_unregister_device(acm_tty_driver, acm->minor); |
| 1546 | 1547 | |
| 1548 | + usb_free_urb(acm->ctrlurb); | |
| 1549 | + for (i = 0; i < ACM_NW; i++) | |
| 1550 | + usb_free_urb(acm->wb[i].urb); | |
| 1551 | + for (i = 0; i < acm->rx_buflimit; i++) | |
| 1552 | + usb_free_urb(acm->read_urbs[i]); | |
| 1547 | 1553 | acm_write_buffers_free(acm); |
| 1548 | 1554 | usb_free_coherent(acm->dev, acm->ctrlsize, acm->ctrl_buffer, acm->ctrl_dma); |
| 1549 | 1555 | acm_read_buffers_free(acm); |
| @@ -642,10 +642,10 @@ static int __maybe_unused xhci_mtk_resume(struct device *dev) · 641 unmodified lines | ||
| 642 | 642 | xhci_mtk_host_enable(mtk); |
| 643 | 643 | |
| 644 | 644 | xhci_dbg(xhci, "%s: restart port polling\n", __func__); |
| 645 | − set_bit(HCD_FLAG_POLL_RH, &hcd->flags); | |
| 646 | − usb_hcd_poll_rh_status(hcd); | |
| 647 | 645 | set_bit(HCD_FLAG_POLL_RH, &xhci->shared_hcd->flags); |
| 648 | 646 | usb_hcd_poll_rh_status(xhci->shared_hcd); |
| 647 | + set_bit(HCD_FLAG_POLL_RH, &hcd->flags); | |
| 648 | + usb_hcd_poll_rh_status(hcd); | |
| 649 | 649 | return 0; |
| 650 | 650 | } |
| 651 | 651 | |
| @@ -185,6 +185,8 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci) · 184 unmodified lines | ||
| 185 | 185 | } |
| 186 | 186 | if (pdev->vendor == PCI_VENDOR_ID_INTEL && |
| 187 | 187 | (pdev->device == PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI || |
| 188 | + pdev->device == PCI_DEVICE_ID_INTEL_SUNRISEPOINT_LP_XHCI || | |
| 189 | + pdev->device == PCI_DEVICE_ID_INTEL_SUNRISEPOINT_H_XHCI || | |
| 188 | 190 | pdev->device == PCI_DEVICE_ID_INTEL_APL_XHCI || |
| 189 | 191 | pdev->device == PCI_DEVICE_ID_INTEL_DNV_XHCI)) |
| 190 | 192 | xhci->quirks |= XHCI_MISSING_CAS; |
| @@ -561,6 +561,9 @@ static void option_instat_callback(struct urb *urb); · 560 unmodified lines | ||
| 561 | 561 | /* Interface is reserved */ |
| 562 | 562 | #define RSVD(ifnum) ((BIT(ifnum) & 0xff) << 0) |
| 563 | 563 | |
| 564 | +/* Interface must have two endpoints */ | |
| 565 | +#define NUMEP2 BIT(16) | |
| 566 | + | |
| 564 | 567 | |
| 565 | 568 | static const struct usb_device_id option_ids[] = { |
| 566 | 569 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) }, |
| @@ -1081,8 +1084,9 @@ static const struct usb_device_id option_ids[] = { · 514 unmodified lines | ||
| 1081 | 1084 | .driver_info = RSVD(4) }, |
| 1082 | 1085 | { USB_DEVICE(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_BG96), |
| 1083 | 1086 | .driver_info = RSVD(4) }, |
| 1084 | − { USB_DEVICE(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EP06), | |
| 1085 | − .driver_info = RSVD(4) | RSVD(5) }, | |
| 1087 | + { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EP06, 0xff, 0xff, 0xff), | |
| 1088 | + .driver_info = RSVD(1) | RSVD(2) | RSVD(3) | RSVD(4) | NUMEP2 }, | |
| 1089 | + { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EP06, 0xff, 0, 0) }, | |
| 1086 | 1090 | { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6001) }, |
| 1087 | 1091 | { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CMU_300) }, |
| 1088 | 1092 | { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6003), |
| @@ -1999,6 +2003,13 @@ static int option_probe(struct usb_serial *serial, · 910 unmodified lines | ||
| 1999 | 2003 | if (device_flags & RSVD(iface_desc->bInterfaceNumber)) |
| 2000 | 2004 | return -ENODEV; |
| 2001 | 2005 | |
| 2006 | + /* | |
| 2007 | + * Allow matching on bNumEndpoints for devices whose interface numbers | |
| 2008 | + * can change (e.g. Quectel EP06). | |
| 2009 | + */ | |
| 2010 | + if (device_flags & NUMEP2 && iface_desc->bNumEndpoints != 2) | |
| 2011 | + return -ENODEV; | |
| 2012 | + | |
| 2002 | 2013 | /* Store the device flags so we can use them during attach. */ |
| 2003 | 2014 | usb_set_serial_data(serial, (void *)device_flags); |
| 2004 | 2015 | |
| @@ -84,7 +84,8 @@ DEVICE(moto_modem, MOTO_IDS); · 83 unmodified lines | ||
| 84 | 84 | |
| 85 | 85 | /* Motorola Tetra driver */ |
| 86 | 86 | #define MOTOROLA_TETRA_IDS() \ |
| 87 | − { USB_DEVICE(0x0cad, 0x9011) } /* Motorola Solutions TETRA PEI */ | |
| 87 | + { USB_DEVICE(0x0cad, 0x9011) }, /* Motorola Solutions TETRA PEI */ \ | |
| 88 | + { USB_DEVICE(0x0cad, 0x9012) } /* MTP6550 */ | |
| 88 | 89 | DEVICE(motorola_tetra, MOTOROLA_TETRA_IDS); |
| 89 | 90 | |
| 90 | 91 | /* Novatel Wireless GPS driver */ |
| @@ -42,6 +42,7 @@ struct bmp_dib_header { · 41 unmodified lines | ||
| 42 | 42 | u32 colors_important; |
| 43 | 43 | } __packed; |
| 44 | 44 | |
| 45 | +static bool use_bgrt = true; | |
| 45 | 46 | static bool request_mem_succeeded = false; |
| 46 | 47 | static u64 mem_flags = EFI_MEMORY_WC | EFI_MEMORY_UC; |
| 47 | 48 | |
| @@ -160,6 +161,9 @@ static void efifb_show_boot_graphics(struct fb_info *info) · 112 unmodified lines | ||
| 160 | 161 | void *bgrt_image = NULL; |
| 161 | 162 | u8 *dst = info->screen_base; |
| 162 | 163 | |
| 164 | + if (!use_bgrt) | |
| 165 | + return; | |
| 166 | + | |
| 163 | 167 | if (!bgrt_tab.image_address) { |
| 164 | 168 | pr_info("efifb: No BGRT, not showing boot graphics\n"); |
| 165 | 169 | return; |
| @@ -290,6 +294,8 @@ static int efifb_setup(char *options) · 124 unmodified lines | ||
| 290 | 294 | screen_info.lfb_width = simple_strtoul(this_opt+6, NULL, 0); |
| 291 | 295 | else if (!strcmp(this_opt, "nowc")) |
| 292 | 296 | mem_flags &= ~EFI_MEMORY_WC; |
| 297 | + else if (!strcmp(this_opt, "nobgrt")) | |
| 298 | + use_bgrt = false; | |
| 293 | 299 | } |
| 294 | 300 | } |
| 295 | 301 | |
| @@ -496,6 +496,9 @@ static int omapfb_memory_read(struct fb_info *fbi, · 495 unmodified lines | ||
| 496 | 496 | if (!access_ok(VERIFY_WRITE, mr->buffer, mr->buffer_size)) |
| 497 | 497 | return -EFAULT; |
| 498 | 498 | |
| 499 | + if (mr->w > 4096 || mr->h > 4096) | |
| 500 | + return -EINVAL; | |
| 501 | + | |
| 499 | 502 | if (mr->w * mr->h * 3 > mr->buffer_size) |
| 500 | 503 | return -EINVAL; |
| 501 | 504 | |
| @@ -509,7 +512,7 @@ static int omapfb_memory_read(struct fb_info *fbi, · 7 unmodified lines | ||
| 509 | 512 | mr->x, mr->y, mr->w, mr->h); |
| 510 | 513 | |
| 511 | 514 | if (r > 0) { |
| 512 | − if (copy_to_user(mr->buffer, buf, mr->buffer_size)) | |
| 515 | + if (copy_to_user(mr->buffer, buf, r)) | |
| 513 | 516 | r = -EFAULT; |
| 514 | 517 | } |
| 515 | 518 | |
| @@ -712,7 +712,7 @@ static int pxa168fb_probe(struct platform_device *pdev) · 711 unmodified lines | ||
| 712 | 712 | /* |
| 713 | 713 | * enable controller clock |
| 714 | 714 | */ |
| 715 | − clk_enable(fbi->clk); | |
| 715 | + clk_prepare_enable(fbi->clk); | |
| 716 | 716 | |
| 717 | 717 | pxa168fb_set_par(info); |
| 718 | 718 | |
| @@ -767,7 +767,7 @@ static int pxa168fb_probe(struct platform_device *pdev) · 48 unmodified lines | ||
| 767 | 767 | failed_free_cmap: |
| 768 | 768 | fb_dealloc_cmap(&info->cmap); |
| 769 | 769 | failed_free_clk: |
| 770 | − clk_disable(fbi->clk); | |
| 770 | + clk_disable_unprepare(fbi->clk); | |
| 771 | 771 | failed_free_fbmem: |
| 772 | 772 | dma_free_coherent(fbi->dev, info->fix.smem_len, |
| 773 | 773 | info->screen_base, fbi->fb_start_dma); |
| @@ -807,7 +807,7 @@ static int pxa168fb_remove(struct platform_device *pdev) · 33 unmodified lines | ||
| 807 | 807 | dma_free_wc(fbi->dev, PAGE_ALIGN(info->fix.smem_len), |
| 808 | 808 | info->screen_base, info->fix.smem_start); |
| 809 | 809 | |
| 810 | − clk_disable(fbi->clk); | |
| 810 | + clk_disable_unprepare(fbi->clk); | |
| 811 | 811 | |
| 812 | 812 | framebuffer_release(info); |
| 813 | 813 | |
| @@ -1157,7 +1157,7 @@ static int __init stifb_init_fb(struct sti_struct *sti, int bpp_pref) · 1156 unmodified lines | ||
| 1157 | 1157 | dev_name); |
| 1158 | 1158 | goto out_err0; |
| 1159 | 1159 | } |
| 1160 | − /* fall though */ | |
| 1160 | + /* fall through */ | |
| 1161 | 1161 | case S9000_ID_ARTIST: |
| 1162 | 1162 | case S9000_ID_HCRX: |
| 1163 | 1163 | case S9000_ID_TIMBER: |
| @@ -1553,6 +1553,7 @@ static inline void free_dfs_info_array(struct dfs_info3_param *param, · 1552 unmodified lines | ||
| 1553 | 1553 | |
| 1554 | 1554 | /* Flags */ |
| 1555 | 1555 | #define MID_WAIT_CANCELLED 1 /* Cancelled while waiting for response */ |
| 1556 | +#define MID_DELETED 2 /* Mid has been dequeued/deleted */ | |
| 1556 | 1557 | |
| 1557 | 1558 | /* Types of response buffer returned from SendReceive2 */ |
| 1558 | 1559 | #define CIFS_NO_BUFFER 0 /* Response buffer not returned */ |
| @@ -659,7 +659,15 @@ dequeue_mid(struct mid_q_entry *mid, bool malformed) · 658 unmodified lines | ||
| 659 | 659 | mid->mid_state = MID_RESPONSE_RECEIVED; |
| 660 | 660 | else |
| 661 | 661 | mid->mid_state = MID_RESPONSE_MALFORMED; |
| 662 | − list_del_init(&mid->qhead); | |
| 662 | + /* | |
| 663 | + * Trying to handle/dequeue a mid after the send_recv() | |
| 664 | + * function has finished processing it is a bug. | |
| 665 | + */ | |
| 666 | + if (mid->mid_flags & MID_DELETED) | |
| 667 | + printk_once(KERN_WARNING | |
| 668 | + "trying to dequeue a deleted mid\n"); | |
| 669 | + else | |
| 670 | + list_del_init(&mid->qhead); | |
| 663 | 671 | spin_unlock(&GlobalMid_Lock); |
| 664 | 672 | } |
| 665 | 673 | |
| @@ -938,8 +946,7 @@ next_pdu: · 272 unmodified lines | ||
| 938 | 946 | } else { |
| 939 | 947 | mids[0] = server->ops->find_mid(server, buf); |
| 940 | 948 | bufs[0] = buf; |
| 941 | − if (mids[0]) | |
| 942 | − num_mids = 1; | |
| 949 | + num_mids = 1; | |
| 943 | 950 | |
| 944 | 951 | if (!mids[0] || !mids[0]->receive) |
| 945 | 952 | length = standard_receive3(server, mids[0]); |
| @@ -1477,7 +1477,7 @@ smb2_query_dir_first(const unsigned int xid, struct cifs_tcon *tcon, · 1476 unmodified lines | ||
| 1477 | 1477 | } |
| 1478 | 1478 | |
| 1479 | 1479 | srch_inf->entries_in_buffer = 0; |
| 1480 | − srch_inf->index_of_last_entry = 0; | |
| 1480 | + srch_inf->index_of_last_entry = 2; | |
| 1481 | 1481 | |
| 1482 | 1482 | rc = SMB2_query_directory(xid, tcon, fid->persistent_fid, |
| 1483 | 1483 | fid->volatile_fid, 0, srch_inf); |
| @@ -142,7 +142,8 @@ void · 141 unmodified lines | ||
| 142 | 142 | cifs_delete_mid(struct mid_q_entry *mid) |
| 143 | 143 | { |
| 144 | 144 | spin_lock(&GlobalMid_Lock); |
| 145 | − list_del(&mid->qhead); | |
| 145 | + list_del_init(&mid->qhead); | |
| 146 | + mid->mid_flags |= MID_DELETED; | |
| 146 | 147 | spin_unlock(&GlobalMid_Lock); |
| 147 | 148 | |
| 148 | 149 | DeleteMidQEntry(mid); |
| @@ -772,6 +773,11 @@ cifs_setup_request(struct cifs_ses *ses, struct smb_rqst *rqst) · 623 unmodified lines | ||
| 772 | 773 | return mid; |
| 773 | 774 | } |
| 774 | 775 | |
| 776 | +static void | |
| 777 | +cifs_noop_callback(struct mid_q_entry *mid) | |
| 778 | +{ | |
| 779 | +} | |
| 780 | + | |
| 775 | 781 | int |
| 776 | 782 | compound_send_recv(const unsigned int xid, struct cifs_ses *ses, |
| 777 | 783 | const int flags, const int num_rqst, struct smb_rqst *rqst, |
| @@ -826,8 +832,13 @@ compound_send_recv(const unsigned int xid, struct cifs_ses *ses, · 48 unmodified lines | ||
| 826 | 832 | } |
| 827 | 833 | |
| 828 | 834 | midQ[i]->mid_state = MID_REQUEST_SUBMITTED; |
| 835 | + /* | |
| 836 | + * We don't invoke the callback compounds unless it is the last | |
| 837 | + * request. | |
| 838 | + */ | |
| 839 | + if (i < num_rqst - 1) | |
| 840 | + midQ[i]->callback = cifs_noop_callback; | |
| 829 | 841 | } |
| 830 | − | |
| 831 | 842 | cifs_in_send_inc(ses->server); |
| 832 | 843 | rc = smb_send_rqst(ses->server, num_rqst, rqst, flags); |
| 833 | 844 | cifs_in_send_dec(ses->server); |
| @@ -908,6 +919,12 @@ compound_send_recv(const unsigned int xid, struct cifs_ses *ses, · 74 unmodified lines | ||
| 908 | 919 | midQ[i]->resp_buf = NULL; |
| 909 | 920 | } |
| 910 | 921 | out: |
| 922 | + /* | |
| 923 | + * This will dequeue all mids. After this it is important that the | |
| 924 | + * demultiplex_thread will not process any of these mids any futher. | |
| 925 | + * This is prevented above by using a noop callback that will not | |
| 926 | + * wake this thread except for the very last PDU. | |
| 927 | + */ | |
| 911 | 928 | for (i = 0; i < num_rqst; i++) |
| 912 | 929 | cifs_delete_mid(midQ[i]); |
| 913 | 930 | add_credits(ses->server, credits, optype); |
| @@ -230,7 +230,7 @@ static long ioctl_file_clone(struct file *dst_file, unsigned long srcfd, · 229 unmodified lines | ||
| 230 | 230 | ret = -EXDEV; |
| 231 | 231 | if (src_file.file->f_path.mnt != dst_file->f_path.mnt) |
| 232 | 232 | goto fdput; |
| 233 | − ret = do_clone_file_range(src_file.file, off, dst_file, destoff, olen); | |
| 233 | + ret = vfs_clone_file_range(src_file.file, off, dst_file, destoff, olen); | |
| 234 | 234 | fdput: |
| 235 | 235 | fdput(src_file); |
| 236 | 236 | return ret; |
| @@ -1051,6 +1051,7 @@ iomap_page_mkwrite_actor(struct inode *inode, loff_t pos, loff_t length, · 1050 unmodified lines | ||
| 1051 | 1051 | } else { |
| 1052 | 1052 | WARN_ON_ONCE(!PageUptodate(page)); |
| 1053 | 1053 | iomap_page_create(inode, page); |
| 1054 | + set_page_dirty(page); | |
| 1054 | 1055 | } |
| 1055 | 1056 | |
| 1056 | 1057 | return length; |
| @@ -1090,7 +1091,6 @@ int iomap_page_mkwrite(struct vm_fault *vmf, const struct iomap_ops *ops) · 33 unmodified lines | ||
| 1090 | 1091 | length -= ret; |
| 1091 | 1092 | } |
| 1092 | 1093 | |
| 1093 | − set_page_dirty(page); | |
| 1094 | 1094 | wait_for_stable_page(page); |
| 1095 | 1095 | return VM_FAULT_LOCKED; |
| 1096 | 1096 | out_unlock: |
| @@ -541,7 +541,8 @@ __be32 nfsd4_set_nfs4_label(struct svc_rqst *rqstp, struct svc_fh *fhp, · 540 unmodified lines | ||
| 541 | 541 | __be32 nfsd4_clone_file_range(struct file *src, u64 src_pos, struct file *dst, |
| 542 | 542 | u64 dst_pos, u64 count) |
| 543 | 543 | { |
| 544 | − return nfserrno(do_clone_file_range(src, src_pos, dst, dst_pos, count)); | |
| 544 | + return nfserrno(vfs_clone_file_range(src, src_pos, dst, dst_pos, | |
| 545 | + count)); | |
| 545 | 546 | } |
| 546 | 547 | |
| 547 | 548 | ssize_t nfsd_copy_file_range(struct file *src, u64 src_pos, struct file *dst, |
| @@ -584,9 +584,9 @@ static void dlm_init_lockres(struct dlm_ctxt *dlm, · 583 unmodified lines | ||
| 584 | 584 | |
| 585 | 585 | res->last_used = 0; |
| 586 | 586 | |
| 587 | − spin_lock(&dlm->spinlock); | |
| 587 | + spin_lock(&dlm->track_lock); | |
| 588 | 588 | list_add_tail(&res->tracking, &dlm->tracking_list); |
| 589 | − spin_unlock(&dlm->spinlock); | |
| 589 | + spin_unlock(&dlm->track_lock); | |
| 590 | 590 | |
| 591 | 591 | memset(res->lvb, 0, DLM_LVB_LEN); |
| 592 | 592 | memset(res->refmap, 0, sizeof(res->refmap)); |
| @@ -2946,6 +2946,7 @@ int ocfs2_duplicate_clusters_by_page(handle_t *handle, · 2945 unmodified lines | ||
| 2946 | 2946 | if (map_end & (PAGE_SIZE - 1)) |
| 2947 | 2947 | to = map_end & (PAGE_SIZE - 1); |
| 2948 | 2948 | |
| 2949 | +retry: | |
| 2949 | 2950 | page = find_or_create_page(mapping, page_index, GFP_NOFS); |
| 2950 | 2951 | if (!page) { |
| 2951 | 2952 | ret = -ENOMEM; |
| @@ -2954,11 +2955,18 @@ int ocfs2_duplicate_clusters_by_page(handle_t *handle, · 2 unmodified lines | ||
| 2954 | 2955 | } |
| 2955 | 2956 | |
| 2956 | 2957 | /* |
| 2957 | − * In case PAGE_SIZE <= CLUSTER_SIZE, This page | |
| 2958 | − * can't be dirtied before we CoW it out. | |
| 2958 | + * In case PAGE_SIZE <= CLUSTER_SIZE, we do not expect a dirty | |
| 2959 | + * page, so write it back. | |
| 2959 | 2960 | */ |
| 2960 | − if (PAGE_SIZE <= OCFS2_SB(sb)->s_clustersize) | |
| 2961 | − BUG_ON(PageDirty(page)); | |
| 2961 | + if (PAGE_SIZE <= OCFS2_SB(sb)->s_clustersize) { | |
| 2962 | + if (PageDirty(page)) { | |
| 2963 | + /* | |
| 2964 | + * write_on_page will unlock the page on return | |
| 2965 | + */ | |
| 2966 | + ret = write_one_page(page); | |
| 2967 | + goto retry; | |
| 2968 | + } | |
| 2969 | + } | |
| 2962 | 2970 | |
| 2963 | 2971 | if (!PageUptodate(page)) { |
| 2964 | 2972 | ret = block_read_full_page(page, ocfs2_get_block); |
| @@ -141,7 +141,7 @@ static int ovl_copy_up_data(struct path *old, struct path *new, loff_t len) · 140 unmodified lines | ||
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | /* Try to use clone_file_range to clone up within the same fs */ |
| 144 | − error = vfs_clone_file_range(old_file, 0, new_file, 0, len); | |
| 144 | + error = do_clone_file_range(old_file, 0, new_file, 0, len); | |
| 145 | 145 | if (!error) |
| 146 | 146 | goto out; |
| 147 | 147 | /* Couldn't clone, so now we try to copy the data */ |
| @@ -240,8 +240,10 @@ static ssize_t ovl_write_iter(struct kiocb *iocb, struct iov_iter *iter) · 239 unmodified lines | ||
| 240 | 240 | goto out_unlock; |
| 241 | 241 | |
| 242 | 242 | old_cred = ovl_override_creds(file_inode(file)->i_sb); |
| 243 | + file_start_write(real.file); | |
| 243 | 244 | ret = vfs_iter_write(real.file, iter, &iocb->ki_pos, |
| 244 | 245 | ovl_iocb_to_rwf(iocb)); |
| 246 | + file_end_write(real.file); | |
| 245 | 247 | revert_creds(old_cred); |
| 246 | 248 | |
| 247 | 249 | /* Update size */ |
| @@ -504,7 +504,7 @@ static const struct inode_operations ovl_special_inode_operations = { · 503 unmodified lines | ||
| 504 | 504 | .update_time = ovl_update_time, |
| 505 | 505 | }; |
| 506 | 506 | |
| 507 | −const struct address_space_operations ovl_aops = { | |
| 507 | +static const struct address_space_operations ovl_aops = { | |
| 508 | 508 | /* For O_DIRECT dentry_open() checks f_mapping->a_ops->direct_IO */ |
| 509 | 509 | .direct_IO = noop_direct_IO, |
| 510 | 510 | }; |
| @@ -686,7 +686,7 @@ struct dentry *ovl_lookup_index(struct ovl_fs *ofs, struct dentry *upper, · 685 unmodified lines | ||
| 686 | 686 | index = NULL; |
| 687 | 687 | goto out; |
| 688 | 688 | } |
| 689 | − pr_warn_ratelimited("overlayfs: failed inode index lookup (ino=%lu, key=%*s, err=%i);\n" | |
| 689 | + pr_warn_ratelimited("overlayfs: failed inode index lookup (ino=%lu, key=%.*s, err=%i);\n" | |
| 690 | 690 | "overlayfs: mount with '-o index=off' to disable inodes index.\n", |
| 691 | 691 | d_inode(origin)->i_ino, name.len, name.name, |
| 692 | 692 | err); |
| @@ -152,8 +152,8 @@ static inline int ovl_do_setxattr(struct dentry *dentry, const char *name, · 151 unmodified lines | ||
| 152 | 152 | const void *value, size_t size, int flags) |
| 153 | 153 | { |
| 154 | 154 | int err = vfs_setxattr(dentry, name, value, size, flags); |
| 155 | − pr_debug("setxattr(%pd2, \"%s\", \"%*s\", 0x%x) = %i\n", | |
| 156 | − dentry, name, (int) size, (char *) value, flags, err); | |
| 155 | + pr_debug("setxattr(%pd2, \"%s\", \"%*pE\", %zu, 0x%x) = %i\n", | |
| 156 | + dentry, name, min((int)size, 48), value, size, flags, err); | |
| 157 | 157 | return err; |
| 158 | 158 | } |
| 159 | 159 | |
| @@ -683,7 +683,7 @@ static void ovl_cleanup_index(struct dentry *dentry) · 682 unmodified lines | ||
| 683 | 683 | struct dentry *upperdentry = ovl_dentry_upper(dentry); |
| 684 | 684 | struct dentry *index = NULL; |
| 685 | 685 | struct inode *inode; |
| 686 | − struct qstr name; | |
| 686 | + struct qstr name = { }; | |
| 687 | 687 | int err; |
| 688 | 688 | |
| 689 | 689 | err = ovl_get_index_name(lowerdentry, &name); |
| @@ -726,6 +726,7 @@ static void ovl_cleanup_index(struct dentry *dentry) · 36 unmodified lines | ||
| 726 | 726 | goto fail; |
| 727 | 727 | |
| 728 | 728 | out: |
| 729 | + kfree(name.name); | |
| 729 | 730 | dput(index); |
| 730 | 731 | return; |
| 731 | 732 | |
| @@ -407,6 +407,20 @@ static int proc_pid_stack(struct seq_file *m, struct pid_namespace *ns, · 406 unmodified lines | ||
| 407 | 407 | unsigned long *entries; |
| 408 | 408 | int err; |
| 409 | 409 | |
| 410 | + /* | |
| 411 | + * The ability to racily run the kernel stack unwinder on a running task | |
| 412 | + * and then observe the unwinder output is scary; while it is useful for | |
| 413 | + * debugging kernel issues, it can also allow an attacker to leak kernel | |
| 414 | + * stack contents. | |
| 415 | + * Doing this in a manner that is at least safe from races would require | |
| 416 | + * some work to ensure that the remote task can not be scheduled; and | |
| 417 | + * even then, this would still expose the unwinder as local attack | |
| 418 | + * surface. | |
| 419 | + * Therefore, this interface is restricted to root. | |
| 420 | + */ | |
| 421 | + if (!file_ns_capable(m->file, &init_user_ns, CAP_SYS_ADMIN)) | |
| 422 | + return -EACCES; | |
| 423 | + | |
| 410 | 424 | entries = kmalloc_array(MAX_STACK_TRACE_DEPTH, sizeof(*entries), |
| 411 | 425 | GFP_KERNEL); |
| 412 | 426 | if (!entries) |
| @@ -898,8 +898,22 @@ static struct platform_driver ramoops_driver = { · 897 unmodified lines | ||
| 898 | 898 | }, |
| 899 | 899 | }; |
| 900 | 900 | |
| 901 | −static void ramoops_register_dummy(void) | |
| 901 | +static inline void ramoops_unregister_dummy(void) | |
| 902 | 902 | { |
| 903 | + platform_device_unregister(dummy); | |
| 904 | + dummy = NULL; | |
| 905 | + | |
| 906 | + kfree(dummy_data); | |
| 907 | + dummy_data = NULL; | |
| 908 | +} | |
| 909 | + | |
| 910 | +static void __init ramoops_register_dummy(void) | |
| 911 | +{ | |
| 912 | + /* | |
| 913 | + * Prepare a dummy platform data structure to carry the module | |
| 914 | + * parameters. If mem_size isn't set, then there are no module | |
| 915 | + * parameters, and we can skip this. | |
| 916 | + */ | |
| 903 | 917 | if (!mem_size) |
| 904 | 918 | return; |
| 905 | 919 | |
| @@ -932,21 +946,28 @@ static void ramoops_register_dummy(void) · 26 unmodified lines | ||
| 932 | 946 | if (IS_ERR(dummy)) { |
| 933 | 947 | pr_info("could not create platform device: %ld\n", |
| 934 | 948 | PTR_ERR(dummy)); |
| 949 | + dummy = NULL; | |
| 950 | + ramoops_unregister_dummy(); | |
| 935 | 951 | } |
| 936 | 952 | } |
| 937 | 953 | |
| 938 | 954 | static int __init ramoops_init(void) |
| 939 | 955 | { |
| 956 | + int ret; | |
| 957 | + | |
| 940 | 958 | ramoops_register_dummy(); |
| 941 | − return platform_driver_register(&ramoops_driver); | |
| 959 | + ret = platform_driver_register(&ramoops_driver); | |
| 960 | + if (ret != 0) | |
| 961 | + ramoops_unregister_dummy(); | |
| 962 | + | |
| 963 | + return ret; | |
| 942 | 964 | } |
| 943 | 965 | late_initcall(ramoops_init); |
| 944 | 966 | |
| 945 | 967 | static void __exit ramoops_exit(void) |
| 946 | 968 | { |
| 947 | 969 | platform_driver_unregister(&ramoops_driver); |
| 948 | − platform_device_unregister(dummy); | |
| 949 | − kfree(dummy_data); | |
| 970 | + ramoops_unregister_dummy(); | |
| 950 | 971 | } |
| 951 | 972 | module_exit(ramoops_exit); |
| 952 | 973 | |
| @@ -1818,8 +1818,8 @@ int vfs_clone_file_prep_inodes(struct inode *inode_in, loff_t pos_in, · 1817 unmodified lines | ||
| 1818 | 1818 | } |
| 1819 | 1819 | EXPORT_SYMBOL(vfs_clone_file_prep_inodes); |
| 1820 | 1820 | |
| 1821 | −int vfs_clone_file_range(struct file *file_in, loff_t pos_in, | |
| 1822 | − struct file *file_out, loff_t pos_out, u64 len) | |
| 1821 | +int do_clone_file_range(struct file *file_in, loff_t pos_in, | |
| 1822 | + struct file *file_out, loff_t pos_out, u64 len) | |
| 1823 | 1823 | { |
| 1824 | 1824 | struct inode *inode_in = file_inode(file_in); |
| 1825 | 1825 | struct inode *inode_out = file_inode(file_out); |
| @@ -1866,6 +1866,19 @@ int vfs_clone_file_range(struct file *file_in, loff_t pos_in, · 40 unmodified lines | ||
| 1866 | 1866 | |
| 1867 | 1867 | return ret; |
| 1868 | 1868 | } |
| 1869 | +EXPORT_SYMBOL(do_clone_file_range); | |
| 1870 | + | |
| 1871 | +int vfs_clone_file_range(struct file *file_in, loff_t pos_in, | |
| 1872 | + struct file *file_out, loff_t pos_out, u64 len) | |
| 1873 | +{ | |
| 1874 | + int ret; | |
| 1875 | + | |
| 1876 | + file_start_write(file_out); | |
| 1877 | + ret = do_clone_file_range(file_in, pos_in, file_out, pos_out, len); | |
| 1878 | + file_end_write(file_out); | |
| 1879 | + | |
| 1880 | + return ret; | |
| 1881 | +} | |
| 1869 | 1882 | EXPORT_SYMBOL(vfs_clone_file_range); |
| 1870 | 1883 | |
| 1871 | 1884 | /* |
| @@ -948,17 +948,19 @@ ssize_t simple_xattr_list(struct inode *inode, struct simple_xattrs *xattrs, · 947 unmodified lines | ||
| 948 | 948 | int err = 0; |
| 949 | 949 | |
| 950 | 950 | #ifdef CONFIG_FS_POSIX_ACL |
| 951 | − if (inode->i_acl) { | |
| 952 | − err = xattr_list_one(&buffer, &remaining_size, | |
| 953 | − XATTR_NAME_POSIX_ACL_ACCESS); | |
| 954 | − if (err) | |
| 955 | − return err; | |
| 956 | − } | |
| 957 | − if (inode->i_default_acl) { | |
| 958 | − err = xattr_list_one(&buffer, &remaining_size, | |
| 959 | − XATTR_NAME_POSIX_ACL_DEFAULT); | |
| 960 | − if (err) | |
| 961 | − return err; | |
| 951 | + if (IS_POSIXACL(inode)) { | |
| 952 | + if (inode->i_acl) { | |
| 953 | + err = xattr_list_one(&buffer, &remaining_size, | |
| 954 | + XATTR_NAME_POSIX_ACL_ACCESS); | |
| 955 | + if (err) | |
| 956 | + return err; | |
| 957 | + } | |
| 958 | + if (inode->i_default_acl) { | |
| 959 | + err = xattr_list_one(&buffer, &remaining_size, | |
| 960 | + XATTR_NAME_POSIX_ACL_DEFAULT); | |
| 961 | + if (err) | |
| 962 | + return err; | |
| 963 | + } | |
| 962 | 964 | } |
| 963 | 965 | #endif |
| 964 | 966 | |
| @@ -587,7 +587,7 @@ xfs_attr_leaf_addname( · 586 unmodified lines | ||
| 587 | 587 | */ |
| 588 | 588 | error = xfs_attr3_leaf_to_node(args); |
| 589 | 589 | if (error) |
| 590 | − goto out_defer_cancel; | |
| 590 | + return error; | |
| 591 | 591 | error = xfs_defer_finish(&args->trans); |
| 592 | 592 | if (error) |
| 593 | 593 | return error; |
| @@ -675,7 +675,7 @@ xfs_attr_leaf_addname( · 81 unmodified lines | ||
| 675 | 675 | error = xfs_attr3_leaf_to_shortform(bp, args, forkoff); |
| 676 | 676 | /* bp is gone due to xfs_da_shrink_inode */ |
| 677 | 677 | if (error) |
| 678 | − goto out_defer_cancel; | |
| 678 | + return error; | |
| 679 | 679 | error = xfs_defer_finish(&args->trans); |
| 680 | 680 | if (error) |
| 681 | 681 | return error; |
| @@ -693,9 +693,6 @@ xfs_attr_leaf_addname( · 11 unmodified lines | ||
| 693 | 693 | error = xfs_attr3_leaf_clearflag(args); |
| 694 | 694 | } |
| 695 | 695 | return error; |
| 696 | −out_defer_cancel: | |
| 697 | − xfs_defer_cancel(args->trans); | |
| 698 | − return error; | |
| 699 | 696 | } |
| 700 | 697 | |
| 701 | 698 | /* |
| @@ -738,15 +735,12 @@ xfs_attr_leaf_removename( · 36 unmodified lines | ||
| 738 | 735 | error = xfs_attr3_leaf_to_shortform(bp, args, forkoff); |
| 739 | 736 | /* bp is gone due to xfs_da_shrink_inode */ |
| 740 | 737 | if (error) |
| 741 | − goto out_defer_cancel; | |
| 738 | + return error; | |
| 742 | 739 | error = xfs_defer_finish(&args->trans); |
| 743 | 740 | if (error) |
| 744 | 741 | return error; |
| 745 | 742 | } |
| 746 | 743 | return 0; |
| 747 | −out_defer_cancel: | |
| 748 | − xfs_defer_cancel(args->trans); | |
| 749 | − return error; | |
| 750 | 744 | } |
| 751 | 745 | |
| 752 | 746 | /* |
| @@ -864,7 +858,7 @@ restart: · 111 unmodified lines | ||
| 864 | 858 | state = NULL; |
| 865 | 859 | error = xfs_attr3_leaf_to_node(args); |
| 866 | 860 | if (error) |
| 867 | − goto out_defer_cancel; | |
| 861 | + goto out; | |
| 868 | 862 | error = xfs_defer_finish(&args->trans); |
| 869 | 863 | if (error) |
| 870 | 864 | goto out; |
| @@ -888,7 +882,7 @@ restart: · 17 unmodified lines | ||
| 888 | 882 | */ |
| 889 | 883 | error = xfs_da3_split(state); |
| 890 | 884 | if (error) |
| 891 | − goto out_defer_cancel; | |
| 885 | + goto out; | |
| 892 | 886 | error = xfs_defer_finish(&args->trans); |
| 893 | 887 | if (error) |
| 894 | 888 | goto out; |
| @@ -984,7 +978,7 @@ restart: · 89 unmodified lines | ||
| 984 | 978 | if (retval && (state->path.active > 1)) { |
| 985 | 979 | error = xfs_da3_join(state); |
| 986 | 980 | if (error) |
| 987 | − goto out_defer_cancel; | |
| 981 | + goto out; | |
| 988 | 982 | error = xfs_defer_finish(&args->trans); |
| 989 | 983 | if (error) |
| 990 | 984 | goto out; |
| @@ -1013,9 +1007,6 @@ out: · 22 unmodified lines | ||
| 1013 | 1007 | if (error) |
| 1014 | 1008 | return error; |
| 1015 | 1009 | return retval; |
| 1016 | −out_defer_cancel: | |
| 1017 | − xfs_defer_cancel(args->trans); | |
| 1018 | − goto out; | |
| 1019 | 1010 | } |
| 1020 | 1011 | |
| 1021 | 1012 | /* |
| @@ -1107,7 +1098,7 @@ xfs_attr_node_removename( · 85 unmodified lines | ||
| 1107 | 1098 | if (retval && (state->path.active > 1)) { |
| 1108 | 1099 | error = xfs_da3_join(state); |
| 1109 | 1100 | if (error) |
| 1110 | − goto out_defer_cancel; | |
| 1101 | + goto out; | |
| 1111 | 1102 | error = xfs_defer_finish(&args->trans); |
| 1112 | 1103 | if (error) |
| 1113 | 1104 | goto out; |
| @@ -1138,7 +1129,7 @@ xfs_attr_node_removename( · 24 unmodified lines | ||
| 1138 | 1129 | error = xfs_attr3_leaf_to_shortform(bp, args, forkoff); |
| 1139 | 1130 | /* bp is gone due to xfs_da_shrink_inode */ |
| 1140 | 1131 | if (error) |
| 1141 | − goto out_defer_cancel; | |
| 1132 | + goto out; | |
| 1142 | 1133 | error = xfs_defer_finish(&args->trans); |
| 1143 | 1134 | if (error) |
| 1144 | 1135 | goto out; |
| @@ -1150,9 +1141,6 @@ xfs_attr_node_removename( · 5 unmodified lines | ||
| 1150 | 1141 | out: |
| 1151 | 1142 | xfs_da_state_free(state); |
| 1152 | 1143 | return error; |
| 1153 | −out_defer_cancel: | |
| 1154 | − xfs_defer_cancel(args->trans); | |
| 1155 | − goto out; | |
| 1156 | 1144 | } |
| 1157 | 1145 | |
| 1158 | 1146 | /* |
| @@ -485,7 +485,7 @@ xfs_attr_rmtval_set( · 484 unmodified lines | ||
| 485 | 485 | blkcnt, XFS_BMAPI_ATTRFORK, args->total, &map, |
| 486 | 486 | &nmap); |
| 487 | 487 | if (error) |
| 488 | − goto out_defer_cancel; | |
| 488 | + return error; | |
| 489 | 489 | error = xfs_defer_finish(&args->trans); |
| 490 | 490 | if (error) |
| 491 | 491 | return error; |
| @@ -553,9 +553,6 @@ xfs_attr_rmtval_set( · 61 unmodified lines | ||
| 553 | 553 | } |
| 554 | 554 | ASSERT(valuelen == 0); |
| 555 | 555 | return 0; |
| 556 | −out_defer_cancel: | |
| 557 | − xfs_defer_cancel(args->trans); | |
| 558 | − return error; | |
| 559 | 556 | } |
| 560 | 557 | |
| 561 | 558 | /* |
| @@ -625,7 +622,7 @@ xfs_attr_rmtval_remove( · 63 unmodified lines | ||
| 625 | 622 | error = xfs_bunmapi(args->trans, args->dp, lblkno, blkcnt, |
| 626 | 623 | XFS_BMAPI_ATTRFORK, 1, &done); |
| 627 | 624 | if (error) |
| 628 | − goto out_defer_cancel; | |
| 625 | + return error; | |
| 629 | 626 | error = xfs_defer_finish(&args->trans); |
| 630 | 627 | if (error) |
| 631 | 628 | return error; |
| @@ -638,7 +635,4 @@ xfs_attr_rmtval_remove( · 6 unmodified lines | ||
| 638 | 635 | return error; |
| 639 | 636 | } |
| 640 | 637 | return 0; |
| 641 | −out_defer_cancel: | |
| 642 | − xfs_defer_cancel(args->trans); | |
| 643 | − return error; | |
| 644 | 638 | } |
| @@ -673,7 +673,8 @@ xfs_bmap_extents_to_btree( · 672 unmodified lines | ||
| 673 | 673 | ASSERT(XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_EXTENTS); |
| 674 | 674 | |
| 675 | 675 | /* |
| 676 | − * Make space in the inode incore. | |
| 676 | + * Make space in the inode incore. This needs to be undone if we fail | |
| 677 | + * to expand the root. | |
| 677 | 678 | */ |
| 678 | 679 | xfs_iroot_realloc(ip, 1, whichfork); |
| 679 | 680 | ifp->if_flags |= XFS_IFBROOT; |
| @@ -711,16 +712,15 @@ xfs_bmap_extents_to_btree( · 31 unmodified lines | ||
| 711 | 712 | args.minlen = args.maxlen = args.prod = 1; |
| 712 | 713 | args.wasdel = wasdel; |
| 713 | 714 | *logflagsp = 0; |
| 714 | − if ((error = xfs_alloc_vextent(&args))) { | |
| 715 | − ASSERT(ifp->if_broot == NULL); | |
| 716 | − goto err1; | |
| 717 | − } | |
| 715 | + error = xfs_alloc_vextent(&args); | |
| 716 | + if (error) | |
| 717 | + goto out_root_realloc; | |
| 718 | 718 | |
| 719 | 719 | if (WARN_ON_ONCE(args.fsbno == NULLFSBLOCK)) { |
| 720 | − ASSERT(ifp->if_broot == NULL); | |
| 721 | 720 | error = -ENOSPC; |
| 722 | − goto err1; | |
| 721 | + goto out_root_realloc; | |
| 723 | 722 | } |
| 723 | + | |
| 724 | 724 | /* |
| 725 | 725 | * Allocation can't fail, the space was reserved. |
| 726 | 726 | */ |
| @@ -732,9 +732,10 @@ xfs_bmap_extents_to_btree( · 5 unmodified lines | ||
| 732 | 732 | xfs_trans_mod_dquot_byino(tp, ip, XFS_TRANS_DQ_BCOUNT, 1L); |
| 733 | 733 | abp = xfs_btree_get_bufl(mp, tp, args.fsbno, 0); |
| 734 | 734 | if (!abp) { |
| 735 | − error = -ENOSPC; | |
| 736 | − goto err2; | |
| 735 | + error = -EFSCORRUPTED; | |
| 736 | + goto out_unreserve_dquot; | |
| 737 | 737 | } |
| 738 | + | |
| 738 | 739 | /* |
| 739 | 740 | * Fill in the child block. |
| 740 | 741 | */ |
| @@ -775,11 +776,12 @@ xfs_bmap_extents_to_btree( · 34 unmodified lines | ||
| 775 | 776 | *logflagsp = XFS_ILOG_CORE | xfs_ilog_fbroot(whichfork); |
| 776 | 777 | return 0; |
| 777 | 778 | |
| 778 | −err2: | |
| 779 | +out_unreserve_dquot: | |
| 779 | 780 | xfs_trans_mod_dquot_byino(tp, ip, XFS_TRANS_DQ_BCOUNT, -1L); |
| 780 | −err1: | |
| 781 | +out_root_realloc: | |
| 781 | 782 | xfs_iroot_realloc(ip, -1, whichfork); |
| 782 | 783 | XFS_IFORK_FMT_SET(ip, whichfork, XFS_DINODE_FMT_EXTENTS); |
| 784 | + ASSERT(ifp->if_broot == NULL); | |
| 783 | 785 | xfs_btree_del_cursor(cur, XFS_BTREE_ERROR); |
| 784 | 786 | |
| 785 | 787 | return error; |
| @@ -1016,6 +1016,8 @@ static inline void xfs_dinode_put_rdev(struct xfs_dinode *dip, xfs_dev_t rdev) · 1015 unmodified lines | ||
| 1016 | 1016 | #define XFS_DIFLAG_EXTSZINHERIT_BIT 12 /* inherit inode extent size */ |
| 1017 | 1017 | #define XFS_DIFLAG_NODEFRAG_BIT 13 /* do not reorganize/defragment */ |
| 1018 | 1018 | #define XFS_DIFLAG_FILESTREAM_BIT 14 /* use filestream allocator */ |
| 1019 | +/* Do not use bit 15, di_flags is legacy and unchanging now */ | |
| 1020 | + | |
| 1019 | 1021 | #define XFS_DIFLAG_REALTIME (1 << XFS_DIFLAG_REALTIME_BIT) |
| 1020 | 1022 | #define XFS_DIFLAG_PREALLOC (1 << XFS_DIFLAG_PREALLOC_BIT) |
| 1021 | 1023 | #define XFS_DIFLAG_NEWRTBM (1 << XFS_DIFLAG_NEWRTBM_BIT) |
| @@ -415,6 +415,31 @@ xfs_dinode_verify_fork( · 414 unmodified lines | ||
| 415 | 415 | return NULL; |
| 416 | 416 | } |
| 417 | 417 | |
| 418 | +static xfs_failaddr_t | |
| 419 | +xfs_dinode_verify_forkoff( | |
| 420 | + struct xfs_dinode *dip, | |
| 421 | + struct xfs_mount *mp) | |
| 422 | +{ | |
| 423 | + if (!XFS_DFORK_Q(dip)) | |
| 424 | + return NULL; | |
| 425 | + | |
| 426 | + switch (dip->di_format) { | |
| 427 | + case XFS_DINODE_FMT_DEV: | |
| 428 | + if (dip->di_forkoff != (roundup(sizeof(xfs_dev_t), 8) >> 3)) | |
| 429 | + return __this_address; | |
| 430 | + break; | |
| 431 | + case XFS_DINODE_FMT_LOCAL: /* fall through ... */ | |
| 432 | + case XFS_DINODE_FMT_EXTENTS: /* fall through ... */ | |
| 433 | + case XFS_DINODE_FMT_BTREE: | |
| 434 | + if (dip->di_forkoff >= (XFS_LITINO(mp, dip->di_version) >> 3)) | |
| 435 | + return __this_address; | |
| 436 | + break; | |
| 437 | + default: | |
| 438 | + return __this_address; | |
| 439 | + } | |
| 440 | + return NULL; | |
| 441 | +} | |
| 442 | + | |
| 418 | 443 | xfs_failaddr_t |
| 419 | 444 | xfs_dinode_verify( |
| 420 | 445 | struct xfs_mount *mp, |
| @@ -470,6 +495,11 @@ xfs_dinode_verify( · 49 unmodified lines | ||
| 470 | 495 | if (mode && (flags & XFS_DIFLAG_REALTIME) && !mp->m_rtdev_targp) |
| 471 | 496 | return __this_address; |
| 472 | 497 | |
| 498 | + /* check for illegal values of forkoff */ | |
| 499 | + fa = xfs_dinode_verify_forkoff(dip, mp); | |
| 500 | + if (fa) | |
| 501 | + return fa; | |
| 502 | + | |
| 473 | 503 | /* Do we have appropriate data fork formats for the mode? */ |
| 474 | 504 | switch (mode & S_IFMT) { |
| 475 | 505 | case S_IFIFO: |
| @@ -17,7 +17,6 @@ · 16 unmodified lines | ||
| 17 | 17 | #include "xfs_sb.h" |
| 18 | 18 | #include "xfs_alloc.h" |
| 19 | 19 | #include "xfs_rmap.h" |
| 20 | −#include "xfs_alloc.h" | |
| 21 | 20 | #include "scrub/xfs_scrub.h" |
| 22 | 21 | #include "scrub/scrub.h" |
| 23 | 22 | #include "scrub/common.h" |
| @@ -126,6 +126,7 @@ xchk_inode_flags( · 125 unmodified lines | ||
| 126 | 126 | { |
| 127 | 127 | struct xfs_mount *mp = sc->mp; |
| 128 | 128 | |
| 129 | + /* di_flags are all taken, last bit cannot be used */ | |
| 129 | 130 | if (flags & ~XFS_DIFLAG_ANY) |
| 130 | 131 | goto bad; |
| 131 | 132 | |
| @@ -172,8 +173,9 @@ xchk_inode_flags2( · 40 unmodified lines | ||
| 172 | 173 | { |
| 173 | 174 | struct xfs_mount *mp = sc->mp; |
| 174 | 175 | |
| 176 | + /* Unknown di_flags2 could be from a future kernel */ | |
| 175 | 177 | if (flags2 & ~XFS_DIFLAG2_ANY) |
| 176 | − goto bad; | |
| 178 | + xchk_ino_set_warning(sc, ino); | |
| 177 | 179 | |
| 178 | 180 | /* reflink flag requires reflink feature */ |
| 179 | 181 | if ((flags2 & XFS_DIFLAG2_REFLINK) && |
| @@ -702,13 +702,9 @@ xfs_bmap_punch_delalloc_range( · 701 unmodified lines | ||
| 702 | 702 | struct xfs_iext_cursor icur; |
| 703 | 703 | int error = 0; |
| 704 | 704 | |
| 705 | − xfs_ilock(ip, XFS_ILOCK_EXCL); | |
| 706 | − if (!(ifp->if_flags & XFS_IFEXTENTS)) { | |
| 707 | − error = xfs_iread_extents(NULL, ip, XFS_DATA_FORK); | |
| 708 | − if (error) | |
| 709 | − goto out_unlock; | |
| 710 | − } | |
| 705 | + ASSERT(ifp->if_flags & XFS_IFEXTENTS); | |
| 711 | 706 | |
| 707 | + xfs_ilock(ip, XFS_ILOCK_EXCL); | |
| 712 | 708 | if (!xfs_iext_lookup_extent_before(ip, ifp, &end_fsb, &icur, &got)) |
| 713 | 709 | goto out_unlock; |
| 714 | 710 | |
| @@ -1584,7 +1580,7 @@ xfs_swap_extent_rmap( · 869 unmodified lines | ||
| 1584 | 1580 | tirec.br_blockcount, &irec, |
| 1585 | 1581 | &nimaps, 0); |
| 1586 | 1582 | if (error) |
| 1587 | − goto out_defer; | |
| 1583 | + goto out; | |
| 1588 | 1584 | ASSERT(nimaps == 1); |
| 1589 | 1585 | ASSERT(tirec.br_startoff == irec.br_startoff); |
| 1590 | 1586 | trace_xfs_swap_extent_rmap_remap_piece(ip, &irec); |
| @@ -1599,22 +1595,22 @@ xfs_swap_extent_rmap( · 8 unmodified lines | ||
| 1599 | 1595 | /* Remove the mapping from the donor file. */ |
| 1600 | 1596 | error = xfs_bmap_unmap_extent(tp, tip, &uirec); |
| 1601 | 1597 | if (error) |
| 1602 | − goto out_defer; | |
| 1598 | + goto out; | |
| 1603 | 1599 | |
| 1604 | 1600 | /* Remove the mapping from the source file. */ |
| 1605 | 1601 | error = xfs_bmap_unmap_extent(tp, ip, &irec); |
| 1606 | 1602 | if (error) |
| 1607 | − goto out_defer; | |
| 1603 | + goto out; | |
| 1608 | 1604 | |
| 1609 | 1605 | /* Map the donor file's blocks into the source file. */ |
| 1610 | 1606 | error = xfs_bmap_map_extent(tp, ip, &uirec); |
| 1611 | 1607 | if (error) |
| 1612 | − goto out_defer; | |
| 1608 | + goto out; | |
| 1613 | 1609 | |
| 1614 | 1610 | /* Map the source file's blocks into the donor file. */ |
| 1615 | 1611 | error = xfs_bmap_map_extent(tp, tip, &irec); |
| 1616 | 1612 | if (error) |
| 1617 | − goto out_defer; | |
| 1613 | + goto out; | |
| 1618 | 1614 | |
| 1619 | 1615 | error = xfs_defer_finish(tpp); |
| 1620 | 1616 | tp = *tpp; |
| @@ -1636,8 +1632,6 @@ xfs_swap_extent_rmap( · 15 unmodified lines | ||
| 1636 | 1632 | tip->i_d.di_flags2 = tip_flags2; |
| 1637 | 1633 | return 0; |
| 1638 | 1634 | |
| 1639 | −out_defer: | |
| 1640 | − xfs_defer_cancel(tp); | |
| 1641 | 1635 | out: |
| 1642 | 1636 | trace_xfs_swap_extent_rmap_error(ip, error, _RET_IP_); |
| 1643 | 1637 | tip->i_d.di_flags2 = tip_flags2; |
| @@ -531,6 +531,49 @@ xfs_buf_item_push( · 530 unmodified lines | ||
| 531 | 531 | return rval; |
| 532 | 532 | } |
| 533 | 533 | |
| 534 | +/* | |
| 535 | + * Drop the buffer log item refcount and take appropriate action. This helper | |
| 536 | + * determines whether the bli must be freed or not, since a decrement to zero | |
| 537 | + * does not necessarily mean the bli is unused. | |
| 538 | + * | |
| 539 | + * Return true if the bli is freed, false otherwise. | |
| 540 | + */ | |
| 541 | +bool | |
| 542 | +xfs_buf_item_put( | |
| 543 | + struct xfs_buf_log_item *bip) | |
| 544 | +{ | |
| 545 | + struct xfs_log_item *lip = &bip->bli_item; | |
| 546 | + bool aborted; | |
| 547 | + bool dirty; | |
| 548 | + | |
| 549 | + /* drop the bli ref and return if it wasn't the last one */ | |
| 550 | + if (!atomic_dec_and_test(&bip->bli_refcount)) | |
| 551 | + return false; | |
| 552 | + | |
| 553 | + /* | |
| 554 | + * We dropped the last ref and must free the item if clean or aborted. | |
| 555 | + * If the bli is dirty and non-aborted, the buffer was clean in the | |
| 556 | + * transaction but still awaiting writeback from previous changes. In | |
| 557 | + * that case, the bli is freed on buffer writeback completion. | |
| 558 | + */ | |
| 559 | + aborted = test_bit(XFS_LI_ABORTED, &lip->li_flags) || | |
| 560 | + XFS_FORCED_SHUTDOWN(lip->li_mountp); | |
| 561 | + dirty = bip->bli_flags & XFS_BLI_DIRTY; | |
| 562 | + if (dirty && !aborted) | |
| 563 | + return false; | |
| 564 | + | |
| 565 | + /* | |
| 566 | + * The bli is aborted or clean. An aborted item may be in the AIL | |
| 567 | + * regardless of dirty state. For example, consider an aborted | |
| 568 | + * transaction that invalidated a dirty bli and cleared the dirty | |
| 569 | + * state. | |
| 570 | + */ | |
| 571 | + if (aborted) | |
| 572 | + xfs_trans_ail_remove(lip, SHUTDOWN_LOG_IO_ERROR); | |
| 573 | + xfs_buf_item_relse(bip->bli_buf); | |
| 574 | + return true; | |
| 575 | +} | |
| 576 | + | |
| 534 | 577 | /* |
| 535 | 578 | * Release the buffer associated with the buf log item. If there is no dirty |
| 536 | 579 | * logged data associated with the buffer recorded in the buf log item, then |
| @@ -556,76 +599,42 @@ xfs_buf_item_unlock( · 19 unmodified lines | ||
| 556 | 599 | { |
| 557 | 600 | struct xfs_buf_log_item *bip = BUF_ITEM(lip); |
| 558 | 601 | struct xfs_buf *bp = bip->bli_buf; |
| 559 | − bool aborted; | |
| 560 | − bool hold = !!(bip->bli_flags & XFS_BLI_HOLD); | |
| 561 | − bool dirty = !!(bip->bli_flags & XFS_BLI_DIRTY); | |
| 602 | + bool released; | |
| 603 | + bool hold = bip->bli_flags & XFS_BLI_HOLD; | |
| 604 | + bool stale = bip->bli_flags & XFS_BLI_STALE; | |
| 562 | 605 | #if defined(DEBUG) || defined(XFS_WARN) |
| 563 | − bool ordered = !!(bip->bli_flags & XFS_BLI_ORDERED); | |
| 606 | + bool ordered = bip->bli_flags & XFS_BLI_ORDERED; | |
| 607 | + bool dirty = bip->bli_flags & XFS_BLI_DIRTY; | |
| 564 | 608 | #endif |
| 565 | 609 | |
| 566 | − aborted = test_bit(XFS_LI_ABORTED, &lip->li_flags); | |
| 567 | − | |
| 568 | − /* Clear the buffer's association with this transaction. */ | |
| 569 | − bp->b_transp = NULL; | |
| 570 | − | |
| 571 | − /* | |
| 572 | − * The per-transaction state has been copied above so clear it from the | |
| 573 | − * bli. | |
| 574 | − */ | |
| 575 | − bip->bli_flags &= ~(XFS_BLI_LOGGED | XFS_BLI_HOLD | XFS_BLI_ORDERED); | |
| 576 | − | |
| 577 | − /* | |
| 578 | − * If the buf item is marked stale, then don't do anything. We'll | |
| 579 | − * unlock the buffer and free the buf item when the buffer is unpinned | |
| 580 | − * for the last time. | |
| 581 | − */ | |
| 582 | − if (bip->bli_flags & XFS_BLI_STALE) { | |
| 583 | − trace_xfs_buf_item_unlock_stale(bip); | |
| 584 | − ASSERT(bip->__bli_format.blf_flags & XFS_BLF_CANCEL); | |
| 585 | − if (!aborted) { | |
| 586 | − atomic_dec(&bip->bli_refcount); | |
| 587 | − return; | |
| 588 | − } | |
| 589 | − } | |
| 590 | − | |
| 591 | 610 | trace_xfs_buf_item_unlock(bip); |
| 592 | 611 | |
| 593 | 612 | /* |
| 594 | − * If the buf item isn't tracking any data, free it, otherwise drop the | |
| 595 | − * reference we hold to it. If we are aborting the transaction, this may | |
| 596 | − * be the only reference to the buf item, so we free it anyway | |
| 597 | − * regardless of whether it is dirty or not. A dirty abort implies a | |
| 598 | − * shutdown, anyway. | |
| 599 | − * | |
| 600 | 613 | * The bli dirty state should match whether the blf has logged segments |
| 601 | 614 | * except for ordered buffers, where only the bli should be dirty. |
| 602 | 615 | */ |
| 603 | 616 | ASSERT((!ordered && dirty == xfs_buf_item_dirty_format(bip)) || |
| 604 | 617 | (ordered && dirty && !xfs_buf_item_dirty_format(bip))); |
| 618 | + ASSERT(!stale || (bip->__bli_format.blf_flags & XFS_BLF_CANCEL)); | |
| 605 | 619 | |
| 606 | 620 | /* |
| 607 | − * Clean buffers, by definition, cannot be in the AIL. However, aborted | |
| 608 | − * buffers may be in the AIL regardless of dirty state. An aborted | |
| 609 | − * transaction that invalidates a buffer already in the AIL may have | |
| 610 | − * marked it stale and cleared the dirty state, for example. | |
| 611 | − * | |
| 612 | − * Therefore if we are aborting a buffer and we've just taken the last | |
| 613 | − * reference away, we have to check if it is in the AIL before freeing | |
| 614 | − * it. We need to free it in this case, because an aborted transaction | |
| 615 | − * has already shut the filesystem down and this is the last chance we | |
| 616 | − * will have to do so. | |
| 621 | + * Clear the buffer's association with this transaction and | |
| 622 | + * per-transaction state from the bli, which has been copied above. | |
| 617 | 623 | */ |
| 618 | − if (atomic_dec_and_test(&bip->bli_refcount)) { | |
| 619 | − if (aborted) { | |
| 620 | − ASSERT(XFS_FORCED_SHUTDOWN(lip->li_mountp)); | |
| 621 | − xfs_trans_ail_remove(lip, SHUTDOWN_LOG_IO_ERROR); | |
| 622 | − xfs_buf_item_relse(bp); | |
| 623 | − } else if (!dirty) | |
| 624 | − xfs_buf_item_relse(bp); | |
| 625 | − } | |
| 624 | + bp->b_transp = NULL; | |
| 625 | + bip->bli_flags &= ~(XFS_BLI_LOGGED | XFS_BLI_HOLD | XFS_BLI_ORDERED); | |
| 626 | 626 | |
| 627 | − if (!hold) | |
| 628 | − xfs_buf_relse(bp); | |
| 627 | + /* | |
| 628 | + * Unref the item and unlock the buffer unless held or stale. Stale | |
| 629 | + * buffers remain locked until final unpin unless the bli is freed by | |
| 630 | + * the unref call. The latter implies shutdown because buffer | |
| 631 | + * invalidation dirties the bli and transaction. | |
| 632 | + */ | |
| 633 | + released = xfs_buf_item_put(bip); | |
| 634 | + if (hold || (stale && !released)) | |
| 635 | + return; | |
| 636 | + ASSERT(!stale || test_bit(XFS_LI_ABORTED, &lip->li_flags)); | |
| 637 | + xfs_buf_relse(bp); | |
| 629 | 638 | } |
| 630 | 639 | |
| 631 | 640 | /* |
| @@ -51,6 +51,7 @@ struct xfs_buf_log_item { · 50 unmodified lines | ||
| 51 | 51 | |
| 52 | 52 | int xfs_buf_item_init(struct xfs_buf *, struct xfs_mount *); |
| 53 | 53 | void xfs_buf_item_relse(struct xfs_buf *); |
| 54 | +bool xfs_buf_item_put(struct xfs_buf_log_item *); | |
| 54 | 55 | void xfs_buf_item_log(struct xfs_buf_log_item *, uint, uint); |
| 55 | 56 | bool xfs_buf_item_dirty_format(struct xfs_buf_log_item *); |
| 56 | 57 | void xfs_buf_attach_iodone(struct xfs_buf *, |
| @@ -1563,7 +1563,7 @@ xfs_itruncate_extents_flags( · 1562 unmodified lines | ||
| 1563 | 1563 | error = xfs_bunmapi(tp, ip, first_unmap_block, unmap_len, flags, |
| 1564 | 1564 | XFS_ITRUNC_MAX_EXTENTS, &done); |
| 1565 | 1565 | if (error) |
| 1566 | − goto out_bmap_cancel; | |
| 1566 | + goto out; | |
| 1567 | 1567 | |
| 1568 | 1568 | /* |
| 1569 | 1569 | * Duplicate the transaction that has the permanent |
| @@ -1599,14 +1599,6 @@ xfs_itruncate_extents_flags( · 29 unmodified lines | ||
| 1599 | 1599 | out: |
| 1600 | 1600 | *tpp = tp; |
| 1601 | 1601 | return error; |
| 1602 | −out_bmap_cancel: | |
| 1603 | − /* | |
| 1604 | − * If the bunmapi call encounters an error, return to the caller where | |
| 1605 | − * the transaction can be properly aborted. We just need to make sure | |
| 1606 | − * we're not holding any resources that we were not when we came in. | |
| 1607 | − */ | |
| 1608 | − xfs_defer_cancel(tp); | |
| 1609 | − goto out; | |
| 1610 | 1602 | } |
| 1611 | 1603 | |
| 1612 | 1604 | int |
| @@ -471,8 +471,18 @@ xfs_vn_get_link_inline( · 470 unmodified lines | ||
| 471 | 471 | struct inode *inode, |
| 472 | 472 | struct delayed_call *done) |
| 473 | 473 | { |
| 474 | + char *link; | |
| 475 | + | |
| 474 | 476 | ASSERT(XFS_I(inode)->i_df.if_flags & XFS_IFINLINE); |
| 475 | − return XFS_I(inode)->i_df.if_u1.if_data; | |
| 477 | + | |
| 478 | + /* | |
| 479 | + * The VFS crashes on a NULL pointer, so return -EFSCORRUPTED if | |
| 480 | + * if_data is junk. | |
| 481 | + */ | |
| 482 | + link = XFS_I(inode)->i_df.if_u1.if_data; | |
| 483 | + if (!link) | |
| 484 | + return ERR_PTR(-EFSCORRUPTED); | |
| 485 | + return link; | |
| 476 | 486 | } |
| 477 | 487 | |
| 478 | 488 | STATIC int |
| @@ -1570,16 +1570,6 @@ xlog_find_zeroed( · 1569 unmodified lines | ||
| 1570 | 1570 | if (last_cycle != 0) { /* log completely written to */ |
| 1571 | 1571 | xlog_put_bp(bp); |
| 1572 | 1572 | return 0; |
| 1573 | − } else if (first_cycle != 1) { | |
| 1574 | − /* | |
| 1575 | − * If the cycle of the last block is zero, the cycle of | |
| 1576 | − * the first block must be 1. If it's not, maybe we're | |
| 1577 | − * not looking at a log... Bail out. | |
| 1578 | − */ | |
| 1579 | − xfs_warn(log->l_mp, | |
| 1580 | − "Log inconsistent or not a log (last==0, first!=1)"); | |
| 1581 | − error = -EINVAL; | |
| 1582 | − goto bp_err; | |
| 1583 | 1573 | } |
| 1584 | 1574 | |
| 1585 | 1575 | /* we have a partially zeroed log */ |
| @@ -352,6 +352,47 @@ xfs_reflink_convert_cow( · 351 unmodified lines | ||
| 352 | 352 | return error; |
| 353 | 353 | } |
| 354 | 354 | |
| 355 | +/* | |
| 356 | + * Find the extent that maps the given range in the COW fork. Even if the extent | |
| 357 | + * is not shared we might have a preallocation for it in the COW fork. If so we | |
| 358 | + * use it that rather than trigger a new allocation. | |
| 359 | + */ | |
| 360 | +static int | |
| 361 | +xfs_find_trim_cow_extent( | |
| 362 | + struct xfs_inode *ip, | |
| 363 | + struct xfs_bmbt_irec *imap, | |
| 364 | + bool *shared, | |
| 365 | + bool *found) | |
| 366 | +{ | |
| 367 | + xfs_fileoff_t offset_fsb = imap->br_startoff; | |
| 368 | + xfs_filblks_t count_fsb = imap->br_blockcount; | |
| 369 | + struct xfs_iext_cursor icur; | |
| 370 | + struct xfs_bmbt_irec got; | |
| 371 | + bool trimmed; | |
| 372 | + | |
| 373 | + *found = false; | |
| 374 | + | |
| 375 | + /* | |
| 376 | + * If we don't find an overlapping extent, trim the range we need to | |
| 377 | + * allocate to fit the hole we found. | |
| 378 | + */ | |
| 379 | + if (!xfs_iext_lookup_extent(ip, ip->i_cowfp, offset_fsb, &icur, &got) || | |
| 380 | + got.br_startoff > offset_fsb) | |
| 381 | + return xfs_reflink_trim_around_shared(ip, imap, shared, &trimmed); | |
| 382 | + | |
| 383 | + *shared = true; | |
| 384 | + if (isnullstartblock(got.br_startblock)) { | |
| 385 | + xfs_trim_extent(imap, got.br_startoff, got.br_blockcount); | |
| 386 | + return 0; | |
| 387 | + } | |
| 388 | + | |
| 389 | + /* real extent found - no need to allocate */ | |
| 390 | + xfs_trim_extent(&got, offset_fsb, count_fsb); | |
| 391 | + *imap = got; | |
| 392 | + *found = true; | |
| 393 | + return 0; | |
| 394 | +} | |
| 395 | + | |
| 355 | 396 | /* Allocate all CoW reservations covering a range of blocks in a file. */ |
| 356 | 397 | int |
| 357 | 398 | xfs_reflink_allocate_cow( |
| @@ -363,78 +404,64 @@ xfs_reflink_allocate_cow( · 5 unmodified lines | ||
| 363 | 404 | struct xfs_mount *mp = ip->i_mount; |
| 364 | 405 | xfs_fileoff_t offset_fsb = imap->br_startoff; |
| 365 | 406 | xfs_filblks_t count_fsb = imap->br_blockcount; |
| 366 | − struct xfs_bmbt_irec got; | |
| 367 | − struct xfs_trans *tp = NULL; | |
| 407 | + struct xfs_trans *tp; | |
| 368 | 408 | int nimaps, error = 0; |
| 369 | − bool trimmed; | |
| 409 | + bool found; | |
| 370 | 410 | xfs_filblks_t resaligned; |
| 371 | 411 | xfs_extlen_t resblks = 0; |
| 372 | − struct xfs_iext_cursor icur; | |
| 373 | 412 | |
| 374 | −retry: | |
| 375 | − ASSERT(xfs_is_reflink_inode(ip)); | |
| 376 | 413 | ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); |
| 414 | + ASSERT(xfs_is_reflink_inode(ip)); | |
| 377 | 415 | |
| 378 | − /* | |
| 379 | − * Even if the extent is not shared we might have a preallocation for | |
| 380 | − * it in the COW fork. If so use it. | |
| 381 | − */ | |
| 382 | − if (xfs_iext_lookup_extent(ip, ip->i_cowfp, offset_fsb, &icur, &got) && | |
| 383 | − got.br_startoff <= offset_fsb) { | |
| 384 | − *shared = true; | |
| 385 | − | |
| 386 | − /* If we have a real allocation in the COW fork we're done. */ | |
| 387 | − if (!isnullstartblock(got.br_startblock)) { | |
| 388 | − xfs_trim_extent(&got, offset_fsb, count_fsb); | |
| 389 | − *imap = got; | |
| 390 | − goto convert; | |
| 391 | − } | |
| 416 | + error = xfs_find_trim_cow_extent(ip, imap, shared, &found); | |
| 417 | + if (error || !*shared) | |
| 418 | + return error; | |
| 419 | + if (found) | |
| 420 | + goto convert; | |
| 392 | 421 | |
| 393 | − xfs_trim_extent(imap, got.br_startoff, got.br_blockcount); | |
| 394 | − } else { | |
| 395 | − error = xfs_reflink_trim_around_shared(ip, imap, shared, &trimmed); | |
| 396 | − if (error || !*shared) | |
| 397 | − goto out; | |
| 398 | − } | |
| 422 | + resaligned = xfs_aligned_fsb_count(imap->br_startoff, | |
| 423 | + imap->br_blockcount, xfs_get_cowextsz_hint(ip)); | |
| 424 | + resblks = XFS_DIOSTRAT_SPACE_RES(mp, resaligned); | |
| 399 | 425 | |
| 400 | − if (!tp) { | |
| 401 | − resaligned = xfs_aligned_fsb_count(imap->br_startoff, | |
| 402 | − imap->br_blockcount, xfs_get_cowextsz_hint(ip)); | |
| 403 | − resblks = XFS_DIOSTRAT_SPACE_RES(mp, resaligned); | |
| 426 | + xfs_iunlock(ip, *lockmode); | |
| 427 | + error = xfs_trans_alloc(mp, &M_RES(mp)->tr_write, resblks, 0, 0, &tp); | |
| 428 | + *lockmode = XFS_ILOCK_EXCL; | |
| 429 | + xfs_ilock(ip, *lockmode); | |
| 404 | 430 | |
| 405 | − xfs_iunlock(ip, *lockmode); | |
| 406 | − error = xfs_trans_alloc(mp, &M_RES(mp)->tr_write, resblks, 0, 0, &tp); | |
| 407 | − *lockmode = XFS_ILOCK_EXCL; | |
| 408 | − xfs_ilock(ip, *lockmode); | |
| 431 | + if (error) | |
| 432 | + return error; | |
| 409 | 433 | |
| 410 | − if (error) | |
| 411 | − return error; | |
| 434 | + error = xfs_qm_dqattach_locked(ip, false); | |
| 435 | + if (error) | |
| 436 | + goto out_trans_cancel; | |
| 412 | 437 | |
| 413 | − error = xfs_qm_dqattach_locked(ip, false); | |
| 414 | − if (error) | |
| 415 | − goto out; | |
| 416 | − goto retry; | |
| 438 | + /* | |
| 439 | + * Check for an overlapping extent again now that we dropped the ilock. | |
| 440 | + */ | |
| 441 | + error = xfs_find_trim_cow_extent(ip, imap, shared, &found); | |
| 442 | + if (error || !*shared) | |
| 443 | + goto out_trans_cancel; | |
| 444 | + if (found) { | |
| 445 | + xfs_trans_cancel(tp); | |
| 446 | + goto convert; | |
| 417 | 447 | } |
| 418 | 448 | |
| 419 | 449 | error = xfs_trans_reserve_quota_nblks(tp, ip, resblks, 0, |
| 420 | 450 | XFS_QMOPT_RES_REGBLKS); |
| 421 | 451 | if (error) |
| 422 | − goto out; | |
| 452 | + goto out_trans_cancel; | |
| 423 | 453 | |
| 424 | 454 | xfs_trans_ijoin(tp, ip, 0); |
| 425 | 455 | |
| 426 | − nimaps = 1; | |
| 427 | − | |
| 428 | 456 | /* Allocate the entire reservation as unwritten blocks. */ |
| 457 | + nimaps = 1; | |
| 429 | 458 | error = xfs_bmapi_write(tp, ip, imap->br_startoff, imap->br_blockcount, |
| 430 | 459 | XFS_BMAPI_COWFORK | XFS_BMAPI_PREALLOC, |
| 431 | 460 | resblks, imap, &nimaps); |
| 432 | 461 | if (error) |
| 433 | − goto out_trans_cancel; | |
| 462 | + goto out_unreserve; | |
| 434 | 463 | |
| 435 | 464 | xfs_inode_set_cowblocks_tag(ip); |
| 436 | − | |
| 437 | − /* Finish up. */ | |
| 438 | 465 | error = xfs_trans_commit(tp); |
| 439 | 466 | if (error) |
| 440 | 467 | return error; |
| @@ -447,12 +474,12 @@ retry: · 6 unmodified lines | ||
| 447 | 474 | return -ENOSPC; |
| 448 | 475 | convert: |
| 449 | 476 | return xfs_reflink_convert_cow_extent(ip, imap, offset_fsb, count_fsb); |
| 450 | −out_trans_cancel: | |
| 477 | + | |
| 478 | +out_unreserve: | |
| 451 | 479 | xfs_trans_unreserve_quota_nblks(tp, ip, (long)resblks, 0, |
| 452 | 480 | XFS_QMOPT_RES_REGBLKS); |
| 453 | −out: | |
| 454 | − if (tp) | |
| 455 | − xfs_trans_cancel(tp); | |
| 481 | +out_trans_cancel: | |
| 482 | + xfs_trans_cancel(tp); | |
| 456 | 483 | return error; |
| 457 | 484 | } |
| 458 | 485 | |
| @@ -666,14 +693,12 @@ xfs_reflink_end_cow( · 207 unmodified lines | ||
| 666 | 693 | if (!del.br_blockcount) |
| 667 | 694 | goto prev_extent; |
| 668 | 695 | |
| 669 | − ASSERT(!isnullstartblock(got.br_startblock)); | |
| 670 | − | |
| 671 | 696 | /* |
| 672 | − * Don't remap unwritten extents; these are | |
| 673 | − * speculatively preallocated CoW extents that have been | |
| 674 | − * allocated but have not yet been involved in a write. | |
| 697 | + * Only remap real extent that contain data. With AIO | |
| 698 | + * speculatively preallocations can leak into the range we | |
| 699 | + * are called upon, and we need to skip them. | |
| 675 | 700 | */ |
| 676 | − if (got.br_state == XFS_EXT_UNWRITTEN) | |
| 701 | + if (!xfs_bmap_is_real_extent(&got)) | |
| 677 | 702 | goto prev_extent; |
| 678 | 703 | |
| 679 | 704 | /* Unmap the old blocks in the data fork. */ |
| @@ -473,7 +473,6 @@ DEFINE_BUF_ITEM_EVENT(xfs_buf_item_pin); · 472 unmodified lines | ||
| 473 | 473 | DEFINE_BUF_ITEM_EVENT(xfs_buf_item_unpin); |
| 474 | 474 | DEFINE_BUF_ITEM_EVENT(xfs_buf_item_unpin_stale); |
| 475 | 475 | DEFINE_BUF_ITEM_EVENT(xfs_buf_item_unlock); |
| 476 | −DEFINE_BUF_ITEM_EVENT(xfs_buf_item_unlock_stale); | |
| 477 | 476 | DEFINE_BUF_ITEM_EVENT(xfs_buf_item_committed); |
| 478 | 477 | DEFINE_BUF_ITEM_EVENT(xfs_buf_item_push); |
| 479 | 478 | DEFINE_BUF_ITEM_EVENT(xfs_trans_get_buf); |
| @@ -259,6 +259,14 @@ xfs_trans_alloc( · 258 unmodified lines | ||
| 259 | 259 | struct xfs_trans *tp; |
| 260 | 260 | int error; |
| 261 | 261 | |
| 262 | + /* | |
| 263 | + * Allocate the handle before we do our freeze accounting and setting up | |
| 264 | + * GFP_NOFS allocation context so that we avoid lockdep false positives | |
| 265 | + * by doing GFP_KERNEL allocations inside sb_start_intwrite(). | |
| 266 | + */ | |
| 267 | + tp = kmem_zone_zalloc(xfs_trans_zone, | |
| 268 | + (flags & XFS_TRANS_NOFS) ? KM_NOFS : KM_SLEEP); | |
| 269 | + | |
| 262 | 270 | if (!(flags & XFS_TRANS_NO_WRITECOUNT)) |
| 263 | 271 | sb_start_intwrite(mp->m_super); |
| 264 | 272 | |
| @@ -270,8 +278,6 @@ xfs_trans_alloc( · 5 unmodified lines | ||
| 270 | 278 | mp->m_super->s_writers.frozen == SB_FREEZE_COMPLETE); |
| 271 | 279 | atomic_inc(&mp->m_active_trans); |
| 272 | 280 | |
| 273 | − tp = kmem_zone_zalloc(xfs_trans_zone, | |
| 274 | − (flags & XFS_TRANS_NOFS) ? KM_NOFS : KM_SLEEP); | |
| 275 | 281 | tp->t_magic = XFS_TRANS_HEADER_MAGIC; |
| 276 | 282 | tp->t_flags = flags; |
| 277 | 283 | tp->t_mountp = mp; |
| @@ -322,49 +322,38 @@ xfs_trans_read_buf_map( · 321 unmodified lines | ||
| 322 | 322 | } |
| 323 | 323 | |
| 324 | 324 | /* |
| 325 | − * Release the buffer bp which was previously acquired with one of the | |
| 326 | − * xfs_trans_... buffer allocation routines if the buffer has not | |
| 327 | − * been modified within this transaction. If the buffer is modified | |
| 328 | − * within this transaction, do decrement the recursion count but do | |
| 329 | − * not release the buffer even if the count goes to 0. If the buffer is not | |
| 330 | − * modified within the transaction, decrement the recursion count and | |
| 331 | − * release the buffer if the recursion count goes to 0. | |
| 325 | + * Release a buffer previously joined to the transaction. If the buffer is | |
| 326 | + * modified within this transaction, decrement the recursion count but do not | |
| 327 | + * release the buffer even if the count goes to 0. If the buffer is not modified | |
| 328 | + * within the transaction, decrement the recursion count and release the buffer | |
| 329 | + * if the recursion count goes to 0. | |
| 332 | 330 | * |
| 333 | − * If the buffer is to be released and it was not modified before | |
| 334 | − * this transaction began, then free the buf_log_item associated with it. | |
| 331 | + * If the buffer is to be released and it was not already dirty before this | |
| 332 | + * transaction began, then also free the buf_log_item associated with it. | |
| 335 | 333 | * |
| 336 | − * If the transaction pointer is NULL, make this just a normal | |
| 337 | − * brelse() call. | |
| 334 | + * If the transaction pointer is NULL, this is a normal xfs_buf_relse() call. | |
| 338 | 335 | */ |
| 339 | 336 | void |
| 340 | 337 | xfs_trans_brelse( |
| 341 | − xfs_trans_t *tp, | |
| 342 | − xfs_buf_t *bp) | |
| 338 | + struct xfs_trans *tp, | |
| 339 | + struct xfs_buf *bp) | |
| 343 | 340 | { |
| 344 | − struct xfs_buf_log_item *bip; | |
| 345 | − int freed; | |
| 341 | + struct xfs_buf_log_item *bip = bp->b_log_item; | |
| 346 | 342 | |
| 347 | − /* | |
| 348 | − * Default to a normal brelse() call if the tp is NULL. | |
| 349 | − */ | |
| 350 | − if (tp == NULL) { | |
| 351 | − ASSERT(bp->b_transp == NULL); | |
| 343 | + ASSERT(bp->b_transp == tp); | |
| 344 | + | |
| 345 | + if (!tp) { | |
| 352 | 346 | xfs_buf_relse(bp); |
| 353 | 347 | return; |
| 354 | 348 | } |
| 355 | 349 | |
| 356 | − ASSERT(bp->b_transp == tp); | |
| 357 | − bip = bp->b_log_item; | |
| 350 | + trace_xfs_trans_brelse(bip); | |
| 358 | 351 | ASSERT(bip->bli_item.li_type == XFS_LI_BUF); |
| 359 | − ASSERT(!(bip->bli_flags & XFS_BLI_STALE)); | |
| 360 | − ASSERT(!(bip->__bli_format.blf_flags & XFS_BLF_CANCEL)); | |
| 361 | 352 | ASSERT(atomic_read(&bip->bli_refcount) > 0); |
| 362 | 353 | |
| 363 | − trace_xfs_trans_brelse(bip); | |
| 364 | − | |
| 365 | 354 | /* |
| 366 | − * If the release is just for a recursive lock, | |
| 367 | − * then decrement the count and return. | |
| 355 | + * If the release is for a recursive lookup, then decrement the count | |
| 356 | + * and return. | |
| 368 | 357 | */ |
| 369 | 358 | if (bip->bli_recur > 0) { |
| 370 | 359 | bip->bli_recur--; |
| @@ -372,64 +361,24 @@ xfs_trans_brelse( · 1 unmodified line | ||
| 372 | 361 | } |
| 373 | 362 | |
| 374 | 363 | /* |
| 375 | − * If the buffer is dirty within this transaction, we can't | |
| 364 | + * If the buffer is invalidated or dirty in this transaction, we can't | |
| 376 | 365 | * release it until we commit. |
| 377 | 366 | */ |
| 378 | 367 | if (test_bit(XFS_LI_DIRTY, &bip->bli_item.li_flags)) |
| 379 | 368 | return; |
| 380 | − | |
| 381 | − /* | |
| 382 | − * If the buffer has been invalidated, then we can't release | |
| 383 | − * it until the transaction commits to disk unless it is re-dirtied | |
| 384 | − * as part of this transaction. This prevents us from pulling | |
| 385 | − * the item from the AIL before we should. | |
| 386 | − */ | |
| 387 | 369 | if (bip->bli_flags & XFS_BLI_STALE) |
| 388 | 370 | return; |
| 389 | 371 | |
| 390 | − ASSERT(!(bip->bli_flags & XFS_BLI_LOGGED)); | |
| 391 | − | |
| 392 | 372 | /* |
| 393 | − * Free up the log item descriptor tracking the released item. | |
| 373 | + * Unlink the log item from the transaction and clear the hold flag, if | |
| 374 | + * set. We wouldn't want the next user of the buffer to get confused. | |
| 394 | 375 | */ |
| 376 | + ASSERT(!(bip->bli_flags & XFS_BLI_LOGGED)); | |
| 395 | 377 | xfs_trans_del_item(&bip->bli_item); |
| 378 | + bip->bli_flags &= ~XFS_BLI_HOLD; | |
| 396 | 379 | |
| 397 | − /* | |
| 398 | − * Clear the hold flag in the buf log item if it is set. | |
| 399 | − * We wouldn't want the next user of the buffer to | |
| 400 | − * get confused. | |
| 401 | − */ | |
| 402 | − if (bip->bli_flags & XFS_BLI_HOLD) { | |
| 403 | − bip->bli_flags &= ~XFS_BLI_HOLD; | |
| 404 | − } | |
| 405 | − | |
| 406 | − /* | |
| 407 | − * Drop our reference to the buf log item. | |
| 408 | − */ | |
| 409 | − freed = atomic_dec_and_test(&bip->bli_refcount); | |
| 410 | − | |
| 411 | − /* | |
| 412 | − * If the buf item is not tracking data in the log, then we must free it | |
| 413 | − * before releasing the buffer back to the free pool. | |
| 414 | − * | |
| 415 | − * If the fs has shutdown and we dropped the last reference, it may fall | |
| 416 | − * on us to release a (possibly dirty) bli if it never made it to the | |
| 417 | − * AIL (e.g., the aborted unpin already happened and didn't release it | |
| 418 | − * due to our reference). Since we're already shutdown and need | |
| 419 | − * ail_lock, just force remove from the AIL and release the bli here. | |
| 420 | − */ | |
| 421 | − if (XFS_FORCED_SHUTDOWN(tp->t_mountp) && freed) { | |
| 422 | − xfs_trans_ail_remove(&bip->bli_item, SHUTDOWN_LOG_IO_ERROR); | |
| 423 | − xfs_buf_item_relse(bp); | |
| 424 | − } else if (!(bip->bli_flags & XFS_BLI_DIRTY)) { | |
| 425 | −/*** | |
| 426 | − ASSERT(bp->b_pincount == 0); | |
| 427 | −***/ | |
| 428 | − ASSERT(atomic_read(&bip->bli_refcount) == 0); | |
| 429 | − ASSERT(!test_bit(XFS_LI_IN_AIL, &bip->bli_item.li_flags)); | |
| 430 | − ASSERT(!(bip->bli_flags & XFS_BLI_INODE_ALLOC_BUF)); | |
| 431 | − xfs_buf_item_relse(bp); | |
| 432 | − } | |
| 380 | + /* drop the reference to the bli */ | |
| 381 | + xfs_buf_item_put(bip); | |
| 433 | 382 | |
| 434 | 383 | bp->b_transp = NULL; |
| 435 | 384 | xfs_buf_relse(bp); |
| @@ -87,9 +87,10 @@ struct drm_client_dev { · 86 unmodified lines | ||
| 87 | 87 | struct drm_file *file; |
| 88 | 88 | }; |
| 89 | 89 | |
| 90 | −int drm_client_new(struct drm_device *dev, struct drm_client_dev *client, | |
| 91 | − const char *name, const struct drm_client_funcs *funcs); | |
| 90 | +int drm_client_init(struct drm_device *dev, struct drm_client_dev *client, | |
| 91 | + const char *name, const struct drm_client_funcs *funcs); | |
| 92 | 92 | void drm_client_release(struct drm_client_dev *client); |
| 93 | +void drm_client_add(struct drm_client_dev *client); | |
| 93 | 94 | |
| 94 | 95 | void drm_client_dev_unregister(struct drm_device *dev); |
| 95 | 96 | void drm_client_dev_hotplug(struct drm_device *dev); |
| @@ -53,12 +53,20 @@ enum fpga_mgr_states { · 52 unmodified lines | ||
| 53 | 53 | FPGA_MGR_STATE_OPERATING, |
| 54 | 54 | }; |
| 55 | 55 | |
| 56 | −/* | |
| 57 | − * FPGA Manager flags | |
| 58 | − * FPGA_MGR_PARTIAL_RECONFIG: do partial reconfiguration if supported | |
| 59 | − * FPGA_MGR_EXTERNAL_CONFIG: FPGA has been configured prior to Linux booting | |
| 60 | − * FPGA_MGR_BITSTREAM_LSB_FIRST: SPI bitstream bit order is LSB first | |
| 61 | − * FPGA_MGR_COMPRESSED_BITSTREAM: FPGA bitstream is compressed | |
| 56 | +/** | |
| 57 | + * DOC: FPGA Manager flags | |
| 58 | + * | |
| 59 | + * Flags used in the &fpga_image_info->flags field | |
| 60 | + * | |
| 61 | + * %FPGA_MGR_PARTIAL_RECONFIG: do partial reconfiguration if supported | |
| 62 | + * | |
| 63 | + * %FPGA_MGR_EXTERNAL_CONFIG: FPGA has been configured prior to Linux booting | |
| 64 | + * | |
| 65 | + * %FPGA_MGR_ENCRYPTED_BITSTREAM: indicates bitstream is encrypted | |
| 66 | + * | |
| 67 | + * %FPGA_MGR_BITSTREAM_LSB_FIRST: SPI bitstream bit order is LSB first | |
| 68 | + * | |
| 69 | + * %FPGA_MGR_COMPRESSED_BITSTREAM: FPGA bitstream is compressed | |
| 62 | 70 | */ |
| 63 | 71 | #define FPGA_MGR_PARTIAL_RECONFIG BIT(0) |
| 64 | 72 | #define FPGA_MGR_EXTERNAL_CONFIG BIT(1) |
| @@ -1828,8 +1828,10 @@ extern ssize_t vfs_copy_file_range(struct file *, loff_t , struct file *, · 1827 unmodified lines | ||
| 1828 | 1828 | extern int vfs_clone_file_prep_inodes(struct inode *inode_in, loff_t pos_in, |
| 1829 | 1829 | struct inode *inode_out, loff_t pos_out, |
| 1830 | 1830 | u64 *len, bool is_dedupe); |
| 1831 | +extern int do_clone_file_range(struct file *file_in, loff_t pos_in, | |
| 1832 | + struct file *file_out, loff_t pos_out, u64 len); | |
| 1831 | 1833 | extern int vfs_clone_file_range(struct file *file_in, loff_t pos_in, |
| 1832 | − struct file *file_out, loff_t pos_out, u64 len); | |
| 1834 | + struct file *file_out, loff_t pos_out, u64 len); | |
| 1833 | 1835 | extern int vfs_dedupe_file_range_compare(struct inode *src, loff_t srcoff, |
| 1834 | 1836 | struct inode *dest, loff_t destoff, |
| 1835 | 1837 | loff_t len, bool *is_same); |
| @@ -2773,19 +2775,6 @@ static inline void file_end_write(struct file *file) · 937 unmodified lines | ||
| 2773 | 2775 | __sb_end_write(file_inode(file)->i_sb, SB_FREEZE_WRITE); |
| 2774 | 2776 | } |
| 2775 | 2777 | |
| 2776 | −static inline int do_clone_file_range(struct file *file_in, loff_t pos_in, | |
| 2777 | − struct file *file_out, loff_t pos_out, | |
| 2778 | − u64 len) | |
| 2779 | −{ | |
| 2780 | − int ret; | |
| 2781 | − | |
| 2782 | − file_start_write(file_out); | |
| 2783 | − ret = vfs_clone_file_range(file_in, pos_in, file_out, pos_out, len); | |
| 2784 | − file_end_write(file_out); | |
| 2785 | − | |
| 2786 | − return ret; | |
| 2787 | −} | |
| 2788 | − | |
| 2789 | 2778 | /* |
| 2790 | 2779 | * get_write_access() gets write permission for a file. |
| 2791 | 2780 | * put_write_access() releases this write permission. |
| @@ -140,6 +140,8 @@ pte_t *huge_pte_alloc(struct mm_struct *mm, · 139 unmodified lines | ||
| 140 | 140 | pte_t *huge_pte_offset(struct mm_struct *mm, |
| 141 | 141 | unsigned long addr, unsigned long sz); |
| 142 | 142 | int huge_pmd_unshare(struct mm_struct *mm, unsigned long *addr, pte_t *ptep); |
| 143 | +void adjust_range_if_pmd_sharing_possible(struct vm_area_struct *vma, | |
| 144 | + unsigned long *start, unsigned long *end); | |
| 143 | 145 | struct page *follow_huge_addr(struct mm_struct *mm, unsigned long address, |
| 144 | 146 | int write); |
| 145 | 147 | struct page *follow_huge_pd(struct vm_area_struct *vma, |
| @@ -170,6 +172,18 @@ static inline unsigned long hugetlb_total_pages(void) · 24 unmodified lines | ||
| 170 | 172 | return 0; |
| 171 | 173 | } |
| 172 | 174 | |
| 175 | +static inline int huge_pmd_unshare(struct mm_struct *mm, unsigned long *addr, | |
| 176 | + pte_t *ptep) | |
| 177 | +{ | |
| 178 | + return 0; | |
| 179 | +} | |
| 180 | + | |
| 181 | +static inline void adjust_range_if_pmd_sharing_possible( | |
| 182 | + struct vm_area_struct *vma, | |
| 183 | + unsigned long *start, unsigned long *end) | |
| 184 | +{ | |
| 185 | +} | |
| 186 | + | |
| 173 | 187 | #define follow_hugetlb_page(m,v,p,vs,a,b,i,w,n) ({ BUG(); 0; }) |
| 174 | 188 | #define follow_huge_addr(mm, addr, write) ERR_PTR(-EINVAL) |
| 175 | 189 | #define copy_hugetlb_page_range(src, dst, vma) ({ BUG(); 0; }) |
| @@ -90,6 +90,8 @@ struct mlx5_hairpin { · 89 unmodified lines | ||
| 90 | 90 | |
| 91 | 91 | u32 *rqn; |
| 92 | 92 | u32 *sqn; |
| 93 | + | |
| 94 | + bool peer_gone; | |
| 93 | 95 | }; |
| 94 | 96 | |
| 95 | 97 | struct mlx5_hairpin * |
| @@ -2455,6 +2455,12 @@ static inline struct vm_area_struct *find_exact_vma(struct mm_struct *mm, · 2454 unmodified lines | ||
| 2455 | 2455 | return vma; |
| 2456 | 2456 | } |
| 2457 | 2457 | |
| 2458 | +static inline bool range_in_vma(struct vm_area_struct *vma, | |
| 2459 | + unsigned long start, unsigned long end) | |
| 2460 | +{ | |
| 2461 | + return (vma && vma->vm_start <= start && end <= vma->vm_end); | |
| 2462 | +} | |
| 2463 | + | |
| 2458 | 2464 | #ifdef CONFIG_MMU |
| 2459 | 2465 | pgprot_t vm_get_page_prot(unsigned long vm_flags); |
| 2460 | 2466 | void vma_set_page_prot(struct vm_area_struct *vma); |
| @@ -671,12 +671,6 @@ typedef struct pglist_data { · 670 unmodified lines | ||
| 671 | 671 | #ifdef CONFIG_NUMA_BALANCING |
| 672 | 672 | /* Lock serializing the migrate rate limiting window */ |
| 673 | 673 | spinlock_t numabalancing_migrate_lock; |
| 674 | − | |
| 675 | − /* Rate limiting time interval */ | |
| 676 | − unsigned long numabalancing_migrate_next_window; | |
| 677 | − | |
| 678 | − /* Number of pages migrated during the rate limiting time interval */ | |
| 679 | − unsigned long numabalancing_migrate_nr_pages; | |
| 680 | 674 | #endif |
| 681 | 675 | /* |
| 682 | 676 | * This is a per-node reserve of pages that are not available |
| @@ -1730,6 +1730,8 @@ enum netdev_priv_flags { · 1729 unmodified lines | ||
| 1730 | 1730 | * switch driver and used to set the phys state of the |
| 1731 | 1731 | * switch port. |
| 1732 | 1732 | * |
| 1733 | + * @wol_enabled: Wake-on-LAN is enabled | |
| 1734 | + * | |
| 1733 | 1735 | * FIXME: cleanup struct net_device such that network protocol info |
| 1734 | 1736 | * moves out. |
| 1735 | 1737 | */ |
| @@ -2014,6 +2016,7 @@ struct net_device { · 278 unmodified lines | ||
| 2014 | 2016 | struct lock_class_key *qdisc_tx_busylock; |
| 2015 | 2017 | struct lock_class_key *qdisc_running_key; |
| 2016 | 2018 | bool proto_down; |
| 2019 | + unsigned wol_enabled:1; | |
| 2017 | 2020 | }; |
| 2018 | 2021 | #define to_net_dev(d) container_of(d, struct net_device, dev) |
| 2019 | 2022 | |
| @@ -215,6 +215,8 @@ static inline int nf_hook(u_int8_t pf, unsigned int hook, struct net *net, · 214 unmodified lines | ||
| 215 | 215 | break; |
| 216 | 216 | case NFPROTO_ARP: |
| 217 | 217 | #ifdef CONFIG_NETFILTER_FAMILY_ARP |
| 218 | + if (WARN_ON_ONCE(hook >= ARRAY_SIZE(net->nf.hooks_arp))) | |
| 219 | + break; | |
| 218 | 220 | hook_head = rcu_dereference(net->nf.hooks_arp[hook]); |
| 219 | 221 | #endif |
| 220 | 222 | break; |
| @@ -36,6 +36,7 @@ enum { · 35 unmodified lines | ||
| 36 | 36 | SCIx_SH4_SCIF_FIFODATA_REGTYPE, |
| 37 | 37 | SCIx_SH7705_SCIF_REGTYPE, |
| 38 | 38 | SCIx_HSCIF_REGTYPE, |
| 39 | + SCIx_RZ_SCIFA_REGTYPE, | |
| 39 | 40 | |
| 40 | 41 | SCIx_NR_REGTYPES, |
| 41 | 42 | }; |
| @@ -5,6 +5,24 @@ · 4 unmodified lines | ||
| 5 | 5 | #include <linux/if_vlan.h> |
| 6 | 6 | #include <uapi/linux/virtio_net.h> |
| 7 | 7 | |
| 8 | +static inline int virtio_net_hdr_set_proto(struct sk_buff *skb, | |
| 9 | + const struct virtio_net_hdr *hdr) | |
| 10 | +{ | |
| 11 | + switch (hdr->gso_type & ~VIRTIO_NET_HDR_GSO_ECN) { | |
| 12 | + case VIRTIO_NET_HDR_GSO_TCPV4: | |
| 13 | + case VIRTIO_NET_HDR_GSO_UDP: | |
| 14 | + skb->protocol = cpu_to_be16(ETH_P_IP); | |
| 15 | + break; | |
| 16 | + case VIRTIO_NET_HDR_GSO_TCPV6: | |
| 17 | + skb->protocol = cpu_to_be16(ETH_P_IPV6); | |
| 18 | + break; | |
| 19 | + default: | |
| 20 | + return -EINVAL; | |
| 21 | + } | |
| 22 | + | |
| 23 | + return 0; | |
| 24 | +} | |
| 25 | + | |
| 8 | 26 | static inline int virtio_net_hdr_to_skb(struct sk_buff *skb, |
| 9 | 27 | const struct virtio_net_hdr *hdr, |
| 10 | 28 | bool little_endian) |
| @@ -38,10 +38,13 @@ struct v4l2_ctrl_handler; · 37 unmodified lines | ||
| 38 | 38 | * @prio: priority of the file handler, as defined by &enum v4l2_priority |
| 39 | 39 | * |
| 40 | 40 | * @wait: event' s wait queue |
| 41 | + * @subscribe_lock: serialise changes to the subscribed list; guarantee that | |
| 42 | + * the add and del event callbacks are orderly called | |
| 41 | 43 | * @subscribed: list of subscribed events |
| 42 | 44 | * @available: list of events waiting to be dequeued |
| 43 | 45 | * @navailable: number of available events at @available list |
| 44 | 46 | * @sequence: event sequence number |
| 47 | + * | |
| 45 | 48 | * @m2m_ctx: pointer to &struct v4l2_m2m_ctx |
| 46 | 49 | */ |
| 47 | 50 | struct v4l2_fh { |
| @@ -52,6 +55,7 @@ struct v4l2_fh { · 4 unmodified lines | ||
| 52 | 55 | |
| 53 | 56 | /* Events */ |
| 54 | 57 | wait_queue_head_t wait; |
| 58 | + struct mutex subscribe_lock; | |
| 55 | 59 | struct list_head subscribed; |
| 56 | 60 | struct list_head available; |
| 57 | 61 | unsigned int navailable; |
| @@ -139,12 +139,6 @@ struct bond_parm_tbl { · 138 unmodified lines | ||
| 139 | 139 | int mode; |
| 140 | 140 | }; |
| 141 | 141 | |
| 142 | −struct netdev_notify_work { | |
| 143 | − struct delayed_work work; | |
| 144 | − struct net_device *dev; | |
| 145 | − struct netdev_bonding_info bonding_info; | |
| 146 | −}; | |
| 147 | − | |
| 148 | 142 | struct slave { |
| 149 | 143 | struct net_device *dev; /* first - useful for panic debug */ |
| 150 | 144 | struct bonding *bond; /* our master */ |
| @@ -172,6 +166,7 @@ struct slave { · 21 unmodified lines | ||
| 172 | 166 | #ifdef CONFIG_NET_POLL_CONTROLLER |
| 173 | 167 | struct netpoll *np; |
| 174 | 168 | #endif |
| 169 | + struct delayed_work notify_work; | |
| 175 | 170 | struct kobject kobj; |
| 176 | 171 | struct rtnl_link_stats64 slave_stats; |
| 177 | 172 | }; |
| @@ -4852,8 +4852,6 @@ const char *reg_initiator_name(enum nl80211_reg_initiator initiator); · 4851 unmodified lines | ||
| 4852 | 4852 | * |
| 4853 | 4853 | * @alpha2: the ISO/IEC 3166 alpha2 wmm rule to be queried. |
| 4854 | 4854 | * @freq: the freqency(in MHz) to be queried. |
| 4855 | − * @ptr: pointer where the regdb wmm data is to be stored (or %NULL if | |
| 4856 | − * irrelevant). This can be used later for deduplication. | |
| 4857 | 4855 | * @rule: pointer to store the wmm rule from the regulatory db. |
| 4858 | 4856 | * |
| 4859 | 4857 | * Self-managed wireless drivers can use this function to query |
| @@ -130,12 +130,6 @@ static inline int inet_request_bound_dev_if(const struct sock *sk, · 129 unmodified lines | ||
| 130 | 130 | return sk->sk_bound_dev_if; |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | −static inline struct ip_options_rcu *ireq_opt_deref(const struct inet_request_sock *ireq) | |
| 134 | −{ | |
| 135 | − return rcu_dereference_check(ireq->ireq_opt, | |
| 136 | − refcount_read(&ireq->req.rsk_refcnt) > 0); | |
| 137 | −} | |
| 138 | − | |
| 139 | 133 | struct inet_cork { |
| 140 | 134 | unsigned int flags; |
| 141 | 135 | __be32 addr; |
| @@ -153,7 +153,7 @@ · 152 unmodified lines | ||
| 153 | 153 | * nla_find() find attribute in stream of attributes |
| 154 | 154 | * nla_find_nested() find attribute in nested attributes |
| 155 | 155 | * nla_parse() parse and validate stream of attrs |
| 156 | − * nla_parse_nested() parse nested attribuets | |
| 156 | + * nla_parse_nested() parse nested attributes | |
| 157 | 157 | * nla_for_each_attr() loop over all attributes |
| 158 | 158 | * nla_for_each_nested() loop over the nested attributes |
| 159 | 159 | *========================================================================= |
| @@ -70,33 +70,6 @@ TRACE_EVENT(mm_migrate_pages, · 69 unmodified lines | ||
| 70 | 70 | __print_symbolic(__entry->mode, MIGRATE_MODE), |
| 71 | 71 | __print_symbolic(__entry->reason, MIGRATE_REASON)) |
| 72 | 72 | ); |
| 73 | − | |
| 74 | −TRACE_EVENT(mm_numa_migrate_ratelimit, | |
| 75 | − | |
| 76 | − TP_PROTO(struct task_struct *p, int dst_nid, unsigned long nr_pages), | |
| 77 | − | |
| 78 | − TP_ARGS(p, dst_nid, nr_pages), | |
| 79 | − | |
| 80 | − TP_STRUCT__entry( | |
| 81 | − __array( char, comm, TASK_COMM_LEN) | |
| 82 | − __field( pid_t, pid) | |
| 83 | − __field( int, dst_nid) | |
| 84 | − __field( unsigned long, nr_pages) | |
| 85 | − ), | |
| 86 | − | |
| 87 | − TP_fast_assign( | |
| 88 | − memcpy(__entry->comm, p->comm, TASK_COMM_LEN); | |
| 89 | − __entry->pid = p->pid; | |
| 90 | − __entry->dst_nid = dst_nid; | |
| 91 | − __entry->nr_pages = nr_pages; | |
| 92 | − ), | |
| 93 | − | |
| 94 | − TP_printk("comm=%s pid=%d dst_nid=%d nr_pages=%lu", | |
| 95 | − __entry->comm, | |
| 96 | − __entry->pid, | |
| 97 | − __entry->dst_nid, | |
| 98 | − __entry->nr_pages) | |
| 99 | −); | |
| 100 | 73 | #endif /* _TRACE_MIGRATE_H */ |
| 101 | 74 | |
| 102 | 75 | /* This part must be outside protection */ |
| @@ -56,7 +56,6 @@ enum rxrpc_peer_trace { · 55 unmodified lines | ||
| 56 | 56 | rxrpc_peer_new, |
| 57 | 57 | rxrpc_peer_processing, |
| 58 | 58 | rxrpc_peer_put, |
| 59 | − rxrpc_peer_queued_error, | |
| 60 | 59 | }; |
| 61 | 60 | |
| 62 | 61 | enum rxrpc_conn_trace { |
| @@ -257,8 +256,7 @@ enum rxrpc_tx_point { · 194 unmodified lines | ||
| 257 | 256 | EM(rxrpc_peer_got, "GOT") \ |
| 258 | 257 | EM(rxrpc_peer_new, "NEW") \ |
| 259 | 258 | EM(rxrpc_peer_processing, "PRO") \ |
| 260 | − EM(rxrpc_peer_put, "PUT") \ | |
| 261 | − E_(rxrpc_peer_queued_error, "QER") | |
| 259 | + E_(rxrpc_peer_put, "PUT") | |
| 262 | 260 | |
| 263 | 261 | #define rxrpc_conn_traces \ |
| 264 | 262 | EM(rxrpc_conn_got, "GOT") \ |
| @@ -26,7 +26,9 @@ · 25 unmodified lines | ||
| 26 | 26 | #define HUGETLB_FLAG_ENCODE_2MB (21 << HUGETLB_FLAG_ENCODE_SHIFT) |
| 27 | 27 | #define HUGETLB_FLAG_ENCODE_8MB (23 << HUGETLB_FLAG_ENCODE_SHIFT) |
| 28 | 28 | #define HUGETLB_FLAG_ENCODE_16MB (24 << HUGETLB_FLAG_ENCODE_SHIFT) |
| 29 | +#define HUGETLB_FLAG_ENCODE_32MB (25 << HUGETLB_FLAG_ENCODE_SHIFT) | |
| 29 | 30 | #define HUGETLB_FLAG_ENCODE_256MB (28 << HUGETLB_FLAG_ENCODE_SHIFT) |
| 31 | +#define HUGETLB_FLAG_ENCODE_512MB (29 << HUGETLB_FLAG_ENCODE_SHIFT) | |
| 30 | 32 | #define HUGETLB_FLAG_ENCODE_1GB (30 << HUGETLB_FLAG_ENCODE_SHIFT) |
| 31 | 33 | #define HUGETLB_FLAG_ENCODE_2GB (31 << HUGETLB_FLAG_ENCODE_SHIFT) |
| 32 | 34 | #define HUGETLB_FLAG_ENCODE_16GB (34 << HUGETLB_FLAG_ENCODE_SHIFT) |
| @@ -25,7 +25,9 @@ · 24 unmodified lines | ||
| 25 | 25 | #define MFD_HUGE_2MB HUGETLB_FLAG_ENCODE_2MB |
| 26 | 26 | #define MFD_HUGE_8MB HUGETLB_FLAG_ENCODE_8MB |
| 27 | 27 | #define MFD_HUGE_16MB HUGETLB_FLAG_ENCODE_16MB |
| 28 | +#define MFD_HUGE_32MB HUGETLB_FLAG_ENCODE_32MB | |
| 28 | 29 | #define MFD_HUGE_256MB HUGETLB_FLAG_ENCODE_256MB |
| 30 | +#define MFD_HUGE_512MB HUGETLB_FLAG_ENCODE_512MB | |
| 29 | 31 | #define MFD_HUGE_1GB HUGETLB_FLAG_ENCODE_1GB |
| 30 | 32 | #define MFD_HUGE_2GB HUGETLB_FLAG_ENCODE_2GB |
| 31 | 33 | #define MFD_HUGE_16GB HUGETLB_FLAG_ENCODE_16GB |
| @@ -28,7 +28,9 @@ · 27 unmodified lines | ||
| 28 | 28 | #define MAP_HUGE_2MB HUGETLB_FLAG_ENCODE_2MB |
| 29 | 29 | #define MAP_HUGE_8MB HUGETLB_FLAG_ENCODE_8MB |
| 30 | 30 | #define MAP_HUGE_16MB HUGETLB_FLAG_ENCODE_16MB |
| 31 | +#define MAP_HUGE_32MB HUGETLB_FLAG_ENCODE_32MB | |
| 31 | 32 | #define MAP_HUGE_256MB HUGETLB_FLAG_ENCODE_256MB |
| 33 | +#define MAP_HUGE_512MB HUGETLB_FLAG_ENCODE_512MB | |
| 32 | 34 | #define MAP_HUGE_1GB HUGETLB_FLAG_ENCODE_1GB |
| 33 | 35 | #define MAP_HUGE_2GB HUGETLB_FLAG_ENCODE_2GB |
| 34 | 36 | #define MAP_HUGE_16GB HUGETLB_FLAG_ENCODE_16GB |
| @@ -65,7 +65,9 @@ struct shmid_ds { · 64 unmodified lines | ||
| 65 | 65 | #define SHM_HUGE_2MB HUGETLB_FLAG_ENCODE_2MB |
| 66 | 66 | #define SHM_HUGE_8MB HUGETLB_FLAG_ENCODE_8MB |
| 67 | 67 | #define SHM_HUGE_16MB HUGETLB_FLAG_ENCODE_16MB |
| 68 | +#define SHM_HUGE_32MB HUGETLB_FLAG_ENCODE_32MB | |
| 68 | 69 | #define SHM_HUGE_256MB HUGETLB_FLAG_ENCODE_256MB |
| 70 | +#define SHM_HUGE_512MB HUGETLB_FLAG_ENCODE_512MB | |
| 69 | 71 | #define SHM_HUGE_1GB HUGETLB_FLAG_ENCODE_1GB |
| 70 | 72 | #define SHM_HUGE_2GB HUGETLB_FLAG_ENCODE_2GB |
| 71 | 73 | #define SHM_HUGE_16GB HUGETLB_FLAG_ENCODE_16GB |
| @@ -206,7 +206,7 @@ err: · 205 unmodified lines | ||
| 206 | 206 | * Callers of shm_lock() must validate the status of the returned ipc |
| 207 | 207 | * object pointer and error out as appropriate. |
| 208 | 208 | */ |
| 209 | − return (void *)ipcp; | |
| 209 | + return ERR_CAST(ipcp); | |
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | static inline void shm_lock_by_ptr(struct shmid_kernel *ipcp) |
| @@ -129,7 +129,7 @@ static int cgroup_storage_update_elem(struct bpf_map *map, void *_key, · 128 unmodified lines | ||
| 129 | 129 | struct bpf_cgroup_storage *storage; |
| 130 | 130 | struct bpf_storage_buffer *new; |
| 131 | 131 | |
| 132 | − if (flags & BPF_NOEXIST) | |
| 132 | + if (flags != BPF_ANY && flags != BPF_EXIST) | |
| 133 | 133 | return -EINVAL; |
| 134 | 134 | |
| 135 | 135 | storage = cgroup_storage_lookup((struct bpf_cgroup_storage_map *)map, |
| @@ -195,6 +195,9 @@ static struct bpf_map *cgroup_storage_map_alloc(union bpf_attr *attr) · 59 unmodified lines | ||
| 195 | 195 | if (attr->key_size != sizeof(struct bpf_cgroup_storage_key)) |
| 196 | 196 | return ERR_PTR(-EINVAL); |
| 197 | 197 | |
| 198 | + if (attr->value_size == 0) | |
| 199 | + return ERR_PTR(-EINVAL); | |
| 200 | + | |
| 198 | 201 | if (attr->value_size > PAGE_SIZE) |
| 199 | 202 | return ERR_PTR(-E2BIG); |
| 200 | 203 | |
| @@ -2896,6 +2896,15 @@ static int adjust_scalar_min_max_vals(struct bpf_verifier_env *env, · 2895 unmodified lines | ||
| 2896 | 2896 | u64 umin_val, umax_val; |
| 2897 | 2897 | u64 insn_bitness = (BPF_CLASS(insn->code) == BPF_ALU64) ? 64 : 32; |
| 2898 | 2898 | |
| 2899 | + if (insn_bitness == 32) { | |
| 2900 | + /* Relevant for 32-bit RSH: Information can propagate towards | |
| 2901 | + * LSB, so it isn't sufficient to only truncate the output to | |
| 2902 | + * 32 bits. | |
| 2903 | + */ | |
| 2904 | + coerce_reg_to_size(dst_reg, 4); | |
| 2905 | + coerce_reg_to_size(&src_reg, 4); | |
| 2906 | + } | |
| 2907 | + | |
| 2899 | 2908 | smin_val = src_reg.smin_value; |
| 2900 | 2909 | smax_val = src_reg.smax_value; |
| 2901 | 2910 | umin_val = src_reg.umin_value; |
| @@ -3131,7 +3140,6 @@ static int adjust_scalar_min_max_vals(struct bpf_verifier_env *env, · 229 unmodified lines | ||
| 3131 | 3140 | if (BPF_CLASS(insn->code) != BPF_ALU64) { |
| 3132 | 3141 | /* 32-bit ALU ops are (32,32)->32 */ |
| 3133 | 3142 | coerce_reg_to_size(dst_reg, 4); |
| 3134 | − coerce_reg_to_size(&src_reg, 4); | |
| 3135 | 3143 | } |
| 3136 | 3144 | |
| 3137 | 3145 | __reg_deduce_bounds(dst_reg); |
| @@ -8314,6 +8314,8 @@ void perf_tp_event(u16 event_type, u64 count, void *record, int entry_size, · 8313 unmodified lines | ||
| 8314 | 8314 | goto unlock; |
| 8315 | 8315 | |
| 8316 | 8316 | list_for_each_entry_rcu(event, &ctx->event_list, event_entry) { |
| 8317 | + if (event->cpu != smp_processor_id()) | |
| 8318 | + continue; | |
| 8317 | 8319 | if (event->attr.type != PERF_TYPE_TRACEPOINT) |
| 8318 | 8320 | continue; |
| 8319 | 8321 | if (event->attr.config != entry->type) |
| @@ -9431,9 +9433,7 @@ static void free_pmu_context(struct pmu *pmu) · 1111 unmodified lines | ||
| 9431 | 9433 | if (pmu->task_ctx_nr > perf_invalid_context) |
| 9432 | 9434 | return; |
| 9433 | 9435 | |
| 9434 | − mutex_lock(&pmus_lock); | |
| 9435 | 9436 | free_percpu(pmu->pmu_cpu_context); |
| 9436 | − mutex_unlock(&pmus_lock); | |
| 9437 | 9437 | } |
| 9438 | 9438 | |
| 9439 | 9439 | /* |
| @@ -9689,12 +9689,8 @@ EXPORT_SYMBOL_GPL(perf_pmu_register); · 249 unmodified lines | ||
| 9689 | 9689 | |
| 9690 | 9690 | void perf_pmu_unregister(struct pmu *pmu) |
| 9691 | 9691 | { |
| 9692 | − int remove_device; | |
| 9693 | − | |
| 9694 | 9692 | mutex_lock(&pmus_lock); |
| 9695 | − remove_device = pmu_bus_running; | |
| 9696 | 9693 | list_del_rcu(&pmu->entry); |
| 9697 | − mutex_unlock(&pmus_lock); | |
| 9698 | 9694 | |
| 9699 | 9695 | /* |
| 9700 | 9696 | * We dereference the pmu list under both SRCU and regular RCU, so |
| @@ -9706,13 +9702,14 @@ void perf_pmu_unregister(struct pmu *pmu) · 5 unmodified lines | ||
| 9706 | 9702 | free_percpu(pmu->pmu_disable_count); |
| 9707 | 9703 | if (pmu->type >= PERF_TYPE_MAX) |
| 9708 | 9704 | idr_remove(&pmu_idr, pmu->type); |
| 9709 | − if (remove_device) { | |
| 9705 | + if (pmu_bus_running) { | |
| 9710 | 9706 | if (pmu->nr_addr_filters) |
| 9711 | 9707 | device_remove_file(pmu->dev, &dev_attr_nr_addr_filters); |
| 9712 | 9708 | device_del(pmu->dev); |
| 9713 | 9709 | put_device(pmu->dev); |
| 9714 | 9710 | } |
| 9715 | 9711 | free_pmu_context(pmu); |
| 9712 | + mutex_unlock(&pmus_lock); | |
| 9716 | 9713 | } |
| 9717 | 9714 | EXPORT_SYMBOL_GPL(perf_pmu_unregister); |
| 9718 | 9715 | |
| @@ -260,7 +260,7 @@ static void test_cycle_work(struct work_struct *work) · 259 unmodified lines | ||
| 260 | 260 | { |
| 261 | 261 | struct test_cycle *cycle = container_of(work, typeof(*cycle), work); |
| 262 | 262 | struct ww_acquire_ctx ctx; |
| 263 | − int err; | |
| 263 | + int err, erra = 0; | |
| 264 | 264 | |
| 265 | 265 | ww_acquire_init(&ctx, &ww_class); |
| 266 | 266 | ww_mutex_lock(&cycle->a_mutex, &ctx); |
| @@ -270,17 +270,19 @@ static void test_cycle_work(struct work_struct *work) · 3 unmodified lines | ||
| 270 | 270 | |
| 271 | 271 | err = ww_mutex_lock(cycle->b_mutex, &ctx); |
| 272 | 272 | if (err == -EDEADLK) { |
| 273 | + err = 0; | |
| 273 | 274 | ww_mutex_unlock(&cycle->a_mutex); |
| 274 | 275 | ww_mutex_lock_slow(cycle->b_mutex, &ctx); |
| 275 | − err = ww_mutex_lock(&cycle->a_mutex, &ctx); | |
| 276 | + erra = ww_mutex_lock(&cycle->a_mutex, &ctx); | |
| 276 | 277 | } |
| 277 | 278 | |
| 278 | 279 | if (!err) |
| 279 | 280 | ww_mutex_unlock(cycle->b_mutex); |
| 280 | − ww_mutex_unlock(&cycle->a_mutex); | |
| 281 | + if (!erra) | |
| 282 | + ww_mutex_unlock(&cycle->a_mutex); | |
| 281 | 283 | ww_acquire_fini(&ctx); |
| 282 | 284 | |
| 283 | − cycle->result = err; | |
| 285 | + cycle->result = err ?: erra; | |
| 284 | 286 | } |
| 285 | 287 | |
| 286 | 288 | static int __test_cycle(unsigned int nthreads) |
| @@ -1167,7 +1167,7 @@ void set_task_cpu(struct task_struct *p, unsigned int new_cpu) · 1166 unmodified lines | ||
| 1167 | 1167 | |
| 1168 | 1168 | if (task_cpu(p) != new_cpu) { |
| 1169 | 1169 | if (p->sched_class->migrate_task_rq) |
| 1170 | − p->sched_class->migrate_task_rq(p); | |
| 1170 | + p->sched_class->migrate_task_rq(p, new_cpu); | |
| 1171 | 1171 | p->se.nr_migrations++; |
| 1172 | 1172 | rseq_migrate(p); |
| 1173 | 1173 | perf_event_task_migrate(p); |
| @@ -1607,7 +1607,7 @@ out: · 1606 unmodified lines | ||
| 1607 | 1607 | return cpu; |
| 1608 | 1608 | } |
| 1609 | 1609 | |
| 1610 | −static void migrate_task_rq_dl(struct task_struct *p) | |
| 1610 | +static void migrate_task_rq_dl(struct task_struct *p, int new_cpu __maybe_unused) | |
| 1611 | 1611 | { |
| 1612 | 1612 | struct rq *rq; |
| 1613 | 1613 | |
| @@ -1392,6 +1392,17 @@ bool should_numa_migrate_memory(struct task_struct *p, struct page * page, · 1391 unmodified lines | ||
| 1392 | 1392 | int last_cpupid, this_cpupid; |
| 1393 | 1393 | |
| 1394 | 1394 | this_cpupid = cpu_pid_to_cpupid(dst_cpu, current->pid); |
| 1395 | + last_cpupid = page_cpupid_xchg_last(page, this_cpupid); | |
| 1396 | + | |
| 1397 | + /* | |
| 1398 | + * Allow first faults or private faults to migrate immediately early in | |
| 1399 | + * the lifetime of a task. The magic number 4 is based on waiting for | |
| 1400 | + * two full passes of the "multi-stage node selection" test that is | |
| 1401 | + * executed below. | |
| 1402 | + */ | |
| 1403 | + if ((p->numa_preferred_nid == -1 || p->numa_scan_seq <= 4) && | |
| 1404 | + (cpupid_pid_unset(last_cpupid) || cpupid_match_pid(p, last_cpupid))) | |
| 1405 | + return true; | |
| 1395 | 1406 | |
| 1396 | 1407 | /* |
| 1397 | 1408 | * Multi-stage node selection is used in conjunction with a periodic |
| @@ -1410,7 +1421,6 @@ bool should_numa_migrate_memory(struct task_struct *p, struct page * page, · 12 unmodified lines | ||
| 1410 | 1421 | * This quadric squishes small probabilities, making it less likely we |
| 1411 | 1422 | * act on an unlikely task<->page relation. |
| 1412 | 1423 | */ |
| 1413 | − last_cpupid = page_cpupid_xchg_last(page, this_cpupid); | |
| 1414 | 1424 | if (!cpupid_pid_unset(last_cpupid) && |
| 1415 | 1425 | cpupid_to_nid(last_cpupid) != dst_nid) |
| 1416 | 1426 | return false; |
| @@ -1514,6 +1524,21 @@ struct task_numa_env { · 97 unmodified lines | ||
| 1514 | 1524 | static void task_numa_assign(struct task_numa_env *env, |
| 1515 | 1525 | struct task_struct *p, long imp) |
| 1516 | 1526 | { |
| 1527 | + struct rq *rq = cpu_rq(env->dst_cpu); | |
| 1528 | + | |
| 1529 | + /* Bail out if run-queue part of active NUMA balance. */ | |
| 1530 | + if (xchg(&rq->numa_migrate_on, 1)) | |
| 1531 | + return; | |
| 1532 | + | |
| 1533 | + /* | |
| 1534 | + * Clear previous best_cpu/rq numa-migrate flag, since task now | |
| 1535 | + * found a better CPU to move/swap. | |
| 1536 | + */ | |
| 1537 | + if (env->best_cpu != -1) { | |
| 1538 | + rq = cpu_rq(env->best_cpu); | |
| 1539 | + WRITE_ONCE(rq->numa_migrate_on, 0); | |
| 1540 | + } | |
| 1541 | + | |
| 1517 | 1542 | if (env->best_task) |
| 1518 | 1543 | put_task_struct(env->best_task); |
| 1519 | 1544 | if (p) |
| @@ -1552,6 +1577,13 @@ static bool load_too_imbalanced(long src_load, long dst_load, · 32 unmodified lines | ||
| 1552 | 1577 | return (imb > old_imb); |
| 1553 | 1578 | } |
| 1554 | 1579 | |
| 1580 | +/* | |
| 1581 | + * Maximum NUMA importance can be 1998 (2*999); | |
| 1582 | + * SMALLIMP @ 30 would be close to 1998/64. | |
| 1583 | + * Used to deter task migration. | |
| 1584 | + */ | |
| 1585 | +#define SMALLIMP 30 | |
| 1586 | + | |
| 1555 | 1587 | /* |
| 1556 | 1588 | * This checks if the overall compute and NUMA accesses of the system would |
| 1557 | 1589 | * be improved if the source tasks was migrated to the target dst_cpu taking |
| @@ -1569,6 +1601,9 @@ static void task_numa_compare(struct task_numa_env *env, · 11 unmodified lines | ||
| 1569 | 1601 | long moveimp = imp; |
| 1570 | 1602 | int dist = env->dist; |
| 1571 | 1603 | |
| 1604 | + if (READ_ONCE(dst_rq->numa_migrate_on)) | |
| 1605 | + return; | |
| 1606 | + | |
| 1572 | 1607 | rcu_read_lock(); |
| 1573 | 1608 | cur = task_rcu_dereference(&dst_rq->curr); |
| 1574 | 1609 | if (cur && ((cur->flags & PF_EXITING) || is_idle_task(cur))) |
| @@ -1582,7 +1617,7 @@ static void task_numa_compare(struct task_numa_env *env, · 7 unmodified lines | ||
| 1582 | 1617 | goto unlock; |
| 1583 | 1618 | |
| 1584 | 1619 | if (!cur) { |
| 1585 | − if (maymove || imp > env->best_imp) | |
| 1620 | + if (maymove && moveimp >= env->best_imp) | |
| 1586 | 1621 | goto assign; |
| 1587 | 1622 | else |
| 1588 | 1623 | goto unlock; |
| @@ -1625,15 +1660,21 @@ static void task_numa_compare(struct task_numa_env *env, · 36 unmodified lines | ||
| 1625 | 1660 | task_weight(cur, env->dst_nid, dist); |
| 1626 | 1661 | } |
| 1627 | 1662 | |
| 1628 | − if (imp <= env->best_imp) | |
| 1629 | − goto unlock; | |
| 1630 | − | |
| 1631 | 1663 | if (maymove && moveimp > imp && moveimp > env->best_imp) { |
| 1632 | − imp = moveimp - 1; | |
| 1664 | + imp = moveimp; | |
| 1633 | 1665 | cur = NULL; |
| 1634 | 1666 | goto assign; |
| 1635 | 1667 | } |
| 1636 | 1668 | |
| 1669 | + /* | |
| 1670 | + * If the NUMA importance is less than SMALLIMP, | |
| 1671 | + * task migration might only result in ping pong | |
| 1672 | + * of tasks and also hurt performance due to cache | |
| 1673 | + * misses. | |
| 1674 | + */ | |
| 1675 | + if (imp < SMALLIMP || imp <= env->best_imp + SMALLIMP / 2) | |
| 1676 | + goto unlock; | |
| 1677 | + | |
| 1637 | 1678 | /* |
| 1638 | 1679 | * In the overloaded case, try and keep the load balanced. |
| 1639 | 1680 | */ |
| @@ -1710,6 +1751,7 @@ static int task_numa_migrate(struct task_struct *p) · 70 unmodified lines | ||
| 1710 | 1751 | .best_cpu = -1, |
| 1711 | 1752 | }; |
| 1712 | 1753 | struct sched_domain *sd; |
| 1754 | + struct rq *best_rq; | |
| 1713 | 1755 | unsigned long taskweight, groupweight; |
| 1714 | 1756 | int nid, ret, dist; |
| 1715 | 1757 | long taskimp, groupimp; |
| @@ -1805,20 +1847,17 @@ static int task_numa_migrate(struct task_struct *p) · 89 unmodified lines | ||
| 1805 | 1847 | if (env.best_cpu == -1) |
| 1806 | 1848 | return -EAGAIN; |
| 1807 | 1849 | |
| 1808 | − /* | |
| 1809 | − * Reset the scan period if the task is being rescheduled on an | |
| 1810 | − * alternative node to recheck if the tasks is now properly placed. | |
| 1811 | − */ | |
| 1812 | − p->numa_scan_period = task_scan_start(p); | |
| 1813 | − | |
| 1850 | + best_rq = cpu_rq(env.best_cpu); | |
| 1814 | 1851 | if (env.best_task == NULL) { |
| 1815 | 1852 | ret = migrate_task_to(p, env.best_cpu); |
| 1853 | + WRITE_ONCE(best_rq->numa_migrate_on, 0); | |
| 1816 | 1854 | if (ret != 0) |
| 1817 | 1855 | trace_sched_stick_numa(p, env.src_cpu, env.best_cpu); |
| 1818 | 1856 | return ret; |
| 1819 | 1857 | } |
| 1820 | 1858 | |
| 1821 | 1859 | ret = migrate_swap(p, env.best_task, env.best_cpu, env.src_cpu); |
| 1860 | + WRITE_ONCE(best_rq->numa_migrate_on, 0); | |
| 1822 | 1861 | |
| 1823 | 1862 | if (ret != 0) |
| 1824 | 1863 | trace_sched_stick_numa(p, env.src_cpu, task_cpu(env.best_task)); |
| @@ -2596,6 +2635,39 @@ void task_tick_numa(struct rq *rq, struct task_struct *curr) · 771 unmodified lines | ||
| 2596 | 2635 | } |
| 2597 | 2636 | } |
| 2598 | 2637 | |
| 2638 | +static void update_scan_period(struct task_struct *p, int new_cpu) | |
| 2639 | +{ | |
| 2640 | + int src_nid = cpu_to_node(task_cpu(p)); | |
| 2641 | + int dst_nid = cpu_to_node(new_cpu); | |
| 2642 | + | |
| 2643 | + if (!static_branch_likely(&sched_numa_balancing)) | |
| 2644 | + return; | |
| 2645 | + | |
| 2646 | + if (!p->mm || !p->numa_faults || (p->flags & PF_EXITING)) | |
| 2647 | + return; | |
| 2648 | + | |
| 2649 | + if (src_nid == dst_nid) | |
| 2650 | + return; | |
| 2651 | + | |
| 2652 | + /* | |
| 2653 | + * Allow resets if faults have been trapped before one scan | |
| 2654 | + * has completed. This is most likely due to a new task that | |
| 2655 | + * is pulled cross-node due to wakeups or load balancing. | |
| 2656 | + */ | |
| 2657 | + if (p->numa_scan_seq) { | |
| 2658 | + /* | |
| 2659 | + * Avoid scan adjustments if moving to the preferred | |
| 2660 | + * node or if the task was not previously running on | |
| 2661 | + * the preferred node. | |
| 2662 | + */ | |
| 2663 | + if (dst_nid == p->numa_preferred_nid || | |
| 2664 | + (p->numa_preferred_nid != -1 && src_nid != p->numa_preferred_nid)) | |
| 2665 | + return; | |
| 2666 | + } | |
| 2667 | + | |
| 2668 | + p->numa_scan_period = task_scan_start(p); | |
| 2669 | +} | |
| 2670 | + | |
| 2599 | 2671 | #else |
| 2600 | 2672 | static void task_tick_numa(struct rq *rq, struct task_struct *curr) |
| 2601 | 2673 | { |
| @@ -2609,6 +2681,10 @@ static inline void account_numa_dequeue(struct rq *rq, struct task_struct *p) · 7 unmodified lines | ||
| 2609 | 2681 | { |
| 2610 | 2682 | } |
| 2611 | 2683 | |
| 2684 | +static inline void update_scan_period(struct task_struct *p, int new_cpu) | |
| 2685 | +{ | |
| 2686 | +} | |
| 2687 | + | |
| 2612 | 2688 | #endif /* CONFIG_NUMA_BALANCING */ |
| 2613 | 2689 | |
| 2614 | 2690 | static void |
| @@ -6275,7 +6351,7 @@ static void detach_entity_cfs_rq(struct sched_entity *se); · 3660 unmodified lines | ||
| 6275 | 6351 | * cfs_rq_of(p) references at time of call are still valid and identify the |
| 6276 | 6352 | * previous CPU. The caller guarantees p->pi_lock or task_rq(p)->lock is held. |
| 6277 | 6353 | */ |
| 6278 | −static void migrate_task_rq_fair(struct task_struct *p) | |
| 6354 | +static void migrate_task_rq_fair(struct task_struct *p, int new_cpu) | |
| 6279 | 6355 | { |
| 6280 | 6356 | /* |
| 6281 | 6357 | * As blocked tasks retain absolute vruntime the migration needs to |
| @@ -6328,6 +6404,8 @@ static void migrate_task_rq_fair(struct task_struct *p) · 46 unmodified lines | ||
| 6328 | 6404 | |
| 6329 | 6405 | /* We have migrated, no longer consider this task hot */ |
| 6330 | 6406 | p->se.exec_start = 0; |
| 6407 | + | |
| 6408 | + update_scan_period(p, new_cpu); | |
| 6331 | 6409 | } |
| 6332 | 6410 | |
| 6333 | 6411 | static void task_dead_fair(struct task_struct *p) |
| @@ -783,6 +783,7 @@ struct rq { · 782 unmodified lines | ||
| 783 | 783 | #ifdef CONFIG_NUMA_BALANCING |
| 784 | 784 | unsigned int nr_numa_running; |
| 785 | 785 | unsigned int nr_preferred_running; |
| 786 | + unsigned int numa_migrate_on; | |
| 786 | 787 | #endif |
| 787 | 788 | #define CPU_LOAD_IDX_MAX 5 |
| 788 | 789 | unsigned long cpu_load[CPU_LOAD_IDX_MAX]; |
| @@ -1523,7 +1524,7 @@ struct sched_class { · 734 unmodified lines | ||
| 1523 | 1524 | |
| 1524 | 1525 | #ifdef CONFIG_SMP |
| 1525 | 1526 | int (*select_task_rq)(struct task_struct *p, int task_cpu, int sd_flag, int flags); |
| 1526 | − void (*migrate_task_rq)(struct task_struct *p); | |
| 1527 | + void (*migrate_task_rq)(struct task_struct *p, int new_cpu); | |
| 1527 | 1528 | |
| 1528 | 1529 | void (*task_woken)(struct rq *this_rq, struct task_struct *task); |
| 1529 | 1530 | |
| @@ -15,7 +15,6 @@ · 14 unmodified lines | ||
| 15 | 15 | * but they are bigger and use more memory for the lookup table. |
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | −#include <linux/crc32poly.h> | |
| 19 | 18 | #include "xz_private.h" |
| 20 | 19 | |
| 21 | 20 | /* |
| @@ -102,6 +102,10 @@ · 101 unmodified lines | ||
| 102 | 102 | # endif |
| 103 | 103 | #endif |
| 104 | 104 | |
| 105 | +#ifndef CRC32_POLY_LE | |
| 106 | +#define CRC32_POLY_LE 0xedb88320 | |
| 107 | +#endif | |
| 108 | + | |
| 105 | 109 | /* |
| 106 | 110 | * Allocate memory for LZMA2 decoder. xz_dec_lzma2_reset() must be used |
| 107 | 111 | * before calling xz_dec_lzma2_run(). |
| @@ -19,7 +19,8 @@ static int __gup_benchmark_ioctl(unsigned int cmd, · 18 unmodified lines | ||
| 19 | 19 | struct gup_benchmark *gup) |
| 20 | 20 | { |
| 21 | 21 | ktime_t start_time, end_time; |
| 22 | − unsigned long i, nr, nr_pages, addr, next; | |
| 22 | + unsigned long i, nr_pages, addr, next; | |
| 23 | + int nr; | |
| 23 | 24 | struct page **pages; |
| 24 | 25 | |
| 25 | 26 | nr_pages = gup->size / PAGE_SIZE; |
| @@ -2931,7 +2931,7 @@ void remove_migration_pmd(struct page_vma_mapped_walk *pvmw, struct page *new) · 2930 unmodified lines | ||
| 2931 | 2931 | else |
| 2932 | 2932 | page_add_file_rmap(new, true); |
| 2933 | 2933 | set_pmd_at(mm, mmun_start, pvmw->pmd, pmde); |
| 2934 | − if (vma->vm_flags & VM_LOCKED) | |
| 2934 | + if ((vma->vm_flags & VM_LOCKED) && !PageDoubleMap(new)) | |
| 2935 | 2935 | mlock_vma_page(new); |
| 2936 | 2936 | update_mmu_cache_pmd(vma, address, pvmw->pmd); |
| 2937 | 2937 | } |
| @@ -3326,8 +3326,8 @@ void __unmap_hugepage_range(struct mmu_gather *tlb, struct vm_area_struct *vma, · 3325 unmodified lines | ||
| 3326 | 3326 | struct page *page; |
| 3327 | 3327 | struct hstate *h = hstate_vma(vma); |
| 3328 | 3328 | unsigned long sz = huge_page_size(h); |
| 3329 | − const unsigned long mmun_start = start; /* For mmu_notifiers */ | |
| 3330 | − const unsigned long mmun_end = end; /* For mmu_notifiers */ | |
| 3329 | + unsigned long mmun_start = start; /* For mmu_notifiers */ | |
| 3330 | + unsigned long mmun_end = end; /* For mmu_notifiers */ | |
| 3331 | 3331 | |
| 3332 | 3332 | WARN_ON(!is_vm_hugetlb_page(vma)); |
| 3333 | 3333 | BUG_ON(start & ~huge_page_mask(h)); |
| @@ -3339,6 +3339,11 @@ void __unmap_hugepage_range(struct mmu_gather *tlb, struct vm_area_struct *vma, · 5 unmodified lines | ||
| 3339 | 3339 | */ |
| 3340 | 3340 | tlb_remove_check_page_size_change(tlb, sz); |
| 3341 | 3341 | tlb_start_vma(tlb, vma); |
| 3342 | + | |
| 3343 | + /* | |
| 3344 | + * If sharing possible, alert mmu notifiers of worst case. | |
| 3345 | + */ | |
| 3346 | + adjust_range_if_pmd_sharing_possible(vma, &mmun_start, &mmun_end); | |
| 3342 | 3347 | mmu_notifier_invalidate_range_start(mm, mmun_start, mmun_end); |
| 3343 | 3348 | address = start; |
| 3344 | 3349 | for (; address < end; address += sz) { |
| @@ -3349,6 +3354,10 @@ void __unmap_hugepage_range(struct mmu_gather *tlb, struct vm_area_struct *vma, · 4 unmodified lines | ||
| 3349 | 3354 | ptl = huge_pte_lock(h, mm, ptep); |
| 3350 | 3355 | if (huge_pmd_unshare(mm, &address, ptep)) { |
| 3351 | 3356 | spin_unlock(ptl); |
| 3357 | + /* | |
| 3358 | + * We just unmapped a page of PMDs by clearing a PUD. | |
| 3359 | + * The caller's TLB flush range should cover this area. | |
| 3360 | + */ | |
| 3352 | 3361 | continue; |
| 3353 | 3362 | } |
| 3354 | 3363 | |
| @@ -3431,12 +3440,23 @@ void unmap_hugepage_range(struct vm_area_struct *vma, unsigned long start, · 76 unmodified lines | ||
| 3431 | 3440 | { |
| 3432 | 3441 | struct mm_struct *mm; |
| 3433 | 3442 | struct mmu_gather tlb; |
| 3443 | + unsigned long tlb_start = start; | |
| 3444 | + unsigned long tlb_end = end; | |
| 3445 | + | |
| 3446 | + /* | |
| 3447 | + * If shared PMDs were possibly used within this vma range, adjust | |
| 3448 | + * start/end for worst case tlb flushing. | |
| 3449 | + * Note that we can not be sure if PMDs are shared until we try to | |
| 3450 | + * unmap pages. However, we want to make sure TLB flushing covers | |
| 3451 | + * the largest possible range. | |
| 3452 | + */ | |
| 3453 | + adjust_range_if_pmd_sharing_possible(vma, &tlb_start, &tlb_end); | |
| 3434 | 3454 | |
| 3435 | 3455 | mm = vma->vm_mm; |
| 3436 | 3456 | |
| 3437 | − tlb_gather_mmu(&tlb, mm, start, end); | |
| 3457 | + tlb_gather_mmu(&tlb, mm, tlb_start, tlb_end); | |
| 3438 | 3458 | __unmap_hugepage_range(&tlb, vma, start, end, ref_page); |
| 3439 | − tlb_finish_mmu(&tlb, start, end); | |
| 3459 | + tlb_finish_mmu(&tlb, tlb_start, tlb_end); | |
| 3440 | 3460 | } |
| 3441 | 3461 | |
| 3442 | 3462 | /* |
| @@ -4298,11 +4318,21 @@ unsigned long hugetlb_change_protection(struct vm_area_struct *vma, · 855 unmodified lines | ||
| 4298 | 4318 | pte_t pte; |
| 4299 | 4319 | struct hstate *h = hstate_vma(vma); |
| 4300 | 4320 | unsigned long pages = 0; |
| 4321 | + unsigned long f_start = start; | |
| 4322 | + unsigned long f_end = end; | |
| 4323 | + bool shared_pmd = false; | |
| 4324 | + | |
| 4325 | + /* | |
| 4326 | + * In the case of shared PMDs, the area to flush could be beyond | |
| 4327 | + * start/end. Set f_start/f_end to cover the maximum possible | |
| 4328 | + * range if PMD sharing is possible. | |
| 4329 | + */ | |
| 4330 | + adjust_range_if_pmd_sharing_possible(vma, &f_start, &f_end); | |
| 4301 | 4331 | |
| 4302 | 4332 | BUG_ON(address >= end); |
| 4303 | − flush_cache_range(vma, address, end); | |
| 4333 | + flush_cache_range(vma, f_start, f_end); | |
| 4304 | 4334 | |
| 4305 | − mmu_notifier_invalidate_range_start(mm, start, end); | |
| 4335 | + mmu_notifier_invalidate_range_start(mm, f_start, f_end); | |
| 4306 | 4336 | i_mmap_lock_write(vma->vm_file->f_mapping); |
| 4307 | 4337 | for (; address < end; address += huge_page_size(h)) { |
| 4308 | 4338 | spinlock_t *ptl; |
| @@ -4313,6 +4343,7 @@ unsigned long hugetlb_change_protection(struct vm_area_struct *vma, · 4 unmodified lines | ||
| 4313 | 4343 | if (huge_pmd_unshare(mm, &address, ptep)) { |
| 4314 | 4344 | pages++; |
| 4315 | 4345 | spin_unlock(ptl); |
| 4346 | + shared_pmd = true; | |
| 4316 | 4347 | continue; |
| 4317 | 4348 | } |
| 4318 | 4349 | pte = huge_ptep_get(ptep); |
| @@ -4348,9 +4379,13 @@ unsigned long hugetlb_change_protection(struct vm_area_struct *vma, · 29 unmodified lines | ||
| 4348 | 4379 | * Must flush TLB before releasing i_mmap_rwsem: x86's huge_pmd_unshare |
| 4349 | 4380 | * may have cleared our pud entry and done put_page on the page table: |
| 4350 | 4381 | * once we release i_mmap_rwsem, another task can do the final put_page |
| 4351 | − * and that page table be reused and filled with junk. | |
| 4382 | + * and that page table be reused and filled with junk. If we actually | |
| 4383 | + * did unshare a page of pmds, flush the range corresponding to the pud. | |
| 4352 | 4384 | */ |
| 4353 | − flush_hugetlb_tlb_range(vma, start, end); | |
| 4385 | + if (shared_pmd) | |
| 4386 | + flush_hugetlb_tlb_range(vma, f_start, f_end); | |
| 4387 | + else | |
| 4388 | + flush_hugetlb_tlb_range(vma, start, end); | |
| 4354 | 4389 | /* |
| 4355 | 4390 | * No need to call mmu_notifier_invalidate_range() we are downgrading |
| 4356 | 4391 | * page table protection not changing it to point to a new page. |
| @@ -4358,7 +4393,7 @@ unsigned long hugetlb_change_protection(struct vm_area_struct *vma, · 1 unmodified line | ||
| 4358 | 4393 | * See Documentation/vm/mmu_notifier.rst |
| 4359 | 4394 | */ |
| 4360 | 4395 | i_mmap_unlock_write(vma->vm_file->f_mapping); |
| 4361 | − mmu_notifier_invalidate_range_end(mm, start, end); | |
| 4396 | + mmu_notifier_invalidate_range_end(mm, f_start, f_end); | |
| 4362 | 4397 | |
| 4363 | 4398 | return pages << h->order; |
| 4364 | 4399 | } |
| @@ -4545,12 +4580,40 @@ static bool vma_shareable(struct vm_area_struct *vma, unsigned long addr) · 180 unmodified lines | ||
| 4545 | 4580 | /* |
| 4546 | 4581 | * check on proper vm_flags and page table alignment |
| 4547 | 4582 | */ |
| 4548 | − if (vma->vm_flags & VM_MAYSHARE && | |
| 4549 | − vma->vm_start <= base && end <= vma->vm_end) | |
| 4583 | + if (vma->vm_flags & VM_MAYSHARE && range_in_vma(vma, base, end)) | |
| 4550 | 4584 | return true; |
| 4551 | 4585 | return false; |
| 4552 | 4586 | } |
| 4553 | 4587 | |
| 4588 | +/* | |
| 4589 | + * Determine if start,end range within vma could be mapped by shared pmd. | |
| 4590 | + * If yes, adjust start and end to cover range associated with possible | |
| 4591 | + * shared pmd mappings. | |
| 4592 | + */ | |
| 4593 | +void adjust_range_if_pmd_sharing_possible(struct vm_area_struct *vma, | |
| 4594 | + unsigned long *start, unsigned long *end) | |
| 4595 | +{ | |
| 4596 | + unsigned long check_addr = *start; | |
| 4597 | + | |
| 4598 | + if (!(vma->vm_flags & VM_MAYSHARE)) | |
| 4599 | + return; | |
| 4600 | + | |
| 4601 | + for (check_addr = *start; check_addr < *end; check_addr += PUD_SIZE) { | |
| 4602 | + unsigned long a_start = check_addr & PUD_MASK; | |
| 4603 | + unsigned long a_end = a_start + PUD_SIZE; | |
| 4604 | + | |
| 4605 | + /* | |
| 4606 | + * If sharing is possible, adjust start/end if necessary. | |
| 4607 | + */ | |
| 4608 | + if (range_in_vma(vma, a_start, a_end)) { | |
| 4609 | + if (a_start < *start) | |
| 4610 | + *start = a_start; | |
| 4611 | + if (a_end > *end) | |
| 4612 | + *end = a_end; | |
| 4613 | + } | |
| 4614 | + } | |
| 4615 | +} | |
| 4616 | + | |
| 4554 | 4617 | /* |
| 4555 | 4618 | * Search for a shareable pmd page for hugetlb. In any case calls pmd_alloc() |
| 4556 | 4619 | * and returns the corresponding pte. While this is not necessary for the |
| @@ -4648,6 +4711,11 @@ int huge_pmd_unshare(struct mm_struct *mm, unsigned long *addr, pte_t *ptep) · 91 unmodified lines | ||
| 4648 | 4711 | { |
| 4649 | 4712 | return 0; |
| 4650 | 4713 | } |
| 4714 | + | |
| 4715 | +void adjust_range_if_pmd_sharing_possible(struct vm_area_struct *vma, | |
| 4716 | + unsigned long *start, unsigned long *end) | |
| 4717 | +{ | |
| 4718 | +} | |
| 4651 | 4719 | #define want_pmd_share() (0) |
| 4652 | 4720 | #endif /* CONFIG_ARCH_WANT_HUGE_PMD_SHARE */ |
| 4653 | 4721 | |
| @@ -96,7 +96,7 @@ static long madvise_behavior(struct vm_area_struct *vma, · 95 unmodified lines | ||
| 96 | 96 | new_flags |= VM_DONTDUMP; |
| 97 | 97 | break; |
| 98 | 98 | case MADV_DODUMP: |
| 99 | − if (new_flags & VM_SPECIAL) { | |
| 99 | + if (!is_vm_hugetlb_page(vma) && new_flags & VM_SPECIAL) { | |
| 100 | 100 | error = -EINVAL; |
| 101 | 101 | goto out; |
| 102 | 102 | } |
| @@ -275,6 +275,9 @@ static bool remove_migration_pte(struct page *page, struct vm_area_struct *vma, · 274 unmodified lines | ||
| 275 | 275 | if (vma->vm_flags & VM_LOCKED && !PageTransCompound(new)) |
| 276 | 276 | mlock_vma_page(new); |
| 277 | 277 | |
| 278 | + if (PageTransHuge(page) && PageMlocked(page)) | |
| 279 | + clear_page_mlock(page); | |
| 280 | + | |
| 278 | 281 | /* No need to invalidate - it was non-present before */ |
| 279 | 282 | update_mmu_cache(vma, pvmw.address, pvmw.pte); |
| 280 | 283 | } |
| @@ -1411,7 +1414,7 @@ retry: · 1130 unmodified lines | ||
| 1411 | 1414 | * we encounter them after the rest of the list |
| 1412 | 1415 | * is processed. |
| 1413 | 1416 | */ |
| 1414 | − if (PageTransHuge(page)) { | |
| 1417 | + if (PageTransHuge(page) && !PageHuge(page)) { | |
| 1415 | 1418 | lock_page(page); |
| 1416 | 1419 | rc = split_huge_page_to_list(page, from); |
| 1417 | 1420 | unlock_page(page); |
| @@ -1855,46 +1858,6 @@ static struct page *alloc_misplaced_dst_page(struct page *page, · 437 unmodified lines | ||
| 1855 | 1858 | return newpage; |
| 1856 | 1859 | } |
| 1857 | 1860 | |
| 1858 | −/* | |
| 1859 | − * page migration rate limiting control. | |
| 1860 | − * Do not migrate more than @pages_to_migrate in a @migrate_interval_millisecs | |
| 1861 | − * window of time. Default here says do not migrate more than 1280M per second. | |
| 1862 | − */ | |
| 1863 | −static unsigned int migrate_interval_millisecs __read_mostly = 100; | |
| 1864 | −static unsigned int ratelimit_pages __read_mostly = 128 << (20 - PAGE_SHIFT); | |
| 1865 | − | |
| 1866 | −/* Returns true if the node is migrate rate-limited after the update */ | |
| 1867 | −static bool numamigrate_update_ratelimit(pg_data_t *pgdat, | |
| 1868 | − unsigned long nr_pages) | |
| 1869 | −{ | |
| 1870 | − /* | |
| 1871 | − * Rate-limit the amount of data that is being migrated to a node. | |
| 1872 | − * Optimal placement is no good if the memory bus is saturated and | |
| 1873 | − * all the time is being spent migrating! | |
| 1874 | − */ | |
| 1875 | − if (time_after(jiffies, pgdat->numabalancing_migrate_next_window)) { | |
| 1876 | − spin_lock(&pgdat->numabalancing_migrate_lock); | |
| 1877 | − pgdat->numabalancing_migrate_nr_pages = 0; | |
| 1878 | − pgdat->numabalancing_migrate_next_window = jiffies + | |
| 1879 | − msecs_to_jiffies(migrate_interval_millisecs); | |
| 1880 | − spin_unlock(&pgdat->numabalancing_migrate_lock); | |
| 1881 | − } | |
| 1882 | − if (pgdat->numabalancing_migrate_nr_pages > ratelimit_pages) { | |
| 1883 | − trace_mm_numa_migrate_ratelimit(current, pgdat->node_id, | |
| 1884 | − nr_pages); | |
| 1885 | − return true; | |
| 1886 | − } | |
| 1887 | − | |
| 1888 | − /* | |
| 1889 | − * This is an unlocked non-atomic update so errors are possible. | |
| 1890 | − * The consequences are failing to migrate when we potentiall should | |
| 1891 | − * have which is not severe enough to warrant locking. If it is ever | |
| 1892 | − * a problem, it can be converted to a per-cpu counter. | |
| 1893 | − */ | |
| 1894 | − pgdat->numabalancing_migrate_nr_pages += nr_pages; | |
| 1895 | − return false; | |
| 1896 | −} | |
| 1897 | − | |
| 1898 | 1861 | static int numamigrate_isolate_page(pg_data_t *pgdat, struct page *page) |
| 1899 | 1862 | { |
| 1900 | 1863 | int page_lru; |
| @@ -1967,14 +1930,6 @@ int migrate_misplaced_page(struct page *page, struct vm_area_struct *vma, · 66 unmodified lines | ||
| 1967 | 1930 | if (page_is_file_cache(page) && PageDirty(page)) |
| 1968 | 1931 | goto out; |
| 1969 | 1932 | |
| 1970 | − /* | |
| 1971 | − * Rate-limit the amount of data that is being migrated to a node. | |
| 1972 | − * Optimal placement is no good if the memory bus is saturated and | |
| 1973 | − * all the time is being spent migrating! | |
| 1974 | − */ | |
| 1975 | − if (numamigrate_update_ratelimit(pgdat, 1)) | |
| 1976 | − goto out; | |
| 1977 | − | |
| 1978 | 1933 | isolated = numamigrate_isolate_page(pgdat, page); |
| 1979 | 1934 | if (!isolated) |
| 1980 | 1935 | goto out; |
| @@ -2021,14 +1976,6 @@ int migrate_misplaced_transhuge_page(struct mm_struct *mm, · 40 unmodified lines | ||
| 2021 | 1976 | unsigned long mmun_start = address & HPAGE_PMD_MASK; |
| 2022 | 1977 | unsigned long mmun_end = mmun_start + HPAGE_PMD_SIZE; |
| 2023 | 1978 | |
| 2024 | − /* | |
| 2025 | − * Rate-limit the amount of data that is being migrated to a node. | |
| 2026 | − * Optimal placement is no good if the memory bus is saturated and | |
| 2027 | − * all the time is being spent migrating! | |
| 2028 | − */ | |
| 2029 | − if (numamigrate_update_ratelimit(pgdat, HPAGE_PMD_NR)) | |
| 2030 | − goto out_dropref; | |
| 2031 | − | |
| 2032 | 1979 | new_page = alloc_pages_node(node, |
| 2033 | 1980 | (GFP_TRANSHUGE_LIGHT | __GFP_THISNODE), |
| 2034 | 1981 | HPAGE_PMD_ORDER); |
| @@ -2125,7 +2072,6 @@ int migrate_misplaced_transhuge_page(struct mm_struct *mm, · 90 unmodified lines | ||
| 2125 | 2072 | |
| 2126 | 2073 | out_fail: |
| 2127 | 2074 | count_vm_events(PGMIGRATE_FAIL, HPAGE_PMD_NR); |
| 2128 | −out_dropref: | |
| 2129 | 2075 | ptl = pmd_lock(mm, pmd); |
| 2130 | 2076 | if (pmd_same(*pmd, entry)) { |
| 2131 | 2077 | entry = pmd_modify(entry, vma->vm_page_prot); |
| @@ -6197,8 +6197,6 @@ static unsigned long __init calc_memmap_size(unsigned long spanned_pages, · 6196 unmodified lines | ||
| 6197 | 6197 | static void pgdat_init_numabalancing(struct pglist_data *pgdat) |
| 6198 | 6198 | { |
| 6199 | 6199 | spin_lock_init(&pgdat->numabalancing_migrate_lock); |
| 6200 | − pgdat->numabalancing_migrate_nr_pages = 0; | |
| 6201 | − pgdat->numabalancing_migrate_next_window = jiffies; | |
| 6202 | 6200 | } |
| 6203 | 6201 | #else |
| 6204 | 6202 | static void pgdat_init_numabalancing(struct pglist_data *pgdat) {} |
| @@ -1362,11 +1362,21 @@ static bool try_to_unmap_one(struct page *page, struct vm_area_struct *vma, · 1361 unmodified lines | ||
| 1362 | 1362 | } |
| 1363 | 1363 | |
| 1364 | 1364 | /* |
| 1365 | − * We have to assume the worse case ie pmd for invalidation. Note that | |
| 1366 | − * the page can not be free in this function as call of try_to_unmap() | |
| 1367 | − * must hold a reference on the page. | |
| 1365 | + * For THP, we have to assume the worse case ie pmd for invalidation. | |
| 1366 | + * For hugetlb, it could be much worse if we need to do pud | |
| 1367 | + * invalidation in the case of pmd sharing. | |
| 1368 | + * | |
| 1369 | + * Note that the page can not be free in this function as call of | |
| 1370 | + * try_to_unmap() must hold a reference on the page. | |
| 1368 | 1371 | */ |
| 1369 | 1372 | end = min(vma->vm_end, start + (PAGE_SIZE << compound_order(page))); |
| 1373 | + if (PageHuge(page)) { | |
| 1374 | + /* | |
| 1375 | + * If sharing is possible, start and end will be adjusted | |
| 1376 | + * accordingly. | |
| 1377 | + */ | |
| 1378 | + adjust_range_if_pmd_sharing_possible(vma, &start, &end); | |
| 1379 | + } | |
| 1370 | 1380 | mmu_notifier_invalidate_range_start(vma->vm_mm, start, end); |
| 1371 | 1381 | |
| 1372 | 1382 | while (page_vma_mapped_walk(&pvmw)) { |
| @@ -1409,6 +1419,32 @@ static bool try_to_unmap_one(struct page *page, struct vm_area_struct *vma, · 36 unmodified lines | ||
| 1409 | 1419 | subpage = page - page_to_pfn(page) + pte_pfn(*pvmw.pte); |
| 1410 | 1420 | address = pvmw.address; |
| 1411 | 1421 | |
| 1422 | + if (PageHuge(page)) { | |
| 1423 | + if (huge_pmd_unshare(mm, &address, pvmw.pte)) { | |
| 1424 | + /* | |
| 1425 | + * huge_pmd_unshare unmapped an entire PMD | |
| 1426 | + * page. There is no way of knowing exactly | |
| 1427 | + * which PMDs may be cached for this mm, so | |
| 1428 | + * we must flush them all. start/end were | |
| 1429 | + * already adjusted above to cover this range. | |
| 1430 | + */ | |
| 1431 | + flush_cache_range(vma, start, end); | |
| 1432 | + flush_tlb_range(vma, start, end); | |
| 1433 | + mmu_notifier_invalidate_range(mm, start, end); | |
| 1434 | + | |
| 1435 | + /* | |
| 1436 | + * The ref count of the PMD page was dropped | |
| 1437 | + * which is part of the way map counting | |
| 1438 | + * is done for shared PMDs. Return 'true' | |
| 1439 | + * here. When there is no other sharing, | |
| 1440 | + * huge_pmd_unshare returns false and we will | |
| 1441 | + * unmap the actual page and drop map count | |
| 1442 | + * to zero. | |
| 1443 | + */ | |
| 1444 | + page_vma_mapped_walk_done(&pvmw); | |
| 1445 | + break; | |
| 1446 | + } | |
| 1447 | + } | |
| 1412 | 1448 | |
| 1413 | 1449 | if (IS_ENABLED(CONFIG_MIGRATION) && |
| 1414 | 1450 | (flags & TTU_MIGRATION) && |
| @@ -580,8 +580,8 @@ static unsigned long shrink_slab_memcg(gfp_t gfp_mask, int nid, · 579 unmodified lines | ||
| 580 | 580 | struct mem_cgroup *memcg, int priority) |
| 581 | 581 | { |
| 582 | 582 | struct memcg_shrinker_map *map; |
| 583 | − unsigned long freed = 0; | |
| 584 | − int ret, i; | |
| 583 | + unsigned long ret, freed = 0; | |
| 584 | + int i; | |
| 585 | 585 | |
| 586 | 586 | if (!memcg_kmem_enabled() || !mem_cgroup_online(memcg)) |
| 587 | 587 | return 0; |
| @@ -677,9 +677,8 @@ static unsigned long shrink_slab(gfp_t gfp_mask, int nid, · 89 unmodified lines | ||
| 677 | 677 | struct mem_cgroup *memcg, |
| 678 | 678 | int priority) |
| 679 | 679 | { |
| 680 | + unsigned long ret, freed = 0; | |
| 680 | 681 | struct shrinker *shrinker; |
| 681 | − unsigned long freed = 0; | |
| 682 | − int ret; | |
| 683 | 682 | |
| 684 | 683 | if (!mem_cgroup_is_root(memcg)) |
| 685 | 684 | return shrink_slab_memcg(gfp_mask, nid, memcg, priority); |
| @@ -1275,6 +1275,9 @@ const char * const vmstat_text[] = { · 1274 unmodified lines | ||
| 1275 | 1275 | #ifdef CONFIG_SMP |
| 1276 | 1276 | "nr_tlb_remote_flush", |
| 1277 | 1277 | "nr_tlb_remote_flush_received", |
| 1278 | +#else | |
| 1279 | + "", /* nr_tlb_remote_flush */ | |
| 1280 | + "", /* nr_tlb_remote_flush_received */ | |
| 1278 | 1281 | #endif /* CONFIG_SMP */ |
| 1279 | 1282 | "nr_tlb_local_flush_all", |
| 1280 | 1283 | "nr_tlb_local_flush_one", |
| @@ -1283,7 +1286,6 @@ const char * const vmstat_text[] = { · 2 unmodified lines | ||
| 1283 | 1286 | #ifdef CONFIG_DEBUG_VM_VMACACHE |
| 1284 | 1287 | "vmacache_find_calls", |
| 1285 | 1288 | "vmacache_find_hits", |
| 1286 | − "vmacache_full_flushes", | |
| 1287 | 1289 | #endif |
| 1288 | 1290 | #ifdef CONFIG_SWAP |
| 1289 | 1291 | "swap_ra", |
| @@ -2434,9 +2434,8 @@ static int unpair_device(struct sock *sk, struct hci_dev *hdev, void *data, · 2433 unmodified lines | ||
| 2434 | 2434 | /* LE address type */ |
| 2435 | 2435 | addr_type = le_addr_type(cp->addr.type); |
| 2436 | 2436 | |
| 2437 | − hci_remove_irk(hdev, &cp->addr.bdaddr, addr_type); | |
| 2438 | − | |
| 2439 | − err = hci_remove_ltk(hdev, &cp->addr.bdaddr, addr_type); | |
| 2437 | + /* Abort any ongoing SMP pairing. Removes ltk and irk if they exist. */ | |
| 2438 | + err = smp_cancel_and_remove_pairing(hdev, &cp->addr.bdaddr, addr_type); | |
| 2440 | 2439 | if (err < 0) { |
| 2441 | 2440 | err = mgmt_cmd_complete(sk, hdev->id, MGMT_OP_UNPAIR_DEVICE, |
| 2442 | 2441 | MGMT_STATUS_NOT_PAIRED, &rp, |
| @@ -2450,8 +2449,6 @@ static int unpair_device(struct sock *sk, struct hci_dev *hdev, void *data, · 7 unmodified lines | ||
| 2450 | 2449 | goto done; |
| 2451 | 2450 | } |
| 2452 | 2451 | |
| 2453 | − /* Abort any ongoing SMP pairing */ | |
| 2454 | − smp_cancel_pairing(conn); | |
| 2455 | 2452 | |
| 2456 | 2453 | /* Defer clearing up the connection parameters until closing to |
| 2457 | 2454 | * give a chance of keeping them if a repairing happens. |
| @@ -2422,30 +2422,51 @@ unlock: · 2421 unmodified lines | ||
| 2422 | 2422 | return ret; |
| 2423 | 2423 | } |
| 2424 | 2424 | |
| 2425 | −void smp_cancel_pairing(struct hci_conn *hcon) | |
| 2425 | +int smp_cancel_and_remove_pairing(struct hci_dev *hdev, bdaddr_t *bdaddr, | |
| 2426 | + u8 addr_type) | |
| 2426 | 2427 | { |
| 2427 | − struct l2cap_conn *conn = hcon->l2cap_data; | |
| 2428 | + struct hci_conn *hcon; | |
| 2429 | + struct l2cap_conn *conn; | |
| 2428 | 2430 | struct l2cap_chan *chan; |
| 2429 | 2431 | struct smp_chan *smp; |
| 2432 | + int err; | |
| 2433 | + | |
| 2434 | + err = hci_remove_ltk(hdev, bdaddr, addr_type); | |
| 2435 | + hci_remove_irk(hdev, bdaddr, addr_type); | |
| 2436 | + | |
| 2437 | + hcon = hci_conn_hash_lookup_le(hdev, bdaddr, addr_type); | |
| 2438 | + if (!hcon) | |
| 2439 | + goto done; | |
| 2430 | 2440 | |
| 2441 | + conn = hcon->l2cap_data; | |
| 2431 | 2442 | if (!conn) |
| 2432 | − return; | |
| 2443 | + goto done; | |
| 2433 | 2444 | |
| 2434 | 2445 | chan = conn->smp; |
| 2435 | 2446 | if (!chan) |
| 2436 | − return; | |
| 2447 | + goto done; | |
| 2437 | 2448 | |
| 2438 | 2449 | l2cap_chan_lock(chan); |
| 2439 | 2450 | |
| 2440 | 2451 | smp = chan->data; |
| 2441 | 2452 | if (smp) { |
| 2453 | + /* Set keys to NULL to make sure smp_failure() does not try to | |
| 2454 | + * remove and free already invalidated rcu list entries. */ | |
| 2455 | + smp->ltk = NULL; | |
| 2456 | + smp->slave_ltk = NULL; | |
| 2457 | + smp->remote_irk = NULL; | |
| 2458 | + | |
| 2442 | 2459 | if (test_bit(SMP_FLAG_COMPLETE, &smp->flags)) |
| 2443 | 2460 | smp_failure(conn, 0); |
| 2444 | 2461 | else |
| 2445 | 2462 | smp_failure(conn, SMP_UNSPECIFIED); |
| 2463 | + err = 0; | |
| 2446 | 2464 | } |
| 2447 | 2465 | |
| 2448 | 2466 | l2cap_chan_unlock(chan); |
| 2467 | + | |
| 2468 | +done: | |
| 2469 | + return err; | |
| 2449 | 2470 | } |
| 2450 | 2471 | |
| 2451 | 2472 | static int smp_cmd_encrypt_info(struct l2cap_conn *conn, struct sk_buff *skb) |
| @@ -181,7 +181,8 @@ enum smp_key_pref { · 180 unmodified lines | ||
| 181 | 181 | }; |
| 182 | 182 | |
| 183 | 183 | /* SMP Commands */ |
| 184 | −void smp_cancel_pairing(struct hci_conn *hcon); | |
| 184 | +int smp_cancel_and_remove_pairing(struct hci_dev *hdev, bdaddr_t *bdaddr, | |
| 185 | + u8 addr_type); | |
| 185 | 186 | bool smp_sufficient_security(struct hci_conn *hcon, u8 sec_level, |
| 186 | 187 | enum smp_key_pref key_pref); |
| 187 | 188 | int smp_conn_security(struct hci_conn *hcon, __u8 sec_level); |
| @@ -59,7 +59,7 @@ static int __bpfilter_process_sockopt(struct sock *sk, int optname, · 58 unmodified lines | ||
| 59 | 59 | req.is_set = is_set; |
| 60 | 60 | req.pid = current->pid; |
| 61 | 61 | req.cmd = optname; |
| 62 | − req.addr = (long)optval; | |
| 62 | + req.addr = (long __force __user)optval; | |
| 63 | 63 | req.len = optlen; |
| 64 | 64 | mutex_lock(&bpfilter_lock); |
| 65 | 65 | if (!info.pid) |
| @@ -98,7 +98,7 @@ static int __init load_umh(void) · 32 unmodified lines | ||
| 98 | 98 | pr_info("Loaded bpfilter_umh pid %d\n", info.pid); |
| 99 | 99 | |
| 100 | 100 | /* health check that usermode process started correctly */ |
| 101 | − if (__bpfilter_process_sockopt(NULL, 0, 0, 0, 0) != 0) { | |
| 101 | + if (__bpfilter_process_sockopt(NULL, 0, NULL, 0, 0) != 0) { | |
| 102 | 102 | stop_umh(); |
| 103 | 103 | return -EFAULT; |
| 104 | 104 | } |
| @@ -835,7 +835,8 @@ static unsigned int ip_sabotage_in(void *priv, · 834 unmodified lines | ||
| 835 | 835 | struct sk_buff *skb, |
| 836 | 836 | const struct nf_hook_state *state) |
| 837 | 837 | { |
| 838 | − if (skb->nf_bridge && !skb->nf_bridge->in_prerouting) { | |
| 838 | + if (skb->nf_bridge && !skb->nf_bridge->in_prerouting && | |
| 839 | + !netif_is_l3_master(skb->dev)) { | |
| 839 | 840 | state->okfn(state->net, state->sk, skb); |
| 840 | 841 | return NF_STOLEN; |
| 841 | 842 | } |
| @@ -1483,6 +1483,7 @@ static int ethtool_get_wol(struct net_device *dev, char __user *useraddr) · 1482 unmodified lines | ||
| 1483 | 1483 | static int ethtool_set_wol(struct net_device *dev, char __user *useraddr) |
| 1484 | 1484 | { |
| 1485 | 1485 | struct ethtool_wolinfo wol; |
| 1486 | + int ret; | |
| 1486 | 1487 | |
| 1487 | 1488 | if (!dev->ethtool_ops->set_wol) |
| 1488 | 1489 | return -EOPNOTSUPP; |
| @@ -1490,7 +1491,13 @@ static int ethtool_set_wol(struct net_device *dev, char __user *useraddr) · 1 unmodified line | ||
| 1490 | 1491 | if (copy_from_user(&wol, useraddr, sizeof(wol))) |
| 1491 | 1492 | return -EFAULT; |
| 1492 | 1493 | |
| 1493 | − return dev->ethtool_ops->set_wol(dev, &wol); | |
| 1494 | + ret = dev->ethtool_ops->set_wol(dev, &wol); | |
| 1495 | + if (ret) | |
| 1496 | + return ret; | |
| 1497 | + | |
| 1498 | + dev->wol_enabled = !!wol.wolopts; | |
| 1499 | + | |
| 1500 | + return 0; | |
| 1494 | 1501 | } |
| 1495 | 1502 | |
| 1496 | 1503 | static int ethtool_get_eee(struct net_device *dev, char __user *useraddr) |
| @@ -135,27 +135,9 @@ static void queue_process(struct work_struct *work) · 134 unmodified lines | ||
| 135 | 135 | } |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | −/* | |
| 139 | − * Check whether delayed processing was scheduled for our NIC. If so, | |
| 140 | − * we attempt to grab the poll lock and use ->poll() to pump the card. | |
| 141 | − * If this fails, either we've recursed in ->poll() or it's already | |
| 142 | − * running on another CPU. | |
| 143 | − * | |
| 144 | − * Note: we don't mask interrupts with this lock because we're using | |
| 145 | − * trylock here and interrupts are already disabled in the softirq | |
| 146 | − * case. Further, we test the poll_owner to avoid recursion on UP | |
| 147 | − * systems where the lock doesn't exist. | |
| 148 | − */ | |
| 149 | 138 | static void poll_one_napi(struct napi_struct *napi) |
| 150 | 139 | { |
| 151 | − int work = 0; | |
| 152 | − | |
| 153 | − /* net_rx_action's ->poll() invocations and our's are | |
| 154 | − * synchronized by this test which is only made while | |
| 155 | − * holding the napi->poll_lock. | |
| 156 | − */ | |
| 157 | − if (!test_bit(NAPI_STATE_SCHED, &napi->state)) | |
| 158 | − return; | |
| 140 | + int work; | |
| 159 | 141 | |
| 160 | 142 | /* If we set this bit but see that it has already been set, |
| 161 | 143 | * that indicates that napi has been disabled and we need |
| @@ -330,6 +312,7 @@ void netpoll_send_skb_on_dev(struct netpoll *np, struct sk_buff *skb, · 168 unmodified lines | ||
| 330 | 312 | /* It is up to the caller to keep npinfo alive. */ |
| 331 | 313 | struct netpoll_info *npinfo; |
| 332 | 314 | |
| 315 | + rcu_read_lock_bh(); | |
| 333 | 316 | lockdep_assert_irqs_disabled(); |
| 334 | 317 | |
| 335 | 318 | npinfo = rcu_dereference_bh(np->dev->npinfo); |
| @@ -374,6 +357,7 @@ void netpoll_send_skb_on_dev(struct netpoll *np, struct sk_buff *skb, · 38 unmodified lines | ||
| 374 | 357 | skb_queue_tail(&npinfo->txq, skb); |
| 375 | 358 | schedule_delayed_work(&npinfo->tx_work,0); |
| 376 | 359 | } |
| 360 | + rcu_read_unlock_bh(); | |
| 377 | 361 | } |
| 378 | 362 | EXPORT_SYMBOL(netpoll_send_skb_on_dev); |
| 379 | 363 | |
| @@ -1898,10 +1898,8 @@ static int rtnl_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb) · 1897 unmodified lines | ||
| 1898 | 1898 | if (tb[IFLA_IF_NETNSID]) { |
| 1899 | 1899 | netnsid = nla_get_s32(tb[IFLA_IF_NETNSID]); |
| 1900 | 1900 | tgt_net = get_target_net(skb->sk, netnsid); |
| 1901 | − if (IS_ERR(tgt_net)) { | |
| 1902 | − tgt_net = net; | |
| 1903 | − netnsid = -1; | |
| 1904 | − } | |
| 1901 | + if (IS_ERR(tgt_net)) | |
| 1902 | + return PTR_ERR(tgt_net); | |
| 1905 | 1903 | } |
| 1906 | 1904 | |
| 1907 | 1905 | if (tb[IFLA_EXT_MASK]) |
| @@ -2837,6 +2835,12 @@ struct net_device *rtnl_create_link(struct net *net, · 929 unmodified lines | ||
| 2837 | 2835 | else if (ops->get_num_rx_queues) |
| 2838 | 2836 | num_rx_queues = ops->get_num_rx_queues(); |
| 2839 | 2837 | |
| 2838 | + if (num_tx_queues < 1 || num_tx_queues > 4096) | |
| 2839 | + return ERR_PTR(-EINVAL); | |
| 2840 | + | |
| 2841 | + if (num_rx_queues < 1 || num_rx_queues > 4096) | |
| 2842 | + return ERR_PTR(-EINVAL); | |
| 2843 | + | |
| 2840 | 2844 | dev = alloc_netdev_mqs(ops->priv_size, ifname, name_assign_type, |
| 2841 | 2845 | ops->setup, num_tx_queues, num_rx_queues); |
| 2842 | 2846 | if (!dev) |
| @@ -3744,16 +3748,27 @@ static int rtnl_fdb_dump(struct sk_buff *skb, struct netlink_callback *cb) · 901 unmodified lines | ||
| 3744 | 3748 | int err = 0; |
| 3745 | 3749 | int fidx = 0; |
| 3746 | 3750 | |
| 3747 | − err = nlmsg_parse(cb->nlh, sizeof(struct ifinfomsg), tb, | |
| 3748 | − IFLA_MAX, ifla_policy, NULL); | |
| 3749 | − if (err < 0) { | |
| 3750 | − return -EINVAL; | |
| 3751 | − } else if (err == 0) { | |
| 3752 | − if (tb[IFLA_MASTER]) | |
| 3753 | − br_idx = nla_get_u32(tb[IFLA_MASTER]); | |
| 3754 | − } | |
| 3751 | + /* A hack to preserve kernel<->userspace interface. | |
| 3752 | + * Before Linux v4.12 this code accepted ndmsg since iproute2 v3.3.0. | |
| 3753 | + * However, ndmsg is shorter than ifinfomsg thus nlmsg_parse() bails. | |
| 3754 | + * So, check for ndmsg with an optional u32 attribute (not used here). | |
| 3755 | + * Fortunately these sizes don't conflict with the size of ifinfomsg | |
| 3756 | + * with an optional attribute. | |
| 3757 | + */ | |
| 3758 | + if (nlmsg_len(cb->nlh) != sizeof(struct ndmsg) && | |
| 3759 | + (nlmsg_len(cb->nlh) != sizeof(struct ndmsg) + | |
| 3760 | + nla_attr_size(sizeof(u32)))) { | |
| 3761 | + err = nlmsg_parse(cb->nlh, sizeof(struct ifinfomsg), tb, | |
| 3762 | + IFLA_MAX, ifla_policy, NULL); | |
| 3763 | + if (err < 0) { | |
| 3764 | + return -EINVAL; | |
| 3765 | + } else if (err == 0) { | |
| 3766 | + if (tb[IFLA_MASTER]) | |
| 3767 | + br_idx = nla_get_u32(tb[IFLA_MASTER]); | |
| 3768 | + } | |
| 3755 | 3769 | |
| 3756 | − brport_idx = ifm->ifi_index; | |
| 3770 | + brport_idx = ifm->ifi_index; | |
| 3771 | + } | |
| 3757 | 3772 | |
| 3758 | 3773 | if (br_idx) { |
| 3759 | 3774 | br_dev = __dev_get_by_index(net, br_idx); |
| @@ -606,11 +606,13 @@ int dccp_rcv_state_process(struct sock *sk, struct sk_buff *skb, · 605 unmodified lines | ||
| 606 | 606 | if (sk->sk_state == DCCP_LISTEN) { |
| 607 | 607 | if (dh->dccph_type == DCCP_PKT_REQUEST) { |
| 608 | 608 | /* It is possible that we process SYN packets from backlog, |
| 609 | − * so we need to make sure to disable BH right there. | |
| 609 | + * so we need to make sure to disable BH and RCU right there. | |
| 610 | 610 | */ |
| 611 | + rcu_read_lock(); | |
| 611 | 612 | local_bh_disable(); |
| 612 | 613 | acceptable = inet_csk(sk)->icsk_af_ops->conn_request(sk, skb) >= 0; |
| 613 | 614 | local_bh_enable(); |
| 615 | + rcu_read_unlock(); | |
| 614 | 616 | if (!acceptable) |
| 615 | 617 | return 1; |
| 616 | 618 | consume_skb(skb); |
| @@ -493,9 +493,11 @@ static int dccp_v4_send_response(const struct sock *sk, struct request_sock *req · 492 unmodified lines | ||
| 493 | 493 | |
| 494 | 494 | dh->dccph_checksum = dccp_v4_csum_finish(skb, ireq->ir_loc_addr, |
| 495 | 495 | ireq->ir_rmt_addr); |
| 496 | + rcu_read_lock(); | |
| 496 | 497 | err = ip_build_and_send_pkt(skb, sk, ireq->ir_loc_addr, |
| 497 | 498 | ireq->ir_rmt_addr, |
| 498 | − ireq_opt_deref(ireq)); | |
| 499 | + rcu_dereference(ireq->ireq_opt)); | |
| 500 | + rcu_read_unlock(); | |
| 499 | 501 | err = net_xmit_eval(err); |
| 500 | 502 | } |
| 501 | 503 | |
| @@ -544,7 +544,8 @@ struct dst_entry *inet_csk_route_req(const struct sock *sk, · 543 unmodified lines | ||
| 544 | 544 | struct ip_options_rcu *opt; |
| 545 | 545 | struct rtable *rt; |
| 546 | 546 | |
| 547 | − opt = ireq_opt_deref(ireq); | |
| 547 | + rcu_read_lock(); | |
| 548 | + opt = rcu_dereference(ireq->ireq_opt); | |
| 548 | 549 | |
| 549 | 550 | flowi4_init_output(fl4, ireq->ir_iif, ireq->ir_mark, |
| 550 | 551 | RT_CONN_FLAGS(sk), RT_SCOPE_UNIVERSE, |
| @@ -558,11 +559,13 @@ struct dst_entry *inet_csk_route_req(const struct sock *sk, · 7 unmodified lines | ||
| 558 | 559 | goto no_route; |
| 559 | 560 | if (opt && opt->opt.is_strictroute && rt->rt_uses_gateway) |
| 560 | 561 | goto route_err; |
| 562 | + rcu_read_unlock(); | |
| 561 | 563 | return &rt->dst; |
| 562 | 564 | |
| 563 | 565 | route_err: |
| 564 | 566 | ip_rt_put(rt); |
| 565 | 567 | no_route: |
| 568 | + rcu_read_unlock(); | |
| 566 | 569 | __IP_INC_STATS(net, IPSTATS_MIB_OUTNOROUTES); |
| 567 | 570 | return NULL; |
| 568 | 571 | } |
| @@ -149,7 +149,6 @@ static void ip_cmsg_recv_security(struct msghdr *msg, struct sk_buff *skb) · 148 unmodified lines | ||
| 149 | 149 | static void ip_cmsg_recv_dstaddr(struct msghdr *msg, struct sk_buff *skb) |
| 150 | 150 | { |
| 151 | 151 | struct sockaddr_in sin; |
| 152 | − const struct iphdr *iph = ip_hdr(skb); | |
| 153 | 152 | __be16 *ports; |
| 154 | 153 | int end; |
| 155 | 154 | |
| @@ -164,7 +163,7 @@ static void ip_cmsg_recv_dstaddr(struct msghdr *msg, struct sk_buff *skb) · 8 unmodified lines | ||
| 164 | 163 | ports = (__be16 *)skb_transport_header(skb); |
| 165 | 164 | |
| 166 | 165 | sin.sin_family = AF_INET; |
| 167 | − sin.sin_addr.s_addr = iph->daddr; | |
| 166 | + sin.sin_addr.s_addr = ip_hdr(skb)->daddr; | |
| 168 | 167 | sin.sin_port = ports[1]; |
| 169 | 168 | memset(sin.sin_zero, 0, sizeof(sin.sin_zero)); |
| 170 | 169 | |
| @@ -48,6 +48,7 @@ static int tcp_syn_retries_max = MAX_TCP_SYNCNT; · 47 unmodified lines | ||
| 48 | 48 | static int ip_ping_group_range_min[] = { 0, 0 }; |
| 49 | 49 | static int ip_ping_group_range_max[] = { GID_T_MAX, GID_T_MAX }; |
| 50 | 50 | static int comp_sack_nr_max = 255; |
| 51 | +static u32 u32_max_div_HZ = UINT_MAX / HZ; | |
| 51 | 52 | |
| 52 | 53 | /* obsolete */ |
| 53 | 54 | static int sysctl_tcp_low_latency __read_mostly; |
| @@ -745,9 +746,10 @@ static struct ctl_table ipv4_net_table[] = { · 691 unmodified lines | ||
| 745 | 746 | { |
| 746 | 747 | .procname = "tcp_probe_interval", |
| 747 | 748 | .data = &init_net.ipv4.sysctl_tcp_probe_interval, |
| 748 | − .maxlen = sizeof(int), | |
| 749 | + .maxlen = sizeof(u32), | |
| 749 | 750 | .mode = 0644, |
| 750 | − .proc_handler = proc_dointvec, | |
| 751 | + .proc_handler = proc_douintvec_minmax, | |
| 752 | + .extra2 = &u32_max_div_HZ, | |
| 751 | 753 | }, |
| 752 | 754 | { |
| 753 | 755 | .procname = "igmp_link_local_mcast_reports", |
| @@ -6009,11 +6009,13 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb) · 6008 unmodified lines | ||
| 6009 | 6009 | if (th->fin) |
| 6010 | 6010 | goto discard; |
| 6011 | 6011 | /* It is possible that we process SYN packets from backlog, |
| 6012 | − * so we need to make sure to disable BH right there. | |
| 6012 | + * so we need to make sure to disable BH and RCU right there. | |
| 6013 | 6013 | */ |
| 6014 | + rcu_read_lock(); | |
| 6014 | 6015 | local_bh_disable(); |
| 6015 | 6016 | acceptable = icsk->icsk_af_ops->conn_request(sk, skb) >= 0; |
| 6016 | 6017 | local_bh_enable(); |
| 6018 | + rcu_read_unlock(); | |
| 6017 | 6019 | |
| 6018 | 6020 | if (!acceptable) |
| 6019 | 6021 | return 1; |
| @@ -943,9 +943,11 @@ static int tcp_v4_send_synack(const struct sock *sk, struct dst_entry *dst, · 942 unmodified lines | ||
| 943 | 943 | if (skb) { |
| 944 | 944 | __tcp_v4_send_check(skb, ireq->ir_loc_addr, ireq->ir_rmt_addr); |
| 945 | 945 | |
| 946 | + rcu_read_lock(); | |
| 946 | 947 | err = ip_build_and_send_pkt(skb, sk, ireq->ir_loc_addr, |
| 947 | 948 | ireq->ir_rmt_addr, |
| 948 | − ireq_opt_deref(ireq)); | |
| 949 | + rcu_dereference(ireq->ireq_opt)); | |
| 950 | + rcu_read_unlock(); | |
| 949 | 951 | err = net_xmit_eval(err); |
| 950 | 952 | } |
| 951 | 953 | |
| @@ -67,6 +67,7 @@ int xfrm4_transport_finish(struct sk_buff *skb, int async) · 66 unmodified lines | ||
| 67 | 67 | |
| 68 | 68 | if (xo && (xo->flags & XFRM_GRO)) { |
| 69 | 69 | skb_mac_header_rebuild(skb); |
| 70 | + skb_reset_transport_header(skb); | |
| 70 | 71 | return 0; |
| 71 | 72 | } |
| 72 | 73 | |
| @@ -46,7 +46,6 @@ static int xfrm4_transport_output(struct xfrm_state *x, struct sk_buff *skb) · 45 unmodified lines | ||
| 46 | 46 | static int xfrm4_transport_input(struct xfrm_state *x, struct sk_buff *skb) |
| 47 | 47 | { |
| 48 | 48 | int ihl = skb->data - skb_transport_header(skb); |
| 49 | − struct xfrm_offload *xo = xfrm_offload(skb); | |
| 50 | 49 | |
| 51 | 50 | if (skb->transport_header != skb->network_header) { |
| 52 | 51 | memmove(skb_transport_header(skb), |
| @@ -54,8 +53,7 @@ static int xfrm4_transport_input(struct xfrm_state *x, struct sk_buff *skb) · 1 unmodified line | ||
| 54 | 53 | skb->network_header = skb->transport_header; |
| 55 | 54 | } |
| 56 | 55 | ip_hdr(skb)->tot_len = htons(skb->len + ihl); |
| 57 | − if (!xo || !(xo->flags & XFRM_GRO)) | |
| 58 | − skb_reset_transport_header(skb); | |
| 56 | + skb_reset_transport_header(skb); | |
| 59 | 57 | return 0; |
| 60 | 58 | } |
| 61 | 59 | |
| @@ -651,8 +651,6 @@ static int rawv6_send_hdrinc(struct sock *sk, struct msghdr *msg, int length, · 650 unmodified lines | ||
| 651 | 651 | skb->priority = sk->sk_priority; |
| 652 | 652 | skb->mark = sk->sk_mark; |
| 653 | 653 | skb->tstamp = sockc->transmit_time; |
| 654 | − skb_dst_set(skb, &rt->dst); | |
| 655 | − *dstp = NULL; | |
| 656 | 654 | |
| 657 | 655 | skb_put(skb, length); |
| 658 | 656 | skb_reset_network_header(skb); |
| @@ -665,8 +663,14 @@ static int rawv6_send_hdrinc(struct sock *sk, struct msghdr *msg, int length, · 6 unmodified lines | ||
| 665 | 663 | |
| 666 | 664 | skb->transport_header = skb->network_header; |
| 667 | 665 | err = memcpy_from_msg(iph, msg, length); |
| 668 | − if (err) | |
| 669 | − goto error_fault; | |
| 666 | + if (err) { | |
| 667 | + err = -EFAULT; | |
| 668 | + kfree_skb(skb); | |
| 669 | + goto error; | |
| 670 | + } | |
| 671 | + | |
| 672 | + skb_dst_set(skb, &rt->dst); | |
| 673 | + *dstp = NULL; | |
| 670 | 674 | |
| 671 | 675 | /* if egress device is enslaved to an L3 master device pass the |
| 672 | 676 | * skb to its handler for processing |
| @@ -675,21 +679,28 @@ static int rawv6_send_hdrinc(struct sock *sk, struct msghdr *msg, int length, · 2 unmodified lines | ||
| 675 | 679 | if (unlikely(!skb)) |
| 676 | 680 | return 0; |
| 677 | 681 | |
| 682 | + /* Acquire rcu_read_lock() in case we need to use rt->rt6i_idev | |
| 683 | + * in the error path. Since skb has been freed, the dst could | |
| 684 | + * have been queued for deletion. | |
| 685 | + */ | |
| 686 | + rcu_read_lock(); | |
| 678 | 687 | IP6_UPD_PO_STATS(net, rt->rt6i_idev, IPSTATS_MIB_OUT, skb->len); |
| 679 | 688 | err = NF_HOOK(NFPROTO_IPV6, NF_INET_LOCAL_OUT, net, sk, skb, |
| 680 | 689 | NULL, rt->dst.dev, dst_output); |
| 681 | 690 | if (err > 0) |
| 682 | 691 | err = net_xmit_errno(err); |
| 683 | − if (err) | |
| 684 | − goto error; | |
| 692 | + if (err) { | |
| 693 | + IP6_INC_STATS(net, rt->rt6i_idev, IPSTATS_MIB_OUTDISCARDS); | |
| 694 | + rcu_read_unlock(); | |
| 695 | + goto error_check; | |
| 696 | + } | |
| 697 | + rcu_read_unlock(); | |
| 685 | 698 | out: |
| 686 | 699 | return 0; |
| 687 | 700 | |
| 688 | −error_fault: | |
| 689 | − err = -EFAULT; | |
| 690 | − kfree_skb(skb); | |
| 691 | 701 | error: |
| 692 | 702 | IP6_INC_STATS(net, rt->rt6i_idev, IPSTATS_MIB_OUTDISCARDS); |
| 703 | +error_check: | |
| 693 | 704 | if (err == -ENOBUFS && !np->recverr) |
| 694 | 705 | err = 0; |
| 695 | 706 | return err; |
| @@ -4321,11 +4321,6 @@ static int ip6_route_info_append(struct net *net, · 4320 unmodified lines | ||
| 4321 | 4321 | if (!nh) |
| 4322 | 4322 | return -ENOMEM; |
| 4323 | 4323 | nh->fib6_info = rt; |
| 4324 | − err = ip6_convert_metrics(net, rt, r_cfg); | |
| 4325 | − if (err) { | |
| 4326 | − kfree(nh); | |
| 4327 | − return err; | |
| 4328 | − } | |
| 4329 | 4324 | memcpy(&nh->r_cfg, r_cfg, sizeof(*r_cfg)); |
| 4330 | 4325 | list_add_tail(&nh->next, rt6_nh_list); |
| 4331 | 4326 | |
| @@ -59,6 +59,7 @@ int xfrm6_transport_finish(struct sk_buff *skb, int async) · 58 unmodified lines | ||
| 59 | 59 | |
| 60 | 60 | if (xo && (xo->flags & XFRM_GRO)) { |
| 61 | 61 | skb_mac_header_rebuild(skb); |
| 62 | + skb_reset_transport_header(skb); | |
| 62 | 63 | return -1; |
| 63 | 64 | } |
| 64 | 65 | |
| @@ -51,7 +51,6 @@ static int xfrm6_transport_output(struct xfrm_state *x, struct sk_buff *skb) · 50 unmodified lines | ||
| 51 | 51 | static int xfrm6_transport_input(struct xfrm_state *x, struct sk_buff *skb) |
| 52 | 52 | { |
| 53 | 53 | int ihl = skb->data - skb_transport_header(skb); |
| 54 | − struct xfrm_offload *xo = xfrm_offload(skb); | |
| 55 | 54 | |
| 56 | 55 | if (skb->transport_header != skb->network_header) { |
| 57 | 56 | memmove(skb_transport_header(skb), |
| @@ -60,8 +59,7 @@ static int xfrm6_transport_input(struct xfrm_state *x, struct sk_buff *skb) · 2 unmodified lines | ||
| 60 | 59 | } |
| 61 | 60 | ipv6_hdr(skb)->payload_len = htons(skb->len + ihl - |
| 62 | 61 | sizeof(struct ipv6hdr)); |
| 63 | − if (!xo || !(xo->flags & XFRM_GRO)) | |
| 64 | − skb_reset_transport_header(skb); | |
| 62 | + skb_reset_transport_header(skb); | |
| 65 | 63 | return 0; |
| 66 | 64 | } |
| 67 | 65 | |
| @@ -170,9 +170,11 @@ static int __xfrm6_output(struct net *net, struct sock *sk, struct sk_buff *skb) · 169 unmodified lines | ||
| 170 | 170 | |
| 171 | 171 | if (toobig && xfrm6_local_dontfrag(skb)) { |
| 172 | 172 | xfrm6_local_rxpmtu(skb, mtu); |
| 173 | + kfree_skb(skb); | |
| 173 | 174 | return -EMSGSIZE; |
| 174 | 175 | } else if (!skb->ignore_df && toobig && skb->sk) { |
| 175 | 176 | xfrm_local_error(skb, mtu); |
| 177 | + kfree_skb(skb); | |
| 176 | 178 | return -EMSGSIZE; |
| 177 | 179 | } |
| 178 | 180 | |
| @@ -427,7 +427,7 @@ static int ieee80211_add_key(struct wiphy *wiphy, struct net_device *dev, · 426 unmodified lines | ||
| 427 | 427 | case NL80211_IFTYPE_AP: |
| 428 | 428 | case NL80211_IFTYPE_AP_VLAN: |
| 429 | 429 | /* Keys without a station are used for TX only */ |
| 430 | − if (key->sta && test_sta_flag(key->sta, WLAN_STA_MFP)) | |
| 430 | + if (sta && test_sta_flag(sta, WLAN_STA_MFP)) | |
| 431 | 431 | key->conf.flags |= IEEE80211_KEY_FLAG_RX_MGMT; |
| 432 | 432 | break; |
| 433 | 433 | case NL80211_IFTYPE_ADHOC: |
| @@ -1756,7 +1756,8 @@ int ieee80211_if_add(struct ieee80211_local *local, const char *name, · 1755 unmodified lines | ||
| 1756 | 1756 | |
| 1757 | 1757 | if (local->ops->wake_tx_queue && |
| 1758 | 1758 | type != NL80211_IFTYPE_AP_VLAN && |
| 1759 | − type != NL80211_IFTYPE_MONITOR) | |
| 1759 | + (type != NL80211_IFTYPE_MONITOR || | |
| 1760 | + (params->flags & MONITOR_FLAG_ACTIVE))) | |
| 1760 | 1761 | txq_size += sizeof(struct txq_info) + |
| 1761 | 1762 | local->hw.txq_data_size; |
| 1762 | 1763 | |
| @@ -217,7 +217,8 @@ void mesh_rmc_free(struct ieee80211_sub_if_data *sdata); · 216 unmodified lines | ||
| 217 | 217 | int mesh_rmc_init(struct ieee80211_sub_if_data *sdata); |
| 218 | 218 | void ieee80211s_init(void); |
| 219 | 219 | void ieee80211s_update_metric(struct ieee80211_local *local, |
| 220 | − struct sta_info *sta, struct sk_buff *skb); | |
| 220 | + struct sta_info *sta, | |
| 221 | + struct ieee80211_tx_status *st); | |
| 221 | 222 | void ieee80211_mesh_init_sdata(struct ieee80211_sub_if_data *sdata); |
| 222 | 223 | void ieee80211_mesh_teardown_sdata(struct ieee80211_sub_if_data *sdata); |
| 223 | 224 | int ieee80211_start_mesh(struct ieee80211_sub_if_data *sdata); |
| @@ -295,15 +295,12 @@ int mesh_path_error_tx(struct ieee80211_sub_if_data *sdata, · 294 unmodified lines | ||
| 295 | 295 | } |
| 296 | 296 | |
| 297 | 297 | void ieee80211s_update_metric(struct ieee80211_local *local, |
| 298 | − struct sta_info *sta, struct sk_buff *skb) | |
| 298 | + struct sta_info *sta, | |
| 299 | + struct ieee80211_tx_status *st) | |
| 299 | 300 | { |
| 300 | − struct ieee80211_tx_info *txinfo = IEEE80211_SKB_CB(skb); | |
| 301 | − struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; | |
| 301 | + struct ieee80211_tx_info *txinfo = st->info; | |
| 302 | 302 | int failed; |
| 303 | 303 | |
| 304 | − if (!ieee80211_is_data(hdr->frame_control)) | |
| 305 | − return; | |
| 306 | − | |
| 307 | 304 | failed = !(txinfo->flags & IEEE80211_TX_STAT_ACK); |
| 308 | 305 | |
| 309 | 306 | /* moving average, scaled to 100. |
| @@ -479,11 +479,6 @@ static void ieee80211_report_ack_skb(struct ieee80211_local *local, · 478 unmodified lines | ||
| 479 | 479 | if (!skb) |
| 480 | 480 | return; |
| 481 | 481 | |
| 482 | − if (dropped) { | |
| 483 | − dev_kfree_skb_any(skb); | |
| 484 | − return; | |
| 485 | − } | |
| 486 | − | |
| 487 | 482 | if (info->flags & IEEE80211_TX_INTFL_NL80211_FRAME_TX) { |
| 488 | 483 | u64 cookie = IEEE80211_SKB_CB(skb)->ack.cookie; |
| 489 | 484 | struct ieee80211_sub_if_data *sdata; |
| @@ -506,6 +501,8 @@ static void ieee80211_report_ack_skb(struct ieee80211_local *local, · 16 unmodified lines | ||
| 506 | 501 | } |
| 507 | 502 | rcu_read_unlock(); |
| 508 | 503 | |
| 504 | + dev_kfree_skb_any(skb); | |
| 505 | + } else if (dropped) { | |
| 509 | 506 | dev_kfree_skb_any(skb); |
| 510 | 507 | } else { |
| 511 | 508 | /* consumes skb */ |
| @@ -811,7 +808,7 @@ static void __ieee80211_tx_status(struct ieee80211_hw *hw, · 299 unmodified lines | ||
| 811 | 808 | |
| 812 | 809 | rate_control_tx_status(local, sband, status); |
| 813 | 810 | if (ieee80211_vif_is_mesh(&sta->sdata->vif)) |
| 814 | − ieee80211s_update_metric(local, sta, skb); | |
| 811 | + ieee80211s_update_metric(local, sta, status); | |
| 815 | 812 | |
| 816 | 813 | if (!(info->flags & IEEE80211_TX_CTL_INJECTED) && acked) |
| 817 | 814 | ieee80211_frame_acked(sta, skb); |
| @@ -972,6 +969,8 @@ void ieee80211_tx_status_ext(struct ieee80211_hw *hw, · 154 unmodified lines | ||
| 972 | 969 | } |
| 973 | 970 | |
| 974 | 971 | rate_control_tx_status(local, sband, status); |
| 972 | + if (ieee80211_vif_is_mesh(&sta->sdata->vif)) | |
| 973 | + ieee80211s_update_metric(local, sta, status); | |
| 975 | 974 | } |
| 976 | 975 | |
| 977 | 976 | if (acked || noack_success) { |
| @@ -16,6 +16,7 @@ · 15 unmodified lines | ||
| 16 | 16 | #include "ieee80211_i.h" |
| 17 | 17 | #include "driver-ops.h" |
| 18 | 18 | #include "rate.h" |
| 19 | +#include "wme.h" | |
| 19 | 20 | |
| 20 | 21 | /* give usermode some time for retries in setting up the TDLS session */ |
| 21 | 22 | #define TDLS_PEER_SETUP_TIMEOUT (15 * HZ) |
| @@ -1010,14 +1011,13 @@ ieee80211_tdls_prep_mgmt_packet(struct wiphy *wiphy, struct net_device *dev, · 988 unmodified lines | ||
| 1010 | 1011 | switch (action_code) { |
| 1011 | 1012 | case WLAN_TDLS_SETUP_REQUEST: |
| 1012 | 1013 | case WLAN_TDLS_SETUP_RESPONSE: |
| 1013 | − skb_set_queue_mapping(skb, IEEE80211_AC_BK); | |
| 1014 | − skb->priority = 2; | |
| 1014 | + skb->priority = 256 + 2; | |
| 1015 | 1015 | break; |
| 1016 | 1016 | default: |
| 1017 | − skb_set_queue_mapping(skb, IEEE80211_AC_VI); | |
| 1018 | − skb->priority = 5; | |
| 1017 | + skb->priority = 256 + 5; | |
| 1019 | 1018 | break; |
| 1020 | 1019 | } |
| 1020 | + skb_set_queue_mapping(skb, ieee80211_select_queue(sdata, skb)); | |
| 1021 | 1021 | |
| 1022 | 1022 | /* |
| 1023 | 1023 | * Set the WLAN_TDLS_TEARDOWN flag to indicate a teardown in progress. |
| @@ -214,6 +214,7 @@ ieee80211_tx_h_dynamic_ps(struct ieee80211_tx_data *tx) · 213 unmodified lines | ||
| 214 | 214 | { |
| 215 | 215 | struct ieee80211_local *local = tx->local; |
| 216 | 216 | struct ieee80211_if_managed *ifmgd; |
| 217 | + struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); | |
| 217 | 218 | |
| 218 | 219 | /* driver doesn't support power save */ |
| 219 | 220 | if (!ieee80211_hw_check(&local->hw, SUPPORTS_PS)) |
| @@ -242,6 +243,9 @@ ieee80211_tx_h_dynamic_ps(struct ieee80211_tx_data *tx) · 22 unmodified lines | ||
| 242 | 243 | if (tx->sdata->vif.type != NL80211_IFTYPE_STATION) |
| 243 | 244 | return TX_CONTINUE; |
| 244 | 245 | |
| 246 | + if (unlikely(info->flags & IEEE80211_TX_INTFL_OFFCHAN_TX_OK)) | |
| 247 | + return TX_CONTINUE; | |
| 248 | + | |
| 245 | 249 | ifmgd = &tx->sdata->u.mgd; |
| 246 | 250 | |
| 247 | 251 | /* |
| @@ -1890,7 +1894,7 @@ static bool ieee80211_tx(struct ieee80211_sub_if_data *sdata, · 1642 unmodified lines | ||
| 1890 | 1894 | sdata->vif.hw_queue[skb_get_queue_mapping(skb)]; |
| 1891 | 1895 | |
| 1892 | 1896 | if (invoke_tx_handlers_early(&tx)) |
| 1893 | − return false; | |
| 1897 | + return true; | |
| 1894 | 1898 | |
| 1895 | 1899 | if (ieee80211_queue_skb(local, sdata, tx.sta, tx.skb)) |
| 1896 | 1900 | return true; |
| @@ -1213,8 +1213,8 @@ static const struct nla_policy tcp_nla_policy[CTA_PROTOINFO_TCP_MAX+1] = { · 1212 unmodified lines | ||
| 1213 | 1213 | #define TCP_NLATTR_SIZE ( \ |
| 1214 | 1214 | NLA_ALIGN(NLA_HDRLEN + 1) + \ |
| 1215 | 1215 | NLA_ALIGN(NLA_HDRLEN + 1) + \ |
| 1216 | − NLA_ALIGN(NLA_HDRLEN + sizeof(sizeof(struct nf_ct_tcp_flags))) + \ | |
| 1217 | − NLA_ALIGN(NLA_HDRLEN + sizeof(sizeof(struct nf_ct_tcp_flags)))) | |
| 1216 | + NLA_ALIGN(NLA_HDRLEN + sizeof(struct nf_ct_tcp_flags)) + \ | |
| 1217 | + NLA_ALIGN(NLA_HDRLEN + sizeof(struct nf_ct_tcp_flags))) | |
| 1218 | 1218 | |
| 1219 | 1219 | static int nlattr_to_tcp(struct nlattr *cda[], struct nf_conn *ct) |
| 1220 | 1220 | { |
| @@ -49,7 +49,7 @@ static int nft_osf_init(const struct nft_ctx *ctx, · 48 unmodified lines | ||
| 49 | 49 | |
| 50 | 50 | priv->dreg = nft_parse_register(tb[NFTA_OSF_DREG]); |
| 51 | 51 | err = nft_validate_register_store(ctx, priv->dreg, NULL, |
| 52 | − NFTA_DATA_VALUE, NFT_OSF_MAXGENRELEN); | |
| 52 | + NFT_DATA_VALUE, NFT_OSF_MAXGENRELEN); | |
| 53 | 53 | if (err < 0) |
| 54 | 54 | return err; |
| 55 | 55 | |
| @@ -355,12 +355,11 @@ cont: · 354 unmodified lines | ||
| 355 | 355 | |
| 356 | 356 | static void nft_rbtree_gc(struct work_struct *work) |
| 357 | 357 | { |
| 358 | + struct nft_rbtree_elem *rbe, *rbe_end = NULL, *rbe_prev = NULL; | |
| 358 | 359 | struct nft_set_gc_batch *gcb = NULL; |
| 359 | − struct rb_node *node, *prev = NULL; | |
| 360 | − struct nft_rbtree_elem *rbe; | |
| 361 | 360 | struct nft_rbtree *priv; |
| 361 | + struct rb_node *node; | |
| 362 | 362 | struct nft_set *set; |
| 363 | − int i; | |
| 364 | 363 | |
| 365 | 364 | priv = container_of(work, struct nft_rbtree, gc_work.work); |
| 366 | 365 | set = nft_set_container_of(priv); |
| @@ -371,7 +370,7 @@ static void nft_rbtree_gc(struct work_struct *work) · 4 unmodified lines | ||
| 371 | 370 | rbe = rb_entry(node, struct nft_rbtree_elem, node); |
| 372 | 371 | |
| 373 | 372 | if (nft_rbtree_interval_end(rbe)) { |
| 374 | − prev = node; | |
| 373 | + rbe_end = rbe; | |
| 375 | 374 | continue; |
| 376 | 375 | } |
| 377 | 376 | if (!nft_set_elem_expired(&rbe->ext)) |
| @@ -379,29 +378,30 @@ static void nft_rbtree_gc(struct work_struct *work) · 1 unmodified line | ||
| 379 | 378 | if (nft_set_elem_mark_busy(&rbe->ext)) |
| 380 | 379 | continue; |
| 381 | 380 | |
| 381 | + if (rbe_prev) { | |
| 382 | + rb_erase(&rbe_prev->node, &priv->root); | |
| 383 | + rbe_prev = NULL; | |
| 384 | + } | |
| 382 | 385 | gcb = nft_set_gc_batch_check(set, gcb, GFP_ATOMIC); |
| 383 | 386 | if (!gcb) |
| 384 | 387 | break; |
| 385 | 388 | |
| 386 | 389 | atomic_dec(&set->nelems); |
| 387 | 390 | nft_set_gc_batch_add(gcb, rbe); |
| 391 | + rbe_prev = rbe; | |
| 388 | 392 | |
| 389 | − if (prev) { | |
| 390 | − rbe = rb_entry(prev, struct nft_rbtree_elem, node); | |
| 393 | + if (rbe_end) { | |
| 391 | 394 | atomic_dec(&set->nelems); |
| 392 | − nft_set_gc_batch_add(gcb, rbe); | |
| 393 | − prev = NULL; | |
| 395 | + nft_set_gc_batch_add(gcb, rbe_end); | |
| 396 | + rb_erase(&rbe_end->node, &priv->root); | |
| 397 | + rbe_end = NULL; | |
| 394 | 398 | } |
| 395 | 399 | node = rb_next(node); |
| 396 | 400 | if (!node) |
| 397 | 401 | break; |
| 398 | 402 | } |
| 399 | − if (gcb) { | |
| 400 | − for (i = 0; i < gcb->head.cnt; i++) { | |
| 401 | − rbe = gcb->elems[i]; | |
| 402 | − rb_erase(&rbe->node, &priv->root); | |
| 403 | − } | |
| 404 | − } | |
| 403 | + if (rbe_prev) | |
| 404 | + rb_erase(&rbe_prev->node, &priv->root); | |
| 405 | 405 | write_seqcount_end(&priv->count); |
| 406 | 406 | write_unlock_bh(&priv->lock); |
| 407 | 407 | |
| @@ -56,7 +56,7 @@ socket_match(const struct sk_buff *skb, struct xt_action_param *par, · 55 unmodified lines | ||
| 56 | 56 | struct sk_buff *pskb = (struct sk_buff *)skb; |
| 57 | 57 | struct sock *sk = skb->sk; |
| 58 | 58 | |
| 59 | − if (!net_eq(xt_net(par), sock_net(sk))) | |
| 59 | + if (sk && !net_eq(xt_net(par), sock_net(sk))) | |
| 60 | 60 | sk = NULL; |
| 61 | 61 | |
| 62 | 62 | if (!sk) |
| @@ -117,7 +117,7 @@ socket_mt6_v1_v2_v3(const struct sk_buff *skb, struct xt_action_param *par) · 54 unmodified lines | ||
| 117 | 117 | struct sk_buff *pskb = (struct sk_buff *)skb; |
| 118 | 118 | struct sock *sk = skb->sk; |
| 119 | 119 | |
| 120 | − if (!net_eq(xt_net(par), sock_net(sk))) | |
| 120 | + if (sk && !net_eq(xt_net(par), sock_net(sk))) | |
| 121 | 121 | sk = NULL; |
| 122 | 122 | |
| 123 | 123 | if (!sk) |
| @@ -1312,6 +1312,10 @@ static int ovs_ct_add_helper(struct ovs_conntrack_info *info, const char *name, · 1311 unmodified lines | ||
| 1312 | 1312 | |
| 1313 | 1313 | rcu_assign_pointer(help->helper, helper); |
| 1314 | 1314 | info->helper = helper; |
| 1315 | + | |
| 1316 | + if (info->nat) | |
| 1317 | + request_module("ip_nat_%s", name); | |
| 1318 | + | |
| 1315 | 1319 | return 0; |
| 1316 | 1320 | } |
| 1317 | 1321 | |
| @@ -1624,10 +1628,6 @@ int ovs_ct_copy_action(struct net *net, const struct nlattr *attr, · 306 unmodified lines | ||
| 1624 | 1628 | OVS_NLERR(log, "Failed to allocate conntrack template"); |
| 1625 | 1629 | return -ENOMEM; |
| 1626 | 1630 | } |
| 1627 | − | |
| 1628 | − __set_bit(IPS_CONFIRMED_BIT, &ct_info.ct->status); | |
| 1629 | − nf_conntrack_get(&ct_info.ct->ct_general); | |
| 1630 | − | |
| 1631 | 1631 | if (helper) { |
| 1632 | 1632 | err = ovs_ct_add_helper(&ct_info, helper, key, log); |
| 1633 | 1633 | if (err) |
| @@ -1639,6 +1639,8 @@ int ovs_ct_copy_action(struct net *net, const struct nlattr *attr, · 5 unmodified lines | ||
| 1639 | 1639 | if (err) |
| 1640 | 1640 | goto err_free_ct; |
| 1641 | 1641 | |
| 1642 | + __set_bit(IPS_CONFIRMED_BIT, &ct_info.ct->status); | |
| 1643 | + nf_conntrack_get(&ct_info.ct->ct_general); | |
| 1642 | 1644 | return 0; |
| 1643 | 1645 | err_free_ct: |
| 1644 | 1646 | __ovs_ct_free_action(&ct_info); |
| @@ -2715,10 +2715,12 @@ tpacket_error: · 2714 unmodified lines | ||
| 2715 | 2715 | } |
| 2716 | 2716 | } |
| 2717 | 2717 | |
| 2718 | − if (po->has_vnet_hdr && virtio_net_hdr_to_skb(skb, vnet_hdr, | |
| 2719 | − vio_le())) { | |
| 2720 | − tp_len = -EINVAL; | |
| 2721 | − goto tpacket_error; | |
| 2718 | + if (po->has_vnet_hdr) { | |
| 2719 | + if (virtio_net_hdr_to_skb(skb, vnet_hdr, vio_le())) { | |
| 2720 | + tp_len = -EINVAL; | |
| 2721 | + goto tpacket_error; | |
| 2722 | + } | |
| 2723 | + virtio_net_hdr_set_proto(skb, vnet_hdr); | |
| 2722 | 2724 | } |
| 2723 | 2725 | |
| 2724 | 2726 | skb->destructor = tpacket_destruct_skb; |
| @@ -2915,6 +2917,7 @@ static int packet_snd(struct socket *sock, struct msghdr *msg, size_t len) · 190 unmodified lines | ||
| 2915 | 2917 | if (err) |
| 2916 | 2918 | goto out_free; |
| 2917 | 2919 | len += sizeof(vnet_hdr); |
| 2920 | + virtio_net_hdr_set_proto(skb, &vnet_hdr); | |
| 2918 | 2921 | } |
| 2919 | 2922 | |
| 2920 | 2923 | skb_probe_transport_header(skb, reserve); |
| @@ -40,17 +40,12 @@ struct rxrpc_crypt { · 39 unmodified lines | ||
| 40 | 40 | struct rxrpc_connection; |
| 41 | 41 | |
| 42 | 42 | /* |
| 43 | − * Mark applied to socket buffers. | |
| 43 | + * Mark applied to socket buffers in skb->mark. skb->priority is used | |
| 44 | + * to pass supplementary information. | |
| 44 | 45 | */ |
| 45 | 46 | enum rxrpc_skb_mark { |
| 46 | − RXRPC_SKB_MARK_DATA, /* data message */ | |
| 47 | − RXRPC_SKB_MARK_FINAL_ACK, /* final ACK received message */ | |
| 48 | − RXRPC_SKB_MARK_BUSY, /* server busy message */ | |
| 49 | − RXRPC_SKB_MARK_REMOTE_ABORT, /* remote abort message */ | |
| 50 | − RXRPC_SKB_MARK_LOCAL_ABORT, /* local abort message */ | |
| 51 | − RXRPC_SKB_MARK_NET_ERROR, /* network error message */ | |
| 52 | − RXRPC_SKB_MARK_LOCAL_ERROR, /* local error message */ | |
| 53 | − RXRPC_SKB_MARK_NEW_CALL, /* local error message */ | |
| 47 | + RXRPC_SKB_MARK_REJECT_BUSY, /* Reject with BUSY */ | |
| 48 | + RXRPC_SKB_MARK_REJECT_ABORT, /* Reject with ABORT (code in skb->priority) */ | |
| 54 | 49 | }; |
| 55 | 50 | |
| 56 | 51 | /* |
| @@ -293,7 +288,6 @@ struct rxrpc_peer { · 236 unmodified lines | ||
| 293 | 288 | struct hlist_node hash_link; |
| 294 | 289 | struct rxrpc_local *local; |
| 295 | 290 | struct hlist_head error_targets; /* targets for net error distribution */ |
| 296 | − struct work_struct error_distributor; | |
| 297 | 291 | struct rb_root service_conns; /* Service connections */ |
| 298 | 292 | struct list_head keepalive_link; /* Link in net->peer_keepalive[] */ |
| 299 | 293 | time64_t last_tx_at; /* Last time packet sent here */ |
| @@ -304,8 +298,6 @@ struct rxrpc_peer { · 4 unmodified lines | ||
| 304 | 298 | unsigned int maxdata; /* data size (MTU - hdrsize) */ |
| 305 | 299 | unsigned short hdrsize; /* header size (IP + UDP + RxRPC) */ |
| 306 | 300 | int debug_id; /* debug ID for printks */ |
| 307 | − int error_report; /* Net (+0) or local (+1000000) to distribute */ | |
| 308 | −#define RXRPC_LOCAL_ERROR_OFFSET 1000000 | |
| 309 | 301 | struct sockaddr_rxrpc srx; /* remote address */ |
| 310 | 302 | |
| 311 | 303 | /* calculated RTT cache */ |
| @@ -463,6 +455,16 @@ struct rxrpc_connection { · 151 unmodified lines | ||
| 463 | 455 | u8 out_clientflag; /* RXRPC_CLIENT_INITIATED if we are client */ |
| 464 | 456 | }; |
| 465 | 457 | |
| 458 | +static inline bool rxrpc_to_server(const struct rxrpc_skb_priv *sp) | |
| 459 | +{ | |
| 460 | + return sp->hdr.flags & RXRPC_CLIENT_INITIATED; | |
| 461 | +} | |
| 462 | + | |
| 463 | +static inline bool rxrpc_to_client(const struct rxrpc_skb_priv *sp) | |
| 464 | +{ | |
| 465 | + return !rxrpc_to_server(sp); | |
| 466 | +} | |
| 467 | + | |
| 466 | 468 | /* |
| 467 | 469 | * Flags in call->flags. |
| 468 | 470 | */ |
| @@ -717,6 +719,8 @@ extern struct workqueue_struct *rxrpc_workqueue; · 248 unmodified lines | ||
| 717 | 719 | int rxrpc_service_prealloc(struct rxrpc_sock *, gfp_t); |
| 718 | 720 | void rxrpc_discard_prealloc(struct rxrpc_sock *); |
| 719 | 721 | struct rxrpc_call *rxrpc_new_incoming_call(struct rxrpc_local *, |
| 722 | + struct rxrpc_sock *, | |
| 723 | + struct rxrpc_peer *, | |
| 720 | 724 | struct rxrpc_connection *, |
| 721 | 725 | struct sk_buff *); |
| 722 | 726 | void rxrpc_accept_incoming_calls(struct rxrpc_local *); |
| @@ -908,7 +912,8 @@ extern unsigned int rxrpc_closed_conn_expiry; · 185 unmodified lines | ||
| 908 | 912 | |
| 909 | 913 | struct rxrpc_connection *rxrpc_alloc_connection(gfp_t); |
| 910 | 914 | struct rxrpc_connection *rxrpc_find_connection_rcu(struct rxrpc_local *, |
| 911 | − struct sk_buff *); | |
| 915 | + struct sk_buff *, | |
| 916 | + struct rxrpc_peer **); | |
| 912 | 917 | void __rxrpc_disconnect_call(struct rxrpc_connection *, struct rxrpc_call *); |
| 913 | 918 | void rxrpc_disconnect_call(struct rxrpc_call *); |
| 914 | 919 | void rxrpc_kill_connection(struct rxrpc_connection *); |
| @@ -1031,7 +1036,6 @@ void rxrpc_send_keepalive(struct rxrpc_peer *); · 116 unmodified lines | ||
| 1031 | 1036 | * peer_event.c |
| 1032 | 1037 | */ |
| 1033 | 1038 | void rxrpc_error_report(struct sock *); |
| 1034 | −void rxrpc_peer_error_distributor(struct work_struct *); | |
| 1035 | 1039 | void rxrpc_peer_add_rtt(struct rxrpc_call *, enum rxrpc_rtt_rx_trace, |
| 1036 | 1040 | rxrpc_serial_t, rxrpc_serial_t, ktime_t, ktime_t); |
| 1037 | 1041 | void rxrpc_peer_keepalive_worker(struct work_struct *); |
| @@ -1044,13 +1048,11 @@ struct rxrpc_peer *rxrpc_lookup_peer_rcu(struct rxrpc_local *, · 6 unmodified lines | ||
| 1044 | 1048 | struct rxrpc_peer *rxrpc_lookup_peer(struct rxrpc_local *, |
| 1045 | 1049 | struct sockaddr_rxrpc *, gfp_t); |
| 1046 | 1050 | struct rxrpc_peer *rxrpc_alloc_peer(struct rxrpc_local *, gfp_t); |
| 1047 | −struct rxrpc_peer *rxrpc_lookup_incoming_peer(struct rxrpc_local *, | |
| 1048 | − struct rxrpc_peer *); | |
| 1051 | +void rxrpc_new_incoming_peer(struct rxrpc_local *, struct rxrpc_peer *); | |
| 1049 | 1052 | void rxrpc_destroy_all_peers(struct rxrpc_net *); |
| 1050 | 1053 | struct rxrpc_peer *rxrpc_get_peer(struct rxrpc_peer *); |
| 1051 | 1054 | struct rxrpc_peer *rxrpc_get_peer_maybe(struct rxrpc_peer *); |
| 1052 | 1055 | void rxrpc_put_peer(struct rxrpc_peer *); |
| 1053 | −void __rxrpc_queue_peer_error(struct rxrpc_peer *); | |
| 1054 | 1056 | |
| 1055 | 1057 | /* |
| 1056 | 1058 | * proc.c |
| @@ -249,11 +249,11 @@ void rxrpc_discard_prealloc(struct rxrpc_sock *rx) · 248 unmodified lines | ||
| 249 | 249 | */ |
| 250 | 250 | static struct rxrpc_call *rxrpc_alloc_incoming_call(struct rxrpc_sock *rx, |
| 251 | 251 | struct rxrpc_local *local, |
| 252 | + struct rxrpc_peer *peer, | |
| 252 | 253 | struct rxrpc_connection *conn, |
| 253 | 254 | struct sk_buff *skb) |
| 254 | 255 | { |
| 255 | 256 | struct rxrpc_backlog *b = rx->backlog; |
| 256 | − struct rxrpc_peer *peer, *xpeer; | |
| 257 | 257 | struct rxrpc_call *call; |
| 258 | 258 | unsigned short call_head, conn_head, peer_head; |
| 259 | 259 | unsigned short call_tail, conn_tail, peer_tail; |
| @@ -276,21 +276,18 @@ static struct rxrpc_call *rxrpc_alloc_incoming_call(struct rxrpc_sock *rx, · 16 unmodified lines | ||
| 276 | 276 | return NULL; |
| 277 | 277 | |
| 278 | 278 | if (!conn) { |
| 279 | − /* No connection. We're going to need a peer to start off | |
| 280 | − * with. If one doesn't yet exist, use a spare from the | |
| 281 | − * preallocation set. We dump the address into the spare in | |
| 282 | − * anticipation - and to save on stack space. | |
| 283 | − */ | |
| 284 | − xpeer = b->peer_backlog[peer_tail]; | |
| 285 | − if (rxrpc_extract_addr_from_skb(local, &xpeer->srx, skb) < 0) | |
| 286 | − return NULL; | |
| 287 | − | |
| 288 | − peer = rxrpc_lookup_incoming_peer(local, xpeer); | |
| 289 | − if (peer == xpeer) { | |
| 279 | + if (peer && !rxrpc_get_peer_maybe(peer)) | |
| 280 | + peer = NULL; | |
| 281 | + if (!peer) { | |
| 282 | + peer = b->peer_backlog[peer_tail]; | |
| 283 | + if (rxrpc_extract_addr_from_skb(local, &peer->srx, skb) < 0) | |
| 284 | + return NULL; | |
| 290 | 285 | b->peer_backlog[peer_tail] = NULL; |
| 291 | 286 | smp_store_release(&b->peer_backlog_tail, |
| 292 | 287 | (peer_tail + 1) & |
| 293 | 288 | (RXRPC_BACKLOG_MAX - 1)); |
| 289 | + | |
| 290 | + rxrpc_new_incoming_peer(local, peer); | |
| 294 | 291 | } |
| 295 | 292 | |
| 296 | 293 | /* Now allocate and set up the connection */ |
| @@ -335,45 +332,31 @@ static struct rxrpc_call *rxrpc_alloc_incoming_call(struct rxrpc_sock *rx, · 38 unmodified lines | ||
| 335 | 332 | * The call is returned with the user access mutex held. |
| 336 | 333 | */ |
| 337 | 334 | struct rxrpc_call *rxrpc_new_incoming_call(struct rxrpc_local *local, |
| 335 | + struct rxrpc_sock *rx, | |
| 336 | + struct rxrpc_peer *peer, | |
| 338 | 337 | struct rxrpc_connection *conn, |
| 339 | 338 | struct sk_buff *skb) |
| 340 | 339 | { |
| 341 | 340 | struct rxrpc_skb_priv *sp = rxrpc_skb(skb); |
| 342 | − struct rxrpc_sock *rx; | |
| 343 | 341 | struct rxrpc_call *call; |
| 344 | − u16 service_id = sp->hdr.serviceId; | |
| 345 | 342 | |
| 346 | 343 | _enter(""); |
| 347 | 344 | |
| 348 | − /* Get the socket providing the service */ | |
| 349 | − rx = rcu_dereference(local->service); | |
| 350 | − if (rx && (service_id == rx->srx.srx_service || | |
| 351 | − service_id == rx->second_service)) | |
| 352 | − goto found_service; | |
| 353 | − | |
| 354 | − trace_rxrpc_abort(0, "INV", sp->hdr.cid, sp->hdr.callNumber, sp->hdr.seq, | |
| 355 | − RX_INVALID_OPERATION, EOPNOTSUPP); | |
| 356 | − skb->mark = RXRPC_SKB_MARK_LOCAL_ABORT; | |
| 357 | − skb->priority = RX_INVALID_OPERATION; | |
| 358 | − _leave(" = NULL [service]"); | |
| 359 | − return NULL; | |
| 360 | − | |
| 361 | −found_service: | |
| 362 | 345 | spin_lock(&rx->incoming_lock); |
| 363 | 346 | if (rx->sk.sk_state == RXRPC_SERVER_LISTEN_DISABLED || |
| 364 | 347 | rx->sk.sk_state == RXRPC_CLOSE) { |
| 365 | 348 | trace_rxrpc_abort(0, "CLS", sp->hdr.cid, sp->hdr.callNumber, |
| 366 | 349 | sp->hdr.seq, RX_INVALID_OPERATION, ESHUTDOWN); |
| 367 | − skb->mark = RXRPC_SKB_MARK_LOCAL_ABORT; | |
| 350 | + skb->mark = RXRPC_SKB_MARK_REJECT_ABORT; | |
| 368 | 351 | skb->priority = RX_INVALID_OPERATION; |
| 369 | 352 | _leave(" = NULL [close]"); |
| 370 | 353 | call = NULL; |
| 371 | 354 | goto out; |
| 372 | 355 | } |
| 373 | 356 | |
| 374 | − call = rxrpc_alloc_incoming_call(rx, local, conn, skb); | |
| 357 | + call = rxrpc_alloc_incoming_call(rx, local, peer, conn, skb); | |
| 375 | 358 | if (!call) { |
| 376 | − skb->mark = RXRPC_SKB_MARK_BUSY; | |
| 359 | + skb->mark = RXRPC_SKB_MARK_REJECT_BUSY; | |
| 377 | 360 | _leave(" = NULL [busy]"); |
| 378 | 361 | call = NULL; |
| 379 | 362 | goto out; |
| @@ -400,7 +400,7 @@ void rxrpc_incoming_call(struct rxrpc_sock *rx, · 399 unmodified lines | ||
| 400 | 400 | rcu_assign_pointer(conn->channels[chan].call, call); |
| 401 | 401 | |
| 402 | 402 | spin_lock(&conn->params.peer->lock); |
| 403 | − hlist_add_head(&call->error_link, &conn->params.peer->error_targets); | |
| 403 | + hlist_add_head_rcu(&call->error_link, &conn->params.peer->error_targets); | |
| 404 | 404 | spin_unlock(&conn->params.peer->lock); |
| 405 | 405 | |
| 406 | 406 | _net("CALL incoming %d on CONN %d", call->debug_id, call->conn->debug_id); |
| @@ -710,8 +710,8 @@ int rxrpc_connect_call(struct rxrpc_call *call, · 709 unmodified lines | ||
| 710 | 710 | } |
| 711 | 711 | |
| 712 | 712 | spin_lock_bh(&call->conn->params.peer->lock); |
| 713 | − hlist_add_head(&call->error_link, | |
| 714 | − &call->conn->params.peer->error_targets); | |
| 713 | + hlist_add_head_rcu(&call->error_link, | |
| 714 | + &call->conn->params.peer->error_targets); | |
| 715 | 715 | spin_unlock_bh(&call->conn->params.peer->lock); |
| 716 | 716 | |
| 717 | 717 | out: |
| @@ -69,10 +69,14 @@ struct rxrpc_connection *rxrpc_alloc_connection(gfp_t gfp) · 68 unmodified lines | ||
| 69 | 69 | * If successful, a pointer to the connection is returned, but no ref is taken. |
| 70 | 70 | * NULL is returned if there is no match. |
| 71 | 71 | * |
| 72 | + * When searching for a service call, if we find a peer but no connection, we | |
| 73 | + * return that through *_peer in case we need to create a new service call. | |
| 74 | + * | |
| 72 | 75 | * The caller must be holding the RCU read lock. |
| 73 | 76 | */ |
| 74 | 77 | struct rxrpc_connection *rxrpc_find_connection_rcu(struct rxrpc_local *local, |
| 75 | − struct sk_buff *skb) | |
| 78 | + struct sk_buff *skb, | |
| 79 | + struct rxrpc_peer **_peer) | |
| 76 | 80 | { |
| 77 | 81 | struct rxrpc_connection *conn; |
| 78 | 82 | struct rxrpc_conn_proto k; |
| @@ -85,9 +89,6 @@ struct rxrpc_connection *rxrpc_find_connection_rcu(struct rxrpc_local *local, · 6 unmodified lines | ||
| 85 | 89 | if (rxrpc_extract_addr_from_skb(local, &srx, skb) < 0) |
| 86 | 90 | goto not_found; |
| 87 | 91 | |
| 88 | − k.epoch = sp->hdr.epoch; | |
| 89 | − k.cid = sp->hdr.cid & RXRPC_CIDMASK; | |
| 90 | − | |
| 91 | 92 | /* We may have to handle mixing IPv4 and IPv6 */ |
| 92 | 93 | if (srx.transport.family != local->srx.transport.family) { |
| 93 | 94 | pr_warn_ratelimited("AF_RXRPC: Protocol mismatch %u not %u\n", |
| @@ -99,7 +100,7 @@ struct rxrpc_connection *rxrpc_find_connection_rcu(struct rxrpc_local *local, · 5 unmodified lines | ||
| 99 | 100 | k.epoch = sp->hdr.epoch; |
| 100 | 101 | k.cid = sp->hdr.cid & RXRPC_CIDMASK; |
| 101 | 102 | |
| 102 | − if (sp->hdr.flags & RXRPC_CLIENT_INITIATED) { | |
| 103 | + if (rxrpc_to_server(sp)) { | |
| 103 | 104 | /* We need to look up service connections by the full protocol |
| 104 | 105 | * parameter set. We look up the peer first as an intermediate |
| 105 | 106 | * step and then the connection from the peer's tree. |
| @@ -107,6 +108,7 @@ struct rxrpc_connection *rxrpc_find_connection_rcu(struct rxrpc_local *local, · 1 unmodified line | ||
| 107 | 108 | peer = rxrpc_lookup_peer_rcu(local, &srx); |
| 108 | 109 | if (!peer) |
| 109 | 110 | goto not_found; |
| 111 | + *_peer = peer; | |
| 110 | 112 | conn = rxrpc_find_service_conn_rcu(peer, skb); |
| 111 | 113 | if (!conn || atomic_read(&conn->usage) == 0) |
| 112 | 114 | goto not_found; |
| @@ -214,7 +216,7 @@ void rxrpc_disconnect_call(struct rxrpc_call *call) · 101 unmodified lines | ||
| 214 | 216 | call->peer->cong_cwnd = call->cong_cwnd; |
| 215 | 217 | |
| 216 | 218 | spin_lock_bh(&conn->params.peer->lock); |
| 217 | − hlist_del_init(&call->error_link); | |
| 219 | + hlist_del_rcu(&call->error_link); | |
| 218 | 220 | spin_unlock_bh(&conn->params.peer->lock); |
| 219 | 221 | |
| 220 | 222 | if (rxrpc_is_client_call(call)) |
| @@ -622,13 +622,14 @@ static void rxrpc_input_requested_ack(struct rxrpc_call *call, · 621 unmodified lines | ||
| 622 | 622 | if (!skb) |
| 623 | 623 | continue; |
| 624 | 624 | |
| 625 | + sent_at = skb->tstamp; | |
| 626 | + smp_rmb(); /* Read timestamp before serial. */ | |
| 625 | 627 | sp = rxrpc_skb(skb); |
| 626 | 628 | if (sp->hdr.serial != orig_serial) |
| 627 | 629 | continue; |
| 628 | − smp_rmb(); | |
| 629 | − sent_at = skb->tstamp; | |
| 630 | 630 | goto found; |
| 631 | 631 | } |
| 632 | + | |
| 632 | 633 | return; |
| 633 | 634 | |
| 634 | 635 | found: |
| @@ -1124,12 +1125,14 @@ void rxrpc_data_ready(struct sock *udp_sk) · 489 unmodified lines | ||
| 1124 | 1125 | { |
| 1125 | 1126 | struct rxrpc_connection *conn; |
| 1126 | 1127 | struct rxrpc_channel *chan; |
| 1127 | − struct rxrpc_call *call; | |
| 1128 | + struct rxrpc_call *call = NULL; | |
| 1128 | 1129 | struct rxrpc_skb_priv *sp; |
| 1129 | 1130 | struct rxrpc_local *local = udp_sk->sk_user_data; |
| 1131 | + struct rxrpc_peer *peer = NULL; | |
| 1132 | + struct rxrpc_sock *rx = NULL; | |
| 1130 | 1133 | struct sk_buff *skb; |
| 1131 | 1134 | unsigned int channel; |
| 1132 | − int ret, skew; | |
| 1135 | + int ret, skew = 0; | |
| 1133 | 1136 | |
| 1134 | 1137 | _enter("%p", udp_sk); |
| 1135 | 1138 | |
| @@ -1143,6 +1146,9 @@ void rxrpc_data_ready(struct sock *udp_sk) · 7 unmodified lines | ||
| 1143 | 1146 | return; |
| 1144 | 1147 | } |
| 1145 | 1148 | |
| 1149 | + if (skb->tstamp == 0) | |
| 1150 | + skb->tstamp = ktime_get_real(); | |
| 1151 | + | |
| 1146 | 1152 | rxrpc_new_skb(skb, rxrpc_skb_rx_received); |
| 1147 | 1153 | |
| 1148 | 1154 | _net("recv skb %p", skb); |
| @@ -1177,46 +1183,75 @@ void rxrpc_data_ready(struct sock *udp_sk) · 28 unmodified lines | ||
| 1177 | 1183 | |
| 1178 | 1184 | trace_rxrpc_rx_packet(sp); |
| 1179 | 1185 | |
| 1180 | − _net("Rx RxRPC %s ep=%x call=%x:%x", | |
| 1181 | − sp->hdr.flags & RXRPC_CLIENT_INITIATED ? "ToServer" : "ToClient", | |
| 1182 | − sp->hdr.epoch, sp->hdr.cid, sp->hdr.callNumber); | |
| 1183 | − | |
| 1184 | − if (sp->hdr.type >= RXRPC_N_PACKET_TYPES || | |
| 1185 | − !((RXRPC_SUPPORTED_PACKET_TYPES >> sp->hdr.type) & 1)) { | |
| 1186 | − _proto("Rx Bad Packet Type %u", sp->hdr.type); | |
| 1187 | − goto bad_message; | |
| 1188 | − } | |
| 1189 | − | |
| 1190 | 1186 | switch (sp->hdr.type) { |
| 1191 | 1187 | case RXRPC_PACKET_TYPE_VERSION: |
| 1192 | − if (!(sp->hdr.flags & RXRPC_CLIENT_INITIATED)) | |
| 1188 | + if (rxrpc_to_client(sp)) | |
| 1193 | 1189 | goto discard; |
| 1194 | 1190 | rxrpc_post_packet_to_local(local, skb); |
| 1195 | 1191 | goto out; |
| 1196 | 1192 | |
| 1197 | 1193 | case RXRPC_PACKET_TYPE_BUSY: |
| 1198 | − if (sp->hdr.flags & RXRPC_CLIENT_INITIATED) | |
| 1194 | + if (rxrpc_to_server(sp)) | |
| 1199 | 1195 | goto discard; |
| 1200 | 1196 | /* Fall through */ |
| 1197 | + case RXRPC_PACKET_TYPE_ACK: | |
| 1198 | + case RXRPC_PACKET_TYPE_ACKALL: | |
| 1199 | + if (sp->hdr.callNumber == 0) | |
| 1200 | + goto bad_message; | |
| 1201 | + /* Fall through */ | |
| 1202 | + case RXRPC_PACKET_TYPE_ABORT: | |
| 1203 | + break; | |
| 1201 | 1204 | |
| 1202 | 1205 | case RXRPC_PACKET_TYPE_DATA: |
| 1203 | − if (sp->hdr.callNumber == 0) | |
| 1206 | + if (sp->hdr.callNumber == 0 || | |
| 1207 | + sp->hdr.seq == 0) | |
| 1204 | 1208 | goto bad_message; |
| 1205 | 1209 | if (sp->hdr.flags & RXRPC_JUMBO_PACKET && |
| 1206 | 1210 | !rxrpc_validate_jumbo(skb)) |
| 1207 | 1211 | goto bad_message; |
| 1208 | 1212 | break; |
| 1209 | 1213 | |
| 1214 | + case RXRPC_PACKET_TYPE_CHALLENGE: | |
| 1215 | + if (rxrpc_to_server(sp)) | |
| 1216 | + goto discard; | |
| 1217 | + break; | |
| 1218 | + case RXRPC_PACKET_TYPE_RESPONSE: | |
| 1219 | + if (rxrpc_to_client(sp)) | |
| 1220 | + goto discard; | |
| 1221 | + break; | |
| 1222 | + | |
| 1210 | 1223 | /* Packet types 9-11 should just be ignored. */ |
| 1211 | 1224 | case RXRPC_PACKET_TYPE_PARAMS: |
| 1212 | 1225 | case RXRPC_PACKET_TYPE_10: |
| 1213 | 1226 | case RXRPC_PACKET_TYPE_11: |
| 1214 | 1227 | goto discard; |
| 1228 | + | |
| 1229 | + default: | |
| 1230 | + _proto("Rx Bad Packet Type %u", sp->hdr.type); | |
| 1231 | + goto bad_message; | |
| 1215 | 1232 | } |
| 1216 | 1233 | |
| 1234 | + if (sp->hdr.serviceId == 0) | |
| 1235 | + goto bad_message; | |
| 1236 | + | |
| 1217 | 1237 | rcu_read_lock(); |
| 1218 | 1238 | |
| 1219 | − conn = rxrpc_find_connection_rcu(local, skb); | |
| 1239 | + if (rxrpc_to_server(sp)) { | |
| 1240 | + /* Weed out packets to services we're not offering. Packets | |
| 1241 | + * that would begin a call are explicitly rejected and the rest | |
| 1242 | + * are just discarded. | |
| 1243 | + */ | |
| 1244 | + rx = rcu_dereference(local->service); | |
| 1245 | + if (!rx || (sp->hdr.serviceId != rx->srx.srx_service && | |
| 1246 | + sp->hdr.serviceId != rx->second_service)) { | |
| 1247 | + if (sp->hdr.type == RXRPC_PACKET_TYPE_DATA && | |
| 1248 | + sp->hdr.seq == 1) | |
| 1249 | + goto unsupported_service; | |
| 1250 | + goto discard_unlock; | |
| 1251 | + } | |
| 1252 | + } | |
| 1253 | + | |
| 1254 | + conn = rxrpc_find_connection_rcu(local, skb, &peer); | |
| 1220 | 1255 | if (conn) { |
| 1221 | 1256 | if (sp->hdr.securityIndex != conn->security_ix) |
| 1222 | 1257 | goto wrong_security; |
| @@ -1280,7 +1315,7 @@ void rxrpc_data_ready(struct sock *udp_sk) · 57 unmodified lines | ||
| 1280 | 1315 | call = rcu_dereference(chan->call); |
| 1281 | 1316 | |
| 1282 | 1317 | if (sp->hdr.callNumber > chan->call_id) { |
| 1283 | − if (!(sp->hdr.flags & RXRPC_CLIENT_INITIATED)) { | |
| 1318 | + if (rxrpc_to_client(sp)) { | |
| 1284 | 1319 | rcu_read_unlock(); |
| 1285 | 1320 | goto reject_packet; |
| 1286 | 1321 | } |
| @@ -1297,19 +1332,15 @@ void rxrpc_data_ready(struct sock *udp_sk) · 10 unmodified lines | ||
| 1297 | 1332 | if (!test_bit(RXRPC_CALL_RX_HEARD, &call->flags)) |
| 1298 | 1333 | set_bit(RXRPC_CALL_RX_HEARD, &call->flags); |
| 1299 | 1334 | } |
| 1300 | − } else { | |
| 1301 | − skew = 0; | |
| 1302 | − call = NULL; | |
| 1303 | 1335 | } |
| 1304 | 1336 | |
| 1305 | 1337 | if (!call || atomic_read(&call->usage) == 0) { |
| 1306 | − if (!(sp->hdr.type & RXRPC_CLIENT_INITIATED) || | |
| 1307 | − sp->hdr.callNumber == 0 || | |
| 1338 | + if (rxrpc_to_client(sp) || | |
| 1308 | 1339 | sp->hdr.type != RXRPC_PACKET_TYPE_DATA) |
| 1309 | 1340 | goto bad_message_unlock; |
| 1310 | 1341 | if (sp->hdr.seq != 1) |
| 1311 | 1342 | goto discard_unlock; |
| 1312 | − call = rxrpc_new_incoming_call(local, conn, skb); | |
| 1343 | + call = rxrpc_new_incoming_call(local, rx, peer, conn, skb); | |
| 1313 | 1344 | if (!call) { |
| 1314 | 1345 | rcu_read_unlock(); |
| 1315 | 1346 | goto reject_packet; |
| @@ -1340,6 +1371,13 @@ wrong_security: · 24 unmodified lines | ||
| 1340 | 1371 | skb->priority = RXKADINCONSISTENCY; |
| 1341 | 1372 | goto post_abort; |
| 1342 | 1373 | |
| 1374 | +unsupported_service: | |
| 1375 | + rcu_read_unlock(); | |
| 1376 | + trace_rxrpc_abort(0, "INV", sp->hdr.cid, sp->hdr.callNumber, sp->hdr.seq, | |
| 1377 | + RX_INVALID_OPERATION, EOPNOTSUPP); | |
| 1378 | + skb->priority = RX_INVALID_OPERATION; | |
| 1379 | + goto post_abort; | |
| 1380 | + | |
| 1343 | 1381 | reupgrade: |
| 1344 | 1382 | rcu_read_unlock(); |
| 1345 | 1383 | trace_rxrpc_abort(0, "UPG", sp->hdr.cid, sp->hdr.callNumber, sp->hdr.seq, |
| @@ -1354,7 +1392,7 @@ bad_message: · 8 unmodified lines | ||
| 1354 | 1392 | protocol_error: |
| 1355 | 1393 | skb->priority = RX_PROTOCOL_ERROR; |
| 1356 | 1394 | post_abort: |
| 1357 | − skb->mark = RXRPC_SKB_MARK_LOCAL_ABORT; | |
| 1395 | + skb->mark = RXRPC_SKB_MARK_REJECT_ABORT; | |
| 1358 | 1396 | reject_packet: |
| 1359 | 1397 | trace_rxrpc_rx_done(skb->mark, skb->priority); |
| 1360 | 1398 | rxrpc_reject_packet(local, skb); |
| @@ -135,10 +135,10 @@ static int rxrpc_open_socket(struct rxrpc_local *local, struct net *net) · 134 unmodified lines | ||
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | switch (local->srx.transport.family) { |
| 138 | − case AF_INET: | |
| 139 | − /* we want to receive ICMP errors */ | |
| 138 | + case AF_INET6: | |
| 139 | + /* we want to receive ICMPv6 errors */ | |
| 140 | 140 | opt = 1; |
| 141 | − ret = kernel_setsockopt(local->socket, SOL_IP, IP_RECVERR, | |
| 141 | + ret = kernel_setsockopt(local->socket, SOL_IPV6, IPV6_RECVERR, | |
| 142 | 142 | (char *) &opt, sizeof(opt)); |
| 143 | 143 | if (ret < 0) { |
| 144 | 144 | _debug("setsockopt failed"); |
| @@ -146,19 +146,22 @@ static int rxrpc_open_socket(struct rxrpc_local *local, struct net *net) · 1 unmodified line | ||
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | /* we want to set the don't fragment bit */ |
| 149 | − opt = IP_PMTUDISC_DO; | |
| 150 | − ret = kernel_setsockopt(local->socket, SOL_IP, IP_MTU_DISCOVER, | |
| 149 | + opt = IPV6_PMTUDISC_DO; | |
| 150 | + ret = kernel_setsockopt(local->socket, SOL_IPV6, IPV6_MTU_DISCOVER, | |
| 151 | 151 | (char *) &opt, sizeof(opt)); |
| 152 | 152 | if (ret < 0) { |
| 153 | 153 | _debug("setsockopt failed"); |
| 154 | 154 | goto error; |
| 155 | 155 | } |
| 156 | − break; | |
| 157 | 156 | |
| 158 | − case AF_INET6: | |
| 157 | + /* Fall through and set IPv4 options too otherwise we don't get | |
| 158 | + * errors from IPv4 packets sent through the IPv6 socket. | |
| 159 | + */ | |
| 160 | + | |
| 161 | + case AF_INET: | |
| 159 | 162 | /* we want to receive ICMP errors */ |
| 160 | 163 | opt = 1; |
| 161 | − ret = kernel_setsockopt(local->socket, SOL_IPV6, IPV6_RECVERR, | |
| 164 | + ret = kernel_setsockopt(local->socket, SOL_IP, IP_RECVERR, | |
| 162 | 165 | (char *) &opt, sizeof(opt)); |
| 163 | 166 | if (ret < 0) { |
| 164 | 167 | _debug("setsockopt failed"); |
| @@ -166,13 +169,22 @@ static int rxrpc_open_socket(struct rxrpc_local *local, struct net *net) · 1 unmodified line | ||
| 166 | 169 | } |
| 167 | 170 | |
| 168 | 171 | /* we want to set the don't fragment bit */ |
| 169 | − opt = IPV6_PMTUDISC_DO; | |
| 170 | − ret = kernel_setsockopt(local->socket, SOL_IPV6, IPV6_MTU_DISCOVER, | |
| 172 | + opt = IP_PMTUDISC_DO; | |
| 173 | + ret = kernel_setsockopt(local->socket, SOL_IP, IP_MTU_DISCOVER, | |
| 171 | 174 | (char *) &opt, sizeof(opt)); |
| 172 | 175 | if (ret < 0) { |
| 173 | 176 | _debug("setsockopt failed"); |
| 174 | 177 | goto error; |
| 175 | 178 | } |
| 179 | + | |
| 180 | + /* We want receive timestamps. */ | |
| 181 | + opt = 1; | |
| 182 | + ret = kernel_setsockopt(local->socket, SOL_SOCKET, SO_TIMESTAMPNS, | |
| 183 | + (char *)&opt, sizeof(opt)); | |
| 184 | + if (ret < 0) { | |
| 185 | + _debug("setsockopt failed"); | |
| 186 | + goto error; | |
| 187 | + } | |
| 176 | 188 | break; |
| 177 | 189 | |
| 178 | 190 | default: |
| @@ -124,7 +124,6 @@ int rxrpc_send_ack_packet(struct rxrpc_call *call, bool ping, · 123 unmodified lines | ||
| 124 | 124 | struct kvec iov[2]; |
| 125 | 125 | rxrpc_serial_t serial; |
| 126 | 126 | rxrpc_seq_t hard_ack, top; |
| 127 | − ktime_t now; | |
| 128 | 127 | size_t len, n; |
| 129 | 128 | int ret; |
| 130 | 129 | u8 reason; |
| @@ -196,9 +195,7 @@ int rxrpc_send_ack_packet(struct rxrpc_call *call, bool ping, · 65 unmodified lines | ||
| 196 | 195 | /* We need to stick a time in before we send the packet in case |
| 197 | 196 | * the reply gets back before kernel_sendmsg() completes - but |
| 198 | 197 | * asking UDP to send the packet can take a relatively long |
| 199 | − * time, so we update the time after, on the assumption that | |
| 200 | − * the packet transmission is more likely to happen towards the | |
| 201 | − * end of the kernel_sendmsg() call. | |
| 198 | + * time. | |
| 202 | 199 | */ |
| 203 | 200 | call->ping_time = ktime_get_real(); |
| 204 | 201 | set_bit(RXRPC_CALL_PINGING, &call->flags); |
| @@ -206,9 +203,6 @@ int rxrpc_send_ack_packet(struct rxrpc_call *call, bool ping, · 1 unmodified line | ||
| 206 | 203 | } |
| 207 | 204 | |
| 208 | 205 | ret = kernel_sendmsg(conn->params.local->socket, &msg, iov, 2, len); |
| 209 | − now = ktime_get_real(); | |
| 210 | − if (ping) | |
| 211 | − call->ping_time = now; | |
| 212 | 206 | conn->params.peer->last_tx_at = ktime_get_seconds(); |
| 213 | 207 | if (ret < 0) |
| 214 | 208 | trace_rxrpc_tx_fail(call->debug_id, serial, ret, |
| @@ -363,8 +357,14 @@ int rxrpc_send_data_packet(struct rxrpc_call *call, struct sk_buff *skb, · 148 unmodified lines | ||
| 363 | 357 | |
| 364 | 358 | /* If our RTT cache needs working on, request an ACK. Also request |
| 365 | 359 | * ACKs if a DATA packet appears to have been lost. |
| 360 | + * | |
| 361 | + * However, we mustn't request an ACK on the last reply packet of a | |
| 362 | + * service call, lest OpenAFS incorrectly send us an ACK with some | |
| 363 | + * soft-ACKs in it and then never follow up with a proper hard ACK. | |
| 366 | 364 | */ |
| 367 | − if (!(sp->hdr.flags & RXRPC_LAST_PACKET) && | |
| 365 | + if ((!(sp->hdr.flags & RXRPC_LAST_PACKET) || | |
| 366 | + rxrpc_to_server(sp) | |
| 367 | + ) && | |
| 368 | 368 | (test_and_clear_bit(RXRPC_CALL_EV_ACK_LOST, &call->events) || |
| 369 | 369 | retrans || |
| 370 | 370 | call->cong_mode == RXRPC_CALL_SLOW_START || |
| @@ -390,6 +390,11 @@ int rxrpc_send_data_packet(struct rxrpc_call *call, struct sk_buff *skb, · 19 unmodified lines | ||
| 390 | 390 | goto send_fragmentable; |
| 391 | 391 | |
| 392 | 392 | down_read(&conn->params.local->defrag_sem); |
| 393 | + | |
| 394 | + sp->hdr.serial = serial; | |
| 395 | + smp_wmb(); /* Set serial before timestamp */ | |
| 396 | + skb->tstamp = ktime_get_real(); | |
| 397 | + | |
| 393 | 398 | /* send the packet by UDP |
| 394 | 399 | * - returns -EMSGSIZE if UDP would have to fragment the packet |
| 395 | 400 | * to go out of the interface |
| @@ -413,12 +418,8 @@ done: · 17 unmodified lines | ||
| 413 | 418 | trace_rxrpc_tx_data(call, sp->hdr.seq, serial, whdr.flags, |
| 414 | 419 | retrans, lost); |
| 415 | 420 | if (ret >= 0) { |
| 416 | − ktime_t now = ktime_get_real(); | |
| 417 | − skb->tstamp = now; | |
| 418 | − smp_wmb(); | |
| 419 | − sp->hdr.serial = serial; | |
| 420 | 421 | if (whdr.flags & RXRPC_REQUEST_ACK) { |
| 421 | − call->peer->rtt_last_req = now; | |
| 422 | + call->peer->rtt_last_req = skb->tstamp; | |
| 422 | 423 | trace_rxrpc_rtt_tx(call, rxrpc_rtt_tx_data, serial); |
| 423 | 424 | if (call->peer->rtt_usage > 1) { |
| 424 | 425 | unsigned long nowj = jiffies, ack_lost_at; |
| @@ -457,6 +458,10 @@ send_fragmentable: · 32 unmodified lines | ||
| 457 | 458 | |
| 458 | 459 | down_write(&conn->params.local->defrag_sem); |
| 459 | 460 | |
| 461 | + sp->hdr.serial = serial; | |
| 462 | + smp_wmb(); /* Set serial before timestamp */ | |
| 463 | + skb->tstamp = ktime_get_real(); | |
| 464 | + | |
| 460 | 465 | switch (conn->params.local->srx.transport.family) { |
| 461 | 466 | case AF_INET: |
| 462 | 467 | opt = IP_PMTUDISC_DONT; |
| @@ -519,7 +524,7 @@ void rxrpc_reject_packets(struct rxrpc_local *local) · 56 unmodified lines | ||
| 519 | 524 | struct kvec iov[2]; |
| 520 | 525 | size_t size; |
| 521 | 526 | __be32 code; |
| 522 | − int ret; | |
| 527 | + int ret, ioc; | |
| 523 | 528 | |
| 524 | 529 | _enter("%d", local->debug_id); |
| 525 | 530 | |
| @@ -527,7 +532,6 @@ void rxrpc_reject_packets(struct rxrpc_local *local) · 1 unmodified line | ||
| 527 | 532 | iov[0].iov_len = sizeof(whdr); |
| 528 | 533 | iov[1].iov_base = &code; |
| 529 | 534 | iov[1].iov_len = sizeof(code); |
| 530 | − size = sizeof(whdr) + sizeof(code); | |
| 531 | 535 | |
| 532 | 536 | msg.msg_name = &srx.transport; |
| 533 | 537 | msg.msg_control = NULL; |
| @@ -535,17 +539,31 @@ void rxrpc_reject_packets(struct rxrpc_local *local) · 1 unmodified line | ||
| 535 | 539 | msg.msg_flags = 0; |
| 536 | 540 | |
| 537 | 541 | memset(&whdr, 0, sizeof(whdr)); |
| 538 | − whdr.type = RXRPC_PACKET_TYPE_ABORT; | |
| 539 | 542 | |
| 540 | 543 | while ((skb = skb_dequeue(&local->reject_queue))) { |
| 541 | 544 | rxrpc_see_skb(skb, rxrpc_skb_rx_seen); |
| 542 | 545 | sp = rxrpc_skb(skb); |
| 543 | 546 | |
| 547 | + switch (skb->mark) { | |
| 548 | + case RXRPC_SKB_MARK_REJECT_BUSY: | |
| 549 | + whdr.type = RXRPC_PACKET_TYPE_BUSY; | |
| 550 | + size = sizeof(whdr); | |
| 551 | + ioc = 1; | |
| 552 | + break; | |
| 553 | + case RXRPC_SKB_MARK_REJECT_ABORT: | |
| 554 | + whdr.type = RXRPC_PACKET_TYPE_ABORT; | |
| 555 | + code = htonl(skb->priority); | |
| 556 | + size = sizeof(whdr) + sizeof(code); | |
| 557 | + ioc = 2; | |
| 558 | + break; | |
| 559 | + default: | |
| 560 | + rxrpc_free_skb(skb, rxrpc_skb_rx_freed); | |
| 561 | + continue; | |
| 562 | + } | |
| 563 | + | |
| 544 | 564 | if (rxrpc_extract_addr_from_skb(local, &srx, skb) == 0) { |
| 545 | 565 | msg.msg_namelen = srx.transport_len; |
| 546 | 566 | |
| 547 | − code = htonl(skb->priority); | |
| 548 | − | |
| 549 | 567 | whdr.epoch = htonl(sp->hdr.epoch); |
| 550 | 568 | whdr.cid = htonl(sp->hdr.cid); |
| 551 | 569 | whdr.callNumber = htonl(sp->hdr.callNumber); |
| @@ -23,6 +23,8 @@ · 22 unmodified lines | ||
| 23 | 23 | #include "ar-internal.h" |
| 24 | 24 | |
| 25 | 25 | static void rxrpc_store_error(struct rxrpc_peer *, struct sock_exterr_skb *); |
| 26 | +static void rxrpc_distribute_error(struct rxrpc_peer *, int, | |
| 27 | + enum rxrpc_call_completion); | |
| 26 | 28 | |
| 27 | 29 | /* |
| 28 | 30 | * Find the peer associated with an ICMP packet. |
| @@ -194,8 +196,6 @@ void rxrpc_error_report(struct sock *sk) · 165 unmodified lines | ||
| 194 | 196 | rcu_read_unlock(); |
| 195 | 197 | rxrpc_free_skb(skb, rxrpc_skb_rx_freed); |
| 196 | 198 | |
| 197 | − /* The ref we obtained is passed off to the work item */ | |
| 198 | − __rxrpc_queue_peer_error(peer); | |
| 199 | 199 | _leave(""); |
| 200 | 200 | } |
| 201 | 201 | |
| @@ -205,6 +205,7 @@ void rxrpc_error_report(struct sock *sk) · 3 unmodified lines | ||
| 205 | 205 | static void rxrpc_store_error(struct rxrpc_peer *peer, |
| 206 | 206 | struct sock_exterr_skb *serr) |
| 207 | 207 | { |
| 208 | + enum rxrpc_call_completion compl = RXRPC_CALL_NETWORK_ERROR; | |
| 208 | 209 | struct sock_extended_err *ee; |
| 209 | 210 | int err; |
| 210 | 211 | |
| @@ -255,7 +256,7 @@ static void rxrpc_store_error(struct rxrpc_peer *peer, · 44 unmodified lines | ||
| 255 | 256 | case SO_EE_ORIGIN_NONE: |
| 256 | 257 | case SO_EE_ORIGIN_LOCAL: |
| 257 | 258 | _proto("Rx Received local error { error=%d }", err); |
| 258 | − err += RXRPC_LOCAL_ERROR_OFFSET; | |
| 259 | + compl = RXRPC_CALL_LOCAL_ERROR; | |
| 259 | 260 | break; |
| 260 | 261 | |
| 261 | 262 | case SO_EE_ORIGIN_ICMP6: |
| @@ -264,48 +265,23 @@ static void rxrpc_store_error(struct rxrpc_peer *peer, · 2 unmodified lines | ||
| 264 | 265 | break; |
| 265 | 266 | } |
| 266 | 267 | |
| 267 | − peer->error_report = err; | |
| 268 | + rxrpc_distribute_error(peer, err, compl); | |
| 268 | 269 | } |
| 269 | 270 | |
| 270 | 271 | /* |
| 271 | − * Distribute an error that occurred on a peer | |
| 272 | + * Distribute an error that occurred on a peer. | |
| 272 | 273 | */ |
| 273 | −void rxrpc_peer_error_distributor(struct work_struct *work) | |
| 274 | +static void rxrpc_distribute_error(struct rxrpc_peer *peer, int error, | |
| 275 | + enum rxrpc_call_completion compl) | |
| 274 | 276 | { |
| 275 | − struct rxrpc_peer *peer = | |
| 276 | − container_of(work, struct rxrpc_peer, error_distributor); | |
| 277 | 277 | struct rxrpc_call *call; |
| 278 | − enum rxrpc_call_completion compl; | |
| 279 | − int error; | |
| 280 | − | |
| 281 | − _enter(""); | |
| 282 | − | |
| 283 | − error = READ_ONCE(peer->error_report); | |
| 284 | − if (error < RXRPC_LOCAL_ERROR_OFFSET) { | |
| 285 | − compl = RXRPC_CALL_NETWORK_ERROR; | |
| 286 | − } else { | |
| 287 | − compl = RXRPC_CALL_LOCAL_ERROR; | |
| 288 | − error -= RXRPC_LOCAL_ERROR_OFFSET; | |
| 289 | − } | |
| 290 | 278 | |
| 291 | − _debug("ISSUE ERROR %s %d", rxrpc_call_completions[compl], error); | |
| 292 | − | |
| 293 | − spin_lock_bh(&peer->lock); | |
| 294 | − | |
| 295 | − while (!hlist_empty(&peer->error_targets)) { | |
| 296 | − call = hlist_entry(peer->error_targets.first, | |
| 297 | − struct rxrpc_call, error_link); | |
| 298 | − hlist_del_init(&call->error_link); | |
| 279 | + hlist_for_each_entry_rcu(call, &peer->error_targets, error_link) { | |
| 299 | 280 | rxrpc_see_call(call); |
| 300 | − | |
| 301 | − if (rxrpc_set_call_completion(call, compl, 0, -error)) | |
| 281 | + if (call->state < RXRPC_CALL_COMPLETE && | |
| 282 | + rxrpc_set_call_completion(call, compl, 0, -error)) | |
| 302 | 283 | rxrpc_notify_socket(call); |
| 303 | 284 | } |
| 304 | − | |
| 305 | − spin_unlock_bh(&peer->lock); | |
| 306 | − | |
| 307 | − rxrpc_put_peer(peer); | |
| 308 | − _leave(""); | |
| 309 | 285 | } |
| 310 | 286 | |
| 311 | 287 | /* |
| @@ -124,11 +124,9 @@ static struct rxrpc_peer *__rxrpc_lookup_peer_rcu( · 123 unmodified lines | ||
| 124 | 124 | struct rxrpc_net *rxnet = local->rxnet; |
| 125 | 125 | |
| 126 | 126 | hash_for_each_possible_rcu(rxnet->peer_hash, peer, hash_link, hash_key) { |
| 127 | − if (rxrpc_peer_cmp_key(peer, local, srx, hash_key) == 0) { | |
| 128 | − if (atomic_read(&peer->usage) == 0) | |
| 129 | − return NULL; | |
| 127 | + if (rxrpc_peer_cmp_key(peer, local, srx, hash_key) == 0 && | |
| 128 | + atomic_read(&peer->usage) > 0) | |
| 130 | 129 | return peer; |
| 131 | − } | |
| 132 | 130 | } |
| 133 | 131 | |
| 134 | 132 | return NULL; |
| @@ -222,8 +220,6 @@ struct rxrpc_peer *rxrpc_alloc_peer(struct rxrpc_local *local, gfp_t gfp) · 87 unmodified lines | ||
| 222 | 220 | atomic_set(&peer->usage, 1); |
| 223 | 221 | peer->local = local; |
| 224 | 222 | INIT_HLIST_HEAD(&peer->error_targets); |
| 225 | − INIT_WORK(&peer->error_distributor, | |
| 226 | − &rxrpc_peer_error_distributor); | |
| 227 | 223 | peer->service_conns = RB_ROOT; |
| 228 | 224 | seqlock_init(&peer->service_conn_lock); |
| 229 | 225 | spin_lock_init(&peer->lock); |
| @@ -299,34 +295,23 @@ static struct rxrpc_peer *rxrpc_create_peer(struct rxrpc_local *local, · 69 unmodified lines | ||
| 299 | 295 | } |
| 300 | 296 | |
| 301 | 297 | /* |
| 302 | − * Set up a new incoming peer. The address is prestored in the preallocated | |
| 303 | − * peer. | |
| 298 | + * Set up a new incoming peer. There shouldn't be any other matching peers | |
| 299 | + * since we've already done a search in the list from the non-reentrant context | |
| 300 | + * (the data_ready handler) that is the only place we can add new peers. | |
| 304 | 301 | */ |
| 305 | −struct rxrpc_peer *rxrpc_lookup_incoming_peer(struct rxrpc_local *local, | |
| 306 | − struct rxrpc_peer *prealloc) | |
| 302 | +void rxrpc_new_incoming_peer(struct rxrpc_local *local, struct rxrpc_peer *peer) | |
| 307 | 303 | { |
| 308 | − struct rxrpc_peer *peer; | |
| 309 | 304 | struct rxrpc_net *rxnet = local->rxnet; |
| 310 | 305 | unsigned long hash_key; |
| 311 | 306 | |
| 312 | − hash_key = rxrpc_peer_hash_key(local, &prealloc->srx); | |
| 313 | − prealloc->local = local; | |
| 314 | − rxrpc_init_peer(prealloc, hash_key); | |
| 307 | + hash_key = rxrpc_peer_hash_key(local, &peer->srx); | |
| 308 | + peer->local = local; | |
| 309 | + rxrpc_init_peer(peer, hash_key); | |
| 315 | 310 | |
| 316 | 311 | spin_lock(&rxnet->peer_hash_lock); |
| 317 | − | |
| 318 | − /* Need to check that we aren't racing with someone else */ | |
| 319 | − peer = __rxrpc_lookup_peer_rcu(local, &prealloc->srx, hash_key); | |
| 320 | − if (peer && !rxrpc_get_peer_maybe(peer)) | |
| 321 | − peer = NULL; | |
| 322 | − if (!peer) { | |
| 323 | − peer = prealloc; | |
| 324 | − hash_add_rcu(rxnet->peer_hash, &peer->hash_link, hash_key); | |
| 325 | − list_add_tail(&peer->keepalive_link, &rxnet->peer_keepalive_new); | |
| 326 | − } | |
| 327 | − | |
| 312 | + hash_add_rcu(rxnet->peer_hash, &peer->hash_link, hash_key); | |
| 313 | + list_add_tail(&peer->keepalive_link, &rxnet->peer_keepalive_new); | |
| 328 | 314 | spin_unlock(&rxnet->peer_hash_lock); |
| 329 | − return peer; | |
| 330 | 315 | } |
| 331 | 316 | |
| 332 | 317 | /* |
| @@ -415,21 +400,6 @@ struct rxrpc_peer *rxrpc_get_peer_maybe(struct rxrpc_peer *peer) · 82 unmodified lines | ||
| 415 | 400 | return peer; |
| 416 | 401 | } |
| 417 | 402 | |
| 418 | −/* | |
| 419 | − * Queue a peer record. This passes the caller's ref to the workqueue. | |
| 420 | − */ | |
| 421 | −void __rxrpc_queue_peer_error(struct rxrpc_peer *peer) | |
| 422 | −{ | |
| 423 | − const void *here = __builtin_return_address(0); | |
| 424 | − int n; | |
| 425 | − | |
| 426 | − n = atomic_read(&peer->usage); | |
| 427 | − if (rxrpc_queue_work(&peer->error_distributor)) | |
| 428 | − trace_rxrpc_peer(peer, rxrpc_peer_queued_error, n, here); | |
| 429 | − else | |
| 430 | − rxrpc_put_peer(peer); | |
| 431 | −} | |
| 432 | − | |
| 433 | 403 | /* |
| 434 | 404 | * Discard a peer record. |
| 435 | 405 | */ |
| @@ -50,7 +50,6 @@ struct rxrpc_wire_header { · 49 unmodified lines | ||
| 50 | 50 | #define RXRPC_PACKET_TYPE_10 10 /* Ignored */ |
| 51 | 51 | #define RXRPC_PACKET_TYPE_11 11 /* Ignored */ |
| 52 | 52 | #define RXRPC_PACKET_TYPE_VERSION 13 /* version string request */ |
| 53 | −#define RXRPC_N_PACKET_TYPES 14 /* number of packet types (incl type 0) */ | |
| 54 | 53 | |
| 55 | 54 | uint8_t flags; /* packet flags */ |
| 56 | 55 | #define RXRPC_CLIENT_INITIATED 0x01 /* signifies a packet generated by a client */ |
| @@ -72,20 +71,6 @@ struct rxrpc_wire_header { · 15 unmodified lines | ||
| 72 | 71 | |
| 73 | 72 | } __packed; |
| 74 | 73 | |
| 75 | −#define RXRPC_SUPPORTED_PACKET_TYPES ( \ | |
| 76 | − (1 << RXRPC_PACKET_TYPE_DATA) | \ | |
| 77 | − (1 << RXRPC_PACKET_TYPE_ACK) | \ | |
| 78 | − (1 << RXRPC_PACKET_TYPE_BUSY) | \ | |
| 79 | − (1 << RXRPC_PACKET_TYPE_ABORT) | \ | |
| 80 | − (1 << RXRPC_PACKET_TYPE_ACKALL) | \ | |
| 81 | − (1 << RXRPC_PACKET_TYPE_CHALLENGE) | \ | |
| 82 | − (1 << RXRPC_PACKET_TYPE_RESPONSE) | \ | |
| 83 | − /*(1 << RXRPC_PACKET_TYPE_DEBUG) | */ \ | |
| 84 | − (1 << RXRPC_PACKET_TYPE_PARAMS) | \ | |
| 85 | − (1 << RXRPC_PACKET_TYPE_10) | \ | |
| 86 | − (1 << RXRPC_PACKET_TYPE_11) | \ | |
| 87 | − (1 << RXRPC_PACKET_TYPE_VERSION)) | |
| 88 | − | |
| 89 | 74 | /*****************************************************************************/ |
| 90 | 75 | /* |
| 91 | 76 | * jumbo packet secondary header |
| @@ -135,7 +135,7 @@ static int __tcf_ipt_init(struct net *net, unsigned int id, struct nlattr *nla, · 134 unmodified lines | ||
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | td = (struct xt_entry_target *)nla_data(tb[TCA_IPT_TARG]); |
| 138 | − if (nla_len(tb[TCA_IPT_TARG]) < td->u.target_size) { | |
| 138 | + if (nla_len(tb[TCA_IPT_TARG]) != td->u.target_size) { | |
| 139 | 139 | if (exists) |
| 140 | 140 | tcf_idr_release(*a, bind); |
| 141 | 141 | else |
| @@ -1311,6 +1311,18 @@ check_loop_fn(struct Qdisc *q, unsigned long cl, struct qdisc_walker *w) · 1310 unmodified lines | ||
| 1311 | 1311 | * Delete/get qdisc. |
| 1312 | 1312 | */ |
| 1313 | 1313 | |
| 1314 | +const struct nla_policy rtm_tca_policy[TCA_MAX + 1] = { | |
| 1315 | + [TCA_KIND] = { .type = NLA_STRING }, | |
| 1316 | + [TCA_OPTIONS] = { .type = NLA_NESTED }, | |
| 1317 | + [TCA_RATE] = { .type = NLA_BINARY, | |
| 1318 | + .len = sizeof(struct tc_estimator) }, | |
| 1319 | + [TCA_STAB] = { .type = NLA_NESTED }, | |
| 1320 | + [TCA_DUMP_INVISIBLE] = { .type = NLA_FLAG }, | |
| 1321 | + [TCA_CHAIN] = { .type = NLA_U32 }, | |
| 1322 | + [TCA_INGRESS_BLOCK] = { .type = NLA_U32 }, | |
| 1323 | + [TCA_EGRESS_BLOCK] = { .type = NLA_U32 }, | |
| 1324 | +}; | |
| 1325 | + | |
| 1314 | 1326 | static int tc_get_qdisc(struct sk_buff *skb, struct nlmsghdr *n, |
| 1315 | 1327 | struct netlink_ext_ack *extack) |
| 1316 | 1328 | { |
| @@ -1327,7 +1339,8 @@ static int tc_get_qdisc(struct sk_buff *skb, struct nlmsghdr *n, · 10 unmodified lines | ||
| 1327 | 1339 | !netlink_ns_capable(skb, net->user_ns, CAP_NET_ADMIN)) |
| 1328 | 1340 | return -EPERM; |
| 1329 | 1341 | |
| 1330 | − err = nlmsg_parse(n, sizeof(*tcm), tca, TCA_MAX, NULL, extack); | |
| 1342 | + err = nlmsg_parse(n, sizeof(*tcm), tca, TCA_MAX, rtm_tca_policy, | |
| 1343 | + extack); | |
| 1331 | 1344 | if (err < 0) |
| 1332 | 1345 | return err; |
| 1333 | 1346 | |
| @@ -1411,7 +1424,8 @@ static int tc_modify_qdisc(struct sk_buff *skb, struct nlmsghdr *n, · 77 unmodified lines | ||
| 1411 | 1424 | |
| 1412 | 1425 | replay: |
| 1413 | 1426 | /* Reinit, just in case something touches this. */ |
| 1414 | − err = nlmsg_parse(n, sizeof(*tcm), tca, TCA_MAX, NULL, extack); | |
| 1427 | + err = nlmsg_parse(n, sizeof(*tcm), tca, TCA_MAX, rtm_tca_policy, | |
| 1428 | + extack); | |
| 1415 | 1429 | if (err < 0) |
| 1416 | 1430 | return err; |
| 1417 | 1431 | |
| @@ -1645,7 +1659,8 @@ static int tc_dump_qdisc(struct sk_buff *skb, struct netlink_callback *cb) · 227 unmodified lines | ||
| 1645 | 1659 | idx = 0; |
| 1646 | 1660 | ASSERT_RTNL(); |
| 1647 | 1661 | |
| 1648 | − err = nlmsg_parse(nlh, sizeof(struct tcmsg), tca, TCA_MAX, NULL, NULL); | |
| 1662 | + err = nlmsg_parse(nlh, sizeof(struct tcmsg), tca, TCA_MAX, | |
| 1663 | + rtm_tca_policy, NULL); | |
| 1649 | 1664 | if (err < 0) |
| 1650 | 1665 | return err; |
| 1651 | 1666 | |
| @@ -1864,7 +1879,8 @@ static int tc_ctl_tclass(struct sk_buff *skb, struct nlmsghdr *n, · 212 unmodified lines | ||
| 1864 | 1879 | !netlink_ns_capable(skb, net->user_ns, CAP_NET_ADMIN)) |
| 1865 | 1880 | return -EPERM; |
| 1866 | 1881 | |
| 1867 | − err = nlmsg_parse(n, sizeof(*tcm), tca, TCA_MAX, NULL, extack); | |
| 1882 | + err = nlmsg_parse(n, sizeof(*tcm), tca, TCA_MAX, rtm_tca_policy, | |
| 1883 | + extack); | |
| 1868 | 1884 | if (err < 0) |
| 1869 | 1885 | return err; |
| 1870 | 1886 | |
| @@ -1048,7 +1048,7 @@ static void sctp_outq_flush_data(struct sctp_flush_ctx *ctx, · 1047 unmodified lines | ||
| 1048 | 1048 | if (!ctx->packet || !ctx->packet->has_cookie_echo) |
| 1049 | 1049 | return; |
| 1050 | 1050 | |
| 1051 | − /* fallthru */ | |
| 1051 | + /* fall through */ | |
| 1052 | 1052 | case SCTP_STATE_ESTABLISHED: |
| 1053 | 1053 | case SCTP_STATE_SHUTDOWN_PENDING: |
| 1054 | 1054 | case SCTP_STATE_SHUTDOWN_RECEIVED: |
| @@ -609,16 +609,18 @@ static int tipc_l2_device_event(struct notifier_block *nb, unsigned long evt, · 608 unmodified lines | ||
| 609 | 609 | |
| 610 | 610 | switch (evt) { |
| 611 | 611 | case NETDEV_CHANGE: |
| 612 | − if (netif_carrier_ok(dev)) | |
| 612 | + if (netif_carrier_ok(dev) && netif_oper_up(dev)) { | |
| 613 | + test_and_set_bit_lock(0, &b->up); | |
| 613 | 614 | break; |
| 614 | − /* else: fall through */ | |
| 615 | − case NETDEV_UP: | |
| 616 | − test_and_set_bit_lock(0, &b->up); | |
| 617 | − break; | |
| 615 | + } | |
| 616 | + /* fall through */ | |
| 618 | 617 | case NETDEV_GOING_DOWN: |
| 619 | 618 | clear_bit_unlock(0, &b->up); |
| 620 | 619 | tipc_reset_bearer(net, b); |
| 621 | 620 | break; |
| 621 | + case NETDEV_UP: | |
| 622 | + test_and_set_bit_lock(0, &b->up); | |
| 623 | + break; | |
| 622 | 624 | case NETDEV_CHANGEMTU: |
| 623 | 625 | if (tipc_mtu_bad(dev, 0)) { |
| 624 | 626 | bearer_disable(net, b); |
| @@ -410,6 +410,11 @@ char *tipc_link_name(struct tipc_link *l) · 409 unmodified lines | ||
| 410 | 410 | return l->name; |
| 411 | 411 | } |
| 412 | 412 | |
| 413 | +u32 tipc_link_state(struct tipc_link *l) | |
| 414 | +{ | |
| 415 | + return l->state; | |
| 416 | +} | |
| 417 | + | |
| 413 | 418 | /** |
| 414 | 419 | * tipc_link_create - create a new link |
| 415 | 420 | * @n: pointer to associated node |
| @@ -841,9 +846,14 @@ void tipc_link_reset(struct tipc_link *l) · 425 unmodified lines | ||
| 841 | 846 | l->in_session = false; |
| 842 | 847 | l->session++; |
| 843 | 848 | l->mtu = l->advertised_mtu; |
| 849 | + spin_lock_bh(&l->wakeupq.lock); | |
| 850 | + spin_lock_bh(&l->inputq->lock); | |
| 851 | + skb_queue_splice_init(&l->wakeupq, l->inputq); | |
| 852 | + spin_unlock_bh(&l->inputq->lock); | |
| 853 | + spin_unlock_bh(&l->wakeupq.lock); | |
| 854 | + | |
| 844 | 855 | __skb_queue_purge(&l->transmq); |
| 845 | 856 | __skb_queue_purge(&l->deferdq); |
| 846 | − skb_queue_splice_init(&l->wakeupq, l->inputq); | |
| 847 | 857 | __skb_queue_purge(&l->backlogq); |
| 848 | 858 | l->backlog[TIPC_LOW_IMPORTANCE].len = 0; |
| 849 | 859 | l->backlog[TIPC_MEDIUM_IMPORTANCE].len = 0; |
| @@ -1380,6 +1390,36 @@ static void tipc_link_build_proto_msg(struct tipc_link *l, int mtyp, bool probe, · 530 unmodified lines | ||
| 1380 | 1390 | __skb_queue_tail(xmitq, skb); |
| 1381 | 1391 | } |
| 1382 | 1392 | |
| 1393 | +void tipc_link_create_dummy_tnl_msg(struct tipc_link *l, | |
| 1394 | + struct sk_buff_head *xmitq) | |
| 1395 | +{ | |
| 1396 | + u32 onode = tipc_own_addr(l->net); | |
| 1397 | + struct tipc_msg *hdr, *ihdr; | |
| 1398 | + struct sk_buff_head tnlq; | |
| 1399 | + struct sk_buff *skb; | |
| 1400 | + u32 dnode = l->addr; | |
| 1401 | + | |
| 1402 | + skb_queue_head_init(&tnlq); | |
| 1403 | + skb = tipc_msg_create(TUNNEL_PROTOCOL, FAILOVER_MSG, | |
| 1404 | + INT_H_SIZE, BASIC_H_SIZE, | |
| 1405 | + dnode, onode, 0, 0, 0); | |
| 1406 | + if (!skb) { | |
| 1407 | + pr_warn("%sunable to create tunnel packet\n", link_co_err); | |
| 1408 | + return; | |
| 1409 | + } | |
| 1410 | + | |
| 1411 | + hdr = buf_msg(skb); | |
| 1412 | + msg_set_msgcnt(hdr, 1); | |
| 1413 | + msg_set_bearer_id(hdr, l->peer_bearer_id); | |
| 1414 | + | |
| 1415 | + ihdr = (struct tipc_msg *)msg_data(hdr); | |
| 1416 | + tipc_msg_init(onode, ihdr, TIPC_LOW_IMPORTANCE, TIPC_DIRECT_MSG, | |
| 1417 | + BASIC_H_SIZE, dnode); | |
| 1418 | + msg_set_errcode(ihdr, TIPC_ERR_NO_PORT); | |
| 1419 | + __skb_queue_tail(&tnlq, skb); | |
| 1420 | + tipc_link_xmit(l, &tnlq, xmitq); | |
| 1421 | +} | |
| 1422 | + | |
| 1383 | 1423 | /* tipc_link_tnl_prepare(): prepare and return a list of tunnel packets |
| 1384 | 1424 | * with contents of the link's transmit and backlog queues. |
| 1385 | 1425 | */ |
| @@ -1476,6 +1516,9 @@ bool tipc_link_validate_msg(struct tipc_link *l, struct tipc_msg *hdr) · 90 unmodified lines | ||
| 1476 | 1516 | return false; |
| 1477 | 1517 | if (session != curr_session) |
| 1478 | 1518 | return false; |
| 1519 | + /* Extra sanity check */ | |
| 1520 | + if (!link_is_up(l) && msg_ack(hdr)) | |
| 1521 | + return false; | |
| 1479 | 1522 | if (!(l->peer_caps & TIPC_LINK_PROTO_SEQNO)) |
| 1480 | 1523 | return true; |
| 1481 | 1524 | /* Accept only STATE with new sequence number */ |
| @@ -88,6 +88,8 @@ bool tipc_link_bc_create(struct net *net, u32 ownnode, u32 peer, · 87 unmodified lines | ||
| 88 | 88 | struct tipc_link **link); |
| 89 | 89 | void tipc_link_tnl_prepare(struct tipc_link *l, struct tipc_link *tnl, |
| 90 | 90 | int mtyp, struct sk_buff_head *xmitq); |
| 91 | +void tipc_link_create_dummy_tnl_msg(struct tipc_link *tnl, | |
| 92 | + struct sk_buff_head *xmitq); | |
| 91 | 93 | void tipc_link_build_reset_msg(struct tipc_link *l, struct sk_buff_head *xmitq); |
| 92 | 94 | int tipc_link_fsm_evt(struct tipc_link *l, int evt); |
| 93 | 95 | bool tipc_link_is_up(struct tipc_link *l); |
| @@ -107,6 +109,7 @@ u16 tipc_link_rcv_nxt(struct tipc_link *l); · 13 unmodified lines | ||
| 107 | 109 | u16 tipc_link_acked(struct tipc_link *l); |
| 108 | 110 | u32 tipc_link_id(struct tipc_link *l); |
| 109 | 111 | char *tipc_link_name(struct tipc_link *l); |
| 112 | +u32 tipc_link_state(struct tipc_link *l); | |
| 110 | 113 | char tipc_link_plane(struct tipc_link *l); |
| 111 | 114 | int tipc_link_prio(struct tipc_link *l); |
| 112 | 115 | int tipc_link_window(struct tipc_link *l); |
| @@ -111,6 +111,7 @@ struct tipc_node { · 110 unmodified lines | ||
| 111 | 111 | int action_flags; |
| 112 | 112 | struct list_head list; |
| 113 | 113 | int state; |
| 114 | + bool failover_sent; | |
| 114 | 115 | u16 sync_point; |
| 115 | 116 | int link_cnt; |
| 116 | 117 | u16 working_links; |
| @@ -680,6 +681,7 @@ static void __tipc_node_link_up(struct tipc_node *n, int bearer_id, · 563 unmodified lines | ||
| 680 | 681 | *slot0 = bearer_id; |
| 681 | 682 | *slot1 = bearer_id; |
| 682 | 683 | tipc_node_fsm_evt(n, SELF_ESTABL_CONTACT_EVT); |
| 684 | + n->failover_sent = false; | |
| 683 | 685 | n->action_flags |= TIPC_NOTIFY_NODE_UP; |
| 684 | 686 | tipc_link_set_active(nl, true); |
| 685 | 687 | tipc_bcast_add_peer(n->net, nl, xmitq); |
| @@ -911,6 +913,7 @@ void tipc_node_check_dest(struct net *net, u32 addr, · 225 unmodified lines | ||
| 911 | 913 | bool reset = true; |
| 912 | 914 | char *if_name; |
| 913 | 915 | unsigned long intv; |
| 916 | + u16 session; | |
| 914 | 917 | |
| 915 | 918 | *dupl_addr = false; |
| 916 | 919 | *respond = false; |
| @@ -997,9 +1000,10 @@ void tipc_node_check_dest(struct net *net, u32 addr, · 80 unmodified lines | ||
| 997 | 1000 | goto exit; |
| 998 | 1001 | |
| 999 | 1002 | if_name = strchr(b->name, ':') + 1; |
| 1003 | + get_random_bytes(&session, sizeof(u16)); | |
| 1000 | 1004 | if (!tipc_link_create(net, if_name, b->identity, b->tolerance, |
| 1001 | 1005 | b->net_plane, b->mtu, b->priority, |
| 1002 | − b->window, mod(tipc_net(net)->random), | |
| 1006 | + b->window, session, | |
| 1003 | 1007 | tipc_own_addr(net), addr, peer_id, |
| 1004 | 1008 | n->capabilities, |
| 1005 | 1009 | tipc_bc_sndlink(n->net), n->bc_entry.link, |
| @@ -1615,6 +1619,14 @@ static bool tipc_node_check_state(struct tipc_node *n, struct sk_buff *skb, · 609 unmodified lines | ||
| 1615 | 1619 | tipc_skb_queue_splice_tail_init(tipc_link_inputq(pl), |
| 1616 | 1620 | tipc_link_inputq(l)); |
| 1617 | 1621 | } |
| 1622 | + /* If parallel link was already down, and this happened before | |
| 1623 | + * the tunnel link came up, FAILOVER was never sent. Ensure that | |
| 1624 | + * FAILOVER is sent to get peer out of NODE_FAILINGOVER state. | |
| 1625 | + */ | |
| 1626 | + if (n->state != NODE_FAILINGOVER && !n->failover_sent) { | |
| 1627 | + tipc_link_create_dummy_tnl_msg(l, xmitq); | |
| 1628 | + n->failover_sent = true; | |
| 1629 | + } | |
| 1618 | 1630 | /* If pkts arrive out of order, use lowest calculated syncpt */ |
| 1619 | 1631 | if (less(syncpt, n->sync_point)) |
| 1620 | 1632 | n->sync_point = syncpt; |
| @@ -1419,8 +1419,10 @@ static int __tipc_sendstream(struct socket *sock, struct msghdr *m, size_t dlen) · 1418 unmodified lines | ||
| 1419 | 1419 | /* Handle implicit connection setup */ |
| 1420 | 1420 | if (unlikely(dest)) { |
| 1421 | 1421 | rc = __tipc_sendmsg(sock, m, dlen); |
| 1422 | − if (dlen && (dlen == rc)) | |
| 1422 | + if (dlen && dlen == rc) { | |
| 1423 | + tsk->peer_caps = tipc_node_get_capabilities(net, dnode); | |
| 1423 | 1424 | tsk->snt_unacked = tsk_inc(tsk, dlen + msg_hdr_sz(hdr)); |
| 1425 | + } | |
| 1424 | 1426 | return rc; |
| 1425 | 1427 | } |
| 1426 | 1428 | |
| @@ -3756,6 +3756,7 @@ static bool ht_rateset_to_mask(struct ieee80211_supported_band *sband, · 3755 unmodified lines | ||
| 3756 | 3756 | return false; |
| 3757 | 3757 | |
| 3758 | 3758 | /* check availability */ |
| 3759 | + ridx = array_index_nospec(ridx, IEEE80211_HT_MCS_MASK_LEN); | |
| 3759 | 3760 | if (sband->ht_cap.mcs.rx_mask[ridx] & rbit) |
| 3760 | 3761 | mcs[ridx] |= rbit; |
| 3761 | 3762 | else |
| @@ -10230,7 +10231,7 @@ static int cfg80211_cqm_rssi_update(struct cfg80211_registered_device *rdev, · 6468 unmodified lines | ||
| 10230 | 10231 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 10231 | 10232 | s32 last, low, high; |
| 10232 | 10233 | u32 hyst; |
| 10233 | − int i, n; | |
| 10234 | + int i, n, low_index; | |
| 10234 | 10235 | int err; |
| 10235 | 10236 | |
| 10236 | 10237 | /* RSSI reporting disabled? */ |
| @@ -10267,10 +10268,19 @@ static int cfg80211_cqm_rssi_update(struct cfg80211_registered_device *rdev, · 30 unmodified lines | ||
| 10267 | 10268 | if (last < wdev->cqm_config->rssi_thresholds[i]) |
| 10268 | 10269 | break; |
| 10269 | 10270 | |
| 10270 | − low = i > 0 ? | |
| 10271 | − (wdev->cqm_config->rssi_thresholds[i - 1] - hyst) : S32_MIN; | |
| 10272 | − high = i < n ? | |
| 10273 | − (wdev->cqm_config->rssi_thresholds[i] + hyst - 1) : S32_MAX; | |
| 10271 | + low_index = i - 1; | |
| 10272 | + if (low_index >= 0) { | |
| 10273 | + low_index = array_index_nospec(low_index, n); | |
| 10274 | + low = wdev->cqm_config->rssi_thresholds[low_index] - hyst; | |
| 10275 | + } else { | |
| 10276 | + low = S32_MIN; | |
| 10277 | + } | |
| 10278 | + if (i < n) { | |
| 10279 | + i = array_index_nospec(i, n); | |
| 10280 | + high = wdev->cqm_config->rssi_thresholds[i] + hyst - 1; | |
| 10281 | + } else { | |
| 10282 | + high = S32_MAX; | |
| 10283 | + } | |
| 10274 | 10284 | |
| 10275 | 10285 | return rdev_set_cqm_rssi_range_config(rdev, dev, low, high); |
| 10276 | 10286 | } |
| @@ -2661,11 +2661,12 @@ static void reg_process_hint(struct regulatory_request *reg_request) · 2660 unmodified lines | ||
| 2661 | 2661 | { |
| 2662 | 2662 | struct wiphy *wiphy = NULL; |
| 2663 | 2663 | enum reg_request_treatment treatment; |
| 2664 | + enum nl80211_reg_initiator initiator = reg_request->initiator; | |
| 2664 | 2665 | |
| 2665 | 2666 | if (reg_request->wiphy_idx != WIPHY_IDX_INVALID) |
| 2666 | 2667 | wiphy = wiphy_idx_to_wiphy(reg_request->wiphy_idx); |
| 2667 | 2668 | |
| 2668 | − switch (reg_request->initiator) { | |
| 2669 | + switch (initiator) { | |
| 2669 | 2670 | case NL80211_REGDOM_SET_BY_CORE: |
| 2670 | 2671 | treatment = reg_process_hint_core(reg_request); |
| 2671 | 2672 | break; |
| @@ -2683,7 +2684,7 @@ static void reg_process_hint(struct regulatory_request *reg_request) · 11 unmodified lines | ||
| 2683 | 2684 | treatment = reg_process_hint_country_ie(wiphy, reg_request); |
| 2684 | 2685 | break; |
| 2685 | 2686 | default: |
| 2686 | − WARN(1, "invalid initiator %d\n", reg_request->initiator); | |
| 2687 | + WARN(1, "invalid initiator %d\n", initiator); | |
| 2687 | 2688 | goto out_free; |
| 2688 | 2689 | } |
| 2689 | 2690 | |
| @@ -2698,7 +2699,7 @@ static void reg_process_hint(struct regulatory_request *reg_request) · 8 unmodified lines | ||
| 2698 | 2699 | */ |
| 2699 | 2700 | if (treatment == REG_REQ_ALREADY_SET && wiphy && |
| 2700 | 2701 | wiphy->regulatory_flags & REGULATORY_STRICT_REG) { |
| 2701 | − wiphy_update_regulatory(wiphy, reg_request->initiator); | |
| 2702 | + wiphy_update_regulatory(wiphy, initiator); | |
| 2702 | 2703 | wiphy_all_share_dfs_chan_state(wiphy); |
| 2703 | 2704 | reg_check_channels(); |
| 2704 | 2705 | } |
| @@ -2867,6 +2868,7 @@ static int regulatory_hint_core(const char *alpha2) · 162 unmodified lines | ||
| 2867 | 2868 | request->alpha2[0] = alpha2[0]; |
| 2868 | 2869 | request->alpha2[1] = alpha2[1]; |
| 2869 | 2870 | request->initiator = NL80211_REGDOM_SET_BY_CORE; |
| 2871 | + request->wiphy_idx = WIPHY_IDX_INVALID; | |
| 2870 | 2872 | |
| 2871 | 2873 | queue_regulatory_request(request); |
| 2872 | 2874 | |
| @@ -1058,13 +1058,23 @@ cfg80211_bss_update(struct cfg80211_registered_device *rdev, · 1057 unmodified lines | ||
| 1058 | 1058 | return NULL; |
| 1059 | 1059 | } |
| 1060 | 1060 | |
| 1061 | +/* | |
| 1062 | + * Update RX channel information based on the available frame payload | |
| 1063 | + * information. This is mainly for the 2.4 GHz band where frames can be received | |
| 1064 | + * from neighboring channels and the Beacon frames use the DSSS Parameter Set | |
| 1065 | + * element to indicate the current (transmitting) channel, but this might also | |
| 1066 | + * be needed on other bands if RX frequency does not match with the actual | |
| 1067 | + * operating channel of a BSS. | |
| 1068 | + */ | |
| 1061 | 1069 | static struct ieee80211_channel * |
| 1062 | 1070 | cfg80211_get_bss_channel(struct wiphy *wiphy, const u8 *ie, size_t ielen, |
| 1063 | − struct ieee80211_channel *channel) | |
| 1071 | + struct ieee80211_channel *channel, | |
| 1072 | + enum nl80211_bss_scan_width scan_width) | |
| 1064 | 1073 | { |
| 1065 | 1074 | const u8 *tmp; |
| 1066 | 1075 | u32 freq; |
| 1067 | 1076 | int channel_number = -1; |
| 1077 | + struct ieee80211_channel *alt_channel; | |
| 1068 | 1078 | |
| 1069 | 1079 | tmp = cfg80211_find_ie(WLAN_EID_DS_PARAMS, ie, ielen); |
| 1070 | 1080 | if (tmp && tmp[1] == 1) { |
| @@ -1078,16 +1088,45 @@ cfg80211_get_bss_channel(struct wiphy *wiphy, const u8 *ie, size_t ielen, · 7 unmodified lines | ||
| 1078 | 1088 | } |
| 1079 | 1089 | } |
| 1080 | 1090 | |
| 1081 | − if (channel_number < 0) | |
| 1091 | + if (channel_number < 0) { | |
| 1092 | + /* No channel information in frame payload */ | |
| 1082 | 1093 | return channel; |
| 1094 | + } | |
| 1083 | 1095 | |
| 1084 | 1096 | freq = ieee80211_channel_to_frequency(channel_number, channel->band); |
| 1085 | − channel = ieee80211_get_channel(wiphy, freq); | |
| 1086 | − if (!channel) | |
| 1087 | − return NULL; | |
| 1088 | − if (channel->flags & IEEE80211_CHAN_DISABLED) | |
| 1097 | + alt_channel = ieee80211_get_channel(wiphy, freq); | |
| 1098 | + if (!alt_channel) { | |
| 1099 | + if (channel->band == NL80211_BAND_2GHZ) { | |
| 1100 | + /* | |
| 1101 | + * Better not allow unexpected channels when that could | |
| 1102 | + * be going beyond the 1-11 range (e.g., discovering | |
| 1103 | + * BSS on channel 12 when radio is configured for | |
| 1104 | + * channel 11. | |
| 1105 | + */ | |
| 1106 | + return NULL; | |
| 1107 | + } | |
| 1108 | + | |
| 1109 | + /* No match for the payload channel number - ignore it */ | |
| 1110 | + return channel; | |
| 1111 | + } | |
| 1112 | + | |
| 1113 | + if (scan_width == NL80211_BSS_CHAN_WIDTH_10 || | |
| 1114 | + scan_width == NL80211_BSS_CHAN_WIDTH_5) { | |
| 1115 | + /* | |
| 1116 | + * Ignore channel number in 5 and 10 MHz channels where there | |
| 1117 | + * may not be an n:1 or 1:n mapping between frequencies and | |
| 1118 | + * channel numbers. | |
| 1119 | + */ | |
| 1120 | + return channel; | |
| 1121 | + } | |
| 1122 | + | |
| 1123 | + /* | |
| 1124 | + * Use the channel determined through the payload channel number | |
| 1125 | + * instead of the RX channel reported by the driver. | |
| 1126 | + */ | |
| 1127 | + if (alt_channel->flags & IEEE80211_CHAN_DISABLED) | |
| 1089 | 1128 | return NULL; |
| 1090 | − return channel; | |
| 1129 | + return alt_channel; | |
| 1091 | 1130 | } |
| 1092 | 1131 | |
| 1093 | 1132 | /* Returned bss is reference counted and must be cleaned up appropriately. */ |
| @@ -1112,7 +1151,8 @@ cfg80211_inform_bss_data(struct wiphy *wiphy, · 18 unmodified lines | ||
| 1112 | 1151 | (data->signal < 0 || data->signal > 100))) |
| 1113 | 1152 | return NULL; |
| 1114 | 1153 | |
| 1115 | − channel = cfg80211_get_bss_channel(wiphy, ie, ielen, data->chan); | |
| 1154 | + channel = cfg80211_get_bss_channel(wiphy, ie, ielen, data->chan, | |
| 1155 | + data->scan_width); | |
| 1116 | 1156 | if (!channel) |
| 1117 | 1157 | return NULL; |
| 1118 | 1158 | |
| @@ -1210,7 +1250,7 @@ cfg80211_inform_bss_frame_data(struct wiphy *wiphy, · 91 unmodified lines | ||
| 1210 | 1250 | return NULL; |
| 1211 | 1251 | |
| 1212 | 1252 | channel = cfg80211_get_bss_channel(wiphy, mgmt->u.beacon.variable, |
| 1213 | − ielen, data->chan); | |
| 1253 | + ielen, data->chan, data->scan_width); | |
| 1214 | 1254 | if (!channel) |
| 1215 | 1255 | return NULL; |
| 1216 | 1256 | |
| @@ -1278,12 +1278,16 @@ static int cfg80211_wext_giwrate(struct net_device *dev, · 1277 unmodified lines | ||
| 1278 | 1278 | if (err) |
| 1279 | 1279 | return err; |
| 1280 | 1280 | |
| 1281 | − if (!(sinfo.filled & BIT_ULL(NL80211_STA_INFO_TX_BITRATE))) | |
| 1282 | − return -EOPNOTSUPP; | |
| 1281 | + if (!(sinfo.filled & BIT_ULL(NL80211_STA_INFO_TX_BITRATE))) { | |
| 1282 | + err = -EOPNOTSUPP; | |
| 1283 | + goto free; | |
| 1284 | + } | |
| 1283 | 1285 | |
| 1284 | 1286 | rate->value = 100000 * cfg80211_calculate_bitrate(&sinfo.txrate); |
| 1285 | 1287 | |
| 1286 | − return 0; | |
| 1288 | +free: | |
| 1289 | + cfg80211_sinfo_release_content(&sinfo); | |
| 1290 | + return err; | |
| 1287 | 1291 | } |
| 1288 | 1292 | |
| 1289 | 1293 | /* Get wireless statistics. Called by /proc/net/wireless and by SIOCGIWSTATS */ |
| @@ -1293,7 +1297,7 @@ static struct iw_statistics *cfg80211_wireless_stats(struct net_device *dev) · 3 unmodified lines | ||
| 1293 | 1297 | struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); |
| 1294 | 1298 | /* we are under RTNL - globally locked - so can use static structs */ |
| 1295 | 1299 | static struct iw_statistics wstats; |
| 1296 | − static struct station_info sinfo; | |
| 1300 | + static struct station_info sinfo = {}; | |
| 1297 | 1301 | u8 bssid[ETH_ALEN]; |
| 1298 | 1302 | |
| 1299 | 1303 | if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_STATION) |
| @@ -1352,6 +1356,8 @@ static struct iw_statistics *cfg80211_wireless_stats(struct net_device *dev) · 52 unmodified lines | ||
| 1352 | 1356 | if (sinfo.filled & BIT_ULL(NL80211_STA_INFO_TX_FAILED)) |
| 1353 | 1357 | wstats.discard.retries = sinfo.tx_failed; |
| 1354 | 1358 | |
| 1359 | + cfg80211_sinfo_release_content(&sinfo); | |
| 1360 | + | |
| 1355 | 1361 | return &wstats; |
| 1356 | 1362 | } |
| 1357 | 1363 | |
| @@ -458,6 +458,7 @@ resume: · 457 unmodified lines | ||
| 458 | 458 | XFRM_INC_STATS(net, LINUX_MIB_XFRMINHDRERROR); |
| 459 | 459 | goto drop; |
| 460 | 460 | } |
| 461 | + crypto_done = false; | |
| 461 | 462 | } while (!err); |
| 462 | 463 | |
| 463 | 464 | err = xfrm_rcv_cb(skb, family, x->type->proto, 0); |
| @@ -100,6 +100,10 @@ static int xfrm_output_one(struct sk_buff *skb, int err) · 99 unmodified lines | ||
| 100 | 100 | spin_unlock_bh(&x->lock); |
| 101 | 101 | |
| 102 | 102 | skb_dst_force(skb); |
| 103 | + if (!skb_dst(skb)) { | |
| 104 | + XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTERROR); | |
| 105 | + goto error_nolock; | |
| 106 | + } | |
| 103 | 107 | |
| 104 | 108 | if (xfrm_offload(skb)) { |
| 105 | 109 | x->type_offload->encap(x, skb); |
| @@ -2491,6 +2491,10 @@ int __xfrm_route_forward(struct sk_buff *skb, unsigned short family) · 2490 unmodified lines | ||
| 2491 | 2491 | } |
| 2492 | 2492 | |
| 2493 | 2493 | skb_dst_force(skb); |
| 2494 | + if (!skb_dst(skb)) { | |
| 2495 | + XFRM_INC_STATS(net, LINUX_MIB_XFRMFWDHDRERROR); | |
| 2496 | + return 0; | |
| 2497 | + } | |
| 2494 | 2498 | |
| 2495 | 2499 | dst = xfrm_lookup(net, skb_dst(skb), &fl, NULL, XFRM_LOOKUP_QUEUE); |
| 2496 | 2500 | if (IS_ERR(dst)) { |
| @@ -151,10 +151,16 @@ static int verify_newsa_info(struct xfrm_usersa_info *p, · 150 unmodified lines | ||
| 151 | 151 | err = -EINVAL; |
| 152 | 152 | switch (p->family) { |
| 153 | 153 | case AF_INET: |
| 154 | + if (p->sel.prefixlen_d > 32 || p->sel.prefixlen_s > 32) | |
| 155 | + goto out; | |
| 156 | + | |
| 154 | 157 | break; |
| 155 | 158 | |
| 156 | 159 | case AF_INET6: |
| 157 | 160 | #if IS_ENABLED(CONFIG_IPV6) |
| 161 | + if (p->sel.prefixlen_d > 128 || p->sel.prefixlen_s > 128) | |
| 162 | + goto out; | |
| 163 | + | |
| 158 | 164 | break; |
| 159 | 165 | #else |
| 160 | 166 | err = -EAFNOSUPPORT; |
| @@ -1396,10 +1402,16 @@ static int verify_newpolicy_info(struct xfrm_userpolicy_info *p) · 1235 unmodified lines | ||
| 1396 | 1402 | |
| 1397 | 1403 | switch (p->sel.family) { |
| 1398 | 1404 | case AF_INET: |
| 1405 | + if (p->sel.prefixlen_d > 32 || p->sel.prefixlen_s > 32) | |
| 1406 | + return -EINVAL; | |
| 1407 | + | |
| 1399 | 1408 | break; |
| 1400 | 1409 | |
| 1401 | 1410 | case AF_INET6: |
| 1402 | 1411 | #if IS_ENABLED(CONFIG_IPV6) |
| 1412 | + if (p->sel.prefixlen_d > 128 || p->sel.prefixlen_s > 128) | |
| 1413 | + return -EINVAL; | |
| 1414 | + | |
| 1403 | 1415 | break; |
| 1404 | 1416 | #else |
| 1405 | 1417 | return -EAFNOSUPPORT; |
| @@ -1480,6 +1492,9 @@ static int validate_tmpl(int nr, struct xfrm_user_tmpl *ut, u16 family) · 74 unmodified lines | ||
| 1480 | 1492 | (ut[i].family != prev_family)) |
| 1481 | 1493 | return -EINVAL; |
| 1482 | 1494 | |
| 1495 | + if (ut[i].mode >= XFRM_MODE_MAX) | |
| 1496 | + return -EINVAL; | |
| 1497 | + | |
| 1483 | 1498 | prev_family = ut[i].family; |
| 1484 | 1499 | |
| 1485 | 1500 | switch (ut[i].family) { |
| @@ -145,9 +145,11 @@ int snd_hdac_i915_init(struct hdac_bus *bus) · 144 unmodified lines | ||
| 145 | 145 | if (!acomp->ops) { |
| 146 | 146 | request_module("i915"); |
| 147 | 147 | /* 10s timeout */ |
| 148 | − wait_for_completion_timeout(&bind_complete, 10 * 1000); | |
| 148 | + wait_for_completion_timeout(&bind_complete, | |
| 149 | + msecs_to_jiffies(10 * 1000)); | |
| 149 | 150 | } |
| 150 | 151 | if (!acomp->ops) { |
| 152 | + dev_info(bus->dev, "couldn't bind with audio component\n"); | |
| 151 | 153 | snd_hdac_acomp_exit(bus); |
| 152 | 154 | return -ENODEV; |
| 153 | 155 | } |
| @@ -6409,6 +6409,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = { · 6408 unmodified lines | ||
| 6409 | 6409 | SND_PCI_QUIRK(0x1028, 0x0706, "Dell Inspiron 7559", ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER), |
| 6410 | 6410 | SND_PCI_QUIRK(0x1028, 0x0725, "Dell Inspiron 3162", ALC255_FIXUP_DELL_SPK_NOISE), |
| 6411 | 6411 | SND_PCI_QUIRK(0x1028, 0x075b, "Dell XPS 13 9360", ALC256_FIXUP_DELL_XPS_13_HEADPHONE_NOISE), |
| 6412 | + SND_PCI_QUIRK(0x1028, 0x075c, "Dell XPS 27 7760", ALC298_FIXUP_SPK_VOLUME), | |
| 6412 | 6413 | SND_PCI_QUIRK(0x1028, 0x075d, "Dell AIO", ALC298_FIXUP_SPK_VOLUME), |
| 6413 | 6414 | SND_PCI_QUIRK(0x1028, 0x07b0, "Dell Precision 7520", ALC295_FIXUP_DISABLE_DAC3), |
| 6414 | 6415 | SND_PCI_QUIRK(0x1028, 0x0798, "Dell Inspiron 17 7000 Gaming", ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER), |
| @@ -234,6 +234,7 @@ int main(int argc, char *argv[]) · 233 unmodified lines | ||
| 234 | 234 | break; |
| 235 | 235 | |
| 236 | 236 | default: |
| 237 | + error = HV_E_FAIL; | |
| 237 | 238 | syslog(LOG_ERR, "Unknown operation: %d", |
| 238 | 239 | buffer.hdr.operation); |
| 239 | 240 | |
| @@ -1325,7 +1325,7 @@ class Tui(object): · 1324 unmodified lines | ||
| 1325 | 1325 | msg = '' |
| 1326 | 1326 | while True: |
| 1327 | 1327 | self.screen.erase() |
| 1328 | − self.screen.addstr(0, 0, 'Set update interval (defaults to %fs).' % | |
| 1328 | + self.screen.addstr(0, 0, 'Set update interval (defaults to %.1fs).' % | |
| 1329 | 1329 | DELAY_DEFAULT, curses.A_BOLD) |
| 1330 | 1330 | self.screen.addstr(4, 0, msg) |
| 1331 | 1331 | self.screen.addstr(2, 0, 'Change delay from %.1fs to ' % |
| @@ -56,15 +56,13 @@ unsigned int yield_mod_cnt, nr_abort; · 55 unmodified lines | ||
| 56 | 56 | printf(fmt, ## __VA_ARGS__); \ |
| 57 | 57 | } while (0) |
| 58 | 58 | |
| 59 | −#if defined(__x86_64__) || defined(__i386__) | |
| 59 | +#ifdef __i386__ | |
| 60 | 60 | |
| 61 | 61 | #define INJECT_ASM_REG "eax" |
| 62 | 62 | |
| 63 | 63 | #define RSEQ_INJECT_CLOBBER \ |
| 64 | 64 | , INJECT_ASM_REG |
| 65 | 65 | |
| 66 | −#ifdef __i386__ | |
| 67 | − | |
| 68 | 66 | #define RSEQ_INJECT_ASM(n) \ |
| 69 | 67 | "mov asm_loop_cnt_" #n ", %%" INJECT_ASM_REG "\n\t" \ |
| 70 | 68 | "test %%" INJECT_ASM_REG ",%%" INJECT_ASM_REG "\n\t" \ |
| @@ -76,9 +74,16 @@ unsigned int yield_mod_cnt, nr_abort; · 5 unmodified lines | ||
| 76 | 74 | |
| 77 | 75 | #elif defined(__x86_64__) |
| 78 | 76 | |
| 77 | +#define INJECT_ASM_REG_P "rax" | |
| 78 | +#define INJECT_ASM_REG "eax" | |
| 79 | + | |
| 80 | +#define RSEQ_INJECT_CLOBBER \ | |
| 81 | + , INJECT_ASM_REG_P \ | |
| 82 | + , INJECT_ASM_REG | |
| 83 | + | |
| 79 | 84 | #define RSEQ_INJECT_ASM(n) \ |
| 80 | − "lea asm_loop_cnt_" #n "(%%rip), %%" INJECT_ASM_REG "\n\t" \ | |
| 81 | − "mov (%%" INJECT_ASM_REG "), %%" INJECT_ASM_REG "\n\t" \ | |
| 85 | + "lea asm_loop_cnt_" #n "(%%rip), %%" INJECT_ASM_REG_P "\n\t" \ | |
| 86 | + "mov (%%" INJECT_ASM_REG_P "), %%" INJECT_ASM_REG "\n\t" \ | |
| 82 | 87 | "test %%" INJECT_ASM_REG ",%%" INJECT_ASM_REG "\n\t" \ |
| 83 | 88 | "jz 333f\n\t" \ |
| 84 | 89 | "222:\n\t" \ |
| @@ -86,10 +91,6 @@ unsigned int yield_mod_cnt, nr_abort; · 1 unmodified line | ||
| 86 | 91 | "jnz 222b\n\t" \ |
| 87 | 92 | "333:\n\t" |
| 88 | 93 | |
| 89 | −#else | |
| 90 | −#error "Unsupported architecture" | |
| 91 | −#endif | |
| 92 | − | |
| 93 | 94 | #elif defined(__s390__) |
| 94 | 95 | |
| 95 | 96 | #define RSEQ_INJECT_INPUT \ |
| @@ -17,6 +17,7 @@ · 16 unmodified lines | ||
| 17 | 17 | #include <errno.h> |
| 18 | 18 | #include <sched.h> |
| 19 | 19 | #include <stdbool.h> |
| 20 | +#include <limits.h> | |
| 20 | 21 | |
| 21 | 22 | #ifndef SYS_getcpu |
| 22 | 23 | # ifdef __x86_64__ |
| @@ -31,6 +32,14 @@ · 8 unmodified lines | ||
| 31 | 32 | |
| 32 | 33 | int nerrs = 0; |
| 33 | 34 | |
| 35 | +typedef int (*vgettime_t)(clockid_t, struct timespec *); | |
| 36 | + | |
| 37 | +vgettime_t vdso_clock_gettime; | |
| 38 | + | |
| 39 | +typedef long (*vgtod_t)(struct timeval *tv, struct timezone *tz); | |
| 40 | + | |
| 41 | +vgtod_t vdso_gettimeofday; | |
| 42 | + | |
| 34 | 43 | typedef long (*getcpu_t)(unsigned *, unsigned *, void *); |
| 35 | 44 | |
| 36 | 45 | getcpu_t vgetcpu; |
| @@ -95,6 +104,15 @@ static void fill_function_pointers() · 58 unmodified lines | ||
| 95 | 104 | printf("Warning: failed to find getcpu in vDSO\n"); |
| 96 | 105 | |
| 97 | 106 | vgetcpu = (getcpu_t) vsyscall_getcpu(); |
| 107 | + | |
| 108 | + vdso_clock_gettime = (vgettime_t)dlsym(vdso, "__vdso_clock_gettime"); | |
| 109 | + if (!vdso_clock_gettime) | |
| 110 | + printf("Warning: failed to find clock_gettime in vDSO\n"); | |
| 111 | + | |
| 112 | + vdso_gettimeofday = (vgtod_t)dlsym(vdso, "__vdso_gettimeofday"); | |
| 113 | + if (!vdso_gettimeofday) | |
| 114 | + printf("Warning: failed to find gettimeofday in vDSO\n"); | |
| 115 | + | |
| 98 | 116 | } |
| 99 | 117 | |
| 100 | 118 | static long sys_getcpu(unsigned * cpu, unsigned * node, |
| @@ -103,6 +121,16 @@ static long sys_getcpu(unsigned * cpu, unsigned * node, · 2 unmodified lines | ||
| 103 | 121 | return syscall(__NR_getcpu, cpu, node, cache); |
| 104 | 122 | } |
| 105 | 123 | |
| 124 | +static inline int sys_clock_gettime(clockid_t id, struct timespec *ts) | |
| 125 | +{ | |
| 126 | + return syscall(__NR_clock_gettime, id, ts); | |
| 127 | +} | |
| 128 | + | |
| 129 | +static inline int sys_gettimeofday(struct timeval *tv, struct timezone *tz) | |
| 130 | +{ | |
| 131 | + return syscall(__NR_gettimeofday, tv, tz); | |
| 132 | +} | |
| 133 | + | |
| 106 | 134 | static void test_getcpu(void) |
| 107 | 135 | { |
| 108 | 136 | printf("[RUN]\tTesting getcpu...\n"); |
| @@ -155,10 +183,154 @@ static void test_getcpu(void) · 46 unmodified lines | ||
| 155 | 183 | } |
| 156 | 184 | } |
| 157 | 185 | |
| 186 | +static bool ts_leq(const struct timespec *a, const struct timespec *b) | |
| 187 | +{ | |
| 188 | + if (a->tv_sec != b->tv_sec) | |
| 189 | + return a->tv_sec < b->tv_sec; | |
| 190 | + else | |
| 191 | + return a->tv_nsec <= b->tv_nsec; | |
| 192 | +} | |
| 193 | + | |
| 194 | +static bool tv_leq(const struct timeval *a, const struct timeval *b) | |
| 195 | +{ | |
| 196 | + if (a->tv_sec != b->tv_sec) | |
| 197 | + return a->tv_sec < b->tv_sec; | |
| 198 | + else | |
| 199 | + return a->tv_usec <= b->tv_usec; | |
| 200 | +} | |
| 201 | + | |
| 202 | +static char const * const clocknames[] = { | |
| 203 | + [0] = "CLOCK_REALTIME", | |
| 204 | + [1] = "CLOCK_MONOTONIC", | |
| 205 | + [2] = "CLOCK_PROCESS_CPUTIME_ID", | |
| 206 | + [3] = "CLOCK_THREAD_CPUTIME_ID", | |
| 207 | + [4] = "CLOCK_MONOTONIC_RAW", | |
| 208 | + [5] = "CLOCK_REALTIME_COARSE", | |
| 209 | + [6] = "CLOCK_MONOTONIC_COARSE", | |
| 210 | + [7] = "CLOCK_BOOTTIME", | |
| 211 | + [8] = "CLOCK_REALTIME_ALARM", | |
| 212 | + [9] = "CLOCK_BOOTTIME_ALARM", | |
| 213 | + [10] = "CLOCK_SGI_CYCLE", | |
| 214 | + [11] = "CLOCK_TAI", | |
| 215 | +}; | |
| 216 | + | |
| 217 | +static void test_one_clock_gettime(int clock, const char *name) | |
| 218 | +{ | |
| 219 | + struct timespec start, vdso, end; | |
| 220 | + int vdso_ret, end_ret; | |
| 221 | + | |
| 222 | + printf("[RUN]\tTesting clock_gettime for clock %s (%d)...\n", name, clock); | |
| 223 | + | |
| 224 | + if (sys_clock_gettime(clock, &start) < 0) { | |
| 225 | + if (errno == EINVAL) { | |
| 226 | + vdso_ret = vdso_clock_gettime(clock, &vdso); | |
| 227 | + if (vdso_ret == -EINVAL) { | |
| 228 | + printf("[OK]\tNo such clock.\n"); | |
| 229 | + } else { | |
| 230 | + printf("[FAIL]\tNo such clock, but __vdso_clock_gettime returned %d\n", vdso_ret); | |
| 231 | + nerrs++; | |
| 232 | + } | |
| 233 | + } else { | |
| 234 | + printf("[WARN]\t clock_gettime(%d) syscall returned error %d\n", clock, errno); | |
| 235 | + } | |
| 236 | + return; | |
| 237 | + } | |
| 238 | + | |
| 239 | + vdso_ret = vdso_clock_gettime(clock, &vdso); | |
| 240 | + end_ret = sys_clock_gettime(clock, &end); | |
| 241 | + | |
| 242 | + if (vdso_ret != 0 || end_ret != 0) { | |
| 243 | + printf("[FAIL]\tvDSO returned %d, syscall errno=%d\n", | |
| 244 | + vdso_ret, errno); | |
| 245 | + nerrs++; | |
| 246 | + return; | |
| 247 | + } | |
| 248 | + | |
| 249 | + printf("\t%llu.%09ld %llu.%09ld %llu.%09ld\n", | |
| 250 | + (unsigned long long)start.tv_sec, start.tv_nsec, | |
| 251 | + (unsigned long long)vdso.tv_sec, vdso.tv_nsec, | |
| 252 | + (unsigned long long)end.tv_sec, end.tv_nsec); | |
| 253 | + | |
| 254 | + if (!ts_leq(&start, &vdso) || !ts_leq(&vdso, &end)) { | |
| 255 | + printf("[FAIL]\tTimes are out of sequence\n"); | |
| 256 | + nerrs++; | |
| 257 | + } | |
| 258 | +} | |
| 259 | + | |
| 260 | +static void test_clock_gettime(void) | |
| 261 | +{ | |
| 262 | + for (int clock = 0; clock < sizeof(clocknames) / sizeof(clocknames[0]); | |
| 263 | + clock++) { | |
| 264 | + test_one_clock_gettime(clock, clocknames[clock]); | |
| 265 | + } | |
| 266 | + | |
| 267 | + /* Also test some invalid clock ids */ | |
| 268 | + test_one_clock_gettime(-1, "invalid"); | |
| 269 | + test_one_clock_gettime(INT_MIN, "invalid"); | |
| 270 | + test_one_clock_gettime(INT_MAX, "invalid"); | |
| 271 | +} | |
| 272 | + | |
| 273 | +static void test_gettimeofday(void) | |
| 274 | +{ | |
| 275 | + struct timeval start, vdso, end; | |
| 276 | + struct timezone sys_tz, vdso_tz; | |
| 277 | + int vdso_ret, end_ret; | |
| 278 | + | |
| 279 | + if (!vdso_gettimeofday) | |
| 280 | + return; | |
| 281 | + | |
| 282 | + printf("[RUN]\tTesting gettimeofday...\n"); | |
| 283 | + | |
| 284 | + if (sys_gettimeofday(&start, &sys_tz) < 0) { | |
| 285 | + printf("[FAIL]\tsys_gettimeofday failed (%d)\n", errno); | |
| 286 | + nerrs++; | |
| 287 | + return; | |
| 288 | + } | |
| 289 | + | |
| 290 | + vdso_ret = vdso_gettimeofday(&vdso, &vdso_tz); | |
| 291 | + end_ret = sys_gettimeofday(&end, NULL); | |
| 292 | + | |
| 293 | + if (vdso_ret != 0 || end_ret != 0) { | |
| 294 | + printf("[FAIL]\tvDSO returned %d, syscall errno=%d\n", | |
| 295 | + vdso_ret, errno); | |
| 296 | + nerrs++; | |
| 297 | + return; | |
| 298 | + } | |
| 299 | + | |
| 300 | + printf("\t%llu.%06ld %llu.%06ld %llu.%06ld\n", | |
| 301 | + (unsigned long long)start.tv_sec, start.tv_usec, | |
| 302 | + (unsigned long long)vdso.tv_sec, vdso.tv_usec, | |
| 303 | + (unsigned long long)end.tv_sec, end.tv_usec); | |
| 304 | + | |
| 305 | + if (!tv_leq(&start, &vdso) || !tv_leq(&vdso, &end)) { | |
| 306 | + printf("[FAIL]\tTimes are out of sequence\n"); | |
| 307 | + nerrs++; | |
| 308 | + } | |
| 309 | + | |
| 310 | + if (sys_tz.tz_minuteswest == vdso_tz.tz_minuteswest && | |
| 311 | + sys_tz.tz_dsttime == vdso_tz.tz_dsttime) { | |
| 312 | + printf("[OK]\ttimezones match: minuteswest=%d, dsttime=%d\n", | |
| 313 | + sys_tz.tz_minuteswest, sys_tz.tz_dsttime); | |
| 314 | + } else { | |
| 315 | + printf("[FAIL]\ttimezones do not match\n"); | |
| 316 | + nerrs++; | |
| 317 | + } | |
| 318 | + | |
| 319 | + /* And make sure that passing NULL for tz doesn't crash. */ | |
| 320 | + vdso_gettimeofday(&vdso, NULL); | |
| 321 | +} | |
| 322 | + | |
| 158 | 323 | int main(int argc, char **argv) |
| 159 | 324 | { |
| 160 | 325 | fill_function_pointers(); |
| 161 | 326 | |
| 327 | + test_clock_gettime(); | |
| 328 | + test_gettimeofday(); | |
| 329 | + | |
| 330 | + /* | |
| 331 | + * Test getcpu() last so that, if something goes wrong setting affinity, | |
| 332 | + * we still run the other tests. | |
| 333 | + */ | |
| 162 | 334 | test_getcpu(); |
| 163 | 335 | |
| 164 | 336 | return nerrs ? 1 : 0; |