diff options
278 files changed, 2569 insertions, 1720 deletions
diff --git a/Documentation/ABI/stable/sysfs-devices-system-xen_memory b/Documentation/ABI/stable/sysfs-devices-system-xen_memory index caa311d59ac1..6d83f95a8a8e 100644 --- a/Documentation/ABI/stable/sysfs-devices-system-xen_memory +++ b/Documentation/ABI/stable/sysfs-devices-system-xen_memory | |||
| @@ -75,3 +75,12 @@ Contact: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> | |||
| 75 | Description: | 75 | Description: |
| 76 | Amount (in KiB) of low (or normal) memory in the | 76 | Amount (in KiB) of low (or normal) memory in the |
| 77 | balloon. | 77 | balloon. |
| 78 | |||
| 79 | What: /sys/devices/system/xen_memory/xen_memory0/scrub_pages | ||
| 80 | Date: September 2018 | ||
| 81 | KernelVersion: 4.20 | ||
| 82 | Contact: xen-devel@lists.xenproject.org | ||
| 83 | Description: | ||
| 84 | Control scrubbing pages before returning them to Xen for others domains | ||
| 85 | use. Can be set with xen_scrub_pages cmdline | ||
| 86 | parameter. Default value controlled with CONFIG_XEN_SCRUB_PAGES_DEFAULT. | ||
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 9871e649ffef..92eb1f42240d 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt | |||
| @@ -3523,6 +3523,12 @@ | |||
| 3523 | ramdisk_size= [RAM] Sizes of RAM disks in kilobytes | 3523 | ramdisk_size= [RAM] Sizes of RAM disks in kilobytes |
| 3524 | See Documentation/blockdev/ramdisk.txt. | 3524 | See Documentation/blockdev/ramdisk.txt. |
| 3525 | 3525 | ||
| 3526 | random.trust_cpu={on,off} | ||
| 3527 | [KNL] Enable or disable trusting the use of the | ||
| 3528 | CPU's random number generator (if available) to | ||
| 3529 | fully seed the kernel's CRNG. Default is controlled | ||
| 3530 | by CONFIG_RANDOM_TRUST_CPU. | ||
| 3531 | |||
| 3526 | ras=option[,option,...] [KNL] RAS-specific options | 3532 | ras=option[,option,...] [KNL] RAS-specific options |
| 3527 | 3533 | ||
| 3528 | cec_disable [X86] | 3534 | cec_disable [X86] |
| @@ -4994,6 +5000,12 @@ | |||
| 4994 | Disables the PV optimizations forcing the HVM guest to | 5000 | Disables the PV optimizations forcing the HVM guest to |
| 4995 | run as generic HVM guest with no PV drivers. | 5001 | run as generic HVM guest with no PV drivers. |
| 4996 | 5002 | ||
| 5003 | xen_scrub_pages= [XEN] | ||
| 5004 | Boolean option to control scrubbing pages before giving them back | ||
| 5005 | to Xen, for use by other domains. Can be also changed at runtime | ||
| 5006 | with /sys/devices/system/xen_memory/xen_memory0/scrub_pages. | ||
| 5007 | Default value controlled with CONFIG_XEN_SCRUB_PAGES_DEFAULT. | ||
| 5008 | |||
| 4997 | xirc2ps_cs= [NET,PCMCIA] | 5009 | xirc2ps_cs= [NET,PCMCIA] |
| 4998 | Format: | 5010 | Format: |
| 4999 | <irq>,<irq_mask>,<io>,<full_duplex>,<do_sound>,<lockup_hack>[,<irq2>[,<irq3>[,<irq4>]]] | 5011 | <irq>,<irq_mask>,<io>,<full_duplex>,<do_sound>,<lockup_hack>[,<irq2>[,<irq3>[,<irq4>]]] |
diff --git a/Documentation/device-mapper/dm-raid.txt b/Documentation/device-mapper/dm-raid.txt index 390c145f01d7..52a719b49afd 100644 --- a/Documentation/device-mapper/dm-raid.txt +++ b/Documentation/device-mapper/dm-raid.txt | |||
| @@ -348,3 +348,7 @@ Version History | |||
| 348 | 1.13.1 Fix deadlock caused by early md_stop_writes(). Also fix size an | 348 | 1.13.1 Fix deadlock caused by early md_stop_writes(). Also fix size an |
| 349 | state races. | 349 | state races. |
| 350 | 1.13.2 Fix raid redundancy validation and avoid keeping raid set frozen | 350 | 1.13.2 Fix raid redundancy validation and avoid keeping raid set frozen |
| 351 | 1.14.0 Fix reshape race on small devices. Fix stripe adding reshape | ||
| 352 | deadlock/potential data corruption. Update superblock when | ||
| 353 | specific devices are requested via rebuild. Fix RAID leg | ||
| 354 | rebuild errors. | ||
diff --git a/Documentation/filesystems/vfs.txt b/Documentation/filesystems/vfs.txt index 4b2084d0f1fb..a6c6a8af48a2 100644 --- a/Documentation/filesystems/vfs.txt +++ b/Documentation/filesystems/vfs.txt | |||
| @@ -848,7 +848,7 @@ struct file_operations | |||
| 848 | ---------------------- | 848 | ---------------------- |
| 849 | 849 | ||
| 850 | This describes how the VFS can manipulate an open file. As of kernel | 850 | This describes how the VFS can manipulate an open file. As of kernel |
| 851 | 4.1, the following members are defined: | 851 | 4.18, the following members are defined: |
| 852 | 852 | ||
| 853 | struct file_operations { | 853 | struct file_operations { |
| 854 | struct module *owner; | 854 | struct module *owner; |
| @@ -858,11 +858,11 @@ struct file_operations { | |||
| 858 | ssize_t (*read_iter) (struct kiocb *, struct iov_iter *); | 858 | ssize_t (*read_iter) (struct kiocb *, struct iov_iter *); |
| 859 | ssize_t (*write_iter) (struct kiocb *, struct iov_iter *); | 859 | ssize_t (*write_iter) (struct kiocb *, struct iov_iter *); |
| 860 | int (*iterate) (struct file *, struct dir_context *); | 860 | int (*iterate) (struct file *, struct dir_context *); |
| 861 | int (*iterate_shared) (struct file *, struct dir_context *); | ||
| 861 | __poll_t (*poll) (struct file *, struct poll_table_struct *); | 862 | __poll_t (*poll) (struct file *, struct poll_table_struct *); |
| 862 | long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long); | 863 | long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long); |
| 863 | long (*compat_ioctl) (struct file *, unsigned int, unsigned long); | 864 | long (*compat_ioctl) (struct file *, unsigned int, unsigned long); |
| 864 | int (*mmap) (struct file *, struct vm_area_struct *); | 865 | int (*mmap) (struct file *, struct vm_area_struct *); |
| 865 | int (*mremap)(struct file *, struct vm_area_struct *); | ||
| 866 | int (*open) (struct inode *, struct file *); | 866 | int (*open) (struct inode *, struct file *); |
| 867 | int (*flush) (struct file *, fl_owner_t id); | 867 | int (*flush) (struct file *, fl_owner_t id); |
| 868 | int (*release) (struct inode *, struct file *); | 868 | int (*release) (struct inode *, struct file *); |
| @@ -882,6 +882,10 @@ struct file_operations { | |||
| 882 | #ifndef CONFIG_MMU | 882 | #ifndef CONFIG_MMU |
| 883 | unsigned (*mmap_capabilities)(struct file *); | 883 | unsigned (*mmap_capabilities)(struct file *); |
| 884 | #endif | 884 | #endif |
| 885 | ssize_t (*copy_file_range)(struct file *, loff_t, struct file *, loff_t, size_t, unsigned int); | ||
| 886 | int (*clone_file_range)(struct file *, loff_t, struct file *, loff_t, u64); | ||
| 887 | int (*dedupe_file_range)(struct file *, loff_t, struct file *, loff_t, u64); | ||
| 888 | int (*fadvise)(struct file *, loff_t, loff_t, int); | ||
| 885 | }; | 889 | }; |
| 886 | 890 | ||
| 887 | Again, all methods are called without any locks being held, unless | 891 | Again, all methods are called without any locks being held, unless |
| @@ -899,6 +903,9 @@ otherwise noted. | |||
| 899 | 903 | ||
| 900 | iterate: called when the VFS needs to read the directory contents | 904 | iterate: called when the VFS needs to read the directory contents |
| 901 | 905 | ||
| 906 | iterate_shared: called when the VFS needs to read the directory contents | ||
| 907 | when filesystem supports concurrent dir iterators | ||
| 908 | |||
| 902 | poll: called by the VFS when a process wants to check if there is | 909 | poll: called by the VFS when a process wants to check if there is |
| 903 | activity on this file and (optionally) go to sleep until there | 910 | activity on this file and (optionally) go to sleep until there |
| 904 | is activity. Called by the select(2) and poll(2) system calls | 911 | is activity. Called by the select(2) and poll(2) system calls |
| @@ -951,6 +958,16 @@ otherwise noted. | |||
| 951 | 958 | ||
| 952 | fallocate: called by the VFS to preallocate blocks or punch a hole. | 959 | fallocate: called by the VFS to preallocate blocks or punch a hole. |
| 953 | 960 | ||
| 961 | copy_file_range: called by the copy_file_range(2) system call. | ||
| 962 | |||
| 963 | clone_file_range: called by the ioctl(2) system call for FICLONERANGE and | ||
| 964 | FICLONE commands. | ||
| 965 | |||
| 966 | dedupe_file_range: called by the ioctl(2) system call for FIDEDUPERANGE | ||
| 967 | command. | ||
| 968 | |||
| 969 | fadvise: possibly called by the fadvise64() system call. | ||
| 970 | |||
| 954 | Note that the file operations are implemented by the specific | 971 | Note that the file operations are implemented by the specific |
| 955 | filesystem in which the inode resides. When opening a device node | 972 | filesystem in which the inode resides. When opening a device node |
| 956 | (character or block special) most filesystems will call special | 973 | (character or block special) most filesystems will call special |
diff --git a/Documentation/process/changes.rst b/Documentation/process/changes.rst index 61f918b10a0c..d1bf143b446f 100644 --- a/Documentation/process/changes.rst +++ b/Documentation/process/changes.rst | |||
| @@ -86,7 +86,7 @@ pkg-config | |||
| 86 | 86 | ||
| 87 | The build system, as of 4.18, requires pkg-config to check for installed | 87 | The build system, as of 4.18, requires pkg-config to check for installed |
| 88 | kconfig tools and to determine flags settings for use in | 88 | kconfig tools and to determine flags settings for use in |
| 89 | 'make {menu,n,g,x}config'. Previously pkg-config was being used but not | 89 | 'make {g,x}config'. Previously pkg-config was being used but not |
| 90 | verified or documented. | 90 | verified or documented. |
| 91 | 91 | ||
| 92 | Flex | 92 | Flex |
diff --git a/MAINTAINERS b/MAINTAINERS index d870cb57c887..3d92ea976f5e 100644 --- a/MAINTAINERS +++ b/MAINTAINERS | |||
| @@ -5625,6 +5625,8 @@ F: lib/fault-inject.c | |||
| 5625 | 5625 | ||
| 5626 | FBTFT Framebuffer drivers | 5626 | FBTFT Framebuffer drivers |
| 5627 | M: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> | 5627 | M: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> |
| 5628 | L: dri-devel@lists.freedesktop.org | ||
| 5629 | L: linux-fbdev@vger.kernel.org | ||
| 5628 | S: Maintained | 5630 | S: Maintained |
| 5629 | F: drivers/staging/fbtft/ | 5631 | F: drivers/staging/fbtft/ |
| 5630 | 5632 | ||
| @@ -6060,7 +6062,7 @@ F: Documentation/gcc-plugins.txt | |||
| 6060 | 6062 | ||
| 6061 | GASKET DRIVER FRAMEWORK | 6063 | GASKET DRIVER FRAMEWORK |
| 6062 | M: Rob Springer <rspringer@google.com> | 6064 | M: Rob Springer <rspringer@google.com> |
| 6063 | M: John Joseph <jnjoseph@google.com> | 6065 | M: Todd Poynor <toddpoynor@google.com> |
| 6064 | M: Ben Chan <benchan@chromium.org> | 6066 | M: Ben Chan <benchan@chromium.org> |
| 6065 | S: Maintained | 6067 | S: Maintained |
| 6066 | F: drivers/staging/gasket/ | 6068 | F: drivers/staging/gasket/ |
| @@ -7016,6 +7018,20 @@ F: drivers/crypto/vmx/aes* | |||
| 7016 | F: drivers/crypto/vmx/ghash* | 7018 | F: drivers/crypto/vmx/ghash* |
| 7017 | F: drivers/crypto/vmx/ppc-xlate.pl | 7019 | F: drivers/crypto/vmx/ppc-xlate.pl |
| 7018 | 7020 | ||
| 7021 | IBM Power PCI Hotplug Driver for RPA-compliant PPC64 platform | ||
| 7022 | M: Tyrel Datwyler <tyreld@linux.vnet.ibm.com> | ||
| 7023 | L: linux-pci@vger.kernel.org | ||
| 7024 | L: linuxppc-dev@lists.ozlabs.org | ||
| 7025 | S: Supported | ||
| 7026 | F: drivers/pci/hotplug/rpaphp* | ||
| 7027 | |||
| 7028 | IBM Power IO DLPAR Driver for RPA-compliant PPC64 platform | ||
| 7029 | M: Tyrel Datwyler <tyreld@linux.vnet.ibm.com> | ||
| 7030 | L: linux-pci@vger.kernel.org | ||
| 7031 | L: linuxppc-dev@lists.ozlabs.org | ||
| 7032 | S: Supported | ||
| 7033 | F: drivers/pci/hotplug/rpadlpar* | ||
| 7034 | |||
| 7019 | IBM ServeRAID RAID DRIVER | 7035 | IBM ServeRAID RAID DRIVER |
| 7020 | S: Orphan | 7036 | S: Orphan |
| 7021 | F: drivers/scsi/ips.* | 7037 | F: drivers/scsi/ips.* |
| @@ -11154,7 +11170,7 @@ F: drivers/pci/controller/dwc/pci-exynos.c | |||
| 11154 | 11170 | ||
| 11155 | PCI DRIVER FOR SYNOPSYS DESIGNWARE | 11171 | PCI DRIVER FOR SYNOPSYS DESIGNWARE |
| 11156 | M: Jingoo Han <jingoohan1@gmail.com> | 11172 | M: Jingoo Han <jingoohan1@gmail.com> |
| 11157 | M: Joao Pinto <Joao.Pinto@synopsys.com> | 11173 | M: Gustavo Pimentel <gustavo.pimentel@synopsys.com> |
| 11158 | L: linux-pci@vger.kernel.org | 11174 | L: linux-pci@vger.kernel.org |
| 11159 | S: Maintained | 11175 | S: Maintained |
| 11160 | F: Documentation/devicetree/bindings/pci/designware-pcie.txt | 11176 | F: Documentation/devicetree/bindings/pci/designware-pcie.txt |
| @@ -11346,10 +11362,10 @@ S: Maintained | |||
| 11346 | F: drivers/platform/x86/peaq-wmi.c | 11362 | F: drivers/platform/x86/peaq-wmi.c |
| 11347 | 11363 | ||
| 11348 | PER-CPU MEMORY ALLOCATOR | 11364 | PER-CPU MEMORY ALLOCATOR |
| 11365 | M: Dennis Zhou <dennis@kernel.org> | ||
| 11349 | M: Tejun Heo <tj@kernel.org> | 11366 | M: Tejun Heo <tj@kernel.org> |
| 11350 | M: Christoph Lameter <cl@linux.com> | 11367 | M: Christoph Lameter <cl@linux.com> |
| 11351 | M: Dennis Zhou <dennisszhou@gmail.com> | 11368 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/dennis/percpu.git |
| 11352 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/tj/percpu.git | ||
| 11353 | S: Maintained | 11369 | S: Maintained |
| 11354 | F: include/linux/percpu*.h | 11370 | F: include/linux/percpu*.h |
| 11355 | F: mm/percpu*.c | 11371 | F: mm/percpu*.c |
| @@ -2,7 +2,7 @@ | |||
| 2 | VERSION = 4 | 2 | VERSION = 4 |
| 3 | PATCHLEVEL = 19 | 3 | PATCHLEVEL = 19 |
| 4 | SUBLEVEL = 0 | 4 | SUBLEVEL = 0 |
| 5 | EXTRAVERSION = -rc2 | 5 | EXTRAVERSION = -rc3 |
| 6 | NAME = Merciless Moray | 6 | NAME = Merciless Moray |
| 7 | 7 | ||
| 8 | # *DOCUMENTATION* | 8 | # *DOCUMENTATION* |
| @@ -616,6 +616,11 @@ CFLAGS_GCOV := -fprofile-arcs -ftest-coverage \ | |||
| 616 | $(call cc-disable-warning,maybe-uninitialized,) | 616 | $(call cc-disable-warning,maybe-uninitialized,) |
| 617 | export CFLAGS_GCOV | 617 | export CFLAGS_GCOV |
| 618 | 618 | ||
| 619 | # The arch Makefiles can override CC_FLAGS_FTRACE. We may also append it later. | ||
| 620 | ifdef CONFIG_FUNCTION_TRACER | ||
| 621 | CC_FLAGS_FTRACE := -pg | ||
| 622 | endif | ||
| 623 | |||
| 619 | # The arch Makefile can set ARCH_{CPP,A,C}FLAGS to override the default | 624 | # The arch Makefile can set ARCH_{CPP,A,C}FLAGS to override the default |
| 620 | # values of the respective KBUILD_* variables | 625 | # values of the respective KBUILD_* variables |
| 621 | ARCH_CPPFLAGS := | 626 | ARCH_CPPFLAGS := |
| @@ -755,9 +760,6 @@ KBUILD_CFLAGS += $(call cc-option, -femit-struct-debug-baseonly) \ | |||
| 755 | endif | 760 | endif |
| 756 | 761 | ||
| 757 | ifdef CONFIG_FUNCTION_TRACER | 762 | ifdef CONFIG_FUNCTION_TRACER |
| 758 | ifndef CC_FLAGS_FTRACE | ||
| 759 | CC_FLAGS_FTRACE := -pg | ||
| 760 | endif | ||
| 761 | ifdef CONFIG_FTRACE_MCOUNT_RECORD | 763 | ifdef CONFIG_FTRACE_MCOUNT_RECORD |
| 762 | # gcc 5 supports generating the mcount tables directly | 764 | # gcc 5 supports generating the mcount tables directly |
| 763 | ifeq ($(call cc-option-yn,-mrecord-mcount),y) | 765 | ifeq ($(call cc-option-yn,-mrecord-mcount),y) |
diff --git a/arch/arm64/include/asm/jump_label.h b/arch/arm64/include/asm/jump_label.h index 1b5e0e843c3a..7e2b3e360086 100644 --- a/arch/arm64/include/asm/jump_label.h +++ b/arch/arm64/include/asm/jump_label.h | |||
| @@ -28,7 +28,7 @@ | |||
| 28 | 28 | ||
| 29 | static __always_inline bool arch_static_branch(struct static_key *key, bool branch) | 29 | static __always_inline bool arch_static_branch(struct static_key *key, bool branch) |
| 30 | { | 30 | { |
| 31 | asm goto("1: nop\n\t" | 31 | asm_volatile_goto("1: nop\n\t" |
| 32 | ".pushsection __jump_table, \"aw\"\n\t" | 32 | ".pushsection __jump_table, \"aw\"\n\t" |
| 33 | ".align 3\n\t" | 33 | ".align 3\n\t" |
| 34 | ".quad 1b, %l[l_yes], %c0\n\t" | 34 | ".quad 1b, %l[l_yes], %c0\n\t" |
| @@ -42,7 +42,7 @@ l_yes: | |||
| 42 | 42 | ||
| 43 | static __always_inline bool arch_static_branch_jump(struct static_key *key, bool branch) | 43 | static __always_inline bool arch_static_branch_jump(struct static_key *key, bool branch) |
| 44 | { | 44 | { |
| 45 | asm goto("1: b %l[l_yes]\n\t" | 45 | asm_volatile_goto("1: b %l[l_yes]\n\t" |
| 46 | ".pushsection __jump_table, \"aw\"\n\t" | 46 | ".pushsection __jump_table, \"aw\"\n\t" |
| 47 | ".align 3\n\t" | 47 | ".align 3\n\t" |
| 48 | ".quad 1b, %l[l_yes], %c0\n\t" | 48 | ".quad 1b, %l[l_yes], %c0\n\t" |
diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile index 95ac7374d723..4c8b13bede80 100644 --- a/arch/arm64/kernel/Makefile +++ b/arch/arm64/kernel/Makefile | |||
| @@ -54,6 +54,7 @@ arm64-obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o \ | |||
| 54 | arm64-obj-$(CONFIG_ARM64_RELOC_TEST) += arm64-reloc-test.o | 54 | arm64-obj-$(CONFIG_ARM64_RELOC_TEST) += arm64-reloc-test.o |
| 55 | arm64-reloc-test-y := reloc_test_core.o reloc_test_syms.o | 55 | arm64-reloc-test-y := reloc_test_core.o reloc_test_syms.o |
| 56 | arm64-obj-$(CONFIG_CRASH_DUMP) += crash_dump.o | 56 | arm64-obj-$(CONFIG_CRASH_DUMP) += crash_dump.o |
| 57 | arm64-obj-$(CONFIG_CRASH_CORE) += crash_core.o | ||
| 57 | arm64-obj-$(CONFIG_ARM_SDE_INTERFACE) += sdei.o | 58 | arm64-obj-$(CONFIG_ARM_SDE_INTERFACE) += sdei.o |
| 58 | arm64-obj-$(CONFIG_ARM64_SSBD) += ssbd.o | 59 | arm64-obj-$(CONFIG_ARM64_SSBD) += ssbd.o |
| 59 | 60 | ||
diff --git a/arch/arm64/kernel/crash_core.c b/arch/arm64/kernel/crash_core.c new file mode 100644 index 000000000000..ca4c3e12d8c5 --- /dev/null +++ b/arch/arm64/kernel/crash_core.c | |||
| @@ -0,0 +1,19 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 2 | /* | ||
| 3 | * Copyright (C) Linaro. | ||
| 4 | * Copyright (C) Huawei Futurewei Technologies. | ||
| 5 | */ | ||
| 6 | |||
| 7 | #include <linux/crash_core.h> | ||
| 8 | #include <asm/memory.h> | ||
| 9 | |||
| 10 | void arch_crash_save_vmcoreinfo(void) | ||
| 11 | { | ||
| 12 | VMCOREINFO_NUMBER(VA_BITS); | ||
| 13 | /* Please note VMCOREINFO_NUMBER() uses "%d", not "%x" */ | ||
| 14 | vmcoreinfo_append_str("NUMBER(kimage_voffset)=0x%llx\n", | ||
| 15 | kimage_voffset); | ||
| 16 | vmcoreinfo_append_str("NUMBER(PHYS_OFFSET)=0x%llx\n", | ||
| 17 | PHYS_OFFSET); | ||
| 18 | vmcoreinfo_append_str("KERNELOFFSET=%lx\n", kaslr_offset()); | ||
| 19 | } | ||
diff --git a/arch/arm64/kernel/machine_kexec.c b/arch/arm64/kernel/machine_kexec.c index f6a5c6bc1434..922add8adb74 100644 --- a/arch/arm64/kernel/machine_kexec.c +++ b/arch/arm64/kernel/machine_kexec.c | |||
| @@ -358,14 +358,3 @@ void crash_free_reserved_phys_range(unsigned long begin, unsigned long end) | |||
| 358 | } | 358 | } |
| 359 | } | 359 | } |
| 360 | #endif /* CONFIG_HIBERNATION */ | 360 | #endif /* CONFIG_HIBERNATION */ |
| 361 | |||
| 362 | void arch_crash_save_vmcoreinfo(void) | ||
| 363 | { | ||
| 364 | VMCOREINFO_NUMBER(VA_BITS); | ||
| 365 | /* Please note VMCOREINFO_NUMBER() uses "%d", not "%x" */ | ||
| 366 | vmcoreinfo_append_str("NUMBER(kimage_voffset)=0x%llx\n", | ||
| 367 | kimage_voffset); | ||
| 368 | vmcoreinfo_append_str("NUMBER(PHYS_OFFSET)=0x%llx\n", | ||
| 369 | PHYS_OFFSET); | ||
| 370 | vmcoreinfo_append_str("KERNELOFFSET=%lx\n", kaslr_offset()); | ||
| 371 | } | ||
diff --git a/arch/hexagon/include/asm/bitops.h b/arch/hexagon/include/asm/bitops.h index 5e4a59b3ec1b..2691a1857d20 100644 --- a/arch/hexagon/include/asm/bitops.h +++ b/arch/hexagon/include/asm/bitops.h | |||
| @@ -211,7 +211,7 @@ static inline long ffz(int x) | |||
| 211 | * This is defined the same way as ffs. | 211 | * This is defined the same way as ffs. |
| 212 | * Note fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32. | 212 | * Note fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32. |
| 213 | */ | 213 | */ |
| 214 | static inline long fls(int x) | 214 | static inline int fls(int x) |
| 215 | { | 215 | { |
| 216 | int r; | 216 | int r; |
| 217 | 217 | ||
| @@ -232,7 +232,7 @@ static inline long fls(int x) | |||
| 232 | * the libc and compiler builtin ffs routines, therefore | 232 | * the libc and compiler builtin ffs routines, therefore |
| 233 | * differs in spirit from the above ffz (man ffs). | 233 | * differs in spirit from the above ffz (man ffs). |
| 234 | */ | 234 | */ |
| 235 | static inline long ffs(int x) | 235 | static inline int ffs(int x) |
| 236 | { | 236 | { |
| 237 | int r; | 237 | int r; |
| 238 | 238 | ||
diff --git a/arch/hexagon/kernel/dma.c b/arch/hexagon/kernel/dma.c index 77459df34e2e..7ebe7ad19d15 100644 --- a/arch/hexagon/kernel/dma.c +++ b/arch/hexagon/kernel/dma.c | |||
| @@ -60,7 +60,7 @@ static void *hexagon_dma_alloc_coherent(struct device *dev, size_t size, | |||
| 60 | panic("Can't create %s() memory pool!", __func__); | 60 | panic("Can't create %s() memory pool!", __func__); |
| 61 | else | 61 | else |
| 62 | gen_pool_add(coherent_pool, | 62 | gen_pool_add(coherent_pool, |
| 63 | pfn_to_virt(max_low_pfn), | 63 | (unsigned long)pfn_to_virt(max_low_pfn), |
| 64 | hexagon_coherent_pool_size, -1); | 64 | hexagon_coherent_pool_size, -1); |
| 65 | } | 65 | } |
| 66 | 66 | ||
diff --git a/arch/mips/include/asm/mach-lantiq/xway/xway_dma.h b/arch/mips/include/asm/mach-lantiq/xway/xway_dma.h index 4901833498f7..8441b2698e64 100644 --- a/arch/mips/include/asm/mach-lantiq/xway/xway_dma.h +++ b/arch/mips/include/asm/mach-lantiq/xway/xway_dma.h | |||
| @@ -40,6 +40,7 @@ struct ltq_dma_channel { | |||
| 40 | int desc; /* the current descriptor */ | 40 | int desc; /* the current descriptor */ |
| 41 | struct ltq_dma_desc *desc_base; /* the descriptor base */ | 41 | struct ltq_dma_desc *desc_base; /* the descriptor base */ |
| 42 | int phys; /* physical addr */ | 42 | int phys; /* physical addr */ |
| 43 | struct device *dev; | ||
| 43 | }; | 44 | }; |
| 44 | 45 | ||
| 45 | enum { | 46 | enum { |
diff --git a/arch/mips/lantiq/xway/dma.c b/arch/mips/lantiq/xway/dma.c index 4b9fbb6744ad..664f2f7f55c1 100644 --- a/arch/mips/lantiq/xway/dma.c +++ b/arch/mips/lantiq/xway/dma.c | |||
| @@ -130,7 +130,7 @@ ltq_dma_alloc(struct ltq_dma_channel *ch) | |||
| 130 | unsigned long flags; | 130 | unsigned long flags; |
| 131 | 131 | ||
| 132 | ch->desc = 0; | 132 | ch->desc = 0; |
| 133 | ch->desc_base = dma_zalloc_coherent(NULL, | 133 | ch->desc_base = dma_zalloc_coherent(ch->dev, |
| 134 | LTQ_DESC_NUM * LTQ_DESC_SIZE, | 134 | LTQ_DESC_NUM * LTQ_DESC_SIZE, |
| 135 | &ch->phys, GFP_ATOMIC); | 135 | &ch->phys, GFP_ATOMIC); |
| 136 | 136 | ||
| @@ -182,7 +182,7 @@ ltq_dma_free(struct ltq_dma_channel *ch) | |||
| 182 | if (!ch->desc_base) | 182 | if (!ch->desc_base) |
| 183 | return; | 183 | return; |
| 184 | ltq_dma_close(ch); | 184 | ltq_dma_close(ch); |
| 185 | dma_free_coherent(NULL, LTQ_DESC_NUM * LTQ_DESC_SIZE, | 185 | dma_free_coherent(ch->dev, LTQ_DESC_NUM * LTQ_DESC_SIZE, |
| 186 | ch->desc_base, ch->phys); | 186 | ch->desc_base, ch->phys); |
| 187 | } | 187 | } |
| 188 | EXPORT_SYMBOL_GPL(ltq_dma_free); | 188 | EXPORT_SYMBOL_GPL(ltq_dma_free); |
diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c index db20dc630e7e..aee603123030 100644 --- a/arch/riscv/kernel/setup.c +++ b/arch/riscv/kernel/setup.c | |||
| @@ -85,15 +85,8 @@ atomic_t hart_lottery; | |||
| 85 | #ifdef CONFIG_BLK_DEV_INITRD | 85 | #ifdef CONFIG_BLK_DEV_INITRD |
| 86 | static void __init setup_initrd(void) | 86 | static void __init setup_initrd(void) |
| 87 | { | 87 | { |
| 88 | extern char __initramfs_start[]; | ||
| 89 | extern unsigned long __initramfs_size; | ||
| 90 | unsigned long size; | 88 | unsigned long size; |
| 91 | 89 | ||
| 92 | if (__initramfs_size > 0) { | ||
| 93 | initrd_start = (unsigned long)(&__initramfs_start); | ||
| 94 | initrd_end = initrd_start + __initramfs_size; | ||
| 95 | } | ||
| 96 | |||
| 97 | if (initrd_start >= initrd_end) { | 90 | if (initrd_start >= initrd_end) { |
| 98 | printk(KERN_INFO "initrd not found or empty"); | 91 | printk(KERN_INFO "initrd not found or empty"); |
| 99 | goto disable; | 92 | goto disable; |
diff --git a/arch/s390/crypto/paes_s390.c b/arch/s390/crypto/paes_s390.c index 80b27294c1de..ab9a0ebecc19 100644 --- a/arch/s390/crypto/paes_s390.c +++ b/arch/s390/crypto/paes_s390.c | |||
| @@ -208,7 +208,7 @@ static int cbc_paes_crypt(struct blkcipher_desc *desc, unsigned long modifier, | |||
| 208 | walk->dst.virt.addr, walk->src.virt.addr, n); | 208 | walk->dst.virt.addr, walk->src.virt.addr, n); |
| 209 | if (k) | 209 | if (k) |
| 210 | ret = blkcipher_walk_done(desc, walk, nbytes - k); | 210 | ret = blkcipher_walk_done(desc, walk, nbytes - k); |
| 211 | if (n < k) { | 211 | if (k < n) { |
| 212 | if (__cbc_paes_set_key(ctx) != 0) | 212 | if (__cbc_paes_set_key(ctx) != 0) |
| 213 | return blkcipher_walk_done(desc, walk, -EIO); | 213 | return blkcipher_walk_done(desc, walk, -EIO); |
| 214 | memcpy(param.key, ctx->pk.protkey, MAXPROTKEYSIZE); | 214 | memcpy(param.key, ctx->pk.protkey, MAXPROTKEYSIZE); |
diff --git a/arch/x86/include/asm/atomic.h b/arch/x86/include/asm/atomic.h index b143717b92b3..ce84388e540c 100644 --- a/arch/x86/include/asm/atomic.h +++ b/arch/x86/include/asm/atomic.h | |||
| @@ -80,11 +80,11 @@ static __always_inline void arch_atomic_sub(int i, atomic_t *v) | |||
| 80 | * true if the result is zero, or false for all | 80 | * true if the result is zero, or false for all |
| 81 | * other cases. | 81 | * other cases. |
| 82 | */ | 82 | */ |
| 83 | #define arch_atomic_sub_and_test arch_atomic_sub_and_test | ||
| 84 | static __always_inline bool arch_atomic_sub_and_test(int i, atomic_t *v) | 83 | static __always_inline bool arch_atomic_sub_and_test(int i, atomic_t *v) |
| 85 | { | 84 | { |
| 86 | GEN_BINARY_RMWcc(LOCK_PREFIX "subl", v->counter, "er", i, "%0", e); | 85 | GEN_BINARY_RMWcc(LOCK_PREFIX "subl", v->counter, "er", i, "%0", e); |
| 87 | } | 86 | } |
| 87 | #define arch_atomic_sub_and_test arch_atomic_sub_and_test | ||
| 88 | 88 | ||
| 89 | /** | 89 | /** |
| 90 | * arch_atomic_inc - increment atomic variable | 90 | * arch_atomic_inc - increment atomic variable |
| @@ -92,12 +92,12 @@ static __always_inline bool arch_atomic_sub_and_test(int i, atomic_t *v) | |||
| 92 | * | 92 | * |
| 93 | * Atomically increments @v by 1. | 93 | * Atomically increments @v by 1. |
| 94 | */ | 94 | */ |
| 95 | #define arch_atomic_inc arch_atomic_inc | ||
| 96 | static __always_inline void arch_atomic_inc(atomic_t *v) | 95 | static __always_inline void arch_atomic_inc(atomic_t *v) |
| 97 | { | 96 | { |
| 98 | asm volatile(LOCK_PREFIX "incl %0" | 97 | asm volatile(LOCK_PREFIX "incl %0" |
| 99 | : "+m" (v->counter)); | 98 | : "+m" (v->counter)); |
| 100 | } | 99 | } |
| 100 | #define arch_atomic_inc arch_atomic_inc | ||
| 101 | 101 | ||
| 102 | /** | 102 | /** |
| 103 | * arch_atomic_dec - decrement atomic variable | 103 | * arch_atomic_dec - decrement atomic variable |
| @@ -105,12 +105,12 @@ static __always_inline void arch_atomic_inc(atomic_t *v) | |||
| 105 | * | 105 | * |
| 106 | * Atomically decrements @v by 1. | 106 | * Atomically decrements @v by 1. |
| 107 | */ | 107 | */ |
| 108 | #define arch_atomic_dec arch_atomic_dec | ||
| 109 | static __always_inline void arch_atomic_dec(atomic_t *v) | 108 | static __always_inline void arch_atomic_dec(atomic_t *v) |
| 110 | { | 109 | { |
| 111 | asm volatile(LOCK_PREFIX "decl %0" | 110 | asm volatile(LOCK_PREFIX "decl %0" |
| 112 | : "+m" (v->counter)); | 111 | : "+m" (v->counter)); |
| 113 | } | 112 | } |
| 113 | #define arch_atomic_dec arch_atomic_dec | ||
| 114 | 114 | ||
| 115 | /** | 115 | /** |
| 116 | * arch_atomic_dec_and_test - decrement and test | 116 | * arch_atomic_dec_and_test - decrement and test |
| @@ -120,11 +120,11 @@ static __always_inline void arch_atomic_dec(atomic_t *v) | |||
| 120 | * returns true if the result is 0, or false for all other | 120 | * returns true if the result is 0, or false for all other |
| 121 | * cases. | 121 | * cases. |
| 122 | */ | 122 | */ |
| 123 | #define arch_atomic_dec_and_test arch_atomic_dec_and_test | ||
| 124 | static __always_inline bool arch_atomic_dec_and_test(atomic_t *v) | 123 | static __always_inline bool arch_atomic_dec_and_test(atomic_t *v) |
| 125 | { | 124 | { |
| 126 | GEN_UNARY_RMWcc(LOCK_PREFIX "decl", v->counter, "%0", e); | 125 | GEN_UNARY_RMWcc(LOCK_PREFIX "decl", v->counter, "%0", e); |
| 127 | } | 126 | } |
| 127 | #define arch_atomic_dec_and_test arch_atomic_dec_and_test | ||
| 128 | 128 | ||
| 129 | /** | 129 | /** |
| 130 | * arch_atomic_inc_and_test - increment and test | 130 | * arch_atomic_inc_and_test - increment and test |
| @@ -134,11 +134,11 @@ static __always_inline bool arch_atomic_dec_and_test(atomic_t *v) | |||
| 134 | * and returns true if the result is zero, or false for all | 134 | * and returns true if the result is zero, or false for all |
| 135 | * other cases. | 135 | * other cases. |
| 136 | */ | 136 | */ |
| 137 | #define arch_atomic_inc_and_test arch_atomic_inc_and_test | ||
| 138 | static __always_inline bool arch_atomic_inc_and_test(atomic_t *v) | 137 | static __always_inline bool arch_atomic_inc_and_test(atomic_t *v) |
| 139 | { | 138 | { |
| 140 | GEN_UNARY_RMWcc(LOCK_PREFIX "incl", v->counter, "%0", e); | 139 | GEN_UNARY_RMWcc(LOCK_PREFIX "incl", v->counter, "%0", e); |
| 141 | } | 140 | } |
| 141 | #define arch_atomic_inc_and_test arch_atomic_inc_and_test | ||
| 142 | 142 | ||
| 143 | /** | 143 | /** |
| 144 | * arch_atomic_add_negative - add and test if negative | 144 | * arch_atomic_add_negative - add and test if negative |
| @@ -149,11 +149,11 @@ static __always_inline bool arch_atomic_inc_and_test(atomic_t *v) | |||
| 149 | * if the result is negative, or false when | 149 | * if the result is negative, or false when |
| 150 | * result is greater than or equal to zero. | 150 | * result is greater than or equal to zero. |
| 151 | */ | 151 | */ |
| 152 | #define arch_atomic_add_negative arch_atomic_add_negative | ||
| 153 | static __always_inline bool arch_atomic_add_negative(int i, atomic_t *v) | 152 | static __always_inline bool arch_atomic_add_negative(int i, atomic_t *v) |
| 154 | { | 153 | { |
| 155 | GEN_BINARY_RMWcc(LOCK_PREFIX "addl", v->counter, "er", i, "%0", s); | 154 | GEN_BINARY_RMWcc(LOCK_PREFIX "addl", v->counter, "er", i, "%0", s); |
| 156 | } | 155 | } |
| 156 | #define arch_atomic_add_negative arch_atomic_add_negative | ||
| 157 | 157 | ||
| 158 | /** | 158 | /** |
| 159 | * arch_atomic_add_return - add integer and return | 159 | * arch_atomic_add_return - add integer and return |
diff --git a/arch/x86/include/asm/atomic64_32.h b/arch/x86/include/asm/atomic64_32.h index ef959f02d070..6a5b0ec460da 100644 --- a/arch/x86/include/asm/atomic64_32.h +++ b/arch/x86/include/asm/atomic64_32.h | |||
| @@ -205,12 +205,12 @@ static inline long long arch_atomic64_sub(long long i, atomic64_t *v) | |||
| 205 | * | 205 | * |
| 206 | * Atomically increments @v by 1. | 206 | * Atomically increments @v by 1. |
| 207 | */ | 207 | */ |
| 208 | #define arch_atomic64_inc arch_atomic64_inc | ||
| 209 | static inline void arch_atomic64_inc(atomic64_t *v) | 208 | static inline void arch_atomic64_inc(atomic64_t *v) |
| 210 | { | 209 | { |
| 211 | __alternative_atomic64(inc, inc_return, /* no output */, | 210 | __alternative_atomic64(inc, inc_return, /* no output */, |
| 212 | "S" (v) : "memory", "eax", "ecx", "edx"); | 211 | "S" (v) : "memory", "eax", "ecx", "edx"); |
| 213 | } | 212 | } |
| 213 | #define arch_atomic64_inc arch_atomic64_inc | ||
| 214 | 214 | ||
| 215 | /** | 215 | /** |
| 216 | * arch_atomic64_dec - decrement atomic64 variable | 216 | * arch_atomic64_dec - decrement atomic64 variable |
| @@ -218,12 +218,12 @@ static inline void arch_atomic64_inc(atomic64_t *v) | |||
| 218 | * | 218 | * |
| 219 | * Atomically decrements @v by 1. | 219 | * Atomically decrements @v by 1. |
| 220 | */ | 220 | */ |
| 221 | #define arch_atomic64_dec arch_atomic64_dec | ||
| 222 | static inline void arch_atomic64_dec(atomic64_t *v) | 221 | static inline void arch_atomic64_dec(atomic64_t *v) |
| 223 | { | 222 | { |
| 224 | __alternative_atomic64(dec, dec_return, /* no output */, | 223 | __alternative_atomic64(dec, dec_return, /* no output */, |
| 225 | "S" (v) : "memory", "eax", "ecx", "edx"); | 224 | "S" (v) : "memory", "eax", "ecx", "edx"); |
| 226 | } | 225 | } |
| 226 | #define arch_atomic64_dec arch_atomic64_dec | ||
| 227 | 227 | ||
| 228 | /** | 228 | /** |
| 229 | * arch_atomic64_add_unless - add unless the number is a given value | 229 | * arch_atomic64_add_unless - add unless the number is a given value |
| @@ -245,7 +245,6 @@ static inline int arch_atomic64_add_unless(atomic64_t *v, long long a, | |||
| 245 | return (int)a; | 245 | return (int)a; |
| 246 | } | 246 | } |
| 247 | 247 | ||
| 248 | #define arch_atomic64_inc_not_zero arch_atomic64_inc_not_zero | ||
| 249 | static inline int arch_atomic64_inc_not_zero(atomic64_t *v) | 248 | static inline int arch_atomic64_inc_not_zero(atomic64_t *v) |
| 250 | { | 249 | { |
| 251 | int r; | 250 | int r; |
| @@ -253,8 +252,8 @@ static inline int arch_atomic64_inc_not_zero(atomic64_t *v) | |||
| 253 | "S" (v) : "ecx", "edx", "memory"); | 252 | "S" (v) : "ecx", "edx", "memory"); |
| 254 | return r; | 253 | return r; |
| 255 | } | 254 | } |
| 255 | #define arch_atomic64_inc_not_zero arch_atomic64_inc_not_zero | ||
| 256 | 256 | ||
| 257 | #define arch_atomic64_dec_if_positive arch_atomic64_dec_if_positive | ||
| 258 | static inline long long arch_atomic64_dec_if_positive(atomic64_t *v) | 257 | static inline long long arch_atomic64_dec_if_positive(atomic64_t *v) |
| 259 | { | 258 | { |
| 260 | long long r; | 259 | long long r; |
| @@ -262,6 +261,7 @@ static inline long long arch_atomic64_dec_if_positive(atomic64_t *v) | |||
| 262 | "S" (v) : "ecx", "memory"); | 261 | "S" (v) : "ecx", "memory"); |
| 263 | return r; | 262 | return r; |
| 264 | } | 263 | } |
| 264 | #define arch_atomic64_dec_if_positive arch_atomic64_dec_if_positive | ||
| 265 | 265 | ||
| 266 | #undef alternative_atomic64 | 266 | #undef alternative_atomic64 |
| 267 | #undef __alternative_atomic64 | 267 | #undef __alternative_atomic64 |
diff --git a/arch/x86/include/asm/atomic64_64.h b/arch/x86/include/asm/atomic64_64.h index 4343d9b4f30e..5f851d92eecd 100644 --- a/arch/x86/include/asm/atomic64_64.h +++ b/arch/x86/include/asm/atomic64_64.h | |||
| @@ -71,11 +71,11 @@ static inline void arch_atomic64_sub(long i, atomic64_t *v) | |||
| 71 | * true if the result is zero, or false for all | 71 | * true if the result is zero, or false for all |
| 72 | * other cases. | 72 | * other cases. |
| 73 | */ | 73 | */ |
| 74 | #define arch_atomic64_sub_and_test arch_atomic64_sub_and_test | ||
| 75 | static inline bool arch_atomic64_sub_and_test(long i, atomic64_t *v) | 74 | static inline bool arch_atomic64_sub_and_test(long i, atomic64_t *v) |
| 76 | { | 75 | { |
| 77 | GEN_BINARY_RMWcc(LOCK_PREFIX "subq", v->counter, "er", i, "%0", e); | 76 | GEN_BINARY_RMWcc(LOCK_PREFIX "subq", v->counter, "er", i, "%0", e); |
| 78 | } | 77 | } |
| 78 | #define arch_atomic64_sub_and_test arch_atomic64_sub_and_test | ||
| 79 | 79 | ||
| 80 | /** | 80 | /** |
| 81 | * arch_atomic64_inc - increment atomic64 variable | 81 | * arch_atomic64_inc - increment atomic64 variable |
| @@ -83,13 +83,13 @@ static inline bool arch_atomic64_sub_and_test(long i, atomic64_t *v) | |||
| 83 | * | 83 | * |
| 84 | * Atomically increments @v by 1. | 84 | * Atomically increments @v by 1. |
| 85 | */ | 85 | */ |
| 86 | #define arch_atomic64_inc arch_atomic64_inc | ||
| 87 | static __always_inline void arch_atomic64_inc(atomic64_t *v) | 86 | static __always_inline void arch_atomic64_inc(atomic64_t *v) |
| 88 | { | 87 | { |
| 89 | asm volatile(LOCK_PREFIX "incq %0" | 88 | asm volatile(LOCK_PREFIX "incq %0" |
| 90 | : "=m" (v->counter) | 89 | : "=m" (v->counter) |
| 91 | : "m" (v->counter)); | 90 | : "m" (v->counter)); |
| 92 | } | 91 | } |
| 92 | #define arch_atomic64_inc arch_atomic64_inc | ||
| 93 | 93 | ||
| 94 | /** | 94 | /** |
| 95 | * arch_atomic64_dec - decrement atomic64 variable | 95 | * arch_atomic64_dec - decrement atomic64 variable |
| @@ -97,13 +97,13 @@ static __always_inline void arch_atomic64_inc(atomic64_t *v) | |||
| 97 | * | 97 | * |
| 98 | * Atomically decrements @v by 1. | 98 | * Atomically decrements @v by 1. |
| 99 | */ | 99 | */ |
| 100 | #define arch_atomic64_dec arch_atomic64_dec | ||
| 101 | static __always_inline void arch_atomic64_dec(atomic64_t *v) | 100 | static __always_inline void arch_atomic64_dec(atomic64_t *v) |
| 102 | { | 101 | { |
| 103 | asm volatile(LOCK_PREFIX "decq %0" | 102 | asm volatile(LOCK_PREFIX "decq %0" |
| 104 | : "=m" (v->counter) | 103 | : "=m" (v->counter) |
| 105 | : "m" (v->counter)); | 104 | : "m" (v->counter)); |
| 106 | } | 105 | } |
| 106 | #define arch_atomic64_dec arch_atomic64_dec | ||
| 107 | 107 | ||
| 108 | /** | 108 | /** |
| 109 | * arch_atomic64_dec_and_test - decrement and test | 109 | * arch_atomic64_dec_and_test - decrement and test |
| @@ -113,11 +113,11 @@ static __always_inline void arch_atomic64_dec(atomic64_t *v) | |||
| 113 | * returns true if the result is 0, or false for all other | 113 | * returns true if the result is 0, or false for all other |
| 114 | * cases. | 114 | * cases. |
| 115 | */ | 115 | */ |
| 116 | #define arch_atomic64_dec_and_test arch_atomic64_dec_and_test | ||
| 117 | static inline bool arch_atomic64_dec_and_test(atomic64_t *v) | 116 | static inline bool arch_atomic64_dec_and_test(atomic64_t *v) |
| 118 | { | 117 | { |
| 119 | GEN_UNARY_RMWcc(LOCK_PREFIX "decq", v->counter, "%0", e); | 118 | GEN_UNARY_RMWcc(LOCK_PREFIX "decq", v->counter, "%0", e); |
| 120 | } | 119 | } |
| 120 | #define arch_atomic64_dec_and_test arch_atomic64_dec_and_test | ||
| 121 | 121 | ||
| 122 | /** | 122 | /** |
| 123 | * arch_atomic64_inc_and_test - increment and test | 123 | * arch_atomic64_inc_and_test - increment and test |
| @@ -127,11 +127,11 @@ static inline bool arch_atomic64_dec_and_test(atomic64_t *v) | |||
| 127 | * and returns true if the result is zero, or false for all | 127 | * and returns true if the result is zero, or false for all |
| 128 | * other cases. | 128 | * other cases. |
| 129 | */ | 129 | */ |
| 130 | #define arch_atomic64_inc_and_test arch_atomic64_inc_and_test | ||
| 131 | static inline bool arch_atomic64_inc_and_test(atomic64_t *v) | 130 | static inline bool arch_atomic64_inc_and_test(atomic64_t *v) |
| 132 | { | 131 | { |
| 133 | GEN_UNARY_RMWcc(LOCK_PREFIX "incq", v->counter, "%0", e); | 132 | GEN_UNARY_RMWcc(LOCK_PREFIX "incq", v->counter, "%0", e); |
| 134 | } | 133 | } |
| 134 | #define arch_atomic64_inc_and_test arch_atomic64_inc_and_test | ||
| 135 | 135 | ||
| 136 | /** | 136 | /** |
| 137 | * arch_atomic64_add_negative - add and test if negative | 137 | * arch_atomic64_add_negative - add and test if negative |
| @@ -142,11 +142,11 @@ static inline bool arch_atomic64_inc_and_test(atomic64_t *v) | |||
| 142 | * if the result is negative, or false when | 142 | * if the result is negative, or false when |
| 143 | * result is greater than or equal to zero. | 143 | * result is greater than or equal to zero. |
| 144 | */ | 144 | */ |
| 145 | #define arch_atomic64_add_negative arch_atomic64_add_negative | ||
| 146 | static inline bool arch_atomic64_add_negative(long i, atomic64_t *v) | 145 | static inline bool arch_atomic64_add_negative(long i, atomic64_t *v) |
| 147 | { | 146 | { |
| 148 | GEN_BINARY_RMWcc(LOCK_PREFIX "addq", v->counter, "er", i, "%0", s); | 147 | GEN_BINARY_RMWcc(LOCK_PREFIX "addq", v->counter, "er", i, "%0", s); |
| 149 | } | 148 | } |
| 149 | #define arch_atomic64_add_negative arch_atomic64_add_negative | ||
| 150 | 150 | ||
| 151 | /** | 151 | /** |
| 152 | * arch_atomic64_add_return - add and return | 152 | * arch_atomic64_add_return - add and return |
diff --git a/arch/x86/include/asm/kdebug.h b/arch/x86/include/asm/kdebug.h index 395c9631e000..75f1e35e7c15 100644 --- a/arch/x86/include/asm/kdebug.h +++ b/arch/x86/include/asm/kdebug.h | |||
| @@ -22,10 +22,20 @@ enum die_val { | |||
| 22 | DIE_NMIUNKNOWN, | 22 | DIE_NMIUNKNOWN, |
| 23 | }; | 23 | }; |
| 24 | 24 | ||
| 25 | enum show_regs_mode { | ||
| 26 | SHOW_REGS_SHORT, | ||
| 27 | /* | ||
| 28 | * For when userspace crashed, but we don't think it's our fault, and | ||
| 29 | * therefore don't print kernel registers. | ||
| 30 | */ | ||
| 31 | SHOW_REGS_USER, | ||
| 32 | SHOW_REGS_ALL | ||
| 33 | }; | ||
| 34 | |||
| 25 | extern void die(const char *, struct pt_regs *,long); | 35 | extern void die(const char *, struct pt_regs *,long); |
| 26 | extern int __must_check __die(const char *, struct pt_regs *, long); | 36 | extern int __must_check __die(const char *, struct pt_regs *, long); |
| 27 | extern void show_stack_regs(struct pt_regs *regs); | 37 | extern void show_stack_regs(struct pt_regs *regs); |
| 28 | extern void __show_regs(struct pt_regs *regs, int all); | 38 | extern void __show_regs(struct pt_regs *regs, enum show_regs_mode); |
| 29 | extern void show_iret_regs(struct pt_regs *regs); | 39 | extern void show_iret_regs(struct pt_regs *regs); |
| 30 | extern unsigned long oops_begin(void); | 40 | extern unsigned long oops_begin(void); |
| 31 | extern void oops_end(unsigned long, struct pt_regs *, int signr); | 41 | extern void oops_end(unsigned long, struct pt_regs *, int signr); |
diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h index e4ffa565a69f..690c0307afed 100644 --- a/arch/x86/include/asm/pgtable.h +++ b/arch/x86/include/asm/pgtable.h | |||
| @@ -1195,7 +1195,7 @@ static inline pmd_t pmdp_establish(struct vm_area_struct *vma, | |||
| 1195 | return xchg(pmdp, pmd); | 1195 | return xchg(pmdp, pmd); |
| 1196 | } else { | 1196 | } else { |
| 1197 | pmd_t old = *pmdp; | 1197 | pmd_t old = *pmdp; |
| 1198 | *pmdp = pmd; | 1198 | WRITE_ONCE(*pmdp, pmd); |
| 1199 | return old; | 1199 | return old; |
| 1200 | } | 1200 | } |
| 1201 | } | 1201 | } |
diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h index f773d5e6c8cc..ce2b59047cb8 100644 --- a/arch/x86/include/asm/pgtable_64.h +++ b/arch/x86/include/asm/pgtable_64.h | |||
| @@ -55,15 +55,15 @@ struct mm_struct; | |||
| 55 | void set_pte_vaddr_p4d(p4d_t *p4d_page, unsigned long vaddr, pte_t new_pte); | 55 | void set_pte_vaddr_p4d(p4d_t *p4d_page, unsigned long vaddr, pte_t new_pte); |
| 56 | void set_pte_vaddr_pud(pud_t *pud_page, unsigned long vaddr, pte_t new_pte); | 56 | void set_pte_vaddr_pud(pud_t *pud_page, unsigned long vaddr, pte_t new_pte); |
| 57 | 57 | ||
| 58 | static inline void native_pte_clear(struct mm_struct *mm, unsigned long addr, | 58 | static inline void native_set_pte(pte_t *ptep, pte_t pte) |
| 59 | pte_t *ptep) | ||
| 60 | { | 59 | { |
| 61 | *ptep = native_make_pte(0); | 60 | WRITE_ONCE(*ptep, pte); |
| 62 | } | 61 | } |
| 63 | 62 | ||
| 64 | static inline void native_set_pte(pte_t *ptep, pte_t pte) | 63 | static inline void native_pte_clear(struct mm_struct *mm, unsigned long addr, |
| 64 | pte_t *ptep) | ||
| 65 | { | 65 | { |
| 66 | *ptep = pte; | 66 | native_set_pte(ptep, native_make_pte(0)); |
| 67 | } | 67 | } |
| 68 | 68 | ||
| 69 | static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte) | 69 | static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte) |
| @@ -73,7 +73,7 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte) | |||
| 73 | 73 | ||
| 74 | static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd) | 74 | static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd) |
| 75 | { | 75 | { |
| 76 | *pmdp = pmd; | 76 | WRITE_ONCE(*pmdp, pmd); |
| 77 | } | 77 | } |
| 78 | 78 | ||
| 79 | static inline void native_pmd_clear(pmd_t *pmd) | 79 | static inline void native_pmd_clear(pmd_t *pmd) |
| @@ -109,7 +109,7 @@ static inline pmd_t native_pmdp_get_and_clear(pmd_t *xp) | |||
| 109 | 109 | ||
| 110 | static inline void native_set_pud(pud_t *pudp, pud_t pud) | 110 | static inline void native_set_pud(pud_t *pudp, pud_t pud) |
| 111 | { | 111 | { |
| 112 | *pudp = pud; | 112 | WRITE_ONCE(*pudp, pud); |
| 113 | } | 113 | } |
| 114 | 114 | ||
| 115 | static inline void native_pud_clear(pud_t *pud) | 115 | static inline void native_pud_clear(pud_t *pud) |
| @@ -137,13 +137,13 @@ static inline void native_set_p4d(p4d_t *p4dp, p4d_t p4d) | |||
| 137 | pgd_t pgd; | 137 | pgd_t pgd; |
| 138 | 138 | ||
| 139 | if (pgtable_l5_enabled() || !IS_ENABLED(CONFIG_PAGE_TABLE_ISOLATION)) { | 139 | if (pgtable_l5_enabled() || !IS_ENABLED(CONFIG_PAGE_TABLE_ISOLATION)) { |
| 140 | *p4dp = p4d; | 140 | WRITE_ONCE(*p4dp, p4d); |
| 141 | return; | 141 | return; |
| 142 | } | 142 | } |
| 143 | 143 | ||
| 144 | pgd = native_make_pgd(native_p4d_val(p4d)); | 144 | pgd = native_make_pgd(native_p4d_val(p4d)); |
| 145 | pgd = pti_set_user_pgtbl((pgd_t *)p4dp, pgd); | 145 | pgd = pti_set_user_pgtbl((pgd_t *)p4dp, pgd); |
| 146 | *p4dp = native_make_p4d(native_pgd_val(pgd)); | 146 | WRITE_ONCE(*p4dp, native_make_p4d(native_pgd_val(pgd))); |
| 147 | } | 147 | } |
| 148 | 148 | ||
| 149 | static inline void native_p4d_clear(p4d_t *p4d) | 149 | static inline void native_p4d_clear(p4d_t *p4d) |
| @@ -153,7 +153,7 @@ static inline void native_p4d_clear(p4d_t *p4d) | |||
| 153 | 153 | ||
| 154 | static inline void native_set_pgd(pgd_t *pgdp, pgd_t pgd) | 154 | static inline void native_set_pgd(pgd_t *pgdp, pgd_t pgd) |
| 155 | { | 155 | { |
| 156 | *pgdp = pti_set_user_pgtbl(pgdp, pgd); | 156 | WRITE_ONCE(*pgdp, pti_set_user_pgtbl(pgdp, pgd)); |
| 157 | } | 157 | } |
| 158 | 158 | ||
| 159 | static inline void native_pgd_clear(pgd_t *pgd) | 159 | static inline void native_pgd_clear(pgd_t *pgd) |
diff --git a/arch/x86/kernel/apic/vector.c b/arch/x86/kernel/apic/vector.c index 9f148e3d45b4..7654febd5102 100644 --- a/arch/x86/kernel/apic/vector.c +++ b/arch/x86/kernel/apic/vector.c | |||
| @@ -413,7 +413,7 @@ static int activate_managed(struct irq_data *irqd) | |||
| 413 | if (WARN_ON_ONCE(cpumask_empty(vector_searchmask))) { | 413 | if (WARN_ON_ONCE(cpumask_empty(vector_searchmask))) { |
| 414 | /* Something in the core code broke! Survive gracefully */ | 414 | /* Something in the core code broke! Survive gracefully */ |
| 415 | pr_err("Managed startup for irq %u, but no CPU\n", irqd->irq); | 415 | pr_err("Managed startup for irq %u, but no CPU\n", irqd->irq); |
| 416 | return EINVAL; | 416 | return -EINVAL; |
| 417 | } | 417 | } |
| 418 | 418 | ||
| 419 | ret = assign_managed_vector(irqd, vector_searchmask); | 419 | ret = assign_managed_vector(irqd, vector_searchmask); |
diff --git a/arch/x86/kernel/cpu/microcode/amd.c b/arch/x86/kernel/cpu/microcode/amd.c index 0624957aa068..07b5fc00b188 100644 --- a/arch/x86/kernel/cpu/microcode/amd.c +++ b/arch/x86/kernel/cpu/microcode/amd.c | |||
| @@ -504,6 +504,7 @@ static enum ucode_state apply_microcode_amd(int cpu) | |||
| 504 | struct microcode_amd *mc_amd; | 504 | struct microcode_amd *mc_amd; |
| 505 | struct ucode_cpu_info *uci; | 505 | struct ucode_cpu_info *uci; |
| 506 | struct ucode_patch *p; | 506 | struct ucode_patch *p; |
| 507 | enum ucode_state ret; | ||
| 507 | u32 rev, dummy; | 508 | u32 rev, dummy; |
| 508 | 509 | ||
| 509 | BUG_ON(raw_smp_processor_id() != cpu); | 510 | BUG_ON(raw_smp_processor_id() != cpu); |
| @@ -521,9 +522,8 @@ static enum ucode_state apply_microcode_amd(int cpu) | |||
| 521 | 522 | ||
| 522 | /* need to apply patch? */ | 523 | /* need to apply patch? */ |
| 523 | if (rev >= mc_amd->hdr.patch_id) { | 524 | if (rev >= mc_amd->hdr.patch_id) { |
| 524 | c->microcode = rev; | 525 | ret = UCODE_OK; |
| 525 | uci->cpu_sig.rev = rev; | 526 | goto out; |
| 526 | return UCODE_OK; | ||
| 527 | } | 527 | } |
| 528 | 528 | ||
| 529 | if (__apply_microcode_amd(mc_amd)) { | 529 | if (__apply_microcode_amd(mc_amd)) { |
| @@ -531,13 +531,21 @@ static enum ucode_state apply_microcode_amd(int cpu) | |||
| 531 | cpu, mc_amd->hdr.patch_id); | 531 | cpu, mc_amd->hdr.patch_id); |
| 532 | return UCODE_ERROR; | 532 | return UCODE_ERROR; |
| 533 | } | 533 | } |
| 534 | pr_info("CPU%d: new patch_level=0x%08x\n", cpu, | ||
| 535 | mc_amd->hdr.patch_id); | ||
| 536 | 534 | ||
| 537 | uci->cpu_sig.rev = mc_amd->hdr.patch_id; | 535 | rev = mc_amd->hdr.patch_id; |
| 538 | c->microcode = mc_amd->hdr.patch_id; | 536 | ret = UCODE_UPDATED; |
| 537 | |||
| 538 | pr_info("CPU%d: new patch_level=0x%08x\n", cpu, rev); | ||
| 539 | 539 | ||
| 540 | return UCODE_UPDATED; | 540 | out: |
| 541 | uci->cpu_sig.rev = rev; | ||
| 542 | c->microcode = rev; | ||
| 543 | |||
| 544 | /* Update boot_cpu_data's revision too, if we're on the BSP: */ | ||
| 545 | if (c->cpu_index == boot_cpu_data.cpu_index) | ||
| 546 | boot_cpu_data.microcode = rev; | ||
| 547 | |||
| 548 | return ret; | ||
| 541 | } | 549 | } |
| 542 | 550 | ||
| 543 | static int install_equiv_cpu_table(const u8 *buf) | 551 | static int install_equiv_cpu_table(const u8 *buf) |
diff --git a/arch/x86/kernel/cpu/microcode/intel.c b/arch/x86/kernel/cpu/microcode/intel.c index 97ccf4c3b45b..16936a24795c 100644 --- a/arch/x86/kernel/cpu/microcode/intel.c +++ b/arch/x86/kernel/cpu/microcode/intel.c | |||
| @@ -795,6 +795,7 @@ static enum ucode_state apply_microcode_intel(int cpu) | |||
| 795 | struct ucode_cpu_info *uci = ucode_cpu_info + cpu; | 795 | struct ucode_cpu_info *uci = ucode_cpu_info + cpu; |
| 796 | struct cpuinfo_x86 *c = &cpu_data(cpu); | 796 | struct cpuinfo_x86 *c = &cpu_data(cpu); |
| 797 | struct microcode_intel *mc; | 797 | struct microcode_intel *mc; |
| 798 | enum ucode_state ret; | ||
| 798 | static int prev_rev; | 799 | static int prev_rev; |
| 799 | u32 rev; | 800 | u32 rev; |
| 800 | 801 | ||
| @@ -817,9 +818,8 @@ static enum ucode_state apply_microcode_intel(int cpu) | |||
| 817 | */ | 818 | */ |
| 818 | rev = intel_get_microcode_revision(); | 819 | rev = intel_get_microcode_revision(); |
| 819 | if (rev >= mc->hdr.rev) { | 820 | if (rev >= mc->hdr.rev) { |
| 820 | uci->cpu_sig.rev = rev; | 821 | ret = UCODE_OK; |
| 821 | c->microcode = rev; | 822 | goto out; |
| 822 | return UCODE_OK; | ||
| 823 | } | 823 | } |
| 824 | 824 | ||
| 825 | /* | 825 | /* |
| @@ -848,10 +848,17 @@ static enum ucode_state apply_microcode_intel(int cpu) | |||
| 848 | prev_rev = rev; | 848 | prev_rev = rev; |
| 849 | } | 849 | } |
| 850 | 850 | ||
| 851 | ret = UCODE_UPDATED; | ||
| 852 | |||
| 853 | out: | ||
| 851 | uci->cpu_sig.rev = rev; | 854 | uci->cpu_sig.rev = rev; |
| 852 | c->microcode = rev; | 855 | c->microcode = rev; |
| 856 | |||
| 857 | /* Update boot_cpu_data's revision too, if we're on the BSP: */ | ||
| 858 | if (c->cpu_index == boot_cpu_data.cpu_index) | ||
| 859 | boot_cpu_data.microcode = rev; | ||
| 853 | 860 | ||
| 854 | return UCODE_UPDATED; | 861 | return ret; |
| 855 | } | 862 | } |
| 856 | 863 | ||
| 857 | static enum ucode_state generic_load_microcode(int cpu, void *data, size_t size, | 864 | static enum ucode_state generic_load_microcode(int cpu, void *data, size_t size, |
diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c index f56895106ccf..2b5886401e5f 100644 --- a/arch/x86/kernel/dumpstack.c +++ b/arch/x86/kernel/dumpstack.c | |||
| @@ -146,7 +146,7 @@ static void show_regs_if_on_stack(struct stack_info *info, struct pt_regs *regs, | |||
| 146 | * they can be printed in the right context. | 146 | * they can be printed in the right context. |
| 147 | */ | 147 | */ |
| 148 | if (!partial && on_stack(info, regs, sizeof(*regs))) { | 148 | if (!partial && on_stack(info, regs, sizeof(*regs))) { |
| 149 | __show_regs(regs, 0); | 149 | __show_regs(regs, SHOW_REGS_SHORT); |
| 150 | 150 | ||
| 151 | } else if (partial && on_stack(info, (void *)regs + IRET_FRAME_OFFSET, | 151 | } else if (partial && on_stack(info, (void *)regs + IRET_FRAME_OFFSET, |
| 152 | IRET_FRAME_SIZE)) { | 152 | IRET_FRAME_SIZE)) { |
| @@ -344,7 +344,7 @@ void oops_end(unsigned long flags, struct pt_regs *regs, int signr) | |||
| 344 | oops_exit(); | 344 | oops_exit(); |
| 345 | 345 | ||
| 346 | /* Executive summary in case the oops scrolled away */ | 346 | /* Executive summary in case the oops scrolled away */ |
| 347 | __show_regs(&exec_summary_regs, true); | 347 | __show_regs(&exec_summary_regs, SHOW_REGS_ALL); |
| 348 | 348 | ||
| 349 | if (!signr) | 349 | if (!signr) |
| 350 | return; | 350 | return; |
| @@ -407,14 +407,9 @@ void die(const char *str, struct pt_regs *regs, long err) | |||
| 407 | 407 | ||
| 408 | void show_regs(struct pt_regs *regs) | 408 | void show_regs(struct pt_regs *regs) |
| 409 | { | 409 | { |
| 410 | bool all = true; | ||
| 411 | |||
| 412 | show_regs_print_info(KERN_DEFAULT); | 410 | show_regs_print_info(KERN_DEFAULT); |
| 413 | 411 | ||
| 414 | if (IS_ENABLED(CONFIG_X86_32)) | 412 | __show_regs(regs, user_mode(regs) ? SHOW_REGS_USER : SHOW_REGS_ALL); |
| 415 | all = !user_mode(regs); | ||
| 416 | |||
| 417 | __show_regs(regs, all); | ||
| 418 | 413 | ||
| 419 | /* | 414 | /* |
| 420 | * When in-kernel, we also print out the stack at the time of the fault.. | 415 | * When in-kernel, we also print out the stack at the time of the fault.. |
diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c index 2924fd447e61..5046a3c9dec2 100644 --- a/arch/x86/kernel/process_32.c +++ b/arch/x86/kernel/process_32.c | |||
| @@ -59,7 +59,7 @@ | |||
| 59 | #include <asm/intel_rdt_sched.h> | 59 | #include <asm/intel_rdt_sched.h> |
| 60 | #include <asm/proto.h> | 60 | #include <asm/proto.h> |
| 61 | 61 | ||
| 62 | void __show_regs(struct pt_regs *regs, int all) | 62 | void __show_regs(struct pt_regs *regs, enum show_regs_mode mode) |
| 63 | { | 63 | { |
| 64 | unsigned long cr0 = 0L, cr2 = 0L, cr3 = 0L, cr4 = 0L; | 64 | unsigned long cr0 = 0L, cr2 = 0L, cr3 = 0L, cr4 = 0L; |
| 65 | unsigned long d0, d1, d2, d3, d6, d7; | 65 | unsigned long d0, d1, d2, d3, d6, d7; |
| @@ -85,7 +85,7 @@ void __show_regs(struct pt_regs *regs, int all) | |||
| 85 | printk(KERN_DEFAULT "DS: %04x ES: %04x FS: %04x GS: %04x SS: %04x EFLAGS: %08lx\n", | 85 | printk(KERN_DEFAULT "DS: %04x ES: %04x FS: %04x GS: %04x SS: %04x EFLAGS: %08lx\n", |
| 86 | (u16)regs->ds, (u16)regs->es, (u16)regs->fs, gs, ss, regs->flags); | 86 | (u16)regs->ds, (u16)regs->es, (u16)regs->fs, gs, ss, regs->flags); |
| 87 | 87 | ||
| 88 | if (!all) | 88 | if (mode != SHOW_REGS_ALL) |
| 89 | return; | 89 | return; |
| 90 | 90 | ||
| 91 | cr0 = read_cr0(); | 91 | cr0 = read_cr0(); |
diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c index a451bc374b9b..ea5ea850348d 100644 --- a/arch/x86/kernel/process_64.c +++ b/arch/x86/kernel/process_64.c | |||
| @@ -62,7 +62,7 @@ | |||
| 62 | __visible DEFINE_PER_CPU(unsigned long, rsp_scratch); | 62 | __visible DEFINE_PER_CPU(unsigned long, rsp_scratch); |
| 63 | 63 | ||
| 64 | /* Prints also some state that isn't saved in the pt_regs */ | 64 | /* Prints also some state that isn't saved in the pt_regs */ |
| 65 | void __show_regs(struct pt_regs *regs, int all) | 65 | void __show_regs(struct pt_regs *regs, enum show_regs_mode mode) |
| 66 | { | 66 | { |
| 67 | unsigned long cr0 = 0L, cr2 = 0L, cr3 = 0L, cr4 = 0L, fs, gs, shadowgs; | 67 | unsigned long cr0 = 0L, cr2 = 0L, cr3 = 0L, cr4 = 0L, fs, gs, shadowgs; |
| 68 | unsigned long d0, d1, d2, d3, d6, d7; | 68 | unsigned long d0, d1, d2, d3, d6, d7; |
| @@ -87,9 +87,17 @@ void __show_regs(struct pt_regs *regs, int all) | |||
| 87 | printk(KERN_DEFAULT "R13: %016lx R14: %016lx R15: %016lx\n", | 87 | printk(KERN_DEFAULT "R13: %016lx R14: %016lx R15: %016lx\n", |
| 88 | regs->r13, regs->r14, regs->r15); | 88 | regs->r13, regs->r14, regs->r15); |
| 89 | 89 | ||
| 90 | if (!all) | 90 | if (mode == SHOW_REGS_SHORT) |
| 91 | return; | 91 | return; |
| 92 | 92 | ||
| 93 | if (mode == SHOW_REGS_USER) { | ||
| 94 | rdmsrl(MSR_FS_BASE, fs); | ||
| 95 | rdmsrl(MSR_KERNEL_GS_BASE, shadowgs); | ||
| 96 | printk(KERN_DEFAULT "FS: %016lx GS: %016lx\n", | ||
| 97 | fs, shadowgs); | ||
| 98 | return; | ||
| 99 | } | ||
| 100 | |||
| 93 | asm("movl %%ds,%0" : "=r" (ds)); | 101 | asm("movl %%ds,%0" : "=r" (ds)); |
| 94 | asm("movl %%cs,%0" : "=r" (cs)); | 102 | asm("movl %%cs,%0" : "=r" (cs)); |
| 95 | asm("movl %%es,%0" : "=r" (es)); | 103 | asm("movl %%es,%0" : "=r" (es)); |
diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c index 1463468ba9a0..6490f618e096 100644 --- a/arch/x86/kernel/tsc.c +++ b/arch/x86/kernel/tsc.c | |||
| @@ -1415,7 +1415,7 @@ static bool __init determine_cpu_tsc_frequencies(bool early) | |||
| 1415 | 1415 | ||
| 1416 | static unsigned long __init get_loops_per_jiffy(void) | 1416 | static unsigned long __init get_loops_per_jiffy(void) |
| 1417 | { | 1417 | { |
| 1418 | unsigned long lpj = tsc_khz * KHZ; | 1418 | u64 lpj = (u64)tsc_khz * KHZ; |
| 1419 | 1419 | ||
| 1420 | do_div(lpj, HZ); | 1420 | do_div(lpj, HZ); |
| 1421 | return lpj; | 1421 | return lpj; |
diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c index e848a4811785..ae394552fb94 100644 --- a/arch/x86/mm/pgtable.c +++ b/arch/x86/mm/pgtable.c | |||
| @@ -269,7 +269,7 @@ static void mop_up_one_pmd(struct mm_struct *mm, pgd_t *pgdp) | |||
| 269 | if (pgd_val(pgd) != 0) { | 269 | if (pgd_val(pgd) != 0) { |
| 270 | pmd_t *pmd = (pmd_t *)pgd_page_vaddr(pgd); | 270 | pmd_t *pmd = (pmd_t *)pgd_page_vaddr(pgd); |
| 271 | 271 | ||
| 272 | *pgdp = native_make_pgd(0); | 272 | pgd_clear(pgdp); |
| 273 | 273 | ||
| 274 | paravirt_release_pmd(pgd_val(pgd) >> PAGE_SHIFT); | 274 | paravirt_release_pmd(pgd_val(pgd) >> PAGE_SHIFT); |
| 275 | pmd_free(mm, pmd); | 275 | pmd_free(mm, pmd); |
| @@ -494,7 +494,7 @@ int ptep_set_access_flags(struct vm_area_struct *vma, | |||
| 494 | int changed = !pte_same(*ptep, entry); | 494 | int changed = !pte_same(*ptep, entry); |
| 495 | 495 | ||
| 496 | if (changed && dirty) | 496 | if (changed && dirty) |
| 497 | *ptep = entry; | 497 | set_pte(ptep, entry); |
| 498 | 498 | ||
| 499 | return changed; | 499 | return changed; |
| 500 | } | 500 | } |
| @@ -509,7 +509,7 @@ int pmdp_set_access_flags(struct vm_area_struct *vma, | |||
| 509 | VM_BUG_ON(address & ~HPAGE_PMD_MASK); | 509 | VM_BUG_ON(address & ~HPAGE_PMD_MASK); |
| 510 | 510 | ||
| 511 | if (changed && dirty) { | 511 | if (changed && dirty) { |
| 512 | *pmdp = entry; | 512 | set_pmd(pmdp, entry); |
| 513 | /* | 513 | /* |
| 514 | * We had a write-protection fault here and changed the pmd | 514 | * We had a write-protection fault here and changed the pmd |
| 515 | * to to more permissive. No need to flush the TLB for that, | 515 | * to to more permissive. No need to flush the TLB for that, |
| @@ -529,7 +529,7 @@ int pudp_set_access_flags(struct vm_area_struct *vma, unsigned long address, | |||
| 529 | VM_BUG_ON(address & ~HPAGE_PUD_MASK); | 529 | VM_BUG_ON(address & ~HPAGE_PUD_MASK); |
| 530 | 530 | ||
| 531 | if (changed && dirty) { | 531 | if (changed && dirty) { |
| 532 | *pudp = entry; | 532 | set_pud(pudp, entry); |
| 533 | /* | 533 | /* |
| 534 | * We had a write-protection fault here and changed the pud | 534 | * We had a write-protection fault here and changed the pud |
| 535 | * to to more permissive. No need to flush the TLB for that, | 535 | * to to more permissive. No need to flush the TLB for that, |
diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig index 04d038f3b6fa..b9ad83a0ee5d 100644 --- a/arch/xtensa/Kconfig +++ b/arch/xtensa/Kconfig | |||
| @@ -4,6 +4,7 @@ config ZONE_DMA | |||
| 4 | 4 | ||
| 5 | config XTENSA | 5 | config XTENSA |
| 6 | def_bool y | 6 | def_bool y |
| 7 | select ARCH_HAS_SG_CHAIN | ||
| 7 | select ARCH_HAS_SYNC_DMA_FOR_CPU | 8 | select ARCH_HAS_SYNC_DMA_FOR_CPU |
| 8 | select ARCH_HAS_SYNC_DMA_FOR_DEVICE | 9 | select ARCH_HAS_SYNC_DMA_FOR_DEVICE |
| 9 | select ARCH_NO_COHERENT_DMA_MMAP if !MMU | 10 | select ARCH_NO_COHERENT_DMA_MMAP if !MMU |
diff --git a/arch/xtensa/Makefile b/arch/xtensa/Makefile index 295c120ed099..d67e30faff9c 100644 --- a/arch/xtensa/Makefile +++ b/arch/xtensa/Makefile | |||
| @@ -64,11 +64,7 @@ endif | |||
| 64 | vardirs := $(patsubst %,arch/xtensa/variants/%/,$(variant-y)) | 64 | vardirs := $(patsubst %,arch/xtensa/variants/%/,$(variant-y)) |
| 65 | plfdirs := $(patsubst %,arch/xtensa/platforms/%/,$(platform-y)) | 65 | plfdirs := $(patsubst %,arch/xtensa/platforms/%/,$(platform-y)) |
| 66 | 66 | ||
| 67 | ifeq ($(KBUILD_SRC),) | ||
| 68 | KBUILD_CPPFLAGS += $(patsubst %,-I%include,$(vardirs) $(plfdirs)) | ||
| 69 | else | ||
| 70 | KBUILD_CPPFLAGS += $(patsubst %,-I$(srctree)/%include,$(vardirs) $(plfdirs)) | 67 | KBUILD_CPPFLAGS += $(patsubst %,-I$(srctree)/%include,$(vardirs) $(plfdirs)) |
| 71 | endif | ||
| 72 | 68 | ||
| 73 | KBUILD_DEFCONFIG := iss_defconfig | 69 | KBUILD_DEFCONFIG := iss_defconfig |
| 74 | 70 | ||
diff --git a/arch/xtensa/platforms/iss/setup.c b/arch/xtensa/platforms/iss/setup.c index f4bbb28026f8..58709e89a8ed 100644 --- a/arch/xtensa/platforms/iss/setup.c +++ b/arch/xtensa/platforms/iss/setup.c | |||
| @@ -78,23 +78,28 @@ static struct notifier_block iss_panic_block = { | |||
| 78 | 78 | ||
| 79 | void __init platform_setup(char **p_cmdline) | 79 | void __init platform_setup(char **p_cmdline) |
| 80 | { | 80 | { |
| 81 | static void *argv[COMMAND_LINE_SIZE / sizeof(void *)] __initdata; | ||
| 82 | static char cmdline[COMMAND_LINE_SIZE] __initdata; | ||
| 81 | int argc = simc_argc(); | 83 | int argc = simc_argc(); |
| 82 | int argv_size = simc_argv_size(); | 84 | int argv_size = simc_argv_size(); |
| 83 | 85 | ||
| 84 | if (argc > 1) { | 86 | if (argc > 1) { |
| 85 | void **argv = alloc_bootmem(argv_size); | 87 | if (argv_size > sizeof(argv)) { |
| 86 | char *cmdline = alloc_bootmem(argv_size); | 88 | pr_err("%s: command line too long: argv_size = %d\n", |
| 87 | int i; | 89 | __func__, argv_size); |
| 90 | } else { | ||
| 91 | int i; | ||
| 88 | 92 | ||
| 89 | cmdline[0] = 0; | 93 | cmdline[0] = 0; |
| 90 | simc_argv((void *)argv); | 94 | simc_argv((void *)argv); |
| 91 | 95 | ||
| 92 | for (i = 1; i < argc; ++i) { | 96 | for (i = 1; i < argc; ++i) { |
| 93 | if (i > 1) | 97 | if (i > 1) |
| 94 | strcat(cmdline, " "); | 98 | strcat(cmdline, " "); |
| 95 | strcat(cmdline, argv[i]); | 99 | strcat(cmdline, argv[i]); |
| 100 | } | ||
| 101 | *p_cmdline = cmdline; | ||
| 96 | } | 102 | } |
| 97 | *p_cmdline = cmdline; | ||
| 98 | } | 103 | } |
| 99 | 104 | ||
| 100 | atomic_notifier_chain_register(&panic_notifier_list, &iss_panic_block); | 105 | atomic_notifier_chain_register(&panic_notifier_list, &iss_panic_block); |
diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c index c19f9078da1e..c630e02836a8 100644 --- a/block/blk-cgroup.c +++ b/block/blk-cgroup.c | |||
| @@ -1510,8 +1510,10 @@ int blkcg_policy_register(struct blkcg_policy *pol) | |||
| 1510 | for (i = 0; i < BLKCG_MAX_POLS; i++) | 1510 | for (i = 0; i < BLKCG_MAX_POLS; i++) |
| 1511 | if (!blkcg_policy[i]) | 1511 | if (!blkcg_policy[i]) |
| 1512 | break; | 1512 | break; |
| 1513 | if (i >= BLKCG_MAX_POLS) | 1513 | if (i >= BLKCG_MAX_POLS) { |
| 1514 | pr_warn("blkcg_policy_register: BLKCG_MAX_POLS too small\n"); | ||
| 1514 | goto err_unlock; | 1515 | goto err_unlock; |
| 1516 | } | ||
| 1515 | 1517 | ||
| 1516 | /* Make sure cpd/pd_alloc_fn and cpd/pd_free_fn in pairs */ | 1518 | /* Make sure cpd/pd_alloc_fn and cpd/pd_free_fn in pairs */ |
| 1517 | if ((!pol->cpd_alloc_fn ^ !pol->cpd_free_fn) || | 1519 | if ((!pol->cpd_alloc_fn ^ !pol->cpd_free_fn) || |
diff --git a/drivers/android/binder_alloc.c b/drivers/android/binder_alloc.c index 3f3b7b253445..64fd96eada31 100644 --- a/drivers/android/binder_alloc.c +++ b/drivers/android/binder_alloc.c | |||
| @@ -332,6 +332,35 @@ err_no_vma: | |||
| 332 | return vma ? -ENOMEM : -ESRCH; | 332 | return vma ? -ENOMEM : -ESRCH; |
| 333 | } | 333 | } |
| 334 | 334 | ||
| 335 | |||
| 336 | static inline void binder_alloc_set_vma(struct binder_alloc *alloc, | ||
| 337 | struct vm_area_struct *vma) | ||
| 338 | { | ||
| 339 | if (vma) | ||
| 340 | alloc->vma_vm_mm = vma->vm_mm; | ||
| 341 | /* | ||
| 342 | * If we see alloc->vma is not NULL, buffer data structures set up | ||
| 343 | * completely. Look at smp_rmb side binder_alloc_get_vma. | ||
| 344 | * We also want to guarantee new alloc->vma_vm_mm is always visible | ||
| 345 | * if alloc->vma is set. | ||
| 346 | */ | ||
| 347 | smp_wmb(); | ||
| 348 | alloc->vma = vma; | ||
| 349 | } | ||
| 350 | |||
| 351 | static inline struct vm_area_struct *binder_alloc_get_vma( | ||
| 352 | struct binder_alloc *alloc) | ||
| 353 | { | ||
| 354 | struct vm_area_struct *vma = NULL; | ||
| 355 | |||
| 356 | if (alloc->vma) { | ||
| 357 | /* Look at description in binder_alloc_set_vma */ | ||
| 358 | smp_rmb(); | ||
| 359 | vma = alloc->vma; | ||
| 360 | } | ||
| 361 | return vma; | ||
| 362 | } | ||
| 363 | |||
| 335 | static struct binder_buffer *binder_alloc_new_buf_locked( | 364 | static struct binder_buffer *binder_alloc_new_buf_locked( |
| 336 | struct binder_alloc *alloc, | 365 | struct binder_alloc *alloc, |
| 337 | size_t data_size, | 366 | size_t data_size, |
| @@ -348,7 +377,7 @@ static struct binder_buffer *binder_alloc_new_buf_locked( | |||
| 348 | size_t size, data_offsets_size; | 377 | size_t size, data_offsets_size; |
| 349 | int ret; | 378 | int ret; |
| 350 | 379 | ||
| 351 | if (alloc->vma == NULL) { | 380 | if (!binder_alloc_get_vma(alloc)) { |
| 352 | binder_alloc_debug(BINDER_DEBUG_USER_ERROR, | 381 | binder_alloc_debug(BINDER_DEBUG_USER_ERROR, |
| 353 | "%d: binder_alloc_buf, no vma\n", | 382 | "%d: binder_alloc_buf, no vma\n", |
| 354 | alloc->pid); | 383 | alloc->pid); |
| @@ -723,9 +752,7 @@ int binder_alloc_mmap_handler(struct binder_alloc *alloc, | |||
| 723 | buffer->free = 1; | 752 | buffer->free = 1; |
| 724 | binder_insert_free_buffer(alloc, buffer); | 753 | binder_insert_free_buffer(alloc, buffer); |
| 725 | alloc->free_async_space = alloc->buffer_size / 2; | 754 | alloc->free_async_space = alloc->buffer_size / 2; |
| 726 | barrier(); | 755 | binder_alloc_set_vma(alloc, vma); |
| 727 | alloc->vma = vma; | ||
| 728 | alloc->vma_vm_mm = vma->vm_mm; | ||
| 729 | mmgrab(alloc->vma_vm_mm); | 756 | mmgrab(alloc->vma_vm_mm); |
| 730 | 757 | ||
| 731 | return 0; | 758 | return 0; |
| @@ -754,10 +781,10 @@ void binder_alloc_deferred_release(struct binder_alloc *alloc) | |||
| 754 | int buffers, page_count; | 781 | int buffers, page_count; |
| 755 | struct binder_buffer *buffer; | 782 | struct binder_buffer *buffer; |
| 756 | 783 | ||
| 757 | BUG_ON(alloc->vma); | ||
| 758 | |||
| 759 | buffers = 0; | 784 | buffers = 0; |
| 760 | mutex_lock(&alloc->mutex); | 785 | mutex_lock(&alloc->mutex); |
| 786 | BUG_ON(alloc->vma); | ||
| 787 | |||
| 761 | while ((n = rb_first(&alloc->allocated_buffers))) { | 788 | while ((n = rb_first(&alloc->allocated_buffers))) { |
| 762 | buffer = rb_entry(n, struct binder_buffer, rb_node); | 789 | buffer = rb_entry(n, struct binder_buffer, rb_node); |
| 763 | 790 | ||
| @@ -900,7 +927,7 @@ int binder_alloc_get_allocated_count(struct binder_alloc *alloc) | |||
| 900 | */ | 927 | */ |
| 901 | void binder_alloc_vma_close(struct binder_alloc *alloc) | 928 | void binder_alloc_vma_close(struct binder_alloc *alloc) |
| 902 | { | 929 | { |
| 903 | WRITE_ONCE(alloc->vma, NULL); | 930 | binder_alloc_set_vma(alloc, NULL); |
| 904 | } | 931 | } |
| 905 | 932 | ||
| 906 | /** | 933 | /** |
| @@ -935,7 +962,7 @@ enum lru_status binder_alloc_free_page(struct list_head *item, | |||
| 935 | 962 | ||
| 936 | index = page - alloc->pages; | 963 | index = page - alloc->pages; |
| 937 | page_addr = (uintptr_t)alloc->buffer + index * PAGE_SIZE; | 964 | page_addr = (uintptr_t)alloc->buffer + index * PAGE_SIZE; |
| 938 | vma = alloc->vma; | 965 | vma = binder_alloc_get_vma(alloc); |
| 939 | if (vma) { | 966 | if (vma) { |
| 940 | if (!mmget_not_zero(alloc->vma_vm_mm)) | 967 | if (!mmget_not_zero(alloc->vma_vm_mm)) |
| 941 | goto err_mmget; | 968 | goto err_mmget; |
diff --git a/drivers/base/firmware_loader/main.c b/drivers/base/firmware_loader/main.c index 0943e7065e0e..b3c0498ee433 100644 --- a/drivers/base/firmware_loader/main.c +++ b/drivers/base/firmware_loader/main.c | |||
| @@ -209,21 +209,24 @@ static struct fw_priv *__lookup_fw_priv(const char *fw_name) | |||
| 209 | static int alloc_lookup_fw_priv(const char *fw_name, | 209 | static int alloc_lookup_fw_priv(const char *fw_name, |
| 210 | struct firmware_cache *fwc, | 210 | struct firmware_cache *fwc, |
| 211 | struct fw_priv **fw_priv, void *dbuf, | 211 | struct fw_priv **fw_priv, void *dbuf, |
| 212 | size_t size) | 212 | size_t size, enum fw_opt opt_flags) |
| 213 | { | 213 | { |
| 214 | struct fw_priv *tmp; | 214 | struct fw_priv *tmp; |
| 215 | 215 | ||
| 216 | spin_lock(&fwc->lock); | 216 | spin_lock(&fwc->lock); |
| 217 | tmp = __lookup_fw_priv(fw_name); | 217 | if (!(opt_flags & FW_OPT_NOCACHE)) { |
| 218 | if (tmp) { | 218 | tmp = __lookup_fw_priv(fw_name); |
| 219 | kref_get(&tmp->ref); | 219 | if (tmp) { |
| 220 | spin_unlock(&fwc->lock); | 220 | kref_get(&tmp->ref); |
| 221 | *fw_priv = tmp; | 221 | spin_unlock(&fwc->lock); |
| 222 | pr_debug("batched request - sharing the same struct fw_priv and lookup for multiple requests\n"); | 222 | *fw_priv = tmp; |
| 223 | return 1; | 223 | pr_debug("batched request - sharing the same struct fw_priv and lookup for multiple requests\n"); |
| 224 | return 1; | ||
| 225 | } | ||
| 224 | } | 226 | } |
| 227 | |||
| 225 | tmp = __allocate_fw_priv(fw_name, fwc, dbuf, size); | 228 | tmp = __allocate_fw_priv(fw_name, fwc, dbuf, size); |
| 226 | if (tmp) | 229 | if (tmp && !(opt_flags & FW_OPT_NOCACHE)) |
| 227 | list_add(&tmp->list, &fwc->head); | 230 | list_add(&tmp->list, &fwc->head); |
| 228 | spin_unlock(&fwc->lock); | 231 | spin_unlock(&fwc->lock); |
| 229 | 232 | ||
| @@ -493,7 +496,8 @@ int assign_fw(struct firmware *fw, struct device *device, | |||
| 493 | */ | 496 | */ |
| 494 | static int | 497 | static int |
| 495 | _request_firmware_prepare(struct firmware **firmware_p, const char *name, | 498 | _request_firmware_prepare(struct firmware **firmware_p, const char *name, |
| 496 | struct device *device, void *dbuf, size_t size) | 499 | struct device *device, void *dbuf, size_t size, |
| 500 | enum fw_opt opt_flags) | ||
| 497 | { | 501 | { |
| 498 | struct firmware *firmware; | 502 | struct firmware *firmware; |
| 499 | struct fw_priv *fw_priv; | 503 | struct fw_priv *fw_priv; |
| @@ -511,7 +515,8 @@ _request_firmware_prepare(struct firmware **firmware_p, const char *name, | |||
| 511 | return 0; /* assigned */ | 515 | return 0; /* assigned */ |
| 512 | } | 516 | } |
| 513 | 517 | ||
| 514 | ret = alloc_lookup_fw_priv(name, &fw_cache, &fw_priv, dbuf, size); | 518 | ret = alloc_lookup_fw_priv(name, &fw_cache, &fw_priv, dbuf, size, |
| 519 | opt_flags); | ||
| 515 | 520 | ||
| 516 | /* | 521 | /* |
| 517 | * bind with 'priv' now to avoid warning in failure path | 522 | * bind with 'priv' now to avoid warning in failure path |
| @@ -571,7 +576,8 @@ _request_firmware(const struct firmware **firmware_p, const char *name, | |||
| 571 | goto out; | 576 | goto out; |
| 572 | } | 577 | } |
| 573 | 578 | ||
| 574 | ret = _request_firmware_prepare(&fw, name, device, buf, size); | 579 | ret = _request_firmware_prepare(&fw, name, device, buf, size, |
| 580 | opt_flags); | ||
| 575 | if (ret <= 0) /* error or already assigned */ | 581 | if (ret <= 0) /* error or already assigned */ |
| 576 | goto out; | 582 | goto out; |
| 577 | 583 | ||
diff --git a/drivers/block/null_blk.h b/drivers/block/null_blk.h index d81781f22dba..34e0030f0592 100644 --- a/drivers/block/null_blk.h +++ b/drivers/block/null_blk.h | |||
| @@ -87,10 +87,10 @@ struct nullb { | |||
| 87 | #ifdef CONFIG_BLK_DEV_ZONED | 87 | #ifdef CONFIG_BLK_DEV_ZONED |
| 88 | int null_zone_init(struct nullb_device *dev); | 88 | int null_zone_init(struct nullb_device *dev); |
| 89 | void null_zone_exit(struct nullb_device *dev); | 89 | void null_zone_exit(struct nullb_device *dev); |
| 90 | blk_status_t null_zone_report(struct nullb *nullb, | 90 | blk_status_t null_zone_report(struct nullb *nullb, struct bio *bio); |
| 91 | struct nullb_cmd *cmd); | 91 | void null_zone_write(struct nullb_cmd *cmd, sector_t sector, |
| 92 | void null_zone_write(struct nullb_cmd *cmd); | 92 | unsigned int nr_sectors); |
| 93 | void null_zone_reset(struct nullb_cmd *cmd); | 93 | void null_zone_reset(struct nullb_cmd *cmd, sector_t sector); |
| 94 | #else | 94 | #else |
| 95 | static inline int null_zone_init(struct nullb_device *dev) | 95 | static inline int null_zone_init(struct nullb_device *dev) |
| 96 | { | 96 | { |
| @@ -98,11 +98,14 @@ static inline int null_zone_init(struct nullb_device *dev) | |||
| 98 | } | 98 | } |
| 99 | static inline void null_zone_exit(struct nullb_device *dev) {} | 99 | static inline void null_zone_exit(struct nullb_device *dev) {} |
| 100 | static inline blk_status_t null_zone_report(struct nullb *nullb, | 100 | static inline blk_status_t null_zone_report(struct nullb *nullb, |
| 101 | struct nullb_cmd *cmd) | 101 | struct bio *bio) |
| 102 | { | 102 | { |
| 103 | return BLK_STS_NOTSUPP; | 103 | return BLK_STS_NOTSUPP; |
| 104 | } | 104 | } |
| 105 | static inline void null_zone_write(struct nullb_cmd *cmd) {} | 105 | static inline void null_zone_write(struct nullb_cmd *cmd, sector_t sector, |
| 106 | static inline void null_zone_reset(struct nullb_cmd *cmd) {} | 106 | unsigned int nr_sectors) |
| 107 | { | ||
| 108 | } | ||
| 109 | static inline void null_zone_reset(struct nullb_cmd *cmd, sector_t sector) {} | ||
| 107 | #endif /* CONFIG_BLK_DEV_ZONED */ | 110 | #endif /* CONFIG_BLK_DEV_ZONED */ |
| 108 | #endif /* __NULL_BLK_H */ | 111 | #endif /* __NULL_BLK_H */ |
diff --git a/drivers/block/null_blk_main.c b/drivers/block/null_blk_main.c index 6127e3ff7b4b..093b614d6524 100644 --- a/drivers/block/null_blk_main.c +++ b/drivers/block/null_blk_main.c | |||
| @@ -1157,16 +1157,33 @@ static void null_restart_queue_async(struct nullb *nullb) | |||
| 1157 | } | 1157 | } |
| 1158 | } | 1158 | } |
| 1159 | 1159 | ||
| 1160 | static bool cmd_report_zone(struct nullb *nullb, struct nullb_cmd *cmd) | ||
| 1161 | { | ||
| 1162 | struct nullb_device *dev = cmd->nq->dev; | ||
| 1163 | |||
| 1164 | if (dev->queue_mode == NULL_Q_BIO) { | ||
| 1165 | if (bio_op(cmd->bio) == REQ_OP_ZONE_REPORT) { | ||
| 1166 | cmd->error = null_zone_report(nullb, cmd->bio); | ||
| 1167 | return true; | ||
| 1168 | } | ||
| 1169 | } else { | ||
| 1170 | if (req_op(cmd->rq) == REQ_OP_ZONE_REPORT) { | ||
| 1171 | cmd->error = null_zone_report(nullb, cmd->rq->bio); | ||
| 1172 | return true; | ||
| 1173 | } | ||
| 1174 | } | ||
| 1175 | |||
| 1176 | return false; | ||
| 1177 | } | ||
| 1178 | |||
| 1160 | static blk_status_t null_handle_cmd(struct nullb_cmd *cmd) | 1179 | static blk_status_t null_handle_cmd(struct nullb_cmd *cmd) |
| 1161 | { | 1180 | { |
| 1162 | struct nullb_device *dev = cmd->nq->dev; | 1181 | struct nullb_device *dev = cmd->nq->dev; |
| 1163 | struct nullb *nullb = dev->nullb; | 1182 | struct nullb *nullb = dev->nullb; |
| 1164 | int err = 0; | 1183 | int err = 0; |
| 1165 | 1184 | ||
| 1166 | if (req_op(cmd->rq) == REQ_OP_ZONE_REPORT) { | 1185 | if (cmd_report_zone(nullb, cmd)) |
| 1167 | cmd->error = null_zone_report(nullb, cmd); | ||
| 1168 | goto out; | 1186 | goto out; |
| 1169 | } | ||
| 1170 | 1187 | ||
| 1171 | if (test_bit(NULLB_DEV_FL_THROTTLED, &dev->flags)) { | 1188 | if (test_bit(NULLB_DEV_FL_THROTTLED, &dev->flags)) { |
| 1172 | struct request *rq = cmd->rq; | 1189 | struct request *rq = cmd->rq; |
| @@ -1234,10 +1251,24 @@ static blk_status_t null_handle_cmd(struct nullb_cmd *cmd) | |||
| 1234 | cmd->error = errno_to_blk_status(err); | 1251 | cmd->error = errno_to_blk_status(err); |
| 1235 | 1252 | ||
| 1236 | if (!cmd->error && dev->zoned) { | 1253 | if (!cmd->error && dev->zoned) { |
| 1237 | if (req_op(cmd->rq) == REQ_OP_WRITE) | 1254 | sector_t sector; |
| 1238 | null_zone_write(cmd); | 1255 | unsigned int nr_sectors; |
| 1239 | else if (req_op(cmd->rq) == REQ_OP_ZONE_RESET) | 1256 | int op; |
| 1240 | null_zone_reset(cmd); | 1257 | |
| 1258 | if (dev->queue_mode == NULL_Q_BIO) { | ||
| 1259 | op = bio_op(cmd->bio); | ||
| 1260 | sector = cmd->bio->bi_iter.bi_sector; | ||
| 1261 | nr_sectors = cmd->bio->bi_iter.bi_size >> 9; | ||
| 1262 | } else { | ||
| 1263 | op = req_op(cmd->rq); | ||
| 1264 | sector = blk_rq_pos(cmd->rq); | ||
| 1265 | nr_sectors = blk_rq_sectors(cmd->rq); | ||
| 1266 | } | ||
| 1267 | |||
| 1268 | if (op == REQ_OP_WRITE) | ||
| 1269 | null_zone_write(cmd, sector, nr_sectors); | ||
| 1270 | else if (op == REQ_OP_ZONE_RESET) | ||
| 1271 | null_zone_reset(cmd, sector); | ||
| 1241 | } | 1272 | } |
| 1242 | out: | 1273 | out: |
| 1243 | /* Complete IO by inline, softirq or timer */ | 1274 | /* Complete IO by inline, softirq or timer */ |
diff --git a/drivers/block/null_blk_zoned.c b/drivers/block/null_blk_zoned.c index a979ca00d7be..7c6b86d98700 100644 --- a/drivers/block/null_blk_zoned.c +++ b/drivers/block/null_blk_zoned.c | |||
| @@ -48,8 +48,8 @@ void null_zone_exit(struct nullb_device *dev) | |||
| 48 | kvfree(dev->zones); | 48 | kvfree(dev->zones); |
| 49 | } | 49 | } |
| 50 | 50 | ||
| 51 | static void null_zone_fill_rq(struct nullb_device *dev, struct request *rq, | 51 | static void null_zone_fill_bio(struct nullb_device *dev, struct bio *bio, |
| 52 | unsigned int zno, unsigned int nr_zones) | 52 | unsigned int zno, unsigned int nr_zones) |
| 53 | { | 53 | { |
| 54 | struct blk_zone_report_hdr *hdr = NULL; | 54 | struct blk_zone_report_hdr *hdr = NULL; |
| 55 | struct bio_vec bvec; | 55 | struct bio_vec bvec; |
| @@ -57,7 +57,7 @@ static void null_zone_fill_rq(struct nullb_device *dev, struct request *rq, | |||
| 57 | void *addr; | 57 | void *addr; |
| 58 | unsigned int zones_to_cpy; | 58 | unsigned int zones_to_cpy; |
| 59 | 59 | ||
| 60 | bio_for_each_segment(bvec, rq->bio, iter) { | 60 | bio_for_each_segment(bvec, bio, iter) { |
| 61 | addr = kmap_atomic(bvec.bv_page); | 61 | addr = kmap_atomic(bvec.bv_page); |
| 62 | 62 | ||
| 63 | zones_to_cpy = bvec.bv_len / sizeof(struct blk_zone); | 63 | zones_to_cpy = bvec.bv_len / sizeof(struct blk_zone); |
| @@ -84,29 +84,24 @@ static void null_zone_fill_rq(struct nullb_device *dev, struct request *rq, | |||
| 84 | } | 84 | } |
| 85 | } | 85 | } |
| 86 | 86 | ||
| 87 | blk_status_t null_zone_report(struct nullb *nullb, | 87 | blk_status_t null_zone_report(struct nullb *nullb, struct bio *bio) |
| 88 | struct nullb_cmd *cmd) | ||
| 89 | { | 88 | { |
| 90 | struct nullb_device *dev = nullb->dev; | 89 | struct nullb_device *dev = nullb->dev; |
| 91 | struct request *rq = cmd->rq; | 90 | unsigned int zno = null_zone_no(dev, bio->bi_iter.bi_sector); |
| 92 | unsigned int zno = null_zone_no(dev, blk_rq_pos(rq)); | ||
| 93 | unsigned int nr_zones = dev->nr_zones - zno; | 91 | unsigned int nr_zones = dev->nr_zones - zno; |
| 94 | unsigned int max_zones = (blk_rq_bytes(rq) / | 92 | unsigned int max_zones; |
| 95 | sizeof(struct blk_zone)) - 1; | ||
| 96 | 93 | ||
| 94 | max_zones = (bio->bi_iter.bi_size / sizeof(struct blk_zone)) - 1; | ||
| 97 | nr_zones = min_t(unsigned int, nr_zones, max_zones); | 95 | nr_zones = min_t(unsigned int, nr_zones, max_zones); |
| 98 | 96 | null_zone_fill_bio(nullb->dev, bio, zno, nr_zones); | |
| 99 | null_zone_fill_rq(nullb->dev, rq, zno, nr_zones); | ||
| 100 | 97 | ||
| 101 | return BLK_STS_OK; | 98 | return BLK_STS_OK; |
| 102 | } | 99 | } |
| 103 | 100 | ||
| 104 | void null_zone_write(struct nullb_cmd *cmd) | 101 | void null_zone_write(struct nullb_cmd *cmd, sector_t sector, |
| 102 | unsigned int nr_sectors) | ||
| 105 | { | 103 | { |
| 106 | struct nullb_device *dev = cmd->nq->dev; | 104 | struct nullb_device *dev = cmd->nq->dev; |
| 107 | struct request *rq = cmd->rq; | ||
| 108 | sector_t sector = blk_rq_pos(rq); | ||
| 109 | unsigned int rq_sectors = blk_rq_sectors(rq); | ||
| 110 | unsigned int zno = null_zone_no(dev, sector); | 105 | unsigned int zno = null_zone_no(dev, sector); |
| 111 | struct blk_zone *zone = &dev->zones[zno]; | 106 | struct blk_zone *zone = &dev->zones[zno]; |
| 112 | 107 | ||
| @@ -118,7 +113,7 @@ void null_zone_write(struct nullb_cmd *cmd) | |||
| 118 | case BLK_ZONE_COND_EMPTY: | 113 | case BLK_ZONE_COND_EMPTY: |
| 119 | case BLK_ZONE_COND_IMP_OPEN: | 114 | case BLK_ZONE_COND_IMP_OPEN: |
| 120 | /* Writes must be at the write pointer position */ | 115 | /* Writes must be at the write pointer position */ |
| 121 | if (blk_rq_pos(rq) != zone->wp) { | 116 | if (sector != zone->wp) { |
| 122 | cmd->error = BLK_STS_IOERR; | 117 | cmd->error = BLK_STS_IOERR; |
| 123 | break; | 118 | break; |
| 124 | } | 119 | } |
| @@ -126,7 +121,7 @@ void null_zone_write(struct nullb_cmd *cmd) | |||
| 126 | if (zone->cond == BLK_ZONE_COND_EMPTY) | 121 | if (zone->cond == BLK_ZONE_COND_EMPTY) |
| 127 | zone->cond = BLK_ZONE_COND_IMP_OPEN; | 122 | zone->cond = BLK_ZONE_COND_IMP_OPEN; |
| 128 | 123 | ||
| 129 | zone->wp += rq_sectors; | 124 | zone->wp += nr_sectors; |
| 130 | if (zone->wp == zone->start + zone->len) | 125 | if (zone->wp == zone->start + zone->len) |
| 131 | zone->cond = BLK_ZONE_COND_FULL; | 126 | zone->cond = BLK_ZONE_COND_FULL; |
| 132 | break; | 127 | break; |
| @@ -137,11 +132,10 @@ void null_zone_write(struct nullb_cmd *cmd) | |||
| 137 | } | 132 | } |
| 138 | } | 133 | } |
| 139 | 134 | ||
| 140 | void null_zone_reset(struct nullb_cmd *cmd) | 135 | void null_zone_reset(struct nullb_cmd *cmd, sector_t sector) |
| 141 | { | 136 | { |
| 142 | struct nullb_device *dev = cmd->nq->dev; | 137 | struct nullb_device *dev = cmd->nq->dev; |
| 143 | struct request *rq = cmd->rq; | 138 | unsigned int zno = null_zone_no(dev, sector); |
| 144 | unsigned int zno = null_zone_no(dev, blk_rq_pos(rq)); | ||
| 145 | struct blk_zone *zone = &dev->zones[zno]; | 139 | struct blk_zone *zone = &dev->zones[zno]; |
| 146 | 140 | ||
| 147 | zone->cond = BLK_ZONE_COND_EMPTY; | 141 | zone->cond = BLK_ZONE_COND_EMPTY; |
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig index ce277ee0a28a..40728491f37b 100644 --- a/drivers/char/Kconfig +++ b/drivers/char/Kconfig | |||
| @@ -566,5 +566,5 @@ config RANDOM_TRUST_CPU | |||
| 566 | that CPU manufacturer (perhaps with the insistence or mandate | 566 | that CPU manufacturer (perhaps with the insistence or mandate |
| 567 | of a Nation State's intelligence or law enforcement agencies) | 567 | of a Nation State's intelligence or law enforcement agencies) |
| 568 | has not installed a hidden back door to compromise the CPU's | 568 | has not installed a hidden back door to compromise the CPU's |
| 569 | random number generation facilities. | 569 | random number generation facilities. This can also be configured |
| 570 | 570 | at boot with "random.trust_cpu=on/off". | |
diff --git a/drivers/char/ipmi/ipmi_bt_sm.c b/drivers/char/ipmi/ipmi_bt_sm.c index a3397664f800..97d6856c9c0f 100644 --- a/drivers/char/ipmi/ipmi_bt_sm.c +++ b/drivers/char/ipmi/ipmi_bt_sm.c | |||
| @@ -59,8 +59,6 @@ enum bt_states { | |||
| 59 | BT_STATE_RESET3, | 59 | BT_STATE_RESET3, |
| 60 | BT_STATE_RESTART, | 60 | BT_STATE_RESTART, |
| 61 | BT_STATE_PRINTME, | 61 | BT_STATE_PRINTME, |
| 62 | BT_STATE_CAPABILITIES_BEGIN, | ||
| 63 | BT_STATE_CAPABILITIES_END, | ||
| 64 | BT_STATE_LONG_BUSY /* BT doesn't get hosed :-) */ | 62 | BT_STATE_LONG_BUSY /* BT doesn't get hosed :-) */ |
| 65 | }; | 63 | }; |
| 66 | 64 | ||
| @@ -86,7 +84,6 @@ struct si_sm_data { | |||
| 86 | int error_retries; /* end of "common" fields */ | 84 | int error_retries; /* end of "common" fields */ |
| 87 | int nonzero_status; /* hung BMCs stay all 0 */ | 85 | int nonzero_status; /* hung BMCs stay all 0 */ |
| 88 | enum bt_states complete; /* to divert the state machine */ | 86 | enum bt_states complete; /* to divert the state machine */ |
| 89 | int BT_CAP_outreqs; | ||
| 90 | long BT_CAP_req2rsp; | 87 | long BT_CAP_req2rsp; |
| 91 | int BT_CAP_retries; /* Recommended retries */ | 88 | int BT_CAP_retries; /* Recommended retries */ |
| 92 | }; | 89 | }; |
| @@ -137,8 +134,6 @@ static char *state2txt(unsigned char state) | |||
| 137 | case BT_STATE_RESET3: return("RESET3"); | 134 | case BT_STATE_RESET3: return("RESET3"); |
| 138 | case BT_STATE_RESTART: return("RESTART"); | 135 | case BT_STATE_RESTART: return("RESTART"); |
| 139 | case BT_STATE_LONG_BUSY: return("LONG_BUSY"); | 136 | case BT_STATE_LONG_BUSY: return("LONG_BUSY"); |
| 140 | case BT_STATE_CAPABILITIES_BEGIN: return("CAP_BEGIN"); | ||
| 141 | case BT_STATE_CAPABILITIES_END: return("CAP_END"); | ||
| 142 | } | 137 | } |
| 143 | return("BAD STATE"); | 138 | return("BAD STATE"); |
| 144 | } | 139 | } |
| @@ -185,7 +180,6 @@ static unsigned int bt_init_data(struct si_sm_data *bt, struct si_sm_io *io) | |||
| 185 | bt->complete = BT_STATE_IDLE; /* end here */ | 180 | bt->complete = BT_STATE_IDLE; /* end here */ |
| 186 | bt->BT_CAP_req2rsp = BT_NORMAL_TIMEOUT * USEC_PER_SEC; | 181 | bt->BT_CAP_req2rsp = BT_NORMAL_TIMEOUT * USEC_PER_SEC; |
| 187 | bt->BT_CAP_retries = BT_NORMAL_RETRY_LIMIT; | 182 | bt->BT_CAP_retries = BT_NORMAL_RETRY_LIMIT; |
| 188 | /* BT_CAP_outreqs == zero is a flag to read BT Capabilities */ | ||
| 189 | return 3; /* We claim 3 bytes of space; ought to check SPMI table */ | 183 | return 3; /* We claim 3 bytes of space; ought to check SPMI table */ |
| 190 | } | 184 | } |
| 191 | 185 | ||
| @@ -451,7 +445,7 @@ static enum si_sm_result error_recovery(struct si_sm_data *bt, | |||
| 451 | 445 | ||
| 452 | static enum si_sm_result bt_event(struct si_sm_data *bt, long time) | 446 | static enum si_sm_result bt_event(struct si_sm_data *bt, long time) |
| 453 | { | 447 | { |
| 454 | unsigned char status, BT_CAP[8]; | 448 | unsigned char status; |
| 455 | static enum bt_states last_printed = BT_STATE_PRINTME; | 449 | static enum bt_states last_printed = BT_STATE_PRINTME; |
| 456 | int i; | 450 | int i; |
| 457 | 451 | ||
| @@ -504,12 +498,6 @@ static enum si_sm_result bt_event(struct si_sm_data *bt, long time) | |||
| 504 | if (status & BT_H_BUSY) /* clear a leftover H_BUSY */ | 498 | if (status & BT_H_BUSY) /* clear a leftover H_BUSY */ |
| 505 | BT_CONTROL(BT_H_BUSY); | 499 | BT_CONTROL(BT_H_BUSY); |
| 506 | 500 | ||
| 507 | bt->timeout = bt->BT_CAP_req2rsp; | ||
| 508 | |||
| 509 | /* Read BT capabilities if it hasn't been done yet */ | ||
| 510 | if (!bt->BT_CAP_outreqs) | ||
| 511 | BT_STATE_CHANGE(BT_STATE_CAPABILITIES_BEGIN, | ||
| 512 | SI_SM_CALL_WITHOUT_DELAY); | ||
| 513 | BT_SI_SM_RETURN(SI_SM_IDLE); | 501 | BT_SI_SM_RETURN(SI_SM_IDLE); |
| 514 | 502 | ||
| 515 | case BT_STATE_XACTION_START: | 503 | case BT_STATE_XACTION_START: |
| @@ -614,37 +602,6 @@ static enum si_sm_result bt_event(struct si_sm_data *bt, long time) | |||
| 614 | BT_STATE_CHANGE(BT_STATE_XACTION_START, | 602 | BT_STATE_CHANGE(BT_STATE_XACTION_START, |
| 615 | SI_SM_CALL_WITH_DELAY); | 603 | SI_SM_CALL_WITH_DELAY); |
| 616 | 604 | ||
| 617 | /* | ||
| 618 | * Get BT Capabilities, using timing of upper level state machine. | ||
| 619 | * Set outreqs to prevent infinite loop on timeout. | ||
| 620 | */ | ||
| 621 | case BT_STATE_CAPABILITIES_BEGIN: | ||
| 622 | bt->BT_CAP_outreqs = 1; | ||
| 623 | { | ||
| 624 | unsigned char GetBT_CAP[] = { 0x18, 0x36 }; | ||
| 625 | bt->state = BT_STATE_IDLE; | ||
| 626 | bt_start_transaction(bt, GetBT_CAP, sizeof(GetBT_CAP)); | ||
| 627 | } | ||
| 628 | bt->complete = BT_STATE_CAPABILITIES_END; | ||
| 629 | BT_STATE_CHANGE(BT_STATE_XACTION_START, | ||
| 630 | SI_SM_CALL_WITH_DELAY); | ||
| 631 | |||
| 632 | case BT_STATE_CAPABILITIES_END: | ||
| 633 | i = bt_get_result(bt, BT_CAP, sizeof(BT_CAP)); | ||
| 634 | bt_init_data(bt, bt->io); | ||
| 635 | if ((i == 8) && !BT_CAP[2]) { | ||
| 636 | bt->BT_CAP_outreqs = BT_CAP[3]; | ||
| 637 | bt->BT_CAP_req2rsp = BT_CAP[6] * USEC_PER_SEC; | ||
| 638 | bt->BT_CAP_retries = BT_CAP[7]; | ||
| 639 | } else | ||
| 640 | printk(KERN_WARNING "IPMI BT: using default values\n"); | ||
| 641 | if (!bt->BT_CAP_outreqs) | ||
| 642 | bt->BT_CAP_outreqs = 1; | ||
| 643 | printk(KERN_WARNING "IPMI BT: req2rsp=%ld secs retries=%d\n", | ||
| 644 | bt->BT_CAP_req2rsp / USEC_PER_SEC, bt->BT_CAP_retries); | ||
| 645 | bt->timeout = bt->BT_CAP_req2rsp; | ||
| 646 | return SI_SM_CALL_WITHOUT_DELAY; | ||
| 647 | |||
| 648 | default: /* should never occur */ | 605 | default: /* should never occur */ |
| 649 | return error_recovery(bt, | 606 | return error_recovery(bt, |
| 650 | status, | 607 | status, |
| @@ -655,6 +612,11 @@ static enum si_sm_result bt_event(struct si_sm_data *bt, long time) | |||
| 655 | 612 | ||
| 656 | static int bt_detect(struct si_sm_data *bt) | 613 | static int bt_detect(struct si_sm_data *bt) |
| 657 | { | 614 | { |
| 615 | unsigned char GetBT_CAP[] = { 0x18, 0x36 }; | ||
| 616 | unsigned char BT_CAP[8]; | ||
| 617 | enum si_sm_result smi_result; | ||
| 618 | int rv; | ||
| 619 | |||
| 658 | /* | 620 | /* |
| 659 | * It's impossible for the BT status and interrupt registers to be | 621 | * It's impossible for the BT status and interrupt registers to be |
| 660 | * all 1's, (assuming a properly functioning, self-initialized BMC) | 622 | * all 1's, (assuming a properly functioning, self-initialized BMC) |
| @@ -665,6 +627,48 @@ static int bt_detect(struct si_sm_data *bt) | |||
| 665 | if ((BT_STATUS == 0xFF) && (BT_INTMASK_R == 0xFF)) | 627 | if ((BT_STATUS == 0xFF) && (BT_INTMASK_R == 0xFF)) |
| 666 | return 1; | 628 | return 1; |
| 667 | reset_flags(bt); | 629 | reset_flags(bt); |
| 630 | |||
| 631 | /* | ||
| 632 | * Try getting the BT capabilities here. | ||
| 633 | */ | ||
| 634 | rv = bt_start_transaction(bt, GetBT_CAP, sizeof(GetBT_CAP)); | ||
| 635 | if (rv) { | ||
| 636 | dev_warn(bt->io->dev, | ||
| 637 | "Can't start capabilities transaction: %d\n", rv); | ||
| 638 | goto out_no_bt_cap; | ||
| 639 | } | ||
| 640 | |||
| 641 | smi_result = SI_SM_CALL_WITHOUT_DELAY; | ||
| 642 | for (;;) { | ||
| 643 | if (smi_result == SI_SM_CALL_WITH_DELAY || | ||
| 644 | smi_result == SI_SM_CALL_WITH_TICK_DELAY) { | ||
| 645 | schedule_timeout_uninterruptible(1); | ||
| 646 | smi_result = bt_event(bt, jiffies_to_usecs(1)); | ||
| 647 | } else if (smi_result == SI_SM_CALL_WITHOUT_DELAY) { | ||
| 648 | smi_result = bt_event(bt, 0); | ||
| 649 | } else | ||
| 650 | break; | ||
| 651 | } | ||
| 652 | |||
| 653 | rv = bt_get_result(bt, BT_CAP, sizeof(BT_CAP)); | ||
| 654 | bt_init_data(bt, bt->io); | ||
| 655 | if (rv < 8) { | ||
| 656 | dev_warn(bt->io->dev, "bt cap response too short: %d\n", rv); | ||
| 657 | goto out_no_bt_cap; | ||
| 658 | } | ||
| 659 | |||
| 660 | if (BT_CAP[2]) { | ||
| 661 | dev_warn(bt->io->dev, "Error fetching bt cap: %x\n", BT_CAP[2]); | ||
| 662 | out_no_bt_cap: | ||
| 663 | dev_warn(bt->io->dev, "using default values\n"); | ||
| 664 | } else { | ||
| 665 | bt->BT_CAP_req2rsp = BT_CAP[6] * USEC_PER_SEC; | ||
| 666 | bt->BT_CAP_retries = BT_CAP[7]; | ||
| 667 | } | ||
| 668 | |||
| 669 | dev_info(bt->io->dev, "req2rsp=%ld secs retries=%d\n", | ||
| 670 | bt->BT_CAP_req2rsp / USEC_PER_SEC, bt->BT_CAP_retries); | ||
| 671 | |||
| 668 | return 0; | 672 | return 0; |
| 669 | } | 673 | } |
| 670 | 674 | ||
diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c index 51832b8a2c62..7fc9612070a1 100644 --- a/drivers/char/ipmi/ipmi_msghandler.c +++ b/drivers/char/ipmi/ipmi_msghandler.c | |||
| @@ -3381,39 +3381,45 @@ int ipmi_register_smi(const struct ipmi_smi_handlers *handlers, | |||
| 3381 | 3381 | ||
| 3382 | rv = handlers->start_processing(send_info, intf); | 3382 | rv = handlers->start_processing(send_info, intf); |
| 3383 | if (rv) | 3383 | if (rv) |
| 3384 | goto out; | 3384 | goto out_err; |
| 3385 | 3385 | ||
| 3386 | rv = __bmc_get_device_id(intf, NULL, &id, NULL, NULL, i); | 3386 | rv = __bmc_get_device_id(intf, NULL, &id, NULL, NULL, i); |
| 3387 | if (rv) { | 3387 | if (rv) { |
| 3388 | dev_err(si_dev, "Unable to get the device id: %d\n", rv); | 3388 | dev_err(si_dev, "Unable to get the device id: %d\n", rv); |
| 3389 | goto out; | 3389 | goto out_err_started; |
| 3390 | } | 3390 | } |
| 3391 | 3391 | ||
| 3392 | mutex_lock(&intf->bmc_reg_mutex); | 3392 | mutex_lock(&intf->bmc_reg_mutex); |
| 3393 | rv = __scan_channels(intf, &id); | 3393 | rv = __scan_channels(intf, &id); |
| 3394 | mutex_unlock(&intf->bmc_reg_mutex); | 3394 | mutex_unlock(&intf->bmc_reg_mutex); |
| 3395 | if (rv) | ||
| 3396 | goto out_err_bmc_reg; | ||
| 3395 | 3397 | ||
| 3396 | out: | 3398 | /* |
| 3397 | if (rv) { | 3399 | * Keep memory order straight for RCU readers. Make |
| 3398 | ipmi_bmc_unregister(intf); | 3400 | * sure everything else is committed to memory before |
| 3399 | list_del_rcu(&intf->link); | 3401 | * setting intf_num to mark the interface valid. |
| 3400 | mutex_unlock(&ipmi_interfaces_mutex); | 3402 | */ |
| 3401 | synchronize_srcu(&ipmi_interfaces_srcu); | 3403 | smp_wmb(); |
| 3402 | cleanup_srcu_struct(&intf->users_srcu); | 3404 | intf->intf_num = i; |
| 3403 | kref_put(&intf->refcount, intf_free); | 3405 | mutex_unlock(&ipmi_interfaces_mutex); |
| 3404 | } else { | ||
| 3405 | /* | ||
| 3406 | * Keep memory order straight for RCU readers. Make | ||
| 3407 | * sure everything else is committed to memory before | ||
| 3408 | * setting intf_num to mark the interface valid. | ||
| 3409 | */ | ||
| 3410 | smp_wmb(); | ||
| 3411 | intf->intf_num = i; | ||
| 3412 | mutex_unlock(&ipmi_interfaces_mutex); | ||
| 3413 | 3406 | ||
| 3414 | /* After this point the interface is legal to use. */ | 3407 | /* After this point the interface is legal to use. */ |
| 3415 | call_smi_watchers(i, intf->si_dev); | 3408 | call_smi_watchers(i, intf->si_dev); |
| 3416 | } | 3409 | |
| 3410 | return 0; | ||
| 3411 | |||
| 3412 | out_err_bmc_reg: | ||
| 3413 | ipmi_bmc_unregister(intf); | ||
| 3414 | out_err_started: | ||
| 3415 | if (intf->handlers->shutdown) | ||
| 3416 | intf->handlers->shutdown(intf->send_info); | ||
| 3417 | out_err: | ||
| 3418 | list_del_rcu(&intf->link); | ||
| 3419 | mutex_unlock(&ipmi_interfaces_mutex); | ||
| 3420 | synchronize_srcu(&ipmi_interfaces_srcu); | ||
| 3421 | cleanup_srcu_struct(&intf->users_srcu); | ||
| 3422 | kref_put(&intf->refcount, intf_free); | ||
| 3417 | 3423 | ||
| 3418 | return rv; | 3424 | return rv; |
| 3419 | } | 3425 | } |
| @@ -3504,7 +3510,8 @@ void ipmi_unregister_smi(struct ipmi_smi *intf) | |||
| 3504 | } | 3510 | } |
| 3505 | srcu_read_unlock(&intf->users_srcu, index); | 3511 | srcu_read_unlock(&intf->users_srcu, index); |
| 3506 | 3512 | ||
| 3507 | intf->handlers->shutdown(intf->send_info); | 3513 | if (intf->handlers->shutdown) |
| 3514 | intf->handlers->shutdown(intf->send_info); | ||
| 3508 | 3515 | ||
| 3509 | cleanup_smi_msgs(intf); | 3516 | cleanup_smi_msgs(intf); |
| 3510 | 3517 | ||
diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c index 90ec010bffbd..5faa917df1b6 100644 --- a/drivers/char/ipmi/ipmi_si_intf.c +++ b/drivers/char/ipmi/ipmi_si_intf.c | |||
| @@ -2083,18 +2083,9 @@ static int try_smi_init(struct smi_info *new_smi) | |||
| 2083 | si_to_str[new_smi->io.si_type]); | 2083 | si_to_str[new_smi->io.si_type]); |
| 2084 | 2084 | ||
| 2085 | WARN_ON(new_smi->io.dev->init_name != NULL); | 2085 | WARN_ON(new_smi->io.dev->init_name != NULL); |
| 2086 | kfree(init_name); | ||
| 2087 | |||
| 2088 | return 0; | ||
| 2089 | |||
| 2090 | out_err: | ||
| 2091 | if (new_smi->intf) { | ||
| 2092 | ipmi_unregister_smi(new_smi->intf); | ||
| 2093 | new_smi->intf = NULL; | ||
| 2094 | } | ||
| 2095 | 2086 | ||
| 2087 | out_err: | ||
| 2096 | kfree(init_name); | 2088 | kfree(init_name); |
| 2097 | |||
| 2098 | return rv; | 2089 | return rv; |
| 2099 | } | 2090 | } |
| 2100 | 2091 | ||
| @@ -2227,6 +2218,8 @@ static void shutdown_smi(void *send_info) | |||
| 2227 | 2218 | ||
| 2228 | kfree(smi_info->si_sm); | 2219 | kfree(smi_info->si_sm); |
| 2229 | smi_info->si_sm = NULL; | 2220 | smi_info->si_sm = NULL; |
| 2221 | |||
| 2222 | smi_info->intf = NULL; | ||
| 2230 | } | 2223 | } |
| 2231 | 2224 | ||
| 2232 | /* | 2225 | /* |
| @@ -2240,10 +2233,8 @@ static void cleanup_one_si(struct smi_info *smi_info) | |||
| 2240 | 2233 | ||
| 2241 | list_del(&smi_info->link); | 2234 | list_del(&smi_info->link); |
| 2242 | 2235 | ||
| 2243 | if (smi_info->intf) { | 2236 | if (smi_info->intf) |
| 2244 | ipmi_unregister_smi(smi_info->intf); | 2237 | ipmi_unregister_smi(smi_info->intf); |
| 2245 | smi_info->intf = NULL; | ||
| 2246 | } | ||
| 2247 | 2238 | ||
| 2248 | if (smi_info->pdev) { | 2239 | if (smi_info->pdev) { |
| 2249 | if (smi_info->pdev_registered) | 2240 | if (smi_info->pdev_registered) |
diff --git a/drivers/char/ipmi/ipmi_ssif.c b/drivers/char/ipmi/ipmi_ssif.c index 18e4650c233b..29e67a80fb20 100644 --- a/drivers/char/ipmi/ipmi_ssif.c +++ b/drivers/char/ipmi/ipmi_ssif.c | |||
| @@ -181,6 +181,8 @@ struct ssif_addr_info { | |||
| 181 | struct device *dev; | 181 | struct device *dev; |
| 182 | struct i2c_client *client; | 182 | struct i2c_client *client; |
| 183 | 183 | ||
| 184 | struct i2c_client *added_client; | ||
| 185 | |||
| 184 | struct mutex clients_mutex; | 186 | struct mutex clients_mutex; |
| 185 | struct list_head clients; | 187 | struct list_head clients; |
| 186 | 188 | ||
| @@ -1214,18 +1216,11 @@ static void shutdown_ssif(void *send_info) | |||
| 1214 | complete(&ssif_info->wake_thread); | 1216 | complete(&ssif_info->wake_thread); |
| 1215 | kthread_stop(ssif_info->thread); | 1217 | kthread_stop(ssif_info->thread); |
| 1216 | } | 1218 | } |
| 1217 | |||
| 1218 | /* | ||
| 1219 | * No message can be outstanding now, we have removed the | ||
| 1220 | * upper layer and it permitted us to do so. | ||
| 1221 | */ | ||
| 1222 | kfree(ssif_info); | ||
| 1223 | } | 1219 | } |
| 1224 | 1220 | ||
| 1225 | static int ssif_remove(struct i2c_client *client) | 1221 | static int ssif_remove(struct i2c_client *client) |
| 1226 | { | 1222 | { |
| 1227 | struct ssif_info *ssif_info = i2c_get_clientdata(client); | 1223 | struct ssif_info *ssif_info = i2c_get_clientdata(client); |
| 1228 | struct ipmi_smi *intf; | ||
| 1229 | struct ssif_addr_info *addr_info; | 1224 | struct ssif_addr_info *addr_info; |
| 1230 | 1225 | ||
| 1231 | if (!ssif_info) | 1226 | if (!ssif_info) |
| @@ -1235,9 +1230,7 @@ static int ssif_remove(struct i2c_client *client) | |||
| 1235 | * After this point, we won't deliver anything asychronously | 1230 | * After this point, we won't deliver anything asychronously |
| 1236 | * to the message handler. We can unregister ourself. | 1231 | * to the message handler. We can unregister ourself. |
| 1237 | */ | 1232 | */ |
| 1238 | intf = ssif_info->intf; | 1233 | ipmi_unregister_smi(ssif_info->intf); |
| 1239 | ssif_info->intf = NULL; | ||
| 1240 | ipmi_unregister_smi(intf); | ||
| 1241 | 1234 | ||
| 1242 | list_for_each_entry(addr_info, &ssif_infos, link) { | 1235 | list_for_each_entry(addr_info, &ssif_infos, link) { |
| 1243 | if (addr_info->client == client) { | 1236 | if (addr_info->client == client) { |
| @@ -1246,6 +1239,8 @@ static int ssif_remove(struct i2c_client *client) | |||
| 1246 | } | 1239 | } |
| 1247 | } | 1240 | } |
| 1248 | 1241 | ||
| 1242 | kfree(ssif_info); | ||
| 1243 | |||
| 1249 | return 0; | 1244 | return 0; |
| 1250 | } | 1245 | } |
| 1251 | 1246 | ||
| @@ -1648,15 +1643,9 @@ static int ssif_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
| 1648 | 1643 | ||
| 1649 | out: | 1644 | out: |
| 1650 | if (rv) { | 1645 | if (rv) { |
| 1651 | /* | 1646 | if (addr_info) |
| 1652 | * Note that if addr_info->client is assigned, we | 1647 | addr_info->client = NULL; |
| 1653 | * leave it. The i2c client hangs around even if we | 1648 | |
| 1654 | * return a failure here, and the failure here is not | ||
| 1655 | * propagated back to the i2c code. This seems to be | ||
| 1656 | * design intent, strange as it may be. But if we | ||
| 1657 | * don't leave it, ssif_platform_remove will not remove | ||
| 1658 | * the client like it should. | ||
| 1659 | */ | ||
| 1660 | dev_err(&client->dev, "Unable to start IPMI SSIF: %d\n", rv); | 1649 | dev_err(&client->dev, "Unable to start IPMI SSIF: %d\n", rv); |
| 1661 | kfree(ssif_info); | 1650 | kfree(ssif_info); |
| 1662 | } | 1651 | } |
| @@ -1676,7 +1665,8 @@ static int ssif_adapter_handler(struct device *adev, void *opaque) | |||
| 1676 | if (adev->type != &i2c_adapter_type) | 1665 | if (adev->type != &i2c_adapter_type) |
| 1677 | return 0; | 1666 | return 0; |
| 1678 | 1667 | ||
| 1679 | i2c_new_device(to_i2c_adapter(adev), &addr_info->binfo); | 1668 | addr_info->added_client = i2c_new_device(to_i2c_adapter(adev), |
| 1669 | &addr_info->binfo); | ||
| 1680 | 1670 | ||
| 1681 | if (!addr_info->adapter_name) | 1671 | if (!addr_info->adapter_name) |
| 1682 | return 1; /* Only try the first I2C adapter by default. */ | 1672 | return 1; /* Only try the first I2C adapter by default. */ |
| @@ -1849,7 +1839,7 @@ static int ssif_platform_remove(struct platform_device *dev) | |||
| 1849 | return 0; | 1839 | return 0; |
| 1850 | 1840 | ||
| 1851 | mutex_lock(&ssif_infos_mutex); | 1841 | mutex_lock(&ssif_infos_mutex); |
| 1852 | i2c_unregister_device(addr_info->client); | 1842 | i2c_unregister_device(addr_info->added_client); |
| 1853 | 1843 | ||
| 1854 | list_del(&addr_info->link); | 1844 | list_del(&addr_info->link); |
| 1855 | kfree(addr_info); | 1845 | kfree(addr_info); |
diff --git a/drivers/char/ipmi/kcs_bmc.c b/drivers/char/ipmi/kcs_bmc.c index bb882ab161fe..e6124bd548df 100644 --- a/drivers/char/ipmi/kcs_bmc.c +++ b/drivers/char/ipmi/kcs_bmc.c | |||
| @@ -16,6 +16,8 @@ | |||
| 16 | 16 | ||
| 17 | #include "kcs_bmc.h" | 17 | #include "kcs_bmc.h" |
| 18 | 18 | ||
| 19 | #define DEVICE_NAME "ipmi-kcs" | ||
| 20 | |||
| 19 | #define KCS_MSG_BUFSIZ 1000 | 21 | #define KCS_MSG_BUFSIZ 1000 |
| 20 | 22 | ||
| 21 | #define KCS_ZERO_DATA 0 | 23 | #define KCS_ZERO_DATA 0 |
| @@ -429,8 +431,6 @@ struct kcs_bmc *kcs_bmc_alloc(struct device *dev, int sizeof_priv, u32 channel) | |||
| 429 | if (!kcs_bmc) | 431 | if (!kcs_bmc) |
| 430 | return NULL; | 432 | return NULL; |
| 431 | 433 | ||
| 432 | dev_set_name(dev, "ipmi-kcs%u", channel); | ||
| 433 | |||
| 434 | spin_lock_init(&kcs_bmc->lock); | 434 | spin_lock_init(&kcs_bmc->lock); |
| 435 | kcs_bmc->channel = channel; | 435 | kcs_bmc->channel = channel; |
| 436 | 436 | ||
| @@ -444,7 +444,8 @@ struct kcs_bmc *kcs_bmc_alloc(struct device *dev, int sizeof_priv, u32 channel) | |||
| 444 | return NULL; | 444 | return NULL; |
| 445 | 445 | ||
| 446 | kcs_bmc->miscdev.minor = MISC_DYNAMIC_MINOR; | 446 | kcs_bmc->miscdev.minor = MISC_DYNAMIC_MINOR; |
| 447 | kcs_bmc->miscdev.name = dev_name(dev); | 447 | kcs_bmc->miscdev.name = devm_kasprintf(dev, GFP_KERNEL, "%s%u", |
| 448 | DEVICE_NAME, channel); | ||
| 448 | kcs_bmc->miscdev.fops = &kcs_bmc_fops; | 449 | kcs_bmc->miscdev.fops = &kcs_bmc_fops; |
| 449 | 450 | ||
| 450 | return kcs_bmc; | 451 | return kcs_bmc; |
diff --git a/drivers/char/random.c b/drivers/char/random.c index bf5f99fc36f1..c75b6cdf0053 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c | |||
| @@ -779,6 +779,13 @@ static struct crng_state **crng_node_pool __read_mostly; | |||
| 779 | 779 | ||
| 780 | static void invalidate_batched_entropy(void); | 780 | static void invalidate_batched_entropy(void); |
| 781 | 781 | ||
| 782 | static bool trust_cpu __ro_after_init = IS_ENABLED(CONFIG_RANDOM_TRUST_CPU); | ||
| 783 | static int __init parse_trust_cpu(char *arg) | ||
| 784 | { | ||
| 785 | return kstrtobool(arg, &trust_cpu); | ||
| 786 | } | ||
| 787 | early_param("random.trust_cpu", parse_trust_cpu); | ||
| 788 | |||
| 782 | static void crng_initialize(struct crng_state *crng) | 789 | static void crng_initialize(struct crng_state *crng) |
| 783 | { | 790 | { |
| 784 | int i; | 791 | int i; |
| @@ -799,12 +806,10 @@ static void crng_initialize(struct crng_state *crng) | |||
| 799 | } | 806 | } |
| 800 | crng->state[i] ^= rv; | 807 | crng->state[i] ^= rv; |
| 801 | } | 808 | } |
| 802 | #ifdef CONFIG_RANDOM_TRUST_CPU | 809 | if (trust_cpu && arch_init) { |
| 803 | if (arch_init) { | ||
| 804 | crng_init = 2; | 810 | crng_init = 2; |
| 805 | pr_notice("random: crng done (trusting CPU's manufacturer)\n"); | 811 | pr_notice("random: crng done (trusting CPU's manufacturer)\n"); |
| 806 | } | 812 | } |
| 807 | #endif | ||
| 808 | crng->init_time = jiffies - CRNG_RESEED_INTERVAL - 1; | 813 | crng->init_time = jiffies - CRNG_RESEED_INTERVAL - 1; |
| 809 | } | 814 | } |
| 810 | 815 | ||
diff --git a/drivers/dma/mic_x100_dma.c b/drivers/dma/mic_x100_dma.c index b76cb17d879c..adfd316db1a8 100644 --- a/drivers/dma/mic_x100_dma.c +++ b/drivers/dma/mic_x100_dma.c | |||
| @@ -639,7 +639,7 @@ static struct mic_dma_device *mic_dma_dev_reg(struct mbus_device *mbdev, | |||
| 639 | int ret; | 639 | int ret; |
| 640 | struct device *dev = &mbdev->dev; | 640 | struct device *dev = &mbdev->dev; |
| 641 | 641 | ||
| 642 | mic_dma_dev = kzalloc(sizeof(*mic_dma_dev), GFP_KERNEL); | 642 | mic_dma_dev = devm_kzalloc(dev, sizeof(*mic_dma_dev), GFP_KERNEL); |
| 643 | if (!mic_dma_dev) { | 643 | if (!mic_dma_dev) { |
| 644 | ret = -ENOMEM; | 644 | ret = -ENOMEM; |
| 645 | goto alloc_error; | 645 | goto alloc_error; |
| @@ -664,7 +664,6 @@ static struct mic_dma_device *mic_dma_dev_reg(struct mbus_device *mbdev, | |||
| 664 | reg_error: | 664 | reg_error: |
| 665 | mic_dma_uninit(mic_dma_dev); | 665 | mic_dma_uninit(mic_dma_dev); |
| 666 | init_error: | 666 | init_error: |
| 667 | kfree(mic_dma_dev); | ||
| 668 | mic_dma_dev = NULL; | 667 | mic_dma_dev = NULL; |
| 669 | alloc_error: | 668 | alloc_error: |
| 670 | dev_err(dev, "Error at %s %d ret=%d\n", __func__, __LINE__, ret); | 669 | dev_err(dev, "Error at %s %d ret=%d\n", __func__, __LINE__, ret); |
| @@ -674,7 +673,6 @@ alloc_error: | |||
| 674 | static void mic_dma_dev_unreg(struct mic_dma_device *mic_dma_dev) | 673 | static void mic_dma_dev_unreg(struct mic_dma_device *mic_dma_dev) |
| 675 | { | 674 | { |
| 676 | mic_dma_uninit(mic_dma_dev); | 675 | mic_dma_uninit(mic_dma_dev); |
| 677 | kfree(mic_dma_dev); | ||
| 678 | } | 676 | } |
| 679 | 677 | ||
| 680 | /* DEBUGFS CODE */ | 678 | /* DEBUGFS CODE */ |
diff --git a/drivers/fpga/dfl-fme-pr.c b/drivers/fpga/dfl-fme-pr.c index fc9fd2d0482f..0b840531ef33 100644 --- a/drivers/fpga/dfl-fme-pr.c +++ b/drivers/fpga/dfl-fme-pr.c | |||
| @@ -420,7 +420,7 @@ static int pr_mgmt_init(struct platform_device *pdev, | |||
| 420 | /* Create region for each port */ | 420 | /* Create region for each port */ |
| 421 | fme_region = dfl_fme_create_region(pdata, mgr, | 421 | fme_region = dfl_fme_create_region(pdata, mgr, |
| 422 | fme_br->br, i); | 422 | fme_br->br, i); |
| 423 | if (!fme_region) { | 423 | if (IS_ERR(fme_region)) { |
| 424 | ret = PTR_ERR(fme_region); | 424 | ret = PTR_ERR(fme_region); |
| 425 | goto destroy_region; | 425 | goto destroy_region; |
| 426 | } | 426 | } |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c index b6e9df11115d..b31d121a876b 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | |||
| @@ -39,6 +39,7 @@ static int amdgpu_cs_user_fence_chunk(struct amdgpu_cs_parser *p, | |||
| 39 | { | 39 | { |
| 40 | struct drm_gem_object *gobj; | 40 | struct drm_gem_object *gobj; |
| 41 | unsigned long size; | 41 | unsigned long size; |
| 42 | int r; | ||
| 42 | 43 | ||
| 43 | gobj = drm_gem_object_lookup(p->filp, data->handle); | 44 | gobj = drm_gem_object_lookup(p->filp, data->handle); |
| 44 | if (gobj == NULL) | 45 | if (gobj == NULL) |
| @@ -50,20 +51,26 @@ static int amdgpu_cs_user_fence_chunk(struct amdgpu_cs_parser *p, | |||
| 50 | p->uf_entry.tv.shared = true; | 51 | p->uf_entry.tv.shared = true; |
| 51 | p->uf_entry.user_pages = NULL; | 52 | p->uf_entry.user_pages = NULL; |
| 52 | 53 | ||
| 53 | size = amdgpu_bo_size(p->uf_entry.robj); | ||
| 54 | if (size != PAGE_SIZE || (data->offset + 8) > size) | ||
| 55 | return -EINVAL; | ||
| 56 | |||
| 57 | *offset = data->offset; | ||
| 58 | |||
| 59 | drm_gem_object_put_unlocked(gobj); | 54 | drm_gem_object_put_unlocked(gobj); |
| 60 | 55 | ||
| 56 | size = amdgpu_bo_size(p->uf_entry.robj); | ||
| 57 | if (size != PAGE_SIZE || (data->offset + 8) > size) { | ||
| 58 | r = -EINVAL; | ||
| 59 | goto error_unref; | ||
| 60 | } | ||
| 61 | |||
| 61 | if (amdgpu_ttm_tt_get_usermm(p->uf_entry.robj->tbo.ttm)) { | 62 | if (amdgpu_ttm_tt_get_usermm(p->uf_entry.robj->tbo.ttm)) { |
| 62 | amdgpu_bo_unref(&p->uf_entry.robj); | 63 | r = -EINVAL; |
| 63 | return -EINVAL; | 64 | goto error_unref; |
| 64 | } | 65 | } |
| 65 | 66 | ||
| 67 | *offset = data->offset; | ||
| 68 | |||
| 66 | return 0; | 69 | return 0; |
| 70 | |||
| 71 | error_unref: | ||
| 72 | amdgpu_bo_unref(&p->uf_entry.robj); | ||
| 73 | return r; | ||
| 67 | } | 74 | } |
| 68 | 75 | ||
| 69 | static int amdgpu_cs_bo_handles_chunk(struct amdgpu_cs_parser *p, | 76 | static int amdgpu_cs_bo_handles_chunk(struct amdgpu_cs_parser *p, |
| @@ -1262,10 +1269,10 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p, | |||
| 1262 | error_abort: | 1269 | error_abort: |
| 1263 | dma_fence_put(&job->base.s_fence->finished); | 1270 | dma_fence_put(&job->base.s_fence->finished); |
| 1264 | job->base.s_fence = NULL; | 1271 | job->base.s_fence = NULL; |
| 1272 | amdgpu_mn_unlock(p->mn); | ||
| 1265 | 1273 | ||
| 1266 | error_unlock: | 1274 | error_unlock: |
| 1267 | amdgpu_job_free(job); | 1275 | amdgpu_job_free(job); |
| 1268 | amdgpu_mn_unlock(p->mn); | ||
| 1269 | return r; | 1276 | return r; |
| 1270 | } | 1277 | } |
| 1271 | 1278 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index 8ab5ccbc14ac..39bf2ce548c6 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | |||
| @@ -2063,6 +2063,7 @@ static int amdgpu_device_ip_reinit_early_sriov(struct amdgpu_device *adev) | |||
| 2063 | static enum amd_ip_block_type ip_order[] = { | 2063 | static enum amd_ip_block_type ip_order[] = { |
| 2064 | AMD_IP_BLOCK_TYPE_GMC, | 2064 | AMD_IP_BLOCK_TYPE_GMC, |
| 2065 | AMD_IP_BLOCK_TYPE_COMMON, | 2065 | AMD_IP_BLOCK_TYPE_COMMON, |
| 2066 | AMD_IP_BLOCK_TYPE_PSP, | ||
| 2066 | AMD_IP_BLOCK_TYPE_IH, | 2067 | AMD_IP_BLOCK_TYPE_IH, |
| 2067 | }; | 2068 | }; |
| 2068 | 2069 | ||
| @@ -2093,7 +2094,6 @@ static int amdgpu_device_ip_reinit_late_sriov(struct amdgpu_device *adev) | |||
| 2093 | 2094 | ||
| 2094 | static enum amd_ip_block_type ip_order[] = { | 2095 | static enum amd_ip_block_type ip_order[] = { |
| 2095 | AMD_IP_BLOCK_TYPE_SMC, | 2096 | AMD_IP_BLOCK_TYPE_SMC, |
| 2096 | AMD_IP_BLOCK_TYPE_PSP, | ||
| 2097 | AMD_IP_BLOCK_TYPE_DCE, | 2097 | AMD_IP_BLOCK_TYPE_DCE, |
| 2098 | AMD_IP_BLOCK_TYPE_GFX, | 2098 | AMD_IP_BLOCK_TYPE_GFX, |
| 2099 | AMD_IP_BLOCK_TYPE_SDMA, | 2099 | AMD_IP_BLOCK_TYPE_SDMA, |
diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c b/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c index e7ca4623cfb9..7c3b634d8d5f 100644 --- a/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +++ b/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c | |||
| @@ -70,6 +70,7 @@ static const struct soc15_reg_golden golden_settings_sdma_4[] = { | |||
| 70 | SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_RLC1_IB_CNTL, 0x800f0100, 0x00000100), | 70 | SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_RLC1_IB_CNTL, 0x800f0100, 0x00000100), |
| 71 | SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_RLC1_RB_WPTR_POLL_CNTL, 0x0000fff0, 0x00403000), | 71 | SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_RLC1_RB_WPTR_POLL_CNTL, 0x0000fff0, 0x00403000), |
| 72 | SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_UTCL1_PAGE, 0x000003ff, 0x000003c0), | 72 | SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_UTCL1_PAGE, 0x000003ff, 0x000003c0), |
| 73 | SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_UTCL1_WATERMK, 0xfc000000, 0x00000000), | ||
| 73 | SOC15_REG_GOLDEN_VALUE(SDMA1, 0, mmSDMA1_CHICKEN_BITS, 0xfe931f07, 0x02831f07), | 74 | SOC15_REG_GOLDEN_VALUE(SDMA1, 0, mmSDMA1_CHICKEN_BITS, 0xfe931f07, 0x02831f07), |
| 74 | SOC15_REG_GOLDEN_VALUE(SDMA1, 0, mmSDMA1_CLK_CTRL, 0xffffffff, 0x3f000100), | 75 | SOC15_REG_GOLDEN_VALUE(SDMA1, 0, mmSDMA1_CLK_CTRL, 0xffffffff, 0x3f000100), |
| 75 | SOC15_REG_GOLDEN_VALUE(SDMA1, 0, mmSDMA1_GFX_IB_CNTL, 0x800f0100, 0x00000100), | 76 | SOC15_REG_GOLDEN_VALUE(SDMA1, 0, mmSDMA1_GFX_IB_CNTL, 0x800f0100, 0x00000100), |
| @@ -81,7 +82,8 @@ static const struct soc15_reg_golden golden_settings_sdma_4[] = { | |||
| 81 | SOC15_REG_GOLDEN_VALUE(SDMA1, 0, mmSDMA1_RLC0_RB_WPTR_POLL_CNTL, 0x0000fff0, 0x00403000), | 82 | SOC15_REG_GOLDEN_VALUE(SDMA1, 0, mmSDMA1_RLC0_RB_WPTR_POLL_CNTL, 0x0000fff0, 0x00403000), |
| 82 | SOC15_REG_GOLDEN_VALUE(SDMA1, 0, mmSDMA1_RLC1_IB_CNTL, 0x800f0100, 0x00000100), | 83 | SOC15_REG_GOLDEN_VALUE(SDMA1, 0, mmSDMA1_RLC1_IB_CNTL, 0x800f0100, 0x00000100), |
| 83 | SOC15_REG_GOLDEN_VALUE(SDMA1, 0, mmSDMA1_RLC1_RB_WPTR_POLL_CNTL, 0x0000fff0, 0x00403000), | 84 | SOC15_REG_GOLDEN_VALUE(SDMA1, 0, mmSDMA1_RLC1_RB_WPTR_POLL_CNTL, 0x0000fff0, 0x00403000), |
| 84 | SOC15_REG_GOLDEN_VALUE(SDMA1, 0, mmSDMA1_UTCL1_PAGE, 0x000003ff, 0x000003c0) | 85 | SOC15_REG_GOLDEN_VALUE(SDMA1, 0, mmSDMA1_UTCL1_PAGE, 0x000003ff, 0x000003c0), |
| 86 | SOC15_REG_GOLDEN_VALUE(SDMA1, 0, mmSDMA1_UTCL1_WATERMK, 0xfc000000, 0x00000000) | ||
| 85 | }; | 87 | }; |
| 86 | 88 | ||
| 87 | static const struct soc15_reg_golden golden_settings_sdma_vg10[] = { | 89 | static const struct soc15_reg_golden golden_settings_sdma_vg10[] = { |
| @@ -109,7 +111,8 @@ static const struct soc15_reg_golden golden_settings_sdma_4_1[] = | |||
| 109 | SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_RLC0_RB_WPTR_POLL_CNTL, 0xfffffff7, 0x00403000), | 111 | SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_RLC0_RB_WPTR_POLL_CNTL, 0xfffffff7, 0x00403000), |
| 110 | SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_RLC1_IB_CNTL, 0x800f0111, 0x00000100), | 112 | SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_RLC1_IB_CNTL, 0x800f0111, 0x00000100), |
| 111 | SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_RLC1_RB_WPTR_POLL_CNTL, 0xfffffff7, 0x00403000), | 113 | SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_RLC1_RB_WPTR_POLL_CNTL, 0xfffffff7, 0x00403000), |
| 112 | SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_UTCL1_PAGE, 0x000003ff, 0x000003c0) | 114 | SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_UTCL1_PAGE, 0x000003ff, 0x000003c0), |
| 115 | SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_UTCL1_WATERMK, 0xfc000000, 0x00000000) | ||
| 113 | }; | 116 | }; |
| 114 | 117 | ||
| 115 | static const struct soc15_reg_golden golden_settings_sdma_4_2[] = | 118 | static const struct soc15_reg_golden golden_settings_sdma_4_2[] = |
diff --git a/drivers/gpu/drm/i915/gvt/kvmgt.c b/drivers/gpu/drm/i915/gvt/kvmgt.c index a45f46d8537f..c7afee37b2b8 100644 --- a/drivers/gpu/drm/i915/gvt/kvmgt.c +++ b/drivers/gpu/drm/i915/gvt/kvmgt.c | |||
| @@ -32,6 +32,7 @@ | |||
| 32 | #include <linux/device.h> | 32 | #include <linux/device.h> |
| 33 | #include <linux/mm.h> | 33 | #include <linux/mm.h> |
| 34 | #include <linux/mmu_context.h> | 34 | #include <linux/mmu_context.h> |
| 35 | #include <linux/sched/mm.h> | ||
| 35 | #include <linux/types.h> | 36 | #include <linux/types.h> |
| 36 | #include <linux/list.h> | 37 | #include <linux/list.h> |
| 37 | #include <linux/rbtree.h> | 38 | #include <linux/rbtree.h> |
| @@ -1792,16 +1793,21 @@ static int kvmgt_rw_gpa(unsigned long handle, unsigned long gpa, | |||
| 1792 | info = (struct kvmgt_guest_info *)handle; | 1793 | info = (struct kvmgt_guest_info *)handle; |
| 1793 | kvm = info->kvm; | 1794 | kvm = info->kvm; |
| 1794 | 1795 | ||
| 1795 | if (kthread) | 1796 | if (kthread) { |
| 1797 | if (!mmget_not_zero(kvm->mm)) | ||
| 1798 | return -EFAULT; | ||
| 1796 | use_mm(kvm->mm); | 1799 | use_mm(kvm->mm); |
| 1800 | } | ||
| 1797 | 1801 | ||
| 1798 | idx = srcu_read_lock(&kvm->srcu); | 1802 | idx = srcu_read_lock(&kvm->srcu); |
| 1799 | ret = write ? kvm_write_guest(kvm, gpa, buf, len) : | 1803 | ret = write ? kvm_write_guest(kvm, gpa, buf, len) : |
| 1800 | kvm_read_guest(kvm, gpa, buf, len); | 1804 | kvm_read_guest(kvm, gpa, buf, len); |
| 1801 | srcu_read_unlock(&kvm->srcu, idx); | 1805 | srcu_read_unlock(&kvm->srcu, idx); |
| 1802 | 1806 | ||
| 1803 | if (kthread) | 1807 | if (kthread) { |
| 1804 | unuse_mm(kvm->mm); | 1808 | unuse_mm(kvm->mm); |
| 1809 | mmput(kvm->mm); | ||
| 1810 | } | ||
| 1805 | 1811 | ||
| 1806 | return ret; | 1812 | return ret; |
| 1807 | } | 1813 | } |
diff --git a/drivers/gpu/drm/i915/gvt/opregion.c b/drivers/gpu/drm/i915/gvt/opregion.c index fa75a2eead90..b0d3a43ccd03 100644 --- a/drivers/gpu/drm/i915/gvt/opregion.c +++ b/drivers/gpu/drm/i915/gvt/opregion.c | |||
| @@ -42,8 +42,6 @@ | |||
| 42 | #define DEVICE_TYPE_EFP3 0x20 | 42 | #define DEVICE_TYPE_EFP3 0x20 |
| 43 | #define DEVICE_TYPE_EFP4 0x10 | 43 | #define DEVICE_TYPE_EFP4 0x10 |
| 44 | 44 | ||
| 45 | #define DEV_SIZE 38 | ||
| 46 | |||
| 47 | struct opregion_header { | 45 | struct opregion_header { |
| 48 | u8 signature[16]; | 46 | u8 signature[16]; |
| 49 | u32 size; | 47 | u32 size; |
| @@ -63,6 +61,10 @@ struct bdb_data_header { | |||
| 63 | u16 size; /* data size */ | 61 | u16 size; /* data size */ |
| 64 | } __packed; | 62 | } __packed; |
| 65 | 63 | ||
| 64 | /* For supporting windows guest with opregion, here hardcode the emulated | ||
| 65 | * bdb header version as '186', and the corresponding child_device_config | ||
| 66 | * length should be '33' but not '38'. | ||
| 67 | */ | ||
| 66 | struct efp_child_device_config { | 68 | struct efp_child_device_config { |
| 67 | u16 handle; | 69 | u16 handle; |
| 68 | u16 device_type; | 70 | u16 device_type; |
| @@ -109,12 +111,6 @@ struct efp_child_device_config { | |||
| 109 | u8 mipi_bridge_type; /* 171 */ | 111 | u8 mipi_bridge_type; /* 171 */ |
| 110 | u16 device_class_ext; | 112 | u16 device_class_ext; |
| 111 | u8 dvo_function; | 113 | u8 dvo_function; |
| 112 | u8 dp_usb_type_c:1; /* 195 */ | ||
| 113 | u8 skip6:7; | ||
| 114 | u8 dp_usb_type_c_2x_gpio_index; /* 195 */ | ||
| 115 | u16 dp_usb_type_c_2x_gpio_pin; /* 195 */ | ||
| 116 | u8 iboost_dp:4; /* 196 */ | ||
| 117 | u8 iboost_hdmi:4; /* 196 */ | ||
| 118 | } __packed; | 114 | } __packed; |
| 119 | 115 | ||
| 120 | struct vbt { | 116 | struct vbt { |
| @@ -155,7 +151,7 @@ static void virt_vbt_generation(struct vbt *v) | |||
| 155 | v->header.bdb_offset = offsetof(struct vbt, bdb_header); | 151 | v->header.bdb_offset = offsetof(struct vbt, bdb_header); |
| 156 | 152 | ||
| 157 | strcpy(&v->bdb_header.signature[0], "BIOS_DATA_BLOCK"); | 153 | strcpy(&v->bdb_header.signature[0], "BIOS_DATA_BLOCK"); |
| 158 | v->bdb_header.version = 186; /* child_dev_size = 38 */ | 154 | v->bdb_header.version = 186; /* child_dev_size = 33 */ |
| 159 | v->bdb_header.header_size = sizeof(v->bdb_header); | 155 | v->bdb_header.header_size = sizeof(v->bdb_header); |
| 160 | 156 | ||
| 161 | v->bdb_header.bdb_size = sizeof(struct vbt) - sizeof(struct vbt_header) | 157 | v->bdb_header.bdb_size = sizeof(struct vbt) - sizeof(struct vbt_header) |
| @@ -169,11 +165,13 @@ static void virt_vbt_generation(struct vbt *v) | |||
| 169 | 165 | ||
| 170 | /* child device */ | 166 | /* child device */ |
| 171 | num_child = 4; /* each port has one child */ | 167 | num_child = 4; /* each port has one child */ |
| 168 | v->general_definitions.child_dev_size = | ||
| 169 | sizeof(struct efp_child_device_config); | ||
| 172 | v->general_definitions_header.id = BDB_GENERAL_DEFINITIONS; | 170 | v->general_definitions_header.id = BDB_GENERAL_DEFINITIONS; |
| 173 | /* size will include child devices */ | 171 | /* size will include child devices */ |
| 174 | v->general_definitions_header.size = | 172 | v->general_definitions_header.size = |
| 175 | sizeof(struct bdb_general_definitions) + num_child * DEV_SIZE; | 173 | sizeof(struct bdb_general_definitions) + |
| 176 | v->general_definitions.child_dev_size = DEV_SIZE; | 174 | num_child * v->general_definitions.child_dev_size; |
| 177 | 175 | ||
| 178 | /* portA */ | 176 | /* portA */ |
| 179 | v->child0.handle = DEVICE_TYPE_EFP1; | 177 | v->child0.handle = DEVICE_TYPE_EFP1; |
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index 4a3c8ee9a973..d2951096bca0 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c | |||
| @@ -5079,10 +5079,14 @@ void hsw_disable_ips(const struct intel_crtc_state *crtc_state) | |||
| 5079 | mutex_lock(&dev_priv->pcu_lock); | 5079 | mutex_lock(&dev_priv->pcu_lock); |
| 5080 | WARN_ON(sandybridge_pcode_write(dev_priv, DISPLAY_IPS_CONTROL, 0)); | 5080 | WARN_ON(sandybridge_pcode_write(dev_priv, DISPLAY_IPS_CONTROL, 0)); |
| 5081 | mutex_unlock(&dev_priv->pcu_lock); | 5081 | mutex_unlock(&dev_priv->pcu_lock); |
| 5082 | /* wait for pcode to finish disabling IPS, which may take up to 42ms */ | 5082 | /* |
| 5083 | * Wait for PCODE to finish disabling IPS. The BSpec specified | ||
| 5084 | * 42ms timeout value leads to occasional timeouts so use 100ms | ||
| 5085 | * instead. | ||
| 5086 | */ | ||
| 5083 | if (intel_wait_for_register(dev_priv, | 5087 | if (intel_wait_for_register(dev_priv, |
| 5084 | IPS_CTL, IPS_ENABLE, 0, | 5088 | IPS_CTL, IPS_ENABLE, 0, |
| 5085 | 42)) | 5089 | 100)) |
| 5086 | DRM_ERROR("Timed out waiting for IPS disable\n"); | 5090 | DRM_ERROR("Timed out waiting for IPS disable\n"); |
| 5087 | } else { | 5091 | } else { |
| 5088 | I915_WRITE(IPS_CTL, 0); | 5092 | I915_WRITE(IPS_CTL, 0); |
diff --git a/drivers/gpu/drm/i915/intel_overlay.c b/drivers/gpu/drm/i915/intel_overlay.c index c2f10d899329..443dfaefd7a6 100644 --- a/drivers/gpu/drm/i915/intel_overlay.c +++ b/drivers/gpu/drm/i915/intel_overlay.c | |||
| @@ -181,8 +181,9 @@ struct intel_overlay { | |||
| 181 | u32 brightness, contrast, saturation; | 181 | u32 brightness, contrast, saturation; |
| 182 | u32 old_xscale, old_yscale; | 182 | u32 old_xscale, old_yscale; |
| 183 | /* register access */ | 183 | /* register access */ |
| 184 | u32 flip_addr; | ||
| 185 | struct drm_i915_gem_object *reg_bo; | 184 | struct drm_i915_gem_object *reg_bo; |
| 185 | struct overlay_registers __iomem *regs; | ||
| 186 | u32 flip_addr; | ||
| 186 | /* flip handling */ | 187 | /* flip handling */ |
| 187 | struct i915_gem_active last_flip; | 188 | struct i915_gem_active last_flip; |
| 188 | }; | 189 | }; |
| @@ -210,29 +211,6 @@ static void i830_overlay_clock_gating(struct drm_i915_private *dev_priv, | |||
| 210 | PCI_DEVFN(0, 0), I830_CLOCK_GATE, val); | 211 | PCI_DEVFN(0, 0), I830_CLOCK_GATE, val); |
| 211 | } | 212 | } |
| 212 | 213 | ||
| 213 | static struct overlay_registers __iomem * | ||
| 214 | intel_overlay_map_regs(struct intel_overlay *overlay) | ||
| 215 | { | ||
| 216 | struct drm_i915_private *dev_priv = overlay->i915; | ||
| 217 | struct overlay_registers __iomem *regs; | ||
| 218 | |||
| 219 | if (OVERLAY_NEEDS_PHYSICAL(dev_priv)) | ||
| 220 | regs = (struct overlay_registers __iomem *)overlay->reg_bo->phys_handle->vaddr; | ||
| 221 | else | ||
| 222 | regs = io_mapping_map_wc(&dev_priv->ggtt.iomap, | ||
| 223 | overlay->flip_addr, | ||
| 224 | PAGE_SIZE); | ||
| 225 | |||
| 226 | return regs; | ||
| 227 | } | ||
| 228 | |||
| 229 | static void intel_overlay_unmap_regs(struct intel_overlay *overlay, | ||
| 230 | struct overlay_registers __iomem *regs) | ||
| 231 | { | ||
| 232 | if (!OVERLAY_NEEDS_PHYSICAL(overlay->i915)) | ||
| 233 | io_mapping_unmap(regs); | ||
| 234 | } | ||
| 235 | |||
| 236 | static void intel_overlay_submit_request(struct intel_overlay *overlay, | 214 | static void intel_overlay_submit_request(struct intel_overlay *overlay, |
| 237 | struct i915_request *rq, | 215 | struct i915_request *rq, |
| 238 | i915_gem_retire_fn retire) | 216 | i915_gem_retire_fn retire) |
| @@ -784,13 +762,13 @@ static int intel_overlay_do_put_image(struct intel_overlay *overlay, | |||
| 784 | struct drm_i915_gem_object *new_bo, | 762 | struct drm_i915_gem_object *new_bo, |
| 785 | struct put_image_params *params) | 763 | struct put_image_params *params) |
| 786 | { | 764 | { |
| 787 | int ret, tmp_width; | 765 | struct overlay_registers __iomem *regs = overlay->regs; |
| 788 | struct overlay_registers __iomem *regs; | ||
| 789 | bool scale_changed = false; | ||
| 790 | struct drm_i915_private *dev_priv = overlay->i915; | 766 | struct drm_i915_private *dev_priv = overlay->i915; |
| 791 | u32 swidth, swidthsw, sheight, ostride; | 767 | u32 swidth, swidthsw, sheight, ostride; |
| 792 | enum pipe pipe = overlay->crtc->pipe; | 768 | enum pipe pipe = overlay->crtc->pipe; |
| 769 | bool scale_changed = false; | ||
| 793 | struct i915_vma *vma; | 770 | struct i915_vma *vma; |
| 771 | int ret, tmp_width; | ||
| 794 | 772 | ||
| 795 | lockdep_assert_held(&dev_priv->drm.struct_mutex); | 773 | lockdep_assert_held(&dev_priv->drm.struct_mutex); |
| 796 | WARN_ON(!drm_modeset_is_locked(&dev_priv->drm.mode_config.connection_mutex)); | 774 | WARN_ON(!drm_modeset_is_locked(&dev_priv->drm.mode_config.connection_mutex)); |
| @@ -815,30 +793,19 @@ static int intel_overlay_do_put_image(struct intel_overlay *overlay, | |||
| 815 | 793 | ||
| 816 | if (!overlay->active) { | 794 | if (!overlay->active) { |
| 817 | u32 oconfig; | 795 | u32 oconfig; |
| 818 | regs = intel_overlay_map_regs(overlay); | 796 | |
| 819 | if (!regs) { | ||
| 820 | ret = -ENOMEM; | ||
| 821 | goto out_unpin; | ||
| 822 | } | ||
| 823 | oconfig = OCONF_CC_OUT_8BIT; | 797 | oconfig = OCONF_CC_OUT_8BIT; |
| 824 | if (IS_GEN4(dev_priv)) | 798 | if (IS_GEN4(dev_priv)) |
| 825 | oconfig |= OCONF_CSC_MODE_BT709; | 799 | oconfig |= OCONF_CSC_MODE_BT709; |
| 826 | oconfig |= pipe == 0 ? | 800 | oconfig |= pipe == 0 ? |
| 827 | OCONF_PIPE_A : OCONF_PIPE_B; | 801 | OCONF_PIPE_A : OCONF_PIPE_B; |
| 828 | iowrite32(oconfig, ®s->OCONFIG); | 802 | iowrite32(oconfig, ®s->OCONFIG); |
| 829 | intel_overlay_unmap_regs(overlay, regs); | ||
| 830 | 803 | ||
| 831 | ret = intel_overlay_on(overlay); | 804 | ret = intel_overlay_on(overlay); |
| 832 | if (ret != 0) | 805 | if (ret != 0) |
| 833 | goto out_unpin; | 806 | goto out_unpin; |
| 834 | } | 807 | } |
| 835 | 808 | ||
| 836 | regs = intel_overlay_map_regs(overlay); | ||
| 837 | if (!regs) { | ||
| 838 | ret = -ENOMEM; | ||
| 839 | goto out_unpin; | ||
| 840 | } | ||
| 841 | |||
| 842 | iowrite32((params->dst_y << 16) | params->dst_x, ®s->DWINPOS); | 809 | iowrite32((params->dst_y << 16) | params->dst_x, ®s->DWINPOS); |
| 843 | iowrite32((params->dst_h << 16) | params->dst_w, ®s->DWINSZ); | 810 | iowrite32((params->dst_h << 16) | params->dst_w, ®s->DWINSZ); |
| 844 | 811 | ||
| @@ -882,8 +849,6 @@ static int intel_overlay_do_put_image(struct intel_overlay *overlay, | |||
| 882 | 849 | ||
| 883 | iowrite32(overlay_cmd_reg(params), ®s->OCMD); | 850 | iowrite32(overlay_cmd_reg(params), ®s->OCMD); |
| 884 | 851 | ||
| 885 | intel_overlay_unmap_regs(overlay, regs); | ||
| 886 | |||
| 887 | ret = intel_overlay_continue(overlay, vma, scale_changed); | 852 | ret = intel_overlay_continue(overlay, vma, scale_changed); |
| 888 | if (ret) | 853 | if (ret) |
| 889 | goto out_unpin; | 854 | goto out_unpin; |
| @@ -901,7 +866,6 @@ out_pin_section: | |||
| 901 | int intel_overlay_switch_off(struct intel_overlay *overlay) | 866 | int intel_overlay_switch_off(struct intel_overlay *overlay) |
| 902 | { | 867 | { |
| 903 | struct drm_i915_private *dev_priv = overlay->i915; | 868 | struct drm_i915_private *dev_priv = overlay->i915; |
| 904 | struct overlay_registers __iomem *regs; | ||
| 905 | int ret; | 869 | int ret; |
| 906 | 870 | ||
| 907 | lockdep_assert_held(&dev_priv->drm.struct_mutex); | 871 | lockdep_assert_held(&dev_priv->drm.struct_mutex); |
| @@ -918,9 +882,7 @@ int intel_overlay_switch_off(struct intel_overlay *overlay) | |||
| 918 | if (ret != 0) | 882 | if (ret != 0) |
| 919 | return ret; | 883 | return ret; |
| 920 | 884 | ||
| 921 | regs = intel_overlay_map_regs(overlay); | 885 | iowrite32(0, &overlay->regs->OCMD); |
| 922 | iowrite32(0, ®s->OCMD); | ||
| 923 | intel_overlay_unmap_regs(overlay, regs); | ||
| 924 | 886 | ||
| 925 | return intel_overlay_off(overlay); | 887 | return intel_overlay_off(overlay); |
| 926 | } | 888 | } |
| @@ -1305,7 +1267,6 @@ int intel_overlay_attrs_ioctl(struct drm_device *dev, void *data, | |||
| 1305 | struct drm_intel_overlay_attrs *attrs = data; | 1267 | struct drm_intel_overlay_attrs *attrs = data; |
| 1306 | struct drm_i915_private *dev_priv = to_i915(dev); | 1268 | struct drm_i915_private *dev_priv = to_i915(dev); |
| 1307 | struct intel_overlay *overlay; | 1269 | struct intel_overlay *overlay; |
| 1308 | struct overlay_registers __iomem *regs; | ||
| 1309 | int ret; | 1270 | int ret; |
| 1310 | 1271 | ||
| 1311 | overlay = dev_priv->overlay; | 1272 | overlay = dev_priv->overlay; |
| @@ -1345,15 +1306,7 @@ int intel_overlay_attrs_ioctl(struct drm_device *dev, void *data, | |||
| 1345 | overlay->contrast = attrs->contrast; | 1306 | overlay->contrast = attrs->contrast; |
| 1346 | overlay->saturation = attrs->saturation; | 1307 | overlay->saturation = attrs->saturation; |
| 1347 | 1308 | ||
| 1348 | regs = intel_overlay_map_regs(overlay); | 1309 | update_reg_attrs(overlay, overlay->regs); |
| 1349 | if (!regs) { | ||
| 1350 | ret = -ENOMEM; | ||
| 1351 | goto out_unlock; | ||
| 1352 | } | ||
| 1353 | |||
| 1354 | update_reg_attrs(overlay, regs); | ||
| 1355 | |||
| 1356 | intel_overlay_unmap_regs(overlay, regs); | ||
| 1357 | 1310 | ||
| 1358 | if (attrs->flags & I915_OVERLAY_UPDATE_GAMMA) { | 1311 | if (attrs->flags & I915_OVERLAY_UPDATE_GAMMA) { |
| 1359 | if (IS_GEN2(dev_priv)) | 1312 | if (IS_GEN2(dev_priv)) |
| @@ -1386,12 +1339,47 @@ out_unlock: | |||
| 1386 | return ret; | 1339 | return ret; |
| 1387 | } | 1340 | } |
| 1388 | 1341 | ||
| 1342 | static int get_registers(struct intel_overlay *overlay, bool use_phys) | ||
| 1343 | { | ||
| 1344 | struct drm_i915_gem_object *obj; | ||
| 1345 | struct i915_vma *vma; | ||
| 1346 | int err; | ||
| 1347 | |||
| 1348 | obj = i915_gem_object_create_stolen(overlay->i915, PAGE_SIZE); | ||
| 1349 | if (obj == NULL) | ||
| 1350 | obj = i915_gem_object_create_internal(overlay->i915, PAGE_SIZE); | ||
| 1351 | if (IS_ERR(obj)) | ||
| 1352 | return PTR_ERR(obj); | ||
| 1353 | |||
| 1354 | vma = i915_gem_object_ggtt_pin(obj, NULL, 0, 0, PIN_MAPPABLE); | ||
| 1355 | if (IS_ERR(vma)) { | ||
| 1356 | err = PTR_ERR(vma); | ||
| 1357 | goto err_put_bo; | ||
| 1358 | } | ||
| 1359 | |||
| 1360 | if (use_phys) | ||
| 1361 | overlay->flip_addr = sg_dma_address(obj->mm.pages->sgl); | ||
| 1362 | else | ||
| 1363 | overlay->flip_addr = i915_ggtt_offset(vma); | ||
| 1364 | overlay->regs = i915_vma_pin_iomap(vma); | ||
| 1365 | i915_vma_unpin(vma); | ||
| 1366 | |||
| 1367 | if (IS_ERR(overlay->regs)) { | ||
| 1368 | err = PTR_ERR(overlay->regs); | ||
| 1369 | goto err_put_bo; | ||
| 1370 | } | ||
| 1371 | |||
| 1372 | overlay->reg_bo = obj; | ||
| 1373 | return 0; | ||
| 1374 | |||
| 1375 | err_put_bo: | ||
| 1376 | i915_gem_object_put(obj); | ||
| 1377 | return err; | ||
| 1378 | } | ||
| 1379 | |||
| 1389 | void intel_setup_overlay(struct drm_i915_private *dev_priv) | 1380 | void intel_setup_overlay(struct drm_i915_private *dev_priv) |
| 1390 | { | 1381 | { |
| 1391 | struct intel_overlay *overlay; | 1382 | struct intel_overlay *overlay; |
| 1392 | struct drm_i915_gem_object *reg_bo; | ||
| 1393 | struct overlay_registers __iomem *regs; | ||
| 1394 | struct i915_vma *vma = NULL; | ||
| 1395 | int ret; | 1383 | int ret; |
| 1396 | 1384 | ||
| 1397 | if (!HAS_OVERLAY(dev_priv)) | 1385 | if (!HAS_OVERLAY(dev_priv)) |
| @@ -1401,46 +1389,8 @@ void intel_setup_overlay(struct drm_i915_private *dev_priv) | |||
| 1401 | if (!overlay) | 1389 | if (!overlay) |
| 1402 | return; | 1390 | return; |
| 1403 | 1391 | ||
| 1404 | mutex_lock(&dev_priv->drm.struct_mutex); | ||
| 1405 | if (WARN_ON(dev_priv->overlay)) | ||
| 1406 | goto out_free; | ||
| 1407 | |||
| 1408 | overlay->i915 = dev_priv; | 1392 | overlay->i915 = dev_priv; |
| 1409 | 1393 | ||
| 1410 | reg_bo = NULL; | ||
| 1411 | if (!OVERLAY_NEEDS_PHYSICAL(dev_priv)) | ||
| 1412 | reg_bo = i915_gem_object_create_stolen(dev_priv, PAGE_SIZE); | ||
| 1413 | if (reg_bo == NULL) | ||
| 1414 | reg_bo = i915_gem_object_create(dev_priv, PAGE_SIZE); | ||
| 1415 | if (IS_ERR(reg_bo)) | ||
| 1416 | goto out_free; | ||
| 1417 | overlay->reg_bo = reg_bo; | ||
| 1418 | |||
| 1419 | if (OVERLAY_NEEDS_PHYSICAL(dev_priv)) { | ||
| 1420 | ret = i915_gem_object_attach_phys(reg_bo, PAGE_SIZE); | ||
| 1421 | if (ret) { | ||
| 1422 | DRM_ERROR("failed to attach phys overlay regs\n"); | ||
| 1423 | goto out_free_bo; | ||
| 1424 | } | ||
| 1425 | overlay->flip_addr = reg_bo->phys_handle->busaddr; | ||
| 1426 | } else { | ||
| 1427 | vma = i915_gem_object_ggtt_pin(reg_bo, NULL, | ||
| 1428 | 0, PAGE_SIZE, PIN_MAPPABLE); | ||
| 1429 | if (IS_ERR(vma)) { | ||
| 1430 | DRM_ERROR("failed to pin overlay register bo\n"); | ||
| 1431 | ret = PTR_ERR(vma); | ||
| 1432 | goto out_free_bo; | ||
| 1433 | } | ||
| 1434 | overlay->flip_addr = i915_ggtt_offset(vma); | ||
| 1435 | |||
| 1436 | ret = i915_gem_object_set_to_gtt_domain(reg_bo, true); | ||
| 1437 | if (ret) { | ||
| 1438 | DRM_ERROR("failed to move overlay register bo into the GTT\n"); | ||
| 1439 | goto out_unpin_bo; | ||
| 1440 | } | ||
| 1441 | } | ||
| 1442 | |||
| 1443 | /* init all values */ | ||
| 1444 | overlay->color_key = 0x0101fe; | 1394 | overlay->color_key = 0x0101fe; |
| 1445 | overlay->color_key_enabled = true; | 1395 | overlay->color_key_enabled = true; |
| 1446 | overlay->brightness = -19; | 1396 | overlay->brightness = -19; |
| @@ -1449,44 +1399,51 @@ void intel_setup_overlay(struct drm_i915_private *dev_priv) | |||
| 1449 | 1399 | ||
| 1450 | init_request_active(&overlay->last_flip, NULL); | 1400 | init_request_active(&overlay->last_flip, NULL); |
| 1451 | 1401 | ||
| 1452 | regs = intel_overlay_map_regs(overlay); | 1402 | mutex_lock(&dev_priv->drm.struct_mutex); |
| 1453 | if (!regs) | 1403 | |
| 1454 | goto out_unpin_bo; | 1404 | ret = get_registers(overlay, OVERLAY_NEEDS_PHYSICAL(dev_priv)); |
| 1405 | if (ret) | ||
| 1406 | goto out_free; | ||
| 1407 | |||
| 1408 | ret = i915_gem_object_set_to_gtt_domain(overlay->reg_bo, true); | ||
| 1409 | if (ret) | ||
| 1410 | goto out_reg_bo; | ||
| 1455 | 1411 | ||
| 1456 | memset_io(regs, 0, sizeof(struct overlay_registers)); | 1412 | mutex_unlock(&dev_priv->drm.struct_mutex); |
| 1457 | update_polyphase_filter(regs); | ||
| 1458 | update_reg_attrs(overlay, regs); | ||
| 1459 | 1413 | ||
| 1460 | intel_overlay_unmap_regs(overlay, regs); | 1414 | memset_io(overlay->regs, 0, sizeof(struct overlay_registers)); |
| 1415 | update_polyphase_filter(overlay->regs); | ||
| 1416 | update_reg_attrs(overlay, overlay->regs); | ||
| 1461 | 1417 | ||
| 1462 | dev_priv->overlay = overlay; | 1418 | dev_priv->overlay = overlay; |
| 1463 | mutex_unlock(&dev_priv->drm.struct_mutex); | 1419 | DRM_INFO("Initialized overlay support.\n"); |
| 1464 | DRM_INFO("initialized overlay support\n"); | ||
| 1465 | return; | 1420 | return; |
| 1466 | 1421 | ||
| 1467 | out_unpin_bo: | 1422 | out_reg_bo: |
| 1468 | if (vma) | 1423 | i915_gem_object_put(overlay->reg_bo); |
| 1469 | i915_vma_unpin(vma); | ||
| 1470 | out_free_bo: | ||
| 1471 | i915_gem_object_put(reg_bo); | ||
| 1472 | out_free: | 1424 | out_free: |
| 1473 | mutex_unlock(&dev_priv->drm.struct_mutex); | 1425 | mutex_unlock(&dev_priv->drm.struct_mutex); |
| 1474 | kfree(overlay); | 1426 | kfree(overlay); |
| 1475 | return; | ||
| 1476 | } | 1427 | } |
| 1477 | 1428 | ||
| 1478 | void intel_cleanup_overlay(struct drm_i915_private *dev_priv) | 1429 | void intel_cleanup_overlay(struct drm_i915_private *dev_priv) |
| 1479 | { | 1430 | { |
| 1480 | if (!dev_priv->overlay) | 1431 | struct intel_overlay *overlay; |
| 1432 | |||
| 1433 | overlay = fetch_and_zero(&dev_priv->overlay); | ||
| 1434 | if (!overlay) | ||
| 1481 | return; | 1435 | return; |
| 1482 | 1436 | ||
| 1483 | /* The bo's should be free'd by the generic code already. | 1437 | /* |
| 1438 | * The bo's should be free'd by the generic code already. | ||
| 1484 | * Furthermore modesetting teardown happens beforehand so the | 1439 | * Furthermore modesetting teardown happens beforehand so the |
| 1485 | * hardware should be off already */ | 1440 | * hardware should be off already. |
| 1486 | WARN_ON(dev_priv->overlay->active); | 1441 | */ |
| 1442 | WARN_ON(overlay->active); | ||
| 1443 | |||
| 1444 | i915_gem_object_put(overlay->reg_bo); | ||
| 1487 | 1445 | ||
| 1488 | i915_gem_object_put(dev_priv->overlay->reg_bo); | 1446 | kfree(overlay); |
| 1489 | kfree(dev_priv->overlay); | ||
| 1490 | } | 1447 | } |
| 1491 | 1448 | ||
| 1492 | #if IS_ENABLED(CONFIG_DRM_I915_CAPTURE_ERROR) | 1449 | #if IS_ENABLED(CONFIG_DRM_I915_CAPTURE_ERROR) |
| @@ -1498,37 +1455,11 @@ struct intel_overlay_error_state { | |||
| 1498 | u32 isr; | 1455 | u32 isr; |
| 1499 | }; | 1456 | }; |
| 1500 | 1457 | ||
| 1501 | static struct overlay_registers __iomem * | ||
| 1502 | intel_overlay_map_regs_atomic(struct intel_overlay *overlay) | ||
| 1503 | { | ||
| 1504 | struct drm_i915_private *dev_priv = overlay->i915; | ||
| 1505 | struct overlay_registers __iomem *regs; | ||
| 1506 | |||
| 1507 | if (OVERLAY_NEEDS_PHYSICAL(dev_priv)) | ||
| 1508 | /* Cast to make sparse happy, but it's wc memory anyway, so | ||
| 1509 | * equivalent to the wc io mapping on X86. */ | ||
| 1510 | regs = (struct overlay_registers __iomem *) | ||
| 1511 | overlay->reg_bo->phys_handle->vaddr; | ||
| 1512 | else | ||
| 1513 | regs = io_mapping_map_atomic_wc(&dev_priv->ggtt.iomap, | ||
| 1514 | overlay->flip_addr); | ||
| 1515 | |||
| 1516 | return regs; | ||
| 1517 | } | ||
| 1518 | |||
| 1519 | static void intel_overlay_unmap_regs_atomic(struct intel_overlay *overlay, | ||
| 1520 | struct overlay_registers __iomem *regs) | ||
| 1521 | { | ||
| 1522 | if (!OVERLAY_NEEDS_PHYSICAL(overlay->i915)) | ||
| 1523 | io_mapping_unmap_atomic(regs); | ||
| 1524 | } | ||
| 1525 | |||
| 1526 | struct intel_overlay_error_state * | 1458 | struct intel_overlay_error_state * |
| 1527 | intel_overlay_capture_error_state(struct drm_i915_private *dev_priv) | 1459 | intel_overlay_capture_error_state(struct drm_i915_private *dev_priv) |
| 1528 | { | 1460 | { |
| 1529 | struct intel_overlay *overlay = dev_priv->overlay; | 1461 | struct intel_overlay *overlay = dev_priv->overlay; |
| 1530 | struct intel_overlay_error_state *error; | 1462 | struct intel_overlay_error_state *error; |
| 1531 | struct overlay_registers __iomem *regs; | ||
| 1532 | 1463 | ||
| 1533 | if (!overlay || !overlay->active) | 1464 | if (!overlay || !overlay->active) |
| 1534 | return NULL; | 1465 | return NULL; |
| @@ -1541,18 +1472,9 @@ intel_overlay_capture_error_state(struct drm_i915_private *dev_priv) | |||
| 1541 | error->isr = I915_READ(ISR); | 1472 | error->isr = I915_READ(ISR); |
| 1542 | error->base = overlay->flip_addr; | 1473 | error->base = overlay->flip_addr; |
| 1543 | 1474 | ||
| 1544 | regs = intel_overlay_map_regs_atomic(overlay); | 1475 | memcpy_fromio(&error->regs, overlay->regs, sizeof(error->regs)); |
| 1545 | if (!regs) | ||
| 1546 | goto err; | ||
| 1547 | |||
| 1548 | memcpy_fromio(&error->regs, regs, sizeof(struct overlay_registers)); | ||
| 1549 | intel_overlay_unmap_regs_atomic(overlay, regs); | ||
| 1550 | 1476 | ||
| 1551 | return error; | 1477 | return error; |
| 1552 | |||
| 1553 | err: | ||
| 1554 | kfree(error); | ||
| 1555 | return NULL; | ||
| 1556 | } | 1478 | } |
| 1557 | 1479 | ||
| 1558 | void | 1480 | void |
diff --git a/drivers/gpu/drm/nouveau/dispnv50/disp.c b/drivers/gpu/drm/nouveau/dispnv50/disp.c index 8412119bd940..5691dfa1db6f 100644 --- a/drivers/gpu/drm/nouveau/dispnv50/disp.c +++ b/drivers/gpu/drm/nouveau/dispnv50/disp.c | |||
| @@ -1123,17 +1123,21 @@ nv50_mstm_enable(struct nv50_mstm *mstm, u8 dpcd, int state) | |||
| 1123 | int ret; | 1123 | int ret; |
| 1124 | 1124 | ||
| 1125 | if (dpcd >= 0x12) { | 1125 | if (dpcd >= 0x12) { |
| 1126 | ret = drm_dp_dpcd_readb(mstm->mgr.aux, DP_MSTM_CTRL, &dpcd); | 1126 | /* Even if we're enabling MST, start with disabling the |
| 1127 | * branching unit to clear any sink-side MST topology state | ||
| 1128 | * that wasn't set by us | ||
| 1129 | */ | ||
| 1130 | ret = drm_dp_dpcd_writeb(mstm->mgr.aux, DP_MSTM_CTRL, 0); | ||
| 1127 | if (ret < 0) | 1131 | if (ret < 0) |
| 1128 | return ret; | 1132 | return ret; |
| 1129 | 1133 | ||
| 1130 | dpcd &= ~DP_MST_EN; | 1134 | if (state) { |
| 1131 | if (state) | 1135 | /* Now, start initializing */ |
| 1132 | dpcd |= DP_MST_EN; | 1136 | ret = drm_dp_dpcd_writeb(mstm->mgr.aux, DP_MSTM_CTRL, |
| 1133 | 1137 | DP_MST_EN); | |
| 1134 | ret = drm_dp_dpcd_writeb(mstm->mgr.aux, DP_MSTM_CTRL, dpcd); | 1138 | if (ret < 0) |
| 1135 | if (ret < 0) | 1139 | return ret; |
| 1136 | return ret; | 1140 | } |
| 1137 | } | 1141 | } |
| 1138 | 1142 | ||
| 1139 | return nvif_mthd(disp, 0, &args, sizeof(args)); | 1143 | return nvif_mthd(disp, 0, &args, sizeof(args)); |
| @@ -1142,31 +1146,58 @@ nv50_mstm_enable(struct nv50_mstm *mstm, u8 dpcd, int state) | |||
| 1142 | int | 1146 | int |
| 1143 | nv50_mstm_detect(struct nv50_mstm *mstm, u8 dpcd[8], int allow) | 1147 | nv50_mstm_detect(struct nv50_mstm *mstm, u8 dpcd[8], int allow) |
| 1144 | { | 1148 | { |
| 1145 | int ret, state = 0; | 1149 | struct drm_dp_aux *aux; |
| 1150 | int ret; | ||
| 1151 | bool old_state, new_state; | ||
| 1152 | u8 mstm_ctrl; | ||
| 1146 | 1153 | ||
| 1147 | if (!mstm) | 1154 | if (!mstm) |
| 1148 | return 0; | 1155 | return 0; |
| 1149 | 1156 | ||
| 1150 | if (dpcd[0] >= 0x12) { | 1157 | mutex_lock(&mstm->mgr.lock); |
| 1151 | ret = drm_dp_dpcd_readb(mstm->mgr.aux, DP_MSTM_CAP, &dpcd[1]); | 1158 | |
| 1159 | old_state = mstm->mgr.mst_state; | ||
| 1160 | new_state = old_state; | ||
| 1161 | aux = mstm->mgr.aux; | ||
| 1162 | |||
| 1163 | if (old_state) { | ||
| 1164 | /* Just check that the MST hub is still as we expect it */ | ||
| 1165 | ret = drm_dp_dpcd_readb(aux, DP_MSTM_CTRL, &mstm_ctrl); | ||
| 1166 | if (ret < 0 || !(mstm_ctrl & DP_MST_EN)) { | ||
| 1167 | DRM_DEBUG_KMS("Hub gone, disabling MST topology\n"); | ||
| 1168 | new_state = false; | ||
| 1169 | } | ||
| 1170 | } else if (dpcd[0] >= 0x12) { | ||
| 1171 | ret = drm_dp_dpcd_readb(aux, DP_MSTM_CAP, &dpcd[1]); | ||
| 1152 | if (ret < 0) | 1172 | if (ret < 0) |
| 1153 | return ret; | 1173 | goto probe_error; |
| 1154 | 1174 | ||
| 1155 | if (!(dpcd[1] & DP_MST_CAP)) | 1175 | if (!(dpcd[1] & DP_MST_CAP)) |
| 1156 | dpcd[0] = 0x11; | 1176 | dpcd[0] = 0x11; |
| 1157 | else | 1177 | else |
| 1158 | state = allow; | 1178 | new_state = allow; |
| 1179 | } | ||
| 1180 | |||
| 1181 | if (new_state == old_state) { | ||
| 1182 | mutex_unlock(&mstm->mgr.lock); | ||
| 1183 | return new_state; | ||
| 1159 | } | 1184 | } |
| 1160 | 1185 | ||
| 1161 | ret = nv50_mstm_enable(mstm, dpcd[0], state); | 1186 | ret = nv50_mstm_enable(mstm, dpcd[0], new_state); |
| 1162 | if (ret) | 1187 | if (ret) |
| 1163 | return ret; | 1188 | goto probe_error; |
| 1189 | |||
| 1190 | mutex_unlock(&mstm->mgr.lock); | ||
| 1164 | 1191 | ||
| 1165 | ret = drm_dp_mst_topology_mgr_set_mst(&mstm->mgr, state); | 1192 | ret = drm_dp_mst_topology_mgr_set_mst(&mstm->mgr, new_state); |
| 1166 | if (ret) | 1193 | if (ret) |
| 1167 | return nv50_mstm_enable(mstm, dpcd[0], 0); | 1194 | return nv50_mstm_enable(mstm, dpcd[0], 0); |
| 1168 | 1195 | ||
| 1169 | return mstm->mgr.mst_state; | 1196 | return new_state; |
| 1197 | |||
| 1198 | probe_error: | ||
| 1199 | mutex_unlock(&mstm->mgr.lock); | ||
| 1200 | return ret; | ||
| 1170 | } | 1201 | } |
| 1171 | 1202 | ||
| 1172 | static void | 1203 | static void |
| @@ -2074,7 +2105,7 @@ nv50_disp_atomic_state_alloc(struct drm_device *dev) | |||
| 2074 | static const struct drm_mode_config_funcs | 2105 | static const struct drm_mode_config_funcs |
| 2075 | nv50_disp_func = { | 2106 | nv50_disp_func = { |
| 2076 | .fb_create = nouveau_user_framebuffer_create, | 2107 | .fb_create = nouveau_user_framebuffer_create, |
| 2077 | .output_poll_changed = drm_fb_helper_output_poll_changed, | 2108 | .output_poll_changed = nouveau_fbcon_output_poll_changed, |
| 2078 | .atomic_check = nv50_disp_atomic_check, | 2109 | .atomic_check = nv50_disp_atomic_check, |
| 2079 | .atomic_commit = nv50_disp_atomic_commit, | 2110 | .atomic_commit = nv50_disp_atomic_commit, |
| 2080 | .atomic_state_alloc = nv50_disp_atomic_state_alloc, | 2111 | .atomic_state_alloc = nv50_disp_atomic_state_alloc, |
diff --git a/drivers/gpu/drm/nouveau/nouveau_connector.c b/drivers/gpu/drm/nouveau/nouveau_connector.c index 51932c72334e..247f72cc4d10 100644 --- a/drivers/gpu/drm/nouveau/nouveau_connector.c +++ b/drivers/gpu/drm/nouveau/nouveau_connector.c | |||
| @@ -409,59 +409,45 @@ static struct nouveau_encoder * | |||
| 409 | nouveau_connector_ddc_detect(struct drm_connector *connector) | 409 | nouveau_connector_ddc_detect(struct drm_connector *connector) |
| 410 | { | 410 | { |
| 411 | struct drm_device *dev = connector->dev; | 411 | struct drm_device *dev = connector->dev; |
| 412 | struct nouveau_connector *nv_connector = nouveau_connector(connector); | 412 | struct nouveau_encoder *nv_encoder = NULL, *found = NULL; |
| 413 | struct nouveau_drm *drm = nouveau_drm(dev); | ||
| 414 | struct nvkm_gpio *gpio = nvxx_gpio(&drm->client.device); | ||
| 415 | struct nouveau_encoder *nv_encoder = NULL; | ||
| 416 | struct drm_encoder *encoder; | 413 | struct drm_encoder *encoder; |
| 417 | int i, panel = -ENODEV; | 414 | int i, ret; |
| 418 | 415 | bool switcheroo_ddc = false; | |
| 419 | /* eDP panels need powering on by us (if the VBIOS doesn't default it | ||
| 420 | * to on) before doing any AUX channel transactions. LVDS panel power | ||
| 421 | * is handled by the SOR itself, and not required for LVDS DDC. | ||
| 422 | */ | ||
| 423 | if (nv_connector->type == DCB_CONNECTOR_eDP) { | ||
| 424 | panel = nvkm_gpio_get(gpio, 0, DCB_GPIO_PANEL_POWER, 0xff); | ||
| 425 | if (panel == 0) { | ||
| 426 | nvkm_gpio_set(gpio, 0, DCB_GPIO_PANEL_POWER, 0xff, 1); | ||
| 427 | msleep(300); | ||
| 428 | } | ||
| 429 | } | ||
| 430 | 416 | ||
| 431 | drm_connector_for_each_possible_encoder(connector, encoder, i) { | 417 | drm_connector_for_each_possible_encoder(connector, encoder, i) { |
| 432 | nv_encoder = nouveau_encoder(encoder); | 418 | nv_encoder = nouveau_encoder(encoder); |
| 433 | 419 | ||
| 434 | if (nv_encoder->dcb->type == DCB_OUTPUT_DP) { | 420 | switch (nv_encoder->dcb->type) { |
| 435 | int ret = nouveau_dp_detect(nv_encoder); | 421 | case DCB_OUTPUT_DP: |
| 422 | ret = nouveau_dp_detect(nv_encoder); | ||
| 436 | if (ret == NOUVEAU_DP_MST) | 423 | if (ret == NOUVEAU_DP_MST) |
| 437 | return NULL; | 424 | return NULL; |
| 438 | if (ret == NOUVEAU_DP_SST) | 425 | else if (ret == NOUVEAU_DP_SST) |
| 439 | break; | 426 | found = nv_encoder; |
| 440 | } else | 427 | |
| 441 | if ((vga_switcheroo_handler_flags() & | 428 | break; |
| 442 | VGA_SWITCHEROO_CAN_SWITCH_DDC) && | 429 | case DCB_OUTPUT_LVDS: |
| 443 | nv_encoder->dcb->type == DCB_OUTPUT_LVDS && | 430 | switcheroo_ddc = !!(vga_switcheroo_handler_flags() & |
| 444 | nv_encoder->i2c) { | 431 | VGA_SWITCHEROO_CAN_SWITCH_DDC); |
| 445 | int ret; | 432 | /* fall-through */ |
| 446 | vga_switcheroo_lock_ddc(dev->pdev); | 433 | default: |
| 447 | ret = nvkm_probe_i2c(nv_encoder->i2c, 0x50); | 434 | if (!nv_encoder->i2c) |
| 448 | vga_switcheroo_unlock_ddc(dev->pdev); | ||
| 449 | if (ret) | ||
| 450 | break; | 435 | break; |
| 451 | } else | 436 | |
| 452 | if (nv_encoder->i2c) { | 437 | if (switcheroo_ddc) |
| 438 | vga_switcheroo_lock_ddc(dev->pdev); | ||
| 453 | if (nvkm_probe_i2c(nv_encoder->i2c, 0x50)) | 439 | if (nvkm_probe_i2c(nv_encoder->i2c, 0x50)) |
| 454 | break; | 440 | found = nv_encoder; |
| 441 | if (switcheroo_ddc) | ||
| 442 | vga_switcheroo_unlock_ddc(dev->pdev); | ||
| 443 | |||
| 444 | break; | ||
| 455 | } | 445 | } |
| 446 | if (found) | ||
| 447 | break; | ||
| 456 | } | 448 | } |
| 457 | 449 | ||
| 458 | /* eDP panel not detected, restore panel power GPIO to previous | 450 | return found; |
| 459 | * state to avoid confusing the SOR for other output types. | ||
| 460 | */ | ||
| 461 | if (!nv_encoder && panel == 0) | ||
| 462 | nvkm_gpio_set(gpio, 0, DCB_GPIO_PANEL_POWER, 0xff, panel); | ||
| 463 | |||
| 464 | return nv_encoder; | ||
| 465 | } | 451 | } |
| 466 | 452 | ||
| 467 | static struct nouveau_encoder * | 453 | static struct nouveau_encoder * |
| @@ -555,12 +541,16 @@ nouveau_connector_detect(struct drm_connector *connector, bool force) | |||
| 555 | nv_connector->edid = NULL; | 541 | nv_connector->edid = NULL; |
| 556 | } | 542 | } |
| 557 | 543 | ||
| 558 | /* Outputs are only polled while runtime active, so acquiring a | 544 | /* Outputs are only polled while runtime active, so resuming the |
| 559 | * runtime PM ref here is unnecessary (and would deadlock upon | 545 | * device here is unnecessary (and would deadlock upon runtime suspend |
| 560 | * runtime suspend because it waits for polling to finish). | 546 | * because it waits for polling to finish). We do however, want to |
| 547 | * prevent the autosuspend timer from elapsing during this operation | ||
| 548 | * if possible. | ||
| 561 | */ | 549 | */ |
| 562 | if (!drm_kms_helper_is_poll_worker()) { | 550 | if (drm_kms_helper_is_poll_worker()) { |
| 563 | ret = pm_runtime_get_sync(connector->dev->dev); | 551 | pm_runtime_get_noresume(dev->dev); |
| 552 | } else { | ||
| 553 | ret = pm_runtime_get_sync(dev->dev); | ||
| 564 | if (ret < 0 && ret != -EACCES) | 554 | if (ret < 0 && ret != -EACCES) |
| 565 | return conn_status; | 555 | return conn_status; |
| 566 | } | 556 | } |
| @@ -638,10 +628,8 @@ detect_analog: | |||
| 638 | 628 | ||
| 639 | out: | 629 | out: |
| 640 | 630 | ||
| 641 | if (!drm_kms_helper_is_poll_worker()) { | 631 | pm_runtime_mark_last_busy(dev->dev); |
| 642 | pm_runtime_mark_last_busy(connector->dev->dev); | 632 | pm_runtime_put_autosuspend(dev->dev); |
| 643 | pm_runtime_put_autosuspend(connector->dev->dev); | ||
| 644 | } | ||
| 645 | 633 | ||
| 646 | return conn_status; | 634 | return conn_status; |
| 647 | } | 635 | } |
| @@ -1105,6 +1093,26 @@ nouveau_connector_hotplug(struct nvif_notify *notify) | |||
| 1105 | const struct nvif_notify_conn_rep_v0 *rep = notify->data; | 1093 | const struct nvif_notify_conn_rep_v0 *rep = notify->data; |
| 1106 | const char *name = connector->name; | 1094 | const char *name = connector->name; |
| 1107 | struct nouveau_encoder *nv_encoder; | 1095 | struct nouveau_encoder *nv_encoder; |
| 1096 | int ret; | ||
| 1097 | |||
| 1098 | ret = pm_runtime_get(drm->dev->dev); | ||
| 1099 | if (ret == 0) { | ||
| 1100 | /* We can't block here if there's a pending PM request | ||
| 1101 | * running, as we'll deadlock nouveau_display_fini() when it | ||
| 1102 | * calls nvif_put() on our nvif_notify struct. So, simply | ||
| 1103 | * defer the hotplug event until the device finishes resuming | ||
| 1104 | */ | ||
| 1105 | NV_DEBUG(drm, "Deferring HPD on %s until runtime resume\n", | ||
| 1106 | name); | ||
| 1107 | schedule_work(&drm->hpd_work); | ||
| 1108 | |||
| 1109 | pm_runtime_put_noidle(drm->dev->dev); | ||
| 1110 | return NVIF_NOTIFY_KEEP; | ||
| 1111 | } else if (ret != 1 && ret != -EACCES) { | ||
| 1112 | NV_WARN(drm, "HPD on %s dropped due to RPM failure: %d\n", | ||
| 1113 | name, ret); | ||
| 1114 | return NVIF_NOTIFY_DROP; | ||
| 1115 | } | ||
| 1108 | 1116 | ||
| 1109 | if (rep->mask & NVIF_NOTIFY_CONN_V0_IRQ) { | 1117 | if (rep->mask & NVIF_NOTIFY_CONN_V0_IRQ) { |
| 1110 | NV_DEBUG(drm, "service %s\n", name); | 1118 | NV_DEBUG(drm, "service %s\n", name); |
| @@ -1122,6 +1130,8 @@ nouveau_connector_hotplug(struct nvif_notify *notify) | |||
| 1122 | drm_helper_hpd_irq_event(connector->dev); | 1130 | drm_helper_hpd_irq_event(connector->dev); |
| 1123 | } | 1131 | } |
| 1124 | 1132 | ||
| 1133 | pm_runtime_mark_last_busy(drm->dev->dev); | ||
| 1134 | pm_runtime_put_autosuspend(drm->dev->dev); | ||
| 1125 | return NVIF_NOTIFY_KEEP; | 1135 | return NVIF_NOTIFY_KEEP; |
| 1126 | } | 1136 | } |
| 1127 | 1137 | ||
diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c b/drivers/gpu/drm/nouveau/nouveau_display.c index 139368b31916..540c0cbbfcee 100644 --- a/drivers/gpu/drm/nouveau/nouveau_display.c +++ b/drivers/gpu/drm/nouveau/nouveau_display.c | |||
| @@ -293,7 +293,7 @@ nouveau_user_framebuffer_create(struct drm_device *dev, | |||
| 293 | 293 | ||
| 294 | static const struct drm_mode_config_funcs nouveau_mode_config_funcs = { | 294 | static const struct drm_mode_config_funcs nouveau_mode_config_funcs = { |
| 295 | .fb_create = nouveau_user_framebuffer_create, | 295 | .fb_create = nouveau_user_framebuffer_create, |
| 296 | .output_poll_changed = drm_fb_helper_output_poll_changed, | 296 | .output_poll_changed = nouveau_fbcon_output_poll_changed, |
| 297 | }; | 297 | }; |
| 298 | 298 | ||
| 299 | 299 | ||
| @@ -355,8 +355,6 @@ nouveau_display_hpd_work(struct work_struct *work) | |||
| 355 | pm_runtime_get_sync(drm->dev->dev); | 355 | pm_runtime_get_sync(drm->dev->dev); |
| 356 | 356 | ||
| 357 | drm_helper_hpd_irq_event(drm->dev); | 357 | drm_helper_hpd_irq_event(drm->dev); |
| 358 | /* enable polling for external displays */ | ||
| 359 | drm_kms_helper_poll_enable(drm->dev); | ||
| 360 | 358 | ||
| 361 | pm_runtime_mark_last_busy(drm->dev->dev); | 359 | pm_runtime_mark_last_busy(drm->dev->dev); |
| 362 | pm_runtime_put_sync(drm->dev->dev); | 360 | pm_runtime_put_sync(drm->dev->dev); |
| @@ -379,15 +377,29 @@ nouveau_display_acpi_ntfy(struct notifier_block *nb, unsigned long val, | |||
| 379 | { | 377 | { |
| 380 | struct nouveau_drm *drm = container_of(nb, typeof(*drm), acpi_nb); | 378 | struct nouveau_drm *drm = container_of(nb, typeof(*drm), acpi_nb); |
| 381 | struct acpi_bus_event *info = data; | 379 | struct acpi_bus_event *info = data; |
| 380 | int ret; | ||
| 382 | 381 | ||
| 383 | if (!strcmp(info->device_class, ACPI_VIDEO_CLASS)) { | 382 | if (!strcmp(info->device_class, ACPI_VIDEO_CLASS)) { |
| 384 | if (info->type == ACPI_VIDEO_NOTIFY_PROBE) { | 383 | if (info->type == ACPI_VIDEO_NOTIFY_PROBE) { |
| 385 | /* | 384 | ret = pm_runtime_get(drm->dev->dev); |
| 386 | * This may be the only indication we receive of a | 385 | if (ret == 1 || ret == -EACCES) { |
| 387 | * connector hotplug on a runtime suspended GPU, | 386 | /* If the GPU is already awake, or in a state |
| 388 | * schedule hpd_work to check. | 387 | * where we can't wake it up, it can handle |
| 389 | */ | 388 | * it's own hotplug events. |
| 390 | schedule_work(&drm->hpd_work); | 389 | */ |
| 390 | pm_runtime_put_autosuspend(drm->dev->dev); | ||
| 391 | } else if (ret == 0) { | ||
| 392 | /* This may be the only indication we receive | ||
| 393 | * of a connector hotplug on a runtime | ||
| 394 | * suspended GPU, schedule hpd_work to check. | ||
| 395 | */ | ||
| 396 | NV_DEBUG(drm, "ACPI requested connector reprobe\n"); | ||
| 397 | schedule_work(&drm->hpd_work); | ||
| 398 | pm_runtime_put_noidle(drm->dev->dev); | ||
| 399 | } else { | ||
| 400 | NV_WARN(drm, "Dropped ACPI reprobe event due to RPM error: %d\n", | ||
| 401 | ret); | ||
| 402 | } | ||
| 391 | 403 | ||
| 392 | /* acpi-video should not generate keypresses for this */ | 404 | /* acpi-video should not generate keypresses for this */ |
| 393 | return NOTIFY_BAD; | 405 | return NOTIFY_BAD; |
| @@ -411,6 +423,11 @@ nouveau_display_init(struct drm_device *dev) | |||
| 411 | if (ret) | 423 | if (ret) |
| 412 | return ret; | 424 | return ret; |
| 413 | 425 | ||
| 426 | /* enable connector detection and polling for connectors without HPD | ||
| 427 | * support | ||
| 428 | */ | ||
| 429 | drm_kms_helper_poll_enable(dev); | ||
| 430 | |||
| 414 | /* enable hotplug interrupts */ | 431 | /* enable hotplug interrupts */ |
| 415 | drm_connector_list_iter_begin(dev, &conn_iter); | 432 | drm_connector_list_iter_begin(dev, &conn_iter); |
| 416 | nouveau_for_each_non_mst_connector_iter(connector, &conn_iter) { | 433 | nouveau_for_each_non_mst_connector_iter(connector, &conn_iter) { |
| @@ -425,7 +442,7 @@ nouveau_display_init(struct drm_device *dev) | |||
| 425 | } | 442 | } |
| 426 | 443 | ||
| 427 | void | 444 | void |
| 428 | nouveau_display_fini(struct drm_device *dev, bool suspend) | 445 | nouveau_display_fini(struct drm_device *dev, bool suspend, bool runtime) |
| 429 | { | 446 | { |
| 430 | struct nouveau_display *disp = nouveau_display(dev); | 447 | struct nouveau_display *disp = nouveau_display(dev); |
| 431 | struct nouveau_drm *drm = nouveau_drm(dev); | 448 | struct nouveau_drm *drm = nouveau_drm(dev); |
| @@ -450,6 +467,9 @@ nouveau_display_fini(struct drm_device *dev, bool suspend) | |||
| 450 | } | 467 | } |
| 451 | drm_connector_list_iter_end(&conn_iter); | 468 | drm_connector_list_iter_end(&conn_iter); |
| 452 | 469 | ||
| 470 | if (!runtime) | ||
| 471 | cancel_work_sync(&drm->hpd_work); | ||
| 472 | |||
| 453 | drm_kms_helper_poll_disable(dev); | 473 | drm_kms_helper_poll_disable(dev); |
| 454 | disp->fini(dev); | 474 | disp->fini(dev); |
| 455 | } | 475 | } |
| @@ -618,11 +638,11 @@ nouveau_display_suspend(struct drm_device *dev, bool runtime) | |||
| 618 | } | 638 | } |
| 619 | } | 639 | } |
| 620 | 640 | ||
| 621 | nouveau_display_fini(dev, true); | 641 | nouveau_display_fini(dev, true, runtime); |
| 622 | return 0; | 642 | return 0; |
| 623 | } | 643 | } |
| 624 | 644 | ||
| 625 | nouveau_display_fini(dev, true); | 645 | nouveau_display_fini(dev, true, runtime); |
| 626 | 646 | ||
| 627 | list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { | 647 | list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { |
| 628 | struct nouveau_framebuffer *nouveau_fb; | 648 | struct nouveau_framebuffer *nouveau_fb; |
diff --git a/drivers/gpu/drm/nouveau/nouveau_display.h b/drivers/gpu/drm/nouveau/nouveau_display.h index 54aa7c3fa42d..ff92b54ce448 100644 --- a/drivers/gpu/drm/nouveau/nouveau_display.h +++ b/drivers/gpu/drm/nouveau/nouveau_display.h | |||
| @@ -62,7 +62,7 @@ nouveau_display(struct drm_device *dev) | |||
| 62 | int nouveau_display_create(struct drm_device *dev); | 62 | int nouveau_display_create(struct drm_device *dev); |
| 63 | void nouveau_display_destroy(struct drm_device *dev); | 63 | void nouveau_display_destroy(struct drm_device *dev); |
| 64 | int nouveau_display_init(struct drm_device *dev); | 64 | int nouveau_display_init(struct drm_device *dev); |
| 65 | void nouveau_display_fini(struct drm_device *dev, bool suspend); | 65 | void nouveau_display_fini(struct drm_device *dev, bool suspend, bool runtime); |
| 66 | int nouveau_display_suspend(struct drm_device *dev, bool runtime); | 66 | int nouveau_display_suspend(struct drm_device *dev, bool runtime); |
| 67 | void nouveau_display_resume(struct drm_device *dev, bool runtime); | 67 | void nouveau_display_resume(struct drm_device *dev, bool runtime); |
| 68 | int nouveau_display_vblank_enable(struct drm_device *, unsigned int); | 68 | int nouveau_display_vblank_enable(struct drm_device *, unsigned int); |
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c index c7ec86d6c3c9..74d2283f2c28 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drm.c +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c | |||
| @@ -230,7 +230,7 @@ nouveau_cli_init(struct nouveau_drm *drm, const char *sname, | |||
| 230 | mutex_unlock(&drm->master.lock); | 230 | mutex_unlock(&drm->master.lock); |
| 231 | } | 231 | } |
| 232 | if (ret) { | 232 | if (ret) { |
| 233 | NV_ERROR(drm, "Client allocation failed: %d\n", ret); | 233 | NV_PRINTK(err, cli, "Client allocation failed: %d\n", ret); |
| 234 | goto done; | 234 | goto done; |
| 235 | } | 235 | } |
| 236 | 236 | ||
| @@ -240,37 +240,37 @@ nouveau_cli_init(struct nouveau_drm *drm, const char *sname, | |||
| 240 | }, sizeof(struct nv_device_v0), | 240 | }, sizeof(struct nv_device_v0), |
| 241 | &cli->device); | 241 | &cli->device); |
| 242 | if (ret) { | 242 | if (ret) { |
| 243 | NV_ERROR(drm, "Device allocation failed: %d\n", ret); | 243 | NV_PRINTK(err, cli, "Device allocation failed: %d\n", ret); |
| 244 | goto done; | 244 | goto done; |
| 245 | } | 245 | } |
| 246 | 246 | ||
| 247 | ret = nvif_mclass(&cli->device.object, mmus); | 247 | ret = nvif_mclass(&cli->device.object, mmus); |
| 248 | if (ret < 0) { | 248 | if (ret < 0) { |
| 249 | NV_ERROR(drm, "No supported MMU class\n"); | 249 | NV_PRINTK(err, cli, "No supported MMU class\n"); |
| 250 | goto done; | 250 | goto done; |
| 251 | } | 251 | } |
| 252 | 252 | ||
| 253 | ret = nvif_mmu_init(&cli->device.object, mmus[ret].oclass, &cli->mmu); | 253 | ret = nvif_mmu_init(&cli->device.object, mmus[ret].oclass, &cli->mmu); |
| 254 | if (ret) { | 254 | if (ret) { |
| 255 | NV_ERROR(drm, "MMU allocation failed: %d\n", ret); | 255 | NV_PRINTK(err, cli, "MMU allocation failed: %d\n", ret); |
| 256 | goto done; | 256 | goto done; |
| 257 | } | 257 | } |
| 258 | 258 | ||
| 259 | ret = nvif_mclass(&cli->mmu.object, vmms); | 259 | ret = nvif_mclass(&cli->mmu.object, vmms); |
| 260 | if (ret < 0) { | 260 | if (ret < 0) { |
| 261 | NV_ERROR(drm, "No supported VMM class\n"); | 261 | NV_PRINTK(err, cli, "No supported VMM class\n"); |
| 262 | goto done; | 262 | goto done; |
| 263 | } | 263 | } |
| 264 | 264 | ||
| 265 | ret = nouveau_vmm_init(cli, vmms[ret].oclass, &cli->vmm); | 265 | ret = nouveau_vmm_init(cli, vmms[ret].oclass, &cli->vmm); |
| 266 | if (ret) { | 266 | if (ret) { |
| 267 | NV_ERROR(drm, "VMM allocation failed: %d\n", ret); | 267 | NV_PRINTK(err, cli, "VMM allocation failed: %d\n", ret); |
| 268 | goto done; | 268 | goto done; |
| 269 | } | 269 | } |
| 270 | 270 | ||
| 271 | ret = nvif_mclass(&cli->mmu.object, mems); | 271 | ret = nvif_mclass(&cli->mmu.object, mems); |
| 272 | if (ret < 0) { | 272 | if (ret < 0) { |
| 273 | NV_ERROR(drm, "No supported MEM class\n"); | 273 | NV_PRINTK(err, cli, "No supported MEM class\n"); |
| 274 | goto done; | 274 | goto done; |
| 275 | } | 275 | } |
| 276 | 276 | ||
| @@ -592,10 +592,8 @@ nouveau_drm_load(struct drm_device *dev, unsigned long flags) | |||
| 592 | pm_runtime_allow(dev->dev); | 592 | pm_runtime_allow(dev->dev); |
| 593 | pm_runtime_mark_last_busy(dev->dev); | 593 | pm_runtime_mark_last_busy(dev->dev); |
| 594 | pm_runtime_put(dev->dev); | 594 | pm_runtime_put(dev->dev); |
| 595 | } else { | ||
| 596 | /* enable polling for external displays */ | ||
| 597 | drm_kms_helper_poll_enable(dev); | ||
| 598 | } | 595 | } |
| 596 | |||
| 599 | return 0; | 597 | return 0; |
| 600 | 598 | ||
| 601 | fail_dispinit: | 599 | fail_dispinit: |
| @@ -629,7 +627,7 @@ nouveau_drm_unload(struct drm_device *dev) | |||
| 629 | nouveau_debugfs_fini(drm); | 627 | nouveau_debugfs_fini(drm); |
| 630 | 628 | ||
| 631 | if (dev->mode_config.num_crtc) | 629 | if (dev->mode_config.num_crtc) |
| 632 | nouveau_display_fini(dev, false); | 630 | nouveau_display_fini(dev, false, false); |
| 633 | nouveau_display_destroy(dev); | 631 | nouveau_display_destroy(dev); |
| 634 | 632 | ||
| 635 | nouveau_bios_takedown(dev); | 633 | nouveau_bios_takedown(dev); |
| @@ -835,7 +833,6 @@ nouveau_pmops_runtime_suspend(struct device *dev) | |||
| 835 | return -EBUSY; | 833 | return -EBUSY; |
| 836 | } | 834 | } |
| 837 | 835 | ||
| 838 | drm_kms_helper_poll_disable(drm_dev); | ||
| 839 | nouveau_switcheroo_optimus_dsm(); | 836 | nouveau_switcheroo_optimus_dsm(); |
| 840 | ret = nouveau_do_suspend(drm_dev, true); | 837 | ret = nouveau_do_suspend(drm_dev, true); |
| 841 | pci_save_state(pdev); | 838 | pci_save_state(pdev); |
diff --git a/drivers/gpu/drm/nouveau/nouveau_fbcon.c b/drivers/gpu/drm/nouveau/nouveau_fbcon.c index 844498c4267c..0f64c0a1d4b3 100644 --- a/drivers/gpu/drm/nouveau/nouveau_fbcon.c +++ b/drivers/gpu/drm/nouveau/nouveau_fbcon.c | |||
| @@ -466,6 +466,7 @@ nouveau_fbcon_set_suspend_work(struct work_struct *work) | |||
| 466 | console_unlock(); | 466 | console_unlock(); |
| 467 | 467 | ||
| 468 | if (state == FBINFO_STATE_RUNNING) { | 468 | if (state == FBINFO_STATE_RUNNING) { |
| 469 | nouveau_fbcon_hotplug_resume(drm->fbcon); | ||
| 469 | pm_runtime_mark_last_busy(drm->dev->dev); | 470 | pm_runtime_mark_last_busy(drm->dev->dev); |
| 470 | pm_runtime_put_sync(drm->dev->dev); | 471 | pm_runtime_put_sync(drm->dev->dev); |
| 471 | } | 472 | } |
| @@ -487,6 +488,61 @@ nouveau_fbcon_set_suspend(struct drm_device *dev, int state) | |||
| 487 | schedule_work(&drm->fbcon_work); | 488 | schedule_work(&drm->fbcon_work); |
| 488 | } | 489 | } |
| 489 | 490 | ||
| 491 | void | ||
| 492 | nouveau_fbcon_output_poll_changed(struct drm_device *dev) | ||
| 493 | { | ||
| 494 | struct nouveau_drm *drm = nouveau_drm(dev); | ||
| 495 | struct nouveau_fbdev *fbcon = drm->fbcon; | ||
| 496 | int ret; | ||
| 497 | |||
| 498 | if (!fbcon) | ||
| 499 | return; | ||
| 500 | |||
| 501 | mutex_lock(&fbcon->hotplug_lock); | ||
| 502 | |||
| 503 | ret = pm_runtime_get(dev->dev); | ||
| 504 | if (ret == 1 || ret == -EACCES) { | ||
| 505 | drm_fb_helper_hotplug_event(&fbcon->helper); | ||
| 506 | |||
| 507 | pm_runtime_mark_last_busy(dev->dev); | ||
| 508 | pm_runtime_put_autosuspend(dev->dev); | ||
| 509 | } else if (ret == 0) { | ||
| 510 | /* If the GPU was already in the process of suspending before | ||
| 511 | * this event happened, then we can't block here as we'll | ||
| 512 | * deadlock the runtime pmops since they wait for us to | ||
| 513 | * finish. So, just defer this event for when we runtime | ||
| 514 | * resume again. It will be handled by fbcon_work. | ||
| 515 | */ | ||
| 516 | NV_DEBUG(drm, "fbcon HPD event deferred until runtime resume\n"); | ||
| 517 | fbcon->hotplug_waiting = true; | ||
| 518 | pm_runtime_put_noidle(drm->dev->dev); | ||
| 519 | } else { | ||
| 520 | DRM_WARN("fbcon HPD event lost due to RPM failure: %d\n", | ||
| 521 | ret); | ||
| 522 | } | ||
| 523 | |||
| 524 | mutex_unlock(&fbcon->hotplug_lock); | ||
| 525 | } | ||
| 526 | |||
| 527 | void | ||
| 528 | nouveau_fbcon_hotplug_resume(struct nouveau_fbdev *fbcon) | ||
| 529 | { | ||
| 530 | struct nouveau_drm *drm; | ||
| 531 | |||
| 532 | if (!fbcon) | ||
| 533 | return; | ||
| 534 | drm = nouveau_drm(fbcon->helper.dev); | ||
| 535 | |||
| 536 | mutex_lock(&fbcon->hotplug_lock); | ||
| 537 | if (fbcon->hotplug_waiting) { | ||
| 538 | fbcon->hotplug_waiting = false; | ||
| 539 | |||
| 540 | NV_DEBUG(drm, "Handling deferred fbcon HPD events\n"); | ||
| 541 | drm_fb_helper_hotplug_event(&fbcon->helper); | ||
| 542 | } | ||
| 543 | mutex_unlock(&fbcon->hotplug_lock); | ||
| 544 | } | ||
| 545 | |||
| 490 | int | 546 | int |
| 491 | nouveau_fbcon_init(struct drm_device *dev) | 547 | nouveau_fbcon_init(struct drm_device *dev) |
| 492 | { | 548 | { |
| @@ -505,6 +561,7 @@ nouveau_fbcon_init(struct drm_device *dev) | |||
| 505 | 561 | ||
| 506 | drm->fbcon = fbcon; | 562 | drm->fbcon = fbcon; |
| 507 | INIT_WORK(&drm->fbcon_work, nouveau_fbcon_set_suspend_work); | 563 | INIT_WORK(&drm->fbcon_work, nouveau_fbcon_set_suspend_work); |
| 564 | mutex_init(&fbcon->hotplug_lock); | ||
| 508 | 565 | ||
| 509 | drm_fb_helper_prepare(dev, &fbcon->helper, &nouveau_fbcon_helper_funcs); | 566 | drm_fb_helper_prepare(dev, &fbcon->helper, &nouveau_fbcon_helper_funcs); |
| 510 | 567 | ||
diff --git a/drivers/gpu/drm/nouveau/nouveau_fbcon.h b/drivers/gpu/drm/nouveau/nouveau_fbcon.h index a6f192ea3fa6..db9d52047ef8 100644 --- a/drivers/gpu/drm/nouveau/nouveau_fbcon.h +++ b/drivers/gpu/drm/nouveau/nouveau_fbcon.h | |||
| @@ -41,6 +41,9 @@ struct nouveau_fbdev { | |||
| 41 | struct nvif_object gdi; | 41 | struct nvif_object gdi; |
| 42 | struct nvif_object blit; | 42 | struct nvif_object blit; |
| 43 | struct nvif_object twod; | 43 | struct nvif_object twod; |
| 44 | |||
| 45 | struct mutex hotplug_lock; | ||
| 46 | bool hotplug_waiting; | ||
| 44 | }; | 47 | }; |
| 45 | 48 | ||
| 46 | void nouveau_fbcon_restore(void); | 49 | void nouveau_fbcon_restore(void); |
| @@ -68,6 +71,8 @@ void nouveau_fbcon_set_suspend(struct drm_device *dev, int state); | |||
| 68 | void nouveau_fbcon_accel_save_disable(struct drm_device *dev); | 71 | void nouveau_fbcon_accel_save_disable(struct drm_device *dev); |
| 69 | void nouveau_fbcon_accel_restore(struct drm_device *dev); | 72 | void nouveau_fbcon_accel_restore(struct drm_device *dev); |
| 70 | 73 | ||
| 74 | void nouveau_fbcon_output_poll_changed(struct drm_device *dev); | ||
| 75 | void nouveau_fbcon_hotplug_resume(struct nouveau_fbdev *fbcon); | ||
| 71 | extern int nouveau_nofbaccel; | 76 | extern int nouveau_nofbaccel; |
| 72 | 77 | ||
| 73 | #endif /* __NV50_FBCON_H__ */ | 78 | #endif /* __NV50_FBCON_H__ */ |
diff --git a/drivers/gpu/drm/nouveau/nouveau_vga.c b/drivers/gpu/drm/nouveau/nouveau_vga.c index 3da5a4305aa4..8f1ce4833230 100644 --- a/drivers/gpu/drm/nouveau/nouveau_vga.c +++ b/drivers/gpu/drm/nouveau/nouveau_vga.c | |||
| @@ -46,12 +46,10 @@ nouveau_switcheroo_set_state(struct pci_dev *pdev, | |||
| 46 | pr_err("VGA switcheroo: switched nouveau on\n"); | 46 | pr_err("VGA switcheroo: switched nouveau on\n"); |
| 47 | dev->switch_power_state = DRM_SWITCH_POWER_CHANGING; | 47 | dev->switch_power_state = DRM_SWITCH_POWER_CHANGING; |
| 48 | nouveau_pmops_resume(&pdev->dev); | 48 | nouveau_pmops_resume(&pdev->dev); |
| 49 | drm_kms_helper_poll_enable(dev); | ||
| 50 | dev->switch_power_state = DRM_SWITCH_POWER_ON; | 49 | dev->switch_power_state = DRM_SWITCH_POWER_ON; |
| 51 | } else { | 50 | } else { |
| 52 | pr_err("VGA switcheroo: switched nouveau off\n"); | 51 | pr_err("VGA switcheroo: switched nouveau off\n"); |
| 53 | dev->switch_power_state = DRM_SWITCH_POWER_CHANGING; | 52 | dev->switch_power_state = DRM_SWITCH_POWER_CHANGING; |
| 54 | drm_kms_helper_poll_disable(dev); | ||
| 55 | nouveau_switcheroo_optimus_dsm(); | 53 | nouveau_switcheroo_optimus_dsm(); |
| 56 | nouveau_pmops_suspend(&pdev->dev); | 54 | nouveau_pmops_suspend(&pdev->dev); |
| 57 | dev->switch_power_state = DRM_SWITCH_POWER_OFF; | 55 | dev->switch_power_state = DRM_SWITCH_POWER_OFF; |
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/base.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/base.c index 32fa94a9773f..cbd33e87b799 100644 --- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/base.c +++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/base.c | |||
| @@ -275,6 +275,7 @@ nvkm_disp_oneinit(struct nvkm_engine *engine) | |||
| 275 | struct nvkm_outp *outp, *outt, *pair; | 275 | struct nvkm_outp *outp, *outt, *pair; |
| 276 | struct nvkm_conn *conn; | 276 | struct nvkm_conn *conn; |
| 277 | struct nvkm_head *head; | 277 | struct nvkm_head *head; |
| 278 | struct nvkm_ior *ior; | ||
| 278 | struct nvbios_connE connE; | 279 | struct nvbios_connE connE; |
| 279 | struct dcb_output dcbE; | 280 | struct dcb_output dcbE; |
| 280 | u8 hpd = 0, ver, hdr; | 281 | u8 hpd = 0, ver, hdr; |
| @@ -399,6 +400,19 @@ nvkm_disp_oneinit(struct nvkm_engine *engine) | |||
| 399 | return ret; | 400 | return ret; |
| 400 | } | 401 | } |
| 401 | 402 | ||
| 403 | /* Enforce identity-mapped SOR assignment for panels, which have | ||
| 404 | * certain bits (ie. backlight controls) wired to a specific SOR. | ||
| 405 | */ | ||
| 406 | list_for_each_entry(outp, &disp->outp, head) { | ||
| 407 | if (outp->conn->info.type == DCB_CONNECTOR_LVDS || | ||
| 408 | outp->conn->info.type == DCB_CONNECTOR_eDP) { | ||
| 409 | ior = nvkm_ior_find(disp, SOR, ffs(outp->info.or) - 1); | ||
| 410 | if (!WARN_ON(!ior)) | ||
| 411 | ior->identity = true; | ||
| 412 | outp->identity = true; | ||
| 413 | } | ||
| 414 | } | ||
| 415 | |||
| 402 | i = 0; | 416 | i = 0; |
| 403 | list_for_each_entry(head, &disp->head, head) | 417 | list_for_each_entry(head, &disp->head, head) |
| 404 | i = max(i, head->id + 1); | 418 | i = max(i, head->id + 1); |
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.c index 7c5bed29ffef..5f301e632599 100644 --- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.c +++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.c | |||
| @@ -28,6 +28,7 @@ | |||
| 28 | 28 | ||
| 29 | #include <subdev/bios.h> | 29 | #include <subdev/bios.h> |
| 30 | #include <subdev/bios/init.h> | 30 | #include <subdev/bios/init.h> |
| 31 | #include <subdev/gpio.h> | ||
| 31 | #include <subdev/i2c.h> | 32 | #include <subdev/i2c.h> |
| 32 | 33 | ||
| 33 | #include <nvif/event.h> | 34 | #include <nvif/event.h> |
| @@ -412,14 +413,10 @@ nvkm_dp_train(struct nvkm_dp *dp, u32 dataKBps) | |||
| 412 | } | 413 | } |
| 413 | 414 | ||
| 414 | static void | 415 | static void |
| 415 | nvkm_dp_release(struct nvkm_outp *outp, struct nvkm_ior *ior) | 416 | nvkm_dp_disable(struct nvkm_outp *outp, struct nvkm_ior *ior) |
| 416 | { | 417 | { |
| 417 | struct nvkm_dp *dp = nvkm_dp(outp); | 418 | struct nvkm_dp *dp = nvkm_dp(outp); |
| 418 | 419 | ||
| 419 | /* Prevent link from being retrained if sink sends an IRQ. */ | ||
| 420 | atomic_set(&dp->lt.done, 0); | ||
| 421 | ior->dp.nr = 0; | ||
| 422 | |||
| 423 | /* Execute DisableLT script from DP Info Table. */ | 420 | /* Execute DisableLT script from DP Info Table. */ |
| 424 | nvbios_init(&ior->disp->engine.subdev, dp->info.script[4], | 421 | nvbios_init(&ior->disp->engine.subdev, dp->info.script[4], |
| 425 | init.outp = &dp->outp.info; | 422 | init.outp = &dp->outp.info; |
| @@ -428,6 +425,16 @@ nvkm_dp_release(struct nvkm_outp *outp, struct nvkm_ior *ior) | |||
| 428 | ); | 425 | ); |
| 429 | } | 426 | } |
| 430 | 427 | ||
| 428 | static void | ||
| 429 | nvkm_dp_release(struct nvkm_outp *outp) | ||
| 430 | { | ||
| 431 | struct nvkm_dp *dp = nvkm_dp(outp); | ||
| 432 | |||
| 433 | /* Prevent link from being retrained if sink sends an IRQ. */ | ||
| 434 | atomic_set(&dp->lt.done, 0); | ||
| 435 | dp->outp.ior->dp.nr = 0; | ||
| 436 | } | ||
| 437 | |||
| 431 | static int | 438 | static int |
| 432 | nvkm_dp_acquire(struct nvkm_outp *outp) | 439 | nvkm_dp_acquire(struct nvkm_outp *outp) |
| 433 | { | 440 | { |
| @@ -491,7 +498,7 @@ done: | |||
| 491 | return ret; | 498 | return ret; |
| 492 | } | 499 | } |
| 493 | 500 | ||
| 494 | static void | 501 | static bool |
| 495 | nvkm_dp_enable(struct nvkm_dp *dp, bool enable) | 502 | nvkm_dp_enable(struct nvkm_dp *dp, bool enable) |
| 496 | { | 503 | { |
| 497 | struct nvkm_i2c_aux *aux = dp->aux; | 504 | struct nvkm_i2c_aux *aux = dp->aux; |
| @@ -505,7 +512,7 @@ nvkm_dp_enable(struct nvkm_dp *dp, bool enable) | |||
| 505 | 512 | ||
| 506 | if (!nvkm_rdaux(aux, DPCD_RC00_DPCD_REV, dp->dpcd, | 513 | if (!nvkm_rdaux(aux, DPCD_RC00_DPCD_REV, dp->dpcd, |
| 507 | sizeof(dp->dpcd))) | 514 | sizeof(dp->dpcd))) |
| 508 | return; | 515 | return true; |
| 509 | } | 516 | } |
| 510 | 517 | ||
| 511 | if (dp->present) { | 518 | if (dp->present) { |
| @@ -515,6 +522,7 @@ nvkm_dp_enable(struct nvkm_dp *dp, bool enable) | |||
| 515 | } | 522 | } |
| 516 | 523 | ||
| 517 | atomic_set(&dp->lt.done, 0); | 524 | atomic_set(&dp->lt.done, 0); |
| 525 | return false; | ||
| 518 | } | 526 | } |
| 519 | 527 | ||
| 520 | static int | 528 | static int |
| @@ -555,9 +563,38 @@ nvkm_dp_fini(struct nvkm_outp *outp) | |||
| 555 | static void | 563 | static void |
| 556 | nvkm_dp_init(struct nvkm_outp *outp) | 564 | nvkm_dp_init(struct nvkm_outp *outp) |
| 557 | { | 565 | { |
| 566 | struct nvkm_gpio *gpio = outp->disp->engine.subdev.device->gpio; | ||
| 558 | struct nvkm_dp *dp = nvkm_dp(outp); | 567 | struct nvkm_dp *dp = nvkm_dp(outp); |
| 568 | |||
| 559 | nvkm_notify_put(&dp->outp.conn->hpd); | 569 | nvkm_notify_put(&dp->outp.conn->hpd); |
| 560 | nvkm_dp_enable(dp, true); | 570 | |
| 571 | /* eDP panels need powering on by us (if the VBIOS doesn't default it | ||
| 572 | * to on) before doing any AUX channel transactions. LVDS panel power | ||
| 573 | * is handled by the SOR itself, and not required for LVDS DDC. | ||
| 574 | */ | ||
| 575 | if (dp->outp.conn->info.type == DCB_CONNECTOR_eDP) { | ||
| 576 | int power = nvkm_gpio_get(gpio, 0, DCB_GPIO_PANEL_POWER, 0xff); | ||
| 577 | if (power == 0) | ||
| 578 | nvkm_gpio_set(gpio, 0, DCB_GPIO_PANEL_POWER, 0xff, 1); | ||
| 579 | |||
| 580 | /* We delay here unconditionally, even if already powered, | ||
| 581 | * because some laptop panels having a significant resume | ||
| 582 | * delay before the panel begins responding. | ||
| 583 | * | ||
| 584 | * This is likely a bit of a hack, but no better idea for | ||
| 585 | * handling this at the moment. | ||
| 586 | */ | ||
| 587 | msleep(300); | ||
| 588 | |||
| 589 | /* If the eDP panel can't be detected, we need to restore | ||
| 590 | * the panel power GPIO to avoid breaking another output. | ||
| 591 | */ | ||
| 592 | if (!nvkm_dp_enable(dp, true) && power == 0) | ||
| 593 | nvkm_gpio_set(gpio, 0, DCB_GPIO_PANEL_POWER, 0xff, 0); | ||
| 594 | } else { | ||
| 595 | nvkm_dp_enable(dp, true); | ||
| 596 | } | ||
| 597 | |||
| 561 | nvkm_notify_get(&dp->hpd); | 598 | nvkm_notify_get(&dp->hpd); |
| 562 | } | 599 | } |
| 563 | 600 | ||
| @@ -576,6 +613,7 @@ nvkm_dp_func = { | |||
| 576 | .fini = nvkm_dp_fini, | 613 | .fini = nvkm_dp_fini, |
| 577 | .acquire = nvkm_dp_acquire, | 614 | .acquire = nvkm_dp_acquire, |
| 578 | .release = nvkm_dp_release, | 615 | .release = nvkm_dp_release, |
| 616 | .disable = nvkm_dp_disable, | ||
| 579 | }; | 617 | }; |
| 580 | 618 | ||
| 581 | static int | 619 | static int |
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/ior.h b/drivers/gpu/drm/nouveau/nvkm/engine/disp/ior.h index e0b4e0c5704e..19911211a12a 100644 --- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/ior.h +++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/ior.h | |||
| @@ -16,6 +16,7 @@ struct nvkm_ior { | |||
| 16 | char name[8]; | 16 | char name[8]; |
| 17 | 17 | ||
| 18 | struct list_head head; | 18 | struct list_head head; |
| 19 | bool identity; | ||
| 19 | 20 | ||
| 20 | struct nvkm_ior_state { | 21 | struct nvkm_ior_state { |
| 21 | struct nvkm_outp *outp; | 22 | struct nvkm_outp *outp; |
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/nv50.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/nv50.c index f89c7b977aa5..def005dd5fda 100644 --- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/nv50.c +++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/nv50.c | |||
| @@ -501,11 +501,11 @@ nv50_disp_super_2_0(struct nv50_disp *disp, struct nvkm_head *head) | |||
| 501 | nv50_disp_super_ied_off(head, ior, 2); | 501 | nv50_disp_super_ied_off(head, ior, 2); |
| 502 | 502 | ||
| 503 | /* If we're shutting down the OR's only active head, execute | 503 | /* If we're shutting down the OR's only active head, execute |
| 504 | * the output path's release function. | 504 | * the output path's disable function. |
| 505 | */ | 505 | */ |
| 506 | if (ior->arm.head == (1 << head->id)) { | 506 | if (ior->arm.head == (1 << head->id)) { |
| 507 | if ((outp = ior->arm.outp) && outp->func->release) | 507 | if ((outp = ior->arm.outp) && outp->func->disable) |
| 508 | outp->func->release(outp, ior); | 508 | outp->func->disable(outp, ior); |
| 509 | } | 509 | } |
| 510 | } | 510 | } |
| 511 | 511 | ||
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/outp.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/outp.c index be9e7f8c3b23..c62030c96fba 100644 --- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/outp.c +++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/outp.c | |||
| @@ -93,6 +93,8 @@ nvkm_outp_release(struct nvkm_outp *outp, u8 user) | |||
| 93 | if (ior) { | 93 | if (ior) { |
| 94 | outp->acquired &= ~user; | 94 | outp->acquired &= ~user; |
| 95 | if (!outp->acquired) { | 95 | if (!outp->acquired) { |
| 96 | if (outp->func->release && outp->ior) | ||
| 97 | outp->func->release(outp); | ||
| 96 | outp->ior->asy.outp = NULL; | 98 | outp->ior->asy.outp = NULL; |
| 97 | outp->ior = NULL; | 99 | outp->ior = NULL; |
| 98 | } | 100 | } |
| @@ -127,17 +129,26 @@ nvkm_outp_acquire(struct nvkm_outp *outp, u8 user) | |||
| 127 | if (proto == UNKNOWN) | 129 | if (proto == UNKNOWN) |
| 128 | return -ENOSYS; | 130 | return -ENOSYS; |
| 129 | 131 | ||
| 132 | /* Deal with panels requiring identity-mapped SOR assignment. */ | ||
| 133 | if (outp->identity) { | ||
| 134 | ior = nvkm_ior_find(outp->disp, SOR, ffs(outp->info.or) - 1); | ||
| 135 | if (WARN_ON(!ior)) | ||
| 136 | return -ENOSPC; | ||
| 137 | return nvkm_outp_acquire_ior(outp, user, ior); | ||
| 138 | } | ||
| 139 | |||
| 130 | /* First preference is to reuse the OR that is currently armed | 140 | /* First preference is to reuse the OR that is currently armed |
| 131 | * on HW, if any, in order to prevent unnecessary switching. | 141 | * on HW, if any, in order to prevent unnecessary switching. |
| 132 | */ | 142 | */ |
| 133 | list_for_each_entry(ior, &outp->disp->ior, head) { | 143 | list_for_each_entry(ior, &outp->disp->ior, head) { |
| 134 | if (!ior->asy.outp && ior->arm.outp == outp) | 144 | if (!ior->identity && !ior->asy.outp && ior->arm.outp == outp) |
| 135 | return nvkm_outp_acquire_ior(outp, user, ior); | 145 | return nvkm_outp_acquire_ior(outp, user, ior); |
| 136 | } | 146 | } |
| 137 | 147 | ||
| 138 | /* Failing that, a completely unused OR is the next best thing. */ | 148 | /* Failing that, a completely unused OR is the next best thing. */ |
| 139 | list_for_each_entry(ior, &outp->disp->ior, head) { | 149 | list_for_each_entry(ior, &outp->disp->ior, head) { |
| 140 | if (!ior->asy.outp && ior->type == type && !ior->arm.outp && | 150 | if (!ior->identity && |
| 151 | !ior->asy.outp && ior->type == type && !ior->arm.outp && | ||
| 141 | (ior->func->route.set || ior->id == __ffs(outp->info.or))) | 152 | (ior->func->route.set || ior->id == __ffs(outp->info.or))) |
| 142 | return nvkm_outp_acquire_ior(outp, user, ior); | 153 | return nvkm_outp_acquire_ior(outp, user, ior); |
| 143 | } | 154 | } |
| @@ -146,7 +157,7 @@ nvkm_outp_acquire(struct nvkm_outp *outp, u8 user) | |||
| 146 | * but will be released during the next modeset. | 157 | * but will be released during the next modeset. |
| 147 | */ | 158 | */ |
| 148 | list_for_each_entry(ior, &outp->disp->ior, head) { | 159 | list_for_each_entry(ior, &outp->disp->ior, head) { |
| 149 | if (!ior->asy.outp && ior->type == type && | 160 | if (!ior->identity && !ior->asy.outp && ior->type == type && |
| 150 | (ior->func->route.set || ior->id == __ffs(outp->info.or))) | 161 | (ior->func->route.set || ior->id == __ffs(outp->info.or))) |
| 151 | return nvkm_outp_acquire_ior(outp, user, ior); | 162 | return nvkm_outp_acquire_ior(outp, user, ior); |
| 152 | } | 163 | } |
| @@ -245,7 +256,6 @@ nvkm_outp_ctor(const struct nvkm_outp_func *func, struct nvkm_disp *disp, | |||
| 245 | outp->index = index; | 256 | outp->index = index; |
| 246 | outp->info = *dcbE; | 257 | outp->info = *dcbE; |
| 247 | outp->i2c = nvkm_i2c_bus_find(i2c, dcbE->i2c_index); | 258 | outp->i2c = nvkm_i2c_bus_find(i2c, dcbE->i2c_index); |
| 248 | outp->or = ffs(outp->info.or) - 1; | ||
| 249 | 259 | ||
| 250 | OUTP_DBG(outp, "type %02x loc %d or %d link %d con %x " | 260 | OUTP_DBG(outp, "type %02x loc %d or %d link %d con %x " |
| 251 | "edid %x bus %d head %x", | 261 | "edid %x bus %d head %x", |
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/outp.h b/drivers/gpu/drm/nouveau/nvkm/engine/disp/outp.h index ea84d7d5741a..6c8aa5cfed9d 100644 --- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/outp.h +++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/outp.h | |||
| @@ -13,10 +13,10 @@ struct nvkm_outp { | |||
| 13 | struct dcb_output info; | 13 | struct dcb_output info; |
| 14 | 14 | ||
| 15 | struct nvkm_i2c_bus *i2c; | 15 | struct nvkm_i2c_bus *i2c; |
| 16 | int or; | ||
| 17 | 16 | ||
| 18 | struct list_head head; | 17 | struct list_head head; |
| 19 | struct nvkm_conn *conn; | 18 | struct nvkm_conn *conn; |
| 19 | bool identity; | ||
| 20 | 20 | ||
| 21 | /* Assembly state. */ | 21 | /* Assembly state. */ |
| 22 | #define NVKM_OUTP_PRIV 1 | 22 | #define NVKM_OUTP_PRIV 1 |
| @@ -41,7 +41,8 @@ struct nvkm_outp_func { | |||
| 41 | void (*init)(struct nvkm_outp *); | 41 | void (*init)(struct nvkm_outp *); |
| 42 | void (*fini)(struct nvkm_outp *); | 42 | void (*fini)(struct nvkm_outp *); |
| 43 | int (*acquire)(struct nvkm_outp *); | 43 | int (*acquire)(struct nvkm_outp *); |
| 44 | void (*release)(struct nvkm_outp *, struct nvkm_ior *); | 44 | void (*release)(struct nvkm_outp *); |
| 45 | void (*disable)(struct nvkm_outp *, struct nvkm_ior *); | ||
| 45 | }; | 46 | }; |
| 46 | 47 | ||
| 47 | #define OUTP_MSG(o,l,f,a...) do { \ | 48 | #define OUTP_MSG(o,l,f,a...) do { \ |
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/devinit/gm200.c b/drivers/gpu/drm/nouveau/nvkm/subdev/devinit/gm200.c index b80618e35491..17235e940ca9 100644 --- a/drivers/gpu/drm/nouveau/nvkm/subdev/devinit/gm200.c +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/devinit/gm200.c | |||
| @@ -86,10 +86,8 @@ pmu_load(struct nv50_devinit *init, u8 type, bool post, | |||
| 86 | struct nvkm_bios *bios = subdev->device->bios; | 86 | struct nvkm_bios *bios = subdev->device->bios; |
| 87 | struct nvbios_pmuR pmu; | 87 | struct nvbios_pmuR pmu; |
| 88 | 88 | ||
| 89 | if (!nvbios_pmuRm(bios, type, &pmu)) { | 89 | if (!nvbios_pmuRm(bios, type, &pmu)) |
| 90 | nvkm_error(subdev, "VBIOS PMU fuc %02x not found\n", type); | ||
| 91 | return -EINVAL; | 90 | return -EINVAL; |
| 92 | } | ||
| 93 | 91 | ||
| 94 | if (!post) | 92 | if (!post) |
| 95 | return 0; | 93 | return 0; |
| @@ -124,29 +122,30 @@ gm200_devinit_post(struct nvkm_devinit *base, bool post) | |||
| 124 | return -EINVAL; | 122 | return -EINVAL; |
| 125 | } | 123 | } |
| 126 | 124 | ||
| 125 | /* Upload DEVINIT application from VBIOS onto PMU. */ | ||
| 127 | ret = pmu_load(init, 0x04, post, &exec, &args); | 126 | ret = pmu_load(init, 0x04, post, &exec, &args); |
| 128 | if (ret) | 127 | if (ret) { |
| 128 | nvkm_error(subdev, "VBIOS PMU/DEVINIT not found\n"); | ||
| 129 | return ret; | 129 | return ret; |
| 130 | } | ||
| 130 | 131 | ||
| 131 | /* upload first chunk of init data */ | 132 | /* Upload tables required by opcodes in boot scripts. */ |
| 132 | if (post) { | 133 | if (post) { |
| 133 | // devinit tables | ||
| 134 | u32 pmu = pmu_args(init, args + 0x08, 0x08); | 134 | u32 pmu = pmu_args(init, args + 0x08, 0x08); |
| 135 | u32 img = nvbios_rd16(bios, bit_I.offset + 0x14); | 135 | u32 img = nvbios_rd16(bios, bit_I.offset + 0x14); |
| 136 | u32 len = nvbios_rd16(bios, bit_I.offset + 0x16); | 136 | u32 len = nvbios_rd16(bios, bit_I.offset + 0x16); |
| 137 | pmu_data(init, pmu, img, len); | 137 | pmu_data(init, pmu, img, len); |
| 138 | } | 138 | } |
| 139 | 139 | ||
| 140 | /* upload second chunk of init data */ | 140 | /* Upload boot scripts. */ |
| 141 | if (post) { | 141 | if (post) { |
| 142 | // devinit boot scripts | ||
| 143 | u32 pmu = pmu_args(init, args + 0x08, 0x10); | 142 | u32 pmu = pmu_args(init, args + 0x08, 0x10); |
| 144 | u32 img = nvbios_rd16(bios, bit_I.offset + 0x18); | 143 | u32 img = nvbios_rd16(bios, bit_I.offset + 0x18); |
| 145 | u32 len = nvbios_rd16(bios, bit_I.offset + 0x1a); | 144 | u32 len = nvbios_rd16(bios, bit_I.offset + 0x1a); |
| 146 | pmu_data(init, pmu, img, len); | 145 | pmu_data(init, pmu, img, len); |
| 147 | } | 146 | } |
| 148 | 147 | ||
| 149 | /* execute init tables */ | 148 | /* Execute DEVINIT. */ |
| 150 | if (post) { | 149 | if (post) { |
| 151 | nvkm_wr32(device, 0x10a040, 0x00005000); | 150 | nvkm_wr32(device, 0x10a040, 0x00005000); |
| 152 | pmu_exec(init, exec); | 151 | pmu_exec(init, exec); |
| @@ -157,8 +156,11 @@ gm200_devinit_post(struct nvkm_devinit *base, bool post) | |||
| 157 | return -ETIMEDOUT; | 156 | return -ETIMEDOUT; |
| 158 | } | 157 | } |
| 159 | 158 | ||
| 160 | /* load and execute some other ucode image (bios therm?) */ | 159 | /* Optional: Execute PRE_OS application on PMU, which should at |
| 161 | return pmu_load(init, 0x01, post, NULL, NULL); | 160 | * least take care of fans until a full PMU has been loaded. |
| 161 | */ | ||
| 162 | pmu_load(init, 0x01, post, NULL, NULL); | ||
| 163 | return 0; | ||
| 162 | } | 164 | } |
| 163 | 165 | ||
| 164 | static const struct nvkm_devinit_func | 166 | static const struct nvkm_devinit_func |
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.c b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.c index de269eb482dd..7459def78d50 100644 --- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.c +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.c | |||
| @@ -1423,7 +1423,7 @@ nvkm_vmm_get(struct nvkm_vmm *vmm, u8 page, u64 size, struct nvkm_vma **pvma) | |||
| 1423 | void | 1423 | void |
| 1424 | nvkm_vmm_part(struct nvkm_vmm *vmm, struct nvkm_memory *inst) | 1424 | nvkm_vmm_part(struct nvkm_vmm *vmm, struct nvkm_memory *inst) |
| 1425 | { | 1425 | { |
| 1426 | if (vmm->func->part && inst) { | 1426 | if (inst && vmm->func->part) { |
| 1427 | mutex_lock(&vmm->mutex); | 1427 | mutex_lock(&vmm->mutex); |
| 1428 | vmm->func->part(vmm, inst); | 1428 | vmm->func->part(vmm, inst); |
| 1429 | mutex_unlock(&vmm->mutex); | 1429 | mutex_unlock(&vmm->mutex); |
diff --git a/drivers/hid/hid-apple.c b/drivers/hid/hid-apple.c index 25b7bd56ae11..1cb41992aaa1 100644 --- a/drivers/hid/hid-apple.c +++ b/drivers/hid/hid-apple.c | |||
| @@ -335,7 +335,8 @@ static int apple_input_mapping(struct hid_device *hdev, struct hid_input *hi, | |||
| 335 | struct hid_field *field, struct hid_usage *usage, | 335 | struct hid_field *field, struct hid_usage *usage, |
| 336 | unsigned long **bit, int *max) | 336 | unsigned long **bit, int *max) |
| 337 | { | 337 | { |
| 338 | if (usage->hid == (HID_UP_CUSTOM | 0x0003)) { | 338 | if (usage->hid == (HID_UP_CUSTOM | 0x0003) || |
| 339 | usage->hid == (HID_UP_MSVENDOR | 0x0003)) { | ||
| 339 | /* The fn key on Apple USB keyboards */ | 340 | /* The fn key on Apple USB keyboards */ |
| 340 | set_bit(EV_REP, hi->input->evbit); | 341 | set_bit(EV_REP, hi->input->evbit); |
| 341 | hid_map_usage_clear(hi, usage, bit, max, EV_KEY, KEY_FN); | 342 | hid_map_usage_clear(hi, usage, bit, max, EV_KEY, KEY_FN); |
| @@ -472,6 +473,12 @@ static const struct hid_device_id apple_devices[] = { | |||
| 472 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, | 473 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, |
| 473 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_ANSI), | 474 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_ANSI), |
| 474 | .driver_data = APPLE_HAS_FN }, | 475 | .driver_data = APPLE_HAS_FN }, |
| 476 | { HID_BLUETOOTH_DEVICE(BT_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_ANSI), | ||
| 477 | .driver_data = APPLE_HAS_FN }, | ||
| 478 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_ANSI), | ||
| 479 | .driver_data = APPLE_HAS_FN }, | ||
| 480 | { HID_BLUETOOTH_DEVICE(BT_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_ANSI), | ||
| 481 | .driver_data = APPLE_HAS_FN }, | ||
| 475 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ANSI), | 482 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ANSI), |
| 476 | .driver_data = APPLE_HAS_FN }, | 483 | .driver_data = APPLE_HAS_FN }, |
| 477 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ISO), | 484 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ISO), |
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index 3da354af7a0a..44564f61e9cc 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c | |||
| @@ -1000,7 +1000,7 @@ int hid_open_report(struct hid_device *device) | |||
| 1000 | parser = vzalloc(sizeof(struct hid_parser)); | 1000 | parser = vzalloc(sizeof(struct hid_parser)); |
| 1001 | if (!parser) { | 1001 | if (!parser) { |
| 1002 | ret = -ENOMEM; | 1002 | ret = -ENOMEM; |
| 1003 | goto err; | 1003 | goto alloc_err; |
| 1004 | } | 1004 | } |
| 1005 | 1005 | ||
| 1006 | parser->device = device; | 1006 | parser->device = device; |
| @@ -1039,6 +1039,7 @@ int hid_open_report(struct hid_device *device) | |||
| 1039 | hid_err(device, "unbalanced delimiter at end of report description\n"); | 1039 | hid_err(device, "unbalanced delimiter at end of report description\n"); |
| 1040 | goto err; | 1040 | goto err; |
| 1041 | } | 1041 | } |
| 1042 | kfree(parser->collection_stack); | ||
| 1042 | vfree(parser); | 1043 | vfree(parser); |
| 1043 | device->status |= HID_STAT_PARSED; | 1044 | device->status |= HID_STAT_PARSED; |
| 1044 | return 0; | 1045 | return 0; |
| @@ -1047,6 +1048,8 @@ int hid_open_report(struct hid_device *device) | |||
| 1047 | 1048 | ||
| 1048 | hid_err(device, "item fetching failed at offset %d\n", (int)(end - start)); | 1049 | hid_err(device, "item fetching failed at offset %d\n", (int)(end - start)); |
| 1049 | err: | 1050 | err: |
| 1051 | kfree(parser->collection_stack); | ||
| 1052 | alloc_err: | ||
| 1050 | vfree(parser); | 1053 | vfree(parser); |
| 1051 | hid_close_report(device); | 1054 | hid_close_report(device); |
| 1052 | return ret; | 1055 | return ret; |
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h index 79bdf0c7e351..5146ee029db4 100644 --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h | |||
| @@ -88,6 +88,7 @@ | |||
| 88 | #define USB_DEVICE_ID_ANTON_TOUCH_PAD 0x3101 | 88 | #define USB_DEVICE_ID_ANTON_TOUCH_PAD 0x3101 |
| 89 | 89 | ||
| 90 | #define USB_VENDOR_ID_APPLE 0x05ac | 90 | #define USB_VENDOR_ID_APPLE 0x05ac |
| 91 | #define BT_VENDOR_ID_APPLE 0x004c | ||
| 91 | #define USB_DEVICE_ID_APPLE_MIGHTYMOUSE 0x0304 | 92 | #define USB_DEVICE_ID_APPLE_MIGHTYMOUSE 0x0304 |
| 92 | #define USB_DEVICE_ID_APPLE_MAGICMOUSE 0x030d | 93 | #define USB_DEVICE_ID_APPLE_MAGICMOUSE 0x030d |
| 93 | #define USB_DEVICE_ID_APPLE_MAGICTRACKPAD 0x030e | 94 | #define USB_DEVICE_ID_APPLE_MAGICTRACKPAD 0x030e |
| @@ -157,6 +158,7 @@ | |||
| 157 | #define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ISO 0x0256 | 158 | #define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ISO 0x0256 |
| 158 | #define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_JIS 0x0257 | 159 | #define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_JIS 0x0257 |
| 159 | #define USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_ANSI 0x0267 | 160 | #define USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_ANSI 0x0267 |
| 161 | #define USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_ANSI 0x026c | ||
| 160 | #define USB_DEVICE_ID_APPLE_WELLSPRING8_ANSI 0x0290 | 162 | #define USB_DEVICE_ID_APPLE_WELLSPRING8_ANSI 0x0290 |
| 161 | #define USB_DEVICE_ID_APPLE_WELLSPRING8_ISO 0x0291 | 163 | #define USB_DEVICE_ID_APPLE_WELLSPRING8_ISO 0x0291 |
| 162 | #define USB_DEVICE_ID_APPLE_WELLSPRING8_JIS 0x0292 | 164 | #define USB_DEVICE_ID_APPLE_WELLSPRING8_JIS 0x0292 |
| @@ -528,9 +530,6 @@ | |||
| 528 | #define I2C_VENDOR_ID_HANTICK 0x0911 | 530 | #define I2C_VENDOR_ID_HANTICK 0x0911 |
| 529 | #define I2C_PRODUCT_ID_HANTICK_5288 0x5288 | 531 | #define I2C_PRODUCT_ID_HANTICK_5288 0x5288 |
| 530 | 532 | ||
| 531 | #define I2C_VENDOR_ID_RAYD 0x2386 | ||
| 532 | #define I2C_PRODUCT_ID_RAYD_3118 0x3118 | ||
| 533 | |||
| 534 | #define USB_VENDOR_ID_HANWANG 0x0b57 | 533 | #define USB_VENDOR_ID_HANWANG 0x0b57 |
| 535 | #define USB_DEVICE_ID_HANWANG_TABLET_FIRST 0x5000 | 534 | #define USB_DEVICE_ID_HANWANG_TABLET_FIRST 0x5000 |
| 536 | #define USB_DEVICE_ID_HANWANG_TABLET_LAST 0x8fff | 535 | #define USB_DEVICE_ID_HANWANG_TABLET_LAST 0x8fff |
| @@ -950,6 +949,7 @@ | |||
| 950 | #define USB_DEVICE_ID_SAITEK_RUMBLEPAD 0xff17 | 949 | #define USB_DEVICE_ID_SAITEK_RUMBLEPAD 0xff17 |
| 951 | #define USB_DEVICE_ID_SAITEK_PS1000 0x0621 | 950 | #define USB_DEVICE_ID_SAITEK_PS1000 0x0621 |
| 952 | #define USB_DEVICE_ID_SAITEK_RAT7_OLD 0x0ccb | 951 | #define USB_DEVICE_ID_SAITEK_RAT7_OLD 0x0ccb |
| 952 | #define USB_DEVICE_ID_SAITEK_RAT7_CONTAGION 0x0ccd | ||
| 953 | #define USB_DEVICE_ID_SAITEK_RAT7 0x0cd7 | 953 | #define USB_DEVICE_ID_SAITEK_RAT7 0x0cd7 |
| 954 | #define USB_DEVICE_ID_SAITEK_RAT9 0x0cfa | 954 | #define USB_DEVICE_ID_SAITEK_RAT9 0x0cfa |
| 955 | #define USB_DEVICE_ID_SAITEK_MMO7 0x0cd0 | 955 | #define USB_DEVICE_ID_SAITEK_MMO7 0x0cd0 |
diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c index 4e94ea3e280a..a481eaf39e88 100644 --- a/drivers/hid/hid-input.c +++ b/drivers/hid/hid-input.c | |||
| @@ -1582,6 +1582,7 @@ static struct hid_input *hidinput_allocate(struct hid_device *hid, | |||
| 1582 | input_dev->dev.parent = &hid->dev; | 1582 | input_dev->dev.parent = &hid->dev; |
| 1583 | 1583 | ||
| 1584 | hidinput->input = input_dev; | 1584 | hidinput->input = input_dev; |
| 1585 | hidinput->application = application; | ||
| 1585 | list_add_tail(&hidinput->list, &hid->inputs); | 1586 | list_add_tail(&hidinput->list, &hid->inputs); |
| 1586 | 1587 | ||
| 1587 | INIT_LIST_HEAD(&hidinput->reports); | 1588 | INIT_LIST_HEAD(&hidinput->reports); |
| @@ -1677,8 +1678,7 @@ static struct hid_input *hidinput_match_application(struct hid_report *report) | |||
| 1677 | struct hid_input *hidinput; | 1678 | struct hid_input *hidinput; |
| 1678 | 1679 | ||
| 1679 | list_for_each_entry(hidinput, &hid->inputs, list) { | 1680 | list_for_each_entry(hidinput, &hid->inputs, list) { |
| 1680 | if (hidinput->report && | 1681 | if (hidinput->application == report->application) |
| 1681 | hidinput->report->application == report->application) | ||
| 1682 | return hidinput; | 1682 | return hidinput; |
| 1683 | } | 1683 | } |
| 1684 | 1684 | ||
| @@ -1815,6 +1815,7 @@ void hidinput_disconnect(struct hid_device *hid) | |||
| 1815 | input_unregister_device(hidinput->input); | 1815 | input_unregister_device(hidinput->input); |
| 1816 | else | 1816 | else |
| 1817 | input_free_device(hidinput->input); | 1817 | input_free_device(hidinput->input); |
| 1818 | kfree(hidinput->name); | ||
| 1818 | kfree(hidinput); | 1819 | kfree(hidinput); |
| 1819 | } | 1820 | } |
| 1820 | 1821 | ||
diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c index 40fbb7c52723..da954f3f4da7 100644 --- a/drivers/hid/hid-multitouch.c +++ b/drivers/hid/hid-multitouch.c | |||
| @@ -1375,7 +1375,8 @@ static bool mt_need_to_apply_feature(struct hid_device *hdev, | |||
| 1375 | struct hid_usage *usage, | 1375 | struct hid_usage *usage, |
| 1376 | enum latency_mode latency, | 1376 | enum latency_mode latency, |
| 1377 | bool surface_switch, | 1377 | bool surface_switch, |
| 1378 | bool button_switch) | 1378 | bool button_switch, |
| 1379 | bool *inputmode_found) | ||
| 1379 | { | 1380 | { |
| 1380 | struct mt_device *td = hid_get_drvdata(hdev); | 1381 | struct mt_device *td = hid_get_drvdata(hdev); |
| 1381 | struct mt_class *cls = &td->mtclass; | 1382 | struct mt_class *cls = &td->mtclass; |
| @@ -1387,6 +1388,14 @@ static bool mt_need_to_apply_feature(struct hid_device *hdev, | |||
| 1387 | 1388 | ||
| 1388 | switch (usage->hid) { | 1389 | switch (usage->hid) { |
| 1389 | case HID_DG_INPUTMODE: | 1390 | case HID_DG_INPUTMODE: |
| 1391 | /* | ||
| 1392 | * Some elan panels wrongly declare 2 input mode features, | ||
| 1393 | * and silently ignore when we set the value in the second | ||
| 1394 | * field. Skip the second feature and hope for the best. | ||
| 1395 | */ | ||
| 1396 | if (*inputmode_found) | ||
| 1397 | return false; | ||
| 1398 | |||
| 1390 | if (cls->quirks & MT_QUIRK_FORCE_GET_FEATURE) { | 1399 | if (cls->quirks & MT_QUIRK_FORCE_GET_FEATURE) { |
| 1391 | report_len = hid_report_len(report); | 1400 | report_len = hid_report_len(report); |
| 1392 | buf = hid_alloc_report_buf(report, GFP_KERNEL); | 1401 | buf = hid_alloc_report_buf(report, GFP_KERNEL); |
| @@ -1402,6 +1411,7 @@ static bool mt_need_to_apply_feature(struct hid_device *hdev, | |||
| 1402 | } | 1411 | } |
| 1403 | 1412 | ||
| 1404 | field->value[index] = td->inputmode_value; | 1413 | field->value[index] = td->inputmode_value; |
| 1414 | *inputmode_found = true; | ||
| 1405 | return true; | 1415 | return true; |
| 1406 | 1416 | ||
| 1407 | case HID_DG_CONTACTMAX: | 1417 | case HID_DG_CONTACTMAX: |
| @@ -1439,6 +1449,7 @@ static void mt_set_modes(struct hid_device *hdev, enum latency_mode latency, | |||
| 1439 | struct hid_usage *usage; | 1449 | struct hid_usage *usage; |
| 1440 | int i, j; | 1450 | int i, j; |
| 1441 | bool update_report; | 1451 | bool update_report; |
| 1452 | bool inputmode_found = false; | ||
| 1442 | 1453 | ||
| 1443 | rep_enum = &hdev->report_enum[HID_FEATURE_REPORT]; | 1454 | rep_enum = &hdev->report_enum[HID_FEATURE_REPORT]; |
| 1444 | list_for_each_entry(rep, &rep_enum->report_list, list) { | 1455 | list_for_each_entry(rep, &rep_enum->report_list, list) { |
| @@ -1457,7 +1468,8 @@ static void mt_set_modes(struct hid_device *hdev, enum latency_mode latency, | |||
| 1457 | usage, | 1468 | usage, |
| 1458 | latency, | 1469 | latency, |
| 1459 | surface_switch, | 1470 | surface_switch, |
| 1460 | button_switch)) | 1471 | button_switch, |
| 1472 | &inputmode_found)) | ||
| 1461 | update_report = true; | 1473 | update_report = true; |
| 1462 | } | 1474 | } |
| 1463 | } | 1475 | } |
| @@ -1685,6 +1697,9 @@ static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id) | |||
| 1685 | */ | 1697 | */ |
| 1686 | hdev->quirks |= HID_QUIRK_INPUT_PER_APP; | 1698 | hdev->quirks |= HID_QUIRK_INPUT_PER_APP; |
| 1687 | 1699 | ||
| 1700 | if (id->group != HID_GROUP_MULTITOUCH_WIN_8) | ||
| 1701 | hdev->quirks |= HID_QUIRK_MULTI_INPUT; | ||
| 1702 | |||
| 1688 | timer_setup(&td->release_timer, mt_expired_timeout, 0); | 1703 | timer_setup(&td->release_timer, mt_expired_timeout, 0); |
| 1689 | 1704 | ||
| 1690 | ret = hid_parse(hdev); | 1705 | ret = hid_parse(hdev); |
diff --git a/drivers/hid/hid-saitek.c b/drivers/hid/hid-saitek.c index 39e642686ff0..683861f324e3 100644 --- a/drivers/hid/hid-saitek.c +++ b/drivers/hid/hid-saitek.c | |||
| @@ -183,6 +183,8 @@ static const struct hid_device_id saitek_devices[] = { | |||
| 183 | .driver_data = SAITEK_RELEASE_MODE_RAT7 }, | 183 | .driver_data = SAITEK_RELEASE_MODE_RAT7 }, |
| 184 | { HID_USB_DEVICE(USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_RAT7), | 184 | { HID_USB_DEVICE(USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_RAT7), |
| 185 | .driver_data = SAITEK_RELEASE_MODE_RAT7 }, | 185 | .driver_data = SAITEK_RELEASE_MODE_RAT7 }, |
| 186 | { HID_USB_DEVICE(USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_RAT7_CONTAGION), | ||
| 187 | .driver_data = SAITEK_RELEASE_MODE_RAT7 }, | ||
| 186 | { HID_USB_DEVICE(USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_RAT9), | 188 | { HID_USB_DEVICE(USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_RAT9), |
| 187 | .driver_data = SAITEK_RELEASE_MODE_RAT7 }, | 189 | .driver_data = SAITEK_RELEASE_MODE_RAT7 }, |
| 188 | { HID_USB_DEVICE(USB_VENDOR_ID_MADCATZ, USB_DEVICE_ID_MADCATZ_RAT9), | 190 | { HID_USB_DEVICE(USB_VENDOR_ID_MADCATZ, USB_DEVICE_ID_MADCATZ_RAT9), |
diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c index 50af72baa5ca..2b63487057c2 100644 --- a/drivers/hid/hid-sensor-hub.c +++ b/drivers/hid/hid-sensor-hub.c | |||
| @@ -579,6 +579,28 @@ void sensor_hub_device_close(struct hid_sensor_hub_device *hsdev) | |||
| 579 | } | 579 | } |
| 580 | EXPORT_SYMBOL_GPL(sensor_hub_device_close); | 580 | EXPORT_SYMBOL_GPL(sensor_hub_device_close); |
| 581 | 581 | ||
| 582 | static __u8 *sensor_hub_report_fixup(struct hid_device *hdev, __u8 *rdesc, | ||
| 583 | unsigned int *rsize) | ||
| 584 | { | ||
| 585 | /* | ||
| 586 | * Checks if the report descriptor of Thinkpad Helix 2 has a logical | ||
| 587 | * minimum for magnetic flux axis greater than the maximum. | ||
| 588 | */ | ||
| 589 | if (hdev->product == USB_DEVICE_ID_TEXAS_INSTRUMENTS_LENOVO_YOGA && | ||
| 590 | *rsize == 2558 && rdesc[913] == 0x17 && rdesc[914] == 0x40 && | ||
| 591 | rdesc[915] == 0x81 && rdesc[916] == 0x08 && | ||
| 592 | rdesc[917] == 0x00 && rdesc[918] == 0x27 && | ||
| 593 | rdesc[921] == 0x07 && rdesc[922] == 0x00) { | ||
| 594 | /* Sets negative logical minimum for mag x, y and z */ | ||
| 595 | rdesc[914] = rdesc[935] = rdesc[956] = 0xc0; | ||
| 596 | rdesc[915] = rdesc[936] = rdesc[957] = 0x7e; | ||
| 597 | rdesc[916] = rdesc[937] = rdesc[958] = 0xf7; | ||
| 598 | rdesc[917] = rdesc[938] = rdesc[959] = 0xff; | ||
| 599 | } | ||
| 600 | |||
| 601 | return rdesc; | ||
| 602 | } | ||
| 603 | |||
| 582 | static int sensor_hub_probe(struct hid_device *hdev, | 604 | static int sensor_hub_probe(struct hid_device *hdev, |
| 583 | const struct hid_device_id *id) | 605 | const struct hid_device_id *id) |
| 584 | { | 606 | { |
| @@ -743,6 +765,7 @@ static struct hid_driver sensor_hub_driver = { | |||
| 743 | .probe = sensor_hub_probe, | 765 | .probe = sensor_hub_probe, |
| 744 | .remove = sensor_hub_remove, | 766 | .remove = sensor_hub_remove, |
| 745 | .raw_event = sensor_hub_raw_event, | 767 | .raw_event = sensor_hub_raw_event, |
| 768 | .report_fixup = sensor_hub_report_fixup, | ||
| 746 | #ifdef CONFIG_PM | 769 | #ifdef CONFIG_PM |
| 747 | .suspend = sensor_hub_suspend, | 770 | .suspend = sensor_hub_suspend, |
| 748 | .resume = sensor_hub_resume, | 771 | .resume = sensor_hub_resume, |
diff --git a/drivers/hid/i2c-hid/i2c-hid.c b/drivers/hid/i2c-hid/i2c-hid.c index 2ce194a84868..f3076659361a 100644 --- a/drivers/hid/i2c-hid/i2c-hid.c +++ b/drivers/hid/i2c-hid/i2c-hid.c | |||
| @@ -170,8 +170,6 @@ static const struct i2c_hid_quirks { | |||
| 170 | I2C_HID_QUIRK_SET_PWR_WAKEUP_DEV }, | 170 | I2C_HID_QUIRK_SET_PWR_WAKEUP_DEV }, |
| 171 | { I2C_VENDOR_ID_HANTICK, I2C_PRODUCT_ID_HANTICK_5288, | 171 | { I2C_VENDOR_ID_HANTICK, I2C_PRODUCT_ID_HANTICK_5288, |
| 172 | I2C_HID_QUIRK_NO_IRQ_AFTER_RESET }, | 172 | I2C_HID_QUIRK_NO_IRQ_AFTER_RESET }, |
| 173 | { I2C_VENDOR_ID_RAYD, I2C_PRODUCT_ID_RAYD_3118, | ||
| 174 | I2C_HID_QUIRK_RESEND_REPORT_DESCR }, | ||
| 175 | { USB_VENDOR_ID_SIS_TOUCH, USB_DEVICE_ID_SIS10FB_TOUCH, | 173 | { USB_VENDOR_ID_SIS_TOUCH, USB_DEVICE_ID_SIS10FB_TOUCH, |
| 176 | I2C_HID_QUIRK_RESEND_REPORT_DESCR }, | 174 | I2C_HID_QUIRK_RESEND_REPORT_DESCR }, |
| 177 | { 0, 0 } | 175 | { 0, 0 } |
| @@ -1235,11 +1233,16 @@ static int i2c_hid_resume(struct device *dev) | |||
| 1235 | pm_runtime_enable(dev); | 1233 | pm_runtime_enable(dev); |
| 1236 | 1234 | ||
| 1237 | enable_irq(client->irq); | 1235 | enable_irq(client->irq); |
| 1238 | ret = i2c_hid_hwreset(client); | 1236 | |
| 1237 | /* Instead of resetting device, simply powers the device on. This | ||
| 1238 | * solves "incomplete reports" on Raydium devices 2386:3118 and | ||
| 1239 | * 2386:4B33 | ||
| 1240 | */ | ||
| 1241 | ret = i2c_hid_set_power(client, I2C_HID_PWR_ON); | ||
| 1239 | if (ret) | 1242 | if (ret) |
| 1240 | return ret; | 1243 | return ret; |
| 1241 | 1244 | ||
| 1242 | /* RAYDIUM device (2386:3118) need to re-send report descr cmd | 1245 | /* Some devices need to re-send report descr cmd |
| 1243 | * after resume, after this it will be back normal. | 1246 | * after resume, after this it will be back normal. |
| 1244 | * otherwise it issues too many incomplete reports. | 1247 | * otherwise it issues too many incomplete reports. |
| 1245 | */ | 1248 | */ |
diff --git a/drivers/hid/intel-ish-hid/ipc/hw-ish.h b/drivers/hid/intel-ish-hid/ipc/hw-ish.h index 97869b7410eb..da133716bed0 100644 --- a/drivers/hid/intel-ish-hid/ipc/hw-ish.h +++ b/drivers/hid/intel-ish-hid/ipc/hw-ish.h | |||
| @@ -29,6 +29,7 @@ | |||
| 29 | #define CNL_Ax_DEVICE_ID 0x9DFC | 29 | #define CNL_Ax_DEVICE_ID 0x9DFC |
| 30 | #define GLK_Ax_DEVICE_ID 0x31A2 | 30 | #define GLK_Ax_DEVICE_ID 0x31A2 |
| 31 | #define CNL_H_DEVICE_ID 0xA37C | 31 | #define CNL_H_DEVICE_ID 0xA37C |
| 32 | #define SPT_H_DEVICE_ID 0xA135 | ||
| 32 | 33 | ||
| 33 | #define REVISION_ID_CHT_A0 0x6 | 34 | #define REVISION_ID_CHT_A0 0x6 |
| 34 | #define REVISION_ID_CHT_Ax_SI 0x0 | 35 | #define REVISION_ID_CHT_Ax_SI 0x0 |
diff --git a/drivers/hid/intel-ish-hid/ipc/pci-ish.c b/drivers/hid/intel-ish-hid/ipc/pci-ish.c index 050f9872f5c0..a1125a5c7965 100644 --- a/drivers/hid/intel-ish-hid/ipc/pci-ish.c +++ b/drivers/hid/intel-ish-hid/ipc/pci-ish.c | |||
| @@ -38,6 +38,7 @@ static const struct pci_device_id ish_pci_tbl[] = { | |||
| 38 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, CNL_Ax_DEVICE_ID)}, | 38 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, CNL_Ax_DEVICE_ID)}, |
| 39 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, GLK_Ax_DEVICE_ID)}, | 39 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, GLK_Ax_DEVICE_ID)}, |
| 40 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, CNL_H_DEVICE_ID)}, | 40 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, CNL_H_DEVICE_ID)}, |
| 41 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, SPT_H_DEVICE_ID)}, | ||
| 41 | {0, } | 42 | {0, } |
| 42 | }; | 43 | }; |
| 43 | MODULE_DEVICE_TABLE(pci, ish_pci_tbl); | 44 | MODULE_DEVICE_TABLE(pci, ish_pci_tbl); |
diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c index b1b548a21f91..c71cc857b649 100644 --- a/drivers/hv/vmbus_drv.c +++ b/drivers/hv/vmbus_drv.c | |||
| @@ -1291,6 +1291,9 @@ static ssize_t vmbus_chan_attr_show(struct kobject *kobj, | |||
| 1291 | if (!attribute->show) | 1291 | if (!attribute->show) |
| 1292 | return -EIO; | 1292 | return -EIO; |
| 1293 | 1293 | ||
| 1294 | if (chan->state != CHANNEL_OPENED_STATE) | ||
| 1295 | return -EINVAL; | ||
| 1296 | |||
| 1294 | return attribute->show(chan, buf); | 1297 | return attribute->show(chan, buf); |
| 1295 | } | 1298 | } |
| 1296 | 1299 | ||
diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c index 7589f2ad1dae..631360b14ca7 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c | |||
| @@ -187,12 +187,15 @@ static int st_lsm6dsx_set_fifo_odr(struct st_lsm6dsx_sensor *sensor, | |||
| 187 | 187 | ||
| 188 | int st_lsm6dsx_update_watermark(struct st_lsm6dsx_sensor *sensor, u16 watermark) | 188 | int st_lsm6dsx_update_watermark(struct st_lsm6dsx_sensor *sensor, u16 watermark) |
| 189 | { | 189 | { |
| 190 | u16 fifo_watermark = ~0, cur_watermark, sip = 0, fifo_th_mask; | 190 | u16 fifo_watermark = ~0, cur_watermark, fifo_th_mask; |
| 191 | struct st_lsm6dsx_hw *hw = sensor->hw; | 191 | struct st_lsm6dsx_hw *hw = sensor->hw; |
| 192 | struct st_lsm6dsx_sensor *cur_sensor; | 192 | struct st_lsm6dsx_sensor *cur_sensor; |
| 193 | int i, err, data; | 193 | int i, err, data; |
| 194 | __le16 wdata; | 194 | __le16 wdata; |
| 195 | 195 | ||
| 196 | if (!hw->sip) | ||
| 197 | return 0; | ||
| 198 | |||
| 196 | for (i = 0; i < ST_LSM6DSX_ID_MAX; i++) { | 199 | for (i = 0; i < ST_LSM6DSX_ID_MAX; i++) { |
| 197 | cur_sensor = iio_priv(hw->iio_devs[i]); | 200 | cur_sensor = iio_priv(hw->iio_devs[i]); |
| 198 | 201 | ||
| @@ -203,14 +206,10 @@ int st_lsm6dsx_update_watermark(struct st_lsm6dsx_sensor *sensor, u16 watermark) | |||
| 203 | : cur_sensor->watermark; | 206 | : cur_sensor->watermark; |
| 204 | 207 | ||
| 205 | fifo_watermark = min_t(u16, fifo_watermark, cur_watermark); | 208 | fifo_watermark = min_t(u16, fifo_watermark, cur_watermark); |
| 206 | sip += cur_sensor->sip; | ||
| 207 | } | 209 | } |
| 208 | 210 | ||
| 209 | if (!sip) | 211 | fifo_watermark = max_t(u16, fifo_watermark, hw->sip); |
| 210 | return 0; | 212 | fifo_watermark = (fifo_watermark / hw->sip) * hw->sip; |
| 211 | |||
| 212 | fifo_watermark = max_t(u16, fifo_watermark, sip); | ||
| 213 | fifo_watermark = (fifo_watermark / sip) * sip; | ||
| 214 | fifo_watermark = fifo_watermark * hw->settings->fifo_ops.th_wl; | 213 | fifo_watermark = fifo_watermark * hw->settings->fifo_ops.th_wl; |
| 215 | 214 | ||
| 216 | err = regmap_read(hw->regmap, hw->settings->fifo_ops.fifo_th.addr + 1, | 215 | err = regmap_read(hw->regmap, hw->settings->fifo_ops.fifo_th.addr + 1, |
diff --git a/drivers/iio/temperature/maxim_thermocouple.c b/drivers/iio/temperature/maxim_thermocouple.c index 54e383231d1e..c31b9633f32d 100644 --- a/drivers/iio/temperature/maxim_thermocouple.c +++ b/drivers/iio/temperature/maxim_thermocouple.c | |||
| @@ -258,7 +258,6 @@ static int maxim_thermocouple_remove(struct spi_device *spi) | |||
| 258 | static const struct spi_device_id maxim_thermocouple_id[] = { | 258 | static const struct spi_device_id maxim_thermocouple_id[] = { |
| 259 | {"max6675", MAX6675}, | 259 | {"max6675", MAX6675}, |
| 260 | {"max31855", MAX31855}, | 260 | {"max31855", MAX31855}, |
| 261 | {"max31856", MAX31855}, | ||
| 262 | {}, | 261 | {}, |
| 263 | }; | 262 | }; |
| 264 | MODULE_DEVICE_TABLE(spi, maxim_thermocouple_id); | 263 | MODULE_DEVICE_TABLE(spi, maxim_thermocouple_id); |
diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index f72677291b69..a36c94930c31 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c | |||
| @@ -724,6 +724,7 @@ static int cma_resolve_ib_dev(struct rdma_id_private *id_priv) | |||
| 724 | dgid = (union ib_gid *) &addr->sib_addr; | 724 | dgid = (union ib_gid *) &addr->sib_addr; |
| 725 | pkey = ntohs(addr->sib_pkey); | 725 | pkey = ntohs(addr->sib_pkey); |
| 726 | 726 | ||
| 727 | mutex_lock(&lock); | ||
| 727 | list_for_each_entry(cur_dev, &dev_list, list) { | 728 | list_for_each_entry(cur_dev, &dev_list, list) { |
| 728 | for (p = 1; p <= cur_dev->device->phys_port_cnt; ++p) { | 729 | for (p = 1; p <= cur_dev->device->phys_port_cnt; ++p) { |
| 729 | if (!rdma_cap_af_ib(cur_dev->device, p)) | 730 | if (!rdma_cap_af_ib(cur_dev->device, p)) |
| @@ -750,18 +751,19 @@ static int cma_resolve_ib_dev(struct rdma_id_private *id_priv) | |||
| 750 | cma_dev = cur_dev; | 751 | cma_dev = cur_dev; |
| 751 | sgid = gid; | 752 | sgid = gid; |
| 752 | id_priv->id.port_num = p; | 753 | id_priv->id.port_num = p; |
| 754 | goto found; | ||
| 753 | } | 755 | } |
| 754 | } | 756 | } |
| 755 | } | 757 | } |
| 756 | } | 758 | } |
| 757 | 759 | mutex_unlock(&lock); | |
| 758 | if (!cma_dev) | 760 | return -ENODEV; |
| 759 | return -ENODEV; | ||
| 760 | 761 | ||
| 761 | found: | 762 | found: |
| 762 | cma_attach_to_dev(id_priv, cma_dev); | 763 | cma_attach_to_dev(id_priv, cma_dev); |
| 763 | addr = (struct sockaddr_ib *) cma_src_addr(id_priv); | 764 | mutex_unlock(&lock); |
| 764 | memcpy(&addr->sib_addr, &sgid, sizeof sgid); | 765 | addr = (struct sockaddr_ib *)cma_src_addr(id_priv); |
| 766 | memcpy(&addr->sib_addr, &sgid, sizeof(sgid)); | ||
| 765 | cma_translate_ib(addr, &id_priv->id.route.addr.dev_addr); | 767 | cma_translate_ib(addr, &id_priv->id.route.addr.dev_addr); |
| 766 | return 0; | 768 | return 0; |
| 767 | } | 769 | } |
diff --git a/drivers/infiniband/core/rdma_core.c b/drivers/infiniband/core/rdma_core.c index 6eb64c6f0802..c4118bcd5103 100644 --- a/drivers/infiniband/core/rdma_core.c +++ b/drivers/infiniband/core/rdma_core.c | |||
| @@ -882,6 +882,8 @@ static int __uverbs_cleanup_ufile(struct ib_uverbs_file *ufile, | |||
| 882 | WARN_ON(uverbs_try_lock_object(obj, UVERBS_LOOKUP_WRITE)); | 882 | WARN_ON(uverbs_try_lock_object(obj, UVERBS_LOOKUP_WRITE)); |
| 883 | if (!uverbs_destroy_uobject(obj, reason)) | 883 | if (!uverbs_destroy_uobject(obj, reason)) |
| 884 | ret = 0; | 884 | ret = 0; |
| 885 | else | ||
| 886 | atomic_set(&obj->usecnt, 0); | ||
| 885 | } | 887 | } |
| 886 | return ret; | 888 | return ret; |
| 887 | } | 889 | } |
diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c index ec8fb289621f..5f437d1570fb 100644 --- a/drivers/infiniband/core/ucma.c +++ b/drivers/infiniband/core/ucma.c | |||
| @@ -124,6 +124,8 @@ static DEFINE_MUTEX(mut); | |||
| 124 | static DEFINE_IDR(ctx_idr); | 124 | static DEFINE_IDR(ctx_idr); |
| 125 | static DEFINE_IDR(multicast_idr); | 125 | static DEFINE_IDR(multicast_idr); |
| 126 | 126 | ||
| 127 | static const struct file_operations ucma_fops; | ||
| 128 | |||
| 127 | static inline struct ucma_context *_ucma_find_context(int id, | 129 | static inline struct ucma_context *_ucma_find_context(int id, |
| 128 | struct ucma_file *file) | 130 | struct ucma_file *file) |
| 129 | { | 131 | { |
| @@ -1581,6 +1583,10 @@ static ssize_t ucma_migrate_id(struct ucma_file *new_file, | |||
| 1581 | f = fdget(cmd.fd); | 1583 | f = fdget(cmd.fd); |
| 1582 | if (!f.file) | 1584 | if (!f.file) |
| 1583 | return -ENOENT; | 1585 | return -ENOENT; |
| 1586 | if (f.file->f_op != &ucma_fops) { | ||
| 1587 | ret = -EINVAL; | ||
| 1588 | goto file_put; | ||
| 1589 | } | ||
| 1584 | 1590 | ||
| 1585 | /* Validate current fd and prevent destruction of id. */ | 1591 | /* Validate current fd and prevent destruction of id. */ |
| 1586 | ctx = ucma_get_ctx(f.file->private_data, cmd.id); | 1592 | ctx = ucma_get_ctx(f.file->private_data, cmd.id); |
diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c index 823beca448e1..6d974e2363df 100644 --- a/drivers/infiniband/core/uverbs_main.c +++ b/drivers/infiniband/core/uverbs_main.c | |||
| @@ -1050,7 +1050,7 @@ static void ib_uverbs_add_one(struct ib_device *device) | |||
| 1050 | uverbs_dev->num_comp_vectors = device->num_comp_vectors; | 1050 | uverbs_dev->num_comp_vectors = device->num_comp_vectors; |
| 1051 | 1051 | ||
| 1052 | if (ib_uverbs_create_uapi(device, uverbs_dev)) | 1052 | if (ib_uverbs_create_uapi(device, uverbs_dev)) |
| 1053 | goto err; | 1053 | goto err_uapi; |
| 1054 | 1054 | ||
| 1055 | cdev_init(&uverbs_dev->cdev, NULL); | 1055 | cdev_init(&uverbs_dev->cdev, NULL); |
| 1056 | uverbs_dev->cdev.owner = THIS_MODULE; | 1056 | uverbs_dev->cdev.owner = THIS_MODULE; |
| @@ -1077,11 +1077,10 @@ static void ib_uverbs_add_one(struct ib_device *device) | |||
| 1077 | 1077 | ||
| 1078 | err_class: | 1078 | err_class: |
| 1079 | device_destroy(uverbs_class, uverbs_dev->cdev.dev); | 1079 | device_destroy(uverbs_class, uverbs_dev->cdev.dev); |
| 1080 | |||
| 1081 | err_cdev: | 1080 | err_cdev: |
| 1082 | cdev_del(&uverbs_dev->cdev); | 1081 | cdev_del(&uverbs_dev->cdev); |
| 1082 | err_uapi: | ||
| 1083 | clear_bit(devnum, dev_map); | 1083 | clear_bit(devnum, dev_map); |
| 1084 | |||
| 1085 | err: | 1084 | err: |
| 1086 | if (atomic_dec_and_test(&uverbs_dev->refcount)) | 1085 | if (atomic_dec_and_test(&uverbs_dev->refcount)) |
| 1087 | ib_uverbs_comp_dev(uverbs_dev); | 1086 | ib_uverbs_comp_dev(uverbs_dev); |
diff --git a/drivers/infiniband/hw/bnxt_re/ib_verbs.c b/drivers/infiniband/hw/bnxt_re/ib_verbs.c index bbfb86eb2d24..bc2b9e038439 100644 --- a/drivers/infiniband/hw/bnxt_re/ib_verbs.c +++ b/drivers/infiniband/hw/bnxt_re/ib_verbs.c | |||
| @@ -833,6 +833,8 @@ int bnxt_re_destroy_qp(struct ib_qp *ib_qp) | |||
| 833 | "Failed to destroy Shadow QP"); | 833 | "Failed to destroy Shadow QP"); |
| 834 | return rc; | 834 | return rc; |
| 835 | } | 835 | } |
| 836 | bnxt_qplib_free_qp_res(&rdev->qplib_res, | ||
| 837 | &rdev->qp1_sqp->qplib_qp); | ||
| 836 | mutex_lock(&rdev->qp_lock); | 838 | mutex_lock(&rdev->qp_lock); |
| 837 | list_del(&rdev->qp1_sqp->list); | 839 | list_del(&rdev->qp1_sqp->list); |
| 838 | atomic_dec(&rdev->qp_count); | 840 | atomic_dec(&rdev->qp_count); |
diff --git a/drivers/infiniband/hw/bnxt_re/qplib_fp.c b/drivers/infiniband/hw/bnxt_re/qplib_fp.c index e426b990c1dd..6ad0d46ab879 100644 --- a/drivers/infiniband/hw/bnxt_re/qplib_fp.c +++ b/drivers/infiniband/hw/bnxt_re/qplib_fp.c | |||
| @@ -196,7 +196,7 @@ static int bnxt_qplib_alloc_qp_hdr_buf(struct bnxt_qplib_res *res, | |||
| 196 | struct bnxt_qplib_qp *qp) | 196 | struct bnxt_qplib_qp *qp) |
| 197 | { | 197 | { |
| 198 | struct bnxt_qplib_q *rq = &qp->rq; | 198 | struct bnxt_qplib_q *rq = &qp->rq; |
| 199 | struct bnxt_qplib_q *sq = &qp->rq; | 199 | struct bnxt_qplib_q *sq = &qp->sq; |
| 200 | int rc = 0; | 200 | int rc = 0; |
| 201 | 201 | ||
| 202 | if (qp->sq_hdr_buf_size && sq->hwq.max_elements) { | 202 | if (qp->sq_hdr_buf_size && sq->hwq.max_elements) { |
diff --git a/drivers/infiniband/hw/cxgb4/qp.c b/drivers/infiniband/hw/cxgb4/qp.c index b3203afa3b1d..347fe18b1a41 100644 --- a/drivers/infiniband/hw/cxgb4/qp.c +++ b/drivers/infiniband/hw/cxgb4/qp.c | |||
| @@ -1685,6 +1685,12 @@ static void flush_qp(struct c4iw_qp *qhp) | |||
| 1685 | schp = to_c4iw_cq(qhp->ibqp.send_cq); | 1685 | schp = to_c4iw_cq(qhp->ibqp.send_cq); |
| 1686 | 1686 | ||
| 1687 | if (qhp->ibqp.uobject) { | 1687 | if (qhp->ibqp.uobject) { |
| 1688 | |||
| 1689 | /* for user qps, qhp->wq.flushed is protected by qhp->mutex */ | ||
| 1690 | if (qhp->wq.flushed) | ||
| 1691 | return; | ||
| 1692 | |||
| 1693 | qhp->wq.flushed = 1; | ||
| 1688 | t4_set_wq_in_error(&qhp->wq, 0); | 1694 | t4_set_wq_in_error(&qhp->wq, 0); |
| 1689 | t4_set_cq_in_error(&rchp->cq); | 1695 | t4_set_cq_in_error(&rchp->cq); |
| 1690 | spin_lock_irqsave(&rchp->comp_handler_lock, flag); | 1696 | spin_lock_irqsave(&rchp->comp_handler_lock, flag); |
diff --git a/drivers/infiniband/hw/hfi1/pcie.c b/drivers/infiniband/hw/hfi1/pcie.c index eec83757d55f..6c967dde58e7 100644 --- a/drivers/infiniband/hw/hfi1/pcie.c +++ b/drivers/infiniband/hw/hfi1/pcie.c | |||
| @@ -893,14 +893,11 @@ static int trigger_sbr(struct hfi1_devdata *dd) | |||
| 893 | } | 893 | } |
| 894 | 894 | ||
| 895 | /* | 895 | /* |
| 896 | * A secondary bus reset (SBR) issues a hot reset to our device. | 896 | * This is an end around to do an SBR during probe time. A new API needs |
| 897 | * The following routine does a 1s wait after the reset is dropped | 897 | * to be implemented to have cleaner interface but this fixes the |
| 898 | * per PCI Trhfa (recovery time). PCIe 3.0 section 6.6.1 - | 898 | * current brokenness |
| 899 | * Conventional Reset, paragraph 3, line 35 also says that a 1s | ||
| 900 | * delay after a reset is required. Per spec requirements, | ||
| 901 | * the link is either working or not after that point. | ||
| 902 | */ | 899 | */ |
| 903 | return pci_reset_bus(dev); | 900 | return pci_bridge_secondary_bus_reset(dev->bus->self); |
| 904 | } | 901 | } |
| 905 | 902 | ||
| 906 | /* | 903 | /* |
diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c index ca0f1ee26091..0bbeaaae47e0 100644 --- a/drivers/infiniband/hw/mlx4/main.c +++ b/drivers/infiniband/hw/mlx4/main.c | |||
| @@ -517,9 +517,11 @@ static int mlx4_ib_query_device(struct ib_device *ibdev, | |||
| 517 | props->page_size_cap = dev->dev->caps.page_size_cap; | 517 | props->page_size_cap = dev->dev->caps.page_size_cap; |
| 518 | props->max_qp = dev->dev->quotas.qp; | 518 | props->max_qp = dev->dev->quotas.qp; |
| 519 | props->max_qp_wr = dev->dev->caps.max_wqes - MLX4_IB_SQ_MAX_SPARE; | 519 | props->max_qp_wr = dev->dev->caps.max_wqes - MLX4_IB_SQ_MAX_SPARE; |
| 520 | props->max_send_sge = dev->dev->caps.max_sq_sg; | 520 | props->max_send_sge = |
| 521 | props->max_recv_sge = dev->dev->caps.max_rq_sg; | 521 | min(dev->dev->caps.max_sq_sg, dev->dev->caps.max_rq_sg); |
| 522 | props->max_sge_rd = MLX4_MAX_SGE_RD; | 522 | props->max_recv_sge = |
| 523 | min(dev->dev->caps.max_sq_sg, dev->dev->caps.max_rq_sg); | ||
| 524 | props->max_sge_rd = MLX4_MAX_SGE_RD; | ||
| 523 | props->max_cq = dev->dev->quotas.cq; | 525 | props->max_cq = dev->dev->quotas.cq; |
| 524 | props->max_cqe = dev->dev->caps.max_cqes; | 526 | props->max_cqe = dev->dev->caps.max_cqes; |
| 525 | props->max_mr = dev->dev->quotas.mpt; | 527 | props->max_mr = dev->dev->quotas.mpt; |
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_cm.c b/drivers/infiniband/ulp/ipoib/ipoib_cm.c index ea01b8dd2be6..3d5424f335cb 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_cm.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_cm.c | |||
| @@ -1027,12 +1027,14 @@ static int ipoib_cm_rep_handler(struct ib_cm_id *cm_id, | |||
| 1027 | 1027 | ||
| 1028 | skb_queue_head_init(&skqueue); | 1028 | skb_queue_head_init(&skqueue); |
| 1029 | 1029 | ||
| 1030 | netif_tx_lock_bh(p->dev); | ||
| 1030 | spin_lock_irq(&priv->lock); | 1031 | spin_lock_irq(&priv->lock); |
| 1031 | set_bit(IPOIB_FLAG_OPER_UP, &p->flags); | 1032 | set_bit(IPOIB_FLAG_OPER_UP, &p->flags); |
| 1032 | if (p->neigh) | 1033 | if (p->neigh) |
| 1033 | while ((skb = __skb_dequeue(&p->neigh->queue))) | 1034 | while ((skb = __skb_dequeue(&p->neigh->queue))) |
| 1034 | __skb_queue_tail(&skqueue, skb); | 1035 | __skb_queue_tail(&skqueue, skb); |
| 1035 | spin_unlock_irq(&priv->lock); | 1036 | spin_unlock_irq(&priv->lock); |
| 1037 | netif_tx_unlock_bh(p->dev); | ||
| 1036 | 1038 | ||
| 1037 | while ((skb = __skb_dequeue(&skqueue))) { | 1039 | while ((skb = __skb_dequeue(&skqueue))) { |
| 1038 | skb->dev = p->dev; | 1040 | skb->dev = p->dev; |
diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index 316a57530f6d..c2df341ff6fa 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c | |||
| @@ -1439,6 +1439,7 @@ static struct irq_chip its_irq_chip = { | |||
| 1439 | * The consequence of the above is that allocation is cost is low, but | 1439 | * The consequence of the above is that allocation is cost is low, but |
| 1440 | * freeing is expensive. We assumes that freeing rarely occurs. | 1440 | * freeing is expensive. We assumes that freeing rarely occurs. |
| 1441 | */ | 1441 | */ |
| 1442 | #define ITS_MAX_LPI_NRBITS 16 /* 64K LPIs */ | ||
| 1442 | 1443 | ||
| 1443 | static DEFINE_MUTEX(lpi_range_lock); | 1444 | static DEFINE_MUTEX(lpi_range_lock); |
| 1444 | static LIST_HEAD(lpi_range_list); | 1445 | static LIST_HEAD(lpi_range_list); |
| @@ -1625,7 +1626,8 @@ static int __init its_alloc_lpi_tables(void) | |||
| 1625 | { | 1626 | { |
| 1626 | phys_addr_t paddr; | 1627 | phys_addr_t paddr; |
| 1627 | 1628 | ||
| 1628 | lpi_id_bits = GICD_TYPER_ID_BITS(gic_rdists->gicd_typer); | 1629 | lpi_id_bits = min_t(u32, GICD_TYPER_ID_BITS(gic_rdists->gicd_typer), |
| 1630 | ITS_MAX_LPI_NRBITS); | ||
| 1629 | gic_rdists->prop_page = its_allocate_prop_table(GFP_NOWAIT); | 1631 | gic_rdists->prop_page = its_allocate_prop_table(GFP_NOWAIT); |
| 1630 | if (!gic_rdists->prop_page) { | 1632 | if (!gic_rdists->prop_page) { |
| 1631 | pr_err("Failed to allocate PROPBASE\n"); | 1633 | pr_err("Failed to allocate PROPBASE\n"); |
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c index f266c81f396f..0481223b1deb 100644 --- a/drivers/md/dm-crypt.c +++ b/drivers/md/dm-crypt.c | |||
| @@ -332,7 +332,7 @@ static int crypt_iv_essiv_init(struct crypt_config *cc) | |||
| 332 | int err; | 332 | int err; |
| 333 | 333 | ||
| 334 | desc->tfm = essiv->hash_tfm; | 334 | desc->tfm = essiv->hash_tfm; |
| 335 | desc->flags = CRYPTO_TFM_REQ_MAY_SLEEP; | 335 | desc->flags = 0; |
| 336 | 336 | ||
| 337 | err = crypto_shash_digest(desc, cc->key, cc->key_size, essiv->salt); | 337 | err = crypto_shash_digest(desc, cc->key, cc->key_size, essiv->salt); |
| 338 | shash_desc_zero(desc); | 338 | shash_desc_zero(desc); |
| @@ -606,7 +606,7 @@ static int crypt_iv_lmk_one(struct crypt_config *cc, u8 *iv, | |||
| 606 | int i, r; | 606 | int i, r; |
| 607 | 607 | ||
| 608 | desc->tfm = lmk->hash_tfm; | 608 | desc->tfm = lmk->hash_tfm; |
| 609 | desc->flags = CRYPTO_TFM_REQ_MAY_SLEEP; | 609 | desc->flags = 0; |
| 610 | 610 | ||
| 611 | r = crypto_shash_init(desc); | 611 | r = crypto_shash_init(desc); |
| 612 | if (r) | 612 | if (r) |
| @@ -768,7 +768,7 @@ static int crypt_iv_tcw_whitening(struct crypt_config *cc, | |||
| 768 | 768 | ||
| 769 | /* calculate crc32 for every 32bit part and xor it */ | 769 | /* calculate crc32 for every 32bit part and xor it */ |
| 770 | desc->tfm = tcw->crc32_tfm; | 770 | desc->tfm = tcw->crc32_tfm; |
| 771 | desc->flags = CRYPTO_TFM_REQ_MAY_SLEEP; | 771 | desc->flags = 0; |
| 772 | for (i = 0; i < 4; i++) { | 772 | for (i = 0; i < 4; i++) { |
| 773 | r = crypto_shash_init(desc); | 773 | r = crypto_shash_init(desc); |
| 774 | if (r) | 774 | if (r) |
| @@ -1251,7 +1251,7 @@ static void crypt_alloc_req_skcipher(struct crypt_config *cc, | |||
| 1251 | * requests if driver request queue is full. | 1251 | * requests if driver request queue is full. |
| 1252 | */ | 1252 | */ |
| 1253 | skcipher_request_set_callback(ctx->r.req, | 1253 | skcipher_request_set_callback(ctx->r.req, |
| 1254 | CRYPTO_TFM_REQ_MAY_BACKLOG | CRYPTO_TFM_REQ_MAY_SLEEP, | 1254 | CRYPTO_TFM_REQ_MAY_BACKLOG, |
| 1255 | kcryptd_async_done, dmreq_of_req(cc, ctx->r.req)); | 1255 | kcryptd_async_done, dmreq_of_req(cc, ctx->r.req)); |
| 1256 | } | 1256 | } |
| 1257 | 1257 | ||
| @@ -1268,7 +1268,7 @@ static void crypt_alloc_req_aead(struct crypt_config *cc, | |||
| 1268 | * requests if driver request queue is full. | 1268 | * requests if driver request queue is full. |
| 1269 | */ | 1269 | */ |
| 1270 | aead_request_set_callback(ctx->r.req_aead, | 1270 | aead_request_set_callback(ctx->r.req_aead, |
| 1271 | CRYPTO_TFM_REQ_MAY_BACKLOG | CRYPTO_TFM_REQ_MAY_SLEEP, | 1271 | CRYPTO_TFM_REQ_MAY_BACKLOG, |
| 1272 | kcryptd_async_done, dmreq_of_req(cc, ctx->r.req_aead)); | 1272 | kcryptd_async_done, dmreq_of_req(cc, ctx->r.req_aead)); |
| 1273 | } | 1273 | } |
| 1274 | 1274 | ||
diff --git a/drivers/md/dm-integrity.c b/drivers/md/dm-integrity.c index 378878599466..89ccb64342de 100644 --- a/drivers/md/dm-integrity.c +++ b/drivers/md/dm-integrity.c | |||
| @@ -532,7 +532,7 @@ static void section_mac(struct dm_integrity_c *ic, unsigned section, __u8 result | |||
| 532 | unsigned j, size; | 532 | unsigned j, size; |
| 533 | 533 | ||
| 534 | desc->tfm = ic->journal_mac; | 534 | desc->tfm = ic->journal_mac; |
| 535 | desc->flags = CRYPTO_TFM_REQ_MAY_SLEEP; | 535 | desc->flags = 0; |
| 536 | 536 | ||
| 537 | r = crypto_shash_init(desc); | 537 | r = crypto_shash_init(desc); |
| 538 | if (unlikely(r)) { | 538 | if (unlikely(r)) { |
| @@ -676,7 +676,7 @@ static void complete_journal_encrypt(struct crypto_async_request *req, int err) | |||
| 676 | static bool do_crypt(bool encrypt, struct skcipher_request *req, struct journal_completion *comp) | 676 | static bool do_crypt(bool encrypt, struct skcipher_request *req, struct journal_completion *comp) |
| 677 | { | 677 | { |
| 678 | int r; | 678 | int r; |
| 679 | skcipher_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG | CRYPTO_TFM_REQ_MAY_SLEEP, | 679 | skcipher_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, |
| 680 | complete_journal_encrypt, comp); | 680 | complete_journal_encrypt, comp); |
| 681 | if (likely(encrypt)) | 681 | if (likely(encrypt)) |
| 682 | r = crypto_skcipher_encrypt(req); | 682 | r = crypto_skcipher_encrypt(req); |
diff --git a/drivers/md/dm-raid.c b/drivers/md/dm-raid.c index cae689de75fd..5ba067fa0c72 100644 --- a/drivers/md/dm-raid.c +++ b/drivers/md/dm-raid.c | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * Copyright (C) 2010-2011 Neil Brown | 2 | * Copyright (C) 2010-2011 Neil Brown |
| 3 | * Copyright (C) 2010-2017 Red Hat, Inc. All rights reserved. | 3 | * Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved. |
| 4 | * | 4 | * |
| 5 | * This file is released under the GPL. | 5 | * This file is released under the GPL. |
| 6 | */ | 6 | */ |
| @@ -29,9 +29,6 @@ | |||
| 29 | */ | 29 | */ |
| 30 | #define MIN_RAID456_JOURNAL_SPACE (4*2048) | 30 | #define MIN_RAID456_JOURNAL_SPACE (4*2048) |
| 31 | 31 | ||
| 32 | /* Global list of all raid sets */ | ||
| 33 | static LIST_HEAD(raid_sets); | ||
| 34 | |||
| 35 | static bool devices_handle_discard_safely = false; | 32 | static bool devices_handle_discard_safely = false; |
| 36 | 33 | ||
| 37 | /* | 34 | /* |
| @@ -227,7 +224,6 @@ struct rs_layout { | |||
| 227 | 224 | ||
| 228 | struct raid_set { | 225 | struct raid_set { |
| 229 | struct dm_target *ti; | 226 | struct dm_target *ti; |
| 230 | struct list_head list; | ||
| 231 | 227 | ||
| 232 | uint32_t stripe_cache_entries; | 228 | uint32_t stripe_cache_entries; |
| 233 | unsigned long ctr_flags; | 229 | unsigned long ctr_flags; |
| @@ -273,19 +269,6 @@ static void rs_config_restore(struct raid_set *rs, struct rs_layout *l) | |||
| 273 | mddev->new_chunk_sectors = l->new_chunk_sectors; | 269 | mddev->new_chunk_sectors = l->new_chunk_sectors; |
| 274 | } | 270 | } |
| 275 | 271 | ||
| 276 | /* Find any raid_set in active slot for @rs on global list */ | ||
| 277 | static struct raid_set *rs_find_active(struct raid_set *rs) | ||
| 278 | { | ||
| 279 | struct raid_set *r; | ||
| 280 | struct mapped_device *md = dm_table_get_md(rs->ti->table); | ||
| 281 | |||
| 282 | list_for_each_entry(r, &raid_sets, list) | ||
| 283 | if (r != rs && dm_table_get_md(r->ti->table) == md) | ||
| 284 | return r; | ||
| 285 | |||
| 286 | return NULL; | ||
| 287 | } | ||
| 288 | |||
| 289 | /* raid10 algorithms (i.e. formats) */ | 272 | /* raid10 algorithms (i.e. formats) */ |
| 290 | #define ALGORITHM_RAID10_DEFAULT 0 | 273 | #define ALGORITHM_RAID10_DEFAULT 0 |
| 291 | #define ALGORITHM_RAID10_NEAR 1 | 274 | #define ALGORITHM_RAID10_NEAR 1 |
| @@ -764,7 +747,6 @@ static struct raid_set *raid_set_alloc(struct dm_target *ti, struct raid_type *r | |||
| 764 | 747 | ||
| 765 | mddev_init(&rs->md); | 748 | mddev_init(&rs->md); |
| 766 | 749 | ||
| 767 | INIT_LIST_HEAD(&rs->list); | ||
| 768 | rs->raid_disks = raid_devs; | 750 | rs->raid_disks = raid_devs; |
| 769 | rs->delta_disks = 0; | 751 | rs->delta_disks = 0; |
| 770 | 752 | ||
| @@ -782,9 +764,6 @@ static struct raid_set *raid_set_alloc(struct dm_target *ti, struct raid_type *r | |||
| 782 | for (i = 0; i < raid_devs; i++) | 764 | for (i = 0; i < raid_devs; i++) |
| 783 | md_rdev_init(&rs->dev[i].rdev); | 765 | md_rdev_init(&rs->dev[i].rdev); |
| 784 | 766 | ||
| 785 | /* Add @rs to global list. */ | ||
| 786 | list_add(&rs->list, &raid_sets); | ||
| 787 | |||
| 788 | /* | 767 | /* |
| 789 | * Remaining items to be initialized by further RAID params: | 768 | * Remaining items to be initialized by further RAID params: |
| 790 | * rs->md.persistent | 769 | * rs->md.persistent |
| @@ -797,7 +776,7 @@ static struct raid_set *raid_set_alloc(struct dm_target *ti, struct raid_type *r | |||
| 797 | return rs; | 776 | return rs; |
| 798 | } | 777 | } |
| 799 | 778 | ||
| 800 | /* Free all @rs allocations and remove it from global list. */ | 779 | /* Free all @rs allocations */ |
| 801 | static void raid_set_free(struct raid_set *rs) | 780 | static void raid_set_free(struct raid_set *rs) |
| 802 | { | 781 | { |
| 803 | int i; | 782 | int i; |
| @@ -815,8 +794,6 @@ static void raid_set_free(struct raid_set *rs) | |||
| 815 | dm_put_device(rs->ti, rs->dev[i].data_dev); | 794 | dm_put_device(rs->ti, rs->dev[i].data_dev); |
| 816 | } | 795 | } |
| 817 | 796 | ||
| 818 | list_del(&rs->list); | ||
| 819 | |||
| 820 | kfree(rs); | 797 | kfree(rs); |
| 821 | } | 798 | } |
| 822 | 799 | ||
| @@ -2649,7 +2626,7 @@ static int rs_adjust_data_offsets(struct raid_set *rs) | |||
| 2649 | return 0; | 2626 | return 0; |
| 2650 | } | 2627 | } |
| 2651 | 2628 | ||
| 2652 | /* HM FIXME: get InSync raid_dev? */ | 2629 | /* HM FIXME: get In_Sync raid_dev? */ |
| 2653 | rdev = &rs->dev[0].rdev; | 2630 | rdev = &rs->dev[0].rdev; |
| 2654 | 2631 | ||
| 2655 | if (rs->delta_disks < 0) { | 2632 | if (rs->delta_disks < 0) { |
| @@ -3149,6 +3126,11 @@ static int raid_ctr(struct dm_target *ti, unsigned int argc, char **argv) | |||
| 3149 | set_bit(RT_FLAG_UPDATE_SBS, &rs->runtime_flags); | 3126 | set_bit(RT_FLAG_UPDATE_SBS, &rs->runtime_flags); |
| 3150 | rs_set_new(rs); | 3127 | rs_set_new(rs); |
| 3151 | } else if (rs_is_recovering(rs)) { | 3128 | } else if (rs_is_recovering(rs)) { |
| 3129 | /* Rebuild particular devices */ | ||
| 3130 | if (test_bit(__CTR_FLAG_REBUILD, &rs->ctr_flags)) { | ||
| 3131 | set_bit(RT_FLAG_UPDATE_SBS, &rs->runtime_flags); | ||
| 3132 | rs_setup_recovery(rs, MaxSector); | ||
| 3133 | } | ||
| 3152 | /* A recovering raid set may be resized */ | 3134 | /* A recovering raid set may be resized */ |
| 3153 | ; /* skip setup rs */ | 3135 | ; /* skip setup rs */ |
| 3154 | } else if (rs_is_reshaping(rs)) { | 3136 | } else if (rs_is_reshaping(rs)) { |
| @@ -3242,6 +3224,8 @@ static int raid_ctr(struct dm_target *ti, unsigned int argc, char **argv) | |||
| 3242 | /* Start raid set read-only and assumed clean to change in raid_resume() */ | 3224 | /* Start raid set read-only and assumed clean to change in raid_resume() */ |
| 3243 | rs->md.ro = 1; | 3225 | rs->md.ro = 1; |
| 3244 | rs->md.in_sync = 1; | 3226 | rs->md.in_sync = 1; |
| 3227 | |||
| 3228 | /* Keep array frozen */ | ||
| 3245 | set_bit(MD_RECOVERY_FROZEN, &rs->md.recovery); | 3229 | set_bit(MD_RECOVERY_FROZEN, &rs->md.recovery); |
| 3246 | 3230 | ||
| 3247 | /* Has to be held on running the array */ | 3231 | /* Has to be held on running the array */ |
| @@ -3265,7 +3249,7 @@ static int raid_ctr(struct dm_target *ti, unsigned int argc, char **argv) | |||
| 3265 | rs->callbacks.congested_fn = raid_is_congested; | 3249 | rs->callbacks.congested_fn = raid_is_congested; |
| 3266 | dm_table_add_target_callbacks(ti->table, &rs->callbacks); | 3250 | dm_table_add_target_callbacks(ti->table, &rs->callbacks); |
| 3267 | 3251 | ||
| 3268 | /* If raid4/5/6 journal mode explictely requested (only possible with journal dev) -> set it */ | 3252 | /* If raid4/5/6 journal mode explicitly requested (only possible with journal dev) -> set it */ |
| 3269 | if (test_bit(__CTR_FLAG_JOURNAL_MODE, &rs->ctr_flags)) { | 3253 | if (test_bit(__CTR_FLAG_JOURNAL_MODE, &rs->ctr_flags)) { |
| 3270 | r = r5c_journal_mode_set(&rs->md, rs->journal_dev.mode); | 3254 | r = r5c_journal_mode_set(&rs->md, rs->journal_dev.mode); |
| 3271 | if (r) { | 3255 | if (r) { |
| @@ -3350,32 +3334,53 @@ static int raid_map(struct dm_target *ti, struct bio *bio) | |||
| 3350 | return DM_MAPIO_SUBMITTED; | 3334 | return DM_MAPIO_SUBMITTED; |
| 3351 | } | 3335 | } |
| 3352 | 3336 | ||
| 3353 | /* Return string describing the current sync action of @mddev */ | 3337 | /* Return sync state string for @state */ |
| 3354 | static const char *decipher_sync_action(struct mddev *mddev, unsigned long recovery) | 3338 | enum sync_state { st_frozen, st_reshape, st_resync, st_check, st_repair, st_recover, st_idle }; |
| 3339 | static const char *sync_str(enum sync_state state) | ||
| 3340 | { | ||
| 3341 | /* Has to be in above sync_state order! */ | ||
| 3342 | static const char *sync_strs[] = { | ||
| 3343 | "frozen", | ||
| 3344 | "reshape", | ||
| 3345 | "resync", | ||
| 3346 | "check", | ||
| 3347 | "repair", | ||
| 3348 | "recover", | ||
| 3349 | "idle" | ||
| 3350 | }; | ||
| 3351 | |||
| 3352 | return __within_range(state, 0, ARRAY_SIZE(sync_strs) - 1) ? sync_strs[state] : "undef"; | ||
| 3353 | }; | ||
| 3354 | |||
| 3355 | /* Return enum sync_state for @mddev derived from @recovery flags */ | ||
| 3356 | static const enum sync_state decipher_sync_action(struct mddev *mddev, unsigned long recovery) | ||
| 3355 | { | 3357 | { |
| 3356 | if (test_bit(MD_RECOVERY_FROZEN, &recovery)) | 3358 | if (test_bit(MD_RECOVERY_FROZEN, &recovery)) |
| 3357 | return "frozen"; | 3359 | return st_frozen; |
| 3358 | 3360 | ||
| 3359 | /* The MD sync thread can be done with io but still be running */ | 3361 | /* The MD sync thread can be done with io or be interrupted but still be running */ |
| 3360 | if (!test_bit(MD_RECOVERY_DONE, &recovery) && | 3362 | if (!test_bit(MD_RECOVERY_DONE, &recovery) && |
| 3361 | (test_bit(MD_RECOVERY_RUNNING, &recovery) || | 3363 | (test_bit(MD_RECOVERY_RUNNING, &recovery) || |
| 3362 | (!mddev->ro && test_bit(MD_RECOVERY_NEEDED, &recovery)))) { | 3364 | (!mddev->ro && test_bit(MD_RECOVERY_NEEDED, &recovery)))) { |
| 3363 | if (test_bit(MD_RECOVERY_RESHAPE, &recovery)) | 3365 | if (test_bit(MD_RECOVERY_RESHAPE, &recovery)) |
| 3364 | return "reshape"; | 3366 | return st_reshape; |
| 3365 | 3367 | ||
| 3366 | if (test_bit(MD_RECOVERY_SYNC, &recovery)) { | 3368 | if (test_bit(MD_RECOVERY_SYNC, &recovery)) { |
| 3367 | if (!test_bit(MD_RECOVERY_REQUESTED, &recovery)) | 3369 | if (!test_bit(MD_RECOVERY_REQUESTED, &recovery)) |
| 3368 | return "resync"; | 3370 | return st_resync; |
| 3369 | else if (test_bit(MD_RECOVERY_CHECK, &recovery)) | 3371 | if (test_bit(MD_RECOVERY_CHECK, &recovery)) |
| 3370 | return "check"; | 3372 | return st_check; |
| 3371 | return "repair"; | 3373 | return st_repair; |
| 3372 | } | 3374 | } |
| 3373 | 3375 | ||
| 3374 | if (test_bit(MD_RECOVERY_RECOVER, &recovery)) | 3376 | if (test_bit(MD_RECOVERY_RECOVER, &recovery)) |
| 3375 | return "recover"; | 3377 | return st_recover; |
| 3378 | |||
| 3379 | if (mddev->reshape_position != MaxSector) | ||
| 3380 | return st_reshape; | ||
| 3376 | } | 3381 | } |
| 3377 | 3382 | ||
| 3378 | return "idle"; | 3383 | return st_idle; |
| 3379 | } | 3384 | } |
| 3380 | 3385 | ||
| 3381 | /* | 3386 | /* |
| @@ -3409,6 +3414,7 @@ static sector_t rs_get_progress(struct raid_set *rs, unsigned long recovery, | |||
| 3409 | sector_t resync_max_sectors) | 3414 | sector_t resync_max_sectors) |
| 3410 | { | 3415 | { |
| 3411 | sector_t r; | 3416 | sector_t r; |
| 3417 | enum sync_state state; | ||
| 3412 | struct mddev *mddev = &rs->md; | 3418 | struct mddev *mddev = &rs->md; |
| 3413 | 3419 | ||
| 3414 | clear_bit(RT_FLAG_RS_IN_SYNC, &rs->runtime_flags); | 3420 | clear_bit(RT_FLAG_RS_IN_SYNC, &rs->runtime_flags); |
| @@ -3419,20 +3425,14 @@ static sector_t rs_get_progress(struct raid_set *rs, unsigned long recovery, | |||
| 3419 | set_bit(RT_FLAG_RS_IN_SYNC, &rs->runtime_flags); | 3425 | set_bit(RT_FLAG_RS_IN_SYNC, &rs->runtime_flags); |
| 3420 | 3426 | ||
| 3421 | } else { | 3427 | } else { |
| 3422 | if (!test_bit(__CTR_FLAG_NOSYNC, &rs->ctr_flags) && | 3428 | state = decipher_sync_action(mddev, recovery); |
| 3423 | !test_bit(MD_RECOVERY_INTR, &recovery) && | 3429 | |
| 3424 | (test_bit(MD_RECOVERY_NEEDED, &recovery) || | 3430 | if (state == st_idle && !test_bit(MD_RECOVERY_INTR, &recovery)) |
| 3425 | test_bit(MD_RECOVERY_RESHAPE, &recovery) || | ||
| 3426 | test_bit(MD_RECOVERY_RUNNING, &recovery))) | ||
| 3427 | r = mddev->curr_resync_completed; | ||
| 3428 | else | ||
| 3429 | r = mddev->recovery_cp; | 3431 | r = mddev->recovery_cp; |
| 3432 | else | ||
| 3433 | r = mddev->curr_resync_completed; | ||
| 3430 | 3434 | ||
| 3431 | if (r >= resync_max_sectors && | 3435 | if (state == st_idle && r >= resync_max_sectors) { |
| 3432 | (!test_bit(MD_RECOVERY_REQUESTED, &recovery) || | ||
| 3433 | (!test_bit(MD_RECOVERY_FROZEN, &recovery) && | ||
| 3434 | !test_bit(MD_RECOVERY_NEEDED, &recovery) && | ||
| 3435 | !test_bit(MD_RECOVERY_RUNNING, &recovery)))) { | ||
| 3436 | /* | 3436 | /* |
| 3437 | * Sync complete. | 3437 | * Sync complete. |
| 3438 | */ | 3438 | */ |
| @@ -3440,24 +3440,20 @@ static sector_t rs_get_progress(struct raid_set *rs, unsigned long recovery, | |||
| 3440 | if (test_bit(MD_RECOVERY_RECOVER, &recovery)) | 3440 | if (test_bit(MD_RECOVERY_RECOVER, &recovery)) |
| 3441 | set_bit(RT_FLAG_RS_IN_SYNC, &rs->runtime_flags); | 3441 | set_bit(RT_FLAG_RS_IN_SYNC, &rs->runtime_flags); |
| 3442 | 3442 | ||
| 3443 | } else if (test_bit(MD_RECOVERY_RECOVER, &recovery)) { | 3443 | } else if (state == st_recover) |
| 3444 | /* | 3444 | /* |
| 3445 | * In case we are recovering, the array is not in sync | 3445 | * In case we are recovering, the array is not in sync |
| 3446 | * and health chars should show the recovering legs. | 3446 | * and health chars should show the recovering legs. |
| 3447 | */ | 3447 | */ |
| 3448 | ; | 3448 | ; |
| 3449 | 3449 | else if (state == st_resync) | |
| 3450 | } else if (test_bit(MD_RECOVERY_SYNC, &recovery) && | ||
| 3451 | !test_bit(MD_RECOVERY_REQUESTED, &recovery)) { | ||
| 3452 | /* | 3450 | /* |
| 3453 | * If "resync" is occurring, the raid set | 3451 | * If "resync" is occurring, the raid set |
| 3454 | * is or may be out of sync hence the health | 3452 | * is or may be out of sync hence the health |
| 3455 | * characters shall be 'a'. | 3453 | * characters shall be 'a'. |
| 3456 | */ | 3454 | */ |
| 3457 | set_bit(RT_FLAG_RS_RESYNCING, &rs->runtime_flags); | 3455 | set_bit(RT_FLAG_RS_RESYNCING, &rs->runtime_flags); |
| 3458 | 3456 | else if (state == st_reshape) | |
| 3459 | } else if (test_bit(MD_RECOVERY_RESHAPE, &recovery) && | ||
| 3460 | !test_bit(MD_RECOVERY_REQUESTED, &recovery)) { | ||
| 3461 | /* | 3457 | /* |
| 3462 | * If "reshape" is occurring, the raid set | 3458 | * If "reshape" is occurring, the raid set |
| 3463 | * is or may be out of sync hence the health | 3459 | * is or may be out of sync hence the health |
| @@ -3465,7 +3461,7 @@ static sector_t rs_get_progress(struct raid_set *rs, unsigned long recovery, | |||
| 3465 | */ | 3461 | */ |
| 3466 | set_bit(RT_FLAG_RS_RESYNCING, &rs->runtime_flags); | 3462 | set_bit(RT_FLAG_RS_RESYNCING, &rs->runtime_flags); |
| 3467 | 3463 | ||
| 3468 | } else if (test_bit(MD_RECOVERY_REQUESTED, &recovery)) { | 3464 | else if (state == st_check || state == st_repair) |
| 3469 | /* | 3465 | /* |
| 3470 | * If "check" or "repair" is occurring, the raid set has | 3466 | * If "check" or "repair" is occurring, the raid set has |
| 3471 | * undergone an initial sync and the health characters | 3467 | * undergone an initial sync and the health characters |
| @@ -3473,12 +3469,12 @@ static sector_t rs_get_progress(struct raid_set *rs, unsigned long recovery, | |||
| 3473 | */ | 3469 | */ |
| 3474 | set_bit(RT_FLAG_RS_IN_SYNC, &rs->runtime_flags); | 3470 | set_bit(RT_FLAG_RS_IN_SYNC, &rs->runtime_flags); |
| 3475 | 3471 | ||
| 3476 | } else { | 3472 | else { |
| 3477 | struct md_rdev *rdev; | 3473 | struct md_rdev *rdev; |
| 3478 | 3474 | ||
| 3479 | /* | 3475 | /* |
| 3480 | * We are idle and recovery is needed, prevent 'A' chars race | 3476 | * We are idle and recovery is needed, prevent 'A' chars race |
| 3481 | * caused by components still set to in-sync by constrcuctor. | 3477 | * caused by components still set to in-sync by constructor. |
| 3482 | */ | 3478 | */ |
| 3483 | if (test_bit(MD_RECOVERY_NEEDED, &recovery)) | 3479 | if (test_bit(MD_RECOVERY_NEEDED, &recovery)) |
| 3484 | set_bit(RT_FLAG_RS_RESYNCING, &rs->runtime_flags); | 3480 | set_bit(RT_FLAG_RS_RESYNCING, &rs->runtime_flags); |
| @@ -3542,7 +3538,7 @@ static void raid_status(struct dm_target *ti, status_type_t type, | |||
| 3542 | progress = rs_get_progress(rs, recovery, resync_max_sectors); | 3538 | progress = rs_get_progress(rs, recovery, resync_max_sectors); |
| 3543 | resync_mismatches = (mddev->last_sync_action && !strcasecmp(mddev->last_sync_action, "check")) ? | 3539 | resync_mismatches = (mddev->last_sync_action && !strcasecmp(mddev->last_sync_action, "check")) ? |
| 3544 | atomic64_read(&mddev->resync_mismatches) : 0; | 3540 | atomic64_read(&mddev->resync_mismatches) : 0; |
| 3545 | sync_action = decipher_sync_action(&rs->md, recovery); | 3541 | sync_action = sync_str(decipher_sync_action(&rs->md, recovery)); |
| 3546 | 3542 | ||
| 3547 | /* HM FIXME: do we want another state char for raid0? It shows 'D'/'A'/'-' now */ | 3543 | /* HM FIXME: do we want another state char for raid0? It shows 'D'/'A'/'-' now */ |
| 3548 | for (i = 0; i < rs->raid_disks; i++) | 3544 | for (i = 0; i < rs->raid_disks; i++) |
| @@ -3892,14 +3888,13 @@ static int rs_start_reshape(struct raid_set *rs) | |||
| 3892 | struct mddev *mddev = &rs->md; | 3888 | struct mddev *mddev = &rs->md; |
| 3893 | struct md_personality *pers = mddev->pers; | 3889 | struct md_personality *pers = mddev->pers; |
| 3894 | 3890 | ||
| 3891 | /* Don't allow the sync thread to work until the table gets reloaded. */ | ||
| 3892 | set_bit(MD_RECOVERY_WAIT, &mddev->recovery); | ||
| 3893 | |||
| 3895 | r = rs_setup_reshape(rs); | 3894 | r = rs_setup_reshape(rs); |
| 3896 | if (r) | 3895 | if (r) |
| 3897 | return r; | 3896 | return r; |
| 3898 | 3897 | ||
| 3899 | /* Need to be resumed to be able to start reshape, recovery is frozen until raid_resume() though */ | ||
| 3900 | if (test_and_clear_bit(RT_FLAG_RS_SUSPENDED, &rs->runtime_flags)) | ||
| 3901 | mddev_resume(mddev); | ||
| 3902 | |||
| 3903 | /* | 3898 | /* |
| 3904 | * Check any reshape constraints enforced by the personalility | 3899 | * Check any reshape constraints enforced by the personalility |
| 3905 | * | 3900 | * |
| @@ -3923,10 +3918,6 @@ static int rs_start_reshape(struct raid_set *rs) | |||
| 3923 | } | 3918 | } |
| 3924 | } | 3919 | } |
| 3925 | 3920 | ||
| 3926 | /* Suspend because a resume will happen in raid_resume() */ | ||
| 3927 | set_bit(RT_FLAG_RS_SUSPENDED, &rs->runtime_flags); | ||
| 3928 | mddev_suspend(mddev); | ||
| 3929 | |||
| 3930 | /* | 3921 | /* |
| 3931 | * Now reshape got set up, update superblocks to | 3922 | * Now reshape got set up, update superblocks to |
| 3932 | * reflect the fact so that a table reload will | 3923 | * reflect the fact so that a table reload will |
| @@ -3947,29 +3938,6 @@ static int raid_preresume(struct dm_target *ti) | |||
| 3947 | if (test_and_set_bit(RT_FLAG_RS_PRERESUMED, &rs->runtime_flags)) | 3938 | if (test_and_set_bit(RT_FLAG_RS_PRERESUMED, &rs->runtime_flags)) |
| 3948 | return 0; | 3939 | return 0; |
| 3949 | 3940 | ||
| 3950 | if (!test_bit(__CTR_FLAG_REBUILD, &rs->ctr_flags)) { | ||
| 3951 | struct raid_set *rs_active = rs_find_active(rs); | ||
| 3952 | |||
| 3953 | if (rs_active) { | ||
| 3954 | /* | ||
| 3955 | * In case no rebuilds have been requested | ||
| 3956 | * and an active table slot exists, copy | ||
| 3957 | * current resynchonization completed and | ||
| 3958 | * reshape position pointers across from | ||
| 3959 | * suspended raid set in the active slot. | ||
| 3960 | * | ||
| 3961 | * This resumes the new mapping at current | ||
| 3962 | * offsets to continue recover/reshape without | ||
| 3963 | * necessarily redoing a raid set partially or | ||
| 3964 | * causing data corruption in case of a reshape. | ||
| 3965 | */ | ||
| 3966 | if (rs_active->md.curr_resync_completed != MaxSector) | ||
| 3967 | mddev->curr_resync_completed = rs_active->md.curr_resync_completed; | ||
| 3968 | if (rs_active->md.reshape_position != MaxSector) | ||
| 3969 | mddev->reshape_position = rs_active->md.reshape_position; | ||
| 3970 | } | ||
| 3971 | } | ||
| 3972 | |||
| 3973 | /* | 3941 | /* |
| 3974 | * The superblocks need to be updated on disk if the | 3942 | * The superblocks need to be updated on disk if the |
| 3975 | * array is new or new devices got added (thus zeroed | 3943 | * array is new or new devices got added (thus zeroed |
| @@ -4046,7 +4014,7 @@ static void raid_resume(struct dm_target *ti) | |||
| 4046 | 4014 | ||
| 4047 | static struct target_type raid_target = { | 4015 | static struct target_type raid_target = { |
| 4048 | .name = "raid", | 4016 | .name = "raid", |
| 4049 | .version = {1, 13, 2}, | 4017 | .version = {1, 14, 0}, |
| 4050 | .module = THIS_MODULE, | 4018 | .module = THIS_MODULE, |
| 4051 | .ctr = raid_ctr, | 4019 | .ctr = raid_ctr, |
| 4052 | .dtr = raid_dtr, | 4020 | .dtr = raid_dtr, |
diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c index 72142021b5c9..74f6770c70b1 100644 --- a/drivers/md/dm-thin-metadata.c +++ b/drivers/md/dm-thin-metadata.c | |||
| @@ -189,6 +189,12 @@ struct dm_pool_metadata { | |||
| 189 | sector_t data_block_size; | 189 | sector_t data_block_size; |
| 190 | 190 | ||
| 191 | /* | 191 | /* |
| 192 | * We reserve a section of the metadata for commit overhead. | ||
| 193 | * All reported space does *not* include this. | ||
| 194 | */ | ||
| 195 | dm_block_t metadata_reserve; | ||
| 196 | |||
| 197 | /* | ||
| 192 | * Set if a transaction has to be aborted but the attempt to roll back | 198 | * Set if a transaction has to be aborted but the attempt to roll back |
| 193 | * to the previous (good) transaction failed. The only pool metadata | 199 | * to the previous (good) transaction failed. The only pool metadata |
| 194 | * operation possible in this state is the closing of the device. | 200 | * operation possible in this state is the closing of the device. |
| @@ -816,6 +822,22 @@ static int __commit_transaction(struct dm_pool_metadata *pmd) | |||
| 816 | return dm_tm_commit(pmd->tm, sblock); | 822 | return dm_tm_commit(pmd->tm, sblock); |
| 817 | } | 823 | } |
| 818 | 824 | ||
| 825 | static void __set_metadata_reserve(struct dm_pool_metadata *pmd) | ||
| 826 | { | ||
| 827 | int r; | ||
| 828 | dm_block_t total; | ||
| 829 | dm_block_t max_blocks = 4096; /* 16M */ | ||
| 830 | |||
| 831 | r = dm_sm_get_nr_blocks(pmd->metadata_sm, &total); | ||
| 832 | if (r) { | ||
| 833 | DMERR("could not get size of metadata device"); | ||
| 834 | pmd->metadata_reserve = max_blocks; | ||
| 835 | } else { | ||
| 836 | sector_div(total, 10); | ||
| 837 | pmd->metadata_reserve = min(max_blocks, total); | ||
| 838 | } | ||
| 839 | } | ||
| 840 | |||
| 819 | struct dm_pool_metadata *dm_pool_metadata_open(struct block_device *bdev, | 841 | struct dm_pool_metadata *dm_pool_metadata_open(struct block_device *bdev, |
| 820 | sector_t data_block_size, | 842 | sector_t data_block_size, |
| 821 | bool format_device) | 843 | bool format_device) |
| @@ -849,6 +871,8 @@ struct dm_pool_metadata *dm_pool_metadata_open(struct block_device *bdev, | |||
| 849 | return ERR_PTR(r); | 871 | return ERR_PTR(r); |
| 850 | } | 872 | } |
| 851 | 873 | ||
| 874 | __set_metadata_reserve(pmd); | ||
| 875 | |||
| 852 | return pmd; | 876 | return pmd; |
| 853 | } | 877 | } |
| 854 | 878 | ||
| @@ -1820,6 +1844,13 @@ int dm_pool_get_free_metadata_block_count(struct dm_pool_metadata *pmd, | |||
| 1820 | down_read(&pmd->root_lock); | 1844 | down_read(&pmd->root_lock); |
| 1821 | if (!pmd->fail_io) | 1845 | if (!pmd->fail_io) |
| 1822 | r = dm_sm_get_nr_free(pmd->metadata_sm, result); | 1846 | r = dm_sm_get_nr_free(pmd->metadata_sm, result); |
| 1847 | |||
| 1848 | if (!r) { | ||
| 1849 | if (*result < pmd->metadata_reserve) | ||
| 1850 | *result = 0; | ||
| 1851 | else | ||
| 1852 | *result -= pmd->metadata_reserve; | ||
| 1853 | } | ||
| 1823 | up_read(&pmd->root_lock); | 1854 | up_read(&pmd->root_lock); |
| 1824 | 1855 | ||
| 1825 | return r; | 1856 | return r; |
| @@ -1932,8 +1963,11 @@ int dm_pool_resize_metadata_dev(struct dm_pool_metadata *pmd, dm_block_t new_cou | |||
| 1932 | int r = -EINVAL; | 1963 | int r = -EINVAL; |
| 1933 | 1964 | ||
| 1934 | down_write(&pmd->root_lock); | 1965 | down_write(&pmd->root_lock); |
| 1935 | if (!pmd->fail_io) | 1966 | if (!pmd->fail_io) { |
| 1936 | r = __resize_space_map(pmd->metadata_sm, new_count); | 1967 | r = __resize_space_map(pmd->metadata_sm, new_count); |
| 1968 | if (!r) | ||
| 1969 | __set_metadata_reserve(pmd); | ||
| 1970 | } | ||
| 1937 | up_write(&pmd->root_lock); | 1971 | up_write(&pmd->root_lock); |
| 1938 | 1972 | ||
| 1939 | return r; | 1973 | return r; |
diff --git a/drivers/md/dm-thin.c b/drivers/md/dm-thin.c index 7bd60a150f8f..aaf1ad481ee8 100644 --- a/drivers/md/dm-thin.c +++ b/drivers/md/dm-thin.c | |||
| @@ -200,7 +200,13 @@ struct dm_thin_new_mapping; | |||
| 200 | enum pool_mode { | 200 | enum pool_mode { |
| 201 | PM_WRITE, /* metadata may be changed */ | 201 | PM_WRITE, /* metadata may be changed */ |
| 202 | PM_OUT_OF_DATA_SPACE, /* metadata may be changed, though data may not be allocated */ | 202 | PM_OUT_OF_DATA_SPACE, /* metadata may be changed, though data may not be allocated */ |
| 203 | |||
| 204 | /* | ||
| 205 | * Like READ_ONLY, except may switch back to WRITE on metadata resize. Reported as READ_ONLY. | ||
| 206 | */ | ||
| 207 | PM_OUT_OF_METADATA_SPACE, | ||
| 203 | PM_READ_ONLY, /* metadata may not be changed */ | 208 | PM_READ_ONLY, /* metadata may not be changed */ |
| 209 | |||
| 204 | PM_FAIL, /* all I/O fails */ | 210 | PM_FAIL, /* all I/O fails */ |
| 205 | }; | 211 | }; |
| 206 | 212 | ||
| @@ -1371,7 +1377,35 @@ static void set_pool_mode(struct pool *pool, enum pool_mode new_mode); | |||
| 1371 | 1377 | ||
| 1372 | static void requeue_bios(struct pool *pool); | 1378 | static void requeue_bios(struct pool *pool); |
| 1373 | 1379 | ||
| 1374 | static void check_for_space(struct pool *pool) | 1380 | static bool is_read_only_pool_mode(enum pool_mode mode) |
| 1381 | { | ||
| 1382 | return (mode == PM_OUT_OF_METADATA_SPACE || mode == PM_READ_ONLY); | ||
| 1383 | } | ||
| 1384 | |||
| 1385 | static bool is_read_only(struct pool *pool) | ||
| 1386 | { | ||
| 1387 | return is_read_only_pool_mode(get_pool_mode(pool)); | ||
| 1388 | } | ||
| 1389 | |||
| 1390 | static void check_for_metadata_space(struct pool *pool) | ||
| 1391 | { | ||
| 1392 | int r; | ||
| 1393 | const char *ooms_reason = NULL; | ||
| 1394 | dm_block_t nr_free; | ||
| 1395 | |||
| 1396 | r = dm_pool_get_free_metadata_block_count(pool->pmd, &nr_free); | ||
| 1397 | if (r) | ||
| 1398 | ooms_reason = "Could not get free metadata blocks"; | ||
| 1399 | else if (!nr_free) | ||
| 1400 | ooms_reason = "No free metadata blocks"; | ||
| 1401 | |||
| 1402 | if (ooms_reason && !is_read_only(pool)) { | ||
| 1403 | DMERR("%s", ooms_reason); | ||
| 1404 | set_pool_mode(pool, PM_OUT_OF_METADATA_SPACE); | ||
| 1405 | } | ||
| 1406 | } | ||
| 1407 | |||
| 1408 | static void check_for_data_space(struct pool *pool) | ||
| 1375 | { | 1409 | { |
| 1376 | int r; | 1410 | int r; |
| 1377 | dm_block_t nr_free; | 1411 | dm_block_t nr_free; |
| @@ -1397,14 +1431,16 @@ static int commit(struct pool *pool) | |||
| 1397 | { | 1431 | { |
| 1398 | int r; | 1432 | int r; |
| 1399 | 1433 | ||
| 1400 | if (get_pool_mode(pool) >= PM_READ_ONLY) | 1434 | if (get_pool_mode(pool) >= PM_OUT_OF_METADATA_SPACE) |
| 1401 | return -EINVAL; | 1435 | return -EINVAL; |
| 1402 | 1436 | ||
| 1403 | r = dm_pool_commit_metadata(pool->pmd); | 1437 | r = dm_pool_commit_metadata(pool->pmd); |
| 1404 | if (r) | 1438 | if (r) |
| 1405 | metadata_operation_failed(pool, "dm_pool_commit_metadata", r); | 1439 | metadata_operation_failed(pool, "dm_pool_commit_metadata", r); |
| 1406 | else | 1440 | else { |
| 1407 | check_for_space(pool); | 1441 | check_for_metadata_space(pool); |
| 1442 | check_for_data_space(pool); | ||
| 1443 | } | ||
| 1408 | 1444 | ||
| 1409 | return r; | 1445 | return r; |
| 1410 | } | 1446 | } |
| @@ -1470,6 +1506,19 @@ static int alloc_data_block(struct thin_c *tc, dm_block_t *result) | |||
| 1470 | return r; | 1506 | return r; |
| 1471 | } | 1507 | } |
| 1472 | 1508 | ||
| 1509 | r = dm_pool_get_free_metadata_block_count(pool->pmd, &free_blocks); | ||
| 1510 | if (r) { | ||
| 1511 | metadata_operation_failed(pool, "dm_pool_get_free_metadata_block_count", r); | ||
| 1512 | return r; | ||
| 1513 | } | ||
| 1514 | |||
| 1515 | if (!free_blocks) { | ||
| 1516 | /* Let's commit before we use up the metadata reserve. */ | ||
| 1517 | r = commit(pool); | ||
| 1518 | if (r) | ||
| 1519 | return r; | ||
| 1520 | } | ||
| 1521 | |||
| 1473 | return 0; | 1522 | return 0; |
| 1474 | } | 1523 | } |
| 1475 | 1524 | ||
| @@ -1501,6 +1550,7 @@ static blk_status_t should_error_unserviceable_bio(struct pool *pool) | |||
| 1501 | case PM_OUT_OF_DATA_SPACE: | 1550 | case PM_OUT_OF_DATA_SPACE: |
| 1502 | return pool->pf.error_if_no_space ? BLK_STS_NOSPC : 0; | 1551 | return pool->pf.error_if_no_space ? BLK_STS_NOSPC : 0; |
| 1503 | 1552 | ||
| 1553 | case PM_OUT_OF_METADATA_SPACE: | ||
| 1504 | case PM_READ_ONLY: | 1554 | case PM_READ_ONLY: |
| 1505 | case PM_FAIL: | 1555 | case PM_FAIL: |
| 1506 | return BLK_STS_IOERR; | 1556 | return BLK_STS_IOERR; |
| @@ -2464,8 +2514,9 @@ static void set_pool_mode(struct pool *pool, enum pool_mode new_mode) | |||
| 2464 | error_retry_list(pool); | 2514 | error_retry_list(pool); |
| 2465 | break; | 2515 | break; |
| 2466 | 2516 | ||
| 2517 | case PM_OUT_OF_METADATA_SPACE: | ||
| 2467 | case PM_READ_ONLY: | 2518 | case PM_READ_ONLY: |
| 2468 | if (old_mode != new_mode) | 2519 | if (!is_read_only_pool_mode(old_mode)) |
| 2469 | notify_of_pool_mode_change(pool, "read-only"); | 2520 | notify_of_pool_mode_change(pool, "read-only"); |
| 2470 | dm_pool_metadata_read_only(pool->pmd); | 2521 | dm_pool_metadata_read_only(pool->pmd); |
| 2471 | pool->process_bio = process_bio_read_only; | 2522 | pool->process_bio = process_bio_read_only; |
| @@ -3403,6 +3454,10 @@ static int maybe_resize_metadata_dev(struct dm_target *ti, bool *need_commit) | |||
| 3403 | DMINFO("%s: growing the metadata device from %llu to %llu blocks", | 3454 | DMINFO("%s: growing the metadata device from %llu to %llu blocks", |
| 3404 | dm_device_name(pool->pool_md), | 3455 | dm_device_name(pool->pool_md), |
| 3405 | sb_metadata_dev_size, metadata_dev_size); | 3456 | sb_metadata_dev_size, metadata_dev_size); |
| 3457 | |||
| 3458 | if (get_pool_mode(pool) == PM_OUT_OF_METADATA_SPACE) | ||
| 3459 | set_pool_mode(pool, PM_WRITE); | ||
| 3460 | |||
| 3406 | r = dm_pool_resize_metadata_dev(pool->pmd, metadata_dev_size); | 3461 | r = dm_pool_resize_metadata_dev(pool->pmd, metadata_dev_size); |
| 3407 | if (r) { | 3462 | if (r) { |
| 3408 | metadata_operation_failed(pool, "dm_pool_resize_metadata_dev", r); | 3463 | metadata_operation_failed(pool, "dm_pool_resize_metadata_dev", r); |
| @@ -3707,7 +3762,7 @@ static int pool_message(struct dm_target *ti, unsigned argc, char **argv, | |||
| 3707 | struct pool_c *pt = ti->private; | 3762 | struct pool_c *pt = ti->private; |
| 3708 | struct pool *pool = pt->pool; | 3763 | struct pool *pool = pt->pool; |
| 3709 | 3764 | ||
| 3710 | if (get_pool_mode(pool) >= PM_READ_ONLY) { | 3765 | if (get_pool_mode(pool) >= PM_OUT_OF_METADATA_SPACE) { |
| 3711 | DMERR("%s: unable to service pool target messages in READ_ONLY or FAIL mode", | 3766 | DMERR("%s: unable to service pool target messages in READ_ONLY or FAIL mode", |
| 3712 | dm_device_name(pool->pool_md)); | 3767 | dm_device_name(pool->pool_md)); |
| 3713 | return -EOPNOTSUPP; | 3768 | return -EOPNOTSUPP; |
| @@ -3781,6 +3836,7 @@ static void pool_status(struct dm_target *ti, status_type_t type, | |||
| 3781 | dm_block_t nr_blocks_data; | 3836 | dm_block_t nr_blocks_data; |
| 3782 | dm_block_t nr_blocks_metadata; | 3837 | dm_block_t nr_blocks_metadata; |
| 3783 | dm_block_t held_root; | 3838 | dm_block_t held_root; |
| 3839 | enum pool_mode mode; | ||
| 3784 | char buf[BDEVNAME_SIZE]; | 3840 | char buf[BDEVNAME_SIZE]; |
| 3785 | char buf2[BDEVNAME_SIZE]; | 3841 | char buf2[BDEVNAME_SIZE]; |
| 3786 | struct pool_c *pt = ti->private; | 3842 | struct pool_c *pt = ti->private; |
| @@ -3851,9 +3907,10 @@ static void pool_status(struct dm_target *ti, status_type_t type, | |||
| 3851 | else | 3907 | else |
| 3852 | DMEMIT("- "); | 3908 | DMEMIT("- "); |
| 3853 | 3909 | ||
| 3854 | if (pool->pf.mode == PM_OUT_OF_DATA_SPACE) | 3910 | mode = get_pool_mode(pool); |
| 3911 | if (mode == PM_OUT_OF_DATA_SPACE) | ||
| 3855 | DMEMIT("out_of_data_space "); | 3912 | DMEMIT("out_of_data_space "); |
| 3856 | else if (pool->pf.mode == PM_READ_ONLY) | 3913 | else if (is_read_only_pool_mode(mode)) |
| 3857 | DMEMIT("ro "); | 3914 | DMEMIT("ro "); |
| 3858 | else | 3915 | else |
| 3859 | DMEMIT("rw "); | 3916 | DMEMIT("rw "); |
diff --git a/drivers/md/dm-verity-target.c b/drivers/md/dm-verity-target.c index 12decdbd722d..fc65f0dedf7f 100644 --- a/drivers/md/dm-verity-target.c +++ b/drivers/md/dm-verity-target.c | |||
| @@ -99,10 +99,26 @@ static int verity_hash_update(struct dm_verity *v, struct ahash_request *req, | |||
| 99 | { | 99 | { |
| 100 | struct scatterlist sg; | 100 | struct scatterlist sg; |
| 101 | 101 | ||
| 102 | sg_init_one(&sg, data, len); | 102 | if (likely(!is_vmalloc_addr(data))) { |
| 103 | ahash_request_set_crypt(req, &sg, NULL, len); | 103 | sg_init_one(&sg, data, len); |
| 104 | 104 | ahash_request_set_crypt(req, &sg, NULL, len); | |
| 105 | return crypto_wait_req(crypto_ahash_update(req), wait); | 105 | return crypto_wait_req(crypto_ahash_update(req), wait); |
| 106 | } else { | ||
| 107 | do { | ||
| 108 | int r; | ||
| 109 | size_t this_step = min_t(size_t, len, PAGE_SIZE - offset_in_page(data)); | ||
| 110 | flush_kernel_vmap_range((void *)data, this_step); | ||
| 111 | sg_init_table(&sg, 1); | ||
| 112 | sg_set_page(&sg, vmalloc_to_page(data), this_step, offset_in_page(data)); | ||
| 113 | ahash_request_set_crypt(req, &sg, NULL, this_step); | ||
| 114 | r = crypto_wait_req(crypto_ahash_update(req), wait); | ||
| 115 | if (unlikely(r)) | ||
| 116 | return r; | ||
| 117 | data += this_step; | ||
| 118 | len -= this_step; | ||
| 119 | } while (len); | ||
| 120 | return 0; | ||
| 121 | } | ||
| 106 | } | 122 | } |
| 107 | 123 | ||
| 108 | /* | 124 | /* |
diff --git a/drivers/misc/hmc6352.c b/drivers/misc/hmc6352.c index eeb7eef62174..38f90e179927 100644 --- a/drivers/misc/hmc6352.c +++ b/drivers/misc/hmc6352.c | |||
| @@ -27,6 +27,7 @@ | |||
| 27 | #include <linux/err.h> | 27 | #include <linux/err.h> |
| 28 | #include <linux/delay.h> | 28 | #include <linux/delay.h> |
| 29 | #include <linux/sysfs.h> | 29 | #include <linux/sysfs.h> |
| 30 | #include <linux/nospec.h> | ||
| 30 | 31 | ||
| 31 | static DEFINE_MUTEX(compass_mutex); | 32 | static DEFINE_MUTEX(compass_mutex); |
| 32 | 33 | ||
| @@ -50,6 +51,7 @@ static int compass_store(struct device *dev, const char *buf, size_t count, | |||
| 50 | return ret; | 51 | return ret; |
| 51 | if (val >= strlen(map)) | 52 | if (val >= strlen(map)) |
| 52 | return -EINVAL; | 53 | return -EINVAL; |
| 54 | val = array_index_nospec(val, strlen(map)); | ||
| 53 | mutex_lock(&compass_mutex); | 55 | mutex_lock(&compass_mutex); |
| 54 | ret = compass_command(c, map[val]); | 56 | ret = compass_command(c, map[val]); |
| 55 | mutex_unlock(&compass_mutex); | 57 | mutex_unlock(&compass_mutex); |
diff --git a/drivers/misc/ibmvmc.c b/drivers/misc/ibmvmc.c index 8f82bb9d11e2..b8aaa684c397 100644 --- a/drivers/misc/ibmvmc.c +++ b/drivers/misc/ibmvmc.c | |||
| @@ -2131,7 +2131,7 @@ static int ibmvmc_init_crq_queue(struct crq_server_adapter *adapter) | |||
| 2131 | retrc = plpar_hcall_norets(H_REG_CRQ, | 2131 | retrc = plpar_hcall_norets(H_REG_CRQ, |
| 2132 | vdev->unit_address, | 2132 | vdev->unit_address, |
| 2133 | queue->msg_token, PAGE_SIZE); | 2133 | queue->msg_token, PAGE_SIZE); |
| 2134 | retrc = rc; | 2134 | rc = retrc; |
| 2135 | 2135 | ||
| 2136 | if (rc == H_RESOURCE) | 2136 | if (rc == H_RESOURCE) |
| 2137 | rc = ibmvmc_reset_crq_queue(adapter); | 2137 | rc = ibmvmc_reset_crq_queue(adapter); |
diff --git a/drivers/misc/mei/bus.c b/drivers/misc/mei/bus.c index 7bba62a72921..fc3872fe7b25 100644 --- a/drivers/misc/mei/bus.c +++ b/drivers/misc/mei/bus.c | |||
| @@ -521,17 +521,15 @@ int mei_cldev_enable(struct mei_cl_device *cldev) | |||
| 521 | 521 | ||
| 522 | cl = cldev->cl; | 522 | cl = cldev->cl; |
| 523 | 523 | ||
| 524 | mutex_lock(&bus->device_lock); | ||
| 524 | if (cl->state == MEI_FILE_UNINITIALIZED) { | 525 | if (cl->state == MEI_FILE_UNINITIALIZED) { |
| 525 | mutex_lock(&bus->device_lock); | ||
| 526 | ret = mei_cl_link(cl); | 526 | ret = mei_cl_link(cl); |
| 527 | mutex_unlock(&bus->device_lock); | ||
| 528 | if (ret) | 527 | if (ret) |
| 529 | return ret; | 528 | goto out; |
| 530 | /* update pointers */ | 529 | /* update pointers */ |
| 531 | cl->cldev = cldev; | 530 | cl->cldev = cldev; |
| 532 | } | 531 | } |
| 533 | 532 | ||
| 534 | mutex_lock(&bus->device_lock); | ||
| 535 | if (mei_cl_is_connected(cl)) { | 533 | if (mei_cl_is_connected(cl)) { |
| 536 | ret = 0; | 534 | ret = 0; |
| 537 | goto out; | 535 | goto out; |
| @@ -616,9 +614,8 @@ int mei_cldev_disable(struct mei_cl_device *cldev) | |||
| 616 | if (err < 0) | 614 | if (err < 0) |
| 617 | dev_err(bus->dev, "Could not disconnect from the ME client\n"); | 615 | dev_err(bus->dev, "Could not disconnect from the ME client\n"); |
| 618 | 616 | ||
| 619 | out: | ||
| 620 | mei_cl_bus_module_put(cldev); | 617 | mei_cl_bus_module_put(cldev); |
| 621 | 618 | out: | |
| 622 | /* Flush queues and remove any pending read */ | 619 | /* Flush queues and remove any pending read */ |
| 623 | mei_cl_flush_queues(cl, NULL); | 620 | mei_cl_flush_queues(cl, NULL); |
| 624 | mei_cl_unlink(cl); | 621 | mei_cl_unlink(cl); |
| @@ -876,12 +873,13 @@ static void mei_cl_bus_dev_release(struct device *dev) | |||
| 876 | 873 | ||
| 877 | mei_me_cl_put(cldev->me_cl); | 874 | mei_me_cl_put(cldev->me_cl); |
| 878 | mei_dev_bus_put(cldev->bus); | 875 | mei_dev_bus_put(cldev->bus); |
| 876 | mei_cl_unlink(cldev->cl); | ||
| 879 | kfree(cldev->cl); | 877 | kfree(cldev->cl); |
| 880 | kfree(cldev); | 878 | kfree(cldev); |
| 881 | } | 879 | } |
| 882 | 880 | ||
| 883 | static const struct device_type mei_cl_device_type = { | 881 | static const struct device_type mei_cl_device_type = { |
| 884 | .release = mei_cl_bus_dev_release, | 882 | .release = mei_cl_bus_dev_release, |
| 885 | }; | 883 | }; |
| 886 | 884 | ||
| 887 | /** | 885 | /** |
diff --git a/drivers/misc/mei/client.c b/drivers/misc/mei/client.c index 4ab6251d418e..ebdcf0b450e2 100644 --- a/drivers/misc/mei/client.c +++ b/drivers/misc/mei/client.c | |||
| @@ -1767,7 +1767,7 @@ out: | |||
| 1767 | } | 1767 | } |
| 1768 | } | 1768 | } |
| 1769 | 1769 | ||
| 1770 | rets = buf->size; | 1770 | rets = len; |
| 1771 | err: | 1771 | err: |
| 1772 | cl_dbg(dev, cl, "rpm: autosuspend\n"); | 1772 | cl_dbg(dev, cl, "rpm: autosuspend\n"); |
| 1773 | pm_runtime_mark_last_busy(dev->dev); | 1773 | pm_runtime_mark_last_busy(dev->dev); |
diff --git a/drivers/misc/mei/hbm.c b/drivers/misc/mei/hbm.c index 09e233d4c0de..e56f3e72d57a 100644 --- a/drivers/misc/mei/hbm.c +++ b/drivers/misc/mei/hbm.c | |||
| @@ -1161,15 +1161,18 @@ int mei_hbm_dispatch(struct mei_device *dev, struct mei_msg_hdr *hdr) | |||
| 1161 | 1161 | ||
| 1162 | props_res = (struct hbm_props_response *)mei_msg; | 1162 | props_res = (struct hbm_props_response *)mei_msg; |
| 1163 | 1163 | ||
| 1164 | if (props_res->status) { | 1164 | if (props_res->status == MEI_HBMS_CLIENT_NOT_FOUND) { |
| 1165 | dev_dbg(dev->dev, "hbm: properties response: %d CLIENT_NOT_FOUND\n", | ||
| 1166 | props_res->me_addr); | ||
| 1167 | } else if (props_res->status) { | ||
| 1165 | dev_err(dev->dev, "hbm: properties response: wrong status = %d %s\n", | 1168 | dev_err(dev->dev, "hbm: properties response: wrong status = %d %s\n", |
| 1166 | props_res->status, | 1169 | props_res->status, |
| 1167 | mei_hbm_status_str(props_res->status)); | 1170 | mei_hbm_status_str(props_res->status)); |
| 1168 | return -EPROTO; | 1171 | return -EPROTO; |
| 1172 | } else { | ||
| 1173 | mei_hbm_me_cl_add(dev, props_res); | ||
| 1169 | } | 1174 | } |
| 1170 | 1175 | ||
| 1171 | mei_hbm_me_cl_add(dev, props_res); | ||
| 1172 | |||
| 1173 | /* request property for the next client */ | 1176 | /* request property for the next client */ |
| 1174 | if (mei_hbm_prop_req(dev, props_res->me_addr + 1)) | 1177 | if (mei_hbm_prop_req(dev, props_res->me_addr + 1)) |
| 1175 | return -EIO; | 1178 | return -EIO; |
diff --git a/drivers/mmc/host/meson-mx-sdio.c b/drivers/mmc/host/meson-mx-sdio.c index 09cb89645d06..2cfec33178c1 100644 --- a/drivers/mmc/host/meson-mx-sdio.c +++ b/drivers/mmc/host/meson-mx-sdio.c | |||
| @@ -517,19 +517,23 @@ static struct mmc_host_ops meson_mx_mmc_ops = { | |||
| 517 | static struct platform_device *meson_mx_mmc_slot_pdev(struct device *parent) | 517 | static struct platform_device *meson_mx_mmc_slot_pdev(struct device *parent) |
| 518 | { | 518 | { |
| 519 | struct device_node *slot_node; | 519 | struct device_node *slot_node; |
| 520 | struct platform_device *pdev; | ||
| 520 | 521 | ||
| 521 | /* | 522 | /* |
| 522 | * TODO: the MMC core framework currently does not support | 523 | * TODO: the MMC core framework currently does not support |
| 523 | * controllers with multiple slots properly. So we only register | 524 | * controllers with multiple slots properly. So we only register |
| 524 | * the first slot for now | 525 | * the first slot for now |
| 525 | */ | 526 | */ |
| 526 | slot_node = of_find_compatible_node(parent->of_node, NULL, "mmc-slot"); | 527 | slot_node = of_get_compatible_child(parent->of_node, "mmc-slot"); |
| 527 | if (!slot_node) { | 528 | if (!slot_node) { |
| 528 | dev_warn(parent, "no 'mmc-slot' sub-node found\n"); | 529 | dev_warn(parent, "no 'mmc-slot' sub-node found\n"); |
| 529 | return ERR_PTR(-ENOENT); | 530 | return ERR_PTR(-ENOENT); |
| 530 | } | 531 | } |
| 531 | 532 | ||
| 532 | return of_platform_device_create(slot_node, NULL, parent); | 533 | pdev = of_platform_device_create(slot_node, NULL, parent); |
| 534 | of_node_put(slot_node); | ||
| 535 | |||
| 536 | return pdev; | ||
| 533 | } | 537 | } |
| 534 | 538 | ||
| 535 | static int meson_mx_mmc_add_host(struct meson_mx_mmc_host *host) | 539 | static int meson_mx_mmc_add_host(struct meson_mx_mmc_host *host) |
diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c index 071693ebfe18..68760d4a5d3d 100644 --- a/drivers/mmc/host/omap_hsmmc.c +++ b/drivers/mmc/host/omap_hsmmc.c | |||
| @@ -2177,6 +2177,7 @@ static int omap_hsmmc_remove(struct platform_device *pdev) | |||
| 2177 | dma_release_channel(host->tx_chan); | 2177 | dma_release_channel(host->tx_chan); |
| 2178 | dma_release_channel(host->rx_chan); | 2178 | dma_release_channel(host->rx_chan); |
| 2179 | 2179 | ||
| 2180 | dev_pm_clear_wake_irq(host->dev); | ||
| 2180 | pm_runtime_dont_use_autosuspend(host->dev); | 2181 | pm_runtime_dont_use_autosuspend(host->dev); |
| 2181 | pm_runtime_put_sync(host->dev); | 2182 | pm_runtime_put_sync(host->dev); |
| 2182 | pm_runtime_disable(host->dev); | 2183 | pm_runtime_disable(host->dev); |
diff --git a/drivers/net/ethernet/amazon/ena/ena_com.c b/drivers/net/ethernet/amazon/ena/ena_com.c index 17f12c18d225..7635c38e77dd 100644 --- a/drivers/net/ethernet/amazon/ena/ena_com.c +++ b/drivers/net/ethernet/amazon/ena/ena_com.c | |||
| @@ -459,12 +459,12 @@ static void ena_com_handle_admin_completion(struct ena_com_admin_queue *admin_qu | |||
| 459 | cqe = &admin_queue->cq.entries[head_masked]; | 459 | cqe = &admin_queue->cq.entries[head_masked]; |
| 460 | 460 | ||
| 461 | /* Go over all the completions */ | 461 | /* Go over all the completions */ |
| 462 | while ((cqe->acq_common_descriptor.flags & | 462 | while ((READ_ONCE(cqe->acq_common_descriptor.flags) & |
| 463 | ENA_ADMIN_ACQ_COMMON_DESC_PHASE_MASK) == phase) { | 463 | ENA_ADMIN_ACQ_COMMON_DESC_PHASE_MASK) == phase) { |
| 464 | /* Do not read the rest of the completion entry before the | 464 | /* Do not read the rest of the completion entry before the |
| 465 | * phase bit was validated | 465 | * phase bit was validated |
| 466 | */ | 466 | */ |
| 467 | rmb(); | 467 | dma_rmb(); |
| 468 | ena_com_handle_single_admin_completion(admin_queue, cqe); | 468 | ena_com_handle_single_admin_completion(admin_queue, cqe); |
| 469 | 469 | ||
| 470 | head_masked++; | 470 | head_masked++; |
| @@ -627,17 +627,10 @@ static u32 ena_com_reg_bar_read32(struct ena_com_dev *ena_dev, u16 offset) | |||
| 627 | mmio_read_reg |= mmio_read->seq_num & | 627 | mmio_read_reg |= mmio_read->seq_num & |
| 628 | ENA_REGS_MMIO_REG_READ_REQ_ID_MASK; | 628 | ENA_REGS_MMIO_REG_READ_REQ_ID_MASK; |
| 629 | 629 | ||
| 630 | /* make sure read_resp->req_id get updated before the hw can write | 630 | writel(mmio_read_reg, ena_dev->reg_bar + ENA_REGS_MMIO_REG_READ_OFF); |
| 631 | * there | ||
| 632 | */ | ||
| 633 | wmb(); | ||
| 634 | |||
| 635 | writel_relaxed(mmio_read_reg, | ||
| 636 | ena_dev->reg_bar + ENA_REGS_MMIO_REG_READ_OFF); | ||
| 637 | 631 | ||
| 638 | mmiowb(); | ||
| 639 | for (i = 0; i < timeout; i++) { | 632 | for (i = 0; i < timeout; i++) { |
| 640 | if (read_resp->req_id == mmio_read->seq_num) | 633 | if (READ_ONCE(read_resp->req_id) == mmio_read->seq_num) |
| 641 | break; | 634 | break; |
| 642 | 635 | ||
| 643 | udelay(1); | 636 | udelay(1); |
| @@ -1796,8 +1789,13 @@ void ena_com_aenq_intr_handler(struct ena_com_dev *dev, void *data) | |||
| 1796 | aenq_common = &aenq_e->aenq_common_desc; | 1789 | aenq_common = &aenq_e->aenq_common_desc; |
| 1797 | 1790 | ||
| 1798 | /* Go over all the events */ | 1791 | /* Go over all the events */ |
| 1799 | while ((aenq_common->flags & ENA_ADMIN_AENQ_COMMON_DESC_PHASE_MASK) == | 1792 | while ((READ_ONCE(aenq_common->flags) & |
| 1800 | phase) { | 1793 | ENA_ADMIN_AENQ_COMMON_DESC_PHASE_MASK) == phase) { |
| 1794 | /* Make sure the phase bit (ownership) is as expected before | ||
| 1795 | * reading the rest of the descriptor. | ||
| 1796 | */ | ||
| 1797 | dma_rmb(); | ||
| 1798 | |||
| 1801 | pr_debug("AENQ! Group[%x] Syndrom[%x] timestamp: [%llus]\n", | 1799 | pr_debug("AENQ! Group[%x] Syndrom[%x] timestamp: [%llus]\n", |
| 1802 | aenq_common->group, aenq_common->syndrom, | 1800 | aenq_common->group, aenq_common->syndrom, |
| 1803 | (u64)aenq_common->timestamp_low + | 1801 | (u64)aenq_common->timestamp_low + |
diff --git a/drivers/net/ethernet/amazon/ena/ena_eth_com.c b/drivers/net/ethernet/amazon/ena/ena_eth_com.c index ea149c134e15..1c682b76190f 100644 --- a/drivers/net/ethernet/amazon/ena/ena_eth_com.c +++ b/drivers/net/ethernet/amazon/ena/ena_eth_com.c | |||
| @@ -51,6 +51,11 @@ static inline struct ena_eth_io_rx_cdesc_base *ena_com_get_next_rx_cdesc( | |||
| 51 | if (desc_phase != expected_phase) | 51 | if (desc_phase != expected_phase) |
| 52 | return NULL; | 52 | return NULL; |
| 53 | 53 | ||
| 54 | /* Make sure we read the rest of the descriptor after the phase bit | ||
| 55 | * has been read | ||
| 56 | */ | ||
| 57 | dma_rmb(); | ||
| 58 | |||
| 54 | return cdesc; | 59 | return cdesc; |
| 55 | } | 60 | } |
| 56 | 61 | ||
| @@ -493,6 +498,7 @@ int ena_com_tx_comp_req_id_get(struct ena_com_io_cq *io_cq, u16 *req_id) | |||
| 493 | if (cdesc_phase != expected_phase) | 498 | if (cdesc_phase != expected_phase) |
| 494 | return -EAGAIN; | 499 | return -EAGAIN; |
| 495 | 500 | ||
| 501 | dma_rmb(); | ||
| 496 | if (unlikely(cdesc->req_id >= io_cq->q_depth)) { | 502 | if (unlikely(cdesc->req_id >= io_cq->q_depth)) { |
| 497 | pr_err("Invalid req id %d\n", cdesc->req_id); | 503 | pr_err("Invalid req id %d\n", cdesc->req_id); |
| 498 | return -EINVAL; | 504 | return -EINVAL; |
diff --git a/drivers/net/ethernet/amazon/ena/ena_eth_com.h b/drivers/net/ethernet/amazon/ena/ena_eth_com.h index 6fdc753d9483..2f7657227cfe 100644 --- a/drivers/net/ethernet/amazon/ena/ena_eth_com.h +++ b/drivers/net/ethernet/amazon/ena/ena_eth_com.h | |||
| @@ -107,8 +107,7 @@ static inline int ena_com_sq_empty_space(struct ena_com_io_sq *io_sq) | |||
| 107 | return io_sq->q_depth - 1 - cnt; | 107 | return io_sq->q_depth - 1 - cnt; |
| 108 | } | 108 | } |
| 109 | 109 | ||
| 110 | static inline int ena_com_write_sq_doorbell(struct ena_com_io_sq *io_sq, | 110 | static inline int ena_com_write_sq_doorbell(struct ena_com_io_sq *io_sq) |
| 111 | bool relaxed) | ||
| 112 | { | 111 | { |
| 113 | u16 tail; | 112 | u16 tail; |
| 114 | 113 | ||
| @@ -117,10 +116,7 @@ static inline int ena_com_write_sq_doorbell(struct ena_com_io_sq *io_sq, | |||
| 117 | pr_debug("write submission queue doorbell for queue: %d tail: %d\n", | 116 | pr_debug("write submission queue doorbell for queue: %d tail: %d\n", |
| 118 | io_sq->qid, tail); | 117 | io_sq->qid, tail); |
| 119 | 118 | ||
| 120 | if (relaxed) | 119 | writel(tail, io_sq->db_addr); |
| 121 | writel_relaxed(tail, io_sq->db_addr); | ||
| 122 | else | ||
| 123 | writel(tail, io_sq->db_addr); | ||
| 124 | 120 | ||
| 125 | return 0; | 121 | return 0; |
| 126 | } | 122 | } |
diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.c b/drivers/net/ethernet/amazon/ena/ena_netdev.c index c673ac2df65b..29b5774dd32d 100644 --- a/drivers/net/ethernet/amazon/ena/ena_netdev.c +++ b/drivers/net/ethernet/amazon/ena/ena_netdev.c | |||
| @@ -76,7 +76,7 @@ MODULE_DEVICE_TABLE(pci, ena_pci_tbl); | |||
| 76 | 76 | ||
| 77 | static int ena_rss_init_default(struct ena_adapter *adapter); | 77 | static int ena_rss_init_default(struct ena_adapter *adapter); |
| 78 | static void check_for_admin_com_state(struct ena_adapter *adapter); | 78 | static void check_for_admin_com_state(struct ena_adapter *adapter); |
| 79 | static void ena_destroy_device(struct ena_adapter *adapter); | 79 | static void ena_destroy_device(struct ena_adapter *adapter, bool graceful); |
| 80 | static int ena_restore_device(struct ena_adapter *adapter); | 80 | static int ena_restore_device(struct ena_adapter *adapter); |
| 81 | 81 | ||
| 82 | static void ena_tx_timeout(struct net_device *dev) | 82 | static void ena_tx_timeout(struct net_device *dev) |
| @@ -461,7 +461,7 @@ static inline int ena_alloc_rx_page(struct ena_ring *rx_ring, | |||
| 461 | return -ENOMEM; | 461 | return -ENOMEM; |
| 462 | } | 462 | } |
| 463 | 463 | ||
| 464 | dma = dma_map_page(rx_ring->dev, page, 0, PAGE_SIZE, | 464 | dma = dma_map_page(rx_ring->dev, page, 0, ENA_PAGE_SIZE, |
| 465 | DMA_FROM_DEVICE); | 465 | DMA_FROM_DEVICE); |
| 466 | if (unlikely(dma_mapping_error(rx_ring->dev, dma))) { | 466 | if (unlikely(dma_mapping_error(rx_ring->dev, dma))) { |
| 467 | u64_stats_update_begin(&rx_ring->syncp); | 467 | u64_stats_update_begin(&rx_ring->syncp); |
| @@ -478,7 +478,7 @@ static inline int ena_alloc_rx_page(struct ena_ring *rx_ring, | |||
| 478 | rx_info->page_offset = 0; | 478 | rx_info->page_offset = 0; |
| 479 | ena_buf = &rx_info->ena_buf; | 479 | ena_buf = &rx_info->ena_buf; |
| 480 | ena_buf->paddr = dma; | 480 | ena_buf->paddr = dma; |
| 481 | ena_buf->len = PAGE_SIZE; | 481 | ena_buf->len = ENA_PAGE_SIZE; |
| 482 | 482 | ||
| 483 | return 0; | 483 | return 0; |
| 484 | } | 484 | } |
| @@ -495,7 +495,7 @@ static void ena_free_rx_page(struct ena_ring *rx_ring, | |||
| 495 | return; | 495 | return; |
| 496 | } | 496 | } |
| 497 | 497 | ||
| 498 | dma_unmap_page(rx_ring->dev, ena_buf->paddr, PAGE_SIZE, | 498 | dma_unmap_page(rx_ring->dev, ena_buf->paddr, ENA_PAGE_SIZE, |
| 499 | DMA_FROM_DEVICE); | 499 | DMA_FROM_DEVICE); |
| 500 | 500 | ||
| 501 | __free_page(page); | 501 | __free_page(page); |
| @@ -551,14 +551,9 @@ static int ena_refill_rx_bufs(struct ena_ring *rx_ring, u32 num) | |||
| 551 | rx_ring->qid, i, num); | 551 | rx_ring->qid, i, num); |
| 552 | } | 552 | } |
| 553 | 553 | ||
| 554 | if (likely(i)) { | 554 | /* ena_com_write_sq_doorbell issues a wmb() */ |
| 555 | /* Add memory barrier to make sure the desc were written before | 555 | if (likely(i)) |
| 556 | * issue a doorbell | 556 | ena_com_write_sq_doorbell(rx_ring->ena_com_io_sq); |
| 557 | */ | ||
| 558 | wmb(); | ||
| 559 | ena_com_write_sq_doorbell(rx_ring->ena_com_io_sq, true); | ||
| 560 | mmiowb(); | ||
| 561 | } | ||
| 562 | 557 | ||
| 563 | rx_ring->next_to_use = next_to_use; | 558 | rx_ring->next_to_use = next_to_use; |
| 564 | 559 | ||
| @@ -916,10 +911,10 @@ static struct sk_buff *ena_rx_skb(struct ena_ring *rx_ring, | |||
| 916 | do { | 911 | do { |
| 917 | dma_unmap_page(rx_ring->dev, | 912 | dma_unmap_page(rx_ring->dev, |
| 918 | dma_unmap_addr(&rx_info->ena_buf, paddr), | 913 | dma_unmap_addr(&rx_info->ena_buf, paddr), |
| 919 | PAGE_SIZE, DMA_FROM_DEVICE); | 914 | ENA_PAGE_SIZE, DMA_FROM_DEVICE); |
| 920 | 915 | ||
| 921 | skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, rx_info->page, | 916 | skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, rx_info->page, |
| 922 | rx_info->page_offset, len, PAGE_SIZE); | 917 | rx_info->page_offset, len, ENA_PAGE_SIZE); |
| 923 | 918 | ||
| 924 | netif_dbg(rx_ring->adapter, rx_status, rx_ring->netdev, | 919 | netif_dbg(rx_ring->adapter, rx_status, rx_ring->netdev, |
| 925 | "rx skb updated. len %d. data_len %d\n", | 920 | "rx skb updated. len %d. data_len %d\n", |
| @@ -1900,7 +1895,7 @@ static int ena_close(struct net_device *netdev) | |||
| 1900 | "Destroy failure, restarting device\n"); | 1895 | "Destroy failure, restarting device\n"); |
| 1901 | ena_dump_stats_to_dmesg(adapter); | 1896 | ena_dump_stats_to_dmesg(adapter); |
| 1902 | /* rtnl lock already obtained in dev_ioctl() layer */ | 1897 | /* rtnl lock already obtained in dev_ioctl() layer */ |
| 1903 | ena_destroy_device(adapter); | 1898 | ena_destroy_device(adapter, false); |
| 1904 | ena_restore_device(adapter); | 1899 | ena_restore_device(adapter); |
| 1905 | } | 1900 | } |
| 1906 | 1901 | ||
| @@ -2112,12 +2107,6 @@ static netdev_tx_t ena_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
| 2112 | tx_ring->next_to_use = ENA_TX_RING_IDX_NEXT(next_to_use, | 2107 | tx_ring->next_to_use = ENA_TX_RING_IDX_NEXT(next_to_use, |
| 2113 | tx_ring->ring_size); | 2108 | tx_ring->ring_size); |
| 2114 | 2109 | ||
| 2115 | /* This WMB is aimed to: | ||
| 2116 | * 1 - perform smp barrier before reading next_to_completion | ||
| 2117 | * 2 - make sure the desc were written before trigger DB | ||
| 2118 | */ | ||
| 2119 | wmb(); | ||
| 2120 | |||
| 2121 | /* stop the queue when no more space available, the packet can have up | 2110 | /* stop the queue when no more space available, the packet can have up |
| 2122 | * to sgl_size + 2. one for the meta descriptor and one for header | 2111 | * to sgl_size + 2. one for the meta descriptor and one for header |
| 2123 | * (if the header is larger than tx_max_header_size). | 2112 | * (if the header is larger than tx_max_header_size). |
| @@ -2136,10 +2125,11 @@ static netdev_tx_t ena_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
| 2136 | * stop the queue but meanwhile clean_tx_irq updates | 2125 | * stop the queue but meanwhile clean_tx_irq updates |
| 2137 | * next_to_completion and terminates. | 2126 | * next_to_completion and terminates. |
| 2138 | * The queue will remain stopped forever. | 2127 | * The queue will remain stopped forever. |
| 2139 | * To solve this issue this function perform rmb, check | 2128 | * To solve this issue add a mb() to make sure that |
| 2140 | * the wakeup condition and wake up the queue if needed. | 2129 | * netif_tx_stop_queue() write is vissible before checking if |
| 2130 | * there is additional space in the queue. | ||
| 2141 | */ | 2131 | */ |
| 2142 | smp_rmb(); | 2132 | smp_mb(); |
| 2143 | 2133 | ||
| 2144 | if (ena_com_sq_empty_space(tx_ring->ena_com_io_sq) | 2134 | if (ena_com_sq_empty_space(tx_ring->ena_com_io_sq) |
| 2145 | > ENA_TX_WAKEUP_THRESH) { | 2135 | > ENA_TX_WAKEUP_THRESH) { |
| @@ -2151,8 +2141,10 @@ static netdev_tx_t ena_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
| 2151 | } | 2141 | } |
| 2152 | 2142 | ||
| 2153 | if (netif_xmit_stopped(txq) || !skb->xmit_more) { | 2143 | if (netif_xmit_stopped(txq) || !skb->xmit_more) { |
| 2154 | /* trigger the dma engine */ | 2144 | /* trigger the dma engine. ena_com_write_sq_doorbell() |
| 2155 | ena_com_write_sq_doorbell(tx_ring->ena_com_io_sq, false); | 2145 | * has a mb |
| 2146 | */ | ||
| 2147 | ena_com_write_sq_doorbell(tx_ring->ena_com_io_sq); | ||
| 2156 | u64_stats_update_begin(&tx_ring->syncp); | 2148 | u64_stats_update_begin(&tx_ring->syncp); |
| 2157 | tx_ring->tx_stats.doorbells++; | 2149 | tx_ring->tx_stats.doorbells++; |
| 2158 | u64_stats_update_end(&tx_ring->syncp); | 2150 | u64_stats_update_end(&tx_ring->syncp); |
| @@ -2550,12 +2542,15 @@ err_disable_msix: | |||
| 2550 | return rc; | 2542 | return rc; |
| 2551 | } | 2543 | } |
| 2552 | 2544 | ||
| 2553 | static void ena_destroy_device(struct ena_adapter *adapter) | 2545 | static void ena_destroy_device(struct ena_adapter *adapter, bool graceful) |
| 2554 | { | 2546 | { |
| 2555 | struct net_device *netdev = adapter->netdev; | 2547 | struct net_device *netdev = adapter->netdev; |
| 2556 | struct ena_com_dev *ena_dev = adapter->ena_dev; | 2548 | struct ena_com_dev *ena_dev = adapter->ena_dev; |
| 2557 | bool dev_up; | 2549 | bool dev_up; |
| 2558 | 2550 | ||
| 2551 | if (!test_bit(ENA_FLAG_DEVICE_RUNNING, &adapter->flags)) | ||
| 2552 | return; | ||
| 2553 | |||
| 2559 | netif_carrier_off(netdev); | 2554 | netif_carrier_off(netdev); |
| 2560 | 2555 | ||
| 2561 | del_timer_sync(&adapter->timer_service); | 2556 | del_timer_sync(&adapter->timer_service); |
| @@ -2563,7 +2558,8 @@ static void ena_destroy_device(struct ena_adapter *adapter) | |||
| 2563 | dev_up = test_bit(ENA_FLAG_DEV_UP, &adapter->flags); | 2558 | dev_up = test_bit(ENA_FLAG_DEV_UP, &adapter->flags); |
| 2564 | adapter->dev_up_before_reset = dev_up; | 2559 | adapter->dev_up_before_reset = dev_up; |
| 2565 | 2560 | ||
| 2566 | ena_com_set_admin_running_state(ena_dev, false); | 2561 | if (!graceful) |
| 2562 | ena_com_set_admin_running_state(ena_dev, false); | ||
| 2567 | 2563 | ||
| 2568 | if (test_bit(ENA_FLAG_DEV_UP, &adapter->flags)) | 2564 | if (test_bit(ENA_FLAG_DEV_UP, &adapter->flags)) |
| 2569 | ena_down(adapter); | 2565 | ena_down(adapter); |
| @@ -2591,6 +2587,7 @@ static void ena_destroy_device(struct ena_adapter *adapter) | |||
| 2591 | adapter->reset_reason = ENA_REGS_RESET_NORMAL; | 2587 | adapter->reset_reason = ENA_REGS_RESET_NORMAL; |
| 2592 | 2588 | ||
| 2593 | clear_bit(ENA_FLAG_TRIGGER_RESET, &adapter->flags); | 2589 | clear_bit(ENA_FLAG_TRIGGER_RESET, &adapter->flags); |
| 2590 | clear_bit(ENA_FLAG_DEVICE_RUNNING, &adapter->flags); | ||
| 2594 | } | 2591 | } |
| 2595 | 2592 | ||
| 2596 | static int ena_restore_device(struct ena_adapter *adapter) | 2593 | static int ena_restore_device(struct ena_adapter *adapter) |
| @@ -2635,6 +2632,7 @@ static int ena_restore_device(struct ena_adapter *adapter) | |||
| 2635 | } | 2632 | } |
| 2636 | } | 2633 | } |
| 2637 | 2634 | ||
| 2635 | set_bit(ENA_FLAG_DEVICE_RUNNING, &adapter->flags); | ||
| 2638 | mod_timer(&adapter->timer_service, round_jiffies(jiffies + HZ)); | 2636 | mod_timer(&adapter->timer_service, round_jiffies(jiffies + HZ)); |
| 2639 | dev_err(&pdev->dev, "Device reset completed successfully\n"); | 2637 | dev_err(&pdev->dev, "Device reset completed successfully\n"); |
| 2640 | 2638 | ||
| @@ -2665,7 +2663,7 @@ static void ena_fw_reset_device(struct work_struct *work) | |||
| 2665 | return; | 2663 | return; |
| 2666 | } | 2664 | } |
| 2667 | rtnl_lock(); | 2665 | rtnl_lock(); |
| 2668 | ena_destroy_device(adapter); | 2666 | ena_destroy_device(adapter, false); |
| 2669 | ena_restore_device(adapter); | 2667 | ena_restore_device(adapter); |
| 2670 | rtnl_unlock(); | 2668 | rtnl_unlock(); |
| 2671 | } | 2669 | } |
| @@ -3409,30 +3407,24 @@ static void ena_remove(struct pci_dev *pdev) | |||
| 3409 | netdev->rx_cpu_rmap = NULL; | 3407 | netdev->rx_cpu_rmap = NULL; |
| 3410 | } | 3408 | } |
| 3411 | #endif /* CONFIG_RFS_ACCEL */ | 3409 | #endif /* CONFIG_RFS_ACCEL */ |
| 3412 | |||
| 3413 | unregister_netdev(netdev); | ||
| 3414 | del_timer_sync(&adapter->timer_service); | 3410 | del_timer_sync(&adapter->timer_service); |
| 3415 | 3411 | ||
| 3416 | cancel_work_sync(&adapter->reset_task); | 3412 | cancel_work_sync(&adapter->reset_task); |
| 3417 | 3413 | ||
| 3418 | /* Reset the device only if the device is running. */ | 3414 | unregister_netdev(netdev); |
| 3419 | if (test_bit(ENA_FLAG_DEVICE_RUNNING, &adapter->flags)) | ||
| 3420 | ena_com_dev_reset(ena_dev, adapter->reset_reason); | ||
| 3421 | 3415 | ||
| 3422 | ena_free_mgmnt_irq(adapter); | 3416 | /* If the device is running then we want to make sure the device will be |
| 3417 | * reset to make sure no more events will be issued by the device. | ||
| 3418 | */ | ||
| 3419 | if (test_bit(ENA_FLAG_DEVICE_RUNNING, &adapter->flags)) | ||
| 3420 | set_bit(ENA_FLAG_TRIGGER_RESET, &adapter->flags); | ||
| 3423 | 3421 | ||
| 3424 | ena_disable_msix(adapter); | 3422 | rtnl_lock(); |
| 3423 | ena_destroy_device(adapter, true); | ||
| 3424 | rtnl_unlock(); | ||
| 3425 | 3425 | ||
| 3426 | free_netdev(netdev); | 3426 | free_netdev(netdev); |
| 3427 | 3427 | ||
| 3428 | ena_com_mmio_reg_read_request_destroy(ena_dev); | ||
| 3429 | |||
| 3430 | ena_com_abort_admin_commands(ena_dev); | ||
| 3431 | |||
| 3432 | ena_com_wait_for_abort_completion(ena_dev); | ||
| 3433 | |||
| 3434 | ena_com_admin_destroy(ena_dev); | ||
| 3435 | |||
| 3436 | ena_com_rss_destroy(ena_dev); | 3428 | ena_com_rss_destroy(ena_dev); |
| 3437 | 3429 | ||
| 3438 | ena_com_delete_debug_area(ena_dev); | 3430 | ena_com_delete_debug_area(ena_dev); |
| @@ -3467,7 +3459,7 @@ static int ena_suspend(struct pci_dev *pdev, pm_message_t state) | |||
| 3467 | "ignoring device reset request as the device is being suspended\n"); | 3459 | "ignoring device reset request as the device is being suspended\n"); |
| 3468 | clear_bit(ENA_FLAG_TRIGGER_RESET, &adapter->flags); | 3460 | clear_bit(ENA_FLAG_TRIGGER_RESET, &adapter->flags); |
| 3469 | } | 3461 | } |
| 3470 | ena_destroy_device(adapter); | 3462 | ena_destroy_device(adapter, true); |
| 3471 | rtnl_unlock(); | 3463 | rtnl_unlock(); |
| 3472 | return 0; | 3464 | return 0; |
| 3473 | } | 3465 | } |
diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.h b/drivers/net/ethernet/amazon/ena/ena_netdev.h index f1972b5ab650..7c7ae56c52cf 100644 --- a/drivers/net/ethernet/amazon/ena/ena_netdev.h +++ b/drivers/net/ethernet/amazon/ena/ena_netdev.h | |||
| @@ -355,4 +355,15 @@ void ena_dump_stats_to_buf(struct ena_adapter *adapter, u8 *buf); | |||
| 355 | 355 | ||
| 356 | int ena_get_sset_count(struct net_device *netdev, int sset); | 356 | int ena_get_sset_count(struct net_device *netdev, int sset); |
| 357 | 357 | ||
| 358 | /* The ENA buffer length fields is 16 bit long. So when PAGE_SIZE == 64kB the | ||
| 359 | * driver passas 0. | ||
| 360 | * Since the max packet size the ENA handles is ~9kB limit the buffer length to | ||
| 361 | * 16kB. | ||
| 362 | */ | ||
| 363 | #if PAGE_SIZE > SZ_16K | ||
| 364 | #define ENA_PAGE_SIZE SZ_16K | ||
| 365 | #else | ||
| 366 | #define ENA_PAGE_SIZE PAGE_SIZE | ||
| 367 | #endif | ||
| 368 | |||
| 358 | #endif /* !(ENA_H) */ | 369 | #endif /* !(ENA_H) */ |
diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c b/drivers/net/ethernet/emulex/benet/be_cmds.c index ff92ab1daeb8..1e9d882c04ef 100644 --- a/drivers/net/ethernet/emulex/benet/be_cmds.c +++ b/drivers/net/ethernet/emulex/benet/be_cmds.c | |||
| @@ -4500,7 +4500,7 @@ int be_cmd_get_profile_config(struct be_adapter *adapter, | |||
| 4500 | port_res->max_vfs += le16_to_cpu(pcie->num_vfs); | 4500 | port_res->max_vfs += le16_to_cpu(pcie->num_vfs); |
| 4501 | } | 4501 | } |
| 4502 | } | 4502 | } |
| 4503 | return status; | 4503 | goto err; |
| 4504 | } | 4504 | } |
| 4505 | 4505 | ||
| 4506 | pcie = be_get_pcie_desc(resp->func_param, desc_count, | 4506 | pcie = be_get_pcie_desc(resp->func_param, desc_count, |
diff --git a/drivers/net/ethernet/lantiq_etop.c b/drivers/net/ethernet/lantiq_etop.c index 7a637b51c7d2..e08301d833e2 100644 --- a/drivers/net/ethernet/lantiq_etop.c +++ b/drivers/net/ethernet/lantiq_etop.c | |||
| @@ -274,6 +274,7 @@ ltq_etop_hw_init(struct net_device *dev) | |||
| 274 | struct ltq_etop_chan *ch = &priv->ch[i]; | 274 | struct ltq_etop_chan *ch = &priv->ch[i]; |
| 275 | 275 | ||
| 276 | ch->idx = ch->dma.nr = i; | 276 | ch->idx = ch->dma.nr = i; |
| 277 | ch->dma.dev = &priv->pdev->dev; | ||
| 277 | 278 | ||
| 278 | if (IS_TX(i)) { | 279 | if (IS_TX(i)) { |
| 279 | ltq_dma_alloc_tx(&ch->dma); | 280 | ltq_dma_alloc_tx(&ch->dma); |
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/dev.c b/drivers/net/ethernet/mellanox/mlx5/core/dev.c index b994b80d5714..37ba7c78859d 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/dev.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/dev.c | |||
| @@ -132,11 +132,11 @@ void mlx5_add_device(struct mlx5_interface *intf, struct mlx5_priv *priv) | |||
| 132 | delayed_event_start(priv); | 132 | delayed_event_start(priv); |
| 133 | 133 | ||
| 134 | dev_ctx->context = intf->add(dev); | 134 | dev_ctx->context = intf->add(dev); |
| 135 | set_bit(MLX5_INTERFACE_ADDED, &dev_ctx->state); | ||
| 136 | if (intf->attach) | ||
| 137 | set_bit(MLX5_INTERFACE_ATTACHED, &dev_ctx->state); | ||
| 138 | |||
| 139 | if (dev_ctx->context) { | 135 | if (dev_ctx->context) { |
| 136 | set_bit(MLX5_INTERFACE_ADDED, &dev_ctx->state); | ||
| 137 | if (intf->attach) | ||
| 138 | set_bit(MLX5_INTERFACE_ATTACHED, &dev_ctx->state); | ||
| 139 | |||
| 140 | spin_lock_irq(&priv->ctx_lock); | 140 | spin_lock_irq(&priv->ctx_lock); |
| 141 | list_add_tail(&dev_ctx->list, &priv->ctx_list); | 141 | list_add_tail(&dev_ctx->list, &priv->ctx_list); |
| 142 | 142 | ||
| @@ -211,12 +211,17 @@ static void mlx5_attach_interface(struct mlx5_interface *intf, struct mlx5_priv | |||
| 211 | if (intf->attach) { | 211 | if (intf->attach) { |
| 212 | if (test_bit(MLX5_INTERFACE_ATTACHED, &dev_ctx->state)) | 212 | if (test_bit(MLX5_INTERFACE_ATTACHED, &dev_ctx->state)) |
| 213 | goto out; | 213 | goto out; |
| 214 | intf->attach(dev, dev_ctx->context); | 214 | if (intf->attach(dev, dev_ctx->context)) |
| 215 | goto out; | ||
| 216 | |||
| 215 | set_bit(MLX5_INTERFACE_ATTACHED, &dev_ctx->state); | 217 | set_bit(MLX5_INTERFACE_ATTACHED, &dev_ctx->state); |
| 216 | } else { | 218 | } else { |
| 217 | if (test_bit(MLX5_INTERFACE_ADDED, &dev_ctx->state)) | 219 | if (test_bit(MLX5_INTERFACE_ADDED, &dev_ctx->state)) |
| 218 | goto out; | 220 | goto out; |
| 219 | dev_ctx->context = intf->add(dev); | 221 | dev_ctx->context = intf->add(dev); |
| 222 | if (!dev_ctx->context) | ||
| 223 | goto out; | ||
| 224 | |||
| 220 | set_bit(MLX5_INTERFACE_ADDED, &dev_ctx->state); | 225 | set_bit(MLX5_INTERFACE_ADDED, &dev_ctx->state); |
| 221 | } | 226 | } |
| 222 | 227 | ||
| @@ -391,16 +396,17 @@ void mlx5_remove_dev_by_protocol(struct mlx5_core_dev *dev, int protocol) | |||
| 391 | } | 396 | } |
| 392 | } | 397 | } |
| 393 | 398 | ||
| 394 | static u16 mlx5_gen_pci_id(struct mlx5_core_dev *dev) | 399 | static u32 mlx5_gen_pci_id(struct mlx5_core_dev *dev) |
| 395 | { | 400 | { |
| 396 | return (u16)((dev->pdev->bus->number << 8) | | 401 | return (u32)((pci_domain_nr(dev->pdev->bus) << 16) | |
| 402 | (dev->pdev->bus->number << 8) | | ||
| 397 | PCI_SLOT(dev->pdev->devfn)); | 403 | PCI_SLOT(dev->pdev->devfn)); |
| 398 | } | 404 | } |
| 399 | 405 | ||
| 400 | /* Must be called with intf_mutex held */ | 406 | /* Must be called with intf_mutex held */ |
| 401 | struct mlx5_core_dev *mlx5_get_next_phys_dev(struct mlx5_core_dev *dev) | 407 | struct mlx5_core_dev *mlx5_get_next_phys_dev(struct mlx5_core_dev *dev) |
| 402 | { | 408 | { |
| 403 | u16 pci_id = mlx5_gen_pci_id(dev); | 409 | u32 pci_id = mlx5_gen_pci_id(dev); |
| 404 | struct mlx5_core_dev *res = NULL; | 410 | struct mlx5_core_dev *res = NULL; |
| 405 | struct mlx5_core_dev *tmp_dev; | 411 | struct mlx5_core_dev *tmp_dev; |
| 406 | struct mlx5_priv *priv; | 412 | struct mlx5_priv *priv; |
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_fs_ethtool.c b/drivers/net/ethernet/mellanox/mlx5/core/en_fs_ethtool.c index 75bb981e00b7..41cde926cdab 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_fs_ethtool.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_fs_ethtool.c | |||
| @@ -191,7 +191,7 @@ set_udp(void *headers_c, void *headers_v, __be16 psrc_m, __be16 psrc_v, | |||
| 191 | { | 191 | { |
| 192 | if (psrc_m) { | 192 | if (psrc_m) { |
| 193 | MLX5E_FTE_SET(headers_c, udp_sport, 0xffff); | 193 | MLX5E_FTE_SET(headers_c, udp_sport, 0xffff); |
| 194 | MLX5E_FTE_SET(headers_c, udp_sport, ntohs(psrc_v)); | 194 | MLX5E_FTE_SET(headers_v, udp_sport, ntohs(psrc_v)); |
| 195 | } | 195 | } |
| 196 | 196 | ||
| 197 | if (pdst_m) { | 197 | if (pdst_m) { |
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c index f72b5c9dcfe9..3028e8d90920 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c | |||
| @@ -663,6 +663,7 @@ static int esw_create_offloads_fdb_tables(struct mlx5_eswitch *esw, int nvports) | |||
| 663 | if (err) | 663 | if (err) |
| 664 | goto miss_rule_err; | 664 | goto miss_rule_err; |
| 665 | 665 | ||
| 666 | kvfree(flow_group_in); | ||
| 666 | return 0; | 667 | return 0; |
| 667 | 668 | ||
| 668 | miss_rule_err: | 669 | miss_rule_err: |
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c index f418541af7cf..37d114c668b7 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c | |||
| @@ -1578,6 +1578,33 @@ static u64 matched_fgs_get_version(struct list_head *match_head) | |||
| 1578 | return version; | 1578 | return version; |
| 1579 | } | 1579 | } |
| 1580 | 1580 | ||
| 1581 | static struct fs_fte * | ||
| 1582 | lookup_fte_locked(struct mlx5_flow_group *g, | ||
| 1583 | u32 *match_value, | ||
| 1584 | bool take_write) | ||
| 1585 | { | ||
| 1586 | struct fs_fte *fte_tmp; | ||
| 1587 | |||
| 1588 | if (take_write) | ||
| 1589 | nested_down_write_ref_node(&g->node, FS_LOCK_PARENT); | ||
| 1590 | else | ||
| 1591 | nested_down_read_ref_node(&g->node, FS_LOCK_PARENT); | ||
| 1592 | fte_tmp = rhashtable_lookup_fast(&g->ftes_hash, match_value, | ||
| 1593 | rhash_fte); | ||
| 1594 | if (!fte_tmp || !tree_get_node(&fte_tmp->node)) { | ||
| 1595 | fte_tmp = NULL; | ||
| 1596 | goto out; | ||
| 1597 | } | ||
| 1598 | |||
| 1599 | nested_down_write_ref_node(&fte_tmp->node, FS_LOCK_CHILD); | ||
| 1600 | out: | ||
| 1601 | if (take_write) | ||
| 1602 | up_write_ref_node(&g->node); | ||
| 1603 | else | ||
| 1604 | up_read_ref_node(&g->node); | ||
| 1605 | return fte_tmp; | ||
| 1606 | } | ||
| 1607 | |||
| 1581 | static struct mlx5_flow_handle * | 1608 | static struct mlx5_flow_handle * |
| 1582 | try_add_to_existing_fg(struct mlx5_flow_table *ft, | 1609 | try_add_to_existing_fg(struct mlx5_flow_table *ft, |
| 1583 | struct list_head *match_head, | 1610 | struct list_head *match_head, |
| @@ -1600,10 +1627,6 @@ try_add_to_existing_fg(struct mlx5_flow_table *ft, | |||
| 1600 | if (IS_ERR(fte)) | 1627 | if (IS_ERR(fte)) |
| 1601 | return ERR_PTR(-ENOMEM); | 1628 | return ERR_PTR(-ENOMEM); |
| 1602 | 1629 | ||
| 1603 | list_for_each_entry(iter, match_head, list) { | ||
| 1604 | nested_down_read_ref_node(&iter->g->node, FS_LOCK_PARENT); | ||
| 1605 | } | ||
| 1606 | |||
| 1607 | search_again_locked: | 1630 | search_again_locked: |
| 1608 | version = matched_fgs_get_version(match_head); | 1631 | version = matched_fgs_get_version(match_head); |
| 1609 | /* Try to find a fg that already contains a matching fte */ | 1632 | /* Try to find a fg that already contains a matching fte */ |
| @@ -1611,20 +1634,9 @@ search_again_locked: | |||
| 1611 | struct fs_fte *fte_tmp; | 1634 | struct fs_fte *fte_tmp; |
| 1612 | 1635 | ||
| 1613 | g = iter->g; | 1636 | g = iter->g; |
| 1614 | fte_tmp = rhashtable_lookup_fast(&g->ftes_hash, spec->match_value, | 1637 | fte_tmp = lookup_fte_locked(g, spec->match_value, take_write); |
| 1615 | rhash_fte); | 1638 | if (!fte_tmp) |
| 1616 | if (!fte_tmp || !tree_get_node(&fte_tmp->node)) | ||
| 1617 | continue; | 1639 | continue; |
| 1618 | |||
| 1619 | nested_down_write_ref_node(&fte_tmp->node, FS_LOCK_CHILD); | ||
| 1620 | if (!take_write) { | ||
| 1621 | list_for_each_entry(iter, match_head, list) | ||
| 1622 | up_read_ref_node(&iter->g->node); | ||
| 1623 | } else { | ||
| 1624 | list_for_each_entry(iter, match_head, list) | ||
| 1625 | up_write_ref_node(&iter->g->node); | ||
| 1626 | } | ||
| 1627 | |||
| 1628 | rule = add_rule_fg(g, spec->match_value, | 1640 | rule = add_rule_fg(g, spec->match_value, |
| 1629 | flow_act, dest, dest_num, fte_tmp); | 1641 | flow_act, dest, dest_num, fte_tmp); |
| 1630 | up_write_ref_node(&fte_tmp->node); | 1642 | up_write_ref_node(&fte_tmp->node); |
| @@ -1633,19 +1645,6 @@ search_again_locked: | |||
| 1633 | return rule; | 1645 | return rule; |
| 1634 | } | 1646 | } |
| 1635 | 1647 | ||
| 1636 | /* No group with matching fte found. Try to add a new fte to any | ||
| 1637 | * matching fg. | ||
| 1638 | */ | ||
| 1639 | |||
| 1640 | if (!take_write) { | ||
| 1641 | list_for_each_entry(iter, match_head, list) | ||
| 1642 | up_read_ref_node(&iter->g->node); | ||
| 1643 | list_for_each_entry(iter, match_head, list) | ||
| 1644 | nested_down_write_ref_node(&iter->g->node, | ||
| 1645 | FS_LOCK_PARENT); | ||
| 1646 | take_write = true; | ||
| 1647 | } | ||
| 1648 | |||
| 1649 | /* Check the ft version, for case that new flow group | 1648 | /* Check the ft version, for case that new flow group |
| 1650 | * was added while the fgs weren't locked | 1649 | * was added while the fgs weren't locked |
| 1651 | */ | 1650 | */ |
| @@ -1657,27 +1656,30 @@ search_again_locked: | |||
| 1657 | /* Check the fgs version, for case the new FTE with the | 1656 | /* Check the fgs version, for case the new FTE with the |
| 1658 | * same values was added while the fgs weren't locked | 1657 | * same values was added while the fgs weren't locked |
| 1659 | */ | 1658 | */ |
| 1660 | if (version != matched_fgs_get_version(match_head)) | 1659 | if (version != matched_fgs_get_version(match_head)) { |
| 1660 | take_write = true; | ||
| 1661 | goto search_again_locked; | 1661 | goto search_again_locked; |
| 1662 | } | ||
| 1662 | 1663 | ||
| 1663 | list_for_each_entry(iter, match_head, list) { | 1664 | list_for_each_entry(iter, match_head, list) { |
| 1664 | g = iter->g; | 1665 | g = iter->g; |
| 1665 | 1666 | ||
| 1666 | if (!g->node.active) | 1667 | if (!g->node.active) |
| 1667 | continue; | 1668 | continue; |
| 1669 | |||
| 1670 | nested_down_write_ref_node(&g->node, FS_LOCK_PARENT); | ||
| 1671 | |||
| 1668 | err = insert_fte(g, fte); | 1672 | err = insert_fte(g, fte); |
| 1669 | if (err) { | 1673 | if (err) { |
| 1674 | up_write_ref_node(&g->node); | ||
| 1670 | if (err == -ENOSPC) | 1675 | if (err == -ENOSPC) |
| 1671 | continue; | 1676 | continue; |
| 1672 | list_for_each_entry(iter, match_head, list) | ||
| 1673 | up_write_ref_node(&iter->g->node); | ||
| 1674 | kmem_cache_free(steering->ftes_cache, fte); | 1677 | kmem_cache_free(steering->ftes_cache, fte); |
| 1675 | return ERR_PTR(err); | 1678 | return ERR_PTR(err); |
| 1676 | } | 1679 | } |
| 1677 | 1680 | ||
| 1678 | nested_down_write_ref_node(&fte->node, FS_LOCK_CHILD); | 1681 | nested_down_write_ref_node(&fte->node, FS_LOCK_CHILD); |
| 1679 | list_for_each_entry(iter, match_head, list) | 1682 | up_write_ref_node(&g->node); |
| 1680 | up_write_ref_node(&iter->g->node); | ||
| 1681 | rule = add_rule_fg(g, spec->match_value, | 1683 | rule = add_rule_fg(g, spec->match_value, |
| 1682 | flow_act, dest, dest_num, fte); | 1684 | flow_act, dest, dest_num, fte); |
| 1683 | up_write_ref_node(&fte->node); | 1685 | up_write_ref_node(&fte->node); |
| @@ -1686,8 +1688,6 @@ search_again_locked: | |||
| 1686 | } | 1688 | } |
| 1687 | rule = ERR_PTR(-ENOENT); | 1689 | rule = ERR_PTR(-ENOENT); |
| 1688 | out: | 1690 | out: |
| 1689 | list_for_each_entry(iter, match_head, list) | ||
| 1690 | up_write_ref_node(&iter->g->node); | ||
| 1691 | kmem_cache_free(steering->ftes_cache, fte); | 1691 | kmem_cache_free(steering->ftes_cache, fte); |
| 1692 | return rule; | 1692 | return rule; |
| 1693 | } | 1693 | } |
| @@ -1726,6 +1726,8 @@ search_again_locked: | |||
| 1726 | if (err) { | 1726 | if (err) { |
| 1727 | if (take_write) | 1727 | if (take_write) |
| 1728 | up_write_ref_node(&ft->node); | 1728 | up_write_ref_node(&ft->node); |
| 1729 | else | ||
| 1730 | up_read_ref_node(&ft->node); | ||
| 1729 | return ERR_PTR(err); | 1731 | return ERR_PTR(err); |
| 1730 | } | 1732 | } |
| 1731 | 1733 | ||
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/health.c b/drivers/net/ethernet/mellanox/mlx5/core/health.c index d39b0b7011b2..9f39aeca863f 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/health.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/health.c | |||
| @@ -331,9 +331,17 @@ void mlx5_start_health_poll(struct mlx5_core_dev *dev) | |||
| 331 | add_timer(&health->timer); | 331 | add_timer(&health->timer); |
| 332 | } | 332 | } |
| 333 | 333 | ||
| 334 | void mlx5_stop_health_poll(struct mlx5_core_dev *dev) | 334 | void mlx5_stop_health_poll(struct mlx5_core_dev *dev, bool disable_health) |
| 335 | { | 335 | { |
| 336 | struct mlx5_core_health *health = &dev->priv.health; | 336 | struct mlx5_core_health *health = &dev->priv.health; |
| 337 | unsigned long flags; | ||
| 338 | |||
| 339 | if (disable_health) { | ||
| 340 | spin_lock_irqsave(&health->wq_lock, flags); | ||
| 341 | set_bit(MLX5_DROP_NEW_HEALTH_WORK, &health->flags); | ||
| 342 | set_bit(MLX5_DROP_NEW_RECOVERY_WORK, &health->flags); | ||
| 343 | spin_unlock_irqrestore(&health->wq_lock, flags); | ||
| 344 | } | ||
| 337 | 345 | ||
| 338 | del_timer_sync(&health->timer); | 346 | del_timer_sync(&health->timer); |
| 339 | } | 347 | } |
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c b/drivers/net/ethernet/mellanox/mlx5/core/main.c index cf3e4a659052..b5e9f664fc66 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c | |||
| @@ -878,8 +878,10 @@ static int mlx5_pci_init(struct mlx5_core_dev *dev, struct mlx5_priv *priv) | |||
| 878 | priv->numa_node = dev_to_node(&dev->pdev->dev); | 878 | priv->numa_node = dev_to_node(&dev->pdev->dev); |
| 879 | 879 | ||
| 880 | priv->dbg_root = debugfs_create_dir(dev_name(&pdev->dev), mlx5_debugfs_root); | 880 | priv->dbg_root = debugfs_create_dir(dev_name(&pdev->dev), mlx5_debugfs_root); |
| 881 | if (!priv->dbg_root) | 881 | if (!priv->dbg_root) { |
| 882 | dev_err(&pdev->dev, "Cannot create debugfs dir, aborting\n"); | ||
| 882 | return -ENOMEM; | 883 | return -ENOMEM; |
| 884 | } | ||
| 883 | 885 | ||
| 884 | err = mlx5_pci_enable_device(dev); | 886 | err = mlx5_pci_enable_device(dev); |
| 885 | if (err) { | 887 | if (err) { |
| @@ -928,7 +930,7 @@ static void mlx5_pci_close(struct mlx5_core_dev *dev, struct mlx5_priv *priv) | |||
| 928 | pci_clear_master(dev->pdev); | 930 | pci_clear_master(dev->pdev); |
| 929 | release_bar(dev->pdev); | 931 | release_bar(dev->pdev); |
| 930 | mlx5_pci_disable_device(dev); | 932 | mlx5_pci_disable_device(dev); |
| 931 | debugfs_remove(priv->dbg_root); | 933 | debugfs_remove_recursive(priv->dbg_root); |
| 932 | } | 934 | } |
| 933 | 935 | ||
| 934 | static int mlx5_init_once(struct mlx5_core_dev *dev, struct mlx5_priv *priv) | 936 | static int mlx5_init_once(struct mlx5_core_dev *dev, struct mlx5_priv *priv) |
| @@ -1286,7 +1288,7 @@ err_cleanup_once: | |||
| 1286 | mlx5_cleanup_once(dev); | 1288 | mlx5_cleanup_once(dev); |
| 1287 | 1289 | ||
| 1288 | err_stop_poll: | 1290 | err_stop_poll: |
| 1289 | mlx5_stop_health_poll(dev); | 1291 | mlx5_stop_health_poll(dev, boot); |
| 1290 | if (mlx5_cmd_teardown_hca(dev)) { | 1292 | if (mlx5_cmd_teardown_hca(dev)) { |
| 1291 | dev_err(&dev->pdev->dev, "tear_down_hca failed, skip cleanup\n"); | 1293 | dev_err(&dev->pdev->dev, "tear_down_hca failed, skip cleanup\n"); |
| 1292 | goto out_err; | 1294 | goto out_err; |
| @@ -1346,7 +1348,7 @@ static int mlx5_unload_one(struct mlx5_core_dev *dev, struct mlx5_priv *priv, | |||
| 1346 | mlx5_free_irq_vectors(dev); | 1348 | mlx5_free_irq_vectors(dev); |
| 1347 | if (cleanup) | 1349 | if (cleanup) |
| 1348 | mlx5_cleanup_once(dev); | 1350 | mlx5_cleanup_once(dev); |
| 1349 | mlx5_stop_health_poll(dev); | 1351 | mlx5_stop_health_poll(dev, cleanup); |
| 1350 | err = mlx5_cmd_teardown_hca(dev); | 1352 | err = mlx5_cmd_teardown_hca(dev); |
| 1351 | if (err) { | 1353 | if (err) { |
| 1352 | dev_err(&dev->pdev->dev, "tear_down_hca failed, skip cleanup\n"); | 1354 | dev_err(&dev->pdev->dev, "tear_down_hca failed, skip cleanup\n"); |
| @@ -1608,7 +1610,7 @@ static int mlx5_try_fast_unload(struct mlx5_core_dev *dev) | |||
| 1608 | * with the HCA, so the health polll is no longer needed. | 1610 | * with the HCA, so the health polll is no longer needed. |
| 1609 | */ | 1611 | */ |
| 1610 | mlx5_drain_health_wq(dev); | 1612 | mlx5_drain_health_wq(dev); |
| 1611 | mlx5_stop_health_poll(dev); | 1613 | mlx5_stop_health_poll(dev, false); |
| 1612 | 1614 | ||
| 1613 | ret = mlx5_cmd_force_teardown_hca(dev); | 1615 | ret = mlx5_cmd_force_teardown_hca(dev); |
| 1614 | if (ret) { | 1616 | if (ret) { |
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/wq.c b/drivers/net/ethernet/mellanox/mlx5/core/wq.c index c8c315eb5128..68e7f8df2a6d 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/wq.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/wq.c | |||
| @@ -39,9 +39,9 @@ u32 mlx5_wq_cyc_get_size(struct mlx5_wq_cyc *wq) | |||
| 39 | return (u32)wq->fbc.sz_m1 + 1; | 39 | return (u32)wq->fbc.sz_m1 + 1; |
| 40 | } | 40 | } |
| 41 | 41 | ||
| 42 | u32 mlx5_wq_cyc_get_frag_size(struct mlx5_wq_cyc *wq) | 42 | u16 mlx5_wq_cyc_get_frag_size(struct mlx5_wq_cyc *wq) |
| 43 | { | 43 | { |
| 44 | return (u32)wq->fbc.frag_sz_m1 + 1; | 44 | return wq->fbc.frag_sz_m1 + 1; |
| 45 | } | 45 | } |
| 46 | 46 | ||
| 47 | u32 mlx5_cqwq_get_size(struct mlx5_cqwq *wq) | 47 | u32 mlx5_cqwq_get_size(struct mlx5_cqwq *wq) |
| @@ -138,7 +138,7 @@ int mlx5_wq_qp_create(struct mlx5_core_dev *mdev, struct mlx5_wq_param *param, | |||
| 138 | void *qpc, struct mlx5_wq_qp *wq, | 138 | void *qpc, struct mlx5_wq_qp *wq, |
| 139 | struct mlx5_wq_ctrl *wq_ctrl) | 139 | struct mlx5_wq_ctrl *wq_ctrl) |
| 140 | { | 140 | { |
| 141 | u32 sq_strides_offset; | 141 | u16 sq_strides_offset; |
| 142 | u32 rq_pg_remainder; | 142 | u32 rq_pg_remainder; |
| 143 | int err; | 143 | int err; |
| 144 | 144 | ||
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/wq.h b/drivers/net/ethernet/mellanox/mlx5/core/wq.h index 2bd4c3184eba..3a1a170bb2d7 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/wq.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/wq.h | |||
| @@ -80,7 +80,7 @@ int mlx5_wq_cyc_create(struct mlx5_core_dev *mdev, struct mlx5_wq_param *param, | |||
| 80 | void *wqc, struct mlx5_wq_cyc *wq, | 80 | void *wqc, struct mlx5_wq_cyc *wq, |
| 81 | struct mlx5_wq_ctrl *wq_ctrl); | 81 | struct mlx5_wq_ctrl *wq_ctrl); |
| 82 | u32 mlx5_wq_cyc_get_size(struct mlx5_wq_cyc *wq); | 82 | u32 mlx5_wq_cyc_get_size(struct mlx5_wq_cyc *wq); |
| 83 | u32 mlx5_wq_cyc_get_frag_size(struct mlx5_wq_cyc *wq); | 83 | u16 mlx5_wq_cyc_get_frag_size(struct mlx5_wq_cyc *wq); |
| 84 | 84 | ||
| 85 | int mlx5_wq_qp_create(struct mlx5_core_dev *mdev, struct mlx5_wq_param *param, | 85 | int mlx5_wq_qp_create(struct mlx5_core_dev *mdev, struct mlx5_wq_param *param, |
| 86 | void *qpc, struct mlx5_wq_qp *wq, | 86 | void *qpc, struct mlx5_wq_qp *wq, |
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c index 4327487553c5..3589432d1643 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c | |||
| @@ -337,14 +337,14 @@ static const struct mlxsw_sp_sb_cm mlxsw_sp_sb_cms_egress[] = { | |||
| 337 | MLXSW_SP_SB_CM(1500, 9, 0), | 337 | MLXSW_SP_SB_CM(1500, 9, 0), |
| 338 | MLXSW_SP_SB_CM(1500, 9, 0), | 338 | MLXSW_SP_SB_CM(1500, 9, 0), |
| 339 | MLXSW_SP_SB_CM(1500, 9, 0), | 339 | MLXSW_SP_SB_CM(1500, 9, 0), |
| 340 | MLXSW_SP_SB_CM(0, 0, 0), | 340 | MLXSW_SP_SB_CM(0, 140000, 15), |
| 341 | MLXSW_SP_SB_CM(0, 0, 0), | 341 | MLXSW_SP_SB_CM(0, 140000, 15), |
| 342 | MLXSW_SP_SB_CM(0, 0, 0), | 342 | MLXSW_SP_SB_CM(0, 140000, 15), |
| 343 | MLXSW_SP_SB_CM(0, 0, 0), | 343 | MLXSW_SP_SB_CM(0, 140000, 15), |
| 344 | MLXSW_SP_SB_CM(0, 0, 0), | 344 | MLXSW_SP_SB_CM(0, 140000, 15), |
| 345 | MLXSW_SP_SB_CM(0, 0, 0), | 345 | MLXSW_SP_SB_CM(0, 140000, 15), |
| 346 | MLXSW_SP_SB_CM(0, 0, 0), | 346 | MLXSW_SP_SB_CM(0, 140000, 15), |
| 347 | MLXSW_SP_SB_CM(0, 0, 0), | 347 | MLXSW_SP_SB_CM(0, 140000, 15), |
| 348 | MLXSW_SP_SB_CM(1, 0xff, 0), | 348 | MLXSW_SP_SB_CM(1, 0xff, 0), |
| 349 | }; | 349 | }; |
| 350 | 350 | ||
diff --git a/drivers/net/ethernet/netronome/nfp/flower/action.c b/drivers/net/ethernet/netronome/nfp/flower/action.c index 9044496803e6..46ba0cf257c6 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/action.c +++ b/drivers/net/ethernet/netronome/nfp/flower/action.c | |||
| @@ -52,6 +52,7 @@ | |||
| 52 | #define NFP_FL_TUNNEL_CSUM cpu_to_be16(0x01) | 52 | #define NFP_FL_TUNNEL_CSUM cpu_to_be16(0x01) |
| 53 | #define NFP_FL_TUNNEL_KEY cpu_to_be16(0x04) | 53 | #define NFP_FL_TUNNEL_KEY cpu_to_be16(0x04) |
| 54 | #define NFP_FL_TUNNEL_GENEVE_OPT cpu_to_be16(0x0800) | 54 | #define NFP_FL_TUNNEL_GENEVE_OPT cpu_to_be16(0x0800) |
| 55 | #define NFP_FL_SUPPORTED_TUNNEL_INFO_FLAGS IP_TUNNEL_INFO_TX | ||
| 55 | #define NFP_FL_SUPPORTED_IPV4_UDP_TUN_FLAGS (NFP_FL_TUNNEL_CSUM | \ | 56 | #define NFP_FL_SUPPORTED_IPV4_UDP_TUN_FLAGS (NFP_FL_TUNNEL_CSUM | \ |
| 56 | NFP_FL_TUNNEL_KEY | \ | 57 | NFP_FL_TUNNEL_KEY | \ |
| 57 | NFP_FL_TUNNEL_GENEVE_OPT) | 58 | NFP_FL_TUNNEL_GENEVE_OPT) |
| @@ -741,11 +742,16 @@ nfp_flower_loop_action(struct nfp_app *app, const struct tc_action *a, | |||
| 741 | nfp_fl_push_vlan(psh_v, a); | 742 | nfp_fl_push_vlan(psh_v, a); |
| 742 | *a_len += sizeof(struct nfp_fl_push_vlan); | 743 | *a_len += sizeof(struct nfp_fl_push_vlan); |
| 743 | } else if (is_tcf_tunnel_set(a)) { | 744 | } else if (is_tcf_tunnel_set(a)) { |
| 745 | struct ip_tunnel_info *ip_tun = tcf_tunnel_info(a); | ||
| 744 | struct nfp_repr *repr = netdev_priv(netdev); | 746 | struct nfp_repr *repr = netdev_priv(netdev); |
| 747 | |||
| 745 | *tun_type = nfp_fl_get_tun_from_act_l4_port(repr->app, a); | 748 | *tun_type = nfp_fl_get_tun_from_act_l4_port(repr->app, a); |
| 746 | if (*tun_type == NFP_FL_TUNNEL_NONE) | 749 | if (*tun_type == NFP_FL_TUNNEL_NONE) |
| 747 | return -EOPNOTSUPP; | 750 | return -EOPNOTSUPP; |
| 748 | 751 | ||
| 752 | if (ip_tun->mode & ~NFP_FL_SUPPORTED_TUNNEL_INFO_FLAGS) | ||
| 753 | return -EOPNOTSUPP; | ||
| 754 | |||
| 749 | /* Pre-tunnel action is required for tunnel encap. | 755 | /* Pre-tunnel action is required for tunnel encap. |
| 750 | * This checks for next hop entries on NFP. | 756 | * This checks for next hop entries on NFP. |
| 751 | * If none, the packet falls back before applying other actions. | 757 | * If none, the packet falls back before applying other actions. |
diff --git a/drivers/net/ethernet/netronome/nfp/flower/main.h b/drivers/net/ethernet/netronome/nfp/flower/main.h index 85f8209bf007..81d941ab895c 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/main.h +++ b/drivers/net/ethernet/netronome/nfp/flower/main.h | |||
| @@ -70,6 +70,7 @@ struct nfp_app; | |||
| 70 | #define NFP_FL_FEATS_GENEVE BIT(0) | 70 | #define NFP_FL_FEATS_GENEVE BIT(0) |
| 71 | #define NFP_FL_NBI_MTU_SETTING BIT(1) | 71 | #define NFP_FL_NBI_MTU_SETTING BIT(1) |
| 72 | #define NFP_FL_FEATS_GENEVE_OPT BIT(2) | 72 | #define NFP_FL_FEATS_GENEVE_OPT BIT(2) |
| 73 | #define NFP_FL_FEATS_VLAN_PCP BIT(3) | ||
| 73 | #define NFP_FL_FEATS_LAG BIT(31) | 74 | #define NFP_FL_FEATS_LAG BIT(31) |
| 74 | 75 | ||
| 75 | struct nfp_fl_mask_id { | 76 | struct nfp_fl_mask_id { |
diff --git a/drivers/net/ethernet/netronome/nfp/flower/match.c b/drivers/net/ethernet/netronome/nfp/flower/match.c index a0c72f277faa..17acb8cc6044 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/match.c +++ b/drivers/net/ethernet/netronome/nfp/flower/match.c | |||
| @@ -56,7 +56,7 @@ nfp_flower_compile_meta_tci(struct nfp_flower_meta_tci *frame, | |||
| 56 | FLOW_DISSECTOR_KEY_VLAN, | 56 | FLOW_DISSECTOR_KEY_VLAN, |
| 57 | target); | 57 | target); |
| 58 | /* Populate the tci field. */ | 58 | /* Populate the tci field. */ |
| 59 | if (flow_vlan->vlan_id) { | 59 | if (flow_vlan->vlan_id || flow_vlan->vlan_priority) { |
| 60 | tmp_tci = FIELD_PREP(NFP_FLOWER_MASK_VLAN_PRIO, | 60 | tmp_tci = FIELD_PREP(NFP_FLOWER_MASK_VLAN_PRIO, |
| 61 | flow_vlan->vlan_priority) | | 61 | flow_vlan->vlan_priority) | |
| 62 | FIELD_PREP(NFP_FLOWER_MASK_VLAN_VID, | 62 | FIELD_PREP(NFP_FLOWER_MASK_VLAN_VID, |
diff --git a/drivers/net/ethernet/netronome/nfp/flower/offload.c b/drivers/net/ethernet/netronome/nfp/flower/offload.c index 2edab01c3beb..bd19624f10cf 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/offload.c +++ b/drivers/net/ethernet/netronome/nfp/flower/offload.c | |||
| @@ -192,6 +192,17 @@ nfp_flower_calculate_key_layers(struct nfp_app *app, | |||
| 192 | key_size += sizeof(struct nfp_flower_mac_mpls); | 192 | key_size += sizeof(struct nfp_flower_mac_mpls); |
| 193 | } | 193 | } |
| 194 | 194 | ||
| 195 | if (dissector_uses_key(flow->dissector, FLOW_DISSECTOR_KEY_VLAN)) { | ||
| 196 | struct flow_dissector_key_vlan *flow_vlan; | ||
| 197 | |||
| 198 | flow_vlan = skb_flow_dissector_target(flow->dissector, | ||
| 199 | FLOW_DISSECTOR_KEY_VLAN, | ||
| 200 | flow->mask); | ||
| 201 | if (!(priv->flower_ext_feats & NFP_FL_FEATS_VLAN_PCP) && | ||
| 202 | flow_vlan->vlan_priority) | ||
| 203 | return -EOPNOTSUPP; | ||
| 204 | } | ||
| 205 | |||
| 195 | if (dissector_uses_key(flow->dissector, | 206 | if (dissector_uses_key(flow->dissector, |
| 196 | FLOW_DISSECTOR_KEY_ENC_CONTROL)) { | 207 | FLOW_DISSECTOR_KEY_ENC_CONTROL)) { |
| 197 | struct flow_dissector_key_ipv4_addrs *mask_ipv4 = NULL; | 208 | struct flow_dissector_key_ipv4_addrs *mask_ipv4 = NULL; |
diff --git a/drivers/net/ethernet/qualcomm/qca_7k.c b/drivers/net/ethernet/qualcomm/qca_7k.c index ffe7a16bdfc8..6c8543fb90c0 100644 --- a/drivers/net/ethernet/qualcomm/qca_7k.c +++ b/drivers/net/ethernet/qualcomm/qca_7k.c | |||
| @@ -45,34 +45,33 @@ qcaspi_read_register(struct qcaspi *qca, u16 reg, u16 *result) | |||
| 45 | { | 45 | { |
| 46 | __be16 rx_data; | 46 | __be16 rx_data; |
| 47 | __be16 tx_data; | 47 | __be16 tx_data; |
| 48 | struct spi_transfer *transfer; | 48 | struct spi_transfer transfer[2]; |
| 49 | struct spi_message *msg; | 49 | struct spi_message msg; |
| 50 | int ret; | 50 | int ret; |
| 51 | 51 | ||
| 52 | memset(transfer, 0, sizeof(transfer)); | ||
| 53 | |||
| 54 | spi_message_init(&msg); | ||
| 55 | |||
| 52 | tx_data = cpu_to_be16(QCA7K_SPI_READ | QCA7K_SPI_INTERNAL | reg); | 56 | tx_data = cpu_to_be16(QCA7K_SPI_READ | QCA7K_SPI_INTERNAL | reg); |
| 57 | *result = 0; | ||
| 58 | |||
| 59 | transfer[0].tx_buf = &tx_data; | ||
| 60 | transfer[0].len = QCASPI_CMD_LEN; | ||
| 61 | transfer[1].rx_buf = &rx_data; | ||
| 62 | transfer[1].len = QCASPI_CMD_LEN; | ||
| 63 | |||
| 64 | spi_message_add_tail(&transfer[0], &msg); | ||
| 53 | 65 | ||
| 54 | if (qca->legacy_mode) { | 66 | if (qca->legacy_mode) { |
| 55 | msg = &qca->spi_msg1; | 67 | spi_sync(qca->spi_dev, &msg); |
| 56 | transfer = &qca->spi_xfer1; | 68 | spi_message_init(&msg); |
| 57 | transfer->tx_buf = &tx_data; | ||
| 58 | transfer->rx_buf = NULL; | ||
| 59 | transfer->len = QCASPI_CMD_LEN; | ||
| 60 | spi_sync(qca->spi_dev, msg); | ||
| 61 | } else { | ||
| 62 | msg = &qca->spi_msg2; | ||
| 63 | transfer = &qca->spi_xfer2[0]; | ||
| 64 | transfer->tx_buf = &tx_data; | ||
| 65 | transfer->rx_buf = NULL; | ||
| 66 | transfer->len = QCASPI_CMD_LEN; | ||
| 67 | transfer = &qca->spi_xfer2[1]; | ||
| 68 | } | 69 | } |
| 69 | transfer->tx_buf = NULL; | 70 | spi_message_add_tail(&transfer[1], &msg); |
| 70 | transfer->rx_buf = &rx_data; | 71 | ret = spi_sync(qca->spi_dev, &msg); |
| 71 | transfer->len = QCASPI_CMD_LEN; | ||
| 72 | ret = spi_sync(qca->spi_dev, msg); | ||
| 73 | 72 | ||
| 74 | if (!ret) | 73 | if (!ret) |
| 75 | ret = msg->status; | 74 | ret = msg.status; |
| 76 | 75 | ||
| 77 | if (ret) | 76 | if (ret) |
| 78 | qcaspi_spi_error(qca); | 77 | qcaspi_spi_error(qca); |
| @@ -86,35 +85,32 @@ int | |||
| 86 | qcaspi_write_register(struct qcaspi *qca, u16 reg, u16 value) | 85 | qcaspi_write_register(struct qcaspi *qca, u16 reg, u16 value) |
| 87 | { | 86 | { |
| 88 | __be16 tx_data[2]; | 87 | __be16 tx_data[2]; |
| 89 | struct spi_transfer *transfer; | 88 | struct spi_transfer transfer[2]; |
| 90 | struct spi_message *msg; | 89 | struct spi_message msg; |
| 91 | int ret; | 90 | int ret; |
| 92 | 91 | ||
| 92 | memset(&transfer, 0, sizeof(transfer)); | ||
| 93 | |||
| 94 | spi_message_init(&msg); | ||
| 95 | |||
| 93 | tx_data[0] = cpu_to_be16(QCA7K_SPI_WRITE | QCA7K_SPI_INTERNAL | reg); | 96 | tx_data[0] = cpu_to_be16(QCA7K_SPI_WRITE | QCA7K_SPI_INTERNAL | reg); |
| 94 | tx_data[1] = cpu_to_be16(value); | 97 | tx_data[1] = cpu_to_be16(value); |
| 95 | 98 | ||
| 99 | transfer[0].tx_buf = &tx_data[0]; | ||
| 100 | transfer[0].len = QCASPI_CMD_LEN; | ||
| 101 | transfer[1].tx_buf = &tx_data[1]; | ||
| 102 | transfer[1].len = QCASPI_CMD_LEN; | ||
| 103 | |||
| 104 | spi_message_add_tail(&transfer[0], &msg); | ||
| 96 | if (qca->legacy_mode) { | 105 | if (qca->legacy_mode) { |
| 97 | msg = &qca->spi_msg1; | 106 | spi_sync(qca->spi_dev, &msg); |
| 98 | transfer = &qca->spi_xfer1; | 107 | spi_message_init(&msg); |
| 99 | transfer->tx_buf = &tx_data[0]; | ||
| 100 | transfer->rx_buf = NULL; | ||
| 101 | transfer->len = QCASPI_CMD_LEN; | ||
| 102 | spi_sync(qca->spi_dev, msg); | ||
| 103 | } else { | ||
| 104 | msg = &qca->spi_msg2; | ||
| 105 | transfer = &qca->spi_xfer2[0]; | ||
| 106 | transfer->tx_buf = &tx_data[0]; | ||
| 107 | transfer->rx_buf = NULL; | ||
| 108 | transfer->len = QCASPI_CMD_LEN; | ||
| 109 | transfer = &qca->spi_xfer2[1]; | ||
| 110 | } | 108 | } |
| 111 | transfer->tx_buf = &tx_data[1]; | 109 | spi_message_add_tail(&transfer[1], &msg); |
| 112 | transfer->rx_buf = NULL; | 110 | ret = spi_sync(qca->spi_dev, &msg); |
| 113 | transfer->len = QCASPI_CMD_LEN; | ||
| 114 | ret = spi_sync(qca->spi_dev, msg); | ||
| 115 | 111 | ||
| 116 | if (!ret) | 112 | if (!ret) |
| 117 | ret = msg->status; | 113 | ret = msg.status; |
| 118 | 114 | ||
| 119 | if (ret) | 115 | if (ret) |
| 120 | qcaspi_spi_error(qca); | 116 | qcaspi_spi_error(qca); |
diff --git a/drivers/net/ethernet/qualcomm/qca_spi.c b/drivers/net/ethernet/qualcomm/qca_spi.c index 206f0266463e..66b775d462fd 100644 --- a/drivers/net/ethernet/qualcomm/qca_spi.c +++ b/drivers/net/ethernet/qualcomm/qca_spi.c | |||
| @@ -99,22 +99,24 @@ static u32 | |||
| 99 | qcaspi_write_burst(struct qcaspi *qca, u8 *src, u32 len) | 99 | qcaspi_write_burst(struct qcaspi *qca, u8 *src, u32 len) |
| 100 | { | 100 | { |
| 101 | __be16 cmd; | 101 | __be16 cmd; |
| 102 | struct spi_message *msg = &qca->spi_msg2; | 102 | struct spi_message msg; |
| 103 | struct spi_transfer *transfer = &qca->spi_xfer2[0]; | 103 | struct spi_transfer transfer[2]; |
| 104 | int ret; | 104 | int ret; |
| 105 | 105 | ||
| 106 | memset(&transfer, 0, sizeof(transfer)); | ||
| 107 | spi_message_init(&msg); | ||
| 108 | |||
| 106 | cmd = cpu_to_be16(QCA7K_SPI_WRITE | QCA7K_SPI_EXTERNAL); | 109 | cmd = cpu_to_be16(QCA7K_SPI_WRITE | QCA7K_SPI_EXTERNAL); |
| 107 | transfer->tx_buf = &cmd; | 110 | transfer[0].tx_buf = &cmd; |
| 108 | transfer->rx_buf = NULL; | 111 | transfer[0].len = QCASPI_CMD_LEN; |
| 109 | transfer->len = QCASPI_CMD_LEN; | 112 | transfer[1].tx_buf = src; |
| 110 | transfer = &qca->spi_xfer2[1]; | 113 | transfer[1].len = len; |
| 111 | transfer->tx_buf = src; | ||
| 112 | transfer->rx_buf = NULL; | ||
| 113 | transfer->len = len; | ||
| 114 | 114 | ||
| 115 | ret = spi_sync(qca->spi_dev, msg); | 115 | spi_message_add_tail(&transfer[0], &msg); |
| 116 | spi_message_add_tail(&transfer[1], &msg); | ||
| 117 | ret = spi_sync(qca->spi_dev, &msg); | ||
| 116 | 118 | ||
| 117 | if (ret || (msg->actual_length != QCASPI_CMD_LEN + len)) { | 119 | if (ret || (msg.actual_length != QCASPI_CMD_LEN + len)) { |
| 118 | qcaspi_spi_error(qca); | 120 | qcaspi_spi_error(qca); |
| 119 | return 0; | 121 | return 0; |
| 120 | } | 122 | } |
| @@ -125,17 +127,20 @@ qcaspi_write_burst(struct qcaspi *qca, u8 *src, u32 len) | |||
| 125 | static u32 | 127 | static u32 |
| 126 | qcaspi_write_legacy(struct qcaspi *qca, u8 *src, u32 len) | 128 | qcaspi_write_legacy(struct qcaspi *qca, u8 *src, u32 len) |
| 127 | { | 129 | { |
| 128 | struct spi_message *msg = &qca->spi_msg1; | 130 | struct spi_message msg; |
| 129 | struct spi_transfer *transfer = &qca->spi_xfer1; | 131 | struct spi_transfer transfer; |
| 130 | int ret; | 132 | int ret; |
| 131 | 133 | ||
| 132 | transfer->tx_buf = src; | 134 | memset(&transfer, 0, sizeof(transfer)); |
| 133 | transfer->rx_buf = NULL; | 135 | spi_message_init(&msg); |
| 134 | transfer->len = len; | 136 | |
| 137 | transfer.tx_buf = src; | ||
| 138 | transfer.len = len; | ||
| 135 | 139 | ||
| 136 | ret = spi_sync(qca->spi_dev, msg); | 140 | spi_message_add_tail(&transfer, &msg); |
| 141 | ret = spi_sync(qca->spi_dev, &msg); | ||
| 137 | 142 | ||
| 138 | if (ret || (msg->actual_length != len)) { | 143 | if (ret || (msg.actual_length != len)) { |
| 139 | qcaspi_spi_error(qca); | 144 | qcaspi_spi_error(qca); |
| 140 | return 0; | 145 | return 0; |
| 141 | } | 146 | } |
| @@ -146,23 +151,25 @@ qcaspi_write_legacy(struct qcaspi *qca, u8 *src, u32 len) | |||
| 146 | static u32 | 151 | static u32 |
| 147 | qcaspi_read_burst(struct qcaspi *qca, u8 *dst, u32 len) | 152 | qcaspi_read_burst(struct qcaspi *qca, u8 *dst, u32 len) |
| 148 | { | 153 | { |
| 149 | struct spi_message *msg = &qca->spi_msg2; | 154 | struct spi_message msg; |
| 150 | __be16 cmd; | 155 | __be16 cmd; |
| 151 | struct spi_transfer *transfer = &qca->spi_xfer2[0]; | 156 | struct spi_transfer transfer[2]; |
| 152 | int ret; | 157 | int ret; |
| 153 | 158 | ||
| 159 | memset(&transfer, 0, sizeof(transfer)); | ||
| 160 | spi_message_init(&msg); | ||
| 161 | |||
| 154 | cmd = cpu_to_be16(QCA7K_SPI_READ | QCA7K_SPI_EXTERNAL); | 162 | cmd = cpu_to_be16(QCA7K_SPI_READ | QCA7K_SPI_EXTERNAL); |
| 155 | transfer->tx_buf = &cmd; | 163 | transfer[0].tx_buf = &cmd; |
| 156 | transfer->rx_buf = NULL; | 164 | transfer[0].len = QCASPI_CMD_LEN; |
| 157 | transfer->len = QCASPI_CMD_LEN; | 165 | transfer[1].rx_buf = dst; |
| 158 | transfer = &qca->spi_xfer2[1]; | 166 | transfer[1].len = len; |
| 159 | transfer->tx_buf = NULL; | ||
| 160 | transfer->rx_buf = dst; | ||
| 161 | transfer->len = len; | ||
| 162 | 167 | ||
| 163 | ret = spi_sync(qca->spi_dev, msg); | 168 | spi_message_add_tail(&transfer[0], &msg); |
| 169 | spi_message_add_tail(&transfer[1], &msg); | ||
| 170 | ret = spi_sync(qca->spi_dev, &msg); | ||
| 164 | 171 | ||
| 165 | if (ret || (msg->actual_length != QCASPI_CMD_LEN + len)) { | 172 | if (ret || (msg.actual_length != QCASPI_CMD_LEN + len)) { |
| 166 | qcaspi_spi_error(qca); | 173 | qcaspi_spi_error(qca); |
| 167 | return 0; | 174 | return 0; |
| 168 | } | 175 | } |
| @@ -173,17 +180,20 @@ qcaspi_read_burst(struct qcaspi *qca, u8 *dst, u32 len) | |||
| 173 | static u32 | 180 | static u32 |
| 174 | qcaspi_read_legacy(struct qcaspi *qca, u8 *dst, u32 len) | 181 | qcaspi_read_legacy(struct qcaspi *qca, u8 *dst, u32 len) |
| 175 | { | 182 | { |
| 176 | struct spi_message *msg = &qca->spi_msg1; | 183 | struct spi_message msg; |
| 177 | struct spi_transfer *transfer = &qca->spi_xfer1; | 184 | struct spi_transfer transfer; |
| 178 | int ret; | 185 | int ret; |
| 179 | 186 | ||
| 180 | transfer->tx_buf = NULL; | 187 | memset(&transfer, 0, sizeof(transfer)); |
| 181 | transfer->rx_buf = dst; | 188 | spi_message_init(&msg); |
| 182 | transfer->len = len; | ||
| 183 | 189 | ||
| 184 | ret = spi_sync(qca->spi_dev, msg); | 190 | transfer.rx_buf = dst; |
| 191 | transfer.len = len; | ||
| 185 | 192 | ||
| 186 | if (ret || (msg->actual_length != len)) { | 193 | spi_message_add_tail(&transfer, &msg); |
| 194 | ret = spi_sync(qca->spi_dev, &msg); | ||
| 195 | |||
| 196 | if (ret || (msg.actual_length != len)) { | ||
| 187 | qcaspi_spi_error(qca); | 197 | qcaspi_spi_error(qca); |
| 188 | return 0; | 198 | return 0; |
| 189 | } | 199 | } |
| @@ -195,19 +205,23 @@ static int | |||
| 195 | qcaspi_tx_cmd(struct qcaspi *qca, u16 cmd) | 205 | qcaspi_tx_cmd(struct qcaspi *qca, u16 cmd) |
| 196 | { | 206 | { |
| 197 | __be16 tx_data; | 207 | __be16 tx_data; |
| 198 | struct spi_message *msg = &qca->spi_msg1; | 208 | struct spi_message msg; |
| 199 | struct spi_transfer *transfer = &qca->spi_xfer1; | 209 | struct spi_transfer transfer; |
| 200 | int ret; | 210 | int ret; |
| 201 | 211 | ||
| 212 | memset(&transfer, 0, sizeof(transfer)); | ||
| 213 | |||
| 214 | spi_message_init(&msg); | ||
| 215 | |||
| 202 | tx_data = cpu_to_be16(cmd); | 216 | tx_data = cpu_to_be16(cmd); |
| 203 | transfer->len = sizeof(tx_data); | 217 | transfer.len = sizeof(cmd); |
| 204 | transfer->tx_buf = &tx_data; | 218 | transfer.tx_buf = &tx_data; |
| 205 | transfer->rx_buf = NULL; | 219 | spi_message_add_tail(&transfer, &msg); |
| 206 | 220 | ||
| 207 | ret = spi_sync(qca->spi_dev, msg); | 221 | ret = spi_sync(qca->spi_dev, &msg); |
| 208 | 222 | ||
| 209 | if (!ret) | 223 | if (!ret) |
| 210 | ret = msg->status; | 224 | ret = msg.status; |
| 211 | 225 | ||
| 212 | if (ret) | 226 | if (ret) |
| 213 | qcaspi_spi_error(qca); | 227 | qcaspi_spi_error(qca); |
| @@ -835,16 +849,6 @@ qcaspi_netdev_setup(struct net_device *dev) | |||
| 835 | qca = netdev_priv(dev); | 849 | qca = netdev_priv(dev); |
| 836 | memset(qca, 0, sizeof(struct qcaspi)); | 850 | memset(qca, 0, sizeof(struct qcaspi)); |
| 837 | 851 | ||
| 838 | memset(&qca->spi_xfer1, 0, sizeof(struct spi_transfer)); | ||
| 839 | memset(&qca->spi_xfer2, 0, sizeof(struct spi_transfer) * 2); | ||
| 840 | |||
| 841 | spi_message_init(&qca->spi_msg1); | ||
| 842 | spi_message_add_tail(&qca->spi_xfer1, &qca->spi_msg1); | ||
| 843 | |||
| 844 | spi_message_init(&qca->spi_msg2); | ||
| 845 | spi_message_add_tail(&qca->spi_xfer2[0], &qca->spi_msg2); | ||
| 846 | spi_message_add_tail(&qca->spi_xfer2[1], &qca->spi_msg2); | ||
| 847 | |||
| 848 | memset(&qca->txr, 0, sizeof(qca->txr)); | 852 | memset(&qca->txr, 0, sizeof(qca->txr)); |
| 849 | qca->txr.count = TX_RING_MAX_LEN; | 853 | qca->txr.count = TX_RING_MAX_LEN; |
| 850 | } | 854 | } |
diff --git a/drivers/net/ethernet/qualcomm/qca_spi.h b/drivers/net/ethernet/qualcomm/qca_spi.h index fc4beb1b32d1..fc0e98726b36 100644 --- a/drivers/net/ethernet/qualcomm/qca_spi.h +++ b/drivers/net/ethernet/qualcomm/qca_spi.h | |||
| @@ -83,11 +83,6 @@ struct qcaspi { | |||
| 83 | struct tx_ring txr; | 83 | struct tx_ring txr; |
| 84 | struct qcaspi_stats stats; | 84 | struct qcaspi_stats stats; |
| 85 | 85 | ||
| 86 | struct spi_message spi_msg1; | ||
| 87 | struct spi_message spi_msg2; | ||
| 88 | struct spi_transfer spi_xfer1; | ||
| 89 | struct spi_transfer spi_xfer2[2]; | ||
| 90 | |||
| 91 | u8 *rx_buffer; | 86 | u8 *rx_buffer; |
| 92 | u32 buffer_size; | 87 | u32 buffer_size; |
| 93 | u8 sync; | 88 | u8 sync; |
diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c index b08d51bf7a20..1d8631303b53 100644 --- a/drivers/net/ethernet/realtek/r8169.c +++ b/drivers/net/ethernet/realtek/r8169.c | |||
| @@ -631,7 +631,7 @@ struct rtl8169_tc_offsets { | |||
| 631 | }; | 631 | }; |
| 632 | 632 | ||
| 633 | enum rtl_flag { | 633 | enum rtl_flag { |
| 634 | RTL_FLAG_TASK_ENABLED, | 634 | RTL_FLAG_TASK_ENABLED = 0, |
| 635 | RTL_FLAG_TASK_SLOW_PENDING, | 635 | RTL_FLAG_TASK_SLOW_PENDING, |
| 636 | RTL_FLAG_TASK_RESET_PENDING, | 636 | RTL_FLAG_TASK_RESET_PENDING, |
| 637 | RTL_FLAG_MAX | 637 | RTL_FLAG_MAX |
| @@ -4634,13 +4634,13 @@ static void rtl_hw_start(struct rtl8169_private *tp) | |||
| 4634 | 4634 | ||
| 4635 | rtl_set_rx_max_size(tp); | 4635 | rtl_set_rx_max_size(tp); |
| 4636 | rtl_set_rx_tx_desc_registers(tp); | 4636 | rtl_set_rx_tx_desc_registers(tp); |
| 4637 | rtl_set_tx_config_registers(tp); | ||
| 4638 | RTL_W8(tp, Cfg9346, Cfg9346_Lock); | 4637 | RTL_W8(tp, Cfg9346, Cfg9346_Lock); |
| 4639 | 4638 | ||
| 4640 | /* Initially a 10 us delay. Turned it into a PCI commit. - FR */ | 4639 | /* Initially a 10 us delay. Turned it into a PCI commit. - FR */ |
| 4641 | RTL_R8(tp, IntrMask); | 4640 | RTL_R8(tp, IntrMask); |
| 4642 | RTL_W8(tp, ChipCmd, CmdTxEnb | CmdRxEnb); | 4641 | RTL_W8(tp, ChipCmd, CmdTxEnb | CmdRxEnb); |
| 4643 | rtl_init_rxcfg(tp); | 4642 | rtl_init_rxcfg(tp); |
| 4643 | rtl_set_tx_config_registers(tp); | ||
| 4644 | 4644 | ||
| 4645 | rtl_set_rx_mode(tp->dev); | 4645 | rtl_set_rx_mode(tp->dev); |
| 4646 | /* no early-rx interrupts */ | 4646 | /* no early-rx interrupts */ |
| @@ -6655,7 +6655,8 @@ static int rtl8169_close(struct net_device *dev) | |||
| 6655 | rtl8169_update_counters(tp); | 6655 | rtl8169_update_counters(tp); |
| 6656 | 6656 | ||
| 6657 | rtl_lock_work(tp); | 6657 | rtl_lock_work(tp); |
| 6658 | clear_bit(RTL_FLAG_TASK_ENABLED, tp->wk.flags); | 6658 | /* Clear all task flags */ |
| 6659 | bitmap_zero(tp->wk.flags, RTL_FLAG_MAX); | ||
| 6659 | 6660 | ||
| 6660 | rtl8169_down(dev); | 6661 | rtl8169_down(dev); |
| 6661 | rtl_unlock_work(tp); | 6662 | rtl_unlock_work(tp); |
| @@ -6838,7 +6839,9 @@ static void rtl8169_net_suspend(struct net_device *dev) | |||
| 6838 | 6839 | ||
| 6839 | rtl_lock_work(tp); | 6840 | rtl_lock_work(tp); |
| 6840 | napi_disable(&tp->napi); | 6841 | napi_disable(&tp->napi); |
| 6841 | clear_bit(RTL_FLAG_TASK_ENABLED, tp->wk.flags); | 6842 | /* Clear all task flags */ |
| 6843 | bitmap_zero(tp->wk.flags, RTL_FLAG_MAX); | ||
| 6844 | |||
| 6842 | rtl_unlock_work(tp); | 6845 | rtl_unlock_work(tp); |
| 6843 | 6846 | ||
| 6844 | rtl_pll_power_down(tp); | 6847 | rtl_pll_power_down(tp); |
diff --git a/drivers/net/ethernet/renesas/Kconfig b/drivers/net/ethernet/renesas/Kconfig index f3f7477043ce..bb0ebdfd4459 100644 --- a/drivers/net/ethernet/renesas/Kconfig +++ b/drivers/net/ethernet/renesas/Kconfig | |||
| @@ -1,3 +1,4 @@ | |||
| 1 | # SPDX-License-Identifier: GPL-2.0 | ||
| 1 | # | 2 | # |
| 2 | # Renesas device configuration | 3 | # Renesas device configuration |
| 3 | # | 4 | # |
diff --git a/drivers/net/ethernet/renesas/Makefile b/drivers/net/ethernet/renesas/Makefile index a05102a7df02..f21ab8c02af0 100644 --- a/drivers/net/ethernet/renesas/Makefile +++ b/drivers/net/ethernet/renesas/Makefile | |||
| @@ -1,3 +1,4 @@ | |||
| 1 | # SPDX-License-Identifier: GPL-2.0 | ||
| 1 | # | 2 | # |
| 2 | # Makefile for the Renesas device drivers. | 3 | # Makefile for the Renesas device drivers. |
| 3 | # | 4 | # |
diff --git a/drivers/net/ethernet/renesas/ravb_ptp.c b/drivers/net/ethernet/renesas/ravb_ptp.c index eede70ec37f8..0721b5c35d91 100644 --- a/drivers/net/ethernet/renesas/ravb_ptp.c +++ b/drivers/net/ethernet/renesas/ravb_ptp.c | |||
| @@ -1,13 +1,9 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0+ | ||
| 1 | /* PTP 1588 clock using the Renesas Ethernet AVB | 2 | /* PTP 1588 clock using the Renesas Ethernet AVB |
| 2 | * | 3 | * |
| 3 | * Copyright (C) 2013-2015 Renesas Electronics Corporation | 4 | * Copyright (C) 2013-2015 Renesas Electronics Corporation |
| 4 | * Copyright (C) 2015 Renesas Solutions Corp. | 5 | * Copyright (C) 2015 Renesas Solutions Corp. |
| 5 | * Copyright (C) 2015-2016 Cogent Embedded, Inc. <source@cogentembedded.com> | 6 | * Copyright (C) 2015-2016 Cogent Embedded, Inc. <source@cogentembedded.com> |
| 6 | * | ||
| 7 | * This program is free software; you can redistribute it and/or modify | ||
| 8 | * it under the terms of the GNU General Public License as published by | ||
| 9 | * the Free Software Foundation; either version 2 of the License, or | ||
| 10 | * (at your option) any later version. | ||
| 11 | */ | 7 | */ |
| 12 | 8 | ||
| 13 | #include "ravb.h" | 9 | #include "ravb.h" |
diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c index cb0cc30c3d6a..e3270deecec2 100644 --- a/drivers/net/usb/qmi_wwan.c +++ b/drivers/net/usb/qmi_wwan.c | |||
| @@ -967,6 +967,13 @@ static const struct usb_device_id products[] = { | |||
| 967 | USB_DEVICE_AND_INTERFACE_INFO(0x03f0, 0x581d, USB_CLASS_VENDOR_SPEC, 1, 7), | 967 | USB_DEVICE_AND_INTERFACE_INFO(0x03f0, 0x581d, USB_CLASS_VENDOR_SPEC, 1, 7), |
| 968 | .driver_info = (unsigned long)&qmi_wwan_info, | 968 | .driver_info = (unsigned long)&qmi_wwan_info, |
| 969 | }, | 969 | }, |
| 970 | { /* Quectel EP06/EG06/EM06 */ | ||
| 971 | USB_DEVICE_AND_INTERFACE_INFO(0x2c7c, 0x0306, | ||
| 972 | USB_CLASS_VENDOR_SPEC, | ||
| 973 | USB_SUBCLASS_VENDOR_SPEC, | ||
| 974 | 0xff), | ||
| 975 | .driver_info = (unsigned long)&qmi_wwan_info_quirk_dtr, | ||
| 976 | }, | ||
| 970 | 977 | ||
| 971 | /* 3. Combined interface devices matching on interface number */ | 978 | /* 3. Combined interface devices matching on interface number */ |
| 972 | {QMI_FIXED_INTF(0x0408, 0xea42, 4)}, /* Yota / Megafon M100-1 */ | 979 | {QMI_FIXED_INTF(0x0408, 0xea42, 4)}, /* Yota / Megafon M100-1 */ |
| @@ -1255,7 +1262,6 @@ static const struct usb_device_id products[] = { | |||
| 1255 | {QMI_QUIRK_SET_DTR(0x2c7c, 0x0121, 4)}, /* Quectel EC21 Mini PCIe */ | 1262 | {QMI_QUIRK_SET_DTR(0x2c7c, 0x0121, 4)}, /* Quectel EC21 Mini PCIe */ |
| 1256 | {QMI_QUIRK_SET_DTR(0x2c7c, 0x0191, 4)}, /* Quectel EG91 */ | 1263 | {QMI_QUIRK_SET_DTR(0x2c7c, 0x0191, 4)}, /* Quectel EG91 */ |
| 1257 | {QMI_FIXED_INTF(0x2c7c, 0x0296, 4)}, /* Quectel BG96 */ | 1264 | {QMI_FIXED_INTF(0x2c7c, 0x0296, 4)}, /* Quectel BG96 */ |
| 1258 | {QMI_QUIRK_SET_DTR(0x2c7c, 0x0306, 4)}, /* Quectel EP06 Mini PCIe */ | ||
| 1259 | 1265 | ||
| 1260 | /* 4. Gobi 1000 devices */ | 1266 | /* 4. Gobi 1000 devices */ |
| 1261 | {QMI_GOBI1K_DEVICE(0x05c6, 0x9212)}, /* Acer Gobi Modem Device */ | 1267 | {QMI_GOBI1K_DEVICE(0x05c6, 0x9212)}, /* Acer Gobi Modem Device */ |
| @@ -1331,6 +1337,19 @@ static bool quectel_ec20_detected(struct usb_interface *intf) | |||
| 1331 | return false; | 1337 | return false; |
| 1332 | } | 1338 | } |
| 1333 | 1339 | ||
| 1340 | static bool quectel_ep06_diag_detected(struct usb_interface *intf) | ||
| 1341 | { | ||
| 1342 | struct usb_device *dev = interface_to_usbdev(intf); | ||
| 1343 | struct usb_interface_descriptor intf_desc = intf->cur_altsetting->desc; | ||
| 1344 | |||
| 1345 | if (le16_to_cpu(dev->descriptor.idVendor) == 0x2c7c && | ||
| 1346 | le16_to_cpu(dev->descriptor.idProduct) == 0x0306 && | ||
| 1347 | intf_desc.bNumEndpoints == 2) | ||
| 1348 | return true; | ||
| 1349 | |||
| 1350 | return false; | ||
| 1351 | } | ||
| 1352 | |||
| 1334 | static int qmi_wwan_probe(struct usb_interface *intf, | 1353 | static int qmi_wwan_probe(struct usb_interface *intf, |
| 1335 | const struct usb_device_id *prod) | 1354 | const struct usb_device_id *prod) |
| 1336 | { | 1355 | { |
| @@ -1365,6 +1384,15 @@ static int qmi_wwan_probe(struct usb_interface *intf, | |||
| 1365 | return -ENODEV; | 1384 | return -ENODEV; |
| 1366 | } | 1385 | } |
| 1367 | 1386 | ||
| 1387 | /* Quectel EP06/EM06/EG06 supports dynamic interface configuration, so | ||
| 1388 | * we need to match on class/subclass/protocol. These values are | ||
| 1389 | * identical for the diagnostic- and QMI-interface, but bNumEndpoints is | ||
| 1390 | * different. Ignore the current interface if the number of endpoints | ||
| 1391 | * the number for the diag interface (two). | ||
| 1392 | */ | ||
| 1393 | if (quectel_ep06_diag_detected(intf)) | ||
| 1394 | return -ENODEV; | ||
| 1395 | |||
| 1368 | return usbnet_probe(intf, id); | 1396 | return usbnet_probe(intf, id); |
| 1369 | } | 1397 | } |
| 1370 | 1398 | ||
diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c index 73f596a90c69..9407acbd19a9 100644 --- a/drivers/net/xen-netfront.c +++ b/drivers/net/xen-netfront.c | |||
| @@ -87,8 +87,7 @@ struct netfront_cb { | |||
| 87 | /* IRQ name is queue name with "-tx" or "-rx" appended */ | 87 | /* IRQ name is queue name with "-tx" or "-rx" appended */ |
| 88 | #define IRQ_NAME_SIZE (QUEUE_NAME_SIZE + 3) | 88 | #define IRQ_NAME_SIZE (QUEUE_NAME_SIZE + 3) |
| 89 | 89 | ||
| 90 | static DECLARE_WAIT_QUEUE_HEAD(module_load_q); | 90 | static DECLARE_WAIT_QUEUE_HEAD(module_wq); |
| 91 | static DECLARE_WAIT_QUEUE_HEAD(module_unload_q); | ||
| 92 | 91 | ||
| 93 | struct netfront_stats { | 92 | struct netfront_stats { |
| 94 | u64 packets; | 93 | u64 packets; |
| @@ -1332,11 +1331,11 @@ static struct net_device *xennet_create_dev(struct xenbus_device *dev) | |||
| 1332 | netif_carrier_off(netdev); | 1331 | netif_carrier_off(netdev); |
| 1333 | 1332 | ||
| 1334 | xenbus_switch_state(dev, XenbusStateInitialising); | 1333 | xenbus_switch_state(dev, XenbusStateInitialising); |
| 1335 | wait_event(module_load_q, | 1334 | wait_event(module_wq, |
| 1336 | xenbus_read_driver_state(dev->otherend) != | 1335 | xenbus_read_driver_state(dev->otherend) != |
| 1337 | XenbusStateClosed && | 1336 | XenbusStateClosed && |
| 1338 | xenbus_read_driver_state(dev->otherend) != | 1337 | xenbus_read_driver_state(dev->otherend) != |
| 1339 | XenbusStateUnknown); | 1338 | XenbusStateUnknown); |
| 1340 | return netdev; | 1339 | return netdev; |
| 1341 | 1340 | ||
| 1342 | exit: | 1341 | exit: |
| @@ -2010,15 +2009,14 @@ static void netback_changed(struct xenbus_device *dev, | |||
| 2010 | 2009 | ||
| 2011 | dev_dbg(&dev->dev, "%s\n", xenbus_strstate(backend_state)); | 2010 | dev_dbg(&dev->dev, "%s\n", xenbus_strstate(backend_state)); |
| 2012 | 2011 | ||
| 2012 | wake_up_all(&module_wq); | ||
| 2013 | |||
| 2013 | switch (backend_state) { | 2014 | switch (backend_state) { |
| 2014 | case XenbusStateInitialising: | 2015 | case XenbusStateInitialising: |
| 2015 | case XenbusStateInitialised: | 2016 | case XenbusStateInitialised: |
| 2016 | case XenbusStateReconfiguring: | 2017 | case XenbusStateReconfiguring: |
| 2017 | case XenbusStateReconfigured: | 2018 | case XenbusStateReconfigured: |
| 2018 | break; | ||
| 2019 | |||
| 2020 | case XenbusStateUnknown: | 2019 | case XenbusStateUnknown: |
| 2021 | wake_up_all(&module_unload_q); | ||
| 2022 | break; | 2020 | break; |
| 2023 | 2021 | ||
| 2024 | case XenbusStateInitWait: | 2022 | case XenbusStateInitWait: |
| @@ -2034,12 +2032,10 @@ static void netback_changed(struct xenbus_device *dev, | |||
| 2034 | break; | 2032 | break; |
| 2035 | 2033 | ||
| 2036 | case XenbusStateClosed: | 2034 | case XenbusStateClosed: |
| 2037 | wake_up_all(&module_unload_q); | ||
| 2038 | if (dev->state == XenbusStateClosed) | 2035 | if (dev->state == XenbusStateClosed) |
| 2039 | break; | 2036 | break; |
| 2040 | /* Missed the backend's CLOSING state -- fallthrough */ | 2037 | /* Missed the backend's CLOSING state -- fallthrough */ |
| 2041 | case XenbusStateClosing: | 2038 | case XenbusStateClosing: |
| 2042 | wake_up_all(&module_unload_q); | ||
| 2043 | xenbus_frontend_closed(dev); | 2039 | xenbus_frontend_closed(dev); |
| 2044 | break; | 2040 | break; |
| 2045 | } | 2041 | } |
| @@ -2147,14 +2143,14 @@ static int xennet_remove(struct xenbus_device *dev) | |||
| 2147 | 2143 | ||
| 2148 | if (xenbus_read_driver_state(dev->otherend) != XenbusStateClosed) { | 2144 | if (xenbus_read_driver_state(dev->otherend) != XenbusStateClosed) { |
| 2149 | xenbus_switch_state(dev, XenbusStateClosing); | 2145 | xenbus_switch_state(dev, XenbusStateClosing); |
| 2150 | wait_event(module_unload_q, | 2146 | wait_event(module_wq, |
| 2151 | xenbus_read_driver_state(dev->otherend) == | 2147 | xenbus_read_driver_state(dev->otherend) == |
| 2152 | XenbusStateClosing || | 2148 | XenbusStateClosing || |
| 2153 | xenbus_read_driver_state(dev->otherend) == | 2149 | xenbus_read_driver_state(dev->otherend) == |
| 2154 | XenbusStateUnknown); | 2150 | XenbusStateUnknown); |
| 2155 | 2151 | ||
| 2156 | xenbus_switch_state(dev, XenbusStateClosed); | 2152 | xenbus_switch_state(dev, XenbusStateClosed); |
| 2157 | wait_event(module_unload_q, | 2153 | wait_event(module_wq, |
| 2158 | xenbus_read_driver_state(dev->otherend) == | 2154 | xenbus_read_driver_state(dev->otherend) == |
| 2159 | XenbusStateClosed || | 2155 | XenbusStateClosed || |
| 2160 | xenbus_read_driver_state(dev->otherend) == | 2156 | xenbus_read_driver_state(dev->otherend) == |
diff --git a/drivers/nvme/target/rdma.c b/drivers/nvme/target/rdma.c index 3533e918ea37..bfc4da660bb4 100644 --- a/drivers/nvme/target/rdma.c +++ b/drivers/nvme/target/rdma.c | |||
| @@ -66,6 +66,7 @@ struct nvmet_rdma_rsp { | |||
| 66 | 66 | ||
| 67 | struct nvmet_req req; | 67 | struct nvmet_req req; |
| 68 | 68 | ||
| 69 | bool allocated; | ||
| 69 | u8 n_rdma; | 70 | u8 n_rdma; |
| 70 | u32 flags; | 71 | u32 flags; |
| 71 | u32 invalidate_rkey; | 72 | u32 invalidate_rkey; |
| @@ -174,11 +175,19 @@ nvmet_rdma_get_rsp(struct nvmet_rdma_queue *queue) | |||
| 174 | unsigned long flags; | 175 | unsigned long flags; |
| 175 | 176 | ||
| 176 | spin_lock_irqsave(&queue->rsps_lock, flags); | 177 | spin_lock_irqsave(&queue->rsps_lock, flags); |
| 177 | rsp = list_first_entry(&queue->free_rsps, | 178 | rsp = list_first_entry_or_null(&queue->free_rsps, |
| 178 | struct nvmet_rdma_rsp, free_list); | 179 | struct nvmet_rdma_rsp, free_list); |
| 179 | list_del(&rsp->free_list); | 180 | if (likely(rsp)) |
| 181 | list_del(&rsp->free_list); | ||
| 180 | spin_unlock_irqrestore(&queue->rsps_lock, flags); | 182 | spin_unlock_irqrestore(&queue->rsps_lock, flags); |
| 181 | 183 | ||
| 184 | if (unlikely(!rsp)) { | ||
| 185 | rsp = kmalloc(sizeof(*rsp), GFP_KERNEL); | ||
| 186 | if (unlikely(!rsp)) | ||
| 187 | return NULL; | ||
| 188 | rsp->allocated = true; | ||
| 189 | } | ||
| 190 | |||
| 182 | return rsp; | 191 | return rsp; |
| 183 | } | 192 | } |
| 184 | 193 | ||
| @@ -187,6 +196,11 @@ nvmet_rdma_put_rsp(struct nvmet_rdma_rsp *rsp) | |||
| 187 | { | 196 | { |
| 188 | unsigned long flags; | 197 | unsigned long flags; |
| 189 | 198 | ||
| 199 | if (rsp->allocated) { | ||
| 200 | kfree(rsp); | ||
| 201 | return; | ||
| 202 | } | ||
| 203 | |||
| 190 | spin_lock_irqsave(&rsp->queue->rsps_lock, flags); | 204 | spin_lock_irqsave(&rsp->queue->rsps_lock, flags); |
| 191 | list_add_tail(&rsp->free_list, &rsp->queue->free_rsps); | 205 | list_add_tail(&rsp->free_list, &rsp->queue->free_rsps); |
| 192 | spin_unlock_irqrestore(&rsp->queue->rsps_lock, flags); | 206 | spin_unlock_irqrestore(&rsp->queue->rsps_lock, flags); |
| @@ -776,6 +790,15 @@ static void nvmet_rdma_recv_done(struct ib_cq *cq, struct ib_wc *wc) | |||
| 776 | 790 | ||
| 777 | cmd->queue = queue; | 791 | cmd->queue = queue; |
| 778 | rsp = nvmet_rdma_get_rsp(queue); | 792 | rsp = nvmet_rdma_get_rsp(queue); |
| 793 | if (unlikely(!rsp)) { | ||
| 794 | /* | ||
| 795 | * we get here only under memory pressure, | ||
| 796 | * silently drop and have the host retry | ||
| 797 | * as we can't even fail it. | ||
| 798 | */ | ||
| 799 | nvmet_rdma_post_recv(queue->dev, cmd); | ||
| 800 | return; | ||
| 801 | } | ||
| 779 | rsp->queue = queue; | 802 | rsp->queue = queue; |
| 780 | rsp->cmd = cmd; | 803 | rsp->cmd = cmd; |
| 781 | rsp->flags = 0; | 804 | rsp->flags = 0; |
diff --git a/drivers/of/base.c b/drivers/of/base.c index 9095b8290150..74eaedd5b860 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c | |||
| @@ -140,6 +140,9 @@ void of_populate_phandle_cache(void) | |||
| 140 | if (np->phandle && np->phandle != OF_PHANDLE_ILLEGAL) | 140 | if (np->phandle && np->phandle != OF_PHANDLE_ILLEGAL) |
| 141 | phandles++; | 141 | phandles++; |
| 142 | 142 | ||
| 143 | if (!phandles) | ||
| 144 | goto out; | ||
| 145 | |||
| 143 | cache_entries = roundup_pow_of_two(phandles); | 146 | cache_entries = roundup_pow_of_two(phandles); |
| 144 | phandle_cache_mask = cache_entries - 1; | 147 | phandle_cache_mask = cache_entries - 1; |
| 145 | 148 | ||
diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c index 7136e3430925..a938abdb41ce 100644 --- a/drivers/pci/hotplug/pciehp_hpc.c +++ b/drivers/pci/hotplug/pciehp_hpc.c | |||
| @@ -496,7 +496,7 @@ int pciehp_power_on_slot(struct slot *slot) | |||
| 496 | u16 slot_status; | 496 | u16 slot_status; |
| 497 | int retval; | 497 | int retval; |
| 498 | 498 | ||
| 499 | /* Clear sticky power-fault bit from previous power failures */ | 499 | /* Clear power-fault bit from previous power failures */ |
| 500 | pcie_capability_read_word(pdev, PCI_EXP_SLTSTA, &slot_status); | 500 | pcie_capability_read_word(pdev, PCI_EXP_SLTSTA, &slot_status); |
| 501 | if (slot_status & PCI_EXP_SLTSTA_PFD) | 501 | if (slot_status & PCI_EXP_SLTSTA_PFD) |
| 502 | pcie_capability_write_word(pdev, PCI_EXP_SLTSTA, | 502 | pcie_capability_write_word(pdev, PCI_EXP_SLTSTA, |
| @@ -646,6 +646,14 @@ static irqreturn_t pciehp_ist(int irq, void *dev_id) | |||
| 646 | pciehp_handle_button_press(slot); | 646 | pciehp_handle_button_press(slot); |
| 647 | } | 647 | } |
| 648 | 648 | ||
| 649 | /* Check Power Fault Detected */ | ||
| 650 | if ((events & PCI_EXP_SLTSTA_PFD) && !ctrl->power_fault_detected) { | ||
| 651 | ctrl->power_fault_detected = 1; | ||
| 652 | ctrl_err(ctrl, "Slot(%s): Power fault\n", slot_name(slot)); | ||
| 653 | pciehp_set_attention_status(slot, 1); | ||
| 654 | pciehp_green_led_off(slot); | ||
| 655 | } | ||
| 656 | |||
| 649 | /* | 657 | /* |
| 650 | * Disable requests have higher priority than Presence Detect Changed | 658 | * Disable requests have higher priority than Presence Detect Changed |
| 651 | * or Data Link Layer State Changed events. | 659 | * or Data Link Layer State Changed events. |
| @@ -657,14 +665,6 @@ static irqreturn_t pciehp_ist(int irq, void *dev_id) | |||
| 657 | pciehp_handle_presence_or_link_change(slot, events); | 665 | pciehp_handle_presence_or_link_change(slot, events); |
| 658 | up_read(&ctrl->reset_lock); | 666 | up_read(&ctrl->reset_lock); |
| 659 | 667 | ||
| 660 | /* Check Power Fault Detected */ | ||
| 661 | if ((events & PCI_EXP_SLTSTA_PFD) && !ctrl->power_fault_detected) { | ||
| 662 | ctrl->power_fault_detected = 1; | ||
| 663 | ctrl_err(ctrl, "Slot(%s): Power fault\n", slot_name(slot)); | ||
| 664 | pciehp_set_attention_status(slot, 1); | ||
| 665 | pciehp_green_led_off(slot); | ||
| 666 | } | ||
| 667 | |||
| 668 | pci_config_pm_runtime_put(pdev); | 668 | pci_config_pm_runtime_put(pdev); |
| 669 | wake_up(&ctrl->requester); | 669 | wake_up(&ctrl->requester); |
| 670 | return IRQ_HANDLED; | 670 | return IRQ_HANDLED; |
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 29ff9619b5fa..1835f3a7aa8d 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c | |||
| @@ -4547,6 +4547,7 @@ int pci_bridge_secondary_bus_reset(struct pci_dev *dev) | |||
| 4547 | 4547 | ||
| 4548 | return pci_dev_wait(dev, "bus reset", PCIE_RESET_READY_POLL_MS); | 4548 | return pci_dev_wait(dev, "bus reset", PCIE_RESET_READY_POLL_MS); |
| 4549 | } | 4549 | } |
| 4550 | EXPORT_SYMBOL_GPL(pci_bridge_secondary_bus_reset); | ||
| 4550 | 4551 | ||
| 4551 | static int pci_parent_bus_reset(struct pci_dev *dev, int probe) | 4552 | static int pci_parent_bus_reset(struct pci_dev *dev, int probe) |
| 4552 | { | 4553 | { |
| @@ -5200,7 +5201,7 @@ static int __pci_reset_bus(struct pci_bus *bus) | |||
| 5200 | */ | 5201 | */ |
| 5201 | int pci_reset_bus(struct pci_dev *pdev) | 5202 | int pci_reset_bus(struct pci_dev *pdev) |
| 5202 | { | 5203 | { |
| 5203 | return pci_probe_reset_slot(pdev->slot) ? | 5204 | return (!pci_probe_reset_slot(pdev->slot)) ? |
| 5204 | __pci_reset_slot(pdev->slot) : __pci_reset_bus(pdev->bus); | 5205 | __pci_reset_slot(pdev->slot) : __pci_reset_bus(pdev->bus); |
| 5205 | } | 5206 | } |
| 5206 | EXPORT_SYMBOL_GPL(pci_reset_bus); | 5207 | EXPORT_SYMBOL_GPL(pci_reset_bus); |
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index ec784009a36b..201f9e5ff55c 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c | |||
| @@ -2074,6 +2074,7 @@ static void pci_configure_eetlp_prefix(struct pci_dev *dev) | |||
| 2074 | { | 2074 | { |
| 2075 | #ifdef CONFIG_PCI_PASID | 2075 | #ifdef CONFIG_PCI_PASID |
| 2076 | struct pci_dev *bridge; | 2076 | struct pci_dev *bridge; |
| 2077 | int pcie_type; | ||
| 2077 | u32 cap; | 2078 | u32 cap; |
| 2078 | 2079 | ||
| 2079 | if (!pci_is_pcie(dev)) | 2080 | if (!pci_is_pcie(dev)) |
| @@ -2083,7 +2084,9 @@ static void pci_configure_eetlp_prefix(struct pci_dev *dev) | |||
| 2083 | if (!(cap & PCI_EXP_DEVCAP2_EE_PREFIX)) | 2084 | if (!(cap & PCI_EXP_DEVCAP2_EE_PREFIX)) |
| 2084 | return; | 2085 | return; |
| 2085 | 2086 | ||
| 2086 | if (pci_pcie_type(dev) == PCI_EXP_TYPE_ROOT_PORT) | 2087 | pcie_type = pci_pcie_type(dev); |
| 2088 | if (pcie_type == PCI_EXP_TYPE_ROOT_PORT || | ||
| 2089 | pcie_type == PCI_EXP_TYPE_RC_END) | ||
| 2087 | dev->eetlp_prefix_path = 1; | 2090 | dev->eetlp_prefix_path = 1; |
| 2088 | else { | 2091 | else { |
| 2089 | bridge = pci_upstream_bridge(dev); | 2092 | bridge = pci_upstream_bridge(dev); |
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index ef7143a274e0..6bc27b7fd452 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c | |||
| @@ -4355,11 +4355,6 @@ static int pci_quirk_qcom_rp_acs(struct pci_dev *dev, u16 acs_flags) | |||
| 4355 | * | 4355 | * |
| 4356 | * 0x9d10-0x9d1b PCI Express Root port #{1-12} | 4356 | * 0x9d10-0x9d1b PCI Express Root port #{1-12} |
| 4357 | * | 4357 | * |
| 4358 | * The 300 series chipset suffers from the same bug so include those root | ||
| 4359 | * ports here as well. | ||
| 4360 | * | ||
| 4361 | * 0xa32c-0xa343 PCI Express Root port #{0-24} | ||
| 4362 | * | ||
| 4363 | * [1] http://www.intel.com/content/www/us/en/chipsets/100-series-chipset-datasheet-vol-2.html | 4358 | * [1] http://www.intel.com/content/www/us/en/chipsets/100-series-chipset-datasheet-vol-2.html |
| 4364 | * [2] http://www.intel.com/content/www/us/en/chipsets/100-series-chipset-datasheet-vol-1.html | 4359 | * [2] http://www.intel.com/content/www/us/en/chipsets/100-series-chipset-datasheet-vol-1.html |
| 4365 | * [3] http://www.intel.com/content/www/us/en/chipsets/100-series-chipset-spec-update.html | 4360 | * [3] http://www.intel.com/content/www/us/en/chipsets/100-series-chipset-spec-update.html |
| @@ -4377,7 +4372,6 @@ static bool pci_quirk_intel_spt_pch_acs_match(struct pci_dev *dev) | |||
| 4377 | case 0xa110 ... 0xa11f: case 0xa167 ... 0xa16a: /* Sunrise Point */ | 4372 | case 0xa110 ... 0xa11f: case 0xa167 ... 0xa16a: /* Sunrise Point */ |
| 4378 | case 0xa290 ... 0xa29f: case 0xa2e7 ... 0xa2ee: /* Union Point */ | 4373 | case 0xa290 ... 0xa29f: case 0xa2e7 ... 0xa2ee: /* Union Point */ |
| 4379 | case 0x9d10 ... 0x9d1b: /* 7th & 8th Gen Mobile */ | 4374 | case 0x9d10 ... 0x9d1b: /* 7th & 8th Gen Mobile */ |
| 4380 | case 0xa32c ... 0xa343: /* 300 series */ | ||
| 4381 | return true; | 4375 | return true; |
| 4382 | } | 4376 | } |
| 4383 | 4377 | ||
diff --git a/drivers/pci/switch/switchtec.c b/drivers/pci/switch/switchtec.c index 9940cc70f38b..54a8b30dda38 100644 --- a/drivers/pci/switch/switchtec.c +++ b/drivers/pci/switch/switchtec.c | |||
| @@ -14,6 +14,8 @@ | |||
| 14 | #include <linux/poll.h> | 14 | #include <linux/poll.h> |
| 15 | #include <linux/wait.h> | 15 | #include <linux/wait.h> |
| 16 | 16 | ||
| 17 | #include <linux/nospec.h> | ||
| 18 | |||
| 17 | MODULE_DESCRIPTION("Microsemi Switchtec(tm) PCIe Management Driver"); | 19 | MODULE_DESCRIPTION("Microsemi Switchtec(tm) PCIe Management Driver"); |
| 18 | MODULE_VERSION("0.1"); | 20 | MODULE_VERSION("0.1"); |
| 19 | MODULE_LICENSE("GPL"); | 21 | MODULE_LICENSE("GPL"); |
| @@ -909,6 +911,8 @@ static int ioctl_port_to_pff(struct switchtec_dev *stdev, | |||
| 909 | default: | 911 | default: |
| 910 | if (p.port > ARRAY_SIZE(pcfg->dsp_pff_inst_id)) | 912 | if (p.port > ARRAY_SIZE(pcfg->dsp_pff_inst_id)) |
| 911 | return -EINVAL; | 913 | return -EINVAL; |
| 914 | p.port = array_index_nospec(p.port, | ||
| 915 | ARRAY_SIZE(pcfg->dsp_pff_inst_id) + 1); | ||
| 912 | p.pff = ioread32(&pcfg->dsp_pff_inst_id[p.port - 1]); | 916 | p.pff = ioread32(&pcfg->dsp_pff_inst_id[p.port - 1]); |
| 913 | break; | 917 | break; |
| 914 | } | 918 | } |
diff --git a/drivers/pinctrl/cirrus/pinctrl-madera-core.c b/drivers/pinctrl/cirrus/pinctrl-madera-core.c index ece41fb2848f..c4f4d904e4a6 100644 --- a/drivers/pinctrl/cirrus/pinctrl-madera-core.c +++ b/drivers/pinctrl/cirrus/pinctrl-madera-core.c | |||
| @@ -1040,7 +1040,7 @@ static int madera_pin_probe(struct platform_device *pdev) | |||
| 1040 | } | 1040 | } |
| 1041 | 1041 | ||
| 1042 | /* if the configuration is provided through pdata, apply it */ | 1042 | /* if the configuration is provided through pdata, apply it */ |
| 1043 | if (pdata) { | 1043 | if (pdata && pdata->gpio_configs) { |
| 1044 | ret = pinctrl_register_mappings(pdata->gpio_configs, | 1044 | ret = pinctrl_register_mappings(pdata->gpio_configs, |
| 1045 | pdata->n_gpio_configs); | 1045 | pdata->n_gpio_configs); |
| 1046 | if (ret) { | 1046 | if (ret) { |
diff --git a/drivers/pinctrl/pinctrl-ingenic.c b/drivers/pinctrl/pinctrl-ingenic.c index 6a1b6058b991..628817c40e3b 100644 --- a/drivers/pinctrl/pinctrl-ingenic.c +++ b/drivers/pinctrl/pinctrl-ingenic.c | |||
| @@ -793,7 +793,7 @@ static int ingenic_pinctrl_probe(struct platform_device *pdev) | |||
| 793 | 793 | ||
| 794 | err = pinctrl_generic_add_group(jzpc->pctl, group->name, | 794 | err = pinctrl_generic_add_group(jzpc->pctl, group->name, |
| 795 | group->pins, group->num_pins, group->data); | 795 | group->pins, group->num_pins, group->data); |
| 796 | if (err) { | 796 | if (err < 0) { |
| 797 | dev_err(dev, "Failed to register group %s\n", | 797 | dev_err(dev, "Failed to register group %s\n", |
| 798 | group->name); | 798 | group->name); |
| 799 | return err; | 799 | return err; |
| @@ -806,7 +806,7 @@ static int ingenic_pinctrl_probe(struct platform_device *pdev) | |||
| 806 | err = pinmux_generic_add_function(jzpc->pctl, func->name, | 806 | err = pinmux_generic_add_function(jzpc->pctl, func->name, |
| 807 | func->group_names, func->num_group_names, | 807 | func->group_names, func->num_group_names, |
| 808 | func->data); | 808 | func->data); |
| 809 | if (err) { | 809 | if (err < 0) { |
| 810 | dev_err(dev, "Failed to register function %s\n", | 810 | dev_err(dev, "Failed to register function %s\n", |
| 811 | func->name); | 811 | func->name); |
| 812 | return err; | 812 | return err; |
diff --git a/drivers/pinctrl/qcom/pinctrl-msm.c b/drivers/pinctrl/qcom/pinctrl-msm.c index 2155a30c282b..5d72ffad32c2 100644 --- a/drivers/pinctrl/qcom/pinctrl-msm.c +++ b/drivers/pinctrl/qcom/pinctrl-msm.c | |||
| @@ -634,6 +634,29 @@ static void msm_gpio_irq_mask(struct irq_data *d) | |||
| 634 | raw_spin_lock_irqsave(&pctrl->lock, flags); | 634 | raw_spin_lock_irqsave(&pctrl->lock, flags); |
| 635 | 635 | ||
| 636 | val = readl(pctrl->regs + g->intr_cfg_reg); | 636 | val = readl(pctrl->regs + g->intr_cfg_reg); |
| 637 | /* | ||
| 638 | * There are two bits that control interrupt forwarding to the CPU. The | ||
| 639 | * RAW_STATUS_EN bit causes the level or edge sensed on the line to be | ||
| 640 | * latched into the interrupt status register when the hardware detects | ||
| 641 | * an irq that it's configured for (either edge for edge type or level | ||
| 642 | * for level type irq). The 'non-raw' status enable bit causes the | ||
| 643 | * hardware to assert the summary interrupt to the CPU if the latched | ||
| 644 | * status bit is set. There's a bug though, the edge detection logic | ||
| 645 | * seems to have a problem where toggling the RAW_STATUS_EN bit may | ||
| 646 | * cause the status bit to latch spuriously when there isn't any edge | ||
| 647 | * so we can't touch that bit for edge type irqs and we have to keep | ||
| 648 | * the bit set anyway so that edges are latched while the line is masked. | ||
| 649 | * | ||
| 650 | * To make matters more complicated, leaving the RAW_STATUS_EN bit | ||
| 651 | * enabled all the time causes level interrupts to re-latch into the | ||
| 652 | * status register because the level is still present on the line after | ||
| 653 | * we ack it. We clear the raw status enable bit during mask here and | ||
| 654 | * set the bit on unmask so the interrupt can't latch into the hardware | ||
| 655 | * while it's masked. | ||
| 656 | */ | ||
| 657 | if (irqd_get_trigger_type(d) & IRQ_TYPE_LEVEL_MASK) | ||
| 658 | val &= ~BIT(g->intr_raw_status_bit); | ||
| 659 | |||
| 637 | val &= ~BIT(g->intr_enable_bit); | 660 | val &= ~BIT(g->intr_enable_bit); |
| 638 | writel(val, pctrl->regs + g->intr_cfg_reg); | 661 | writel(val, pctrl->regs + g->intr_cfg_reg); |
| 639 | 662 | ||
| @@ -655,6 +678,7 @@ static void msm_gpio_irq_unmask(struct irq_data *d) | |||
| 655 | raw_spin_lock_irqsave(&pctrl->lock, flags); | 678 | raw_spin_lock_irqsave(&pctrl->lock, flags); |
| 656 | 679 | ||
| 657 | val = readl(pctrl->regs + g->intr_cfg_reg); | 680 | val = readl(pctrl->regs + g->intr_cfg_reg); |
| 681 | val |= BIT(g->intr_raw_status_bit); | ||
| 658 | val |= BIT(g->intr_enable_bit); | 682 | val |= BIT(g->intr_enable_bit); |
| 659 | writel(val, pctrl->regs + g->intr_cfg_reg); | 683 | writel(val, pctrl->regs + g->intr_cfg_reg); |
| 660 | 684 | ||
diff --git a/drivers/s390/crypto/ap_bus.c b/drivers/s390/crypto/ap_bus.c index ec891bc7d10a..f039266b275d 100644 --- a/drivers/s390/crypto/ap_bus.c +++ b/drivers/s390/crypto/ap_bus.c | |||
| @@ -872,8 +872,6 @@ static int hex2bitmap(const char *str, unsigned long *bitmap, int bits) | |||
| 872 | if (bits & 0x07) | 872 | if (bits & 0x07) |
| 873 | return -EINVAL; | 873 | return -EINVAL; |
| 874 | 874 | ||
| 875 | memset(bitmap, 0, bits / 8); | ||
| 876 | |||
| 877 | if (str[0] == '0' && str[1] == 'x') | 875 | if (str[0] == '0' && str[1] == 'x') |
| 878 | str++; | 876 | str++; |
| 879 | if (*str == 'x') | 877 | if (*str == 'x') |
| @@ -895,25 +893,23 @@ static int hex2bitmap(const char *str, unsigned long *bitmap, int bits) | |||
| 895 | } | 893 | } |
| 896 | 894 | ||
| 897 | /* | 895 | /* |
| 898 | * str2clrsetmasks() - parse bitmask argument and set the clear and | 896 | * modify_bitmap() - parse bitmask argument and modify an existing |
| 899 | * the set bitmap mask. A concatenation (done with ',') of these terms | 897 | * bit mask accordingly. A concatenation (done with ',') of these |
| 900 | * is recognized: | 898 | * terms is recognized: |
| 901 | * +<bitnr>[-<bitnr>] or -<bitnr>[-<bitnr>] | 899 | * +<bitnr>[-<bitnr>] or -<bitnr>[-<bitnr>] |
| 902 | * <bitnr> may be any valid number (hex, decimal or octal) in the range | 900 | * <bitnr> may be any valid number (hex, decimal or octal) in the range |
| 903 | * 0...bits-1; the leading + or - is required. Here are some examples: | 901 | * 0...bits-1; the leading + or - is required. Here are some examples: |
| 904 | * +0-15,+32,-128,-0xFF | 902 | * +0-15,+32,-128,-0xFF |
| 905 | * -0-255,+1-16,+0x128 | 903 | * -0-255,+1-16,+0x128 |
| 906 | * +1,+2,+3,+4,-5,-7-10 | 904 | * +1,+2,+3,+4,-5,-7-10 |
| 907 | * Returns a clear and a set bitmask. Every positive value in the string | 905 | * Returns the new bitmap after all changes have been applied. Every |
| 908 | * results in a bit set in the set mask and every negative value in the | 906 | * positive value in the string will set a bit and every negative value |
| 909 | * string results in a bit SET in the clear mask. As a bit may be touched | 907 | * in the string will clear a bit. As a bit may be touched more than once, |
| 910 | * more than once, the last 'operation' wins: +0-255,-128 = all but bit | 908 | * the last 'operation' wins: |
| 911 | * 128 set in the set mask, only bit 128 set in the clear mask. | 909 | * +0-255,-128 = first bits 0-255 will be set, then bit 128 will be |
| 910 | * cleared again. All other bits are unmodified. | ||
| 912 | */ | 911 | */ |
| 913 | static int str2clrsetmasks(const char *str, | 912 | static int modify_bitmap(const char *str, unsigned long *bitmap, int bits) |
| 914 | unsigned long *clrmap, | ||
| 915 | unsigned long *setmap, | ||
| 916 | int bits) | ||
| 917 | { | 913 | { |
| 918 | int a, i, z; | 914 | int a, i, z; |
| 919 | char *np, sign; | 915 | char *np, sign; |
| @@ -922,9 +918,6 @@ static int str2clrsetmasks(const char *str, | |||
| 922 | if (bits & 0x07) | 918 | if (bits & 0x07) |
| 923 | return -EINVAL; | 919 | return -EINVAL; |
| 924 | 920 | ||
| 925 | memset(clrmap, 0, bits / 8); | ||
| 926 | memset(setmap, 0, bits / 8); | ||
| 927 | |||
| 928 | while (*str) { | 921 | while (*str) { |
| 929 | sign = *str++; | 922 | sign = *str++; |
| 930 | if (sign != '+' && sign != '-') | 923 | if (sign != '+' && sign != '-') |
| @@ -940,13 +933,10 @@ static int str2clrsetmasks(const char *str, | |||
| 940 | str = np; | 933 | str = np; |
| 941 | } | 934 | } |
| 942 | for (i = a; i <= z; i++) | 935 | for (i = a; i <= z; i++) |
| 943 | if (sign == '+') { | 936 | if (sign == '+') |
| 944 | set_bit_inv(i, setmap); | 937 | set_bit_inv(i, bitmap); |
| 945 | clear_bit_inv(i, clrmap); | 938 | else |
| 946 | } else { | 939 | clear_bit_inv(i, bitmap); |
| 947 | clear_bit_inv(i, setmap); | ||
| 948 | set_bit_inv(i, clrmap); | ||
| 949 | } | ||
| 950 | while (*str == ',' || *str == '\n') | 940 | while (*str == ',' || *str == '\n') |
| 951 | str++; | 941 | str++; |
| 952 | } | 942 | } |
| @@ -970,44 +960,34 @@ static int process_mask_arg(const char *str, | |||
| 970 | unsigned long *bitmap, int bits, | 960 | unsigned long *bitmap, int bits, |
| 971 | struct mutex *lock) | 961 | struct mutex *lock) |
| 972 | { | 962 | { |
| 973 | int i; | 963 | unsigned long *newmap, size; |
| 964 | int rc; | ||
| 974 | 965 | ||
| 975 | /* bits needs to be a multiple of 8 */ | 966 | /* bits needs to be a multiple of 8 */ |
| 976 | if (bits & 0x07) | 967 | if (bits & 0x07) |
| 977 | return -EINVAL; | 968 | return -EINVAL; |
| 978 | 969 | ||
| 970 | size = BITS_TO_LONGS(bits)*sizeof(unsigned long); | ||
| 971 | newmap = kmalloc(size, GFP_KERNEL); | ||
| 972 | if (!newmap) | ||
| 973 | return -ENOMEM; | ||
| 974 | if (mutex_lock_interruptible(lock)) { | ||
| 975 | kfree(newmap); | ||
| 976 | return -ERESTARTSYS; | ||
| 977 | } | ||
| 978 | |||
| 979 | if (*str == '+' || *str == '-') { | 979 | if (*str == '+' || *str == '-') { |
| 980 | DECLARE_BITMAP(clrm, bits); | 980 | memcpy(newmap, bitmap, size); |
| 981 | DECLARE_BITMAP(setm, bits); | 981 | rc = modify_bitmap(str, newmap, bits); |
| 982 | |||
| 983 | i = str2clrsetmasks(str, clrm, setm, bits); | ||
| 984 | if (i) | ||
| 985 | return i; | ||
| 986 | if (mutex_lock_interruptible(lock)) | ||
| 987 | return -ERESTARTSYS; | ||
| 988 | for (i = 0; i < bits; i++) { | ||
| 989 | if (test_bit_inv(i, clrm)) | ||
| 990 | clear_bit_inv(i, bitmap); | ||
| 991 | if (test_bit_inv(i, setm)) | ||
| 992 | set_bit_inv(i, bitmap); | ||
| 993 | } | ||
| 994 | } else { | 982 | } else { |
| 995 | DECLARE_BITMAP(setm, bits); | 983 | memset(newmap, 0, size); |
| 996 | 984 | rc = hex2bitmap(str, newmap, bits); | |
| 997 | i = hex2bitmap(str, setm, bits); | ||
| 998 | if (i) | ||
| 999 | return i; | ||
| 1000 | if (mutex_lock_interruptible(lock)) | ||
| 1001 | return -ERESTARTSYS; | ||
| 1002 | for (i = 0; i < bits; i++) | ||
| 1003 | if (test_bit_inv(i, setm)) | ||
| 1004 | set_bit_inv(i, bitmap); | ||
| 1005 | else | ||
| 1006 | clear_bit_inv(i, bitmap); | ||
| 1007 | } | 985 | } |
| 986 | if (rc == 0) | ||
| 987 | memcpy(bitmap, newmap, size); | ||
| 1008 | mutex_unlock(lock); | 988 | mutex_unlock(lock); |
| 1009 | 989 | kfree(newmap); | |
| 1010 | return 0; | 990 | return rc; |
| 1011 | } | 991 | } |
| 1012 | 992 | ||
| 1013 | /* | 993 | /* |
diff --git a/drivers/s390/net/qeth_core_main.c b/drivers/s390/net/qeth_core_main.c index 49f64eb3eab0..de8282420f96 100644 --- a/drivers/s390/net/qeth_core_main.c +++ b/drivers/s390/net/qeth_core_main.c | |||
| @@ -25,6 +25,7 @@ | |||
| 25 | #include <linux/netdevice.h> | 25 | #include <linux/netdevice.h> |
| 26 | #include <linux/netdev_features.h> | 26 | #include <linux/netdev_features.h> |
| 27 | #include <linux/skbuff.h> | 27 | #include <linux/skbuff.h> |
| 28 | #include <linux/vmalloc.h> | ||
| 28 | 29 | ||
| 29 | #include <net/iucv/af_iucv.h> | 30 | #include <net/iucv/af_iucv.h> |
| 30 | #include <net/dsfield.h> | 31 | #include <net/dsfield.h> |
| @@ -4699,7 +4700,7 @@ static int qeth_query_oat_command(struct qeth_card *card, char __user *udata) | |||
| 4699 | 4700 | ||
| 4700 | priv.buffer_len = oat_data.buffer_len; | 4701 | priv.buffer_len = oat_data.buffer_len; |
| 4701 | priv.response_len = 0; | 4702 | priv.response_len = 0; |
| 4702 | priv.buffer = kzalloc(oat_data.buffer_len, GFP_KERNEL); | 4703 | priv.buffer = vzalloc(oat_data.buffer_len); |
| 4703 | if (!priv.buffer) { | 4704 | if (!priv.buffer) { |
| 4704 | rc = -ENOMEM; | 4705 | rc = -ENOMEM; |
| 4705 | goto out; | 4706 | goto out; |
| @@ -4740,7 +4741,7 @@ static int qeth_query_oat_command(struct qeth_card *card, char __user *udata) | |||
| 4740 | rc = -EFAULT; | 4741 | rc = -EFAULT; |
| 4741 | 4742 | ||
| 4742 | out_free: | 4743 | out_free: |
| 4743 | kfree(priv.buffer); | 4744 | vfree(priv.buffer); |
| 4744 | out: | 4745 | out: |
| 4745 | return rc; | 4746 | return rc; |
| 4746 | } | 4747 | } |
| @@ -5706,6 +5707,8 @@ static struct net_device *qeth_alloc_netdev(struct qeth_card *card) | |||
| 5706 | dev->priv_flags &= ~IFF_TX_SKB_SHARING; | 5707 | dev->priv_flags &= ~IFF_TX_SKB_SHARING; |
| 5707 | dev->hw_features |= NETIF_F_SG; | 5708 | dev->hw_features |= NETIF_F_SG; |
| 5708 | dev->vlan_features |= NETIF_F_SG; | 5709 | dev->vlan_features |= NETIF_F_SG; |
| 5710 | if (IS_IQD(card)) | ||
| 5711 | dev->features |= NETIF_F_SG; | ||
| 5709 | } | 5712 | } |
| 5710 | 5713 | ||
| 5711 | return dev; | 5714 | return dev; |
| @@ -5768,8 +5771,10 @@ static int qeth_core_probe_device(struct ccwgroup_device *gdev) | |||
| 5768 | qeth_update_from_chp_desc(card); | 5771 | qeth_update_from_chp_desc(card); |
| 5769 | 5772 | ||
| 5770 | card->dev = qeth_alloc_netdev(card); | 5773 | card->dev = qeth_alloc_netdev(card); |
| 5771 | if (!card->dev) | 5774 | if (!card->dev) { |
| 5775 | rc = -ENOMEM; | ||
| 5772 | goto err_card; | 5776 | goto err_card; |
| 5777 | } | ||
| 5773 | 5778 | ||
| 5774 | qeth_determine_capabilities(card); | 5779 | qeth_determine_capabilities(card); |
| 5775 | enforced_disc = qeth_enforce_discipline(card); | 5780 | enforced_disc = qeth_enforce_discipline(card); |
diff --git a/drivers/s390/net/qeth_l2_main.c b/drivers/s390/net/qeth_l2_main.c index 710fa74892ae..b5e38531733f 100644 --- a/drivers/s390/net/qeth_l2_main.c +++ b/drivers/s390/net/qeth_l2_main.c | |||
| @@ -423,7 +423,7 @@ static int qeth_l2_process_inbound_buffer(struct qeth_card *card, | |||
| 423 | default: | 423 | default: |
| 424 | dev_kfree_skb_any(skb); | 424 | dev_kfree_skb_any(skb); |
| 425 | QETH_CARD_TEXT(card, 3, "inbunkno"); | 425 | QETH_CARD_TEXT(card, 3, "inbunkno"); |
| 426 | QETH_DBF_HEX(CTRL, 3, hdr, QETH_DBF_CTRL_LEN); | 426 | QETH_DBF_HEX(CTRL, 3, hdr, sizeof(*hdr)); |
| 427 | continue; | 427 | continue; |
| 428 | } | 428 | } |
| 429 | work_done++; | 429 | work_done++; |
diff --git a/drivers/s390/net/qeth_l3_main.c b/drivers/s390/net/qeth_l3_main.c index 7175086677fb..ada258c01a08 100644 --- a/drivers/s390/net/qeth_l3_main.c +++ b/drivers/s390/net/qeth_l3_main.c | |||
| @@ -1390,7 +1390,7 @@ static int qeth_l3_process_inbound_buffer(struct qeth_card *card, | |||
| 1390 | default: | 1390 | default: |
| 1391 | dev_kfree_skb_any(skb); | 1391 | dev_kfree_skb_any(skb); |
| 1392 | QETH_CARD_TEXT(card, 3, "inbunkno"); | 1392 | QETH_CARD_TEXT(card, 3, "inbunkno"); |
| 1393 | QETH_DBF_HEX(CTRL, 3, hdr, QETH_DBF_CTRL_LEN); | 1393 | QETH_DBF_HEX(CTRL, 3, hdr, sizeof(*hdr)); |
| 1394 | continue; | 1394 | continue; |
| 1395 | } | 1395 | } |
| 1396 | work_done++; | 1396 | work_done++; |
diff --git a/drivers/scsi/qedi/qedi.h b/drivers/scsi/qedi/qedi.h index fc3babc15fa3..a6f96b35e971 100644 --- a/drivers/scsi/qedi/qedi.h +++ b/drivers/scsi/qedi/qedi.h | |||
| @@ -77,6 +77,11 @@ enum qedi_nvm_tgts { | |||
| 77 | QEDI_NVM_TGT_SEC, | 77 | QEDI_NVM_TGT_SEC, |
| 78 | }; | 78 | }; |
| 79 | 79 | ||
| 80 | struct qedi_nvm_iscsi_image { | ||
| 81 | struct nvm_iscsi_cfg iscsi_cfg; | ||
| 82 | u32 crc; | ||
| 83 | }; | ||
| 84 | |||
| 80 | struct qedi_uio_ctrl { | 85 | struct qedi_uio_ctrl { |
| 81 | /* meta data */ | 86 | /* meta data */ |
| 82 | u32 uio_hsi_version; | 87 | u32 uio_hsi_version; |
| @@ -294,7 +299,7 @@ struct qedi_ctx { | |||
| 294 | void *bdq_pbl_list; | 299 | void *bdq_pbl_list; |
| 295 | dma_addr_t bdq_pbl_list_dma; | 300 | dma_addr_t bdq_pbl_list_dma; |
| 296 | u8 bdq_pbl_list_num_entries; | 301 | u8 bdq_pbl_list_num_entries; |
| 297 | struct nvm_iscsi_cfg *iscsi_cfg; | 302 | struct qedi_nvm_iscsi_image *iscsi_image; |
| 298 | dma_addr_t nvm_buf_dma; | 303 | dma_addr_t nvm_buf_dma; |
| 299 | void __iomem *bdq_primary_prod; | 304 | void __iomem *bdq_primary_prod; |
| 300 | void __iomem *bdq_secondary_prod; | 305 | void __iomem *bdq_secondary_prod; |
diff --git a/drivers/scsi/qedi/qedi_main.c b/drivers/scsi/qedi/qedi_main.c index aa96bccb5a96..cc8e64dc65ad 100644 --- a/drivers/scsi/qedi/qedi_main.c +++ b/drivers/scsi/qedi/qedi_main.c | |||
| @@ -1346,23 +1346,26 @@ exit_setup_int: | |||
| 1346 | 1346 | ||
| 1347 | static void qedi_free_nvm_iscsi_cfg(struct qedi_ctx *qedi) | 1347 | static void qedi_free_nvm_iscsi_cfg(struct qedi_ctx *qedi) |
| 1348 | { | 1348 | { |
| 1349 | if (qedi->iscsi_cfg) | 1349 | if (qedi->iscsi_image) |
| 1350 | dma_free_coherent(&qedi->pdev->dev, | 1350 | dma_free_coherent(&qedi->pdev->dev, |
| 1351 | sizeof(struct nvm_iscsi_cfg), | 1351 | sizeof(struct qedi_nvm_iscsi_image), |
| 1352 | qedi->iscsi_cfg, qedi->nvm_buf_dma); | 1352 | qedi->iscsi_image, qedi->nvm_buf_dma); |
| 1353 | } | 1353 | } |
| 1354 | 1354 | ||
| 1355 | static int qedi_alloc_nvm_iscsi_cfg(struct qedi_ctx *qedi) | 1355 | static int qedi_alloc_nvm_iscsi_cfg(struct qedi_ctx *qedi) |
| 1356 | { | 1356 | { |
| 1357 | qedi->iscsi_cfg = dma_zalloc_coherent(&qedi->pdev->dev, | 1357 | struct qedi_nvm_iscsi_image nvm_image; |
| 1358 | sizeof(struct nvm_iscsi_cfg), | 1358 | |
| 1359 | &qedi->nvm_buf_dma, GFP_KERNEL); | 1359 | qedi->iscsi_image = dma_zalloc_coherent(&qedi->pdev->dev, |
| 1360 | if (!qedi->iscsi_cfg) { | 1360 | sizeof(nvm_image), |
| 1361 | &qedi->nvm_buf_dma, | ||
| 1362 | GFP_KERNEL); | ||
| 1363 | if (!qedi->iscsi_image) { | ||
| 1361 | QEDI_ERR(&qedi->dbg_ctx, "Could not allocate NVM BUF.\n"); | 1364 | QEDI_ERR(&qedi->dbg_ctx, "Could not allocate NVM BUF.\n"); |
| 1362 | return -ENOMEM; | 1365 | return -ENOMEM; |
| 1363 | } | 1366 | } |
| 1364 | QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_INFO, | 1367 | QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_INFO, |
| 1365 | "NVM BUF addr=0x%p dma=0x%llx.\n", qedi->iscsi_cfg, | 1368 | "NVM BUF addr=0x%p dma=0x%llx.\n", qedi->iscsi_image, |
| 1366 | qedi->nvm_buf_dma); | 1369 | qedi->nvm_buf_dma); |
| 1367 | 1370 | ||
| 1368 | return 0; | 1371 | return 0; |
| @@ -1905,7 +1908,7 @@ qedi_get_nvram_block(struct qedi_ctx *qedi) | |||
| 1905 | struct nvm_iscsi_block *block; | 1908 | struct nvm_iscsi_block *block; |
| 1906 | 1909 | ||
| 1907 | pf = qedi->dev_info.common.abs_pf_id; | 1910 | pf = qedi->dev_info.common.abs_pf_id; |
| 1908 | block = &qedi->iscsi_cfg->block[0]; | 1911 | block = &qedi->iscsi_image->iscsi_cfg.block[0]; |
| 1909 | for (i = 0; i < NUM_OF_ISCSI_PF_SUPPORTED; i++, block++) { | 1912 | for (i = 0; i < NUM_OF_ISCSI_PF_SUPPORTED; i++, block++) { |
| 1910 | flags = ((block->id) & NVM_ISCSI_CFG_BLK_CTRL_FLAG_MASK) >> | 1913 | flags = ((block->id) & NVM_ISCSI_CFG_BLK_CTRL_FLAG_MASK) >> |
| 1911 | NVM_ISCSI_CFG_BLK_CTRL_FLAG_OFFSET; | 1914 | NVM_ISCSI_CFG_BLK_CTRL_FLAG_OFFSET; |
| @@ -2194,15 +2197,14 @@ static void qedi_boot_release(void *data) | |||
| 2194 | static int qedi_get_boot_info(struct qedi_ctx *qedi) | 2197 | static int qedi_get_boot_info(struct qedi_ctx *qedi) |
| 2195 | { | 2198 | { |
| 2196 | int ret = 1; | 2199 | int ret = 1; |
| 2197 | u16 len; | 2200 | struct qedi_nvm_iscsi_image nvm_image; |
| 2198 | |||
| 2199 | len = sizeof(struct nvm_iscsi_cfg); | ||
| 2200 | 2201 | ||
| 2201 | QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_INFO, | 2202 | QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_INFO, |
| 2202 | "Get NVM iSCSI CFG image\n"); | 2203 | "Get NVM iSCSI CFG image\n"); |
| 2203 | ret = qedi_ops->common->nvm_get_image(qedi->cdev, | 2204 | ret = qedi_ops->common->nvm_get_image(qedi->cdev, |
| 2204 | QED_NVM_IMAGE_ISCSI_CFG, | 2205 | QED_NVM_IMAGE_ISCSI_CFG, |
| 2205 | (char *)qedi->iscsi_cfg, len); | 2206 | (char *)qedi->iscsi_image, |
| 2207 | sizeof(nvm_image)); | ||
| 2206 | if (ret) | 2208 | if (ret) |
| 2207 | QEDI_ERR(&qedi->dbg_ctx, | 2209 | QEDI_ERR(&qedi->dbg_ctx, |
| 2208 | "Could not get NVM image. ret = %d\n", ret); | 2210 | "Could not get NVM image. ret = %d\n", ret); |
diff --git a/drivers/staging/erofs/Kconfig b/drivers/staging/erofs/Kconfig index 96f614934df1..663b755bf2fb 100644 --- a/drivers/staging/erofs/Kconfig +++ b/drivers/staging/erofs/Kconfig | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | 2 | ||
| 3 | config EROFS_FS | 3 | config EROFS_FS |
| 4 | tristate "EROFS filesystem support" | 4 | tristate "EROFS filesystem support" |
| 5 | depends on BROKEN | 5 | depends on BLOCK |
| 6 | help | 6 | help |
| 7 | EROFS(Enhanced Read-Only File System) is a lightweight | 7 | EROFS(Enhanced Read-Only File System) is a lightweight |
| 8 | read-only file system with modern designs (eg. page-sized | 8 | read-only file system with modern designs (eg. page-sized |
diff --git a/drivers/staging/erofs/super.c b/drivers/staging/erofs/super.c index 1aec509c805f..2df9768edac9 100644 --- a/drivers/staging/erofs/super.c +++ b/drivers/staging/erofs/super.c | |||
| @@ -340,7 +340,7 @@ static int erofs_read_super(struct super_block *sb, | |||
| 340 | goto err_sbread; | 340 | goto err_sbread; |
| 341 | 341 | ||
| 342 | sb->s_magic = EROFS_SUPER_MAGIC; | 342 | sb->s_magic = EROFS_SUPER_MAGIC; |
| 343 | sb->s_flags |= MS_RDONLY | MS_NOATIME; | 343 | sb->s_flags |= SB_RDONLY | SB_NOATIME; |
| 344 | sb->s_maxbytes = MAX_LFS_FILESIZE; | 344 | sb->s_maxbytes = MAX_LFS_FILESIZE; |
| 345 | sb->s_time_gran = 1; | 345 | sb->s_time_gran = 1; |
| 346 | 346 | ||
| @@ -627,7 +627,7 @@ static int erofs_remount(struct super_block *sb, int *flags, char *data) | |||
| 627 | { | 627 | { |
| 628 | BUG_ON(!sb_rdonly(sb)); | 628 | BUG_ON(!sb_rdonly(sb)); |
| 629 | 629 | ||
| 630 | *flags |= MS_RDONLY; | 630 | *flags |= SB_RDONLY; |
| 631 | return 0; | 631 | return 0; |
| 632 | } | 632 | } |
| 633 | 633 | ||
diff --git a/drivers/staging/fbtft/TODO b/drivers/staging/fbtft/TODO index 7e64c7e438f0..a9f4802bb6be 100644 --- a/drivers/staging/fbtft/TODO +++ b/drivers/staging/fbtft/TODO | |||
| @@ -2,3 +2,7 @@ | |||
| 2 | GPIO descriptor API in <linux/gpio/consumer.h> and look up GPIO | 2 | GPIO descriptor API in <linux/gpio/consumer.h> and look up GPIO |
| 3 | lines from device tree, ACPI or board files, board files should | 3 | lines from device tree, ACPI or board files, board files should |
| 4 | use <linux/gpio/machine.h> | 4 | use <linux/gpio/machine.h> |
| 5 | |||
| 6 | * convert all these over to drm_simple_display_pipe and submit for inclusion | ||
| 7 | into the DRM subsystem under drivers/gpu/drm - fbdev doesn't take any new | ||
| 8 | drivers anymore. | ||
diff --git a/drivers/staging/gasket/TODO b/drivers/staging/gasket/TODO index 6ff8e01b04cc..5b1865f8af2d 100644 --- a/drivers/staging/gasket/TODO +++ b/drivers/staging/gasket/TODO | |||
| @@ -1,9 +1,22 @@ | |||
| 1 | This is a list of things that need to be done to get this driver out of the | 1 | This is a list of things that need to be done to get this driver out of the |
| 2 | staging directory. | 2 | staging directory. |
| 3 | |||
| 4 | - Implement the gasket framework's functionality through UIO instead of | ||
| 5 | introducing a new user-space drivers framework that is quite similar. | ||
| 6 | |||
| 7 | UIO provides the necessary bits to implement user-space drivers. Meanwhile | ||
| 8 | the gasket APIs adds some extra conveniences like PCI BAR mapping, and | ||
| 9 | MSI interrupts. Add these features to the UIO subsystem, then re-implement | ||
| 10 | the Apex driver as a basic UIO driver instead (include/linux/uio_driver.h) | ||
| 11 | |||
| 3 | - Document sysfs files with Documentation/ABI/ entries. | 12 | - Document sysfs files with Documentation/ABI/ entries. |
| 13 | |||
| 4 | - Use misc interface instead of major number for driver version description. | 14 | - Use misc interface instead of major number for driver version description. |
| 15 | |||
| 5 | - Add descriptions of module_param's | 16 | - Add descriptions of module_param's |
| 17 | |||
| 6 | - apex_get_status() should actually check status. | 18 | - apex_get_status() should actually check status. |
| 19 | |||
| 7 | - "drivers" should never be dealing with "raw" sysfs calls or mess around with | 20 | - "drivers" should never be dealing with "raw" sysfs calls or mess around with |
| 8 | kobjects at all. The driver core should handle all of this for you | 21 | kobjects at all. The driver core should handle all of this for you |
| 9 | automaically. There should not be a need for raw attribute macros. | 22 | automaically. There should not be a need for raw attribute macros. |
diff --git a/drivers/staging/vboxvideo/vbox_drv.c b/drivers/staging/vboxvideo/vbox_drv.c index da92c493f157..69cc508af1bc 100644 --- a/drivers/staging/vboxvideo/vbox_drv.c +++ b/drivers/staging/vboxvideo/vbox_drv.c | |||
| @@ -59,6 +59,11 @@ static int vbox_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
| 59 | ret = PTR_ERR(dev); | 59 | ret = PTR_ERR(dev); |
| 60 | goto err_drv_alloc; | 60 | goto err_drv_alloc; |
| 61 | } | 61 | } |
| 62 | |||
| 63 | ret = pci_enable_device(pdev); | ||
| 64 | if (ret) | ||
| 65 | goto err_pci_enable; | ||
| 66 | |||
| 62 | dev->pdev = pdev; | 67 | dev->pdev = pdev; |
| 63 | pci_set_drvdata(pdev, dev); | 68 | pci_set_drvdata(pdev, dev); |
| 64 | 69 | ||
| @@ -75,6 +80,8 @@ static int vbox_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
| 75 | err_drv_dev_register: | 80 | err_drv_dev_register: |
| 76 | vbox_driver_unload(dev); | 81 | vbox_driver_unload(dev); |
| 77 | err_vbox_driver_load: | 82 | err_vbox_driver_load: |
| 83 | pci_disable_device(pdev); | ||
| 84 | err_pci_enable: | ||
| 78 | drm_dev_put(dev); | 85 | drm_dev_put(dev); |
| 79 | err_drv_alloc: | 86 | err_drv_alloc: |
| 80 | return ret; | 87 | return ret; |
diff --git a/drivers/staging/vboxvideo/vbox_mode.c b/drivers/staging/vboxvideo/vbox_mode.c index a83eac8668d0..79836c8fb909 100644 --- a/drivers/staging/vboxvideo/vbox_mode.c +++ b/drivers/staging/vboxvideo/vbox_mode.c | |||
| @@ -323,6 +323,11 @@ static int vbox_crtc_page_flip(struct drm_crtc *crtc, | |||
| 323 | if (rc) | 323 | if (rc) |
| 324 | return rc; | 324 | return rc; |
| 325 | 325 | ||
| 326 | mutex_lock(&vbox->hw_mutex); | ||
| 327 | vbox_set_view(crtc); | ||
| 328 | vbox_do_modeset(crtc, &crtc->mode); | ||
| 329 | mutex_unlock(&vbox->hw_mutex); | ||
| 330 | |||
| 326 | spin_lock_irqsave(&drm->event_lock, flags); | 331 | spin_lock_irqsave(&drm->event_lock, flags); |
| 327 | 332 | ||
| 328 | if (event) | 333 | if (event) |
diff --git a/drivers/staging/wilc1000/Makefile b/drivers/staging/wilc1000/Makefile index f7b07c0b5ce2..ee7e26b886a5 100644 --- a/drivers/staging/wilc1000/Makefile +++ b/drivers/staging/wilc1000/Makefile | |||
| @@ -1,4 +1,5 @@ | |||
| 1 | # SPDX-License-Identifier: GPL-2.0 | 1 | # SPDX-License-Identifier: GPL-2.0 |
| 2 | obj-$(CONFIG_WILC1000) += wilc1000.o | ||
| 2 | 3 | ||
| 3 | ccflags-y += -DFIRMWARE_1002=\"atmel/wilc1002_firmware.bin\" \ | 4 | ccflags-y += -DFIRMWARE_1002=\"atmel/wilc1002_firmware.bin\" \ |
| 4 | -DFIRMWARE_1003=\"atmel/wilc1003_firmware.bin\" | 5 | -DFIRMWARE_1003=\"atmel/wilc1003_firmware.bin\" |
| @@ -11,9 +12,7 @@ wilc1000-objs := wilc_wfi_cfgoperations.o linux_wlan.o linux_mon.o \ | |||
| 11 | wilc_wlan.o | 12 | wilc_wlan.o |
| 12 | 13 | ||
| 13 | obj-$(CONFIG_WILC1000_SDIO) += wilc1000-sdio.o | 14 | obj-$(CONFIG_WILC1000_SDIO) += wilc1000-sdio.o |
| 14 | wilc1000-sdio-objs += $(wilc1000-objs) | ||
| 15 | wilc1000-sdio-objs += wilc_sdio.o | 15 | wilc1000-sdio-objs += wilc_sdio.o |
| 16 | 16 | ||
| 17 | obj-$(CONFIG_WILC1000_SPI) += wilc1000-spi.o | 17 | obj-$(CONFIG_WILC1000_SPI) += wilc1000-spi.o |
| 18 | wilc1000-spi-objs += $(wilc1000-objs) | ||
| 19 | wilc1000-spi-objs += wilc_spi.o | 18 | wilc1000-spi-objs += wilc_spi.o |
diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c index 01cf4bd2e192..3b8d237decbf 100644 --- a/drivers/staging/wilc1000/linux_wlan.c +++ b/drivers/staging/wilc1000/linux_wlan.c | |||
| @@ -1038,8 +1038,8 @@ void wilc_netdev_cleanup(struct wilc *wilc) | |||
| 1038 | } | 1038 | } |
| 1039 | 1039 | ||
| 1040 | kfree(wilc); | 1040 | kfree(wilc); |
| 1041 | wilc_debugfs_remove(); | ||
| 1042 | } | 1041 | } |
| 1042 | EXPORT_SYMBOL_GPL(wilc_netdev_cleanup); | ||
| 1043 | 1043 | ||
| 1044 | static const struct net_device_ops wilc_netdev_ops = { | 1044 | static const struct net_device_ops wilc_netdev_ops = { |
| 1045 | .ndo_init = mac_init_fn, | 1045 | .ndo_init = mac_init_fn, |
| @@ -1062,7 +1062,6 @@ int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type, | |||
| 1062 | if (!wl) | 1062 | if (!wl) |
| 1063 | return -ENOMEM; | 1063 | return -ENOMEM; |
| 1064 | 1064 | ||
| 1065 | wilc_debugfs_init(); | ||
| 1066 | *wilc = wl; | 1065 | *wilc = wl; |
| 1067 | wl->io_type = io_type; | 1066 | wl->io_type = io_type; |
| 1068 | wl->hif_func = ops; | 1067 | wl->hif_func = ops; |
| @@ -1124,3 +1123,6 @@ int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type, | |||
| 1124 | 1123 | ||
| 1125 | return 0; | 1124 | return 0; |
| 1126 | } | 1125 | } |
| 1126 | EXPORT_SYMBOL_GPL(wilc_netdev_init); | ||
| 1127 | |||
| 1128 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/staging/wilc1000/wilc_debugfs.c b/drivers/staging/wilc1000/wilc_debugfs.c index edc72876458d..8001df66b8c2 100644 --- a/drivers/staging/wilc1000/wilc_debugfs.c +++ b/drivers/staging/wilc1000/wilc_debugfs.c | |||
| @@ -19,6 +19,7 @@ static struct dentry *wilc_dir; | |||
| 19 | 19 | ||
| 20 | #define DBG_LEVEL_ALL (DEBUG | INFO | WRN | ERR) | 20 | #define DBG_LEVEL_ALL (DEBUG | INFO | WRN | ERR) |
| 21 | static atomic_t WILC_DEBUG_LEVEL = ATOMIC_INIT(ERR); | 21 | static atomic_t WILC_DEBUG_LEVEL = ATOMIC_INIT(ERR); |
| 22 | EXPORT_SYMBOL_GPL(WILC_DEBUG_LEVEL); | ||
| 22 | 23 | ||
| 23 | static ssize_t wilc_debug_level_read(struct file *file, char __user *userbuf, | 24 | static ssize_t wilc_debug_level_read(struct file *file, char __user *userbuf, |
| 24 | size_t count, loff_t *ppos) | 25 | size_t count, loff_t *ppos) |
| @@ -87,7 +88,7 @@ static struct wilc_debugfs_info_t debugfs_info[] = { | |||
| 87 | }, | 88 | }, |
| 88 | }; | 89 | }; |
| 89 | 90 | ||
| 90 | int wilc_debugfs_init(void) | 91 | static int __init wilc_debugfs_init(void) |
| 91 | { | 92 | { |
| 92 | int i; | 93 | int i; |
| 93 | struct wilc_debugfs_info_t *info; | 94 | struct wilc_debugfs_info_t *info; |
| @@ -103,10 +104,12 @@ int wilc_debugfs_init(void) | |||
| 103 | } | 104 | } |
| 104 | return 0; | 105 | return 0; |
| 105 | } | 106 | } |
| 107 | module_init(wilc_debugfs_init); | ||
| 106 | 108 | ||
| 107 | void wilc_debugfs_remove(void) | 109 | static void __exit wilc_debugfs_remove(void) |
| 108 | { | 110 | { |
| 109 | debugfs_remove_recursive(wilc_dir); | 111 | debugfs_remove_recursive(wilc_dir); |
| 110 | } | 112 | } |
| 113 | module_exit(wilc_debugfs_remove); | ||
| 111 | 114 | ||
| 112 | #endif | 115 | #endif |
diff --git a/drivers/staging/wilc1000/wilc_wlan.c b/drivers/staging/wilc1000/wilc_wlan.c index 6787b6e9f124..8b184aa30d25 100644 --- a/drivers/staging/wilc1000/wilc_wlan.c +++ b/drivers/staging/wilc1000/wilc_wlan.c | |||
| @@ -417,6 +417,7 @@ void chip_allow_sleep(struct wilc *wilc) | |||
| 417 | wilc->hif_func->hif_write_reg(wilc, 0xf0, reg & ~BIT(0)); | 417 | wilc->hif_func->hif_write_reg(wilc, 0xf0, reg & ~BIT(0)); |
| 418 | wilc->hif_func->hif_write_reg(wilc, 0xfa, 0); | 418 | wilc->hif_func->hif_write_reg(wilc, 0xfa, 0); |
| 419 | } | 419 | } |
| 420 | EXPORT_SYMBOL_GPL(chip_allow_sleep); | ||
| 420 | 421 | ||
| 421 | void chip_wakeup(struct wilc *wilc) | 422 | void chip_wakeup(struct wilc *wilc) |
| 422 | { | 423 | { |
| @@ -471,6 +472,7 @@ void chip_wakeup(struct wilc *wilc) | |||
| 471 | } | 472 | } |
| 472 | chip_ps_state = CHIP_WAKEDUP; | 473 | chip_ps_state = CHIP_WAKEDUP; |
| 473 | } | 474 | } |
| 475 | EXPORT_SYMBOL_GPL(chip_wakeup); | ||
| 474 | 476 | ||
| 475 | void wilc_chip_sleep_manually(struct wilc *wilc) | 477 | void wilc_chip_sleep_manually(struct wilc *wilc) |
| 476 | { | 478 | { |
| @@ -484,6 +486,7 @@ void wilc_chip_sleep_manually(struct wilc *wilc) | |||
| 484 | chip_ps_state = CHIP_SLEEPING_MANUAL; | 486 | chip_ps_state = CHIP_SLEEPING_MANUAL; |
| 485 | release_bus(wilc, RELEASE_ONLY); | 487 | release_bus(wilc, RELEASE_ONLY); |
| 486 | } | 488 | } |
| 489 | EXPORT_SYMBOL_GPL(wilc_chip_sleep_manually); | ||
| 487 | 490 | ||
| 488 | void host_wakeup_notify(struct wilc *wilc) | 491 | void host_wakeup_notify(struct wilc *wilc) |
| 489 | { | 492 | { |
| @@ -491,6 +494,7 @@ void host_wakeup_notify(struct wilc *wilc) | |||
| 491 | wilc->hif_func->hif_write_reg(wilc, 0x10b0, 1); | 494 | wilc->hif_func->hif_write_reg(wilc, 0x10b0, 1); |
| 492 | release_bus(wilc, RELEASE_ONLY); | 495 | release_bus(wilc, RELEASE_ONLY); |
| 493 | } | 496 | } |
| 497 | EXPORT_SYMBOL_GPL(host_wakeup_notify); | ||
| 494 | 498 | ||
| 495 | void host_sleep_notify(struct wilc *wilc) | 499 | void host_sleep_notify(struct wilc *wilc) |
| 496 | { | 500 | { |
| @@ -498,6 +502,7 @@ void host_sleep_notify(struct wilc *wilc) | |||
| 498 | wilc->hif_func->hif_write_reg(wilc, 0x10ac, 1); | 502 | wilc->hif_func->hif_write_reg(wilc, 0x10ac, 1); |
| 499 | release_bus(wilc, RELEASE_ONLY); | 503 | release_bus(wilc, RELEASE_ONLY); |
| 500 | } | 504 | } |
| 505 | EXPORT_SYMBOL_GPL(host_sleep_notify); | ||
| 501 | 506 | ||
| 502 | int wilc_wlan_handle_txq(struct net_device *dev, u32 *txq_count) | 507 | int wilc_wlan_handle_txq(struct net_device *dev, u32 *txq_count) |
| 503 | { | 508 | { |
| @@ -871,6 +876,7 @@ void wilc_handle_isr(struct wilc *wilc) | |||
| 871 | 876 | ||
| 872 | release_bus(wilc, RELEASE_ALLOW_SLEEP); | 877 | release_bus(wilc, RELEASE_ALLOW_SLEEP); |
| 873 | } | 878 | } |
| 879 | EXPORT_SYMBOL_GPL(wilc_handle_isr); | ||
| 874 | 880 | ||
| 875 | int wilc_wlan_firmware_download(struct wilc *wilc, const u8 *buffer, | 881 | int wilc_wlan_firmware_download(struct wilc *wilc, const u8 *buffer, |
| 876 | u32 buffer_size) | 882 | u32 buffer_size) |
diff --git a/drivers/staging/wilc1000/wilc_wlan_if.h b/drivers/staging/wilc1000/wilc_wlan_if.h index 00d13b153f80..b81a73b9bd67 100644 --- a/drivers/staging/wilc1000/wilc_wlan_if.h +++ b/drivers/staging/wilc1000/wilc_wlan_if.h | |||
| @@ -831,6 +831,4 @@ struct wilc; | |||
| 831 | int wilc_wlan_init(struct net_device *dev); | 831 | int wilc_wlan_init(struct net_device *dev); |
| 832 | u32 wilc_get_chipid(struct wilc *wilc, bool update); | 832 | u32 wilc_get_chipid(struct wilc *wilc, bool update); |
| 833 | 833 | ||
| 834 | int wilc_debugfs_init(void); | ||
| 835 | void wilc_debugfs_remove(void); | ||
| 836 | #endif | 834 | #endif |
diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c index 94bad43c41ff..9cdfccbdd06f 100644 --- a/drivers/target/iscsi/iscsi_target.c +++ b/drivers/target/iscsi/iscsi_target.c | |||
| @@ -4208,22 +4208,15 @@ int iscsit_close_connection( | |||
| 4208 | crypto_free_ahash(tfm); | 4208 | crypto_free_ahash(tfm); |
| 4209 | } | 4209 | } |
| 4210 | 4210 | ||
| 4211 | free_cpumask_var(conn->conn_cpumask); | ||
| 4212 | |||
| 4213 | kfree(conn->conn_ops); | ||
| 4214 | conn->conn_ops = NULL; | ||
| 4215 | |||
| 4216 | if (conn->sock) | 4211 | if (conn->sock) |
| 4217 | sock_release(conn->sock); | 4212 | sock_release(conn->sock); |
| 4218 | 4213 | ||
| 4219 | if (conn->conn_transport->iscsit_free_conn) | 4214 | if (conn->conn_transport->iscsit_free_conn) |
| 4220 | conn->conn_transport->iscsit_free_conn(conn); | 4215 | conn->conn_transport->iscsit_free_conn(conn); |
| 4221 | 4216 | ||
| 4222 | iscsit_put_transport(conn->conn_transport); | ||
| 4223 | |||
| 4224 | pr_debug("Moving to TARG_CONN_STATE_FREE.\n"); | 4217 | pr_debug("Moving to TARG_CONN_STATE_FREE.\n"); |
| 4225 | conn->conn_state = TARG_CONN_STATE_FREE; | 4218 | conn->conn_state = TARG_CONN_STATE_FREE; |
| 4226 | kfree(conn); | 4219 | iscsit_free_conn(conn); |
| 4227 | 4220 | ||
| 4228 | spin_lock_bh(&sess->conn_lock); | 4221 | spin_lock_bh(&sess->conn_lock); |
| 4229 | atomic_dec(&sess->nconn); | 4222 | atomic_dec(&sess->nconn); |
diff --git a/drivers/target/iscsi/iscsi_target_login.c b/drivers/target/iscsi/iscsi_target_login.c index 9e74f8bc2963..bb90c80ff388 100644 --- a/drivers/target/iscsi/iscsi_target_login.c +++ b/drivers/target/iscsi/iscsi_target_login.c | |||
| @@ -67,45 +67,10 @@ static struct iscsi_login *iscsi_login_init_conn(struct iscsi_conn *conn) | |||
| 67 | goto out_req_buf; | 67 | goto out_req_buf; |
| 68 | } | 68 | } |
| 69 | 69 | ||
| 70 | conn->conn_ops = kzalloc(sizeof(struct iscsi_conn_ops), GFP_KERNEL); | ||
| 71 | if (!conn->conn_ops) { | ||
| 72 | pr_err("Unable to allocate memory for" | ||
| 73 | " struct iscsi_conn_ops.\n"); | ||
| 74 | goto out_rsp_buf; | ||
| 75 | } | ||
| 76 | |||
| 77 | init_waitqueue_head(&conn->queues_wq); | ||
| 78 | INIT_LIST_HEAD(&conn->conn_list); | ||
| 79 | INIT_LIST_HEAD(&conn->conn_cmd_list); | ||
| 80 | INIT_LIST_HEAD(&conn->immed_queue_list); | ||
| 81 | INIT_LIST_HEAD(&conn->response_queue_list); | ||
| 82 | init_completion(&conn->conn_post_wait_comp); | ||
| 83 | init_completion(&conn->conn_wait_comp); | ||
| 84 | init_completion(&conn->conn_wait_rcfr_comp); | ||
| 85 | init_completion(&conn->conn_waiting_on_uc_comp); | ||
| 86 | init_completion(&conn->conn_logout_comp); | ||
| 87 | init_completion(&conn->rx_half_close_comp); | ||
| 88 | init_completion(&conn->tx_half_close_comp); | ||
| 89 | init_completion(&conn->rx_login_comp); | ||
| 90 | spin_lock_init(&conn->cmd_lock); | ||
| 91 | spin_lock_init(&conn->conn_usage_lock); | ||
| 92 | spin_lock_init(&conn->immed_queue_lock); | ||
| 93 | spin_lock_init(&conn->nopin_timer_lock); | ||
| 94 | spin_lock_init(&conn->response_queue_lock); | ||
| 95 | spin_lock_init(&conn->state_lock); | ||
| 96 | |||
| 97 | if (!zalloc_cpumask_var(&conn->conn_cpumask, GFP_KERNEL)) { | ||
| 98 | pr_err("Unable to allocate conn->conn_cpumask\n"); | ||
| 99 | goto out_conn_ops; | ||
| 100 | } | ||
| 101 | conn->conn_login = login; | 70 | conn->conn_login = login; |
| 102 | 71 | ||
| 103 | return login; | 72 | return login; |
| 104 | 73 | ||
| 105 | out_conn_ops: | ||
| 106 | kfree(conn->conn_ops); | ||
| 107 | out_rsp_buf: | ||
| 108 | kfree(login->rsp_buf); | ||
| 109 | out_req_buf: | 74 | out_req_buf: |
| 110 | kfree(login->req_buf); | 75 | kfree(login->req_buf); |
| 111 | out_login: | 76 | out_login: |
| @@ -310,11 +275,9 @@ static int iscsi_login_zero_tsih_s1( | |||
| 310 | return -ENOMEM; | 275 | return -ENOMEM; |
| 311 | } | 276 | } |
| 312 | 277 | ||
| 313 | ret = iscsi_login_set_conn_values(sess, conn, pdu->cid); | 278 | if (iscsi_login_set_conn_values(sess, conn, pdu->cid)) |
| 314 | if (unlikely(ret)) { | 279 | goto free_sess; |
| 315 | kfree(sess); | 280 | |
| 316 | return ret; | ||
| 317 | } | ||
| 318 | sess->init_task_tag = pdu->itt; | 281 | sess->init_task_tag = pdu->itt; |
| 319 | memcpy(&sess->isid, pdu->isid, 6); | 282 | memcpy(&sess->isid, pdu->isid, 6); |
| 320 | sess->exp_cmd_sn = be32_to_cpu(pdu->cmdsn); | 283 | sess->exp_cmd_sn = be32_to_cpu(pdu->cmdsn); |
| @@ -1149,6 +1112,75 @@ iscsit_conn_set_transport(struct iscsi_conn *conn, struct iscsit_transport *t) | |||
| 1149 | return 0; | 1112 | return 0; |
| 1150 | } | 1113 | } |
| 1151 | 1114 | ||
| 1115 | static struct iscsi_conn *iscsit_alloc_conn(struct iscsi_np *np) | ||
| 1116 | { | ||
| 1117 | struct iscsi_conn *conn; | ||
| 1118 | |||
| 1119 | conn = kzalloc(sizeof(struct iscsi_conn), GFP_KERNEL); | ||
| 1120 | if (!conn) { | ||
| 1121 | pr_err("Could not allocate memory for new connection\n"); | ||
| 1122 | return NULL; | ||
| 1123 | } | ||
| 1124 | pr_debug("Moving to TARG_CONN_STATE_FREE.\n"); | ||
| 1125 | conn->conn_state = TARG_CONN_STATE_FREE; | ||
| 1126 | |||
| 1127 | init_waitqueue_head(&conn->queues_wq); | ||
| 1128 | INIT_LIST_HEAD(&conn->conn_list); | ||
| 1129 | INIT_LIST_HEAD(&conn->conn_cmd_list); | ||
| 1130 | INIT_LIST_HEAD(&conn->immed_queue_list); | ||
| 1131 | INIT_LIST_HEAD(&conn->response_queue_list); | ||
| 1132 | init_completion(&conn->conn_post_wait_comp); | ||
| 1133 | init_completion(&conn->conn_wait_comp); | ||
| 1134 | init_completion(&conn->conn_wait_rcfr_comp); | ||
| 1135 | init_completion(&conn->conn_waiting_on_uc_comp); | ||
| 1136 | init_completion(&conn->conn_logout_comp); | ||
| 1137 | init_completion(&conn->rx_half_close_comp); | ||
| 1138 | init_completion(&conn->tx_half_close_comp); | ||
| 1139 | init_completion(&conn->rx_login_comp); | ||
| 1140 | spin_lock_init(&conn->cmd_lock); | ||
| 1141 | spin_lock_init(&conn->conn_usage_lock); | ||
| 1142 | spin_lock_init(&conn->immed_queue_lock); | ||
| 1143 | spin_lock_init(&conn->nopin_timer_lock); | ||
| 1144 | spin_lock_init(&conn->response_queue_lock); | ||
| 1145 | spin_lock_init(&conn->state_lock); | ||
| 1146 | |||
| 1147 | timer_setup(&conn->nopin_response_timer, | ||
| 1148 | iscsit_handle_nopin_response_timeout, 0); | ||
| 1149 | timer_setup(&conn->nopin_timer, iscsit_handle_nopin_timeout, 0); | ||
| 1150 | |||
| 1151 | if (iscsit_conn_set_transport(conn, np->np_transport) < 0) | ||
| 1152 | goto free_conn; | ||
| 1153 | |||
| 1154 | conn->conn_ops = kzalloc(sizeof(struct iscsi_conn_ops), GFP_KERNEL); | ||
| 1155 | if (!conn->conn_ops) { | ||
| 1156 | pr_err("Unable to allocate memory for struct iscsi_conn_ops.\n"); | ||
| 1157 | goto put_transport; | ||
| 1158 | } | ||
| 1159 | |||
| 1160 | if (!zalloc_cpumask_var(&conn->conn_cpumask, GFP_KERNEL)) { | ||
| 1161 | pr_err("Unable to allocate conn->conn_cpumask\n"); | ||
| 1162 | goto free_mask; | ||
| 1163 | } | ||
| 1164 | |||
| 1165 | return conn; | ||
| 1166 | |||
| 1167 | free_mask: | ||
| 1168 | free_cpumask_var(conn->conn_cpumask); | ||
| 1169 | put_transport: | ||
| 1170 | iscsit_put_transport(conn->conn_transport); | ||
| 1171 | free_conn: | ||
| 1172 | kfree(conn); | ||
| 1173 | return NULL; | ||
| 1174 | } | ||
| 1175 | |||
| 1176 | void iscsit_free_conn(struct iscsi_conn *conn) | ||
| 1177 | { | ||
| 1178 | free_cpumask_var(conn->conn_cpumask); | ||
| 1179 | kfree(conn->conn_ops); | ||
| 1180 | iscsit_put_transport(conn->conn_transport); | ||
| 1181 | kfree(conn); | ||
| 1182 | } | ||
| 1183 | |||
| 1152 | void iscsi_target_login_sess_out(struct iscsi_conn *conn, | 1184 | void iscsi_target_login_sess_out(struct iscsi_conn *conn, |
| 1153 | struct iscsi_np *np, bool zero_tsih, bool new_sess) | 1185 | struct iscsi_np *np, bool zero_tsih, bool new_sess) |
| 1154 | { | 1186 | { |
| @@ -1198,10 +1230,6 @@ old_sess_out: | |||
| 1198 | crypto_free_ahash(tfm); | 1230 | crypto_free_ahash(tfm); |
| 1199 | } | 1231 | } |
| 1200 | 1232 | ||
| 1201 | free_cpumask_var(conn->conn_cpumask); | ||
| 1202 | |||
| 1203 | kfree(conn->conn_ops); | ||
| 1204 | |||
| 1205 | if (conn->param_list) { | 1233 | if (conn->param_list) { |
| 1206 | iscsi_release_param_list(conn->param_list); | 1234 | iscsi_release_param_list(conn->param_list); |
| 1207 | conn->param_list = NULL; | 1235 | conn->param_list = NULL; |
| @@ -1219,8 +1247,7 @@ old_sess_out: | |||
| 1219 | if (conn->conn_transport->iscsit_free_conn) | 1247 | if (conn->conn_transport->iscsit_free_conn) |
| 1220 | conn->conn_transport->iscsit_free_conn(conn); | 1248 | conn->conn_transport->iscsit_free_conn(conn); |
| 1221 | 1249 | ||
| 1222 | iscsit_put_transport(conn->conn_transport); | 1250 | iscsit_free_conn(conn); |
| 1223 | kfree(conn); | ||
| 1224 | } | 1251 | } |
| 1225 | 1252 | ||
| 1226 | static int __iscsi_target_login_thread(struct iscsi_np *np) | 1253 | static int __iscsi_target_login_thread(struct iscsi_np *np) |
| @@ -1250,31 +1277,16 @@ static int __iscsi_target_login_thread(struct iscsi_np *np) | |||
| 1250 | } | 1277 | } |
| 1251 | spin_unlock_bh(&np->np_thread_lock); | 1278 | spin_unlock_bh(&np->np_thread_lock); |
| 1252 | 1279 | ||
| 1253 | conn = kzalloc(sizeof(struct iscsi_conn), GFP_KERNEL); | 1280 | conn = iscsit_alloc_conn(np); |
| 1254 | if (!conn) { | 1281 | if (!conn) { |
| 1255 | pr_err("Could not allocate memory for" | ||
| 1256 | " new connection\n"); | ||
| 1257 | /* Get another socket */ | 1282 | /* Get another socket */ |
| 1258 | return 1; | 1283 | return 1; |
| 1259 | } | 1284 | } |
| 1260 | pr_debug("Moving to TARG_CONN_STATE_FREE.\n"); | ||
| 1261 | conn->conn_state = TARG_CONN_STATE_FREE; | ||
| 1262 | |||
| 1263 | timer_setup(&conn->nopin_response_timer, | ||
| 1264 | iscsit_handle_nopin_response_timeout, 0); | ||
| 1265 | timer_setup(&conn->nopin_timer, iscsit_handle_nopin_timeout, 0); | ||
| 1266 | |||
| 1267 | if (iscsit_conn_set_transport(conn, np->np_transport) < 0) { | ||
| 1268 | kfree(conn); | ||
| 1269 | return 1; | ||
| 1270 | } | ||
| 1271 | 1285 | ||
| 1272 | rc = np->np_transport->iscsit_accept_np(np, conn); | 1286 | rc = np->np_transport->iscsit_accept_np(np, conn); |
| 1273 | if (rc == -ENOSYS) { | 1287 | if (rc == -ENOSYS) { |
| 1274 | complete(&np->np_restart_comp); | 1288 | complete(&np->np_restart_comp); |
| 1275 | iscsit_put_transport(conn->conn_transport); | 1289 | iscsit_free_conn(conn); |
| 1276 | kfree(conn); | ||
| 1277 | conn = NULL; | ||
| 1278 | goto exit; | 1290 | goto exit; |
| 1279 | } else if (rc < 0) { | 1291 | } else if (rc < 0) { |
| 1280 | spin_lock_bh(&np->np_thread_lock); | 1292 | spin_lock_bh(&np->np_thread_lock); |
| @@ -1282,17 +1294,13 @@ static int __iscsi_target_login_thread(struct iscsi_np *np) | |||
| 1282 | np->np_thread_state = ISCSI_NP_THREAD_ACTIVE; | 1294 | np->np_thread_state = ISCSI_NP_THREAD_ACTIVE; |
| 1283 | spin_unlock_bh(&np->np_thread_lock); | 1295 | spin_unlock_bh(&np->np_thread_lock); |
| 1284 | complete(&np->np_restart_comp); | 1296 | complete(&np->np_restart_comp); |
| 1285 | iscsit_put_transport(conn->conn_transport); | 1297 | iscsit_free_conn(conn); |
| 1286 | kfree(conn); | ||
| 1287 | conn = NULL; | ||
| 1288 | /* Get another socket */ | 1298 | /* Get another socket */ |
| 1289 | return 1; | 1299 | return 1; |
| 1290 | } | 1300 | } |
| 1291 | spin_unlock_bh(&np->np_thread_lock); | 1301 | spin_unlock_bh(&np->np_thread_lock); |
| 1292 | iscsit_put_transport(conn->conn_transport); | 1302 | iscsit_free_conn(conn); |
| 1293 | kfree(conn); | 1303 | return 1; |
| 1294 | conn = NULL; | ||
| 1295 | goto out; | ||
| 1296 | } | 1304 | } |
| 1297 | /* | 1305 | /* |
| 1298 | * Perform the remaining iSCSI connection initialization items.. | 1306 | * Perform the remaining iSCSI connection initialization items.. |
| @@ -1442,7 +1450,6 @@ old_sess_out: | |||
| 1442 | tpg_np = NULL; | 1450 | tpg_np = NULL; |
| 1443 | } | 1451 | } |
| 1444 | 1452 | ||
| 1445 | out: | ||
| 1446 | return 1; | 1453 | return 1; |
| 1447 | 1454 | ||
| 1448 | exit: | 1455 | exit: |
diff --git a/drivers/target/iscsi/iscsi_target_login.h b/drivers/target/iscsi/iscsi_target_login.h index 74ac3abc44a0..3b8e3639ff5d 100644 --- a/drivers/target/iscsi/iscsi_target_login.h +++ b/drivers/target/iscsi/iscsi_target_login.h | |||
| @@ -19,7 +19,7 @@ extern int iscsi_target_setup_login_socket(struct iscsi_np *, | |||
| 19 | extern int iscsit_accept_np(struct iscsi_np *, struct iscsi_conn *); | 19 | extern int iscsit_accept_np(struct iscsi_np *, struct iscsi_conn *); |
| 20 | extern int iscsit_get_login_rx(struct iscsi_conn *, struct iscsi_login *); | 20 | extern int iscsit_get_login_rx(struct iscsi_conn *, struct iscsi_login *); |
| 21 | extern int iscsit_put_login_tx(struct iscsi_conn *, struct iscsi_login *, u32); | 21 | extern int iscsit_put_login_tx(struct iscsi_conn *, struct iscsi_login *, u32); |
| 22 | extern void iscsit_free_conn(struct iscsi_np *, struct iscsi_conn *); | 22 | extern void iscsit_free_conn(struct iscsi_conn *); |
| 23 | extern int iscsit_start_kthreads(struct iscsi_conn *); | 23 | extern int iscsit_start_kthreads(struct iscsi_conn *); |
| 24 | extern void iscsi_post_login_handler(struct iscsi_np *, struct iscsi_conn *, u8); | 24 | extern void iscsi_post_login_handler(struct iscsi_np *, struct iscsi_conn *, u8); |
| 25 | extern void iscsi_target_login_sess_out(struct iscsi_conn *, struct iscsi_np *, | 25 | extern void iscsi_target_login_sess_out(struct iscsi_conn *, struct iscsi_np *, |
diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c index 5414c4a87bea..27284a2dcd2b 100644 --- a/drivers/tty/hvc/hvc_console.c +++ b/drivers/tty/hvc/hvc_console.c | |||
| @@ -522,6 +522,8 @@ static int hvc_write(struct tty_struct *tty, const unsigned char *buf, int count | |||
| 522 | return -EIO; | 522 | return -EIO; |
| 523 | 523 | ||
| 524 | while (count > 0) { | 524 | while (count > 0) { |
| 525 | int ret = 0; | ||
| 526 | |||
| 525 | spin_lock_irqsave(&hp->lock, flags); | 527 | spin_lock_irqsave(&hp->lock, flags); |
| 526 | 528 | ||
| 527 | rsize = hp->outbuf_size - hp->n_outbuf; | 529 | rsize = hp->outbuf_size - hp->n_outbuf; |
| @@ -537,10 +539,13 @@ static int hvc_write(struct tty_struct *tty, const unsigned char *buf, int count | |||
| 537 | } | 539 | } |
| 538 | 540 | ||
| 539 | if (hp->n_outbuf > 0) | 541 | if (hp->n_outbuf > 0) |
| 540 | hvc_push(hp); | 542 | ret = hvc_push(hp); |
| 541 | 543 | ||
| 542 | spin_unlock_irqrestore(&hp->lock, flags); | 544 | spin_unlock_irqrestore(&hp->lock, flags); |
| 543 | 545 | ||
| 546 | if (!ret) | ||
| 547 | break; | ||
| 548 | |||
| 544 | if (count) { | 549 | if (count) { |
| 545 | if (hp->n_outbuf > 0) | 550 | if (hp->n_outbuf > 0) |
| 546 | hvc_flush(hp); | 551 | hvc_flush(hp); |
| @@ -623,6 +628,15 @@ static int hvc_chars_in_buffer(struct tty_struct *tty) | |||
| 623 | #define MAX_TIMEOUT (2000) | 628 | #define MAX_TIMEOUT (2000) |
| 624 | static u32 timeout = MIN_TIMEOUT; | 629 | static u32 timeout = MIN_TIMEOUT; |
| 625 | 630 | ||
| 631 | /* | ||
| 632 | * Maximum number of bytes to get from the console driver if hvc_poll is | ||
| 633 | * called from driver (and can't sleep). Any more than this and we break | ||
| 634 | * and start polling with khvcd. This value was derived from from an OpenBMC | ||
| 635 | * console with the OPAL driver that results in about 0.25ms interrupts off | ||
| 636 | * latency. | ||
| 637 | */ | ||
| 638 | #define HVC_ATOMIC_READ_MAX 128 | ||
| 639 | |||
| 626 | #define HVC_POLL_READ 0x00000001 | 640 | #define HVC_POLL_READ 0x00000001 |
| 627 | #define HVC_POLL_WRITE 0x00000002 | 641 | #define HVC_POLL_WRITE 0x00000002 |
| 628 | 642 | ||
| @@ -669,8 +683,8 @@ static int __hvc_poll(struct hvc_struct *hp, bool may_sleep) | |||
| 669 | if (!hp->irq_requested) | 683 | if (!hp->irq_requested) |
| 670 | poll_mask |= HVC_POLL_READ; | 684 | poll_mask |= HVC_POLL_READ; |
| 671 | 685 | ||
| 686 | read_again: | ||
| 672 | /* Read data if any */ | 687 | /* Read data if any */ |
| 673 | |||
| 674 | count = tty_buffer_request_room(&hp->port, N_INBUF); | 688 | count = tty_buffer_request_room(&hp->port, N_INBUF); |
| 675 | 689 | ||
| 676 | /* If flip is full, just reschedule a later read */ | 690 | /* If flip is full, just reschedule a later read */ |
| @@ -717,9 +731,23 @@ static int __hvc_poll(struct hvc_struct *hp, bool may_sleep) | |||
| 717 | #endif /* CONFIG_MAGIC_SYSRQ */ | 731 | #endif /* CONFIG_MAGIC_SYSRQ */ |
| 718 | tty_insert_flip_char(&hp->port, buf[i], 0); | 732 | tty_insert_flip_char(&hp->port, buf[i], 0); |
| 719 | } | 733 | } |
| 720 | if (n == count) | 734 | read_total += n; |
| 721 | poll_mask |= HVC_POLL_READ; | 735 | |
| 722 | read_total = n; | 736 | if (may_sleep) { |
| 737 | /* Keep going until the flip is full */ | ||
| 738 | spin_unlock_irqrestore(&hp->lock, flags); | ||
| 739 | cond_resched(); | ||
| 740 | spin_lock_irqsave(&hp->lock, flags); | ||
| 741 | goto read_again; | ||
| 742 | } else if (read_total < HVC_ATOMIC_READ_MAX) { | ||
| 743 | /* Break and defer if it's a large read in atomic */ | ||
| 744 | goto read_again; | ||
| 745 | } | ||
| 746 | |||
| 747 | /* | ||
| 748 | * Latency break, schedule another poll immediately. | ||
| 749 | */ | ||
| 750 | poll_mask |= HVC_POLL_READ; | ||
| 723 | 751 | ||
| 724 | out: | 752 | out: |
| 725 | /* Wakeup write queue if necessary */ | 753 | /* Wakeup write queue if necessary */ |
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c index 27346d69f393..f9b40a9dc4d3 100644 --- a/drivers/usb/class/cdc-acm.c +++ b/drivers/usb/class/cdc-acm.c | |||
| @@ -780,20 +780,9 @@ static int acm_tty_write(struct tty_struct *tty, | |||
| 780 | } | 780 | } |
| 781 | 781 | ||
| 782 | if (acm->susp_count) { | 782 | if (acm->susp_count) { |
| 783 | if (acm->putbuffer) { | ||
| 784 | /* now to preserve order */ | ||
| 785 | usb_anchor_urb(acm->putbuffer->urb, &acm->delayed); | ||
| 786 | acm->putbuffer = NULL; | ||
| 787 | } | ||
| 788 | usb_anchor_urb(wb->urb, &acm->delayed); | 783 | usb_anchor_urb(wb->urb, &acm->delayed); |
| 789 | spin_unlock_irqrestore(&acm->write_lock, flags); | 784 | spin_unlock_irqrestore(&acm->write_lock, flags); |
| 790 | return count; | 785 | return count; |
| 791 | } else { | ||
| 792 | if (acm->putbuffer) { | ||
| 793 | /* at this point there is no good way to handle errors */ | ||
| 794 | acm_start_wb(acm, acm->putbuffer); | ||
| 795 | acm->putbuffer = NULL; | ||
| 796 | } | ||
| 797 | } | 786 | } |
| 798 | 787 | ||
| 799 | stat = acm_start_wb(acm, wb); | 788 | stat = acm_start_wb(acm, wb); |
| @@ -804,66 +793,6 @@ static int acm_tty_write(struct tty_struct *tty, | |||
| 804 | return count; | 793 | return count; |
| 805 | } | 794 | } |
| 806 | 795 | ||
| 807 | static void acm_tty_flush_chars(struct tty_struct *tty) | ||
| 808 | { | ||
| 809 | struct acm *acm = tty->driver_data; | ||
| 810 | struct acm_wb *cur; | ||
| 811 | int err; | ||
| 812 | unsigned long flags; | ||
| 813 | |||
| 814 | spin_lock_irqsave(&acm->write_lock, flags); | ||
| 815 | |||
| 816 | cur = acm->putbuffer; | ||
| 817 | if (!cur) /* nothing to do */ | ||
| 818 | goto out; | ||
| 819 | |||
| 820 | acm->putbuffer = NULL; | ||
| 821 | err = usb_autopm_get_interface_async(acm->control); | ||
| 822 | if (err < 0) { | ||
| 823 | cur->use = 0; | ||
| 824 | acm->putbuffer = cur; | ||
| 825 | goto out; | ||
| 826 | } | ||
| 827 | |||
| 828 | if (acm->susp_count) | ||
| 829 | usb_anchor_urb(cur->urb, &acm->delayed); | ||
| 830 | else | ||
| 831 | acm_start_wb(acm, cur); | ||
| 832 | out: | ||
| 833 | spin_unlock_irqrestore(&acm->write_lock, flags); | ||
| 834 | return; | ||
| 835 | } | ||
| 836 | |||
| 837 | static int acm_tty_put_char(struct tty_struct *tty, unsigned char ch) | ||
| 838 | { | ||
| 839 | struct acm *acm = tty->driver_data; | ||
| 840 | struct acm_wb *cur; | ||
| 841 | int wbn; | ||
| 842 | unsigned long flags; | ||
| 843 | |||
| 844 | overflow: | ||
| 845 | cur = acm->putbuffer; | ||
| 846 | if (!cur) { | ||
| 847 | spin_lock_irqsave(&acm->write_lock, flags); | ||
| 848 | wbn = acm_wb_alloc(acm); | ||
| 849 | if (wbn >= 0) { | ||
| 850 | cur = &acm->wb[wbn]; | ||
| 851 | acm->putbuffer = cur; | ||
| 852 | } | ||
| 853 | spin_unlock_irqrestore(&acm->write_lock, flags); | ||
| 854 | if (!cur) | ||
| 855 | return 0; | ||
| 856 | } | ||
| 857 | |||
| 858 | if (cur->len == acm->writesize) { | ||
| 859 | acm_tty_flush_chars(tty); | ||
| 860 | goto overflow; | ||
| 861 | } | ||
| 862 | |||
| 863 | cur->buf[cur->len++] = ch; | ||
| 864 | return 1; | ||
| 865 | } | ||
| 866 | |||
| 867 | static int acm_tty_write_room(struct tty_struct *tty) | 796 | static int acm_tty_write_room(struct tty_struct *tty) |
| 868 | { | 797 | { |
| 869 | struct acm *acm = tty->driver_data; | 798 | struct acm *acm = tty->driver_data; |
| @@ -1987,8 +1916,6 @@ static const struct tty_operations acm_ops = { | |||
| 1987 | .cleanup = acm_tty_cleanup, | 1916 | .cleanup = acm_tty_cleanup, |
| 1988 | .hangup = acm_tty_hangup, | 1917 | .hangup = acm_tty_hangup, |
| 1989 | .write = acm_tty_write, | 1918 | .write = acm_tty_write, |
| 1990 | .put_char = acm_tty_put_char, | ||
| 1991 | .flush_chars = acm_tty_flush_chars, | ||
| 1992 | .write_room = acm_tty_write_room, | 1919 | .write_room = acm_tty_write_room, |
| 1993 | .ioctl = acm_tty_ioctl, | 1920 | .ioctl = acm_tty_ioctl, |
| 1994 | .throttle = acm_tty_throttle, | 1921 | .throttle = acm_tty_throttle, |
diff --git a/drivers/usb/class/cdc-acm.h b/drivers/usb/class/cdc-acm.h index eacc116e83da..ca06b20d7af9 100644 --- a/drivers/usb/class/cdc-acm.h +++ b/drivers/usb/class/cdc-acm.h | |||
| @@ -96,7 +96,6 @@ struct acm { | |||
| 96 | unsigned long read_urbs_free; | 96 | unsigned long read_urbs_free; |
| 97 | struct urb *read_urbs[ACM_NR]; | 97 | struct urb *read_urbs[ACM_NR]; |
| 98 | struct acm_rb read_buffers[ACM_NR]; | 98 | struct acm_rb read_buffers[ACM_NR]; |
| 99 | struct acm_wb *putbuffer; /* for acm_tty_put_char() */ | ||
| 100 | int rx_buflimit; | 99 | int rx_buflimit; |
| 101 | spinlock_t read_lock; | 100 | spinlock_t read_lock; |
| 102 | u8 *notification_buffer; /* to reassemble fragmented notifications */ | 101 | u8 *notification_buffer; /* to reassemble fragmented notifications */ |
diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c index bec581fb7c63..656d247819c9 100644 --- a/drivers/usb/class/cdc-wdm.c +++ b/drivers/usb/class/cdc-wdm.c | |||
| @@ -460,7 +460,7 @@ static int service_outstanding_interrupt(struct wdm_device *desc) | |||
| 460 | 460 | ||
| 461 | set_bit(WDM_RESPONDING, &desc->flags); | 461 | set_bit(WDM_RESPONDING, &desc->flags); |
| 462 | spin_unlock_irq(&desc->iuspin); | 462 | spin_unlock_irq(&desc->iuspin); |
| 463 | rv = usb_submit_urb(desc->response, GFP_KERNEL); | 463 | rv = usb_submit_urb(desc->response, GFP_ATOMIC); |
| 464 | spin_lock_irq(&desc->iuspin); | 464 | spin_lock_irq(&desc->iuspin); |
| 465 | if (rv) { | 465 | if (rv) { |
| 466 | dev_err(&desc->intf->dev, | 466 | dev_err(&desc->intf->dev, |
diff --git a/drivers/usb/common/common.c b/drivers/usb/common/common.c index 50a2362ed3ea..48277bbc15e4 100644 --- a/drivers/usb/common/common.c +++ b/drivers/usb/common/common.c | |||
| @@ -246,6 +246,31 @@ int of_usb_update_otg_caps(struct device_node *np, | |||
| 246 | } | 246 | } |
| 247 | EXPORT_SYMBOL_GPL(of_usb_update_otg_caps); | 247 | EXPORT_SYMBOL_GPL(of_usb_update_otg_caps); |
| 248 | 248 | ||
| 249 | /** | ||
| 250 | * usb_of_get_companion_dev - Find the companion device | ||
| 251 | * @dev: the device pointer to find a companion | ||
| 252 | * | ||
| 253 | * Find the companion device from platform bus. | ||
| 254 | * | ||
| 255 | * Takes a reference to the returned struct device which needs to be dropped | ||
| 256 | * after use. | ||
| 257 | * | ||
| 258 | * Return: On success, a pointer to the companion device, %NULL on failure. | ||
| 259 | */ | ||
| 260 | struct device *usb_of_get_companion_dev(struct device *dev) | ||
| 261 | { | ||
| 262 | struct device_node *node; | ||
| 263 | struct platform_device *pdev = NULL; | ||
| 264 | |||
| 265 | node = of_parse_phandle(dev->of_node, "companion", 0); | ||
| 266 | if (node) | ||
| 267 | pdev = of_find_device_by_node(node); | ||
| 268 | |||
| 269 | of_node_put(node); | ||
| 270 | |||
| 271 | return pdev ? &pdev->dev : NULL; | ||
| 272 | } | ||
| 273 | EXPORT_SYMBOL_GPL(usb_of_get_companion_dev); | ||
| 249 | #endif | 274 | #endif |
| 250 | 275 | ||
| 251 | MODULE_LICENSE("GPL"); | 276 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c index 66fe1b78d952..03432467b05f 100644 --- a/drivers/usb/core/hcd-pci.c +++ b/drivers/usb/core/hcd-pci.c | |||
| @@ -515,8 +515,6 @@ static int resume_common(struct device *dev, int event) | |||
| 515 | event == PM_EVENT_RESTORE); | 515 | event == PM_EVENT_RESTORE); |
| 516 | if (retval) { | 516 | if (retval) { |
| 517 | dev_err(dev, "PCI post-resume error %d!\n", retval); | 517 | dev_err(dev, "PCI post-resume error %d!\n", retval); |
| 518 | if (hcd->shared_hcd) | ||
| 519 | usb_hc_died(hcd->shared_hcd); | ||
| 520 | usb_hc_died(hcd); | 518 | usb_hc_died(hcd); |
| 521 | } | 519 | } |
| 522 | } | 520 | } |
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c index 228672f2c4a1..bfa5eda0cc26 100644 --- a/drivers/usb/core/message.c +++ b/drivers/usb/core/message.c | |||
| @@ -1341,6 +1341,11 @@ void usb_enable_interface(struct usb_device *dev, | |||
| 1341 | * is submitted that needs that bandwidth. Some other operating systems | 1341 | * is submitted that needs that bandwidth. Some other operating systems |
| 1342 | * allocate bandwidth early, when a configuration is chosen. | 1342 | * allocate bandwidth early, when a configuration is chosen. |
| 1343 | * | 1343 | * |
| 1344 | * xHCI reserves bandwidth and configures the alternate setting in | ||
| 1345 | * usb_hcd_alloc_bandwidth(). If it fails the original interface altsetting | ||
| 1346 | * may be disabled. Drivers cannot rely on any particular alternate | ||
| 1347 | * setting being in effect after a failure. | ||
| 1348 | * | ||
| 1344 | * This call is synchronous, and may not be used in an interrupt context. | 1349 | * This call is synchronous, and may not be used in an interrupt context. |
| 1345 | * Also, drivers must not change altsettings while urbs are scheduled for | 1350 | * Also, drivers must not change altsettings while urbs are scheduled for |
| 1346 | * endpoints in that interface; all such urbs must first be completed | 1351 | * endpoints in that interface; all such urbs must first be completed |
| @@ -1376,6 +1381,12 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate) | |||
| 1376 | alternate); | 1381 | alternate); |
| 1377 | return -EINVAL; | 1382 | return -EINVAL; |
| 1378 | } | 1383 | } |
| 1384 | /* | ||
| 1385 | * usb3 hosts configure the interface in usb_hcd_alloc_bandwidth, | ||
| 1386 | * including freeing dropped endpoint ring buffers. | ||
| 1387 | * Make sure the interface endpoints are flushed before that | ||
| 1388 | */ | ||
| 1389 | usb_disable_interface(dev, iface, false); | ||
| 1379 | 1390 | ||
| 1380 | /* Make sure we have enough bandwidth for this alternate interface. | 1391 | /* Make sure we have enough bandwidth for this alternate interface. |
| 1381 | * Remove the current alt setting and add the new alt setting. | 1392 | * Remove the current alt setting and add the new alt setting. |
diff --git a/drivers/usb/core/of.c b/drivers/usb/core/of.c index fd77442c2d12..651708d8c908 100644 --- a/drivers/usb/core/of.c +++ b/drivers/usb/core/of.c | |||
| @@ -105,29 +105,3 @@ usb_of_get_interface_node(struct usb_device *udev, u8 config, u8 ifnum) | |||
| 105 | return NULL; | 105 | return NULL; |
| 106 | } | 106 | } |
| 107 | EXPORT_SYMBOL_GPL(usb_of_get_interface_node); | 107 | EXPORT_SYMBOL_GPL(usb_of_get_interface_node); |
| 108 | |||
| 109 | /** | ||
| 110 | * usb_of_get_companion_dev - Find the companion device | ||
| 111 | * @dev: the device pointer to find a companion | ||
| 112 | * | ||
| 113 | * Find the companion device from platform bus. | ||
| 114 | * | ||
| 115 | * Takes a reference to the returned struct device which needs to be dropped | ||
| 116 | * after use. | ||
| 117 | * | ||
| 118 | * Return: On success, a pointer to the companion device, %NULL on failure. | ||
| 119 | */ | ||
| 120 | struct device *usb_of_get_companion_dev(struct device *dev) | ||
| 121 | { | ||
| 122 | struct device_node *node; | ||
| 123 | struct platform_device *pdev = NULL; | ||
| 124 | |||
| 125 | node = of_parse_phandle(dev->of_node, "companion", 0); | ||
| 126 | if (node) | ||
| 127 | pdev = of_find_device_by_node(node); | ||
| 128 | |||
| 129 | of_node_put(node); | ||
| 130 | |||
| 131 | return pdev ? &pdev->dev : NULL; | ||
| 132 | } | ||
| 133 | EXPORT_SYMBOL_GPL(usb_of_get_companion_dev); | ||
diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c index 097057d2eacf..e77dfe5ed5ec 100644 --- a/drivers/usb/core/quirks.c +++ b/drivers/usb/core/quirks.c | |||
| @@ -178,6 +178,10 @@ static const struct usb_device_id usb_quirk_list[] = { | |||
| 178 | /* CBM - Flash disk */ | 178 | /* CBM - Flash disk */ |
| 179 | { USB_DEVICE(0x0204, 0x6025), .driver_info = USB_QUIRK_RESET_RESUME }, | 179 | { USB_DEVICE(0x0204, 0x6025), .driver_info = USB_QUIRK_RESET_RESUME }, |
| 180 | 180 | ||
| 181 | /* WORLDE Controller KS49 or Prodipe MIDI 49C USB controller */ | ||
| 182 | { USB_DEVICE(0x0218, 0x0201), .driver_info = | ||
| 183 | USB_QUIRK_CONFIG_INTF_STRINGS }, | ||
| 184 | |||
| 181 | /* WORLDE easy key (easykey.25) MIDI controller */ | 185 | /* WORLDE easy key (easykey.25) MIDI controller */ |
| 182 | { USB_DEVICE(0x0218, 0x0401), .driver_info = | 186 | { USB_DEVICE(0x0218, 0x0401), .driver_info = |
| 183 | USB_QUIRK_CONFIG_INTF_STRINGS }, | 187 | USB_QUIRK_CONFIG_INTF_STRINGS }, |
| @@ -406,6 +410,9 @@ static const struct usb_device_id usb_quirk_list[] = { | |||
| 406 | { USB_DEVICE(0x2040, 0x7200), .driver_info = | 410 | { USB_DEVICE(0x2040, 0x7200), .driver_info = |
| 407 | USB_QUIRK_CONFIG_INTF_STRINGS }, | 411 | USB_QUIRK_CONFIG_INTF_STRINGS }, |
| 408 | 412 | ||
| 413 | /* DJI CineSSD */ | ||
| 414 | { USB_DEVICE(0x2ca3, 0x0031), .driver_info = USB_QUIRK_NO_LPM }, | ||
| 415 | |||
| 409 | /* INTEL VALUE SSD */ | 416 | /* INTEL VALUE SSD */ |
| 410 | { USB_DEVICE(0x8086, 0xf1a5), .driver_info = USB_QUIRK_RESET_RESUME }, | 417 | { USB_DEVICE(0x8086, 0xf1a5), .driver_info = USB_QUIRK_RESET_RESUME }, |
| 411 | 418 | ||
diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c index 9a53a58e676e..577642895b57 100644 --- a/drivers/usb/dwc2/platform.c +++ b/drivers/usb/dwc2/platform.c | |||
| @@ -412,8 +412,6 @@ static int dwc2_driver_probe(struct platform_device *dev) | |||
| 412 | dev_dbg(&dev->dev, "mapped PA %08lx to VA %p\n", | 412 | dev_dbg(&dev->dev, "mapped PA %08lx to VA %p\n", |
| 413 | (unsigned long)res->start, hsotg->regs); | 413 | (unsigned long)res->start, hsotg->regs); |
| 414 | 414 | ||
| 415 | hsotg->needs_byte_swap = dwc2_check_core_endianness(hsotg); | ||
| 416 | |||
| 417 | retval = dwc2_lowlevel_hw_init(hsotg); | 415 | retval = dwc2_lowlevel_hw_init(hsotg); |
| 418 | if (retval) | 416 | if (retval) |
| 419 | return retval; | 417 | return retval; |
| @@ -438,6 +436,8 @@ static int dwc2_driver_probe(struct platform_device *dev) | |||
| 438 | if (retval) | 436 | if (retval) |
| 439 | return retval; | 437 | return retval; |
| 440 | 438 | ||
| 439 | hsotg->needs_byte_swap = dwc2_check_core_endianness(hsotg); | ||
| 440 | |||
| 441 | retval = dwc2_get_dr_mode(hsotg); | 441 | retval = dwc2_get_dr_mode(hsotg); |
| 442 | if (retval) | 442 | if (retval) |
| 443 | goto error; | 443 | goto error; |
diff --git a/drivers/usb/dwc3/dwc3-of-simple.c b/drivers/usb/dwc3/dwc3-of-simple.c index 40bf9e0bbc59..4c2771c5e727 100644 --- a/drivers/usb/dwc3/dwc3-of-simple.c +++ b/drivers/usb/dwc3/dwc3-of-simple.c | |||
| @@ -180,8 +180,7 @@ static int dwc3_of_simple_remove(struct platform_device *pdev) | |||
| 180 | return 0; | 180 | return 0; |
| 181 | } | 181 | } |
| 182 | 182 | ||
| 183 | #ifdef CONFIG_PM | 183 | static int __maybe_unused dwc3_of_simple_runtime_suspend(struct device *dev) |
| 184 | static int dwc3_of_simple_runtime_suspend(struct device *dev) | ||
| 185 | { | 184 | { |
| 186 | struct dwc3_of_simple *simple = dev_get_drvdata(dev); | 185 | struct dwc3_of_simple *simple = dev_get_drvdata(dev); |
| 187 | int i; | 186 | int i; |
| @@ -192,7 +191,7 @@ static int dwc3_of_simple_runtime_suspend(struct device *dev) | |||
| 192 | return 0; | 191 | return 0; |
| 193 | } | 192 | } |
| 194 | 193 | ||
| 195 | static int dwc3_of_simple_runtime_resume(struct device *dev) | 194 | static int __maybe_unused dwc3_of_simple_runtime_resume(struct device *dev) |
| 196 | { | 195 | { |
| 197 | struct dwc3_of_simple *simple = dev_get_drvdata(dev); | 196 | struct dwc3_of_simple *simple = dev_get_drvdata(dev); |
| 198 | int ret; | 197 | int ret; |
| @@ -210,7 +209,7 @@ static int dwc3_of_simple_runtime_resume(struct device *dev) | |||
| 210 | return 0; | 209 | return 0; |
| 211 | } | 210 | } |
| 212 | 211 | ||
| 213 | static int dwc3_of_simple_suspend(struct device *dev) | 212 | static int __maybe_unused dwc3_of_simple_suspend(struct device *dev) |
| 214 | { | 213 | { |
| 215 | struct dwc3_of_simple *simple = dev_get_drvdata(dev); | 214 | struct dwc3_of_simple *simple = dev_get_drvdata(dev); |
| 216 | 215 | ||
| @@ -220,7 +219,7 @@ static int dwc3_of_simple_suspend(struct device *dev) | |||
| 220 | return 0; | 219 | return 0; |
| 221 | } | 220 | } |
| 222 | 221 | ||
| 223 | static int dwc3_of_simple_resume(struct device *dev) | 222 | static int __maybe_unused dwc3_of_simple_resume(struct device *dev) |
| 224 | { | 223 | { |
| 225 | struct dwc3_of_simple *simple = dev_get_drvdata(dev); | 224 | struct dwc3_of_simple *simple = dev_get_drvdata(dev); |
| 226 | 225 | ||
| @@ -229,7 +228,6 @@ static int dwc3_of_simple_resume(struct device *dev) | |||
| 229 | 228 | ||
| 230 | return 0; | 229 | return 0; |
| 231 | } | 230 | } |
| 232 | #endif | ||
| 233 | 231 | ||
| 234 | static const struct dev_pm_ops dwc3_of_simple_dev_pm_ops = { | 232 | static const struct dev_pm_ops dwc3_of_simple_dev_pm_ops = { |
| 235 | SET_SYSTEM_SLEEP_PM_OPS(dwc3_of_simple_suspend, dwc3_of_simple_resume) | 233 | SET_SYSTEM_SLEEP_PM_OPS(dwc3_of_simple_suspend, dwc3_of_simple_resume) |
diff --git a/drivers/usb/dwc3/dwc3-pci.c b/drivers/usb/dwc3/dwc3-pci.c index 5edd79470368..1286076a8890 100644 --- a/drivers/usb/dwc3/dwc3-pci.c +++ b/drivers/usb/dwc3/dwc3-pci.c | |||
| @@ -85,8 +85,8 @@ static int dwc3_byt_enable_ulpi_refclock(struct pci_dev *pci) | |||
| 85 | u32 value; | 85 | u32 value; |
| 86 | 86 | ||
| 87 | reg = pcim_iomap(pci, GP_RWBAR, 0); | 87 | reg = pcim_iomap(pci, GP_RWBAR, 0); |
| 88 | if (IS_ERR(reg)) | 88 | if (!reg) |
| 89 | return PTR_ERR(reg); | 89 | return -ENOMEM; |
| 90 | 90 | ||
| 91 | value = readl(reg + GP_RWREG1); | 91 | value = readl(reg + GP_RWREG1); |
| 92 | if (!(value & GP_RWREG1_ULPI_REFCLK_DISABLE)) | 92 | if (!(value & GP_RWREG1_ULPI_REFCLK_DISABLE)) |
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 032ea7d709ba..2b53194081ba 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c | |||
| @@ -473,7 +473,6 @@ static int dwc3_gadget_set_xfer_resource(struct dwc3_ep *dep) | |||
| 473 | 473 | ||
| 474 | /** | 474 | /** |
| 475 | * dwc3_gadget_start_config - configure ep resources | 475 | * dwc3_gadget_start_config - configure ep resources |
| 476 | * @dwc: pointer to our controller context structure | ||
| 477 | * @dep: endpoint that is being enabled | 476 | * @dep: endpoint that is being enabled |
| 478 | * | 477 | * |
| 479 | * Issue a %DWC3_DEPCMD_DEPSTARTCFG command to @dep. After the command's | 478 | * Issue a %DWC3_DEPCMD_DEPSTARTCFG command to @dep. After the command's |
diff --git a/drivers/usb/gadget/udc/fotg210-udc.c b/drivers/usb/gadget/udc/fotg210-udc.c index 53a48f561458..587c5037ff07 100644 --- a/drivers/usb/gadget/udc/fotg210-udc.c +++ b/drivers/usb/gadget/udc/fotg210-udc.c | |||
| @@ -1063,12 +1063,15 @@ static const struct usb_gadget_ops fotg210_gadget_ops = { | |||
| 1063 | static int fotg210_udc_remove(struct platform_device *pdev) | 1063 | static int fotg210_udc_remove(struct platform_device *pdev) |
| 1064 | { | 1064 | { |
| 1065 | struct fotg210_udc *fotg210 = platform_get_drvdata(pdev); | 1065 | struct fotg210_udc *fotg210 = platform_get_drvdata(pdev); |
| 1066 | int i; | ||
| 1066 | 1067 | ||
| 1067 | usb_del_gadget_udc(&fotg210->gadget); | 1068 | usb_del_gadget_udc(&fotg210->gadget); |
| 1068 | iounmap(fotg210->reg); | 1069 | iounmap(fotg210->reg); |
| 1069 | free_irq(platform_get_irq(pdev, 0), fotg210); | 1070 | free_irq(platform_get_irq(pdev, 0), fotg210); |
| 1070 | 1071 | ||
| 1071 | fotg210_ep_free_request(&fotg210->ep[0]->ep, fotg210->ep0_req); | 1072 | fotg210_ep_free_request(&fotg210->ep[0]->ep, fotg210->ep0_req); |
| 1073 | for (i = 0; i < FOTG210_MAX_NUM_EP; i++) | ||
| 1074 | kfree(fotg210->ep[i]); | ||
| 1072 | kfree(fotg210); | 1075 | kfree(fotg210); |
| 1073 | 1076 | ||
| 1074 | return 0; | 1077 | return 0; |
| @@ -1099,7 +1102,7 @@ static int fotg210_udc_probe(struct platform_device *pdev) | |||
| 1099 | /* initialize udc */ | 1102 | /* initialize udc */ |
| 1100 | fotg210 = kzalloc(sizeof(struct fotg210_udc), GFP_KERNEL); | 1103 | fotg210 = kzalloc(sizeof(struct fotg210_udc), GFP_KERNEL); |
| 1101 | if (fotg210 == NULL) | 1104 | if (fotg210 == NULL) |
| 1102 | goto err_alloc; | 1105 | goto err; |
| 1103 | 1106 | ||
| 1104 | for (i = 0; i < FOTG210_MAX_NUM_EP; i++) { | 1107 | for (i = 0; i < FOTG210_MAX_NUM_EP; i++) { |
| 1105 | _ep[i] = kzalloc(sizeof(struct fotg210_ep), GFP_KERNEL); | 1108 | _ep[i] = kzalloc(sizeof(struct fotg210_ep), GFP_KERNEL); |
| @@ -1111,7 +1114,7 @@ static int fotg210_udc_probe(struct platform_device *pdev) | |||
| 1111 | fotg210->reg = ioremap(res->start, resource_size(res)); | 1114 | fotg210->reg = ioremap(res->start, resource_size(res)); |
| 1112 | if (fotg210->reg == NULL) { | 1115 | if (fotg210->reg == NULL) { |
| 1113 | pr_err("ioremap error.\n"); | 1116 | pr_err("ioremap error.\n"); |
| 1114 | goto err_map; | 1117 | goto err_alloc; |
| 1115 | } | 1118 | } |
| 1116 | 1119 | ||
| 1117 | spin_lock_init(&fotg210->lock); | 1120 | spin_lock_init(&fotg210->lock); |
| @@ -1159,7 +1162,7 @@ static int fotg210_udc_probe(struct platform_device *pdev) | |||
| 1159 | fotg210->ep0_req = fotg210_ep_alloc_request(&fotg210->ep[0]->ep, | 1162 | fotg210->ep0_req = fotg210_ep_alloc_request(&fotg210->ep[0]->ep, |
| 1160 | GFP_KERNEL); | 1163 | GFP_KERNEL); |
| 1161 | if (fotg210->ep0_req == NULL) | 1164 | if (fotg210->ep0_req == NULL) |
| 1162 | goto err_req; | 1165 | goto err_map; |
| 1163 | 1166 | ||
| 1164 | fotg210_init(fotg210); | 1167 | fotg210_init(fotg210); |
| 1165 | 1168 | ||
| @@ -1187,12 +1190,14 @@ err_req: | |||
| 1187 | fotg210_ep_free_request(&fotg210->ep[0]->ep, fotg210->ep0_req); | 1190 | fotg210_ep_free_request(&fotg210->ep[0]->ep, fotg210->ep0_req); |
| 1188 | 1191 | ||
| 1189 | err_map: | 1192 | err_map: |
| 1190 | if (fotg210->reg) | 1193 | iounmap(fotg210->reg); |
| 1191 | iounmap(fotg210->reg); | ||
| 1192 | 1194 | ||
| 1193 | err_alloc: | 1195 | err_alloc: |
| 1196 | for (i = 0; i < FOTG210_MAX_NUM_EP; i++) | ||
| 1197 | kfree(fotg210->ep[i]); | ||
| 1194 | kfree(fotg210); | 1198 | kfree(fotg210); |
| 1195 | 1199 | ||
| 1200 | err: | ||
| 1196 | return ret; | 1201 | return ret; |
| 1197 | } | 1202 | } |
| 1198 | 1203 | ||
diff --git a/drivers/usb/gadget/udc/net2280.c b/drivers/usb/gadget/udc/net2280.c index 318246d8b2e2..b02ab2a8d927 100644 --- a/drivers/usb/gadget/udc/net2280.c +++ b/drivers/usb/gadget/udc/net2280.c | |||
| @@ -1545,11 +1545,14 @@ static int net2280_pullup(struct usb_gadget *_gadget, int is_on) | |||
| 1545 | writel(tmp | BIT(USB_DETECT_ENABLE), &dev->usb->usbctl); | 1545 | writel(tmp | BIT(USB_DETECT_ENABLE), &dev->usb->usbctl); |
| 1546 | } else { | 1546 | } else { |
| 1547 | writel(tmp & ~BIT(USB_DETECT_ENABLE), &dev->usb->usbctl); | 1547 | writel(tmp & ~BIT(USB_DETECT_ENABLE), &dev->usb->usbctl); |
| 1548 | stop_activity(dev, dev->driver); | 1548 | stop_activity(dev, NULL); |
| 1549 | } | 1549 | } |
| 1550 | 1550 | ||
| 1551 | spin_unlock_irqrestore(&dev->lock, flags); | 1551 | spin_unlock_irqrestore(&dev->lock, flags); |
| 1552 | 1552 | ||
| 1553 | if (!is_on && dev->driver) | ||
| 1554 | dev->driver->disconnect(&dev->gadget); | ||
| 1555 | |||
| 1553 | return 0; | 1556 | return 0; |
| 1554 | } | 1557 | } |
| 1555 | 1558 | ||
| @@ -2466,8 +2469,11 @@ static void stop_activity(struct net2280 *dev, struct usb_gadget_driver *driver) | |||
| 2466 | nuke(&dev->ep[i]); | 2469 | nuke(&dev->ep[i]); |
| 2467 | 2470 | ||
| 2468 | /* report disconnect; the driver is already quiesced */ | 2471 | /* report disconnect; the driver is already quiesced */ |
| 2469 | if (driver) | 2472 | if (driver) { |
| 2473 | spin_unlock(&dev->lock); | ||
| 2470 | driver->disconnect(&dev->gadget); | 2474 | driver->disconnect(&dev->gadget); |
| 2475 | spin_lock(&dev->lock); | ||
| 2476 | } | ||
| 2471 | 2477 | ||
| 2472 | usb_reinit(dev); | 2478 | usb_reinit(dev); |
| 2473 | } | 2479 | } |
| @@ -3341,6 +3347,8 @@ next_endpoints: | |||
| 3341 | BIT(PCI_RETRY_ABORT_INTERRUPT)) | 3347 | BIT(PCI_RETRY_ABORT_INTERRUPT)) |
| 3342 | 3348 | ||
| 3343 | static void handle_stat1_irqs(struct net2280 *dev, u32 stat) | 3349 | static void handle_stat1_irqs(struct net2280 *dev, u32 stat) |
| 3350 | __releases(dev->lock) | ||
| 3351 | __acquires(dev->lock) | ||
| 3344 | { | 3352 | { |
| 3345 | struct net2280_ep *ep; | 3353 | struct net2280_ep *ep; |
| 3346 | u32 tmp, num, mask, scratch; | 3354 | u32 tmp, num, mask, scratch; |
| @@ -3381,12 +3389,14 @@ static void handle_stat1_irqs(struct net2280 *dev, u32 stat) | |||
| 3381 | if (disconnect || reset) { | 3389 | if (disconnect || reset) { |
| 3382 | stop_activity(dev, dev->driver); | 3390 | stop_activity(dev, dev->driver); |
| 3383 | ep0_start(dev); | 3391 | ep0_start(dev); |
| 3392 | spin_unlock(&dev->lock); | ||
| 3384 | if (reset) | 3393 | if (reset) |
| 3385 | usb_gadget_udc_reset | 3394 | usb_gadget_udc_reset |
| 3386 | (&dev->gadget, dev->driver); | 3395 | (&dev->gadget, dev->driver); |
| 3387 | else | 3396 | else |
| 3388 | (dev->driver->disconnect) | 3397 | (dev->driver->disconnect) |
| 3389 | (&dev->gadget); | 3398 | (&dev->gadget); |
| 3399 | spin_lock(&dev->lock); | ||
| 3390 | return; | 3400 | return; |
| 3391 | } | 3401 | } |
| 3392 | } | 3402 | } |
| @@ -3405,6 +3415,7 @@ static void handle_stat1_irqs(struct net2280 *dev, u32 stat) | |||
| 3405 | tmp = BIT(SUSPEND_REQUEST_CHANGE_INTERRUPT); | 3415 | tmp = BIT(SUSPEND_REQUEST_CHANGE_INTERRUPT); |
| 3406 | if (stat & tmp) { | 3416 | if (stat & tmp) { |
| 3407 | writel(tmp, &dev->regs->irqstat1); | 3417 | writel(tmp, &dev->regs->irqstat1); |
| 3418 | spin_unlock(&dev->lock); | ||
| 3408 | if (stat & BIT(SUSPEND_REQUEST_INTERRUPT)) { | 3419 | if (stat & BIT(SUSPEND_REQUEST_INTERRUPT)) { |
| 3409 | if (dev->driver->suspend) | 3420 | if (dev->driver->suspend) |
| 3410 | dev->driver->suspend(&dev->gadget); | 3421 | dev->driver->suspend(&dev->gadget); |
| @@ -3415,6 +3426,7 @@ static void handle_stat1_irqs(struct net2280 *dev, u32 stat) | |||
| 3415 | dev->driver->resume(&dev->gadget); | 3426 | dev->driver->resume(&dev->gadget); |
| 3416 | /* at high speed, note erratum 0133 */ | 3427 | /* at high speed, note erratum 0133 */ |
| 3417 | } | 3428 | } |
| 3429 | spin_lock(&dev->lock); | ||
| 3418 | stat &= ~tmp; | 3430 | stat &= ~tmp; |
| 3419 | } | 3431 | } |
| 3420 | 3432 | ||
diff --git a/drivers/usb/gadget/udc/renesas_usb3.c b/drivers/usb/gadget/udc/renesas_usb3.c index 1f879b3f2c96..e1656f361e08 100644 --- a/drivers/usb/gadget/udc/renesas_usb3.c +++ b/drivers/usb/gadget/udc/renesas_usb3.c | |||
| @@ -812,12 +812,15 @@ static void usb3_irq_epc_int_1_speed(struct renesas_usb3 *usb3) | |||
| 812 | switch (speed) { | 812 | switch (speed) { |
| 813 | case USB_STA_SPEED_SS: | 813 | case USB_STA_SPEED_SS: |
| 814 | usb3->gadget.speed = USB_SPEED_SUPER; | 814 | usb3->gadget.speed = USB_SPEED_SUPER; |
| 815 | usb3->gadget.ep0->maxpacket = USB3_EP0_SS_MAX_PACKET_SIZE; | ||
| 815 | break; | 816 | break; |
| 816 | case USB_STA_SPEED_HS: | 817 | case USB_STA_SPEED_HS: |
| 817 | usb3->gadget.speed = USB_SPEED_HIGH; | 818 | usb3->gadget.speed = USB_SPEED_HIGH; |
| 819 | usb3->gadget.ep0->maxpacket = USB3_EP0_HSFS_MAX_PACKET_SIZE; | ||
| 818 | break; | 820 | break; |
| 819 | case USB_STA_SPEED_FS: | 821 | case USB_STA_SPEED_FS: |
| 820 | usb3->gadget.speed = USB_SPEED_FULL; | 822 | usb3->gadget.speed = USB_SPEED_FULL; |
| 823 | usb3->gadget.ep0->maxpacket = USB3_EP0_HSFS_MAX_PACKET_SIZE; | ||
| 821 | break; | 824 | break; |
| 822 | default: | 825 | default: |
| 823 | usb3->gadget.speed = USB_SPEED_UNKNOWN; | 826 | usb3->gadget.speed = USB_SPEED_UNKNOWN; |
| @@ -2513,7 +2516,7 @@ static int renesas_usb3_init_ep(struct renesas_usb3 *usb3, struct device *dev, | |||
| 2513 | /* for control pipe */ | 2516 | /* for control pipe */ |
| 2514 | usb3->gadget.ep0 = &usb3_ep->ep; | 2517 | usb3->gadget.ep0 = &usb3_ep->ep; |
| 2515 | usb_ep_set_maxpacket_limit(&usb3_ep->ep, | 2518 | usb_ep_set_maxpacket_limit(&usb3_ep->ep, |
| 2516 | USB3_EP0_HSFS_MAX_PACKET_SIZE); | 2519 | USB3_EP0_SS_MAX_PACKET_SIZE); |
| 2517 | usb3_ep->ep.caps.type_control = true; | 2520 | usb3_ep->ep.caps.type_control = true; |
| 2518 | usb3_ep->ep.caps.dir_in = true; | 2521 | usb3_ep->ep.caps.dir_in = true; |
| 2519 | usb3_ep->ep.caps.dir_out = true; | 2522 | usb3_ep->ep.caps.dir_out = true; |
diff --git a/drivers/usb/host/u132-hcd.c b/drivers/usb/host/u132-hcd.c index 072bd5d5738e..5b8a3d9530c4 100644 --- a/drivers/usb/host/u132-hcd.c +++ b/drivers/usb/host/u132-hcd.c | |||
| @@ -2555,7 +2555,7 @@ static int u132_get_frame(struct usb_hcd *hcd) | |||
| 2555 | } else { | 2555 | } else { |
| 2556 | int frame = 0; | 2556 | int frame = 0; |
| 2557 | dev_err(&u132->platform_dev->dev, "TODO: u132_get_frame\n"); | 2557 | dev_err(&u132->platform_dev->dev, "TODO: u132_get_frame\n"); |
| 2558 | msleep(100); | 2558 | mdelay(100); |
| 2559 | return frame; | 2559 | return frame; |
| 2560 | } | 2560 | } |
| 2561 | } | 2561 | } |
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index ef350c33dc4a..b1f27aa38b10 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c | |||
| @@ -1613,6 +1613,10 @@ void xhci_endpoint_copy(struct xhci_hcd *xhci, | |||
| 1613 | in_ep_ctx->ep_info2 = out_ep_ctx->ep_info2; | 1613 | in_ep_ctx->ep_info2 = out_ep_ctx->ep_info2; |
| 1614 | in_ep_ctx->deq = out_ep_ctx->deq; | 1614 | in_ep_ctx->deq = out_ep_ctx->deq; |
| 1615 | in_ep_ctx->tx_info = out_ep_ctx->tx_info; | 1615 | in_ep_ctx->tx_info = out_ep_ctx->tx_info; |
| 1616 | if (xhci->quirks & XHCI_MTK_HOST) { | ||
| 1617 | in_ep_ctx->reserved[0] = out_ep_ctx->reserved[0]; | ||
| 1618 | in_ep_ctx->reserved[1] = out_ep_ctx->reserved[1]; | ||
| 1619 | } | ||
| 1616 | } | 1620 | } |
| 1617 | 1621 | ||
| 1618 | /* Copy output xhci_slot_ctx to the input xhci_slot_ctx. | 1622 | /* Copy output xhci_slot_ctx to the input xhci_slot_ctx. |
diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c index 8dc77e34a859..94e939249b2b 100644 --- a/drivers/usb/host/xhci-plat.c +++ b/drivers/usb/host/xhci-plat.c | |||
| @@ -153,7 +153,7 @@ static int xhci_plat_probe(struct platform_device *pdev) | |||
| 153 | { | 153 | { |
| 154 | const struct xhci_plat_priv *priv_match; | 154 | const struct xhci_plat_priv *priv_match; |
| 155 | const struct hc_driver *driver; | 155 | const struct hc_driver *driver; |
| 156 | struct device *sysdev; | 156 | struct device *sysdev, *tmpdev; |
| 157 | struct xhci_hcd *xhci; | 157 | struct xhci_hcd *xhci; |
| 158 | struct resource *res; | 158 | struct resource *res; |
| 159 | struct usb_hcd *hcd; | 159 | struct usb_hcd *hcd; |
| @@ -273,19 +273,24 @@ static int xhci_plat_probe(struct platform_device *pdev) | |||
| 273 | goto disable_clk; | 273 | goto disable_clk; |
| 274 | } | 274 | } |
| 275 | 275 | ||
| 276 | if (device_property_read_bool(sysdev, "usb2-lpm-disable")) | 276 | /* imod_interval is the interrupt moderation value in nanoseconds. */ |
| 277 | xhci->quirks |= XHCI_HW_LPM_DISABLE; | 277 | xhci->imod_interval = 40000; |
| 278 | 278 | ||
| 279 | if (device_property_read_bool(sysdev, "usb3-lpm-capable")) | 279 | /* Iterate over all parent nodes for finding quirks */ |
| 280 | xhci->quirks |= XHCI_LPM_SUPPORT; | 280 | for (tmpdev = &pdev->dev; tmpdev; tmpdev = tmpdev->parent) { |
| 281 | 281 | ||
| 282 | if (device_property_read_bool(&pdev->dev, "quirk-broken-port-ped")) | 282 | if (device_property_read_bool(tmpdev, "usb2-lpm-disable")) |
| 283 | xhci->quirks |= XHCI_BROKEN_PORT_PED; | 283 | xhci->quirks |= XHCI_HW_LPM_DISABLE; |
| 284 | 284 | ||
| 285 | /* imod_interval is the interrupt moderation value in nanoseconds. */ | 285 | if (device_property_read_bool(tmpdev, "usb3-lpm-capable")) |
| 286 | xhci->imod_interval = 40000; | 286 | xhci->quirks |= XHCI_LPM_SUPPORT; |
| 287 | device_property_read_u32(sysdev, "imod-interval-ns", | 287 | |
| 288 | &xhci->imod_interval); | 288 | if (device_property_read_bool(tmpdev, "quirk-broken-port-ped")) |
| 289 | xhci->quirks |= XHCI_BROKEN_PORT_PED; | ||
| 290 | |||
| 291 | device_property_read_u32(tmpdev, "imod-interval-ns", | ||
| 292 | &xhci->imod_interval); | ||
| 293 | } | ||
| 289 | 294 | ||
| 290 | hcd->usb_phy = devm_usb_get_phy_by_phandle(sysdev, "usb-phy", 0); | 295 | hcd->usb_phy = devm_usb_get_phy_by_phandle(sysdev, "usb-phy", 0); |
| 291 | if (IS_ERR(hcd->usb_phy)) { | 296 | if (IS_ERR(hcd->usb_phy)) { |
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 61f48b17e57b..0420eefa647a 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c | |||
| @@ -37,6 +37,21 @@ static unsigned long long quirks; | |||
| 37 | module_param(quirks, ullong, S_IRUGO); | 37 | module_param(quirks, ullong, S_IRUGO); |
| 38 | MODULE_PARM_DESC(quirks, "Bit flags for quirks to be enabled as default"); | 38 | MODULE_PARM_DESC(quirks, "Bit flags for quirks to be enabled as default"); |
| 39 | 39 | ||
| 40 | static bool td_on_ring(struct xhci_td *td, struct xhci_ring *ring) | ||
| 41 | { | ||
| 42 | struct xhci_segment *seg = ring->first_seg; | ||
| 43 | |||
| 44 | if (!td || !td->start_seg) | ||
| 45 | return false; | ||
| 46 | do { | ||
| 47 | if (seg == td->start_seg) | ||
| 48 | return true; | ||
| 49 | seg = seg->next; | ||
| 50 | } while (seg && seg != ring->first_seg); | ||
| 51 | |||
| 52 | return false; | ||
| 53 | } | ||
| 54 | |||
| 40 | /* TODO: copied from ehci-hcd.c - can this be refactored? */ | 55 | /* TODO: copied from ehci-hcd.c - can this be refactored? */ |
| 41 | /* | 56 | /* |
| 42 | * xhci_handshake - spin reading hc until handshake completes or fails | 57 | * xhci_handshake - spin reading hc until handshake completes or fails |
| @@ -1571,6 +1586,21 @@ static int xhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) | |||
| 1571 | goto done; | 1586 | goto done; |
| 1572 | } | 1587 | } |
| 1573 | 1588 | ||
| 1589 | /* | ||
| 1590 | * check ring is not re-allocated since URB was enqueued. If it is, then | ||
| 1591 | * make sure none of the ring related pointers in this URB private data | ||
| 1592 | * are touched, such as td_list, otherwise we overwrite freed data | ||
| 1593 | */ | ||
| 1594 | if (!td_on_ring(&urb_priv->td[0], ep_ring)) { | ||
| 1595 | xhci_err(xhci, "Canceled URB td not found on endpoint ring"); | ||
| 1596 | for (i = urb_priv->num_tds_done; i < urb_priv->num_tds; i++) { | ||
| 1597 | td = &urb_priv->td[i]; | ||
| 1598 | if (!list_empty(&td->cancelled_td_list)) | ||
| 1599 | list_del_init(&td->cancelled_td_list); | ||
| 1600 | } | ||
| 1601 | goto err_giveback; | ||
| 1602 | } | ||
| 1603 | |||
| 1574 | if (xhci->xhc_state & XHCI_STATE_HALTED) { | 1604 | if (xhci->xhc_state & XHCI_STATE_HALTED) { |
| 1575 | xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb, | 1605 | xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb, |
| 1576 | "HC halted, freeing TD manually."); | 1606 | "HC halted, freeing TD manually."); |
diff --git a/drivers/usb/misc/uss720.c b/drivers/usb/misc/uss720.c index 82f220631bd7..b5d661644263 100644 --- a/drivers/usb/misc/uss720.c +++ b/drivers/usb/misc/uss720.c | |||
| @@ -369,7 +369,7 @@ static unsigned char parport_uss720_frob_control(struct parport *pp, unsigned ch | |||
| 369 | mask &= 0x0f; | 369 | mask &= 0x0f; |
| 370 | val &= 0x0f; | 370 | val &= 0x0f; |
| 371 | d = (priv->reg[1] & (~mask)) ^ val; | 371 | d = (priv->reg[1] & (~mask)) ^ val; |
| 372 | if (set_1284_register(pp, 2, d, GFP_KERNEL)) | 372 | if (set_1284_register(pp, 2, d, GFP_ATOMIC)) |
| 373 | return 0; | 373 | return 0; |
| 374 | priv->reg[1] = d; | 374 | priv->reg[1] = d; |
| 375 | return d & 0xf; | 375 | return d & 0xf; |
| @@ -379,7 +379,7 @@ static unsigned char parport_uss720_read_status(struct parport *pp) | |||
| 379 | { | 379 | { |
| 380 | unsigned char ret; | 380 | unsigned char ret; |
| 381 | 381 | ||
| 382 | if (get_1284_register(pp, 1, &ret, GFP_KERNEL)) | 382 | if (get_1284_register(pp, 1, &ret, GFP_ATOMIC)) |
| 383 | return 0; | 383 | return 0; |
| 384 | return ret & 0xf8; | 384 | return ret & 0xf8; |
| 385 | } | 385 | } |
diff --git a/drivers/usb/misc/yurex.c b/drivers/usb/misc/yurex.c index 3be40eaa1ac9..6d9fd5f64903 100644 --- a/drivers/usb/misc/yurex.c +++ b/drivers/usb/misc/yurex.c | |||
| @@ -413,6 +413,9 @@ static ssize_t yurex_read(struct file *file, char __user *buffer, size_t count, | |||
| 413 | spin_unlock_irqrestore(&dev->lock, flags); | 413 | spin_unlock_irqrestore(&dev->lock, flags); |
| 414 | mutex_unlock(&dev->io_mutex); | 414 | mutex_unlock(&dev->io_mutex); |
| 415 | 415 | ||
| 416 | if (WARN_ON_ONCE(len >= sizeof(in_buffer))) | ||
| 417 | return -EIO; | ||
| 418 | |||
| 416 | return simple_read_from_buffer(buffer, count, ppos, in_buffer, len); | 419 | return simple_read_from_buffer(buffer, count, ppos, in_buffer, len); |
| 417 | } | 420 | } |
| 418 | 421 | ||
| @@ -421,13 +424,13 @@ static ssize_t yurex_write(struct file *file, const char __user *user_buffer, | |||
| 421 | { | 424 | { |
| 422 | struct usb_yurex *dev; | 425 | struct usb_yurex *dev; |
| 423 | int i, set = 0, retval = 0; | 426 | int i, set = 0, retval = 0; |
| 424 | char buffer[16]; | 427 | char buffer[16 + 1]; |
| 425 | char *data = buffer; | 428 | char *data = buffer; |
| 426 | unsigned long long c, c2 = 0; | 429 | unsigned long long c, c2 = 0; |
| 427 | signed long timeout = 0; | 430 | signed long timeout = 0; |
| 428 | DEFINE_WAIT(wait); | 431 | DEFINE_WAIT(wait); |
| 429 | 432 | ||
| 430 | count = min(sizeof(buffer), count); | 433 | count = min(sizeof(buffer) - 1, count); |
| 431 | dev = file->private_data; | 434 | dev = file->private_data; |
| 432 | 435 | ||
| 433 | /* verify that we actually have some data to write */ | 436 | /* verify that we actually have some data to write */ |
| @@ -446,6 +449,7 @@ static ssize_t yurex_write(struct file *file, const char __user *user_buffer, | |||
| 446 | retval = -EFAULT; | 449 | retval = -EFAULT; |
| 447 | goto error; | 450 | goto error; |
| 448 | } | 451 | } |
| 452 | buffer[count] = 0; | ||
| 449 | memset(dev->cntl_buffer, CMD_PADDING, YUREX_BUF_SIZE); | 453 | memset(dev->cntl_buffer, CMD_PADDING, YUREX_BUF_SIZE); |
| 450 | 454 | ||
| 451 | switch (buffer[0]) { | 455 | switch (buffer[0]) { |
diff --git a/drivers/usb/mtu3/mtu3_core.c b/drivers/usb/mtu3/mtu3_core.c index eecfd0671362..d045d8458f81 100644 --- a/drivers/usb/mtu3/mtu3_core.c +++ b/drivers/usb/mtu3/mtu3_core.c | |||
| @@ -107,8 +107,12 @@ static int mtu3_device_enable(struct mtu3 *mtu) | |||
| 107 | (SSUSB_U2_PORT_DIS | SSUSB_U2_PORT_PDN | | 107 | (SSUSB_U2_PORT_DIS | SSUSB_U2_PORT_PDN | |
| 108 | SSUSB_U2_PORT_HOST_SEL)); | 108 | SSUSB_U2_PORT_HOST_SEL)); |
| 109 | 109 | ||
| 110 | if (mtu->ssusb->dr_mode == USB_DR_MODE_OTG) | 110 | if (mtu->ssusb->dr_mode == USB_DR_MODE_OTG) { |
| 111 | mtu3_setbits(ibase, SSUSB_U2_CTRL(0), SSUSB_U2_PORT_OTG_SEL); | 111 | mtu3_setbits(ibase, SSUSB_U2_CTRL(0), SSUSB_U2_PORT_OTG_SEL); |
| 112 | if (mtu->is_u3_ip) | ||
| 113 | mtu3_setbits(ibase, SSUSB_U3_CTRL(0), | ||
| 114 | SSUSB_U3_PORT_DUAL_MODE); | ||
| 115 | } | ||
| 112 | 116 | ||
| 113 | return ssusb_check_clocks(mtu->ssusb, check_clk); | 117 | return ssusb_check_clocks(mtu->ssusb, check_clk); |
| 114 | } | 118 | } |
diff --git a/drivers/usb/mtu3/mtu3_hw_regs.h b/drivers/usb/mtu3/mtu3_hw_regs.h index 6ee371478d89..a45bb253939f 100644 --- a/drivers/usb/mtu3/mtu3_hw_regs.h +++ b/drivers/usb/mtu3/mtu3_hw_regs.h | |||
| @@ -459,6 +459,7 @@ | |||
| 459 | 459 | ||
| 460 | /* U3D_SSUSB_U3_CTRL_0P */ | 460 | /* U3D_SSUSB_U3_CTRL_0P */ |
| 461 | #define SSUSB_U3_PORT_SSP_SPEED BIT(9) | 461 | #define SSUSB_U3_PORT_SSP_SPEED BIT(9) |
| 462 | #define SSUSB_U3_PORT_DUAL_MODE BIT(7) | ||
| 462 | #define SSUSB_U3_PORT_HOST_SEL BIT(2) | 463 | #define SSUSB_U3_PORT_HOST_SEL BIT(2) |
| 463 | #define SSUSB_U3_PORT_PDN BIT(1) | 464 | #define SSUSB_U3_PORT_PDN BIT(1) |
| 464 | #define SSUSB_U3_PORT_DIS BIT(0) | 465 | #define SSUSB_U3_PORT_DIS BIT(0) |
diff --git a/drivers/usb/serial/io_ti.h b/drivers/usb/serial/io_ti.h index e53c68261017..9bbcee37524e 100644 --- a/drivers/usb/serial/io_ti.h +++ b/drivers/usb/serial/io_ti.h | |||
| @@ -173,7 +173,7 @@ struct ump_interrupt { | |||
| 173 | } __attribute__((packed)); | 173 | } __attribute__((packed)); |
| 174 | 174 | ||
| 175 | 175 | ||
| 176 | #define TIUMP_GET_PORT_FROM_CODE(c) (((c) >> 4) - 3) | 176 | #define TIUMP_GET_PORT_FROM_CODE(c) (((c) >> 6) & 0x01) |
| 177 | #define TIUMP_GET_FUNC_FROM_CODE(c) ((c) & 0x0f) | 177 | #define TIUMP_GET_FUNC_FROM_CODE(c) ((c) & 0x0f) |
| 178 | #define TIUMP_INTERRUPT_CODE_LSR 0x03 | 178 | #define TIUMP_INTERRUPT_CODE_LSR 0x03 |
| 179 | #define TIUMP_INTERRUPT_CODE_MSR 0x04 | 179 | #define TIUMP_INTERRUPT_CODE_MSR 0x04 |
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c index 3010878f7f8e..e3c5832337e0 100644 --- a/drivers/usb/serial/ti_usb_3410_5052.c +++ b/drivers/usb/serial/ti_usb_3410_5052.c | |||
| @@ -1119,7 +1119,7 @@ static void ti_break(struct tty_struct *tty, int break_state) | |||
| 1119 | 1119 | ||
| 1120 | static int ti_get_port_from_code(unsigned char code) | 1120 | static int ti_get_port_from_code(unsigned char code) |
| 1121 | { | 1121 | { |
| 1122 | return (code >> 4) - 3; | 1122 | return (code >> 6) & 0x01; |
| 1123 | } | 1123 | } |
| 1124 | 1124 | ||
| 1125 | static int ti_get_func_from_code(unsigned char code) | 1125 | static int ti_get_func_from_code(unsigned char code) |
diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c index c267f2812a04..e227bb5b794f 100644 --- a/drivers/usb/storage/scsiglue.c +++ b/drivers/usb/storage/scsiglue.c | |||
| @@ -376,6 +376,15 @@ static int queuecommand_lck(struct scsi_cmnd *srb, | |||
| 376 | return 0; | 376 | return 0; |
| 377 | } | 377 | } |
| 378 | 378 | ||
| 379 | if ((us->fflags & US_FL_NO_ATA_1X) && | ||
| 380 | (srb->cmnd[0] == ATA_12 || srb->cmnd[0] == ATA_16)) { | ||
| 381 | memcpy(srb->sense_buffer, usb_stor_sense_invalidCDB, | ||
| 382 | sizeof(usb_stor_sense_invalidCDB)); | ||
| 383 | srb->result = SAM_STAT_CHECK_CONDITION; | ||
| 384 | done(srb); | ||
| 385 | return 0; | ||
| 386 | } | ||
| 387 | |||
| 379 | /* enqueue the command and wake up the control thread */ | 388 | /* enqueue the command and wake up the control thread */ |
| 380 | srb->scsi_done = done; | 389 | srb->scsi_done = done; |
| 381 | us->srb = srb; | 390 | us->srb = srb; |
diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c index 9e9de5452860..1f7b401c4d04 100644 --- a/drivers/usb/storage/uas.c +++ b/drivers/usb/storage/uas.c | |||
| @@ -842,6 +842,27 @@ static int uas_slave_configure(struct scsi_device *sdev) | |||
| 842 | sdev->skip_ms_page_8 = 1; | 842 | sdev->skip_ms_page_8 = 1; |
| 843 | sdev->wce_default_on = 1; | 843 | sdev->wce_default_on = 1; |
| 844 | } | 844 | } |
| 845 | |||
| 846 | /* | ||
| 847 | * Some disks return the total number of blocks in response | ||
| 848 | * to READ CAPACITY rather than the highest block number. | ||
| 849 | * If this device makes that mistake, tell the sd driver. | ||
| 850 | */ | ||
| 851 | if (devinfo->flags & US_FL_FIX_CAPACITY) | ||
| 852 | sdev->fix_capacity = 1; | ||
| 853 | |||
| 854 | /* | ||
| 855 | * Some devices don't like MODE SENSE with page=0x3f, | ||
| 856 | * which is the command used for checking if a device | ||
| 857 | * is write-protected. Now that we tell the sd driver | ||
| 858 | * to do a 192-byte transfer with this command the | ||
| 859 | * majority of devices work fine, but a few still can't | ||
| 860 | * handle it. The sd driver will simply assume those | ||
| 861 | * devices are write-enabled. | ||
| 862 | */ | ||
| 863 | if (devinfo->flags & US_FL_NO_WP_DETECT) | ||
| 864 | sdev->skip_ms_page_3f = 1; | ||
| 865 | |||
| 845 | scsi_change_queue_depth(sdev, devinfo->qdepth - 2); | 866 | scsi_change_queue_depth(sdev, devinfo->qdepth - 2); |
| 846 | return 0; | 867 | return 0; |
| 847 | } | 868 | } |
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h index 22fcfccf453a..f7f83b21dc74 100644 --- a/drivers/usb/storage/unusual_devs.h +++ b/drivers/usb/storage/unusual_devs.h | |||
| @@ -2288,6 +2288,13 @@ UNUSUAL_DEV( 0x2735, 0x100b, 0x0000, 0x9999, | |||
| 2288 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, | 2288 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, |
| 2289 | US_FL_GO_SLOW ), | 2289 | US_FL_GO_SLOW ), |
| 2290 | 2290 | ||
| 2291 | /* Reported-by: Tim Anderson <tsa@biglakesoftware.com> */ | ||
| 2292 | UNUSUAL_DEV( 0x2ca3, 0x0031, 0x0000, 0x9999, | ||
| 2293 | "DJI", | ||
| 2294 | "CineSSD", | ||
| 2295 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, | ||
| 2296 | US_FL_NO_ATA_1X), | ||
| 2297 | |||
| 2291 | /* | 2298 | /* |
| 2292 | * Reported by Frederic Marchal <frederic.marchal@wowcompany.com> | 2299 | * Reported by Frederic Marchal <frederic.marchal@wowcompany.com> |
| 2293 | * Mio Moov 330 | 2300 | * Mio Moov 330 |
diff --git a/drivers/usb/typec/bus.c b/drivers/usb/typec/bus.c index 95a2b10127db..76299b6ff06d 100644 --- a/drivers/usb/typec/bus.c +++ b/drivers/usb/typec/bus.c | |||
| @@ -255,12 +255,13 @@ EXPORT_SYMBOL_GPL(typec_altmode_unregister_driver); | |||
| 255 | /* API for the port drivers */ | 255 | /* API for the port drivers */ |
| 256 | 256 | ||
| 257 | /** | 257 | /** |
| 258 | * typec_match_altmode - Match SVID to an array of alternate modes | 258 | * typec_match_altmode - Match SVID and mode to an array of alternate modes |
| 259 | * @altmodes: Array of alternate modes | 259 | * @altmodes: Array of alternate modes |
| 260 | * @n: Number of elements in the array, or -1 for NULL termiated arrays | 260 | * @n: Number of elements in the array, or -1 for NULL terminated arrays |
| 261 | * @svid: Standard or Vendor ID to match with | 261 | * @svid: Standard or Vendor ID to match with |
| 262 | * @mode: Mode to match with | ||
| 262 | * | 263 | * |
| 263 | * Return pointer to an alternate mode with SVID mathing @svid, or NULL when no | 264 | * Return pointer to an alternate mode with SVID matching @svid, or NULL when no |
| 264 | * match is found. | 265 | * match is found. |
| 265 | */ | 266 | */ |
| 266 | struct typec_altmode *typec_match_altmode(struct typec_altmode **altmodes, | 267 | struct typec_altmode *typec_match_altmode(struct typec_altmode **altmodes, |
diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c index c202975f8097..e61dffb27a0c 100644 --- a/drivers/usb/typec/class.c +++ b/drivers/usb/typec/class.c | |||
| @@ -1484,7 +1484,6 @@ EXPORT_SYMBOL_GPL(typec_set_mode); | |||
| 1484 | * typec_port_register_altmode - Register USB Type-C Port Alternate Mode | 1484 | * typec_port_register_altmode - Register USB Type-C Port Alternate Mode |
| 1485 | * @port: USB Type-C Port that supports the alternate mode | 1485 | * @port: USB Type-C Port that supports the alternate mode |
| 1486 | * @desc: Description of the alternate mode | 1486 | * @desc: Description of the alternate mode |
| 1487 | * @drvdata: Private pointer to driver specific info | ||
| 1488 | * | 1487 | * |
| 1489 | * This routine is used to register an alternate mode that @port is capable of | 1488 | * This routine is used to register an alternate mode that @port is capable of |
| 1490 | * supporting. | 1489 | * supporting. |
diff --git a/drivers/xen/Kconfig b/drivers/xen/Kconfig index b459edfacff3..90d387b50ab7 100644 --- a/drivers/xen/Kconfig +++ b/drivers/xen/Kconfig | |||
| @@ -79,15 +79,19 @@ config XEN_BALLOON_MEMORY_HOTPLUG_LIMIT | |||
| 79 | This value is used to allocate enough space in internal | 79 | This value is used to allocate enough space in internal |
| 80 | tables needed for physical memory administration. | 80 | tables needed for physical memory administration. |
| 81 | 81 | ||
| 82 | config XEN_SCRUB_PAGES | 82 | config XEN_SCRUB_PAGES_DEFAULT |
| 83 | bool "Scrub pages before returning them to system" | 83 | bool "Scrub pages before returning them to system by default" |
| 84 | depends on XEN_BALLOON | 84 | depends on XEN_BALLOON |
| 85 | default y | 85 | default y |
| 86 | help | 86 | help |
| 87 | Scrub pages before returning them to the system for reuse by | 87 | Scrub pages before returning them to the system for reuse by |
| 88 | other domains. This makes sure that any confidential data | 88 | other domains. This makes sure that any confidential data |
| 89 | is not accidentally visible to other domains. Is it more | 89 | is not accidentally visible to other domains. Is it more |
| 90 | secure, but slightly less efficient. | 90 | secure, but slightly less efficient. This can be controlled with |
| 91 | xen_scrub_pages=0 parameter and | ||
| 92 | /sys/devices/system/xen_memory/xen_memory0/scrub_pages. | ||
| 93 | This option only sets the default value. | ||
| 94 | |||
| 91 | If in doubt, say yes. | 95 | If in doubt, say yes. |
| 92 | 96 | ||
| 93 | config XEN_DEV_EVTCHN | 97 | config XEN_DEV_EVTCHN |
diff --git a/drivers/xen/cpu_hotplug.c b/drivers/xen/cpu_hotplug.c index d4265c8ebb22..b1357aa4bc55 100644 --- a/drivers/xen/cpu_hotplug.c +++ b/drivers/xen/cpu_hotplug.c | |||
| @@ -19,15 +19,16 @@ static void enable_hotplug_cpu(int cpu) | |||
| 19 | 19 | ||
| 20 | static void disable_hotplug_cpu(int cpu) | 20 | static void disable_hotplug_cpu(int cpu) |
| 21 | { | 21 | { |
| 22 | if (cpu_online(cpu)) { | 22 | if (!cpu_is_hotpluggable(cpu)) |
| 23 | lock_device_hotplug(); | 23 | return; |
| 24 | lock_device_hotplug(); | ||
| 25 | if (cpu_online(cpu)) | ||
| 24 | device_offline(get_cpu_device(cpu)); | 26 | device_offline(get_cpu_device(cpu)); |
| 25 | unlock_device_hotplug(); | 27 | if (!cpu_online(cpu) && cpu_present(cpu)) { |
| 26 | } | ||
| 27 | if (cpu_present(cpu)) | ||
| 28 | xen_arch_unregister_cpu(cpu); | 28 | xen_arch_unregister_cpu(cpu); |
| 29 | 29 | set_cpu_present(cpu, false); | |
| 30 | set_cpu_present(cpu, false); | 30 | } |
| 31 | unlock_device_hotplug(); | ||
| 31 | } | 32 | } |
| 32 | 33 | ||
| 33 | static int vcpu_online(unsigned int cpu) | 34 | static int vcpu_online(unsigned int cpu) |
diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c index 08e4af04d6f2..e6c1934734b7 100644 --- a/drivers/xen/events/events_base.c +++ b/drivers/xen/events/events_base.c | |||
| @@ -138,7 +138,7 @@ static int set_evtchn_to_irq(unsigned evtchn, unsigned irq) | |||
| 138 | clear_evtchn_to_irq_row(row); | 138 | clear_evtchn_to_irq_row(row); |
| 139 | } | 139 | } |
| 140 | 140 | ||
| 141 | evtchn_to_irq[EVTCHN_ROW(evtchn)][EVTCHN_COL(evtchn)] = irq; | 141 | evtchn_to_irq[row][col] = irq; |
| 142 | return 0; | 142 | return 0; |
| 143 | } | 143 | } |
| 144 | 144 | ||
diff --git a/drivers/xen/gntdev.c b/drivers/xen/gntdev.c index 57390c7666e5..b0b02a501167 100644 --- a/drivers/xen/gntdev.c +++ b/drivers/xen/gntdev.c | |||
| @@ -492,12 +492,19 @@ static bool in_range(struct gntdev_grant_map *map, | |||
| 492 | return true; | 492 | return true; |
| 493 | } | 493 | } |
| 494 | 494 | ||
| 495 | static void unmap_if_in_range(struct gntdev_grant_map *map, | 495 | static int unmap_if_in_range(struct gntdev_grant_map *map, |
| 496 | unsigned long start, unsigned long end) | 496 | unsigned long start, unsigned long end, |
| 497 | bool blockable) | ||
| 497 | { | 498 | { |
| 498 | unsigned long mstart, mend; | 499 | unsigned long mstart, mend; |
| 499 | int err; | 500 | int err; |
| 500 | 501 | ||
| 502 | if (!in_range(map, start, end)) | ||
| 503 | return 0; | ||
| 504 | |||
| 505 | if (!blockable) | ||
| 506 | return -EAGAIN; | ||
| 507 | |||
| 501 | mstart = max(start, map->vma->vm_start); | 508 | mstart = max(start, map->vma->vm_start); |
| 502 | mend = min(end, map->vma->vm_end); | 509 | mend = min(end, map->vma->vm_end); |
| 503 | pr_debug("map %d+%d (%lx %lx), range %lx %lx, mrange %lx %lx\n", | 510 | pr_debug("map %d+%d (%lx %lx), range %lx %lx, mrange %lx %lx\n", |
| @@ -508,6 +515,8 @@ static void unmap_if_in_range(struct gntdev_grant_map *map, | |||
| 508 | (mstart - map->vma->vm_start) >> PAGE_SHIFT, | 515 | (mstart - map->vma->vm_start) >> PAGE_SHIFT, |
| 509 | (mend - mstart) >> PAGE_SHIFT); | 516 | (mend - mstart) >> PAGE_SHIFT); |
| 510 | WARN_ON(err); | 517 | WARN_ON(err); |
| 518 | |||
| 519 | return 0; | ||
| 511 | } | 520 | } |
| 512 | 521 | ||
| 513 | static int mn_invl_range_start(struct mmu_notifier *mn, | 522 | static int mn_invl_range_start(struct mmu_notifier *mn, |
| @@ -519,25 +528,20 @@ static int mn_invl_range_start(struct mmu_notifier *mn, | |||
| 519 | struct gntdev_grant_map *map; | 528 | struct gntdev_grant_map *map; |
| 520 | int ret = 0; | 529 | int ret = 0; |
| 521 | 530 | ||
| 522 | /* TODO do we really need a mutex here? */ | ||
| 523 | if (blockable) | 531 | if (blockable) |
| 524 | mutex_lock(&priv->lock); | 532 | mutex_lock(&priv->lock); |
| 525 | else if (!mutex_trylock(&priv->lock)) | 533 | else if (!mutex_trylock(&priv->lock)) |
| 526 | return -EAGAIN; | 534 | return -EAGAIN; |
| 527 | 535 | ||
| 528 | list_for_each_entry(map, &priv->maps, next) { | 536 | list_for_each_entry(map, &priv->maps, next) { |
| 529 | if (in_range(map, start, end)) { | 537 | ret = unmap_if_in_range(map, start, end, blockable); |
| 530 | ret = -EAGAIN; | 538 | if (ret) |
| 531 | goto out_unlock; | 539 | goto out_unlock; |
| 532 | } | ||
| 533 | unmap_if_in_range(map, start, end); | ||
| 534 | } | 540 | } |
| 535 | list_for_each_entry(map, &priv->freeable_maps, next) { | 541 | list_for_each_entry(map, &priv->freeable_maps, next) { |
| 536 | if (in_range(map, start, end)) { | 542 | ret = unmap_if_in_range(map, start, end, blockable); |
| 537 | ret = -EAGAIN; | 543 | if (ret) |
| 538 | goto out_unlock; | 544 | goto out_unlock; |
| 539 | } | ||
| 540 | unmap_if_in_range(map, start, end); | ||
| 541 | } | 545 | } |
| 542 | 546 | ||
| 543 | out_unlock: | 547 | out_unlock: |
diff --git a/drivers/xen/manage.c b/drivers/xen/manage.c index c93d8ef8df34..5bb01a62f214 100644 --- a/drivers/xen/manage.c +++ b/drivers/xen/manage.c | |||
| @@ -280,9 +280,11 @@ static void sysrq_handler(struct xenbus_watch *watch, const char *path, | |||
| 280 | /* | 280 | /* |
| 281 | * The Xenstore watch fires directly after registering it and | 281 | * The Xenstore watch fires directly after registering it and |
| 282 | * after a suspend/resume cycle. So ENOENT is no error but | 282 | * after a suspend/resume cycle. So ENOENT is no error but |
| 283 | * might happen in those cases. | 283 | * might happen in those cases. ERANGE is observed when we get |
| 284 | * an empty value (''), this happens when we acknowledge the | ||
| 285 | * request by writing '\0' below. | ||
| 284 | */ | 286 | */ |
| 285 | if (err != -ENOENT) | 287 | if (err != -ENOENT && err != -ERANGE) |
| 286 | pr_err("Error %d reading sysrq code in control/sysrq\n", | 288 | pr_err("Error %d reading sysrq code in control/sysrq\n", |
| 287 | err); | 289 | err); |
| 288 | xenbus_transaction_end(xbt, 1); | 290 | xenbus_transaction_end(xbt, 1); |
diff --git a/drivers/xen/mem-reservation.c b/drivers/xen/mem-reservation.c index 084799c6180e..3782cf070338 100644 --- a/drivers/xen/mem-reservation.c +++ b/drivers/xen/mem-reservation.c | |||
| @@ -14,6 +14,10 @@ | |||
| 14 | 14 | ||
| 15 | #include <xen/interface/memory.h> | 15 | #include <xen/interface/memory.h> |
| 16 | #include <xen/mem-reservation.h> | 16 | #include <xen/mem-reservation.h> |
| 17 | #include <linux/moduleparam.h> | ||
| 18 | |||
| 19 | bool __read_mostly xen_scrub_pages = IS_ENABLED(CONFIG_XEN_SCRUB_PAGES_DEFAULT); | ||
| 20 | core_param(xen_scrub_pages, xen_scrub_pages, bool, 0); | ||
| 17 | 21 | ||
| 18 | /* | 22 | /* |
| 19 | * Use one extent per PAGE_SIZE to avoid to break down the page into | 23 | * Use one extent per PAGE_SIZE to avoid to break down the page into |
diff --git a/drivers/xen/xen-balloon.c b/drivers/xen/xen-balloon.c index 294f35ce9e46..63c1494a8d73 100644 --- a/drivers/xen/xen-balloon.c +++ b/drivers/xen/xen-balloon.c | |||
| @@ -44,6 +44,7 @@ | |||
| 44 | #include <xen/xenbus.h> | 44 | #include <xen/xenbus.h> |
| 45 | #include <xen/features.h> | 45 | #include <xen/features.h> |
| 46 | #include <xen/page.h> | 46 | #include <xen/page.h> |
| 47 | #include <xen/mem-reservation.h> | ||
| 47 | 48 | ||
| 48 | #define PAGES2KB(_p) ((_p)<<(PAGE_SHIFT-10)) | 49 | #define PAGES2KB(_p) ((_p)<<(PAGE_SHIFT-10)) |
| 49 | 50 | ||
| @@ -137,6 +138,7 @@ static DEVICE_ULONG_ATTR(schedule_delay, 0444, balloon_stats.schedule_delay); | |||
| 137 | static DEVICE_ULONG_ATTR(max_schedule_delay, 0644, balloon_stats.max_schedule_delay); | 138 | static DEVICE_ULONG_ATTR(max_schedule_delay, 0644, balloon_stats.max_schedule_delay); |
| 138 | static DEVICE_ULONG_ATTR(retry_count, 0444, balloon_stats.retry_count); | 139 | static DEVICE_ULONG_ATTR(retry_count, 0444, balloon_stats.retry_count); |
| 139 | static DEVICE_ULONG_ATTR(max_retry_count, 0644, balloon_stats.max_retry_count); | 140 | static DEVICE_ULONG_ATTR(max_retry_count, 0644, balloon_stats.max_retry_count); |
| 141 | static DEVICE_BOOL_ATTR(scrub_pages, 0644, xen_scrub_pages); | ||
| 140 | 142 | ||
| 141 | static ssize_t show_target_kb(struct device *dev, struct device_attribute *attr, | 143 | static ssize_t show_target_kb(struct device *dev, struct device_attribute *attr, |
| 142 | char *buf) | 144 | char *buf) |
| @@ -203,6 +205,7 @@ static struct attribute *balloon_attrs[] = { | |||
| 203 | &dev_attr_max_schedule_delay.attr.attr, | 205 | &dev_attr_max_schedule_delay.attr.attr, |
| 204 | &dev_attr_retry_count.attr.attr, | 206 | &dev_attr_retry_count.attr.attr, |
| 205 | &dev_attr_max_retry_count.attr.attr, | 207 | &dev_attr_max_retry_count.attr.attr, |
| 208 | &dev_attr_scrub_pages.attr.attr, | ||
| 206 | NULL | 209 | NULL |
| 207 | }; | 210 | }; |
| 208 | 211 | ||
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 34830f6457ea..8220a168282e 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c | |||
| @@ -1637,6 +1637,14 @@ static void nfs_state_set_delegation(struct nfs4_state *state, | |||
| 1637 | write_sequnlock(&state->seqlock); | 1637 | write_sequnlock(&state->seqlock); |
| 1638 | } | 1638 | } |
| 1639 | 1639 | ||
| 1640 | static void nfs_state_clear_delegation(struct nfs4_state *state) | ||
| 1641 | { | ||
| 1642 | write_seqlock(&state->seqlock); | ||
| 1643 | nfs4_stateid_copy(&state->stateid, &state->open_stateid); | ||
| 1644 | clear_bit(NFS_DELEGATED_STATE, &state->flags); | ||
| 1645 | write_sequnlock(&state->seqlock); | ||
| 1646 | } | ||
| 1647 | |||
| 1640 | static int update_open_stateid(struct nfs4_state *state, | 1648 | static int update_open_stateid(struct nfs4_state *state, |
| 1641 | const nfs4_stateid *open_stateid, | 1649 | const nfs4_stateid *open_stateid, |
| 1642 | const nfs4_stateid *delegation, | 1650 | const nfs4_stateid *delegation, |
| @@ -2145,10 +2153,7 @@ int nfs4_open_delegation_recall(struct nfs_open_context *ctx, | |||
| 2145 | if (IS_ERR(opendata)) | 2153 | if (IS_ERR(opendata)) |
| 2146 | return PTR_ERR(opendata); | 2154 | return PTR_ERR(opendata); |
| 2147 | nfs4_stateid_copy(&opendata->o_arg.u.delegation, stateid); | 2155 | nfs4_stateid_copy(&opendata->o_arg.u.delegation, stateid); |
| 2148 | write_seqlock(&state->seqlock); | 2156 | nfs_state_clear_delegation(state); |
| 2149 | nfs4_stateid_copy(&state->stateid, &state->open_stateid); | ||
| 2150 | write_sequnlock(&state->seqlock); | ||
| 2151 | clear_bit(NFS_DELEGATED_STATE, &state->flags); | ||
| 2152 | switch (type & (FMODE_READ|FMODE_WRITE)) { | 2157 | switch (type & (FMODE_READ|FMODE_WRITE)) { |
| 2153 | case FMODE_READ|FMODE_WRITE: | 2158 | case FMODE_READ|FMODE_WRITE: |
| 2154 | case FMODE_WRITE: | 2159 | case FMODE_WRITE: |
| @@ -2601,10 +2606,7 @@ static void nfs_finish_clear_delegation_stateid(struct nfs4_state *state, | |||
| 2601 | const nfs4_stateid *stateid) | 2606 | const nfs4_stateid *stateid) |
| 2602 | { | 2607 | { |
| 2603 | nfs_remove_bad_delegation(state->inode, stateid); | 2608 | nfs_remove_bad_delegation(state->inode, stateid); |
| 2604 | write_seqlock(&state->seqlock); | 2609 | nfs_state_clear_delegation(state); |
| 2605 | nfs4_stateid_copy(&state->stateid, &state->open_stateid); | ||
| 2606 | write_sequnlock(&state->seqlock); | ||
| 2607 | clear_bit(NFS_DELEGATED_STATE, &state->flags); | ||
| 2608 | } | 2610 | } |
| 2609 | 2611 | ||
| 2610 | static void nfs40_clear_delegation_stateid(struct nfs4_state *state) | 2612 | static void nfs40_clear_delegation_stateid(struct nfs4_state *state) |
| @@ -2672,15 +2674,20 @@ static void nfs41_check_delegation_stateid(struct nfs4_state *state) | |||
| 2672 | delegation = rcu_dereference(NFS_I(state->inode)->delegation); | 2674 | delegation = rcu_dereference(NFS_I(state->inode)->delegation); |
| 2673 | if (delegation == NULL) { | 2675 | if (delegation == NULL) { |
| 2674 | rcu_read_unlock(); | 2676 | rcu_read_unlock(); |
| 2677 | nfs_state_clear_delegation(state); | ||
| 2675 | return; | 2678 | return; |
| 2676 | } | 2679 | } |
| 2677 | 2680 | ||
| 2678 | nfs4_stateid_copy(&stateid, &delegation->stateid); | 2681 | nfs4_stateid_copy(&stateid, &delegation->stateid); |
| 2679 | if (test_bit(NFS_DELEGATION_REVOKED, &delegation->flags) || | 2682 | if (test_bit(NFS_DELEGATION_REVOKED, &delegation->flags)) { |
| 2680 | !test_and_clear_bit(NFS_DELEGATION_TEST_EXPIRED, | 2683 | rcu_read_unlock(); |
| 2681 | &delegation->flags)) { | 2684 | nfs_state_clear_delegation(state); |
| 2685 | return; | ||
| 2686 | } | ||
| 2687 | |||
| 2688 | if (!test_and_clear_bit(NFS_DELEGATION_TEST_EXPIRED, | ||
| 2689 | &delegation->flags)) { | ||
| 2682 | rcu_read_unlock(); | 2690 | rcu_read_unlock(); |
| 2683 | nfs_finish_clear_delegation_stateid(state, &stateid); | ||
| 2684 | return; | 2691 | return; |
| 2685 | } | 2692 | } |
| 2686 | 2693 | ||
diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c index 3df0eb52da1c..40a08cd483f0 100644 --- a/fs/nfs/nfs4state.c +++ b/fs/nfs/nfs4state.c | |||
| @@ -1390,6 +1390,8 @@ int nfs4_schedule_stateid_recovery(const struct nfs_server *server, struct nfs4_ | |||
| 1390 | 1390 | ||
| 1391 | if (!nfs4_state_mark_reclaim_nograce(clp, state)) | 1391 | if (!nfs4_state_mark_reclaim_nograce(clp, state)) |
| 1392 | return -EBADF; | 1392 | return -EBADF; |
| 1393 | nfs_inode_find_delegation_state_and_recover(state->inode, | ||
| 1394 | &state->stateid); | ||
| 1393 | dprintk("%s: scheduling stateid recovery for server %s\n", __func__, | 1395 | dprintk("%s: scheduling stateid recovery for server %s\n", __func__, |
| 1394 | clp->cl_hostname); | 1396 | clp->cl_hostname); |
| 1395 | nfs4_schedule_state_manager(clp); | 1397 | nfs4_schedule_state_manager(clp); |
diff --git a/fs/nfs/nfs4trace.h b/fs/nfs/nfs4trace.h index a275fba93170..b1483b303e0b 100644 --- a/fs/nfs/nfs4trace.h +++ b/fs/nfs/nfs4trace.h | |||
| @@ -1137,7 +1137,7 @@ DECLARE_EVENT_CLASS(nfs4_inode_callback_event, | |||
| 1137 | TP_fast_assign( | 1137 | TP_fast_assign( |
| 1138 | __entry->error = error; | 1138 | __entry->error = error; |
| 1139 | __entry->fhandle = nfs_fhandle_hash(fhandle); | 1139 | __entry->fhandle = nfs_fhandle_hash(fhandle); |
| 1140 | if (inode != NULL) { | 1140 | if (!IS_ERR_OR_NULL(inode)) { |
| 1141 | __entry->fileid = NFS_FILEID(inode); | 1141 | __entry->fileid = NFS_FILEID(inode); |
| 1142 | __entry->dev = inode->i_sb->s_dev; | 1142 | __entry->dev = inode->i_sb->s_dev; |
| 1143 | } else { | 1143 | } else { |
| @@ -1194,7 +1194,7 @@ DECLARE_EVENT_CLASS(nfs4_inode_stateid_callback_event, | |||
| 1194 | TP_fast_assign( | 1194 | TP_fast_assign( |
| 1195 | __entry->error = error; | 1195 | __entry->error = error; |
| 1196 | __entry->fhandle = nfs_fhandle_hash(fhandle); | 1196 | __entry->fhandle = nfs_fhandle_hash(fhandle); |
| 1197 | if (inode != NULL) { | 1197 | if (!IS_ERR_OR_NULL(inode)) { |
| 1198 | __entry->fileid = NFS_FILEID(inode); | 1198 | __entry->fileid = NFS_FILEID(inode); |
| 1199 | __entry->dev = inode->i_sb->s_dev; | 1199 | __entry->dev = inode->i_sb->s_dev; |
| 1200 | } else { | 1200 | } else { |
diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index e8f232de484f..7d9a51e6b847 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c | |||
| @@ -1740,16 +1740,16 @@ static bool pnfs_within_mdsthreshold(struct nfs_open_context *ctx, | |||
| 1740 | return ret; | 1740 | return ret; |
| 1741 | } | 1741 | } |
| 1742 | 1742 | ||
| 1743 | static bool pnfs_prepare_to_retry_layoutget(struct pnfs_layout_hdr *lo) | 1743 | static int pnfs_prepare_to_retry_layoutget(struct pnfs_layout_hdr *lo) |
| 1744 | { | 1744 | { |
| 1745 | /* | 1745 | /* |
| 1746 | * send layoutcommit as it can hold up layoutreturn due to lseg | 1746 | * send layoutcommit as it can hold up layoutreturn due to lseg |
| 1747 | * reference | 1747 | * reference |
| 1748 | */ | 1748 | */ |
| 1749 | pnfs_layoutcommit_inode(lo->plh_inode, false); | 1749 | pnfs_layoutcommit_inode(lo->plh_inode, false); |
| 1750 | return !wait_on_bit_action(&lo->plh_flags, NFS_LAYOUT_RETURN, | 1750 | return wait_on_bit_action(&lo->plh_flags, NFS_LAYOUT_RETURN, |
| 1751 | nfs_wait_bit_killable, | 1751 | nfs_wait_bit_killable, |
| 1752 | TASK_UNINTERRUPTIBLE); | 1752 | TASK_KILLABLE); |
| 1753 | } | 1753 | } |
| 1754 | 1754 | ||
| 1755 | static void nfs_layoutget_begin(struct pnfs_layout_hdr *lo) | 1755 | static void nfs_layoutget_begin(struct pnfs_layout_hdr *lo) |
| @@ -1830,7 +1830,9 @@ pnfs_update_layout(struct inode *ino, | |||
| 1830 | } | 1830 | } |
| 1831 | 1831 | ||
| 1832 | lookup_again: | 1832 | lookup_again: |
| 1833 | nfs4_client_recover_expired_lease(clp); | 1833 | lseg = ERR_PTR(nfs4_client_recover_expired_lease(clp)); |
| 1834 | if (IS_ERR(lseg)) | ||
| 1835 | goto out; | ||
| 1834 | first = false; | 1836 | first = false; |
| 1835 | spin_lock(&ino->i_lock); | 1837 | spin_lock(&ino->i_lock); |
| 1836 | lo = pnfs_find_alloc_layout(ino, ctx, gfp_flags); | 1838 | lo = pnfs_find_alloc_layout(ino, ctx, gfp_flags); |
| @@ -1863,9 +1865,9 @@ lookup_again: | |||
| 1863 | if (list_empty(&lo->plh_segs) && | 1865 | if (list_empty(&lo->plh_segs) && |
| 1864 | atomic_read(&lo->plh_outstanding) != 0) { | 1866 | atomic_read(&lo->plh_outstanding) != 0) { |
| 1865 | spin_unlock(&ino->i_lock); | 1867 | spin_unlock(&ino->i_lock); |
| 1866 | if (wait_var_event_killable(&lo->plh_outstanding, | 1868 | lseg = ERR_PTR(wait_var_event_killable(&lo->plh_outstanding, |
| 1867 | atomic_read(&lo->plh_outstanding) == 0 | 1869 | atomic_read(&lo->plh_outstanding))); |
| 1868 | || !list_empty(&lo->plh_segs))) | 1870 | if (IS_ERR(lseg) || !list_empty(&lo->plh_segs)) |
| 1869 | goto out_put_layout_hdr; | 1871 | goto out_put_layout_hdr; |
| 1870 | pnfs_put_layout_hdr(lo); | 1872 | pnfs_put_layout_hdr(lo); |
| 1871 | goto lookup_again; | 1873 | goto lookup_again; |
| @@ -1898,8 +1900,11 @@ lookup_again: | |||
| 1898 | if (test_and_set_bit(NFS_LAYOUT_FIRST_LAYOUTGET, | 1900 | if (test_and_set_bit(NFS_LAYOUT_FIRST_LAYOUTGET, |
| 1899 | &lo->plh_flags)) { | 1901 | &lo->plh_flags)) { |
| 1900 | spin_unlock(&ino->i_lock); | 1902 | spin_unlock(&ino->i_lock); |
| 1901 | wait_on_bit(&lo->plh_flags, NFS_LAYOUT_FIRST_LAYOUTGET, | 1903 | lseg = ERR_PTR(wait_on_bit(&lo->plh_flags, |
| 1902 | TASK_UNINTERRUPTIBLE); | 1904 | NFS_LAYOUT_FIRST_LAYOUTGET, |
| 1905 | TASK_KILLABLE)); | ||
| 1906 | if (IS_ERR(lseg)) | ||
| 1907 | goto out_put_layout_hdr; | ||
| 1903 | pnfs_put_layout_hdr(lo); | 1908 | pnfs_put_layout_hdr(lo); |
| 1904 | dprintk("%s retrying\n", __func__); | 1909 | dprintk("%s retrying\n", __func__); |
| 1905 | goto lookup_again; | 1910 | goto lookup_again; |
| @@ -1925,7 +1930,8 @@ lookup_again: | |||
| 1925 | if (test_bit(NFS_LAYOUT_RETURN, &lo->plh_flags)) { | 1930 | if (test_bit(NFS_LAYOUT_RETURN, &lo->plh_flags)) { |
| 1926 | spin_unlock(&ino->i_lock); | 1931 | spin_unlock(&ino->i_lock); |
| 1927 | dprintk("%s wait for layoutreturn\n", __func__); | 1932 | dprintk("%s wait for layoutreturn\n", __func__); |
| 1928 | if (pnfs_prepare_to_retry_layoutget(lo)) { | 1933 | lseg = ERR_PTR(pnfs_prepare_to_retry_layoutget(lo)); |
| 1934 | if (!IS_ERR(lseg)) { | ||
| 1929 | if (first) | 1935 | if (first) |
| 1930 | pnfs_clear_first_layoutget(lo); | 1936 | pnfs_clear_first_layoutget(lo); |
| 1931 | pnfs_put_layout_hdr(lo); | 1937 | pnfs_put_layout_hdr(lo); |
diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c index 32e9282893c9..aeaefd2a551b 100644 --- a/fs/overlayfs/file.c +++ b/fs/overlayfs/file.c | |||
| @@ -131,9 +131,6 @@ static int ovl_open(struct inode *inode, struct file *file) | |||
| 131 | if (IS_ERR(realfile)) | 131 | if (IS_ERR(realfile)) |
| 132 | return PTR_ERR(realfile); | 132 | return PTR_ERR(realfile); |
| 133 | 133 | ||
| 134 | /* For O_DIRECT dentry_open() checks f_mapping->a_ops->direct_IO */ | ||
| 135 | file->f_mapping = realfile->f_mapping; | ||
| 136 | |||
| 137 | file->private_data = realfile; | 134 | file->private_data = realfile; |
| 138 | 135 | ||
| 139 | return 0; | 136 | return 0; |
| @@ -334,6 +331,25 @@ static long ovl_fallocate(struct file *file, int mode, loff_t offset, loff_t len | |||
| 334 | return ret; | 331 | return ret; |
| 335 | } | 332 | } |
| 336 | 333 | ||
| 334 | static int ovl_fadvise(struct file *file, loff_t offset, loff_t len, int advice) | ||
| 335 | { | ||
| 336 | struct fd real; | ||
| 337 | const struct cred *old_cred; | ||
| 338 | int ret; | ||
| 339 | |||
| 340 | ret = ovl_real_fdget(file, &real); | ||
| 341 | if (ret) | ||
| 342 | return ret; | ||
| 343 | |||
| 344 | old_cred = ovl_override_creds(file_inode(file)->i_sb); | ||
| 345 | ret = vfs_fadvise(real.file, offset, len, advice); | ||
| 346 | revert_creds(old_cred); | ||
| 347 | |||
| 348 | fdput(real); | ||
| 349 | |||
| 350 | return ret; | ||
| 351 | } | ||
| 352 | |||
| 337 | static long ovl_real_ioctl(struct file *file, unsigned int cmd, | 353 | static long ovl_real_ioctl(struct file *file, unsigned int cmd, |
| 338 | unsigned long arg) | 354 | unsigned long arg) |
| 339 | { | 355 | { |
| @@ -502,6 +518,7 @@ const struct file_operations ovl_file_operations = { | |||
| 502 | .fsync = ovl_fsync, | 518 | .fsync = ovl_fsync, |
| 503 | .mmap = ovl_mmap, | 519 | .mmap = ovl_mmap, |
| 504 | .fallocate = ovl_fallocate, | 520 | .fallocate = ovl_fallocate, |
| 521 | .fadvise = ovl_fadvise, | ||
| 505 | .unlocked_ioctl = ovl_ioctl, | 522 | .unlocked_ioctl = ovl_ioctl, |
| 506 | .compat_ioctl = ovl_compat_ioctl, | 523 | .compat_ioctl = ovl_compat_ioctl, |
| 507 | 524 | ||
diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c index e0bb217c01e2..b6ac545b5a32 100644 --- a/fs/overlayfs/inode.c +++ b/fs/overlayfs/inode.c | |||
| @@ -467,6 +467,10 @@ static int ovl_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, | |||
| 467 | return -EOPNOTSUPP; | 467 | return -EOPNOTSUPP; |
| 468 | 468 | ||
| 469 | old_cred = ovl_override_creds(inode->i_sb); | 469 | old_cred = ovl_override_creds(inode->i_sb); |
| 470 | |||
| 471 | if (fieinfo->fi_flags & FIEMAP_FLAG_SYNC) | ||
| 472 | filemap_write_and_wait(realinode->i_mapping); | ||
| 473 | |||
| 470 | err = realinode->i_op->fiemap(realinode, fieinfo, start, len); | 474 | err = realinode->i_op->fiemap(realinode, fieinfo, start, len); |
| 471 | revert_creds(old_cred); | 475 | revert_creds(old_cred); |
| 472 | 476 | ||
| @@ -500,6 +504,11 @@ static const struct inode_operations ovl_special_inode_operations = { | |||
| 500 | .update_time = ovl_update_time, | 504 | .update_time = ovl_update_time, |
| 501 | }; | 505 | }; |
| 502 | 506 | ||
| 507 | const struct address_space_operations ovl_aops = { | ||
| 508 | /* For O_DIRECT dentry_open() checks f_mapping->a_ops->direct_IO */ | ||
| 509 | .direct_IO = noop_direct_IO, | ||
| 510 | }; | ||
| 511 | |||
| 503 | /* | 512 | /* |
| 504 | * It is possible to stack overlayfs instance on top of another | 513 | * It is possible to stack overlayfs instance on top of another |
| 505 | * overlayfs instance as lower layer. We need to annonate the | 514 | * overlayfs instance as lower layer. We need to annonate the |
| @@ -571,6 +580,7 @@ static void ovl_fill_inode(struct inode *inode, umode_t mode, dev_t rdev, | |||
| 571 | case S_IFREG: | 580 | case S_IFREG: |
| 572 | inode->i_op = &ovl_file_inode_operations; | 581 | inode->i_op = &ovl_file_inode_operations; |
| 573 | inode->i_fop = &ovl_file_operations; | 582 | inode->i_fop = &ovl_file_operations; |
| 583 | inode->i_mapping->a_ops = &ovl_aops; | ||
| 574 | break; | 584 | break; |
| 575 | 585 | ||
| 576 | case S_IFDIR: | 586 | case S_IFDIR: |
diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c index 2e0fc93c2c06..30adc9d408a0 100644 --- a/fs/overlayfs/super.c +++ b/fs/overlayfs/super.c | |||
| @@ -982,16 +982,6 @@ static int ovl_get_upper(struct ovl_fs *ofs, struct path *upperpath) | |||
| 982 | if (err) | 982 | if (err) |
| 983 | goto out; | 983 | goto out; |
| 984 | 984 | ||
| 985 | err = -EBUSY; | ||
| 986 | if (ovl_inuse_trylock(upperpath->dentry)) { | ||
| 987 | ofs->upperdir_locked = true; | ||
| 988 | } else if (ofs->config.index) { | ||
| 989 | pr_err("overlayfs: upperdir is in-use by another mount, mount with '-o index=off' to override exclusive upperdir protection.\n"); | ||
| 990 | goto out; | ||
| 991 | } else { | ||
| 992 | pr_warn("overlayfs: upperdir is in-use by another mount, accessing files from both mounts will result in undefined behavior.\n"); | ||
| 993 | } | ||
| 994 | |||
| 995 | upper_mnt = clone_private_mount(upperpath); | 985 | upper_mnt = clone_private_mount(upperpath); |
| 996 | err = PTR_ERR(upper_mnt); | 986 | err = PTR_ERR(upper_mnt); |
| 997 | if (IS_ERR(upper_mnt)) { | 987 | if (IS_ERR(upper_mnt)) { |
| @@ -1002,6 +992,17 @@ static int ovl_get_upper(struct ovl_fs *ofs, struct path *upperpath) | |||
| 1002 | /* Don't inherit atime flags */ | 992 | /* Don't inherit atime flags */ |
| 1003 | upper_mnt->mnt_flags &= ~(MNT_NOATIME | MNT_NODIRATIME | MNT_RELATIME); | 993 | upper_mnt->mnt_flags &= ~(MNT_NOATIME | MNT_NODIRATIME | MNT_RELATIME); |
| 1004 | ofs->upper_mnt = upper_mnt; | 994 | ofs->upper_mnt = upper_mnt; |
| 995 | |||
| 996 | err = -EBUSY; | ||
| 997 | if (ovl_inuse_trylock(ofs->upper_mnt->mnt_root)) { | ||
| 998 | ofs->upperdir_locked = true; | ||
| 999 | } else if (ofs->config.index) { | ||
| 1000 | pr_err("overlayfs: upperdir is in-use by another mount, mount with '-o index=off' to override exclusive upperdir protection.\n"); | ||
| 1001 | goto out; | ||
| 1002 | } else { | ||
| 1003 | pr_warn("overlayfs: upperdir is in-use by another mount, accessing files from both mounts will result in undefined behavior.\n"); | ||
| 1004 | } | ||
| 1005 | |||
| 1005 | err = 0; | 1006 | err = 0; |
| 1006 | out: | 1007 | out: |
| 1007 | return err; | 1008 | return err; |
| @@ -1101,8 +1102,10 @@ static int ovl_get_workdir(struct ovl_fs *ofs, struct path *upperpath) | |||
| 1101 | goto out; | 1102 | goto out; |
| 1102 | } | 1103 | } |
| 1103 | 1104 | ||
| 1105 | ofs->workbasedir = dget(workpath.dentry); | ||
| 1106 | |||
| 1104 | err = -EBUSY; | 1107 | err = -EBUSY; |
| 1105 | if (ovl_inuse_trylock(workpath.dentry)) { | 1108 | if (ovl_inuse_trylock(ofs->workbasedir)) { |
| 1106 | ofs->workdir_locked = true; | 1109 | ofs->workdir_locked = true; |
| 1107 | } else if (ofs->config.index) { | 1110 | } else if (ofs->config.index) { |
| 1108 | pr_err("overlayfs: workdir is in-use by another mount, mount with '-o index=off' to override exclusive workdir protection.\n"); | 1111 | pr_err("overlayfs: workdir is in-use by another mount, mount with '-o index=off' to override exclusive workdir protection.\n"); |
| @@ -1111,7 +1114,6 @@ static int ovl_get_workdir(struct ovl_fs *ofs, struct path *upperpath) | |||
| 1111 | pr_warn("overlayfs: workdir is in-use by another mount, accessing files from both mounts will result in undefined behavior.\n"); | 1114 | pr_warn("overlayfs: workdir is in-use by another mount, accessing files from both mounts will result in undefined behavior.\n"); |
| 1112 | } | 1115 | } |
| 1113 | 1116 | ||
| 1114 | ofs->workbasedir = dget(workpath.dentry); | ||
| 1115 | err = ovl_make_workdir(ofs, &workpath); | 1117 | err = ovl_make_workdir(ofs, &workpath); |
| 1116 | if (err) | 1118 | if (err) |
| 1117 | goto out; | 1119 | goto out; |
diff --git a/fs/pstore/ram_core.c b/fs/pstore/ram_core.c index 951a14edcf51..0792595ebcfb 100644 --- a/fs/pstore/ram_core.c +++ b/fs/pstore/ram_core.c | |||
| @@ -429,7 +429,12 @@ static void *persistent_ram_vmap(phys_addr_t start, size_t size, | |||
| 429 | vaddr = vmap(pages, page_count, VM_MAP, prot); | 429 | vaddr = vmap(pages, page_count, VM_MAP, prot); |
| 430 | kfree(pages); | 430 | kfree(pages); |
| 431 | 431 | ||
| 432 | return vaddr; | 432 | /* |
| 433 | * Since vmap() uses page granularity, we must add the offset | ||
| 434 | * into the page here, to get the byte granularity address | ||
| 435 | * into the mapping to represent the actual "start" location. | ||
| 436 | */ | ||
| 437 | return vaddr + offset_in_page(start); | ||
| 433 | } | 438 | } |
| 434 | 439 | ||
| 435 | static void *persistent_ram_iomap(phys_addr_t start, size_t size, | 440 | static void *persistent_ram_iomap(phys_addr_t start, size_t size, |
| @@ -448,6 +453,11 @@ static void *persistent_ram_iomap(phys_addr_t start, size_t size, | |||
| 448 | else | 453 | else |
| 449 | va = ioremap_wc(start, size); | 454 | va = ioremap_wc(start, size); |
| 450 | 455 | ||
| 456 | /* | ||
| 457 | * Since request_mem_region() and ioremap() are byte-granularity | ||
| 458 | * there is no need handle anything special like we do when the | ||
| 459 | * vmap() case in persistent_ram_vmap() above. | ||
| 460 | */ | ||
| 451 | return va; | 461 | return va; |
| 452 | } | 462 | } |
| 453 | 463 | ||
| @@ -468,7 +478,7 @@ static int persistent_ram_buffer_map(phys_addr_t start, phys_addr_t size, | |||
| 468 | return -ENOMEM; | 478 | return -ENOMEM; |
| 469 | } | 479 | } |
| 470 | 480 | ||
| 471 | prz->buffer = prz->vaddr + offset_in_page(start); | 481 | prz->buffer = prz->vaddr; |
| 472 | prz->buffer_size = size - sizeof(struct persistent_ram_buffer); | 482 | prz->buffer_size = size - sizeof(struct persistent_ram_buffer); |
| 473 | 483 | ||
| 474 | return 0; | 484 | return 0; |
| @@ -515,7 +525,8 @@ void persistent_ram_free(struct persistent_ram_zone *prz) | |||
| 515 | 525 | ||
| 516 | if (prz->vaddr) { | 526 | if (prz->vaddr) { |
| 517 | if (pfn_valid(prz->paddr >> PAGE_SHIFT)) { | 527 | if (pfn_valid(prz->paddr >> PAGE_SHIFT)) { |
| 518 | vunmap(prz->vaddr); | 528 | /* We must vunmap() at page-granularity. */ |
| 529 | vunmap(prz->vaddr - offset_in_page(prz->paddr)); | ||
| 519 | } else { | 530 | } else { |
| 520 | iounmap(prz->vaddr); | 531 | iounmap(prz->vaddr); |
| 521 | release_mem_region(prz->paddr, prz->size); | 532 | release_mem_region(prz->paddr, prz->size); |
diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h index 66d1d45fa2e1..d356f802945a 100644 --- a/include/asm-generic/io.h +++ b/include/asm-generic/io.h | |||
| @@ -1026,7 +1026,8 @@ static inline void __iomem *ioremap_wt(phys_addr_t offset, size_t size) | |||
| 1026 | #define ioport_map ioport_map | 1026 | #define ioport_map ioport_map |
| 1027 | static inline void __iomem *ioport_map(unsigned long port, unsigned int nr) | 1027 | static inline void __iomem *ioport_map(unsigned long port, unsigned int nr) |
| 1028 | { | 1028 | { |
| 1029 | return PCI_IOBASE + (port & MMIO_UPPER_LIMIT); | 1029 | port &= IO_SPACE_LIMIT; |
| 1030 | return (port > MMIO_UPPER_LIMIT) ? NULL : PCI_IOBASE + port; | ||
| 1030 | } | 1031 | } |
| 1031 | #endif | 1032 | #endif |
| 1032 | 1033 | ||
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index d6869e0e2b64..6980014357d4 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h | |||
| @@ -54,7 +54,7 @@ struct blk_stat_callback; | |||
| 54 | * Maximum number of blkcg policies allowed to be registered concurrently. | 54 | * Maximum number of blkcg policies allowed to be registered concurrently. |
| 55 | * Defined here to simplify include dependency. | 55 | * Defined here to simplify include dependency. |
| 56 | */ | 56 | */ |
| 57 | #define BLKCG_MAX_POLS 3 | 57 | #define BLKCG_MAX_POLS 5 |
| 58 | 58 | ||
| 59 | typedef void (rq_end_io_fn)(struct request *, blk_status_t); | 59 | typedef void (rq_end_io_fn)(struct request *, blk_status_t); |
| 60 | 60 | ||
diff --git a/include/linux/fs.h b/include/linux/fs.h index 33322702c910..6c0b4a1c22ff 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h | |||
| @@ -1763,6 +1763,7 @@ struct file_operations { | |||
| 1763 | u64); | 1763 | u64); |
| 1764 | int (*dedupe_file_range)(struct file *, loff_t, struct file *, loff_t, | 1764 | int (*dedupe_file_range)(struct file *, loff_t, struct file *, loff_t, |
| 1765 | u64); | 1765 | u64); |
| 1766 | int (*fadvise)(struct file *, loff_t, loff_t, int); | ||
| 1766 | } __randomize_layout; | 1767 | } __randomize_layout; |
| 1767 | 1768 | ||
| 1768 | struct inode_operations { | 1769 | struct inode_operations { |
| @@ -3459,4 +3460,8 @@ static inline bool dir_relax_shared(struct inode *inode) | |||
| 3459 | extern bool path_noexec(const struct path *path); | 3460 | extern bool path_noexec(const struct path *path); |
| 3460 | extern void inode_nohighmem(struct inode *inode); | 3461 | extern void inode_nohighmem(struct inode *inode); |
| 3461 | 3462 | ||
| 3463 | /* mm/fadvise.c */ | ||
| 3464 | extern int vfs_fadvise(struct file *file, loff_t offset, loff_t len, | ||
| 3465 | int advice); | ||
| 3466 | |||
| 3462 | #endif /* _LINUX_FS_H */ | 3467 | #endif /* _LINUX_FS_H */ |
diff --git a/include/linux/hid.h b/include/linux/hid.h index 834e6461a690..d44a78362942 100644 --- a/include/linux/hid.h +++ b/include/linux/hid.h | |||
| @@ -526,6 +526,7 @@ struct hid_input { | |||
| 526 | const char *name; | 526 | const char *name; |
| 527 | bool registered; | 527 | bool registered; |
| 528 | struct list_head reports; /* the list of reports */ | 528 | struct list_head reports; /* the list of reports */ |
| 529 | unsigned int application; /* application usage for this input */ | ||
| 529 | }; | 530 | }; |
| 530 | 531 | ||
| 531 | enum hid_type { | 532 | enum hid_type { |
diff --git a/include/linux/mlx5/driver.h b/include/linux/mlx5/driver.h index 7a452716de4b..66d94b4557cf 100644 --- a/include/linux/mlx5/driver.h +++ b/include/linux/mlx5/driver.h | |||
| @@ -362,8 +362,8 @@ struct mlx5_frag_buf { | |||
| 362 | struct mlx5_frag_buf_ctrl { | 362 | struct mlx5_frag_buf_ctrl { |
| 363 | struct mlx5_frag_buf frag_buf; | 363 | struct mlx5_frag_buf frag_buf; |
| 364 | u32 sz_m1; | 364 | u32 sz_m1; |
| 365 | u32 frag_sz_m1; | 365 | u16 frag_sz_m1; |
| 366 | u32 strides_offset; | 366 | u16 strides_offset; |
| 367 | u8 log_sz; | 367 | u8 log_sz; |
| 368 | u8 log_stride; | 368 | u8 log_stride; |
| 369 | u8 log_frag_strides; | 369 | u8 log_frag_strides; |
| @@ -995,7 +995,7 @@ static inline u32 mlx5_base_mkey(const u32 key) | |||
| 995 | } | 995 | } |
| 996 | 996 | ||
| 997 | static inline void mlx5_fill_fbc_offset(u8 log_stride, u8 log_sz, | 997 | static inline void mlx5_fill_fbc_offset(u8 log_stride, u8 log_sz, |
| 998 | u32 strides_offset, | 998 | u16 strides_offset, |
| 999 | struct mlx5_frag_buf_ctrl *fbc) | 999 | struct mlx5_frag_buf_ctrl *fbc) |
| 1000 | { | 1000 | { |
| 1001 | fbc->log_stride = log_stride; | 1001 | fbc->log_stride = log_stride; |
| @@ -1052,7 +1052,7 @@ int mlx5_cmd_free_uar(struct mlx5_core_dev *dev, u32 uarn); | |||
| 1052 | void mlx5_health_cleanup(struct mlx5_core_dev *dev); | 1052 | void mlx5_health_cleanup(struct mlx5_core_dev *dev); |
| 1053 | int mlx5_health_init(struct mlx5_core_dev *dev); | 1053 | int mlx5_health_init(struct mlx5_core_dev *dev); |
| 1054 | void mlx5_start_health_poll(struct mlx5_core_dev *dev); | 1054 | void mlx5_start_health_poll(struct mlx5_core_dev *dev); |
| 1055 | void mlx5_stop_health_poll(struct mlx5_core_dev *dev); | 1055 | void mlx5_stop_health_poll(struct mlx5_core_dev *dev, bool disable_health); |
| 1056 | void mlx5_drain_health_wq(struct mlx5_core_dev *dev); | 1056 | void mlx5_drain_health_wq(struct mlx5_core_dev *dev); |
| 1057 | void mlx5_trigger_health_work(struct mlx5_core_dev *dev); | 1057 | void mlx5_trigger_health_work(struct mlx5_core_dev *dev); |
| 1058 | void mlx5_drain_health_recovery(struct mlx5_core_dev *dev); | 1058 | void mlx5_drain_health_recovery(struct mlx5_core_dev *dev); |
diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h index cd2bc939efd0..5ed8f6292a53 100644 --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h | |||
| @@ -341,7 +341,7 @@ struct mm_struct { | |||
| 341 | struct { | 341 | struct { |
| 342 | struct vm_area_struct *mmap; /* list of VMAs */ | 342 | struct vm_area_struct *mmap; /* list of VMAs */ |
| 343 | struct rb_root mm_rb; | 343 | struct rb_root mm_rb; |
| 344 | u32 vmacache_seqnum; /* per-thread vmacache */ | 344 | u64 vmacache_seqnum; /* per-thread vmacache */ |
| 345 | #ifdef CONFIG_MMU | 345 | #ifdef CONFIG_MMU |
| 346 | unsigned long (*get_unmapped_area) (struct file *filp, | 346 | unsigned long (*get_unmapped_area) (struct file *filp, |
| 347 | unsigned long addr, unsigned long len, | 347 | unsigned long addr, unsigned long len, |
diff --git a/include/linux/mm_types_task.h b/include/linux/mm_types_task.h index 5fe87687664c..d7016dcb245e 100644 --- a/include/linux/mm_types_task.h +++ b/include/linux/mm_types_task.h | |||
| @@ -32,7 +32,7 @@ | |||
| 32 | #define VMACACHE_MASK (VMACACHE_SIZE - 1) | 32 | #define VMACACHE_MASK (VMACACHE_SIZE - 1) |
| 33 | 33 | ||
| 34 | struct vmacache { | 34 | struct vmacache { |
| 35 | u32 seqnum; | 35 | u64 seqnum; |
| 36 | struct vm_area_struct *vmas[VMACACHE_SIZE]; | 36 | struct vm_area_struct *vmas[VMACACHE_SIZE]; |
| 37 | }; | 37 | }; |
| 38 | 38 | ||
diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h index 1298a7daa57d..01797cb4587e 100644 --- a/include/linux/mod_devicetable.h +++ b/include/linux/mod_devicetable.h | |||
| @@ -754,6 +754,7 @@ struct tb_service_id { | |||
| 754 | * struct typec_device_id - USB Type-C alternate mode identifiers | 754 | * struct typec_device_id - USB Type-C alternate mode identifiers |
| 755 | * @svid: Standard or Vendor ID | 755 | * @svid: Standard or Vendor ID |
| 756 | * @mode: Mode index | 756 | * @mode: Mode index |
| 757 | * @driver_data: Driver specific data | ||
| 757 | */ | 758 | */ |
| 758 | struct typec_device_id { | 759 | struct typec_device_id { |
| 759 | __u16 svid; | 760 | __u16 svid; |
diff --git a/include/linux/pci.h b/include/linux/pci.h index e72ca8dd6241..6925828f9f25 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h | |||
| @@ -1235,6 +1235,9 @@ void pci_bus_remove_resources(struct pci_bus *bus); | |||
| 1235 | int devm_request_pci_bus_resources(struct device *dev, | 1235 | int devm_request_pci_bus_resources(struct device *dev, |
| 1236 | struct list_head *resources); | 1236 | struct list_head *resources); |
| 1237 | 1237 | ||
| 1238 | /* Temporary until new and working PCI SBR API in place */ | ||
| 1239 | int pci_bridge_secondary_bus_reset(struct pci_dev *dev); | ||
| 1240 | |||
| 1238 | #define pci_bus_for_each_resource(bus, res, i) \ | 1241 | #define pci_bus_for_each_resource(bus, res, i) \ |
| 1239 | for (i = 0; \ | 1242 | for (i = 0; \ |
| 1240 | (res = pci_bus_resource_n(bus, i)) || i < PCI_BRIDGE_RESOURCE_NUM; \ | 1243 | (res = pci_bus_resource_n(bus, i)) || i < PCI_BRIDGE_RESOURCE_NUM; \ |
diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h index 5d738804e3d6..a5a3cfc3c2fa 100644 --- a/include/linux/timekeeping.h +++ b/include/linux/timekeeping.h | |||
| @@ -258,8 +258,8 @@ extern void ktime_get_snapshot(struct system_time_snapshot *systime_snapshot); | |||
| 258 | extern int persistent_clock_is_local; | 258 | extern int persistent_clock_is_local; |
| 259 | 259 | ||
| 260 | extern void read_persistent_clock64(struct timespec64 *ts); | 260 | extern void read_persistent_clock64(struct timespec64 *ts); |
| 261 | void read_persistent_clock_and_boot_offset(struct timespec64 *wall_clock, | 261 | void read_persistent_wall_and_boot_offset(struct timespec64 *wall_clock, |
| 262 | struct timespec64 *boot_offset); | 262 | struct timespec64 *boot_offset); |
| 263 | extern int update_persistent_clock64(struct timespec64 now); | 263 | extern int update_persistent_clock64(struct timespec64 now); |
| 264 | 264 | ||
| 265 | /* | 265 | /* |
diff --git a/include/linux/vm_event_item.h b/include/linux/vm_event_item.h index 5c7f010676a7..47a3441cf4c4 100644 --- a/include/linux/vm_event_item.h +++ b/include/linux/vm_event_item.h | |||
| @@ -105,7 +105,6 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT, | |||
| 105 | #ifdef CONFIG_DEBUG_VM_VMACACHE | 105 | #ifdef CONFIG_DEBUG_VM_VMACACHE |
| 106 | VMACACHE_FIND_CALLS, | 106 | VMACACHE_FIND_CALLS, |
| 107 | VMACACHE_FIND_HITS, | 107 | VMACACHE_FIND_HITS, |
| 108 | VMACACHE_FULL_FLUSHES, | ||
| 109 | #endif | 108 | #endif |
| 110 | #ifdef CONFIG_SWAP | 109 | #ifdef CONFIG_SWAP |
| 111 | SWAP_RA, | 110 | SWAP_RA, |
diff --git a/include/linux/vmacache.h b/include/linux/vmacache.h index 3e9a963edd6a..6fce268a4588 100644 --- a/include/linux/vmacache.h +++ b/include/linux/vmacache.h | |||
| @@ -10,7 +10,6 @@ static inline void vmacache_flush(struct task_struct *tsk) | |||
| 10 | memset(tsk->vmacache.vmas, 0, sizeof(tsk->vmacache.vmas)); | 10 | memset(tsk->vmacache.vmas, 0, sizeof(tsk->vmacache.vmas)); |
| 11 | } | 11 | } |
| 12 | 12 | ||
| 13 | extern void vmacache_flush_all(struct mm_struct *mm); | ||
| 14 | extern void vmacache_update(unsigned long addr, struct vm_area_struct *newvma); | 13 | extern void vmacache_update(unsigned long addr, struct vm_area_struct *newvma); |
| 15 | extern struct vm_area_struct *vmacache_find(struct mm_struct *mm, | 14 | extern struct vm_area_struct *vmacache_find(struct mm_struct *mm, |
| 16 | unsigned long addr); | 15 | unsigned long addr); |
| @@ -24,10 +23,6 @@ extern struct vm_area_struct *vmacache_find_exact(struct mm_struct *mm, | |||
| 24 | static inline void vmacache_invalidate(struct mm_struct *mm) | 23 | static inline void vmacache_invalidate(struct mm_struct *mm) |
| 25 | { | 24 | { |
| 26 | mm->vmacache_seqnum++; | 25 | mm->vmacache_seqnum++; |
| 27 | |||
| 28 | /* deal with overflows */ | ||
| 29 | if (unlikely(mm->vmacache_seqnum == 0)) | ||
| 30 | vmacache_flush_all(mm); | ||
| 31 | } | 26 | } |
| 32 | 27 | ||
| 33 | #endif /* __LINUX_VMACACHE_H */ | 28 | #endif /* __LINUX_VMACACHE_H */ |
diff --git a/include/net/netfilter/nf_conntrack_timeout.h b/include/net/netfilter/nf_conntrack_timeout.h index d5f62cc6c2ae..3394d75e1c80 100644 --- a/include/net/netfilter/nf_conntrack_timeout.h +++ b/include/net/netfilter/nf_conntrack_timeout.h | |||
| @@ -30,7 +30,7 @@ struct nf_conn_timeout { | |||
| 30 | }; | 30 | }; |
| 31 | 31 | ||
| 32 | static inline unsigned int * | 32 | static inline unsigned int * |
| 33 | nf_ct_timeout_data(struct nf_conn_timeout *t) | 33 | nf_ct_timeout_data(const struct nf_conn_timeout *t) |
| 34 | { | 34 | { |
| 35 | struct nf_ct_timeout *timeout; | 35 | struct nf_ct_timeout *timeout; |
| 36 | 36 | ||
diff --git a/include/xen/mem-reservation.h b/include/xen/mem-reservation.h index 80b52b4945e9..a2ab516fcd2c 100644 --- a/include/xen/mem-reservation.h +++ b/include/xen/mem-reservation.h | |||
| @@ -17,11 +17,12 @@ | |||
| 17 | 17 | ||
| 18 | #include <xen/page.h> | 18 | #include <xen/page.h> |
| 19 | 19 | ||
| 20 | extern bool xen_scrub_pages; | ||
| 21 | |||
| 20 | static inline void xenmem_reservation_scrub_page(struct page *page) | 22 | static inline void xenmem_reservation_scrub_page(struct page *page) |
| 21 | { | 23 | { |
| 22 | #ifdef CONFIG_XEN_SCRUB_PAGES | 24 | if (xen_scrub_pages) |
| 23 | clear_highpage(page); | 25 | clear_highpage(page); |
| 24 | #endif | ||
| 25 | } | 26 | } |
| 26 | 27 | ||
| 27 | #ifdef CONFIG_XEN_HAVE_PVMMU | 28 | #ifdef CONFIG_XEN_HAVE_PVMMU |
diff --git a/kernel/cpu.c b/kernel/cpu.c index aa7fe85ad62e..0097acec1c71 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c | |||
| @@ -607,15 +607,15 @@ static void cpuhp_thread_fun(unsigned int cpu) | |||
| 607 | bool bringup = st->bringup; | 607 | bool bringup = st->bringup; |
| 608 | enum cpuhp_state state; | 608 | enum cpuhp_state state; |
| 609 | 609 | ||
| 610 | if (WARN_ON_ONCE(!st->should_run)) | ||
| 611 | return; | ||
| 612 | |||
| 610 | /* | 613 | /* |
| 611 | * ACQUIRE for the cpuhp_should_run() load of ->should_run. Ensures | 614 | * ACQUIRE for the cpuhp_should_run() load of ->should_run. Ensures |
| 612 | * that if we see ->should_run we also see the rest of the state. | 615 | * that if we see ->should_run we also see the rest of the state. |
| 613 | */ | 616 | */ |
| 614 | smp_mb(); | 617 | smp_mb(); |
| 615 | 618 | ||
| 616 | if (WARN_ON_ONCE(!st->should_run)) | ||
| 617 | return; | ||
| 618 | |||
| 619 | cpuhp_lock_acquire(bringup); | 619 | cpuhp_lock_acquire(bringup); |
| 620 | 620 | ||
| 621 | if (st->single) { | 621 | if (st->single) { |
| @@ -916,7 +916,8 @@ static int cpuhp_down_callbacks(unsigned int cpu, struct cpuhp_cpu_state *st, | |||
| 916 | ret = cpuhp_invoke_callback(cpu, st->state, false, NULL, NULL); | 916 | ret = cpuhp_invoke_callback(cpu, st->state, false, NULL, NULL); |
| 917 | if (ret) { | 917 | if (ret) { |
| 918 | st->target = prev_state; | 918 | st->target = prev_state; |
| 919 | undo_cpu_down(cpu, st); | 919 | if (st->state < prev_state) |
| 920 | undo_cpu_down(cpu, st); | ||
| 920 | break; | 921 | break; |
| 921 | } | 922 | } |
| 922 | } | 923 | } |
| @@ -969,7 +970,7 @@ static int __ref _cpu_down(unsigned int cpu, int tasks_frozen, | |||
| 969 | * to do the further cleanups. | 970 | * to do the further cleanups. |
| 970 | */ | 971 | */ |
| 971 | ret = cpuhp_down_callbacks(cpu, st, target); | 972 | ret = cpuhp_down_callbacks(cpu, st, target); |
| 972 | if (ret && st->state > CPUHP_TEARDOWN_CPU && st->state < prev_state) { | 973 | if (ret && st->state == CPUHP_TEARDOWN_CPU && st->state < prev_state) { |
| 973 | cpuhp_reset_state(st, prev_state); | 974 | cpuhp_reset_state(st, prev_state); |
| 974 | __cpuhp_kick_ap(st); | 975 | __cpuhp_kick_ap(st); |
| 975 | } | 976 | } |
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index fd6f8ed28e01..9bf5404397e0 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c | |||
| @@ -351,7 +351,6 @@ static int console_msg_format = MSG_FORMAT_DEFAULT; | |||
| 351 | */ | 351 | */ |
| 352 | 352 | ||
| 353 | enum log_flags { | 353 | enum log_flags { |
| 354 | LOG_NOCONS = 1, /* suppress print, do not print to console */ | ||
| 355 | LOG_NEWLINE = 2, /* text ended with a newline */ | 354 | LOG_NEWLINE = 2, /* text ended with a newline */ |
| 356 | LOG_PREFIX = 4, /* text started with a prefix */ | 355 | LOG_PREFIX = 4, /* text started with a prefix */ |
| 357 | LOG_CONT = 8, /* text is a fragment of a continuation line */ | 356 | LOG_CONT = 8, /* text is a fragment of a continuation line */ |
| @@ -1881,9 +1880,6 @@ int vprintk_store(int facility, int level, | |||
| 1881 | if (dict) | 1880 | if (dict) |
| 1882 | lflags |= LOG_PREFIX|LOG_NEWLINE; | 1881 | lflags |= LOG_PREFIX|LOG_NEWLINE; |
| 1883 | 1882 | ||
| 1884 | if (suppress_message_printing(level)) | ||
| 1885 | lflags |= LOG_NOCONS; | ||
| 1886 | |||
| 1887 | return log_output(facility, level, lflags, | 1883 | return log_output(facility, level, lflags, |
| 1888 | dict, dictlen, text, text_len); | 1884 | dict, dictlen, text, text_len); |
| 1889 | } | 1885 | } |
| @@ -2032,6 +2028,7 @@ static void call_console_drivers(const char *ext_text, size_t ext_len, | |||
| 2032 | const char *text, size_t len) {} | 2028 | const char *text, size_t len) {} |
| 2033 | static size_t msg_print_text(const struct printk_log *msg, | 2029 | static size_t msg_print_text(const struct printk_log *msg, |
| 2034 | bool syslog, char *buf, size_t size) { return 0; } | 2030 | bool syslog, char *buf, size_t size) { return 0; } |
| 2031 | static bool suppress_message_printing(int level) { return false; } | ||
| 2035 | 2032 | ||
| 2036 | #endif /* CONFIG_PRINTK */ | 2033 | #endif /* CONFIG_PRINTK */ |
| 2037 | 2034 | ||
| @@ -2368,10 +2365,11 @@ skip: | |||
| 2368 | break; | 2365 | break; |
| 2369 | 2366 | ||
| 2370 | msg = log_from_idx(console_idx); | 2367 | msg = log_from_idx(console_idx); |
| 2371 | if (msg->flags & LOG_NOCONS) { | 2368 | if (suppress_message_printing(msg->level)) { |
| 2372 | /* | 2369 | /* |
| 2373 | * Skip record if !ignore_loglevel, and | 2370 | * Skip record we have buffered and already printed |
| 2374 | * record has level above the console loglevel. | 2371 | * directly to the console when we received it, and |
| 2372 | * record that has level above the console loglevel. | ||
| 2375 | */ | 2373 | */ |
| 2376 | console_idx = log_next(console_idx); | 2374 | console_idx = log_next(console_idx); |
| 2377 | console_seq++; | 2375 | console_seq++; |
diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c index f74fb00d8064..0e6e97a01942 100644 --- a/kernel/time/clocksource.c +++ b/kernel/time/clocksource.c | |||
| @@ -133,19 +133,40 @@ static void inline clocksource_watchdog_unlock(unsigned long *flags) | |||
| 133 | spin_unlock_irqrestore(&watchdog_lock, *flags); | 133 | spin_unlock_irqrestore(&watchdog_lock, *flags); |
| 134 | } | 134 | } |
| 135 | 135 | ||
| 136 | static int clocksource_watchdog_kthread(void *data); | ||
| 137 | static void __clocksource_change_rating(struct clocksource *cs, int rating); | ||
| 138 | |||
| 136 | /* | 139 | /* |
| 137 | * Interval: 0.5sec Threshold: 0.0625s | 140 | * Interval: 0.5sec Threshold: 0.0625s |
| 138 | */ | 141 | */ |
| 139 | #define WATCHDOG_INTERVAL (HZ >> 1) | 142 | #define WATCHDOG_INTERVAL (HZ >> 1) |
| 140 | #define WATCHDOG_THRESHOLD (NSEC_PER_SEC >> 4) | 143 | #define WATCHDOG_THRESHOLD (NSEC_PER_SEC >> 4) |
| 141 | 144 | ||
| 145 | static void clocksource_watchdog_work(struct work_struct *work) | ||
| 146 | { | ||
| 147 | /* | ||
| 148 | * We cannot directly run clocksource_watchdog_kthread() here, because | ||
| 149 | * clocksource_select() calls timekeeping_notify() which uses | ||
| 150 | * stop_machine(). One cannot use stop_machine() from a workqueue() due | ||
| 151 | * lock inversions wrt CPU hotplug. | ||
| 152 | * | ||
| 153 | * Also, we only ever run this work once or twice during the lifetime | ||
| 154 | * of the kernel, so there is no point in creating a more permanent | ||
| 155 | * kthread for this. | ||
| 156 | * | ||
| 157 | * If kthread_run fails the next watchdog scan over the | ||
| 158 | * watchdog_list will find the unstable clock again. | ||
| 159 | */ | ||
| 160 | kthread_run(clocksource_watchdog_kthread, NULL, "kwatchdog"); | ||
| 161 | } | ||
| 162 | |||
| 142 | static void __clocksource_unstable(struct clocksource *cs) | 163 | static void __clocksource_unstable(struct clocksource *cs) |
| 143 | { | 164 | { |
| 144 | cs->flags &= ~(CLOCK_SOURCE_VALID_FOR_HRES | CLOCK_SOURCE_WATCHDOG); | 165 | cs->flags &= ~(CLOCK_SOURCE_VALID_FOR_HRES | CLOCK_SOURCE_WATCHDOG); |
| 145 | cs->flags |= CLOCK_SOURCE_UNSTABLE; | 166 | cs->flags |= CLOCK_SOURCE_UNSTABLE; |
| 146 | 167 | ||
| 147 | /* | 168 | /* |
| 148 | * If the clocksource is registered clocksource_watchdog_work() will | 169 | * If the clocksource is registered clocksource_watchdog_kthread() will |
| 149 | * re-rate and re-select. | 170 | * re-rate and re-select. |
| 150 | */ | 171 | */ |
| 151 | if (list_empty(&cs->list)) { | 172 | if (list_empty(&cs->list)) { |
| @@ -156,7 +177,7 @@ static void __clocksource_unstable(struct clocksource *cs) | |||
| 156 | if (cs->mark_unstable) | 177 | if (cs->mark_unstable) |
| 157 | cs->mark_unstable(cs); | 178 | cs->mark_unstable(cs); |
| 158 | 179 | ||
| 159 | /* kick clocksource_watchdog_work() */ | 180 | /* kick clocksource_watchdog_kthread() */ |
| 160 | if (finished_booting) | 181 | if (finished_booting) |
| 161 | schedule_work(&watchdog_work); | 182 | schedule_work(&watchdog_work); |
| 162 | } | 183 | } |
| @@ -166,7 +187,7 @@ static void __clocksource_unstable(struct clocksource *cs) | |||
| 166 | * @cs: clocksource to be marked unstable | 187 | * @cs: clocksource to be marked unstable |
| 167 | * | 188 | * |
| 168 | * This function is called by the x86 TSC code to mark clocksources as unstable; | 189 | * This function is called by the x86 TSC code to mark clocksources as unstable; |
| 169 | * it defers demotion and re-selection to a work. | 190 | * it defers demotion and re-selection to a kthread. |
| 170 | */ | 191 | */ |
| 171 | void clocksource_mark_unstable(struct clocksource *cs) | 192 | void clocksource_mark_unstable(struct clocksource *cs) |
| 172 | { | 193 | { |
| @@ -391,9 +412,7 @@ static void clocksource_dequeue_watchdog(struct clocksource *cs) | |||
| 391 | } | 412 | } |
| 392 | } | 413 | } |
| 393 | 414 | ||
| 394 | static void __clocksource_change_rating(struct clocksource *cs, int rating); | 415 | static int __clocksource_watchdog_kthread(void) |
| 395 | |||
| 396 | static int __clocksource_watchdog_work(void) | ||
| 397 | { | 416 | { |
| 398 | struct clocksource *cs, *tmp; | 417 | struct clocksource *cs, *tmp; |
| 399 | unsigned long flags; | 418 | unsigned long flags; |
| @@ -418,12 +437,13 @@ static int __clocksource_watchdog_work(void) | |||
| 418 | return select; | 437 | return select; |
| 419 | } | 438 | } |
| 420 | 439 | ||
| 421 | static void clocksource_watchdog_work(struct work_struct *work) | 440 | static int clocksource_watchdog_kthread(void *data) |
| 422 | { | 441 | { |
| 423 | mutex_lock(&clocksource_mutex); | 442 | mutex_lock(&clocksource_mutex); |
| 424 | if (__clocksource_watchdog_work()) | 443 | if (__clocksource_watchdog_kthread()) |
| 425 | clocksource_select(); | 444 | clocksource_select(); |
| 426 | mutex_unlock(&clocksource_mutex); | 445 | mutex_unlock(&clocksource_mutex); |
| 446 | return 0; | ||
| 427 | } | 447 | } |
| 428 | 448 | ||
| 429 | static bool clocksource_is_watchdog(struct clocksource *cs) | 449 | static bool clocksource_is_watchdog(struct clocksource *cs) |
| @@ -442,7 +462,7 @@ static void clocksource_enqueue_watchdog(struct clocksource *cs) | |||
| 442 | static void clocksource_select_watchdog(bool fallback) { } | 462 | static void clocksource_select_watchdog(bool fallback) { } |
| 443 | static inline void clocksource_dequeue_watchdog(struct clocksource *cs) { } | 463 | static inline void clocksource_dequeue_watchdog(struct clocksource *cs) { } |
| 444 | static inline void clocksource_resume_watchdog(void) { } | 464 | static inline void clocksource_resume_watchdog(void) { } |
| 445 | static inline int __clocksource_watchdog_work(void) { return 0; } | 465 | static inline int __clocksource_watchdog_kthread(void) { return 0; } |
| 446 | static bool clocksource_is_watchdog(struct clocksource *cs) { return false; } | 466 | static bool clocksource_is_watchdog(struct clocksource *cs) { return false; } |
| 447 | void clocksource_mark_unstable(struct clocksource *cs) { } | 467 | void clocksource_mark_unstable(struct clocksource *cs) { } |
| 448 | 468 | ||
| @@ -810,7 +830,7 @@ static int __init clocksource_done_booting(void) | |||
| 810 | /* | 830 | /* |
| 811 | * Run the watchdog first to eliminate unstable clock sources | 831 | * Run the watchdog first to eliminate unstable clock sources |
| 812 | */ | 832 | */ |
| 813 | __clocksource_watchdog_work(); | 833 | __clocksource_watchdog_kthread(); |
| 814 | clocksource_select(); | 834 | clocksource_select(); |
| 815 | mutex_unlock(&clocksource_mutex); | 835 | mutex_unlock(&clocksource_mutex); |
| 816 | return 0; | 836 | return 0; |
diff --git a/mm/Makefile b/mm/Makefile index 8716bdabe1e6..26ef77a3883b 100644 --- a/mm/Makefile +++ b/mm/Makefile | |||
| @@ -32,7 +32,7 @@ ifdef CONFIG_CROSS_MEMORY_ATTACH | |||
| 32 | mmu-$(CONFIG_MMU) += process_vm_access.o | 32 | mmu-$(CONFIG_MMU) += process_vm_access.o |
| 33 | endif | 33 | endif |
| 34 | 34 | ||
| 35 | obj-y := filemap.o mempool.o oom_kill.o \ | 35 | obj-y := filemap.o mempool.o oom_kill.o fadvise.o \ |
| 36 | maccess.o page_alloc.o page-writeback.o \ | 36 | maccess.o page_alloc.o page-writeback.o \ |
| 37 | readahead.o swap.o truncate.o vmscan.o shmem.o \ | 37 | readahead.o swap.o truncate.o vmscan.o shmem.o \ |
| 38 | util.o mmzone.o vmstat.o backing-dev.o \ | 38 | util.o mmzone.o vmstat.o backing-dev.o \ |
| @@ -49,7 +49,6 @@ else | |||
| 49 | obj-y += bootmem.o | 49 | obj-y += bootmem.o |
| 50 | endif | 50 | endif |
| 51 | 51 | ||
| 52 | obj-$(CONFIG_ADVISE_SYSCALLS) += fadvise.o | ||
| 53 | ifdef CONFIG_MMU | 52 | ifdef CONFIG_MMU |
| 54 | obj-$(CONFIG_ADVISE_SYSCALLS) += madvise.o | 53 | obj-$(CONFIG_ADVISE_SYSCALLS) += madvise.o |
| 55 | endif | 54 | endif |
diff --git a/mm/debug.c b/mm/debug.c index 38c926520c97..bd10aad8539a 100644 --- a/mm/debug.c +++ b/mm/debug.c | |||
| @@ -114,7 +114,7 @@ EXPORT_SYMBOL(dump_vma); | |||
| 114 | 114 | ||
| 115 | void dump_mm(const struct mm_struct *mm) | 115 | void dump_mm(const struct mm_struct *mm) |
| 116 | { | 116 | { |
| 117 | pr_emerg("mm %px mmap %px seqnum %d task_size %lu\n" | 117 | pr_emerg("mm %px mmap %px seqnum %llu task_size %lu\n" |
| 118 | #ifdef CONFIG_MMU | 118 | #ifdef CONFIG_MMU |
| 119 | "get_unmapped_area %px\n" | 119 | "get_unmapped_area %px\n" |
| 120 | #endif | 120 | #endif |
| @@ -142,7 +142,7 @@ void dump_mm(const struct mm_struct *mm) | |||
| 142 | "tlb_flush_pending %d\n" | 142 | "tlb_flush_pending %d\n" |
| 143 | "def_flags: %#lx(%pGv)\n", | 143 | "def_flags: %#lx(%pGv)\n", |
| 144 | 144 | ||
| 145 | mm, mm->mmap, mm->vmacache_seqnum, mm->task_size, | 145 | mm, mm->mmap, (long long) mm->vmacache_seqnum, mm->task_size, |
| 146 | #ifdef CONFIG_MMU | 146 | #ifdef CONFIG_MMU |
| 147 | mm->get_unmapped_area, | 147 | mm->get_unmapped_area, |
| 148 | #endif | 148 | #endif |
diff --git a/mm/fadvise.c b/mm/fadvise.c index 2d8376e3c640..467bcd032037 100644 --- a/mm/fadvise.c +++ b/mm/fadvise.c | |||
| @@ -27,9 +27,9 @@ | |||
| 27 | * deactivate the pages and clear PG_Referenced. | 27 | * deactivate the pages and clear PG_Referenced. |
| 28 | */ | 28 | */ |
| 29 | 29 | ||
| 30 | int ksys_fadvise64_64(int fd, loff_t offset, loff_t len, int advice) | 30 | static int generic_fadvise(struct file *file, loff_t offset, loff_t len, |
| 31 | int advice) | ||
| 31 | { | 32 | { |
| 32 | struct fd f = fdget(fd); | ||
| 33 | struct inode *inode; | 33 | struct inode *inode; |
| 34 | struct address_space *mapping; | 34 | struct address_space *mapping; |
| 35 | struct backing_dev_info *bdi; | 35 | struct backing_dev_info *bdi; |
| @@ -37,22 +37,14 @@ int ksys_fadvise64_64(int fd, loff_t offset, loff_t len, int advice) | |||
| 37 | pgoff_t start_index; | 37 | pgoff_t start_index; |
| 38 | pgoff_t end_index; | 38 | pgoff_t end_index; |
| 39 | unsigned long nrpages; | 39 | unsigned long nrpages; |
| 40 | int ret = 0; | ||
| 41 | |||
| 42 | if (!f.file) | ||
| 43 | return -EBADF; | ||
| 44 | 40 | ||
| 45 | inode = file_inode(f.file); | 41 | inode = file_inode(file); |
| 46 | if (S_ISFIFO(inode->i_mode)) { | 42 | if (S_ISFIFO(inode->i_mode)) |
| 47 | ret = -ESPIPE; | 43 | return -ESPIPE; |
| 48 | goto out; | ||
| 49 | } | ||
| 50 | 44 | ||
| 51 | mapping = f.file->f_mapping; | 45 | mapping = file->f_mapping; |
| 52 | if (!mapping || len < 0) { | 46 | if (!mapping || len < 0) |
| 53 | ret = -EINVAL; | 47 | return -EINVAL; |
| 54 | goto out; | ||
| 55 | } | ||
| 56 | 48 | ||
| 57 | bdi = inode_to_bdi(mapping->host); | 49 | bdi = inode_to_bdi(mapping->host); |
| 58 | 50 | ||
| @@ -67,9 +59,9 @@ int ksys_fadvise64_64(int fd, loff_t offset, loff_t len, int advice) | |||
| 67 | /* no bad return value, but ignore advice */ | 59 | /* no bad return value, but ignore advice */ |
| 68 | break; | 60 | break; |
| 69 | default: | 61 | default: |
| 70 | ret = -EINVAL; | 62 | return -EINVAL; |
| 71 | } | 63 | } |
| 72 | goto out; | 64 | return 0; |
| 73 | } | 65 | } |
| 74 | 66 | ||
| 75 | /* | 67 | /* |
| @@ -85,21 +77,21 @@ int ksys_fadvise64_64(int fd, loff_t offset, loff_t len, int advice) | |||
| 85 | 77 | ||
| 86 | switch (advice) { | 78 | switch (advice) { |
| 87 | case POSIX_FADV_NORMAL: | 79 | case POSIX_FADV_NORMAL: |
| 88 | f.file->f_ra.ra_pages = bdi->ra_pages; | 80 | file->f_ra.ra_pages = bdi->ra_pages; |
| 89 | spin_lock(&f.file->f_lock); | 81 | spin_lock(&file->f_lock); |
| 90 | f.file->f_mode &= ~FMODE_RANDOM; | 82 | file->f_mode &= ~FMODE_RANDOM; |
| 91 | spin_unlock(&f.file->f_lock); | 83 | spin_unlock(&file->f_lock); |
| 92 | break; | 84 | break; |
| 93 | case POSIX_FADV_RANDOM: | 85 | case POSIX_FADV_RANDOM: |
| 94 | spin_lock(&f.file->f_lock); | 86 | spin_lock(&file->f_lock); |
| 95 | f.file->f_mode |= FMODE_RANDOM; | 87 | file->f_mode |= FMODE_RANDOM; |
| 96 | spin_unlock(&f.file->f_lock); | 88 | spin_unlock(&file->f_lock); |
| 97 | break; | 89 | break; |
| 98 | case POSIX_FADV_SEQUENTIAL: | 90 | case POSIX_FADV_SEQUENTIAL: |
| 99 | f.file->f_ra.ra_pages = bdi->ra_pages * 2; | 91 | file->f_ra.ra_pages = bdi->ra_pages * 2; |
| 100 | spin_lock(&f.file->f_lock); | 92 | spin_lock(&file->f_lock); |
| 101 | f.file->f_mode &= ~FMODE_RANDOM; | 93 | file->f_mode &= ~FMODE_RANDOM; |
| 102 | spin_unlock(&f.file->f_lock); | 94 | spin_unlock(&file->f_lock); |
| 103 | break; | 95 | break; |
| 104 | case POSIX_FADV_WILLNEED: | 96 | case POSIX_FADV_WILLNEED: |
| 105 | /* First and last PARTIAL page! */ | 97 | /* First and last PARTIAL page! */ |
| @@ -115,8 +107,7 @@ int ksys_fadvise64_64(int fd, loff_t offset, loff_t len, int advice) | |||
| 115 | * Ignore return value because fadvise() shall return | 107 | * Ignore return value because fadvise() shall return |
| 116 | * success even if filesystem can't retrieve a hint, | 108 | * success even if filesystem can't retrieve a hint, |
| 117 | */ | 109 | */ |
| 118 | force_page_cache_readahead(mapping, f.file, start_index, | 110 | force_page_cache_readahead(mapping, file, start_index, nrpages); |
| 119 | nrpages); | ||
| 120 | break; | 111 | break; |
| 121 | case POSIX_FADV_NOREUSE: | 112 | case POSIX_FADV_NOREUSE: |
| 122 | break; | 113 | break; |
| @@ -183,9 +174,32 @@ int ksys_fadvise64_64(int fd, loff_t offset, loff_t len, int advice) | |||
| 183 | } | 174 | } |
| 184 | break; | 175 | break; |
| 185 | default: | 176 | default: |
| 186 | ret = -EINVAL; | 177 | return -EINVAL; |
| 187 | } | 178 | } |
| 188 | out: | 179 | return 0; |
| 180 | } | ||
| 181 | |||
| 182 | int vfs_fadvise(struct file *file, loff_t offset, loff_t len, int advice) | ||
| 183 | { | ||
| 184 | if (file->f_op->fadvise) | ||
| 185 | return file->f_op->fadvise(file, offset, len, advice); | ||
| 186 | |||
| 187 | return generic_fadvise(file, offset, len, advice); | ||
| 188 | } | ||
| 189 | EXPORT_SYMBOL(vfs_fadvise); | ||
| 190 | |||
| 191 | #ifdef CONFIG_ADVISE_SYSCALLS | ||
| 192 | |||
| 193 | int ksys_fadvise64_64(int fd, loff_t offset, loff_t len, int advice) | ||
| 194 | { | ||
| 195 | struct fd f = fdget(fd); | ||
| 196 | int ret; | ||
| 197 | |||
| 198 | if (!f.file) | ||
| 199 | return -EBADF; | ||
| 200 | |||
| 201 | ret = vfs_fadvise(f.file, offset, len, advice); | ||
| 202 | |||
| 189 | fdput(f); | 203 | fdput(f); |
| 190 | return ret; | 204 | return ret; |
| 191 | } | 205 | } |
| @@ -203,3 +217,4 @@ SYSCALL_DEFINE4(fadvise64, int, fd, loff_t, offset, size_t, len, int, advice) | |||
| 203 | } | 217 | } |
| 204 | 218 | ||
| 205 | #endif | 219 | #endif |
| 220 | #endif | ||
diff --git a/mm/readahead.c b/mm/readahead.c index a59ea70527b9..4e630143a0ba 100644 --- a/mm/readahead.c +++ b/mm/readahead.c | |||
| @@ -20,6 +20,7 @@ | |||
| 20 | #include <linux/file.h> | 20 | #include <linux/file.h> |
| 21 | #include <linux/mm_inline.h> | 21 | #include <linux/mm_inline.h> |
| 22 | #include <linux/blk-cgroup.h> | 22 | #include <linux/blk-cgroup.h> |
| 23 | #include <linux/fadvise.h> | ||
| 23 | 24 | ||
| 24 | #include "internal.h" | 25 | #include "internal.h" |
| 25 | 26 | ||
| @@ -575,24 +576,6 @@ page_cache_async_readahead(struct address_space *mapping, | |||
| 575 | } | 576 | } |
| 576 | EXPORT_SYMBOL_GPL(page_cache_async_readahead); | 577 | EXPORT_SYMBOL_GPL(page_cache_async_readahead); |
| 577 | 578 | ||
| 578 | static ssize_t | ||
| 579 | do_readahead(struct address_space *mapping, struct file *filp, | ||
| 580 | pgoff_t index, unsigned long nr) | ||
| 581 | { | ||
| 582 | if (!mapping || !mapping->a_ops) | ||
| 583 | return -EINVAL; | ||
| 584 | |||
| 585 | /* | ||
| 586 | * Readahead doesn't make sense for DAX inodes, but we don't want it | ||
| 587 | * to report a failure either. Instead, we just return success and | ||
| 588 | * don't do any work. | ||
| 589 | */ | ||
| 590 | if (dax_mapping(mapping)) | ||
| 591 | return 0; | ||
| 592 | |||
| 593 | return force_page_cache_readahead(mapping, filp, index, nr); | ||
| 594 | } | ||
| 595 | |||
| 596 | ssize_t ksys_readahead(int fd, loff_t offset, size_t count) | 579 | ssize_t ksys_readahead(int fd, loff_t offset, size_t count) |
| 597 | { | 580 | { |
| 598 | ssize_t ret; | 581 | ssize_t ret; |
| @@ -600,16 +583,22 @@ ssize_t ksys_readahead(int fd, loff_t offset, size_t count) | |||
| 600 | 583 | ||
| 601 | ret = -EBADF; | 584 | ret = -EBADF; |
| 602 | f = fdget(fd); | 585 | f = fdget(fd); |
| 603 | if (f.file) { | 586 | if (!f.file || !(f.file->f_mode & FMODE_READ)) |
| 604 | if (f.file->f_mode & FMODE_READ) { | 587 | goto out; |
| 605 | struct address_space *mapping = f.file->f_mapping; | 588 | |
| 606 | pgoff_t start = offset >> PAGE_SHIFT; | 589 | /* |
| 607 | pgoff_t end = (offset + count - 1) >> PAGE_SHIFT; | 590 | * The readahead() syscall is intended to run only on files |
| 608 | unsigned long len = end - start + 1; | 591 | * that can execute readahead. If readahead is not possible |
| 609 | ret = do_readahead(mapping, f.file, start, len); | 592 | * on this file, then we must return -EINVAL. |
| 610 | } | 593 | */ |
| 611 | fdput(f); | 594 | ret = -EINVAL; |
| 612 | } | 595 | if (!f.file->f_mapping || !f.file->f_mapping->a_ops || |
| 596 | !S_ISREG(file_inode(f.file)->i_mode)) | ||
| 597 | goto out; | ||
| 598 | |||
| 599 | ret = vfs_fadvise(f.file, offset, count, POSIX_FADV_WILLNEED); | ||
| 600 | out: | ||
| 601 | fdput(f); | ||
| 613 | return ret; | 602 | return ret; |
| 614 | } | 603 | } |
| 615 | 604 | ||
diff --git a/mm/vmacache.c b/mm/vmacache.c index ea517bef7dc5..cdc32a3b02fa 100644 --- a/mm/vmacache.c +++ b/mm/vmacache.c | |||
| @@ -20,44 +20,6 @@ | |||
| 20 | #define VMACACHE_HASH(addr) ((addr >> VMACACHE_SHIFT) & VMACACHE_MASK) | 20 | #define VMACACHE_HASH(addr) ((addr >> VMACACHE_SHIFT) & VMACACHE_MASK) |
| 21 | 21 | ||
| 22 | /* | 22 | /* |
| 23 | * Flush vma caches for threads that share a given mm. | ||
| 24 | * | ||
| 25 | * The operation is safe because the caller holds the mmap_sem | ||
| 26 | * exclusively and other threads accessing the vma cache will | ||
| 27 | * have mmap_sem held at least for read, so no extra locking | ||
| 28 | * is required to maintain the vma cache. | ||
| 29 | */ | ||
| 30 | void vmacache_flush_all(struct mm_struct *mm) | ||
| 31 | { | ||
| 32 | struct task_struct *g, *p; | ||
| 33 | |||
| 34 | count_vm_vmacache_event(VMACACHE_FULL_FLUSHES); | ||
| 35 | |||
| 36 | /* | ||
| 37 | * Single threaded tasks need not iterate the entire | ||
| 38 | * list of process. We can avoid the flushing as well | ||
| 39 | * since the mm's seqnum was increased and don't have | ||
| 40 | * to worry about other threads' seqnum. Current's | ||
| 41 | * flush will occur upon the next lookup. | ||
| 42 | */ | ||
| 43 | if (atomic_read(&mm->mm_users) == 1) | ||
| 44 | return; | ||
| 45 | |||
| 46 | rcu_read_lock(); | ||
| 47 | for_each_process_thread(g, p) { | ||
| 48 | /* | ||
| 49 | * Only flush the vmacache pointers as the | ||
| 50 | * mm seqnum is already set and curr's will | ||
| 51 | * be set upon invalidation when the next | ||
| 52 | * lookup is done. | ||
| 53 | */ | ||
| 54 | if (mm == p->mm) | ||
| 55 | vmacache_flush(p); | ||
| 56 | } | ||
| 57 | rcu_read_unlock(); | ||
| 58 | } | ||
| 59 | |||
| 60 | /* | ||
| 61 | * This task may be accessing a foreign mm via (for example) | 23 | * This task may be accessing a foreign mm via (for example) |
| 62 | * get_user_pages()->find_vma(). The vmacache is task-local and this | 24 | * get_user_pages()->find_vma(). The vmacache is task-local and this |
| 63 | * task's vmacache pertains to a different mm (ie, its own). There is | 25 | * task's vmacache pertains to a different mm (ie, its own). There is |
diff --git a/net/core/skbuff.c b/net/core/skbuff.c index c996c09d095f..b2c807f67aba 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c | |||
| @@ -939,9 +939,6 @@ struct ubuf_info *sock_zerocopy_alloc(struct sock *sk, size_t size) | |||
| 939 | 939 | ||
| 940 | WARN_ON_ONCE(!in_task()); | 940 | WARN_ON_ONCE(!in_task()); |
| 941 | 941 | ||
| 942 | if (!sock_flag(sk, SOCK_ZEROCOPY)) | ||
| 943 | return NULL; | ||
| 944 | |||
| 945 | skb = sock_omalloc(sk, 0, GFP_KERNEL); | 942 | skb = sock_omalloc(sk, 0, GFP_KERNEL); |
| 946 | if (!skb) | 943 | if (!skb) |
| 947 | return NULL; | 944 | return NULL; |
diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c index 88281fbce88c..e7227128df2c 100644 --- a/net/ipv4/ip_fragment.c +++ b/net/ipv4/ip_fragment.c | |||
| @@ -599,6 +599,7 @@ static int ip_frag_reasm(struct ipq *qp, struct sk_buff *skb, | |||
| 599 | nextp = &fp->next; | 599 | nextp = &fp->next; |
| 600 | fp->prev = NULL; | 600 | fp->prev = NULL; |
| 601 | memset(&fp->rbnode, 0, sizeof(fp->rbnode)); | 601 | memset(&fp->rbnode, 0, sizeof(fp->rbnode)); |
| 602 | fp->sk = NULL; | ||
| 602 | head->data_len += fp->len; | 603 | head->data_len += fp->len; |
| 603 | head->len += fp->len; | 604 | head->len += fp->len; |
| 604 | if (head->ip_summed != fp->ip_summed) | 605 | if (head->ip_summed != fp->ip_summed) |
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c index ae714aecc31c..8cce0e9ea08c 100644 --- a/net/ipv4/ip_gre.c +++ b/net/ipv4/ip_gre.c | |||
| @@ -178,6 +178,9 @@ static void ipgre_err(struct sk_buff *skb, u32 info, | |||
| 178 | 178 | ||
| 179 | if (tpi->proto == htons(ETH_P_TEB)) | 179 | if (tpi->proto == htons(ETH_P_TEB)) |
| 180 | itn = net_generic(net, gre_tap_net_id); | 180 | itn = net_generic(net, gre_tap_net_id); |
| 181 | else if (tpi->proto == htons(ETH_P_ERSPAN) || | ||
| 182 | tpi->proto == htons(ETH_P_ERSPAN2)) | ||
| 183 | itn = net_generic(net, erspan_net_id); | ||
| 181 | else | 184 | else |
| 182 | itn = net_generic(net, ipgre_net_id); | 185 | itn = net_generic(net, ipgre_net_id); |
| 183 | 186 | ||
| @@ -328,6 +331,8 @@ static int erspan_rcv(struct sk_buff *skb, struct tnl_ptk_info *tpi, | |||
| 328 | ip_tunnel_rcv(tunnel, skb, tpi, tun_dst, log_ecn_error); | 331 | ip_tunnel_rcv(tunnel, skb, tpi, tun_dst, log_ecn_error); |
| 329 | return PACKET_RCVD; | 332 | return PACKET_RCVD; |
| 330 | } | 333 | } |
| 334 | return PACKET_REJECT; | ||
| 335 | |||
| 331 | drop: | 336 | drop: |
| 332 | kfree_skb(skb); | 337 | kfree_skb(skb); |
| 333 | return PACKET_RCVD; | 338 | return PACKET_RCVD; |
diff --git a/net/ipv4/netfilter/Kconfig b/net/ipv4/netfilter/Kconfig index d9504adc47b3..184bf2e0a1ed 100644 --- a/net/ipv4/netfilter/Kconfig +++ b/net/ipv4/netfilter/Kconfig | |||
| @@ -106,6 +106,10 @@ config NF_NAT_IPV4 | |||
| 106 | 106 | ||
| 107 | if NF_NAT_IPV4 | 107 | if NF_NAT_IPV4 |
| 108 | 108 | ||
| 109 | config NF_NAT_MASQUERADE_IPV4 | ||
| 110 | bool | ||
| 111 | |||
| 112 | if NF_TABLES | ||
| 109 | config NFT_CHAIN_NAT_IPV4 | 113 | config NFT_CHAIN_NAT_IPV4 |
| 110 | depends on NF_TABLES_IPV4 | 114 | depends on NF_TABLES_IPV4 |
| 111 | tristate "IPv4 nf_tables nat chain support" | 115 | tristate "IPv4 nf_tables nat chain support" |
| @@ -115,9 +119,6 @@ config NFT_CHAIN_NAT_IPV4 | |||
| 115 | packet transformations such as the source, destination address and | 119 | packet transformations such as the source, destination address and |
| 116 | source and destination ports. | 120 | source and destination ports. |
| 117 | 121 | ||
| 118 | config NF_NAT_MASQUERADE_IPV4 | ||
| 119 | bool | ||
| 120 | |||
| 121 | config NFT_MASQ_IPV4 | 122 | config NFT_MASQ_IPV4 |
| 122 | tristate "IPv4 masquerading support for nf_tables" | 123 | tristate "IPv4 masquerading support for nf_tables" |
| 123 | depends on NF_TABLES_IPV4 | 124 | depends on NF_TABLES_IPV4 |
| @@ -135,6 +136,7 @@ config NFT_REDIR_IPV4 | |||
| 135 | help | 136 | help |
| 136 | This is the expression that provides IPv4 redirect support for | 137 | This is the expression that provides IPv4 redirect support for |
| 137 | nf_tables. | 138 | nf_tables. |
| 139 | endif # NF_TABLES | ||
| 138 | 140 | ||
| 139 | config NF_NAT_SNMP_BASIC | 141 | config NF_NAT_SNMP_BASIC |
| 140 | tristate "Basic SNMP-ALG support" | 142 | tristate "Basic SNMP-ALG support" |
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index b8af2fec5ad5..10c6246396cc 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c | |||
| @@ -1185,7 +1185,7 @@ int tcp_sendmsg_locked(struct sock *sk, struct msghdr *msg, size_t size) | |||
| 1185 | 1185 | ||
| 1186 | flags = msg->msg_flags; | 1186 | flags = msg->msg_flags; |
| 1187 | 1187 | ||
| 1188 | if (flags & MSG_ZEROCOPY && size) { | 1188 | if (flags & MSG_ZEROCOPY && size && sock_flag(sk, SOCK_ZEROCOPY)) { |
| 1189 | if (sk->sk_state != TCP_ESTABLISHED) { | 1189 | if (sk->sk_state != TCP_ESTABLISHED) { |
| 1190 | err = -EINVAL; | 1190 | err = -EINVAL; |
| 1191 | goto out_err; | 1191 | goto out_err; |
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 4c2dd9f863f7..4cf2f7bb2802 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c | |||
| @@ -6367,8 +6367,8 @@ static bool tcp_syn_flood_action(const struct sock *sk, | |||
| 6367 | if (!queue->synflood_warned && | 6367 | if (!queue->synflood_warned && |
| 6368 | net->ipv4.sysctl_tcp_syncookies != 2 && | 6368 | net->ipv4.sysctl_tcp_syncookies != 2 && |
| 6369 | xchg(&queue->synflood_warned, 1) == 0) | 6369 | xchg(&queue->synflood_warned, 1) == 0) |
| 6370 | pr_info("%s: Possible SYN flooding on port %d. %s. Check SNMP counters.\n", | 6370 | net_info_ratelimited("%s: Possible SYN flooding on port %d. %s. Check SNMP counters.\n", |
| 6371 | proto, ntohs(tcp_hdr(skb)->dest), msg); | 6371 | proto, ntohs(tcp_hdr(skb)->dest), msg); |
| 6372 | 6372 | ||
| 6373 | return want_cookie; | 6373 | return want_cookie; |
| 6374 | } | 6374 | } |
diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c index 2a14d8b65924..8f68a518d9db 100644 --- a/net/ipv6/netfilter/nf_conntrack_reasm.c +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c | |||
| @@ -445,6 +445,7 @@ nf_ct_frag6_reasm(struct frag_queue *fq, struct sk_buff *prev, struct net_devic | |||
| 445 | else if (head->ip_summed == CHECKSUM_COMPLETE) | 445 | else if (head->ip_summed == CHECKSUM_COMPLETE) |
| 446 | head->csum = csum_add(head->csum, fp->csum); | 446 | head->csum = csum_add(head->csum, fp->csum); |
| 447 | head->truesize += fp->truesize; | 447 | head->truesize += fp->truesize; |
| 448 | fp->sk = NULL; | ||
| 448 | } | 449 | } |
| 449 | sub_frag_mem_limit(fq->q.net, head->truesize); | 450 | sub_frag_mem_limit(fq->q.net, head->truesize); |
| 450 | 451 | ||
diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c index a21d8ed0a325..e2f16a0173a9 100644 --- a/net/iucv/af_iucv.c +++ b/net/iucv/af_iucv.c | |||
| @@ -351,20 +351,28 @@ static int afiucv_hs_send(struct iucv_message *imsg, struct sock *sock, | |||
| 351 | memcpy(&phs_hdr->iucv_hdr, imsg, sizeof(struct iucv_message)); | 351 | memcpy(&phs_hdr->iucv_hdr, imsg, sizeof(struct iucv_message)); |
| 352 | 352 | ||
| 353 | skb->dev = iucv->hs_dev; | 353 | skb->dev = iucv->hs_dev; |
| 354 | if (!skb->dev) | 354 | if (!skb->dev) { |
| 355 | return -ENODEV; | 355 | err = -ENODEV; |
| 356 | if (!(skb->dev->flags & IFF_UP) || !netif_carrier_ok(skb->dev)) | 356 | goto err_free; |
| 357 | return -ENETDOWN; | 357 | } |
| 358 | if (!(skb->dev->flags & IFF_UP) || !netif_carrier_ok(skb->dev)) { | ||
| 359 | err = -ENETDOWN; | ||
| 360 | goto err_free; | ||
| 361 | } | ||
| 358 | if (skb->len > skb->dev->mtu) { | 362 | if (skb->len > skb->dev->mtu) { |
| 359 | if (sock->sk_type == SOCK_SEQPACKET) | 363 | if (sock->sk_type == SOCK_SEQPACKET) { |
| 360 | return -EMSGSIZE; | 364 | err = -EMSGSIZE; |
| 361 | else | 365 | goto err_free; |
| 362 | skb_trim(skb, skb->dev->mtu); | 366 | } |
| 367 | skb_trim(skb, skb->dev->mtu); | ||
| 363 | } | 368 | } |
| 364 | skb->protocol = cpu_to_be16(ETH_P_AF_IUCV); | 369 | skb->protocol = cpu_to_be16(ETH_P_AF_IUCV); |
| 365 | nskb = skb_clone(skb, GFP_ATOMIC); | 370 | nskb = skb_clone(skb, GFP_ATOMIC); |
| 366 | if (!nskb) | 371 | if (!nskb) { |
| 367 | return -ENOMEM; | 372 | err = -ENOMEM; |
| 373 | goto err_free; | ||
| 374 | } | ||
| 375 | |||
| 368 | skb_queue_tail(&iucv->send_skb_q, nskb); | 376 | skb_queue_tail(&iucv->send_skb_q, nskb); |
| 369 | err = dev_queue_xmit(skb); | 377 | err = dev_queue_xmit(skb); |
| 370 | if (net_xmit_eval(err)) { | 378 | if (net_xmit_eval(err)) { |
| @@ -375,6 +383,10 @@ static int afiucv_hs_send(struct iucv_message *imsg, struct sock *sock, | |||
| 375 | WARN_ON(atomic_read(&iucv->msg_recv) < 0); | 383 | WARN_ON(atomic_read(&iucv->msg_recv) < 0); |
| 376 | } | 384 | } |
| 377 | return net_xmit_eval(err); | 385 | return net_xmit_eval(err); |
| 386 | |||
| 387 | err_free: | ||
| 388 | kfree_skb(skb); | ||
| 389 | return err; | ||
| 378 | } | 390 | } |
| 379 | 391 | ||
| 380 | static struct sock *__iucv_get_sock_by_name(char *nm) | 392 | static struct sock *__iucv_get_sock_by_name(char *nm) |
| @@ -1167,7 +1179,7 @@ static int iucv_sock_sendmsg(struct socket *sock, struct msghdr *msg, | |||
| 1167 | err = afiucv_hs_send(&txmsg, sk, skb, 0); | 1179 | err = afiucv_hs_send(&txmsg, sk, skb, 0); |
| 1168 | if (err) { | 1180 | if (err) { |
| 1169 | atomic_dec(&iucv->msg_sent); | 1181 | atomic_dec(&iucv->msg_sent); |
| 1170 | goto fail; | 1182 | goto out; |
| 1171 | } | 1183 | } |
| 1172 | } else { /* Classic VM IUCV transport */ | 1184 | } else { /* Classic VM IUCV transport */ |
| 1173 | skb_queue_tail(&iucv->send_skb_q, skb); | 1185 | skb_queue_tail(&iucv->send_skb_q, skb); |
| @@ -2155,8 +2167,8 @@ static int afiucv_hs_rcv(struct sk_buff *skb, struct net_device *dev, | |||
| 2155 | struct sock *sk; | 2167 | struct sock *sk; |
| 2156 | struct iucv_sock *iucv; | 2168 | struct iucv_sock *iucv; |
| 2157 | struct af_iucv_trans_hdr *trans_hdr; | 2169 | struct af_iucv_trans_hdr *trans_hdr; |
| 2170 | int err = NET_RX_SUCCESS; | ||
| 2158 | char nullstring[8]; | 2171 | char nullstring[8]; |
| 2159 | int err = 0; | ||
| 2160 | 2172 | ||
| 2161 | if (skb->len < (ETH_HLEN + sizeof(struct af_iucv_trans_hdr))) { | 2173 | if (skb->len < (ETH_HLEN + sizeof(struct af_iucv_trans_hdr))) { |
| 2162 | WARN_ONCE(1, "AF_IUCV too short skb, len=%d, min=%d", | 2174 | WARN_ONCE(1, "AF_IUCV too short skb, len=%d, min=%d", |
| @@ -2254,7 +2266,7 @@ static int afiucv_hs_rcv(struct sk_buff *skb, struct net_device *dev, | |||
| 2254 | err = afiucv_hs_callback_rx(sk, skb); | 2266 | err = afiucv_hs_callback_rx(sk, skb); |
| 2255 | break; | 2267 | break; |
| 2256 | default: | 2268 | default: |
| 2257 | ; | 2269 | kfree_skb(skb); |
| 2258 | } | 2270 | } |
| 2259 | 2271 | ||
| 2260 | return err; | 2272 | return err; |
diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c index 8f7ef167c45a..eb502c6290c2 100644 --- a/net/iucv/iucv.c +++ b/net/iucv/iucv.c | |||
| @@ -1874,7 +1874,7 @@ static void iucv_pm_complete(struct device *dev) | |||
| 1874 | * Returns 0 if there are still iucv pathes defined | 1874 | * Returns 0 if there are still iucv pathes defined |
| 1875 | * 1 if there are no iucv pathes defined | 1875 | * 1 if there are no iucv pathes defined |
| 1876 | */ | 1876 | */ |
| 1877 | int iucv_path_table_empty(void) | 1877 | static int iucv_path_table_empty(void) |
| 1878 | { | 1878 | { |
| 1879 | int i; | 1879 | int i; |
| 1880 | 1880 | ||
diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig index 71709c104081..f61c306de1d0 100644 --- a/net/netfilter/Kconfig +++ b/net/netfilter/Kconfig | |||
| @@ -771,13 +771,13 @@ config NETFILTER_XT_TARGET_CHECKSUM | |||
| 771 | depends on NETFILTER_ADVANCED | 771 | depends on NETFILTER_ADVANCED |
| 772 | ---help--- | 772 | ---help--- |
| 773 | This option adds a `CHECKSUM' target, which can be used in the iptables mangle | 773 | This option adds a `CHECKSUM' target, which can be used in the iptables mangle |
| 774 | table. | 774 | table to work around buggy DHCP clients in virtualized environments. |
| 775 | 775 | ||
| 776 | You can use this target to compute and fill in the checksum in | 776 | Some old DHCP clients drop packets because they are not aware |
| 777 | a packet that lacks a checksum. This is particularly useful, | 777 | that the checksum would normally be offloaded to hardware and |
| 778 | if you need to work around old applications such as dhcp clients, | 778 | thus should be considered valid. |
| 779 | that do not work well with checksum offloads, but don't want to disable | 779 | This target can be used to fill in the checksum using iptables |
| 780 | checksum offload in your device. | 780 | when such packets are sent via a virtual network device. |
| 781 | 781 | ||
| 782 | To compile it as a module, choose M here. If unsure, say N. | 782 | To compile it as a module, choose M here. If unsure, say N. |
| 783 | 783 | ||
diff --git a/net/netfilter/nf_conntrack_proto.c b/net/netfilter/nf_conntrack_proto.c index 9f14b0df6960..51c5d7eec0a3 100644 --- a/net/netfilter/nf_conntrack_proto.c +++ b/net/netfilter/nf_conntrack_proto.c | |||
| @@ -776,9 +776,26 @@ static const struct nf_hook_ops ipv6_conntrack_ops[] = { | |||
| 776 | }; | 776 | }; |
| 777 | #endif | 777 | #endif |
| 778 | 778 | ||
| 779 | static int nf_ct_tcp_fixup(struct nf_conn *ct, void *_nfproto) | ||
| 780 | { | ||
| 781 | u8 nfproto = (unsigned long)_nfproto; | ||
| 782 | |||
| 783 | if (nf_ct_l3num(ct) != nfproto) | ||
| 784 | return 0; | ||
| 785 | |||
| 786 | if (nf_ct_protonum(ct) == IPPROTO_TCP && | ||
| 787 | ct->proto.tcp.state == TCP_CONNTRACK_ESTABLISHED) { | ||
| 788 | ct->proto.tcp.seen[0].td_maxwin = 0; | ||
| 789 | ct->proto.tcp.seen[1].td_maxwin = 0; | ||
| 790 | } | ||
| 791 | |||
| 792 | return 0; | ||
| 793 | } | ||
| 794 | |||
| 779 | static int nf_ct_netns_do_get(struct net *net, u8 nfproto) | 795 | static int nf_ct_netns_do_get(struct net *net, u8 nfproto) |
| 780 | { | 796 | { |
| 781 | struct nf_conntrack_net *cnet = net_generic(net, nf_conntrack_net_id); | 797 | struct nf_conntrack_net *cnet = net_generic(net, nf_conntrack_net_id); |
| 798 | bool fixup_needed = false; | ||
| 782 | int err = 0; | 799 | int err = 0; |
| 783 | 800 | ||
| 784 | mutex_lock(&nf_ct_proto_mutex); | 801 | mutex_lock(&nf_ct_proto_mutex); |
| @@ -798,6 +815,8 @@ static int nf_ct_netns_do_get(struct net *net, u8 nfproto) | |||
| 798 | ARRAY_SIZE(ipv4_conntrack_ops)); | 815 | ARRAY_SIZE(ipv4_conntrack_ops)); |
| 799 | if (err) | 816 | if (err) |
| 800 | cnet->users4 = 0; | 817 | cnet->users4 = 0; |
| 818 | else | ||
| 819 | fixup_needed = true; | ||
| 801 | break; | 820 | break; |
| 802 | #if IS_ENABLED(CONFIG_IPV6) | 821 | #if IS_ENABLED(CONFIG_IPV6) |
| 803 | case NFPROTO_IPV6: | 822 | case NFPROTO_IPV6: |
| @@ -814,6 +833,8 @@ static int nf_ct_netns_do_get(struct net *net, u8 nfproto) | |||
| 814 | ARRAY_SIZE(ipv6_conntrack_ops)); | 833 | ARRAY_SIZE(ipv6_conntrack_ops)); |
| 815 | if (err) | 834 | if (err) |
| 816 | cnet->users6 = 0; | 835 | cnet->users6 = 0; |
| 836 | else | ||
| 837 | fixup_needed = true; | ||
| 817 | break; | 838 | break; |
| 818 | #endif | 839 | #endif |
| 819 | default: | 840 | default: |
| @@ -822,6 +843,11 @@ static int nf_ct_netns_do_get(struct net *net, u8 nfproto) | |||
| 822 | } | 843 | } |
| 823 | out_unlock: | 844 | out_unlock: |
| 824 | mutex_unlock(&nf_ct_proto_mutex); | 845 | mutex_unlock(&nf_ct_proto_mutex); |
| 846 | |||
| 847 | if (fixup_needed) | ||
| 848 | nf_ct_iterate_cleanup_net(net, nf_ct_tcp_fixup, | ||
| 849 | (void *)(unsigned long)nfproto, 0, 0); | ||
| 850 | |||
| 825 | return err; | 851 | return err; |
| 826 | } | 852 | } |
| 827 | 853 | ||
diff --git a/net/netfilter/nf_conntrack_proto_dccp.c b/net/netfilter/nf_conntrack_proto_dccp.c index 8c58f96b59e7..f3f91ed2c21a 100644 --- a/net/netfilter/nf_conntrack_proto_dccp.c +++ b/net/netfilter/nf_conntrack_proto_dccp.c | |||
| @@ -675,7 +675,7 @@ static int nlattr_to_dccp(struct nlattr *cda[], struct nf_conn *ct) | |||
| 675 | } | 675 | } |
| 676 | #endif | 676 | #endif |
| 677 | 677 | ||
| 678 | #if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT) | 678 | #ifdef CONFIG_NF_CONNTRACK_TIMEOUT |
| 679 | 679 | ||
| 680 | #include <linux/netfilter/nfnetlink.h> | 680 | #include <linux/netfilter/nfnetlink.h> |
| 681 | #include <linux/netfilter/nfnetlink_cttimeout.h> | 681 | #include <linux/netfilter/nfnetlink_cttimeout.h> |
| @@ -697,6 +697,8 @@ static int dccp_timeout_nlattr_to_obj(struct nlattr *tb[], | |||
| 697 | timeouts[i] = ntohl(nla_get_be32(tb[i])) * HZ; | 697 | timeouts[i] = ntohl(nla_get_be32(tb[i])) * HZ; |
| 698 | } | 698 | } |
| 699 | } | 699 | } |
| 700 | |||
| 701 | timeouts[CTA_TIMEOUT_DCCP_UNSPEC] = timeouts[CTA_TIMEOUT_DCCP_REQUEST]; | ||
| 700 | return 0; | 702 | return 0; |
| 701 | } | 703 | } |
| 702 | 704 | ||
| @@ -726,7 +728,7 @@ dccp_timeout_nla_policy[CTA_TIMEOUT_DCCP_MAX+1] = { | |||
| 726 | [CTA_TIMEOUT_DCCP_CLOSING] = { .type = NLA_U32 }, | 728 | [CTA_TIMEOUT_DCCP_CLOSING] = { .type = NLA_U32 }, |
| 727 | [CTA_TIMEOUT_DCCP_TIMEWAIT] = { .type = NLA_U32 }, | 729 | [CTA_TIMEOUT_DCCP_TIMEWAIT] = { .type = NLA_U32 }, |
| 728 | }; | 730 | }; |
| 729 | #endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ | 731 | #endif /* CONFIG_NF_CONNTRACK_TIMEOUT */ |
| 730 | 732 | ||
| 731 | #ifdef CONFIG_SYSCTL | 733 | #ifdef CONFIG_SYSCTL |
| 732 | /* template, data assigned later */ | 734 | /* template, data assigned later */ |
| @@ -827,6 +829,11 @@ static int dccp_init_net(struct net *net, u_int16_t proto) | |||
| 827 | dn->dccp_timeout[CT_DCCP_CLOSEREQ] = 64 * HZ; | 829 | dn->dccp_timeout[CT_DCCP_CLOSEREQ] = 64 * HZ; |
| 828 | dn->dccp_timeout[CT_DCCP_CLOSING] = 64 * HZ; | 830 | dn->dccp_timeout[CT_DCCP_CLOSING] = 64 * HZ; |
| 829 | dn->dccp_timeout[CT_DCCP_TIMEWAIT] = 2 * DCCP_MSL; | 831 | dn->dccp_timeout[CT_DCCP_TIMEWAIT] = 2 * DCCP_MSL; |
| 832 | |||
| 833 | /* timeouts[0] is unused, make it same as SYN_SENT so | ||
| 834 | * ->timeouts[0] contains 'new' timeout, like udp or icmp. | ||
| 835 | */ | ||
| 836 | dn->dccp_timeout[CT_DCCP_NONE] = dn->dccp_timeout[CT_DCCP_REQUEST]; | ||
| 830 | } | 837 | } |
| 831 | 838 | ||
| 832 | return dccp_kmemdup_sysctl_table(net, pn, dn); | 839 | return dccp_kmemdup_sysctl_table(net, pn, dn); |
| @@ -856,7 +863,7 @@ const struct nf_conntrack_l4proto nf_conntrack_l4proto_dccp4 = { | |||
| 856 | .nlattr_to_tuple = nf_ct_port_nlattr_to_tuple, | 863 | .nlattr_to_tuple = nf_ct_port_nlattr_to_tuple, |
| 857 | .nla_policy = nf_ct_port_nla_policy, | 864 | .nla_policy = nf_ct_port_nla_policy, |
| 858 | #endif | 865 | #endif |
| 859 | #if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT) | 866 | #ifdef CONFIG_NF_CONNTRACK_TIMEOUT |
| 860 | .ctnl_timeout = { | 867 | .ctnl_timeout = { |
| 861 | .nlattr_to_obj = dccp_timeout_nlattr_to_obj, | 868 | .nlattr_to_obj = dccp_timeout_nlattr_to_obj, |
| 862 | .obj_to_nlattr = dccp_timeout_obj_to_nlattr, | 869 | .obj_to_nlattr = dccp_timeout_obj_to_nlattr, |
| @@ -864,7 +871,7 @@ const struct nf_conntrack_l4proto nf_conntrack_l4proto_dccp4 = { | |||
| 864 | .obj_size = sizeof(unsigned int) * CT_DCCP_MAX, | 871 | .obj_size = sizeof(unsigned int) * CT_DCCP_MAX, |
| 865 | .nla_policy = dccp_timeout_nla_policy, | 872 | .nla_policy = dccp_timeout_nla_policy, |
| 866 | }, | 873 | }, |
| 867 | #endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ | 874 | #endif /* CONFIG_NF_CONNTRACK_TIMEOUT */ |
| 868 | .init_net = dccp_init_net, | 875 | .init_net = dccp_init_net, |
| 869 | .get_net_proto = dccp_get_net_proto, | 876 | .get_net_proto = dccp_get_net_proto, |
| 870 | }; | 877 | }; |
| @@ -889,7 +896,7 @@ const struct nf_conntrack_l4proto nf_conntrack_l4proto_dccp6 = { | |||
| 889 | .nlattr_to_tuple = nf_ct_port_nlattr_to_tuple, | 896 | .nlattr_to_tuple = nf_ct_port_nlattr_to_tuple, |
| 890 | .nla_policy = nf_ct_port_nla_policy, | 897 | .nla_policy = nf_ct_port_nla_policy, |
| 891 | #endif | 898 | #endif |
| 892 | #if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT) | 899 | #ifdef CONFIG_NF_CONNTRACK_TIMEOUT |
| 893 | .ctnl_timeout = { | 900 | .ctnl_timeout = { |
| 894 | .nlattr_to_obj = dccp_timeout_nlattr_to_obj, | 901 | .nlattr_to_obj = dccp_timeout_nlattr_to_obj, |
| 895 | .obj_to_nlattr = dccp_timeout_obj_to_nlattr, | 902 | .obj_to_nlattr = dccp_timeout_obj_to_nlattr, |
| @@ -897,7 +904,7 @@ const struct nf_conntrack_l4proto nf_conntrack_l4proto_dccp6 = { | |||
| 897 | .obj_size = sizeof(unsigned int) * CT_DCCP_MAX, | 904 | .obj_size = sizeof(unsigned int) * CT_DCCP_MAX, |
| 898 | .nla_policy = dccp_timeout_nla_policy, | 905 | .nla_policy = dccp_timeout_nla_policy, |
| 899 | }, | 906 | }, |
| 900 | #endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ | 907 | #endif /* CONFIG_NF_CONNTRACK_TIMEOUT */ |
| 901 | .init_net = dccp_init_net, | 908 | .init_net = dccp_init_net, |
| 902 | .get_net_proto = dccp_get_net_proto, | 909 | .get_net_proto = dccp_get_net_proto, |
| 903 | }; | 910 | }; |
diff --git a/net/netfilter/nf_conntrack_proto_generic.c b/net/netfilter/nf_conntrack_proto_generic.c index ac4a0b296dcd..1df3244ecd07 100644 --- a/net/netfilter/nf_conntrack_proto_generic.c +++ b/net/netfilter/nf_conntrack_proto_generic.c | |||
| @@ -70,7 +70,7 @@ static bool generic_new(struct nf_conn *ct, const struct sk_buff *skb, | |||
| 70 | return ret; | 70 | return ret; |
| 71 | } | 71 | } |
| 72 | 72 | ||
| 73 | #if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT) | 73 | #ifdef CONFIG_NF_CONNTRACK_TIMEOUT |
| 74 | 74 | ||
| 75 | #include <linux/netfilter/nfnetlink.h> | 75 | #include <linux/netfilter/nfnetlink.h> |
| 76 | #include <linux/netfilter/nfnetlink_cttimeout.h> | 76 | #include <linux/netfilter/nfnetlink_cttimeout.h> |
| @@ -113,7 +113,7 @@ static const struct nla_policy | |||
| 113 | generic_timeout_nla_policy[CTA_TIMEOUT_GENERIC_MAX+1] = { | 113 | generic_timeout_nla_policy[CTA_TIMEOUT_GENERIC_MAX+1] = { |
| 114 | [CTA_TIMEOUT_GENERIC_TIMEOUT] = { .type = NLA_U32 }, | 114 | [CTA_TIMEOUT_GENERIC_TIMEOUT] = { .type = NLA_U32 }, |
| 115 | }; | 115 | }; |
| 116 | #endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ | 116 | #endif /* CONFIG_NF_CONNTRACK_TIMEOUT */ |
| 117 | 117 | ||
| 118 | #ifdef CONFIG_SYSCTL | 118 | #ifdef CONFIG_SYSCTL |
| 119 | static struct ctl_table generic_sysctl_table[] = { | 119 | static struct ctl_table generic_sysctl_table[] = { |
| @@ -164,7 +164,7 @@ const struct nf_conntrack_l4proto nf_conntrack_l4proto_generic = | |||
| 164 | .pkt_to_tuple = generic_pkt_to_tuple, | 164 | .pkt_to_tuple = generic_pkt_to_tuple, |
| 165 | .packet = generic_packet, | 165 | .packet = generic_packet, |
| 166 | .new = generic_new, | 166 | .new = generic_new, |
| 167 | #if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT) | 167 | #ifdef CONFIG_NF_CONNTRACK_TIMEOUT |
| 168 | .ctnl_timeout = { | 168 | .ctnl_timeout = { |
| 169 | .nlattr_to_obj = generic_timeout_nlattr_to_obj, | 169 | .nlattr_to_obj = generic_timeout_nlattr_to_obj, |
| 170 | .obj_to_nlattr = generic_timeout_obj_to_nlattr, | 170 | .obj_to_nlattr = generic_timeout_obj_to_nlattr, |
| @@ -172,7 +172,7 @@ const struct nf_conntrack_l4proto nf_conntrack_l4proto_generic = | |||
| 172 | .obj_size = sizeof(unsigned int), | 172 | .obj_size = sizeof(unsigned int), |
| 173 | .nla_policy = generic_timeout_nla_policy, | 173 | .nla_policy = generic_timeout_nla_policy, |
| 174 | }, | 174 | }, |
| 175 | #endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ | 175 | #endif /* CONFIG_NF_CONNTRACK_TIMEOUT */ |
| 176 | .init_net = generic_init_net, | 176 | .init_net = generic_init_net, |
| 177 | .get_net_proto = generic_get_net_proto, | 177 | .get_net_proto = generic_get_net_proto, |
| 178 | }; | 178 | }; |
diff --git a/net/netfilter/nf_conntrack_proto_gre.c b/net/netfilter/nf_conntrack_proto_gre.c index d1632252bf5b..650eb4fba2c5 100644 --- a/net/netfilter/nf_conntrack_proto_gre.c +++ b/net/netfilter/nf_conntrack_proto_gre.c | |||
| @@ -285,7 +285,7 @@ static void gre_destroy(struct nf_conn *ct) | |||
| 285 | nf_ct_gre_keymap_destroy(master); | 285 | nf_ct_gre_keymap_destroy(master); |
| 286 | } | 286 | } |
| 287 | 287 | ||
| 288 | #if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT) | 288 | #ifdef CONFIG_NF_CONNTRACK_TIMEOUT |
| 289 | 289 | ||
| 290 | #include <linux/netfilter/nfnetlink.h> | 290 | #include <linux/netfilter/nfnetlink.h> |
| 291 | #include <linux/netfilter/nfnetlink_cttimeout.h> | 291 | #include <linux/netfilter/nfnetlink_cttimeout.h> |
| @@ -334,7 +334,7 @@ gre_timeout_nla_policy[CTA_TIMEOUT_GRE_MAX+1] = { | |||
| 334 | [CTA_TIMEOUT_GRE_UNREPLIED] = { .type = NLA_U32 }, | 334 | [CTA_TIMEOUT_GRE_UNREPLIED] = { .type = NLA_U32 }, |
| 335 | [CTA_TIMEOUT_GRE_REPLIED] = { .type = NLA_U32 }, | 335 | [CTA_TIMEOUT_GRE_REPLIED] = { .type = NLA_U32 }, |
| 336 | }; | 336 | }; |
| 337 | #endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ | 337 | #endif /* CONFIG_NF_CONNTRACK_TIMEOUT */ |
| 338 | 338 | ||
| 339 | static int gre_init_net(struct net *net, u_int16_t proto) | 339 | static int gre_init_net(struct net *net, u_int16_t proto) |
| 340 | { | 340 | { |
| @@ -367,7 +367,7 @@ static const struct nf_conntrack_l4proto nf_conntrack_l4proto_gre4 = { | |||
| 367 | .nlattr_to_tuple = nf_ct_port_nlattr_to_tuple, | 367 | .nlattr_to_tuple = nf_ct_port_nlattr_to_tuple, |
| 368 | .nla_policy = nf_ct_port_nla_policy, | 368 | .nla_policy = nf_ct_port_nla_policy, |
| 369 | #endif | 369 | #endif |
| 370 | #if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT) | 370 | #ifdef CONFIG_NF_CONNTRACK_TIMEOUT |
| 371 | .ctnl_timeout = { | 371 | .ctnl_timeout = { |
| 372 | .nlattr_to_obj = gre_timeout_nlattr_to_obj, | 372 | .nlattr_to_obj = gre_timeout_nlattr_to_obj, |
| 373 | .obj_to_nlattr = gre_timeout_obj_to_nlattr, | 373 | .obj_to_nlattr = gre_timeout_obj_to_nlattr, |
| @@ -375,7 +375,7 @@ static const struct nf_conntrack_l4proto nf_conntrack_l4proto_gre4 = { | |||
| 375 | .obj_size = sizeof(unsigned int) * GRE_CT_MAX, | 375 | .obj_size = sizeof(unsigned int) * GRE_CT_MAX, |
| 376 | .nla_policy = gre_timeout_nla_policy, | 376 | .nla_policy = gre_timeout_nla_policy, |
| 377 | }, | 377 | }, |
| 378 | #endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ | 378 | #endif /* CONFIG_NF_CONNTRACK_TIMEOUT */ |
| 379 | .net_id = &proto_gre_net_id, | 379 | .net_id = &proto_gre_net_id, |
| 380 | .init_net = gre_init_net, | 380 | .init_net = gre_init_net, |
| 381 | }; | 381 | }; |
diff --git a/net/netfilter/nf_conntrack_proto_icmp.c b/net/netfilter/nf_conntrack_proto_icmp.c index 036670b38282..43c7e1a217b9 100644 --- a/net/netfilter/nf_conntrack_proto_icmp.c +++ b/net/netfilter/nf_conntrack_proto_icmp.c | |||
| @@ -273,7 +273,7 @@ static unsigned int icmp_nlattr_tuple_size(void) | |||
| 273 | } | 273 | } |
| 274 | #endif | 274 | #endif |
| 275 | 275 | ||
| 276 | #if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT) | 276 | #ifdef CONFIG_NF_CONNTRACK_TIMEOUT |
| 277 | 277 | ||
| 278 | #include <linux/netfilter/nfnetlink.h> | 278 | #include <linux/netfilter/nfnetlink.h> |
| 279 | #include <linux/netfilter/nfnetlink_cttimeout.h> | 279 | #include <linux/netfilter/nfnetlink_cttimeout.h> |
| @@ -313,7 +313,7 @@ static const struct nla_policy | |||
| 313 | icmp_timeout_nla_policy[CTA_TIMEOUT_ICMP_MAX+1] = { | 313 | icmp_timeout_nla_policy[CTA_TIMEOUT_ICMP_MAX+1] = { |
| 314 | [CTA_TIMEOUT_ICMP_TIMEOUT] = { .type = NLA_U32 }, | 314 | [CTA_TIMEOUT_ICMP_TIMEOUT] = { .type = NLA_U32 }, |
| 315 | }; | 315 | }; |
| 316 | #endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ | 316 | #endif /* CONFIG_NF_CONNTRACK_TIMEOUT */ |
| 317 | 317 | ||
| 318 | #ifdef CONFIG_SYSCTL | 318 | #ifdef CONFIG_SYSCTL |
| 319 | static struct ctl_table icmp_sysctl_table[] = { | 319 | static struct ctl_table icmp_sysctl_table[] = { |
| @@ -374,7 +374,7 @@ const struct nf_conntrack_l4proto nf_conntrack_l4proto_icmp = | |||
| 374 | .nlattr_to_tuple = icmp_nlattr_to_tuple, | 374 | .nlattr_to_tuple = icmp_nlattr_to_tuple, |
| 375 | .nla_policy = icmp_nla_policy, | 375 | .nla_policy = icmp_nla_policy, |
| 376 | #endif | 376 | #endif |
| 377 | #if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT) | 377 | #ifdef CONFIG_NF_CONNTRACK_TIMEOUT |
| 378 | .ctnl_timeout = { | 378 | .ctnl_timeout = { |
| 379 | .nlattr_to_obj = icmp_timeout_nlattr_to_obj, | 379 | .nlattr_to_obj = icmp_timeout_nlattr_to_obj, |
| 380 | .obj_to_nlattr = icmp_timeout_obj_to_nlattr, | 380 | .obj_to_nlattr = icmp_timeout_obj_to_nlattr, |
| @@ -382,7 +382,7 @@ const struct nf_conntrack_l4proto nf_conntrack_l4proto_icmp = | |||
| 382 | .obj_size = sizeof(unsigned int), | 382 | .obj_size = sizeof(unsigned int), |
| 383 | .nla_policy = icmp_timeout_nla_policy, | 383 | .nla_policy = icmp_timeout_nla_policy, |
| 384 | }, | 384 | }, |
| 385 | #endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ | 385 | #endif /* CONFIG_NF_CONNTRACK_TIMEOUT */ |
| 386 | .init_net = icmp_init_net, | 386 | .init_net = icmp_init_net, |
| 387 | .get_net_proto = icmp_get_net_proto, | 387 | .get_net_proto = icmp_get_net_proto, |
| 388 | }; | 388 | }; |
diff --git a/net/netfilter/nf_conntrack_proto_icmpv6.c b/net/netfilter/nf_conntrack_proto_icmpv6.c index bed07b998a10..97e40f77d678 100644 --- a/net/netfilter/nf_conntrack_proto_icmpv6.c +++ b/net/netfilter/nf_conntrack_proto_icmpv6.c | |||
| @@ -274,7 +274,7 @@ static unsigned int icmpv6_nlattr_tuple_size(void) | |||
| 274 | } | 274 | } |
| 275 | #endif | 275 | #endif |
| 276 | 276 | ||
| 277 | #if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT) | 277 | #ifdef CONFIG_NF_CONNTRACK_TIMEOUT |
| 278 | 278 | ||
| 279 | #include <linux/netfilter/nfnetlink.h> | 279 | #include <linux/netfilter/nfnetlink.h> |
| 280 | #include <linux/netfilter/nfnetlink_cttimeout.h> | 280 | #include <linux/netfilter/nfnetlink_cttimeout.h> |
| @@ -314,7 +314,7 @@ static const struct nla_policy | |||
| 314 | icmpv6_timeout_nla_policy[CTA_TIMEOUT_ICMPV6_MAX+1] = { | 314 | icmpv6_timeout_nla_policy[CTA_TIMEOUT_ICMPV6_MAX+1] = { |
| 315 | [CTA_TIMEOUT_ICMPV6_TIMEOUT] = { .type = NLA_U32 }, | 315 | [CTA_TIMEOUT_ICMPV6_TIMEOUT] = { .type = NLA_U32 }, |
| 316 | }; | 316 | }; |
| 317 | #endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ | 317 | #endif /* CONFIG_NF_CONNTRACK_TIMEOUT */ |
| 318 | 318 | ||
| 319 | #ifdef CONFIG_SYSCTL | 319 | #ifdef CONFIG_SYSCTL |
| 320 | static struct ctl_table icmpv6_sysctl_table[] = { | 320 | static struct ctl_table icmpv6_sysctl_table[] = { |
| @@ -373,7 +373,7 @@ const struct nf_conntrack_l4proto nf_conntrack_l4proto_icmpv6 = | |||
| 373 | .nlattr_to_tuple = icmpv6_nlattr_to_tuple, | 373 | .nlattr_to_tuple = icmpv6_nlattr_to_tuple, |
| 374 | .nla_policy = icmpv6_nla_policy, | 374 | .nla_policy = icmpv6_nla_policy, |
| 375 | #endif | 375 | #endif |
| 376 | #if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT) | 376 | #ifdef CONFIG_NF_CONNTRACK_TIMEOUT |
| 377 | .ctnl_timeout = { | 377 | .ctnl_timeout = { |
| 378 | .nlattr_to_obj = icmpv6_timeout_nlattr_to_obj, | 378 | .nlattr_to_obj = icmpv6_timeout_nlattr_to_obj, |
| 379 | .obj_to_nlattr = icmpv6_timeout_obj_to_nlattr, | 379 | .obj_to_nlattr = icmpv6_timeout_obj_to_nlattr, |
| @@ -381,7 +381,7 @@ const struct nf_conntrack_l4proto nf_conntrack_l4proto_icmpv6 = | |||
| 381 | .obj_size = sizeof(unsigned int), | 381 | .obj_size = sizeof(unsigned int), |
| 382 | .nla_policy = icmpv6_timeout_nla_policy, | 382 | .nla_policy = icmpv6_timeout_nla_policy, |
| 383 | }, | 383 | }, |
| 384 | #endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ | 384 | #endif /* CONFIG_NF_CONNTRACK_TIMEOUT */ |
| 385 | .init_net = icmpv6_init_net, | 385 | .init_net = icmpv6_init_net, |
| 386 | .get_net_proto = icmpv6_get_net_proto, | 386 | .get_net_proto = icmpv6_get_net_proto, |
| 387 | }; | 387 | }; |
diff --git a/net/netfilter/nf_conntrack_proto_sctp.c b/net/netfilter/nf_conntrack_proto_sctp.c index 8d1e085fc14a..e4d738d34cd0 100644 --- a/net/netfilter/nf_conntrack_proto_sctp.c +++ b/net/netfilter/nf_conntrack_proto_sctp.c | |||
| @@ -591,7 +591,7 @@ static int nlattr_to_sctp(struct nlattr *cda[], struct nf_conn *ct) | |||
| 591 | } | 591 | } |
| 592 | #endif | 592 | #endif |
| 593 | 593 | ||
| 594 | #if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT) | 594 | #ifdef CONFIG_NF_CONNTRACK_TIMEOUT |
| 595 | 595 | ||
| 596 | #include <linux/netfilter/nfnetlink.h> | 596 | #include <linux/netfilter/nfnetlink.h> |
| 597 | #include <linux/netfilter/nfnetlink_cttimeout.h> | 597 | #include <linux/netfilter/nfnetlink_cttimeout.h> |
| @@ -613,6 +613,8 @@ static int sctp_timeout_nlattr_to_obj(struct nlattr *tb[], | |||
| 613 | timeouts[i] = ntohl(nla_get_be32(tb[i])) * HZ; | 613 | timeouts[i] = ntohl(nla_get_be32(tb[i])) * HZ; |
| 614 | } | 614 | } |
| 615 | } | 615 | } |
| 616 | |||
| 617 | timeouts[CTA_TIMEOUT_SCTP_UNSPEC] = timeouts[CTA_TIMEOUT_SCTP_CLOSED]; | ||
| 616 | return 0; | 618 | return 0; |
| 617 | } | 619 | } |
| 618 | 620 | ||
| @@ -644,7 +646,7 @@ sctp_timeout_nla_policy[CTA_TIMEOUT_SCTP_MAX+1] = { | |||
| 644 | [CTA_TIMEOUT_SCTP_HEARTBEAT_SENT] = { .type = NLA_U32 }, | 646 | [CTA_TIMEOUT_SCTP_HEARTBEAT_SENT] = { .type = NLA_U32 }, |
| 645 | [CTA_TIMEOUT_SCTP_HEARTBEAT_ACKED] = { .type = NLA_U32 }, | 647 | [CTA_TIMEOUT_SCTP_HEARTBEAT_ACKED] = { .type = NLA_U32 }, |
| 646 | }; | 648 | }; |
| 647 | #endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ | 649 | #endif /* CONFIG_NF_CONNTRACK_TIMEOUT */ |
| 648 | 650 | ||
| 649 | 651 | ||
| 650 | #ifdef CONFIG_SYSCTL | 652 | #ifdef CONFIG_SYSCTL |
| @@ -743,6 +745,11 @@ static int sctp_init_net(struct net *net, u_int16_t proto) | |||
| 743 | 745 | ||
| 744 | for (i = 0; i < SCTP_CONNTRACK_MAX; i++) | 746 | for (i = 0; i < SCTP_CONNTRACK_MAX; i++) |
| 745 | sn->timeouts[i] = sctp_timeouts[i]; | 747 | sn->timeouts[i] = sctp_timeouts[i]; |
| 748 | |||
| 749 | /* timeouts[0] is unused, init it so ->timeouts[0] contains | ||
| 750 | * 'new' timeout, like udp or icmp. | ||
| 751 | */ | ||
| 752 | sn->timeouts[0] = sctp_timeouts[SCTP_CONNTRACK_CLOSED]; | ||
| 746 | } | 753 | } |
| 747 | 754 | ||
| 748 | return sctp_kmemdup_sysctl_table(pn, sn); | 755 | return sctp_kmemdup_sysctl_table(pn, sn); |
| @@ -773,7 +780,7 @@ const struct nf_conntrack_l4proto nf_conntrack_l4proto_sctp4 = { | |||
| 773 | .nlattr_to_tuple = nf_ct_port_nlattr_to_tuple, | 780 | .nlattr_to_tuple = nf_ct_port_nlattr_to_tuple, |
| 774 | .nla_policy = nf_ct_port_nla_policy, | 781 | .nla_policy = nf_ct_port_nla_policy, |
| 775 | #endif | 782 | #endif |
| 776 | #if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT) | 783 | #ifdef CONFIG_NF_CONNTRACK_TIMEOUT |
| 777 | .ctnl_timeout = { | 784 | .ctnl_timeout = { |
| 778 | .nlattr_to_obj = sctp_timeout_nlattr_to_obj, | 785 | .nlattr_to_obj = sctp_timeout_nlattr_to_obj, |
| 779 | .obj_to_nlattr = sctp_timeout_obj_to_nlattr, | 786 | .obj_to_nlattr = sctp_timeout_obj_to_nlattr, |
| @@ -781,7 +788,7 @@ const struct nf_conntrack_l4proto nf_conntrack_l4proto_sctp4 = { | |||
| 781 | .obj_size = sizeof(unsigned int) * SCTP_CONNTRACK_MAX, | 788 | .obj_size = sizeof(unsigned int) * SCTP_CONNTRACK_MAX, |
| 782 | .nla_policy = sctp_timeout_nla_policy, | 789 | .nla_policy = sctp_timeout_nla_policy, |
| 783 | }, | 790 | }, |
| 784 | #endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ | 791 | #endif /* CONFIG_NF_CONNTRACK_TIMEOUT */ |
| 785 | .init_net = sctp_init_net, | 792 | .init_net = sctp_init_net, |
| 786 | .get_net_proto = sctp_get_net_proto, | 793 | .get_net_proto = sctp_get_net_proto, |
| 787 | }; | 794 | }; |
| @@ -806,7 +813,8 @@ const struct nf_conntrack_l4proto nf_conntrack_l4proto_sctp6 = { | |||
| 806 | .nlattr_tuple_size = nf_ct_port_nlattr_tuple_size, | 813 | .nlattr_tuple_size = nf_ct_port_nlattr_tuple_size, |
| 807 | .nlattr_to_tuple = nf_ct_port_nlattr_to_tuple, | 814 | .nlattr_to_tuple = nf_ct_port_nlattr_to_tuple, |
| 808 | .nla_policy = nf_ct_port_nla_policy, | 815 | .nla_policy = nf_ct_port_nla_policy, |
| 809 | #if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT) | 816 | #endif |
| 817 | #ifdef CONFIG_NF_CONNTRACK_TIMEOUT | ||
| 810 | .ctnl_timeout = { | 818 | .ctnl_timeout = { |
| 811 | .nlattr_to_obj = sctp_timeout_nlattr_to_obj, | 819 | .nlattr_to_obj = sctp_timeout_nlattr_to_obj, |
| 812 | .obj_to_nlattr = sctp_timeout_obj_to_nlattr, | 820 | .obj_to_nlattr = sctp_timeout_obj_to_nlattr, |
| @@ -814,8 +822,7 @@ const struct nf_conntrack_l4proto nf_conntrack_l4proto_sctp6 = { | |||
| 814 | .obj_size = sizeof(unsigned int) * SCTP_CONNTRACK_MAX, | 822 | .obj_size = sizeof(unsigned int) * SCTP_CONNTRACK_MAX, |
| 815 | .nla_policy = sctp_timeout_nla_policy, | 823 | .nla_policy = sctp_timeout_nla_policy, |
| 816 | }, | 824 | }, |
| 817 | #endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ | 825 | #endif /* CONFIG_NF_CONNTRACK_TIMEOUT */ |
| 818 | #endif | ||
| 819 | .init_net = sctp_init_net, | 826 | .init_net = sctp_init_net, |
| 820 | .get_net_proto = sctp_get_net_proto, | 827 | .get_net_proto = sctp_get_net_proto, |
| 821 | }; | 828 | }; |
diff --git a/net/netfilter/nf_conntrack_proto_tcp.c b/net/netfilter/nf_conntrack_proto_tcp.c index d80d322b9d8b..b4bdf9eda7b7 100644 --- a/net/netfilter/nf_conntrack_proto_tcp.c +++ b/net/netfilter/nf_conntrack_proto_tcp.c | |||
| @@ -1279,7 +1279,7 @@ static unsigned int tcp_nlattr_tuple_size(void) | |||
| 1279 | } | 1279 | } |
| 1280 | #endif | 1280 | #endif |
| 1281 | 1281 | ||
| 1282 | #if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT) | 1282 | #ifdef CONFIG_NF_CONNTRACK_TIMEOUT |
| 1283 | 1283 | ||
| 1284 | #include <linux/netfilter/nfnetlink.h> | 1284 | #include <linux/netfilter/nfnetlink.h> |
| 1285 | #include <linux/netfilter/nfnetlink_cttimeout.h> | 1285 | #include <linux/netfilter/nfnetlink_cttimeout.h> |
| @@ -1301,6 +1301,7 @@ static int tcp_timeout_nlattr_to_obj(struct nlattr *tb[], | |||
| 1301 | timeouts[TCP_CONNTRACK_SYN_SENT] = | 1301 | timeouts[TCP_CONNTRACK_SYN_SENT] = |
| 1302 | ntohl(nla_get_be32(tb[CTA_TIMEOUT_TCP_SYN_SENT]))*HZ; | 1302 | ntohl(nla_get_be32(tb[CTA_TIMEOUT_TCP_SYN_SENT]))*HZ; |
| 1303 | } | 1303 | } |
| 1304 | |||
| 1304 | if (tb[CTA_TIMEOUT_TCP_SYN_RECV]) { | 1305 | if (tb[CTA_TIMEOUT_TCP_SYN_RECV]) { |
| 1305 | timeouts[TCP_CONNTRACK_SYN_RECV] = | 1306 | timeouts[TCP_CONNTRACK_SYN_RECV] = |
| 1306 | ntohl(nla_get_be32(tb[CTA_TIMEOUT_TCP_SYN_RECV]))*HZ; | 1307 | ntohl(nla_get_be32(tb[CTA_TIMEOUT_TCP_SYN_RECV]))*HZ; |
| @@ -1341,6 +1342,8 @@ static int tcp_timeout_nlattr_to_obj(struct nlattr *tb[], | |||
| 1341 | timeouts[TCP_CONNTRACK_UNACK] = | 1342 | timeouts[TCP_CONNTRACK_UNACK] = |
| 1342 | ntohl(nla_get_be32(tb[CTA_TIMEOUT_TCP_UNACK]))*HZ; | 1343 | ntohl(nla_get_be32(tb[CTA_TIMEOUT_TCP_UNACK]))*HZ; |
| 1343 | } | 1344 | } |
| 1345 | |||
| 1346 | timeouts[CTA_TIMEOUT_TCP_UNSPEC] = timeouts[CTA_TIMEOUT_TCP_SYN_SENT]; | ||
| 1344 | return 0; | 1347 | return 0; |
| 1345 | } | 1348 | } |
| 1346 | 1349 | ||
| @@ -1391,7 +1394,7 @@ static const struct nla_policy tcp_timeout_nla_policy[CTA_TIMEOUT_TCP_MAX+1] = { | |||
| 1391 | [CTA_TIMEOUT_TCP_RETRANS] = { .type = NLA_U32 }, | 1394 | [CTA_TIMEOUT_TCP_RETRANS] = { .type = NLA_U32 }, |
| 1392 | [CTA_TIMEOUT_TCP_UNACK] = { .type = NLA_U32 }, | 1395 | [CTA_TIMEOUT_TCP_UNACK] = { .type = NLA_U32 }, |
| 1393 | }; | 1396 | }; |
| 1394 | #endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ | 1397 | #endif /* CONFIG_NF_CONNTRACK_TIMEOUT */ |
| 1395 | 1398 | ||
| 1396 | #ifdef CONFIG_SYSCTL | 1399 | #ifdef CONFIG_SYSCTL |
| 1397 | static struct ctl_table tcp_sysctl_table[] = { | 1400 | static struct ctl_table tcp_sysctl_table[] = { |
| @@ -1518,6 +1521,10 @@ static int tcp_init_net(struct net *net, u_int16_t proto) | |||
| 1518 | for (i = 0; i < TCP_CONNTRACK_TIMEOUT_MAX; i++) | 1521 | for (i = 0; i < TCP_CONNTRACK_TIMEOUT_MAX; i++) |
| 1519 | tn->timeouts[i] = tcp_timeouts[i]; | 1522 | tn->timeouts[i] = tcp_timeouts[i]; |
| 1520 | 1523 | ||
| 1524 | /* timeouts[0] is unused, make it same as SYN_SENT so | ||
| 1525 | * ->timeouts[0] contains 'new' timeout, like udp or icmp. | ||
| 1526 | */ | ||
| 1527 | tn->timeouts[0] = tcp_timeouts[TCP_CONNTRACK_SYN_SENT]; | ||
| 1521 | tn->tcp_loose = nf_ct_tcp_loose; | 1528 | tn->tcp_loose = nf_ct_tcp_loose; |
| 1522 | tn->tcp_be_liberal = nf_ct_tcp_be_liberal; | 1529 | tn->tcp_be_liberal = nf_ct_tcp_be_liberal; |
| 1523 | tn->tcp_max_retrans = nf_ct_tcp_max_retrans; | 1530 | tn->tcp_max_retrans = nf_ct_tcp_max_retrans; |
| @@ -1551,7 +1558,7 @@ const struct nf_conntrack_l4proto nf_conntrack_l4proto_tcp4 = | |||
| 1551 | .nlattr_size = TCP_NLATTR_SIZE, | 1558 | .nlattr_size = TCP_NLATTR_SIZE, |
| 1552 | .nla_policy = nf_ct_port_nla_policy, | 1559 | .nla_policy = nf_ct_port_nla_policy, |
| 1553 | #endif | 1560 | #endif |
| 1554 | #if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT) | 1561 | #ifdef CONFIG_NF_CONNTRACK_TIMEOUT |
| 1555 | .ctnl_timeout = { | 1562 | .ctnl_timeout = { |
| 1556 | .nlattr_to_obj = tcp_timeout_nlattr_to_obj, | 1563 | .nlattr_to_obj = tcp_timeout_nlattr_to_obj, |
| 1557 | .obj_to_nlattr = tcp_timeout_obj_to_nlattr, | 1564 | .obj_to_nlattr = tcp_timeout_obj_to_nlattr, |
| @@ -1560,7 +1567,7 @@ const struct nf_conntrack_l4proto nf_conntrack_l4proto_tcp4 = | |||
| 1560 | TCP_CONNTRACK_TIMEOUT_MAX, | 1567 | TCP_CONNTRACK_TIMEOUT_MAX, |
| 1561 | .nla_policy = tcp_timeout_nla_policy, | 1568 | .nla_policy = tcp_timeout_nla_policy, |
| 1562 | }, | 1569 | }, |
| 1563 | #endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ | 1570 | #endif /* CONFIG_NF_CONNTRACK_TIMEOUT */ |
| 1564 | .init_net = tcp_init_net, | 1571 | .init_net = tcp_init_net, |
| 1565 | .get_net_proto = tcp_get_net_proto, | 1572 | .get_net_proto = tcp_get_net_proto, |
| 1566 | }; | 1573 | }; |
| @@ -1586,7 +1593,7 @@ const struct nf_conntrack_l4proto nf_conntrack_l4proto_tcp6 = | |||
| 1586 | .nlattr_tuple_size = tcp_nlattr_tuple_size, | 1593 | .nlattr_tuple_size = tcp_nlattr_tuple_size, |
| 1587 | .nla_policy = nf_ct_port_nla_policy, | 1594 | .nla_policy = nf_ct_port_nla_policy, |
| 1588 | #endif | 1595 | #endif |
| 1589 | #if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT) | 1596 | #ifdef CONFIG_NF_CONNTRACK_TIMEOUT |
| 1590 | .ctnl_timeout = { | 1597 | .ctnl_timeout = { |
| 1591 | .nlattr_to_obj = tcp_timeout_nlattr_to_obj, | 1598 | .nlattr_to_obj = tcp_timeout_nlattr_to_obj, |
| 1592 | .obj_to_nlattr = tcp_timeout_obj_to_nlattr, | 1599 | .obj_to_nlattr = tcp_timeout_obj_to_nlattr, |
| @@ -1595,7 +1602,7 @@ const struct nf_conntrack_l4proto nf_conntrack_l4proto_tcp6 = | |||
| 1595 | TCP_CONNTRACK_TIMEOUT_MAX, | 1602 | TCP_CONNTRACK_TIMEOUT_MAX, |
| 1596 | .nla_policy = tcp_timeout_nla_policy, | 1603 | .nla_policy = tcp_timeout_nla_policy, |
| 1597 | }, | 1604 | }, |
| 1598 | #endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ | 1605 | #endif /* CONFIG_NF_CONNTRACK_TIMEOUT */ |
| 1599 | .init_net = tcp_init_net, | 1606 | .init_net = tcp_init_net, |
| 1600 | .get_net_proto = tcp_get_net_proto, | 1607 | .get_net_proto = tcp_get_net_proto, |
| 1601 | }; | 1608 | }; |
diff --git a/net/netfilter/nf_conntrack_proto_udp.c b/net/netfilter/nf_conntrack_proto_udp.c index 7a1b8988a931..3065fb8ef91b 100644 --- a/net/netfilter/nf_conntrack_proto_udp.c +++ b/net/netfilter/nf_conntrack_proto_udp.c | |||
| @@ -171,7 +171,7 @@ static int udp_error(struct net *net, struct nf_conn *tmpl, struct sk_buff *skb, | |||
| 171 | return NF_ACCEPT; | 171 | return NF_ACCEPT; |
| 172 | } | 172 | } |
| 173 | 173 | ||
| 174 | #if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT) | 174 | #ifdef CONFIG_NF_CONNTRACK_TIMEOUT |
| 175 | 175 | ||
| 176 | #include <linux/netfilter/nfnetlink.h> | 176 | #include <linux/netfilter/nfnetlink.h> |
| 177 | #include <linux/netfilter/nfnetlink_cttimeout.h> | 177 | #include <linux/netfilter/nfnetlink_cttimeout.h> |
| @@ -221,7 +221,7 @@ udp_timeout_nla_policy[CTA_TIMEOUT_UDP_MAX+1] = { | |||
| 221 | [CTA_TIMEOUT_UDP_UNREPLIED] = { .type = NLA_U32 }, | 221 | [CTA_TIMEOUT_UDP_UNREPLIED] = { .type = NLA_U32 }, |
| 222 | [CTA_TIMEOUT_UDP_REPLIED] = { .type = NLA_U32 }, | 222 | [CTA_TIMEOUT_UDP_REPLIED] = { .type = NLA_U32 }, |
| 223 | }; | 223 | }; |
| 224 | #endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ | 224 | #endif /* CONFIG_NF_CONNTRACK_TIMEOUT */ |
| 225 | 225 | ||
| 226 | #ifdef CONFIG_SYSCTL | 226 | #ifdef CONFIG_SYSCTL |
| 227 | static struct ctl_table udp_sysctl_table[] = { | 227 | static struct ctl_table udp_sysctl_table[] = { |
| @@ -292,7 +292,7 @@ const struct nf_conntrack_l4proto nf_conntrack_l4proto_udp4 = | |||
| 292 | .nlattr_tuple_size = nf_ct_port_nlattr_tuple_size, | 292 | .nlattr_tuple_size = nf_ct_port_nlattr_tuple_size, |
| 293 | .nla_policy = nf_ct_port_nla_policy, | 293 | .nla_policy = nf_ct_port_nla_policy, |
| 294 | #endif | 294 | #endif |
| 295 | #if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT) | 295 | #ifdef CONFIG_NF_CONNTRACK_TIMEOUT |
| 296 | .ctnl_timeout = { | 296 | .ctnl_timeout = { |
| 297 | .nlattr_to_obj = udp_timeout_nlattr_to_obj, | 297 | .nlattr_to_obj = udp_timeout_nlattr_to_obj, |
| 298 | .obj_to_nlattr = udp_timeout_obj_to_nlattr, | 298 | .obj_to_nlattr = udp_timeout_obj_to_nlattr, |
| @@ -300,7 +300,7 @@ const struct nf_conntrack_l4proto nf_conntrack_l4proto_udp4 = | |||
| 300 | .obj_size = sizeof(unsigned int) * CTA_TIMEOUT_UDP_MAX, | 300 | .obj_size = sizeof(unsigned int) * CTA_TIMEOUT_UDP_MAX, |
| 301 | .nla_policy = udp_timeout_nla_policy, | 301 | .nla_policy = udp_timeout_nla_policy, |
| 302 | }, | 302 | }, |
| 303 | #endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ | 303 | #endif /* CONFIG_NF_CONNTRACK_TIMEOUT */ |
| 304 | .init_net = udp_init_net, | 304 | .init_net = udp_init_net, |
| 305 | .get_net_proto = udp_get_net_proto, | 305 | .get_net_proto = udp_get_net_proto, |
| 306 | }; | 306 | }; |
| @@ -321,7 +321,7 @@ const struct nf_conntrack_l4proto nf_conntrack_l4proto_udplite4 = | |||
| 321 | .nlattr_tuple_size = nf_ct_port_nlattr_tuple_size, | 321 | .nlattr_tuple_size = nf_ct_port_nlattr_tuple_size, |
| 322 | .nla_policy = nf_ct_port_nla_policy, | 322 | .nla_policy = nf_ct_port_nla_policy, |
| 323 | #endif | 323 | #endif |
| 324 | #if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT) | 324 | #ifdef CONFIG_NF_CONNTRACK_TIMEOUT |
| 325 | .ctnl_timeout = { | 325 | .ctnl_timeout = { |
| 326 | .nlattr_to_obj = udp_timeout_nlattr_to_obj, | 326 | .nlattr_to_obj = udp_timeout_nlattr_to_obj, |
| 327 | .obj_to_nlattr = udp_timeout_obj_to_nlattr, | 327 | .obj_to_nlattr = udp_timeout_obj_to_nlattr, |
| @@ -329,7 +329,7 @@ const struct nf_conntrack_l4proto nf_conntrack_l4proto_udplite4 = | |||
| 329 | .obj_size = sizeof(unsigned int) * CTA_TIMEOUT_UDP_MAX, | 329 | .obj_size = sizeof(unsigned int) * CTA_TIMEOUT_UDP_MAX, |
| 330 | .nla_policy = udp_timeout_nla_policy, | 330 | .nla_policy = udp_timeout_nla_policy, |
| 331 | }, | 331 | }, |
| 332 | #endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ | 332 | #endif /* CONFIG_NF_CONNTRACK_TIMEOUT */ |
| 333 | .init_net = udp_init_net, | 333 | .init_net = udp_init_net, |
| 334 | .get_net_proto = udp_get_net_proto, | 334 | .get_net_proto = udp_get_net_proto, |
| 335 | }; | 335 | }; |
| @@ -350,7 +350,7 @@ const struct nf_conntrack_l4proto nf_conntrack_l4proto_udp6 = | |||
| 350 | .nlattr_tuple_size = nf_ct_port_nlattr_tuple_size, | 350 | .nlattr_tuple_size = nf_ct_port_nlattr_tuple_size, |
| 351 | .nla_policy = nf_ct_port_nla_policy, | 351 | .nla_policy = nf_ct_port_nla_policy, |
| 352 | #endif | 352 | #endif |
| 353 | #if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT) | 353 | #ifdef CONFIG_NF_CONNTRACK_TIMEOUT |
| 354 | .ctnl_timeout = { | 354 | .ctnl_timeout = { |
| 355 | .nlattr_to_obj = udp_timeout_nlattr_to_obj, | 355 | .nlattr_to_obj = udp_timeout_nlattr_to_obj, |
| 356 | .obj_to_nlattr = udp_timeout_obj_to_nlattr, | 356 | .obj_to_nlattr = udp_timeout_obj_to_nlattr, |
| @@ -358,7 +358,7 @@ const struct nf_conntrack_l4proto nf_conntrack_l4proto_udp6 = | |||
| 358 | .obj_size = sizeof(unsigned int) * CTA_TIMEOUT_UDP_MAX, | 358 | .obj_size = sizeof(unsigned int) * CTA_TIMEOUT_UDP_MAX, |
| 359 | .nla_policy = udp_timeout_nla_policy, | 359 | .nla_policy = udp_timeout_nla_policy, |
| 360 | }, | 360 | }, |
| 361 | #endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ | 361 | #endif /* CONFIG_NF_CONNTRACK_TIMEOUT */ |
| 362 | .init_net = udp_init_net, | 362 | .init_net = udp_init_net, |
| 363 | .get_net_proto = udp_get_net_proto, | 363 | .get_net_proto = udp_get_net_proto, |
| 364 | }; | 364 | }; |
| @@ -379,7 +379,7 @@ const struct nf_conntrack_l4proto nf_conntrack_l4proto_udplite6 = | |||
| 379 | .nlattr_tuple_size = nf_ct_port_nlattr_tuple_size, | 379 | .nlattr_tuple_size = nf_ct_port_nlattr_tuple_size, |
| 380 | .nla_policy = nf_ct_port_nla_policy, | 380 | .nla_policy = nf_ct_port_nla_policy, |
| 381 | #endif | 381 | #endif |
| 382 | #if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT) | 382 | #ifdef CONFIG_NF_CONNTRACK_TIMEOUT |
| 383 | .ctnl_timeout = { | 383 | .ctnl_timeout = { |
| 384 | .nlattr_to_obj = udp_timeout_nlattr_to_obj, | 384 | .nlattr_to_obj = udp_timeout_nlattr_to_obj, |
| 385 | .obj_to_nlattr = udp_timeout_obj_to_nlattr, | 385 | .obj_to_nlattr = udp_timeout_obj_to_nlattr, |
| @@ -387,10 +387,9 @@ const struct nf_conntrack_l4proto nf_conntrack_l4proto_udplite6 = | |||
| 387 | .obj_size = sizeof(unsigned int) * CTA_TIMEOUT_UDP_MAX, | 387 | .obj_size = sizeof(unsigned int) * CTA_TIMEOUT_UDP_MAX, |
| 388 | .nla_policy = udp_timeout_nla_policy, | 388 | .nla_policy = udp_timeout_nla_policy, |
| 389 | }, | 389 | }, |
| 390 | #endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ | 390 | #endif /* CONFIG_NF_CONNTRACK_TIMEOUT */ |
| 391 | .init_net = udp_init_net, | 391 | .init_net = udp_init_net, |
| 392 | .get_net_proto = udp_get_net_proto, | 392 | .get_net_proto = udp_get_net_proto, |
| 393 | }; | 393 | }; |
| 394 | EXPORT_SYMBOL_GPL(nf_conntrack_l4proto_udplite6); | 394 | EXPORT_SYMBOL_GPL(nf_conntrack_l4proto_udplite6); |
| 395 | #endif | 395 | #endif |
| 396 | #include <net/netfilter/nf_conntrack_timeout.h> | ||
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c index 1dca5683f59f..2cfb173cd0b2 100644 --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c | |||
| @@ -4637,6 +4637,7 @@ static int nft_flush_set(const struct nft_ctx *ctx, | |||
| 4637 | } | 4637 | } |
| 4638 | set->ndeact++; | 4638 | set->ndeact++; |
| 4639 | 4639 | ||
| 4640 | nft_set_elem_deactivate(ctx->net, set, elem); | ||
| 4640 | nft_trans_elem_set(trans) = set; | 4641 | nft_trans_elem_set(trans) = set; |
| 4641 | nft_trans_elem(trans) = *elem; | 4642 | nft_trans_elem(trans) = *elem; |
| 4642 | list_add_tail(&trans->list, &ctx->net->nft.commit_list); | 4643 | list_add_tail(&trans->list, &ctx->net->nft.commit_list); |
diff --git a/net/netfilter/nfnetlink_cttimeout.c b/net/netfilter/nfnetlink_cttimeout.c index d46a236cdf31..a30f8ba4b89a 100644 --- a/net/netfilter/nfnetlink_cttimeout.c +++ b/net/netfilter/nfnetlink_cttimeout.c | |||
| @@ -489,8 +489,8 @@ err: | |||
| 489 | return err; | 489 | return err; |
| 490 | } | 490 | } |
| 491 | 491 | ||
| 492 | static struct ctnl_timeout * | 492 | static struct nf_ct_timeout *ctnl_timeout_find_get(struct net *net, |
| 493 | ctnl_timeout_find_get(struct net *net, const char *name) | 493 | const char *name) |
| 494 | { | 494 | { |
| 495 | struct ctnl_timeout *timeout, *matching = NULL; | 495 | struct ctnl_timeout *timeout, *matching = NULL; |
| 496 | 496 | ||
| @@ -509,7 +509,7 @@ ctnl_timeout_find_get(struct net *net, const char *name) | |||
| 509 | break; | 509 | break; |
| 510 | } | 510 | } |
| 511 | err: | 511 | err: |
| 512 | return matching; | 512 | return matching ? &matching->timeout : NULL; |
| 513 | } | 513 | } |
| 514 | 514 | ||
| 515 | static void ctnl_timeout_put(struct nf_ct_timeout *t) | 515 | static void ctnl_timeout_put(struct nf_ct_timeout *t) |
diff --git a/net/netfilter/nfnetlink_queue.c b/net/netfilter/nfnetlink_queue.c index ea4ba551abb2..d33094f4ec41 100644 --- a/net/netfilter/nfnetlink_queue.c +++ b/net/netfilter/nfnetlink_queue.c | |||
| @@ -233,6 +233,7 @@ static void nfqnl_reinject(struct nf_queue_entry *entry, unsigned int verdict) | |||
| 233 | int err; | 233 | int err; |
| 234 | 234 | ||
| 235 | if (verdict == NF_ACCEPT || | 235 | if (verdict == NF_ACCEPT || |
| 236 | verdict == NF_REPEAT || | ||
| 236 | verdict == NF_STOP) { | 237 | verdict == NF_STOP) { |
| 237 | rcu_read_lock(); | 238 | rcu_read_lock(); |
| 238 | ct_hook = rcu_dereference(nf_ct_hook); | 239 | ct_hook = rcu_dereference(nf_ct_hook); |
diff --git a/net/netfilter/nft_ct.c b/net/netfilter/nft_ct.c index 26a8baebd072..5dd87748afa8 100644 --- a/net/netfilter/nft_ct.c +++ b/net/netfilter/nft_ct.c | |||
| @@ -799,7 +799,7 @@ err: | |||
| 799 | } | 799 | } |
| 800 | 800 | ||
| 801 | struct nft_ct_timeout_obj { | 801 | struct nft_ct_timeout_obj { |
| 802 | struct nf_conn *tmpl; | 802 | struct nf_ct_timeout *timeout; |
| 803 | u8 l4proto; | 803 | u8 l4proto; |
| 804 | }; | 804 | }; |
| 805 | 805 | ||
| @@ -809,26 +809,42 @@ static void nft_ct_timeout_obj_eval(struct nft_object *obj, | |||
| 809 | { | 809 | { |
| 810 | const struct nft_ct_timeout_obj *priv = nft_obj_data(obj); | 810 | const struct nft_ct_timeout_obj *priv = nft_obj_data(obj); |
| 811 | struct nf_conn *ct = (struct nf_conn *)skb_nfct(pkt->skb); | 811 | struct nf_conn *ct = (struct nf_conn *)skb_nfct(pkt->skb); |
| 812 | struct sk_buff *skb = pkt->skb; | 812 | struct nf_conn_timeout *timeout; |
| 813 | const unsigned int *values; | ||
| 814 | |||
| 815 | if (priv->l4proto != pkt->tprot) | ||
| 816 | return; | ||
| 813 | 817 | ||
| 814 | if (ct || | 818 | if (!ct || nf_ct_is_template(ct) || nf_ct_is_confirmed(ct)) |
| 815 | priv->l4proto != pkt->tprot) | ||
| 816 | return; | 819 | return; |
| 817 | 820 | ||
| 818 | nf_ct_set(skb, priv->tmpl, IP_CT_NEW); | 821 | timeout = nf_ct_timeout_find(ct); |
| 822 | if (!timeout) { | ||
| 823 | timeout = nf_ct_timeout_ext_add(ct, priv->timeout, GFP_ATOMIC); | ||
| 824 | if (!timeout) { | ||
| 825 | regs->verdict.code = NF_DROP; | ||
| 826 | return; | ||
| 827 | } | ||
| 828 | } | ||
| 829 | |||
| 830 | rcu_assign_pointer(timeout->timeout, priv->timeout); | ||
| 831 | |||
| 832 | /* adjust the timeout as per 'new' state. ct is unconfirmed, | ||
| 833 | * so the current timestamp must not be added. | ||
| 834 | */ | ||
| 835 | values = nf_ct_timeout_data(timeout); | ||
| 836 | if (values) | ||
| 837 | nf_ct_refresh(ct, pkt->skb, values[0]); | ||
| 819 | } | 838 | } |
| 820 | 839 | ||
| 821 | static int nft_ct_timeout_obj_init(const struct nft_ctx *ctx, | 840 | static int nft_ct_timeout_obj_init(const struct nft_ctx *ctx, |
| 822 | const struct nlattr * const tb[], | 841 | const struct nlattr * const tb[], |
| 823 | struct nft_object *obj) | 842 | struct nft_object *obj) |
| 824 | { | 843 | { |
| 825 | const struct nf_conntrack_zone *zone = &nf_ct_zone_dflt; | ||
| 826 | struct nft_ct_timeout_obj *priv = nft_obj_data(obj); | 844 | struct nft_ct_timeout_obj *priv = nft_obj_data(obj); |
| 827 | const struct nf_conntrack_l4proto *l4proto; | 845 | const struct nf_conntrack_l4proto *l4proto; |
| 828 | struct nf_conn_timeout *timeout_ext; | ||
| 829 | struct nf_ct_timeout *timeout; | 846 | struct nf_ct_timeout *timeout; |
| 830 | int l3num = ctx->family; | 847 | int l3num = ctx->family; |
| 831 | struct nf_conn *tmpl; | ||
| 832 | __u8 l4num; | 848 | __u8 l4num; |
| 833 | int ret; | 849 | int ret; |
| 834 | 850 | ||
| @@ -863,28 +879,14 @@ static int nft_ct_timeout_obj_init(const struct nft_ctx *ctx, | |||
| 863 | 879 | ||
| 864 | timeout->l3num = l3num; | 880 | timeout->l3num = l3num; |
| 865 | timeout->l4proto = l4proto; | 881 | timeout->l4proto = l4proto; |
| 866 | tmpl = nf_ct_tmpl_alloc(ctx->net, zone, GFP_ATOMIC); | ||
| 867 | if (!tmpl) { | ||
| 868 | ret = -ENOMEM; | ||
| 869 | goto err_free_timeout; | ||
| 870 | } | ||
| 871 | |||
| 872 | timeout_ext = nf_ct_timeout_ext_add(tmpl, timeout, GFP_ATOMIC); | ||
| 873 | if (!timeout_ext) { | ||
| 874 | ret = -ENOMEM; | ||
| 875 | goto err_free_tmpl; | ||
| 876 | } | ||
| 877 | 882 | ||
| 878 | ret = nf_ct_netns_get(ctx->net, ctx->family); | 883 | ret = nf_ct_netns_get(ctx->net, ctx->family); |
| 879 | if (ret < 0) | 884 | if (ret < 0) |
| 880 | goto err_free_tmpl; | 885 | goto err_free_timeout; |
| 881 | |||
| 882 | priv->tmpl = tmpl; | ||
| 883 | 886 | ||
| 887 | priv->timeout = timeout; | ||
| 884 | return 0; | 888 | return 0; |
| 885 | 889 | ||
| 886 | err_free_tmpl: | ||
| 887 | nf_ct_tmpl_free(tmpl); | ||
| 888 | err_free_timeout: | 890 | err_free_timeout: |
| 889 | kfree(timeout); | 891 | kfree(timeout); |
| 890 | err_proto_put: | 892 | err_proto_put: |
| @@ -896,22 +898,19 @@ static void nft_ct_timeout_obj_destroy(const struct nft_ctx *ctx, | |||
| 896 | struct nft_object *obj) | 898 | struct nft_object *obj) |
| 897 | { | 899 | { |
| 898 | struct nft_ct_timeout_obj *priv = nft_obj_data(obj); | 900 | struct nft_ct_timeout_obj *priv = nft_obj_data(obj); |
| 899 | struct nf_conn_timeout *t = nf_ct_timeout_find(priv->tmpl); | 901 | struct nf_ct_timeout *timeout = priv->timeout; |
| 900 | struct nf_ct_timeout *timeout; | ||
| 901 | 902 | ||
| 902 | timeout = rcu_dereference_raw(t->timeout); | ||
| 903 | nf_ct_untimeout(ctx->net, timeout); | 903 | nf_ct_untimeout(ctx->net, timeout); |
| 904 | nf_ct_l4proto_put(timeout->l4proto); | 904 | nf_ct_l4proto_put(timeout->l4proto); |
| 905 | nf_ct_netns_put(ctx->net, ctx->family); | 905 | nf_ct_netns_put(ctx->net, ctx->family); |
| 906 | nf_ct_tmpl_free(priv->tmpl); | 906 | kfree(priv->timeout); |
| 907 | } | 907 | } |
| 908 | 908 | ||
| 909 | static int nft_ct_timeout_obj_dump(struct sk_buff *skb, | 909 | static int nft_ct_timeout_obj_dump(struct sk_buff *skb, |
| 910 | struct nft_object *obj, bool reset) | 910 | struct nft_object *obj, bool reset) |
| 911 | { | 911 | { |
| 912 | const struct nft_ct_timeout_obj *priv = nft_obj_data(obj); | 912 | const struct nft_ct_timeout_obj *priv = nft_obj_data(obj); |
| 913 | const struct nf_conn_timeout *t = nf_ct_timeout_find(priv->tmpl); | 913 | const struct nf_ct_timeout *timeout = priv->timeout; |
| 914 | const struct nf_ct_timeout *timeout = rcu_dereference_raw(t->timeout); | ||
| 915 | struct nlattr *nest_params; | 914 | struct nlattr *nest_params; |
| 916 | int ret; | 915 | int ret; |
| 917 | 916 | ||
diff --git a/net/netfilter/xt_CHECKSUM.c b/net/netfilter/xt_CHECKSUM.c index 9f4151ec3e06..6c7aa6a0a0d2 100644 --- a/net/netfilter/xt_CHECKSUM.c +++ b/net/netfilter/xt_CHECKSUM.c | |||
| @@ -16,6 +16,9 @@ | |||
| 16 | #include <linux/netfilter/x_tables.h> | 16 | #include <linux/netfilter/x_tables.h> |
| 17 | #include <linux/netfilter/xt_CHECKSUM.h> | 17 | #include <linux/netfilter/xt_CHECKSUM.h> |
| 18 | 18 | ||
| 19 | #include <linux/netfilter_ipv4/ip_tables.h> | ||
| 20 | #include <linux/netfilter_ipv6/ip6_tables.h> | ||
| 21 | |||
| 19 | MODULE_LICENSE("GPL"); | 22 | MODULE_LICENSE("GPL"); |
| 20 | MODULE_AUTHOR("Michael S. Tsirkin <mst@redhat.com>"); | 23 | MODULE_AUTHOR("Michael S. Tsirkin <mst@redhat.com>"); |
| 21 | MODULE_DESCRIPTION("Xtables: checksum modification"); | 24 | MODULE_DESCRIPTION("Xtables: checksum modification"); |
| @@ -25,7 +28,7 @@ MODULE_ALIAS("ip6t_CHECKSUM"); | |||
| 25 | static unsigned int | 28 | static unsigned int |
| 26 | checksum_tg(struct sk_buff *skb, const struct xt_action_param *par) | 29 | checksum_tg(struct sk_buff *skb, const struct xt_action_param *par) |
| 27 | { | 30 | { |
| 28 | if (skb->ip_summed == CHECKSUM_PARTIAL) | 31 | if (skb->ip_summed == CHECKSUM_PARTIAL && !skb_is_gso(skb)) |
| 29 | skb_checksum_help(skb); | 32 | skb_checksum_help(skb); |
| 30 | 33 | ||
| 31 | return XT_CONTINUE; | 34 | return XT_CONTINUE; |
| @@ -34,6 +37,8 @@ checksum_tg(struct sk_buff *skb, const struct xt_action_param *par) | |||
| 34 | static int checksum_tg_check(const struct xt_tgchk_param *par) | 37 | static int checksum_tg_check(const struct xt_tgchk_param *par) |
| 35 | { | 38 | { |
| 36 | const struct xt_CHECKSUM_info *einfo = par->targinfo; | 39 | const struct xt_CHECKSUM_info *einfo = par->targinfo; |
| 40 | const struct ip6t_ip6 *i6 = par->entryinfo; | ||
| 41 | const struct ipt_ip *i4 = par->entryinfo; | ||
| 37 | 42 | ||
| 38 | if (einfo->operation & ~XT_CHECKSUM_OP_FILL) { | 43 | if (einfo->operation & ~XT_CHECKSUM_OP_FILL) { |
| 39 | pr_info_ratelimited("unsupported CHECKSUM operation %x\n", | 44 | pr_info_ratelimited("unsupported CHECKSUM operation %x\n", |
| @@ -43,6 +48,21 @@ static int checksum_tg_check(const struct xt_tgchk_param *par) | |||
| 43 | if (!einfo->operation) | 48 | if (!einfo->operation) |
| 44 | return -EINVAL; | 49 | return -EINVAL; |
| 45 | 50 | ||
| 51 | switch (par->family) { | ||
| 52 | case NFPROTO_IPV4: | ||
| 53 | if (i4->proto == IPPROTO_UDP && | ||
| 54 | (i4->invflags & XT_INV_PROTO) == 0) | ||
| 55 | return 0; | ||
| 56 | break; | ||
| 57 | case NFPROTO_IPV6: | ||
| 58 | if ((i6->flags & IP6T_F_PROTO) && | ||
| 59 | i6->proto == IPPROTO_UDP && | ||
| 60 | (i6->invflags & XT_INV_PROTO) == 0) | ||
| 61 | return 0; | ||
| 62 | break; | ||
| 63 | } | ||
| 64 | |||
| 65 | pr_warn_once("CHECKSUM should be avoided. If really needed, restrict with \"-p udp\" and only use in OUTPUT\n"); | ||
| 46 | return 0; | 66 | return 0; |
| 47 | } | 67 | } |
| 48 | 68 | ||
diff --git a/net/netfilter/xt_cluster.c b/net/netfilter/xt_cluster.c index dfbdbb2fc0ed..51d0c257e7a5 100644 --- a/net/netfilter/xt_cluster.c +++ b/net/netfilter/xt_cluster.c | |||
| @@ -125,6 +125,7 @@ xt_cluster_mt(const struct sk_buff *skb, struct xt_action_param *par) | |||
| 125 | static int xt_cluster_mt_checkentry(const struct xt_mtchk_param *par) | 125 | static int xt_cluster_mt_checkentry(const struct xt_mtchk_param *par) |
| 126 | { | 126 | { |
| 127 | struct xt_cluster_match_info *info = par->matchinfo; | 127 | struct xt_cluster_match_info *info = par->matchinfo; |
| 128 | int ret; | ||
| 128 | 129 | ||
| 129 | if (info->total_nodes > XT_CLUSTER_NODES_MAX) { | 130 | if (info->total_nodes > XT_CLUSTER_NODES_MAX) { |
| 130 | pr_info_ratelimited("you have exceeded the maximum number of cluster nodes (%u > %u)\n", | 131 | pr_info_ratelimited("you have exceeded the maximum number of cluster nodes (%u > %u)\n", |
| @@ -135,7 +136,17 @@ static int xt_cluster_mt_checkentry(const struct xt_mtchk_param *par) | |||
| 135 | pr_info_ratelimited("node mask cannot exceed total number of nodes\n"); | 136 | pr_info_ratelimited("node mask cannot exceed total number of nodes\n"); |
| 136 | return -EDOM; | 137 | return -EDOM; |
| 137 | } | 138 | } |
| 138 | return 0; | 139 | |
| 140 | ret = nf_ct_netns_get(par->net, par->family); | ||
| 141 | if (ret < 0) | ||
| 142 | pr_info_ratelimited("cannot load conntrack support for proto=%u\n", | ||
| 143 | par->family); | ||
| 144 | return ret; | ||
| 145 | } | ||
| 146 | |||
| 147 | static void xt_cluster_mt_destroy(const struct xt_mtdtor_param *par) | ||
| 148 | { | ||
| 149 | nf_ct_netns_put(par->net, par->family); | ||
| 139 | } | 150 | } |
| 140 | 151 | ||
| 141 | static struct xt_match xt_cluster_match __read_mostly = { | 152 | static struct xt_match xt_cluster_match __read_mostly = { |
| @@ -144,6 +155,7 @@ static struct xt_match xt_cluster_match __read_mostly = { | |||
| 144 | .match = xt_cluster_mt, | 155 | .match = xt_cluster_mt, |
| 145 | .checkentry = xt_cluster_mt_checkentry, | 156 | .checkentry = xt_cluster_mt_checkentry, |
| 146 | .matchsize = sizeof(struct xt_cluster_match_info), | 157 | .matchsize = sizeof(struct xt_cluster_match_info), |
| 158 | .destroy = xt_cluster_mt_destroy, | ||
| 147 | .me = THIS_MODULE, | 159 | .me = THIS_MODULE, |
| 148 | }; | 160 | }; |
| 149 | 161 | ||
diff --git a/net/netfilter/xt_hashlimit.c b/net/netfilter/xt_hashlimit.c index 9b16402f29af..3e7d259e5d8d 100644 --- a/net/netfilter/xt_hashlimit.c +++ b/net/netfilter/xt_hashlimit.c | |||
| @@ -1057,7 +1057,7 @@ static struct xt_match hashlimit_mt_reg[] __read_mostly = { | |||
| 1057 | static void *dl_seq_start(struct seq_file *s, loff_t *pos) | 1057 | static void *dl_seq_start(struct seq_file *s, loff_t *pos) |
| 1058 | __acquires(htable->lock) | 1058 | __acquires(htable->lock) |
| 1059 | { | 1059 | { |
| 1060 | struct xt_hashlimit_htable *htable = PDE_DATA(file_inode(s->private)); | 1060 | struct xt_hashlimit_htable *htable = PDE_DATA(file_inode(s->file)); |
| 1061 | unsigned int *bucket; | 1061 | unsigned int *bucket; |
| 1062 | 1062 | ||
| 1063 | spin_lock_bh(&htable->lock); | 1063 | spin_lock_bh(&htable->lock); |
| @@ -1074,7 +1074,7 @@ static void *dl_seq_start(struct seq_file *s, loff_t *pos) | |||
| 1074 | 1074 | ||
| 1075 | static void *dl_seq_next(struct seq_file *s, void *v, loff_t *pos) | 1075 | static void *dl_seq_next(struct seq_file *s, void *v, loff_t *pos) |
| 1076 | { | 1076 | { |
| 1077 | struct xt_hashlimit_htable *htable = PDE_DATA(file_inode(s->private)); | 1077 | struct xt_hashlimit_htable *htable = PDE_DATA(file_inode(s->file)); |
| 1078 | unsigned int *bucket = v; | 1078 | unsigned int *bucket = v; |
| 1079 | 1079 | ||
| 1080 | *pos = ++(*bucket); | 1080 | *pos = ++(*bucket); |
| @@ -1088,7 +1088,7 @@ static void *dl_seq_next(struct seq_file *s, void *v, loff_t *pos) | |||
| 1088 | static void dl_seq_stop(struct seq_file *s, void *v) | 1088 | static void dl_seq_stop(struct seq_file *s, void *v) |
| 1089 | __releases(htable->lock) | 1089 | __releases(htable->lock) |
| 1090 | { | 1090 | { |
| 1091 | struct xt_hashlimit_htable *htable = PDE_DATA(file_inode(s->private)); | 1091 | struct xt_hashlimit_htable *htable = PDE_DATA(file_inode(s->file)); |
| 1092 | unsigned int *bucket = v; | 1092 | unsigned int *bucket = v; |
| 1093 | 1093 | ||
| 1094 | if (!IS_ERR(bucket)) | 1094 | if (!IS_ERR(bucket)) |
| @@ -1130,7 +1130,7 @@ static void dl_seq_print(struct dsthash_ent *ent, u_int8_t family, | |||
| 1130 | static int dl_seq_real_show_v2(struct dsthash_ent *ent, u_int8_t family, | 1130 | static int dl_seq_real_show_v2(struct dsthash_ent *ent, u_int8_t family, |
| 1131 | struct seq_file *s) | 1131 | struct seq_file *s) |
| 1132 | { | 1132 | { |
| 1133 | struct xt_hashlimit_htable *ht = PDE_DATA(file_inode(s->private)); | 1133 | struct xt_hashlimit_htable *ht = PDE_DATA(file_inode(s->file)); |
| 1134 | 1134 | ||
| 1135 | spin_lock(&ent->lock); | 1135 | spin_lock(&ent->lock); |
| 1136 | /* recalculate to show accurate numbers */ | 1136 | /* recalculate to show accurate numbers */ |
| @@ -1145,7 +1145,7 @@ static int dl_seq_real_show_v2(struct dsthash_ent *ent, u_int8_t family, | |||
| 1145 | static int dl_seq_real_show_v1(struct dsthash_ent *ent, u_int8_t family, | 1145 | static int dl_seq_real_show_v1(struct dsthash_ent *ent, u_int8_t family, |
| 1146 | struct seq_file *s) | 1146 | struct seq_file *s) |
| 1147 | { | 1147 | { |
| 1148 | struct xt_hashlimit_htable *ht = PDE_DATA(file_inode(s->private)); | 1148 | struct xt_hashlimit_htable *ht = PDE_DATA(file_inode(s->file)); |
| 1149 | 1149 | ||
| 1150 | spin_lock(&ent->lock); | 1150 | spin_lock(&ent->lock); |
| 1151 | /* recalculate to show accurate numbers */ | 1151 | /* recalculate to show accurate numbers */ |
| @@ -1160,7 +1160,7 @@ static int dl_seq_real_show_v1(struct dsthash_ent *ent, u_int8_t family, | |||
| 1160 | static int dl_seq_real_show(struct dsthash_ent *ent, u_int8_t family, | 1160 | static int dl_seq_real_show(struct dsthash_ent *ent, u_int8_t family, |
| 1161 | struct seq_file *s) | 1161 | struct seq_file *s) |
| 1162 | { | 1162 | { |
| 1163 | struct xt_hashlimit_htable *ht = PDE_DATA(file_inode(s->private)); | 1163 | struct xt_hashlimit_htable *ht = PDE_DATA(file_inode(s->file)); |
| 1164 | 1164 | ||
| 1165 | spin_lock(&ent->lock); | 1165 | spin_lock(&ent->lock); |
| 1166 | /* recalculate to show accurate numbers */ | 1166 | /* recalculate to show accurate numbers */ |
| @@ -1174,7 +1174,7 @@ static int dl_seq_real_show(struct dsthash_ent *ent, u_int8_t family, | |||
| 1174 | 1174 | ||
| 1175 | static int dl_seq_show_v2(struct seq_file *s, void *v) | 1175 | static int dl_seq_show_v2(struct seq_file *s, void *v) |
| 1176 | { | 1176 | { |
| 1177 | struct xt_hashlimit_htable *htable = PDE_DATA(file_inode(s->private)); | 1177 | struct xt_hashlimit_htable *htable = PDE_DATA(file_inode(s->file)); |
| 1178 | unsigned int *bucket = (unsigned int *)v; | 1178 | unsigned int *bucket = (unsigned int *)v; |
| 1179 | struct dsthash_ent *ent; | 1179 | struct dsthash_ent *ent; |
| 1180 | 1180 | ||
| @@ -1188,7 +1188,7 @@ static int dl_seq_show_v2(struct seq_file *s, void *v) | |||
| 1188 | 1188 | ||
| 1189 | static int dl_seq_show_v1(struct seq_file *s, void *v) | 1189 | static int dl_seq_show_v1(struct seq_file *s, void *v) |
| 1190 | { | 1190 | { |
| 1191 | struct xt_hashlimit_htable *htable = PDE_DATA(file_inode(s->private)); | 1191 | struct xt_hashlimit_htable *htable = PDE_DATA(file_inode(s->file)); |
| 1192 | unsigned int *bucket = v; | 1192 | unsigned int *bucket = v; |
| 1193 | struct dsthash_ent *ent; | 1193 | struct dsthash_ent *ent; |
| 1194 | 1194 | ||
| @@ -1202,7 +1202,7 @@ static int dl_seq_show_v1(struct seq_file *s, void *v) | |||
| 1202 | 1202 | ||
| 1203 | static int dl_seq_show(struct seq_file *s, void *v) | 1203 | static int dl_seq_show(struct seq_file *s, void *v) |
| 1204 | { | 1204 | { |
| 1205 | struct xt_hashlimit_htable *htable = PDE_DATA(file_inode(s->private)); | 1205 | struct xt_hashlimit_htable *htable = PDE_DATA(file_inode(s->file)); |
| 1206 | unsigned int *bucket = v; | 1206 | unsigned int *bucket = v; |
| 1207 | struct dsthash_ent *ent; | 1207 | struct dsthash_ent *ent; |
| 1208 | 1208 | ||
diff --git a/net/rds/bind.c b/net/rds/bind.c index 3ab55784b637..762d2c6788a3 100644 --- a/net/rds/bind.c +++ b/net/rds/bind.c | |||
| @@ -76,11 +76,13 @@ struct rds_sock *rds_find_bound(const struct in6_addr *addr, __be16 port, | |||
| 76 | struct rds_sock *rs; | 76 | struct rds_sock *rs; |
| 77 | 77 | ||
| 78 | __rds_create_bind_key(key, addr, port, scope_id); | 78 | __rds_create_bind_key(key, addr, port, scope_id); |
| 79 | rs = rhashtable_lookup_fast(&bind_hash_table, key, ht_parms); | 79 | rcu_read_lock(); |
| 80 | rs = rhashtable_lookup(&bind_hash_table, key, ht_parms); | ||
| 80 | if (rs && !sock_flag(rds_rs_to_sk(rs), SOCK_DEAD)) | 81 | if (rs && !sock_flag(rds_rs_to_sk(rs), SOCK_DEAD)) |
| 81 | rds_sock_addref(rs); | 82 | rds_sock_addref(rs); |
| 82 | else | 83 | else |
| 83 | rs = NULL; | 84 | rs = NULL; |
| 85 | rcu_read_unlock(); | ||
| 84 | 86 | ||
| 85 | rdsdebug("returning rs %p for %pI6c:%u\n", rs, addr, | 87 | rdsdebug("returning rs %p for %pI6c:%u\n", rs, addr, |
| 86 | ntohs(port)); | 88 | ntohs(port)); |
| @@ -235,6 +237,7 @@ int rds_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) | |||
| 235 | goto out; | 237 | goto out; |
| 236 | } | 238 | } |
| 237 | 239 | ||
| 240 | sock_set_flag(sk, SOCK_RCU_FREE); | ||
| 238 | ret = rds_add_bound(rs, binding_addr, &port, scope_id); | 241 | ret = rds_add_bound(rs, binding_addr, &port, scope_id); |
| 239 | if (ret) | 242 | if (ret) |
| 240 | goto out; | 243 | goto out; |
diff --git a/net/sched/act_tunnel_key.c b/net/sched/act_tunnel_key.c index 420759153d5f..681f6f04e7da 100644 --- a/net/sched/act_tunnel_key.c +++ b/net/sched/act_tunnel_key.c | |||
| @@ -317,7 +317,7 @@ static int tunnel_key_init(struct net *net, struct nlattr *nla, | |||
| 317 | &metadata->u.tun_info, | 317 | &metadata->u.tun_info, |
| 318 | opts_len, extack); | 318 | opts_len, extack); |
| 319 | if (ret < 0) | 319 | if (ret < 0) |
| 320 | goto err_out; | 320 | goto release_tun_meta; |
| 321 | } | 321 | } |
| 322 | 322 | ||
| 323 | metadata->u.tun_info.mode |= IP_TUNNEL_INFO_TX; | 323 | metadata->u.tun_info.mode |= IP_TUNNEL_INFO_TX; |
| @@ -333,23 +333,24 @@ static int tunnel_key_init(struct net *net, struct nlattr *nla, | |||
| 333 | &act_tunnel_key_ops, bind, true); | 333 | &act_tunnel_key_ops, bind, true); |
| 334 | if (ret) { | 334 | if (ret) { |
| 335 | NL_SET_ERR_MSG(extack, "Cannot create TC IDR"); | 335 | NL_SET_ERR_MSG(extack, "Cannot create TC IDR"); |
| 336 | goto err_out; | 336 | goto release_tun_meta; |
| 337 | } | 337 | } |
| 338 | 338 | ||
| 339 | ret = ACT_P_CREATED; | 339 | ret = ACT_P_CREATED; |
| 340 | } else if (!ovr) { | 340 | } else if (!ovr) { |
| 341 | tcf_idr_release(*a, bind); | ||
| 342 | NL_SET_ERR_MSG(extack, "TC IDR already exists"); | 341 | NL_SET_ERR_MSG(extack, "TC IDR already exists"); |
| 343 | return -EEXIST; | 342 | ret = -EEXIST; |
| 343 | goto release_tun_meta; | ||
| 344 | } | 344 | } |
| 345 | 345 | ||
| 346 | t = to_tunnel_key(*a); | 346 | t = to_tunnel_key(*a); |
| 347 | 347 | ||
| 348 | params_new = kzalloc(sizeof(*params_new), GFP_KERNEL); | 348 | params_new = kzalloc(sizeof(*params_new), GFP_KERNEL); |
| 349 | if (unlikely(!params_new)) { | 349 | if (unlikely(!params_new)) { |
| 350 | tcf_idr_release(*a, bind); | ||
| 351 | NL_SET_ERR_MSG(extack, "Cannot allocate tunnel key parameters"); | 350 | NL_SET_ERR_MSG(extack, "Cannot allocate tunnel key parameters"); |
| 352 | return -ENOMEM; | 351 | ret = -ENOMEM; |
| 352 | exists = true; | ||
| 353 | goto release_tun_meta; | ||
| 353 | } | 354 | } |
| 354 | params_new->tcft_action = parm->t_action; | 355 | params_new->tcft_action = parm->t_action; |
| 355 | params_new->tcft_enc_metadata = metadata; | 356 | params_new->tcft_enc_metadata = metadata; |
| @@ -367,6 +368,9 @@ static int tunnel_key_init(struct net *net, struct nlattr *nla, | |||
| 367 | 368 | ||
| 368 | return ret; | 369 | return ret; |
| 369 | 370 | ||
| 371 | release_tun_meta: | ||
| 372 | dst_release(&metadata->dst); | ||
| 373 | |||
| 370 | err_out: | 374 | err_out: |
| 371 | if (exists) | 375 | if (exists) |
| 372 | tcf_idr_release(*a, bind); | 376 | tcf_idr_release(*a, bind); |
| @@ -408,8 +412,10 @@ static int tunnel_key_geneve_opts_dump(struct sk_buff *skb, | |||
| 408 | nla_put_u8(skb, TCA_TUNNEL_KEY_ENC_OPT_GENEVE_TYPE, | 412 | nla_put_u8(skb, TCA_TUNNEL_KEY_ENC_OPT_GENEVE_TYPE, |
| 409 | opt->type) || | 413 | opt->type) || |
| 410 | nla_put(skb, TCA_TUNNEL_KEY_ENC_OPT_GENEVE_DATA, | 414 | nla_put(skb, TCA_TUNNEL_KEY_ENC_OPT_GENEVE_DATA, |
| 411 | opt->length * 4, opt + 1)) | 415 | opt->length * 4, opt + 1)) { |
| 416 | nla_nest_cancel(skb, start); | ||
| 412 | return -EMSGSIZE; | 417 | return -EMSGSIZE; |
| 418 | } | ||
| 413 | 419 | ||
| 414 | len -= sizeof(struct geneve_opt) + opt->length * 4; | 420 | len -= sizeof(struct geneve_opt) + opt->length * 4; |
| 415 | src += sizeof(struct geneve_opt) + opt->length * 4; | 421 | src += sizeof(struct geneve_opt) + opt->length * 4; |
| @@ -423,7 +429,7 @@ static int tunnel_key_opts_dump(struct sk_buff *skb, | |||
| 423 | const struct ip_tunnel_info *info) | 429 | const struct ip_tunnel_info *info) |
| 424 | { | 430 | { |
| 425 | struct nlattr *start; | 431 | struct nlattr *start; |
| 426 | int err; | 432 | int err = -EINVAL; |
| 427 | 433 | ||
| 428 | if (!info->options_len) | 434 | if (!info->options_len) |
| 429 | return 0; | 435 | return 0; |
| @@ -435,9 +441,11 @@ static int tunnel_key_opts_dump(struct sk_buff *skb, | |||
| 435 | if (info->key.tun_flags & TUNNEL_GENEVE_OPT) { | 441 | if (info->key.tun_flags & TUNNEL_GENEVE_OPT) { |
| 436 | err = tunnel_key_geneve_opts_dump(skb, info); | 442 | err = tunnel_key_geneve_opts_dump(skb, info); |
| 437 | if (err) | 443 | if (err) |
| 438 | return err; | 444 | goto err_out; |
| 439 | } else { | 445 | } else { |
| 440 | return -EINVAL; | 446 | err_out: |
| 447 | nla_nest_cancel(skb, start); | ||
| 448 | return err; | ||
| 441 | } | 449 | } |
| 442 | 450 | ||
| 443 | nla_nest_end(skb, start); | 451 | nla_nest_end(skb, start); |
diff --git a/net/tipc/netlink_compat.c b/net/tipc/netlink_compat.c index a2f76743c73a..6376467e78f8 100644 --- a/net/tipc/netlink_compat.c +++ b/net/tipc/netlink_compat.c | |||
| @@ -185,6 +185,10 @@ static int __tipc_nl_compat_dumpit(struct tipc_nl_compat_cmd_dump *cmd, | |||
| 185 | return -ENOMEM; | 185 | return -ENOMEM; |
| 186 | 186 | ||
| 187 | buf->sk = msg->dst_sk; | 187 | buf->sk = msg->dst_sk; |
| 188 | if (__tipc_dump_start(&cb, msg->net)) { | ||
| 189 | kfree_skb(buf); | ||
| 190 | return -ENOMEM; | ||
| 191 | } | ||
| 188 | 192 | ||
| 189 | do { | 193 | do { |
| 190 | int rem; | 194 | int rem; |
| @@ -216,6 +220,7 @@ static int __tipc_nl_compat_dumpit(struct tipc_nl_compat_cmd_dump *cmd, | |||
| 216 | err = 0; | 220 | err = 0; |
| 217 | 221 | ||
| 218 | err_out: | 222 | err_out: |
| 223 | tipc_dump_done(&cb); | ||
| 219 | kfree_skb(buf); | 224 | kfree_skb(buf); |
| 220 | 225 | ||
| 221 | if (err == -EMSGSIZE) { | 226 | if (err == -EMSGSIZE) { |
diff --git a/net/tipc/socket.c b/net/tipc/socket.c index ab7a2a7178f7..3f03ddd0e35b 100644 --- a/net/tipc/socket.c +++ b/net/tipc/socket.c | |||
| @@ -576,6 +576,7 @@ static int tipc_release(struct socket *sock) | |||
| 576 | sk_stop_timer(sk, &sk->sk_timer); | 576 | sk_stop_timer(sk, &sk->sk_timer); |
| 577 | tipc_sk_remove(tsk); | 577 | tipc_sk_remove(tsk); |
| 578 | 578 | ||
| 579 | sock_orphan(sk); | ||
| 579 | /* Reject any messages that accumulated in backlog queue */ | 580 | /* Reject any messages that accumulated in backlog queue */ |
| 580 | release_sock(sk); | 581 | release_sock(sk); |
| 581 | tipc_dest_list_purge(&tsk->cong_links); | 582 | tipc_dest_list_purge(&tsk->cong_links); |
| @@ -3229,7 +3230,7 @@ int tipc_nl_sk_walk(struct sk_buff *skb, struct netlink_callback *cb, | |||
| 3229 | struct netlink_callback *cb, | 3230 | struct netlink_callback *cb, |
| 3230 | struct tipc_sock *tsk)) | 3231 | struct tipc_sock *tsk)) |
| 3231 | { | 3232 | { |
| 3232 | struct rhashtable_iter *iter = (void *)cb->args[0]; | 3233 | struct rhashtable_iter *iter = (void *)cb->args[4]; |
| 3233 | struct tipc_sock *tsk; | 3234 | struct tipc_sock *tsk; |
| 3234 | int err; | 3235 | int err; |
| 3235 | 3236 | ||
| @@ -3265,8 +3266,14 @@ EXPORT_SYMBOL(tipc_nl_sk_walk); | |||
| 3265 | 3266 | ||
| 3266 | int tipc_dump_start(struct netlink_callback *cb) | 3267 | int tipc_dump_start(struct netlink_callback *cb) |
| 3267 | { | 3268 | { |
| 3268 | struct rhashtable_iter *iter = (void *)cb->args[0]; | 3269 | return __tipc_dump_start(cb, sock_net(cb->skb->sk)); |
| 3269 | struct net *net = sock_net(cb->skb->sk); | 3270 | } |
| 3271 | EXPORT_SYMBOL(tipc_dump_start); | ||
| 3272 | |||
| 3273 | int __tipc_dump_start(struct netlink_callback *cb, struct net *net) | ||
| 3274 | { | ||
| 3275 | /* tipc_nl_name_table_dump() uses cb->args[0...3]. */ | ||
| 3276 | struct rhashtable_iter *iter = (void *)cb->args[4]; | ||
| 3270 | struct tipc_net *tn = tipc_net(net); | 3277 | struct tipc_net *tn = tipc_net(net); |
| 3271 | 3278 | ||
| 3272 | if (!iter) { | 3279 | if (!iter) { |
| @@ -3274,17 +3281,16 @@ int tipc_dump_start(struct netlink_callback *cb) | |||
| 3274 | if (!iter) | 3281 | if (!iter) |
| 3275 | return -ENOMEM; | 3282 | return -ENOMEM; |
| 3276 | 3283 | ||
| 3277 | cb->args[0] = (long)iter; | 3284 | cb->args[4] = (long)iter; |
| 3278 | } | 3285 | } |
| 3279 | 3286 | ||
| 3280 | rhashtable_walk_enter(&tn->sk_rht, iter); | 3287 | rhashtable_walk_enter(&tn->sk_rht, iter); |
| 3281 | return 0; | 3288 | return 0; |
| 3282 | } | 3289 | } |
| 3283 | EXPORT_SYMBOL(tipc_dump_start); | ||
| 3284 | 3290 | ||
| 3285 | int tipc_dump_done(struct netlink_callback *cb) | 3291 | int tipc_dump_done(struct netlink_callback *cb) |
| 3286 | { | 3292 | { |
| 3287 | struct rhashtable_iter *hti = (void *)cb->args[0]; | 3293 | struct rhashtable_iter *hti = (void *)cb->args[4]; |
| 3288 | 3294 | ||
| 3289 | rhashtable_walk_exit(hti); | 3295 | rhashtable_walk_exit(hti); |
| 3290 | kfree(hti); | 3296 | kfree(hti); |
diff --git a/net/tipc/socket.h b/net/tipc/socket.h index d43032e26532..5e575f205afe 100644 --- a/net/tipc/socket.h +++ b/net/tipc/socket.h | |||
| @@ -69,5 +69,6 @@ int tipc_nl_sk_walk(struct sk_buff *skb, struct netlink_callback *cb, | |||
| 69 | struct netlink_callback *cb, | 69 | struct netlink_callback *cb, |
| 70 | struct tipc_sock *tsk)); | 70 | struct tipc_sock *tsk)); |
| 71 | int tipc_dump_start(struct netlink_callback *cb); | 71 | int tipc_dump_start(struct netlink_callback *cb); |
| 72 | int __tipc_dump_start(struct netlink_callback *cb, struct net *net); | ||
| 72 | int tipc_dump_done(struct netlink_callback *cb); | 73 | int tipc_dump_done(struct netlink_callback *cb); |
| 73 | #endif | 74 | #endif |
diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c index 52fbe727d7c1..e28a6ff25d96 100644 --- a/net/tls/tls_sw.c +++ b/net/tls/tls_sw.c | |||
| @@ -125,6 +125,9 @@ static int alloc_encrypted_sg(struct sock *sk, int len) | |||
| 125 | &ctx->sg_encrypted_num_elem, | 125 | &ctx->sg_encrypted_num_elem, |
| 126 | &ctx->sg_encrypted_size, 0); | 126 | &ctx->sg_encrypted_size, 0); |
| 127 | 127 | ||
| 128 | if (rc == -ENOSPC) | ||
| 129 | ctx->sg_encrypted_num_elem = ARRAY_SIZE(ctx->sg_encrypted_data); | ||
| 130 | |||
| 128 | return rc; | 131 | return rc; |
| 129 | } | 132 | } |
| 130 | 133 | ||
| @@ -138,6 +141,9 @@ static int alloc_plaintext_sg(struct sock *sk, int len) | |||
| 138 | &ctx->sg_plaintext_num_elem, &ctx->sg_plaintext_size, | 141 | &ctx->sg_plaintext_num_elem, &ctx->sg_plaintext_size, |
| 139 | tls_ctx->pending_open_record_frags); | 142 | tls_ctx->pending_open_record_frags); |
| 140 | 143 | ||
| 144 | if (rc == -ENOSPC) | ||
| 145 | ctx->sg_plaintext_num_elem = ARRAY_SIZE(ctx->sg_plaintext_data); | ||
| 146 | |||
| 141 | return rc; | 147 | return rc; |
| 142 | } | 148 | } |
| 143 | 149 | ||
diff --git a/scripts/depmod.sh b/scripts/depmod.sh index 999d585eaa73..e083bcae343f 100755 --- a/scripts/depmod.sh +++ b/scripts/depmod.sh | |||
| @@ -11,13 +11,14 @@ DEPMOD=$1 | |||
| 11 | KERNELRELEASE=$2 | 11 | KERNELRELEASE=$2 |
| 12 | 12 | ||
| 13 | if ! test -r System.map ; then | 13 | if ! test -r System.map ; then |
| 14 | echo "Warning: modules_install: missing 'System.map' file. Skipping depmod." >&2 | ||
| 14 | exit 0 | 15 | exit 0 |
| 15 | fi | 16 | fi |
| 16 | 17 | ||
| 17 | if [ -z $(command -v $DEPMOD) ]; then | 18 | if [ -z $(command -v $DEPMOD) ]; then |
| 18 | echo "'make modules_install' requires $DEPMOD. Please install it." >&2 | 19 | echo "Warning: 'make modules_install' requires $DEPMOD. Please install it." >&2 |
| 19 | echo "This is probably in the kmod package." >&2 | 20 | echo "This is probably in the kmod package." >&2 |
| 20 | exit 1 | 21 | exit 0 |
| 21 | fi | 22 | fi |
| 22 | 23 | ||
| 23 | # older versions of depmod require the version string to start with three | 24 | # older versions of depmod require the version string to start with three |
diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile index 4a7bd2192073..67ed9f6ccdf8 100644 --- a/scripts/kconfig/Makefile +++ b/scripts/kconfig/Makefile | |||
| @@ -221,7 +221,6 @@ $(obj)/zconf.tab.o: $(obj)/zconf.lex.c | |||
| 221 | 221 | ||
| 222 | # check if necessary packages are available, and configure build flags | 222 | # check if necessary packages are available, and configure build flags |
| 223 | define filechk_conf_cfg | 223 | define filechk_conf_cfg |
| 224 | $(CONFIG_SHELL) $(srctree)/scripts/kconfig/check-pkgconfig.sh; \ | ||
| 225 | $(CONFIG_SHELL) $< | 224 | $(CONFIG_SHELL) $< |
| 226 | endef | 225 | endef |
| 227 | 226 | ||
diff --git a/scripts/kconfig/check-pkgconfig.sh b/scripts/kconfig/check-pkgconfig.sh deleted file mode 100644 index 7a1c40bfb58c..000000000000 --- a/scripts/kconfig/check-pkgconfig.sh +++ /dev/null | |||
| @@ -1,8 +0,0 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | # SPDX-License-Identifier: GPL-2.0 | ||
| 3 | # Check for pkg-config presence | ||
| 4 | |||
| 5 | if [ -z $(command -v pkg-config) ]; then | ||
| 6 | echo "'make *config' requires 'pkg-config'. Please install it." 1>&2 | ||
| 7 | exit 1 | ||
| 8 | fi | ||
diff --git a/scripts/kconfig/gconf-cfg.sh b/scripts/kconfig/gconf-cfg.sh index 533b3d8f8f08..480ecd8b9f41 100755 --- a/scripts/kconfig/gconf-cfg.sh +++ b/scripts/kconfig/gconf-cfg.sh | |||
| @@ -3,6 +3,13 @@ | |||
| 3 | 3 | ||
| 4 | PKG="gtk+-2.0 gmodule-2.0 libglade-2.0" | 4 | PKG="gtk+-2.0 gmodule-2.0 libglade-2.0" |
| 5 | 5 | ||
| 6 | if [ -z "$(command -v pkg-config)" ]; then | ||
| 7 | echo >&2 "*" | ||
| 8 | echo >&2 "* 'make gconfig' requires 'pkg-config'. Please install it." | ||
| 9 | echo >&2 "*" | ||
| 10 | exit 1 | ||
| 11 | fi | ||
| 12 | |||
| 6 | if ! pkg-config --exists $PKG; then | 13 | if ! pkg-config --exists $PKG; then |
| 7 | echo >&2 "*" | 14 | echo >&2 "*" |
| 8 | echo >&2 "* Unable to find the GTK+ installation. Please make sure that" | 15 | echo >&2 "* Unable to find the GTK+ installation. Please make sure that" |
diff --git a/scripts/kconfig/mconf-cfg.sh b/scripts/kconfig/mconf-cfg.sh index e6f9facd0077..c812872d7f9d 100755 --- a/scripts/kconfig/mconf-cfg.sh +++ b/scripts/kconfig/mconf-cfg.sh | |||
| @@ -4,20 +4,23 @@ | |||
| 4 | PKG="ncursesw" | 4 | PKG="ncursesw" |
| 5 | PKG2="ncurses" | 5 | PKG2="ncurses" |
| 6 | 6 | ||
| 7 | if pkg-config --exists $PKG; then | 7 | if [ -n "$(command -v pkg-config)" ]; then |
| 8 | echo cflags=\"$(pkg-config --cflags $PKG)\" | 8 | if pkg-config --exists $PKG; then |
| 9 | echo libs=\"$(pkg-config --libs $PKG)\" | 9 | echo cflags=\"$(pkg-config --cflags $PKG)\" |
| 10 | exit 0 | 10 | echo libs=\"$(pkg-config --libs $PKG)\" |
| 11 | fi | 11 | exit 0 |
| 12 | fi | ||
| 12 | 13 | ||
| 13 | if pkg-config --exists $PKG2; then | 14 | if pkg-config --exists $PKG2; then |
| 14 | echo cflags=\"$(pkg-config --cflags $PKG2)\" | 15 | echo cflags=\"$(pkg-config --cflags $PKG2)\" |
| 15 | echo libs=\"$(pkg-config --libs $PKG2)\" | 16 | echo libs=\"$(pkg-config --libs $PKG2)\" |
| 16 | exit 0 | 17 | exit 0 |
| 18 | fi | ||
| 17 | fi | 19 | fi |
| 18 | 20 | ||
| 19 | # Unfortunately, some distributions (e.g. openSUSE) cannot find ncurses | 21 | # Check the default paths in case pkg-config is not installed. |
| 20 | # by pkg-config. | 22 | # (Even if it is installed, some distributions such as openSUSE cannot |
| 23 | # find ncurses by pkg-config.) | ||
| 21 | if [ -f /usr/include/ncursesw/ncurses.h ]; then | 24 | if [ -f /usr/include/ncursesw/ncurses.h ]; then |
| 22 | echo cflags=\"-D_GNU_SOURCE -I/usr/include/ncursesw\" | 25 | echo cflags=\"-D_GNU_SOURCE -I/usr/include/ncursesw\" |
| 23 | echo libs=\"-lncursesw\" | 26 | echo libs=\"-lncursesw\" |
diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c index 83b5836615fb..143c05fec161 100644 --- a/scripts/kconfig/mconf.c +++ b/scripts/kconfig/mconf.c | |||
| @@ -490,7 +490,6 @@ static void build_conf(struct menu *menu) | |||
| 490 | switch (prop->type) { | 490 | switch (prop->type) { |
| 491 | case P_MENU: | 491 | case P_MENU: |
| 492 | child_count++; | 492 | child_count++; |
| 493 | prompt = prompt; | ||
| 494 | if (single_menu_mode) { | 493 | if (single_menu_mode) { |
| 495 | item_make("%s%*c%s", | 494 | item_make("%s%*c%s", |
| 496 | menu->data ? "-->" : "++>", | 495 | menu->data ? "-->" : "++>", |
diff --git a/scripts/kconfig/nconf-cfg.sh b/scripts/kconfig/nconf-cfg.sh index 42f5ac73548e..001559ef0a60 100644 --- a/scripts/kconfig/nconf-cfg.sh +++ b/scripts/kconfig/nconf-cfg.sh | |||
| @@ -4,20 +4,23 @@ | |||
| 4 | PKG="ncursesw menuw panelw" | 4 | PKG="ncursesw menuw panelw" |
| 5 | PKG2="ncurses menu panel" | 5 | PKG2="ncurses menu panel" |
| 6 | 6 | ||
| 7 | if pkg-config --exists $PKG; then | 7 | if [ -n "$(command -v pkg-config)" ]; then |
| 8 | echo cflags=\"$(pkg-config --cflags $PKG)\" | 8 | if pkg-config --exists $PKG; then |
| 9 | echo libs=\"$(pkg-config --libs $PKG)\" | 9 | echo cflags=\"$(pkg-config --cflags $PKG)\" |
| 10 | exit 0 | 10 | echo libs=\"$(pkg-config --libs $PKG)\" |
| 11 | fi | 11 | exit 0 |
| 12 | fi | ||
| 12 | 13 | ||
| 13 | if pkg-config --exists $PKG2; then | 14 | if pkg-config --exists $PKG2; then |
| 14 | echo cflags=\"$(pkg-config --cflags $PKG2)\" | 15 | echo cflags=\"$(pkg-config --cflags $PKG2)\" |
| 15 | echo libs=\"$(pkg-config --libs $PKG2)\" | 16 | echo libs=\"$(pkg-config --libs $PKG2)\" |
| 16 | exit 0 | 17 | exit 0 |
| 18 | fi | ||
| 17 | fi | 19 | fi |
| 18 | 20 | ||
| 19 | # Unfortunately, some distributions (e.g. openSUSE) cannot find ncurses | 21 | # Check the default paths in case pkg-config is not installed. |
| 20 | # by pkg-config. | 22 | # (Even if it is installed, some distributions such as openSUSE cannot |
| 23 | # find ncurses by pkg-config.) | ||
| 21 | if [ -f /usr/include/ncursesw/ncurses.h ]; then | 24 | if [ -f /usr/include/ncursesw/ncurses.h ]; then |
| 22 | echo cflags=\"-D_GNU_SOURCE -I/usr/include/ncursesw\" | 25 | echo cflags=\"-D_GNU_SOURCE -I/usr/include/ncursesw\" |
| 23 | echo libs=\"-lncursesw -lmenuw -lpanelw\" | 26 | echo libs=\"-lncursesw -lmenuw -lpanelw\" |
diff --git a/scripts/kconfig/qconf-cfg.sh b/scripts/kconfig/qconf-cfg.sh index 0862e1562536..02ccc0ae1031 100755 --- a/scripts/kconfig/qconf-cfg.sh +++ b/scripts/kconfig/qconf-cfg.sh | |||
| @@ -4,6 +4,13 @@ | |||
| 4 | PKG="Qt5Core Qt5Gui Qt5Widgets" | 4 | PKG="Qt5Core Qt5Gui Qt5Widgets" |
| 5 | PKG2="QtCore QtGui" | 5 | PKG2="QtCore QtGui" |
| 6 | 6 | ||
| 7 | if [ -z "$(command -v pkg-config)" ]; then | ||
| 8 | echo >&2 "*" | ||
| 9 | echo >&2 "* 'make xconfig' requires 'pkg-config'. Please install it." | ||
| 10 | echo >&2 "*" | ||
| 11 | exit 1 | ||
| 12 | fi | ||
| 13 | |||
| 7 | if pkg-config --exists $PKG; then | 14 | if pkg-config --exists $PKG; then |
| 8 | echo cflags=\"-std=c++11 -fPIC $(pkg-config --cflags Qt5Core Qt5Gui Qt5Widgets)\" | 15 | echo cflags=\"-std=c++11 -fPIC $(pkg-config --cflags Qt5Core Qt5Gui Qt5Widgets)\" |
| 9 | echo libs=\"$(pkg-config --libs $PKG)\" | 16 | echo libs=\"$(pkg-config --libs $PKG)\" |
diff --git a/scripts/setlocalversion b/scripts/setlocalversion index 71f39410691b..79f7dd57d571 100755 --- a/scripts/setlocalversion +++ b/scripts/setlocalversion | |||
| @@ -74,7 +74,7 @@ scm_version() | |||
| 74 | fi | 74 | fi |
| 75 | 75 | ||
| 76 | # Check for uncommitted changes | 76 | # Check for uncommitted changes |
| 77 | if git diff-index --name-only HEAD | grep -qv "^scripts/package"; then | 77 | if git status -uno --porcelain | grep -qv '^.. scripts/package'; then |
| 78 | printf '%s' -dirty | 78 | printf '%s' -dirty |
| 79 | fi | 79 | fi |
| 80 | 80 | ||
diff --git a/tools/hv/hv_kvp_daemon.c b/tools/hv/hv_kvp_daemon.c index dbf6e8bd98ba..bbb2a8ef367c 100644 --- a/tools/hv/hv_kvp_daemon.c +++ b/tools/hv/hv_kvp_daemon.c | |||
| @@ -286,7 +286,7 @@ static int kvp_key_delete(int pool, const __u8 *key, int key_size) | |||
| 286 | * Found a match; just move the remaining | 286 | * Found a match; just move the remaining |
| 287 | * entries up. | 287 | * entries up. |
| 288 | */ | 288 | */ |
| 289 | if (i == num_records) { | 289 | if (i == (num_records - 1)) { |
| 290 | kvp_file_info[pool].num_records--; | 290 | kvp_file_info[pool].num_records--; |
| 291 | kvp_update_file(pool); | 291 | kvp_update_file(pool); |
| 292 | return 0; | 292 | return 0; |
