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

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

Conflict resolution of af_smc.c from Stephen Rothwell.

Signed-off-by: David S. Miller <davem@davemloft.net>

+3837 -1907
+24
.clang-format
··· 78 78 - 'ata_qc_for_each_with_internal' 79 79 - 'ax25_for_each' 80 80 - 'ax25_uid_for_each' 81 + - '__bio_for_each_bvec' 82 + - 'bio_for_each_bvec' 81 83 - 'bio_for_each_integrity_vec' 82 84 - '__bio_for_each_segment' 83 85 - 'bio_for_each_segment' ··· 120 118 - 'drm_for_each_legacy_plane' 121 119 - 'drm_for_each_plane' 122 120 - 'drm_for_each_plane_mask' 121 + - 'drm_for_each_privobj' 123 122 - 'drm_mm_for_each_hole' 124 123 - 'drm_mm_for_each_node' 125 124 - 'drm_mm_for_each_node_in_range' 126 125 - 'drm_mm_for_each_node_safe' 126 + - 'flow_action_for_each' 127 127 - 'for_each_active_drhd_unit' 128 128 - 'for_each_active_iommu' 129 129 - 'for_each_available_child_of_node' ··· 162 158 - 'for_each_dss_dev' 163 159 - 'for_each_efi_memory_desc' 164 160 - 'for_each_efi_memory_desc_in_map' 161 + - 'for_each_element' 162 + - 'for_each_element_extid' 163 + - 'for_each_element_id' 165 164 - 'for_each_endpoint_of_node' 166 165 - 'for_each_evictable_lru' 167 166 - 'for_each_fib6_node_rt_rcu' ··· 202 195 - 'for_each_net_rcu' 203 196 - 'for_each_new_connector_in_state' 204 197 - 'for_each_new_crtc_in_state' 198 + - 'for_each_new_mst_mgr_in_state' 205 199 - 'for_each_new_plane_in_state' 206 200 - 'for_each_new_private_obj_in_state' 207 201 - 'for_each_node' ··· 218 210 - 'for_each_of_pci_range' 219 211 - 'for_each_old_connector_in_state' 220 212 - 'for_each_old_crtc_in_state' 213 + - 'for_each_old_mst_mgr_in_state' 221 214 - 'for_each_oldnew_connector_in_state' 222 215 - 'for_each_oldnew_crtc_in_state' 216 + - 'for_each_oldnew_mst_mgr_in_state' 223 217 - 'for_each_oldnew_plane_in_state' 224 218 - 'for_each_oldnew_plane_in_state_reverse' 225 219 - 'for_each_oldnew_private_obj_in_state' ··· 253 243 - 'for_each_sg_dma_page' 254 244 - 'for_each_sg_page' 255 245 - 'for_each_sibling_event' 246 + - 'for_each_subelement' 247 + - 'for_each_subelement_extid' 248 + - 'for_each_subelement_id' 256 249 - '__for_each_thread' 257 250 - 'for_each_thread' 258 251 - 'for_each_zone' ··· 265 252 - 'fwnode_for_each_child_node' 266 253 - 'fwnode_graph_for_each_endpoint' 267 254 - 'gadget_for_each_ep' 255 + - 'genradix_for_each' 256 + - 'genradix_for_each_from' 268 257 - 'hash_for_each' 269 258 - 'hash_for_each_possible' 270 259 - 'hash_for_each_possible_rcu' ··· 308 293 - 'key_for_each' 309 294 - 'key_for_each_safe' 310 295 - 'klp_for_each_func' 296 + - 'klp_for_each_func_safe' 297 + - 'klp_for_each_func_static' 311 298 - 'klp_for_each_object' 299 + - 'klp_for_each_object_safe' 300 + - 'klp_for_each_object_static' 312 301 - 'kvm_for_each_memslot' 313 302 - 'kvm_for_each_vcpu' 314 303 - 'list_for_each' ··· 343 324 - 'media_device_for_each_intf' 344 325 - 'media_device_for_each_link' 345 326 - 'media_device_for_each_pad' 327 + - 'mp_bvec_for_each_page' 328 + - 'mp_bvec_for_each_segment' 346 329 - 'nanddev_io_for_each_page' 347 330 - 'netdev_for_each_lower_dev' 348 331 - 'netdev_for_each_lower_private' ··· 396 375 - 'rht_for_each_rcu' 397 376 - 'rht_for_each_rcu_from' 398 377 - '__rq_for_each_bio' 378 + - 'rq_for_each_bvec' 399 379 - 'rq_for_each_segment' 400 380 - 'scsi_for_each_prot_sg' 401 381 - 'scsi_for_each_sg' ··· 432 410 - 'v4l2_m2m_for_each_src_buf_safe' 433 411 - 'virtio_device_for_each_vq' 434 412 - 'xa_for_each' 413 + - 'xa_for_each_marked' 414 + - 'xa_for_each_start' 435 415 - 'xas_for_each' 436 416 - 'xas_for_each_conflict' 437 417 - 'xas_for_each_marked'
+9 -7
Documentation/networking/rxrpc.txt
··· 1009 1009 1010 1010 (*) Check call still alive. 1011 1011 1012 - u32 rxrpc_kernel_check_life(struct socket *sock, 1013 - struct rxrpc_call *call); 1012 + bool rxrpc_kernel_check_life(struct socket *sock, 1013 + struct rxrpc_call *call, 1014 + u32 *_life); 1014 1015 void rxrpc_kernel_probe_life(struct socket *sock, 1015 1016 struct rxrpc_call *call); 1016 1017 1017 - The first function returns a number that is updated when ACKs are received 1018 - from the peer (notably including PING RESPONSE ACKs which we can elicit by 1019 - sending PING ACKs to see if the call still exists on the server). The 1020 - caller should compare the numbers of two calls to see if the call is still 1021 - alive after waiting for a suitable interval. 1018 + The first function passes back in *_life a number that is updated when 1019 + ACKs are received from the peer (notably including PING RESPONSE ACKs 1020 + which we can elicit by sending PING ACKs to see if the call still exists 1021 + on the server). The caller should compare the numbers of two calls to see 1022 + if the call is still alive after waiting for a suitable interval. It also 1023 + returns true as long as the call hasn't yet reached the completed state. 1022 1024 1023 1025 This allows the caller to work out if the server is still contactable and 1024 1026 if the call is still alive on the server while waiting for the server to
+15 -2
MAINTAINERS
··· 10139 10139 F: Documentation/devicetree/bindings/mfd/atmel-usart.txt 10140 10140 10141 10141 MICROCHIP KSZ SERIES ETHERNET SWITCH DRIVER 10142 - M: Woojung Huh <Woojung.Huh@microchip.com> 10142 + M: Woojung Huh <woojung.huh@microchip.com> 10143 10143 M: Microchip Linux Driver Support <UNGLinuxDriver@microchip.com> 10144 10144 L: netdev@vger.kernel.org 10145 10145 S: Maintained ··· 16503 16503 F: include/linux/virtio_console.h 16504 16504 F: include/uapi/linux/virtio_console.h 16505 16505 16506 - VIRTIO CORE, NET AND BLOCK DRIVERS 16506 + VIRTIO CORE AND NET DRIVERS 16507 16507 M: "Michael S. Tsirkin" <mst@redhat.com> 16508 16508 M: Jason Wang <jasowang@redhat.com> 16509 16509 L: virtualization@lists.linux-foundation.org ··· 16517 16517 F: include/uapi/linux/virtio_*.h 16518 16518 F: drivers/crypto/virtio/ 16519 16519 F: mm/balloon_compaction.c 16520 + 16521 + VIRTIO BLOCK AND SCSI DRIVERS 16522 + M: "Michael S. Tsirkin" <mst@redhat.com> 16523 + M: Jason Wang <jasowang@redhat.com> 16524 + R: Paolo Bonzini <pbonzini@redhat.com> 16525 + R: Stefan Hajnoczi <stefanha@redhat.com> 16526 + L: virtualization@lists.linux-foundation.org 16527 + S: Maintained 16528 + F: drivers/block/virtio_blk.c 16529 + F: drivers/scsi/virtio_scsi.c 16530 + F: include/uapi/linux/virtio_blk.h 16531 + F: include/uapi/linux/virtio_scsi.h 16532 + F: drivers/vhost/scsi.c 16520 16533 16521 16534 VIRTIO CRYPTO DRIVER 16522 16535 M: Gonglei <arei.gonglei@huawei.com>
+1 -1
Makefile
··· 2 2 VERSION = 5 3 3 PATCHLEVEL = 1 4 4 SUBLEVEL = 0 5 - EXTRAVERSION = -rc4 5 + EXTRAVERSION = -rc5 6 6 NAME = Shy Crocodile 7 7 8 8 # *DOCUMENTATION*
+8 -8
arch/arm64/include/asm/futex.h
··· 30 30 " prfm pstl1strm, %2\n" \ 31 31 "1: ldxr %w1, %2\n" \ 32 32 insn "\n" \ 33 - "2: stlxr %w3, %w0, %2\n" \ 34 - " cbnz %w3, 1b\n" \ 33 + "2: stlxr %w0, %w3, %2\n" \ 34 + " cbnz %w0, 1b\n" \ 35 35 " dmb ish\n" \ 36 36 "3:\n" \ 37 37 " .pushsection .fixup,\"ax\"\n" \ ··· 50 50 static inline int 51 51 arch_futex_atomic_op_inuser(int op, int oparg, int *oval, u32 __user *_uaddr) 52 52 { 53 - int oldval = 0, ret, tmp; 53 + int oldval, ret, tmp; 54 54 u32 __user *uaddr = __uaccess_mask_ptr(_uaddr); 55 55 56 56 pagefault_disable(); 57 57 58 58 switch (op) { 59 59 case FUTEX_OP_SET: 60 - __futex_atomic_op("mov %w0, %w4", 60 + __futex_atomic_op("mov %w3, %w4", 61 61 ret, oldval, uaddr, tmp, oparg); 62 62 break; 63 63 case FUTEX_OP_ADD: 64 - __futex_atomic_op("add %w0, %w1, %w4", 64 + __futex_atomic_op("add %w3, %w1, %w4", 65 65 ret, oldval, uaddr, tmp, oparg); 66 66 break; 67 67 case FUTEX_OP_OR: 68 - __futex_atomic_op("orr %w0, %w1, %w4", 68 + __futex_atomic_op("orr %w3, %w1, %w4", 69 69 ret, oldval, uaddr, tmp, oparg); 70 70 break; 71 71 case FUTEX_OP_ANDN: 72 - __futex_atomic_op("and %w0, %w1, %w4", 72 + __futex_atomic_op("and %w3, %w1, %w4", 73 73 ret, oldval, uaddr, tmp, ~oparg); 74 74 break; 75 75 case FUTEX_OP_XOR: 76 - __futex_atomic_op("eor %w0, %w1, %w4", 76 + __futex_atomic_op("eor %w3, %w1, %w4", 77 77 ret, oldval, uaddr, tmp, oparg); 78 78 break; 79 79 default:
+5
arch/arm64/include/asm/module.h
··· 73 73 struct plt_entry get_plt_entry(u64 dst, void *pc); 74 74 bool plt_entries_equal(const struct plt_entry *a, const struct plt_entry *b); 75 75 76 + static inline bool plt_entry_is_initialized(const struct plt_entry *e) 77 + { 78 + return e->adrp || e->add || e->br; 79 + } 80 + 76 81 #endif /* __ASM_MODULE_H */
+1 -2
arch/arm64/kernel/ftrace.c
··· 107 107 trampoline = get_plt_entry(addr, mod->arch.ftrace_trampoline); 108 108 if (!plt_entries_equal(mod->arch.ftrace_trampoline, 109 109 &trampoline)) { 110 - if (!plt_entries_equal(mod->arch.ftrace_trampoline, 111 - &(struct plt_entry){})) { 110 + if (plt_entry_is_initialized(mod->arch.ftrace_trampoline)) { 112 111 pr_err("ftrace: far branches to multiple entry points unsupported inside a single module\n"); 113 112 return -EINVAL; 114 113 }
+9 -6
arch/arm64/kernel/traps.c
··· 102 102 void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk) 103 103 { 104 104 struct stackframe frame; 105 - int skip; 105 + int skip = 0; 106 106 107 107 pr_debug("%s(regs = %p tsk = %p)\n", __func__, regs, tsk); 108 + 109 + if (regs) { 110 + if (user_mode(regs)) 111 + return; 112 + skip = 1; 113 + } 108 114 109 115 if (!tsk) 110 116 tsk = current; ··· 132 126 frame.graph = 0; 133 127 #endif 134 128 135 - skip = !!regs; 136 129 printk("Call trace:\n"); 137 130 do { 138 131 /* skip until specified stack frame */ ··· 181 176 return ret; 182 177 183 178 print_modules(); 184 - __show_regs(regs); 185 179 pr_emerg("Process %.*s (pid: %d, stack limit = 0x%p)\n", 186 180 TASK_COMM_LEN, tsk->comm, task_pid_nr(tsk), 187 181 end_of_stack(tsk)); 182 + show_regs(regs); 188 183 189 - if (!user_mode(regs)) { 190 - dump_backtrace(regs, tsk); 184 + if (!user_mode(regs)) 191 185 dump_instr(KERN_EMERG, regs); 192 - } 193 186 194 187 return ret; 195 188 }
+8
arch/mips/configs/generic/board-ocelot.config
··· 1 1 # require CONFIG_CPU_MIPS32_R2=y 2 2 3 3 CONFIG_LEGACY_BOARD_OCELOT=y 4 + CONFIG_FIT_IMAGE_FDT_OCELOT=y 5 + 6 + CONFIG_BRIDGE=y 7 + CONFIG_GENERIC_PHY=y 4 8 5 9 CONFIG_MTD=y 6 10 CONFIG_MTD_CMDLINE_PARTS=y ··· 23 19 CONFIG_SERIAL_OF_PLATFORM=y 24 20 25 21 CONFIG_NETDEVICES=y 22 + CONFIG_NET_SWITCHDEV=y 23 + CONFIG_NET_DSA=y 26 24 CONFIG_MSCC_OCELOT_SWITCH=y 27 25 CONFIG_MSCC_OCELOT_SWITCH_OCELOT=y 28 26 CONFIG_MDIO_MSCC_MIIM=y ··· 40 34 CONFIG_SPI_DESIGNWARE=y 41 35 CONFIG_SPI_DW_MMIO=y 42 36 CONFIG_SPI_SPIDEV=y 37 + 38 + CONFIG_PINCTRL_OCELOT=y 43 39 44 40 CONFIG_GPIO_SYSFS=y 45 41
+2 -1
arch/mips/kernel/kgdb.c
··· 33 33 #include <asm/processor.h> 34 34 #include <asm/sigcontext.h> 35 35 #include <linux/uaccess.h> 36 + #include <asm/irq_regs.h> 36 37 37 38 static struct hard_trap_info { 38 39 unsigned char tt; /* Trap type code for MIPS R3xxx and R4xxx */ ··· 215 214 old_fs = get_fs(); 216 215 set_fs(KERNEL_DS); 217 216 218 - kgdb_nmicallback(raw_smp_processor_id(), NULL); 217 + kgdb_nmicallback(raw_smp_processor_id(), get_irq_regs()); 219 218 220 219 set_fs(old_fs); 221 220 }
+1 -2
arch/mips/sgi-ip27/ip27-irq.c
··· 118 118 { 119 119 struct hub_irq_data *hd = irq_data_get_irq_chip_data(d); 120 120 struct bridge_controller *bc; 121 - int pin = hd->pin; 122 121 123 122 if (!hd) 124 123 return; ··· 125 126 disable_hub_irq(d); 126 127 127 128 bc = hd->bc; 128 - bridge_clr(bc, b_int_enable, (1 << pin)); 129 + bridge_clr(bc, b_int_enable, (1 << hd->pin)); 129 130 bridge_read(bc, b_wid_tflush); 130 131 } 131 132
+1 -1
arch/powerpc/include/asm/mmu.h
··· 352 352 #if defined(CONFIG_SPARSEMEM_VMEMMAP) && defined(CONFIG_SPARSEMEM_EXTREME) && \ 353 353 defined (CONFIG_PPC_64K_PAGES) 354 354 #define MAX_PHYSMEM_BITS 51 355 - #elif defined(CONFIG_SPARSEMEM) 355 + #elif defined(CONFIG_PPC64) 356 356 #define MAX_PHYSMEM_BITS 46 357 357 #endif 358 358
+12
arch/powerpc/kernel/exceptions-64s.S
··· 656 656 ld r4,PACA_EXSLB+EX_DAR(r13) 657 657 std r4,_DAR(r1) 658 658 addi r3,r1,STACK_FRAME_OVERHEAD 659 + BEGIN_MMU_FTR_SECTION 660 + /* HPT case, do SLB fault */ 659 661 bl do_slb_fault 660 662 cmpdi r3,0 661 663 bne- 1f 662 664 b fast_exception_return 663 665 1: /* Error case */ 666 + MMU_FTR_SECTION_ELSE 667 + /* Radix case, access is outside page table range */ 668 + li r3,-EFAULT 669 + ALT_MMU_FTR_SECTION_END_IFCLR(MMU_FTR_TYPE_RADIX) 664 670 std r3,RESULT(r1) 665 671 bl save_nvgprs 666 672 RECONCILE_IRQ_STATE(r10, r11) ··· 711 705 EXCEPTION_PROLOG_COMMON(0x480, PACA_EXSLB) 712 706 ld r4,_NIP(r1) 713 707 addi r3,r1,STACK_FRAME_OVERHEAD 708 + BEGIN_MMU_FTR_SECTION 709 + /* HPT case, do SLB fault */ 714 710 bl do_slb_fault 715 711 cmpdi r3,0 716 712 bne- 1f 717 713 b fast_exception_return 718 714 1: /* Error case */ 715 + MMU_FTR_SECTION_ELSE 716 + /* Radix case, access is outside page table range */ 717 + li r3,-EFAULT 718 + ALT_MMU_FTR_SECTION_END_IFCLR(MMU_FTR_TYPE_RADIX) 719 719 std r3,RESULT(r1) 720 720 bl save_nvgprs 721 721 RECONCILE_IRQ_STATE(r10, r11)
-8
arch/powerpc/kernel/head_32.S
··· 851 851 tophys(r4,r2) 852 852 addi r4,r4,THREAD /* phys address of our thread_struct */ 853 853 mtspr SPRN_SPRG_THREAD,r4 854 - #ifdef CONFIG_PPC_RTAS 855 - li r3,0 856 - stw r3, RTAS_SP(r4) /* 0 => not in RTAS */ 857 - #endif 858 854 lis r4, (swapper_pg_dir - PAGE_OFFSET)@h 859 855 ori r4, r4, (swapper_pg_dir - PAGE_OFFSET)@l 860 856 mtspr SPRN_SPRG_PGDIR, r4 ··· 937 941 tophys(r4,r2) 938 942 addi r4,r4,THREAD /* init task's THREAD */ 939 943 mtspr SPRN_SPRG_THREAD,r4 940 - #ifdef CONFIG_PPC_RTAS 941 - li r3,0 942 - stw r3, RTAS_SP(r4) /* 0 => not in RTAS */ 943 - #endif 944 944 lis r4, (swapper_pg_dir - PAGE_OFFSET)@h 945 945 ori r4, r4, (swapper_pg_dir - PAGE_OFFSET)@l 946 946 mtspr SPRN_SPRG_PGDIR, r4
+1 -1
arch/powerpc/kernel/vdso32/gettimeofday.S
··· 98 98 * can be used, r7 contains NSEC_PER_SEC. 99 99 */ 100 100 101 - lwz r5,WTOM_CLOCK_SEC(r9) 101 + lwz r5,(WTOM_CLOCK_SEC+LOPART)(r9) 102 102 lwz r6,WTOM_CLOCK_NSEC(r9) 103 103 104 104 /* We now have our offset in r5,r6. We create a fake dependency
+84
arch/riscv/configs/rv32_defconfig
··· 1 + CONFIG_SYSVIPC=y 2 + CONFIG_POSIX_MQUEUE=y 3 + CONFIG_IKCONFIG=y 4 + CONFIG_IKCONFIG_PROC=y 5 + CONFIG_CGROUPS=y 6 + CONFIG_CGROUP_SCHED=y 7 + CONFIG_CFS_BANDWIDTH=y 8 + CONFIG_CGROUP_BPF=y 9 + CONFIG_NAMESPACES=y 10 + CONFIG_USER_NS=y 11 + CONFIG_CHECKPOINT_RESTORE=y 12 + CONFIG_BLK_DEV_INITRD=y 13 + CONFIG_EXPERT=y 14 + CONFIG_BPF_SYSCALL=y 15 + CONFIG_ARCH_RV32I=y 16 + CONFIG_SMP=y 17 + CONFIG_MODULES=y 18 + CONFIG_MODULE_UNLOAD=y 19 + CONFIG_NET=y 20 + CONFIG_PACKET=y 21 + CONFIG_UNIX=y 22 + CONFIG_INET=y 23 + CONFIG_IP_MULTICAST=y 24 + CONFIG_IP_ADVANCED_ROUTER=y 25 + CONFIG_IP_PNP=y 26 + CONFIG_IP_PNP_DHCP=y 27 + CONFIG_IP_PNP_BOOTP=y 28 + CONFIG_IP_PNP_RARP=y 29 + CONFIG_NETLINK_DIAG=y 30 + CONFIG_PCI=y 31 + CONFIG_PCIEPORTBUS=y 32 + CONFIG_PCI_HOST_GENERIC=y 33 + CONFIG_PCIE_XILINX=y 34 + CONFIG_DEVTMPFS=y 35 + CONFIG_BLK_DEV_LOOP=y 36 + CONFIG_VIRTIO_BLK=y 37 + CONFIG_BLK_DEV_SD=y 38 + CONFIG_BLK_DEV_SR=y 39 + CONFIG_ATA=y 40 + CONFIG_SATA_AHCI=y 41 + CONFIG_SATA_AHCI_PLATFORM=y 42 + CONFIG_NETDEVICES=y 43 + CONFIG_VIRTIO_NET=y 44 + CONFIG_MACB=y 45 + CONFIG_E1000E=y 46 + CONFIG_R8169=y 47 + CONFIG_MICROSEMI_PHY=y 48 + CONFIG_INPUT_MOUSEDEV=y 49 + CONFIG_SERIAL_8250=y 50 + CONFIG_SERIAL_8250_CONSOLE=y 51 + CONFIG_SERIAL_OF_PLATFORM=y 52 + CONFIG_SERIAL_EARLYCON_RISCV_SBI=y 53 + CONFIG_HVC_RISCV_SBI=y 54 + # CONFIG_PTP_1588_CLOCK is not set 55 + CONFIG_DRM=y 56 + CONFIG_DRM_RADEON=y 57 + CONFIG_FRAMEBUFFER_CONSOLE=y 58 + CONFIG_USB=y 59 + CONFIG_USB_XHCI_HCD=y 60 + CONFIG_USB_XHCI_PLATFORM=y 61 + CONFIG_USB_EHCI_HCD=y 62 + CONFIG_USB_EHCI_HCD_PLATFORM=y 63 + CONFIG_USB_OHCI_HCD=y 64 + CONFIG_USB_OHCI_HCD_PLATFORM=y 65 + CONFIG_USB_STORAGE=y 66 + CONFIG_USB_UAS=y 67 + CONFIG_VIRTIO_MMIO=y 68 + CONFIG_SIFIVE_PLIC=y 69 + CONFIG_EXT4_FS=y 70 + CONFIG_EXT4_FS_POSIX_ACL=y 71 + CONFIG_AUTOFS4_FS=y 72 + CONFIG_MSDOS_FS=y 73 + CONFIG_VFAT_FS=y 74 + CONFIG_TMPFS=y 75 + CONFIG_TMPFS_POSIX_ACL=y 76 + CONFIG_NFS_FS=y 77 + CONFIG_NFS_V4=y 78 + CONFIG_NFS_V4_1=y 79 + CONFIG_NFS_V4_2=y 80 + CONFIG_ROOT_NFS=y 81 + CONFIG_CRYPTO_USER_API_HASH=y 82 + CONFIG_CRYPTO_DEV_VIRTIO=y 83 + CONFIG_PRINTK_TIME=y 84 + # CONFIG_RCU_TRACE is not set
+8
arch/riscv/mm/init.c
··· 121 121 */ 122 122 memblock_reserve(reg->base, vmlinux_end - reg->base); 123 123 mem_size = min(reg->size, (phys_addr_t)-PAGE_OFFSET); 124 + 125 + /* 126 + * Remove memblock from the end of usable area to the 127 + * end of region 128 + */ 129 + if (reg->base + mem_size < end) 130 + memblock_remove(reg->base + mem_size, 131 + end - reg->base - mem_size); 124 132 } 125 133 } 126 134 BUG_ON(mem_size == 0);
+11 -9
arch/sparc/kernel/pci_sun4v.c
··· 73 73 p->npages = 0; 74 74 } 75 75 76 + static inline bool iommu_use_atu(struct iommu *iommu, u64 mask) 77 + { 78 + return iommu->atu && mask > DMA_BIT_MASK(32); 79 + } 80 + 76 81 /* Interrupts must be disabled. */ 77 82 static long iommu_batch_flush(struct iommu_batch *p, u64 mask) 78 83 { ··· 97 92 prot &= (HV_PCI_MAP_ATTR_READ | HV_PCI_MAP_ATTR_WRITE); 98 93 99 94 while (npages != 0) { 100 - if (mask <= DMA_BIT_MASK(32) || !pbm->iommu->atu) { 95 + if (!iommu_use_atu(pbm->iommu, mask)) { 101 96 num = pci_sun4v_iommu_map(devhandle, 102 97 HV_PCI_TSBID(0, entry), 103 98 npages, ··· 184 179 unsigned long flags, order, first_page, npages, n; 185 180 unsigned long prot = 0; 186 181 struct iommu *iommu; 187 - struct atu *atu; 188 182 struct iommu_map_table *tbl; 189 183 struct page *page; 190 184 void *ret; ··· 209 205 memset((char *)first_page, 0, PAGE_SIZE << order); 210 206 211 207 iommu = dev->archdata.iommu; 212 - atu = iommu->atu; 213 - 214 208 mask = dev->coherent_dma_mask; 215 - if (mask <= DMA_BIT_MASK(32) || !atu) 209 + if (!iommu_use_atu(iommu, mask)) 216 210 tbl = &iommu->tbl; 217 211 else 218 - tbl = &atu->tbl; 212 + tbl = &iommu->atu->tbl; 219 213 220 214 entry = iommu_tbl_range_alloc(dev, tbl, npages, NULL, 221 215 (unsigned long)(-1), 0); ··· 335 333 atu = iommu->atu; 336 334 devhandle = pbm->devhandle; 337 335 338 - if (dvma <= DMA_BIT_MASK(32)) { 336 + if (!iommu_use_atu(iommu, dvma)) { 339 337 tbl = &iommu->tbl; 340 338 iotsb_num = 0; /* we don't care for legacy iommu */ 341 339 } else { ··· 376 374 npages >>= IO_PAGE_SHIFT; 377 375 378 376 mask = *dev->dma_mask; 379 - if (mask <= DMA_BIT_MASK(32)) 377 + if (!iommu_use_atu(iommu, mask)) 380 378 tbl = &iommu->tbl; 381 379 else 382 380 tbl = &atu->tbl; ··· 512 510 IO_PAGE_SIZE) >> IO_PAGE_SHIFT; 513 511 514 512 mask = *dev->dma_mask; 515 - if (mask <= DMA_BIT_MASK(32)) 513 + if (!iommu_use_atu(iommu, mask)) 516 514 tbl = &iommu->tbl; 517 515 else 518 516 tbl = &atu->tbl;
+135 -5
arch/x86/events/amd/core.c
··· 3 3 #include <linux/types.h> 4 4 #include <linux/init.h> 5 5 #include <linux/slab.h> 6 + #include <linux/delay.h> 6 7 #include <asm/apicdef.h> 8 + #include <asm/nmi.h> 7 9 8 10 #include "../perf_event.h" 11 + 12 + static DEFINE_PER_CPU(unsigned int, perf_nmi_counter); 9 13 10 14 static __initconst const u64 amd_hw_cache_event_ids 11 15 [PERF_COUNT_HW_CACHE_MAX] ··· 433 429 } 434 430 } 435 431 432 + /* 433 + * When a PMC counter overflows, an NMI is used to process the event and 434 + * reset the counter. NMI latency can result in the counter being updated 435 + * before the NMI can run, which can result in what appear to be spurious 436 + * NMIs. This function is intended to wait for the NMI to run and reset 437 + * the counter to avoid possible unhandled NMI messages. 438 + */ 439 + #define OVERFLOW_WAIT_COUNT 50 440 + 441 + static void amd_pmu_wait_on_overflow(int idx) 442 + { 443 + unsigned int i; 444 + u64 counter; 445 + 446 + /* 447 + * Wait for the counter to be reset if it has overflowed. This loop 448 + * should exit very, very quickly, but just in case, don't wait 449 + * forever... 450 + */ 451 + for (i = 0; i < OVERFLOW_WAIT_COUNT; i++) { 452 + rdmsrl(x86_pmu_event_addr(idx), counter); 453 + if (counter & (1ULL << (x86_pmu.cntval_bits - 1))) 454 + break; 455 + 456 + /* Might be in IRQ context, so can't sleep */ 457 + udelay(1); 458 + } 459 + } 460 + 461 + static void amd_pmu_disable_all(void) 462 + { 463 + struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events); 464 + int idx; 465 + 466 + x86_pmu_disable_all(); 467 + 468 + /* 469 + * This shouldn't be called from NMI context, but add a safeguard here 470 + * to return, since if we're in NMI context we can't wait for an NMI 471 + * to reset an overflowed counter value. 472 + */ 473 + if (in_nmi()) 474 + return; 475 + 476 + /* 477 + * Check each counter for overflow and wait for it to be reset by the 478 + * NMI if it has overflowed. This relies on the fact that all active 479 + * counters are always enabled when this function is caled and 480 + * ARCH_PERFMON_EVENTSEL_INT is always set. 481 + */ 482 + for (idx = 0; idx < x86_pmu.num_counters; idx++) { 483 + if (!test_bit(idx, cpuc->active_mask)) 484 + continue; 485 + 486 + amd_pmu_wait_on_overflow(idx); 487 + } 488 + } 489 + 490 + static void amd_pmu_disable_event(struct perf_event *event) 491 + { 492 + x86_pmu_disable_event(event); 493 + 494 + /* 495 + * This can be called from NMI context (via x86_pmu_stop). The counter 496 + * may have overflowed, but either way, we'll never see it get reset 497 + * by the NMI if we're already in the NMI. And the NMI latency support 498 + * below will take care of any pending NMI that might have been 499 + * generated by the overflow. 500 + */ 501 + if (in_nmi()) 502 + return; 503 + 504 + amd_pmu_wait_on_overflow(event->hw.idx); 505 + } 506 + 507 + /* 508 + * Because of NMI latency, if multiple PMC counters are active or other sources 509 + * of NMIs are received, the perf NMI handler can handle one or more overflowed 510 + * PMC counters outside of the NMI associated with the PMC overflow. If the NMI 511 + * doesn't arrive at the LAPIC in time to become a pending NMI, then the kernel 512 + * back-to-back NMI support won't be active. This PMC handler needs to take into 513 + * account that this can occur, otherwise this could result in unknown NMI 514 + * messages being issued. Examples of this is PMC overflow while in the NMI 515 + * handler when multiple PMCs are active or PMC overflow while handling some 516 + * other source of an NMI. 517 + * 518 + * Attempt to mitigate this by using the number of active PMCs to determine 519 + * whether to return NMI_HANDLED if the perf NMI handler did not handle/reset 520 + * any PMCs. The per-CPU perf_nmi_counter variable is set to a minimum of the 521 + * number of active PMCs or 2. The value of 2 is used in case an NMI does not 522 + * arrive at the LAPIC in time to be collapsed into an already pending NMI. 523 + */ 524 + static int amd_pmu_handle_irq(struct pt_regs *regs) 525 + { 526 + struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events); 527 + int active, handled; 528 + 529 + /* 530 + * Obtain the active count before calling x86_pmu_handle_irq() since 531 + * it is possible that x86_pmu_handle_irq() may make a counter 532 + * inactive (through x86_pmu_stop). 533 + */ 534 + active = __bitmap_weight(cpuc->active_mask, X86_PMC_IDX_MAX); 535 + 536 + /* Process any counter overflows */ 537 + handled = x86_pmu_handle_irq(regs); 538 + 539 + /* 540 + * If a counter was handled, record the number of possible remaining 541 + * NMIs that can occur. 542 + */ 543 + if (handled) { 544 + this_cpu_write(perf_nmi_counter, 545 + min_t(unsigned int, 2, active)); 546 + 547 + return handled; 548 + } 549 + 550 + if (!this_cpu_read(perf_nmi_counter)) 551 + return NMI_DONE; 552 + 553 + this_cpu_dec(perf_nmi_counter); 554 + 555 + return NMI_HANDLED; 556 + } 557 + 436 558 static struct event_constraint * 437 559 amd_get_event_constraints(struct cpu_hw_events *cpuc, int idx, 438 560 struct perf_event *event) ··· 751 621 752 622 static __initconst const struct x86_pmu amd_pmu = { 753 623 .name = "AMD", 754 - .handle_irq = x86_pmu_handle_irq, 755 - .disable_all = x86_pmu_disable_all, 624 + .handle_irq = amd_pmu_handle_irq, 625 + .disable_all = amd_pmu_disable_all, 756 626 .enable_all = x86_pmu_enable_all, 757 627 .enable = x86_pmu_enable_event, 758 - .disable = x86_pmu_disable_event, 628 + .disable = amd_pmu_disable_event, 759 629 .hw_config = amd_pmu_hw_config, 760 630 .schedule_events = x86_schedule_events, 761 631 .eventsel = MSR_K7_EVNTSEL0, ··· 862 732 cpuc->perf_ctr_virt_mask = 0; 863 733 864 734 /* Reload all events */ 865 - x86_pmu_disable_all(); 735 + amd_pmu_disable_all(); 866 736 x86_pmu_enable_all(0); 867 737 } 868 738 EXPORT_SYMBOL_GPL(amd_pmu_enable_virt); ··· 880 750 cpuc->perf_ctr_virt_mask = AMD64_EVENTSEL_HOSTONLY; 881 751 882 752 /* Reload all events */ 883 - x86_pmu_disable_all(); 753 + amd_pmu_disable_all(); 884 754 x86_pmu_enable_all(0); 885 755 } 886 756 EXPORT_SYMBOL_GPL(amd_pmu_disable_virt);
+3 -10
arch/x86/events/core.c
··· 1349 1349 struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events); 1350 1350 struct hw_perf_event *hwc = &event->hw; 1351 1351 1352 - if (__test_and_clear_bit(hwc->idx, cpuc->active_mask)) { 1352 + if (test_bit(hwc->idx, cpuc->active_mask)) { 1353 1353 x86_pmu.disable(event); 1354 + __clear_bit(hwc->idx, cpuc->active_mask); 1354 1355 cpuc->events[hwc->idx] = NULL; 1355 1356 WARN_ON_ONCE(hwc->state & PERF_HES_STOPPED); 1356 1357 hwc->state |= PERF_HES_STOPPED; ··· 1448 1447 apic_write(APIC_LVTPC, APIC_DM_NMI); 1449 1448 1450 1449 for (idx = 0; idx < x86_pmu.num_counters; idx++) { 1451 - if (!test_bit(idx, cpuc->active_mask)) { 1452 - /* 1453 - * Though we deactivated the counter some cpus 1454 - * might still deliver spurious interrupts still 1455 - * in flight. Catch them: 1456 - */ 1457 - if (__test_and_clear_bit(idx, cpuc->running)) 1458 - handled++; 1450 + if (!test_bit(idx, cpuc->active_mask)) 1459 1451 continue; 1460 - } 1461 1452 1462 1453 event = cpuc->events[idx]; 1463 1454
+7 -1
arch/x86/events/intel/core.c
··· 3185 3185 return ret; 3186 3186 3187 3187 if (event->attr.precise_ip) { 3188 - if (!event->attr.freq) { 3188 + if (!(event->attr.freq || event->attr.wakeup_events)) { 3189 3189 event->hw.flags |= PERF_X86_EVENT_AUTO_RELOAD; 3190 3190 if (!(event->attr.sample_type & 3191 3191 ~intel_pmu_large_pebs_flags(event))) ··· 3574 3574 intel_pmu_lbr_reset(); 3575 3575 3576 3576 cpuc->lbr_sel = NULL; 3577 + 3578 + if (x86_pmu.flags & PMU_FL_TFA) { 3579 + WARN_ON_ONCE(cpuc->tfa_shadow); 3580 + cpuc->tfa_shadow = ~0ULL; 3581 + intel_set_tfa(cpuc, false); 3582 + } 3577 3583 3578 3584 if (x86_pmu.version > 1) 3579 3585 flip_smm_bit(&x86_pmu.attr_freeze_on_smi);
+18 -23
arch/x86/include/asm/bitops.h
··· 36 36 * bit 0 is the LSB of addr; bit 32 is the LSB of (addr+1). 37 37 */ 38 38 39 - #define BITOP_ADDR(x) "+m" (*(volatile long *) (x)) 39 + #define RLONG_ADDR(x) "m" (*(volatile long *) (x)) 40 + #define WBYTE_ADDR(x) "+m" (*(volatile char *) (x)) 40 41 41 - #define ADDR BITOP_ADDR(addr) 42 + #define ADDR RLONG_ADDR(addr) 42 43 43 44 /* 44 45 * We do the locked ops that don't return the old value as 45 46 * a mask operation on a byte. 46 47 */ 47 48 #define IS_IMMEDIATE(nr) (__builtin_constant_p(nr)) 48 - #define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((void *)(addr) + ((nr)>>3)) 49 + #define CONST_MASK_ADDR(nr, addr) WBYTE_ADDR((void *)(addr) + ((nr)>>3)) 49 50 #define CONST_MASK(nr) (1 << ((nr) & 7)) 50 51 51 52 /** ··· 74 73 : "memory"); 75 74 } else { 76 75 asm volatile(LOCK_PREFIX __ASM_SIZE(bts) " %1,%0" 77 - : BITOP_ADDR(addr) : "Ir" (nr) : "memory"); 76 + : : RLONG_ADDR(addr), "Ir" (nr) : "memory"); 78 77 } 79 78 } 80 79 ··· 89 88 */ 90 89 static __always_inline void __set_bit(long nr, volatile unsigned long *addr) 91 90 { 92 - asm volatile(__ASM_SIZE(bts) " %1,%0" : ADDR : "Ir" (nr) : "memory"); 91 + asm volatile(__ASM_SIZE(bts) " %1,%0" : : ADDR, "Ir" (nr) : "memory"); 93 92 } 94 93 95 94 /** ··· 111 110 : "iq" ((u8)~CONST_MASK(nr))); 112 111 } else { 113 112 asm volatile(LOCK_PREFIX __ASM_SIZE(btr) " %1,%0" 114 - : BITOP_ADDR(addr) 115 - : "Ir" (nr)); 113 + : : RLONG_ADDR(addr), "Ir" (nr) : "memory"); 116 114 } 117 115 } 118 116 ··· 131 131 132 132 static __always_inline void __clear_bit(long nr, volatile unsigned long *addr) 133 133 { 134 - asm volatile(__ASM_SIZE(btr) " %1,%0" : ADDR : "Ir" (nr)); 134 + asm volatile(__ASM_SIZE(btr) " %1,%0" : : ADDR, "Ir" (nr) : "memory"); 135 135 } 136 136 137 137 static __always_inline bool clear_bit_unlock_is_negative_byte(long nr, volatile unsigned long *addr) ··· 139 139 bool negative; 140 140 asm volatile(LOCK_PREFIX "andb %2,%1" 141 141 CC_SET(s) 142 - : CC_OUT(s) (negative), ADDR 142 + : CC_OUT(s) (negative), WBYTE_ADDR(addr) 143 143 : "ir" ((char) ~(1 << nr)) : "memory"); 144 144 return negative; 145 145 } ··· 155 155 * __clear_bit() is non-atomic and implies release semantics before the memory 156 156 * operation. It can be used for an unlock if no other CPUs can concurrently 157 157 * modify other bits in the word. 158 - * 159 - * No memory barrier is required here, because x86 cannot reorder stores past 160 - * older loads. Same principle as spin_unlock. 161 158 */ 162 159 static __always_inline void __clear_bit_unlock(long nr, volatile unsigned long *addr) 163 160 { 164 - barrier(); 165 161 __clear_bit(nr, addr); 166 162 } 167 163 ··· 172 176 */ 173 177 static __always_inline void __change_bit(long nr, volatile unsigned long *addr) 174 178 { 175 - asm volatile(__ASM_SIZE(btc) " %1,%0" : ADDR : "Ir" (nr)); 179 + asm volatile(__ASM_SIZE(btc) " %1,%0" : : ADDR, "Ir" (nr) : "memory"); 176 180 } 177 181 178 182 /** ··· 192 196 : "iq" ((u8)CONST_MASK(nr))); 193 197 } else { 194 198 asm volatile(LOCK_PREFIX __ASM_SIZE(btc) " %1,%0" 195 - : BITOP_ADDR(addr) 196 - : "Ir" (nr)); 199 + : : RLONG_ADDR(addr), "Ir" (nr) : "memory"); 197 200 } 198 201 } 199 202 ··· 237 242 238 243 asm(__ASM_SIZE(bts) " %2,%1" 239 244 CC_SET(c) 240 - : CC_OUT(c) (oldbit), ADDR 241 - : "Ir" (nr)); 245 + : CC_OUT(c) (oldbit) 246 + : ADDR, "Ir" (nr) : "memory"); 242 247 return oldbit; 243 248 } 244 249 ··· 277 282 278 283 asm volatile(__ASM_SIZE(btr) " %2,%1" 279 284 CC_SET(c) 280 - : CC_OUT(c) (oldbit), ADDR 281 - : "Ir" (nr)); 285 + : CC_OUT(c) (oldbit) 286 + : ADDR, "Ir" (nr) : "memory"); 282 287 return oldbit; 283 288 } 284 289 ··· 289 294 290 295 asm volatile(__ASM_SIZE(btc) " %2,%1" 291 296 CC_SET(c) 292 - : CC_OUT(c) (oldbit), ADDR 293 - : "Ir" (nr) : "memory"); 297 + : CC_OUT(c) (oldbit) 298 + : ADDR, "Ir" (nr) : "memory"); 294 299 295 300 return oldbit; 296 301 } ··· 321 326 asm volatile(__ASM_SIZE(bt) " %2,%1" 322 327 CC_SET(c) 323 328 : CC_OUT(c) (oldbit) 324 - : "m" (*(unsigned long *)addr), "Ir" (nr)); 329 + : "m" (*(unsigned long *)addr), "Ir" (nr) : "memory"); 325 330 326 331 return oldbit; 327 332 }
+3 -1
arch/x86/include/asm/kvm_emulate.h
··· 226 226 227 227 unsigned (*get_hflags)(struct x86_emulate_ctxt *ctxt); 228 228 void (*set_hflags)(struct x86_emulate_ctxt *ctxt, unsigned hflags); 229 - int (*pre_leave_smm)(struct x86_emulate_ctxt *ctxt, u64 smbase); 229 + int (*pre_leave_smm)(struct x86_emulate_ctxt *ctxt, 230 + const char *smstate); 231 + void (*post_leave_smm)(struct x86_emulate_ctxt *ctxt); 230 232 231 233 }; 232 234
+10 -7
arch/x86/include/asm/kvm_host.h
··· 126 126 } 127 127 128 128 #define KVM_PERMILLE_MMU_PAGES 20 129 - #define KVM_MIN_ALLOC_MMU_PAGES 64 129 + #define KVM_MIN_ALLOC_MMU_PAGES 64UL 130 130 #define KVM_MMU_HASH_SHIFT 12 131 131 #define KVM_NUM_MMU_PAGES (1 << KVM_MMU_HASH_SHIFT) 132 132 #define KVM_MIN_FREE_MMU_PAGES 5 ··· 844 844 }; 845 845 846 846 struct kvm_arch { 847 - unsigned int n_used_mmu_pages; 848 - unsigned int n_requested_mmu_pages; 849 - unsigned int n_max_mmu_pages; 847 + unsigned long n_used_mmu_pages; 848 + unsigned long n_requested_mmu_pages; 849 + unsigned long n_max_mmu_pages; 850 850 unsigned int indirect_shadow_pages; 851 851 struct hlist_head mmu_page_hash[KVM_NUM_MMU_PAGES]; 852 852 /* ··· 1182 1182 1183 1183 int (*smi_allowed)(struct kvm_vcpu *vcpu); 1184 1184 int (*pre_enter_smm)(struct kvm_vcpu *vcpu, char *smstate); 1185 - int (*pre_leave_smm)(struct kvm_vcpu *vcpu, u64 smbase); 1185 + int (*pre_leave_smm)(struct kvm_vcpu *vcpu, const char *smstate); 1186 1186 int (*enable_smi_window)(struct kvm_vcpu *vcpu); 1187 1187 1188 1188 int (*mem_enc_op)(struct kvm *kvm, void __user *argp); ··· 1256 1256 gfn_t gfn_offset, unsigned long mask); 1257 1257 void kvm_mmu_zap_all(struct kvm *kvm); 1258 1258 void kvm_mmu_invalidate_mmio_sptes(struct kvm *kvm, u64 gen); 1259 - unsigned int kvm_mmu_calculate_default_mmu_pages(struct kvm *kvm); 1260 - void kvm_mmu_change_mmu_pages(struct kvm *kvm, unsigned int kvm_nr_mmu_pages); 1259 + unsigned long kvm_mmu_calculate_default_mmu_pages(struct kvm *kvm); 1260 + void kvm_mmu_change_mmu_pages(struct kvm *kvm, unsigned long kvm_nr_mmu_pages); 1261 1261 1262 1262 int load_pdptrs(struct kvm_vcpu *vcpu, struct kvm_mmu *mmu, unsigned long cr3); 1263 1263 bool pdptrs_changed(struct kvm_vcpu *vcpu); ··· 1591 1591 1592 1592 #define put_smstate(type, buf, offset, val) \ 1593 1593 *(type *)((buf) + (offset) - 0x7e00) = val 1594 + 1595 + #define GET_SMSTATE(type, buf, offset) \ 1596 + (*(type *)((buf) + (offset) - 0x7e00)) 1594 1597 1595 1598 #endif /* _ASM_X86_KVM_HOST_H */
+1
arch/x86/include/uapi/asm/vmx.h
··· 146 146 147 147 #define VMX_ABORT_SAVE_GUEST_MSR_FAIL 1 148 148 #define VMX_ABORT_LOAD_HOST_PDPTE_FAIL 2 149 + #define VMX_ABORT_VMCS_CORRUPTED 3 149 150 #define VMX_ABORT_LOAD_HOST_MSR_FAIL 4 150 151 151 152 #endif /* _UAPIVMX_H */
+3 -3
arch/x86/kernel/cpu/resctrl/rdtgroup.c
··· 2039 2039 enum rdt_param { 2040 2040 Opt_cdp, 2041 2041 Opt_cdpl2, 2042 - Opt_mba_mpbs, 2042 + Opt_mba_mbps, 2043 2043 nr__rdt_params 2044 2044 }; 2045 2045 2046 2046 static const struct fs_parameter_spec rdt_param_specs[] = { 2047 2047 fsparam_flag("cdp", Opt_cdp), 2048 2048 fsparam_flag("cdpl2", Opt_cdpl2), 2049 - fsparam_flag("mba_mpbs", Opt_mba_mpbs), 2049 + fsparam_flag("mba_MBps", Opt_mba_mbps), 2050 2050 {} 2051 2051 }; 2052 2052 ··· 2072 2072 case Opt_cdpl2: 2073 2073 ctx->enable_cdpl2 = true; 2074 2074 return 0; 2075 - case Opt_mba_mpbs: 2075 + case Opt_mba_mbps: 2076 2076 if (boot_cpu_data.x86_vendor != X86_VENDOR_INTEL) 2077 2077 return -EINVAL; 2078 2078 ctx->enable_mba_mbps = true;
+102 -89
arch/x86/kvm/emulate.c
··· 2331 2331 2332 2332 static int emulator_has_longmode(struct x86_emulate_ctxt *ctxt) 2333 2333 { 2334 + #ifdef CONFIG_X86_64 2334 2335 u32 eax, ebx, ecx, edx; 2335 2336 2336 2337 eax = 0x80000001; 2337 2338 ecx = 0; 2338 2339 ctxt->ops->get_cpuid(ctxt, &eax, &ebx, &ecx, &edx, false); 2339 2340 return edx & bit(X86_FEATURE_LM); 2341 + #else 2342 + return false; 2343 + #endif 2340 2344 } 2341 - 2342 - #define GET_SMSTATE(type, smbase, offset) \ 2343 - ({ \ 2344 - type __val; \ 2345 - int r = ctxt->ops->read_phys(ctxt, smbase + offset, &__val, \ 2346 - sizeof(__val)); \ 2347 - if (r != X86EMUL_CONTINUE) \ 2348 - return X86EMUL_UNHANDLEABLE; \ 2349 - __val; \ 2350 - }) 2351 2345 2352 2346 static void rsm_set_desc_flags(struct desc_struct *desc, u32 flags) 2353 2347 { ··· 2355 2361 desc->type = (flags >> 8) & 15; 2356 2362 } 2357 2363 2358 - static int rsm_load_seg_32(struct x86_emulate_ctxt *ctxt, u64 smbase, int n) 2364 + static int rsm_load_seg_32(struct x86_emulate_ctxt *ctxt, const char *smstate, 2365 + int n) 2359 2366 { 2360 2367 struct desc_struct desc; 2361 2368 int offset; 2362 2369 u16 selector; 2363 2370 2364 - selector = GET_SMSTATE(u32, smbase, 0x7fa8 + n * 4); 2371 + selector = GET_SMSTATE(u32, smstate, 0x7fa8 + n * 4); 2365 2372 2366 2373 if (n < 3) 2367 2374 offset = 0x7f84 + n * 12; 2368 2375 else 2369 2376 offset = 0x7f2c + (n - 3) * 12; 2370 2377 2371 - set_desc_base(&desc, GET_SMSTATE(u32, smbase, offset + 8)); 2372 - set_desc_limit(&desc, GET_SMSTATE(u32, smbase, offset + 4)); 2373 - rsm_set_desc_flags(&desc, GET_SMSTATE(u32, smbase, offset)); 2378 + set_desc_base(&desc, GET_SMSTATE(u32, smstate, offset + 8)); 2379 + set_desc_limit(&desc, GET_SMSTATE(u32, smstate, offset + 4)); 2380 + rsm_set_desc_flags(&desc, GET_SMSTATE(u32, smstate, offset)); 2374 2381 ctxt->ops->set_segment(ctxt, selector, &desc, 0, n); 2375 2382 return X86EMUL_CONTINUE; 2376 2383 } 2377 2384 2378 - static int rsm_load_seg_64(struct x86_emulate_ctxt *ctxt, u64 smbase, int n) 2385 + #ifdef CONFIG_X86_64 2386 + static int rsm_load_seg_64(struct x86_emulate_ctxt *ctxt, const char *smstate, 2387 + int n) 2379 2388 { 2380 2389 struct desc_struct desc; 2381 2390 int offset; ··· 2387 2390 2388 2391 offset = 0x7e00 + n * 16; 2389 2392 2390 - selector = GET_SMSTATE(u16, smbase, offset); 2391 - rsm_set_desc_flags(&desc, GET_SMSTATE(u16, smbase, offset + 2) << 8); 2392 - set_desc_limit(&desc, GET_SMSTATE(u32, smbase, offset + 4)); 2393 - set_desc_base(&desc, GET_SMSTATE(u32, smbase, offset + 8)); 2394 - base3 = GET_SMSTATE(u32, smbase, offset + 12); 2393 + selector = GET_SMSTATE(u16, smstate, offset); 2394 + rsm_set_desc_flags(&desc, GET_SMSTATE(u16, smstate, offset + 2) << 8); 2395 + set_desc_limit(&desc, GET_SMSTATE(u32, smstate, offset + 4)); 2396 + set_desc_base(&desc, GET_SMSTATE(u32, smstate, offset + 8)); 2397 + base3 = GET_SMSTATE(u32, smstate, offset + 12); 2395 2398 2396 2399 ctxt->ops->set_segment(ctxt, selector, &desc, base3, n); 2397 2400 return X86EMUL_CONTINUE; 2398 2401 } 2402 + #endif 2399 2403 2400 2404 static int rsm_enter_protected_mode(struct x86_emulate_ctxt *ctxt, 2401 2405 u64 cr0, u64 cr3, u64 cr4) ··· 2443 2445 return X86EMUL_CONTINUE; 2444 2446 } 2445 2447 2446 - static int rsm_load_state_32(struct x86_emulate_ctxt *ctxt, u64 smbase) 2448 + static int rsm_load_state_32(struct x86_emulate_ctxt *ctxt, 2449 + const char *smstate) 2447 2450 { 2448 2451 struct desc_struct desc; 2449 2452 struct desc_ptr dt; ··· 2452 2453 u32 val, cr0, cr3, cr4; 2453 2454 int i; 2454 2455 2455 - cr0 = GET_SMSTATE(u32, smbase, 0x7ffc); 2456 - cr3 = GET_SMSTATE(u32, smbase, 0x7ff8); 2457 - ctxt->eflags = GET_SMSTATE(u32, smbase, 0x7ff4) | X86_EFLAGS_FIXED; 2458 - ctxt->_eip = GET_SMSTATE(u32, smbase, 0x7ff0); 2456 + cr0 = GET_SMSTATE(u32, smstate, 0x7ffc); 2457 + cr3 = GET_SMSTATE(u32, smstate, 0x7ff8); 2458 + ctxt->eflags = GET_SMSTATE(u32, smstate, 0x7ff4) | X86_EFLAGS_FIXED; 2459 + ctxt->_eip = GET_SMSTATE(u32, smstate, 0x7ff0); 2459 2460 2460 2461 for (i = 0; i < 8; i++) 2461 - *reg_write(ctxt, i) = GET_SMSTATE(u32, smbase, 0x7fd0 + i * 4); 2462 + *reg_write(ctxt, i) = GET_SMSTATE(u32, smstate, 0x7fd0 + i * 4); 2462 2463 2463 - val = GET_SMSTATE(u32, smbase, 0x7fcc); 2464 + val = GET_SMSTATE(u32, smstate, 0x7fcc); 2464 2465 ctxt->ops->set_dr(ctxt, 6, (val & DR6_VOLATILE) | DR6_FIXED_1); 2465 - val = GET_SMSTATE(u32, smbase, 0x7fc8); 2466 + val = GET_SMSTATE(u32, smstate, 0x7fc8); 2466 2467 ctxt->ops->set_dr(ctxt, 7, (val & DR7_VOLATILE) | DR7_FIXED_1); 2467 2468 2468 - selector = GET_SMSTATE(u32, smbase, 0x7fc4); 2469 - set_desc_base(&desc, GET_SMSTATE(u32, smbase, 0x7f64)); 2470 - set_desc_limit(&desc, GET_SMSTATE(u32, smbase, 0x7f60)); 2471 - rsm_set_desc_flags(&desc, GET_SMSTATE(u32, smbase, 0x7f5c)); 2469 + selector = GET_SMSTATE(u32, smstate, 0x7fc4); 2470 + set_desc_base(&desc, GET_SMSTATE(u32, smstate, 0x7f64)); 2471 + set_desc_limit(&desc, GET_SMSTATE(u32, smstate, 0x7f60)); 2472 + rsm_set_desc_flags(&desc, GET_SMSTATE(u32, smstate, 0x7f5c)); 2472 2473 ctxt->ops->set_segment(ctxt, selector, &desc, 0, VCPU_SREG_TR); 2473 2474 2474 - selector = GET_SMSTATE(u32, smbase, 0x7fc0); 2475 - set_desc_base(&desc, GET_SMSTATE(u32, smbase, 0x7f80)); 2476 - set_desc_limit(&desc, GET_SMSTATE(u32, smbase, 0x7f7c)); 2477 - rsm_set_desc_flags(&desc, GET_SMSTATE(u32, smbase, 0x7f78)); 2475 + selector = GET_SMSTATE(u32, smstate, 0x7fc0); 2476 + set_desc_base(&desc, GET_SMSTATE(u32, smstate, 0x7f80)); 2477 + set_desc_limit(&desc, GET_SMSTATE(u32, smstate, 0x7f7c)); 2478 + rsm_set_desc_flags(&desc, GET_SMSTATE(u32, smstate, 0x7f78)); 2478 2479 ctxt->ops->set_segment(ctxt, selector, &desc, 0, VCPU_SREG_LDTR); 2479 2480 2480 - dt.address = GET_SMSTATE(u32, smbase, 0x7f74); 2481 - dt.size = GET_SMSTATE(u32, smbase, 0x7f70); 2481 + dt.address = GET_SMSTATE(u32, smstate, 0x7f74); 2482 + dt.size = GET_SMSTATE(u32, smstate, 0x7f70); 2482 2483 ctxt->ops->set_gdt(ctxt, &dt); 2483 2484 2484 - dt.address = GET_SMSTATE(u32, smbase, 0x7f58); 2485 - dt.size = GET_SMSTATE(u32, smbase, 0x7f54); 2485 + dt.address = GET_SMSTATE(u32, smstate, 0x7f58); 2486 + dt.size = GET_SMSTATE(u32, smstate, 0x7f54); 2486 2487 ctxt->ops->set_idt(ctxt, &dt); 2487 2488 2488 2489 for (i = 0; i < 6; i++) { 2489 - int r = rsm_load_seg_32(ctxt, smbase, i); 2490 + int r = rsm_load_seg_32(ctxt, smstate, i); 2490 2491 if (r != X86EMUL_CONTINUE) 2491 2492 return r; 2492 2493 } 2493 2494 2494 - cr4 = GET_SMSTATE(u32, smbase, 0x7f14); 2495 + cr4 = GET_SMSTATE(u32, smstate, 0x7f14); 2495 2496 2496 - ctxt->ops->set_smbase(ctxt, GET_SMSTATE(u32, smbase, 0x7ef8)); 2497 + ctxt->ops->set_smbase(ctxt, GET_SMSTATE(u32, smstate, 0x7ef8)); 2497 2498 2498 2499 return rsm_enter_protected_mode(ctxt, cr0, cr3, cr4); 2499 2500 } 2500 2501 2501 - static int rsm_load_state_64(struct x86_emulate_ctxt *ctxt, u64 smbase) 2502 + #ifdef CONFIG_X86_64 2503 + static int rsm_load_state_64(struct x86_emulate_ctxt *ctxt, 2504 + const char *smstate) 2502 2505 { 2503 2506 struct desc_struct desc; 2504 2507 struct desc_ptr dt; ··· 2510 2509 int i, r; 2511 2510 2512 2511 for (i = 0; i < 16; i++) 2513 - *reg_write(ctxt, i) = GET_SMSTATE(u64, smbase, 0x7ff8 - i * 8); 2512 + *reg_write(ctxt, i) = GET_SMSTATE(u64, smstate, 0x7ff8 - i * 8); 2514 2513 2515 - ctxt->_eip = GET_SMSTATE(u64, smbase, 0x7f78); 2516 - ctxt->eflags = GET_SMSTATE(u32, smbase, 0x7f70) | X86_EFLAGS_FIXED; 2514 + ctxt->_eip = GET_SMSTATE(u64, smstate, 0x7f78); 2515 + ctxt->eflags = GET_SMSTATE(u32, smstate, 0x7f70) | X86_EFLAGS_FIXED; 2517 2516 2518 - val = GET_SMSTATE(u32, smbase, 0x7f68); 2517 + val = GET_SMSTATE(u32, smstate, 0x7f68); 2519 2518 ctxt->ops->set_dr(ctxt, 6, (val & DR6_VOLATILE) | DR6_FIXED_1); 2520 - val = GET_SMSTATE(u32, smbase, 0x7f60); 2519 + val = GET_SMSTATE(u32, smstate, 0x7f60); 2521 2520 ctxt->ops->set_dr(ctxt, 7, (val & DR7_VOLATILE) | DR7_FIXED_1); 2522 2521 2523 - cr0 = GET_SMSTATE(u64, smbase, 0x7f58); 2524 - cr3 = GET_SMSTATE(u64, smbase, 0x7f50); 2525 - cr4 = GET_SMSTATE(u64, smbase, 0x7f48); 2526 - ctxt->ops->set_smbase(ctxt, GET_SMSTATE(u32, smbase, 0x7f00)); 2527 - val = GET_SMSTATE(u64, smbase, 0x7ed0); 2522 + cr0 = GET_SMSTATE(u64, smstate, 0x7f58); 2523 + cr3 = GET_SMSTATE(u64, smstate, 0x7f50); 2524 + cr4 = GET_SMSTATE(u64, smstate, 0x7f48); 2525 + ctxt->ops->set_smbase(ctxt, GET_SMSTATE(u32, smstate, 0x7f00)); 2526 + val = GET_SMSTATE(u64, smstate, 0x7ed0); 2528 2527 ctxt->ops->set_msr(ctxt, MSR_EFER, val & ~EFER_LMA); 2529 2528 2530 - selector = GET_SMSTATE(u32, smbase, 0x7e90); 2531 - rsm_set_desc_flags(&desc, GET_SMSTATE(u32, smbase, 0x7e92) << 8); 2532 - set_desc_limit(&desc, GET_SMSTATE(u32, smbase, 0x7e94)); 2533 - set_desc_base(&desc, GET_SMSTATE(u32, smbase, 0x7e98)); 2534 - base3 = GET_SMSTATE(u32, smbase, 0x7e9c); 2529 + selector = GET_SMSTATE(u32, smstate, 0x7e90); 2530 + rsm_set_desc_flags(&desc, GET_SMSTATE(u32, smstate, 0x7e92) << 8); 2531 + set_desc_limit(&desc, GET_SMSTATE(u32, smstate, 0x7e94)); 2532 + set_desc_base(&desc, GET_SMSTATE(u32, smstate, 0x7e98)); 2533 + base3 = GET_SMSTATE(u32, smstate, 0x7e9c); 2535 2534 ctxt->ops->set_segment(ctxt, selector, &desc, base3, VCPU_SREG_TR); 2536 2535 2537 - dt.size = GET_SMSTATE(u32, smbase, 0x7e84); 2538 - dt.address = GET_SMSTATE(u64, smbase, 0x7e88); 2536 + dt.size = GET_SMSTATE(u32, smstate, 0x7e84); 2537 + dt.address = GET_SMSTATE(u64, smstate, 0x7e88); 2539 2538 ctxt->ops->set_idt(ctxt, &dt); 2540 2539 2541 - selector = GET_SMSTATE(u32, smbase, 0x7e70); 2542 - rsm_set_desc_flags(&desc, GET_SMSTATE(u32, smbase, 0x7e72) << 8); 2543 - set_desc_limit(&desc, GET_SMSTATE(u32, smbase, 0x7e74)); 2544 - set_desc_base(&desc, GET_SMSTATE(u32, smbase, 0x7e78)); 2545 - base3 = GET_SMSTATE(u32, smbase, 0x7e7c); 2540 + selector = GET_SMSTATE(u32, smstate, 0x7e70); 2541 + rsm_set_desc_flags(&desc, GET_SMSTATE(u32, smstate, 0x7e72) << 8); 2542 + set_desc_limit(&desc, GET_SMSTATE(u32, smstate, 0x7e74)); 2543 + set_desc_base(&desc, GET_SMSTATE(u32, smstate, 0x7e78)); 2544 + base3 = GET_SMSTATE(u32, smstate, 0x7e7c); 2546 2545 ctxt->ops->set_segment(ctxt, selector, &desc, base3, VCPU_SREG_LDTR); 2547 2546 2548 - dt.size = GET_SMSTATE(u32, smbase, 0x7e64); 2549 - dt.address = GET_SMSTATE(u64, smbase, 0x7e68); 2547 + dt.size = GET_SMSTATE(u32, smstate, 0x7e64); 2548 + dt.address = GET_SMSTATE(u64, smstate, 0x7e68); 2550 2549 ctxt->ops->set_gdt(ctxt, &dt); 2551 2550 2552 2551 r = rsm_enter_protected_mode(ctxt, cr0, cr3, cr4); ··· 2554 2553 return r; 2555 2554 2556 2555 for (i = 0; i < 6; i++) { 2557 - r = rsm_load_seg_64(ctxt, smbase, i); 2556 + r = rsm_load_seg_64(ctxt, smstate, i); 2558 2557 if (r != X86EMUL_CONTINUE) 2559 2558 return r; 2560 2559 } 2561 2560 2562 2561 return X86EMUL_CONTINUE; 2563 2562 } 2563 + #endif 2564 2564 2565 2565 static int em_rsm(struct x86_emulate_ctxt *ctxt) 2566 2566 { 2567 2567 unsigned long cr0, cr4, efer; 2568 + char buf[512]; 2568 2569 u64 smbase; 2569 2570 int ret; 2570 2571 2571 2572 if ((ctxt->ops->get_hflags(ctxt) & X86EMUL_SMM_MASK) == 0) 2572 2573 return emulate_ud(ctxt); 2573 2574 2575 + smbase = ctxt->ops->get_smbase(ctxt); 2576 + 2577 + ret = ctxt->ops->read_phys(ctxt, smbase + 0xfe00, buf, sizeof(buf)); 2578 + if (ret != X86EMUL_CONTINUE) 2579 + return X86EMUL_UNHANDLEABLE; 2580 + 2581 + if ((ctxt->ops->get_hflags(ctxt) & X86EMUL_SMM_INSIDE_NMI_MASK) == 0) 2582 + ctxt->ops->set_nmi_mask(ctxt, false); 2583 + 2584 + ctxt->ops->set_hflags(ctxt, ctxt->ops->get_hflags(ctxt) & 2585 + ~(X86EMUL_SMM_INSIDE_NMI_MASK | X86EMUL_SMM_MASK)); 2586 + 2574 2587 /* 2575 2588 * Get back to real mode, to prepare a safe state in which to load 2576 2589 * CR0/CR3/CR4/EFER. It's all a bit more complicated if the vCPU 2577 2590 * supports long mode. 2578 2591 */ 2579 - cr4 = ctxt->ops->get_cr(ctxt, 4); 2580 2592 if (emulator_has_longmode(ctxt)) { 2581 2593 struct desc_struct cs_desc; 2582 2594 2583 2595 /* Zero CR4.PCIDE before CR0.PG. */ 2584 - if (cr4 & X86_CR4_PCIDE) { 2596 + cr4 = ctxt->ops->get_cr(ctxt, 4); 2597 + if (cr4 & X86_CR4_PCIDE) 2585 2598 ctxt->ops->set_cr(ctxt, 4, cr4 & ~X86_CR4_PCIDE); 2586 - cr4 &= ~X86_CR4_PCIDE; 2587 - } 2588 2599 2589 2600 /* A 32-bit code segment is required to clear EFER.LMA. */ 2590 2601 memset(&cs_desc, 0, sizeof(cs_desc)); ··· 2610 2597 if (cr0 & X86_CR0_PE) 2611 2598 ctxt->ops->set_cr(ctxt, 0, cr0 & ~(X86_CR0_PG | X86_CR0_PE)); 2612 2599 2613 - /* Now clear CR4.PAE (which must be done before clearing EFER.LME). */ 2614 - if (cr4 & X86_CR4_PAE) 2615 - ctxt->ops->set_cr(ctxt, 4, cr4 & ~X86_CR4_PAE); 2600 + if (emulator_has_longmode(ctxt)) { 2601 + /* Clear CR4.PAE before clearing EFER.LME. */ 2602 + cr4 = ctxt->ops->get_cr(ctxt, 4); 2603 + if (cr4 & X86_CR4_PAE) 2604 + ctxt->ops->set_cr(ctxt, 4, cr4 & ~X86_CR4_PAE); 2616 2605 2617 - /* And finally go back to 32-bit mode. */ 2618 - efer = 0; 2619 - ctxt->ops->set_msr(ctxt, MSR_EFER, efer); 2620 - 2621 - smbase = ctxt->ops->get_smbase(ctxt); 2606 + /* And finally go back to 32-bit mode. */ 2607 + efer = 0; 2608 + ctxt->ops->set_msr(ctxt, MSR_EFER, efer); 2609 + } 2622 2610 2623 2611 /* 2624 2612 * Give pre_leave_smm() a chance to make ISA-specific changes to the 2625 2613 * vCPU state (e.g. enter guest mode) before loading state from the SMM 2626 2614 * state-save area. 2627 2615 */ 2628 - if (ctxt->ops->pre_leave_smm(ctxt, smbase)) 2616 + if (ctxt->ops->pre_leave_smm(ctxt, buf)) 2629 2617 return X86EMUL_UNHANDLEABLE; 2630 2618 2619 + #ifdef CONFIG_X86_64 2631 2620 if (emulator_has_longmode(ctxt)) 2632 - ret = rsm_load_state_64(ctxt, smbase + 0x8000); 2621 + ret = rsm_load_state_64(ctxt, buf); 2633 2622 else 2634 - ret = rsm_load_state_32(ctxt, smbase + 0x8000); 2623 + #endif 2624 + ret = rsm_load_state_32(ctxt, buf); 2635 2625 2636 2626 if (ret != X86EMUL_CONTINUE) { 2637 2627 /* FIXME: should triple fault */ 2638 2628 return X86EMUL_UNHANDLEABLE; 2639 2629 } 2640 2630 2641 - if ((ctxt->ops->get_hflags(ctxt) & X86EMUL_SMM_INSIDE_NMI_MASK) == 0) 2642 - ctxt->ops->set_nmi_mask(ctxt, false); 2631 + ctxt->ops->post_leave_smm(ctxt); 2643 2632 2644 - ctxt->ops->set_hflags(ctxt, ctxt->ops->get_hflags(ctxt) & 2645 - ~(X86EMUL_SMM_INSIDE_NMI_MASK | X86EMUL_SMM_MASK)); 2646 2633 return X86EMUL_CONTINUE; 2647 2634 } 2648 2635
+3 -1
arch/x86/kvm/lapic.c
··· 138 138 if (offset <= max_apic_id) { 139 139 u8 cluster_size = min(max_apic_id - offset + 1, 16U); 140 140 141 + offset = array_index_nospec(offset, map->max_apic_id + 1); 141 142 *cluster = &map->phys_map[offset]; 142 143 *mask = dest_id & (0xffff >> (16 - cluster_size)); 143 144 } else { ··· 902 901 if (irq->dest_id > map->max_apic_id) { 903 902 *bitmap = 0; 904 903 } else { 905 - *dst = &map->phys_map[irq->dest_id]; 904 + u32 dest_id = array_index_nospec(irq->dest_id, map->max_apic_id + 1); 905 + *dst = &map->phys_map[dest_id]; 906 906 *bitmap = 1; 907 907 } 908 908 return true;
+7 -8
arch/x86/kvm/mmu.c
··· 2007 2007 * aggregate version in order to make the slab shrinker 2008 2008 * faster 2009 2009 */ 2010 - static inline void kvm_mod_used_mmu_pages(struct kvm *kvm, int nr) 2010 + static inline void kvm_mod_used_mmu_pages(struct kvm *kvm, unsigned long nr) 2011 2011 { 2012 2012 kvm->arch.n_used_mmu_pages += nr; 2013 2013 percpu_counter_add(&kvm_total_used_mmu_pages, nr); ··· 2238 2238 struct list_head *invalid_list, 2239 2239 bool remote_flush) 2240 2240 { 2241 - if (!remote_flush && !list_empty(invalid_list)) 2241 + if (!remote_flush && list_empty(invalid_list)) 2242 2242 return false; 2243 2243 2244 2244 if (!list_empty(invalid_list)) ··· 2763 2763 * Changing the number of mmu pages allocated to the vm 2764 2764 * Note: if goal_nr_mmu_pages is too small, you will get dead lock 2765 2765 */ 2766 - void kvm_mmu_change_mmu_pages(struct kvm *kvm, unsigned int goal_nr_mmu_pages) 2766 + void kvm_mmu_change_mmu_pages(struct kvm *kvm, unsigned long goal_nr_mmu_pages) 2767 2767 { 2768 2768 LIST_HEAD(invalid_list); 2769 2769 ··· 6031 6031 /* 6032 6032 * Calculate mmu pages needed for kvm. 6033 6033 */ 6034 - unsigned int kvm_mmu_calculate_default_mmu_pages(struct kvm *kvm) 6034 + unsigned long kvm_mmu_calculate_default_mmu_pages(struct kvm *kvm) 6035 6035 { 6036 - unsigned int nr_mmu_pages; 6037 - unsigned int nr_pages = 0; 6036 + unsigned long nr_mmu_pages; 6037 + unsigned long nr_pages = 0; 6038 6038 struct kvm_memslots *slots; 6039 6039 struct kvm_memory_slot *memslot; 6040 6040 int i; ··· 6047 6047 } 6048 6048 6049 6049 nr_mmu_pages = nr_pages * KVM_PERMILLE_MMU_PAGES / 1000; 6050 - nr_mmu_pages = max(nr_mmu_pages, 6051 - (unsigned int) KVM_MIN_ALLOC_MMU_PAGES); 6050 + nr_mmu_pages = max(nr_mmu_pages, KVM_MIN_ALLOC_MMU_PAGES); 6052 6051 6053 6052 return nr_mmu_pages; 6054 6053 }
+1 -1
arch/x86/kvm/mmu.h
··· 64 64 int kvm_handle_page_fault(struct kvm_vcpu *vcpu, u64 error_code, 65 65 u64 fault_address, char *insn, int insn_len); 66 66 67 - static inline unsigned int kvm_mmu_available_pages(struct kvm *kvm) 67 + static inline unsigned long kvm_mmu_available_pages(struct kvm *kvm) 68 68 { 69 69 if (kvm->arch.n_max_mmu_pages > kvm->arch.n_used_mmu_pages) 70 70 return kvm->arch.n_max_mmu_pages -
+4
arch/x86/kvm/pmu.c
··· 281 281 int kvm_pmu_rdpmc(struct kvm_vcpu *vcpu, unsigned idx, u64 *data) 282 282 { 283 283 bool fast_mode = idx & (1u << 31); 284 + struct kvm_pmu *pmu = vcpu_to_pmu(vcpu); 284 285 struct kvm_pmc *pmc; 285 286 u64 ctr_val; 287 + 288 + if (!pmu->version) 289 + return 1; 286 290 287 291 if (is_vmware_backdoor_pmc(idx)) 288 292 return kvm_pmu_rdpmc_vmware(vcpu, idx, data);
+33 -24
arch/x86/kvm/svm.c
··· 262 262 }; 263 263 264 264 #define AVIC_LOGICAL_ID_ENTRY_GUEST_PHYSICAL_ID_MASK (0xFF) 265 + #define AVIC_LOGICAL_ID_ENTRY_VALID_BIT 31 265 266 #define AVIC_LOGICAL_ID_ENTRY_VALID_MASK (1 << 31) 266 267 267 268 #define AVIC_PHYSICAL_ID_ENTRY_HOST_PHYSICAL_ID_MASK (0xFFULL) ··· 2693 2692 static int db_interception(struct vcpu_svm *svm) 2694 2693 { 2695 2694 struct kvm_run *kvm_run = svm->vcpu.run; 2695 + struct kvm_vcpu *vcpu = &svm->vcpu; 2696 2696 2697 2697 if (!(svm->vcpu.guest_debug & 2698 2698 (KVM_GUESTDBG_SINGLESTEP | KVM_GUESTDBG_USE_HW_BP)) && ··· 2704 2702 2705 2703 if (svm->nmi_singlestep) { 2706 2704 disable_nmi_singlestep(svm); 2705 + /* Make sure we check for pending NMIs upon entry */ 2706 + kvm_make_request(KVM_REQ_EVENT, vcpu); 2707 2707 } 2708 2708 2709 2709 if (svm->vcpu.guest_debug & ··· 4521 4517 kvm_lapic_reg_write(apic, APIC_ICR, icrl); 4522 4518 break; 4523 4519 case AVIC_IPI_FAILURE_TARGET_NOT_RUNNING: { 4520 + int i; 4521 + struct kvm_vcpu *vcpu; 4522 + struct kvm *kvm = svm->vcpu.kvm; 4524 4523 struct kvm_lapic *apic = svm->vcpu.arch.apic; 4525 4524 4526 4525 /* 4527 - * Update ICR high and low, then emulate sending IPI, 4528 - * which is handled when writing APIC_ICR. 4526 + * At this point, we expect that the AVIC HW has already 4527 + * set the appropriate IRR bits on the valid target 4528 + * vcpus. So, we just need to kick the appropriate vcpu. 4529 4529 */ 4530 - kvm_lapic_reg_write(apic, APIC_ICR2, icrh); 4531 - kvm_lapic_reg_write(apic, APIC_ICR, icrl); 4530 + kvm_for_each_vcpu(i, vcpu, kvm) { 4531 + bool m = kvm_apic_match_dest(vcpu, apic, 4532 + icrl & KVM_APIC_SHORT_MASK, 4533 + GET_APIC_DEST_FIELD(icrh), 4534 + icrl & KVM_APIC_DEST_MASK); 4535 + 4536 + if (m && !avic_vcpu_is_running(vcpu)) 4537 + kvm_vcpu_wake_up(vcpu); 4538 + } 4532 4539 break; 4533 4540 } 4534 4541 case AVIC_IPI_FAILURE_INVALID_TARGET: ··· 4611 4596 u32 *entry = avic_get_logical_id_entry(vcpu, svm->ldr_reg, flat); 4612 4597 4613 4598 if (entry) 4614 - WRITE_ONCE(*entry, (u32) ~AVIC_LOGICAL_ID_ENTRY_VALID_MASK); 4599 + clear_bit(AVIC_LOGICAL_ID_ENTRY_VALID_BIT, (unsigned long *)entry); 4615 4600 } 4616 4601 4617 4602 static int avic_handle_ldr_update(struct kvm_vcpu *vcpu) ··· 5636 5621 svm->vmcb->save.cr2 = vcpu->arch.cr2; 5637 5622 5638 5623 clgi(); 5624 + kvm_load_guest_xcr0(vcpu); 5639 5625 5640 5626 /* 5641 5627 * If this vCPU has touched SPEC_CTRL, restore the guest's value if ··· 5782 5766 if (unlikely(svm->vmcb->control.exit_code == SVM_EXIT_NMI)) 5783 5767 kvm_before_interrupt(&svm->vcpu); 5784 5768 5769 + kvm_put_guest_xcr0(vcpu); 5785 5770 stgi(); 5786 5771 5787 5772 /* Any pending NMI will happen here */ ··· 6232 6215 return 0; 6233 6216 } 6234 6217 6235 - static int svm_pre_leave_smm(struct kvm_vcpu *vcpu, u64 smbase) 6218 + static int svm_pre_leave_smm(struct kvm_vcpu *vcpu, const char *smstate) 6236 6219 { 6237 6220 struct vcpu_svm *svm = to_svm(vcpu); 6238 6221 struct vmcb *nested_vmcb; 6239 6222 struct page *page; 6240 - struct { 6241 - u64 guest; 6242 - u64 vmcb; 6243 - } svm_state_save; 6244 - int ret; 6223 + u64 guest; 6224 + u64 vmcb; 6245 6225 6246 - ret = kvm_vcpu_read_guest(vcpu, smbase + 0xfed8, &svm_state_save, 6247 - sizeof(svm_state_save)); 6248 - if (ret) 6249 - return ret; 6226 + guest = GET_SMSTATE(u64, smstate, 0x7ed8); 6227 + vmcb = GET_SMSTATE(u64, smstate, 0x7ee0); 6250 6228 6251 - if (svm_state_save.guest) { 6252 - vcpu->arch.hflags &= ~HF_SMM_MASK; 6253 - nested_vmcb = nested_svm_map(svm, svm_state_save.vmcb, &page); 6254 - if (nested_vmcb) 6255 - enter_svm_guest_mode(svm, svm_state_save.vmcb, nested_vmcb, page); 6256 - else 6257 - ret = 1; 6258 - vcpu->arch.hflags |= HF_SMM_MASK; 6229 + if (guest) { 6230 + nested_vmcb = nested_svm_map(svm, vmcb, &page); 6231 + if (!nested_vmcb) 6232 + return 1; 6233 + enter_svm_guest_mode(svm, vmcb, nested_vmcb, page); 6259 6234 } 6260 - return ret; 6235 + return 0; 6261 6236 } 6262 6237 6263 6238 static int enable_smi_window(struct kvm_vcpu *vcpu)
+2 -2
arch/x86/kvm/trace.h
··· 438 438 ); 439 439 440 440 TRACE_EVENT(kvm_apic_accept_irq, 441 - TP_PROTO(__u32 apicid, __u16 dm, __u8 tm, __u8 vec), 441 + TP_PROTO(__u32 apicid, __u16 dm, __u16 tm, __u8 vec), 442 442 TP_ARGS(apicid, dm, tm, vec), 443 443 444 444 TP_STRUCT__entry( 445 445 __field( __u32, apicid ) 446 446 __field( __u16, dm ) 447 - __field( __u8, tm ) 447 + __field( __u16, tm ) 448 448 __field( __u8, vec ) 449 449 ), 450 450
+36 -11
arch/x86/kvm/vmx/nested.c
··· 2873 2873 /* 2874 2874 * If translation failed, VM entry will fail because 2875 2875 * prepare_vmcs02 set VIRTUAL_APIC_PAGE_ADDR to -1ull. 2876 - * Failing the vm entry is _not_ what the processor 2877 - * does but it's basically the only possibility we 2878 - * have. We could still enter the guest if CR8 load 2879 - * exits are enabled, CR8 store exits are enabled, and 2880 - * virtualize APIC access is disabled; in this case 2881 - * the processor would never use the TPR shadow and we 2882 - * could simply clear the bit from the execution 2883 - * control. But such a configuration is useless, so 2884 - * let's keep the code simple. 2885 2876 */ 2886 2877 if (!is_error_page(page)) { 2887 2878 vmx->nested.virtual_apic_page = page; 2888 2879 hpa = page_to_phys(vmx->nested.virtual_apic_page); 2889 2880 vmcs_write64(VIRTUAL_APIC_PAGE_ADDR, hpa); 2881 + } else if (nested_cpu_has(vmcs12, CPU_BASED_CR8_LOAD_EXITING) && 2882 + nested_cpu_has(vmcs12, CPU_BASED_CR8_STORE_EXITING) && 2883 + !nested_cpu_has2(vmcs12, SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES)) { 2884 + /* 2885 + * The processor will never use the TPR shadow, simply 2886 + * clear the bit from the execution control. Such a 2887 + * configuration is useless, but it happens in tests. 2888 + * For any other configuration, failing the vm entry is 2889 + * _not_ what the processor does but it's basically the 2890 + * only possibility we have. 2891 + */ 2892 + vmcs_clear_bits(CPU_BASED_VM_EXEC_CONTROL, 2893 + CPU_BASED_TPR_SHADOW); 2894 + } else { 2895 + printk("bad virtual-APIC page address\n"); 2896 + dump_vmcs(); 2890 2897 } 2891 2898 } 2892 2899 ··· 3796 3789 vmx_set_cr4(vcpu, vmcs_readl(CR4_READ_SHADOW)); 3797 3790 3798 3791 nested_ept_uninit_mmu_context(vcpu); 3799 - vcpu->arch.cr3 = vmcs_readl(GUEST_CR3); 3800 - __set_bit(VCPU_EXREG_CR3, (ulong *)&vcpu->arch.regs_avail); 3792 + 3793 + /* 3794 + * This is only valid if EPT is in use, otherwise the vmcs01 GUEST_CR3 3795 + * points to shadow pages! Fortunately we only get here after a WARN_ON 3796 + * if EPT is disabled, so a VMabort is perfectly fine. 3797 + */ 3798 + if (enable_ept) { 3799 + vcpu->arch.cr3 = vmcs_readl(GUEST_CR3); 3800 + __set_bit(VCPU_EXREG_CR3, (ulong *)&vcpu->arch.regs_avail); 3801 + } else { 3802 + nested_vmx_abort(vcpu, VMX_ABORT_VMCS_CORRUPTED); 3803 + } 3801 3804 3802 3805 /* 3803 3806 * Use ept_save_pdptrs(vcpu) to load the MMU's cached PDPTRs ··· 5754 5737 __init int nested_vmx_hardware_setup(int (*exit_handlers[])(struct kvm_vcpu *)) 5755 5738 { 5756 5739 int i; 5740 + 5741 + /* 5742 + * Without EPT it is not possible to restore L1's CR3 and PDPTR on 5743 + * VMfail, because they are not available in vmcs01. Just always 5744 + * use hardware checks. 5745 + */ 5746 + if (!enable_ept) 5747 + nested_early_check = 1; 5757 5748 5758 5749 if (!cpu_has_vmx_shadow_vmcs()) 5759 5750 enable_shadow_vmcs = 0;
+31 -4
arch/x86/kvm/vmx/vmx.c
··· 5603 5603 vmcs_readl(limit + GUEST_GDTR_BASE - GUEST_GDTR_LIMIT)); 5604 5604 } 5605 5605 5606 - static void dump_vmcs(void) 5606 + void dump_vmcs(void) 5607 5607 { 5608 5608 u32 vmentry_ctl = vmcs_read32(VM_ENTRY_CONTROLS); 5609 5609 u32 vmexit_ctl = vmcs_read32(VM_EXIT_CONTROLS); ··· 6410 6410 if (vcpu->guest_debug & KVM_GUESTDBG_SINGLESTEP) 6411 6411 vmx_set_interrupt_shadow(vcpu, 0); 6412 6412 6413 + kvm_load_guest_xcr0(vcpu); 6414 + 6413 6415 if (static_cpu_has(X86_FEATURE_PKU) && 6414 6416 kvm_read_cr4_bits(vcpu, X86_CR4_PKE) && 6415 6417 vcpu->arch.pkru != vmx->host_pkru) ··· 6507 6505 if (vcpu->arch.pkru != vmx->host_pkru) 6508 6506 __write_pkru(vmx->host_pkru); 6509 6507 } 6508 + 6509 + kvm_put_guest_xcr0(vcpu); 6510 6510 6511 6511 vmx->nested.nested_run_pending = 0; 6512 6512 vmx->idt_vectoring_info = 0; ··· 6856 6852 } 6857 6853 } 6858 6854 6855 + static bool guest_cpuid_has_pmu(struct kvm_vcpu *vcpu) 6856 + { 6857 + struct kvm_cpuid_entry2 *entry; 6858 + union cpuid10_eax eax; 6859 + 6860 + entry = kvm_find_cpuid_entry(vcpu, 0xa, 0); 6861 + if (!entry) 6862 + return false; 6863 + 6864 + eax.full = entry->eax; 6865 + return (eax.split.version_id > 0); 6866 + } 6867 + 6868 + static void nested_vmx_procbased_ctls_update(struct kvm_vcpu *vcpu) 6869 + { 6870 + struct vcpu_vmx *vmx = to_vmx(vcpu); 6871 + bool pmu_enabled = guest_cpuid_has_pmu(vcpu); 6872 + 6873 + if (pmu_enabled) 6874 + vmx->nested.msrs.procbased_ctls_high |= CPU_BASED_RDPMC_EXITING; 6875 + else 6876 + vmx->nested.msrs.procbased_ctls_high &= ~CPU_BASED_RDPMC_EXITING; 6877 + } 6878 + 6859 6879 static void update_intel_pt_cfg(struct kvm_vcpu *vcpu) 6860 6880 { 6861 6881 struct vcpu_vmx *vmx = to_vmx(vcpu); ··· 6968 6940 if (nested_vmx_allowed(vcpu)) { 6969 6941 nested_vmx_cr_fixed1_bits_update(vcpu); 6970 6942 nested_vmx_entry_exit_ctls_update(vcpu); 6943 + nested_vmx_procbased_ctls_update(vcpu); 6971 6944 } 6972 6945 6973 6946 if (boot_cpu_has(X86_FEATURE_INTEL_PT) && ··· 7398 7369 return 0; 7399 7370 } 7400 7371 7401 - static int vmx_pre_leave_smm(struct kvm_vcpu *vcpu, u64 smbase) 7372 + static int vmx_pre_leave_smm(struct kvm_vcpu *vcpu, const char *smstate) 7402 7373 { 7403 7374 struct vcpu_vmx *vmx = to_vmx(vcpu); 7404 7375 int ret; ··· 7409 7380 } 7410 7381 7411 7382 if (vmx->nested.smm.guest_mode) { 7412 - vcpu->arch.hflags &= ~HF_SMM_MASK; 7413 7383 ret = nested_vmx_enter_non_root_mode(vcpu, false); 7414 - vcpu->arch.hflags |= HF_SMM_MASK; 7415 7384 if (ret) 7416 7385 return ret; 7417 7386
+2
arch/x86/kvm/vmx/vmx.h
··· 517 517 vmcs_write64(TSC_MULTIPLIER, vmx->current_tsc_ratio); 518 518 } 519 519 520 + void dump_vmcs(void); 521 + 520 522 #endif /* __KVM_X86_VMX_H */
+31 -33
arch/x86/kvm/x86.c
··· 800 800 } 801 801 EXPORT_SYMBOL_GPL(kvm_lmsw); 802 802 803 - static void kvm_load_guest_xcr0(struct kvm_vcpu *vcpu) 803 + void kvm_load_guest_xcr0(struct kvm_vcpu *vcpu) 804 804 { 805 805 if (kvm_read_cr4_bits(vcpu, X86_CR4_OSXSAVE) && 806 806 !vcpu->guest_xcr0_loaded) { ··· 810 810 vcpu->guest_xcr0_loaded = 1; 811 811 } 812 812 } 813 + EXPORT_SYMBOL_GPL(kvm_load_guest_xcr0); 813 814 814 - static void kvm_put_guest_xcr0(struct kvm_vcpu *vcpu) 815 + void kvm_put_guest_xcr0(struct kvm_vcpu *vcpu) 815 816 { 816 817 if (vcpu->guest_xcr0_loaded) { 817 818 if (vcpu->arch.xcr0 != host_xcr0) ··· 820 819 vcpu->guest_xcr0_loaded = 0; 821 820 } 822 821 } 822 + EXPORT_SYMBOL_GPL(kvm_put_guest_xcr0); 823 823 824 824 static int __kvm_set_xcr(struct kvm_vcpu *vcpu, u32 index, u64 xcr) 825 825 { ··· 3095 3093 break; 3096 3094 case KVM_CAP_NESTED_STATE: 3097 3095 r = kvm_x86_ops->get_nested_state ? 3098 - kvm_x86_ops->get_nested_state(NULL, 0, 0) : 0; 3096 + kvm_x86_ops->get_nested_state(NULL, NULL, 0) : 0; 3099 3097 break; 3100 3098 default: 3101 3099 break; ··· 3530 3528 memset(&events->reserved, 0, sizeof(events->reserved)); 3531 3529 } 3532 3530 3533 - static void kvm_set_hflags(struct kvm_vcpu *vcpu, unsigned emul_flags); 3531 + static void kvm_smm_changed(struct kvm_vcpu *vcpu); 3534 3532 3535 3533 static int kvm_vcpu_ioctl_x86_set_vcpu_events(struct kvm_vcpu *vcpu, 3536 3534 struct kvm_vcpu_events *events) ··· 3590 3588 vcpu->arch.apic->sipi_vector = events->sipi_vector; 3591 3589 3592 3590 if (events->flags & KVM_VCPUEVENT_VALID_SMM) { 3593 - u32 hflags = vcpu->arch.hflags; 3594 - if (events->smi.smm) 3595 - hflags |= HF_SMM_MASK; 3596 - else 3597 - hflags &= ~HF_SMM_MASK; 3598 - kvm_set_hflags(vcpu, hflags); 3591 + if (!!(vcpu->arch.hflags & HF_SMM_MASK) != events->smi.smm) { 3592 + if (events->smi.smm) 3593 + vcpu->arch.hflags |= HF_SMM_MASK; 3594 + else 3595 + vcpu->arch.hflags &= ~HF_SMM_MASK; 3596 + kvm_smm_changed(vcpu); 3597 + } 3599 3598 3600 3599 vcpu->arch.smi_pending = events->smi.pending; 3601 3600 ··· 4273 4270 } 4274 4271 4275 4272 static int kvm_vm_ioctl_set_nr_mmu_pages(struct kvm *kvm, 4276 - u32 kvm_nr_mmu_pages) 4273 + unsigned long kvm_nr_mmu_pages) 4277 4274 { 4278 4275 if (kvm_nr_mmu_pages < KVM_MIN_ALLOC_MMU_PAGES) 4279 4276 return -EINVAL; ··· 4287 4284 return 0; 4288 4285 } 4289 4286 4290 - static int kvm_vm_ioctl_get_nr_mmu_pages(struct kvm *kvm) 4287 + static unsigned long kvm_vm_ioctl_get_nr_mmu_pages(struct kvm *kvm) 4291 4288 { 4292 4289 return kvm->arch.n_max_mmu_pages; 4293 4290 } ··· 5961 5958 5962 5959 static void emulator_set_hflags(struct x86_emulate_ctxt *ctxt, unsigned emul_flags) 5963 5960 { 5964 - kvm_set_hflags(emul_to_vcpu(ctxt), emul_flags); 5961 + emul_to_vcpu(ctxt)->arch.hflags = emul_flags; 5965 5962 } 5966 5963 5967 - static int emulator_pre_leave_smm(struct x86_emulate_ctxt *ctxt, u64 smbase) 5964 + static int emulator_pre_leave_smm(struct x86_emulate_ctxt *ctxt, 5965 + const char *smstate) 5968 5966 { 5969 - return kvm_x86_ops->pre_leave_smm(emul_to_vcpu(ctxt), smbase); 5967 + return kvm_x86_ops->pre_leave_smm(emul_to_vcpu(ctxt), smstate); 5968 + } 5969 + 5970 + static void emulator_post_leave_smm(struct x86_emulate_ctxt *ctxt) 5971 + { 5972 + kvm_smm_changed(emul_to_vcpu(ctxt)); 5970 5973 } 5971 5974 5972 5975 static const struct x86_emulate_ops emulate_ops = { ··· 6015 6006 .get_hflags = emulator_get_hflags, 6016 6007 .set_hflags = emulator_set_hflags, 6017 6008 .pre_leave_smm = emulator_pre_leave_smm, 6009 + .post_leave_smm = emulator_post_leave_smm, 6018 6010 }; 6019 6011 6020 6012 static void toggle_interruptibility(struct kvm_vcpu *vcpu, u32 mask) ··· 6255 6245 } 6256 6246 6257 6247 kvm_mmu_reset_context(vcpu); 6258 - } 6259 - 6260 - static void kvm_set_hflags(struct kvm_vcpu *vcpu, unsigned emul_flags) 6261 - { 6262 - unsigned changed = vcpu->arch.hflags ^ emul_flags; 6263 - 6264 - vcpu->arch.hflags = emul_flags; 6265 - 6266 - if (changed & HF_SMM_MASK) 6267 - kvm_smm_changed(vcpu); 6268 6248 } 6269 6249 6270 6250 static int kvm_vcpu_check_hw_bp(unsigned long addr, u32 type, u32 dr7, ··· 7441 7441 put_smstate(u32, buf, 0x7ef8, vcpu->arch.smbase); 7442 7442 } 7443 7443 7444 + #ifdef CONFIG_X86_64 7444 7445 static void enter_smm_save_state_64(struct kvm_vcpu *vcpu, char *buf) 7445 7446 { 7446 - #ifdef CONFIG_X86_64 7447 7447 struct desc_ptr dt; 7448 7448 struct kvm_segment seg; 7449 7449 unsigned long val; ··· 7493 7493 7494 7494 for (i = 0; i < 6; i++) 7495 7495 enter_smm_save_seg_64(vcpu, buf, i); 7496 - #else 7497 - WARN_ON_ONCE(1); 7498 - #endif 7499 7496 } 7497 + #endif 7500 7498 7501 7499 static void enter_smm(struct kvm_vcpu *vcpu) 7502 7500 { ··· 7505 7507 7506 7508 trace_kvm_enter_smm(vcpu->vcpu_id, vcpu->arch.smbase, true); 7507 7509 memset(buf, 0, 512); 7510 + #ifdef CONFIG_X86_64 7508 7511 if (guest_cpuid_has(vcpu, X86_FEATURE_LM)) 7509 7512 enter_smm_save_state_64(vcpu, buf); 7510 7513 else 7514 + #endif 7511 7515 enter_smm_save_state_32(vcpu, buf); 7512 7516 7513 7517 /* ··· 7567 7567 kvm_set_segment(vcpu, &ds, VCPU_SREG_GS); 7568 7568 kvm_set_segment(vcpu, &ds, VCPU_SREG_SS); 7569 7569 7570 + #ifdef CONFIG_X86_64 7570 7571 if (guest_cpuid_has(vcpu, X86_FEATURE_LM)) 7571 7572 kvm_x86_ops->set_efer(vcpu, 0); 7573 + #endif 7572 7574 7573 7575 kvm_update_cpuid(vcpu); 7574 7576 kvm_mmu_reset_context(vcpu); ··· 7867 7865 goto cancel_injection; 7868 7866 } 7869 7867 7870 - kvm_load_guest_xcr0(vcpu); 7871 - 7872 7868 if (req_immediate_exit) { 7873 7869 kvm_make_request(KVM_REQ_EVENT, vcpu); 7874 7870 kvm_x86_ops->request_immediate_exit(vcpu); ··· 7918 7918 7919 7919 vcpu->mode = OUTSIDE_GUEST_MODE; 7920 7920 smp_wmb(); 7921 - 7922 - kvm_put_guest_xcr0(vcpu); 7923 7921 7924 7922 kvm_before_interrupt(vcpu); 7925 7923 kvm_x86_ops->handle_external_intr(vcpu);
+2
arch/x86/kvm/x86.h
··· 347 347 __this_cpu_write(current_vcpu, NULL); 348 348 } 349 349 350 + void kvm_load_guest_xcr0(struct kvm_vcpu *vcpu); 351 + void kvm_put_guest_xcr0(struct kvm_vcpu *vcpu); 350 352 #endif
+7 -8
block/bfq-iosched.c
··· 2822 2822 bfq_remove_request(q, rq); 2823 2823 } 2824 2824 2825 - static void __bfq_bfqq_expire(struct bfq_data *bfqd, struct bfq_queue *bfqq) 2825 + static bool __bfq_bfqq_expire(struct bfq_data *bfqd, struct bfq_queue *bfqq) 2826 2826 { 2827 2827 /* 2828 2828 * If this bfqq is shared between multiple processes, check ··· 2855 2855 /* 2856 2856 * All in-service entities must have been properly deactivated 2857 2857 * or requeued before executing the next function, which 2858 - * resets all in-service entites as no more in service. 2858 + * resets all in-service entities as no more in service. This 2859 + * may cause bfqq to be freed. If this happens, the next 2860 + * function returns true. 2859 2861 */ 2860 - __bfq_bfqd_reset_in_service(bfqd); 2862 + return __bfq_bfqd_reset_in_service(bfqd); 2861 2863 } 2862 2864 2863 2865 /** ··· 3264 3262 bool slow; 3265 3263 unsigned long delta = 0; 3266 3264 struct bfq_entity *entity = &bfqq->entity; 3267 - int ref; 3268 3265 3269 3266 /* 3270 3267 * Check whether the process is slow (see bfq_bfqq_is_slow). ··· 3348 3347 * reason. 3349 3348 */ 3350 3349 __bfq_bfqq_recalc_budget(bfqd, bfqq, reason); 3351 - ref = bfqq->ref; 3352 - __bfq_bfqq_expire(bfqd, bfqq); 3353 - 3354 - if (ref == 1) /* bfqq is gone, no more actions on it */ 3350 + if (__bfq_bfqq_expire(bfqd, bfqq)) 3351 + /* bfqq is gone, no more actions on it */ 3355 3352 return; 3356 3353 3357 3354 bfqq->injected_service = 0;
+1 -1
block/bfq-iosched.h
··· 995 995 bool ins_into_idle_tree); 996 996 bool next_queue_may_preempt(struct bfq_data *bfqd); 997 997 struct bfq_queue *bfq_get_next_queue(struct bfq_data *bfqd); 998 - void __bfq_bfqd_reset_in_service(struct bfq_data *bfqd); 998 + bool __bfq_bfqd_reset_in_service(struct bfq_data *bfqd); 999 999 void bfq_deactivate_bfqq(struct bfq_data *bfqd, struct bfq_queue *bfqq, 1000 1000 bool ins_into_idle_tree, bool expiration); 1001 1001 void bfq_activate_bfqq(struct bfq_data *bfqd, struct bfq_queue *bfqq);
+15 -2
block/bfq-wf2q.c
··· 1605 1605 return bfqq; 1606 1606 } 1607 1607 1608 - void __bfq_bfqd_reset_in_service(struct bfq_data *bfqd) 1608 + /* returns true if the in-service queue gets freed */ 1609 + bool __bfq_bfqd_reset_in_service(struct bfq_data *bfqd) 1609 1610 { 1610 1611 struct bfq_queue *in_serv_bfqq = bfqd->in_service_queue; 1611 1612 struct bfq_entity *in_serv_entity = &in_serv_bfqq->entity; ··· 1630 1629 * service tree either, then release the service reference to 1631 1630 * the queue it represents (taken with bfq_get_entity). 1632 1631 */ 1633 - if (!in_serv_entity->on_st) 1632 + if (!in_serv_entity->on_st) { 1633 + /* 1634 + * If no process is referencing in_serv_bfqq any 1635 + * longer, then the service reference may be the only 1636 + * reference to the queue. If this is the case, then 1637 + * bfqq gets freed here. 1638 + */ 1639 + int ref = in_serv_bfqq->ref; 1634 1640 bfq_put_queue(in_serv_bfqq); 1641 + if (ref == 1) 1642 + return true; 1643 + } 1644 + 1645 + return false; 1635 1646 } 1636 1647 1637 1648 void bfq_deactivate_bfqq(struct bfq_data *bfqd, struct bfq_queue *bfqq,
+4 -1
block/bio.c
··· 1298 1298 } 1299 1299 } 1300 1300 1301 - if (bio_add_pc_page(q, bio, page, bytes, offset) < bytes) 1301 + if (bio_add_pc_page(q, bio, page, bytes, offset) < bytes) { 1302 + if (!map_data) 1303 + __free_page(page); 1302 1304 break; 1305 + } 1303 1306 1304 1307 len -= bytes; 1305 1308 offset = 0;
+7
block/blk-mq.c
··· 654 654 } 655 655 EXPORT_SYMBOL(blk_mq_complete_request); 656 656 657 + void blk_mq_complete_request_sync(struct request *rq) 658 + { 659 + WRITE_ONCE(rq->state, MQ_RQ_COMPLETE); 660 + rq->q->mq_ops->complete(rq); 661 + } 662 + EXPORT_SYMBOL_GPL(blk_mq_complete_request_sync); 663 + 657 664 int blk_mq_request_started(struct request *rq) 658 665 { 659 666 return blk_mq_rq_state(rq) != MQ_RQ_IDLE;
+4
drivers/acpi/acpica/nsobject.c
··· 186 186 } 187 187 } 188 188 189 + if (obj_desc->common.type == ACPI_TYPE_REGION) { 190 + acpi_ut_remove_address_range(obj_desc->region.space_id, node); 191 + } 192 + 189 193 /* Clear the Node entry in all cases */ 190 194 191 195 node->object = NULL;
+6 -6
drivers/acpi/nfit/core.c
··· 567 567 goto out; 568 568 } 569 569 570 + dev_dbg(dev, "%s cmd: %s output length: %d\n", dimm_name, 571 + cmd_name, out_obj->buffer.length); 572 + print_hex_dump_debug(cmd_name, DUMP_PREFIX_OFFSET, 4, 4, 573 + out_obj->buffer.pointer, 574 + min_t(u32, 128, out_obj->buffer.length), true); 575 + 570 576 if (call_pkg) { 571 577 call_pkg->nd_fw_size = out_obj->buffer.length; 572 578 memcpy(call_pkg->nd_payload + call_pkg->nd_size_in, ··· 590 584 *cmd_rc = 0; 591 585 return 0; 592 586 } 593 - 594 - dev_dbg(dev, "%s cmd: %s output length: %d\n", dimm_name, 595 - cmd_name, out_obj->buffer.length); 596 - print_hex_dump_debug(cmd_name, DUMP_PREFIX_OFFSET, 4, 4, 597 - out_obj->buffer.pointer, 598 - min_t(u32, 128, out_obj->buffer.length), true); 599 587 600 588 for (i = 0, offset = 0; i < desc->out_num; i++) { 601 589 u32 out_size = nd_cmd_out_size(nvdimm, cmd, desc, i, buf,
+4 -6
drivers/acpi/nfit/intel.c
··· 122 122 if (!test_bit(cmd, &nfit_mem->dsm_mask)) 123 123 return -ENOTTY; 124 124 125 - if (old_data) 126 - memcpy(nd_cmd.cmd.old_pass, old_data->data, 127 - sizeof(nd_cmd.cmd.old_pass)); 125 + memcpy(nd_cmd.cmd.old_pass, old_data->data, 126 + sizeof(nd_cmd.cmd.old_pass)); 128 127 memcpy(nd_cmd.cmd.new_pass, new_data->data, 129 128 sizeof(nd_cmd.cmd.new_pass)); 130 129 rc = nvdimm_ctl(nvdimm, ND_CMD_CALL, &nd_cmd, sizeof(nd_cmd), NULL); ··· 335 336 336 337 /* flush all cache before we erase DIMM */ 337 338 nvdimm_invalidate_cache(); 338 - if (nkey) 339 - memcpy(nd_cmd.cmd.passphrase, nkey->data, 340 - sizeof(nd_cmd.cmd.passphrase)); 339 + memcpy(nd_cmd.cmd.passphrase, nkey->data, 340 + sizeof(nd_cmd.cmd.passphrase)); 341 341 rc = nvdimm_ctl(nvdimm, ND_CMD_CALL, &nd_cmd, sizeof(nd_cmd), NULL); 342 342 if (rc < 0) 343 343 return rc;
+2
drivers/block/virtio_blk.c
··· 513 513 if (err) 514 514 num_vqs = 1; 515 515 516 + num_vqs = min_t(unsigned int, nr_cpu_ids, num_vqs); 517 + 516 518 vblk->vqs = kmalloc_array(num_vqs, sizeof(*vblk->vqs), GFP_KERNEL); 517 519 if (!vblk->vqs) 518 520 return -ENOMEM;
+1 -1
drivers/bluetooth/btusb.c
··· 2942 2942 return 0; 2943 2943 } 2944 2944 2945 + irq_set_status_flags(irq, IRQ_NOAUTOEN); 2945 2946 ret = devm_request_irq(&hdev->dev, irq, btusb_oob_wake_handler, 2946 2947 0, "OOB Wake-on-BT", data); 2947 2948 if (ret) { ··· 2957 2956 } 2958 2957 2959 2958 data->oob_wake_irq = irq; 2960 - disable_irq(irq); 2961 2959 bt_dev_info(hdev, "OOB Wake-on-BT configured at IRQ %u", irq); 2962 2960 return 0; 2963 2961 }
-1
drivers/char/ipmi/ipmi_dmi.c
··· 66 66 return; 67 67 } 68 68 69 - memset(&p, 0, sizeof(p)); 70 69 p.addr = base_addr; 71 70 p.space = space; 72 71 p.regspacing = offset;
+17 -2
drivers/char/ipmi/ipmi_msghandler.c
··· 214 214 215 215 /* Does this interface receive IPMI events? */ 216 216 bool gets_events; 217 + 218 + /* Free must run in process context for RCU cleanup. */ 219 + struct work_struct remove_work; 217 220 }; 218 221 219 222 static struct ipmi_user *acquire_ipmi_user(struct ipmi_user *user, int *index) ··· 1160 1157 return rv; 1161 1158 } 1162 1159 1160 + static void free_user_work(struct work_struct *work) 1161 + { 1162 + struct ipmi_user *user = container_of(work, struct ipmi_user, 1163 + remove_work); 1164 + 1165 + cleanup_srcu_struct(&user->release_barrier); 1166 + kfree(user); 1167 + } 1168 + 1163 1169 int ipmi_create_user(unsigned int if_num, 1164 1170 const struct ipmi_user_hndl *handler, 1165 1171 void *handler_data, ··· 1212 1200 goto out_kfree; 1213 1201 1214 1202 found: 1203 + INIT_WORK(&new_user->remove_work, free_user_work); 1204 + 1215 1205 rv = init_srcu_struct(&new_user->release_barrier); 1216 1206 if (rv) 1217 1207 goto out_kfree; ··· 1274 1260 static void free_user(struct kref *ref) 1275 1261 { 1276 1262 struct ipmi_user *user = container_of(ref, struct ipmi_user, refcount); 1277 - cleanup_srcu_struct(&user->release_barrier); 1278 - kfree(user); 1263 + 1264 + /* SRCU cleanup must happen in task context. */ 1265 + schedule_work(&user->remove_work); 1279 1266 } 1280 1267 1281 1268 static void _ipmi_destroy_user(struct ipmi_user *user)
+2
drivers/char/ipmi/ipmi_si_hardcode.c
··· 118 118 char *str; 119 119 char *si_type[SI_MAX_PARMS]; 120 120 121 + memset(si_type, 0, sizeof(si_type)); 122 + 121 123 /* Parse out the si_type string into its components. */ 122 124 str = si_type_str; 123 125 if (*str != '\0') {
+43 -14
drivers/clk/at91/clk-programmable.c
··· 20 20 #define PROG_ID_MAX 7 21 21 22 22 #define PROG_STATUS_MASK(id) (1 << ((id) + 8)) 23 - #define PROG_PRES_MASK 0x7 24 - #define PROG_PRES(layout, pckr) ((pckr >> layout->pres_shift) & PROG_PRES_MASK) 23 + #define PROG_PRES(layout, pckr) ((pckr >> layout->pres_shift) & layout->pres_mask) 25 24 #define PROG_MAX_RM9200_CSS 3 26 25 27 26 struct clk_programmable { ··· 36 37 unsigned long parent_rate) 37 38 { 38 39 struct clk_programmable *prog = to_clk_programmable(hw); 40 + const struct clk_programmable_layout *layout = prog->layout; 39 41 unsigned int pckr; 42 + unsigned long rate; 40 43 41 44 regmap_read(prog->regmap, AT91_PMC_PCKR(prog->id), &pckr); 42 45 43 - return parent_rate >> PROG_PRES(prog->layout, pckr); 46 + if (layout->is_pres_direct) 47 + rate = parent_rate / (PROG_PRES(layout, pckr) + 1); 48 + else 49 + rate = parent_rate >> PROG_PRES(layout, pckr); 50 + 51 + return rate; 44 52 } 45 53 46 54 static int clk_programmable_determine_rate(struct clk_hw *hw, 47 55 struct clk_rate_request *req) 48 56 { 57 + struct clk_programmable *prog = to_clk_programmable(hw); 58 + const struct clk_programmable_layout *layout = prog->layout; 49 59 struct clk_hw *parent; 50 60 long best_rate = -EINVAL; 51 61 unsigned long parent_rate; 52 - unsigned long tmp_rate; 62 + unsigned long tmp_rate = 0; 53 63 int shift; 54 64 int i; 55 65 ··· 68 60 continue; 69 61 70 62 parent_rate = clk_hw_get_rate(parent); 71 - for (shift = 0; shift < PROG_PRES_MASK; shift++) { 72 - tmp_rate = parent_rate >> shift; 73 - if (tmp_rate <= req->rate) 74 - break; 63 + if (layout->is_pres_direct) { 64 + for (shift = 0; shift <= layout->pres_mask; shift++) { 65 + tmp_rate = parent_rate / (shift + 1); 66 + if (tmp_rate <= req->rate) 67 + break; 68 + } 69 + } else { 70 + for (shift = 0; shift < layout->pres_mask; shift++) { 71 + tmp_rate = parent_rate >> shift; 72 + if (tmp_rate <= req->rate) 73 + break; 74 + } 75 75 } 76 76 77 77 if (tmp_rate > req->rate) ··· 153 137 if (!div) 154 138 return -EINVAL; 155 139 156 - shift = fls(div) - 1; 140 + if (layout->is_pres_direct) { 141 + shift = div - 1; 157 142 158 - if (div != (1 << shift)) 159 - return -EINVAL; 143 + if (shift > layout->pres_mask) 144 + return -EINVAL; 145 + } else { 146 + shift = fls(div) - 1; 160 147 161 - if (shift >= PROG_PRES_MASK) 162 - return -EINVAL; 148 + if (div != (1 << shift)) 149 + return -EINVAL; 150 + 151 + if (shift >= layout->pres_mask) 152 + return -EINVAL; 153 + } 163 154 164 155 regmap_update_bits(prog->regmap, AT91_PMC_PCKR(prog->id), 165 - PROG_PRES_MASK << layout->pres_shift, 156 + layout->pres_mask << layout->pres_shift, 166 157 shift << layout->pres_shift); 167 158 168 159 return 0; ··· 225 202 } 226 203 227 204 const struct clk_programmable_layout at91rm9200_programmable_layout = { 205 + .pres_mask = 0x7, 228 206 .pres_shift = 2, 229 207 .css_mask = 0x3, 230 208 .have_slck_mck = 0, 209 + .is_pres_direct = 0, 231 210 }; 232 211 233 212 const struct clk_programmable_layout at91sam9g45_programmable_layout = { 213 + .pres_mask = 0x7, 234 214 .pres_shift = 2, 235 215 .css_mask = 0x3, 236 216 .have_slck_mck = 1, 217 + .is_pres_direct = 0, 237 218 }; 238 219 239 220 const struct clk_programmable_layout at91sam9x5_programmable_layout = { 221 + .pres_mask = 0x7, 240 222 .pres_shift = 4, 241 223 .css_mask = 0x7, 242 224 .have_slck_mck = 0, 225 + .is_pres_direct = 0, 243 226 };
+2
drivers/clk/at91/pmc.h
··· 71 71 }; 72 72 73 73 struct clk_programmable_layout { 74 + u8 pres_mask; 74 75 u8 pres_shift; 75 76 u8 css_mask; 76 77 u8 have_slck_mck; 78 + u8 is_pres_direct; 77 79 }; 78 80 79 81 extern const struct clk_programmable_layout at91rm9200_programmable_layout;
+9 -1
drivers/clk/at91/sama5d2.c
··· 125 125 .pll = true }, 126 126 }; 127 127 128 + static const struct clk_programmable_layout sama5d2_programmable_layout = { 129 + .pres_mask = 0xff, 130 + .pres_shift = 4, 131 + .css_mask = 0x7, 132 + .have_slck_mck = 0, 133 + .is_pres_direct = 1, 134 + }; 135 + 128 136 static void __init sama5d2_pmc_setup(struct device_node *np) 129 137 { 130 138 struct clk_range range = CLK_RANGE(0, 0); ··· 257 249 258 250 hw = at91_clk_register_programmable(regmap, name, 259 251 parent_names, 6, i, 260 - &at91sam9x5_programmable_layout); 252 + &sama5d2_programmable_layout); 261 253 if (IS_ERR(hw)) 262 254 goto err_free; 263 255 }
+1 -1
drivers/clk/imx/clk-pll14xx.c
··· 362 362 363 363 switch (pll_clk->type) { 364 364 case PLL_1416X: 365 - if (!pll->rate_table) 365 + if (!pll_clk->rate_table) 366 366 init.ops = &clk_pll1416x_min_ops; 367 367 else 368 368 init.ops = &clk_pll1416x_ops;
+1 -2
drivers/clk/mediatek/clk-gate.c
··· 169 169 return ERR_PTR(-ENOMEM); 170 170 171 171 init.name = name; 172 - init.flags = CLK_SET_RATE_PARENT; 172 + init.flags = flags | CLK_SET_RATE_PARENT; 173 173 init.parent_names = parent_name ? &parent_name : NULL; 174 174 init.num_parents = parent_name ? 1 : 0; 175 175 init.ops = ops; 176 - init.flags = flags; 177 176 178 177 cg->regmap = regmap; 179 178 cg->set_ofs = set_ofs;
+1 -1
drivers/clk/meson/clk-pll.c
··· 120 120 return true; 121 121 } else { 122 122 /* Round down */ 123 - if (now < rate && best < now) 123 + if (now <= rate && best < now) 124 124 return true; 125 125 } 126 126
+3 -3
drivers/clk/meson/g12a.c
··· 960 960 /* VPU Clock */ 961 961 962 962 static const char * const g12a_vpu_parent_names[] = { 963 - "fclk_div4", "fclk_div3", "fclk_div5", "fclk_div7", 963 + "fclk_div3", "fclk_div4", "fclk_div5", "fclk_div7", 964 964 "mpll1", "vid_pll", "hifi_pll", "gp0_pll", 965 965 }; 966 966 967 967 static struct clk_regmap g12a_vpu_0_sel = { 968 968 .data = &(struct clk_regmap_mux_data){ 969 969 .offset = HHI_VPU_CLK_CNTL, 970 - .mask = 0x3, 970 + .mask = 0x7, 971 971 .shift = 9, 972 972 }, 973 973 .hw.init = &(struct clk_init_data){ ··· 1011 1011 static struct clk_regmap g12a_vpu_1_sel = { 1012 1012 .data = &(struct clk_regmap_mux_data){ 1013 1013 .offset = HHI_VPU_CLK_CNTL, 1014 - .mask = 0x3, 1014 + .mask = 0x7, 1015 1015 .shift = 25, 1016 1016 }, 1017 1017 .hw.init = &(struct clk_init_data){
+2
drivers/clk/meson/gxbb.c
··· 2216 2216 .offset = HHI_VDEC_CLK_CNTL, 2217 2217 .shift = 0, 2218 2218 .width = 7, 2219 + .flags = CLK_DIVIDER_ROUND_CLOSEST, 2219 2220 }, 2220 2221 .hw.init = &(struct clk_init_data){ 2221 2222 .name = "vdec_1_div", ··· 2262 2261 .offset = HHI_VDEC2_CLK_CNTL, 2263 2262 .shift = 16, 2264 2263 .width = 7, 2264 + .flags = CLK_DIVIDER_ROUND_CLOSEST, 2265 2265 }, 2266 2266 .hw.init = &(struct clk_init_data){ 2267 2267 .name = "vdec_hevc_div",
+2 -2
drivers/clk/meson/vid-pll-div.c
··· 82 82 div = _get_table_val(meson_parm_read(clk->map, &pll_div->val), 83 83 meson_parm_read(clk->map, &pll_div->sel)); 84 84 if (!div || !div->divider) { 85 - pr_info("%s: Invalid config value for vid_pll_div\n", __func__); 86 - return parent_rate; 85 + pr_debug("%s: Invalid config value for vid_pll_div\n", __func__); 86 + return 0; 87 87 } 88 88 89 89 return DIV_ROUND_UP_ULL(parent_rate * div->multiplier, div->divider);
+11 -3
drivers/clk/x86/clk-pmc-atom.c
··· 165 165 }; 166 166 167 167 static struct clk_plt *plt_clk_register(struct platform_device *pdev, int id, 168 - void __iomem *base, 168 + const struct pmc_clk_data *pmc_data, 169 169 const char **parent_names, 170 170 int num_parents) 171 171 { ··· 184 184 init.num_parents = num_parents; 185 185 186 186 pclk->hw.init = &init; 187 - pclk->reg = base + PMC_CLK_CTL_OFFSET + id * PMC_CLK_CTL_SIZE; 187 + pclk->reg = pmc_data->base + PMC_CLK_CTL_OFFSET + id * PMC_CLK_CTL_SIZE; 188 188 spin_lock_init(&pclk->lock); 189 + 190 + /* 191 + * On some systems, the pmc_plt_clocks already enabled by the 192 + * firmware are being marked as critical to avoid them being 193 + * gated by the clock framework. 194 + */ 195 + if (pmc_data->critical && plt_clk_is_enabled(&pclk->hw)) 196 + init.flags |= CLK_IS_CRITICAL; 189 197 190 198 ret = devm_clk_hw_register(&pdev->dev, &pclk->hw); 191 199 if (ret) { ··· 340 332 return PTR_ERR(parent_names); 341 333 342 334 for (i = 0; i < PMC_CLK_NUM; i++) { 343 - data->clks[i] = plt_clk_register(pdev, i, pmc_data->base, 335 + data->clks[i] = plt_clk_register(pdev, i, pmc_data, 344 336 parent_names, data->nparents); 345 337 if (IS_ERR(data->clks[i])) { 346 338 err = PTR_ERR(data->clks[i]);
+9 -4
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
··· 3173 3173 break; 3174 3174 3175 3175 if (fence) { 3176 - r = dma_fence_wait_timeout(fence, false, tmo); 3176 + tmo = dma_fence_wait_timeout(fence, false, tmo); 3177 3177 dma_fence_put(fence); 3178 3178 fence = next; 3179 - if (r <= 0) 3179 + if (tmo == 0) { 3180 + r = -ETIMEDOUT; 3180 3181 break; 3182 + } else if (tmo < 0) { 3183 + r = tmo; 3184 + break; 3185 + } 3181 3186 } else { 3182 3187 fence = next; 3183 3188 } ··· 3193 3188 tmo = dma_fence_wait_timeout(fence, false, tmo); 3194 3189 dma_fence_put(fence); 3195 3190 3196 - if (r <= 0 || tmo <= 0) { 3197 - DRM_ERROR("recover vram bo from shadow failed\n"); 3191 + if (r < 0 || tmo <= 0) { 3192 + DRM_ERROR("recover vram bo from shadow failed, r is %ld, tmo is %ld\n", r, tmo); 3198 3193 return -EIO; 3199 3194 } 3200 3195
+3
drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c
··· 35 35 #include "amdgpu_trace.h" 36 36 37 37 #define AMDGPU_IB_TEST_TIMEOUT msecs_to_jiffies(1000) 38 + #define AMDGPU_IB_TEST_GFX_XGMI_TIMEOUT msecs_to_jiffies(2000) 38 39 39 40 /* 40 41 * IB ··· 345 344 * cost waiting for it coming back under RUNTIME only 346 345 */ 347 346 tmo_gfx = 8 * AMDGPU_IB_TEST_TIMEOUT; 347 + } else if (adev->gmc.xgmi.hive_id) { 348 + tmo_gfx = AMDGPU_IB_TEST_GFX_XGMI_TIMEOUT; 348 349 } 349 350 350 351 for (i = 0; i < adev->num_rings; ++i) {
+1
drivers/gpu/drm/amd/amdkfd/kfd_device.c
··· 320 320 { 0x9876, &carrizo_device_info }, /* Carrizo */ 321 321 { 0x9877, &carrizo_device_info }, /* Carrizo */ 322 322 { 0x15DD, &raven_device_info }, /* Raven */ 323 + { 0x15D8, &raven_device_info }, /* Raven */ 323 324 #endif 324 325 { 0x67A0, &hawaii_device_info }, /* Hawaii */ 325 326 { 0x67A1, &hawaii_device_info }, /* Hawaii */
+1
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
··· 4533 4533 amdgpu_crtc->cursor_width = plane->state->crtc_w; 4534 4534 amdgpu_crtc->cursor_height = plane->state->crtc_h; 4535 4535 4536 + memset(&attributes, 0, sizeof(attributes)); 4536 4537 attributes.address.high_part = upper_32_bits(address); 4537 4538 attributes.address.low_part = lower_32_bits(address); 4538 4539 attributes.width = plane->state->crtc_w;
+2 -21
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.c
··· 1150 1150 REG_UPDATE(CURSOR_CONTROL, 1151 1151 CURSOR_ENABLE, cur_en); 1152 1152 1153 - //account for cases where we see negative offset relative to overlay plane 1154 - if (src_x_offset < 0 && src_y_offset < 0) { 1155 - REG_SET_2(CURSOR_POSITION, 0, 1156 - CURSOR_X_POSITION, 0, 1157 - CURSOR_Y_POSITION, 0); 1158 - x_hotspot -= src_x_offset; 1159 - y_hotspot -= src_y_offset; 1160 - } else if (src_x_offset < 0) { 1161 - REG_SET_2(CURSOR_POSITION, 0, 1162 - CURSOR_X_POSITION, 0, 1163 - CURSOR_Y_POSITION, pos->y); 1164 - x_hotspot -= src_x_offset; 1165 - } else if (src_y_offset < 0) { 1166 - REG_SET_2(CURSOR_POSITION, 0, 1153 + REG_SET_2(CURSOR_POSITION, 0, 1167 1154 CURSOR_X_POSITION, pos->x, 1168 - CURSOR_Y_POSITION, 0); 1169 - y_hotspot -= src_y_offset; 1170 - } else { 1171 - REG_SET_2(CURSOR_POSITION, 0, 1172 - CURSOR_X_POSITION, pos->x, 1173 - CURSOR_Y_POSITION, pos->y); 1174 - } 1155 + CURSOR_Y_POSITION, pos->y); 1175 1156 1176 1157 REG_SET_2(CURSOR_HOT_SPOT, 0, 1177 1158 CURSOR_HOT_SPOT_X, x_hotspot,
+30 -4
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
··· 1037 1037 } 1038 1038 EXPORT_SYMBOL_GPL(dw_hdmi_phy_i2c_write); 1039 1039 1040 + /* Filter out invalid setups to avoid configuring SCDC and scrambling */ 1041 + static bool dw_hdmi_support_scdc(struct dw_hdmi *hdmi) 1042 + { 1043 + struct drm_display_info *display = &hdmi->connector.display_info; 1044 + 1045 + /* Completely disable SCDC support for older controllers */ 1046 + if (hdmi->version < 0x200a) 1047 + return false; 1048 + 1049 + /* Disable if SCDC is not supported, or if an HF-VSDB block is absent */ 1050 + if (!display->hdmi.scdc.supported || 1051 + !display->hdmi.scdc.scrambling.supported) 1052 + return false; 1053 + 1054 + /* 1055 + * Disable if display only support low TMDS rates and scrambling 1056 + * for low rates is not supported either 1057 + */ 1058 + if (!display->hdmi.scdc.scrambling.low_rates && 1059 + display->max_tmds_clock <= 340000) 1060 + return false; 1061 + 1062 + return true; 1063 + } 1064 + 1040 1065 /* 1041 1066 * HDMI2.0 Specifies the following procedure for High TMDS Bit Rates: 1042 1067 * - The Source shall suspend transmission of the TMDS clock and data ··· 1080 1055 unsigned long mtmdsclock = hdmi->hdmi_data.video_mode.mtmdsclock; 1081 1056 1082 1057 /* Control for TMDS Bit Period/TMDS Clock-Period Ratio */ 1083 - if (hdmi->connector.display_info.hdmi.scdc.supported) { 1058 + if (dw_hdmi_support_scdc(hdmi)) { 1084 1059 if (mtmdsclock > HDMI14_MAX_TMDSCLK) 1085 1060 drm_scdc_set_high_tmds_clock_ratio(hdmi->ddc, 1); 1086 1061 else ··· 1604 1579 1605 1580 /* Set up HDMI_FC_INVIDCONF */ 1606 1581 inv_val = (hdmi->hdmi_data.hdcp_enable || 1607 - vmode->mtmdsclock > HDMI14_MAX_TMDSCLK || 1608 - hdmi_info->scdc.scrambling.low_rates ? 1582 + (dw_hdmi_support_scdc(hdmi) && 1583 + (vmode->mtmdsclock > HDMI14_MAX_TMDSCLK || 1584 + hdmi_info->scdc.scrambling.low_rates)) ? 1609 1585 HDMI_FC_INVIDCONF_HDCP_KEEPOUT_ACTIVE : 1610 1586 HDMI_FC_INVIDCONF_HDCP_KEEPOUT_INACTIVE); 1611 1587 ··· 1672 1646 } 1673 1647 1674 1648 /* Scrambling Control */ 1675 - if (hdmi_info->scdc.supported) { 1649 + if (dw_hdmi_support_scdc(hdmi)) { 1676 1650 if (vmode->mtmdsclock > HDMI14_MAX_TMDSCLK || 1677 1651 hdmi_info->scdc.scrambling.low_rates) { 1678 1652 /*
+2 -3
drivers/gpu/drm/drm_atomic_helper.c
··· 1034 1034 funcs->atomic_disable(crtc, old_crtc_state); 1035 1035 else if (funcs->disable) 1036 1036 funcs->disable(crtc); 1037 - else 1037 + else if (funcs->dpms) 1038 1038 funcs->dpms(crtc, DRM_MODE_DPMS_OFF); 1039 1039 1040 1040 if (!(dev->irq_enabled && dev->num_crtcs)) ··· 1277 1277 if (new_crtc_state->enable) { 1278 1278 DRM_DEBUG_ATOMIC("enabling [CRTC:%d:%s]\n", 1279 1279 crtc->base.id, crtc->name); 1280 - 1281 1280 if (funcs->atomic_enable) 1282 1281 funcs->atomic_enable(crtc, old_crtc_state); 1283 - else 1282 + else if (funcs->commit) 1284 1283 funcs->commit(crtc); 1285 1284 } 1286 1285 }
+6 -3
drivers/gpu/drm/i915/gvt/dmabuf.c
··· 209 209 struct drm_i915_private *dev_priv = to_i915(dev); 210 210 struct intel_vgpu_primary_plane_format p; 211 211 struct intel_vgpu_cursor_plane_format c; 212 - int ret; 212 + int ret, tile_height = 1; 213 213 214 214 if (plane_id == DRM_PLANE_TYPE_PRIMARY) { 215 215 ret = intel_vgpu_decode_primary_plane(vgpu, &p); ··· 228 228 break; 229 229 case PLANE_CTL_TILED_X: 230 230 info->drm_format_mod = I915_FORMAT_MOD_X_TILED; 231 + tile_height = 8; 231 232 break; 232 233 case PLANE_CTL_TILED_Y: 233 234 info->drm_format_mod = I915_FORMAT_MOD_Y_TILED; 235 + tile_height = 32; 234 236 break; 235 237 case PLANE_CTL_TILED_YF: 236 238 info->drm_format_mod = I915_FORMAT_MOD_Yf_TILED; 239 + tile_height = 32; 237 240 break; 238 241 default: 239 242 gvt_vgpu_err("invalid tiling mode: %x\n", p.tiled); ··· 267 264 return -EINVAL; 268 265 } 269 266 270 - info->size = (info->stride * info->height + PAGE_SIZE - 1) 271 - >> PAGE_SHIFT; 267 + info->size = (info->stride * roundup(info->height, tile_height) 268 + + PAGE_SIZE - 1) >> PAGE_SHIFT; 272 269 if (info->size == 0) { 273 270 gvt_vgpu_err("fb size is zero\n"); 274 271 return -EINVAL;
+9 -3
drivers/gpu/drm/i915/gvt/gtt.c
··· 750 750 751 751 static void ppgtt_free_all_spt(struct intel_vgpu *vgpu) 752 752 { 753 - struct intel_vgpu_ppgtt_spt *spt; 753 + struct intel_vgpu_ppgtt_spt *spt, *spn; 754 754 struct radix_tree_iter iter; 755 - void **slot; 755 + LIST_HEAD(all_spt); 756 + void __rcu **slot; 756 757 758 + rcu_read_lock(); 757 759 radix_tree_for_each_slot(slot, &vgpu->gtt.spt_tree, &iter, 0) { 758 760 spt = radix_tree_deref_slot(slot); 759 - ppgtt_free_spt(spt); 761 + list_move(&spt->post_shadow_list, &all_spt); 760 762 } 763 + rcu_read_unlock(); 764 + 765 + list_for_each_entry_safe(spt, spn, &all_spt, post_shadow_list) 766 + ppgtt_free_spt(spt); 761 767 } 762 768 763 769 static int ppgtt_handle_guest_write_page_table_bytes(
+3 -3
drivers/gpu/drm/i915/gvt/kvmgt.c
··· 905 905 static int intel_vgpu_aperture_rw(struct intel_vgpu *vgpu, u64 off, 906 906 void *buf, unsigned long count, bool is_write) 907 907 { 908 - void *aperture_va; 908 + void __iomem *aperture_va; 909 909 910 910 if (!intel_vgpu_in_aperture(vgpu, off) || 911 911 !intel_vgpu_in_aperture(vgpu, off + count)) { ··· 920 920 return -EIO; 921 921 922 922 if (is_write) 923 - memcpy(aperture_va + offset_in_page(off), buf, count); 923 + memcpy_toio(aperture_va + offset_in_page(off), buf, count); 924 924 else 925 - memcpy(buf, aperture_va + offset_in_page(off), count); 925 + memcpy_fromio(buf, aperture_va + offset_in_page(off), count); 926 926 927 927 io_mapping_unmap(aperture_va); 928 928
+27 -21
drivers/gpu/drm/i915/icl_dsi.c
··· 323 323 } 324 324 } 325 325 326 + static void get_dsi_io_power_domains(struct drm_i915_private *dev_priv, 327 + struct intel_dsi *intel_dsi) 328 + { 329 + enum port port; 330 + 331 + for_each_dsi_port(port, intel_dsi->ports) { 332 + WARN_ON(intel_dsi->io_wakeref[port]); 333 + intel_dsi->io_wakeref[port] = 334 + intel_display_power_get(dev_priv, 335 + port == PORT_A ? 336 + POWER_DOMAIN_PORT_DDI_A_IO : 337 + POWER_DOMAIN_PORT_DDI_B_IO); 338 + } 339 + } 340 + 326 341 static void gen11_dsi_enable_io_power(struct intel_encoder *encoder) 327 342 { 328 343 struct drm_i915_private *dev_priv = to_i915(encoder->base.dev); ··· 351 336 I915_WRITE(ICL_DSI_IO_MODECTL(port), tmp); 352 337 } 353 338 354 - for_each_dsi_port(port, intel_dsi->ports) { 355 - intel_dsi->io_wakeref[port] = 356 - intel_display_power_get(dev_priv, 357 - port == PORT_A ? 358 - POWER_DOMAIN_PORT_DDI_A_IO : 359 - POWER_DOMAIN_PORT_DDI_B_IO); 360 - } 339 + get_dsi_io_power_domains(dev_priv, intel_dsi); 361 340 } 362 341 363 342 static void gen11_dsi_power_up_lanes(struct intel_encoder *encoder) ··· 598 589 val |= DPCLKA_CFGCR0_DDI_CLK_SEL(pll->info->id, port); 599 590 } 600 591 I915_WRITE(DPCLKA_CFGCR0_ICL, val); 592 + 593 + for_each_dsi_port(port, intel_dsi->ports) { 594 + val &= ~DPCLKA_CFGCR0_DDI_CLK_OFF(port); 595 + } 596 + I915_WRITE(DPCLKA_CFGCR0_ICL, val); 597 + 601 598 POSTING_READ(DPCLKA_CFGCR0_ICL); 602 599 603 600 mutex_unlock(&dev_priv->dpll_lock); ··· 1132 1117 DRM_ERROR("DDI port:%c buffer not idle\n", 1133 1118 port_name(port)); 1134 1119 } 1135 - gen11_dsi_ungate_clocks(encoder); 1120 + gen11_dsi_gate_clocks(encoder); 1136 1121 } 1137 1122 1138 1123 static void gen11_dsi_disable_io_power(struct intel_encoder *encoder) ··· 1233 1218 return 0; 1234 1219 } 1235 1220 1236 - static u64 gen11_dsi_get_power_domains(struct intel_encoder *encoder, 1237 - struct intel_crtc_state *crtc_state) 1221 + static void gen11_dsi_get_power_domains(struct intel_encoder *encoder, 1222 + struct intel_crtc_state *crtc_state) 1238 1223 { 1239 - struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base); 1240 - u64 domains = 0; 1241 - enum port port; 1242 - 1243 - for_each_dsi_port(port, intel_dsi->ports) 1244 - if (port == PORT_A) 1245 - domains |= BIT_ULL(POWER_DOMAIN_PORT_DDI_A_IO); 1246 - else 1247 - domains |= BIT_ULL(POWER_DOMAIN_PORT_DDI_B_IO); 1248 - 1249 - return domains; 1224 + get_dsi_io_power_domains(to_i915(encoder->base.dev), 1225 + enc_to_intel_dsi(&encoder->base)); 1250 1226 } 1251 1227 1252 1228 static bool gen11_dsi_get_hw_state(struct intel_encoder *encoder,
+11 -12
drivers/gpu/drm/i915/intel_ddi.c
··· 2075 2075 intel_aux_power_domain(dig_port); 2076 2076 } 2077 2077 2078 - static u64 intel_ddi_get_power_domains(struct intel_encoder *encoder, 2079 - struct intel_crtc_state *crtc_state) 2078 + static void intel_ddi_get_power_domains(struct intel_encoder *encoder, 2079 + struct intel_crtc_state *crtc_state) 2080 2080 { 2081 2081 struct drm_i915_private *dev_priv = to_i915(encoder->base.dev); 2082 2082 struct intel_digital_port *dig_port; 2083 - u64 domains; 2084 2083 2085 2084 /* 2086 2085 * TODO: Add support for MST encoders. Atm, the following should never ··· 2087 2088 * hook. 2088 2089 */ 2089 2090 if (WARN_ON(intel_crtc_has_type(crtc_state, INTEL_OUTPUT_DP_MST))) 2090 - return 0; 2091 + return; 2091 2092 2092 2093 dig_port = enc_to_dig_port(&encoder->base); 2093 - domains = BIT_ULL(dig_port->ddi_io_power_domain); 2094 + intel_display_power_get(dev_priv, dig_port->ddi_io_power_domain); 2094 2095 2095 2096 /* 2096 2097 * AUX power is only needed for (e)DP mode, and for HDMI mode on TC ··· 2098 2099 */ 2099 2100 if (intel_crtc_has_dp_encoder(crtc_state) || 2100 2101 intel_port_is_tc(dev_priv, encoder->port)) 2101 - domains |= BIT_ULL(intel_ddi_main_link_aux_domain(dig_port)); 2102 + intel_display_power_get(dev_priv, 2103 + intel_ddi_main_link_aux_domain(dig_port)); 2102 2104 2103 2105 /* 2104 2106 * VDSC power is needed when DSC is enabled 2105 2107 */ 2106 2108 if (crtc_state->dsc_params.compression_enable) 2107 - domains |= BIT_ULL(intel_dsc_power_domain(crtc_state)); 2108 - 2109 - return domains; 2109 + intel_display_power_get(dev_priv, 2110 + intel_dsc_power_domain(crtc_state)); 2110 2111 } 2111 2112 2112 2113 void intel_ddi_enable_pipe_clock(const struct intel_crtc_state *crtc_state) ··· 2824 2825 return; 2825 2826 } 2826 2827 /* 2827 - * DSI ports should have their DDI clock ungated when disabled 2828 - * and gated when enabled. 2828 + * For DSI we keep the ddi clocks gated 2829 + * except during enable/disable sequence. 2829 2830 */ 2830 - ddi_clk_needed = !encoder->base.crtc; 2831 + ddi_clk_needed = false; 2831 2832 } 2832 2833 2833 2834 val = I915_READ(DPCLKA_CFGCR0_ICL);
+1 -5
drivers/gpu/drm/i915/intel_display.c
··· 15986 15986 struct intel_encoder *encoder; 15987 15987 15988 15988 for_each_intel_encoder(&dev_priv->drm, encoder) { 15989 - u64 get_domains; 15990 - enum intel_display_power_domain domain; 15991 15989 struct intel_crtc_state *crtc_state; 15992 15990 15993 15991 if (!encoder->get_power_domains) ··· 15999 16001 continue; 16000 16002 16001 16003 crtc_state = to_intel_crtc_state(encoder->base.crtc->state); 16002 - get_domains = encoder->get_power_domains(encoder, crtc_state); 16003 - for_each_power_domain(domain, get_domains) 16004 - intel_display_power_get(dev_priv, domain); 16004 + encoder->get_power_domains(encoder, crtc_state); 16005 16005 } 16006 16006 } 16007 16007
+10 -59
drivers/gpu/drm/i915/intel_dp.c
··· 1859 1859 return -EINVAL; 1860 1860 } 1861 1861 1862 - /* Optimize link config in order: max bpp, min lanes, min clock */ 1863 - static int 1864 - intel_dp_compute_link_config_fast(struct intel_dp *intel_dp, 1865 - struct intel_crtc_state *pipe_config, 1866 - const struct link_config_limits *limits) 1867 - { 1868 - struct drm_display_mode *adjusted_mode = &pipe_config->base.adjusted_mode; 1869 - int bpp, clock, lane_count; 1870 - int mode_rate, link_clock, link_avail; 1871 - 1872 - for (bpp = limits->max_bpp; bpp >= limits->min_bpp; bpp -= 2 * 3) { 1873 - mode_rate = intel_dp_link_required(adjusted_mode->crtc_clock, 1874 - bpp); 1875 - 1876 - for (lane_count = limits->min_lane_count; 1877 - lane_count <= limits->max_lane_count; 1878 - lane_count <<= 1) { 1879 - for (clock = limits->min_clock; clock <= limits->max_clock; clock++) { 1880 - link_clock = intel_dp->common_rates[clock]; 1881 - link_avail = intel_dp_max_data_rate(link_clock, 1882 - lane_count); 1883 - 1884 - if (mode_rate <= link_avail) { 1885 - pipe_config->lane_count = lane_count; 1886 - pipe_config->pipe_bpp = bpp; 1887 - pipe_config->port_clock = link_clock; 1888 - 1889 - return 0; 1890 - } 1891 - } 1892 - } 1893 - } 1894 - 1895 - return -EINVAL; 1896 - } 1897 - 1898 1862 static int intel_dp_dsc_compute_bpp(struct intel_dp *intel_dp, u8 dsc_max_bpc) 1899 1863 { 1900 1864 int i, num_bpc; ··· 1995 2031 limits.min_bpp = 6 * 3; 1996 2032 limits.max_bpp = intel_dp_compute_bpp(intel_dp, pipe_config); 1997 2033 1998 - if (intel_dp_is_edp(intel_dp) && intel_dp->edp_dpcd[0] < DP_EDP_14) { 2034 + if (intel_dp_is_edp(intel_dp)) { 1999 2035 /* 2000 2036 * Use the maximum clock and number of lanes the eDP panel 2001 - * advertizes being capable of. The eDP 1.3 and earlier panels 2002 - * are generally designed to support only a single clock and 2003 - * lane configuration, and typically these values correspond to 2004 - * the native resolution of the panel. With eDP 1.4 rate select 2005 - * and DSC, this is decreasingly the case, and we need to be 2006 - * able to select less than maximum link config. 2037 + * advertizes being capable of. The panels are generally 2038 + * designed to support only a single clock and lane 2039 + * configuration, and typically these values correspond to the 2040 + * native resolution of the panel. 2007 2041 */ 2008 2042 limits.min_lane_count = limits.max_lane_count; 2009 2043 limits.min_clock = limits.max_clock; ··· 2015 2053 intel_dp->common_rates[limits.max_clock], 2016 2054 limits.max_bpp, adjusted_mode->crtc_clock); 2017 2055 2018 - if (intel_dp_is_edp(intel_dp)) 2019 - /* 2020 - * Optimize for fast and narrow. eDP 1.3 section 3.3 and eDP 1.4 2021 - * section A.1: "It is recommended that the minimum number of 2022 - * lanes be used, using the minimum link rate allowed for that 2023 - * lane configuration." 2024 - * 2025 - * Note that we use the max clock and lane count for eDP 1.3 and 2026 - * earlier, and fast vs. wide is irrelevant. 2027 - */ 2028 - ret = intel_dp_compute_link_config_fast(intel_dp, pipe_config, 2029 - &limits); 2030 - else 2031 - /* Optimize for slow and wide. */ 2032 - ret = intel_dp_compute_link_config_wide(intel_dp, pipe_config, 2033 - &limits); 2056 + /* 2057 + * Optimize for slow and wide. This is the place to add alternative 2058 + * optimization policy. 2059 + */ 2060 + ret = intel_dp_compute_link_config_wide(intel_dp, pipe_config, &limits); 2034 2061 2035 2062 /* enable compression if the mode doesn't fit available BW */ 2036 2063 DRM_DEBUG_KMS("Force DSC en = %d\n", intel_dp->force_dsc_en);
+6 -4
drivers/gpu/drm/i915/intel_drv.h
··· 270 270 * be set correctly before calling this function. */ 271 271 void (*get_config)(struct intel_encoder *, 272 272 struct intel_crtc_state *pipe_config); 273 - /* Returns a mask of power domains that need to be referenced as part 274 - * of the hardware state readout code. */ 275 - u64 (*get_power_domains)(struct intel_encoder *encoder, 276 - struct intel_crtc_state *crtc_state); 273 + /* 274 + * Acquires the power domains needed for an active encoder during 275 + * hardware state readout. 276 + */ 277 + void (*get_power_domains)(struct intel_encoder *encoder, 278 + struct intel_crtc_state *crtc_state); 277 279 /* 278 280 * Called during system suspend after all pending requests for the 279 281 * encoder are flushed (for example for DP AUX transactions) and
+24
drivers/gpu/drm/i915/vlv_dsi.c
··· 256 256 mutex_unlock(&dev_priv->sb_lock); 257 257 } 258 258 259 + static int bdw_get_pipemisc_bpp(struct intel_crtc *crtc) 260 + { 261 + struct drm_i915_private *dev_priv = to_i915(crtc->base.dev); 262 + u32 tmp; 263 + 264 + tmp = I915_READ(PIPEMISC(crtc->pipe)); 265 + 266 + switch (tmp & PIPEMISC_DITHER_BPC_MASK) { 267 + case PIPEMISC_DITHER_6_BPC: 268 + return 18; 269 + case PIPEMISC_DITHER_8_BPC: 270 + return 24; 271 + case PIPEMISC_DITHER_10_BPC: 272 + return 30; 273 + case PIPEMISC_DITHER_12_BPC: 274 + return 36; 275 + default: 276 + MISSING_CASE(tmp); 277 + return 0; 278 + } 279 + } 280 + 259 281 static int intel_dsi_compute_config(struct intel_encoder *encoder, 260 282 struct intel_crtc_state *pipe_config, 261 283 struct drm_connector_state *conn_state) ··· 1092 1070 fmt = I915_READ(MIPI_DSI_FUNC_PRG(port)) & VID_MODE_FORMAT_MASK; 1093 1071 bpp = mipi_dsi_pixel_format_to_bpp( 1094 1072 pixel_format_from_register_bits(fmt)); 1073 + 1074 + pipe_config->pipe_bpp = bdw_get_pipemisc_bpp(crtc); 1095 1075 1096 1076 /* Enable Frame time stamo based scanline reporting */ 1097 1077 adjusted_mode->private_flags |=
+3 -5
drivers/gpu/drm/mediatek/mtk_dpi.c
··· 662 662 static unsigned int mt2701_calculate_factor(int clock) 663 663 { 664 664 if (clock <= 64000) 665 - return 16; 666 - else if (clock <= 128000) 667 - return 8; 668 - else if (clock <= 256000) 669 665 return 4; 670 - else 666 + else if (clock <= 128000) 671 667 return 2; 668 + else 669 + return 1; 672 670 } 673 671 674 672 static const struct mtk_dpi_conf mt8173_conf = {
+7
drivers/gpu/drm/mediatek/mtk_drm_drv.c
··· 15 15 #include <drm/drmP.h> 16 16 #include <drm/drm_atomic.h> 17 17 #include <drm/drm_atomic_helper.h> 18 + #include <drm/drm_fb_helper.h> 18 19 #include <drm/drm_gem.h> 19 20 #include <drm/drm_gem_cma_helper.h> 20 21 #include <drm/drm_of.h> ··· 342 341 .gem_prime_get_sg_table = mtk_gem_prime_get_sg_table, 343 342 .gem_prime_import_sg_table = mtk_gem_prime_import_sg_table, 344 343 .gem_prime_mmap = mtk_drm_gem_mmap_buf, 344 + .gem_prime_vmap = mtk_drm_gem_prime_vmap, 345 + .gem_prime_vunmap = mtk_drm_gem_prime_vunmap, 345 346 .fops = &mtk_drm_fops, 346 347 347 348 .name = DRIVER_NAME, ··· 378 375 ret = drm_dev_register(drm, 0); 379 376 if (ret < 0) 380 377 goto err_deinit; 378 + 379 + ret = drm_fbdev_generic_setup(drm, 32); 380 + if (ret) 381 + DRM_ERROR("Failed to initialize fbdev: %d\n", ret); 381 382 382 383 return 0; 383 384
+46
drivers/gpu/drm/mediatek/mtk_drm_gem.c
··· 241 241 kfree(mtk_gem); 242 242 return ERR_PTR(ret); 243 243 } 244 + 245 + void *mtk_drm_gem_prime_vmap(struct drm_gem_object *obj) 246 + { 247 + struct mtk_drm_gem_obj *mtk_gem = to_mtk_gem_obj(obj); 248 + struct sg_table *sgt; 249 + struct sg_page_iter iter; 250 + unsigned int npages; 251 + unsigned int i = 0; 252 + 253 + if (mtk_gem->kvaddr) 254 + return mtk_gem->kvaddr; 255 + 256 + sgt = mtk_gem_prime_get_sg_table(obj); 257 + if (IS_ERR(sgt)) 258 + return NULL; 259 + 260 + npages = obj->size >> PAGE_SHIFT; 261 + mtk_gem->pages = kcalloc(npages, sizeof(*mtk_gem->pages), GFP_KERNEL); 262 + if (!mtk_gem->pages) 263 + goto out; 264 + 265 + for_each_sg_page(sgt->sgl, &iter, sgt->orig_nents, 0) { 266 + mtk_gem->pages[i++] = sg_page_iter_page(&iter); 267 + if (i > npages) 268 + break; 269 + } 270 + mtk_gem->kvaddr = vmap(mtk_gem->pages, npages, VM_MAP, 271 + pgprot_writecombine(PAGE_KERNEL)); 272 + 273 + out: 274 + kfree((void *)sgt); 275 + 276 + return mtk_gem->kvaddr; 277 + } 278 + 279 + void mtk_drm_gem_prime_vunmap(struct drm_gem_object *obj, void *vaddr) 280 + { 281 + struct mtk_drm_gem_obj *mtk_gem = to_mtk_gem_obj(obj); 282 + 283 + if (!mtk_gem->pages) 284 + return; 285 + 286 + vunmap(vaddr); 287 + mtk_gem->kvaddr = 0; 288 + kfree((void *)mtk_gem->pages); 289 + }
+3
drivers/gpu/drm/mediatek/mtk_drm_gem.h
··· 37 37 dma_addr_t dma_addr; 38 38 unsigned long dma_attrs; 39 39 struct sg_table *sg; 40 + struct page **pages; 40 41 }; 41 42 42 43 #define to_mtk_gem_obj(x) container_of(x, struct mtk_drm_gem_obj, base) ··· 53 52 struct sg_table *mtk_gem_prime_get_sg_table(struct drm_gem_object *obj); 54 53 struct drm_gem_object *mtk_gem_prime_import_sg_table(struct drm_device *dev, 55 54 struct dma_buf_attachment *attach, struct sg_table *sg); 55 + void *mtk_drm_gem_prime_vmap(struct drm_gem_object *obj); 56 + void mtk_drm_gem_prime_vunmap(struct drm_gem_object *obj, void *vaddr); 56 57 57 58 #endif
+1 -1
drivers/gpu/drm/mediatek/mtk_hdmi.c
··· 1480 1480 if (IS_ERR(regmap)) 1481 1481 ret = PTR_ERR(regmap); 1482 1482 if (ret) { 1483 - ret = PTR_ERR(regmap); 1484 1483 dev_err(dev, 1485 1484 "Failed to get system configuration registers: %d\n", 1486 1485 ret); ··· 1515 1516 of_node_put(remote); 1516 1517 1517 1518 hdmi->ddc_adpt = of_find_i2c_adapter_by_node(i2c_np); 1519 + of_node_put(i2c_np); 1518 1520 if (!hdmi->ddc_adpt) { 1519 1521 dev_err(dev, "Failed to get ddc i2c adapter by node\n"); 1520 1522 return -EINVAL;
+5 -30
drivers/gpu/drm/mediatek/mtk_hdmi_phy.c
··· 15 15 .owner = THIS_MODULE, 16 16 }; 17 17 18 - long mtk_hdmi_pll_round_rate(struct clk_hw *hw, unsigned long rate, 19 - unsigned long *parent_rate) 20 - { 21 - struct mtk_hdmi_phy *hdmi_phy = to_mtk_hdmi_phy(hw); 22 - 23 - hdmi_phy->pll_rate = rate; 24 - if (rate <= 74250000) 25 - *parent_rate = rate; 26 - else 27 - *parent_rate = rate / 2; 28 - 29 - return rate; 30 - } 31 - 32 - unsigned long mtk_hdmi_pll_recalc_rate(struct clk_hw *hw, 33 - unsigned long parent_rate) 34 - { 35 - struct mtk_hdmi_phy *hdmi_phy = to_mtk_hdmi_phy(hw); 36 - 37 - return hdmi_phy->pll_rate; 38 - } 39 - 40 18 void mtk_hdmi_phy_clear_bits(struct mtk_hdmi_phy *hdmi_phy, u32 offset, 41 19 u32 bits) 42 20 { ··· 88 110 return NULL; 89 111 } 90 112 91 - static void mtk_hdmi_phy_clk_get_ops(struct mtk_hdmi_phy *hdmi_phy, 92 - const struct clk_ops **ops) 113 + static void mtk_hdmi_phy_clk_get_data(struct mtk_hdmi_phy *hdmi_phy, 114 + struct clk_init_data *clk_init) 93 115 { 94 - if (hdmi_phy && hdmi_phy->conf && hdmi_phy->conf->hdmi_phy_clk_ops) 95 - *ops = hdmi_phy->conf->hdmi_phy_clk_ops; 96 - else 97 - dev_err(hdmi_phy->dev, "Failed to get clk ops of phy\n"); 116 + clk_init->flags = hdmi_phy->conf->flags; 117 + clk_init->ops = hdmi_phy->conf->hdmi_phy_clk_ops; 98 118 } 99 119 100 120 static int mtk_hdmi_phy_probe(struct platform_device *pdev) ··· 105 129 struct clk_init_data clk_init = { 106 130 .num_parents = 1, 107 131 .parent_names = (const char * const *)&ref_clk_name, 108 - .flags = CLK_SET_RATE_PARENT | CLK_SET_RATE_GATE, 109 132 }; 110 133 111 134 struct phy *phy; ··· 142 167 hdmi_phy->dev = dev; 143 168 hdmi_phy->conf = 144 169 (struct mtk_hdmi_phy_conf *)of_device_get_match_data(dev); 145 - mtk_hdmi_phy_clk_get_ops(hdmi_phy, &clk_init.ops); 170 + mtk_hdmi_phy_clk_get_data(hdmi_phy, &clk_init); 146 171 hdmi_phy->pll_hw.init = &clk_init; 147 172 hdmi_phy->pll = devm_clk_register(dev, &hdmi_phy->pll_hw); 148 173 if (IS_ERR(hdmi_phy->pll)) {
+1 -4
drivers/gpu/drm/mediatek/mtk_hdmi_phy.h
··· 21 21 22 22 struct mtk_hdmi_phy_conf { 23 23 bool tz_disabled; 24 + unsigned long flags; 24 25 const struct clk_ops *hdmi_phy_clk_ops; 25 26 void (*hdmi_phy_enable_tmds)(struct mtk_hdmi_phy *hdmi_phy); 26 27 void (*hdmi_phy_disable_tmds)(struct mtk_hdmi_phy *hdmi_phy); ··· 49 48 void mtk_hdmi_phy_mask(struct mtk_hdmi_phy *hdmi_phy, u32 offset, 50 49 u32 val, u32 mask); 51 50 struct mtk_hdmi_phy *to_mtk_hdmi_phy(struct clk_hw *hw); 52 - long mtk_hdmi_pll_round_rate(struct clk_hw *hw, unsigned long rate, 53 - unsigned long *parent_rate); 54 - unsigned long mtk_hdmi_pll_recalc_rate(struct clk_hw *hw, 55 - unsigned long parent_rate); 56 51 57 52 extern struct platform_driver mtk_hdmi_phy_driver; 58 53 extern struct mtk_hdmi_phy_conf mtk_hdmi_phy_8173_conf;
+43 -6
drivers/gpu/drm/mediatek/mtk_mt2701_hdmi_phy.c
··· 79 79 mtk_hdmi_phy_set_bits(hdmi_phy, HDMI_CON0, RG_HDMITX_EN_SLDO_MASK); 80 80 usleep_range(80, 100); 81 81 mtk_hdmi_phy_set_bits(hdmi_phy, HDMI_CON2, RG_HDMITX_MBIAS_LPF_EN); 82 - mtk_hdmi_phy_set_bits(hdmi_phy, HDMI_CON2, RG_HDMITX_EN_TX_POSDIV); 83 82 mtk_hdmi_phy_set_bits(hdmi_phy, HDMI_CON0, RG_HDMITX_EN_SER_MASK); 84 83 mtk_hdmi_phy_set_bits(hdmi_phy, HDMI_CON0, RG_HDMITX_EN_PRED_MASK); 85 84 mtk_hdmi_phy_set_bits(hdmi_phy, HDMI_CON0, RG_HDMITX_EN_DRV_MASK); ··· 93 94 mtk_hdmi_phy_clear_bits(hdmi_phy, HDMI_CON0, RG_HDMITX_EN_DRV_MASK); 94 95 mtk_hdmi_phy_clear_bits(hdmi_phy, HDMI_CON0, RG_HDMITX_EN_PRED_MASK); 95 96 mtk_hdmi_phy_clear_bits(hdmi_phy, HDMI_CON0, RG_HDMITX_EN_SER_MASK); 96 - mtk_hdmi_phy_clear_bits(hdmi_phy, HDMI_CON2, RG_HDMITX_EN_TX_POSDIV); 97 97 mtk_hdmi_phy_clear_bits(hdmi_phy, HDMI_CON2, RG_HDMITX_MBIAS_LPF_EN); 98 98 usleep_range(80, 100); 99 99 mtk_hdmi_phy_clear_bits(hdmi_phy, HDMI_CON0, RG_HDMITX_EN_SLDO_MASK); ··· 106 108 usleep_range(80, 100); 107 109 } 108 110 111 + static long mtk_hdmi_pll_round_rate(struct clk_hw *hw, unsigned long rate, 112 + unsigned long *parent_rate) 113 + { 114 + return rate; 115 + } 116 + 109 117 static int mtk_hdmi_pll_set_rate(struct clk_hw *hw, unsigned long rate, 110 118 unsigned long parent_rate) 111 119 { ··· 120 116 121 117 if (rate <= 64000000) 122 118 pos_div = 3; 123 - else if (rate <= 12800000) 124 - pos_div = 1; 119 + else if (rate <= 128000000) 120 + pos_div = 2; 125 121 else 126 122 pos_div = 1; 127 123 128 124 mtk_hdmi_phy_set_bits(hdmi_phy, HDMI_CON6, RG_HTPLL_PREDIV_MASK); 129 125 mtk_hdmi_phy_set_bits(hdmi_phy, HDMI_CON6, RG_HTPLL_POSDIV_MASK); 126 + mtk_hdmi_phy_set_bits(hdmi_phy, HDMI_CON2, RG_HDMITX_EN_TX_POSDIV); 130 127 mtk_hdmi_phy_mask(hdmi_phy, HDMI_CON6, (0x1 << RG_HTPLL_IC), 131 128 RG_HTPLL_IC_MASK); 132 129 mtk_hdmi_phy_mask(hdmi_phy, HDMI_CON6, (0x1 << RG_HTPLL_IR), ··· 159 154 return 0; 160 155 } 161 156 157 + static unsigned long mtk_hdmi_pll_recalc_rate(struct clk_hw *hw, 158 + unsigned long parent_rate) 159 + { 160 + struct mtk_hdmi_phy *hdmi_phy = to_mtk_hdmi_phy(hw); 161 + unsigned long out_rate, val; 162 + 163 + val = (readl(hdmi_phy->regs + HDMI_CON6) 164 + & RG_HTPLL_PREDIV_MASK) >> RG_HTPLL_PREDIV; 165 + switch (val) { 166 + case 0x00: 167 + out_rate = parent_rate; 168 + break; 169 + case 0x01: 170 + out_rate = parent_rate / 2; 171 + break; 172 + default: 173 + out_rate = parent_rate / 4; 174 + break; 175 + } 176 + 177 + val = (readl(hdmi_phy->regs + HDMI_CON6) 178 + & RG_HTPLL_FBKDIV_MASK) >> RG_HTPLL_FBKDIV; 179 + out_rate *= (val + 1) * 2; 180 + val = (readl(hdmi_phy->regs + HDMI_CON2) 181 + & RG_HDMITX_TX_POSDIV_MASK); 182 + out_rate >>= (val >> RG_HDMITX_TX_POSDIV); 183 + 184 + if (readl(hdmi_phy->regs + HDMI_CON2) & RG_HDMITX_EN_TX_POSDIV) 185 + out_rate /= 5; 186 + 187 + return out_rate; 188 + } 189 + 162 190 static const struct clk_ops mtk_hdmi_phy_pll_ops = { 163 191 .prepare = mtk_hdmi_pll_prepare, 164 192 .unprepare = mtk_hdmi_pll_unprepare, ··· 212 174 mtk_hdmi_phy_set_bits(hdmi_phy, HDMI_CON0, RG_HDMITX_EN_SLDO_MASK); 213 175 usleep_range(80, 100); 214 176 mtk_hdmi_phy_set_bits(hdmi_phy, HDMI_CON2, RG_HDMITX_MBIAS_LPF_EN); 215 - mtk_hdmi_phy_set_bits(hdmi_phy, HDMI_CON2, RG_HDMITX_EN_TX_POSDIV); 216 177 mtk_hdmi_phy_set_bits(hdmi_phy, HDMI_CON0, RG_HDMITX_EN_SER_MASK); 217 178 mtk_hdmi_phy_set_bits(hdmi_phy, HDMI_CON0, RG_HDMITX_EN_PRED_MASK); 218 179 mtk_hdmi_phy_set_bits(hdmi_phy, HDMI_CON0, RG_HDMITX_EN_DRV_MASK); ··· 223 186 mtk_hdmi_phy_clear_bits(hdmi_phy, HDMI_CON0, RG_HDMITX_EN_DRV_MASK); 224 187 mtk_hdmi_phy_clear_bits(hdmi_phy, HDMI_CON0, RG_HDMITX_EN_PRED_MASK); 225 188 mtk_hdmi_phy_clear_bits(hdmi_phy, HDMI_CON0, RG_HDMITX_EN_SER_MASK); 226 - mtk_hdmi_phy_clear_bits(hdmi_phy, HDMI_CON2, RG_HDMITX_EN_TX_POSDIV); 227 189 mtk_hdmi_phy_clear_bits(hdmi_phy, HDMI_CON2, RG_HDMITX_MBIAS_LPF_EN); 228 190 usleep_range(80, 100); 229 191 mtk_hdmi_phy_clear_bits(hdmi_phy, HDMI_CON0, RG_HDMITX_EN_SLDO_MASK); ··· 238 202 239 203 struct mtk_hdmi_phy_conf mtk_hdmi_phy_2701_conf = { 240 204 .tz_disabled = true, 205 + .flags = CLK_SET_RATE_GATE, 241 206 .hdmi_phy_clk_ops = &mtk_hdmi_phy_pll_ops, 242 207 .hdmi_phy_enable_tmds = mtk_hdmi_phy_enable_tmds, 243 208 .hdmi_phy_disable_tmds = mtk_hdmi_phy_disable_tmds,
+23
drivers/gpu/drm/mediatek/mtk_mt8173_hdmi_phy.c
··· 199 199 usleep_range(100, 150); 200 200 } 201 201 202 + static long mtk_hdmi_pll_round_rate(struct clk_hw *hw, unsigned long rate, 203 + unsigned long *parent_rate) 204 + { 205 + struct mtk_hdmi_phy *hdmi_phy = to_mtk_hdmi_phy(hw); 206 + 207 + hdmi_phy->pll_rate = rate; 208 + if (rate <= 74250000) 209 + *parent_rate = rate; 210 + else 211 + *parent_rate = rate / 2; 212 + 213 + return rate; 214 + } 215 + 202 216 static int mtk_hdmi_pll_set_rate(struct clk_hw *hw, unsigned long rate, 203 217 unsigned long parent_rate) 204 218 { ··· 299 285 return 0; 300 286 } 301 287 288 + static unsigned long mtk_hdmi_pll_recalc_rate(struct clk_hw *hw, 289 + unsigned long parent_rate) 290 + { 291 + struct mtk_hdmi_phy *hdmi_phy = to_mtk_hdmi_phy(hw); 292 + 293 + return hdmi_phy->pll_rate; 294 + } 295 + 302 296 static const struct clk_ops mtk_hdmi_phy_pll_ops = { 303 297 .prepare = mtk_hdmi_pll_prepare, 304 298 .unprepare = mtk_hdmi_pll_unprepare, ··· 331 309 } 332 310 333 311 struct mtk_hdmi_phy_conf mtk_hdmi_phy_8173_conf = { 312 + .flags = CLK_SET_RATE_PARENT | CLK_SET_RATE_GATE, 334 313 .hdmi_phy_clk_ops = &mtk_hdmi_phy_pll_ops, 335 314 .hdmi_phy_enable_tmds = mtk_hdmi_phy_enable_tmds, 336 315 .hdmi_phy_disable_tmds = mtk_hdmi_phy_disable_tmds,
+19 -7
drivers/gpu/drm/omapdrm/dss/hdmi4_cec.c
··· 175 175 REG_FLD_MOD(core->base, HDMI_CORE_SYS_INTR_UNMASK4, 0, 3, 3); 176 176 hdmi_wp_clear_irqenable(core->wp, HDMI_IRQ_CORE); 177 177 hdmi_wp_set_irqstatus(core->wp, HDMI_IRQ_CORE); 178 + REG_FLD_MOD(core->wp->base, HDMI_WP_CLK, 0, 5, 0); 178 179 hdmi4_core_disable(core); 179 180 return 0; 180 181 } ··· 183 182 if (err) 184 183 return err; 185 184 185 + /* 186 + * Initialize CEC clock divider: CEC needs 2MHz clock hence 187 + * set the divider to 24 to get 48/24=2MHz clock 188 + */ 189 + REG_FLD_MOD(core->wp->base, HDMI_WP_CLK, 0x18, 5, 0); 190 + 186 191 /* Clear TX FIFO */ 187 192 if (!hdmi_cec_clear_tx_fifo(adap)) { 188 193 pr_err("cec-%s: could not clear TX FIFO\n", adap->name); 189 - return -EIO; 194 + err = -EIO; 195 + goto err_disable_clk; 190 196 } 191 197 192 198 /* Clear RX FIFO */ 193 199 if (!hdmi_cec_clear_rx_fifo(adap)) { 194 200 pr_err("cec-%s: could not clear RX FIFO\n", adap->name); 195 - return -EIO; 201 + err = -EIO; 202 + goto err_disable_clk; 196 203 } 197 204 198 205 /* Clear CEC interrupts */ ··· 245 236 hdmi_write_reg(core->base, HDMI_CEC_INT_STATUS_1, temp); 246 237 } 247 238 return 0; 239 + 240 + err_disable_clk: 241 + REG_FLD_MOD(core->wp->base, HDMI_WP_CLK, 0, 5, 0); 242 + hdmi4_core_disable(core); 243 + 244 + return err; 248 245 } 249 246 250 247 static int hdmi_cec_adap_log_addr(struct cec_adapter *adap, u8 log_addr) ··· 348 333 return ret; 349 334 core->wp = wp; 350 335 351 - /* 352 - * Initialize CEC clock divider: CEC needs 2MHz clock hence 353 - * set the devider to 24 to get 48/24=2MHz clock 354 - */ 355 - REG_FLD_MOD(core->wp->base, HDMI_WP_CLK, 0x18, 5, 0); 336 + /* Disable clock initially, hdmi_cec_adap_enable() manages it */ 337 + REG_FLD_MOD(core->wp->base, HDMI_WP_CLK, 0, 5, 0); 356 338 357 339 ret = cec_register_adapter(core->adap, &pdev->dev); 358 340 if (ret < 0) {
+1 -1
drivers/gpu/drm/omapdrm/dss/hdmi4_core.c
··· 708 708 else 709 709 acore.i2s_cfg.justification = HDMI_AUDIO_JUSTIFY_RIGHT; 710 710 /* 711 - * The I2S input word length is twice the lenght given in the IEC-60958 711 + * The I2S input word length is twice the length given in the IEC-60958 712 712 * status word. If the word size is greater than 713 713 * 20 bits, increment by one. 714 714 */
+7 -2
drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c
··· 48 48 sun8i_dw_hdmi_mode_valid_h6(struct drm_connector *connector, 49 49 const struct drm_display_mode *mode) 50 50 { 51 - /* This is max for HDMI 2.0b (4K@60Hz) */ 52 - if (mode->clock > 594000) 51 + /* 52 + * Controller support maximum of 594 MHz, which correlates to 53 + * 4K@60Hz 4:4:4 or RGB. However, for frequencies greater than 54 + * 340 MHz scrambling has to be enabled. Because scrambling is 55 + * not yet implemented, just limit to 340 MHz for now. 56 + */ 57 + if (mode->clock > 340000) 53 58 return MODE_CLOCK_HIGH; 54 59 55 60 return MODE_OK;
+3 -2
drivers/gpu/drm/sun4i/sun8i_tcon_top.c
··· 227 227 228 228 err_unregister_gates: 229 229 for (i = 0; i < CLK_NUM; i++) 230 - if (clk_data->hws[i]) 230 + if (!IS_ERR_OR_NULL(clk_data->hws[i])) 231 231 clk_hw_unregister_gate(clk_data->hws[i]); 232 232 clk_disable_unprepare(tcon_top->bus); 233 233 err_assert_reset: ··· 245 245 246 246 of_clk_del_provider(dev->of_node); 247 247 for (i = 0; i < CLK_NUM; i++) 248 - clk_hw_unregister_gate(clk_data->hws[i]); 248 + if (clk_data->hws[i]) 249 + clk_hw_unregister_gate(clk_data->hws[i]); 249 250 250 251 clk_disable_unprepare(tcon_top->bus); 251 252 reset_control_assert(tcon_top->rst);
+1
drivers/gpu/drm/udl/udl_drv.c
··· 52 52 .driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_PRIME, 53 53 .load = udl_driver_load, 54 54 .unload = udl_driver_unload, 55 + .release = udl_driver_release, 55 56 56 57 /* gem hooks */ 57 58 .gem_free_object_unlocked = udl_gem_free_object,
+1
drivers/gpu/drm/udl/udl_drv.h
··· 104 104 105 105 int udl_driver_load(struct drm_device *dev, unsigned long flags); 106 106 void udl_driver_unload(struct drm_device *dev); 107 + void udl_driver_release(struct drm_device *dev); 107 108 108 109 int udl_fbdev_init(struct drm_device *dev); 109 110 void udl_fbdev_cleanup(struct drm_device *dev);
+7 -1
drivers/gpu/drm/udl/udl_main.c
··· 379 379 udl_free_urb_list(dev); 380 380 381 381 udl_fbdev_cleanup(dev); 382 - udl_modeset_cleanup(dev); 383 382 kfree(udl); 383 + } 384 + 385 + void udl_driver_release(struct drm_device *dev) 386 + { 387 + udl_modeset_cleanup(dev); 388 + drm_dev_fini(dev); 389 + kfree(dev); 384 390 }
+1 -1
drivers/gpu/host1x/hw/channel_hw.c
··· 114 114 115 115 static void host1x_channel_set_streamid(struct host1x_channel *channel) 116 116 { 117 - #if HOST1X_HW >= 6 117 + #if IS_ENABLED(CONFIG_IOMMU_API) && HOST1X_HW >= 6 118 118 struct iommu_fwspec *spec = dev_iommu_fwspec_get(channel->dev->parent); 119 119 u32 sid = spec ? spec->ids[0] & 0xffff : 0x7f; 120 120
+19 -7
drivers/infiniband/hw/hfi1/chip.c
··· 13232 13232 int total_contexts; 13233 13233 int ret; 13234 13234 unsigned ngroups; 13235 - int qos_rmt_count; 13235 + int rmt_count; 13236 13236 int user_rmt_reduced; 13237 13237 u32 n_usr_ctxts; 13238 13238 u32 send_contexts = chip_send_contexts(dd); ··· 13294 13294 n_usr_ctxts = rcv_contexts - total_contexts; 13295 13295 } 13296 13296 13297 - /* each user context requires an entry in the RMT */ 13298 - qos_rmt_count = qos_rmt_entries(dd, NULL, NULL); 13299 - if (qos_rmt_count + n_usr_ctxts > NUM_MAP_ENTRIES) { 13300 - user_rmt_reduced = NUM_MAP_ENTRIES - qos_rmt_count; 13297 + /* 13298 + * The RMT entries are currently allocated as shown below: 13299 + * 1. QOS (0 to 128 entries); 13300 + * 2. FECN for PSM (num_user_contexts + num_vnic_contexts); 13301 + * 3. VNIC (num_vnic_contexts). 13302 + * It should be noted that PSM FECN oversubscribe num_vnic_contexts 13303 + * entries of RMT because both VNIC and PSM could allocate any receive 13304 + * context between dd->first_dyn_alloc_text and dd->num_rcv_contexts, 13305 + * and PSM FECN must reserve an RMT entry for each possible PSM receive 13306 + * context. 13307 + */ 13308 + rmt_count = qos_rmt_entries(dd, NULL, NULL) + (num_vnic_contexts * 2); 13309 + if (rmt_count + n_usr_ctxts > NUM_MAP_ENTRIES) { 13310 + user_rmt_reduced = NUM_MAP_ENTRIES - rmt_count; 13301 13311 dd_dev_err(dd, 13302 13312 "RMT size is reducing the number of user receive contexts from %u to %d\n", 13303 13313 n_usr_ctxts, ··· 14295 14285 u64 reg; 14296 14286 int i, idx, regoff, regidx; 14297 14287 u8 offset; 14288 + u32 total_cnt; 14298 14289 14299 14290 /* there needs to be enough room in the map table */ 14300 - if (rmt->used + dd->num_user_contexts >= NUM_MAP_ENTRIES) { 14291 + total_cnt = dd->num_rcv_contexts - dd->first_dyn_alloc_ctxt; 14292 + if (rmt->used + total_cnt >= NUM_MAP_ENTRIES) { 14301 14293 dd_dev_err(dd, "User FECN handling disabled - too many user contexts allocated\n"); 14302 14294 return; 14303 14295 } ··· 14353 14341 /* add rule 1 */ 14354 14342 add_rsm_rule(dd, RSM_INS_FECN, &rrd); 14355 14343 14356 - rmt->used += dd->num_user_contexts; 14344 + rmt->used += total_cnt; 14357 14345 } 14358 14346 14359 14347 /* Initialize RSM for VNIC */
+3 -1
drivers/infiniband/hw/hfi1/qp.c
··· 898 898 if (!list_empty(&priv->s_iowait.list) && 899 899 !(qp->s_flags & RVT_S_BUSY) && 900 900 !(priv->s_flags & RVT_S_BUSY)) { 901 - qp->s_flags &= ~RVT_S_ANY_WAIT_IO; 901 + qp->s_flags &= ~HFI1_S_ANY_WAIT_IO; 902 + iowait_clear_flag(&priv->s_iowait, IOWAIT_PENDING_IB); 903 + iowait_clear_flag(&priv->s_iowait, IOWAIT_PENDING_TID); 902 904 list_del_init(&priv->s_iowait.list); 903 905 priv->s_iowait.lock = NULL; 904 906 rvt_put_qp(qp);
+2 -2
drivers/infiniband/hw/hfi1/rc.c
··· 3088 3088 update_ack_queue(qp, next); 3089 3089 } 3090 3090 e = &qp->s_ack_queue[qp->r_head_ack_queue]; 3091 - if (e->opcode == OP(RDMA_READ_REQUEST) && e->rdma_sge.mr) { 3091 + if (e->rdma_sge.mr) { 3092 3092 rvt_put_mr(e->rdma_sge.mr); 3093 3093 e->rdma_sge.mr = NULL; 3094 3094 } ··· 3166 3166 update_ack_queue(qp, next); 3167 3167 } 3168 3168 e = &qp->s_ack_queue[qp->r_head_ack_queue]; 3169 - if (e->opcode == OP(RDMA_READ_REQUEST) && e->rdma_sge.mr) { 3169 + if (e->rdma_sge.mr) { 3170 3170 rvt_put_mr(e->rdma_sge.mr); 3171 3171 e->rdma_sge.mr = NULL; 3172 3172 }
+8 -23
drivers/infiniband/hw/hfi1/tid_rdma.c
··· 5017 5017 make_tid_rdma_ack(qp, ohdr, ps)) 5018 5018 return 1; 5019 5019 5020 - if (!(ib_rvt_state_ops[qp->state] & RVT_PROCESS_SEND_OK)) { 5021 - if (!(ib_rvt_state_ops[qp->state] & RVT_FLUSH_SEND)) 5022 - goto bail; 5023 - /* We are in the error state, flush the work request. */ 5024 - if (qp->s_last == READ_ONCE(qp->s_head)) 5025 - goto bail; 5026 - /* If DMAs are in progress, we can't flush immediately. */ 5027 - if (iowait_sdma_pending(&priv->s_iowait)) { 5028 - qp->s_flags |= RVT_S_WAIT_DMA; 5029 - goto bail; 5030 - } 5031 - clear_ahg(qp); 5032 - wqe = rvt_get_swqe_ptr(qp, qp->s_last); 5033 - hfi1_trdma_send_complete(qp, wqe, qp->s_last != qp->s_acked ? 5034 - IB_WC_SUCCESS : IB_WC_WR_FLUSH_ERR); 5035 - /* will get called again */ 5036 - goto done_free_tx; 5037 - } 5020 + /* 5021 + * Bail out if we can't send data. 5022 + * Be reminded that this check must been done after the call to 5023 + * make_tid_rdma_ack() because the responding QP could be in 5024 + * RTR state where it can send TID RDMA ACK, not TID RDMA WRITE DATA. 5025 + */ 5026 + if (!(ib_rvt_state_ops[qp->state] & RVT_PROCESS_SEND_OK)) 5027 + goto bail; 5038 5028 5039 5029 if (priv->s_flags & RVT_S_WAIT_ACK) 5040 5030 goto bail; ··· 5134 5144 hfi1_make_ruc_header(qp, ohdr, (opcode << 24), bth1, bth2, 5135 5145 middle, ps); 5136 5146 return 1; 5137 - done_free_tx: 5138 - hfi1_put_txreq(ps->s_txreq); 5139 - ps->s_txreq = NULL; 5140 - return 1; 5141 - 5142 5147 bail: 5143 5148 hfi1_put_txreq(ps->s_txreq); 5144 5149 bail_no_tx:
+4 -2
drivers/infiniband/hw/hns/hns_roce_hem.c
··· 792 792 idx_offset = (obj & (table->num_obj - 1)) % obj_per_chunk; 793 793 dma_offset = offset = idx_offset * table->obj_size; 794 794 } else { 795 + u32 seg_size = 64; /* 8 bytes per BA and 8 BA per segment */ 796 + 795 797 hns_roce_calc_hem_mhop(hr_dev, table, &mhop_obj, &mhop); 796 798 /* mtt mhop */ 797 799 i = mhop.l0_idx; ··· 805 803 hem_idx = i; 806 804 807 805 hem = table->hem[hem_idx]; 808 - dma_offset = offset = (obj & (table->num_obj - 1)) * 809 - table->obj_size % mhop.bt_chunk_size; 806 + dma_offset = offset = (obj & (table->num_obj - 1)) * seg_size % 807 + mhop.bt_chunk_size; 810 808 if (mhop.hop_num == 2) 811 809 dma_offset = offset = 0; 812 810 }
+2 -2
drivers/infiniband/hw/hns/hns_roce_mr.c
··· 746 746 struct hns_roce_hem_table *table; 747 747 dma_addr_t dma_handle; 748 748 __le64 *mtts; 749 - u32 s = start_index * sizeof(u64); 750 749 u32 bt_page_size; 751 750 u32 i; 752 751 ··· 779 780 return -EINVAL; 780 781 781 782 mtts = hns_roce_table_find(hr_dev, table, 782 - mtt->first_seg + s / hr_dev->caps.mtt_entry_sz, 783 + mtt->first_seg + 784 + start_index / HNS_ROCE_MTT_ENTRY_PER_SEG, 783 785 &dma_handle); 784 786 if (!mtts) 785 787 return -ENOMEM;
-3
drivers/infiniband/hw/hns/hns_roce_qp.c
··· 274 274 wait_for_completion(&hr_qp->free); 275 275 276 276 if ((hr_qp->ibqp.qp_type) != IB_QPT_GSI) { 277 - if (hr_dev->caps.sccc_entry_sz) 278 - hns_roce_table_put(hr_dev, &qp_table->sccc_table, 279 - hr_qp->qpn); 280 277 if (hr_dev->caps.trrl_entry_sz) 281 278 hns_roce_table_put(hr_dev, &qp_table->trrl_table, 282 279 hr_qp->qpn);
+2 -1
drivers/infiniband/hw/mlx5/odp.c
··· 585 585 struct ib_umem_odp *odp_mr = to_ib_umem_odp(mr->umem); 586 586 bool downgrade = flags & MLX5_PF_FLAGS_DOWNGRADE; 587 587 bool prefetch = flags & MLX5_PF_FLAGS_PREFETCH; 588 - u64 access_mask = ODP_READ_ALLOWED_BIT; 588 + u64 access_mask; 589 589 u64 start_idx, page_mask; 590 590 struct ib_umem_odp *odp; 591 591 size_t size; ··· 607 607 page_shift = mr->umem->page_shift; 608 608 page_mask = ~(BIT(page_shift) - 1); 609 609 start_idx = (io_virt - (mr->mmkey.iova & page_mask)) >> page_shift; 610 + access_mask = ODP_READ_ALLOWED_BIT; 610 611 611 612 if (prefetch && !downgrade && !mr->umem->writable) { 612 613 /* prefetch with write-access must
+2
drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c
··· 1131 1131 pvrdma_page_dir_cleanup(dev, &dev->cq_pdir); 1132 1132 pvrdma_page_dir_cleanup(dev, &dev->async_pdir); 1133 1133 pvrdma_free_slots(dev); 1134 + dma_free_coherent(&pdev->dev, sizeof(*dev->dsr), dev->dsr, 1135 + dev->dsrbase); 1134 1136 1135 1137 iounmap(dev->regs); 1136 1138 kfree(dev->sgid_tbl);
+1 -1
drivers/iommu/amd_iommu_init.c
··· 359 359 static void iommu_set_exclusion_range(struct amd_iommu *iommu) 360 360 { 361 361 u64 start = iommu->exclusion_start & PAGE_MASK; 362 - u64 limit = (start + iommu->exclusion_length) & PAGE_MASK; 362 + u64 limit = (start + iommu->exclusion_length - 1) & PAGE_MASK; 363 363 u64 entry; 364 364 365 365 if (!iommu->exclusion_start)
+1
drivers/irqchip/irq-ls1x.c
··· 130 130 NULL); 131 131 if (!priv->domain) { 132 132 pr_err("ls1x-irq: cannot add IRQ domain\n"); 133 + err = -ENOMEM; 133 134 goto out_iounmap; 134 135 } 135 136
+2 -2
drivers/isdn/mISDN/socket.c
··· 710 710 struct sock *sk = sock->sk; 711 711 int err = 0; 712 712 713 - if (!maddr || maddr->family != AF_ISDN) 713 + if (addr_len < sizeof(struct sockaddr_mISDN)) 714 714 return -EINVAL; 715 715 716 - if (addr_len < sizeof(struct sockaddr_mISDN)) 716 + if (!maddr || maddr->family != AF_ISDN) 717 717 return -EINVAL; 718 718 719 719 lock_sock(sk);
+28 -22
drivers/lightnvm/pblk-read.c
··· 231 231 struct pblk_sec_meta *meta; 232 232 struct bio *new_bio = rqd->bio; 233 233 struct bio *bio = pr_ctx->orig_bio; 234 - struct bio_vec src_bv, dst_bv; 235 234 void *meta_list = rqd->meta_list; 236 - int bio_init_idx = pr_ctx->bio_init_idx; 237 235 unsigned long *read_bitmap = pr_ctx->bitmap; 236 + struct bvec_iter orig_iter = BVEC_ITER_ALL_INIT; 237 + struct bvec_iter new_iter = BVEC_ITER_ALL_INIT; 238 238 int nr_secs = pr_ctx->orig_nr_secs; 239 239 int nr_holes = nr_secs - bitmap_weight(read_bitmap, nr_secs); 240 240 void *src_p, *dst_p; 241 - int hole, i; 241 + int bit, i; 242 242 243 243 if (unlikely(nr_holes == 1)) { 244 244 struct ppa_addr ppa; ··· 257 257 258 258 /* Fill the holes in the original bio */ 259 259 i = 0; 260 - hole = find_first_zero_bit(read_bitmap, nr_secs); 261 - do { 262 - struct pblk_line *line; 260 + for (bit = 0; bit < nr_secs; bit++) { 261 + if (!test_bit(bit, read_bitmap)) { 262 + struct bio_vec dst_bv, src_bv; 263 + struct pblk_line *line; 263 264 264 - line = pblk_ppa_to_line(pblk, rqd->ppa_list[i]); 265 - kref_put(&line->ref, pblk_line_put); 265 + line = pblk_ppa_to_line(pblk, rqd->ppa_list[i]); 266 + kref_put(&line->ref, pblk_line_put); 266 267 267 - meta = pblk_get_meta(pblk, meta_list, hole); 268 - meta->lba = cpu_to_le64(pr_ctx->lba_list_media[i]); 268 + meta = pblk_get_meta(pblk, meta_list, bit); 269 + meta->lba = cpu_to_le64(pr_ctx->lba_list_media[i]); 269 270 270 - src_bv = new_bio->bi_io_vec[i++]; 271 - dst_bv = bio->bi_io_vec[bio_init_idx + hole]; 271 + dst_bv = bio_iter_iovec(bio, orig_iter); 272 + src_bv = bio_iter_iovec(new_bio, new_iter); 272 273 273 - src_p = kmap_atomic(src_bv.bv_page); 274 - dst_p = kmap_atomic(dst_bv.bv_page); 274 + src_p = kmap_atomic(src_bv.bv_page); 275 + dst_p = kmap_atomic(dst_bv.bv_page); 275 276 276 - memcpy(dst_p + dst_bv.bv_offset, 277 - src_p + src_bv.bv_offset, 278 - PBLK_EXPOSED_PAGE_SIZE); 277 + memcpy(dst_p + dst_bv.bv_offset, 278 + src_p + src_bv.bv_offset, 279 + PBLK_EXPOSED_PAGE_SIZE); 279 280 280 - kunmap_atomic(src_p); 281 - kunmap_atomic(dst_p); 281 + kunmap_atomic(src_p); 282 + kunmap_atomic(dst_p); 282 283 283 - mempool_free(src_bv.bv_page, &pblk->page_bio_pool); 284 + flush_dcache_page(dst_bv.bv_page); 285 + mempool_free(src_bv.bv_page, &pblk->page_bio_pool); 284 286 285 - hole = find_next_zero_bit(read_bitmap, nr_secs, hole + 1); 286 - } while (hole < nr_secs); 287 + bio_advance_iter(new_bio, &new_iter, 288 + PBLK_EXPOSED_PAGE_SIZE); 289 + i++; 290 + } 291 + bio_advance_iter(bio, &orig_iter, PBLK_EXPOSED_PAGE_SIZE); 292 + } 287 293 288 294 bio_put(new_bio); 289 295 kfree(pr_ctx);
+13 -21
drivers/mmc/host/alcor.c
··· 48 48 struct mmc_command *cmd; 49 49 struct mmc_data *data; 50 50 unsigned int dma_on:1; 51 - unsigned int early_data:1; 52 51 53 52 struct mutex cmd_mutex; 54 53 ··· 143 144 host->sg_count--; 144 145 } 145 146 146 - static void alcor_trigger_data_transfer(struct alcor_sdmmc_host *host, 147 - bool early) 147 + static void alcor_trigger_data_transfer(struct alcor_sdmmc_host *host) 148 148 { 149 149 struct alcor_pci_priv *priv = host->alcor_pci; 150 150 struct mmc_data *data = host->data; ··· 153 155 ctrl |= AU6601_DATA_WRITE; 154 156 155 157 if (data->host_cookie == COOKIE_MAPPED) { 156 - if (host->early_data) { 157 - host->early_data = false; 158 - return; 159 - } 160 - 161 - host->early_data = early; 162 - 163 158 alcor_data_set_dma(host); 164 159 ctrl |= AU6601_DATA_DMA_MODE; 165 160 host->dma_on = 1; ··· 222 231 static void alcor_prepare_data(struct alcor_sdmmc_host *host, 223 232 struct mmc_command *cmd) 224 233 { 234 + struct alcor_pci_priv *priv = host->alcor_pci; 225 235 struct mmc_data *data = cmd->data; 226 236 227 237 if (!data) ··· 240 248 if (data->host_cookie != COOKIE_MAPPED) 241 249 alcor_prepare_sg_miter(host); 242 250 243 - alcor_trigger_data_transfer(host, true); 251 + alcor_write8(priv, 0, AU6601_DATA_XFER_CTRL); 244 252 } 245 253 246 254 static void alcor_send_cmd(struct alcor_sdmmc_host *host, ··· 427 435 if (!host->data) 428 436 return false; 429 437 430 - alcor_trigger_data_transfer(host, false); 438 + alcor_trigger_data_transfer(host); 431 439 host->cmd = NULL; 432 440 return true; 433 441 } ··· 448 456 if (!host->data) 449 457 alcor_request_complete(host, 1); 450 458 else 451 - alcor_trigger_data_transfer(host, false); 459 + alcor_trigger_data_transfer(host); 452 460 host->cmd = NULL; 453 461 } 454 462 ··· 479 487 break; 480 488 case AU6601_INT_READ_BUF_RDY: 481 489 alcor_trf_block_pio(host, true); 482 - if (!host->blocks) 483 - break; 484 - alcor_trigger_data_transfer(host, false); 485 490 return 1; 486 491 case AU6601_INT_WRITE_BUF_RDY: 487 492 alcor_trf_block_pio(host, false); 488 - if (!host->blocks) 489 - break; 490 - alcor_trigger_data_transfer(host, false); 491 493 return 1; 492 494 case AU6601_INT_DMA_END: 493 495 if (!host->sg_count) ··· 494 508 break; 495 509 } 496 510 497 - if (intmask & AU6601_INT_DATA_END) 498 - return 0; 511 + if (intmask & AU6601_INT_DATA_END) { 512 + if (!host->dma_on && host->blocks) { 513 + alcor_trigger_data_transfer(host); 514 + return 1; 515 + } else { 516 + return 0; 517 + } 518 + } 499 519 500 520 return 1; 501 521 }
+38
drivers/mmc/host/sdhci-omap.c
··· 797 797 sdhci_reset(host, mask); 798 798 } 799 799 800 + #define CMD_ERR_MASK (SDHCI_INT_CRC | SDHCI_INT_END_BIT | SDHCI_INT_INDEX |\ 801 + SDHCI_INT_TIMEOUT) 802 + #define CMD_MASK (CMD_ERR_MASK | SDHCI_INT_RESPONSE) 803 + 804 + static u32 sdhci_omap_irq(struct sdhci_host *host, u32 intmask) 805 + { 806 + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); 807 + struct sdhci_omap_host *omap_host = sdhci_pltfm_priv(pltfm_host); 808 + 809 + if (omap_host->is_tuning && host->cmd && !host->data_early && 810 + (intmask & CMD_ERR_MASK)) { 811 + 812 + /* 813 + * Since we are not resetting data lines during tuning 814 + * operation, data error or data complete interrupts 815 + * might still arrive. Mark this request as a failure 816 + * but still wait for the data interrupt 817 + */ 818 + if (intmask & SDHCI_INT_TIMEOUT) 819 + host->cmd->error = -ETIMEDOUT; 820 + else 821 + host->cmd->error = -EILSEQ; 822 + 823 + host->cmd = NULL; 824 + 825 + /* 826 + * Sometimes command error interrupts and command complete 827 + * interrupt will arrive together. Clear all command related 828 + * interrupts here. 829 + */ 830 + sdhci_writel(host, intmask & CMD_MASK, SDHCI_INT_STATUS); 831 + intmask &= ~CMD_MASK; 832 + } 833 + 834 + return intmask; 835 + } 836 + 800 837 static struct sdhci_ops sdhci_omap_ops = { 801 838 .set_clock = sdhci_omap_set_clock, 802 839 .set_power = sdhci_omap_set_power, ··· 844 807 .platform_send_init_74_clocks = sdhci_omap_init_74_clocks, 845 808 .reset = sdhci_omap_reset, 846 809 .set_uhs_signaling = sdhci_omap_set_uhs_signaling, 810 + .irq = sdhci_omap_irq, 847 811 }; 848 812 849 813 static int sdhci_omap_set_capabilities(struct sdhci_omap_host *omap_host)
+5 -1
drivers/net/bonding/bond_main.c
··· 3213 3213 return NOTIFY_DONE; 3214 3214 3215 3215 if (event_dev->flags & IFF_MASTER) { 3216 + int ret; 3217 + 3216 3218 netdev_dbg(event_dev, "IFF_MASTER\n"); 3217 - return bond_master_netdev_event(event, event_dev); 3219 + ret = bond_master_netdev_event(event, event_dev); 3220 + if (ret != NOTIFY_DONE) 3221 + return ret; 3218 3222 } 3219 3223 3220 3224 if (event_dev->flags & IFF_SLAVE) {
+1 -1
drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c
··· 957 957 bnx2x_sample_bulletin(bp); 958 958 959 959 if (bp->shadow_bulletin.content.valid_bitmap & 1 << VLAN_VALID) { 960 - BNX2X_ERR("Hypervisor will dicline the request, avoiding\n"); 960 + BNX2X_ERR("Hypervisor will decline the request, avoiding\n"); 961 961 rc = -EINVAL; 962 962 goto out; 963 963 }
+20 -2
drivers/net/ethernet/cavium/thunder/nicvf_main.c
··· 32 32 #define DRV_NAME "nicvf" 33 33 #define DRV_VERSION "1.0" 34 34 35 + /* NOTE: Packets bigger than 1530 are split across multiple pages and XDP needs 36 + * the buffer to be contiguous. Allow XDP to be set up only if we don't exceed 37 + * this value, keeping headroom for the 14 byte Ethernet header and two 38 + * VLAN tags (for QinQ) 39 + */ 40 + #define MAX_XDP_MTU (1530 - ETH_HLEN - VLAN_HLEN * 2) 41 + 35 42 /* Supported devices */ 36 43 static const struct pci_device_id nicvf_id_table[] = { 37 44 { PCI_DEVICE_SUB(PCI_VENDOR_ID_CAVIUM, ··· 1589 1582 struct nicvf *nic = netdev_priv(netdev); 1590 1583 int orig_mtu = netdev->mtu; 1591 1584 1585 + /* For now just support only the usual MTU sized frames, 1586 + * plus some headroom for VLAN, QinQ. 1587 + */ 1588 + if (nic->xdp_prog && new_mtu > MAX_XDP_MTU) { 1589 + netdev_warn(netdev, "Jumbo frames not yet supported with XDP, current MTU %d.\n", 1590 + netdev->mtu); 1591 + return -EINVAL; 1592 + } 1593 + 1592 1594 netdev->mtu = new_mtu; 1593 1595 1594 1596 if (!netif_running(netdev)) ··· 1846 1830 bool bpf_attached = false; 1847 1831 int ret = 0; 1848 1832 1849 - /* For now just support only the usual MTU sized frames */ 1850 - if (prog && (dev->mtu > 1500)) { 1833 + /* For now just support only the usual MTU sized frames, 1834 + * plus some headroom for VLAN, QinQ. 1835 + */ 1836 + if (prog && dev->mtu > MAX_XDP_MTU) { 1851 1837 netdev_warn(dev, "Jumbo frames not yet supported with XDP, current MTU %d.\n", 1852 1838 dev->mtu); 1853 1839 return -EOPNOTSUPP;
+21 -9
drivers/net/ethernet/freescale/fec_main.c
··· 1840 1840 int ret; 1841 1841 1842 1842 if (enable) { 1843 - ret = clk_prepare_enable(fep->clk_ahb); 1844 - if (ret) 1845 - return ret; 1846 - 1847 1843 ret = clk_prepare_enable(fep->clk_enet_out); 1848 1844 if (ret) 1849 - goto failed_clk_enet_out; 1845 + return ret; 1850 1846 1851 1847 if (fep->clk_ptp) { 1852 1848 mutex_lock(&fep->ptp_clk_mutex); ··· 1862 1866 1863 1867 phy_reset_after_clk_enable(ndev->phydev); 1864 1868 } else { 1865 - clk_disable_unprepare(fep->clk_ahb); 1866 1869 clk_disable_unprepare(fep->clk_enet_out); 1867 1870 if (fep->clk_ptp) { 1868 1871 mutex_lock(&fep->ptp_clk_mutex); ··· 1880 1885 failed_clk_ptp: 1881 1886 if (fep->clk_enet_out) 1882 1887 clk_disable_unprepare(fep->clk_enet_out); 1883 - failed_clk_enet_out: 1884 - clk_disable_unprepare(fep->clk_ahb); 1885 1888 1886 1889 return ret; 1887 1890 } ··· 3463 3470 ret = clk_prepare_enable(fep->clk_ipg); 3464 3471 if (ret) 3465 3472 goto failed_clk_ipg; 3473 + ret = clk_prepare_enable(fep->clk_ahb); 3474 + if (ret) 3475 + goto failed_clk_ahb; 3466 3476 3467 3477 fep->reg_phy = devm_regulator_get_optional(&pdev->dev, "phy"); 3468 3478 if (!IS_ERR(fep->reg_phy)) { ··· 3559 3563 pm_runtime_put(&pdev->dev); 3560 3564 pm_runtime_disable(&pdev->dev); 3561 3565 failed_regulator: 3566 + clk_disable_unprepare(fep->clk_ahb); 3567 + failed_clk_ahb: 3568 + clk_disable_unprepare(fep->clk_ipg); 3562 3569 failed_clk_ipg: 3563 3570 fec_enet_clk_enable(ndev, false); 3564 3571 failed_clk: ··· 3685 3686 struct net_device *ndev = dev_get_drvdata(dev); 3686 3687 struct fec_enet_private *fep = netdev_priv(ndev); 3687 3688 3689 + clk_disable_unprepare(fep->clk_ahb); 3688 3690 clk_disable_unprepare(fep->clk_ipg); 3689 3691 3690 3692 return 0; ··· 3695 3695 { 3696 3696 struct net_device *ndev = dev_get_drvdata(dev); 3697 3697 struct fec_enet_private *fep = netdev_priv(ndev); 3698 + int ret; 3698 3699 3699 - return clk_prepare_enable(fep->clk_ipg); 3700 + ret = clk_prepare_enable(fep->clk_ahb); 3701 + if (ret) 3702 + return ret; 3703 + ret = clk_prepare_enable(fep->clk_ipg); 3704 + if (ret) 3705 + goto failed_clk_ipg; 3706 + 3707 + return 0; 3708 + 3709 + failed_clk_ipg: 3710 + clk_disable_unprepare(fep->clk_ahb); 3711 + return ret; 3700 3712 } 3701 3713 3702 3714 static const struct dev_pm_ops fec_pm_ops = {
+25 -7
drivers/net/ethernet/ibm/ibmvnic.c
··· 3758 3758 { 3759 3759 struct device *dev = &adapter->vdev->dev; 3760 3760 struct ibmvnic_query_ip_offload_buffer *buf = &adapter->ip_offload_buf; 3761 + netdev_features_t old_hw_features = 0; 3761 3762 union ibmvnic_crq crq; 3762 3763 int i; 3763 3764 ··· 3834 3833 adapter->ip_offload_ctrl.large_rx_ipv4 = 0; 3835 3834 adapter->ip_offload_ctrl.large_rx_ipv6 = 0; 3836 3835 3837 - adapter->netdev->features = NETIF_F_SG | NETIF_F_GSO; 3836 + if (adapter->state != VNIC_PROBING) { 3837 + old_hw_features = adapter->netdev->hw_features; 3838 + adapter->netdev->hw_features = 0; 3839 + } 3840 + 3841 + adapter->netdev->hw_features = NETIF_F_SG | NETIF_F_GSO | NETIF_F_GRO; 3838 3842 3839 3843 if (buf->tcp_ipv4_chksum || buf->udp_ipv4_chksum) 3840 - adapter->netdev->features |= NETIF_F_IP_CSUM; 3844 + adapter->netdev->hw_features |= NETIF_F_IP_CSUM; 3841 3845 3842 3846 if (buf->tcp_ipv6_chksum || buf->udp_ipv6_chksum) 3843 - adapter->netdev->features |= NETIF_F_IPV6_CSUM; 3847 + adapter->netdev->hw_features |= NETIF_F_IPV6_CSUM; 3844 3848 3845 3849 if ((adapter->netdev->features & 3846 3850 (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM))) 3847 - adapter->netdev->features |= NETIF_F_RXCSUM; 3851 + adapter->netdev->hw_features |= NETIF_F_RXCSUM; 3848 3852 3849 3853 if (buf->large_tx_ipv4) 3850 - adapter->netdev->features |= NETIF_F_TSO; 3854 + adapter->netdev->hw_features |= NETIF_F_TSO; 3851 3855 if (buf->large_tx_ipv6) 3852 - adapter->netdev->features |= NETIF_F_TSO6; 3856 + adapter->netdev->hw_features |= NETIF_F_TSO6; 3853 3857 3854 - adapter->netdev->hw_features |= adapter->netdev->features; 3858 + if (adapter->state == VNIC_PROBING) { 3859 + adapter->netdev->features |= adapter->netdev->hw_features; 3860 + } else if (old_hw_features != adapter->netdev->hw_features) { 3861 + netdev_features_t tmp = 0; 3862 + 3863 + /* disable features no longer supported */ 3864 + adapter->netdev->features &= adapter->netdev->hw_features; 3865 + /* turn on features now supported if previously enabled */ 3866 + tmp = (old_hw_features ^ adapter->netdev->hw_features) & 3867 + adapter->netdev->hw_features; 3868 + adapter->netdev->features |= 3869 + tmp & adapter->netdev->wanted_features; 3870 + } 3855 3871 3856 3872 memset(&crq, 0, sizeof(crq)); 3857 3873 crq.control_ip_offload.first = IBMVNIC_CRQ_CMD;
+1
drivers/net/ethernet/mellanox/mlx5/core/en.h
··· 856 856 * switching channels 857 857 */ 858 858 typedef int (*mlx5e_fp_hw_modify)(struct mlx5e_priv *priv); 859 + int mlx5e_safe_reopen_channels(struct mlx5e_priv *priv); 859 860 int mlx5e_safe_switch_channels(struct mlx5e_priv *priv, 860 861 struct mlx5e_channels *new_chs, 861 862 mlx5e_fp_hw_modify hw_modify);
+8 -3
drivers/net/ethernet/mellanox/mlx5/core/en/reporter_tx.c
··· 186 186 187 187 static int mlx5e_tx_reporter_recover_all(struct mlx5e_priv *priv) 188 188 { 189 - int err; 189 + int err = 0; 190 190 191 191 rtnl_lock(); 192 192 mutex_lock(&priv->state_lock); 193 - mlx5e_close_locked(priv->netdev); 194 - err = mlx5e_open_locked(priv->netdev); 193 + 194 + if (!test_bit(MLX5E_STATE_OPENED, &priv->state)) 195 + goto out; 196 + 197 + err = mlx5e_safe_reopen_channels(priv); 198 + 199 + out: 195 200 mutex_unlock(&priv->state_lock); 196 201 rtnl_unlock(); 197 202
+4
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c
··· 39 39 return -EOPNOTSUPP; 40 40 } 41 41 42 + if (!(mlx5e_eswitch_rep(*out_dev) && 43 + mlx5e_is_uplink_rep(netdev_priv(*out_dev)))) 44 + return -EOPNOTSUPP; 45 + 42 46 return 0; 43 47 } 44 48
+2 -1
drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
··· 1768 1768 struct mlx5e_channel *c; 1769 1769 int i; 1770 1770 1771 - if (!test_bit(MLX5E_STATE_OPENED, &priv->state)) 1771 + if (!test_bit(MLX5E_STATE_OPENED, &priv->state) || 1772 + priv->channels.params.xdp_prog) 1772 1773 return 0; 1773 1774 1774 1775 for (i = 0; i < channels->num; i++) {
+16 -5
drivers/net/ethernet/mellanox/mlx5/core/en_main.c
··· 952 952 if (params->rx_dim_enabled) 953 953 __set_bit(MLX5E_RQ_STATE_AM, &c->rq.state); 954 954 955 - if (MLX5E_GET_PFLAG(params, MLX5E_PFLAG_RX_NO_CSUM_COMPLETE)) 955 + /* We disable csum_complete when XDP is enabled since 956 + * XDP programs might manipulate packets which will render 957 + * skb->checksum incorrect. 958 + */ 959 + if (MLX5E_GET_PFLAG(params, MLX5E_PFLAG_RX_NO_CSUM_COMPLETE) || c->xdp) 956 960 __set_bit(MLX5E_RQ_STATE_NO_CSUM_COMPLETE, &c->rq.state); 957 961 958 962 return 0; ··· 2960 2956 return 0; 2961 2957 } 2962 2958 2959 + int mlx5e_safe_reopen_channels(struct mlx5e_priv *priv) 2960 + { 2961 + struct mlx5e_channels new_channels = {}; 2962 + 2963 + new_channels.params = priv->channels.params; 2964 + return mlx5e_safe_switch_channels(priv, &new_channels, NULL); 2965 + } 2966 + 2963 2967 void mlx5e_timestamp_init(struct mlx5e_priv *priv) 2964 2968 { 2965 2969 priv->tstamp.tx_type = HWTSTAMP_TX_OFF; ··· 4198 4186 if (!report_failed) 4199 4187 goto unlock; 4200 4188 4201 - mlx5e_close_locked(priv->netdev); 4202 - err = mlx5e_open_locked(priv->netdev); 4189 + err = mlx5e_safe_reopen_channels(priv); 4203 4190 if (err) 4204 4191 netdev_err(priv->netdev, 4205 - "mlx5e_open_locked failed recovering from a tx_timeout, err(%d).\n", 4192 + "mlx5e_safe_reopen_channels failed recovering from a tx_timeout, err(%d).\n", 4206 4193 err); 4207 4194 4208 4195 unlock: ··· 4589 4578 { 4590 4579 enum mlx5e_traffic_types tt; 4591 4580 4592 - rss_params->hfunc = ETH_RSS_HASH_XOR; 4581 + rss_params->hfunc = ETH_RSS_HASH_TOP; 4593 4582 netdev_rss_key_fill(rss_params->toeplitz_hash_key, 4594 4583 sizeof(rss_params->toeplitz_hash_key)); 4595 4584 mlx5e_build_default_indir_rqt(rss_params->indirection_rqt,
+75 -19
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
··· 692 692 { 693 693 *proto = ((struct ethhdr *)skb->data)->h_proto; 694 694 *proto = __vlan_get_protocol(skb, *proto, network_depth); 695 - return (*proto == htons(ETH_P_IP) || *proto == htons(ETH_P_IPV6)); 695 + 696 + if (*proto == htons(ETH_P_IP)) 697 + return pskb_may_pull(skb, *network_depth + sizeof(struct iphdr)); 698 + 699 + if (*proto == htons(ETH_P_IPV6)) 700 + return pskb_may_pull(skb, *network_depth + sizeof(struct ipv6hdr)); 701 + 702 + return false; 696 703 } 697 704 698 705 static inline void mlx5e_enable_ecn(struct mlx5e_rq *rq, struct sk_buff *skb) ··· 719 712 rq->stats->ecn_mark += !!rc; 720 713 } 721 714 722 - static u32 mlx5e_get_fcs(const struct sk_buff *skb) 723 - { 724 - const void *fcs_bytes; 725 - u32 _fcs_bytes; 726 - 727 - fcs_bytes = skb_header_pointer(skb, skb->len - ETH_FCS_LEN, 728 - ETH_FCS_LEN, &_fcs_bytes); 729 - 730 - return __get_unaligned_cpu32(fcs_bytes); 731 - } 732 - 733 715 static u8 get_ip_proto(struct sk_buff *skb, int network_depth, __be16 proto) 734 716 { 735 717 void *ip_p = skb->data + network_depth; ··· 728 732 } 729 733 730 734 #define short_frame(size) ((size) <= ETH_ZLEN + ETH_FCS_LEN) 735 + 736 + #define MAX_PADDING 8 737 + 738 + static void 739 + tail_padding_csum_slow(struct sk_buff *skb, int offset, int len, 740 + struct mlx5e_rq_stats *stats) 741 + { 742 + stats->csum_complete_tail_slow++; 743 + skb->csum = csum_block_add(skb->csum, 744 + skb_checksum(skb, offset, len, 0), 745 + offset); 746 + } 747 + 748 + static void 749 + tail_padding_csum(struct sk_buff *skb, int offset, 750 + struct mlx5e_rq_stats *stats) 751 + { 752 + u8 tail_padding[MAX_PADDING]; 753 + int len = skb->len - offset; 754 + void *tail; 755 + 756 + if (unlikely(len > MAX_PADDING)) { 757 + tail_padding_csum_slow(skb, offset, len, stats); 758 + return; 759 + } 760 + 761 + tail = skb_header_pointer(skb, offset, len, tail_padding); 762 + if (unlikely(!tail)) { 763 + tail_padding_csum_slow(skb, offset, len, stats); 764 + return; 765 + } 766 + 767 + stats->csum_complete_tail++; 768 + skb->csum = csum_block_add(skb->csum, csum_partial(tail, len, 0), offset); 769 + } 770 + 771 + static void 772 + mlx5e_skb_padding_csum(struct sk_buff *skb, int network_depth, __be16 proto, 773 + struct mlx5e_rq_stats *stats) 774 + { 775 + struct ipv6hdr *ip6; 776 + struct iphdr *ip4; 777 + int pkt_len; 778 + 779 + switch (proto) { 780 + case htons(ETH_P_IP): 781 + ip4 = (struct iphdr *)(skb->data + network_depth); 782 + pkt_len = network_depth + ntohs(ip4->tot_len); 783 + break; 784 + case htons(ETH_P_IPV6): 785 + ip6 = (struct ipv6hdr *)(skb->data + network_depth); 786 + pkt_len = network_depth + sizeof(*ip6) + ntohs(ip6->payload_len); 787 + break; 788 + default: 789 + return; 790 + } 791 + 792 + if (likely(pkt_len >= skb->len)) 793 + return; 794 + 795 + tail_padding_csum(skb, pkt_len, stats); 796 + } 731 797 732 798 static inline void mlx5e_handle_csum(struct net_device *netdev, 733 799 struct mlx5_cqe64 *cqe, ··· 810 752 return; 811 753 } 812 754 813 - if (unlikely(test_bit(MLX5E_RQ_STATE_NO_CSUM_COMPLETE, &rq->state))) 755 + /* True when explicitly set via priv flag, or XDP prog is loaded */ 756 + if (test_bit(MLX5E_RQ_STATE_NO_CSUM_COMPLETE, &rq->state)) 814 757 goto csum_unnecessary; 815 758 816 759 /* CQE csum doesn't cover padding octets in short ethernet ··· 839 780 skb->csum = csum_partial(skb->data + ETH_HLEN, 840 781 network_depth - ETH_HLEN, 841 782 skb->csum); 842 - if (unlikely(netdev->features & NETIF_F_RXFCS)) 843 - skb->csum = csum_block_add(skb->csum, 844 - (__force __wsum)mlx5e_get_fcs(skb), 845 - skb->len - ETH_FCS_LEN); 783 + 784 + mlx5e_skb_padding_csum(skb, network_depth, proto, stats); 846 785 stats->csum_complete++; 847 786 return; 848 787 } 849 788 850 789 csum_unnecessary: 851 790 if (likely((cqe->hds_ip_ext & CQE_L3_OK) && 852 - ((cqe->hds_ip_ext & CQE_L4_OK) || 853 - (get_cqe_l4_hdr_type(cqe) == CQE_L4_HDR_TYPE_NONE)))) { 791 + (cqe->hds_ip_ext & CQE_L4_OK))) { 854 792 skb->ip_summed = CHECKSUM_UNNECESSARY; 855 793 if (cqe_is_tunneled(cqe)) { 856 794 skb->csum_level = 1;
+6
drivers/net/ethernet/mellanox/mlx5/core/en_stats.c
··· 59 59 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_csum_unnecessary) }, 60 60 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_csum_none) }, 61 61 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_csum_complete) }, 62 + { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_csum_complete_tail) }, 63 + { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_csum_complete_tail_slow) }, 62 64 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_csum_unnecessary_inner) }, 63 65 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_xdp_drop) }, 64 66 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_xdp_redirect) }, ··· 153 151 s->rx_removed_vlan_packets += rq_stats->removed_vlan_packets; 154 152 s->rx_csum_none += rq_stats->csum_none; 155 153 s->rx_csum_complete += rq_stats->csum_complete; 154 + s->rx_csum_complete_tail += rq_stats->csum_complete_tail; 155 + s->rx_csum_complete_tail_slow += rq_stats->csum_complete_tail_slow; 156 156 s->rx_csum_unnecessary += rq_stats->csum_unnecessary; 157 157 s->rx_csum_unnecessary_inner += rq_stats->csum_unnecessary_inner; 158 158 s->rx_xdp_drop += rq_stats->xdp_drop; ··· 1194 1190 { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, packets) }, 1195 1191 { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, bytes) }, 1196 1192 { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, csum_complete) }, 1193 + { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, csum_complete_tail) }, 1194 + { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, csum_complete_tail_slow) }, 1197 1195 { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, csum_unnecessary) }, 1198 1196 { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, csum_unnecessary_inner) }, 1199 1197 { MLX5E_DECLARE_RX_STAT(struct mlx5e_rq_stats, csum_none) },
+4
drivers/net/ethernet/mellanox/mlx5/core/en_stats.h
··· 71 71 u64 rx_csum_unnecessary; 72 72 u64 rx_csum_none; 73 73 u64 rx_csum_complete; 74 + u64 rx_csum_complete_tail; 75 + u64 rx_csum_complete_tail_slow; 74 76 u64 rx_csum_unnecessary_inner; 75 77 u64 rx_xdp_drop; 76 78 u64 rx_xdp_redirect; ··· 183 181 u64 packets; 184 182 u64 bytes; 185 183 u64 csum_complete; 184 + u64 csum_complete_tail; 185 + u64 csum_complete_tail_slow; 186 186 u64 csum_unnecessary; 187 187 u64 csum_unnecessary_inner; 188 188 u64 csum_none;
+24 -37
drivers/net/ethernet/mellanox/mlx5/core/fpga/tls.c
··· 148 148 return ret; 149 149 } 150 150 151 - static void mlx5_fpga_tls_release_swid(struct idr *idr, 152 - spinlock_t *idr_spinlock, u32 swid) 151 + static void *mlx5_fpga_tls_release_swid(struct idr *idr, 152 + spinlock_t *idr_spinlock, u32 swid) 153 153 { 154 154 unsigned long flags; 155 + void *ptr; 155 156 156 157 spin_lock_irqsave(idr_spinlock, flags); 157 - idr_remove(idr, swid); 158 + ptr = idr_remove(idr, swid); 158 159 spin_unlock_irqrestore(idr_spinlock, flags); 160 + return ptr; 159 161 } 160 162 161 163 static void mlx_tls_kfree_complete(struct mlx5_fpga_conn *conn, ··· 167 165 kfree(buf); 168 166 } 169 167 170 - struct mlx5_teardown_stream_context { 171 - struct mlx5_fpga_tls_command_context cmd; 172 - u32 swid; 173 - }; 174 - 175 168 static void 176 169 mlx5_fpga_tls_teardown_completion(struct mlx5_fpga_conn *conn, 177 170 struct mlx5_fpga_device *fdev, 178 171 struct mlx5_fpga_tls_command_context *cmd, 179 172 struct mlx5_fpga_dma_buf *resp) 180 173 { 181 - struct mlx5_teardown_stream_context *ctx = 182 - container_of(cmd, struct mlx5_teardown_stream_context, cmd); 183 - 184 174 if (resp) { 185 175 u32 syndrome = MLX5_GET(tls_resp, resp->sg[0].data, syndrome); 186 176 ··· 180 186 mlx5_fpga_err(fdev, 181 187 "Teardown stream failed with syndrome = %d", 182 188 syndrome); 183 - else if (MLX5_GET(tls_cmd, cmd->buf.sg[0].data, direction_sx)) 184 - mlx5_fpga_tls_release_swid(&fdev->tls->tx_idr, 185 - &fdev->tls->tx_idr_spinlock, 186 - ctx->swid); 187 - else 188 - mlx5_fpga_tls_release_swid(&fdev->tls->rx_idr, 189 - &fdev->tls->rx_idr_spinlock, 190 - ctx->swid); 191 189 } 192 190 mlx5_fpga_tls_put_command_ctx(cmd); 193 191 } ··· 203 217 void *cmd; 204 218 int ret; 205 219 206 - rcu_read_lock(); 207 - flow = idr_find(&mdev->fpga->tls->rx_idr, ntohl(handle)); 208 - rcu_read_unlock(); 209 - 210 - if (!flow) { 211 - WARN_ONCE(1, "Received NULL pointer for handle\n"); 212 - return -EINVAL; 213 - } 214 - 215 220 buf = kzalloc(size, GFP_ATOMIC); 216 221 if (!buf) 217 222 return -ENOMEM; 218 223 219 224 cmd = (buf + 1); 220 225 226 + rcu_read_lock(); 227 + flow = idr_find(&mdev->fpga->tls->rx_idr, ntohl(handle)); 228 + if (unlikely(!flow)) { 229 + rcu_read_unlock(); 230 + WARN_ONCE(1, "Received NULL pointer for handle\n"); 231 + kfree(buf); 232 + return -EINVAL; 233 + } 221 234 mlx5_fpga_tls_flow_to_cmd(flow, cmd); 235 + rcu_read_unlock(); 222 236 223 237 MLX5_SET(tls_cmd, cmd, swid, ntohl(handle)); 224 238 MLX5_SET64(tls_cmd, cmd, tls_rcd_sn, be64_to_cpu(rcd_sn)); ··· 239 253 static void mlx5_fpga_tls_send_teardown_cmd(struct mlx5_core_dev *mdev, 240 254 void *flow, u32 swid, gfp_t flags) 241 255 { 242 - struct mlx5_teardown_stream_context *ctx; 256 + struct mlx5_fpga_tls_command_context *ctx; 243 257 struct mlx5_fpga_dma_buf *buf; 244 258 void *cmd; 245 259 ··· 247 261 if (!ctx) 248 262 return; 249 263 250 - buf = &ctx->cmd.buf; 264 + buf = &ctx->buf; 251 265 cmd = (ctx + 1); 252 266 MLX5_SET(tls_cmd, cmd, command_type, CMD_TEARDOWN_STREAM); 253 267 MLX5_SET(tls_cmd, cmd, swid, swid); ··· 258 272 buf->sg[0].data = cmd; 259 273 buf->sg[0].size = MLX5_TLS_COMMAND_SIZE; 260 274 261 - ctx->swid = swid; 262 - mlx5_fpga_tls_cmd_send(mdev->fpga, &ctx->cmd, 275 + mlx5_fpga_tls_cmd_send(mdev->fpga, ctx, 263 276 mlx5_fpga_tls_teardown_completion); 264 277 } 265 278 ··· 268 283 struct mlx5_fpga_tls *tls = mdev->fpga->tls; 269 284 void *flow; 270 285 271 - rcu_read_lock(); 272 286 if (direction_sx) 273 - flow = idr_find(&tls->tx_idr, swid); 287 + flow = mlx5_fpga_tls_release_swid(&tls->tx_idr, 288 + &tls->tx_idr_spinlock, 289 + swid); 274 290 else 275 - flow = idr_find(&tls->rx_idr, swid); 276 - 277 - rcu_read_unlock(); 291 + flow = mlx5_fpga_tls_release_swid(&tls->rx_idr, 292 + &tls->rx_idr_spinlock, 293 + swid); 278 294 279 295 if (!flow) { 280 296 mlx5_fpga_err(mdev->fpga, "No flow information for swid %u\n", ··· 283 297 return; 284 298 } 285 299 300 + synchronize_rcu(); /* before kfree(flow) */ 286 301 mlx5_fpga_tls_send_teardown_cmd(mdev, flow, swid, flags); 287 302 } 288 303
+3 -3
drivers/net/ethernet/mellanox/mlxsw/core.c
··· 568 568 if (!(mlxsw_core->bus->features & MLXSW_BUS_F_TXRX)) 569 569 return 0; 570 570 571 - emad_wq = alloc_workqueue("mlxsw_core_emad", WQ_MEM_RECLAIM, 0); 571 + emad_wq = alloc_workqueue("mlxsw_core_emad", 0, 0); 572 572 if (!emad_wq) 573 573 return -ENOMEM; 574 574 mlxsw_core->emad_wq = emad_wq; ··· 2004 2004 { 2005 2005 int err; 2006 2006 2007 - mlxsw_wq = alloc_workqueue(mlxsw_core_driver_name, WQ_MEM_RECLAIM, 0); 2007 + mlxsw_wq = alloc_workqueue(mlxsw_core_driver_name, 0, 0); 2008 2008 if (!mlxsw_wq) 2009 2009 return -ENOMEM; 2010 - mlxsw_owq = alloc_ordered_workqueue("%s_ordered", WQ_MEM_RECLAIM, 2010 + mlxsw_owq = alloc_ordered_workqueue("%s_ordered", 0, 2011 2011 mlxsw_core_driver_name); 2012 2012 if (!mlxsw_owq) { 2013 2013 err = -ENOMEM;
+11 -8
drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c
··· 70 70 {MLXSW_REG_SBXX_DIR_EGRESS, 1}, 71 71 {MLXSW_REG_SBXX_DIR_EGRESS, 2}, 72 72 {MLXSW_REG_SBXX_DIR_EGRESS, 3}, 73 + {MLXSW_REG_SBXX_DIR_EGRESS, 15}, 73 74 }; 74 75 75 76 #define MLXSW_SP_SB_ING_TC_COUNT 8 ··· 429 428 MLXSW_SP_SB_PR(MLXSW_REG_SBPR_MODE_STATIC, 0), 430 429 MLXSW_SP_SB_PR(MLXSW_REG_SBPR_MODE_STATIC, 0), 431 430 MLXSW_SP_SB_PR(MLXSW_REG_SBPR_MODE_STATIC, 0), 431 + MLXSW_SP_SB_PR(MLXSW_REG_SBPR_MODE_STATIC, MLXSW_SP_SB_INFI), 432 432 }; 433 433 434 434 static int mlxsw_sp_sb_prs_init(struct mlxsw_sp *mlxsw_sp, ··· 519 517 MLXSW_SP_SB_CM(0, 7, 4), 520 518 MLXSW_SP_SB_CM(0, 7, 4), 521 519 MLXSW_SP_SB_CM(0, 7, 4), 522 - MLXSW_SP_SB_CM(0, 7, 4), 523 - MLXSW_SP_SB_CM(0, 7, 4), 524 - MLXSW_SP_SB_CM(0, 7, 4), 525 - MLXSW_SP_SB_CM(0, 7, 4), 526 - MLXSW_SP_SB_CM(0, 7, 4), 527 - MLXSW_SP_SB_CM(0, 7, 4), 528 - MLXSW_SP_SB_CM(0, 7, 4), 529 - MLXSW_SP_SB_CM(0, 7, 4), 520 + MLXSW_SP_SB_CM(0, MLXSW_SP_SB_INFI, 8), 521 + MLXSW_SP_SB_CM(0, MLXSW_SP_SB_INFI, 8), 522 + MLXSW_SP_SB_CM(0, MLXSW_SP_SB_INFI, 8), 523 + MLXSW_SP_SB_CM(0, MLXSW_SP_SB_INFI, 8), 524 + MLXSW_SP_SB_CM(0, MLXSW_SP_SB_INFI, 8), 525 + MLXSW_SP_SB_CM(0, MLXSW_SP_SB_INFI, 8), 526 + MLXSW_SP_SB_CM(0, MLXSW_SP_SB_INFI, 8), 527 + MLXSW_SP_SB_CM(0, MLXSW_SP_SB_INFI, 8), 530 528 MLXSW_SP_SB_CM(1, 0xff, 4), 531 529 }; 532 530 ··· 673 671 MLXSW_SP_SB_PM(0, 0), 674 672 MLXSW_SP_SB_PM(0, 0), 675 673 MLXSW_SP_SB_PM(0, 0), 674 + MLXSW_SP_SB_PM(10000, 90000), 676 675 }; 677 676 678 677 static int mlxsw_sp_port_sb_pms_init(struct mlxsw_sp_port *mlxsw_sp_port)
+1 -1
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
··· 6804 6804 /* A RIF is not created for macvlan netdevs. Their MAC is used to 6805 6805 * populate the FDB 6806 6806 */ 6807 - if (netif_is_macvlan(dev)) 6807 + if (netif_is_macvlan(dev) || netif_is_l3_master(dev)) 6808 6808 return 0; 6809 6809 6810 6810 for (i = 0; i < MLXSW_CORE_RES_GET(mlxsw_sp->core, MAX_RIFS); i++) {
+1 -1
drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
··· 1630 1630 u16 fid_index; 1631 1631 int err = 0; 1632 1632 1633 - if (switchdev_trans_ph_prepare(trans)) 1633 + if (switchdev_trans_ph_commit(trans)) 1634 1634 return 0; 1635 1635 1636 1636 bridge_port = mlxsw_sp_bridge_port_find(mlxsw_sp->bridge, orig_dev);
+15 -9
drivers/net/ethernet/mscc/ocelot.c
··· 613 613 struct netdev_hw_addr *hw_addr) 614 614 { 615 615 struct ocelot *ocelot = port->ocelot; 616 - struct netdev_hw_addr *ha = kzalloc(sizeof(*ha), GFP_KERNEL); 616 + struct netdev_hw_addr *ha = kzalloc(sizeof(*ha), GFP_ATOMIC); 617 617 618 618 if (!ha) 619 619 return -ENOMEM; ··· 959 959 ETH_GSTRING_LEN); 960 960 } 961 961 962 - static void ocelot_check_stats(struct work_struct *work) 962 + static void ocelot_update_stats(struct ocelot *ocelot) 963 963 { 964 - struct delayed_work *del_work = to_delayed_work(work); 965 - struct ocelot *ocelot = container_of(del_work, struct ocelot, stats_work); 966 964 int i, j; 967 965 968 966 mutex_lock(&ocelot->stats_lock); ··· 984 986 } 985 987 } 986 988 987 - cancel_delayed_work(&ocelot->stats_work); 989 + mutex_unlock(&ocelot->stats_lock); 990 + } 991 + 992 + static void ocelot_check_stats_work(struct work_struct *work) 993 + { 994 + struct delayed_work *del_work = to_delayed_work(work); 995 + struct ocelot *ocelot = container_of(del_work, struct ocelot, 996 + stats_work); 997 + 998 + ocelot_update_stats(ocelot); 999 + 988 1000 queue_delayed_work(ocelot->stats_queue, &ocelot->stats_work, 989 1001 OCELOT_STATS_CHECK_DELAY); 990 - 991 - mutex_unlock(&ocelot->stats_lock); 992 1002 } 993 1003 994 1004 static void ocelot_get_ethtool_stats(struct net_device *dev, ··· 1007 1001 int i; 1008 1002 1009 1003 /* check and update now */ 1010 - ocelot_check_stats(&ocelot->stats_work.work); 1004 + ocelot_update_stats(ocelot); 1011 1005 1012 1006 /* Copy all counters */ 1013 1007 for (i = 0; i < ocelot->num_stats; i++) ··· 1815 1809 ANA_CPUQ_8021_CFG_CPUQ_BPDU_VAL(6), 1816 1810 ANA_CPUQ_8021_CFG, i); 1817 1811 1818 - INIT_DELAYED_WORK(&ocelot->stats_work, ocelot_check_stats); 1812 + INIT_DELAYED_WORK(&ocelot->stats_work, ocelot_check_stats_work); 1819 1813 queue_delayed_work(ocelot->stats_queue, &ocelot->stats_work, 1820 1814 OCELOT_STATS_CHECK_DELAY); 1821 1815 return 0;
+1
drivers/net/ethernet/neterion/vxge/vxge-config.c
··· 2366 2366 dma_object->addr))) { 2367 2367 vxge_os_dma_free(devh->pdev, memblock, 2368 2368 &dma_object->acc_handle); 2369 + memblock = NULL; 2369 2370 goto exit; 2370 2371 } 2371 2372
+5 -2
drivers/net/ethernet/qlogic/qed/qed.h
··· 431 431 u8 num_pf_rls; 432 432 }; 433 433 434 + #define QED_OVERFLOW_BIT 1 435 + 434 436 struct qed_db_recovery_info { 435 437 struct list_head list; 436 438 437 439 /* Lock to protect the doorbell recovery mechanism list */ 438 440 spinlock_t lock; 441 + bool dorq_attn; 439 442 u32 db_recovery_counter; 443 + unsigned long overflow; 440 444 }; 441 445 442 446 struct storm_stats { ··· 927 923 928 924 /* doorbell recovery mechanism */ 929 925 void qed_db_recovery_dp(struct qed_hwfn *p_hwfn); 930 - void qed_db_recovery_execute(struct qed_hwfn *p_hwfn, 931 - enum qed_db_rec_exec db_exec); 926 + void qed_db_recovery_execute(struct qed_hwfn *p_hwfn); 932 927 bool qed_edpm_enabled(struct qed_hwfn *p_hwfn); 933 928 934 929 /* Other Linux specific common definitions */
+33 -50
drivers/net/ethernet/qlogic/qed/qed_dev.c
··· 102 102 103 103 /* Doorbell address sanity (address within doorbell bar range) */ 104 104 static bool qed_db_rec_sanity(struct qed_dev *cdev, 105 - void __iomem *db_addr, void *db_data) 105 + void __iomem *db_addr, 106 + enum qed_db_rec_width db_width, 107 + void *db_data) 106 108 { 109 + u32 width = (db_width == DB_REC_WIDTH_32B) ? 32 : 64; 110 + 107 111 /* Make sure doorbell address is within the doorbell bar */ 108 112 if (db_addr < cdev->doorbells || 109 - (u8 __iomem *)db_addr > 113 + (u8 __iomem *)db_addr + width > 110 114 (u8 __iomem *)cdev->doorbells + cdev->db_size) { 111 115 WARN(true, 112 116 "Illegal doorbell address: %p. Legal range for doorbell addresses is [%p..%p]\n", ··· 163 159 } 164 160 165 161 /* Sanitize doorbell address */ 166 - if (!qed_db_rec_sanity(cdev, db_addr, db_data)) 162 + if (!qed_db_rec_sanity(cdev, db_addr, db_width, db_data)) 167 163 return -EINVAL; 168 164 169 165 /* Obtain hwfn from doorbell address */ ··· 208 204 QED_MSG_IOV, "db recovery - skipping VF doorbell\n"); 209 205 return 0; 210 206 } 211 - 212 - /* Sanitize doorbell address */ 213 - if (!qed_db_rec_sanity(cdev, db_addr, db_data)) 214 - return -EINVAL; 215 207 216 208 /* Obtain hwfn from doorbell address */ 217 209 p_hwfn = qed_db_rec_find_hwfn(cdev, db_addr); ··· 300 300 301 301 /* Ring the doorbell of a single doorbell recovery entry */ 302 302 static void qed_db_recovery_ring(struct qed_hwfn *p_hwfn, 303 - struct qed_db_recovery_entry *db_entry, 304 - enum qed_db_rec_exec db_exec) 303 + struct qed_db_recovery_entry *db_entry) 305 304 { 306 - if (db_exec != DB_REC_ONCE) { 307 - /* Print according to width */ 308 - if (db_entry->db_width == DB_REC_WIDTH_32B) { 309 - DP_VERBOSE(p_hwfn, QED_MSG_SPQ, 310 - "%s doorbell address %p data %x\n", 311 - db_exec == DB_REC_DRY_RUN ? 312 - "would have rung" : "ringing", 313 - db_entry->db_addr, 314 - *(u32 *)db_entry->db_data); 315 - } else { 316 - DP_VERBOSE(p_hwfn, QED_MSG_SPQ, 317 - "%s doorbell address %p data %llx\n", 318 - db_exec == DB_REC_DRY_RUN ? 319 - "would have rung" : "ringing", 320 - db_entry->db_addr, 321 - *(u64 *)(db_entry->db_data)); 322 - } 305 + /* Print according to width */ 306 + if (db_entry->db_width == DB_REC_WIDTH_32B) { 307 + DP_VERBOSE(p_hwfn, QED_MSG_SPQ, 308 + "ringing doorbell address %p data %x\n", 309 + db_entry->db_addr, 310 + *(u32 *)db_entry->db_data); 311 + } else { 312 + DP_VERBOSE(p_hwfn, QED_MSG_SPQ, 313 + "ringing doorbell address %p data %llx\n", 314 + db_entry->db_addr, 315 + *(u64 *)(db_entry->db_data)); 323 316 } 324 317 325 318 /* Sanity */ 326 319 if (!qed_db_rec_sanity(p_hwfn->cdev, db_entry->db_addr, 327 - db_entry->db_data)) 320 + db_entry->db_width, db_entry->db_data)) 328 321 return; 329 322 330 323 /* Flush the write combined buffer. Since there are multiple doorbelling ··· 327 334 wmb(); 328 335 329 336 /* Ring the doorbell */ 330 - if (db_exec == DB_REC_REAL_DEAL || db_exec == DB_REC_ONCE) { 331 - if (db_entry->db_width == DB_REC_WIDTH_32B) 332 - DIRECT_REG_WR(db_entry->db_addr, 333 - *(u32 *)(db_entry->db_data)); 334 - else 335 - DIRECT_REG_WR64(db_entry->db_addr, 336 - *(u64 *)(db_entry->db_data)); 337 - } 337 + if (db_entry->db_width == DB_REC_WIDTH_32B) 338 + DIRECT_REG_WR(db_entry->db_addr, 339 + *(u32 *)(db_entry->db_data)); 340 + else 341 + DIRECT_REG_WR64(db_entry->db_addr, 342 + *(u64 *)(db_entry->db_data)); 338 343 339 344 /* Flush the write combined buffer. Next doorbell may come from a 340 345 * different entity to the same address... ··· 341 350 } 342 351 343 352 /* Traverse the doorbell recovery entry list and ring all the doorbells */ 344 - void qed_db_recovery_execute(struct qed_hwfn *p_hwfn, 345 - enum qed_db_rec_exec db_exec) 353 + void qed_db_recovery_execute(struct qed_hwfn *p_hwfn) 346 354 { 347 355 struct qed_db_recovery_entry *db_entry = NULL; 348 356 349 - if (db_exec != DB_REC_ONCE) { 350 - DP_NOTICE(p_hwfn, 351 - "Executing doorbell recovery. Counter was %d\n", 352 - p_hwfn->db_recovery_info.db_recovery_counter); 357 + DP_NOTICE(p_hwfn, "Executing doorbell recovery. Counter was %d\n", 358 + p_hwfn->db_recovery_info.db_recovery_counter); 353 359 354 - /* Track amount of times recovery was executed */ 355 - p_hwfn->db_recovery_info.db_recovery_counter++; 356 - } 360 + /* Track amount of times recovery was executed */ 361 + p_hwfn->db_recovery_info.db_recovery_counter++; 357 362 358 363 /* Protect the list */ 359 364 spin_lock_bh(&p_hwfn->db_recovery_info.lock); 360 365 list_for_each_entry(db_entry, 361 - &p_hwfn->db_recovery_info.list, list_entry) { 362 - qed_db_recovery_ring(p_hwfn, db_entry, db_exec); 363 - if (db_exec == DB_REC_ONCE) 364 - break; 365 - } 366 - 366 + &p_hwfn->db_recovery_info.list, list_entry) 367 + qed_db_recovery_ring(p_hwfn, db_entry); 367 368 spin_unlock_bh(&p_hwfn->db_recovery_info.lock); 368 369 } 369 370
+64 -21
drivers/net/ethernet/qlogic/qed/qed_int.c
··· 378 378 u32 count = QED_DB_REC_COUNT; 379 379 u32 usage = 1; 380 380 381 + /* Flush any pending (e)dpms as they may never arrive */ 382 + qed_wr(p_hwfn, p_ptt, DORQ_REG_DPM_FORCE_ABORT, 0x1); 383 + 381 384 /* wait for usage to zero or count to run out. This is necessary since 382 385 * EDPM doorbell transactions can take multiple 64b cycles, and as such 383 386 * can "split" over the pci. Possibly, the doorbell drop can happen with ··· 409 406 410 407 int qed_db_rec_handler(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt) 411 408 { 412 - u32 overflow; 409 + u32 attn_ovfl, cur_ovfl; 413 410 int rc; 414 411 415 - overflow = qed_rd(p_hwfn, p_ptt, DORQ_REG_PF_OVFL_STICKY); 416 - DP_NOTICE(p_hwfn, "PF Overflow sticky 0x%x\n", overflow); 417 - if (!overflow) { 418 - qed_db_recovery_execute(p_hwfn, DB_REC_ONCE); 412 + attn_ovfl = test_and_clear_bit(QED_OVERFLOW_BIT, 413 + &p_hwfn->db_recovery_info.overflow); 414 + cur_ovfl = qed_rd(p_hwfn, p_ptt, DORQ_REG_PF_OVFL_STICKY); 415 + if (!cur_ovfl && !attn_ovfl) 419 416 return 0; 420 - } 421 417 422 - if (qed_edpm_enabled(p_hwfn)) { 418 + DP_NOTICE(p_hwfn, "PF Overflow sticky: attn %u current %u\n", 419 + attn_ovfl, cur_ovfl); 420 + 421 + if (cur_ovfl && !p_hwfn->db_bar_no_edpm) { 423 422 rc = qed_db_rec_flush_queue(p_hwfn, p_ptt); 424 423 if (rc) 425 424 return rc; 426 425 } 427 426 428 - /* Flush any pending (e)dpm as they may never arrive */ 429 - qed_wr(p_hwfn, p_ptt, DORQ_REG_DPM_FORCE_ABORT, 0x1); 430 - 431 427 /* Release overflow sticky indication (stop silently dropping everything) */ 432 428 qed_wr(p_hwfn, p_ptt, DORQ_REG_PF_OVFL_STICKY, 0x0); 433 429 434 430 /* Repeat all last doorbells (doorbell drop recovery) */ 435 - qed_db_recovery_execute(p_hwfn, DB_REC_REAL_DEAL); 431 + qed_db_recovery_execute(p_hwfn); 436 432 437 433 return 0; 438 434 } 439 435 440 - static int qed_dorq_attn_cb(struct qed_hwfn *p_hwfn) 436 + static void qed_dorq_attn_overflow(struct qed_hwfn *p_hwfn) 437 + { 438 + struct qed_ptt *p_ptt = p_hwfn->p_dpc_ptt; 439 + u32 overflow; 440 + int rc; 441 + 442 + overflow = qed_rd(p_hwfn, p_ptt, DORQ_REG_PF_OVFL_STICKY); 443 + if (!overflow) 444 + goto out; 445 + 446 + /* Run PF doorbell recovery in next periodic handler */ 447 + set_bit(QED_OVERFLOW_BIT, &p_hwfn->db_recovery_info.overflow); 448 + 449 + if (!p_hwfn->db_bar_no_edpm) { 450 + rc = qed_db_rec_flush_queue(p_hwfn, p_ptt); 451 + if (rc) 452 + goto out; 453 + } 454 + 455 + qed_wr(p_hwfn, p_ptt, DORQ_REG_PF_OVFL_STICKY, 0x0); 456 + out: 457 + /* Schedule the handler even if overflow was not detected */ 458 + qed_periodic_db_rec_start(p_hwfn); 459 + } 460 + 461 + static int qed_dorq_attn_int_sts(struct qed_hwfn *p_hwfn) 441 462 { 442 463 u32 int_sts, first_drop_reason, details, address, all_drops_reason; 443 464 struct qed_ptt *p_ptt = p_hwfn->p_dpc_ptt; 444 - int rc; 445 - 446 - int_sts = qed_rd(p_hwfn, p_ptt, DORQ_REG_INT_STS); 447 - DP_NOTICE(p_hwfn->cdev, "DORQ attention. int_sts was %x\n", int_sts); 448 465 449 466 /* int_sts may be zero since all PFs were interrupted for doorbell 450 467 * overflow but another one already handled it. Can abort here. If 451 468 * This PF also requires overflow recovery we will be interrupted again. 452 469 * The masked almost full indication may also be set. Ignoring. 453 470 */ 471 + int_sts = qed_rd(p_hwfn, p_ptt, DORQ_REG_INT_STS); 454 472 if (!(int_sts & ~DORQ_REG_INT_STS_DORQ_FIFO_AFULL)) 455 473 return 0; 474 + 475 + DP_NOTICE(p_hwfn->cdev, "DORQ attention. int_sts was %x\n", int_sts); 456 476 457 477 /* check if db_drop or overflow happened */ 458 478 if (int_sts & (DORQ_REG_INT_STS_DB_DROP | ··· 503 477 GET_FIELD(details, QED_DORQ_ATTENTION_SIZE) * 4, 504 478 first_drop_reason, all_drops_reason); 505 479 506 - rc = qed_db_rec_handler(p_hwfn, p_ptt); 507 - qed_periodic_db_rec_start(p_hwfn); 508 - if (rc) 509 - return rc; 510 - 511 480 /* Clear the doorbell drop details and prepare for next drop */ 512 481 qed_wr(p_hwfn, p_ptt, DORQ_REG_DB_DROP_DETAILS_REL, 0); 513 482 ··· 526 505 DP_INFO(p_hwfn, "DORQ fatal attention\n"); 527 506 528 507 return -EINVAL; 508 + } 509 + 510 + static int qed_dorq_attn_cb(struct qed_hwfn *p_hwfn) 511 + { 512 + p_hwfn->db_recovery_info.dorq_attn = true; 513 + qed_dorq_attn_overflow(p_hwfn); 514 + 515 + return qed_dorq_attn_int_sts(p_hwfn); 516 + } 517 + 518 + static void qed_dorq_attn_handler(struct qed_hwfn *p_hwfn) 519 + { 520 + if (p_hwfn->db_recovery_info.dorq_attn) 521 + goto out; 522 + 523 + /* Call DORQ callback if the attention was missed */ 524 + qed_dorq_attn_cb(p_hwfn); 525 + out: 526 + p_hwfn->db_recovery_info.dorq_attn = false; 529 527 } 530 528 531 529 /* Instead of major changes to the data-structure, we have a some 'special' ··· 1119 1079 } 1120 1080 } 1121 1081 } 1082 + 1083 + /* Handle missed DORQ attention */ 1084 + qed_dorq_attn_handler(p_hwfn); 1122 1085 1123 1086 /* Clear IGU indication for the deasserted bits */ 1124 1087 DIRECT_REG_WR((u8 __iomem *)p_hwfn->regview +
+2 -2
drivers/net/ethernet/qlogic/qed/qed_int.h
··· 192 192 193 193 /** 194 194 * @brief - Doorbell Recovery handler. 195 - * Run DB_REAL_DEAL doorbell recovery in case of PF overflow 196 - * (and flush DORQ if needed), otherwise run DB_REC_ONCE. 195 + * Run doorbell recovery in case of PF overflow (and flush DORQ if 196 + * needed). 197 197 * 198 198 * @param p_hwfn 199 199 * @param p_ptt
+1 -1
drivers/net/ethernet/qlogic/qed/qed_main.c
··· 970 970 } 971 971 } 972 972 973 - #define QED_PERIODIC_DB_REC_COUNT 100 973 + #define QED_PERIODIC_DB_REC_COUNT 10 974 974 #define QED_PERIODIC_DB_REC_INTERVAL_MS 100 975 975 #define QED_PERIODIC_DB_REC_INTERVAL \ 976 976 msecs_to_jiffies(QED_PERIODIC_DB_REC_INTERVAL_MS)
+1 -1
drivers/net/ethernet/qlogic/qed/qed_sriov.c
··· 1591 1591 p_vfdev->eth_fp_hsi_minor = ETH_HSI_VER_NO_PKT_LEN_TUNN; 1592 1592 } else { 1593 1593 DP_INFO(p_hwfn, 1594 - "VF[%d] needs fastpath HSI %02x.%02x, which is incompatible with loaded FW's faspath HSI %02x.%02x\n", 1594 + "VF[%d] needs fastpath HSI %02x.%02x, which is incompatible with loaded FW's fastpath HSI %02x.%02x\n", 1595 1595 vf->abs_vf_id, 1596 1596 req->vfdev_info.eth_fp_hsi_major, 1597 1597 req->vfdev_info.eth_fp_hsi_minor,
+3 -4
drivers/net/ethernet/qlogic/qede/qede_ptp.c
··· 490 490 491 491 ptp->clock = ptp_clock_register(&ptp->clock_info, &edev->pdev->dev); 492 492 if (IS_ERR(ptp->clock)) { 493 - rc = -EINVAL; 494 493 DP_ERR(edev, "PTP clock registration failed\n"); 494 + qede_ptp_disable(edev); 495 + rc = -EINVAL; 495 496 goto err2; 496 497 } 497 498 498 499 return 0; 499 500 500 - err2: 501 - qede_ptp_disable(edev); 502 - ptp->clock = NULL; 503 501 err1: 504 502 kfree(ptp); 503 + err2: 505 504 edev->ptp = NULL; 506 505 507 506 return rc;
+26
drivers/net/team/team.c
··· 1244 1244 goto err_option_port_add; 1245 1245 } 1246 1246 1247 + /* set promiscuity level to new slave */ 1248 + if (dev->flags & IFF_PROMISC) { 1249 + err = dev_set_promiscuity(port_dev, 1); 1250 + if (err) 1251 + goto err_set_slave_promisc; 1252 + } 1253 + 1254 + /* set allmulti level to new slave */ 1255 + if (dev->flags & IFF_ALLMULTI) { 1256 + err = dev_set_allmulti(port_dev, 1); 1257 + if (err) { 1258 + if (dev->flags & IFF_PROMISC) 1259 + dev_set_promiscuity(port_dev, -1); 1260 + goto err_set_slave_promisc; 1261 + } 1262 + } 1263 + 1247 1264 netif_addr_lock_bh(dev); 1248 1265 dev_uc_sync_multiple(port_dev, dev); 1249 1266 dev_mc_sync_multiple(port_dev, dev); ··· 1276 1259 netdev_info(dev, "Port device %s added\n", portname); 1277 1260 1278 1261 return 0; 1262 + 1263 + err_set_slave_promisc: 1264 + __team_option_inst_del_port(team, port); 1279 1265 1280 1266 err_option_port_add: 1281 1267 team_upper_dev_unlink(team, port); ··· 1325 1305 1326 1306 team_port_disable(team, port); 1327 1307 list_del_rcu(&port->list); 1308 + 1309 + if (dev->flags & IFF_PROMISC) 1310 + dev_set_promiscuity(port_dev, -1); 1311 + if (dev->flags & IFF_ALLMULTI) 1312 + dev_set_allmulti(port_dev, -1); 1313 + 1328 1314 team_upper_dev_unlink(team, port); 1329 1315 netdev_rx_handler_unregister(port_dev); 1330 1316 team_port_disable_netpoll(port);
+1 -1
drivers/net/wireless/ath/ath10k/htt_rx.c
··· 2728 2728 num_msdus++; 2729 2729 num_bytes += ret; 2730 2730 } 2731 - ieee80211_return_txq(hw, txq); 2731 + ieee80211_return_txq(hw, txq, false); 2732 2732 ieee80211_txq_schedule_end(hw, txq->ac); 2733 2733 2734 2734 record->num_msdus = cpu_to_le16(num_msdus);
+2 -2
drivers/net/wireless/ath/ath10k/mac.c
··· 4089 4089 if (ret < 0) 4090 4090 break; 4091 4091 } 4092 - ieee80211_return_txq(hw, txq); 4092 + ieee80211_return_txq(hw, txq, false); 4093 4093 ath10k_htt_tx_txq_update(hw, txq); 4094 4094 if (ret == -EBUSY) 4095 4095 break; ··· 4374 4374 if (ret < 0) 4375 4375 break; 4376 4376 } 4377 - ieee80211_return_txq(hw, txq); 4377 + ieee80211_return_txq(hw, txq, false); 4378 4378 ath10k_htt_tx_txq_update(hw, txq); 4379 4379 out: 4380 4380 ieee80211_txq_schedule_end(hw, ac);
+4 -1
drivers/net/wireless/ath/ath9k/xmit.c
··· 1938 1938 goto out; 1939 1939 1940 1940 while ((queue = ieee80211_next_txq(hw, txq->mac80211_qnum))) { 1941 + bool force; 1942 + 1941 1943 tid = (struct ath_atx_tid *)queue->drv_priv; 1942 1944 1943 1945 ret = ath_tx_sched_aggr(sc, txq, tid); 1944 1946 ath_dbg(common, QUEUE, "ath_tx_sched_aggr returned %d\n", ret); 1945 1947 1946 - ieee80211_return_txq(hw, queue); 1948 + force = !skb_queue_empty(&tid->retry_q); 1949 + ieee80211_return_txq(hw, queue, force); 1947 1950 } 1948 1951 1949 1952 out:
+22 -8
drivers/net/wireless/intel/iwlwifi/cfg/22000.c
··· 82 82 #define IWL_22000_HR_A0_FW_PRE "iwlwifi-QuQnj-a0-hr-a0-" 83 83 #define IWL_22000_SU_Z0_FW_PRE "iwlwifi-su-z0-" 84 84 #define IWL_QU_B_JF_B_FW_PRE "iwlwifi-Qu-b0-jf-b0-" 85 + #define IWL_QUZ_A_HR_B_FW_PRE "iwlwifi-QuZ-a0-hr-b0-" 85 86 #define IWL_QNJ_B_JF_B_FW_PRE "iwlwifi-QuQnj-b0-jf-b0-" 86 87 #define IWL_CC_A_FW_PRE "iwlwifi-cc-a0-" 87 88 #define IWL_22000_SO_A_JF_B_FW_PRE "iwlwifi-so-a0-jf-b0-" ··· 106 105 IWL_22000_HR_A0_FW_PRE __stringify(api) ".ucode" 107 106 #define IWL_22000_SU_Z0_MODULE_FIRMWARE(api) \ 108 107 IWL_22000_SU_Z0_FW_PRE __stringify(api) ".ucode" 109 - #define IWL_QU_B_JF_B_MODULE_FIRMWARE(api) \ 110 - IWL_QU_B_JF_B_FW_PRE __stringify(api) ".ucode" 108 + #define IWL_QUZ_A_HR_B_MODULE_FIRMWARE(api) \ 109 + IWL_QUZ_A_HR_B_FW_PRE __stringify(api) ".ucode" 111 110 #define IWL_QU_B_JF_B_MODULE_FIRMWARE(api) \ 112 111 IWL_QU_B_JF_B_FW_PRE __stringify(api) ".ucode" 113 112 #define IWL_QNJ_B_JF_B_MODULE_FIRMWARE(api) \ ··· 236 235 .max_tx_agg_size = IEEE80211_MAX_AMPDU_BUF_HT, 237 236 }; 238 237 239 - const struct iwl_cfg iwl22260_2ax_cfg = { 240 - .name = "Intel(R) Wireless-AX 22260", 238 + const struct iwl_cfg iwl_ax101_cfg_quz_hr = { 239 + .name = "Intel(R) Wi-Fi 6 AX101", 240 + .fw_name_pre = IWL_QUZ_A_HR_B_FW_PRE, 241 + IWL_DEVICE_22500, 242 + /* 243 + * This device doesn't support receiving BlockAck with a large bitmap 244 + * so we need to restrict the size of transmitted aggregation to the 245 + * HT size; mac80211 would otherwise pick the HE max (256) by default. 246 + */ 247 + .max_tx_agg_size = IEEE80211_MAX_AMPDU_BUF_HT, 248 + }; 249 + 250 + const struct iwl_cfg iwl_ax200_cfg_cc = { 251 + .name = "Intel(R) Wi-Fi 6 AX200 160MHz", 241 252 .fw_name_pre = IWL_CC_A_FW_PRE, 242 253 IWL_DEVICE_22500, 243 254 /* ··· 262 249 }; 263 250 264 251 const struct iwl_cfg killer1650x_2ax_cfg = { 265 - .name = "Killer(R) Wireless-AX 1650x Wireless Network Adapter (200NGW)", 252 + .name = "Killer(R) Wi-Fi 6 AX1650x 160MHz Wireless Network Adapter (200NGW)", 266 253 .fw_name_pre = IWL_CC_A_FW_PRE, 267 254 IWL_DEVICE_22500, 268 255 /* ··· 275 262 }; 276 263 277 264 const struct iwl_cfg killer1650w_2ax_cfg = { 278 - .name = "Killer(R) Wireless-AX 1650w Wireless Network Adapter (200D2W)", 265 + .name = "Killer(R) Wi-Fi 6 AX1650w 160MHz Wireless Network Adapter (200D2W)", 279 266 .fw_name_pre = IWL_CC_A_FW_PRE, 280 267 IWL_DEVICE_22500, 281 268 /* ··· 341 328 }; 342 329 343 330 const struct iwl_cfg killer1650s_2ax_cfg_qu_b0_hr_b0 = { 344 - .name = "Killer(R) Wireless-AX 1650i Wireless Network Adapter (22560NGW)", 331 + .name = "Killer(R) Wi-Fi 6 AX1650i 160MHz Wireless Network Adapter (201NGW)", 345 332 .fw_name_pre = IWL_22000_QU_B_HR_B_FW_PRE, 346 333 IWL_DEVICE_22500, 347 334 /* ··· 353 340 }; 354 341 355 342 const struct iwl_cfg killer1650i_2ax_cfg_qu_b0_hr_b0 = { 356 - .name = "Killer(R) Wireless-AX 1650s Wireless Network Adapter (22560D2W)", 343 + .name = "Killer(R) Wi-Fi 6 AX1650s 160MHz Wireless Network Adapter (201D2W)", 357 344 .fw_name_pre = IWL_22000_QU_B_HR_B_FW_PRE, 358 345 IWL_DEVICE_22500, 359 346 /* ··· 457 444 MODULE_FIRMWARE(IWL_22000_HR_A0_QNJ_MODULE_FIRMWARE(IWL_22000_UCODE_API_MAX)); 458 445 MODULE_FIRMWARE(IWL_22000_SU_Z0_MODULE_FIRMWARE(IWL_22000_UCODE_API_MAX)); 459 446 MODULE_FIRMWARE(IWL_QU_B_JF_B_MODULE_FIRMWARE(IWL_22000_UCODE_API_MAX)); 447 + MODULE_FIRMWARE(IWL_QUZ_A_HR_B_MODULE_FIRMWARE(IWL_22000_UCODE_API_MAX)); 460 448 MODULE_FIRMWARE(IWL_QNJ_B_JF_B_MODULE_FIRMWARE(IWL_22000_UCODE_API_MAX)); 461 449 MODULE_FIRMWARE(IWL_CC_A_MODULE_FIRMWARE(IWL_22000_UCODE_API_MAX)); 462 450 MODULE_FIRMWARE(IWL_22000_SO_A_JF_B_MODULE_FIRMWARE(IWL_22000_UCODE_API_MAX));
+8 -26
drivers/net/wireless/intel/iwlwifi/fw/dbg.c
··· 1614 1614 if (!range) { 1615 1615 IWL_ERR(fwrt, "Failed to fill region header: id=%d, type=%d\n", 1616 1616 le32_to_cpu(reg->region_id), type); 1617 + memset(*data, 0, le32_to_cpu((*data)->len)); 1617 1618 return; 1618 1619 } 1619 1620 ··· 1624 1623 if (range_size < 0) { 1625 1624 IWL_ERR(fwrt, "Failed to dump region: id=%d, type=%d\n", 1626 1625 le32_to_cpu(reg->region_id), type); 1626 + memset(*data, 0, le32_to_cpu((*data)->len)); 1627 1627 return; 1628 1628 } 1629 1629 range = range + range_size; ··· 1809 1807 1810 1808 trigger = fwrt->dump.active_trigs[id].trig; 1811 1809 1812 - size = sizeof(*dump_file); 1813 - size += iwl_fw_ini_get_trigger_len(fwrt, trigger); 1814 - 1810 + size = iwl_fw_ini_get_trigger_len(fwrt, trigger); 1815 1811 if (!size) 1816 1812 return NULL; 1813 + 1814 + size += sizeof(*dump_file); 1817 1815 1818 1816 dump_file = vzalloc(size); 1819 1817 if (!dump_file) ··· 1944 1942 iwl_dump_error_desc->len = 0; 1945 1943 1946 1944 ret = iwl_fw_dbg_collect_desc(fwrt, iwl_dump_error_desc, false, 0); 1947 - if (ret) { 1945 + if (ret) 1948 1946 kfree(iwl_dump_error_desc); 1949 - } else { 1950 - set_bit(STATUS_FW_WAIT_DUMP, &fwrt->trans->status); 1951 - 1952 - /* trigger nmi to halt the fw */ 1953 - iwl_force_nmi(fwrt->trans); 1954 - } 1947 + else 1948 + iwl_trans_sync_nmi(fwrt->trans); 1955 1949 1956 1950 return ret; 1957 1951 } ··· 2487 2489 2488 2490 void iwl_fwrt_stop_device(struct iwl_fw_runtime *fwrt) 2489 2491 { 2490 - /* if the wait event timeout elapses instead of wake up then 2491 - * the driver did not receive NMI interrupt and can not assume the FW 2492 - * is halted 2493 - */ 2494 - int ret = wait_event_timeout(fwrt->trans->fw_halt_waitq, 2495 - !test_bit(STATUS_FW_WAIT_DUMP, 2496 - &fwrt->trans->status), 2497 - msecs_to_jiffies(2000)); 2498 - if (!ret) { 2499 - /* failed to receive NMI interrupt, assuming the FW is stuck */ 2500 - set_bit(STATUS_FW_ERROR, &fwrt->trans->status); 2501 - 2502 - clear_bit(STATUS_FW_WAIT_DUMP, &fwrt->trans->status); 2503 - } 2504 - 2505 - /* Assuming the op mode mutex is held at this point */ 2506 2492 iwl_fw_dbg_collect_sync(fwrt); 2507 2493 2508 2494 iwl_trans_stop_device(fwrt->trans);
-1
drivers/net/wireless/intel/iwlwifi/fw/init.c
··· 76 76 fwrt->ops_ctx = ops_ctx; 77 77 INIT_DELAYED_WORK(&fwrt->dump.wk, iwl_fw_error_dump_wk); 78 78 iwl_fwrt_dbgfs_register(fwrt, dbgfs_dir); 79 - init_waitqueue_head(&fwrt->trans->fw_halt_waitq); 80 79 } 81 80 IWL_EXPORT_SYMBOL(iwl_fw_runtime_init); 82 81
+2 -1
drivers/net/wireless/intel/iwlwifi/iwl-config.h
··· 549 549 extern const struct iwl_cfg iwl22000_2ac_cfg_hr_cdb; 550 550 extern const struct iwl_cfg iwl22000_2ac_cfg_jf; 551 551 extern const struct iwl_cfg iwl_ax101_cfg_qu_hr; 552 + extern const struct iwl_cfg iwl_ax101_cfg_quz_hr; 552 553 extern const struct iwl_cfg iwl22000_2ax_cfg_hr; 553 - extern const struct iwl_cfg iwl22260_2ax_cfg; 554 + extern const struct iwl_cfg iwl_ax200_cfg_cc; 554 555 extern const struct iwl_cfg killer1650s_2ax_cfg_qu_b0_hr_b0; 555 556 extern const struct iwl_cfg killer1650i_2ax_cfg_qu_b0_hr_b0; 556 557 extern const struct iwl_cfg killer1650x_2ax_cfg;
+1
drivers/net/wireless/intel/iwlwifi/iwl-csr.h
··· 327 327 #define CSR_HW_REV_TYPE_NONE (0x00001F0) 328 328 #define CSR_HW_REV_TYPE_QNJ (0x0000360) 329 329 #define CSR_HW_REV_TYPE_QNJ_B0 (0x0000364) 330 + #define CSR_HW_REV_TYPE_QUZ (0x0000354) 330 331 #define CSR_HW_REV_TYPE_HR_CDB (0x0000340) 331 332 #define CSR_HW_REV_TYPE_SO (0x0000370) 332 333 #define CSR_HW_REV_TYPE_TY (0x0000420)
+6 -6
drivers/net/wireless/intel/iwlwifi/iwl-trans.h
··· 338 338 * are sent 339 339 * @STATUS_TRANS_IDLE: the trans is idle - general commands are not to be sent 340 340 * @STATUS_TRANS_DEAD: trans is dead - avoid any read/write operation 341 - * @STATUS_FW_WAIT_DUMP: if set, wait until cleared before collecting dump 342 341 */ 343 342 enum iwl_trans_status { 344 343 STATUS_SYNC_HCMD_ACTIVE, ··· 350 351 STATUS_TRANS_GOING_IDLE, 351 352 STATUS_TRANS_IDLE, 352 353 STATUS_TRANS_DEAD, 353 - STATUS_FW_WAIT_DUMP, 354 354 }; 355 355 356 356 static inline int ··· 616 618 struct iwl_trans_dump_data *(*dump_data)(struct iwl_trans *trans, 617 619 u32 dump_mask); 618 620 void (*debugfs_cleanup)(struct iwl_trans *trans); 621 + void (*sync_nmi)(struct iwl_trans *trans); 619 622 }; 620 623 621 624 /** ··· 830 831 u32 lmac_error_event_table[2]; 831 832 u32 umac_error_event_table; 832 833 unsigned int error_event_table_tlv_status; 833 - wait_queue_head_t fw_halt_waitq; 834 834 835 835 /* pointer to trans specific struct */ 836 836 /*Ensure that this pointer will always be aligned to sizeof pointer */ ··· 1237 1239 /* prevent double restarts due to the same erroneous FW */ 1238 1240 if (!test_and_set_bit(STATUS_FW_ERROR, &trans->status)) 1239 1241 iwl_op_mode_nic_error(trans->op_mode); 1242 + } 1240 1243 1241 - if (test_and_clear_bit(STATUS_FW_WAIT_DUMP, &trans->status)) 1242 - wake_up(&trans->fw_halt_waitq); 1243 - 1244 + static inline void iwl_trans_sync_nmi(struct iwl_trans *trans) 1245 + { 1246 + if (trans->ops->sync_nmi) 1247 + trans->ops->sync_nmi(trans); 1244 1248 } 1245 1249 1246 1250 /*****************************************************
+22 -49
drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
··· 2714 2714 2715 2715 iwl_mvm_mac_ctxt_remove(mvm, vif); 2716 2716 2717 - kfree(mvmvif->ap_wep_key); 2718 - mvmvif->ap_wep_key = NULL; 2719 - 2720 2717 mutex_unlock(&mvm->mutex); 2721 2718 } 2722 2719 ··· 3180 3183 ret = iwl_mvm_update_sta(mvm, vif, sta); 3181 3184 } else if (old_state == IEEE80211_STA_ASSOC && 3182 3185 new_state == IEEE80211_STA_AUTHORIZED) { 3183 - /* if wep is used, need to set the key for the station now */ 3184 - if (vif->type == NL80211_IFTYPE_AP && mvmvif->ap_wep_key) { 3185 - mvm_sta->wep_key = 3186 - kmemdup(mvmvif->ap_wep_key, 3187 - sizeof(*mvmvif->ap_wep_key) + 3188 - mvmvif->ap_wep_key->keylen, 3189 - GFP_KERNEL); 3190 - if (!mvm_sta->wep_key) { 3191 - ret = -ENOMEM; 3192 - goto out_unlock; 3193 - } 3194 - 3195 - ret = iwl_mvm_set_sta_key(mvm, vif, sta, 3196 - mvm_sta->wep_key, 3197 - STA_KEY_IDX_INVALID); 3198 - } else { 3199 - ret = 0; 3200 - } 3186 + ret = 0; 3201 3187 3202 3188 /* we don't support TDLS during DCM */ 3203 3189 if (iwl_mvm_phy_ctx_count(mvm) > 1) ··· 3222 3242 NL80211_TDLS_DISABLE_LINK); 3223 3243 } 3224 3244 3225 - /* Remove STA key if this is an AP using WEP */ 3226 - if (vif->type == NL80211_IFTYPE_AP && mvmvif->ap_wep_key) { 3227 - int rm_ret = iwl_mvm_remove_sta_key(mvm, vif, sta, 3228 - mvm_sta->wep_key); 3229 - 3230 - if (!ret) 3231 - ret = rm_ret; 3232 - kfree(mvm_sta->wep_key); 3233 - mvm_sta->wep_key = NULL; 3234 - } 3235 - 3236 3245 if (unlikely(ret && 3237 3246 test_bit(IWL_MVM_STATUS_HW_RESTART_REQUESTED, 3238 3247 &mvm->status))) ··· 3258 3289 struct ieee80211_sta *sta, u32 changed) 3259 3290 { 3260 3291 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); 3292 + struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); 3293 + 3294 + if (changed & (IEEE80211_RC_BW_CHANGED | 3295 + IEEE80211_RC_SUPP_RATES_CHANGED | 3296 + IEEE80211_RC_NSS_CHANGED)) 3297 + iwl_mvm_rs_rate_init(mvm, sta, mvmvif->phy_ctxt->channel->band, 3298 + true); 3261 3299 3262 3300 if (vif->type == NL80211_IFTYPE_STATION && 3263 3301 changed & IEEE80211_RC_NSS_CHANGED) ··· 3415 3439 break; 3416 3440 case WLAN_CIPHER_SUITE_WEP40: 3417 3441 case WLAN_CIPHER_SUITE_WEP104: 3418 - if (vif->type == NL80211_IFTYPE_AP) { 3419 - struct iwl_mvm_vif *mvmvif = 3420 - iwl_mvm_vif_from_mac80211(vif); 3421 - 3422 - mvmvif->ap_wep_key = kmemdup(key, 3423 - sizeof(*key) + key->keylen, 3424 - GFP_KERNEL); 3425 - if (!mvmvif->ap_wep_key) 3426 - return -ENOMEM; 3427 - } 3428 - 3429 - if (vif->type != NL80211_IFTYPE_STATION) 3430 - return 0; 3431 - break; 3442 + if (vif->type == NL80211_IFTYPE_STATION) 3443 + break; 3444 + if (iwl_mvm_has_new_tx_api(mvm)) 3445 + return -EOPNOTSUPP; 3446 + /* support HW crypto on TX */ 3447 + return 0; 3432 3448 default: 3433 3449 /* currently FW supports only one optional cipher scheme */ 3434 3450 if (hw->n_cipher_schemes && ··· 3508 3540 ret = iwl_mvm_set_sta_key(mvm, vif, sta, key, key_offset); 3509 3541 if (ret) { 3510 3542 IWL_WARN(mvm, "set key failed\n"); 3543 + key->hw_key_idx = STA_KEY_IDX_INVALID; 3511 3544 /* 3512 3545 * can't add key for RX, but we don't need it 3513 - * in the device for TX so still return 0 3546 + * in the device for TX so still return 0, 3547 + * unless we have new TX API where we cannot 3548 + * put key material into the TX_CMD 3514 3549 */ 3515 - key->hw_key_idx = STA_KEY_IDX_INVALID; 3516 - ret = 0; 3550 + if (iwl_mvm_has_new_tx_api(mvm)) 3551 + ret = -EOPNOTSUPP; 3552 + else 3553 + ret = 0; 3517 3554 } 3518 3555 3519 3556 break;
-1
drivers/net/wireless/intel/iwlwifi/mvm/mvm.h
··· 498 498 netdev_features_t features; 499 499 500 500 struct iwl_probe_resp_data __rcu *probe_resp_data; 501 - struct ieee80211_key_conf *ap_wep_key; 502 501 }; 503 502 504 503 static inline struct iwl_mvm_vif *
+4 -39
drivers/net/wireless/intel/iwlwifi/mvm/sta.c
··· 8 8 * Copyright(c) 2012 - 2015 Intel Corporation. All rights reserved. 9 9 * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH 10 10 * Copyright(c) 2016 - 2017 Intel Deutschland GmbH 11 - * Copyright(c) 2018 Intel Corporation 11 + * Copyright(c) 2018 - 2019 Intel Corporation 12 12 * 13 13 * This program is free software; you can redistribute it and/or modify 14 14 * it under the terms of version 2 of the GNU General Public License as ··· 31 31 * Copyright(c) 2012 - 2015 Intel Corporation. All rights reserved. 32 32 * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH 33 33 * Copyright(c) 2016 - 2017 Intel Deutschland GmbH 34 - * Copyright(c) 2018 Intel Corporation 34 + * Copyright(c) 2018 - 2019 Intel Corporation 35 35 * All rights reserved. 36 36 * 37 37 * Redistribution and use in source and binary forms, with or without ··· 1399 1399 1400 1400 iwl_mvm_sta_alloc_queue(mvm, txq->sta, txq->ac, tid); 1401 1401 list_del_init(&mvmtxq->list); 1402 + local_bh_disable(); 1402 1403 iwl_mvm_mac_itxq_xmit(mvm->hw, txq); 1404 + local_bh_enable(); 1403 1405 } 1404 1406 1405 1407 mutex_unlock(&mvm->mutex); ··· 2335 2333 iwl_mvm_enable_txq(mvm, NULL, mvmvif->cab_queue, 0, &cfg, 2336 2334 timeout); 2337 2335 2338 - if (mvmvif->ap_wep_key) { 2339 - u8 key_offset = iwl_mvm_set_fw_key_idx(mvm); 2340 - 2341 - __set_bit(key_offset, mvm->fw_key_table); 2342 - 2343 - if (key_offset == STA_KEY_IDX_INVALID) 2344 - return -ENOSPC; 2345 - 2346 - ret = iwl_mvm_send_sta_key(mvm, mvmvif->mcast_sta.sta_id, 2347 - mvmvif->ap_wep_key, true, 0, NULL, 0, 2348 - key_offset, 0); 2349 - if (ret) 2350 - return ret; 2351 - } 2352 - 2353 2336 return 0; 2354 2337 } 2355 2338 ··· 2405 2418 iwl_mvm_flush_sta(mvm, &mvmvif->mcast_sta, true, 0); 2406 2419 2407 2420 iwl_mvm_disable_txq(mvm, NULL, mvmvif->cab_queue, 0, 0); 2408 - 2409 - if (mvmvif->ap_wep_key) { 2410 - int i; 2411 - 2412 - if (!__test_and_clear_bit(mvmvif->ap_wep_key->hw_key_idx, 2413 - mvm->fw_key_table)) { 2414 - IWL_ERR(mvm, "offset %d not used in fw key table.\n", 2415 - mvmvif->ap_wep_key->hw_key_idx); 2416 - return -ENOENT; 2417 - } 2418 - 2419 - /* track which key was deleted last */ 2420 - for (i = 0; i < STA_KEY_MAX_NUM; i++) { 2421 - if (mvm->fw_key_deleted[i] < U8_MAX) 2422 - mvm->fw_key_deleted[i]++; 2423 - } 2424 - mvm->fw_key_deleted[mvmvif->ap_wep_key->hw_key_idx] = 0; 2425 - ret = __iwl_mvm_remove_sta_key(mvm, mvmvif->mcast_sta.sta_id, 2426 - mvmvif->ap_wep_key, true); 2427 - if (ret) 2428 - return ret; 2429 - } 2430 2421 2431 2422 ret = iwl_mvm_rm_sta_common(mvm, mvmvif->mcast_sta.sta_id); 2432 2423 if (ret)
+2 -5
drivers/net/wireless/intel/iwlwifi/mvm/sta.h
··· 8 8 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved. 9 9 * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH 10 10 * Copyright(c) 2015 - 2016 Intel Deutschland GmbH 11 - * Copyright(c) 2018 Intel Corporation 11 + * Copyright(c) 2018 - 2019 Intel Corporation 12 12 * 13 13 * This program is free software; you can redistribute it and/or modify 14 14 * it under the terms of version 2 of the GNU General Public License as ··· 31 31 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved. 32 32 * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH 33 33 * Copyright(c) 2015 - 2016 Intel Deutschland GmbH 34 - * Copyright(c) 2018 Intel Corporation 34 + * Copyright(c) 2018 - 2019 Intel Corporation 35 35 * All rights reserved. 36 36 * 37 37 * Redistribution and use in source and binary forms, with or without ··· 394 394 * the BA window. To be used for UAPSD only. 395 395 * @ptk_pn: per-queue PTK PN data structures 396 396 * @dup_data: per queue duplicate packet detection data 397 - * @wep_key: used in AP mode. Is a duplicate of the WEP key. 398 397 * @deferred_traffic_tid_map: indication bitmap of deferred traffic per-TID 399 398 * @tx_ant: the index of the antenna to use for data tx to this station. Only 400 399 * used during connection establishment (e.g. for the 4 way handshake ··· 424 425 struct ieee80211_vif *vif; 425 426 struct iwl_mvm_key_pn __rcu *ptk_pn[4]; 426 427 struct iwl_mvm_rxq_dup_data *dup_data; 427 - 428 - struct ieee80211_key_conf *wep_key; 429 428 430 429 u8 reserved_queue; 431 430
+7 -6
drivers/net/wireless/intel/iwlwifi/pcie/drv.c
··· 953 953 {IWL_PCI_DEVICE(0xA0F0, 0x1652, killer1650i_2ax_cfg_qu_b0_hr_b0)}, 954 954 {IWL_PCI_DEVICE(0xA0F0, 0x4070, iwl_ax101_cfg_qu_hr)}, 955 955 956 - {IWL_PCI_DEVICE(0x2723, 0x0080, iwl22260_2ax_cfg)}, 957 - {IWL_PCI_DEVICE(0x2723, 0x0084, iwl22260_2ax_cfg)}, 958 - {IWL_PCI_DEVICE(0x2723, 0x0088, iwl22260_2ax_cfg)}, 959 - {IWL_PCI_DEVICE(0x2723, 0x008C, iwl22260_2ax_cfg)}, 956 + {IWL_PCI_DEVICE(0x2723, 0x0080, iwl_ax200_cfg_cc)}, 957 + {IWL_PCI_DEVICE(0x2723, 0x0084, iwl_ax200_cfg_cc)}, 958 + {IWL_PCI_DEVICE(0x2723, 0x0088, iwl_ax200_cfg_cc)}, 959 + {IWL_PCI_DEVICE(0x2723, 0x008C, iwl_ax200_cfg_cc)}, 960 960 {IWL_PCI_DEVICE(0x2723, 0x1653, killer1650w_2ax_cfg)}, 961 961 {IWL_PCI_DEVICE(0x2723, 0x1654, killer1650x_2ax_cfg)}, 962 - {IWL_PCI_DEVICE(0x2723, 0x4080, iwl22260_2ax_cfg)}, 963 - {IWL_PCI_DEVICE(0x2723, 0x4088, iwl22260_2ax_cfg)}, 962 + {IWL_PCI_DEVICE(0x2723, 0x2080, iwl_ax200_cfg_cc)}, 963 + {IWL_PCI_DEVICE(0x2723, 0x4080, iwl_ax200_cfg_cc)}, 964 + {IWL_PCI_DEVICE(0x2723, 0x4088, iwl_ax200_cfg_cc)}, 964 965 965 966 {IWL_PCI_DEVICE(0x1a56, 0x1653, killer1650w_2ax_cfg)}, 966 967 {IWL_PCI_DEVICE(0x1a56, 0x1654, killer1650x_2ax_cfg)},
+1 -1
drivers/net/wireless/intel/iwlwifi/pcie/internal.h
··· 1043 1043 1044 1044 void iwl_trans_pcie_rf_kill(struct iwl_trans *trans, bool state); 1045 1045 void iwl_trans_pcie_dump_regs(struct iwl_trans *trans); 1046 - void iwl_trans_sync_nmi(struct iwl_trans *trans); 1046 + void iwl_trans_pcie_sync_nmi(struct iwl_trans *trans); 1047 1047 1048 1048 #ifdef CONFIG_IWLWIFI_DEBUGFS 1049 1049 int iwl_trans_pcie_dbgfs_register(struct iwl_trans *trans);
+8 -3
drivers/net/wireless/intel/iwlwifi/pcie/trans.c
··· 3318 3318 .unref = iwl_trans_pcie_unref, \ 3319 3319 .dump_data = iwl_trans_pcie_dump_data, \ 3320 3320 .d3_suspend = iwl_trans_pcie_d3_suspend, \ 3321 - .d3_resume = iwl_trans_pcie_d3_resume 3321 + .d3_resume = iwl_trans_pcie_d3_resume, \ 3322 + .sync_nmi = iwl_trans_pcie_sync_nmi 3322 3323 3323 3324 #ifdef CONFIG_PM_SLEEP 3324 3325 #define IWL_TRANS_PM_OPS \ ··· 3543 3542 } 3544 3543 } else if (cfg == &iwl_ax101_cfg_qu_hr) { 3545 3544 if (CSR_HW_RF_ID_TYPE_CHIP_ID(trans->hw_rf_id) == 3545 + CSR_HW_RF_ID_TYPE_CHIP_ID(CSR_HW_RF_ID_TYPE_HR) && 3546 + trans->hw_rev == CSR_HW_REV_TYPE_QNJ_B0) { 3547 + trans->cfg = &iwl22000_2ax_cfg_qnj_hr_b0; 3548 + } else if (CSR_HW_RF_ID_TYPE_CHIP_ID(trans->hw_rf_id) == 3546 3549 CSR_HW_RF_ID_TYPE_CHIP_ID(CSR_HW_RF_ID_TYPE_HR)) { 3547 3550 trans->cfg = &iwl_ax101_cfg_qu_hr; 3548 3551 } else if (CSR_HW_RF_ID_TYPE_CHIP_ID(trans->hw_rf_id) == ··· 3565 3560 } 3566 3561 } else if (CSR_HW_RF_ID_TYPE_CHIP_ID(trans->hw_rf_id) == 3567 3562 CSR_HW_RF_ID_TYPE_CHIP_ID(CSR_HW_RF_ID_TYPE_HR) && 3568 - (trans->cfg != &iwl22260_2ax_cfg || 3563 + (trans->cfg != &iwl_ax200_cfg_cc || 3569 3564 trans->hw_rev == CSR_HW_REV_TYPE_QNJ_B0)) { 3570 3565 u32 hw_status; 3571 3566 ··· 3642 3637 return ERR_PTR(ret); 3643 3638 } 3644 3639 3645 - void iwl_trans_sync_nmi(struct iwl_trans *trans) 3640 + void iwl_trans_pcie_sync_nmi(struct iwl_trans *trans) 3646 3641 { 3647 3642 unsigned long timeout = jiffies + IWL_TRANS_NMI_TIMEOUT; 3648 3643
+1 -1
drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c
··· 965 965 cmd_str); 966 966 ret = -ETIMEDOUT; 967 967 968 - iwl_trans_sync_nmi(trans); 968 + iwl_trans_pcie_sync_nmi(trans); 969 969 goto cancel; 970 970 } 971 971
+1 -1
drivers/net/wireless/intel/iwlwifi/pcie/tx.c
··· 1960 1960 iwl_get_cmd_string(trans, cmd->id)); 1961 1961 ret = -ETIMEDOUT; 1962 1962 1963 - iwl_trans_sync_nmi(trans); 1963 + iwl_trans_pcie_sync_nmi(trans); 1964 1964 goto cancel; 1965 1965 } 1966 1966
+15 -4
drivers/net/wireless/mac80211_hwsim.c
··· 2644 2644 enum nl80211_band band; 2645 2645 const struct ieee80211_ops *ops = &mac80211_hwsim_ops; 2646 2646 struct net *net; 2647 - int idx; 2647 + int idx, i; 2648 2648 int n_limits = 0; 2649 2649 2650 2650 if (WARN_ON(param->channels > 1 && !param->use_chanctx)) ··· 2768 2768 goto failed_hw; 2769 2769 } 2770 2770 2771 + data->if_combination.max_interfaces = 0; 2772 + for (i = 0; i < n_limits; i++) 2773 + data->if_combination.max_interfaces += 2774 + data->if_limits[i].max; 2775 + 2771 2776 data->if_combination.n_limits = n_limits; 2772 - data->if_combination.max_interfaces = 2048; 2773 2777 data->if_combination.limits = data->if_limits; 2774 2778 2775 - hw->wiphy->iface_combinations = &data->if_combination; 2776 - hw->wiphy->n_iface_combinations = 1; 2779 + /* 2780 + * If we actually were asked to support combinations, 2781 + * advertise them - if there's only a single thing like 2782 + * only IBSS then don't advertise it as combinations. 2783 + */ 2784 + if (data->if_combination.max_interfaces > 1) { 2785 + hw->wiphy->iface_combinations = &data->if_combination; 2786 + hw->wiphy->n_iface_combinations = 1; 2787 + } 2777 2788 2778 2789 if (param->ciphers) { 2779 2790 memcpy(data->ciphers, param->ciphers,
+2
drivers/net/wireless/mediatek/mt76/mt7603/init.c
··· 510 510 bus_ops->rmw = mt7603_rmw; 511 511 dev->mt76.bus = bus_ops; 512 512 513 + spin_lock_init(&dev->ps_lock); 514 + 513 515 INIT_DELAYED_WORK(&dev->mac_work, mt7603_mac_work); 514 516 tasklet_init(&dev->pre_tbtt_tasklet, mt7603_pre_tbtt_tasklet, 515 517 (unsigned long)dev);
+14 -39
drivers/net/wireless/mediatek/mt76/mt7603/mac.c
··· 343 343 MT_BA_CONTROL_1_RESET)); 344 344 } 345 345 346 - void mt7603_mac_tx_ba_reset(struct mt7603_dev *dev, int wcid, int tid, int ssn, 346 + void mt7603_mac_tx_ba_reset(struct mt7603_dev *dev, int wcid, int tid, 347 347 int ba_size) 348 348 { 349 349 u32 addr = mt7603_wtbl2_addr(wcid); ··· 358 358 mt76_clear(dev, addr + (15 * 4), tid_mask); 359 359 return; 360 360 } 361 - mt76_poll(dev, MT_WTBL_UPDATE, MT_WTBL_UPDATE_BUSY, 0, 5000); 362 - 363 - mt7603_mac_stop(dev); 364 - switch (tid) { 365 - case 0: 366 - mt76_rmw_field(dev, addr + (2 * 4), MT_WTBL2_W2_TID0_SN, ssn); 367 - break; 368 - case 1: 369 - mt76_rmw_field(dev, addr + (2 * 4), MT_WTBL2_W2_TID1_SN, ssn); 370 - break; 371 - case 2: 372 - mt76_rmw_field(dev, addr + (2 * 4), MT_WTBL2_W2_TID2_SN_LO, 373 - ssn); 374 - mt76_rmw_field(dev, addr + (3 * 4), MT_WTBL2_W3_TID2_SN_HI, 375 - ssn >> 8); 376 - break; 377 - case 3: 378 - mt76_rmw_field(dev, addr + (3 * 4), MT_WTBL2_W3_TID3_SN, ssn); 379 - break; 380 - case 4: 381 - mt76_rmw_field(dev, addr + (3 * 4), MT_WTBL2_W3_TID4_SN, ssn); 382 - break; 383 - case 5: 384 - mt76_rmw_field(dev, addr + (3 * 4), MT_WTBL2_W3_TID5_SN_LO, 385 - ssn); 386 - mt76_rmw_field(dev, addr + (4 * 4), MT_WTBL2_W4_TID5_SN_HI, 387 - ssn >> 4); 388 - break; 389 - case 6: 390 - mt76_rmw_field(dev, addr + (4 * 4), MT_WTBL2_W4_TID6_SN, ssn); 391 - break; 392 - case 7: 393 - mt76_rmw_field(dev, addr + (4 * 4), MT_WTBL2_W4_TID7_SN, ssn); 394 - break; 395 - } 396 - mt7603_wtbl_update(dev, wcid, MT_WTBL_UPDATE_WTBL2); 397 - mt7603_mac_start(dev); 398 361 399 362 for (i = 7; i > 0; i--) { 400 363 if (ba_size >= MT_AGG_SIZE_LIMIT(i)) ··· 790 827 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 791 828 struct ieee80211_tx_rate *rate = &info->control.rates[0]; 792 829 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; 830 + struct ieee80211_bar *bar = (struct ieee80211_bar *)skb->data; 793 831 struct ieee80211_vif *vif = info->control.vif; 794 832 struct mt7603_vif *mvif; 795 833 int wlan_idx; ··· 798 834 int tx_count = 8; 799 835 u8 frame_type, frame_subtype; 800 836 u16 fc = le16_to_cpu(hdr->frame_control); 837 + u16 seqno = 0; 801 838 u8 vif_idx = 0; 802 839 u32 val; 803 840 u8 bw; ··· 884 919 tx_count = 0x1f; 885 920 886 921 val = FIELD_PREP(MT_TXD3_REM_TX_COUNT, tx_count) | 887 - FIELD_PREP(MT_TXD3_SEQ, le16_to_cpu(hdr->seq_ctrl)); 922 + MT_TXD3_SN_VALID; 923 + 924 + if (ieee80211_is_data_qos(hdr->frame_control)) 925 + seqno = le16_to_cpu(hdr->seq_ctrl); 926 + else if (ieee80211_is_back_req(hdr->frame_control)) 927 + seqno = le16_to_cpu(bar->start_seq_num); 928 + else 929 + val &= ~MT_TXD3_SN_VALID; 930 + 931 + val |= FIELD_PREP(MT_TXD3_SEQ, seqno >> 4); 932 + 888 933 txwi[3] = cpu_to_le32(val); 889 934 890 935 if (key) {
+4 -4
drivers/net/wireless/mediatek/mt76/mt7603/main.c
··· 372 372 struct mt7603_sta *msta = (struct mt7603_sta *)sta->drv_priv; 373 373 struct sk_buff_head list; 374 374 375 - mt76_stop_tx_queues(&dev->mt76, sta, false); 375 + mt76_stop_tx_queues(&dev->mt76, sta, true); 376 376 mt7603_wtbl_set_ps(dev, msta, ps); 377 377 if (ps) 378 378 return; ··· 584 584 case IEEE80211_AMPDU_TX_OPERATIONAL: 585 585 mtxq->aggr = true; 586 586 mtxq->send_bar = false; 587 - mt7603_mac_tx_ba_reset(dev, msta->wcid.idx, tid, *ssn, ba_size); 587 + mt7603_mac_tx_ba_reset(dev, msta->wcid.idx, tid, ba_size); 588 588 break; 589 589 case IEEE80211_AMPDU_TX_STOP_FLUSH: 590 590 case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT: 591 591 mtxq->aggr = false; 592 592 ieee80211_send_bar(vif, sta->addr, tid, mtxq->agg_ssn); 593 - mt7603_mac_tx_ba_reset(dev, msta->wcid.idx, tid, *ssn, -1); 593 + mt7603_mac_tx_ba_reset(dev, msta->wcid.idx, tid, -1); 594 594 break; 595 595 case IEEE80211_AMPDU_TX_START: 596 596 mtxq->agg_ssn = *ssn << 4; ··· 598 598 break; 599 599 case IEEE80211_AMPDU_TX_STOP_CONT: 600 600 mtxq->aggr = false; 601 - mt7603_mac_tx_ba_reset(dev, msta->wcid.idx, tid, *ssn, -1); 601 + mt7603_mac_tx_ba_reset(dev, msta->wcid.idx, tid, -1); 602 602 ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid); 603 603 break; 604 604 }
+1 -1
drivers/net/wireless/mediatek/mt76/mt7603/mt7603.h
··· 200 200 int mt7603_mac_fill_rx(struct mt7603_dev *dev, struct sk_buff *skb); 201 201 void mt7603_mac_add_txs(struct mt7603_dev *dev, void *data); 202 202 void mt7603_mac_rx_ba_reset(struct mt7603_dev *dev, void *addr, u8 tid); 203 - void mt7603_mac_tx_ba_reset(struct mt7603_dev *dev, int wcid, int tid, int ssn, 203 + void mt7603_mac_tx_ba_reset(struct mt7603_dev *dev, int wcid, int tid, 204 204 int ba_size); 205 205 206 206 void mt7603_pse_client_reset(struct mt7603_dev *dev);
+8 -6
drivers/net/wireless/mediatek/mt76/mt76x02_mac.c
··· 466 466 return; 467 467 468 468 rcu_read_lock(); 469 - mt76_tx_status_lock(mdev, &list); 470 469 471 470 if (stat->wcid < ARRAY_SIZE(dev->mt76.wcid)) 472 471 wcid = rcu_dereference(dev->mt76.wcid[stat->wcid]); ··· 477 478 status.sta = container_of(priv, struct ieee80211_sta, 478 479 drv_priv); 479 480 } 481 + 482 + mt76_tx_status_lock(mdev, &list); 480 483 481 484 if (wcid) { 482 485 if (stat->pktid >= MT_PACKET_ID_FIRST) ··· 499 498 if (*update == 0 && stat_val == stat_cache && 500 499 stat->wcid == msta->status.wcid && msta->n_frames < 32) { 501 500 msta->n_frames++; 502 - goto out; 501 + mt76_tx_status_unlock(mdev, &list); 502 + rcu_read_unlock(); 503 + return; 503 504 } 504 505 505 506 mt76x02_mac_fill_tx_status(dev, status.info, &msta->status, ··· 517 514 518 515 if (status.skb) 519 516 mt76_tx_status_skb_done(mdev, status.skb, &list); 520 - else 521 - ieee80211_tx_status_ext(mt76_hw(dev), &status); 522 - 523 - out: 524 517 mt76_tx_status_unlock(mdev, &list); 518 + 519 + if (!status.skb) 520 + ieee80211_tx_status_ext(mt76_hw(dev), &status); 525 521 rcu_read_unlock(); 526 522 } 527 523
-1
drivers/net/wireless/ralink/rt2x00/rt2x00.h
··· 673 673 CONFIG_CHANNEL_HT40, 674 674 CONFIG_POWERSAVING, 675 675 CONFIG_HT_DISABLED, 676 - CONFIG_QOS_DISABLED, 677 676 CONFIG_MONITORING, 678 677 679 678 /*
-10
drivers/net/wireless/ralink/rt2x00/rt2x00mac.c
··· 642 642 rt2x00dev->intf_associated--; 643 643 644 644 rt2x00leds_led_assoc(rt2x00dev, !!rt2x00dev->intf_associated); 645 - 646 - clear_bit(CONFIG_QOS_DISABLED, &rt2x00dev->flags); 647 645 } 648 - 649 - /* 650 - * Check for access point which do not support 802.11e . We have to 651 - * generate data frames sequence number in S/W for such AP, because 652 - * of H/W bug. 653 - */ 654 - if (changes & BSS_CHANGED_QOS && !bss_conf->qos) 655 - set_bit(CONFIG_QOS_DISABLED, &rt2x00dev->flags); 656 646 657 647 /* 658 648 * When the erp information has changed, we should perform
+9 -6
drivers/net/wireless/ralink/rt2x00/rt2x00queue.c
··· 201 201 if (!rt2x00_has_cap_flag(rt2x00dev, REQUIRE_SW_SEQNO)) { 202 202 /* 203 203 * rt2800 has a H/W (or F/W) bug, device incorrectly increase 204 - * seqno on retransmited data (non-QOS) frames. To workaround 205 - * the problem let's generate seqno in software if QOS is 206 - * disabled. 204 + * seqno on retransmitted data (non-QOS) and management frames. 205 + * To workaround the problem let's generate seqno in software. 206 + * Except for beacons which are transmitted periodically by H/W 207 + * hence hardware has to assign seqno for them. 207 208 */ 208 - if (test_bit(CONFIG_QOS_DISABLED, &rt2x00dev->flags)) 209 - __clear_bit(ENTRY_TXD_GENERATE_SEQ, &txdesc->flags); 210 - else 209 + if (ieee80211_is_beacon(hdr->frame_control)) { 210 + __set_bit(ENTRY_TXD_GENERATE_SEQ, &txdesc->flags); 211 211 /* H/W will generate sequence number */ 212 212 return; 213 + } 214 + 215 + __clear_bit(ENTRY_TXD_GENERATE_SEQ, &txdesc->flags); 213 216 } 214 217 215 218 /*
+13 -5
drivers/nvdimm/btt_devs.c
··· 198 198 return NULL; 199 199 200 200 nd_btt->id = ida_simple_get(&nd_region->btt_ida, 0, 0, GFP_KERNEL); 201 - if (nd_btt->id < 0) { 202 - kfree(nd_btt); 203 - return NULL; 204 - } 201 + if (nd_btt->id < 0) 202 + goto out_nd_btt; 205 203 206 204 nd_btt->lbasize = lbasize; 207 - if (uuid) 205 + if (uuid) { 208 206 uuid = kmemdup(uuid, 16, GFP_KERNEL); 207 + if (!uuid) 208 + goto out_put_id; 209 + } 209 210 nd_btt->uuid = uuid; 210 211 dev = &nd_btt->dev; 211 212 dev_set_name(dev, "btt%d.%d", nd_region->id, nd_btt->id); ··· 221 220 return NULL; 222 221 } 223 222 return dev; 223 + 224 + out_put_id: 225 + ida_simple_remove(&nd_region->btt_ida, nd_btt->id); 226 + 227 + out_nd_btt: 228 + kfree(nd_btt); 229 + return NULL; 224 230 } 225 231 226 232 struct device *nd_btt_create(struct nd_region *nd_region)
+4 -1
drivers/nvdimm/namespace_devs.c
··· 2249 2249 if (!nsblk->uuid) 2250 2250 goto blk_err; 2251 2251 memcpy(name, nd_label->name, NSLABEL_NAME_LEN); 2252 - if (name[0]) 2252 + if (name[0]) { 2253 2253 nsblk->alt_name = kmemdup(name, NSLABEL_NAME_LEN, 2254 2254 GFP_KERNEL); 2255 + if (!nsblk->alt_name) 2256 + goto blk_err; 2257 + } 2255 2258 res = nsblk_add_resource(nd_region, ndd, nsblk, 2256 2259 __le64_to_cpu(nd_label->dpa)); 2257 2260 if (!res)
+4 -4
drivers/nvdimm/pmem.c
··· 113 113 114 114 while (len) { 115 115 mem = kmap_atomic(page); 116 - chunk = min_t(unsigned int, len, PAGE_SIZE); 116 + chunk = min_t(unsigned int, len, PAGE_SIZE - off); 117 117 memcpy_flushcache(pmem_addr, mem + off, chunk); 118 118 kunmap_atomic(mem); 119 119 len -= chunk; 120 120 off = 0; 121 121 page++; 122 - pmem_addr += PAGE_SIZE; 122 + pmem_addr += chunk; 123 123 } 124 124 } 125 125 ··· 132 132 133 133 while (len) { 134 134 mem = kmap_atomic(page); 135 - chunk = min_t(unsigned int, len, PAGE_SIZE); 135 + chunk = min_t(unsigned int, len, PAGE_SIZE - off); 136 136 rem = memcpy_mcsafe(mem + off, pmem_addr, chunk); 137 137 kunmap_atomic(mem); 138 138 if (rem) ··· 140 140 len -= chunk; 141 141 off = 0; 142 142 page++; 143 - pmem_addr += PAGE_SIZE; 143 + pmem_addr += chunk; 144 144 } 145 145 return BLK_STS_OK; 146 146 }
+73 -45
drivers/nvdimm/security.c
··· 22 22 module_param(key_revalidate, bool, 0444); 23 23 MODULE_PARM_DESC(key_revalidate, "Require key validation at init."); 24 24 25 + static const char zero_key[NVDIMM_PASSPHRASE_LEN]; 26 + 25 27 static void *key_data(struct key *key) 26 28 { 27 29 struct encrypted_key_payload *epayload = dereference_key_locked(key); ··· 77 75 return key; 78 76 } 79 77 78 + static const void *nvdimm_get_key_payload(struct nvdimm *nvdimm, 79 + struct key **key) 80 + { 81 + *key = nvdimm_request_key(nvdimm); 82 + if (!*key) 83 + return zero_key; 84 + 85 + return key_data(*key); 86 + } 87 + 80 88 static struct key *nvdimm_lookup_user_key(struct nvdimm *nvdimm, 81 89 key_serial_t id, int subclass) 82 90 { ··· 117 105 return key; 118 106 } 119 107 120 - static struct key *nvdimm_key_revalidate(struct nvdimm *nvdimm) 108 + static const void *nvdimm_get_user_key_payload(struct nvdimm *nvdimm, 109 + key_serial_t id, int subclass, struct key **key) 110 + { 111 + *key = NULL; 112 + if (id == 0) { 113 + if (subclass == NVDIMM_BASE_KEY) 114 + return zero_key; 115 + else 116 + return NULL; 117 + } 118 + 119 + *key = nvdimm_lookup_user_key(nvdimm, id, subclass); 120 + if (!*key) 121 + return NULL; 122 + 123 + return key_data(*key); 124 + } 125 + 126 + 127 + static int nvdimm_key_revalidate(struct nvdimm *nvdimm) 121 128 { 122 129 struct key *key; 123 130 int rc; 131 + const void *data; 124 132 125 133 if (!nvdimm->sec.ops->change_key) 126 - return NULL; 134 + return -EOPNOTSUPP; 127 135 128 - key = nvdimm_request_key(nvdimm); 129 - if (!key) 130 - return NULL; 136 + data = nvdimm_get_key_payload(nvdimm, &key); 131 137 132 138 /* 133 139 * Send the same key to the hardware as new and old key to 134 140 * verify that the key is good. 135 141 */ 136 - rc = nvdimm->sec.ops->change_key(nvdimm, key_data(key), 137 - key_data(key), NVDIMM_USER); 142 + rc = nvdimm->sec.ops->change_key(nvdimm, data, data, NVDIMM_USER); 138 143 if (rc < 0) { 139 144 nvdimm_put_key(key); 140 - key = NULL; 145 + return rc; 141 146 } 142 - return key; 147 + 148 + nvdimm_put_key(key); 149 + nvdimm->sec.state = nvdimm_security_state(nvdimm, NVDIMM_USER); 150 + return 0; 143 151 } 144 152 145 153 static int __nvdimm_security_unlock(struct nvdimm *nvdimm) 146 154 { 147 155 struct device *dev = &nvdimm->dev; 148 156 struct nvdimm_bus *nvdimm_bus = walk_to_nvdimm_bus(dev); 149 - struct key *key = NULL; 157 + struct key *key; 158 + const void *data; 150 159 int rc; 151 160 152 161 /* The bus lock should be held at the top level of the call stack */ ··· 193 160 if (!key_revalidate) 194 161 return 0; 195 162 196 - key = nvdimm_key_revalidate(nvdimm); 197 - if (!key) 198 - return nvdimm_security_freeze(nvdimm); 163 + return nvdimm_key_revalidate(nvdimm); 199 164 } else 200 - key = nvdimm_request_key(nvdimm); 165 + data = nvdimm_get_key_payload(nvdimm, &key); 201 166 202 - if (!key) 203 - return -ENOKEY; 204 - 205 - rc = nvdimm->sec.ops->unlock(nvdimm, key_data(key)); 167 + rc = nvdimm->sec.ops->unlock(nvdimm, data); 206 168 dev_dbg(dev, "key: %d unlock: %s\n", key_serial(key), 207 169 rc == 0 ? "success" : "fail"); 208 170 ··· 223 195 struct nvdimm_bus *nvdimm_bus = walk_to_nvdimm_bus(dev); 224 196 struct key *key; 225 197 int rc; 198 + const void *data; 226 199 227 200 /* The bus lock should be held at the top level of the call stack */ 228 201 lockdep_assert_held(&nvdimm_bus->reconfig_mutex); ··· 243 214 return -EBUSY; 244 215 } 245 216 246 - key = nvdimm_lookup_user_key(nvdimm, keyid, NVDIMM_BASE_KEY); 247 - if (!key) 217 + data = nvdimm_get_user_key_payload(nvdimm, keyid, 218 + NVDIMM_BASE_KEY, &key); 219 + if (!data) 248 220 return -ENOKEY; 249 221 250 - rc = nvdimm->sec.ops->disable(nvdimm, key_data(key)); 222 + rc = nvdimm->sec.ops->disable(nvdimm, data); 251 223 dev_dbg(dev, "key: %d disable: %s\n", key_serial(key), 252 224 rc == 0 ? "success" : "fail"); 253 225 ··· 265 235 struct nvdimm_bus *nvdimm_bus = walk_to_nvdimm_bus(dev); 266 236 struct key *key, *newkey; 267 237 int rc; 238 + const void *data, *newdata; 268 239 269 240 /* The bus lock should be held at the top level of the call stack */ 270 241 lockdep_assert_held(&nvdimm_bus->reconfig_mutex); ··· 280 249 return -EIO; 281 250 } 282 251 283 - if (keyid == 0) 284 - key = NULL; 285 - else { 286 - key = nvdimm_lookup_user_key(nvdimm, keyid, NVDIMM_BASE_KEY); 287 - if (!key) 288 - return -ENOKEY; 289 - } 252 + data = nvdimm_get_user_key_payload(nvdimm, keyid, 253 + NVDIMM_BASE_KEY, &key); 254 + if (!data) 255 + return -ENOKEY; 290 256 291 - newkey = nvdimm_lookup_user_key(nvdimm, new_keyid, NVDIMM_NEW_KEY); 292 - if (!newkey) { 257 + newdata = nvdimm_get_user_key_payload(nvdimm, new_keyid, 258 + NVDIMM_NEW_KEY, &newkey); 259 + if (!newdata) { 293 260 nvdimm_put_key(key); 294 261 return -ENOKEY; 295 262 } 296 263 297 - rc = nvdimm->sec.ops->change_key(nvdimm, key ? key_data(key) : NULL, 298 - key_data(newkey), pass_type); 264 + rc = nvdimm->sec.ops->change_key(nvdimm, data, newdata, pass_type); 299 265 dev_dbg(dev, "key: %d %d update%s: %s\n", 300 266 key_serial(key), key_serial(newkey), 301 267 pass_type == NVDIMM_MASTER ? "(master)" : "(user)", ··· 314 286 { 315 287 struct device *dev = &nvdimm->dev; 316 288 struct nvdimm_bus *nvdimm_bus = walk_to_nvdimm_bus(dev); 317 - struct key *key; 289 + struct key *key = NULL; 318 290 int rc; 291 + const void *data; 319 292 320 293 /* The bus lock should be held at the top level of the call stack */ 321 294 lockdep_assert_held(&nvdimm_bus->reconfig_mutex); ··· 348 319 return -EOPNOTSUPP; 349 320 } 350 321 351 - key = nvdimm_lookup_user_key(nvdimm, keyid, NVDIMM_BASE_KEY); 352 - if (!key) 322 + data = nvdimm_get_user_key_payload(nvdimm, keyid, 323 + NVDIMM_BASE_KEY, &key); 324 + if (!data) 353 325 return -ENOKEY; 354 326 355 - rc = nvdimm->sec.ops->erase(nvdimm, key_data(key), pass_type); 327 + rc = nvdimm->sec.ops->erase(nvdimm, data, pass_type); 356 328 dev_dbg(dev, "key: %d erase%s: %s\n", key_serial(key), 357 329 pass_type == NVDIMM_MASTER ? "(master)" : "(user)", 358 330 rc == 0 ? "success" : "fail"); ··· 367 337 { 368 338 struct device *dev = &nvdimm->dev; 369 339 struct nvdimm_bus *nvdimm_bus = walk_to_nvdimm_bus(dev); 370 - struct key *key; 340 + struct key *key = NULL; 371 341 int rc; 342 + const void *data; 372 343 373 344 /* The bus lock should be held at the top level of the call stack */ 374 345 lockdep_assert_held(&nvdimm_bus->reconfig_mutex); ··· 399 368 return -EBUSY; 400 369 } 401 370 402 - if (keyid == 0) 403 - key = NULL; 404 - else { 405 - key = nvdimm_lookup_user_key(nvdimm, keyid, NVDIMM_BASE_KEY); 406 - if (!key) 407 - return -ENOKEY; 408 - } 371 + data = nvdimm_get_user_key_payload(nvdimm, keyid, 372 + NVDIMM_BASE_KEY, &key); 373 + if (!data) 374 + return -ENOKEY; 409 375 410 - rc = nvdimm->sec.ops->overwrite(nvdimm, key ? key_data(key) : NULL); 376 + rc = nvdimm->sec.ops->overwrite(nvdimm, data); 411 377 dev_dbg(dev, "key: %d overwrite submission: %s\n", key_serial(key), 412 378 rc == 0 ? "success" : "fail"); 413 379
+1 -1
drivers/nvme/host/core.c
··· 288 288 "Cancelling I/O %d", req->tag); 289 289 290 290 nvme_req(req)->status = NVME_SC_ABORT_REQ; 291 - blk_mq_complete_request(req); 291 + blk_mq_complete_request_sync(req); 292 292 return true; 293 293 } 294 294 EXPORT_SYMBOL_GPL(nvme_cancel_request);
+15 -5
drivers/nvme/host/fc.c
··· 1845 1845 memset(queue, 0, sizeof(*queue)); 1846 1846 queue->ctrl = ctrl; 1847 1847 queue->qnum = idx; 1848 - atomic_set(&queue->csn, 1); 1848 + atomic_set(&queue->csn, 0); 1849 1849 queue->dev = ctrl->dev; 1850 1850 1851 1851 if (idx > 0) ··· 1887 1887 */ 1888 1888 1889 1889 queue->connection_id = 0; 1890 - atomic_set(&queue->csn, 1); 1890 + atomic_set(&queue->csn, 0); 1891 1891 } 1892 1892 1893 1893 static void ··· 2183 2183 { 2184 2184 struct nvme_fc_cmd_iu *cmdiu = &op->cmd_iu; 2185 2185 struct nvme_command *sqe = &cmdiu->sqe; 2186 - u32 csn; 2187 2186 int ret, opstate; 2188 2187 2189 2188 /* ··· 2197 2198 2198 2199 /* format the FC-NVME CMD IU and fcp_req */ 2199 2200 cmdiu->connection_id = cpu_to_be64(queue->connection_id); 2200 - csn = atomic_inc_return(&queue->csn); 2201 - cmdiu->csn = cpu_to_be32(csn); 2202 2201 cmdiu->data_len = cpu_to_be32(data_len); 2203 2202 switch (io_dir) { 2204 2203 case NVMEFC_FCP_WRITE: ··· 2254 2257 if (!(op->flags & FCOP_FLAGS_AEN)) 2255 2258 blk_mq_start_request(op->rq); 2256 2259 2260 + cmdiu->csn = cpu_to_be32(atomic_inc_return(&queue->csn)); 2257 2261 ret = ctrl->lport->ops->fcp_io(&ctrl->lport->localport, 2258 2262 &ctrl->rport->remoteport, 2259 2263 queue->lldd_handle, &op->fcp_req); 2260 2264 2261 2265 if (ret) { 2266 + /* 2267 + * If the lld fails to send the command is there an issue with 2268 + * the csn value? If the command that fails is the Connect, 2269 + * no - as the connection won't be live. If it is a command 2270 + * post-connect, it's possible a gap in csn may be created. 2271 + * Does this matter? As Linux initiators don't send fused 2272 + * commands, no. The gap would exist, but as there's nothing 2273 + * that depends on csn order to be delivered on the target 2274 + * side, it shouldn't hurt. It would be difficult for a 2275 + * target to even detect the csn gap as it has no idea when the 2276 + * cmd with the csn was supposed to arrive. 2277 + */ 2262 2278 opstate = atomic_xchg(&op->state, FCPOP_STATE_COMPLETE); 2263 2279 __nvme_fc_fcpop_chk_teardowns(ctrl, op, opstate); 2264 2280
+5
drivers/nvme/target/admin-cmd.c
··· 24 24 return len; 25 25 } 26 26 27 + u64 nvmet_get_log_page_offset(struct nvme_command *cmd) 28 + { 29 + return le64_to_cpu(cmd->get_log_page.lpo); 30 + } 31 + 27 32 static void nvmet_execute_get_log_page_noop(struct nvmet_req *req) 28 33 { 29 34 nvmet_req_complete(req, nvmet_zero_sgl(req, 0, req->data_len));
+44 -22
drivers/nvme/target/discovery.c
··· 131 131 memcpy(traddr, port->disc_addr.traddr, NVMF_TRADDR_SIZE); 132 132 } 133 133 134 + static size_t discovery_log_entries(struct nvmet_req *req) 135 + { 136 + struct nvmet_ctrl *ctrl = req->sq->ctrl; 137 + struct nvmet_subsys_link *p; 138 + struct nvmet_port *r; 139 + size_t entries = 0; 140 + 141 + list_for_each_entry(p, &req->port->subsystems, entry) { 142 + if (!nvmet_host_allowed(p->subsys, ctrl->hostnqn)) 143 + continue; 144 + entries++; 145 + } 146 + list_for_each_entry(r, &req->port->referrals, entry) 147 + entries++; 148 + return entries; 149 + } 150 + 134 151 static void nvmet_execute_get_disc_log_page(struct nvmet_req *req) 135 152 { 136 153 const int entry_size = sizeof(struct nvmf_disc_rsp_page_entry); 137 154 struct nvmet_ctrl *ctrl = req->sq->ctrl; 138 155 struct nvmf_disc_rsp_page_hdr *hdr; 156 + u64 offset = nvmet_get_log_page_offset(req->cmd); 139 157 size_t data_len = nvmet_get_log_page_len(req->cmd); 140 - size_t alloc_len = max(data_len, sizeof(*hdr)); 141 - int residual_len = data_len - sizeof(*hdr); 158 + size_t alloc_len; 142 159 struct nvmet_subsys_link *p; 143 160 struct nvmet_port *r; 144 161 u32 numrec = 0; 145 162 u16 status = 0; 163 + void *buffer; 164 + 165 + /* Spec requires dword aligned offsets */ 166 + if (offset & 0x3) { 167 + status = NVME_SC_INVALID_FIELD | NVME_SC_DNR; 168 + goto out; 169 + } 146 170 147 171 /* 148 172 * Make sure we're passing at least a buffer of response header size. 149 173 * If host provided data len is less than the header size, only the 150 174 * number of bytes requested by host will be sent to host. 151 175 */ 152 - hdr = kzalloc(alloc_len, GFP_KERNEL); 153 - if (!hdr) { 176 + down_read(&nvmet_config_sem); 177 + alloc_len = sizeof(*hdr) + entry_size * discovery_log_entries(req); 178 + buffer = kzalloc(alloc_len, GFP_KERNEL); 179 + if (!buffer) { 180 + up_read(&nvmet_config_sem); 154 181 status = NVME_SC_INTERNAL; 155 182 goto out; 156 183 } 157 184 158 - down_read(&nvmet_config_sem); 185 + hdr = buffer; 159 186 list_for_each_entry(p, &req->port->subsystems, entry) { 187 + char traddr[NVMF_TRADDR_SIZE]; 188 + 160 189 if (!nvmet_host_allowed(p->subsys, ctrl->hostnqn)) 161 190 continue; 162 - if (residual_len >= entry_size) { 163 - char traddr[NVMF_TRADDR_SIZE]; 164 191 165 - nvmet_set_disc_traddr(req, req->port, traddr); 166 - nvmet_format_discovery_entry(hdr, req->port, 167 - p->subsys->subsysnqn, traddr, 168 - NVME_NQN_NVME, numrec); 169 - residual_len -= entry_size; 170 - } 192 + nvmet_set_disc_traddr(req, req->port, traddr); 193 + nvmet_format_discovery_entry(hdr, req->port, 194 + p->subsys->subsysnqn, traddr, 195 + NVME_NQN_NVME, numrec); 171 196 numrec++; 172 197 } 173 198 174 199 list_for_each_entry(r, &req->port->referrals, entry) { 175 - if (residual_len >= entry_size) { 176 - nvmet_format_discovery_entry(hdr, r, 177 - NVME_DISC_SUBSYS_NAME, 178 - r->disc_addr.traddr, 179 - NVME_NQN_DISC, numrec); 180 - residual_len -= entry_size; 181 - } 200 + nvmet_format_discovery_entry(hdr, r, 201 + NVME_DISC_SUBSYS_NAME, 202 + r->disc_addr.traddr, 203 + NVME_NQN_DISC, numrec); 182 204 numrec++; 183 205 } 184 206 ··· 212 190 213 191 up_read(&nvmet_config_sem); 214 192 215 - status = nvmet_copy_to_sgl(req, 0, hdr, data_len); 216 - kfree(hdr); 193 + status = nvmet_copy_to_sgl(req, 0, buffer + offset, data_len); 194 + kfree(buffer); 217 195 out: 218 196 nvmet_req_complete(req, status); 219 197 }
+1
drivers/nvme/target/nvmet.h
··· 428 428 u16 nvmet_zero_sgl(struct nvmet_req *req, off_t off, size_t len); 429 429 430 430 u32 nvmet_get_log_page_len(struct nvme_command *cmd); 431 + u64 nvmet_get_log_page_offset(struct nvme_command *cmd); 431 432 432 433 extern struct list_head *nvmet_ports; 433 434 void nvmet_port_disc_changed(struct nvmet_port *port,
+4
drivers/pci/hotplug/pciehp_ctrl.c
··· 115 115 * removed from the slot/adapter. 116 116 */ 117 117 msleep(1000); 118 + 119 + /* Ignore link or presence changes caused by power off */ 120 + atomic_and(~(PCI_EXP_SLTSTA_DLLSC | PCI_EXP_SLTSTA_PDC), 121 + &ctrl->pending_events); 118 122 } 119 123 120 124 /* turn off Green LED */
+2
drivers/pci/quirks.c
··· 3877 3877 /* https://bugzilla.kernel.org/show_bug.cgi?id=42679#c14 */ 3878 3878 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL_EXT, 0x9130, 3879 3879 quirk_dma_func1_alias); 3880 + DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL_EXT, 0x9170, 3881 + quirk_dma_func1_alias); 3880 3882 /* https://bugzilla.kernel.org/show_bug.cgi?id=42679#c47 + c57 */ 3881 3883 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL_EXT, 0x9172, 3882 3884 quirk_dma_func1_alias);
+21
drivers/platform/x86/pmc_atom.c
··· 17 17 18 18 #include <linux/debugfs.h> 19 19 #include <linux/device.h> 20 + #include <linux/dmi.h> 20 21 #include <linux/init.h> 21 22 #include <linux/io.h> 22 23 #include <linux/platform_data/x86/clk-pmc-atom.h> ··· 392 391 } 393 392 #endif /* CONFIG_DEBUG_FS */ 394 393 394 + /* 395 + * Some systems need one or more of their pmc_plt_clks to be 396 + * marked as critical. 397 + */ 398 + static const struct dmi_system_id critclk_systems[] = { 399 + { 400 + .ident = "MPL CEC1x", 401 + .matches = { 402 + DMI_MATCH(DMI_SYS_VENDOR, "MPL AG"), 403 + DMI_MATCH(DMI_PRODUCT_NAME, "CEC10 Family"), 404 + }, 405 + }, 406 + { /*sentinel*/ } 407 + }; 408 + 395 409 static int pmc_setup_clks(struct pci_dev *pdev, void __iomem *pmc_regmap, 396 410 const struct pmc_data *pmc_data) 397 411 { 398 412 struct platform_device *clkdev; 399 413 struct pmc_clk_data *clk_data; 414 + const struct dmi_system_id *d = dmi_first_match(critclk_systems); 400 415 401 416 clk_data = kzalloc(sizeof(*clk_data), GFP_KERNEL); 402 417 if (!clk_data) ··· 420 403 421 404 clk_data->base = pmc_regmap; /* offset is added by client */ 422 405 clk_data->clks = pmc_data->clks; 406 + if (d) { 407 + clk_data->critical = true; 408 + pr_info("%s critclks quirk enabled\n", d->ident); 409 + } 423 410 424 411 clkdev = platform_device_register_data(&pdev->dev, "clk-pmc-atom", 425 412 PLATFORM_DEVID_NONE,
+4 -1
drivers/scsi/csiostor/csio_scsi.c
··· 1713 1713 } 1714 1714 1715 1715 out: 1716 - if (req->nsge > 0) 1716 + if (req->nsge > 0) { 1717 1717 scsi_dma_unmap(cmnd); 1718 + if (req->dcopy && (host_status == DID_OK)) 1719 + host_status = csio_scsi_copy_to_sgl(hw, req); 1720 + } 1718 1721 1719 1722 cmnd->result = (((host_status) << 16) | scsi_status); 1720 1723 cmnd->scsi_done(cmnd);
+1
drivers/scsi/virtio_scsi.c
··· 793 793 794 794 /* We need to know how many queues before we allocate. */ 795 795 num_queues = virtscsi_config_get(vdev, num_queues) ? : 1; 796 + num_queues = min_t(unsigned int, nr_cpu_ids, num_queues); 796 797 797 798 num_targets = virtscsi_config_get(vdev, max_target) + 1; 798 799
+5 -1
drivers/vhost/vhost.c
··· 911 911 u64 start, u64 size, u64 end, 912 912 u64 userspace_addr, int perm) 913 913 { 914 - struct vhost_umem_node *tmp, *node = kmalloc(sizeof(*node), GFP_ATOMIC); 914 + struct vhost_umem_node *tmp, *node; 915 915 916 + if (!size) 917 + return -EFAULT; 918 + 919 + node = kmalloc(sizeof(*node), GFP_ATOMIC); 916 920 if (!node) 917 921 return -ENOMEM; 918 922
+5 -3
drivers/virtio/virtio_pci_common.c
··· 255 255 for (i = 0; i < vp_dev->msix_used_vectors; ++i) 256 256 free_irq(pci_irq_vector(vp_dev->pci_dev, i), vp_dev); 257 257 258 - for (i = 0; i < vp_dev->msix_vectors; i++) 259 - if (vp_dev->msix_affinity_masks[i]) 260 - free_cpumask_var(vp_dev->msix_affinity_masks[i]); 258 + if (vp_dev->msix_affinity_masks) { 259 + for (i = 0; i < vp_dev->msix_vectors; i++) 260 + if (vp_dev->msix_affinity_masks[i]) 261 + free_cpumask_var(vp_dev->msix_affinity_masks[i]); 262 + } 261 263 262 264 if (vp_dev->msix_enabled) { 263 265 /* Disable the vector used for configuration */
+2
drivers/virtio/virtio_ring.c
··· 882 882 GFP_KERNEL|__GFP_NOWARN|__GFP_ZERO); 883 883 if (queue) 884 884 break; 885 + if (!may_reduce_num) 886 + return NULL; 885 887 } 886 888 887 889 if (!num)
+17 -7
fs/afs/rxrpc.c
··· 610 610 bool stalled = false; 611 611 u64 rtt; 612 612 u32 life, last_life; 613 + bool rxrpc_complete = false; 613 614 614 615 DECLARE_WAITQUEUE(myself, current); 615 616 ··· 622 621 rtt2 = 2; 623 622 624 623 timeout = rtt2; 625 - last_life = rxrpc_kernel_check_life(call->net->socket, call->rxcall); 624 + rxrpc_kernel_check_life(call->net->socket, call->rxcall, &last_life); 626 625 627 626 add_wait_queue(&call->waitq, &myself); 628 627 for (;;) { ··· 640 639 if (afs_check_call_state(call, AFS_CALL_COMPLETE)) 641 640 break; 642 641 643 - life = rxrpc_kernel_check_life(call->net->socket, call->rxcall); 642 + if (!rxrpc_kernel_check_life(call->net->socket, call->rxcall, &life)) { 643 + /* rxrpc terminated the call. */ 644 + rxrpc_complete = true; 645 + break; 646 + } 647 + 644 648 if (timeout == 0 && 645 649 life == last_life && signal_pending(current)) { 646 650 if (stalled) ··· 669 663 remove_wait_queue(&call->waitq, &myself); 670 664 __set_current_state(TASK_RUNNING); 671 665 672 - /* Kill off the call if it's still live. */ 673 666 if (!afs_check_call_state(call, AFS_CALL_COMPLETE)) { 674 - _debug("call interrupted"); 675 - if (rxrpc_kernel_abort_call(call->net->socket, call->rxcall, 676 - RX_USER_ABORT, -EINTR, "KWI")) 677 - afs_set_call_complete(call, -EINTR, 0); 667 + if (rxrpc_complete) { 668 + afs_set_call_complete(call, call->error, call->abort_code); 669 + } else { 670 + /* Kill off the call if it's still live. */ 671 + _debug("call interrupted"); 672 + if (rxrpc_kernel_abort_call(call->net->socket, call->rxcall, 673 + RX_USER_ABORT, -EINTR, "KWI")) 674 + afs_set_call_complete(call, -EINTR, 0); 675 + } 678 676 } 679 677 680 678 spin_lock_bh(&call->state_lock);
+2 -2
fs/aio.c
··· 1034 1034 return NULL; 1035 1035 1036 1036 if (unlikely(!get_reqs_available(ctx))) { 1037 - kfree(req); 1037 + kmem_cache_free(kiocb_cachep, req); 1038 1038 return NULL; 1039 1039 } 1040 1040 ··· 1794 1794 */ 1795 1795 eventfd = eventfd_ctx_fdget(iocb->aio_resfd); 1796 1796 if (IS_ERR(eventfd)) 1797 - return PTR_ERR(req->ki_eventfd); 1797 + return PTR_ERR(eventfd); 1798 1798 1799 1799 req->ki_eventfd = eventfd; 1800 1800 }
+4 -4
fs/block_dev.c
··· 307 307 struct blkdev_dio *dio = bio->bi_private; 308 308 bool should_dirty = dio->should_dirty; 309 309 310 - if (dio->multi_bio && !atomic_dec_and_test(&dio->ref)) { 311 - if (bio->bi_status && !dio->bio.bi_status) 312 - dio->bio.bi_status = bio->bi_status; 313 - } else { 310 + if (bio->bi_status && !dio->bio.bi_status) 311 + dio->bio.bi_status = bio->bi_status; 312 + 313 + if (!dio->multi_bio || atomic_dec_and_test(&dio->ref)) { 314 314 if (!dio->is_sync) { 315 315 struct kiocb *iocb = dio->iocb; 316 316 ssize_t ret;
+10
fs/btrfs/ioctl.c
··· 501 501 if (!capable(CAP_SYS_ADMIN)) 502 502 return -EPERM; 503 503 504 + /* 505 + * If the fs is mounted with nologreplay, which requires it to be 506 + * mounted in RO mode as well, we can not allow discard on free space 507 + * inside block groups, because log trees refer to extents that are not 508 + * pinned in a block group's free space cache (pinning the extents is 509 + * precisely the first phase of replaying a log tree). 510 + */ 511 + if (btrfs_test_opt(fs_info, NOLOGREPLAY)) 512 + return -EROFS; 513 + 504 514 rcu_read_lock(); 505 515 list_for_each_entry_rcu(device, &fs_info->fs_devices->devices, 506 516 dev_list) {
+4 -4
fs/btrfs/props.c
··· 366 366 367 367 static int prop_compression_validate(const char *value, size_t len) 368 368 { 369 - if (!strncmp("lzo", value, len)) 369 + if (!strncmp("lzo", value, 3)) 370 370 return 0; 371 - else if (!strncmp("zlib", value, len)) 371 + else if (!strncmp("zlib", value, 4)) 372 372 return 0; 373 - else if (!strncmp("zstd", value, len)) 373 + else if (!strncmp("zstd", value, 4)) 374 374 return 0; 375 375 376 376 return -EINVAL; ··· 396 396 btrfs_set_fs_incompat(fs_info, COMPRESS_LZO); 397 397 } else if (!strncmp("zlib", value, 4)) { 398 398 type = BTRFS_COMPRESS_ZLIB; 399 - } else if (!strncmp("zstd", value, len)) { 399 + } else if (!strncmp("zstd", value, 4)) { 400 400 type = BTRFS_COMPRESS_ZSTD; 401 401 btrfs_set_fs_incompat(fs_info, COMPRESS_ZSTD); 402 402 } else {
+15
fs/dax.c
··· 33 33 #include <linux/sizes.h> 34 34 #include <linux/mmu_notifier.h> 35 35 #include <linux/iomap.h> 36 + #include <asm/pgalloc.h> 36 37 #include "internal.h" 37 38 38 39 #define CREATE_TRACE_POINTS ··· 1408 1407 { 1409 1408 struct address_space *mapping = vmf->vma->vm_file->f_mapping; 1410 1409 unsigned long pmd_addr = vmf->address & PMD_MASK; 1410 + struct vm_area_struct *vma = vmf->vma; 1411 1411 struct inode *inode = mapping->host; 1412 + pgtable_t pgtable = NULL; 1412 1413 struct page *zero_page; 1413 1414 spinlock_t *ptl; 1414 1415 pmd_t pmd_entry; ··· 1425 1422 *entry = dax_insert_entry(xas, mapping, vmf, *entry, pfn, 1426 1423 DAX_PMD | DAX_ZERO_PAGE, false); 1427 1424 1425 + if (arch_needs_pgtable_deposit()) { 1426 + pgtable = pte_alloc_one(vma->vm_mm); 1427 + if (!pgtable) 1428 + return VM_FAULT_OOM; 1429 + } 1430 + 1428 1431 ptl = pmd_lock(vmf->vma->vm_mm, vmf->pmd); 1429 1432 if (!pmd_none(*(vmf->pmd))) { 1430 1433 spin_unlock(ptl); 1431 1434 goto fallback; 1432 1435 } 1433 1436 1437 + if (pgtable) { 1438 + pgtable_trans_huge_deposit(vma->vm_mm, vmf->pmd, pgtable); 1439 + mm_inc_nr_ptes(vma->vm_mm); 1440 + } 1434 1441 pmd_entry = mk_pmd(zero_page, vmf->vma->vm_page_prot); 1435 1442 pmd_entry = pmd_mkhuge(pmd_entry); 1436 1443 set_pmd_at(vmf->vma->vm_mm, pmd_addr, vmf->pmd, pmd_entry); ··· 1449 1436 return VM_FAULT_NOPAGE; 1450 1437 1451 1438 fallback: 1439 + if (pgtable) 1440 + pte_free(vma->vm_mm, pgtable); 1452 1441 trace_dax_pmd_load_hole_fallback(inode, vmf, zero_page, *entry); 1453 1442 return VM_FAULT_FALLBACK; 1454 1443 }
+6 -6
fs/fuse/dev.c
··· 2056 2056 rem += pipe->bufs[(pipe->curbuf + idx) & (pipe->buffers - 1)].len; 2057 2057 2058 2058 ret = -EINVAL; 2059 - if (rem < len) { 2060 - pipe_unlock(pipe); 2061 - goto out; 2062 - } 2059 + if (rem < len) 2060 + goto out_free; 2063 2061 2064 2062 rem = len; 2065 2063 while (rem) { ··· 2075 2077 pipe->curbuf = (pipe->curbuf + 1) & (pipe->buffers - 1); 2076 2078 pipe->nrbufs--; 2077 2079 } else { 2078 - pipe_buf_get(pipe, ibuf); 2080 + if (!pipe_buf_get(pipe, ibuf)) 2081 + goto out_free; 2082 + 2079 2083 *obuf = *ibuf; 2080 2084 obuf->flags &= ~PIPE_BUF_FLAG_GIFT; 2081 2085 obuf->len = rem; ··· 2100 2100 ret = fuse_dev_do_write(fud, &cs, len); 2101 2101 2102 2102 pipe_lock(pipe); 2103 + out_free: 2103 2104 for (idx = 0; idx < nbuf; idx++) 2104 2105 pipe_buf_release(pipe, &bufs[idx]); 2105 2106 pipe_unlock(pipe); 2106 2107 2107 - out: 2108 2108 kvfree(bufs); 2109 2109 return ret; 2110 2110 }
+4
fs/io_uring.c
··· 2245 2245 goto err; 2246 2246 2247 2247 if (ctx->flags & IORING_SETUP_SQPOLL) { 2248 + ret = -EPERM; 2249 + if (!capable(CAP_SYS_ADMIN)) 2250 + goto err; 2251 + 2248 2252 if (p->flags & IORING_SETUP_SQ_AFF) { 2249 2253 int cpu; 2250 2254
-3
fs/nfs/nfs42proc.c
··· 329 329 }; 330 330 ssize_t err, err2; 331 331 332 - if (!nfs_server_capable(file_inode(dst), NFS_CAP_COPY)) 333 - return -EOPNOTSUPP; 334 - 335 332 src_lock = nfs_get_lock_context(nfs_file_open_context(src)); 336 333 if (IS_ERR(src_lock)) 337 334 return PTR_ERR(src_lock);
+3 -1
fs/nfs/nfs4file.c
··· 133 133 struct file *file_out, loff_t pos_out, 134 134 size_t count, unsigned int flags) 135 135 { 136 + if (!nfs_server_capable(file_inode(file_out), NFS_CAP_COPY)) 137 + return -EOPNOTSUPP; 136 138 if (file_inode(file_in) == file_inode(file_out)) 137 - return -EINVAL; 139 + return -EOPNOTSUPP; 138 140 return nfs42_proc_copy(file_in, pos_in, file_out, pos_out, count); 139 141 } 140 142
+2 -2
fs/nfs/nfs4xdr.c
··· 2589 2589 ARRAY_SIZE(nfs4_acl_bitmap), &hdr); 2590 2590 2591 2591 rpc_prepare_reply_pages(req, args->acl_pages, 0, 2592 - args->acl_len, replen); 2592 + args->acl_len, replen + 1); 2593 2593 encode_nops(&hdr); 2594 2594 } 2595 2595 ··· 2811 2811 } 2812 2812 2813 2813 rpc_prepare_reply_pages(req, (struct page **)&args->page, 0, 2814 - PAGE_SIZE, replen); 2814 + PAGE_SIZE, replen + 1); 2815 2815 encode_nops(&hdr); 2816 2816 } 2817 2817
+2 -1
fs/nfs/super.c
··· 2041 2041 memcpy(sap, &data->addr, sizeof(data->addr)); 2042 2042 args->nfs_server.addrlen = sizeof(data->addr); 2043 2043 args->nfs_server.port = ntohs(data->addr.sin_port); 2044 - if (!nfs_verify_server_address(sap)) 2044 + if (sap->sa_family != AF_INET || 2045 + !nfs_verify_server_address(sap)) 2045 2046 goto out_no_address; 2046 2047 2047 2048 if (!(data->flags & NFS_MOUNT_TCP))
+2 -2
fs/pipe.c
··· 188 188 * in the tee() system call, when we duplicate the buffers in one 189 189 * pipe into another. 190 190 */ 191 - void generic_pipe_buf_get(struct pipe_inode_info *pipe, struct pipe_buffer *buf) 191 + bool generic_pipe_buf_get(struct pipe_inode_info *pipe, struct pipe_buffer *buf) 192 192 { 193 - get_page(buf->page); 193 + return try_get_page(buf->page); 194 194 } 195 195 EXPORT_SYMBOL(generic_pipe_buf_get); 196 196
+10 -2
fs/splice.c
··· 1593 1593 * Get a reference to this pipe buffer, 1594 1594 * so we can copy the contents over. 1595 1595 */ 1596 - pipe_buf_get(ipipe, ibuf); 1596 + if (!pipe_buf_get(ipipe, ibuf)) { 1597 + if (ret == 0) 1598 + ret = -EFAULT; 1599 + break; 1600 + } 1597 1601 *obuf = *ibuf; 1598 1602 1599 1603 /* ··· 1671 1667 * Get a reference to this pipe buffer, 1672 1668 * so we can copy the contents over. 1673 1669 */ 1674 - pipe_buf_get(ipipe, ibuf); 1670 + if (!pipe_buf_get(ipipe, ibuf)) { 1671 + if (ret == 0) 1672 + ret = -EFAULT; 1673 + break; 1674 + } 1675 1675 1676 1676 obuf = opipe->bufs + nbuf; 1677 1677 *obuf = *ibuf;
+4
include/drm/drm_modeset_helper_vtables.h
··· 418 418 * Drivers can use the @old_crtc_state input parameter if the operations 419 419 * needed to enable the CRTC don't depend solely on the new state but 420 420 * also on the transition between the old state and the new state. 421 + * 422 + * This function is optional. 421 423 */ 422 424 void (*atomic_enable)(struct drm_crtc *crtc, 423 425 struct drm_crtc_state *old_crtc_state); ··· 443 441 * parameter @old_crtc_state which could be used to access the old 444 442 * state. Atomic drivers should consider to use this one instead 445 443 * of @disable. 444 + * 445 + * This function is optional. 446 446 */ 447 447 void (*atomic_disable)(struct drm_crtc *crtc, 448 448 struct drm_crtc_state *old_crtc_state);
+18
include/dt-bindings/clock/sifive-fu540-prci.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + /* 3 + * Copyright (C) 2018-2019 SiFive, Inc. 4 + * Wesley Terpstra 5 + * Paul Walmsley 6 + */ 7 + 8 + #ifndef __DT_BINDINGS_CLOCK_SIFIVE_FU540_PRCI_H 9 + #define __DT_BINDINGS_CLOCK_SIFIVE_FU540_PRCI_H 10 + 11 + /* Clock indexes for use by Device Tree data and the PRCI driver */ 12 + 13 + #define PRCI_CLK_COREPLL 0 14 + #define PRCI_CLK_DDRPLL 1 15 + #define PRCI_CLK_GEMGXLPLL 2 16 + #define PRCI_CLK_TLCLK 3 17 + 18 + #endif
+12 -8
include/linux/bio.h
··· 120 120 return bio->bi_vcnt >= bio->bi_max_vecs; 121 121 } 122 122 123 - #define mp_bvec_for_each_segment(bv, bvl, i, iter_all) \ 124 - for (bv = bvec_init_iter_all(&iter_all); \ 125 - (iter_all.done < (bvl)->bv_len) && \ 126 - (mp_bvec_next_segment((bvl), &iter_all), 1); \ 127 - iter_all.done += bv->bv_len, i += 1) 123 + static inline bool bio_next_segment(const struct bio *bio, 124 + struct bvec_iter_all *iter) 125 + { 126 + if (iter->idx >= bio->bi_vcnt) 127 + return false; 128 + 129 + bvec_advance(&bio->bi_io_vec[iter->idx], iter); 130 + return true; 131 + } 128 132 129 133 /* 130 134 * drivers should _never_ use the all version - the bio may have been split 131 135 * before it got to the driver and the driver won't own all of it 132 136 */ 133 - #define bio_for_each_segment_all(bvl, bio, i, iter_all) \ 134 - for (i = 0, iter_all.idx = 0; iter_all.idx < (bio)->bi_vcnt; iter_all.idx++) \ 135 - mp_bvec_for_each_segment(bvl, &((bio)->bi_io_vec[iter_all.idx]), i, iter_all) 137 + #define bio_for_each_segment_all(bvl, bio, i, iter) \ 138 + for (i = 0, bvl = bvec_init_iter_all(&iter); \ 139 + bio_next_segment((bio), &iter); i++) 136 140 137 141 static inline void bio_advance_iter(struct bio *bio, struct bvec_iter *iter, 138 142 unsigned bytes)
+1
include/linux/blk-mq.h
··· 302 302 void blk_mq_kick_requeue_list(struct request_queue *q); 303 303 void blk_mq_delay_kick_requeue_list(struct request_queue *q, unsigned long msecs); 304 304 bool blk_mq_complete_request(struct request *rq); 305 + void blk_mq_complete_request_sync(struct request *rq); 305 306 bool blk_mq_bio_list_merge(struct request_queue *q, struct list_head *list, 306 307 struct bio *bio); 307 308 bool blk_mq_queue_stopped(struct request_queue *q);
+10 -4
include/linux/bvec.h
··· 145 145 146 146 static inline struct bio_vec *bvec_init_iter_all(struct bvec_iter_all *iter_all) 147 147 { 148 - iter_all->bv.bv_page = NULL; 149 148 iter_all->done = 0; 149 + iter_all->idx = 0; 150 150 151 151 return &iter_all->bv; 152 152 } 153 153 154 - static inline void mp_bvec_next_segment(const struct bio_vec *bvec, 155 - struct bvec_iter_all *iter_all) 154 + static inline void bvec_advance(const struct bio_vec *bvec, 155 + struct bvec_iter_all *iter_all) 156 156 { 157 157 struct bio_vec *bv = &iter_all->bv; 158 158 159 - if (bv->bv_page) { 159 + if (iter_all->done) { 160 160 bv->bv_page = nth_page(bv->bv_page, 1); 161 161 bv->bv_offset = 0; 162 162 } else { ··· 165 165 } 166 166 bv->bv_len = min_t(unsigned int, PAGE_SIZE - bv->bv_offset, 167 167 bvec->bv_len - iter_all->done); 168 + iter_all->done += bv->bv_len; 169 + 170 + if (iter_all->done == bvec->bv_len) { 171 + iter_all->idx++; 172 + iter_all->done = 0; 173 + } 168 174 } 169 175 170 176 /*
+2 -2
include/linux/kernel.h
··· 47 47 48 48 #define u64_to_user_ptr(x) ( \ 49 49 { \ 50 - typecheck(u64, x); \ 51 - (void __user *)(uintptr_t)x; \ 50 + typecheck(u64, (x)); \ 51 + (void __user *)(uintptr_t)(x); \ 52 52 } \ 53 53 ) 54 54
+6 -4
include/linux/kvm_host.h
··· 28 28 #include <linux/irqbypass.h> 29 29 #include <linux/swait.h> 30 30 #include <linux/refcount.h> 31 + #include <linux/nospec.h> 31 32 #include <asm/signal.h> 32 33 33 34 #include <linux/kvm.h> ··· 514 513 515 514 static inline struct kvm_vcpu *kvm_get_vcpu(struct kvm *kvm, int i) 516 515 { 517 - /* Pairs with smp_wmb() in kvm_vm_ioctl_create_vcpu, in case 518 - * the caller has read kvm->online_vcpus before (as is the case 519 - * for kvm_for_each_vcpu, for example). 520 - */ 516 + int num_vcpus = atomic_read(&kvm->online_vcpus); 517 + i = array_index_nospec(i, num_vcpus); 518 + 519 + /* Pairs with smp_wmb() in kvm_vm_ioctl_create_vcpu. */ 521 520 smp_rmb(); 522 521 return kvm->vcpus[i]; 523 522 } ··· 601 600 602 601 static inline struct kvm_memslots *__kvm_memslots(struct kvm *kvm, int as_id) 603 602 { 603 + as_id = array_index_nospec(as_id, KVM_ADDRESS_SPACE_NUM); 604 604 return srcu_dereference_check(kvm->memslots[as_id], &kvm->srcu, 605 605 lockdep_is_held(&kvm->slots_lock) || 606 606 !refcount_read(&kvm->users_count));
+14 -1
include/linux/mm.h
··· 966 966 } 967 967 #endif /* CONFIG_DEV_PAGEMAP_OPS */ 968 968 969 + /* 127: arbitrary random number, small enough to assemble well */ 970 + #define page_ref_zero_or_close_to_overflow(page) \ 971 + ((unsigned int) page_ref_count(page) + 127u <= 127u) 972 + 969 973 static inline void get_page(struct page *page) 970 974 { 971 975 page = compound_head(page); ··· 977 973 * Getting a normal page or the head of a compound page 978 974 * requires to already have an elevated page->_refcount. 979 975 */ 980 - VM_BUG_ON_PAGE(page_ref_count(page) <= 0, page); 976 + VM_BUG_ON_PAGE(page_ref_zero_or_close_to_overflow(page), page); 981 977 page_ref_inc(page); 978 + } 979 + 980 + static inline __must_check bool try_get_page(struct page *page) 981 + { 982 + page = compound_head(page); 983 + if (WARN_ON_ONCE(page_ref_count(page) <= 0)) 984 + return false; 985 + page_ref_inc(page); 986 + return true; 982 987 } 983 988 984 989 static inline void put_page(struct page *page)
+3
include/linux/netdevice.h
··· 1498 1498 * @IFF_FAILOVER: device is a failover master device 1499 1499 * @IFF_FAILOVER_SLAVE: device is lower dev of a failover master device 1500 1500 * @IFF_L3MDEV_RX_HANDLER: only invoke the rx handler of L3 master device 1501 + * @IFF_LIVE_RENAME_OK: rename is allowed while device is up and running 1501 1502 */ 1502 1503 enum netdev_priv_flags { 1503 1504 IFF_802_1Q_VLAN = 1<<0, ··· 1531 1530 IFF_FAILOVER = 1<<27, 1532 1531 IFF_FAILOVER_SLAVE = 1<<28, 1533 1532 IFF_L3MDEV_RX_HANDLER = 1<<29, 1533 + IFF_LIVE_RENAME_OK = 1<<30, 1534 1534 }; 1535 1535 1536 1536 #define IFF_802_1Q_VLAN IFF_802_1Q_VLAN ··· 1563 1561 #define IFF_FAILOVER IFF_FAILOVER 1564 1562 #define IFF_FAILOVER_SLAVE IFF_FAILOVER_SLAVE 1565 1563 #define IFF_L3MDEV_RX_HANDLER IFF_L3MDEV_RX_HANDLER 1564 + #define IFF_LIVE_RENAME_OK IFF_LIVE_RENAME_OK 1566 1565 1567 1566 /** 1568 1567 * struct net_device - The DEVICE structure.
+7 -2
include/linux/nvme.h
··· 967 967 __le16 numdl; 968 968 __le16 numdu; 969 969 __u16 rsvd11; 970 - __le32 lpol; 971 - __le32 lpou; 970 + union { 971 + struct { 972 + __le32 lpol; 973 + __le32 lpou; 974 + }; 975 + __le64 lpo; 976 + }; 972 977 __u32 rsvd14[2]; 973 978 }; 974 979
+6 -4
include/linux/pipe_fs_i.h
··· 101 101 /* 102 102 * Get a reference to the pipe buffer. 103 103 */ 104 - void (*get)(struct pipe_inode_info *, struct pipe_buffer *); 104 + bool (*get)(struct pipe_inode_info *, struct pipe_buffer *); 105 105 }; 106 106 107 107 /** 108 108 * pipe_buf_get - get a reference to a pipe_buffer 109 109 * @pipe: the pipe that the buffer belongs to 110 110 * @buf: the buffer to get a reference to 111 + * 112 + * Return: %true if the reference was successfully obtained. 111 113 */ 112 - static inline void pipe_buf_get(struct pipe_inode_info *pipe, 114 + static inline __must_check bool pipe_buf_get(struct pipe_inode_info *pipe, 113 115 struct pipe_buffer *buf) 114 116 { 115 - buf->ops->get(pipe, buf); 117 + return buf->ops->get(pipe, buf); 116 118 } 117 119 118 120 /** ··· 173 171 void free_pipe_info(struct pipe_inode_info *); 174 172 175 173 /* Generic pipe buffer ops functions */ 176 - void generic_pipe_buf_get(struct pipe_inode_info *, struct pipe_buffer *); 174 + bool generic_pipe_buf_get(struct pipe_inode_info *, struct pipe_buffer *); 177 175 int generic_pipe_buf_confirm(struct pipe_inode_info *, struct pipe_buffer *); 178 176 int generic_pipe_buf_steal(struct pipe_inode_info *, struct pipe_buffer *); 179 177 void generic_pipe_buf_release(struct pipe_inode_info *, struct pipe_buffer *);
+3
include/linux/platform_data/x86/clk-pmc-atom.h
··· 35 35 * 36 36 * @base: PMC clock register base offset 37 37 * @clks: pointer to set of registered clocks, typically 0..5 38 + * @critical: flag to indicate if firmware enabled pmc_plt_clks 39 + * should be marked as critial or not 38 40 */ 39 41 struct pmc_clk_data { 40 42 void __iomem *base; 41 43 const struct pmc_clk *clks; 44 + bool critical; 42 45 }; 43 46 44 47 #endif /* __PLATFORM_DATA_X86_CLK_PMC_ATOM_H */
-8
include/linux/sunrpc/sched.h
··· 304 304 } 305 305 #endif /* CONFIG_SUNRPC_SWAP */ 306 306 307 - static inline bool 308 - rpc_task_need_resched(const struct rpc_task *task) 309 - { 310 - if (RPC_IS_QUEUED(task) || task->tk_callback) 311 - return true; 312 - return false; 313 - } 314 - 315 307 #endif /* _LINUX_SUNRPC_SCHED_H_ */
+1 -1
include/linux/virtio_ring.h
··· 63 63 /* 64 64 * Creates a virtqueue and allocates the descriptor ring. If 65 65 * may_reduce_num is set, then this may allocate a smaller ring than 66 - * expected. The caller should query virtqueue_get_ring_size to learn 66 + * expected. The caller should query virtqueue_get_vring_size to learn 67 67 * the actual size of the ring. 68 68 */ 69 69 struct virtqueue *vring_create_virtqueue(unsigned int index,
+3 -1
include/net/af_rxrpc.h
··· 61 61 rxrpc_user_attach_call_t, unsigned long, gfp_t, 62 62 unsigned int); 63 63 void rxrpc_kernel_set_tx_length(struct socket *, struct rxrpc_call *, s64); 64 - u32 rxrpc_kernel_check_life(const struct socket *, const struct rxrpc_call *); 64 + bool rxrpc_kernel_check_life(const struct socket *, const struct rxrpc_call *, 65 + u32 *); 65 66 void rxrpc_kernel_probe_life(struct socket *, struct rxrpc_call *); 66 67 u32 rxrpc_kernel_get_epoch(struct socket *, struct rxrpc_call *); 67 68 bool rxrpc_kernel_get_reply_time(struct socket *, struct rxrpc_call *, 68 69 ktime_t *); 70 + bool rxrpc_kernel_call_is_complete(struct rxrpc_call *); 69 71 70 72 #endif /* _NET_RXRPC_H */
+5
include/net/cfg80211.h
··· 7183 7183 #define wiphy_info(wiphy, format, args...) \ 7184 7184 dev_info(&(wiphy)->dev, format, ##args) 7185 7185 7186 + #define wiphy_err_ratelimited(wiphy, format, args...) \ 7187 + dev_err_ratelimited(&(wiphy)->dev, format, ##args) 7188 + #define wiphy_warn_ratelimited(wiphy, format, args...) \ 7189 + dev_warn_ratelimited(&(wiphy)->dev, format, ##args) 7190 + 7186 7191 #define wiphy_debug(wiphy, format, args...) \ 7187 7192 wiphy_printk(KERN_DEBUG, wiphy, format, ##args) 7188 7193
+38 -33
include/net/mac80211.h
··· 6231 6231 * @hw: pointer as obtained from ieee80211_alloc_hw() 6232 6232 * @ac: AC number to return packets from. 6233 6233 * 6234 - * Should only be called between calls to ieee80211_txq_schedule_start() 6235 - * and ieee80211_txq_schedule_end(). 6236 6234 * Returns the next txq if successful, %NULL if no queue is eligible. If a txq 6237 6235 * is returned, it should be returned with ieee80211_return_txq() after the 6238 6236 * driver has finished scheduling it. ··· 6238 6240 struct ieee80211_txq *ieee80211_next_txq(struct ieee80211_hw *hw, u8 ac); 6239 6241 6240 6242 /** 6241 - * ieee80211_return_txq - return a TXQ previously acquired by ieee80211_next_txq() 6242 - * 6243 - * @hw: pointer as obtained from ieee80211_alloc_hw() 6244 - * @txq: pointer obtained from station or virtual interface 6245 - * 6246 - * Should only be called between calls to ieee80211_txq_schedule_start() 6247 - * and ieee80211_txq_schedule_end(). 6248 - */ 6249 - void ieee80211_return_txq(struct ieee80211_hw *hw, struct ieee80211_txq *txq); 6250 - 6251 - /** 6252 - * ieee80211_txq_schedule_start - acquire locks for safe scheduling of an AC 6243 + * ieee80211_txq_schedule_start - start new scheduling round for TXQs 6253 6244 * 6254 6245 * @hw: pointer as obtained from ieee80211_alloc_hw() 6255 6246 * @ac: AC number to acquire locks for 6256 6247 * 6257 - * Acquire locks needed to schedule TXQs from the given AC. Should be called 6258 - * before ieee80211_next_txq() or ieee80211_return_txq(). 6248 + * Should be called before ieee80211_next_txq() or ieee80211_return_txq(). 6249 + * The driver must not call multiple TXQ scheduling rounds concurrently. 6259 6250 */ 6260 - void ieee80211_txq_schedule_start(struct ieee80211_hw *hw, u8 ac) 6261 - __acquires(txq_lock); 6251 + void ieee80211_txq_schedule_start(struct ieee80211_hw *hw, u8 ac); 6262 6252 6263 - /** 6264 - * ieee80211_txq_schedule_end - release locks for safe scheduling of an AC 6265 - * 6266 - * @hw: pointer as obtained from ieee80211_alloc_hw() 6267 - * @ac: AC number to acquire locks for 6268 - * 6269 - * Release locks previously acquired by ieee80211_txq_schedule_end(). 6270 - */ 6271 - void ieee80211_txq_schedule_end(struct ieee80211_hw *hw, u8 ac) 6272 - __releases(txq_lock); 6253 + /* (deprecated) */ 6254 + static inline void ieee80211_txq_schedule_end(struct ieee80211_hw *hw, u8 ac) 6255 + { 6256 + } 6257 + 6258 + void __ieee80211_schedule_txq(struct ieee80211_hw *hw, 6259 + struct ieee80211_txq *txq, bool force); 6273 6260 6274 6261 /** 6275 6262 * ieee80211_schedule_txq - schedule a TXQ for transmission ··· 6262 6279 * @hw: pointer as obtained from ieee80211_alloc_hw() 6263 6280 * @txq: pointer obtained from station or virtual interface 6264 6281 * 6265 - * Schedules a TXQ for transmission if it is not already scheduled. Takes a 6266 - * lock, which means it must *not* be called between 6267 - * ieee80211_txq_schedule_start() and ieee80211_txq_schedule_end() 6282 + * Schedules a TXQ for transmission if it is not already scheduled, 6283 + * even if mac80211 does not have any packets buffered. 6284 + * 6285 + * The driver may call this function if it has buffered packets for 6286 + * this TXQ internally. 6268 6287 */ 6269 - void ieee80211_schedule_txq(struct ieee80211_hw *hw, struct ieee80211_txq *txq) 6270 - __acquires(txq_lock) __releases(txq_lock); 6288 + static inline void 6289 + ieee80211_schedule_txq(struct ieee80211_hw *hw, struct ieee80211_txq *txq) 6290 + { 6291 + __ieee80211_schedule_txq(hw, txq, true); 6292 + } 6293 + 6294 + /** 6295 + * ieee80211_return_txq - return a TXQ previously acquired by ieee80211_next_txq() 6296 + * 6297 + * @hw: pointer as obtained from ieee80211_alloc_hw() 6298 + * @txq: pointer obtained from station or virtual interface 6299 + * @force: schedule txq even if mac80211 does not have any buffered packets. 6300 + * 6301 + * The driver may set force=true if it has buffered packets for this TXQ 6302 + * internally. 6303 + */ 6304 + static inline void 6305 + ieee80211_return_txq(struct ieee80211_hw *hw, struct ieee80211_txq *txq, 6306 + bool force) 6307 + { 6308 + __ieee80211_schedule_txq(hw, txq, force); 6309 + } 6271 6310 6272 6311 /** 6273 6312 * ieee80211_txq_may_transmit - check whether TXQ is allowed to transmit
+1 -1
include/net/netrom.h
··· 266 266 int nr_t1timer_running(struct sock *); 267 267 268 268 /* sysctl_net_netrom.c */ 269 - void nr_register_sysctl(void); 269 + int nr_register_sysctl(void); 270 270 void nr_unregister_sysctl(void); 271 271 272 272 #endif
-6
include/net/sock.h
··· 2091 2091 * @p: poll_table 2092 2092 * 2093 2093 * See the comments in the wq_has_sleeper function. 2094 - * 2095 - * Do not derive sock from filp->private_data here. An SMC socket establishes 2096 - * an internal TCP socket that is used in the fallback case. All socket 2097 - * operations on the SMC socket are then forwarded to the TCP socket. In case of 2098 - * poll, the filp->private_data pointer references the SMC socket because the 2099 - * TCP socket has no file assigned. 2100 2094 */ 2101 2095 static inline void sock_poll_wait(struct file *filp, struct socket *sock, 2102 2096 poll_table *p)
+3 -1
include/net/tls.h
··· 318 318 int tls_device_sendpage(struct sock *sk, struct page *page, 319 319 int offset, size_t size, int flags); 320 320 void tls_device_sk_destruct(struct sock *sk); 321 + void tls_device_free_resources_tx(struct sock *sk); 321 322 void tls_device_init(void); 322 323 void tls_device_cleanup(void); 323 324 int tls_tx_records(struct sock *sk, int flags); ··· 342 341 int flags); 343 342 int tls_push_partial_record(struct sock *sk, struct tls_context *ctx, 344 343 int flags); 344 + bool tls_free_partial_record(struct sock *sk, struct tls_context *ctx); 345 345 346 346 static inline struct tls_msg *tls_msg(struct sk_buff *skb) 347 347 { ··· 392 390 static inline bool tls_is_sk_tx_device_offloaded(struct sock *sk) 393 391 { 394 392 #ifdef CONFIG_SOCK_VALIDATE_XMIT 395 - return sk_fullsock(sk) & 393 + return sk_fullsock(sk) && 396 394 (smp_load_acquire(&sk->sk_validate_xmit_skb) == 397 395 &tls_validate_xmit_skb); 398 396 #else
+9 -2
include/sound/soc.h
··· 802 802 int probe_order; 803 803 int remove_order; 804 804 805 - /* signal if the module handling the component cannot be removed */ 806 - unsigned int ignore_module_refcount:1; 805 + /* 806 + * signal if the module handling the component should not be removed 807 + * if a pcm is open. Setting this would prevent the module 808 + * refcount being incremented in probe() but allow it be incremented 809 + * when a pcm is opened and decremented when it is closed. 810 + */ 811 + unsigned int module_get_upon_open:1; 807 812 808 813 /* bits */ 809 814 unsigned int idle_bias_on:1; ··· 1087 1082 1088 1083 struct mutex mutex; 1089 1084 struct mutex dapm_mutex; 1085 + 1086 + spinlock_t dpcm_lock; 1090 1087 1091 1088 bool instantiated; 1092 1089 bool topology_shortname_created;
+1
include/uapi/sound/asound.h
··· 32 32 33 33 #ifndef __KERNEL__ 34 34 #include <stdlib.h> 35 + #include <time.h> 35 36 #endif 36 37 37 38 /*
+1 -1
kernel/dma/debug.c
··· 706 706 #ifdef CONFIG_STACKTRACE 707 707 entry->stacktrace.max_entries = DMA_DEBUG_STACKTRACE_ENTRIES; 708 708 entry->stacktrace.entries = entry->st_entries; 709 - entry->stacktrace.skip = 2; 709 + entry->stacktrace.skip = 1; 710 710 save_stack_trace(&entry->stacktrace); 711 711 #endif 712 712
+43 -9
kernel/events/core.c
··· 2009 2009 event->pmu->del(event, 0); 2010 2010 event->oncpu = -1; 2011 2011 2012 - if (event->pending_disable) { 2013 - event->pending_disable = 0; 2012 + if (READ_ONCE(event->pending_disable) >= 0) { 2013 + WRITE_ONCE(event->pending_disable, -1); 2014 2014 state = PERF_EVENT_STATE_OFF; 2015 2015 } 2016 2016 perf_event_set_state(event, state); ··· 2198 2198 2199 2199 void perf_event_disable_inatomic(struct perf_event *event) 2200 2200 { 2201 - event->pending_disable = 1; 2201 + WRITE_ONCE(event->pending_disable, smp_processor_id()); 2202 + /* can fail, see perf_pending_event_disable() */ 2202 2203 irq_work_queue(&event->pending); 2203 2204 } 2204 2205 ··· 5811 5810 } 5812 5811 } 5813 5812 5813 + static void perf_pending_event_disable(struct perf_event *event) 5814 + { 5815 + int cpu = READ_ONCE(event->pending_disable); 5816 + 5817 + if (cpu < 0) 5818 + return; 5819 + 5820 + if (cpu == smp_processor_id()) { 5821 + WRITE_ONCE(event->pending_disable, -1); 5822 + perf_event_disable_local(event); 5823 + return; 5824 + } 5825 + 5826 + /* 5827 + * CPU-A CPU-B 5828 + * 5829 + * perf_event_disable_inatomic() 5830 + * @pending_disable = CPU-A; 5831 + * irq_work_queue(); 5832 + * 5833 + * sched-out 5834 + * @pending_disable = -1; 5835 + * 5836 + * sched-in 5837 + * perf_event_disable_inatomic() 5838 + * @pending_disable = CPU-B; 5839 + * irq_work_queue(); // FAILS 5840 + * 5841 + * irq_work_run() 5842 + * perf_pending_event() 5843 + * 5844 + * But the event runs on CPU-B and wants disabling there. 5845 + */ 5846 + irq_work_queue_on(&event->pending, cpu); 5847 + } 5848 + 5814 5849 static void perf_pending_event(struct irq_work *entry) 5815 5850 { 5816 - struct perf_event *event = container_of(entry, 5817 - struct perf_event, pending); 5851 + struct perf_event *event = container_of(entry, struct perf_event, pending); 5818 5852 int rctx; 5819 5853 5820 5854 rctx = perf_swevent_get_recursion_context(); ··· 5858 5822 * and we won't recurse 'further'. 5859 5823 */ 5860 5824 5861 - if (event->pending_disable) { 5862 - event->pending_disable = 0; 5863 - perf_event_disable_local(event); 5864 - } 5825 + perf_pending_event_disable(event); 5865 5826 5866 5827 if (event->pending_wakeup) { 5867 5828 event->pending_wakeup = 0; ··· 10269 10236 10270 10237 10271 10238 init_waitqueue_head(&event->waitq); 10239 + event->pending_disable = -1; 10272 10240 init_irq_work(&event->pending, perf_pending_event); 10273 10241 10274 10242 mutex_init(&event->mmap_mutex);
+2 -2
kernel/events/ring_buffer.c
··· 392 392 * store that will be enabled on successful return 393 393 */ 394 394 if (!handle->size) { /* A, matches D */ 395 - event->pending_disable = 1; 395 + event->pending_disable = smp_processor_id(); 396 396 perf_output_wakeup(handle); 397 397 local_set(&rb->aux_nest, 0); 398 398 goto err_put; ··· 480 480 481 481 if (wakeup) { 482 482 if (handle->aux_flags & PERF_AUX_FLAG_TRUNCATED) 483 - handle->event->pending_disable = 1; 483 + handle->event->pending_disable = smp_processor_id(); 484 484 perf_output_wakeup(handle); 485 485 } 486 486
+4
kernel/irq/chip.c
··· 1449 1449 int irq_chip_set_wake_parent(struct irq_data *data, unsigned int on) 1450 1450 { 1451 1451 data = data->parent_data; 1452 + 1453 + if (data->chip->flags & IRQCHIP_SKIP_SET_WAKE) 1454 + return 0; 1455 + 1452 1456 if (data->chip->irq_set_wake) 1453 1457 return data->chip->irq_set_wake(data, on); 1454 1458
+1
kernel/irq/irqdesc.c
··· 558 558 alloc_masks(&desc[i], node); 559 559 raw_spin_lock_init(&desc[i].lock); 560 560 lockdep_set_class(&desc[i].lock, &irq_desc_lock_class); 561 + mutex_init(&desc[i].request_mutex); 561 562 desc_set_defaults(i, &desc[i], node, NULL, NULL); 562 563 } 563 564 return arch_early_irq_init();
+12 -17
kernel/locking/lockdep.c
··· 4689 4689 return; 4690 4690 4691 4691 raw_local_irq_save(flags); 4692 - if (!graph_lock()) 4693 - goto out_irq; 4692 + arch_spin_lock(&lockdep_lock); 4693 + current->lockdep_recursion = 1; 4694 4694 4695 4695 /* closed head */ 4696 4696 pf = delayed_free.pf + (delayed_free.index ^ 1); ··· 4702 4702 */ 4703 4703 call_rcu_zapped(delayed_free.pf + delayed_free.index); 4704 4704 4705 - graph_unlock(); 4706 - out_irq: 4705 + current->lockdep_recursion = 0; 4706 + arch_spin_unlock(&lockdep_lock); 4707 4707 raw_local_irq_restore(flags); 4708 4708 } 4709 4709 ··· 4744 4744 { 4745 4745 struct pending_free *pf; 4746 4746 unsigned long flags; 4747 - int locked; 4748 4747 4749 4748 init_data_structures_once(); 4750 4749 4751 4750 raw_local_irq_save(flags); 4752 - locked = graph_lock(); 4753 - if (!locked) 4754 - goto out_irq; 4755 - 4751 + arch_spin_lock(&lockdep_lock); 4752 + current->lockdep_recursion = 1; 4756 4753 pf = get_pending_free(); 4757 4754 __lockdep_free_key_range(pf, start, size); 4758 4755 call_rcu_zapped(pf); 4759 - 4760 - graph_unlock(); 4761 - out_irq: 4756 + current->lockdep_recursion = 0; 4757 + arch_spin_unlock(&lockdep_lock); 4762 4758 raw_local_irq_restore(flags); 4763 4759 4764 4760 /* ··· 4907 4911 return; 4908 4912 4909 4913 raw_local_irq_save(flags); 4910 - if (!graph_lock()) 4911 - goto out_irq; 4912 - 4914 + arch_spin_lock(&lockdep_lock); 4915 + current->lockdep_recursion = 1; 4913 4916 pf = get_pending_free(); 4914 4917 hlist_for_each_entry_rcu(k, hash_head, hash_entry) { 4915 4918 if (k == key) { ··· 4920 4925 WARN_ON_ONCE(!found); 4921 4926 __lockdep_free_key_range(pf, key, 1); 4922 4927 call_rcu_zapped(pf); 4923 - graph_unlock(); 4924 - out_irq: 4928 + current->lockdep_recursion = 0; 4929 + arch_spin_unlock(&lockdep_lock); 4925 4930 raw_local_irq_restore(flags); 4926 4931 4927 4932 /* Wait until is_dynamic_key() has finished accessing k->hash_entry. */
+3 -3
kernel/sched/fair.c
··· 7784 7784 if (cfs_rq->last_h_load_update == now) 7785 7785 return; 7786 7786 7787 - cfs_rq->h_load_next = NULL; 7787 + WRITE_ONCE(cfs_rq->h_load_next, NULL); 7788 7788 for_each_sched_entity(se) { 7789 7789 cfs_rq = cfs_rq_of(se); 7790 - cfs_rq->h_load_next = se; 7790 + WRITE_ONCE(cfs_rq->h_load_next, se); 7791 7791 if (cfs_rq->last_h_load_update == now) 7792 7792 break; 7793 7793 } ··· 7797 7797 cfs_rq->last_h_load_update = now; 7798 7798 } 7799 7799 7800 - while ((se = cfs_rq->h_load_next) != NULL) { 7800 + while ((se = READ_ONCE(cfs_rq->h_load_next)) != NULL) { 7801 7801 load = cfs_rq->h_load; 7802 7802 load = div64_ul(load * se->avg.load_avg, 7803 7803 cfs_rq_load_avg(cfs_rq) + 1);
+1 -1
kernel/time/alarmtimer.c
··· 594 594 { 595 595 struct alarm *alarm = &timr->it.alarm.alarmtimer; 596 596 597 - return ktime_sub(now, alarm->node.expires); 597 + return ktime_sub(alarm->node.expires, now); 598 598 } 599 599 600 600 /**
+5 -1
kernel/trace/trace.c
··· 7041 7041 buf->private = 0; 7042 7042 } 7043 7043 7044 - static void buffer_pipe_buf_get(struct pipe_inode_info *pipe, 7044 + static bool buffer_pipe_buf_get(struct pipe_inode_info *pipe, 7045 7045 struct pipe_buffer *buf) 7046 7046 { 7047 7047 struct buffer_ref *ref = (struct buffer_ref *)buf->private; 7048 7048 7049 + if (ref->ref > INT_MAX/2) 7050 + return false; 7051 + 7049 7052 ref->ref++; 7053 + return true; 7050 7054 } 7051 7055 7052 7056 /* Pipe buffer operations for a buffer. */
+4
lib/iov_iter.c
··· 1528 1528 size_t hash_and_copy_to_iter(const void *addr, size_t bytes, void *hashp, 1529 1529 struct iov_iter *i) 1530 1530 { 1531 + #ifdef CONFIG_CRYPTO 1531 1532 struct ahash_request *hash = hashp; 1532 1533 struct scatterlist sg; 1533 1534 size_t copied; ··· 1538 1537 ahash_request_set_crypt(hash, &sg, NULL, copied); 1539 1538 crypto_ahash_update(hash); 1540 1539 return copied; 1540 + #else 1541 + return 0; 1542 + #endif 1541 1543 } 1542 1544 EXPORT_SYMBOL(hash_and_copy_to_iter); 1543 1545
+36 -12
mm/gup.c
··· 160 160 goto retry; 161 161 } 162 162 163 - if (flags & FOLL_GET) 164 - get_page(page); 163 + if (flags & FOLL_GET) { 164 + if (unlikely(!try_get_page(page))) { 165 + page = ERR_PTR(-ENOMEM); 166 + goto out; 167 + } 168 + } 165 169 if (flags & FOLL_TOUCH) { 166 170 if ((flags & FOLL_WRITE) && 167 171 !pte_dirty(pte) && !PageDirty(page)) ··· 302 298 if (pmd_trans_unstable(pmd)) 303 299 ret = -EBUSY; 304 300 } else { 305 - get_page(page); 301 + if (unlikely(!try_get_page(page))) { 302 + spin_unlock(ptl); 303 + return ERR_PTR(-ENOMEM); 304 + } 306 305 spin_unlock(ptl); 307 306 lock_page(page); 308 307 ret = split_huge_page(page); ··· 507 500 if (is_device_public_page(*page)) 508 501 goto unmap; 509 502 } 510 - get_page(*page); 503 + if (unlikely(!try_get_page(*page))) { 504 + ret = -ENOMEM; 505 + goto unmap; 506 + } 511 507 out: 512 508 ret = 0; 513 509 unmap: ··· 1555 1545 } 1556 1546 } 1557 1547 1548 + /* 1549 + * Return the compund head page with ref appropriately incremented, 1550 + * or NULL if that failed. 1551 + */ 1552 + static inline struct page *try_get_compound_head(struct page *page, int refs) 1553 + { 1554 + struct page *head = compound_head(page); 1555 + if (WARN_ON_ONCE(page_ref_count(head) < 0)) 1556 + return NULL; 1557 + if (unlikely(!page_cache_add_speculative(head, refs))) 1558 + return NULL; 1559 + return head; 1560 + } 1561 + 1558 1562 #ifdef CONFIG_ARCH_HAS_PTE_SPECIAL 1559 1563 static int gup_pte_range(pmd_t pmd, unsigned long addr, unsigned long end, 1560 1564 int write, struct page **pages, int *nr) ··· 1603 1579 1604 1580 VM_BUG_ON(!pfn_valid(pte_pfn(pte))); 1605 1581 page = pte_page(pte); 1606 - head = compound_head(page); 1607 1582 1608 - if (!page_cache_get_speculative(head)) 1583 + head = try_get_compound_head(page, 1); 1584 + if (!head) 1609 1585 goto pte_unmap; 1610 1586 1611 1587 if (unlikely(pte_val(pte) != pte_val(*ptep))) { ··· 1744 1720 refs++; 1745 1721 } while (addr += PAGE_SIZE, addr != end); 1746 1722 1747 - head = compound_head(pmd_page(orig)); 1748 - if (!page_cache_add_speculative(head, refs)) { 1723 + head = try_get_compound_head(pmd_page(orig), refs); 1724 + if (!head) { 1749 1725 *nr -= refs; 1750 1726 return 0; 1751 1727 } ··· 1782 1758 refs++; 1783 1759 } while (addr += PAGE_SIZE, addr != end); 1784 1760 1785 - head = compound_head(pud_page(orig)); 1786 - if (!page_cache_add_speculative(head, refs)) { 1761 + head = try_get_compound_head(pud_page(orig), refs); 1762 + if (!head) { 1787 1763 *nr -= refs; 1788 1764 return 0; 1789 1765 } ··· 1819 1795 refs++; 1820 1796 } while (addr += PAGE_SIZE, addr != end); 1821 1797 1822 - head = compound_head(pgd_page(orig)); 1823 - if (!page_cache_add_speculative(head, refs)) { 1798 + head = try_get_compound_head(pgd_page(orig), refs); 1799 + if (!head) { 1824 1800 *nr -= refs; 1825 1801 return 0; 1826 1802 }
+13
mm/hugetlb.c
··· 4299 4299 4300 4300 pfn_offset = (vaddr & ~huge_page_mask(h)) >> PAGE_SHIFT; 4301 4301 page = pte_page(huge_ptep_get(pte)); 4302 + 4303 + /* 4304 + * Instead of doing 'try_get_page()' below in the same_page 4305 + * loop, just check the count once here. 4306 + */ 4307 + if (unlikely(page_count(page) <= 0)) { 4308 + if (pages) { 4309 + spin_unlock(ptl); 4310 + remainder = 0; 4311 + err = -ENOMEM; 4312 + break; 4313 + } 4314 + } 4302 4315 same_page: 4303 4316 if (pages) { 4304 4317 pages[i] = mem_map_offset(page, pfn_offset);
+5 -1
net/atm/lec.c
··· 710 710 711 711 static int lec_mcast_attach(struct atm_vcc *vcc, int arg) 712 712 { 713 - if (arg < 0 || arg >= MAX_LEC_ITF || !dev_lec[arg]) 713 + if (arg < 0 || arg >= MAX_LEC_ITF) 714 + return -EINVAL; 715 + arg = array_index_nospec(arg, MAX_LEC_ITF); 716 + if (!dev_lec[arg]) 714 717 return -EINVAL; 715 718 vcc->proto_data = dev_lec[arg]; 716 719 return lec_mcast_make(netdev_priv(dev_lec[arg]), vcc); ··· 731 728 i = arg; 732 729 if (arg >= MAX_LEC_ITF) 733 730 return -EINVAL; 731 + i = array_index_nospec(arg, MAX_LEC_ITF); 734 732 if (!dev_lec[i]) { 735 733 int size; 736 734
+2 -2
net/bluetooth/sco.c
··· 523 523 struct sock *sk = sock->sk; 524 524 int err = 0; 525 525 526 - BT_DBG("sk %p %pMR", sk, &sa->sco_bdaddr); 527 - 528 526 if (!addr || addr_len < sizeof(struct sockaddr_sco) || 529 527 addr->sa_family != AF_BLUETOOTH) 530 528 return -EINVAL; 529 + 530 + BT_DBG("sk %p %pMR", sk, &sa->sco_bdaddr); 531 531 532 532 lock_sock(sk); 533 533
+14 -9
net/bridge/br_input.c
··· 196 196 /* note: already called with rcu_read_lock */ 197 197 static int br_handle_local_finish(struct net *net, struct sock *sk, struct sk_buff *skb) 198 198 { 199 - struct net_bridge_port *p = br_port_get_rcu(skb->dev); 200 - 201 199 __br_handle_local_finish(skb); 202 200 203 - BR_INPUT_SKB_CB(skb)->brdev = p->br->dev; 204 - br_pass_frame_up(skb); 205 - return 0; 201 + /* return 1 to signal the okfn() was called so it's ok to use the skb */ 202 + return 1; 206 203 } 207 204 208 205 static int nf_hook_bridge_pre(struct sk_buff *skb, struct sk_buff **pskb) ··· 330 333 goto forward; 331 334 } 332 335 333 - /* Deliver packet to local host only */ 334 - NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_IN, dev_net(skb->dev), 335 - NULL, skb, skb->dev, NULL, br_handle_local_finish); 336 - return RX_HANDLER_CONSUMED; 336 + /* The else clause should be hit when nf_hook(): 337 + * - returns < 0 (drop/error) 338 + * - returns = 0 (stolen/nf_queue) 339 + * Thus return 1 from the okfn() to signal the skb is ok to pass 340 + */ 341 + if (NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_IN, 342 + dev_net(skb->dev), NULL, skb, skb->dev, NULL, 343 + br_handle_local_finish) == 1) { 344 + return RX_HANDLER_PASS; 345 + } else { 346 + return RX_HANDLER_CONSUMED; 347 + } 337 348 } 338 349 339 350 forward:
+3 -1
net/bridge/br_multicast.c
··· 2013 2013 2014 2014 __br_multicast_open(br, query); 2015 2015 2016 - list_for_each_entry(port, &br->port_list, list) { 2016 + rcu_read_lock(); 2017 + list_for_each_entry_rcu(port, &br->port_list, list) { 2017 2018 if (port->state == BR_STATE_DISABLED || 2018 2019 port->state == BR_STATE_BLOCKING) 2019 2020 continue; ··· 2026 2025 br_multicast_enable(&port->ip6_own_query); 2027 2026 #endif 2028 2027 } 2028 + rcu_read_unlock(); 2029 2029 } 2030 2030 2031 2031 int br_multicast_toggle(struct net_bridge *br, unsigned long val)
+1 -1
net/bridge/br_netlink.c
··· 1441 1441 nla_put_u8(skb, IFLA_BR_VLAN_STATS_ENABLED, 1442 1442 br_opt_get(br, BROPT_VLAN_STATS_ENABLED)) || 1443 1443 nla_put_u8(skb, IFLA_BR_VLAN_STATS_PER_PORT, 1444 - br_opt_get(br, IFLA_BR_VLAN_STATS_PER_PORT))) 1444 + br_opt_get(br, BROPT_VLAN_STATS_PER_PORT))) 1445 1445 return -EMSGSIZE; 1446 1446 #endif 1447 1447 #ifdef CONFIG_BRIDGE_IGMP_SNOOPING
+15 -1
net/core/dev.c
··· 1184 1184 BUG_ON(!dev_net(dev)); 1185 1185 1186 1186 net = dev_net(dev); 1187 - if (dev->flags & IFF_UP) 1187 + 1188 + /* Some auto-enslaved devices e.g. failover slaves are 1189 + * special, as userspace might rename the device after 1190 + * the interface had been brought up and running since 1191 + * the point kernel initiated auto-enslavement. Allow 1192 + * live name change even when these slave devices are 1193 + * up and running. 1194 + * 1195 + * Typically, users of these auto-enslaving devices 1196 + * don't actually care about slave name change, as 1197 + * they are supposed to operate on master interface 1198 + * directly. 1199 + */ 1200 + if (dev->flags & IFF_UP && 1201 + likely(!(dev->priv_flags & IFF_LIVE_RENAME_OK))) 1188 1202 return -EBUSY; 1189 1203 1190 1204 write_seqcount_begin(&devnet_rename_seq);
+3 -3
net/core/failover.c
··· 80 80 goto err_upper_link; 81 81 } 82 82 83 - slave_dev->priv_flags |= IFF_FAILOVER_SLAVE; 83 + slave_dev->priv_flags |= (IFF_FAILOVER_SLAVE | IFF_LIVE_RENAME_OK); 84 84 85 85 if (fops && fops->slave_register && 86 86 !fops->slave_register(slave_dev, failover_dev)) 87 87 return NOTIFY_OK; 88 88 89 89 netdev_upper_dev_unlink(slave_dev, failover_dev); 90 - slave_dev->priv_flags &= ~IFF_FAILOVER_SLAVE; 90 + slave_dev->priv_flags &= ~(IFF_FAILOVER_SLAVE | IFF_LIVE_RENAME_OK); 91 91 err_upper_link: 92 92 netdev_rx_handler_unregister(slave_dev); 93 93 done: ··· 121 121 122 122 netdev_rx_handler_unregister(slave_dev); 123 123 netdev_upper_dev_unlink(slave_dev, failover_dev); 124 - slave_dev->priv_flags &= ~IFF_FAILOVER_SLAVE; 124 + slave_dev->priv_flags &= ~(IFF_FAILOVER_SLAVE | IFF_LIVE_RENAME_OK); 125 125 126 126 if (fops && fops->slave_unregister && 127 127 !fops->slave_unregister(slave_dev, failover_dev))
+2
net/core/filter.c
··· 4462 4462 * Only binding to IP is supported. 4463 4463 */ 4464 4464 err = -EINVAL; 4465 + if (addr_len < offsetofend(struct sockaddr, sa_family)) 4466 + return err; 4465 4467 if (addr->sa_family == AF_INET) { 4466 4468 if (addr_len < sizeof(struct sockaddr_in)) 4467 4469 return err;
+5 -9
net/core/net-sysfs.c
··· 1747 1747 1748 1748 error = device_add(dev); 1749 1749 if (error) 1750 - goto error_put_device; 1750 + return error; 1751 1751 1752 1752 error = register_queue_kobjects(ndev); 1753 - if (error) 1754 - goto error_device_del; 1753 + if (error) { 1754 + device_del(dev); 1755 + return error; 1756 + } 1755 1757 1756 1758 pm_runtime_set_memalloc_noio(dev, true); 1757 1759 1758 - return 0; 1759 - 1760 - error_device_del: 1761 - device_del(dev); 1762 - error_put_device: 1763 - put_device(dev); 1764 1760 return error; 1765 1761 } 1766 1762
+4 -3
net/core/ptp_classifier.c
··· 185 185 { 0x16, 0, 0, 0x00000000 }, 186 186 { 0x06, 0, 0, 0x00000000 }, 187 187 }; 188 - struct sock_fprog_kern ptp_prog = { 189 - .len = ARRAY_SIZE(ptp_filter), .filter = ptp_filter, 190 - }; 188 + struct sock_fprog_kern ptp_prog; 189 + 190 + ptp_prog.len = ARRAY_SIZE(ptp_filter); 191 + ptp_prog.filter = ptp_filter; 191 192 192 193 BUG_ON(bpf_prog_create(&ptp_insns, &ptp_prog)); 193 194 }
+1 -1
net/core/rtnetlink.c
··· 4951 4951 { 4952 4952 struct if_stats_msg *ifsm; 4953 4953 4954 - if (nlh->nlmsg_len < sizeof(*ifsm)) { 4954 + if (nlh->nlmsg_len < nlmsg_msg_size(sizeof(*ifsm))) { 4955 4955 NL_SET_ERR_MSG(extack, "Invalid header for stats dump"); 4956 4956 return -EINVAL; 4957 4957 }
+9 -1
net/core/skbuff.c
··· 5082 5082 5083 5083 static struct sk_buff *skb_reorder_vlan_header(struct sk_buff *skb) 5084 5084 { 5085 - int mac_len; 5085 + int mac_len, meta_len; 5086 + void *meta; 5086 5087 5087 5088 if (skb_cow(skb, skb_headroom(skb)) < 0) { 5088 5089 kfree_skb(skb); ··· 5095 5094 memmove(skb_mac_header(skb) + VLAN_HLEN, skb_mac_header(skb), 5096 5095 mac_len - VLAN_HLEN - ETH_TLEN); 5097 5096 } 5097 + 5098 + meta_len = skb_metadata_len(skb); 5099 + if (meta_len) { 5100 + meta = skb_metadata_end(skb) - meta_len; 5101 + memmove(meta + VLAN_HLEN, meta, meta_len); 5102 + } 5103 + 5098 5104 skb->mac_header += VLAN_HLEN; 5099 5105 return skb; 5100 5106 }
+2 -2
net/core/sock.c
··· 348 348 tv.tv_usec = ((timeo % HZ) * USEC_PER_SEC) / HZ; 349 349 } 350 350 351 - if (in_compat_syscall() && !COMPAT_USE_64BIT_TIME) { 351 + if (old_timeval && in_compat_syscall() && !COMPAT_USE_64BIT_TIME) { 352 352 struct old_timeval32 tv32 = { tv.tv_sec, tv.tv_usec }; 353 353 *(struct old_timeval32 *)optval = tv32; 354 354 return sizeof(tv32); ··· 372 372 { 373 373 struct __kernel_sock_timeval tv; 374 374 375 - if (in_compat_syscall() && !COMPAT_USE_64BIT_TIME) { 375 + if (old_timeval && in_compat_syscall() && !COMPAT_USE_64BIT_TIME) { 376 376 struct old_timeval32 tv32; 377 377 378 378 if (optlen < sizeof(tv32))
+3 -1
net/ipv4/fou.c
··· 121 121 struct guehdr *guehdr; 122 122 void *data; 123 123 u16 doffset = 0; 124 + u8 proto_ctype; 124 125 125 126 if (!fou) 126 127 return 1; ··· 211 210 if (unlikely(guehdr->control)) 212 211 return gue_control_message(skb, guehdr); 213 212 213 + proto_ctype = guehdr->proto_ctype; 214 214 __skb_pull(skb, sizeof(struct udphdr) + hdrlen); 215 215 skb_reset_transport_header(skb); 216 216 217 217 if (iptunnel_pull_offloads(skb)) 218 218 goto drop; 219 219 220 - return -guehdr->proto_ctype; 220 + return -proto_ctype; 221 221 222 222 drop: 223 223 kfree_skb(skb);
+15 -1
net/ipv4/route.c
··· 1200 1200 1201 1201 static void ipv4_link_failure(struct sk_buff *skb) 1202 1202 { 1203 + struct ip_options opt; 1203 1204 struct rtable *rt; 1205 + int res; 1204 1206 1205 - icmp_send(skb, ICMP_DEST_UNREACH, ICMP_HOST_UNREACH, 0); 1207 + /* Recompile ip options since IPCB may not be valid anymore. 1208 + */ 1209 + memset(&opt, 0, sizeof(opt)); 1210 + opt.optlen = ip_hdr(skb)->ihl*4 - sizeof(struct iphdr); 1211 + 1212 + rcu_read_lock(); 1213 + res = __ip_options_compile(dev_net(skb->dev), &opt, skb, NULL); 1214 + rcu_read_unlock(); 1215 + 1216 + if (res) 1217 + return; 1218 + 1219 + __icmp_send(skb, ICMP_DEST_UNREACH, ICMP_HOST_UNREACH, 0, &opt); 1206 1220 1207 1221 rt = skb_rtable(skb); 1208 1222 if (rt)
+19 -30
net/ipv4/tcp_dctcp.c
··· 49 49 #define DCTCP_MAX_ALPHA 1024U 50 50 51 51 struct dctcp { 52 - u32 acked_bytes_ecn; 53 - u32 acked_bytes_total; 54 - u32 prior_snd_una; 52 + u32 old_delivered; 53 + u32 old_delivered_ce; 55 54 u32 prior_rcv_nxt; 56 55 u32 dctcp_alpha; 57 56 u32 next_seq; ··· 72 73 { 73 74 ca->next_seq = tp->snd_nxt; 74 75 75 - ca->acked_bytes_ecn = 0; 76 - ca->acked_bytes_total = 0; 76 + ca->old_delivered = tp->delivered; 77 + ca->old_delivered_ce = tp->delivered_ce; 77 78 } 78 79 79 80 static void dctcp_init(struct sock *sk) ··· 85 86 sk->sk_state == TCP_CLOSE)) { 86 87 struct dctcp *ca = inet_csk_ca(sk); 87 88 88 - ca->prior_snd_una = tp->snd_una; 89 89 ca->prior_rcv_nxt = tp->rcv_nxt; 90 90 91 91 ca->dctcp_alpha = min(dctcp_alpha_on_init, DCTCP_MAX_ALPHA); ··· 116 118 { 117 119 const struct tcp_sock *tp = tcp_sk(sk); 118 120 struct dctcp *ca = inet_csk_ca(sk); 119 - u32 acked_bytes = tp->snd_una - ca->prior_snd_una; 120 - 121 - /* If ack did not advance snd_una, count dupack as MSS size. 122 - * If ack did update window, do not count it at all. 123 - */ 124 - if (acked_bytes == 0 && !(flags & CA_ACK_WIN_UPDATE)) 125 - acked_bytes = inet_csk(sk)->icsk_ack.rcv_mss; 126 - if (acked_bytes) { 127 - ca->acked_bytes_total += acked_bytes; 128 - ca->prior_snd_una = tp->snd_una; 129 - 130 - if (flags & CA_ACK_ECE) 131 - ca->acked_bytes_ecn += acked_bytes; 132 - } 133 121 134 122 /* Expired RTT */ 135 123 if (!before(tp->snd_una, ca->next_seq)) { 136 - u64 bytes_ecn = ca->acked_bytes_ecn; 124 + u32 delivered_ce = tp->delivered_ce - ca->old_delivered_ce; 137 125 u32 alpha = ca->dctcp_alpha; 138 126 139 127 /* alpha = (1 - g) * alpha + g * F */ 140 128 141 129 alpha -= min_not_zero(alpha, alpha >> dctcp_shift_g); 142 - if (bytes_ecn) { 143 - /* If dctcp_shift_g == 1, a 32bit value would overflow 144 - * after 8 Mbytes. 145 - */ 146 - bytes_ecn <<= (10 - dctcp_shift_g); 147 - do_div(bytes_ecn, max(1U, ca->acked_bytes_total)); 130 + if (delivered_ce) { 131 + u32 delivered = tp->delivered - ca->old_delivered; 148 132 149 - alpha = min(alpha + (u32)bytes_ecn, DCTCP_MAX_ALPHA); 133 + /* If dctcp_shift_g == 1, a 32bit value would overflow 134 + * after 8 M packets. 135 + */ 136 + delivered_ce <<= (10 - dctcp_shift_g); 137 + delivered_ce /= max(1U, delivered); 138 + 139 + alpha = min(alpha + delivered_ce, DCTCP_MAX_ALPHA); 150 140 } 151 141 /* dctcp_alpha can be read from dctcp_get_info() without 152 142 * synchro, so we ask compiler to not use dctcp_alpha ··· 186 200 union tcp_cc_info *info) 187 201 { 188 202 const struct dctcp *ca = inet_csk_ca(sk); 203 + const struct tcp_sock *tp = tcp_sk(sk); 189 204 190 205 /* Fill it also in case of VEGASINFO due to req struct limits. 191 206 * We can still correctly retrieve it later. ··· 198 211 info->dctcp.dctcp_enabled = 1; 199 212 info->dctcp.dctcp_ce_state = (u16) ca->ce_state; 200 213 info->dctcp.dctcp_alpha = ca->dctcp_alpha; 201 - info->dctcp.dctcp_ab_ecn = ca->acked_bytes_ecn; 202 - info->dctcp.dctcp_ab_tot = ca->acked_bytes_total; 214 + info->dctcp.dctcp_ab_ecn = tp->mss_cache * 215 + (tp->delivered_ce - ca->old_delivered_ce); 216 + info->dctcp.dctcp_ab_tot = tp->mss_cache * 217 + (tp->delivered - ca->old_delivered); 203 218 } 204 219 205 220 *attr = INET_DIAG_DCTCPINFO;
+5 -5
net/ipv4/tcp_input.c
··· 402 402 static void tcp_grow_window(struct sock *sk, const struct sk_buff *skb) 403 403 { 404 404 struct tcp_sock *tp = tcp_sk(sk); 405 + int room; 406 + 407 + room = min_t(int, tp->window_clamp, tcp_space(sk)) - tp->rcv_ssthresh; 405 408 406 409 /* Check #1 */ 407 - if (tp->rcv_ssthresh < tp->window_clamp && 408 - (int)tp->rcv_ssthresh < tcp_space(sk) && 409 - !tcp_under_memory_pressure(sk)) { 410 + if (room > 0 && !tcp_under_memory_pressure(sk)) { 410 411 int incr; 411 412 412 413 /* Check #2. Increase window, if skb with such overhead ··· 420 419 421 420 if (incr) { 422 421 incr = max_t(int, incr, 2 * skb->len); 423 - tp->rcv_ssthresh = min(tp->rcv_ssthresh + incr, 424 - tp->window_clamp); 422 + tp->rcv_ssthresh += min(room, incr); 425 423 inet_csk(sk)->icsk_ack.quick |= 1; 426 424 } 427 425 }
+4
net/ipv6/route.c
··· 2331 2331 2332 2332 rcu_read_lock(); 2333 2333 from = rcu_dereference(rt6->from); 2334 + if (!from) { 2335 + rcu_read_unlock(); 2336 + return; 2337 + } 2334 2338 nrt6 = ip6_rt_cache_alloc(from, daddr, saddr); 2335 2339 if (nrt6) { 2336 2340 rt6_do_update_pmtu(nrt6, mtu);
+2
net/ipv6/udp.c
··· 1045 1045 static int udpv6_pre_connect(struct sock *sk, struct sockaddr *uaddr, 1046 1046 int addr_len) 1047 1047 { 1048 + if (addr_len < offsetofend(struct sockaddr, sa_family)) 1049 + return -EINVAL; 1048 1050 /* The following checks are replicated from __ip6_datagram_connect() 1049 1051 * and intended to prevent BPF program called below from accessing 1050 1052 * bytes that are out of the bound specified by user in addr_len.
+1 -2
net/llc/af_llc.c
··· 320 320 struct llc_sap *sap; 321 321 int rc = -EINVAL; 322 322 323 - dprintk("%s: binding %02X\n", __func__, addr->sllc_sap); 324 - 325 323 lock_sock(sk); 326 324 if (unlikely(!sock_flag(sk, SOCK_ZAPPED) || addrlen != sizeof(*addr))) 327 325 goto out; 328 326 rc = -EAFNOSUPPORT; 329 327 if (unlikely(addr->sllc_family != AF_LLC)) 330 328 goto out; 329 + dprintk("%s: binding %02X\n", __func__, addr->sllc_sap); 331 330 rc = -ENODEV; 332 331 rcu_read_lock(); 333 332 if (sk->sk_bound_dev_if) {
+3
net/mac80211/driver-ops.h
··· 1195 1195 { 1196 1196 struct ieee80211_sub_if_data *sdata = vif_to_sdata(txq->txq.vif); 1197 1197 1198 + if (local->in_reconfig) 1199 + return; 1200 + 1198 1201 if (!check_sdata_in_driver(sdata)) 1199 1202 return; 1200 1203
+4 -5
net/mac80211/key.c
··· 167 167 * The driver doesn't know anything about VLAN interfaces. 168 168 * Hence, don't send GTKs for VLAN interfaces to the driver. 169 169 */ 170 - if (!(key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE)) 170 + if (!(key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE)) { 171 + ret = 1; 171 172 goto out_unsupported; 173 + } 172 174 } 173 175 174 176 ret = drv_set_key(key->local, SET_KEY, sdata, ··· 215 213 /* all of these we can do in software - if driver can */ 216 214 if (ret == 1) 217 215 return 0; 218 - if (ieee80211_hw_check(&key->local->hw, SW_CRYPTO_CONTROL)) { 219 - if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) 220 - return 0; 216 + if (ieee80211_hw_check(&key->local->hw, SW_CRYPTO_CONTROL)) 221 217 return -EINVAL; 222 - } 223 218 return 0; 224 219 default: 225 220 return -EINVAL;
+1 -1
net/mac80211/mesh_pathtbl.c
··· 23 23 static u32 mesh_table_hash(const void *addr, u32 len, u32 seed) 24 24 { 25 25 /* Use last four bytes of hw addr as hash index */ 26 - return jhash_1word(*(u32 *)(addr+2), seed); 26 + return jhash_1word(__get_unaligned_cpu32((u8 *)addr + 2), seed); 27 27 } 28 28 29 29 static const struct rhashtable_params mesh_rht_params = {
+9 -1
net/mac80211/rx.c
··· 1568 1568 return; 1569 1569 1570 1570 for (tid = 0; tid < IEEE80211_NUM_TIDS; tid++) { 1571 - if (txq_has_queue(sta->sta.txq[tid])) 1571 + struct ieee80211_txq *txq = sta->sta.txq[tid]; 1572 + struct txq_info *txqi = to_txq_info(txq); 1573 + 1574 + spin_lock(&local->active_txq_lock[txq->ac]); 1575 + if (!list_empty(&txqi->schedule_order)) 1576 + list_del_init(&txqi->schedule_order); 1577 + spin_unlock(&local->active_txq_lock[txq->ac]); 1578 + 1579 + if (txq_has_queue(txq)) 1572 1580 set_bit(tid, &sta->txq_buffered_tids); 1573 1581 else 1574 1582 clear_bit(tid, &sta->txq_buffered_tids);
+6 -1
net/mac80211/trace_msg.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0 */ 2 + /* 3 + * Portions of this file 4 + * Copyright (C) 2019 Intel Corporation 5 + */ 6 + 2 7 #ifdef CONFIG_MAC80211_MESSAGE_TRACING 3 8 4 9 #if !defined(__MAC80211_MSG_DRIVER_TRACE) || defined(TRACE_HEADER_MULTI_READ) ··· 16 11 #undef TRACE_SYSTEM 17 12 #define TRACE_SYSTEM mac80211_msg 18 13 19 - #define MAX_MSG_LEN 100 14 + #define MAX_MSG_LEN 120 20 15 21 16 DECLARE_EVENT_CLASS(mac80211_msg_event, 22 17 TP_PROTO(struct va_format *vaf),
+23 -30
net/mac80211/tx.c
··· 3221 3221 u8 max_subframes = sta->sta.max_amsdu_subframes; 3222 3222 int max_frags = local->hw.max_tx_fragments; 3223 3223 int max_amsdu_len = sta->sta.max_amsdu_len; 3224 + int orig_truesize; 3224 3225 __be16 len; 3225 3226 void *data; 3226 3227 bool ret = false; ··· 3262 3261 if (!head || skb_is_gso(head)) 3263 3262 goto out; 3264 3263 3264 + orig_truesize = head->truesize; 3265 3265 orig_len = head->len; 3266 3266 3267 3267 if (skb->len + head->len > max_amsdu_len) ··· 3320 3318 *frag_tail = skb; 3321 3319 3322 3320 out_recalc: 3321 + fq->memory_usage += head->truesize - orig_truesize; 3323 3322 if (head->len != orig_len) { 3324 3323 flow->backlog += head->len - orig_len; 3325 3324 tin->backlog_bytes += head->len - orig_len; ··· 3649 3646 struct ieee80211_txq *ieee80211_next_txq(struct ieee80211_hw *hw, u8 ac) 3650 3647 { 3651 3648 struct ieee80211_local *local = hw_to_local(hw); 3649 + struct ieee80211_txq *ret = NULL; 3652 3650 struct txq_info *txqi = NULL; 3653 3651 3654 - lockdep_assert_held(&local->active_txq_lock[ac]); 3652 + spin_lock_bh(&local->active_txq_lock[ac]); 3655 3653 3656 3654 begin: 3657 3655 txqi = list_first_entry_or_null(&local->active_txqs[ac], 3658 3656 struct txq_info, 3659 3657 schedule_order); 3660 3658 if (!txqi) 3661 - return NULL; 3659 + goto out; 3662 3660 3663 3661 if (txqi->txq.sta) { 3664 3662 struct sta_info *sta = container_of(txqi->txq.sta, ··· 3676 3672 3677 3673 3678 3674 if (txqi->schedule_round == local->schedule_round[ac]) 3679 - return NULL; 3675 + goto out; 3680 3676 3681 3677 list_del_init(&txqi->schedule_order); 3682 3678 txqi->schedule_round = local->schedule_round[ac]; 3683 - return &txqi->txq; 3679 + ret = &txqi->txq; 3680 + 3681 + out: 3682 + spin_unlock_bh(&local->active_txq_lock[ac]); 3683 + return ret; 3684 3684 } 3685 3685 EXPORT_SYMBOL(ieee80211_next_txq); 3686 3686 3687 - void ieee80211_return_txq(struct ieee80211_hw *hw, 3688 - struct ieee80211_txq *txq) 3687 + void __ieee80211_schedule_txq(struct ieee80211_hw *hw, 3688 + struct ieee80211_txq *txq, 3689 + bool force) 3689 3690 { 3690 3691 struct ieee80211_local *local = hw_to_local(hw); 3691 3692 struct txq_info *txqi = to_txq_info(txq); 3692 3693 3693 - lockdep_assert_held(&local->active_txq_lock[txq->ac]); 3694 + spin_lock_bh(&local->active_txq_lock[txq->ac]); 3694 3695 3695 3696 if (list_empty(&txqi->schedule_order) && 3696 - (!skb_queue_empty(&txqi->frags) || txqi->tin.backlog_packets)) { 3697 + (force || !skb_queue_empty(&txqi->frags) || 3698 + txqi->tin.backlog_packets)) { 3697 3699 /* If airtime accounting is active, always enqueue STAs at the 3698 3700 * head of the list to ensure that they only get moved to the 3699 3701 * back by the airtime DRR scheduler once they have a negative ··· 3716 3706 list_add_tail(&txqi->schedule_order, 3717 3707 &local->active_txqs[txq->ac]); 3718 3708 } 3719 - } 3720 - EXPORT_SYMBOL(ieee80211_return_txq); 3721 3709 3722 - void ieee80211_schedule_txq(struct ieee80211_hw *hw, 3723 - struct ieee80211_txq *txq) 3724 - __acquires(txq_lock) __releases(txq_lock) 3725 - { 3726 - struct ieee80211_local *local = hw_to_local(hw); 3727 - 3728 - spin_lock_bh(&local->active_txq_lock[txq->ac]); 3729 - ieee80211_return_txq(hw, txq); 3730 3710 spin_unlock_bh(&local->active_txq_lock[txq->ac]); 3731 3711 } 3732 - EXPORT_SYMBOL(ieee80211_schedule_txq); 3712 + EXPORT_SYMBOL(__ieee80211_schedule_txq); 3733 3713 3734 3714 bool ieee80211_txq_may_transmit(struct ieee80211_hw *hw, 3735 3715 struct ieee80211_txq *txq) ··· 3729 3729 struct sta_info *sta; 3730 3730 u8 ac = txq->ac; 3731 3731 3732 - lockdep_assert_held(&local->active_txq_lock[ac]); 3732 + spin_lock_bh(&local->active_txq_lock[ac]); 3733 3733 3734 3734 if (!txqi->txq.sta) 3735 3735 goto out; ··· 3759 3759 3760 3760 sta->airtime[ac].deficit += sta->airtime_weight; 3761 3761 list_move_tail(&txqi->schedule_order, &local->active_txqs[ac]); 3762 + spin_unlock_bh(&local->active_txq_lock[ac]); 3762 3763 3763 3764 return false; 3764 3765 out: 3765 3766 if (!list_empty(&txqi->schedule_order)) 3766 3767 list_del_init(&txqi->schedule_order); 3768 + spin_unlock_bh(&local->active_txq_lock[ac]); 3767 3769 3768 3770 return true; 3769 3771 } 3770 3772 EXPORT_SYMBOL(ieee80211_txq_may_transmit); 3771 3773 3772 3774 void ieee80211_txq_schedule_start(struct ieee80211_hw *hw, u8 ac) 3773 - __acquires(txq_lock) 3774 3775 { 3775 3776 struct ieee80211_local *local = hw_to_local(hw); 3776 3777 3777 3778 spin_lock_bh(&local->active_txq_lock[ac]); 3778 3779 local->schedule_round[ac]++; 3779 - } 3780 - EXPORT_SYMBOL(ieee80211_txq_schedule_start); 3781 - 3782 - void ieee80211_txq_schedule_end(struct ieee80211_hw *hw, u8 ac) 3783 - __releases(txq_lock) 3784 - { 3785 - struct ieee80211_local *local = hw_to_local(hw); 3786 - 3787 3780 spin_unlock_bh(&local->active_txq_lock[ac]); 3788 3781 } 3789 - EXPORT_SYMBOL(ieee80211_txq_schedule_end); 3782 + EXPORT_SYMBOL(ieee80211_txq_schedule_start); 3790 3783 3791 3784 void __ieee80211_subif_start_xmit(struct sk_buff *skb, 3792 3785 struct net_device *dev,
+2 -1
net/netlink/af_netlink.c
··· 988 988 struct netlink_sock *nlk = nlk_sk(sk); 989 989 struct sockaddr_nl *nladdr = (struct sockaddr_nl *)addr; 990 990 int err = 0; 991 - unsigned long groups = nladdr->nl_groups; 991 + unsigned long groups; 992 992 bool bound; 993 993 994 994 if (addr_len < sizeof(struct sockaddr_nl)) ··· 996 996 997 997 if (nladdr->nl_family != AF_NETLINK) 998 998 return -EINVAL; 999 + groups = nladdr->nl_groups; 999 1000 1000 1001 /* Only superuser is allowed to listen multicasts */ 1001 1002 if (groups) {
+54 -22
net/netrom/af_netrom.c
··· 1392 1392 int i; 1393 1393 int rc = proto_register(&nr_proto, 0); 1394 1394 1395 - if (rc != 0) 1396 - goto out; 1395 + if (rc) 1396 + return rc; 1397 1397 1398 1398 if (nr_ndevs > 0x7fffffff/sizeof(struct net_device *)) { 1399 - printk(KERN_ERR "NET/ROM: nr_proto_init - nr_ndevs parameter to large\n"); 1400 - return -1; 1399 + pr_err("NET/ROM: %s - nr_ndevs parameter too large\n", 1400 + __func__); 1401 + rc = -EINVAL; 1402 + goto unregister_proto; 1401 1403 } 1402 1404 1403 1405 dev_nr = kcalloc(nr_ndevs, sizeof(struct net_device *), GFP_KERNEL); 1404 - if (dev_nr == NULL) { 1405 - printk(KERN_ERR "NET/ROM: nr_proto_init - unable to allocate device array\n"); 1406 - return -1; 1406 + if (!dev_nr) { 1407 + pr_err("NET/ROM: %s - unable to allocate device array\n", 1408 + __func__); 1409 + rc = -ENOMEM; 1410 + goto unregister_proto; 1407 1411 } 1408 1412 1409 1413 for (i = 0; i < nr_ndevs; i++) { ··· 1417 1413 sprintf(name, "nr%d", i); 1418 1414 dev = alloc_netdev(0, name, NET_NAME_UNKNOWN, nr_setup); 1419 1415 if (!dev) { 1420 - printk(KERN_ERR "NET/ROM: nr_proto_init - unable to allocate device structure\n"); 1416 + rc = -ENOMEM; 1421 1417 goto fail; 1422 1418 } 1423 1419 1424 1420 dev->base_addr = i; 1425 - if (register_netdev(dev)) { 1426 - printk(KERN_ERR "NET/ROM: nr_proto_init - unable to register network device\n"); 1421 + rc = register_netdev(dev); 1422 + if (rc) { 1427 1423 free_netdev(dev); 1428 1424 goto fail; 1429 1425 } ··· 1431 1427 dev_nr[i] = dev; 1432 1428 } 1433 1429 1434 - if (sock_register(&nr_family_ops)) { 1435 - printk(KERN_ERR "NET/ROM: nr_proto_init - unable to register socket family\n"); 1430 + rc = sock_register(&nr_family_ops); 1431 + if (rc) 1436 1432 goto fail; 1437 - } 1438 1433 1439 - register_netdevice_notifier(&nr_dev_notifier); 1434 + rc = register_netdevice_notifier(&nr_dev_notifier); 1435 + if (rc) 1436 + goto out_sock; 1440 1437 1441 1438 ax25_register_pid(&nr_pid); 1442 1439 ax25_linkfail_register(&nr_linkfail_notifier); 1443 1440 1444 1441 #ifdef CONFIG_SYSCTL 1445 - nr_register_sysctl(); 1442 + rc = nr_register_sysctl(); 1443 + if (rc) 1444 + goto out_sysctl; 1446 1445 #endif 1447 1446 1448 1447 nr_loopback_init(); 1449 1448 1450 - proc_create_seq("nr", 0444, init_net.proc_net, &nr_info_seqops); 1451 - proc_create_seq("nr_neigh", 0444, init_net.proc_net, &nr_neigh_seqops); 1452 - proc_create_seq("nr_nodes", 0444, init_net.proc_net, &nr_node_seqops); 1453 - out: 1454 - return rc; 1449 + rc = -ENOMEM; 1450 + if (!proc_create_seq("nr", 0444, init_net.proc_net, &nr_info_seqops)) 1451 + goto proc_remove1; 1452 + if (!proc_create_seq("nr_neigh", 0444, init_net.proc_net, 1453 + &nr_neigh_seqops)) 1454 + goto proc_remove2; 1455 + if (!proc_create_seq("nr_nodes", 0444, init_net.proc_net, 1456 + &nr_node_seqops)) 1457 + goto proc_remove3; 1458 + 1459 + return 0; 1460 + 1461 + proc_remove3: 1462 + remove_proc_entry("nr_neigh", init_net.proc_net); 1463 + proc_remove2: 1464 + remove_proc_entry("nr", init_net.proc_net); 1465 + proc_remove1: 1466 + 1467 + nr_loopback_clear(); 1468 + nr_rt_free(); 1469 + 1470 + #ifdef CONFIG_SYSCTL 1471 + nr_unregister_sysctl(); 1472 + out_sysctl: 1473 + #endif 1474 + ax25_linkfail_release(&nr_linkfail_notifier); 1475 + ax25_protocol_release(AX25_P_NETROM); 1476 + unregister_netdevice_notifier(&nr_dev_notifier); 1477 + out_sock: 1478 + sock_unregister(PF_NETROM); 1455 1479 fail: 1456 1480 while (--i >= 0) { 1457 1481 unregister_netdev(dev_nr[i]); 1458 1482 free_netdev(dev_nr[i]); 1459 1483 } 1460 1484 kfree(dev_nr); 1485 + unregister_proto: 1461 1486 proto_unregister(&nr_proto); 1462 - rc = -1; 1463 - goto out; 1487 + return rc; 1464 1488 } 1465 1489 1466 1490 module_init(nr_proto_init);
+1 -1
net/netrom/nr_loopback.c
··· 70 70 } 71 71 } 72 72 73 - void __exit nr_loopback_clear(void) 73 + void nr_loopback_clear(void) 74 74 { 75 75 del_timer_sync(&loopback_timer); 76 76 skb_queue_purge(&loopback_queue);
+1 -1
net/netrom/nr_route.c
··· 953 953 /* 954 954 * Free all memory associated with the nodes and routes lists. 955 955 */ 956 - void __exit nr_rt_free(void) 956 + void nr_rt_free(void) 957 957 { 958 958 struct nr_neigh *s = NULL; 959 959 struct nr_node *t = NULL;
+4 -1
net/netrom/sysctl_net_netrom.c
··· 146 146 { } 147 147 }; 148 148 149 - void __init nr_register_sysctl(void) 149 + int __init nr_register_sysctl(void) 150 150 { 151 151 nr_table_header = register_net_sysctl(&init_net, "net/netrom", nr_table); 152 + if (!nr_table_header) 153 + return -ENOMEM; 154 + return 0; 152 155 } 153 156 154 157 void nr_unregister_sysctl(void)
+3
net/rds/af_rds.c
··· 543 543 struct rds_sock *rs = rds_sk_to_rs(sk); 544 544 int ret = 0; 545 545 546 + if (addr_len < offsetofend(struct sockaddr, sa_family)) 547 + return -EINVAL; 548 + 546 549 lock_sock(sk); 547 550 548 551 switch (uaddr->sa_family) {
+2
net/rds/bind.c
··· 173 173 /* We allow an RDS socket to be bound to either IPv4 or IPv6 174 174 * address. 175 175 */ 176 + if (addr_len < offsetofend(struct sockaddr, sa_family)) 177 + return -EINVAL; 176 178 if (uaddr->sa_family == AF_INET) { 177 179 struct sockaddr_in *sin = (struct sockaddr_in *)uaddr; 178 180
+11 -6
net/rxrpc/af_rxrpc.c
··· 135 135 struct sockaddr_rxrpc *srx = (struct sockaddr_rxrpc *)saddr; 136 136 struct rxrpc_local *local; 137 137 struct rxrpc_sock *rx = rxrpc_sk(sock->sk); 138 - u16 service_id = srx->srx_service; 138 + u16 service_id; 139 139 int ret; 140 140 141 141 _enter("%p,%p,%d", rx, saddr, len); ··· 143 143 ret = rxrpc_validate_address(rx, srx, len); 144 144 if (ret < 0) 145 145 goto error; 146 + service_id = srx->srx_service; 146 147 147 148 lock_sock(&rx->sk); 148 149 ··· 371 370 * rxrpc_kernel_check_life - Check to see whether a call is still alive 372 371 * @sock: The socket the call is on 373 372 * @call: The call to check 373 + * @_life: Where to store the life value 374 374 * 375 375 * Allow a kernel service to find out whether a call is still alive - ie. we're 376 - * getting ACKs from the server. Returns a number representing the life state 377 - * which can be compared to that returned by a previous call. 376 + * getting ACKs from the server. Passes back in *_life a number representing 377 + * the life state which can be compared to that returned by a previous call and 378 + * return true if the call is still alive. 378 379 * 379 380 * If the life state stalls, rxrpc_kernel_probe_life() should be called and 380 381 * then 2RTT waited. 381 382 */ 382 - u32 rxrpc_kernel_check_life(const struct socket *sock, 383 - const struct rxrpc_call *call) 383 + bool rxrpc_kernel_check_life(const struct socket *sock, 384 + const struct rxrpc_call *call, 385 + u32 *_life) 384 386 { 385 - return call->acks_latest; 387 + *_life = call->acks_latest; 388 + return call->state != RXRPC_CALL_COMPLETE; 386 389 } 387 390 EXPORT_SYMBOL(rxrpc_kernel_check_life); 388 391
+1
net/rxrpc/ar-internal.h
··· 654 654 u8 ackr_reason; /* reason to ACK */ 655 655 u16 ackr_skew; /* skew on packet being ACK'd */ 656 656 rxrpc_serial_t ackr_serial; /* serial of packet being ACK'd */ 657 + rxrpc_serial_t ackr_first_seq; /* first sequence number received */ 657 658 rxrpc_seq_t ackr_prev_seq; /* previous sequence number received */ 658 659 rxrpc_seq_t ackr_consumed; /* Highest packet shown consumed */ 659 660 rxrpc_seq_t ackr_seen; /* Highest packet shown seen */
+7 -4
net/rxrpc/conn_event.c
··· 153 153 * pass a connection-level abort onto all calls on that connection 154 154 */ 155 155 static void rxrpc_abort_calls(struct rxrpc_connection *conn, 156 - enum rxrpc_call_completion compl) 156 + enum rxrpc_call_completion compl, 157 + rxrpc_serial_t serial) 157 158 { 158 159 struct rxrpc_call *call; 159 160 int i; ··· 174 173 call->call_id, 0, 175 174 conn->abort_code, 176 175 conn->error); 176 + else 177 + trace_rxrpc_rx_abort(call, serial, 178 + conn->abort_code); 177 179 if (rxrpc_set_call_completion(call, compl, 178 180 conn->abort_code, 179 181 conn->error)) ··· 217 213 conn->state = RXRPC_CONN_LOCALLY_ABORTED; 218 214 spin_unlock_bh(&conn->state_lock); 219 215 220 - rxrpc_abort_calls(conn, RXRPC_CALL_LOCALLY_ABORTED); 221 - 222 216 msg.msg_name = &conn->params.peer->srx.transport; 223 217 msg.msg_namelen = conn->params.peer->srx.transport_len; 224 218 msg.msg_control = NULL; ··· 244 242 len = iov[0].iov_len + iov[1].iov_len; 245 243 246 244 serial = atomic_inc_return(&conn->serial); 245 + rxrpc_abort_calls(conn, RXRPC_CALL_LOCALLY_ABORTED, serial); 247 246 whdr.serial = htonl(serial); 248 247 _proto("Tx CONN ABORT %%%u { %d }", serial, conn->abort_code); 249 248 ··· 324 321 conn->error = -ECONNABORTED; 325 322 conn->abort_code = abort_code; 326 323 conn->state = RXRPC_CONN_REMOTELY_ABORTED; 327 - rxrpc_abort_calls(conn, RXRPC_CALL_REMOTELY_ABORTED); 324 + rxrpc_abort_calls(conn, RXRPC_CALL_REMOTELY_ABORTED, sp->hdr.serial); 328 325 return -ECONNABORTED; 329 326 330 327 case RXRPC_PACKET_TYPE_CHALLENGE:
+12 -6
net/rxrpc/input.c
··· 837 837 u8 acks[RXRPC_MAXACKS]; 838 838 } buf; 839 839 rxrpc_serial_t acked_serial; 840 - rxrpc_seq_t first_soft_ack, hard_ack; 840 + rxrpc_seq_t first_soft_ack, hard_ack, prev_pkt; 841 841 int nr_acks, offset, ioffset; 842 842 843 843 _enter(""); ··· 851 851 852 852 acked_serial = ntohl(buf.ack.serial); 853 853 first_soft_ack = ntohl(buf.ack.firstPacket); 854 + prev_pkt = ntohl(buf.ack.previousPacket); 854 855 hard_ack = first_soft_ack - 1; 855 856 nr_acks = buf.ack.nAcks; 856 857 summary.ack_reason = (buf.ack.reason < RXRPC_ACK__INVALID ? 857 858 buf.ack.reason : RXRPC_ACK__INVALID); 858 859 859 860 trace_rxrpc_rx_ack(call, sp->hdr.serial, acked_serial, 860 - first_soft_ack, ntohl(buf.ack.previousPacket), 861 + first_soft_ack, prev_pkt, 861 862 summary.ack_reason, nr_acks); 862 863 863 864 if (buf.ack.reason == RXRPC_ACK_PING_RESPONSE) ··· 879 878 rxrpc_propose_ack_respond_to_ack); 880 879 } 881 880 882 - /* Discard any out-of-order or duplicate ACKs. */ 883 - if (before_eq(sp->hdr.serial, call->acks_latest)) 881 + /* Discard any out-of-order or duplicate ACKs (outside lock). */ 882 + if (before(first_soft_ack, call->ackr_first_seq) || 883 + before(prev_pkt, call->ackr_prev_seq)) 884 884 return; 885 885 886 886 buf.info.rxMTU = 0; ··· 892 890 893 891 spin_lock(&call->input_lock); 894 892 895 - /* Discard any out-of-order or duplicate ACKs. */ 896 - if (before_eq(sp->hdr.serial, call->acks_latest)) 893 + /* Discard any out-of-order or duplicate ACKs (inside lock). */ 894 + if (before(first_soft_ack, call->ackr_first_seq) || 895 + before(prev_pkt, call->ackr_prev_seq)) 897 896 goto out; 898 897 call->acks_latest_ts = skb->tstamp; 899 898 call->acks_latest = sp->hdr.serial; 899 + 900 + call->ackr_first_seq = first_soft_ack; 901 + call->ackr_prev_seq = prev_pkt; 900 902 901 903 /* Parse rwind and mtu sizes if provided. */ 902 904 if (buf.info.rxMTU)
+5
net/rxrpc/peer_event.c
··· 157 157 158 158 _enter("%p{%d}", sk, local->debug_id); 159 159 160 + /* Clear the outstanding error value on the socket so that it doesn't 161 + * cause kernel_sendmsg() to return it later. 162 + */ 163 + sock_error(sk); 164 + 160 165 skb = sock_dequeue_err_skb(sk); 161 166 if (!skb) { 162 167 _leave("UDP socket errqueue empty");
+12 -9
net/rxrpc/sendmsg.c
··· 152 152 } 153 153 154 154 /* 155 - * Queue a DATA packet for transmission, set the resend timeout and send the 156 - * packet immediately 155 + * Queue a DATA packet for transmission, set the resend timeout and send 156 + * the packet immediately. Returns the error from rxrpc_send_data_packet() 157 + * in case the caller wants to do something with it. 157 158 */ 158 - static void rxrpc_queue_packet(struct rxrpc_sock *rx, struct rxrpc_call *call, 159 - struct sk_buff *skb, bool last, 160 - rxrpc_notify_end_tx_t notify_end_tx) 159 + static int rxrpc_queue_packet(struct rxrpc_sock *rx, struct rxrpc_call *call, 160 + struct sk_buff *skb, bool last, 161 + rxrpc_notify_end_tx_t notify_end_tx) 161 162 { 162 163 struct rxrpc_skb_priv *sp = rxrpc_skb(skb); 163 164 unsigned long now; ··· 251 250 252 251 out: 253 252 rxrpc_free_skb(skb, rxrpc_skb_tx_freed); 254 - _leave(""); 253 + _leave(" = %d", ret); 254 + return ret; 255 255 } 256 256 257 257 /* ··· 425 423 if (ret < 0) 426 424 goto out; 427 425 428 - rxrpc_queue_packet(rx, call, skb, 429 - !msg_data_left(msg) && !more, 430 - notify_end_tx); 426 + ret = rxrpc_queue_packet(rx, call, skb, 427 + !msg_data_left(msg) && !more, 428 + notify_end_tx); 429 + /* Should check for failure here */ 431 430 skb = NULL; 432 431 } 433 432 } while (msg_data_left(msg) > 0);
+2 -1
net/sctp/socket.c
··· 4850 4850 } 4851 4851 4852 4852 /* Validate addr_len before calling common connect/connectx routine. */ 4853 - af = sctp_get_af_specific(addr->sa_family); 4853 + af = addr_len < offsetofend(struct sockaddr, sa_family) ? NULL : 4854 + sctp_get_af_specific(addr->sa_family); 4854 4855 if (!af || addr_len < af->sockaddr_len) { 4855 4856 err = -EINVAL; 4856 4857 } else {
+39 -19
net/smc/af_smc.c
··· 165 165 166 166 if (sk->sk_state == SMC_CLOSED) { 167 167 if (smc->clcsock) { 168 - mutex_lock(&smc->clcsock_release_lock); 169 - sock_release(smc->clcsock); 170 - smc->clcsock = NULL; 171 - mutex_unlock(&smc->clcsock_release_lock); 168 + release_sock(sk); 169 + smc_clcsock_release(smc); 170 + lock_sock(sk); 172 171 } 173 172 if (!smc->use_fallback) 174 173 smc_conn_free(&smc->conn); ··· 443 444 link->peer_mtu = clc->qp_mtu; 444 445 } 445 446 447 + static void smc_switch_to_fallback(struct smc_sock *smc) 448 + { 449 + smc->use_fallback = true; 450 + if (smc->sk.sk_socket && smc->sk.sk_socket->file) { 451 + smc->clcsock->file = smc->sk.sk_socket->file; 452 + smc->clcsock->file->private_data = smc->clcsock; 453 + } 454 + } 455 + 446 456 /* fall back during connect */ 447 457 static int smc_connect_fallback(struct smc_sock *smc, int reason_code) 448 458 { 449 - smc->use_fallback = true; 459 + smc_switch_to_fallback(smc); 450 460 smc->fallback_rsn = reason_code; 451 461 smc_copy_sock_settings_to_clc(smc); 452 462 smc->connect_nonblock = 0; ··· 788 780 smc->sk.sk_err = -rc; 789 781 790 782 out: 791 - if (smc->sk.sk_err) 792 - smc->sk.sk_state_change(&smc->sk); 793 - else 794 - smc->sk.sk_write_space(&smc->sk); 783 + if (!sock_flag(&smc->sk, SOCK_DEAD)) { 784 + if (smc->sk.sk_err) { 785 + smc->sk.sk_state_change(&smc->sk); 786 + } else { /* allow polling before and after fallback decision */ 787 + smc->clcsock->sk->sk_write_space(smc->clcsock->sk); 788 + smc->sk.sk_write_space(&smc->sk); 789 + } 790 + } 795 791 release_sock(&smc->sk); 796 792 } 797 793 ··· 879 867 if (rc < 0) 880 868 lsk->sk_err = -rc; 881 869 if (rc < 0 || lsk->sk_state == SMC_CLOSED) { 870 + new_sk->sk_prot->unhash(new_sk); 882 871 if (new_clcsock) 883 872 sock_release(new_clcsock); 884 873 new_sk->sk_state = SMC_CLOSED; 885 874 sock_set_flag(new_sk, SOCK_DEAD); 886 - new_sk->sk_prot->unhash(new_sk); 887 875 sock_put(new_sk); /* final */ 888 876 *new_smc = NULL; 889 877 goto out; ··· 934 922 935 923 smc_accept_unlink(new_sk); 936 924 if (new_sk->sk_state == SMC_CLOSED) { 925 + new_sk->sk_prot->unhash(new_sk); 937 926 if (isk->clcsock) { 938 927 sock_release(isk->clcsock); 939 928 isk->clcsock = NULL; 940 929 } 941 - new_sk->sk_prot->unhash(new_sk); 942 930 sock_put(new_sk); /* final */ 943 931 continue; 944 932 } 945 - if (new_sock) 933 + if (new_sock) { 946 934 sock_graft(new_sk, new_sock); 935 + if (isk->use_fallback) { 936 + smc_sk(new_sk)->clcsock->file = new_sock->file; 937 + isk->clcsock->file->private_data = isk->clcsock; 938 + } 939 + } 947 940 return new_sk; 948 941 } 949 942 return NULL; ··· 968 951 sock_set_flag(sk, SOCK_DEAD); 969 952 sk->sk_shutdown |= SHUTDOWN_MASK; 970 953 } 954 + sk->sk_prot->unhash(sk); 971 955 if (smc->clcsock) { 972 956 struct socket *tcp; 973 957 ··· 984 966 smc_conn_free(&smc->conn); 985 967 } 986 968 release_sock(sk); 987 - sk->sk_prot->unhash(sk); 988 969 sock_put(sk); /* final sock_put */ 989 970 } 990 971 ··· 1049 1032 struct smc_sock *lsmc = new_smc->listen_smc; 1050 1033 struct sock *newsmcsk = &new_smc->sk; 1051 1034 1052 - lock_sock_nested(&lsmc->sk, SINGLE_DEPTH_NESTING); 1053 1035 if (lsmc->sk.sk_state == SMC_LISTEN) { 1036 + lock_sock_nested(&lsmc->sk, SINGLE_DEPTH_NESTING); 1054 1037 smc_accept_enqueue(&lsmc->sk, newsmcsk); 1038 + release_sock(&lsmc->sk); 1055 1039 } else { /* no longer listening */ 1056 1040 smc_close_non_accepted(newsmcsk); 1057 1041 } 1058 - release_sock(&lsmc->sk); 1059 1042 1060 1043 /* Wake up accept */ 1061 1044 lsmc->sk.sk_data_ready(&lsmc->sk); ··· 1099 1082 return; 1100 1083 } 1101 1084 smc_conn_free(&new_smc->conn); 1102 - new_smc->use_fallback = true; 1085 + smc_switch_to_fallback(new_smc); 1103 1086 new_smc->fallback_rsn = reason_code; 1104 1087 if (reason_code && reason_code != SMC_CLC_DECL_PEERDECL) { 1105 1088 if (smc_clc_send_decline(new_smc, reason_code) < 0) { ··· 1237 1220 u8 buf[SMC_CLC_MAX_LEN]; 1238 1221 int rc = 0; 1239 1222 1223 + if (new_smc->listen_smc->sk.sk_state != SMC_LISTEN) 1224 + return smc_listen_out_err(new_smc); 1225 + 1240 1226 if (new_smc->use_fallback) { 1241 1227 smc_listen_out_connected(new_smc); 1242 1228 return; ··· 1247 1227 1248 1228 /* check if peer is smc capable */ 1249 1229 if (!tcp_sk(newclcsock->sk)->syn_smc) { 1250 - new_smc->use_fallback = true; 1230 + smc_switch_to_fallback(new_smc); 1251 1231 new_smc->fallback_rsn = SMC_CLC_DECL_PEERNOSMC; 1252 1232 smc_listen_out_connected(new_smc); 1253 1233 return; ··· 1527 1507 1528 1508 if (msg->msg_flags & MSG_FASTOPEN) { 1529 1509 if (sk->sk_state == SMC_INIT) { 1530 - smc->use_fallback = true; 1510 + smc_switch_to_fallback(smc); 1531 1511 smc->fallback_rsn = SMC_CLC_DECL_OPTUNSUPP; 1532 1512 } else { 1533 1513 rc = -EINVAL; ··· 1732 1712 case TCP_FASTOPEN_NO_COOKIE: 1733 1713 /* option not supported by SMC */ 1734 1714 if (sk->sk_state == SMC_INIT) { 1735 - smc->use_fallback = true; 1715 + smc_switch_to_fallback(smc); 1736 1716 smc->fallback_rsn = SMC_CLC_DECL_OPTUNSUPP; 1737 1717 } else { 1738 1718 if (!smc->use_fallback)
+21 -4
net/smc/smc_close.c
··· 21 21 22 22 #define SMC_CLOSE_WAIT_LISTEN_CLCSOCK_TIME (5 * HZ) 23 23 24 + /* release the clcsock that is assigned to the smc_sock */ 25 + void smc_clcsock_release(struct smc_sock *smc) 26 + { 27 + struct socket *tcp; 28 + 29 + if (smc->listen_smc && current_work() != &smc->smc_listen_work) 30 + cancel_work_sync(&smc->smc_listen_work); 31 + mutex_lock(&smc->clcsock_release_lock); 32 + if (smc->clcsock) { 33 + tcp = smc->clcsock; 34 + smc->clcsock = NULL; 35 + sock_release(tcp); 36 + } 37 + mutex_unlock(&smc->clcsock_release_lock); 38 + } 39 + 24 40 static void smc_close_cleanup_listen(struct sock *parent) 25 41 { 26 42 struct sock *sk; ··· 337 321 close_work); 338 322 struct smc_sock *smc = container_of(conn, struct smc_sock, conn); 339 323 struct smc_cdc_conn_state_flags *rxflags; 324 + bool release_clcsock = false; 340 325 struct sock *sk = &smc->sk; 341 326 int old_state; 342 327 ··· 417 400 if ((sk->sk_state == SMC_CLOSED) && 418 401 (sock_flag(sk, SOCK_DEAD) || !sk->sk_socket)) { 419 402 smc_conn_free(conn); 420 - if (smc->clcsock) { 421 - sock_release(smc->clcsock); 422 - smc->clcsock = NULL; 423 - } 403 + if (smc->clcsock) 404 + release_clcsock = true; 424 405 } 425 406 } 426 407 release_sock(sk); 408 + if (release_clcsock) 409 + smc_clcsock_release(smc); 427 410 sock_put(sk); /* sock_hold done by schedulers of close_work */ 428 411 } 429 412
+1
net/smc/smc_close.h
··· 23 23 int smc_close_active(struct smc_sock *smc); 24 24 int smc_close_shutdown_write(struct smc_sock *smc); 25 25 void smc_close_init(struct smc_sock *smc); 26 + void smc_clcsock_release(struct smc_sock *smc); 26 27 27 28 #endif /* SMC_CLOSE_H */
+5
net/smc/smc_ism.c
··· 289 289 INIT_LIST_HEAD(&smcd->vlan); 290 290 smcd->event_wq = alloc_ordered_workqueue("ism_evt_wq-%s)", 291 291 WQ_MEM_RECLAIM, name); 292 + if (!smcd->event_wq) { 293 + kfree(smcd->conn); 294 + kfree(smcd); 295 + return NULL; 296 + } 292 297 return smcd; 293 298 } 294 299 EXPORT_SYMBOL_GPL(smcd_alloc_dev);
+2 -1
net/smc/smc_pnet.c
··· 604 604 { 605 605 struct net *net = genl_info_net(info); 606 606 607 - return smc_pnet_remove_by_pnetid(net, NULL); 607 + smc_pnet_remove_by_pnetid(net, NULL); 608 + return 0; 608 609 } 609 610 610 611 /* SMC_PNETID generic netlink operation definition */
+5 -7
net/strparser/strparser.c
··· 140 140 /* We are going to append to the frags_list of head. 141 141 * Need to unshare the frag_list. 142 142 */ 143 - if (skb_has_frag_list(head)) { 144 - err = skb_unclone(head, GFP_ATOMIC); 145 - if (err) { 146 - STRP_STATS_INCR(strp->stats.mem_fail); 147 - desc->error = err; 148 - return 0; 149 - } 143 + err = skb_unclone(head, GFP_ATOMIC); 144 + if (err) { 145 + STRP_STATS_INCR(strp->stats.mem_fail); 146 + desc->error = err; 147 + return 0; 150 148 } 151 149 152 150 if (unlikely(skb_shinfo(head)->frag_list)) {
+8 -37
net/sunrpc/clnt.c
··· 1540 1540 clnt->cl_stats->rpccnt++; 1541 1541 task->tk_action = call_reserve; 1542 1542 rpc_task_set_transport(task, clnt); 1543 - call_reserve(task); 1544 1543 } 1545 1544 1546 1545 /* ··· 1553 1554 task->tk_status = 0; 1554 1555 task->tk_action = call_reserveresult; 1555 1556 xprt_reserve(task); 1556 - if (rpc_task_need_resched(task)) 1557 - return; 1558 - call_reserveresult(task); 1559 1557 } 1560 1558 1561 1559 static void call_retry_reserve(struct rpc_task *task); ··· 1575 1579 if (status >= 0) { 1576 1580 if (task->tk_rqstp) { 1577 1581 task->tk_action = call_refresh; 1578 - call_refresh(task); 1579 1582 return; 1580 1583 } 1581 1584 ··· 1600 1605 /* fall through */ 1601 1606 case -EAGAIN: /* woken up; retry */ 1602 1607 task->tk_action = call_retry_reserve; 1603 - call_retry_reserve(task); 1604 1608 return; 1605 1609 case -EIO: /* probably a shutdown */ 1606 1610 break; ··· 1622 1628 task->tk_status = 0; 1623 1629 task->tk_action = call_reserveresult; 1624 1630 xprt_retry_reserve(task); 1625 - if (rpc_task_need_resched(task)) 1626 - return; 1627 - call_reserveresult(task); 1628 1631 } 1629 1632 1630 1633 /* ··· 1636 1645 task->tk_status = 0; 1637 1646 task->tk_client->cl_stats->rpcauthrefresh++; 1638 1647 rpcauth_refreshcred(task); 1639 - if (rpc_task_need_resched(task)) 1640 - return; 1641 - call_refreshresult(task); 1642 1648 } 1643 1649 1644 1650 /* ··· 1654 1666 case 0: 1655 1667 if (rpcauth_uptodatecred(task)) { 1656 1668 task->tk_action = call_allocate; 1657 - call_allocate(task); 1658 1669 return; 1659 1670 } 1660 1671 /* Use rate-limiting and a max number of retries if refresh ··· 1672 1685 task->tk_cred_retry--; 1673 1686 dprintk("RPC: %5u %s: retry refresh creds\n", 1674 1687 task->tk_pid, __func__); 1675 - call_refresh(task); 1676 1688 return; 1677 1689 } 1678 1690 dprintk("RPC: %5u %s: refresh creds failed with error %d\n", ··· 1697 1711 task->tk_status = 0; 1698 1712 task->tk_action = call_encode; 1699 1713 1700 - if (req->rq_buffer) { 1701 - call_encode(task); 1714 + if (req->rq_buffer) 1702 1715 return; 1703 - } 1704 1716 1705 1717 if (proc->p_proc != 0) { 1706 1718 BUG_ON(proc->p_arglen == 0); ··· 1724 1740 1725 1741 status = xprt->ops->buf_alloc(task); 1726 1742 xprt_inject_disconnect(xprt); 1727 - if (status == 0) { 1728 - if (rpc_task_need_resched(task)) 1729 - return; 1730 - call_encode(task); 1743 + if (status == 0) 1731 1744 return; 1732 - } 1733 1745 if (status != -ENOMEM) { 1734 1746 rpc_exit(task, status); 1735 1747 return; ··· 1808 1828 xprt_request_enqueue_receive(task); 1809 1829 xprt_request_enqueue_transmit(task); 1810 1830 out: 1811 - task->tk_action = call_bind; 1812 - call_bind(task); 1831 + task->tk_action = call_transmit; 1832 + /* Check that the connection is OK */ 1833 + if (!xprt_bound(task->tk_xprt)) 1834 + task->tk_action = call_bind; 1835 + else if (!xprt_connected(task->tk_xprt)) 1836 + task->tk_action = call_connect; 1813 1837 } 1814 1838 1815 1839 /* ··· 1831 1847 { 1832 1848 xprt_end_transmit(task); 1833 1849 task->tk_action = call_transmit_status; 1834 - call_transmit_status(task); 1835 1850 } 1836 1851 1837 1852 /* ··· 1848 1865 1849 1866 if (xprt_bound(xprt)) { 1850 1867 task->tk_action = call_connect; 1851 - call_connect(task); 1852 1868 return; 1853 1869 } 1854 1870 ··· 1878 1896 dprint_status(task); 1879 1897 task->tk_status = 0; 1880 1898 task->tk_action = call_connect; 1881 - call_connect(task); 1882 1899 return; 1883 1900 } 1884 1901 ··· 1962 1981 1963 1982 if (xprt_connected(xprt)) { 1964 1983 task->tk_action = call_transmit; 1965 - call_transmit(task); 1966 1984 return; 1967 1985 } 1968 1986 ··· 2031 2051 case 0: 2032 2052 clnt->cl_stats->netreconn++; 2033 2053 task->tk_action = call_transmit; 2034 - call_transmit(task); 2035 2054 return; 2036 2055 } 2037 2056 rpc_exit(task, status); ··· 2066 2087 xprt_transmit(task); 2067 2088 } 2068 2089 xprt_end_transmit(task); 2069 - if (rpc_task_need_resched(task)) 2070 - return; 2071 - call_transmit_status(task); 2072 2090 } 2073 2091 2074 2092 /* ··· 2083 2107 if (rpc_task_transmitted(task)) { 2084 2108 if (task->tk_status == 0) 2085 2109 xprt_request_wait_receive(task); 2086 - if (rpc_task_need_resched(task)) 2087 - return; 2088 - call_status(task); 2089 2110 return; 2090 2111 } 2091 2112 ··· 2143 2170 { 2144 2171 xprt_request_enqueue_transmit(task); 2145 2172 task->tk_action = call_bc_transmit; 2146 - call_bc_transmit(task); 2147 2173 } 2148 2174 2149 2175 /* ··· 2233 2261 status = task->tk_status; 2234 2262 if (status >= 0) { 2235 2263 task->tk_action = call_decode; 2236 - call_decode(task); 2237 2264 return; 2238 2265 } 2239 2266
+1 -1
net/sunrpc/xprtrdma/verbs.c
··· 90 90 /* Flush Receives, then wait for deferred Reply work 91 91 * to complete. 92 92 */ 93 - ib_drain_qp(ia->ri_id->qp); 93 + ib_drain_rq(ia->ri_id->qp); 94 94 drain_workqueue(buf->rb_completion_wq); 95 95 96 96 /* Deferred Reply processing might have scheduled
+2
net/tipc/link.c
··· 876 876 __skb_queue_head_init(&list); 877 877 878 878 l->in_session = false; 879 + /* Force re-synch of peer session number before establishing */ 880 + l->peer_session--; 879 881 l->session++; 880 882 l->mtu = l->advertised_mtu; 881 883
+2 -1
net/tipc/name_table.c
··· 909 909 for (; i < TIPC_NAMETBL_SIZE; i++) { 910 910 head = &tn->nametbl->services[i]; 911 911 912 - if (*last_type) { 912 + if (*last_type || 913 + (!i && *last_key && (*last_lower == *last_key))) { 913 914 service = tipc_service_find(net, *last_type); 914 915 if (!service) 915 916 return -EPIPE;
+6 -2
net/tipc/sysctl.c
··· 38 38 39 39 #include <linux/sysctl.h> 40 40 41 + static int zero; 42 + static int one = 1; 41 43 static struct ctl_table_header *tipc_ctl_hdr; 42 44 43 45 static struct ctl_table tipc_table[] = { ··· 48 46 .data = &sysctl_tipc_rmem, 49 47 .maxlen = sizeof(sysctl_tipc_rmem), 50 48 .mode = 0644, 51 - .proc_handler = proc_dointvec, 49 + .proc_handler = proc_dointvec_minmax, 50 + .extra1 = &one, 52 51 }, 53 52 { 54 53 .procname = "named_timeout", 55 54 .data = &sysctl_tipc_named_timeout, 56 55 .maxlen = sizeof(sysctl_tipc_named_timeout), 57 56 .mode = 0644, 58 - .proc_handler = proc_dointvec, 57 + .proc_handler = proc_dointvec_minmax, 58 + .extra1 = &zero, 59 59 }, 60 60 { 61 61 .procname = "sk_filter",
+11 -1
net/tls/tls_device.c
··· 52 52 53 53 static void tls_device_free_ctx(struct tls_context *ctx) 54 54 { 55 - if (ctx->tx_conf == TLS_HW) 55 + if (ctx->tx_conf == TLS_HW) { 56 56 kfree(tls_offload_ctx_tx(ctx)); 57 + kfree(ctx->tx.rec_seq); 58 + kfree(ctx->tx.iv); 59 + } 57 60 58 61 if (ctx->rx_conf == TLS_HW) 59 62 kfree(tls_offload_ctx_rx(ctx)); ··· 218 215 tls_device_queue_ctx_destruction(tls_ctx); 219 216 } 220 217 EXPORT_SYMBOL(tls_device_sk_destruct); 218 + 219 + void tls_device_free_resources_tx(struct sock *sk) 220 + { 221 + struct tls_context *tls_ctx = tls_get_ctx(sk); 222 + 223 + tls_free_partial_record(sk, tls_ctx); 224 + } 221 225 222 226 static void tls_append_frag(struct tls_record_info *record, 223 227 struct page_frag *pfrag,
+24
net/tls/tls_main.c
··· 208 208 return tls_push_sg(sk, ctx, sg, offset, flags); 209 209 } 210 210 211 + bool tls_free_partial_record(struct sock *sk, struct tls_context *ctx) 212 + { 213 + struct scatterlist *sg; 214 + 215 + sg = ctx->partially_sent_record; 216 + if (!sg) 217 + return false; 218 + 219 + while (1) { 220 + put_page(sg_page(sg)); 221 + sk_mem_uncharge(sk, sg->length); 222 + 223 + if (sg_is_last(sg)) 224 + break; 225 + sg++; 226 + } 227 + ctx->partially_sent_record = NULL; 228 + return true; 229 + } 230 + 211 231 static void tls_write_space(struct sock *sk) 212 232 { 213 233 struct tls_context *ctx = tls_get_ctx(sk); ··· 287 267 kfree(ctx->tx.rec_seq); 288 268 kfree(ctx->tx.iv); 289 269 tls_sw_free_resources_tx(sk); 270 + #ifdef CONFIG_TLS_DEVICE 271 + } else if (ctx->tx_conf == TLS_HW) { 272 + tls_device_free_resources_tx(sk); 273 + #endif 290 274 } 291 275 292 276 if (ctx->rx_conf == TLS_SW) {
+1 -14
net/tls/tls_sw.c
··· 2065 2065 /* Free up un-sent records in tx_list. First, free 2066 2066 * the partially sent record if any at head of tx_list. 2067 2067 */ 2068 - if (tls_ctx->partially_sent_record) { 2069 - struct scatterlist *sg = tls_ctx->partially_sent_record; 2070 - 2071 - while (1) { 2072 - put_page(sg_page(sg)); 2073 - sk_mem_uncharge(sk, sg->length); 2074 - 2075 - if (sg_is_last(sg)) 2076 - break; 2077 - sg++; 2078 - } 2079 - 2080 - tls_ctx->partially_sent_record = NULL; 2081 - 2068 + if (tls_free_partial_record(sk, tls_ctx)) { 2082 2069 rec = list_first_entry(&ctx->tx_list, 2083 2070 struct tls_rec, list); 2084 2071 list_del(&rec->list);
+12 -6
net/wireless/nl80211.c
··· 13614 13614 .doit = nl80211_associate, 13615 13615 .flags = GENL_UNS_ADMIN_PERM, 13616 13616 .internal_flags = NL80211_FLAG_NEED_NETDEV_UP | 13617 - NL80211_FLAG_NEED_RTNL, 13617 + NL80211_FLAG_NEED_RTNL | 13618 + NL80211_FLAG_CLEAR_SKB, 13618 13619 }, 13619 13620 { 13620 13621 .cmd = NL80211_CMD_DEAUTHENTICATE, ··· 13660 13659 .doit = nl80211_connect, 13661 13660 .flags = GENL_UNS_ADMIN_PERM, 13662 13661 .internal_flags = NL80211_FLAG_NEED_NETDEV_UP | 13663 - NL80211_FLAG_NEED_RTNL, 13662 + NL80211_FLAG_NEED_RTNL | 13663 + NL80211_FLAG_CLEAR_SKB, 13664 13664 }, 13665 13665 { 13666 13666 .cmd = NL80211_CMD_UPDATE_CONNECT_PARAMS, 13667 13667 .doit = nl80211_update_connect_params, 13668 13668 .flags = GENL_ADMIN_PERM, 13669 13669 .internal_flags = NL80211_FLAG_NEED_NETDEV_UP | 13670 - NL80211_FLAG_NEED_RTNL, 13670 + NL80211_FLAG_NEED_RTNL | 13671 + NL80211_FLAG_CLEAR_SKB, 13671 13672 }, 13672 13673 { 13673 13674 .cmd = NL80211_CMD_DISCONNECT, ··· 13694 13691 .doit = nl80211_setdel_pmksa, 13695 13692 .flags = GENL_UNS_ADMIN_PERM, 13696 13693 .internal_flags = NL80211_FLAG_NEED_NETDEV_UP | 13697 - NL80211_FLAG_NEED_RTNL, 13694 + NL80211_FLAG_NEED_RTNL | 13695 + NL80211_FLAG_CLEAR_SKB, 13698 13696 }, 13699 13697 { 13700 13698 .cmd = NL80211_CMD_DEL_PMKSA, ··· 14003 13999 .dumpit = nl80211_vendor_cmd_dump, 14004 14000 .flags = GENL_UNS_ADMIN_PERM, 14005 14001 .internal_flags = NL80211_FLAG_NEED_WIPHY | 14006 - NL80211_FLAG_NEED_RTNL, 14002 + NL80211_FLAG_NEED_RTNL | 14003 + NL80211_FLAG_CLEAR_SKB, 14007 14004 }, 14008 14005 { 14009 14006 .cmd = NL80211_CMD_SET_QOS_MAP, ··· 14052 14047 .cmd = NL80211_CMD_SET_PMK, 14053 14048 .doit = nl80211_set_pmk, 14054 14049 .internal_flags = NL80211_FLAG_NEED_NETDEV_UP | 14055 - NL80211_FLAG_NEED_RTNL, 14050 + NL80211_FLAG_NEED_RTNL | 14051 + NL80211_FLAG_CLEAR_SKB, 14056 14052 }, 14057 14053 { 14058 14054 .cmd = NL80211_CMD_DEL_PMK,
+39
net/wireless/reg.c
··· 1309 1309 return dfs_region1; 1310 1310 } 1311 1311 1312 + static void reg_wmm_rules_intersect(const struct ieee80211_wmm_ac *wmm_ac1, 1313 + const struct ieee80211_wmm_ac *wmm_ac2, 1314 + struct ieee80211_wmm_ac *intersect) 1315 + { 1316 + intersect->cw_min = max_t(u16, wmm_ac1->cw_min, wmm_ac2->cw_min); 1317 + intersect->cw_max = max_t(u16, wmm_ac1->cw_max, wmm_ac2->cw_max); 1318 + intersect->cot = min_t(u16, wmm_ac1->cot, wmm_ac2->cot); 1319 + intersect->aifsn = max_t(u8, wmm_ac1->aifsn, wmm_ac2->aifsn); 1320 + } 1321 + 1312 1322 /* 1313 1323 * Helper for regdom_intersect(), this does the real 1314 1324 * mathematical intersection fun ··· 1333 1323 struct ieee80211_freq_range *freq_range; 1334 1324 const struct ieee80211_power_rule *power_rule1, *power_rule2; 1335 1325 struct ieee80211_power_rule *power_rule; 1326 + const struct ieee80211_wmm_rule *wmm_rule1, *wmm_rule2; 1327 + struct ieee80211_wmm_rule *wmm_rule; 1336 1328 u32 freq_diff, max_bandwidth1, max_bandwidth2; 1337 1329 1338 1330 freq_range1 = &rule1->freq_range; ··· 1344 1332 power_rule1 = &rule1->power_rule; 1345 1333 power_rule2 = &rule2->power_rule; 1346 1334 power_rule = &intersected_rule->power_rule; 1335 + 1336 + wmm_rule1 = &rule1->wmm_rule; 1337 + wmm_rule2 = &rule2->wmm_rule; 1338 + wmm_rule = &intersected_rule->wmm_rule; 1347 1339 1348 1340 freq_range->start_freq_khz = max(freq_range1->start_freq_khz, 1349 1341 freq_range2->start_freq_khz); ··· 1391 1375 1392 1376 intersected_rule->dfs_cac_ms = max(rule1->dfs_cac_ms, 1393 1377 rule2->dfs_cac_ms); 1378 + 1379 + if (rule1->has_wmm && rule2->has_wmm) { 1380 + u8 ac; 1381 + 1382 + for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) { 1383 + reg_wmm_rules_intersect(&wmm_rule1->client[ac], 1384 + &wmm_rule2->client[ac], 1385 + &wmm_rule->client[ac]); 1386 + reg_wmm_rules_intersect(&wmm_rule1->ap[ac], 1387 + &wmm_rule2->ap[ac], 1388 + &wmm_rule->ap[ac]); 1389 + } 1390 + 1391 + intersected_rule->has_wmm = true; 1392 + } else if (rule1->has_wmm) { 1393 + *wmm_rule = *wmm_rule1; 1394 + intersected_rule->has_wmm = true; 1395 + } else if (rule2->has_wmm) { 1396 + *wmm_rule = *wmm_rule2; 1397 + intersected_rule->has_wmm = true; 1398 + } else { 1399 + intersected_rule->has_wmm = false; 1400 + } 1394 1401 1395 1402 if (!is_valid_reg_rule(intersected_rule)) 1396 1403 return -EINVAL;
+1 -2
net/wireless/scan.c
··· 190 190 /* copy subelement as we need to change its content to 191 191 * mark an ie after it is processed. 192 192 */ 193 - sub_copy = kmalloc(subie_len, gfp); 193 + sub_copy = kmemdup(subelement, subie_len, gfp); 194 194 if (!sub_copy) 195 195 return 0; 196 - memcpy(sub_copy, subelement, subie_len); 197 196 198 197 pos = &new_ie[0]; 199 198
+4 -2
net/wireless/util.c
··· 1220 1220 else if (rate->bw == RATE_INFO_BW_HE_RU && 1221 1221 rate->he_ru_alloc == NL80211_RATE_INFO_HE_RU_ALLOC_26) 1222 1222 result = rates_26[rate->he_gi]; 1223 - else if (WARN(1, "invalid HE MCS: bw:%d, ru:%d\n", 1224 - rate->bw, rate->he_ru_alloc)) 1223 + else { 1224 + WARN(1, "invalid HE MCS: bw:%d, ru:%d\n", 1225 + rate->bw, rate->he_ru_alloc); 1225 1226 return 0; 1227 + } 1226 1228 1227 1229 /* now scale to the appropriate MCS */ 1228 1230 tmp = result;
+48 -1
security/apparmor/lsm.c
··· 1336 1336 bool aa_g_paranoid_load = true; 1337 1337 module_param_named(paranoid_load, aa_g_paranoid_load, aabool, S_IRUGO); 1338 1338 1339 + static int param_get_aaintbool(char *buffer, const struct kernel_param *kp); 1340 + static int param_set_aaintbool(const char *val, const struct kernel_param *kp); 1341 + #define param_check_aaintbool param_check_int 1342 + static const struct kernel_param_ops param_ops_aaintbool = { 1343 + .set = param_set_aaintbool, 1344 + .get = param_get_aaintbool 1345 + }; 1339 1346 /* Boot time disable flag */ 1340 1347 static int apparmor_enabled __lsm_ro_after_init = 1; 1341 - module_param_named(enabled, apparmor_enabled, int, 0444); 1348 + module_param_named(enabled, apparmor_enabled, aaintbool, 0444); 1342 1349 1343 1350 static int __init apparmor_enabled_setup(char *str) 1344 1351 { ··· 1418 1411 if (apparmor_initialized && !policy_view_capable(NULL)) 1419 1412 return -EPERM; 1420 1413 return param_get_uint(buffer, kp); 1414 + } 1415 + 1416 + /* Can only be set before AppArmor is initialized (i.e. on boot cmdline). */ 1417 + static int param_set_aaintbool(const char *val, const struct kernel_param *kp) 1418 + { 1419 + struct kernel_param kp_local; 1420 + bool value; 1421 + int error; 1422 + 1423 + if (apparmor_initialized) 1424 + return -EPERM; 1425 + 1426 + /* Create local copy, with arg pointing to bool type. */ 1427 + value = !!*((int *)kp->arg); 1428 + memcpy(&kp_local, kp, sizeof(kp_local)); 1429 + kp_local.arg = &value; 1430 + 1431 + error = param_set_bool(val, &kp_local); 1432 + if (!error) 1433 + *((int *)kp->arg) = *((bool *)kp_local.arg); 1434 + return error; 1435 + } 1436 + 1437 + /* 1438 + * To avoid changing /sys/module/apparmor/parameters/enabled from Y/N to 1439 + * 1/0, this converts the "int that is actually bool" back to bool for 1440 + * display in the /sys filesystem, while keeping it "int" for the LSM 1441 + * infrastructure. 1442 + */ 1443 + static int param_get_aaintbool(char *buffer, const struct kernel_param *kp) 1444 + { 1445 + struct kernel_param kp_local; 1446 + bool value; 1447 + 1448 + /* Create local copy, with arg pointing to bool type. */ 1449 + value = !!*((int *)kp->arg); 1450 + memcpy(&kp_local, kp, sizeof(kp_local)); 1451 + kp_local.arg = &value; 1452 + 1453 + return param_get_bool(buffer, &kp_local); 1421 1454 } 1422 1455 1423 1456 static int param_get_audit(char *buffer, const struct kernel_param *kp)
+3 -3
sound/core/seq/seq_clientmgr.c
··· 1252 1252 1253 1253 /* fill the info fields */ 1254 1254 if (client_info->name[0]) 1255 - strlcpy(client->name, client_info->name, sizeof(client->name)); 1255 + strscpy(client->name, client_info->name, sizeof(client->name)); 1256 1256 1257 1257 client->filter = client_info->filter; 1258 1258 client->event_lost = client_info->event_lost; ··· 1530 1530 /* set queue name */ 1531 1531 if (!info->name[0]) 1532 1532 snprintf(info->name, sizeof(info->name), "Queue-%d", q->queue); 1533 - strlcpy(q->name, info->name, sizeof(q->name)); 1533 + strscpy(q->name, info->name, sizeof(q->name)); 1534 1534 snd_use_lock_free(&q->use_lock); 1535 1535 1536 1536 return 0; ··· 1592 1592 queuefree(q); 1593 1593 return -EPERM; 1594 1594 } 1595 - strlcpy(q->name, info->name, sizeof(q->name)); 1595 + strscpy(q->name, info->name, sizeof(q->name)); 1596 1596 queuefree(q); 1597 1597 1598 1598 return 0;
-1
sound/hda/ext/hdac_ext_bus.c
··· 107 107 INIT_LIST_HEAD(&bus->hlink_list); 108 108 bus->idx = idx++; 109 109 110 - mutex_init(&bus->lock); 111 110 bus->cmd_dma_state = true; 112 111 113 112 return 0;
+1
sound/hda/hdac_bus.c
··· 38 38 INIT_WORK(&bus->unsol_work, snd_hdac_bus_process_unsol_events); 39 39 spin_lock_init(&bus->reg_lock); 40 40 mutex_init(&bus->cmd_mutex); 41 + mutex_init(&bus->lock); 41 42 bus->irq = -1; 42 43 return 0; 43 44 }
+5 -1
sound/hda/hdac_component.c
··· 69 69 70 70 dev_dbg(bus->dev, "display power %s\n", 71 71 enable ? "enable" : "disable"); 72 + 73 + mutex_lock(&bus->lock); 72 74 if (enable) 73 75 set_bit(idx, &bus->display_power_status); 74 76 else 75 77 clear_bit(idx, &bus->display_power_status); 76 78 77 79 if (!acomp || !acomp->ops) 78 - return; 80 + goto unlock; 79 81 80 82 if (bus->display_power_status) { 81 83 if (!bus->display_power_active) { ··· 94 92 bus->display_power_active = false; 95 93 } 96 94 } 95 + unlock: 96 + mutex_unlock(&bus->lock); 97 97 } 98 98 EXPORT_SYMBOL_GPL(snd_hdac_display_power); 99 99
+4
sound/pci/hda/hda_intel.c
··· 2142 2142 SND_PCI_QUIRK(0x8086, 0x2040, "Intel DZ77BH-55K", 0), 2143 2143 /* https://bugzilla.kernel.org/show_bug.cgi?id=199607 */ 2144 2144 SND_PCI_QUIRK(0x8086, 0x2057, "Intel NUC5i7RYB", 0), 2145 + /* https://bugs.launchpad.net/bugs/1821663 */ 2146 + SND_PCI_QUIRK(0x8086, 0x2064, "Intel SDP 8086:2064", 0), 2145 2147 /* https://bugzilla.redhat.com/show_bug.cgi?id=1520902 */ 2146 2148 SND_PCI_QUIRK(0x8086, 0x2068, "Intel NUC7i3BNB", 0), 2147 2149 /* https://bugzilla.kernel.org/show_bug.cgi?id=198611 */ ··· 2152 2150 SND_PCI_QUIRK(0x17aa, 0x367b, "Lenovo IdeaCentre B550", 0), 2153 2151 /* https://bugzilla.redhat.com/show_bug.cgi?id=1572975 */ 2154 2152 SND_PCI_QUIRK(0x17aa, 0x36a7, "Lenovo C50 All in one", 0), 2153 + /* https://bugs.launchpad.net/bugs/1821663 */ 2154 + SND_PCI_QUIRK(0x1631, 0xe017, "Packard Bell NEC IMEDIA 5204", 0), 2155 2155 {} 2156 2156 }; 2157 2157 #endif /* CONFIG_PM */
+51 -21
sound/pci/hda/patch_realtek.c
··· 1864 1864 ALC887_FIXUP_BASS_CHMAP, 1865 1865 ALC1220_FIXUP_GB_DUAL_CODECS, 1866 1866 ALC1220_FIXUP_CLEVO_P950, 1867 - ALC1220_FIXUP_SYSTEM76_ORYP5, 1868 - ALC1220_FIXUP_SYSTEM76_ORYP5_PINS, 1867 + ALC1220_FIXUP_CLEVO_PB51ED, 1868 + ALC1220_FIXUP_CLEVO_PB51ED_PINS, 1869 1869 }; 1870 1870 1871 1871 static void alc889_fixup_coef(struct hda_codec *codec, ··· 2070 2070 static void alc_fixup_headset_mode_no_hp_mic(struct hda_codec *codec, 2071 2071 const struct hda_fixup *fix, int action); 2072 2072 2073 - static void alc1220_fixup_system76_oryp5(struct hda_codec *codec, 2073 + static void alc1220_fixup_clevo_pb51ed(struct hda_codec *codec, 2074 2074 const struct hda_fixup *fix, 2075 2075 int action) 2076 2076 { ··· 2322 2322 .type = HDA_FIXUP_FUNC, 2323 2323 .v.func = alc1220_fixup_clevo_p950, 2324 2324 }, 2325 - [ALC1220_FIXUP_SYSTEM76_ORYP5] = { 2325 + [ALC1220_FIXUP_CLEVO_PB51ED] = { 2326 2326 .type = HDA_FIXUP_FUNC, 2327 - .v.func = alc1220_fixup_system76_oryp5, 2327 + .v.func = alc1220_fixup_clevo_pb51ed, 2328 2328 }, 2329 - [ALC1220_FIXUP_SYSTEM76_ORYP5_PINS] = { 2329 + [ALC1220_FIXUP_CLEVO_PB51ED_PINS] = { 2330 2330 .type = HDA_FIXUP_PINS, 2331 2331 .v.pins = (const struct hda_pintbl[]) { 2332 2332 { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */ 2333 2333 {} 2334 2334 }, 2335 2335 .chained = true, 2336 - .chain_id = ALC1220_FIXUP_SYSTEM76_ORYP5, 2336 + .chain_id = ALC1220_FIXUP_CLEVO_PB51ED, 2337 2337 }, 2338 2338 }; 2339 2339 ··· 2411 2411 SND_PCI_QUIRK(0x1558, 0x9501, "Clevo P950HR", ALC1220_FIXUP_CLEVO_P950), 2412 2412 SND_PCI_QUIRK(0x1558, 0x95e1, "Clevo P95xER", ALC1220_FIXUP_CLEVO_P950), 2413 2413 SND_PCI_QUIRK(0x1558, 0x95e2, "Clevo P950ER", ALC1220_FIXUP_CLEVO_P950), 2414 - SND_PCI_QUIRK(0x1558, 0x96e1, "System76 Oryx Pro (oryp5)", ALC1220_FIXUP_SYSTEM76_ORYP5_PINS), 2415 - SND_PCI_QUIRK(0x1558, 0x97e1, "System76 Oryx Pro (oryp5)", ALC1220_FIXUP_SYSTEM76_ORYP5_PINS), 2414 + SND_PCI_QUIRK(0x1558, 0x96e1, "System76 Oryx Pro (oryp5)", ALC1220_FIXUP_CLEVO_PB51ED_PINS), 2415 + SND_PCI_QUIRK(0x1558, 0x97e1, "System76 Oryx Pro (oryp5)", ALC1220_FIXUP_CLEVO_PB51ED_PINS), 2416 + SND_PCI_QUIRK(0x1558, 0x65d1, "Tuxedo Book XC1509", ALC1220_FIXUP_CLEVO_PB51ED_PINS), 2416 2417 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC882_FIXUP_EAPD), 2417 2418 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_FIXUP_EAPD), 2418 2419 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", ALC882_FIXUP_LENOVO_Y530), ··· 5492 5491 jack->jack->button_state = report; 5493 5492 } 5494 5493 5495 - static void alc295_fixup_chromebook(struct hda_codec *codec, 5494 + static void alc_fixup_headset_jack(struct hda_codec *codec, 5496 5495 const struct hda_fixup *fix, int action) 5497 5496 { 5498 5497 ··· 5502 5501 alc_headset_btn_callback); 5503 5502 snd_hda_jack_add_kctl(codec, 0x55, "Headset Jack", false, 5504 5503 SND_JACK_HEADSET, alc_headset_btn_keymap); 5505 - switch (codec->core.vendor_id) { 5506 - case 0x10ec0295: 5507 - alc_update_coef_idx(codec, 0x4a, 0x8000, 1 << 15); /* Reset HP JD */ 5508 - alc_update_coef_idx(codec, 0x4a, 0x8000, 0 << 15); 5509 - break; 5510 - case 0x10ec0236: 5511 - alc_update_coef_idx(codec, 0x1b, 0x8000, 1 << 15); /* Reset HP JD */ 5512 - alc_update_coef_idx(codec, 0x1b, 0x8000, 0 << 15); 5513 - break; 5514 - } 5515 5504 break; 5516 5505 case HDA_FIXUP_ACT_INIT: 5517 5506 switch (codec->core.vendor_id) { ··· 5516 5525 case 0x10ec0256: 5517 5526 alc_write_coef_idx(codec, 0x48, 0xd011); 5518 5527 alc_update_coef_idx(codec, 0x49, 0x007f, 0x0045); 5528 + break; 5529 + } 5530 + break; 5531 + } 5532 + } 5533 + 5534 + static void alc295_fixup_chromebook(struct hda_codec *codec, 5535 + const struct hda_fixup *fix, int action) 5536 + { 5537 + switch (action) { 5538 + case HDA_FIXUP_ACT_INIT: 5539 + switch (codec->core.vendor_id) { 5540 + case 0x10ec0295: 5541 + alc_update_coef_idx(codec, 0x4a, 0x8000, 1 << 15); /* Reset HP JD */ 5542 + alc_update_coef_idx(codec, 0x4a, 0x8000, 0 << 15); 5543 + break; 5544 + case 0x10ec0236: 5545 + alc_update_coef_idx(codec, 0x1b, 0x8000, 1 << 15); /* Reset HP JD */ 5546 + alc_update_coef_idx(codec, 0x1b, 0x8000, 0 << 15); 5519 5547 break; 5520 5548 } 5521 5549 break; ··· 5673 5663 ALC233_FIXUP_ASUS_MIC_NO_PRESENCE, 5674 5664 ALC233_FIXUP_EAPD_COEF_AND_MIC_NO_PRESENCE, 5675 5665 ALC233_FIXUP_LENOVO_MULTI_CODECS, 5666 + ALC233_FIXUP_ACER_HEADSET_MIC, 5676 5667 ALC294_FIXUP_LENOVO_MIC_LOCATION, 5677 5668 ALC225_FIXUP_DELL_WYSE_MIC_NO_PRESENCE, 5678 5669 ALC700_FIXUP_INTEL_REFERENCE, ··· 5695 5684 ALC285_FIXUP_LENOVO_PC_BEEP_IN_NOISE, 5696 5685 ALC255_FIXUP_ACER_HEADSET_MIC, 5697 5686 ALC295_FIXUP_CHROME_BOOK, 5687 + ALC225_FIXUP_HEADSET_JACK, 5698 5688 ALC225_FIXUP_DELL_WYSE_AIO_MIC_NO_PRESENCE, 5699 5689 ALC225_FIXUP_WYSE_AUTO_MUTE, 5700 5690 ALC225_FIXUP_WYSE_DISABLE_MIC_VREF, ··· 6502 6490 .type = HDA_FIXUP_FUNC, 6503 6491 .v.func = alc233_alc662_fixup_lenovo_dual_codecs, 6504 6492 }, 6493 + [ALC233_FIXUP_ACER_HEADSET_MIC] = { 6494 + .type = HDA_FIXUP_VERBS, 6495 + .v.verbs = (const struct hda_verb[]) { 6496 + { 0x20, AC_VERB_SET_COEF_INDEX, 0x45 }, 6497 + { 0x20, AC_VERB_SET_PROC_COEF, 0x5089 }, 6498 + { } 6499 + }, 6500 + .chained = true, 6501 + .chain_id = ALC233_FIXUP_ASUS_MIC_NO_PRESENCE 6502 + }, 6505 6503 [ALC294_FIXUP_LENOVO_MIC_LOCATION] = { 6506 6504 .type = HDA_FIXUP_PINS, 6507 6505 .v.pins = (const struct hda_pintbl[]) { ··· 6657 6635 [ALC295_FIXUP_CHROME_BOOK] = { 6658 6636 .type = HDA_FIXUP_FUNC, 6659 6637 .v.func = alc295_fixup_chromebook, 6638 + .chained = true, 6639 + .chain_id = ALC225_FIXUP_HEADSET_JACK 6640 + }, 6641 + [ALC225_FIXUP_HEADSET_JACK] = { 6642 + .type = HDA_FIXUP_FUNC, 6643 + .v.func = alc_fixup_headset_jack, 6660 6644 }, 6661 6645 [ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE] = { 6662 6646 .type = HDA_FIXUP_PINS, ··· 6765 6737 SND_PCI_QUIRK(0x1025, 0x1290, "Acer Veriton Z4860G", ALC286_FIXUP_ACER_AIO_HEADSET_MIC), 6766 6738 SND_PCI_QUIRK(0x1025, 0x1291, "Acer Veriton Z4660G", ALC286_FIXUP_ACER_AIO_HEADSET_MIC), 6767 6739 SND_PCI_QUIRK(0x1025, 0x1308, "Acer Aspire Z24-890", ALC286_FIXUP_ACER_AIO_HEADSET_MIC), 6740 + SND_PCI_QUIRK(0x1025, 0x132a, "Acer TravelMate B114-21", ALC233_FIXUP_ACER_HEADSET_MIC), 6768 6741 SND_PCI_QUIRK(0x1025, 0x1330, "Acer TravelMate X514-51T", ALC255_FIXUP_ACER_HEADSET_MIC), 6769 6742 SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z), 6770 6743 SND_PCI_QUIRK(0x1028, 0x054b, "Dell XPS one 2710", ALC275_FIXUP_DELL_XPS), ··· 7161 7132 {.id = ALC255_FIXUP_DUMMY_LINEOUT_VERB, .name = "alc255-dummy-lineout"}, 7162 7133 {.id = ALC255_FIXUP_DELL_HEADSET_MIC, .name = "alc255-dell-headset"}, 7163 7134 {.id = ALC295_FIXUP_HP_X360, .name = "alc295-hp-x360"}, 7164 - {.id = ALC295_FIXUP_CHROME_BOOK, .name = "alc-sense-combo"}, 7135 + {.id = ALC225_FIXUP_HEADSET_JACK, .name = "alc-headset-jack"}, 7136 + {.id = ALC295_FIXUP_CHROME_BOOK, .name = "alc-chrome-book"}, 7165 7137 {.id = ALC299_FIXUP_PREDATOR_SPK, .name = "predator-spk"}, 7166 7138 {} 7167 7139 };
+1
sound/soc/codecs/Kconfig
··· 1151 1151 tristate "WCD9335 Codec" 1152 1152 depends on SLIMBUS 1153 1153 select REGMAP_SLIMBUS 1154 + select REGMAP_IRQ 1154 1155 help 1155 1156 The WCD9335 is a standalone Hi-Fi audio CODEC IC, supports 1156 1157 Qualcomm Technologies, Inc. (QTI) multimedia solutions,
+1
sound/soc/codecs/ab8500-codec.c
··· 2129 2129 dev_err(dai->component->dev, 2130 2130 "%s: ERROR: The device is either a master or a slave.\n", 2131 2131 __func__); 2132 + /* fall through */ 2132 2133 default: 2133 2134 dev_err(dai->component->dev, 2134 2135 "%s: ERROR: Unsupporter master mask 0x%x\n",
+11
sound/soc/codecs/cs35l35.c
··· 1635 1635 return ret; 1636 1636 } 1637 1637 1638 + static int cs35l35_i2c_remove(struct i2c_client *i2c_client) 1639 + { 1640 + struct cs35l35_private *cs35l35 = i2c_get_clientdata(i2c_client); 1641 + 1642 + regulator_bulk_disable(cs35l35->num_supplies, cs35l35->supplies); 1643 + gpiod_set_value_cansleep(cs35l35->reset_gpio, 0); 1644 + 1645 + return 0; 1646 + } 1647 + 1638 1648 static const struct of_device_id cs35l35_of_match[] = { 1639 1649 {.compatible = "cirrus,cs35l35"}, 1640 1650 {}, ··· 1665 1655 }, 1666 1656 .id_table = cs35l35_id, 1667 1657 .probe = cs35l35_i2c_probe, 1658 + .remove = cs35l35_i2c_remove, 1668 1659 }; 1669 1660 1670 1661 module_i2c_driver(cs35l35_i2c_driver);
+1
sound/soc/codecs/cs4270.c
··· 642 642 .reg_defaults = cs4270_reg_defaults, 643 643 .num_reg_defaults = ARRAY_SIZE(cs4270_reg_defaults), 644 644 .cache_type = REGCACHE_RBTREE, 645 + .write_flag_mask = CS4270_I2C_INCR, 645 646 646 647 .readable_reg = cs4270_reg_is_readable, 647 648 .volatile_reg = cs4270_reg_is_volatile,
+40 -15
sound/soc/codecs/hdac_hda.c
··· 38 38 struct snd_soc_dai *dai); 39 39 static int hdac_hda_dai_prepare(struct snd_pcm_substream *substream, 40 40 struct snd_soc_dai *dai); 41 + static int hdac_hda_dai_hw_params(struct snd_pcm_substream *substream, 42 + struct snd_pcm_hw_params *params, 43 + struct snd_soc_dai *dai); 41 44 static int hdac_hda_dai_hw_free(struct snd_pcm_substream *substream, 42 45 struct snd_soc_dai *dai); 43 46 static int hdac_hda_dai_set_tdm_slot(struct snd_soc_dai *dai, ··· 53 50 .startup = hdac_hda_dai_open, 54 51 .shutdown = hdac_hda_dai_close, 55 52 .prepare = hdac_hda_dai_prepare, 53 + .hw_params = hdac_hda_dai_hw_params, 56 54 .hw_free = hdac_hda_dai_hw_free, 57 55 .set_tdm_slot = hdac_hda_dai_set_tdm_slot, 58 56 }; ··· 143 139 return 0; 144 140 } 145 141 142 + static int hdac_hda_dai_hw_params(struct snd_pcm_substream *substream, 143 + struct snd_pcm_hw_params *params, 144 + struct snd_soc_dai *dai) 145 + { 146 + struct snd_soc_component *component = dai->component; 147 + struct hdac_hda_priv *hda_pvt; 148 + unsigned int format_val; 149 + unsigned int maxbps; 150 + 151 + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) 152 + maxbps = dai->driver->playback.sig_bits; 153 + else 154 + maxbps = dai->driver->capture.sig_bits; 155 + 156 + hda_pvt = snd_soc_component_get_drvdata(component); 157 + format_val = snd_hdac_calc_stream_format(params_rate(params), 158 + params_channels(params), 159 + params_format(params), 160 + maxbps, 161 + 0); 162 + if (!format_val) { 163 + dev_err(dai->dev, 164 + "invalid format_val, rate=%d, ch=%d, format=%d, maxbps=%d\n", 165 + params_rate(params), params_channels(params), 166 + params_format(params), maxbps); 167 + 168 + return -EINVAL; 169 + } 170 + 171 + hda_pvt->pcm[dai->id].format_val[substream->stream] = format_val; 172 + return 0; 173 + } 174 + 146 175 static int hdac_hda_dai_hw_free(struct snd_pcm_substream *substream, 147 176 struct snd_soc_dai *dai) 148 177 { ··· 199 162 struct snd_soc_dai *dai) 200 163 { 201 164 struct snd_soc_component *component = dai->component; 202 - struct hdac_hda_priv *hda_pvt; 203 - struct snd_pcm_runtime *runtime = substream->runtime; 204 - struct hdac_device *hdev; 205 165 struct hda_pcm_stream *hda_stream; 166 + struct hdac_hda_priv *hda_pvt; 167 + struct hdac_device *hdev; 206 168 unsigned int format_val; 207 169 struct hda_pcm *pcm; 208 170 unsigned int stream; ··· 215 179 216 180 hda_stream = &pcm->stream[substream->stream]; 217 181 218 - format_val = snd_hdac_calc_stream_format(runtime->rate, 219 - runtime->channels, 220 - runtime->format, 221 - hda_stream->maxbps, 222 - 0); 223 - if (!format_val) { 224 - dev_err(&hdev->dev, 225 - "invalid format_val, rate=%d, ch=%d, format=%d\n", 226 - runtime->rate, runtime->channels, runtime->format); 227 - return -EINVAL; 228 - } 229 - 230 182 stream = hda_pvt->pcm[dai->id].stream_tag[substream->stream]; 183 + format_val = hda_pvt->pcm[dai->id].format_val[substream->stream]; 231 184 232 185 ret = snd_hda_codec_prepare(&hda_pvt->codec, hda_stream, 233 186 stream, format_val, substream);
+1
sound/soc/codecs/hdac_hda.h
··· 8 8 9 9 struct hdac_hda_pcm { 10 10 int stream_tag[2]; 11 + unsigned int format_val[2]; 11 12 }; 12 13 13 14 struct hdac_hda_priv {
+59 -62
sound/soc/codecs/hdmi-codec.c
··· 484 484 params_width(params), params_rate(params), 485 485 params_channels(params)); 486 486 487 - if (params_width(params) > 24) 488 - params->msbits = 24; 489 - 490 487 ret = snd_pcm_create_iec958_consumer_hw_params(params, hp.iec.status, 491 488 sizeof(hp.iec.status)); 492 489 if (ret < 0) { ··· 526 529 { 527 530 struct hdmi_codec_priv *hcp = snd_soc_dai_get_drvdata(dai); 528 531 struct hdmi_codec_daifmt cf = { 0 }; 529 - int ret = 0; 530 532 531 533 dev_dbg(dai->dev, "%s()\n", __func__); 532 534 533 - if (dai->id == DAI_ID_SPDIF) { 534 - cf.fmt = HDMI_SPDIF; 535 - } else { 536 - switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { 537 - case SND_SOC_DAIFMT_CBM_CFM: 538 - cf.bit_clk_master = 1; 539 - cf.frame_clk_master = 1; 540 - break; 541 - case SND_SOC_DAIFMT_CBS_CFM: 542 - cf.frame_clk_master = 1; 543 - break; 544 - case SND_SOC_DAIFMT_CBM_CFS: 545 - cf.bit_clk_master = 1; 546 - break; 547 - case SND_SOC_DAIFMT_CBS_CFS: 548 - break; 549 - default: 550 - return -EINVAL; 551 - } 535 + if (dai->id == DAI_ID_SPDIF) 536 + return 0; 552 537 553 - switch (fmt & SND_SOC_DAIFMT_INV_MASK) { 554 - case SND_SOC_DAIFMT_NB_NF: 555 - break; 556 - case SND_SOC_DAIFMT_NB_IF: 557 - cf.frame_clk_inv = 1; 558 - break; 559 - case SND_SOC_DAIFMT_IB_NF: 560 - cf.bit_clk_inv = 1; 561 - break; 562 - case SND_SOC_DAIFMT_IB_IF: 563 - cf.frame_clk_inv = 1; 564 - cf.bit_clk_inv = 1; 565 - break; 566 - } 538 + switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { 539 + case SND_SOC_DAIFMT_CBM_CFM: 540 + cf.bit_clk_master = 1; 541 + cf.frame_clk_master = 1; 542 + break; 543 + case SND_SOC_DAIFMT_CBS_CFM: 544 + cf.frame_clk_master = 1; 545 + break; 546 + case SND_SOC_DAIFMT_CBM_CFS: 547 + cf.bit_clk_master = 1; 548 + break; 549 + case SND_SOC_DAIFMT_CBS_CFS: 550 + break; 551 + default: 552 + return -EINVAL; 553 + } 567 554 568 - switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { 569 - case SND_SOC_DAIFMT_I2S: 570 - cf.fmt = HDMI_I2S; 571 - break; 572 - case SND_SOC_DAIFMT_DSP_A: 573 - cf.fmt = HDMI_DSP_A; 574 - break; 575 - case SND_SOC_DAIFMT_DSP_B: 576 - cf.fmt = HDMI_DSP_B; 577 - break; 578 - case SND_SOC_DAIFMT_RIGHT_J: 579 - cf.fmt = HDMI_RIGHT_J; 580 - break; 581 - case SND_SOC_DAIFMT_LEFT_J: 582 - cf.fmt = HDMI_LEFT_J; 583 - break; 584 - case SND_SOC_DAIFMT_AC97: 585 - cf.fmt = HDMI_AC97; 586 - break; 587 - default: 588 - dev_err(dai->dev, "Invalid DAI interface format\n"); 589 - return -EINVAL; 590 - } 555 + switch (fmt & SND_SOC_DAIFMT_INV_MASK) { 556 + case SND_SOC_DAIFMT_NB_NF: 557 + break; 558 + case SND_SOC_DAIFMT_NB_IF: 559 + cf.frame_clk_inv = 1; 560 + break; 561 + case SND_SOC_DAIFMT_IB_NF: 562 + cf.bit_clk_inv = 1; 563 + break; 564 + case SND_SOC_DAIFMT_IB_IF: 565 + cf.frame_clk_inv = 1; 566 + cf.bit_clk_inv = 1; 567 + break; 568 + } 569 + 570 + switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { 571 + case SND_SOC_DAIFMT_I2S: 572 + cf.fmt = HDMI_I2S; 573 + break; 574 + case SND_SOC_DAIFMT_DSP_A: 575 + cf.fmt = HDMI_DSP_A; 576 + break; 577 + case SND_SOC_DAIFMT_DSP_B: 578 + cf.fmt = HDMI_DSP_B; 579 + break; 580 + case SND_SOC_DAIFMT_RIGHT_J: 581 + cf.fmt = HDMI_RIGHT_J; 582 + break; 583 + case SND_SOC_DAIFMT_LEFT_J: 584 + cf.fmt = HDMI_LEFT_J; 585 + break; 586 + case SND_SOC_DAIFMT_AC97: 587 + cf.fmt = HDMI_AC97; 588 + break; 589 + default: 590 + dev_err(dai->dev, "Invalid DAI interface format\n"); 591 + return -EINVAL; 591 592 } 592 593 593 594 hcp->daifmt[dai->id] = cf; 594 595 595 - return ret; 596 + return 0; 596 597 } 597 598 598 599 static int hdmi_codec_digital_mute(struct snd_soc_dai *dai, int mute) ··· 787 792 i++; 788 793 } 789 794 790 - if (hcd->spdif) 795 + if (hcd->spdif) { 791 796 hcp->daidrv[i] = hdmi_spdif_dai; 797 + hcp->daifmt[DAI_ID_SPDIF].fmt = HDMI_SPDIF; 798 + } 792 799 793 800 dev_set_drvdata(dev, hcp); 794 801
+2 -2
sound/soc/codecs/nau8810.c
··· 411 411 SND_SOC_DAPM_MIXER("Mono Mixer", NAU8810_REG_POWER3, 412 412 NAU8810_MOUTMX_EN_SFT, 0, &nau8810_mono_mixer_controls[0], 413 413 ARRAY_SIZE(nau8810_mono_mixer_controls)), 414 - SND_SOC_DAPM_DAC("DAC", "HiFi Playback", NAU8810_REG_POWER3, 414 + SND_SOC_DAPM_DAC("DAC", "Playback", NAU8810_REG_POWER3, 415 415 NAU8810_DAC_EN_SFT, 0), 416 - SND_SOC_DAPM_ADC("ADC", "HiFi Capture", NAU8810_REG_POWER2, 416 + SND_SOC_DAPM_ADC("ADC", "Capture", NAU8810_REG_POWER2, 417 417 NAU8810_ADC_EN_SFT, 0), 418 418 SND_SOC_DAPM_PGA("SpkN Out", NAU8810_REG_POWER3, 419 419 NAU8810_NSPK_EN_SFT, 0, NULL, 0),
+38 -8
sound/soc/codecs/nau8824.c
··· 681 681 SND_SOC_DAPM_ADC("ADCR", NULL, NAU8824_REG_ANALOG_ADC_2, 682 682 NAU8824_ADCR_EN_SFT, 0), 683 683 684 - SND_SOC_DAPM_AIF_OUT("AIFTX", "HiFi Capture", 0, SND_SOC_NOPM, 0, 0), 685 - SND_SOC_DAPM_AIF_IN("AIFRX", "HiFi Playback", 0, SND_SOC_NOPM, 0, 0), 684 + SND_SOC_DAPM_AIF_OUT("AIFTX", "Capture", 0, SND_SOC_NOPM, 0, 0), 685 + SND_SOC_DAPM_AIF_IN("AIFRX", "Playback", 0, SND_SOC_NOPM, 0, 0), 686 686 687 687 SND_SOC_DAPM_DAC("DACL", NULL, NAU8824_REG_RDAC, 688 688 NAU8824_DACL_EN_SFT, 0), ··· 831 831 } 832 832 } 833 833 834 + static void nau8824_dapm_disable_pin(struct nau8824 *nau8824, const char *pin) 835 + { 836 + struct snd_soc_dapm_context *dapm = nau8824->dapm; 837 + const char *prefix = dapm->component->name_prefix; 838 + char prefixed_pin[80]; 839 + 840 + if (prefix) { 841 + snprintf(prefixed_pin, sizeof(prefixed_pin), "%s %s", 842 + prefix, pin); 843 + snd_soc_dapm_disable_pin(dapm, prefixed_pin); 844 + } else { 845 + snd_soc_dapm_disable_pin(dapm, pin); 846 + } 847 + } 848 + 849 + static void nau8824_dapm_enable_pin(struct nau8824 *nau8824, const char *pin) 850 + { 851 + struct snd_soc_dapm_context *dapm = nau8824->dapm; 852 + const char *prefix = dapm->component->name_prefix; 853 + char prefixed_pin[80]; 854 + 855 + if (prefix) { 856 + snprintf(prefixed_pin, sizeof(prefixed_pin), "%s %s", 857 + prefix, pin); 858 + snd_soc_dapm_force_enable_pin(dapm, prefixed_pin); 859 + } else { 860 + snd_soc_dapm_force_enable_pin(dapm, pin); 861 + } 862 + } 863 + 834 864 static void nau8824_eject_jack(struct nau8824 *nau8824) 835 865 { 836 866 struct snd_soc_dapm_context *dapm = nau8824->dapm; ··· 869 839 /* Clear all interruption status */ 870 840 nau8824_int_status_clear_all(regmap); 871 841 872 - snd_soc_dapm_disable_pin(dapm, "SAR"); 873 - snd_soc_dapm_disable_pin(dapm, "MICBIAS"); 842 + nau8824_dapm_disable_pin(nau8824, "SAR"); 843 + nau8824_dapm_disable_pin(nau8824, "MICBIAS"); 874 844 snd_soc_dapm_sync(dapm); 875 845 876 846 /* Enable the insertion interruption, disable the ejection ··· 900 870 struct regmap *regmap = nau8824->regmap; 901 871 int adc_value, event = 0, event_mask = 0; 902 872 903 - snd_soc_dapm_force_enable_pin(dapm, "MICBIAS"); 904 - snd_soc_dapm_force_enable_pin(dapm, "SAR"); 873 + nau8824_dapm_enable_pin(nau8824, "MICBIAS"); 874 + nau8824_dapm_enable_pin(nau8824, "SAR"); 905 875 snd_soc_dapm_sync(dapm); 906 876 907 877 msleep(100); ··· 912 882 if (adc_value < HEADSET_SARADC_THD) { 913 883 event |= SND_JACK_HEADPHONE; 914 884 915 - snd_soc_dapm_disable_pin(dapm, "SAR"); 916 - snd_soc_dapm_disable_pin(dapm, "MICBIAS"); 885 + nau8824_dapm_disable_pin(nau8824, "SAR"); 886 + nau8824_dapm_disable_pin(nau8824, "MICBIAS"); 917 887 snd_soc_dapm_sync(dapm); 918 888 } else { 919 889 event |= SND_JACK_HEADSET;
+25 -31
sound/soc/codecs/rt5682.c
··· 910 910 int jack_insert) 911 911 { 912 912 struct rt5682_priv *rt5682 = snd_soc_component_get_drvdata(component); 913 - struct snd_soc_dapm_context *dapm = 914 - snd_soc_component_get_dapm(component); 915 913 unsigned int val, count; 916 914 917 915 if (jack_insert) { 918 - snd_soc_dapm_force_enable_pin(dapm, "CBJ Power"); 919 - snd_soc_dapm_sync(dapm); 916 + 917 + snd_soc_component_update_bits(component, RT5682_PWR_ANLG_1, 918 + RT5682_PWR_VREF2 | RT5682_PWR_MB, 919 + RT5682_PWR_VREF2 | RT5682_PWR_MB); 920 + snd_soc_component_update_bits(component, 921 + RT5682_PWR_ANLG_1, RT5682_PWR_FV2, 0); 922 + usleep_range(15000, 20000); 923 + snd_soc_component_update_bits(component, 924 + RT5682_PWR_ANLG_1, RT5682_PWR_FV2, RT5682_PWR_FV2); 925 + snd_soc_component_update_bits(component, RT5682_PWR_ANLG_3, 926 + RT5682_PWR_CBJ, RT5682_PWR_CBJ); 927 + 920 928 snd_soc_component_update_bits(component, RT5682_CBJ_CTRL_1, 921 929 RT5682_TRIG_JD_MASK, RT5682_TRIG_JD_HIGH); 922 930 ··· 952 944 rt5682_enable_push_button_irq(component, false); 953 945 snd_soc_component_update_bits(component, RT5682_CBJ_CTRL_1, 954 946 RT5682_TRIG_JD_MASK, RT5682_TRIG_JD_LOW); 955 - snd_soc_dapm_disable_pin(dapm, "CBJ Power"); 956 - snd_soc_dapm_sync(dapm); 947 + snd_soc_component_update_bits(component, RT5682_PWR_ANLG_1, 948 + RT5682_PWR_VREF2 | RT5682_PWR_MB, 0); 949 + snd_soc_component_update_bits(component, RT5682_PWR_ANLG_3, 950 + RT5682_PWR_CBJ, 0); 957 951 958 952 rt5682->jack_type = 0; 959 953 } ··· 1208 1198 struct snd_soc_component *component = 1209 1199 snd_soc_dapm_to_component(w->dapm); 1210 1200 struct rt5682_priv *rt5682 = snd_soc_component_get_drvdata(component); 1211 - int ref, val, reg, sft, mask, idx = -EINVAL; 1201 + int ref, val, reg, idx = -EINVAL; 1212 1202 static const int div_f[] = {1, 2, 3, 4, 6, 8, 12, 16, 24, 32, 48}; 1213 1203 static const int div_o[] = {1, 2, 4, 6, 8, 12, 16, 24, 32, 48}; 1214 1204 ··· 1222 1212 1223 1213 idx = rt5682_div_sel(rt5682, ref, div_f, ARRAY_SIZE(div_f)); 1224 1214 1225 - if (w->shift == RT5682_PWR_ADC_S1F_BIT) { 1215 + if (w->shift == RT5682_PWR_ADC_S1F_BIT) 1226 1216 reg = RT5682_PLL_TRACK_3; 1227 - sft = RT5682_ADC_OSR_SFT; 1228 - mask = RT5682_ADC_OSR_MASK; 1229 - } else { 1217 + else 1230 1218 reg = RT5682_PLL_TRACK_2; 1231 - sft = RT5682_DAC_OSR_SFT; 1232 - mask = RT5682_DAC_OSR_MASK; 1233 - } 1234 1219 1235 1220 snd_soc_component_update_bits(component, reg, 1236 1221 RT5682_FILTER_CLK_DIV_MASK, idx << RT5682_FILTER_CLK_DIV_SFT); ··· 1237 1232 } 1238 1233 1239 1234 snd_soc_component_update_bits(component, RT5682_ADDA_CLK_1, 1240 - mask, idx << sft); 1235 + RT5682_ADC_OSR_MASK | RT5682_DAC_OSR_MASK, 1236 + (idx << RT5682_ADC_OSR_SFT) | (idx << RT5682_DAC_OSR_SFT)); 1241 1237 1242 1238 return 0; 1243 1239 } ··· 1597 1591 0, NULL, 0), 1598 1592 SND_SOC_DAPM_SUPPLY("Vref1", RT5682_PWR_ANLG_1, RT5682_PWR_VREF1_BIT, 0, 1599 1593 rt5655_set_verf, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU), 1600 - SND_SOC_DAPM_SUPPLY("Vref2", RT5682_PWR_ANLG_1, RT5682_PWR_VREF2_BIT, 0, 1601 - rt5655_set_verf, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU), 1602 1594 1603 1595 /* ASRC */ 1604 1596 SND_SOC_DAPM_SUPPLY_S("DAC STO1 ASRC", 1, RT5682_PLL_TRACK_1, ··· 1630 1626 /* Boost */ 1631 1627 SND_SOC_DAPM_PGA("BST1 CBJ", SND_SOC_NOPM, 1632 1628 0, 0, NULL, 0), 1633 - 1634 - SND_SOC_DAPM_SUPPLY("CBJ Power", RT5682_PWR_ANLG_3, 1635 - RT5682_PWR_CBJ_BIT, 0, NULL, 0), 1636 1629 1637 1630 /* REC Mixer */ 1638 1631 SND_SOC_DAPM_MIXER("RECMIX1L", SND_SOC_NOPM, 0, 0, rt5682_rec1_l_mix, ··· 1793 1792 1794 1793 /*Vref*/ 1795 1794 {"MICBIAS1", NULL, "Vref1"}, 1796 - {"MICBIAS1", NULL, "Vref2"}, 1797 1795 {"MICBIAS2", NULL, "Vref1"}, 1798 - {"MICBIAS2", NULL, "Vref2"}, 1799 1796 1800 1797 {"CLKDET SYS", NULL, "CLKDET"}, 1801 1798 1802 1799 {"IN1P", NULL, "LDO2"}, 1803 1800 1804 1801 {"BST1 CBJ", NULL, "IN1P"}, 1805 - {"BST1 CBJ", NULL, "CBJ Power"}, 1806 - {"CBJ Power", NULL, "Vref2"}, 1807 1802 1808 1803 {"RECMIX1L", "CBJ Switch", "BST1 CBJ"}, 1809 1804 {"RECMIX1L", NULL, "RECMIX1L Power"}, ··· 1909 1912 {"HP Amp", NULL, "Capless"}, 1910 1913 {"HP Amp", NULL, "Charge Pump"}, 1911 1914 {"HP Amp", NULL, "CLKDET SYS"}, 1912 - {"HP Amp", NULL, "CBJ Power"}, 1913 1915 {"HP Amp", NULL, "Vref1"}, 1914 - {"HP Amp", NULL, "Vref2"}, 1915 1916 {"HPOL Playback", "Switch", "HP Amp"}, 1916 1917 {"HPOR Playback", "Switch", "HP Amp"}, 1917 1918 {"HPOL", NULL, "HPOL Playback"}, ··· 2298 2303 switch (level) { 2299 2304 case SND_SOC_BIAS_PREPARE: 2300 2305 regmap_update_bits(rt5682->regmap, RT5682_PWR_ANLG_1, 2301 - RT5682_PWR_MB | RT5682_PWR_BG, 2302 - RT5682_PWR_MB | RT5682_PWR_BG); 2306 + RT5682_PWR_BG, RT5682_PWR_BG); 2303 2307 regmap_update_bits(rt5682->regmap, RT5682_PWR_DIG_1, 2304 2308 RT5682_DIG_GATE_CTRL | RT5682_PWR_LDO, 2305 2309 RT5682_DIG_GATE_CTRL | RT5682_PWR_LDO); 2306 2310 break; 2307 2311 2308 2312 case SND_SOC_BIAS_STANDBY: 2309 - regmap_update_bits(rt5682->regmap, RT5682_PWR_ANLG_1, 2310 - RT5682_PWR_MB, RT5682_PWR_MB); 2311 2313 regmap_update_bits(rt5682->regmap, RT5682_PWR_DIG_1, 2312 2314 RT5682_DIG_GATE_CTRL, RT5682_DIG_GATE_CTRL); 2313 2315 break; ··· 2312 2320 regmap_update_bits(rt5682->regmap, RT5682_PWR_DIG_1, 2313 2321 RT5682_DIG_GATE_CTRL | RT5682_PWR_LDO, 0); 2314 2322 regmap_update_bits(rt5682->regmap, RT5682_PWR_ANLG_1, 2315 - RT5682_PWR_MB | RT5682_PWR_BG, 0); 2323 + RT5682_PWR_BG, 0); 2316 2324 break; 2317 2325 2318 2326 default: ··· 2354 2362 2355 2363 regcache_cache_only(rt5682->regmap, false); 2356 2364 regcache_sync(rt5682->regmap); 2365 + 2366 + rt5682_irq(0, rt5682); 2357 2367 2358 2368 return 0; 2359 2369 }
+2 -2
sound/soc/codecs/tlv320aic32x4-i2c.c
··· 3 3 * 4 4 * Copyright 2011 NW Digital Radio 5 5 * 6 - * Author: Jeremy McDermond <nh6z@nh6z.net> 6 + * Author: Annaliese McDermond <nh6z@nh6z.net> 7 7 * 8 8 * Based on sound/soc/codecs/wm8974 and TI driver for kernel 2.6.27. 9 9 * ··· 72 72 module_i2c_driver(aic32x4_i2c_driver); 73 73 74 74 MODULE_DESCRIPTION("ASoC TLV320AIC32x4 codec driver I2C"); 75 - MODULE_AUTHOR("Jeremy McDermond <nh6z@nh6z.net>"); 75 + MODULE_AUTHOR("Annaliese McDermond <nh6z@nh6z.net>"); 76 76 MODULE_LICENSE("GPL");
+2 -2
sound/soc/codecs/tlv320aic32x4-spi.c
··· 3 3 * 4 4 * Copyright 2011 NW Digital Radio 5 5 * 6 - * Author: Jeremy McDermond <nh6z@nh6z.net> 6 + * Author: Annaliese McDermond <nh6z@nh6z.net> 7 7 * 8 8 * Based on sound/soc/codecs/wm8974 and TI driver for kernel 2.6.27. 9 9 * ··· 74 74 module_spi_driver(aic32x4_spi_driver); 75 75 76 76 MODULE_DESCRIPTION("ASoC TLV320AIC32x4 codec driver SPI"); 77 - MODULE_AUTHOR("Jeremy McDermond <nh6z@nh6z.net>"); 77 + MODULE_AUTHOR("Annaliese McDermond <nh6z@nh6z.net>"); 78 78 MODULE_LICENSE("GPL");
+2
sound/soc/codecs/tlv320aic32x4.c
··· 490 490 SND_SOC_DAPM_INPUT("IN2_R"), 491 491 SND_SOC_DAPM_INPUT("IN3_L"), 492 492 SND_SOC_DAPM_INPUT("IN3_R"), 493 + SND_SOC_DAPM_INPUT("CM_L"), 494 + SND_SOC_DAPM_INPUT("CM_R"), 493 495 }; 494 496 495 497 static const struct snd_soc_dapm_route aic32x4_dapm_routes[] = {
+3 -1
sound/soc/codecs/tlv320aic3x.c
··· 1609 1609 struct aic3x_priv *aic3x = snd_soc_component_get_drvdata(component); 1610 1610 int ret, i; 1611 1611 1612 - INIT_LIST_HEAD(&aic3x->list); 1613 1612 aic3x->component = component; 1614 1613 1615 1614 for (i = 0; i < ARRAY_SIZE(aic3x->supplies); i++) { ··· 1872 1873 if (ret != 0) 1873 1874 goto err_gpio; 1874 1875 1876 + INIT_LIST_HEAD(&aic3x->list); 1875 1877 list_add(&aic3x->list, &reset_list); 1876 1878 1877 1879 return 0; ··· 1888 1888 static int aic3x_i2c_remove(struct i2c_client *client) 1889 1889 { 1890 1890 struct aic3x_priv *aic3x = i2c_get_clientdata(client); 1891 + 1892 + list_del(&aic3x->list); 1891 1893 1892 1894 if (gpio_is_valid(aic3x->gpio_reset) && 1893 1895 !aic3x_is_shared_reset(aic3x)) {
+33 -7
sound/soc/codecs/wm_adsp.c
··· 2905 2905 if (wm_adsp_fw[dsp->fw].num_caps != 0) 2906 2906 wm_adsp_buffer_free(dsp); 2907 2907 2908 + dsp->fatal_error = false; 2909 + 2908 2910 mutex_unlock(&dsp->pwr_lock); 2909 2911 2910 2912 adsp_dbg(dsp, "Execution stopped\n"); ··· 3001 2999 static int wm_adsp_compr_attach(struct wm_adsp_compr *compr) 3002 3000 { 3003 3001 struct wm_adsp_compr_buf *buf = NULL, *tmp; 3002 + 3003 + if (compr->dsp->fatal_error) 3004 + return -EINVAL; 3004 3005 3005 3006 list_for_each_entry(tmp, &compr->dsp->buffer_list, list) { 3006 3007 if (!tmp->name || !strcmp(compr->name, tmp->name)) { ··· 3540 3535 3541 3536 ret = wm_adsp_buffer_read(buf, HOST_BUFFER_FIELD(error), &buf->error); 3542 3537 if (ret < 0) { 3543 - adsp_err(buf->dsp, "Failed to check buffer error: %d\n", ret); 3538 + compr_err(buf, "Failed to check buffer error: %d\n", ret); 3544 3539 return ret; 3545 3540 } 3546 3541 if (buf->error != 0) { 3547 - adsp_err(buf->dsp, "Buffer error occurred: %d\n", buf->error); 3542 + compr_err(buf, "Buffer error occurred: %d\n", buf->error); 3548 3543 return -EIO; 3549 3544 } 3550 3545 ··· 3576 3571 if (ret < 0) 3577 3572 break; 3578 3573 3579 - wm_adsp_buffer_clear(compr->buf); 3580 - 3581 3574 /* Trigger the IRQ at one fragment of data */ 3582 3575 ret = wm_adsp_buffer_write(compr->buf, 3583 3576 HOST_BUFFER_FIELD(high_water_mark), ··· 3587 3584 } 3588 3585 break; 3589 3586 case SNDRV_PCM_TRIGGER_STOP: 3587 + if (wm_adsp_compr_attached(compr)) 3588 + wm_adsp_buffer_clear(compr->buf); 3590 3589 break; 3591 3590 default: 3592 3591 ret = -EINVAL; ··· 3922 3917 } 3923 3918 EXPORT_SYMBOL_GPL(wm_adsp2_lock); 3924 3919 3920 + static void wm_adsp_fatal_error(struct wm_adsp *dsp) 3921 + { 3922 + struct wm_adsp_compr *compr; 3923 + 3924 + dsp->fatal_error = true; 3925 + 3926 + list_for_each_entry(compr, &dsp->compr_list, list) { 3927 + if (compr->stream) { 3928 + snd_compr_stop_error(compr->stream, 3929 + SNDRV_PCM_STATE_XRUN); 3930 + snd_compr_fragment_elapsed(compr->stream); 3931 + } 3932 + } 3933 + } 3934 + 3925 3935 irqreturn_t wm_adsp2_bus_error(struct wm_adsp *dsp) 3926 3936 { 3927 3937 unsigned int val; 3928 3938 struct regmap *regmap = dsp->regmap; 3929 3939 int ret = 0; 3930 3940 3941 + mutex_lock(&dsp->pwr_lock); 3942 + 3931 3943 ret = regmap_read(regmap, dsp->base + ADSP2_LOCK_REGION_CTRL, &val); 3932 3944 if (ret) { 3933 3945 adsp_err(dsp, 3934 3946 "Failed to read Region Lock Ctrl register: %d\n", ret); 3935 - return IRQ_HANDLED; 3947 + goto error; 3936 3948 } 3937 3949 3938 3950 if (val & ADSP2_WDT_TIMEOUT_STS_MASK) { 3939 3951 adsp_err(dsp, "watchdog timeout error\n"); 3940 3952 wm_adsp_stop_watchdog(dsp); 3953 + wm_adsp_fatal_error(dsp); 3941 3954 } 3942 3955 3943 3956 if (val & (ADSP2_SLAVE_ERR_MASK | ADSP2_REGION_LOCK_ERR_MASK)) { ··· 3969 3946 adsp_err(dsp, 3970 3947 "Failed to read Bus Err Addr register: %d\n", 3971 3948 ret); 3972 - return IRQ_HANDLED; 3949 + goto error; 3973 3950 } 3974 3951 3975 3952 adsp_err(dsp, "bus error address = 0x%x\n", ··· 3982 3959 adsp_err(dsp, 3983 3960 "Failed to read Pmem Xmem Err Addr register: %d\n", 3984 3961 ret); 3985 - return IRQ_HANDLED; 3962 + goto error; 3986 3963 } 3987 3964 3988 3965 adsp_err(dsp, "xmem error address = 0x%x\n", ··· 3994 3971 3995 3972 regmap_update_bits(regmap, dsp->base + ADSP2_LOCK_REGION_CTRL, 3996 3973 ADSP2_CTRL_ERR_EINT, ADSP2_CTRL_ERR_EINT); 3974 + 3975 + error: 3976 + mutex_unlock(&dsp->pwr_lock); 3997 3977 3998 3978 return IRQ_HANDLED; 3999 3979 }
+1
sound/soc/codecs/wm_adsp.h
··· 85 85 bool preloaded; 86 86 bool booted; 87 87 bool running; 88 + bool fatal_error; 88 89 89 90 struct list_head ctl_list; 90 91
+14
sound/soc/fsl/fsl_asrc.c
··· 445 445 } 446 446 EXPORT_SYMBOL_GPL(fsl_asrc_get_dma_channel); 447 447 448 + static int fsl_asrc_dai_startup(struct snd_pcm_substream *substream, 449 + struct snd_soc_dai *dai) 450 + { 451 + struct fsl_asrc *asrc_priv = snd_soc_dai_get_drvdata(dai); 452 + 453 + /* Odd channel number is not valid for older ASRC (channel_bits==3) */ 454 + if (asrc_priv->channel_bits == 3) 455 + snd_pcm_hw_constraint_step(substream->runtime, 0, 456 + SNDRV_PCM_HW_PARAM_CHANNELS, 2); 457 + 458 + return 0; 459 + } 460 + 448 461 static int fsl_asrc_dai_hw_params(struct snd_pcm_substream *substream, 449 462 struct snd_pcm_hw_params *params, 450 463 struct snd_soc_dai *dai) ··· 552 539 } 553 540 554 541 static const struct snd_soc_dai_ops fsl_asrc_dai_ops = { 542 + .startup = fsl_asrc_dai_startup, 555 543 .hw_params = fsl_asrc_dai_hw_params, 556 544 .hw_free = fsl_asrc_dai_hw_free, 557 545 .trigger = fsl_asrc_dai_trigger,
+37 -10
sound/soc/fsl/fsl_esai.c
··· 54 54 u32 fifo_depth; 55 55 u32 slot_width; 56 56 u32 slots; 57 + u32 tx_mask; 58 + u32 rx_mask; 57 59 u32 hck_rate[2]; 58 60 u32 sck_rate[2]; 59 61 bool hck_dir[2]; ··· 363 361 regmap_update_bits(esai_priv->regmap, REG_ESAI_TCCR, 364 362 ESAI_xCCR_xDC_MASK, ESAI_xCCR_xDC(slots)); 365 363 366 - regmap_update_bits(esai_priv->regmap, REG_ESAI_TSMA, 367 - ESAI_xSMA_xS_MASK, ESAI_xSMA_xS(tx_mask)); 368 - regmap_update_bits(esai_priv->regmap, REG_ESAI_TSMB, 369 - ESAI_xSMB_xS_MASK, ESAI_xSMB_xS(tx_mask)); 370 - 371 364 regmap_update_bits(esai_priv->regmap, REG_ESAI_RCCR, 372 365 ESAI_xCCR_xDC_MASK, ESAI_xCCR_xDC(slots)); 373 366 374 - regmap_update_bits(esai_priv->regmap, REG_ESAI_RSMA, 375 - ESAI_xSMA_xS_MASK, ESAI_xSMA_xS(rx_mask)); 376 - regmap_update_bits(esai_priv->regmap, REG_ESAI_RSMB, 377 - ESAI_xSMB_xS_MASK, ESAI_xSMB_xS(rx_mask)); 378 - 379 367 esai_priv->slot_width = slot_width; 380 368 esai_priv->slots = slots; 369 + esai_priv->tx_mask = tx_mask; 370 + esai_priv->rx_mask = rx_mask; 381 371 382 372 return 0; 383 373 } ··· 590 596 bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; 591 597 u8 i, channels = substream->runtime->channels; 592 598 u32 pins = DIV_ROUND_UP(channels, esai_priv->slots); 599 + u32 mask; 593 600 594 601 switch (cmd) { 595 602 case SNDRV_PCM_TRIGGER_START: ··· 603 608 for (i = 0; tx && i < channels; i++) 604 609 regmap_write(esai_priv->regmap, REG_ESAI_ETDR, 0x0); 605 610 611 + /* 612 + * When set the TE/RE in the end of enablement flow, there 613 + * will be channel swap issue for multi data line case. 614 + * In order to workaround this issue, we switch the bit 615 + * enablement sequence to below sequence 616 + * 1) clear the xSMB & xSMA: which is done in probe and 617 + * stop state. 618 + * 2) set TE/RE 619 + * 3) set xSMB 620 + * 4) set xSMA: xSMA is the last one in this flow, which 621 + * will trigger esai to start. 622 + */ 606 623 regmap_update_bits(esai_priv->regmap, REG_ESAI_xCR(tx), 607 624 tx ? ESAI_xCR_TE_MASK : ESAI_xCR_RE_MASK, 608 625 tx ? ESAI_xCR_TE(pins) : ESAI_xCR_RE(pins)); 626 + mask = tx ? esai_priv->tx_mask : esai_priv->rx_mask; 627 + 628 + regmap_update_bits(esai_priv->regmap, REG_ESAI_xSMB(tx), 629 + ESAI_xSMB_xS_MASK, ESAI_xSMB_xS(mask)); 630 + regmap_update_bits(esai_priv->regmap, REG_ESAI_xSMA(tx), 631 + ESAI_xSMA_xS_MASK, ESAI_xSMA_xS(mask)); 632 + 609 633 break; 610 634 case SNDRV_PCM_TRIGGER_SUSPEND: 611 635 case SNDRV_PCM_TRIGGER_STOP: 612 636 case SNDRV_PCM_TRIGGER_PAUSE_PUSH: 613 637 regmap_update_bits(esai_priv->regmap, REG_ESAI_xCR(tx), 614 638 tx ? ESAI_xCR_TE_MASK : ESAI_xCR_RE_MASK, 0); 639 + regmap_update_bits(esai_priv->regmap, REG_ESAI_xSMA(tx), 640 + ESAI_xSMA_xS_MASK, 0); 641 + regmap_update_bits(esai_priv->regmap, REG_ESAI_xSMB(tx), 642 + ESAI_xSMB_xS_MASK, 0); 615 643 616 644 /* Disable and reset FIFO */ 617 645 regmap_update_bits(esai_priv->regmap, REG_ESAI_xFCR(tx), ··· 923 905 dev_err(&pdev->dev, "failed to enable ESAI: %d\n", ret); 924 906 return ret; 925 907 } 908 + 909 + esai_priv->tx_mask = 0xFFFFFFFF; 910 + esai_priv->rx_mask = 0xFFFFFFFF; 911 + 912 + /* Clear the TSMA, TSMB, RSMA, RSMB */ 913 + regmap_write(esai_priv->regmap, REG_ESAI_TSMA, 0); 914 + regmap_write(esai_priv->regmap, REG_ESAI_TSMB, 0); 915 + regmap_write(esai_priv->regmap, REG_ESAI_RSMA, 0); 916 + regmap_write(esai_priv->regmap, REG_ESAI_RSMB, 0); 926 917 927 918 ret = devm_snd_soc_register_component(&pdev->dev, &fsl_esai_component, 928 919 &fsl_esai_dai, 1);
+8 -3
sound/soc/generic/audio-graph-card.c
··· 20 20 #include <linux/string.h> 21 21 #include <sound/simple_card_utils.h> 22 22 23 + #define DPCM_SELECTABLE 1 24 + 23 25 struct graph_priv { 24 26 struct snd_soc_card snd_card; 25 27 struct graph_dai_props { ··· 442 440 struct device_node *codec_port; 443 441 struct device_node *codec_port_old = NULL; 444 442 struct asoc_simple_card_data adata; 443 + uintptr_t dpcm_selectable = (uintptr_t)of_device_get_match_data(dev); 445 444 int rc, ret; 446 445 447 446 /* loop for all listed CPU port */ ··· 473 470 * if Codec port has many endpoints, 474 471 * or has convert-xxx property 475 472 */ 476 - if ((of_get_child_count(codec_port) > 1) || 477 - adata.convert_rate || adata.convert_channels) 473 + if (dpcm_selectable && 474 + ((of_get_child_count(codec_port) > 1) || 475 + adata.convert_rate || adata.convert_channels)) 478 476 ret = func_dpcm(priv, cpu_ep, codec_ep, li, 479 477 (codec_port_old == codec_port)); 480 478 /* else normal sound */ ··· 736 732 737 733 static const struct of_device_id graph_of_match[] = { 738 734 { .compatible = "audio-graph-card", }, 739 - { .compatible = "audio-graph-scu-card", }, 735 + { .compatible = "audio-graph-scu-card", 736 + .data = (void *)DPCM_SELECTABLE }, 740 737 {}, 741 738 }; 742 739 MODULE_DEVICE_TABLE(of, graph_of_match);
+9 -3
sound/soc/generic/simple-card.c
··· 9 9 #include <linux/device.h> 10 10 #include <linux/module.h> 11 11 #include <linux/of.h> 12 + #include <linux/of_device.h> 12 13 #include <linux/platform_device.h> 13 14 #include <linux/string.h> 14 15 #include <sound/simple_card.h> 15 16 #include <sound/soc-dai.h> 16 17 #include <sound/soc.h> 18 + 19 + #define DPCM_SELECTABLE 1 17 20 18 21 struct simple_priv { 19 22 struct snd_soc_card snd_card; ··· 444 441 struct device *dev = simple_priv_to_dev(priv); 445 442 struct device_node *top = dev->of_node; 446 443 struct device_node *node; 444 + uintptr_t dpcm_selectable = (uintptr_t)of_device_get_match_data(dev); 447 445 bool is_top = 0; 448 446 int ret = 0; 449 447 ··· 484 480 * if it has many CPUs, 485 481 * or has convert-xxx property 486 482 */ 487 - if (num > 2 || 488 - adata.convert_rate || adata.convert_channels) 483 + if (dpcm_selectable && 484 + (num > 2 || 485 + adata.convert_rate || adata.convert_channels)) 489 486 ret = func_dpcm(priv, np, codec, li, is_top); 490 487 /* else normal sound */ 491 488 else ··· 827 822 828 823 static const struct of_device_id simple_of_match[] = { 829 824 { .compatible = "simple-audio-card", }, 830 - { .compatible = "simple-scu-audio-card", }, 825 + { .compatible = "simple-scu-audio-card", 826 + .data = (void *)DPCM_SELECTABLE }, 831 827 {}, 832 828 }; 833 829 MODULE_DEVICE_TABLE(of, simple_of_match);
+8
sound/soc/intel/atom/sst-mfld-platform-pcm.c
··· 706 706 return sst_dsp_init_v2_dpcm(component); 707 707 } 708 708 709 + static void sst_soc_remove(struct snd_soc_component *component) 710 + { 711 + struct sst_data *drv = dev_get_drvdata(component->dev); 712 + 713 + drv->soc_card = NULL; 714 + } 715 + 709 716 static const struct snd_soc_component_driver sst_soc_platform_drv = { 710 717 .name = DRV_NAME, 711 718 .probe = sst_soc_probe, 719 + .remove = sst_soc_remove, 712 720 .ops = &sst_platform_ops, 713 721 .compr_ops = &sst_platform_compr_ops, 714 722 .pcm_new = sst_pcm_new,
+41 -6
sound/soc/intel/boards/cht_bsw_max98090_ti.c
··· 43 43 struct clk *mclk; 44 44 struct snd_soc_jack jack; 45 45 bool ts3a227e_present; 46 + int quirks; 46 47 }; 47 48 48 49 static int platform_clock_control(struct snd_soc_dapm_widget *w, ··· 54 53 struct snd_soc_dai *codec_dai; 55 54 struct cht_mc_private *ctx = snd_soc_card_get_drvdata(card); 56 55 int ret; 56 + 57 + /* See the comment in snd_cht_mc_probe() */ 58 + if (ctx->quirks & QUIRK_PMC_PLT_CLK_0) 59 + return 0; 57 60 58 61 codec_dai = snd_soc_card_get_codec_dai(card, CHT_CODEC_DAI); 59 62 if (!codec_dai) { ··· 227 222 dev_err(runtime->dev, 228 223 "jack detection gpios not added, error %d\n", ret); 229 224 } 225 + 226 + /* See the comment in snd_cht_mc_probe() */ 227 + if (ctx->quirks & QUIRK_PMC_PLT_CLK_0) 228 + return 0; 230 229 231 230 /* 232 231 * The firmware might enable the clock at ··· 432 423 const char *mclk_name; 433 424 struct snd_soc_acpi_mach *mach; 434 425 const char *platform_name; 435 - int quirks = 0; 436 - 437 - dmi_id = dmi_first_match(cht_max98090_quirk_table); 438 - if (dmi_id) 439 - quirks = (unsigned long)dmi_id->driver_data; 440 426 441 427 drv = devm_kzalloc(&pdev->dev, sizeof(*drv), GFP_KERNEL); 442 428 if (!drv) 443 429 return -ENOMEM; 430 + 431 + dmi_id = dmi_first_match(cht_max98090_quirk_table); 432 + if (dmi_id) 433 + drv->quirks = (unsigned long)dmi_id->driver_data; 444 434 445 435 drv->ts3a227e_present = acpi_dev_found("104C227E"); 446 436 if (!drv->ts3a227e_present) { ··· 466 458 snd_soc_card_cht.dev = &pdev->dev; 467 459 snd_soc_card_set_drvdata(&snd_soc_card_cht, drv); 468 460 469 - if (quirks & QUIRK_PMC_PLT_CLK_0) 461 + if (drv->quirks & QUIRK_PMC_PLT_CLK_0) 470 462 mclk_name = "pmc_plt_clk_0"; 471 463 else 472 464 mclk_name = "pmc_plt_clk_3"; ··· 479 471 return PTR_ERR(drv->mclk); 480 472 } 481 473 474 + /* 475 + * Boards which have the MAX98090's clk connected to clk_0 do not seem 476 + * to like it if we muck with the clock. If we disable the clock when 477 + * it is unused we get "max98090 i2c-193C9890:00: PLL unlocked" errors 478 + * and the PLL never seems to lock again. 479 + * So for these boards we enable it here once and leave it at that. 480 + */ 481 + if (drv->quirks & QUIRK_PMC_PLT_CLK_0) { 482 + ret_val = clk_prepare_enable(drv->mclk); 483 + if (ret_val < 0) { 484 + dev_err(&pdev->dev, "MCLK enable error: %d\n", ret_val); 485 + return ret_val; 486 + } 487 + } 488 + 482 489 ret_val = devm_snd_soc_register_card(&pdev->dev, &snd_soc_card_cht); 483 490 if (ret_val) { 484 491 dev_err(&pdev->dev, ··· 504 481 return ret_val; 505 482 } 506 483 484 + static int snd_cht_mc_remove(struct platform_device *pdev) 485 + { 486 + struct snd_soc_card *card = platform_get_drvdata(pdev); 487 + struct cht_mc_private *ctx = snd_soc_card_get_drvdata(card); 488 + 489 + if (ctx->quirks & QUIRK_PMC_PLT_CLK_0) 490 + clk_disable_unprepare(ctx->mclk); 491 + 492 + return 0; 493 + } 494 + 507 495 static struct platform_driver snd_cht_mc_driver = { 508 496 .driver = { 509 497 .name = "cht-bsw-max98090", 510 498 }, 511 499 .probe = snd_cht_mc_probe, 500 + .remove = snd_cht_mc_remove, 512 501 }; 513 502 514 503 module_platform_driver(snd_cht_mc_driver)
+1 -1
sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c
··· 405 405 }; 406 406 407 407 static const unsigned int dmic_2ch[] = { 408 - 4, 408 + 2, 409 409 }; 410 410 411 411 static const struct snd_pcm_hw_constraint_list constraints_dmic_2ch = {
+1
sound/soc/intel/skylake/skl-messages.c
··· 483 483 base_cfg->audio_fmt.bit_depth = format->bit_depth; 484 484 base_cfg->audio_fmt.valid_bit_depth = format->valid_bit_depth; 485 485 base_cfg->audio_fmt.ch_cfg = format->ch_cfg; 486 + base_cfg->audio_fmt.sample_type = format->sample_type; 486 487 487 488 dev_dbg(ctx->dev, "bit_depth=%x valid_bd=%x ch_config=%x\n", 488 489 format->bit_depth, format->valid_bit_depth,
+22 -6
sound/soc/intel/skylake/skl-pcm.c
··· 181 181 struct hdac_stream *hstream; 182 182 struct hdac_ext_stream *stream; 183 183 struct hdac_ext_link *link; 184 + unsigned char stream_tag; 184 185 185 186 hstream = snd_hdac_get_stream(bus, params->stream, 186 187 params->link_dma_id + 1); ··· 200 199 201 200 snd_hdac_ext_link_stream_setup(stream, format_val); 202 201 203 - list_for_each_entry(link, &bus->hlink_list, list) { 204 - if (link->index == params->link_index) 205 - snd_hdac_ext_link_set_stream_id(link, 206 - hstream->stream_tag); 202 + stream_tag = hstream->stream_tag; 203 + if (stream->hstream.direction == SNDRV_PCM_STREAM_PLAYBACK) { 204 + list_for_each_entry(link, &bus->hlink_list, list) { 205 + if (link->index == params->link_index) 206 + snd_hdac_ext_link_set_stream_id(link, 207 + stream_tag); 208 + } 207 209 } 208 210 209 211 stream->link_prepared = 1; ··· 649 645 struct hdac_ext_stream *link_dev = 650 646 snd_soc_dai_get_dma_data(dai, substream); 651 647 struct hdac_ext_link *link; 648 + unsigned char stream_tag; 652 649 653 650 dev_dbg(dai->dev, "%s: %s\n", __func__, dai->name); 654 651 ··· 659 654 if (!link) 660 655 return -EINVAL; 661 656 662 - snd_hdac_ext_link_clear_stream_id(link, hdac_stream(link_dev)->stream_tag); 657 + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { 658 + stream_tag = hdac_stream(link_dev)->stream_tag; 659 + snd_hdac_ext_link_clear_stream_id(link, stream_tag); 660 + } 661 + 663 662 snd_hdac_ext_stream_release(link_dev, HDAC_EXT_STREAM_TYPE_LINK); 664 663 return 0; 665 664 } ··· 1462 1453 return 0; 1463 1454 } 1464 1455 1456 + static void skl_pcm_remove(struct snd_soc_component *component) 1457 + { 1458 + /* remove topology */ 1459 + snd_soc_tplg_component_remove(component, SND_SOC_TPLG_INDEX_ALL); 1460 + } 1461 + 1465 1462 static const struct snd_soc_component_driver skl_component = { 1466 1463 .name = "pcm", 1467 1464 .probe = skl_platform_soc_probe, 1465 + .remove = skl_pcm_remove, 1468 1466 .ops = &skl_platform_ops, 1469 1467 .pcm_new = skl_pcm_new, 1470 1468 .pcm_free = skl_pcm_free, 1471 - .ignore_module_refcount = 1, /* do not increase the refcount in core */ 1469 + .module_get_upon_open = 1, /* increment refcount when a pcm is opened */ 1472 1470 }; 1473 1471 1474 1472 int skl_platform_register(struct device *dev)
+68 -1
sound/soc/mediatek/common/mtk-btcvsd.c
··· 49 49 BT_SCO_STATE_IDLE, 50 50 BT_SCO_STATE_RUNNING, 51 51 BT_SCO_STATE_ENDING, 52 + BT_SCO_STATE_LOOPBACK, 52 53 }; 53 54 54 55 enum bt_sco_direct { ··· 487 486 if (bt->rx->state != BT_SCO_STATE_RUNNING && 488 487 bt->rx->state != BT_SCO_STATE_ENDING && 489 488 bt->tx->state != BT_SCO_STATE_RUNNING && 490 - bt->tx->state != BT_SCO_STATE_ENDING) { 489 + bt->tx->state != BT_SCO_STATE_ENDING && 490 + bt->tx->state != BT_SCO_STATE_LOOPBACK) { 491 491 dev_warn(bt->dev, "%s(), in idle state: rx->state: %d, tx->state: %d\n", 492 492 __func__, bt->rx->state, bt->tx->state); 493 493 goto irq_handler_exit; ··· 513 511 packet_num = btsco_packet_info[packet_type][1]; 514 512 buf_cnt_tx = btsco_packet_info[packet_type][2]; 515 513 buf_cnt_rx = btsco_packet_info[packet_type][3]; 514 + 515 + if (bt->tx->state == BT_SCO_STATE_LOOPBACK) { 516 + u8 *src, *dst; 517 + unsigned long connsys_addr_rx, ap_addr_rx; 518 + unsigned long connsys_addr_tx, ap_addr_tx; 519 + 520 + connsys_addr_rx = *bt->bt_reg_pkt_r; 521 + ap_addr_rx = (unsigned long)bt->bt_sram_bank2_base + 522 + (connsys_addr_rx & 0xFFFF); 523 + 524 + connsys_addr_tx = *bt->bt_reg_pkt_w; 525 + ap_addr_tx = (unsigned long)bt->bt_sram_bank2_base + 526 + (connsys_addr_tx & 0xFFFF); 527 + 528 + if (connsys_addr_tx == 0xdeadfeed || 529 + connsys_addr_rx == 0xdeadfeed) { 530 + /* bt return 0xdeadfeed if read reg during bt sleep */ 531 + dev_warn(bt->dev, "%s(), connsys_addr_tx == 0xdeadfeed\n", 532 + __func__); 533 + goto irq_handler_exit; 534 + } 535 + 536 + src = (u8 *)ap_addr_rx; 537 + dst = (u8 *)ap_addr_tx; 538 + 539 + mtk_btcvsd_snd_data_transfer(BT_SCO_DIRECT_BT2ARM, src, 540 + bt->tx->temp_packet_buf, 541 + packet_length, 542 + packet_num); 543 + mtk_btcvsd_snd_data_transfer(BT_SCO_DIRECT_ARM2BT, 544 + bt->tx->temp_packet_buf, dst, 545 + packet_length, 546 + packet_num); 547 + bt->rx->rw_cnt++; 548 + bt->tx->rw_cnt++; 549 + } 516 550 517 551 if (bt->rx->state == BT_SCO_STATE_RUNNING || 518 552 bt->rx->state == BT_SCO_STATE_ENDING) { ··· 1105 1067 return 0; 1106 1068 } 1107 1069 1070 + static int btcvsd_loopback_get(struct snd_kcontrol *kcontrol, 1071 + struct snd_ctl_elem_value *ucontrol) 1072 + { 1073 + struct snd_soc_component *cmpnt = snd_soc_kcontrol_component(kcontrol); 1074 + struct mtk_btcvsd_snd *bt = snd_soc_component_get_drvdata(cmpnt); 1075 + bool lpbk_en = bt->tx->state == BT_SCO_STATE_LOOPBACK; 1076 + 1077 + ucontrol->value.integer.value[0] = lpbk_en; 1078 + return 0; 1079 + } 1080 + 1081 + static int btcvsd_loopback_set(struct snd_kcontrol *kcontrol, 1082 + struct snd_ctl_elem_value *ucontrol) 1083 + { 1084 + struct snd_soc_component *cmpnt = snd_soc_kcontrol_component(kcontrol); 1085 + struct mtk_btcvsd_snd *bt = snd_soc_component_get_drvdata(cmpnt); 1086 + 1087 + if (ucontrol->value.integer.value[0]) { 1088 + mtk_btcvsd_snd_set_state(bt, bt->tx, BT_SCO_STATE_LOOPBACK); 1089 + mtk_btcvsd_snd_set_state(bt, bt->rx, BT_SCO_STATE_LOOPBACK); 1090 + } else { 1091 + mtk_btcvsd_snd_set_state(bt, bt->tx, BT_SCO_STATE_RUNNING); 1092 + mtk_btcvsd_snd_set_state(bt, bt->rx, BT_SCO_STATE_RUNNING); 1093 + } 1094 + return 0; 1095 + } 1096 + 1108 1097 static int btcvsd_tx_mute_get(struct snd_kcontrol *kcontrol, 1109 1098 struct snd_ctl_elem_value *ucontrol) 1110 1099 { ··· 1267 1202 static const struct snd_kcontrol_new mtk_btcvsd_snd_controls[] = { 1268 1203 SOC_ENUM_EXT("BTCVSD Band", btcvsd_enum[0], 1269 1204 btcvsd_band_get, btcvsd_band_set), 1205 + SOC_SINGLE_BOOL_EXT("BTCVSD Loopback Switch", 0, 1206 + btcvsd_loopback_get, btcvsd_loopback_set), 1270 1207 SOC_SINGLE_BOOL_EXT("BTCVSD Tx Mute Switch", 0, 1271 1208 btcvsd_tx_mute_get, btcvsd_tx_mute_set), 1272 1209 SOC_SINGLE_BOOL_EXT("BTCVSD Tx Irq Received Switch", 0,
+4
sound/soc/mediatek/mt8183/mt8183-afe-clk.c
··· 605 605 int m_sel_id = mck_div[mck_id].m_sel_id; 606 606 int div_clk_id = mck_div[mck_id].div_clk_id; 607 607 608 + /* i2s5 mck not support */ 609 + if (mck_id == MT8183_I2S5_MCK) 610 + return; 611 + 608 612 clk_disable_unprepare(afe_priv->clk[div_clk_id]); 609 613 if (m_sel_id >= 0) 610 614 clk_disable_unprepare(afe_priv->clk[m_sel_id]);
+3 -1
sound/soc/rockchip/rockchip_pdm.c
··· 24 24 25 25 #include "rockchip_pdm.h" 26 26 27 - #define PDM_DMA_BURST_SIZE (16) /* size * width: 16*4 = 64 bytes */ 27 + #define PDM_DMA_BURST_SIZE (8) /* size * width: 8*4 = 32 bytes */ 28 28 29 29 struct rk_pdm_dev { 30 30 struct device *dev; ··· 208 208 return -EINVAL; 209 209 } 210 210 211 + pm_runtime_get_sync(cpu_dai->dev); 211 212 regmap_update_bits(pdm->regmap, PDM_CLK_CTRL, mask, val); 213 + pm_runtime_put(cpu_dai->dev); 212 214 213 215 return 0; 214 216 }
+6 -4
sound/soc/samsung/i2s.c
··· 1130 1130 }; 1131 1131 1132 1132 static const struct snd_soc_dapm_route samsung_i2s_dapm_routes[] = { 1133 - { "Playback Mixer", NULL, "Primary" }, 1134 - { "Playback Mixer", NULL, "Secondary" }, 1133 + { "Playback Mixer", NULL, "Primary Playback" }, 1134 + { "Playback Mixer", NULL, "Secondary Playback" }, 1135 1135 1136 1136 { "Mixer DAI TX", NULL, "Playback Mixer" }, 1137 - { "Playback Mixer", NULL, "Mixer DAI RX" }, 1137 + { "Primary Capture", NULL, "Mixer DAI RX" }, 1138 1138 }; 1139 1139 1140 1140 static const struct snd_soc_component_driver samsung_i2s_component = { ··· 1155 1155 int num_dais) 1156 1156 { 1157 1157 static const char *dai_names[] = { "samsung-i2s", "samsung-i2s-sec" }; 1158 - static const char *stream_names[] = { "Primary", "Secondary" }; 1158 + static const char *stream_names[] = { "Primary Playback", 1159 + "Secondary Playback" }; 1159 1160 struct snd_soc_dai_driver *dai_drv; 1160 1161 struct i2s_dai *dai; 1161 1162 int i; ··· 1202 1201 dai_drv->capture.channels_max = 2; 1203 1202 dai_drv->capture.rates = i2s_dai_data->pcm_rates; 1204 1203 dai_drv->capture.formats = SAMSUNG_I2S_FMTS; 1204 + dai_drv->capture.stream_name = "Primary Capture"; 1205 1205 1206 1206 return 0; 1207 1207 }
+2 -2
sound/soc/samsung/odroid.c
··· 91 91 return ret; 92 92 93 93 /* 94 - * We add 1 to the rclk_freq value in order to avoid too low clock 94 + * We add 2 to the rclk_freq value in order to avoid too low clock 95 95 * frequency values due to the EPLL output frequency not being exact 96 96 * multiple of the audio sampling rate. 97 97 */ 98 - rclk_freq = params_rate(params) * rfs + 1; 98 + rclk_freq = params_rate(params) * rfs + 2; 99 99 100 100 ret = clk_set_rate(priv->sclk_i2s, rclk_freq); 101 101 if (ret < 0)
+2
sound/soc/sh/rcar/core.c
··· 110 110 { .compatible = "renesas,rcar_sound-gen1", .data = (void *)RSND_GEN1 }, 111 111 { .compatible = "renesas,rcar_sound-gen2", .data = (void *)RSND_GEN2 }, 112 112 { .compatible = "renesas,rcar_sound-gen3", .data = (void *)RSND_GEN3 }, 113 + /* Special Handling */ 114 + { .compatible = "renesas,rcar_sound-r8a77990", .data = (void *)(RSND_GEN3 | RSND_SOC_E) }, 113 115 {}, 114 116 }; 115 117 MODULE_DEVICE_TABLE(of, rsnd_of_match);
+5
sound/soc/sh/rcar/rsnd.h
··· 607 607 #define RSND_GEN1 (1 << 0) 608 608 #define RSND_GEN2 (2 << 0) 609 609 #define RSND_GEN3 (3 << 0) 610 + #define RSND_SOC_MASK (0xFF << 4) 611 + #define RSND_SOC_E (1 << 4) /* E1/E2/E3 */ 610 612 611 613 /* 612 614 * below value will be filled on rsnd_gen_probe() ··· 681 679 #define rsnd_is_gen1(priv) (((priv)->flags & RSND_GEN_MASK) == RSND_GEN1) 682 680 #define rsnd_is_gen2(priv) (((priv)->flags & RSND_GEN_MASK) == RSND_GEN2) 683 681 #define rsnd_is_gen3(priv) (((priv)->flags & RSND_GEN_MASK) == RSND_GEN3) 682 + #define rsnd_is_e3(priv) (((priv)->flags & \ 683 + (RSND_GEN_MASK | RSND_SOC_MASK)) == \ 684 + (RSND_GEN3 | RSND_SOC_E)) 684 685 685 686 #define rsnd_flags_has(p, f) ((p)->flags & (f)) 686 687 #define rsnd_flags_set(p, f) ((p)->flags |= (f))
+7 -14
sound/soc/sh/rcar/src.c
··· 14 14 */ 15 15 16 16 #include "rsnd.h" 17 - #include <linux/sys_soc.h> 18 17 19 18 #define SRC_NAME "src" 20 19 ··· 134 135 return rate; 135 136 } 136 137 137 - const static u32 bsdsr_table_pattern1[] = { 138 + static const u32 bsdsr_table_pattern1[] = { 138 139 0x01800000, /* 6 - 1/6 */ 139 140 0x01000000, /* 6 - 1/4 */ 140 141 0x00c00000, /* 6 - 1/3 */ ··· 143 144 0x00400000, /* 6 - 1 */ 144 145 }; 145 146 146 - const static u32 bsdsr_table_pattern2[] = { 147 + static const u32 bsdsr_table_pattern2[] = { 147 148 0x02400000, /* 6 - 1/6 */ 148 149 0x01800000, /* 6 - 1/4 */ 149 150 0x01200000, /* 6 - 1/3 */ ··· 152 153 0x00600000, /* 6 - 1 */ 153 154 }; 154 155 155 - const static u32 bsisr_table[] = { 156 + static const u32 bsisr_table[] = { 156 157 0x00100060, /* 6 - 1/6 */ 157 158 0x00100040, /* 6 - 1/4 */ 158 159 0x00100030, /* 6 - 1/3 */ ··· 161 162 0x00100020, /* 6 - 1 */ 162 163 }; 163 164 164 - const static u32 chan288888[] = { 165 + static const u32 chan288888[] = { 165 166 0x00000006, /* 1 to 2 */ 166 167 0x000001fe, /* 1 to 8 */ 167 168 0x000001fe, /* 1 to 8 */ ··· 170 171 0x000001fe, /* 1 to 8 */ 171 172 }; 172 173 173 - const static u32 chan244888[] = { 174 + static const u32 chan244888[] = { 174 175 0x00000006, /* 1 to 2 */ 175 176 0x0000001e, /* 1 to 4 */ 176 177 0x0000001e, /* 1 to 4 */ ··· 179 180 0x000001fe, /* 1 to 8 */ 180 181 }; 181 182 182 - const static u32 chan222222[] = { 183 + static const u32 chan222222[] = { 183 184 0x00000006, /* 1 to 2 */ 184 185 0x00000006, /* 1 to 2 */ 185 186 0x00000006, /* 1 to 2 */ 186 187 0x00000006, /* 1 to 2 */ 187 188 0x00000006, /* 1 to 2 */ 188 189 0x00000006, /* 1 to 2 */ 189 - }; 190 - 191 - static const struct soc_device_attribute ov_soc[] = { 192 - { .soc_id = "r8a77990" }, /* E3 */ 193 - { /* sentinel */ } 194 190 }; 195 191 196 192 static void rsnd_src_set_convert_rate(struct rsnd_dai_stream *io, ··· 194 200 struct rsnd_priv *priv = rsnd_mod_to_priv(mod); 195 201 struct device *dev = rsnd_priv_to_dev(priv); 196 202 struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io); 197 - const struct soc_device_attribute *soc = soc_device_match(ov_soc); 198 203 int is_play = rsnd_io_is_play(io); 199 204 int use_src = 0; 200 205 u32 fin, fout; ··· 300 307 /* 301 308 * E3 need to overwrite 302 309 */ 303 - if (soc) 310 + if (rsnd_is_e3(priv)) 304 311 switch (rsnd_mod_id(mod)) { 305 312 case 0: 306 313 case 4:
+4 -2
sound/soc/soc-core.c
··· 947 947 snd_soc_dapm_free(snd_soc_component_get_dapm(component)); 948 948 soc_cleanup_component_debugfs(component); 949 949 component->card = NULL; 950 - if (!component->driver->ignore_module_refcount) 950 + if (!component->driver->module_get_upon_open) 951 951 module_put(component->dev->driver->owner); 952 952 } 953 953 ··· 1381 1381 return 0; 1382 1382 } 1383 1383 1384 - if (!component->driver->ignore_module_refcount && 1384 + if (!component->driver->module_get_upon_open && 1385 1385 !try_module_get(component->dev->driver->owner)) 1386 1386 return -ENODEV; 1387 1387 ··· 2797 2797 2798 2798 ret = soc_init_dai_link(card, link); 2799 2799 if (ret) { 2800 + soc_cleanup_platform(card); 2800 2801 dev_err(card->dev, "ASoC: failed to init link %s\n", 2801 2802 link->name); 2802 2803 mutex_unlock(&client_mutex); ··· 2820 2819 card->instantiated = 0; 2821 2820 mutex_init(&card->mutex); 2822 2821 mutex_init(&card->dapm_mutex); 2822 + spin_lock_init(&card->dpcm_lock); 2823 2823 2824 2824 return snd_soc_bind_card(card); 2825 2825 }
+11
sound/soc/soc-dapm.c
··· 3650 3650 case snd_soc_dapm_dac: 3651 3651 case snd_soc_dapm_aif_in: 3652 3652 case snd_soc_dapm_pga: 3653 + case snd_soc_dapm_buffer: 3654 + case snd_soc_dapm_scheduler: 3655 + case snd_soc_dapm_effect: 3656 + case snd_soc_dapm_src: 3657 + case snd_soc_dapm_asrc: 3658 + case snd_soc_dapm_encoder: 3659 + case snd_soc_dapm_decoder: 3653 3660 case snd_soc_dapm_out_drv: 3654 3661 case snd_soc_dapm_micbias: 3655 3662 case snd_soc_dapm_line: ··· 3964 3957 int count; 3965 3958 3966 3959 devm_kfree(card->dev, (void *)*private_value); 3960 + 3961 + if (!w_param_text) 3962 + return; 3963 + 3967 3964 for (count = 0 ; count < num_params; count++) 3968 3965 devm_kfree(card->dev, (void *)w_param_text[count]); 3969 3966 devm_kfree(card->dev, w_param_text);
+55 -11
sound/soc/soc-pcm.c
··· 15 15 #include <linux/delay.h> 16 16 #include <linux/pinctrl/consumer.h> 17 17 #include <linux/pm_runtime.h> 18 + #include <linux/module.h> 18 19 #include <linux/slab.h> 19 20 #include <linux/workqueue.h> 20 21 #include <linux/export.h> ··· 464 463 continue; 465 464 466 465 component->driver->ops->close(substream); 466 + 467 + if (component->driver->module_get_upon_open) 468 + module_put(component->dev->driver->owner); 467 469 } 468 470 469 471 return 0; ··· 516 512 if (!component->driver->ops || 517 513 !component->driver->ops->open) 518 514 continue; 515 + 516 + if (component->driver->module_get_upon_open && 517 + !try_module_get(component->dev->driver->owner)) { 518 + ret = -ENODEV; 519 + goto module_err; 520 + } 519 521 520 522 ret = component->driver->ops->open(substream); 521 523 if (ret < 0) { ··· 638 628 639 629 component_err: 640 630 soc_pcm_components_close(substream, component); 641 - 631 + module_err: 642 632 if (cpu_dai->driver->ops->shutdown) 643 633 cpu_dai->driver->ops->shutdown(substream, cpu_dai); 644 634 out: ··· 964 954 codec_params = *params; 965 955 966 956 /* fixup params based on TDM slot masks */ 967 - if (codec_dai->tx_mask) 957 + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && 958 + codec_dai->tx_mask) 968 959 soc_pcm_codec_params_fixup(&codec_params, 969 960 codec_dai->tx_mask); 970 - if (codec_dai->rx_mask) 961 + 962 + if (substream->stream == SNDRV_PCM_STREAM_CAPTURE && 963 + codec_dai->rx_mask) 971 964 soc_pcm_codec_params_fixup(&codec_params, 972 965 codec_dai->rx_mask); 973 966 ··· 1226 1213 struct snd_soc_pcm_runtime *be, int stream) 1227 1214 { 1228 1215 struct snd_soc_dpcm *dpcm; 1216 + unsigned long flags; 1229 1217 1230 1218 /* only add new dpcms */ 1231 1219 for_each_dpcm_be(fe, stream, dpcm) { ··· 1242 1228 dpcm->fe = fe; 1243 1229 be->dpcm[stream].runtime = fe->dpcm[stream].runtime; 1244 1230 dpcm->state = SND_SOC_DPCM_LINK_STATE_NEW; 1231 + spin_lock_irqsave(&fe->card->dpcm_lock, flags); 1245 1232 list_add(&dpcm->list_be, &fe->dpcm[stream].be_clients); 1246 1233 list_add(&dpcm->list_fe, &be->dpcm[stream].fe_clients); 1234 + spin_unlock_irqrestore(&fe->card->dpcm_lock, flags); 1247 1235 1248 1236 dev_dbg(fe->dev, "connected new DPCM %s path %s %s %s\n", 1249 1237 stream ? "capture" : "playback", fe->dai_link->name, ··· 1291 1275 void dpcm_be_disconnect(struct snd_soc_pcm_runtime *fe, int stream) 1292 1276 { 1293 1277 struct snd_soc_dpcm *dpcm, *d; 1278 + unsigned long flags; 1294 1279 1295 1280 for_each_dpcm_be_safe(fe, stream, dpcm, d) { 1296 1281 dev_dbg(fe->dev, "ASoC: BE %s disconnect check for %s\n", ··· 1311 1294 #ifdef CONFIG_DEBUG_FS 1312 1295 debugfs_remove(dpcm->debugfs_state); 1313 1296 #endif 1297 + spin_lock_irqsave(&fe->card->dpcm_lock, flags); 1314 1298 list_del(&dpcm->list_be); 1315 1299 list_del(&dpcm->list_fe); 1300 + spin_unlock_irqrestore(&fe->card->dpcm_lock, flags); 1316 1301 kfree(dpcm); 1317 1302 } 1318 1303 } ··· 1566 1547 void dpcm_clear_pending_state(struct snd_soc_pcm_runtime *fe, int stream) 1567 1548 { 1568 1549 struct snd_soc_dpcm *dpcm; 1550 + unsigned long flags; 1569 1551 1552 + spin_lock_irqsave(&fe->card->dpcm_lock, flags); 1570 1553 for_each_dpcm_be(fe, stream, dpcm) 1571 1554 dpcm->be->dpcm[stream].runtime_update = 1572 1555 SND_SOC_DPCM_UPDATE_NO; 1556 + spin_unlock_irqrestore(&fe->card->dpcm_lock, flags); 1573 1557 } 1574 1558 1575 1559 static void dpcm_be_dai_startup_unwind(struct snd_soc_pcm_runtime *fe, ··· 1921 1899 struct snd_soc_pcm_runtime *be = dpcm->be; 1922 1900 struct snd_pcm_substream *be_substream = 1923 1901 snd_soc_dpcm_get_substream(be, stream); 1924 - struct snd_soc_pcm_runtime *rtd = be_substream->private_data; 1902 + struct snd_soc_pcm_runtime *rtd; 1925 1903 struct snd_soc_dai *codec_dai; 1926 1904 int i; 1927 1905 1906 + /* A backend may not have the requested substream */ 1907 + if (!be_substream) 1908 + continue; 1909 + 1910 + rtd = be_substream->private_data; 1928 1911 if (rtd->dai_link->be_hw_params_fixup) 1929 1912 continue; 1930 1913 ··· 2598 2571 struct snd_soc_dpcm *dpcm; 2599 2572 enum snd_soc_dpcm_trigger trigger = fe->dai_link->trigger[stream]; 2600 2573 int ret; 2574 + unsigned long flags; 2601 2575 2602 2576 dev_dbg(fe->dev, "ASoC: runtime %s open on FE %s\n", 2603 2577 stream ? "capture" : "playback", fe->dai_link->name); ··· 2668 2640 dpcm_be_dai_shutdown(fe, stream); 2669 2641 disconnect: 2670 2642 /* disconnect any non started BEs */ 2643 + spin_lock_irqsave(&fe->card->dpcm_lock, flags); 2671 2644 for_each_dpcm_be(fe, stream, dpcm) { 2672 2645 struct snd_soc_pcm_runtime *be = dpcm->be; 2673 2646 if (be->dpcm[stream].state != SND_SOC_DPCM_STATE_START) 2674 2647 dpcm->state = SND_SOC_DPCM_LINK_STATE_FREE; 2675 2648 } 2649 + spin_unlock_irqrestore(&fe->card->dpcm_lock, flags); 2676 2650 2677 2651 return ret; 2678 2652 } ··· 3251 3221 { 3252 3222 struct snd_soc_dpcm *dpcm; 3253 3223 int state; 3224 + int ret = 1; 3225 + unsigned long flags; 3254 3226 3227 + spin_lock_irqsave(&fe->card->dpcm_lock, flags); 3255 3228 for_each_dpcm_fe(be, stream, dpcm) { 3256 3229 3257 3230 if (dpcm->fe == fe) ··· 3263 3230 state = dpcm->fe->dpcm[stream].state; 3264 3231 if (state == SND_SOC_DPCM_STATE_START || 3265 3232 state == SND_SOC_DPCM_STATE_PAUSED || 3266 - state == SND_SOC_DPCM_STATE_SUSPEND) 3267 - return 0; 3233 + state == SND_SOC_DPCM_STATE_SUSPEND) { 3234 + ret = 0; 3235 + break; 3236 + } 3268 3237 } 3238 + spin_unlock_irqrestore(&fe->card->dpcm_lock, flags); 3269 3239 3270 3240 /* it's safe to free/stop this BE DAI */ 3271 - return 1; 3241 + return ret; 3272 3242 } 3273 3243 EXPORT_SYMBOL_GPL(snd_soc_dpcm_can_be_free_stop); 3274 3244 ··· 3284 3248 { 3285 3249 struct snd_soc_dpcm *dpcm; 3286 3250 int state; 3251 + int ret = 1; 3252 + unsigned long flags; 3287 3253 3254 + spin_lock_irqsave(&fe->card->dpcm_lock, flags); 3288 3255 for_each_dpcm_fe(be, stream, dpcm) { 3289 3256 3290 3257 if (dpcm->fe == fe) ··· 3297 3258 if (state == SND_SOC_DPCM_STATE_START || 3298 3259 state == SND_SOC_DPCM_STATE_PAUSED || 3299 3260 state == SND_SOC_DPCM_STATE_SUSPEND || 3300 - state == SND_SOC_DPCM_STATE_PREPARE) 3301 - return 0; 3261 + state == SND_SOC_DPCM_STATE_PREPARE) { 3262 + ret = 0; 3263 + break; 3264 + } 3302 3265 } 3266 + spin_unlock_irqrestore(&fe->card->dpcm_lock, flags); 3303 3267 3304 3268 /* it's safe to change hw_params */ 3305 - return 1; 3269 + return ret; 3306 3270 } 3307 3271 EXPORT_SYMBOL_GPL(snd_soc_dpcm_can_be_params); 3308 3272 ··· 3344 3302 struct snd_pcm_hw_params *params = &fe->dpcm[stream].hw_params; 3345 3303 struct snd_soc_dpcm *dpcm; 3346 3304 ssize_t offset = 0; 3305 + unsigned long flags; 3347 3306 3348 3307 /* FE state */ 3349 3308 offset += snprintf(buf + offset, size - offset, ··· 3372 3329 goto out; 3373 3330 } 3374 3331 3332 + spin_lock_irqsave(&fe->card->dpcm_lock, flags); 3375 3333 for_each_dpcm_be(fe, stream, dpcm) { 3376 3334 struct snd_soc_pcm_runtime *be = dpcm->be; 3377 3335 params = &dpcm->hw_params; ··· 3393 3349 params_channels(params), 3394 3350 params_rate(params)); 3395 3351 } 3396 - 3352 + spin_unlock_irqrestore(&fe->card->dpcm_lock, flags); 3397 3353 out: 3398 3354 return offset; 3399 3355 }
+4 -3
sound/soc/soc-topology.c
··· 482 482 483 483 snd_ctl_remove(card, kcontrol); 484 484 485 - kfree(dobj->control.dvalues); 485 + /* free enum kcontrol's dvalues and dtexts */ 486 + kfree(se->dobj.control.dvalues); 486 487 for (j = 0; j < se->items; j++) 487 - kfree(dobj->control.dtexts[j]); 488 - kfree(dobj->control.dtexts); 488 + kfree(se->dobj.control.dtexts[j]); 489 + kfree(se->dobj.control.dtexts); 489 490 490 491 kfree(se); 491 492 kfree(w->kcontrol_news[i].name);
+34 -4
sound/soc/stm/stm32_adfsdm.c
··· 9 9 10 10 #include <linux/clk.h> 11 11 #include <linux/module.h> 12 + #include <linux/mutex.h> 12 13 #include <linux/platform_device.h> 13 14 #include <linux/slab.h> 14 15 ··· 38 37 /* PCM buffer */ 39 38 unsigned char *pcm_buff; 40 39 unsigned int pos; 40 + 41 + struct mutex lock; /* protect against race condition on iio state */ 41 42 }; 42 43 43 44 static const struct snd_pcm_hardware stm32_adfsdm_pcm_hw = { ··· 65 62 { 66 63 struct stm32_adfsdm_priv *priv = snd_soc_dai_get_drvdata(dai); 67 64 65 + mutex_lock(&priv->lock); 68 66 if (priv->iio_active) { 69 67 iio_channel_stop_all_cb(priv->iio_cb); 70 68 priv->iio_active = false; 71 69 } 70 + mutex_unlock(&priv->lock); 72 71 } 73 72 74 73 static int stm32_adfsdm_dai_prepare(struct snd_pcm_substream *substream, ··· 79 74 struct stm32_adfsdm_priv *priv = snd_soc_dai_get_drvdata(dai); 80 75 int ret; 81 76 77 + mutex_lock(&priv->lock); 78 + if (priv->iio_active) { 79 + iio_channel_stop_all_cb(priv->iio_cb); 80 + priv->iio_active = false; 81 + } 82 + 82 83 ret = iio_write_channel_attribute(priv->iio_ch, 83 84 substream->runtime->rate, 0, 84 85 IIO_CHAN_INFO_SAMP_FREQ); 85 86 if (ret < 0) { 86 87 dev_err(dai->dev, "%s: Failed to set %d sampling rate\n", 87 88 __func__, substream->runtime->rate); 88 - return ret; 89 + goto out; 89 90 } 90 91 91 92 if (!priv->iio_active) { ··· 102 91 dev_err(dai->dev, "%s: IIO channel start failed (%d)\n", 103 92 __func__, ret); 104 93 } 94 + 95 + out: 96 + mutex_unlock(&priv->lock); 105 97 106 98 return ret; 107 99 } ··· 305 291 static int stm32_adfsdm_probe(struct platform_device *pdev) 306 292 { 307 293 struct stm32_adfsdm_priv *priv; 294 + struct snd_soc_component *component; 308 295 int ret; 309 296 310 297 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); ··· 314 299 315 300 priv->dev = &pdev->dev; 316 301 priv->dai_drv = stm32_adfsdm_dai; 302 + mutex_init(&priv->lock); 317 303 318 304 dev_set_drvdata(&pdev->dev, priv); 319 305 ··· 333 317 if (IS_ERR(priv->iio_cb)) 334 318 return PTR_ERR(priv->iio_cb); 335 319 336 - ret = devm_snd_soc_register_component(&pdev->dev, 337 - &stm32_adfsdm_soc_platform, 338 - NULL, 0); 320 + component = devm_kzalloc(&pdev->dev, sizeof(*component), GFP_KERNEL); 321 + if (!component) 322 + return -ENOMEM; 323 + #ifdef CONFIG_DEBUG_FS 324 + component->debugfs_prefix = "pcm"; 325 + #endif 326 + 327 + ret = snd_soc_add_component(&pdev->dev, component, 328 + &stm32_adfsdm_soc_platform, NULL, 0); 339 329 if (ret < 0) 340 330 dev_err(&pdev->dev, "%s: Failed to register PCM platform\n", 341 331 __func__); 342 332 343 333 return ret; 334 + } 335 + 336 + static int stm32_adfsdm_remove(struct platform_device *pdev) 337 + { 338 + snd_soc_unregister_component(&pdev->dev); 339 + 340 + return 0; 344 341 } 345 342 346 343 static struct platform_driver stm32_adfsdm_driver = { ··· 362 333 .of_match_table = stm32_adfsdm_of_match, 363 334 }, 364 335 .probe = stm32_adfsdm_probe, 336 + .remove = stm32_adfsdm_remove, 365 337 }; 366 338 367 339 module_platform_driver(stm32_adfsdm_driver);
+1 -2
sound/soc/stm/stm32_i2s.c
··· 281 281 case STM32_I2S_CFG2_REG: 282 282 case STM32_I2S_IER_REG: 283 283 case STM32_I2S_SR_REG: 284 - case STM32_I2S_TXDR_REG: 285 284 case STM32_I2S_RXDR_REG: 286 285 case STM32_I2S_CGFR_REG: 287 286 return true; ··· 292 293 static bool stm32_i2s_volatile_reg(struct device *dev, unsigned int reg) 293 294 { 294 295 switch (reg) { 295 - case STM32_I2S_TXDR_REG: 296 + case STM32_I2S_SR_REG: 296 297 case STM32_I2S_RXDR_REG: 297 298 return true; 298 299 default:
+5 -3
sound/soc/stm/stm32_sai.c
··· 105 105 if (!pdev) { 106 106 dev_err(&sai_client->pdev->dev, 107 107 "Device not found for node %pOFn\n", np_provider); 108 + of_node_put(np_provider); 108 109 return -ENODEV; 109 110 } 110 111 ··· 114 113 dev_err(&sai_client->pdev->dev, 115 114 "SAI sync provider data not found\n"); 116 115 ret = -EINVAL; 117 - goto out_put_dev; 116 + goto error; 118 117 } 119 118 120 119 /* Configure sync client */ 121 120 ret = stm32_sai_sync_conf_client(sai_client, synci); 122 121 if (ret < 0) 123 - goto out_put_dev; 122 + goto error; 124 123 125 124 /* Configure sync provider */ 126 125 ret = stm32_sai_sync_conf_provider(sai_provider, synco); 127 126 128 - out_put_dev: 127 + error: 129 128 put_device(&pdev->dev); 129 + of_node_put(np_provider); 130 130 return ret; 131 131 } 132 132
+86 -28
sound/soc/stm/stm32_sai_sub.c
··· 70 70 #define SAI_IEC60958_STATUS_BYTES 24 71 71 72 72 #define SAI_MCLK_NAME_LEN 32 73 + #define SAI_RATE_11K 11025 73 74 74 75 /** 75 76 * struct stm32_sai_sub_data - private data of SAI sub block (block A or B) ··· 101 100 * @slot_mask: rx or tx active slots mask. set at init or at runtime 102 101 * @data_size: PCM data width. corresponds to PCM substream width. 103 102 * @spdif_frm_cnt: S/PDIF playback frame counter 104 - * @snd_aes_iec958: iec958 data 103 + * @iec958: iec958 data 105 104 * @ctrl_lock: control lock 105 + * @irq_lock: prevent race condition with IRQ 106 106 */ 107 107 struct stm32_sai_sub_data { 108 108 struct platform_device *pdev; ··· 135 133 unsigned int spdif_frm_cnt; 136 134 struct snd_aes_iec958 iec958; 137 135 struct mutex ctrl_lock; /* protect resources accessed by controls */ 136 + spinlock_t irq_lock; /* used to prevent race condition with IRQ */ 138 137 }; 139 138 140 139 enum stm32_sai_fifo_th { ··· 310 307 return ret; 311 308 } 312 309 310 + static int stm32_sai_set_parent_clock(struct stm32_sai_sub_data *sai, 311 + unsigned int rate) 312 + { 313 + struct platform_device *pdev = sai->pdev; 314 + struct clk *parent_clk = sai->pdata->clk_x8k; 315 + int ret; 316 + 317 + if (!(rate % SAI_RATE_11K)) 318 + parent_clk = sai->pdata->clk_x11k; 319 + 320 + ret = clk_set_parent(sai->sai_ck, parent_clk); 321 + if (ret) 322 + dev_err(&pdev->dev, " Error %d setting sai_ck parent clock. %s", 323 + ret, ret == -EBUSY ? 324 + "Active stream rates conflict\n" : "\n"); 325 + 326 + return ret; 327 + } 328 + 313 329 static long stm32_sai_mclk_round_rate(struct clk_hw *hw, unsigned long rate, 314 330 unsigned long *prate) 315 331 { ··· 496 474 status = SNDRV_PCM_STATE_XRUN; 497 475 } 498 476 499 - if (status != SNDRV_PCM_STATE_RUNNING) 477 + spin_lock(&sai->irq_lock); 478 + if (status != SNDRV_PCM_STATE_RUNNING && sai->substream) 500 479 snd_pcm_stop_xrun(sai->substream); 480 + spin_unlock(&sai->irq_lock); 501 481 502 482 return IRQ_HANDLED; 503 483 } ··· 510 486 struct stm32_sai_sub_data *sai = snd_soc_dai_get_drvdata(cpu_dai); 511 487 int ret; 512 488 513 - if (dir == SND_SOC_CLOCK_OUT) { 489 + if (dir == SND_SOC_CLOCK_OUT && sai->sai_mclk) { 514 490 ret = regmap_update_bits(sai->regmap, STM_SAI_CR1_REGX, 515 491 SAI_XCR1_NODIV, 516 492 (unsigned int)~SAI_XCR1_NODIV); 517 493 if (ret < 0) 518 494 return ret; 519 495 496 + /* If master clock is used, set parent clock now */ 497 + ret = stm32_sai_set_parent_clock(sai, freq); 498 + if (ret) 499 + return ret; 500 + 501 + ret = clk_set_rate_exclusive(sai->sai_mclk, freq); 502 + if (ret) { 503 + dev_err(cpu_dai->dev, 504 + ret == -EBUSY ? 505 + "Active streams have incompatible rates" : 506 + "Could not set mclk rate\n"); 507 + return ret; 508 + } 509 + 520 510 dev_dbg(cpu_dai->dev, "SAI MCLK frequency is %uHz\n", freq); 521 511 sai->mclk_rate = freq; 522 - 523 - if (sai->sai_mclk) { 524 - ret = clk_set_rate_exclusive(sai->sai_mclk, 525 - sai->mclk_rate); 526 - if (ret) { 527 - dev_err(cpu_dai->dev, 528 - "Could not set mclk rate\n"); 529 - return ret; 530 - } 531 - } 532 512 } 533 513 534 514 return 0; ··· 707 679 { 708 680 struct stm32_sai_sub_data *sai = snd_soc_dai_get_drvdata(cpu_dai); 709 681 int imr, cr2, ret; 682 + unsigned long flags; 710 683 684 + spin_lock_irqsave(&sai->irq_lock, flags); 711 685 sai->substream = substream; 686 + spin_unlock_irqrestore(&sai->irq_lock, flags); 687 + 688 + if (STM_SAI_PROTOCOL_IS_SPDIF(sai)) { 689 + snd_pcm_hw_constraint_mask64(substream->runtime, 690 + SNDRV_PCM_HW_PARAM_FORMAT, 691 + SNDRV_PCM_FMTBIT_S32_LE); 692 + snd_pcm_hw_constraint_single(substream->runtime, 693 + SNDRV_PCM_HW_PARAM_CHANNELS, 2); 694 + } 712 695 713 696 ret = clk_prepare_enable(sai->sai_ck); 714 697 if (ret < 0) { ··· 937 898 struct snd_pcm_hw_params *params) 938 899 { 939 900 struct stm32_sai_sub_data *sai = snd_soc_dai_get_drvdata(cpu_dai); 940 - int div = 0; 901 + int div = 0, cr1 = 0; 941 902 int sai_clk_rate, mclk_ratio, den; 942 903 unsigned int rate = params_rate(params); 904 + int ret; 943 905 944 - if (!(rate % 11025)) 945 - clk_set_parent(sai->sai_ck, sai->pdata->clk_x11k); 946 - else 947 - clk_set_parent(sai->sai_ck, sai->pdata->clk_x8k); 906 + if (!sai->sai_mclk) { 907 + ret = stm32_sai_set_parent_clock(sai, rate); 908 + if (ret) 909 + return ret; 910 + } 948 911 sai_clk_rate = clk_get_rate(sai->sai_ck); 949 912 950 913 if (STM_SAI_IS_F4(sai->pdata)) { ··· 984 943 } else { 985 944 if (sai->mclk_rate) { 986 945 mclk_ratio = sai->mclk_rate / rate; 987 - if ((mclk_ratio != 512) && 988 - (mclk_ratio != 256)) { 946 + if (mclk_ratio == 512) { 947 + cr1 = SAI_XCR1_OSR; 948 + } else if (mclk_ratio != 256) { 989 949 dev_err(cpu_dai->dev, 990 950 "Wrong mclk ratio %d\n", 991 951 mclk_ratio); 992 952 return -EINVAL; 993 953 } 954 + 955 + regmap_update_bits(sai->regmap, 956 + STM_SAI_CR1_REGX, 957 + SAI_XCR1_OSR, cr1); 958 + 994 959 div = stm32_sai_get_clk_div(sai, sai_clk_rate, 995 960 sai->mclk_rate); 996 961 if (div < 0) ··· 1098 1051 struct snd_soc_dai *cpu_dai) 1099 1052 { 1100 1053 struct stm32_sai_sub_data *sai = snd_soc_dai_get_drvdata(cpu_dai); 1054 + unsigned long flags; 1101 1055 1102 1056 regmap_update_bits(sai->regmap, STM_SAI_IMR_REGX, SAI_XIMR_MASK, 0); 1103 1057 1104 1058 regmap_update_bits(sai->regmap, STM_SAI_CR1_REGX, SAI_XCR1_NODIV, 1105 1059 SAI_XCR1_NODIV); 1106 1060 1061 + /* Release mclk rate only if rate was actually set */ 1062 + if (sai->mclk_rate) { 1063 + clk_rate_exclusive_put(sai->sai_mclk); 1064 + sai->mclk_rate = 0; 1065 + } 1066 + 1107 1067 clk_disable_unprepare(sai->sai_ck); 1108 1068 1109 - clk_rate_exclusive_put(sai->sai_mclk); 1110 - 1069 + spin_lock_irqsave(&sai->irq_lock, flags); 1111 1070 sai->substream = NULL; 1071 + spin_unlock_irqrestore(&sai->irq_lock, flags); 1112 1072 } 1113 1073 1114 1074 static int stm32_sai_pcm_new(struct snd_soc_pcm_runtime *rtd, 1115 1075 struct snd_soc_dai *cpu_dai) 1116 1076 { 1117 1077 struct stm32_sai_sub_data *sai = dev_get_drvdata(cpu_dai->dev); 1078 + struct snd_kcontrol_new knew = iec958_ctls; 1118 1079 1119 1080 if (STM_SAI_PROTOCOL_IS_SPDIF(sai)) { 1120 1081 dev_dbg(&sai->pdev->dev, "%s: register iec controls", __func__); 1121 - return snd_ctl_add(rtd->pcm->card, 1122 - snd_ctl_new1(&iec958_ctls, sai)); 1082 + knew.device = rtd->pcm->device; 1083 + return snd_ctl_add(rtd->pcm->card, snd_ctl_new1(&knew, sai)); 1123 1084 } 1124 1085 1125 1086 return 0; ··· 1136 1081 static int stm32_sai_dai_probe(struct snd_soc_dai *cpu_dai) 1137 1082 { 1138 1083 struct stm32_sai_sub_data *sai = dev_get_drvdata(cpu_dai->dev); 1139 - int cr1 = 0, cr1_mask; 1084 + int cr1 = 0, cr1_mask, ret; 1140 1085 1141 1086 sai->cpu_dai = cpu_dai; 1142 1087 ··· 1166 1111 /* Configure synchronization */ 1167 1112 if (sai->sync == SAI_SYNC_EXTERNAL) { 1168 1113 /* Configure synchro client and provider */ 1169 - sai->pdata->set_sync(sai->pdata, sai->np_sync_provider, 1170 - sai->synco, sai->synci); 1114 + ret = sai->pdata->set_sync(sai->pdata, sai->np_sync_provider, 1115 + sai->synco, sai->synci); 1116 + if (ret) 1117 + return ret; 1171 1118 } 1172 1119 1173 1120 cr1_mask |= SAI_XCR1_SYNCEN_MASK; ··· 1449 1392 if (!sai->cpu_dai_drv) 1450 1393 return -ENOMEM; 1451 1394 1452 - sai->cpu_dai_drv->name = dev_name(&pdev->dev); 1453 1395 if (STM_SAI_IS_PLAYBACK(sai)) { 1454 1396 memcpy(sai->cpu_dai_drv, &stm32_sai_playback_dai, 1455 1397 sizeof(stm32_sai_playback_dai)); ··· 1458 1402 sizeof(stm32_sai_capture_dai)); 1459 1403 sai->cpu_dai_drv->capture.stream_name = sai->cpu_dai_drv->name; 1460 1404 } 1405 + sai->cpu_dai_drv->name = dev_name(&pdev->dev); 1461 1406 1462 1407 return 0; 1463 1408 } ··· 1481 1424 1482 1425 sai->pdev = pdev; 1483 1426 mutex_init(&sai->ctrl_lock); 1427 + spin_lock_init(&sai->irq_lock); 1484 1428 platform_set_drvdata(pdev, sai); 1485 1429 1486 1430 sai->pdata = dev_get_drvdata(pdev->dev.parent);
+1 -1
sound/xen/xen_snd_front_alsa.c
··· 441 441 { 442 442 int i; 443 443 444 - stream->buffer = alloc_pages_exact(stream->buffer_sz, GFP_KERNEL); 444 + stream->buffer = alloc_pages_exact(buffer_sz, GFP_KERNEL); 445 445 if (!stream->buffer) 446 446 return -ENOMEM; 447 447
+4 -28
tools/io_uring/io_uring-bench.c
··· 32 32 #include "liburing.h" 33 33 #include "barrier.h" 34 34 35 - #ifndef IOCQE_FLAG_CACHEHIT 36 - #define IOCQE_FLAG_CACHEHIT (1U << 0) 37 - #endif 38 - 39 35 #define min(a, b) ((a < b) ? (a) : (b)) 40 36 41 37 struct io_sq_ring { ··· 81 85 unsigned long reaps; 82 86 unsigned long done; 83 87 unsigned long calls; 84 - unsigned long cachehit, cachemiss; 85 88 volatile int finish; 86 89 87 90 __s32 *fds; ··· 265 270 return -1; 266 271 } 267 272 } 268 - if (cqe->flags & IOCQE_FLAG_CACHEHIT) 269 - s->cachehit++; 270 - else 271 - s->cachemiss++; 272 273 reaped++; 273 274 head++; 274 275 } while (1); ··· 480 489 int main(int argc, char *argv[]) 481 490 { 482 491 struct submitter *s = &submitters[0]; 483 - unsigned long done, calls, reap, cache_hit, cache_miss; 492 + unsigned long done, calls, reap; 484 493 int err, i, flags, fd; 485 494 char *fdepths; 486 495 void *ret; ··· 560 569 pthread_create(&s->thread, NULL, submitter_fn, s); 561 570 562 571 fdepths = malloc(8 * s->nr_files); 563 - cache_hit = cache_miss = reap = calls = done = 0; 572 + reap = calls = done = 0; 564 573 do { 565 574 unsigned long this_done = 0; 566 575 unsigned long this_reap = 0; 567 576 unsigned long this_call = 0; 568 - unsigned long this_cache_hit = 0; 569 - unsigned long this_cache_miss = 0; 570 577 unsigned long rpc = 0, ipc = 0; 571 - double hit = 0.0; 572 578 573 579 sleep(1); 574 580 this_done += s->done; 575 581 this_call += s->calls; 576 582 this_reap += s->reaps; 577 - this_cache_hit += s->cachehit; 578 - this_cache_miss += s->cachemiss; 579 - if (this_cache_hit && this_cache_miss) { 580 - unsigned long hits, total; 581 - 582 - hits = this_cache_hit - cache_hit; 583 - total = hits + this_cache_miss - cache_miss; 584 - hit = (double) hits / (double) total; 585 - hit *= 100.0; 586 - } 587 583 if (this_call - calls) { 588 584 rpc = (this_done - done) / (this_call - calls); 589 585 ipc = (this_reap - reap) / (this_call - calls); 590 586 } else 591 587 rpc = ipc = -1; 592 588 file_depths(fdepths); 593 - printf("IOPS=%lu, IOS/call=%ld/%ld, inflight=%u (%s), Cachehit=%0.2f%%\n", 589 + printf("IOPS=%lu, IOS/call=%ld/%ld, inflight=%u (%s)\n", 594 590 this_done - done, rpc, ipc, s->inflight, 595 - fdepths, hit); 591 + fdepths); 596 592 done = this_done; 597 593 calls = this_call; 598 594 reap = this_reap; 599 - cache_hit = s->cachehit; 600 - cache_miss = s->cachemiss; 601 595 } while (!finish); 602 596 603 597 pthread_join(s->thread, &ret);
+1
tools/objtool/check.c
··· 165 165 "fortify_panic", 166 166 "usercopy_abort", 167 167 "machine_real_restart", 168 + "rewind_stack_do_exit", 168 169 }; 169 170 170 171 if (func->bind == STB_WEAK)
+13 -4
tools/testing/nvdimm/test/nfit.c
··· 146 146 struct nfit_test_sec { 147 147 u8 state; 148 148 u8 ext_state; 149 + u8 old_state; 149 150 u8 passphrase[32]; 150 151 u8 master_passphrase[32]; 151 152 u64 overwrite_end_time; ··· 225 224 static struct workqueue_struct *nfit_wq; 226 225 227 226 static struct gen_pool *nfit_pool; 227 + 228 + static const char zero_key[NVDIMM_PASSPHRASE_LEN]; 228 229 229 230 static struct nfit_test *to_nfit_test(struct device *dev) 230 231 { ··· 1062 1059 struct device *dev = &t->pdev.dev; 1063 1060 struct nfit_test_sec *sec = &dimm_sec_info[dimm]; 1064 1061 1065 - if (!(sec->state & ND_INTEL_SEC_STATE_ENABLED) || 1066 - (sec->state & ND_INTEL_SEC_STATE_FROZEN)) { 1062 + if (sec->state & ND_INTEL_SEC_STATE_FROZEN) { 1067 1063 nd_cmd->status = ND_INTEL_STATUS_INVALID_STATE; 1068 1064 dev_dbg(dev, "secure erase: wrong security state\n"); 1069 1065 } else if (memcmp(nd_cmd->passphrase, sec->passphrase, ··· 1070 1068 nd_cmd->status = ND_INTEL_STATUS_INVALID_PASS; 1071 1069 dev_dbg(dev, "secure erase: wrong passphrase\n"); 1072 1070 } else { 1071 + if (!(sec->state & ND_INTEL_SEC_STATE_ENABLED) 1072 + && (memcmp(nd_cmd->passphrase, zero_key, 1073 + ND_INTEL_PASSPHRASE_SIZE) != 0)) { 1074 + dev_dbg(dev, "invalid zero key\n"); 1075 + return 0; 1076 + } 1073 1077 memset(sec->passphrase, 0, ND_INTEL_PASSPHRASE_SIZE); 1074 1078 memset(sec->master_passphrase, 0, ND_INTEL_PASSPHRASE_SIZE); 1075 1079 sec->state = 0; ··· 1101 1093 return 0; 1102 1094 } 1103 1095 1104 - memset(sec->passphrase, 0, ND_INTEL_PASSPHRASE_SIZE); 1096 + sec->old_state = sec->state; 1105 1097 sec->state = ND_INTEL_SEC_STATE_OVERWRITE; 1106 1098 dev_dbg(dev, "overwrite progressing.\n"); 1107 1099 sec->overwrite_end_time = get_jiffies_64() + 5 * HZ; ··· 1123 1115 1124 1116 if (time_is_before_jiffies64(sec->overwrite_end_time)) { 1125 1117 sec->overwrite_end_time = 0; 1126 - sec->state = 0; 1118 + sec->state = sec->old_state; 1119 + sec->old_state = 0; 1127 1120 sec->ext_state = ND_INTEL_SEC_ESTATE_ENABLED; 1128 1121 dev_dbg(dev, "overwrite is complete\n"); 1129 1122 } else
+20
tools/testing/selftests/drivers/net/mlxsw/rtnetlink.sh
··· 11 11 12 12 ALL_TESTS=" 13 13 rif_set_addr_test 14 + rif_vrf_set_addr_test 14 15 rif_inherit_bridge_addr_test 15 16 rif_non_inherit_bridge_addr_test 16 17 vlan_interface_deletion_test ··· 98 97 99 98 ip link set dev $swp2 addr $swp2_mac 100 99 ip link set dev $swp1 addr $swp1_mac 100 + } 101 + 102 + rif_vrf_set_addr_test() 103 + { 104 + # Test that it is possible to set an IP address on a VRF upper despite 105 + # its random MAC address. 106 + RET=0 107 + 108 + ip link add name vrf-test type vrf table 10 109 + ip link set dev $swp1 master vrf-test 110 + 111 + ip -4 address add 192.0.2.1/24 dev vrf-test 112 + check_err $? "failed to set IPv4 address on VRF" 113 + ip -6 address add 2001:db8:1::1/64 dev vrf-test 114 + check_err $? "failed to set IPv6 address on VRF" 115 + 116 + log_test "RIF - setting IP address on VRF" 117 + 118 + ip link del dev vrf-test 101 119 } 102 120 103 121 rif_inherit_bridge_addr_test()
+8 -1
tools/testing/selftests/kvm/Makefile
··· 1 + include ../../../../scripts/Kbuild.include 2 + 1 3 all: 2 4 3 5 top_srcdir = ../../../.. ··· 19 17 TEST_GEN_PROGS_x86_64 += x86_64/evmcs_test 20 18 TEST_GEN_PROGS_x86_64 += x86_64/hyperv_cpuid 21 19 TEST_GEN_PROGS_x86_64 += x86_64/vmx_close_while_nested_test 20 + TEST_GEN_PROGS_x86_64 += x86_64/smm_test 22 21 TEST_GEN_PROGS_x86_64 += dirty_log_test 23 22 TEST_GEN_PROGS_x86_64 += clear_dirty_log_test 24 23 ··· 33 30 LINUX_HDR_PATH = $(INSTALL_HDR_PATH)/include/ 34 31 LINUX_TOOL_INCLUDE = $(top_srcdir)/tools/include 35 32 CFLAGS += -O2 -g -std=gnu99 -fno-stack-protector -fno-PIE -I$(LINUX_TOOL_INCLUDE) -I$(LINUX_HDR_PATH) -Iinclude -I$(<D) -Iinclude/$(UNAME_M) -I.. 36 - LDFLAGS += -pthread -no-pie 33 + 34 + no-pie-option := $(call try-run, echo 'int main() { return 0; }' | \ 35 + $(CC) -Werror $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -no-pie -x c - -o "$$TMP", -no-pie) 36 + 37 + LDFLAGS += -pthread $(no-pie-option) 37 38 38 39 # After inclusion, $(OUTPUT) is defined and 39 40 # $(TEST_GEN_PROGS) starts with $(OUTPUT)/
+27
tools/testing/selftests/kvm/include/x86_64/processor.h
··· 778 778 #define MSR_IA32_APICBASE_ENABLE (1<<11) 779 779 #define MSR_IA32_APICBASE_BASE (0xfffff<<12) 780 780 781 + #define APIC_BASE_MSR 0x800 782 + #define X2APIC_ENABLE (1UL << 10) 783 + #define APIC_ICR 0x300 784 + #define APIC_DEST_SELF 0x40000 785 + #define APIC_DEST_ALLINC 0x80000 786 + #define APIC_DEST_ALLBUT 0xC0000 787 + #define APIC_ICR_RR_MASK 0x30000 788 + #define APIC_ICR_RR_INVALID 0x00000 789 + #define APIC_ICR_RR_INPROG 0x10000 790 + #define APIC_ICR_RR_VALID 0x20000 791 + #define APIC_INT_LEVELTRIG 0x08000 792 + #define APIC_INT_ASSERT 0x04000 793 + #define APIC_ICR_BUSY 0x01000 794 + #define APIC_DEST_LOGICAL 0x00800 795 + #define APIC_DEST_PHYSICAL 0x00000 796 + #define APIC_DM_FIXED 0x00000 797 + #define APIC_DM_FIXED_MASK 0x00700 798 + #define APIC_DM_LOWEST 0x00100 799 + #define APIC_DM_SMI 0x00200 800 + #define APIC_DM_REMRD 0x00300 801 + #define APIC_DM_NMI 0x00400 802 + #define APIC_DM_INIT 0x00500 803 + #define APIC_DM_STARTUP 0x00600 804 + #define APIC_DM_EXTINT 0x00700 805 + #define APIC_VECTOR_MASK 0x000FF 806 + #define APIC_ICR2 0x310 807 + 781 808 #define MSR_IA32_TSCDEADLINE 0x000006e0 782 809 783 810 #define MSR_IA32_UCODE_WRITE 0x00000079
+5
tools/testing/selftests/kvm/lib/kvm_util.c
··· 91 91 if (vm->kvm_fd < 0) 92 92 exit(KSFT_SKIP); 93 93 94 + if (!kvm_check_cap(KVM_CAP_IMMEDIATE_EXIT)) { 95 + fprintf(stderr, "immediate_exit not available, skipping test\n"); 96 + exit(KSFT_SKIP); 97 + } 98 + 94 99 vm->fd = ioctl(vm->kvm_fd, KVM_CREATE_VM, type); 95 100 TEST_ASSERT(vm->fd >= 0, "KVM_CREATE_VM ioctl failed, " 96 101 "rc: %i errno: %i", vm->fd, errno);
+14 -6
tools/testing/selftests/kvm/lib/x86_64/processor.c
··· 1030 1030 nested_size, sizeof(state->nested_)); 1031 1031 } 1032 1032 1033 + /* 1034 + * When KVM exits to userspace with KVM_EXIT_IO, KVM guarantees 1035 + * guest state is consistent only after userspace re-enters the 1036 + * kernel with KVM_RUN. Complete IO prior to migrating state 1037 + * to a new VM. 1038 + */ 1039 + vcpu_run_complete_io(vm, vcpuid); 1040 + 1033 1041 nmsrs = kvm_get_num_msrs(vm); 1034 1042 list = malloc(sizeof(*list) + nmsrs * sizeof(list->indices[0])); 1035 1043 list->nmsrs = nmsrs; ··· 1101 1093 struct vcpu *vcpu = vcpu_find(vm, vcpuid); 1102 1094 int r; 1103 1095 1104 - if (state->nested.size) { 1105 - r = ioctl(vcpu->fd, KVM_SET_NESTED_STATE, &state->nested); 1106 - TEST_ASSERT(r == 0, "Unexpected result from KVM_SET_NESTED_STATE, r: %i", 1107 - r); 1108 - } 1109 - 1110 1096 r = ioctl(vcpu->fd, KVM_SET_XSAVE, &state->xsave); 1111 1097 TEST_ASSERT(r == 0, "Unexpected result from KVM_SET_XSAVE, r: %i", 1112 1098 r); ··· 1132 1130 r = ioctl(vcpu->fd, KVM_SET_REGS, &state->regs); 1133 1131 TEST_ASSERT(r == 0, "Unexpected result from KVM_SET_REGS, r: %i", 1134 1132 r); 1133 + 1134 + if (state->nested.size) { 1135 + r = ioctl(vcpu->fd, KVM_SET_NESTED_STATE, &state->nested); 1136 + TEST_ASSERT(r == 0, "Unexpected result from KVM_SET_NESTED_STATE, r: %i", 1137 + r); 1138 + } 1135 1139 }
+3 -2
tools/testing/selftests/kvm/x86_64/evmcs_test.c
··· 123 123 stage, run->exit_reason, 124 124 exit_reason_str(run->exit_reason)); 125 125 126 - memset(&regs1, 0, sizeof(regs1)); 127 - vcpu_regs_get(vm, VCPU_ID, &regs1); 128 126 switch (get_ucall(vm, VCPU_ID, &uc)) { 129 127 case UCALL_ABORT: 130 128 TEST_ASSERT(false, "%s at %s:%d", (const char *)uc.args[0], ··· 142 144 stage, (ulong)uc.args[1]); 143 145 144 146 state = vcpu_save_state(vm, VCPU_ID); 147 + memset(&regs1, 0, sizeof(regs1)); 148 + vcpu_regs_get(vm, VCPU_ID, &regs1); 149 + 145 150 kvm_vm_release(vm); 146 151 147 152 /* Restore state in a new VM. */
+157
tools/testing/selftests/kvm/x86_64/smm_test.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* 3 + * Copyright (C) 2018, Red Hat, Inc. 4 + * 5 + * Tests for SMM. 6 + */ 7 + #define _GNU_SOURCE /* for program_invocation_short_name */ 8 + #include <fcntl.h> 9 + #include <stdio.h> 10 + #include <stdlib.h> 11 + #include <stdint.h> 12 + #include <string.h> 13 + #include <sys/ioctl.h> 14 + 15 + #include "test_util.h" 16 + 17 + #include "kvm_util.h" 18 + 19 + #include "vmx.h" 20 + 21 + #define VCPU_ID 1 22 + 23 + #define PAGE_SIZE 4096 24 + 25 + #define SMRAM_SIZE 65536 26 + #define SMRAM_MEMSLOT ((1 << 16) | 1) 27 + #define SMRAM_PAGES (SMRAM_SIZE / PAGE_SIZE) 28 + #define SMRAM_GPA 0x1000000 29 + #define SMRAM_STAGE 0xfe 30 + 31 + #define STR(x) #x 32 + #define XSTR(s) STR(s) 33 + 34 + #define SYNC_PORT 0xe 35 + #define DONE 0xff 36 + 37 + /* 38 + * This is compiled as normal 64-bit code, however, SMI handler is executed 39 + * in real-address mode. To stay simple we're limiting ourselves to a mode 40 + * independent subset of asm here. 41 + * SMI handler always report back fixed stage SMRAM_STAGE. 42 + */ 43 + uint8_t smi_handler[] = { 44 + 0xb0, SMRAM_STAGE, /* mov $SMRAM_STAGE, %al */ 45 + 0xe4, SYNC_PORT, /* in $SYNC_PORT, %al */ 46 + 0x0f, 0xaa, /* rsm */ 47 + }; 48 + 49 + void sync_with_host(uint64_t phase) 50 + { 51 + asm volatile("in $" XSTR(SYNC_PORT)", %%al \n" 52 + : : "a" (phase)); 53 + } 54 + 55 + void self_smi(void) 56 + { 57 + wrmsr(APIC_BASE_MSR + (APIC_ICR >> 4), 58 + APIC_DEST_SELF | APIC_INT_ASSERT | APIC_DM_SMI); 59 + } 60 + 61 + void guest_code(struct vmx_pages *vmx_pages) 62 + { 63 + uint64_t apicbase = rdmsr(MSR_IA32_APICBASE); 64 + 65 + sync_with_host(1); 66 + 67 + wrmsr(MSR_IA32_APICBASE, apicbase | X2APIC_ENABLE); 68 + 69 + sync_with_host(2); 70 + 71 + self_smi(); 72 + 73 + sync_with_host(4); 74 + 75 + if (vmx_pages) { 76 + GUEST_ASSERT(prepare_for_vmx_operation(vmx_pages)); 77 + 78 + sync_with_host(5); 79 + 80 + self_smi(); 81 + 82 + sync_with_host(7); 83 + } 84 + 85 + sync_with_host(DONE); 86 + } 87 + 88 + int main(int argc, char *argv[]) 89 + { 90 + struct vmx_pages *vmx_pages = NULL; 91 + vm_vaddr_t vmx_pages_gva = 0; 92 + 93 + struct kvm_regs regs; 94 + struct kvm_vm *vm; 95 + struct kvm_run *run; 96 + struct kvm_x86_state *state; 97 + int stage, stage_reported; 98 + 99 + /* Create VM */ 100 + vm = vm_create_default(VCPU_ID, 0, guest_code); 101 + 102 + vcpu_set_cpuid(vm, VCPU_ID, kvm_get_supported_cpuid()); 103 + 104 + run = vcpu_state(vm, VCPU_ID); 105 + 106 + vm_userspace_mem_region_add(vm, VM_MEM_SRC_ANONYMOUS, SMRAM_GPA, 107 + SMRAM_MEMSLOT, SMRAM_PAGES, 0); 108 + TEST_ASSERT(vm_phy_pages_alloc(vm, SMRAM_PAGES, SMRAM_GPA, SMRAM_MEMSLOT) 109 + == SMRAM_GPA, "could not allocate guest physical addresses?"); 110 + 111 + memset(addr_gpa2hva(vm, SMRAM_GPA), 0x0, SMRAM_SIZE); 112 + memcpy(addr_gpa2hva(vm, SMRAM_GPA) + 0x8000, smi_handler, 113 + sizeof(smi_handler)); 114 + 115 + vcpu_set_msr(vm, VCPU_ID, MSR_IA32_SMBASE, SMRAM_GPA); 116 + 117 + if (kvm_check_cap(KVM_CAP_NESTED_STATE)) { 118 + vmx_pages = vcpu_alloc_vmx(vm, &vmx_pages_gva); 119 + vcpu_args_set(vm, VCPU_ID, 1, vmx_pages_gva); 120 + } else { 121 + printf("will skip SMM test with VMX enabled\n"); 122 + vcpu_args_set(vm, VCPU_ID, 1, 0); 123 + } 124 + 125 + for (stage = 1;; stage++) { 126 + _vcpu_run(vm, VCPU_ID); 127 + TEST_ASSERT(run->exit_reason == KVM_EXIT_IO, 128 + "Stage %d: unexpected exit reason: %u (%s),\n", 129 + stage, run->exit_reason, 130 + exit_reason_str(run->exit_reason)); 131 + 132 + memset(&regs, 0, sizeof(regs)); 133 + vcpu_regs_get(vm, VCPU_ID, &regs); 134 + 135 + stage_reported = regs.rax & 0xff; 136 + 137 + if (stage_reported == DONE) 138 + goto done; 139 + 140 + TEST_ASSERT(stage_reported == stage || 141 + stage_reported == SMRAM_STAGE, 142 + "Unexpected stage: #%x, got %x", 143 + stage, stage_reported); 144 + 145 + state = vcpu_save_state(vm, VCPU_ID); 146 + kvm_vm_release(vm); 147 + kvm_vm_restart(vm, O_RDWR); 148 + vm_vcpu_add(vm, VCPU_ID, 0, 0); 149 + vcpu_set_cpuid(vm, VCPU_ID, kvm_get_supported_cpuid()); 150 + vcpu_load_state(vm, VCPU_ID, state); 151 + run = vcpu_state(vm, VCPU_ID); 152 + free(state); 153 + } 154 + 155 + done: 156 + kvm_vm_free(vm); 157 + }
+1 -14
tools/testing/selftests/kvm/x86_64/state_test.c
··· 134 134 135 135 struct kvm_cpuid_entry2 *entry = kvm_get_supported_cpuid_entry(1); 136 136 137 - if (!kvm_check_cap(KVM_CAP_IMMEDIATE_EXIT)) { 138 - fprintf(stderr, "immediate_exit not available, skipping test\n"); 139 - exit(KSFT_SKIP); 140 - } 141 - 142 137 /* Create VM */ 143 138 vm = vm_create_default(VCPU_ID, 0, guest_code); 144 139 vcpu_set_cpuid(vm, VCPU_ID, kvm_get_supported_cpuid()); ··· 174 179 uc.args[1] == stage, "Unexpected register values vmexit #%lx, got %lx", 175 180 stage, (ulong)uc.args[1]); 176 181 177 - /* 178 - * When KVM exits to userspace with KVM_EXIT_IO, KVM guarantees 179 - * guest state is consistent only after userspace re-enters the 180 - * kernel with KVM_RUN. Complete IO prior to migrating state 181 - * to a new VM. 182 - */ 183 - vcpu_run_complete_io(vm, VCPU_ID); 184 - 182 + state = vcpu_save_state(vm, VCPU_ID); 185 183 memset(&regs1, 0, sizeof(regs1)); 186 184 vcpu_regs_get(vm, VCPU_ID, &regs1); 187 185 188 - state = vcpu_save_state(vm, VCPU_ID); 189 186 kvm_vm_release(vm); 190 187 191 188 /* Restore state in a new VM. */
+40 -54
tools/testing/selftests/net/fib_tests.sh
··· 607 607 return $rc 608 608 } 609 609 610 + check_expected() 611 + { 612 + local out="$1" 613 + local expected="$2" 614 + local rc=0 615 + 616 + [ "${out}" = "${expected}" ] && return 0 617 + 618 + if [ -z "${out}" ]; then 619 + if [ "$VERBOSE" = "1" ]; then 620 + printf "\nNo route entry found\n" 621 + printf "Expected:\n" 622 + printf " ${expected}\n" 623 + fi 624 + return 1 625 + fi 626 + 627 + # tricky way to convert output to 1-line without ip's 628 + # messy '\'; this drops all extra white space 629 + out=$(echo ${out}) 630 + if [ "${out}" != "${expected}" ]; then 631 + rc=1 632 + if [ "${VERBOSE}" = "1" ]; then 633 + printf " Unexpected route entry. Have:\n" 634 + printf " ${out}\n" 635 + printf " Expected:\n" 636 + printf " ${expected}\n\n" 637 + fi 638 + fi 639 + 640 + return $rc 641 + } 642 + 610 643 # add route for a prefix, flushing any existing routes first 611 644 # expected to be the first step of a test 612 645 add_route6() ··· 687 654 pfx=$1 688 655 689 656 out=$($IP -6 ro ls match ${pfx} | sed -e 's/ pref medium//') 690 - [ "${out}" = "${expected}" ] && return 0 691 - 692 - if [ -z "${out}" ]; then 693 - if [ "$VERBOSE" = "1" ]; then 694 - printf "\nNo route entry found\n" 695 - printf "Expected:\n" 696 - printf " ${expected}\n" 697 - fi 698 - return 1 699 - fi 700 - 701 - # tricky way to convert output to 1-line without ip's 702 - # messy '\'; this drops all extra white space 703 - out=$(echo ${out}) 704 - if [ "${out}" != "${expected}" ]; then 705 - rc=1 706 - if [ "${VERBOSE}" = "1" ]; then 707 - printf " Unexpected route entry. Have:\n" 708 - printf " ${out}\n" 709 - printf " Expected:\n" 710 - printf " ${expected}\n\n" 711 - fi 712 - fi 713 - 714 - return $rc 657 + check_expected "${out}" "${expected}" 715 658 } 716 659 717 660 route_cleanup() ··· 737 728 ip -netns ns2 addr add 172.16.103.2/24 dev veth4 738 729 ip -netns ns2 addr add 172.16.104.1/24 dev dummy1 739 730 740 - set +ex 731 + set +e 741 732 } 742 733 743 734 # assumption is that basic add of a single path route works ··· 972 963 run_cmd "$IP li set dev dummy2 down" 973 964 rc=$? 974 965 if [ $rc -eq 0 ]; then 975 - check_route6 "" 966 + out=$($IP -6 ro ls match 2001:db8:104::/64) 967 + check_expected "${out}" "" 976 968 rc=$? 977 969 fi 978 970 log_test $rc 0 "Prefix route removed on link down" ··· 1104 1094 local pfx 1105 1095 local expected="$1" 1106 1096 local out 1107 - local rc=0 1108 1097 1109 1098 set -- $expected 1110 1099 pfx=$1 1111 1100 [ "${pfx}" = "unreachable" ] && pfx=$2 1112 1101 1113 1102 out=$($IP ro ls match ${pfx}) 1114 - [ "${out}" = "${expected}" ] && return 0 1115 - 1116 - if [ -z "${out}" ]; then 1117 - if [ "$VERBOSE" = "1" ]; then 1118 - printf "\nNo route entry found\n" 1119 - printf "Expected:\n" 1120 - printf " ${expected}\n" 1121 - fi 1122 - return 1 1123 - fi 1124 - 1125 - # tricky way to convert output to 1-line without ip's 1126 - # messy '\'; this drops all extra white space 1127 - out=$(echo ${out}) 1128 - if [ "${out}" != "${expected}" ]; then 1129 - rc=1 1130 - if [ "${VERBOSE}" = "1" ]; then 1131 - printf " Unexpected route entry. Have:\n" 1132 - printf " ${out}\n" 1133 - printf " Expected:\n" 1134 - printf " ${expected}\n\n" 1135 - fi 1136 - fi 1137 - 1138 - return $rc 1103 + check_expected "${out}" "${expected}" 1139 1104 } 1140 1105 1141 1106 # assumption is that basic add of a single path route works ··· 1375 1390 run_cmd "$IP li set dev dummy2 down" 1376 1391 rc=$? 1377 1392 if [ $rc -eq 0 ]; then 1378 - check_route "" 1393 + out=$($IP ro ls match 172.16.104.0/24) 1394 + check_expected "${out}" "" 1379 1395 rc=$? 1380 1396 fi 1381 1397 log_test $rc 0 "Prefix route removed on link down"
+3 -2
virt/kvm/irqchip.c
··· 144 144 { 145 145 struct kvm_kernel_irq_routing_entry *ei; 146 146 int r; 147 + u32 gsi = array_index_nospec(ue->gsi, KVM_MAX_IRQ_ROUTES); 147 148 148 149 /* 149 150 * Do not allow GSI to be mapped to the same irqchip more than once. 150 151 * Allow only one to one mapping between GSI and non-irqchip routing. 151 152 */ 152 - hlist_for_each_entry(ei, &rt->map[ue->gsi], link) 153 + hlist_for_each_entry(ei, &rt->map[gsi], link) 153 154 if (ei->type != KVM_IRQ_ROUTING_IRQCHIP || 154 155 ue->type != KVM_IRQ_ROUTING_IRQCHIP || 155 156 ue->u.irqchip.irqchip == ei->irqchip.irqchip) 156 157 return -EINVAL; 157 158 158 - e->gsi = ue->gsi; 159 + e->gsi = gsi; 159 160 e->type = ue->type; 160 161 r = kvm_set_routing_entry(kvm, e, ue); 161 162 if (r)
+4 -2
virt/kvm/kvm_main.c
··· 2977 2977 struct kvm_device_ops *ops = NULL; 2978 2978 struct kvm_device *dev; 2979 2979 bool test = cd->flags & KVM_CREATE_DEVICE_TEST; 2980 + int type; 2980 2981 int ret; 2981 2982 2982 2983 if (cd->type >= ARRAY_SIZE(kvm_device_ops_table)) 2983 2984 return -ENODEV; 2984 2985 2985 - ops = kvm_device_ops_table[cd->type]; 2986 + type = array_index_nospec(cd->type, ARRAY_SIZE(kvm_device_ops_table)); 2987 + ops = kvm_device_ops_table[type]; 2986 2988 if (ops == NULL) 2987 2989 return -ENODEV; 2988 2990 ··· 2999 2997 dev->kvm = kvm; 3000 2998 3001 2999 mutex_lock(&kvm->lock); 3002 - ret = ops->create(dev, cd->type); 3000 + ret = ops->create(dev, type); 3003 3001 if (ret < 0) { 3004 3002 mutex_unlock(&kvm->lock); 3005 3003 kfree(dev);