diff options
author | Jens Axboe <axboe@fb.com> | 2017-04-25 00:03:14 -0400 |
---|---|---|
committer | Jens Axboe <axboe@fb.com> | 2017-04-25 00:03:14 -0400 |
commit | d9fd363a6cbfae24ffaa00ac6fd3ce8e271acaf1 (patch) | |
tree | 9139831824ebe9cf77d1bf836b558ee2061c0483 | |
parent | a44f53faf4674d84cba79f7ee574584e18ab8744 (diff) | |
parent | 8f9cedc76fc7d9bc916127f8fe1287a249891d40 (diff) |
Merge branch 'master' into for-4.12/post-merge
668 files changed, 7382 insertions, 4064 deletions
@@ -99,6 +99,8 @@ Linas Vepstas <linas@austin.ibm.com> | |||
99 | Linus Lüssing <linus.luessing@c0d3.blue> <linus.luessing@web.de> | 99 | Linus Lüssing <linus.luessing@c0d3.blue> <linus.luessing@web.de> |
100 | Linus Lüssing <linus.luessing@c0d3.blue> <linus.luessing@ascom.ch> | 100 | Linus Lüssing <linus.luessing@c0d3.blue> <linus.luessing@ascom.ch> |
101 | Mark Brown <broonie@sirena.org.uk> | 101 | Mark Brown <broonie@sirena.org.uk> |
102 | Martin Kepplinger <martink@posteo.de> <martin.kepplinger@theobroma-systems.com> | ||
103 | Martin Kepplinger <martink@posteo.de> <martin.kepplinger@ginzinger.com> | ||
102 | Matthieu CASTET <castet.matthieu@free.fr> | 104 | Matthieu CASTET <castet.matthieu@free.fr> |
103 | Mauro Carvalho Chehab <mchehab@kernel.org> <mchehab@brturbo.com.br> | 105 | Mauro Carvalho Chehab <mchehab@kernel.org> <mchehab@brturbo.com.br> |
104 | Mauro Carvalho Chehab <mchehab@kernel.org> <maurochehab@gmail.com> | 106 | Mauro Carvalho Chehab <mchehab@kernel.org> <maurochehab@gmail.com> |
@@ -171,6 +173,7 @@ Vlad Dogaru <ddvlad@gmail.com> <vlad.dogaru@intel.com> | |||
171 | Vladimir Davydov <vdavydov.dev@gmail.com> <vdavydov@virtuozzo.com> | 173 | Vladimir Davydov <vdavydov.dev@gmail.com> <vdavydov@virtuozzo.com> |
172 | Vladimir Davydov <vdavydov.dev@gmail.com> <vdavydov@parallels.com> | 174 | Vladimir Davydov <vdavydov.dev@gmail.com> <vdavydov@parallels.com> |
173 | Takashi YOSHII <takashi.yoshii.zj@renesas.com> | 175 | Takashi YOSHII <takashi.yoshii.zj@renesas.com> |
176 | Yakir Yang <kuankuan.y@gmail.com> <ykk@rock-chips.com> | ||
174 | Yusuke Goda <goda.yusuke@renesas.com> | 177 | Yusuke Goda <goda.yusuke@renesas.com> |
175 | Gustavo Padovan <gustavo@las.ic.unicamp.br> | 178 | Gustavo Padovan <gustavo@las.ic.unicamp.br> |
176 | Gustavo Padovan <padovan@profusion.mobi> | 179 | Gustavo Padovan <padovan@profusion.mobi> |
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 2ba45caabada..facc20a3f962 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt | |||
@@ -1725,6 +1725,12 @@ | |||
1725 | kernel and module base offset ASLR (Address Space | 1725 | kernel and module base offset ASLR (Address Space |
1726 | Layout Randomization). | 1726 | Layout Randomization). |
1727 | 1727 | ||
1728 | kasan_multi_shot | ||
1729 | [KNL] Enforce KASAN (Kernel Address Sanitizer) to print | ||
1730 | report on every invalid memory access. Without this | ||
1731 | parameter KASAN will print report only for the first | ||
1732 | invalid access. | ||
1733 | |||
1728 | keepinitrd [HW,ARM] | 1734 | keepinitrd [HW,ARM] |
1729 | 1735 | ||
1730 | kernelcore= [KNL,X86,IA-64,PPC] | 1736 | kernelcore= [KNL,X86,IA-64,PPC] |
diff --git a/Documentation/devicetree/bindings/pci/hisilicon-pcie.txt b/Documentation/devicetree/bindings/pci/hisilicon-pcie.txt index b7fa3b97986d..a339dbb15493 100644 --- a/Documentation/devicetree/bindings/pci/hisilicon-pcie.txt +++ b/Documentation/devicetree/bindings/pci/hisilicon-pcie.txt | |||
@@ -44,13 +44,19 @@ Hip05 Example (note that Hip06 is the same except compatible): | |||
44 | }; | 44 | }; |
45 | 45 | ||
46 | HiSilicon Hip06/Hip07 PCIe host bridge DT (almost-ECAM) description. | 46 | HiSilicon Hip06/Hip07 PCIe host bridge DT (almost-ECAM) description. |
47 | |||
48 | Some BIOSes place the host controller in a mode where it is ECAM | ||
49 | compliant for all devices other than the root complex. In such cases, | ||
50 | the host controller should be described as below. | ||
51 | |||
47 | The properties and their meanings are identical to those described in | 52 | The properties and their meanings are identical to those described in |
48 | host-generic-pci.txt except as listed below. | 53 | host-generic-pci.txt except as listed below. |
49 | 54 | ||
50 | Properties of the host controller node that differ from | 55 | Properties of the host controller node that differ from |
51 | host-generic-pci.txt: | 56 | host-generic-pci.txt: |
52 | 57 | ||
53 | - compatible : Must be "hisilicon,pcie-almost-ecam" | 58 | - compatible : Must be "hisilicon,hip06-pcie-ecam", or |
59 | "hisilicon,hip07-pcie-ecam" | ||
54 | 60 | ||
55 | - reg : Two entries: First the ECAM configuration space for any | 61 | - reg : Two entries: First the ECAM configuration space for any |
56 | other bus underneath the root bus. Second, the base | 62 | other bus underneath the root bus. Second, the base |
@@ -59,7 +65,7 @@ host-generic-pci.txt: | |||
59 | 65 | ||
60 | Example: | 66 | Example: |
61 | pcie0: pcie@a0090000 { | 67 | pcie0: pcie@a0090000 { |
62 | compatible = "hisilicon,pcie-almost-ecam"; | 68 | compatible = "hisilicon,hip06-pcie-ecam"; |
63 | reg = <0 0xb0000000 0 0x2000000>, /* ECAM configuration space */ | 69 | reg = <0 0xb0000000 0 0x2000000>, /* ECAM configuration space */ |
64 | <0 0xa0090000 0 0x10000>; /* host bridge registers */ | 70 | <0 0xa0090000 0 0x10000>; /* host bridge registers */ |
65 | bus-range = <0 31>; | 71 | bus-range = <0 31>; |
diff --git a/Documentation/devicetree/bindings/rng/omap_rng.txt b/Documentation/devicetree/bindings/rng/omap_rng.txt index 471477299ece..9cf7876ab434 100644 --- a/Documentation/devicetree/bindings/rng/omap_rng.txt +++ b/Documentation/devicetree/bindings/rng/omap_rng.txt | |||
@@ -12,7 +12,8 @@ Required properties: | |||
12 | - reg : Offset and length of the register set for the module | 12 | - reg : Offset and length of the register set for the module |
13 | - interrupts : the interrupt number for the RNG module. | 13 | - interrupts : the interrupt number for the RNG module. |
14 | Used for "ti,omap4-rng" and "inside-secure,safexcel-eip76" | 14 | Used for "ti,omap4-rng" and "inside-secure,safexcel-eip76" |
15 | - clocks: the trng clock source | 15 | - clocks: the trng clock source. Only mandatory for the |
16 | "inside-secure,safexcel-eip76" compatible. | ||
16 | 17 | ||
17 | Example: | 18 | Example: |
18 | /* AM335x */ | 19 | /* AM335x */ |
diff --git a/Documentation/filesystems/Locking b/Documentation/filesystems/Locking index fdcfdd79682a..fe25787ff6d4 100644 --- a/Documentation/filesystems/Locking +++ b/Documentation/filesystems/Locking | |||
@@ -58,8 +58,7 @@ prototypes: | |||
58 | int (*permission) (struct inode *, int, unsigned int); | 58 | int (*permission) (struct inode *, int, unsigned int); |
59 | int (*get_acl)(struct inode *, int); | 59 | int (*get_acl)(struct inode *, int); |
60 | int (*setattr) (struct dentry *, struct iattr *); | 60 | int (*setattr) (struct dentry *, struct iattr *); |
61 | int (*getattr) (const struct path *, struct dentry *, struct kstat *, | 61 | int (*getattr) (const struct path *, struct kstat *, u32, unsigned int); |
62 | u32, unsigned int); | ||
63 | ssize_t (*listxattr) (struct dentry *, char *, size_t); | 62 | ssize_t (*listxattr) (struct dentry *, char *, size_t); |
64 | int (*fiemap)(struct inode *, struct fiemap_extent_info *, u64 start, u64 len); | 63 | int (*fiemap)(struct inode *, struct fiemap_extent_info *, u64 start, u64 len); |
65 | void (*update_time)(struct inode *, struct timespec *, int); | 64 | void (*update_time)(struct inode *, struct timespec *, int); |
diff --git a/Documentation/filesystems/porting b/Documentation/filesystems/porting index 95280079c0b3..5fb17f49f7a2 100644 --- a/Documentation/filesystems/porting +++ b/Documentation/filesystems/porting | |||
@@ -600,3 +600,9 @@ in your dentry operations instead. | |||
600 | [recommended] | 600 | [recommended] |
601 | ->readlink is optional for symlinks. Don't set, unless filesystem needs | 601 | ->readlink is optional for symlinks. Don't set, unless filesystem needs |
602 | to fake something for readlink(2). | 602 | to fake something for readlink(2). |
603 | -- | ||
604 | [mandatory] | ||
605 | ->getattr() is now passed a struct path rather than a vfsmount and | ||
606 | dentry separately, and it now has request_mask and query_flags arguments | ||
607 | to specify the fields and sync type requested by statx. Filesystems not | ||
608 | supporting any statx-specific features may ignore the new arguments. | ||
diff --git a/Documentation/filesystems/vfs.txt b/Documentation/filesystems/vfs.txt index 569211703721..94dd27ef4a76 100644 --- a/Documentation/filesystems/vfs.txt +++ b/Documentation/filesystems/vfs.txt | |||
@@ -382,8 +382,7 @@ struct inode_operations { | |||
382 | int (*permission) (struct inode *, int); | 382 | int (*permission) (struct inode *, int); |
383 | int (*get_acl)(struct inode *, int); | 383 | int (*get_acl)(struct inode *, int); |
384 | int (*setattr) (struct dentry *, struct iattr *); | 384 | int (*setattr) (struct dentry *, struct iattr *); |
385 | int (*getattr) (const struct path *, struct dentry *, struct kstat *, | 385 | int (*getattr) (const struct path *, struct kstat *, u32, unsigned int); |
386 | u32, unsigned int); | ||
387 | ssize_t (*listxattr) (struct dentry *, char *, size_t); | 386 | ssize_t (*listxattr) (struct dentry *, char *, size_t); |
388 | void (*update_time)(struct inode *, struct timespec *, int); | 387 | void (*update_time)(struct inode *, struct timespec *, int); |
389 | int (*atomic_open)(struct inode *, struct dentry *, struct file *, | 388 | int (*atomic_open)(struct inode *, struct dentry *, struct file *, |
diff --git a/Documentation/pinctrl.txt b/Documentation/pinctrl.txt index 54bd5faa8782..f2af35f6d6b2 100644 --- a/Documentation/pinctrl.txt +++ b/Documentation/pinctrl.txt | |||
@@ -77,9 +77,15 @@ static struct pinctrl_desc foo_desc = { | |||
77 | 77 | ||
78 | int __init foo_probe(void) | 78 | int __init foo_probe(void) |
79 | { | 79 | { |
80 | int error; | ||
81 | |||
80 | struct pinctrl_dev *pctl; | 82 | struct pinctrl_dev *pctl; |
81 | 83 | ||
82 | return pinctrl_register_and_init(&foo_desc, <PARENT>, NULL, &pctl); | 84 | error = pinctrl_register_and_init(&foo_desc, <PARENT>, NULL, &pctl); |
85 | if (error) | ||
86 | return error; | ||
87 | |||
88 | return pinctrl_enable(pctl); | ||
83 | } | 89 | } |
84 | 90 | ||
85 | To enable the pinctrl subsystem and the subgroups for PINMUX and PINCONF and | 91 | To enable the pinctrl subsystem and the subgroups for PINMUX and PINCONF and |
diff --git a/Documentation/process/stable-kernel-rules.rst b/Documentation/process/stable-kernel-rules.rst index 11ec2d93a5e0..61e9c78bd6d1 100644 --- a/Documentation/process/stable-kernel-rules.rst +++ b/Documentation/process/stable-kernel-rules.rst | |||
@@ -124,7 +124,7 @@ specified in the following format in the sign-off area: | |||
124 | 124 | ||
125 | .. code-block:: none | 125 | .. code-block:: none |
126 | 126 | ||
127 | Cc: <stable@vger.kernel.org> # 3.3.x- | 127 | Cc: <stable@vger.kernel.org> # 3.3.x |
128 | 128 | ||
129 | The tag has the meaning of: | 129 | The tag has the meaning of: |
130 | 130 | ||
diff --git a/Documentation/virtual/kvm/devices/arm-vgic.txt b/Documentation/virtual/kvm/devices/arm-vgic.txt index 76e61c883347..b2f60ca8b60c 100644 --- a/Documentation/virtual/kvm/devices/arm-vgic.txt +++ b/Documentation/virtual/kvm/devices/arm-vgic.txt | |||
@@ -83,6 +83,12 @@ Groups: | |||
83 | 83 | ||
84 | Bits for undefined preemption levels are RAZ/WI. | 84 | Bits for undefined preemption levels are RAZ/WI. |
85 | 85 | ||
86 | For historical reasons and to provide ABI compatibility with userspace we | ||
87 | export the GICC_PMR register in the format of the GICH_VMCR.VMPriMask | ||
88 | field in the lower 5 bits of a word, meaning that userspace must always | ||
89 | use the lower 5 bits to communicate with the KVM device and must shift the | ||
90 | value left by 3 places to obtain the actual priority mask level. | ||
91 | |||
86 | Limitations: | 92 | Limitations: |
87 | - Priorities are not implemented, and registers are RAZ/WI | 93 | - Priorities are not implemented, and registers are RAZ/WI |
88 | - Currently only implemented for KVM_DEV_TYPE_ARM_VGIC_V2. | 94 | - Currently only implemented for KVM_DEV_TYPE_ARM_VGIC_V2. |
diff --git a/MAINTAINERS b/MAINTAINERS index 1b0a87ffffab..38d3e4ed7208 100644 --- a/MAINTAINERS +++ b/MAINTAINERS | |||
@@ -2585,12 +2585,26 @@ F: include/uapi/linux/if_bonding.h | |||
2585 | 2585 | ||
2586 | BPF (Safe dynamic programs and tools) | 2586 | BPF (Safe dynamic programs and tools) |
2587 | M: Alexei Starovoitov <ast@kernel.org> | 2587 | M: Alexei Starovoitov <ast@kernel.org> |
2588 | M: Daniel Borkmann <daniel@iogearbox.net> | ||
2588 | L: netdev@vger.kernel.org | 2589 | L: netdev@vger.kernel.org |
2589 | L: linux-kernel@vger.kernel.org | 2590 | L: linux-kernel@vger.kernel.org |
2590 | S: Supported | 2591 | S: Supported |
2592 | F: arch/x86/net/bpf_jit* | ||
2593 | F: Documentation/networking/filter.txt | ||
2594 | F: include/linux/bpf* | ||
2595 | F: include/linux/filter.h | ||
2596 | F: include/uapi/linux/bpf* | ||
2597 | F: include/uapi/linux/filter.h | ||
2591 | F: kernel/bpf/ | 2598 | F: kernel/bpf/ |
2592 | F: tools/testing/selftests/bpf/ | 2599 | F: kernel/trace/bpf_trace.c |
2593 | F: lib/test_bpf.c | 2600 | F: lib/test_bpf.c |
2601 | F: net/bpf/ | ||
2602 | F: net/core/filter.c | ||
2603 | F: net/sched/act_bpf.c | ||
2604 | F: net/sched/cls_bpf.c | ||
2605 | F: samples/bpf/ | ||
2606 | F: tools/net/bpf* | ||
2607 | F: tools/testing/selftests/bpf/ | ||
2594 | 2608 | ||
2595 | BROADCOM B44 10/100 ETHERNET DRIVER | 2609 | BROADCOM B44 10/100 ETHERNET DRIVER |
2596 | M: Michael Chan <michael.chan@broadcom.com> | 2610 | M: Michael Chan <michael.chan@broadcom.com> |
@@ -4117,14 +4131,13 @@ F: drivers/block/drbd/ | |||
4117 | F: lib/lru_cache.c | 4131 | F: lib/lru_cache.c |
4118 | F: Documentation/blockdev/drbd/ | 4132 | F: Documentation/blockdev/drbd/ |
4119 | 4133 | ||
4120 | DRIVER CORE, KOBJECTS, DEBUGFS, KERNFS AND SYSFS | 4134 | DRIVER CORE, KOBJECTS, DEBUGFS AND SYSFS |
4121 | M: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 4135 | M: Greg Kroah-Hartman <gregkh@linuxfoundation.org> |
4122 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core.git | 4136 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core.git |
4123 | S: Supported | 4137 | S: Supported |
4124 | F: Documentation/kobject.txt | 4138 | F: Documentation/kobject.txt |
4125 | F: drivers/base/ | 4139 | F: drivers/base/ |
4126 | F: fs/debugfs/ | 4140 | F: fs/debugfs/ |
4127 | F: fs/kernfs/ | ||
4128 | F: fs/sysfs/ | 4141 | F: fs/sysfs/ |
4129 | F: include/linux/debugfs.h | 4142 | F: include/linux/debugfs.h |
4130 | F: include/linux/kobj* | 4143 | F: include/linux/kobj* |
@@ -4928,6 +4941,7 @@ F: include/linux/netfilter_bridge/ | |||
4928 | F: net/bridge/ | 4941 | F: net/bridge/ |
4929 | 4942 | ||
4930 | ETHERNET PHY LIBRARY | 4943 | ETHERNET PHY LIBRARY |
4944 | M: Andrew Lunn <andrew@lunn.ch> | ||
4931 | M: Florian Fainelli <f.fainelli@gmail.com> | 4945 | M: Florian Fainelli <f.fainelli@gmail.com> |
4932 | L: netdev@vger.kernel.org | 4946 | L: netdev@vger.kernel.org |
4933 | S: Maintained | 4947 | S: Maintained |
@@ -7089,9 +7103,9 @@ S: Maintained | |||
7089 | F: fs/autofs4/ | 7103 | F: fs/autofs4/ |
7090 | 7104 | ||
7091 | KERNEL BUILD + files below scripts/ (unless maintained elsewhere) | 7105 | KERNEL BUILD + files below scripts/ (unless maintained elsewhere) |
7106 | M: Masahiro Yamada <yamada.masahiro@socionext.com> | ||
7092 | M: Michal Marek <mmarek@suse.com> | 7107 | M: Michal Marek <mmarek@suse.com> |
7093 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild.git for-next | 7108 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git |
7094 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild.git rc-fixes | ||
7095 | L: linux-kbuild@vger.kernel.org | 7109 | L: linux-kbuild@vger.kernel.org |
7096 | S: Maintained | 7110 | S: Maintained |
7097 | F: Documentation/kbuild/ | 7111 | F: Documentation/kbuild/ |
@@ -7208,6 +7222,14 @@ F: arch/mips/include/uapi/asm/kvm* | |||
7208 | F: arch/mips/include/asm/kvm* | 7222 | F: arch/mips/include/asm/kvm* |
7209 | F: arch/mips/kvm/ | 7223 | F: arch/mips/kvm/ |
7210 | 7224 | ||
7225 | KERNFS | ||
7226 | M: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | ||
7227 | M: Tejun Heo <tj@kernel.org> | ||
7228 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core.git | ||
7229 | S: Supported | ||
7230 | F: include/linux/kernfs.h | ||
7231 | F: fs/kernfs/ | ||
7232 | |||
7211 | KEXEC | 7233 | KEXEC |
7212 | M: Eric Biederman <ebiederm@xmission.com> | 7234 | M: Eric Biederman <ebiederm@xmission.com> |
7213 | W: http://kernel.org/pub/linux/utils/kernel/kexec/ | 7235 | W: http://kernel.org/pub/linux/utils/kernel/kexec/ |
@@ -8753,6 +8775,7 @@ W: http://www.linuxfoundation.org/en/Net | |||
8753 | Q: http://patchwork.ozlabs.org/project/netdev/list/ | 8775 | Q: http://patchwork.ozlabs.org/project/netdev/list/ |
8754 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/davem/net.git | 8776 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/davem/net.git |
8755 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git | 8777 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git |
8778 | B: mailto:netdev@vger.kernel.org | ||
8756 | S: Maintained | 8779 | S: Maintained |
8757 | F: net/ | 8780 | F: net/ |
8758 | F: include/net/ | 8781 | F: include/net/ |
@@ -10814,6 +10837,7 @@ F: drivers/s390/block/dasd* | |||
10814 | F: block/partitions/ibm.c | 10837 | F: block/partitions/ibm.c |
10815 | 10838 | ||
10816 | S390 NETWORK DRIVERS | 10839 | S390 NETWORK DRIVERS |
10840 | M: Julian Wiedmann <jwi@linux.vnet.ibm.com> | ||
10817 | M: Ursula Braun <ubraun@linux.vnet.ibm.com> | 10841 | M: Ursula Braun <ubraun@linux.vnet.ibm.com> |
10818 | L: linux-s390@vger.kernel.org | 10842 | L: linux-s390@vger.kernel.org |
10819 | W: http://www.ibm.com/developerworks/linux/linux390/ | 10843 | W: http://www.ibm.com/developerworks/linux/linux390/ |
@@ -10844,6 +10868,7 @@ S: Supported | |||
10844 | F: drivers/s390/scsi/zfcp_* | 10868 | F: drivers/s390/scsi/zfcp_* |
10845 | 10869 | ||
10846 | S390 IUCV NETWORK LAYER | 10870 | S390 IUCV NETWORK LAYER |
10871 | M: Julian Wiedmann <jwi@linux.vnet.ibm.com> | ||
10847 | M: Ursula Braun <ubraun@linux.vnet.ibm.com> | 10872 | M: Ursula Braun <ubraun@linux.vnet.ibm.com> |
10848 | L: linux-s390@vger.kernel.org | 10873 | L: linux-s390@vger.kernel.org |
10849 | W: http://www.ibm.com/developerworks/linux/linux390/ | 10874 | W: http://www.ibm.com/developerworks/linux/linux390/ |
@@ -12454,7 +12479,6 @@ F: drivers/clk/ti/ | |||
12454 | F: include/linux/clk/ti.h | 12479 | F: include/linux/clk/ti.h |
12455 | 12480 | ||
12456 | TI ETHERNET SWITCH DRIVER (CPSW) | 12481 | TI ETHERNET SWITCH DRIVER (CPSW) |
12457 | M: Mugunthan V N <mugunthanvnm@ti.com> | ||
12458 | R: Grygorii Strashko <grygorii.strashko@ti.com> | 12482 | R: Grygorii Strashko <grygorii.strashko@ti.com> |
12459 | L: linux-omap@vger.kernel.org | 12483 | L: linux-omap@vger.kernel.org |
12460 | L: netdev@vger.kernel.org | 12484 | L: netdev@vger.kernel.org |
@@ -13295,7 +13319,7 @@ F: drivers/virtio/ | |||
13295 | F: tools/virtio/ | 13319 | F: tools/virtio/ |
13296 | F: drivers/net/virtio_net.c | 13320 | F: drivers/net/virtio_net.c |
13297 | F: drivers/block/virtio_blk.c | 13321 | F: drivers/block/virtio_blk.c |
13298 | F: include/linux/virtio_*.h | 13322 | F: include/linux/virtio*.h |
13299 | F: include/uapi/linux/virtio_*.h | 13323 | F: include/uapi/linux/virtio_*.h |
13300 | F: drivers/crypto/virtio/ | 13324 | F: drivers/crypto/virtio/ |
13301 | 13325 | ||
@@ -1,7 +1,7 @@ | |||
1 | VERSION = 4 | 1 | VERSION = 4 |
2 | PATCHLEVEL = 11 | 2 | PATCHLEVEL = 11 |
3 | SUBLEVEL = 0 | 3 | SUBLEVEL = 0 |
4 | EXTRAVERSION = -rc4 | 4 | EXTRAVERSION = -rc8 |
5 | NAME = Fearless Coyote | 5 | NAME = Fearless Coyote |
6 | 6 | ||
7 | # *DOCUMENTATION* | 7 | # *DOCUMENTATION* |
@@ -372,7 +372,7 @@ LDFLAGS_MODULE = | |||
372 | CFLAGS_KERNEL = | 372 | CFLAGS_KERNEL = |
373 | AFLAGS_KERNEL = | 373 | AFLAGS_KERNEL = |
374 | LDFLAGS_vmlinux = | 374 | LDFLAGS_vmlinux = |
375 | CFLAGS_GCOV = -fprofile-arcs -ftest-coverage -fno-tree-loop-im -Wno-maybe-uninitialized | 375 | CFLAGS_GCOV := -fprofile-arcs -ftest-coverage -fno-tree-loop-im $(call cc-disable-warning,maybe-uninitialized,) |
376 | CFLAGS_KCOV := $(call cc-option,-fsanitize-coverage=trace-pc,) | 376 | CFLAGS_KCOV := $(call cc-option,-fsanitize-coverage=trace-pc,) |
377 | 377 | ||
378 | 378 | ||
@@ -653,6 +653,12 @@ KBUILD_CFLAGS += $(call cc-ifversion, -lt, 0409, \ | |||
653 | # Tell gcc to never replace conditional load with a non-conditional one | 653 | # Tell gcc to never replace conditional load with a non-conditional one |
654 | KBUILD_CFLAGS += $(call cc-option,--param=allow-store-data-races=0) | 654 | KBUILD_CFLAGS += $(call cc-option,--param=allow-store-data-races=0) |
655 | 655 | ||
656 | # check for 'asm goto' | ||
657 | ifeq ($(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-goto.sh $(CC) $(KBUILD_CFLAGS)), y) | ||
658 | KBUILD_CFLAGS += -DCC_HAVE_ASM_GOTO | ||
659 | KBUILD_AFLAGS += -DCC_HAVE_ASM_GOTO | ||
660 | endif | ||
661 | |||
656 | include scripts/Makefile.gcc-plugins | 662 | include scripts/Makefile.gcc-plugins |
657 | 663 | ||
658 | ifdef CONFIG_READABLE_ASM | 664 | ifdef CONFIG_READABLE_ASM |
@@ -798,12 +804,6 @@ KBUILD_CFLAGS += $(call cc-option,-Werror=incompatible-pointer-types) | |||
798 | # use the deterministic mode of AR if available | 804 | # use the deterministic mode of AR if available |
799 | KBUILD_ARFLAGS := $(call ar-option,D) | 805 | KBUILD_ARFLAGS := $(call ar-option,D) |
800 | 806 | ||
801 | # check for 'asm goto' | ||
802 | ifeq ($(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-goto.sh $(CC) $(KBUILD_CFLAGS)), y) | ||
803 | KBUILD_CFLAGS += -DCC_HAVE_ASM_GOTO | ||
804 | KBUILD_AFLAGS += -DCC_HAVE_ASM_GOTO | ||
805 | endif | ||
806 | |||
807 | include scripts/Makefile.kasan | 807 | include scripts/Makefile.kasan |
808 | include scripts/Makefile.extrawarn | 808 | include scripts/Makefile.extrawarn |
809 | include scripts/Makefile.ubsan | 809 | include scripts/Makefile.ubsan |
diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c index 0b961093ca5c..6d76e528ab8f 100644 --- a/arch/alpha/kernel/osf_sys.c +++ b/arch/alpha/kernel/osf_sys.c | |||
@@ -1290,7 +1290,7 @@ SYSCALL_DEFINE1(old_adjtimex, struct timex32 __user *, txc_p) | |||
1290 | /* copy relevant bits of struct timex. */ | 1290 | /* copy relevant bits of struct timex. */ |
1291 | if (copy_from_user(&txc, txc_p, offsetof(struct timex32, time)) || | 1291 | if (copy_from_user(&txc, txc_p, offsetof(struct timex32, time)) || |
1292 | copy_from_user(&txc.tick, &txc_p->tick, sizeof(struct timex32) - | 1292 | copy_from_user(&txc.tick, &txc_p->tick, sizeof(struct timex32) - |
1293 | offsetof(struct timex32, time))) | 1293 | offsetof(struct timex32, tick))) |
1294 | return -EFAULT; | 1294 | return -EFAULT; |
1295 | 1295 | ||
1296 | ret = do_adjtimex(&txc); | 1296 | ret = do_adjtimex(&txc); |
diff --git a/arch/arc/boot/dts/skeleton.dtsi b/arch/arc/boot/dts/skeleton.dtsi index 65808fe0a290..2891cb266cf0 100644 --- a/arch/arc/boot/dts/skeleton.dtsi +++ b/arch/arc/boot/dts/skeleton.dtsi | |||
@@ -26,6 +26,7 @@ | |||
26 | device_type = "cpu"; | 26 | device_type = "cpu"; |
27 | compatible = "snps,arc770d"; | 27 | compatible = "snps,arc770d"; |
28 | reg = <0>; | 28 | reg = <0>; |
29 | clocks = <&core_clk>; | ||
29 | }; | 30 | }; |
30 | }; | 31 | }; |
31 | 32 | ||
diff --git a/arch/arc/boot/dts/skeleton_hs.dtsi b/arch/arc/boot/dts/skeleton_hs.dtsi index 2dfe8037dfbb..5e944d3e5b74 100644 --- a/arch/arc/boot/dts/skeleton_hs.dtsi +++ b/arch/arc/boot/dts/skeleton_hs.dtsi | |||
@@ -21,6 +21,7 @@ | |||
21 | device_type = "cpu"; | 21 | device_type = "cpu"; |
22 | compatible = "snps,archs38"; | 22 | compatible = "snps,archs38"; |
23 | reg = <0>; | 23 | reg = <0>; |
24 | clocks = <&core_clk>; | ||
24 | }; | 25 | }; |
25 | }; | 26 | }; |
26 | 27 | ||
diff --git a/arch/arc/boot/dts/skeleton_hs_idu.dtsi b/arch/arc/boot/dts/skeleton_hs_idu.dtsi index 4c11079f3565..54b277d7dea0 100644 --- a/arch/arc/boot/dts/skeleton_hs_idu.dtsi +++ b/arch/arc/boot/dts/skeleton_hs_idu.dtsi | |||
@@ -19,8 +19,27 @@ | |||
19 | 19 | ||
20 | cpu@0 { | 20 | cpu@0 { |
21 | device_type = "cpu"; | 21 | device_type = "cpu"; |
22 | compatible = "snps,archs38xN"; | 22 | compatible = "snps,archs38"; |
23 | reg = <0>; | 23 | reg = <0>; |
24 | clocks = <&core_clk>; | ||
25 | }; | ||
26 | cpu@1 { | ||
27 | device_type = "cpu"; | ||
28 | compatible = "snps,archs38"; | ||
29 | reg = <1>; | ||
30 | clocks = <&core_clk>; | ||
31 | }; | ||
32 | cpu@2 { | ||
33 | device_type = "cpu"; | ||
34 | compatible = "snps,archs38"; | ||
35 | reg = <2>; | ||
36 | clocks = <&core_clk>; | ||
37 | }; | ||
38 | cpu@3 { | ||
39 | device_type = "cpu"; | ||
40 | compatible = "snps,archs38"; | ||
41 | reg = <3>; | ||
42 | clocks = <&core_clk>; | ||
24 | }; | 43 | }; |
25 | }; | 44 | }; |
26 | 45 | ||
diff --git a/arch/arc/boot/dts/vdk_axs10x_mb.dtsi b/arch/arc/boot/dts/vdk_axs10x_mb.dtsi index f0df59b23e21..459fc656b759 100644 --- a/arch/arc/boot/dts/vdk_axs10x_mb.dtsi +++ b/arch/arc/boot/dts/vdk_axs10x_mb.dtsi | |||
@@ -112,13 +112,19 @@ | |||
112 | interrupts = <7>; | 112 | interrupts = <7>; |
113 | bus-width = <4>; | 113 | bus-width = <4>; |
114 | }; | 114 | }; |
115 | }; | ||
115 | 116 | ||
116 | /* Embedded Vision subsystem UIO mappings; only relevant for EV VDK */ | 117 | /* |
117 | uio_ev: uio@0xD0000000 { | 118 | * Embedded Vision subsystem UIO mappings; only relevant for EV VDK |
118 | compatible = "generic-uio"; | 119 | * |
119 | reg = <0xD0000000 0x2000 0xD1000000 0x2000 0x90000000 0x10000000 0xC0000000 0x10000000>; | 120 | * This node is intentionally put outside of MB above becase |
120 | reg-names = "ev_gsa", "ev_ctrl", "ev_shared_mem", "ev_code_mem"; | 121 | * it maps areas outside of MB's 0xEz-0xFz. |
121 | interrupts = <23>; | 122 | */ |
122 | }; | 123 | uio_ev: uio@0xD0000000 { |
124 | compatible = "generic-uio"; | ||
125 | reg = <0xD0000000 0x2000 0xD1000000 0x2000 0x90000000 0x10000000 0xC0000000 0x10000000>; | ||
126 | reg-names = "ev_gsa", "ev_ctrl", "ev_shared_mem", "ev_code_mem"; | ||
127 | interrupt-parent = <&mb_intc>; | ||
128 | interrupts = <23>; | ||
123 | }; | 129 | }; |
124 | }; | 130 | }; |
diff --git a/arch/arc/include/asm/kprobes.h b/arch/arc/include/asm/kprobes.h index 00bdbe167615..2e52d18e6bc7 100644 --- a/arch/arc/include/asm/kprobes.h +++ b/arch/arc/include/asm/kprobes.h | |||
@@ -54,9 +54,7 @@ int kprobe_fault_handler(struct pt_regs *regs, unsigned long cause); | |||
54 | void kretprobe_trampoline(void); | 54 | void kretprobe_trampoline(void); |
55 | void trap_is_kprobe(unsigned long address, struct pt_regs *regs); | 55 | void trap_is_kprobe(unsigned long address, struct pt_regs *regs); |
56 | #else | 56 | #else |
57 | static void trap_is_kprobe(unsigned long address, struct pt_regs *regs) | 57 | #define trap_is_kprobe(address, regs) |
58 | { | ||
59 | } | ||
60 | #endif /* CONFIG_KPROBES */ | 58 | #endif /* CONFIG_KPROBES */ |
61 | 59 | ||
62 | #endif /* _ARC_KPROBES_H */ | 60 | #endif /* _ARC_KPROBES_H */ |
diff --git a/arch/arc/kernel/entry-arcv2.S b/arch/arc/kernel/entry-arcv2.S index 2585632eaa68..cc558a25b8fa 100644 --- a/arch/arc/kernel/entry-arcv2.S +++ b/arch/arc/kernel/entry-arcv2.S | |||
@@ -100,15 +100,21 @@ END(handle_interrupt) | |||
100 | ;################### Non TLB Exception Handling ############################# | 100 | ;################### Non TLB Exception Handling ############################# |
101 | 101 | ||
102 | ENTRY(EV_SWI) | 102 | ENTRY(EV_SWI) |
103 | flag 1 | 103 | ; TODO: implement this |
104 | EXCEPTION_PROLOGUE | ||
105 | b ret_from_exception | ||
104 | END(EV_SWI) | 106 | END(EV_SWI) |
105 | 107 | ||
106 | ENTRY(EV_DivZero) | 108 | ENTRY(EV_DivZero) |
107 | flag 1 | 109 | ; TODO: implement this |
110 | EXCEPTION_PROLOGUE | ||
111 | b ret_from_exception | ||
108 | END(EV_DivZero) | 112 | END(EV_DivZero) |
109 | 113 | ||
110 | ENTRY(EV_DCError) | 114 | ENTRY(EV_DCError) |
111 | flag 1 | 115 | ; TODO: implement this |
116 | EXCEPTION_PROLOGUE | ||
117 | b ret_from_exception | ||
112 | END(EV_DCError) | 118 | END(EV_DCError) |
113 | 119 | ||
114 | ; --------------------------------------------- | 120 | ; --------------------------------------------- |
diff --git a/arch/arc/kernel/setup.c b/arch/arc/kernel/setup.c index 3093fa898a23..fa62404ba58f 100644 --- a/arch/arc/kernel/setup.c +++ b/arch/arc/kernel/setup.c | |||
@@ -10,6 +10,7 @@ | |||
10 | #include <linux/fs.h> | 10 | #include <linux/fs.h> |
11 | #include <linux/delay.h> | 11 | #include <linux/delay.h> |
12 | #include <linux/root_dev.h> | 12 | #include <linux/root_dev.h> |
13 | #include <linux/clk.h> | ||
13 | #include <linux/clk-provider.h> | 14 | #include <linux/clk-provider.h> |
14 | #include <linux/clocksource.h> | 15 | #include <linux/clocksource.h> |
15 | #include <linux/console.h> | 16 | #include <linux/console.h> |
@@ -488,8 +489,9 @@ static int show_cpuinfo(struct seq_file *m, void *v) | |||
488 | { | 489 | { |
489 | char *str; | 490 | char *str; |
490 | int cpu_id = ptr_to_cpu(v); | 491 | int cpu_id = ptr_to_cpu(v); |
491 | struct device_node *core_clk = of_find_node_by_name(NULL, "core_clk"); | 492 | struct device *cpu_dev = get_cpu_device(cpu_id); |
492 | u32 freq = 0; | 493 | struct clk *cpu_clk; |
494 | unsigned long freq = 0; | ||
493 | 495 | ||
494 | if (!cpu_online(cpu_id)) { | 496 | if (!cpu_online(cpu_id)) { |
495 | seq_printf(m, "processor [%d]\t: Offline\n", cpu_id); | 497 | seq_printf(m, "processor [%d]\t: Offline\n", cpu_id); |
@@ -502,9 +504,15 @@ static int show_cpuinfo(struct seq_file *m, void *v) | |||
502 | 504 | ||
503 | seq_printf(m, arc_cpu_mumbojumbo(cpu_id, str, PAGE_SIZE)); | 505 | seq_printf(m, arc_cpu_mumbojumbo(cpu_id, str, PAGE_SIZE)); |
504 | 506 | ||
505 | of_property_read_u32(core_clk, "clock-frequency", &freq); | 507 | cpu_clk = clk_get(cpu_dev, NULL); |
508 | if (IS_ERR(cpu_clk)) { | ||
509 | seq_printf(m, "CPU speed \t: Cannot get clock for processor [%d]\n", | ||
510 | cpu_id); | ||
511 | } else { | ||
512 | freq = clk_get_rate(cpu_clk); | ||
513 | } | ||
506 | if (freq) | 514 | if (freq) |
507 | seq_printf(m, "CPU speed\t: %u.%02u Mhz\n", | 515 | seq_printf(m, "CPU speed\t: %lu.%02lu Mhz\n", |
508 | freq / 1000000, (freq / 10000) % 100); | 516 | freq / 1000000, (freq / 10000) % 100); |
509 | 517 | ||
510 | seq_printf(m, "Bogo MIPS\t: %lu.%02lu\n", | 518 | seq_printf(m, "Bogo MIPS\t: %lu.%02lu\n", |
diff --git a/arch/arc/mm/cache.c b/arch/arc/mm/cache.c index d408fa21a07c..928562967f3c 100644 --- a/arch/arc/mm/cache.c +++ b/arch/arc/mm/cache.c | |||
@@ -633,6 +633,9 @@ noinline static void slc_entire_op(const int op) | |||
633 | 633 | ||
634 | write_aux_reg(ARC_REG_SLC_INVALIDATE, 1); | 634 | write_aux_reg(ARC_REG_SLC_INVALIDATE, 1); |
635 | 635 | ||
636 | /* Make sure "busy" bit reports correct stataus, see STAR 9001165532 */ | ||
637 | read_aux_reg(r); | ||
638 | |||
636 | /* Important to wait for flush to complete */ | 639 | /* Important to wait for flush to complete */ |
637 | while (read_aux_reg(r) & SLC_CTRL_BUSY); | 640 | while (read_aux_reg(r) & SLC_CTRL_BUSY); |
638 | } | 641 | } |
diff --git a/arch/arm/boot/dts/am335x-baltos.dtsi b/arch/arm/boot/dts/am335x-baltos.dtsi index efb5eae290a8..d42b98f15e8b 100644 --- a/arch/arm/boot/dts/am335x-baltos.dtsi +++ b/arch/arm/boot/dts/am335x-baltos.dtsi | |||
@@ -371,6 +371,8 @@ | |||
371 | 371 | ||
372 | phy1: ethernet-phy@1 { | 372 | phy1: ethernet-phy@1 { |
373 | reg = <7>; | 373 | reg = <7>; |
374 | eee-broken-100tx; | ||
375 | eee-broken-1000t; | ||
374 | }; | 376 | }; |
375 | }; | 377 | }; |
376 | 378 | ||
diff --git a/arch/arm/boot/dts/am335x-evmsk.dts b/arch/arm/boot/dts/am335x-evmsk.dts index 9e43c443738a..9ba4b18c0cb2 100644 --- a/arch/arm/boot/dts/am335x-evmsk.dts +++ b/arch/arm/boot/dts/am335x-evmsk.dts | |||
@@ -672,6 +672,7 @@ | |||
672 | ti,non-removable; | 672 | ti,non-removable; |
673 | bus-width = <4>; | 673 | bus-width = <4>; |
674 | cap-power-off-card; | 674 | cap-power-off-card; |
675 | keep-power-in-suspend; | ||
675 | pinctrl-names = "default"; | 676 | pinctrl-names = "default"; |
676 | pinctrl-0 = <&mmc2_pins>; | 677 | pinctrl-0 = <&mmc2_pins>; |
677 | 678 | ||
diff --git a/arch/arm/boot/dts/dra7.dtsi b/arch/arm/boot/dts/dra7.dtsi index 2c9e56f4aac5..bbfb9d5a70a9 100644 --- a/arch/arm/boot/dts/dra7.dtsi +++ b/arch/arm/boot/dts/dra7.dtsi | |||
@@ -283,6 +283,7 @@ | |||
283 | device_type = "pci"; | 283 | device_type = "pci"; |
284 | ranges = <0x81000000 0 0 0x03000 0 0x00010000 | 284 | ranges = <0x81000000 0 0 0x03000 0 0x00010000 |
285 | 0x82000000 0 0x20013000 0x13000 0 0xffed000>; | 285 | 0x82000000 0 0x20013000 0x13000 0 0xffed000>; |
286 | bus-range = <0x00 0xff>; | ||
286 | #interrupt-cells = <1>; | 287 | #interrupt-cells = <1>; |
287 | num-lanes = <1>; | 288 | num-lanes = <1>; |
288 | linux,pci-domain = <0>; | 289 | linux,pci-domain = <0>; |
@@ -319,6 +320,7 @@ | |||
319 | device_type = "pci"; | 320 | device_type = "pci"; |
320 | ranges = <0x81000000 0 0 0x03000 0 0x00010000 | 321 | ranges = <0x81000000 0 0 0x03000 0 0x00010000 |
321 | 0x82000000 0 0x30013000 0x13000 0 0xffed000>; | 322 | 0x82000000 0 0x30013000 0x13000 0 0xffed000>; |
323 | bus-range = <0x00 0xff>; | ||
322 | #interrupt-cells = <1>; | 324 | #interrupt-cells = <1>; |
323 | num-lanes = <1>; | 325 | num-lanes = <1>; |
324 | linux,pci-domain = <1>; | 326 | linux,pci-domain = <1>; |
diff --git a/arch/arm/boot/dts/logicpd-torpedo-som.dtsi b/arch/arm/boot/dts/logicpd-torpedo-som.dtsi index 8f9a69ca818c..efe53998c961 100644 --- a/arch/arm/boot/dts/logicpd-torpedo-som.dtsi +++ b/arch/arm/boot/dts/logicpd-torpedo-som.dtsi | |||
@@ -121,7 +121,7 @@ | |||
121 | &i2c3 { | 121 | &i2c3 { |
122 | clock-frequency = <400000>; | 122 | clock-frequency = <400000>; |
123 | at24@50 { | 123 | at24@50 { |
124 | compatible = "at24,24c02"; | 124 | compatible = "atmel,24c64"; |
125 | readonly; | 125 | readonly; |
126 | reg = <0x50>; | 126 | reg = <0x50>; |
127 | }; | 127 | }; |
diff --git a/arch/arm/boot/dts/sun8i-a33.dtsi b/arch/arm/boot/dts/sun8i-a33.dtsi index 18c174fef84f..306af6cadf26 100644 --- a/arch/arm/boot/dts/sun8i-a33.dtsi +++ b/arch/arm/boot/dts/sun8i-a33.dtsi | |||
@@ -66,12 +66,6 @@ | |||
66 | opp-microvolt = <1200000>; | 66 | opp-microvolt = <1200000>; |
67 | clock-latency-ns = <244144>; /* 8 32k periods */ | 67 | clock-latency-ns = <244144>; /* 8 32k periods */ |
68 | }; | 68 | }; |
69 | |||
70 | opp@1200000000 { | ||
71 | opp-hz = /bits/ 64 <1200000000>; | ||
72 | opp-microvolt = <1320000>; | ||
73 | clock-latency-ns = <244144>; /* 8 32k periods */ | ||
74 | }; | ||
75 | }; | 69 | }; |
76 | 70 | ||
77 | cpus { | 71 | cpus { |
@@ -81,16 +75,22 @@ | |||
81 | operating-points-v2 = <&cpu0_opp_table>; | 75 | operating-points-v2 = <&cpu0_opp_table>; |
82 | }; | 76 | }; |
83 | 77 | ||
78 | cpu@1 { | ||
79 | operating-points-v2 = <&cpu0_opp_table>; | ||
80 | }; | ||
81 | |||
84 | cpu@2 { | 82 | cpu@2 { |
85 | compatible = "arm,cortex-a7"; | 83 | compatible = "arm,cortex-a7"; |
86 | device_type = "cpu"; | 84 | device_type = "cpu"; |
87 | reg = <2>; | 85 | reg = <2>; |
86 | operating-points-v2 = <&cpu0_opp_table>; | ||
88 | }; | 87 | }; |
89 | 88 | ||
90 | cpu@3 { | 89 | cpu@3 { |
91 | compatible = "arm,cortex-a7"; | 90 | compatible = "arm,cortex-a7"; |
92 | device_type = "cpu"; | 91 | device_type = "cpu"; |
93 | reg = <3>; | 92 | reg = <3>; |
93 | operating-points-v2 = <&cpu0_opp_table>; | ||
94 | }; | 94 | }; |
95 | }; | 95 | }; |
96 | 96 | ||
@@ -113,8 +113,8 @@ | |||
113 | simple-audio-card,mclk-fs = <512>; | 113 | simple-audio-card,mclk-fs = <512>; |
114 | simple-audio-card,aux-devs = <&codec_analog>; | 114 | simple-audio-card,aux-devs = <&codec_analog>; |
115 | simple-audio-card,routing = | 115 | simple-audio-card,routing = |
116 | "Left DAC", "Digital Left DAC", | 116 | "Left DAC", "AIF1 Slot 0 Left", |
117 | "Right DAC", "Digital Right DAC"; | 117 | "Right DAC", "AIF1 Slot 0 Right"; |
118 | status = "disabled"; | 118 | status = "disabled"; |
119 | 119 | ||
120 | simple-audio-card,cpu { | 120 | simple-audio-card,cpu { |
diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c index 96dba7cd8be7..314eb6abe1ff 100644 --- a/arch/arm/kvm/arm.c +++ b/arch/arm/kvm/arm.c | |||
@@ -1124,6 +1124,9 @@ static void cpu_hyp_reinit(void) | |||
1124 | if (__hyp_get_vectors() == hyp_default_vectors) | 1124 | if (__hyp_get_vectors() == hyp_default_vectors) |
1125 | cpu_init_hyp_mode(NULL); | 1125 | cpu_init_hyp_mode(NULL); |
1126 | } | 1126 | } |
1127 | |||
1128 | if (vgic_present) | ||
1129 | kvm_vgic_init_cpu_hardware(); | ||
1127 | } | 1130 | } |
1128 | 1131 | ||
1129 | static void cpu_hyp_reset(void) | 1132 | static void cpu_hyp_reset(void) |
diff --git a/arch/arm/kvm/mmu.c b/arch/arm/kvm/mmu.c index 962616fd4ddd..582a972371cf 100644 --- a/arch/arm/kvm/mmu.c +++ b/arch/arm/kvm/mmu.c | |||
@@ -292,11 +292,18 @@ static void unmap_stage2_range(struct kvm *kvm, phys_addr_t start, u64 size) | |||
292 | phys_addr_t addr = start, end = start + size; | 292 | phys_addr_t addr = start, end = start + size; |
293 | phys_addr_t next; | 293 | phys_addr_t next; |
294 | 294 | ||
295 | assert_spin_locked(&kvm->mmu_lock); | ||
295 | pgd = kvm->arch.pgd + stage2_pgd_index(addr); | 296 | pgd = kvm->arch.pgd + stage2_pgd_index(addr); |
296 | do { | 297 | do { |
297 | next = stage2_pgd_addr_end(addr, end); | 298 | next = stage2_pgd_addr_end(addr, end); |
298 | if (!stage2_pgd_none(*pgd)) | 299 | if (!stage2_pgd_none(*pgd)) |
299 | unmap_stage2_puds(kvm, pgd, addr, next); | 300 | unmap_stage2_puds(kvm, pgd, addr, next); |
301 | /* | ||
302 | * If the range is too large, release the kvm->mmu_lock | ||
303 | * to prevent starvation and lockup detector warnings. | ||
304 | */ | ||
305 | if (next != end) | ||
306 | cond_resched_lock(&kvm->mmu_lock); | ||
300 | } while (pgd++, addr = next, addr != end); | 307 | } while (pgd++, addr = next, addr != end); |
301 | } | 308 | } |
302 | 309 | ||
@@ -803,6 +810,7 @@ void stage2_unmap_vm(struct kvm *kvm) | |||
803 | int idx; | 810 | int idx; |
804 | 811 | ||
805 | idx = srcu_read_lock(&kvm->srcu); | 812 | idx = srcu_read_lock(&kvm->srcu); |
813 | down_read(¤t->mm->mmap_sem); | ||
806 | spin_lock(&kvm->mmu_lock); | 814 | spin_lock(&kvm->mmu_lock); |
807 | 815 | ||
808 | slots = kvm_memslots(kvm); | 816 | slots = kvm_memslots(kvm); |
@@ -810,6 +818,7 @@ void stage2_unmap_vm(struct kvm *kvm) | |||
810 | stage2_unmap_memslot(kvm, memslot); | 818 | stage2_unmap_memslot(kvm, memslot); |
811 | 819 | ||
812 | spin_unlock(&kvm->mmu_lock); | 820 | spin_unlock(&kvm->mmu_lock); |
821 | up_read(¤t->mm->mmap_sem); | ||
813 | srcu_read_unlock(&kvm->srcu, idx); | 822 | srcu_read_unlock(&kvm->srcu, idx); |
814 | } | 823 | } |
815 | 824 | ||
@@ -829,7 +838,10 @@ void kvm_free_stage2_pgd(struct kvm *kvm) | |||
829 | if (kvm->arch.pgd == NULL) | 838 | if (kvm->arch.pgd == NULL) |
830 | return; | 839 | return; |
831 | 840 | ||
841 | spin_lock(&kvm->mmu_lock); | ||
832 | unmap_stage2_range(kvm, 0, KVM_PHYS_SIZE); | 842 | unmap_stage2_range(kvm, 0, KVM_PHYS_SIZE); |
843 | spin_unlock(&kvm->mmu_lock); | ||
844 | |||
833 | /* Free the HW pgd, one page at a time */ | 845 | /* Free the HW pgd, one page at a time */ |
834 | free_pages_exact(kvm->arch.pgd, S2_PGD_SIZE); | 846 | free_pages_exact(kvm->arch.pgd, S2_PGD_SIZE); |
835 | kvm->arch.pgd = NULL; | 847 | kvm->arch.pgd = NULL; |
@@ -1801,6 +1813,7 @@ int kvm_arch_prepare_memory_region(struct kvm *kvm, | |||
1801 | (KVM_PHYS_SIZE >> PAGE_SHIFT)) | 1813 | (KVM_PHYS_SIZE >> PAGE_SHIFT)) |
1802 | return -EFAULT; | 1814 | return -EFAULT; |
1803 | 1815 | ||
1816 | down_read(¤t->mm->mmap_sem); | ||
1804 | /* | 1817 | /* |
1805 | * A memory region could potentially cover multiple VMAs, and any holes | 1818 | * A memory region could potentially cover multiple VMAs, and any holes |
1806 | * between them, so iterate over all of them to find out if we can map | 1819 | * between them, so iterate over all of them to find out if we can map |
@@ -1844,8 +1857,10 @@ int kvm_arch_prepare_memory_region(struct kvm *kvm, | |||
1844 | pa += vm_start - vma->vm_start; | 1857 | pa += vm_start - vma->vm_start; |
1845 | 1858 | ||
1846 | /* IO region dirty page logging not allowed */ | 1859 | /* IO region dirty page logging not allowed */ |
1847 | if (memslot->flags & KVM_MEM_LOG_DIRTY_PAGES) | 1860 | if (memslot->flags & KVM_MEM_LOG_DIRTY_PAGES) { |
1848 | return -EINVAL; | 1861 | ret = -EINVAL; |
1862 | goto out; | ||
1863 | } | ||
1849 | 1864 | ||
1850 | ret = kvm_phys_addr_ioremap(kvm, gpa, pa, | 1865 | ret = kvm_phys_addr_ioremap(kvm, gpa, pa, |
1851 | vm_end - vm_start, | 1866 | vm_end - vm_start, |
@@ -1857,7 +1872,7 @@ int kvm_arch_prepare_memory_region(struct kvm *kvm, | |||
1857 | } while (hva < reg_end); | 1872 | } while (hva < reg_end); |
1858 | 1873 | ||
1859 | if (change == KVM_MR_FLAGS_ONLY) | 1874 | if (change == KVM_MR_FLAGS_ONLY) |
1860 | return ret; | 1875 | goto out; |
1861 | 1876 | ||
1862 | spin_lock(&kvm->mmu_lock); | 1877 | spin_lock(&kvm->mmu_lock); |
1863 | if (ret) | 1878 | if (ret) |
@@ -1865,6 +1880,8 @@ int kvm_arch_prepare_memory_region(struct kvm *kvm, | |||
1865 | else | 1880 | else |
1866 | stage2_flush_memslot(kvm, memslot); | 1881 | stage2_flush_memslot(kvm, memslot); |
1867 | spin_unlock(&kvm->mmu_lock); | 1882 | spin_unlock(&kvm->mmu_lock); |
1883 | out: | ||
1884 | up_read(¤t->mm->mmap_sem); | ||
1868 | return ret; | 1885 | return ret; |
1869 | } | 1886 | } |
1870 | 1887 | ||
diff --git a/arch/arm/mach-omap2/common.h b/arch/arm/mach-omap2/common.h index c4f2ace91ea2..3089d3bfa19b 100644 --- a/arch/arm/mach-omap2/common.h +++ b/arch/arm/mach-omap2/common.h | |||
@@ -270,6 +270,7 @@ extern const struct smp_operations omap4_smp_ops; | |||
270 | extern int omap4_mpuss_init(void); | 270 | extern int omap4_mpuss_init(void); |
271 | extern int omap4_enter_lowpower(unsigned int cpu, unsigned int power_state); | 271 | extern int omap4_enter_lowpower(unsigned int cpu, unsigned int power_state); |
272 | extern int omap4_hotplug_cpu(unsigned int cpu, unsigned int power_state); | 272 | extern int omap4_hotplug_cpu(unsigned int cpu, unsigned int power_state); |
273 | extern u32 omap4_get_cpu1_ns_pa_addr(void); | ||
273 | #else | 274 | #else |
274 | static inline int omap4_enter_lowpower(unsigned int cpu, | 275 | static inline int omap4_enter_lowpower(unsigned int cpu, |
275 | unsigned int power_state) | 276 | unsigned int power_state) |
diff --git a/arch/arm/mach-omap2/omap-hotplug.c b/arch/arm/mach-omap2/omap-hotplug.c index d3fb5661bb5d..433db6d0b073 100644 --- a/arch/arm/mach-omap2/omap-hotplug.c +++ b/arch/arm/mach-omap2/omap-hotplug.c | |||
@@ -50,7 +50,7 @@ void omap4_cpu_die(unsigned int cpu) | |||
50 | omap4_hotplug_cpu(cpu, PWRDM_POWER_OFF); | 50 | omap4_hotplug_cpu(cpu, PWRDM_POWER_OFF); |
51 | 51 | ||
52 | if (omap_secure_apis_support()) | 52 | if (omap_secure_apis_support()) |
53 | boot_cpu = omap_read_auxcoreboot0(); | 53 | boot_cpu = omap_read_auxcoreboot0() >> 9; |
54 | else | 54 | else |
55 | boot_cpu = | 55 | boot_cpu = |
56 | readl_relaxed(base + OMAP_AUX_CORE_BOOT_0) >> 5; | 56 | readl_relaxed(base + OMAP_AUX_CORE_BOOT_0) >> 5; |
diff --git a/arch/arm/mach-omap2/omap-mpuss-lowpower.c b/arch/arm/mach-omap2/omap-mpuss-lowpower.c index 113ab2dd2ee9..03ec6d307c82 100644 --- a/arch/arm/mach-omap2/omap-mpuss-lowpower.c +++ b/arch/arm/mach-omap2/omap-mpuss-lowpower.c | |||
@@ -64,6 +64,7 @@ | |||
64 | #include "prm-regbits-44xx.h" | 64 | #include "prm-regbits-44xx.h" |
65 | 65 | ||
66 | static void __iomem *sar_base; | 66 | static void __iomem *sar_base; |
67 | static u32 old_cpu1_ns_pa_addr; | ||
67 | 68 | ||
68 | #if defined(CONFIG_PM) && defined(CONFIG_SMP) | 69 | #if defined(CONFIG_PM) && defined(CONFIG_SMP) |
69 | 70 | ||
@@ -212,6 +213,11 @@ static void __init save_l2x0_context(void) | |||
212 | {} | 213 | {} |
213 | #endif | 214 | #endif |
214 | 215 | ||
216 | u32 omap4_get_cpu1_ns_pa_addr(void) | ||
217 | { | ||
218 | return old_cpu1_ns_pa_addr; | ||
219 | } | ||
220 | |||
215 | /** | 221 | /** |
216 | * omap4_enter_lowpower: OMAP4 MPUSS Low Power Entry Function | 222 | * omap4_enter_lowpower: OMAP4 MPUSS Low Power Entry Function |
217 | * The purpose of this function is to manage low power programming | 223 | * The purpose of this function is to manage low power programming |
@@ -460,22 +466,30 @@ int __init omap4_mpuss_init(void) | |||
460 | void __init omap4_mpuss_early_init(void) | 466 | void __init omap4_mpuss_early_init(void) |
461 | { | 467 | { |
462 | unsigned long startup_pa; | 468 | unsigned long startup_pa; |
469 | void __iomem *ns_pa_addr; | ||
463 | 470 | ||
464 | if (!(cpu_is_omap44xx() || soc_is_omap54xx())) | 471 | if (!(soc_is_omap44xx() || soc_is_omap54xx())) |
465 | return; | 472 | return; |
466 | 473 | ||
467 | sar_base = omap4_get_sar_ram_base(); | 474 | sar_base = omap4_get_sar_ram_base(); |
468 | 475 | ||
469 | if (cpu_is_omap443x()) | 476 | /* Save old NS_PA_ADDR for validity checks later on */ |
477 | if (soc_is_omap44xx()) | ||
478 | ns_pa_addr = sar_base + CPU1_WAKEUP_NS_PA_ADDR_OFFSET; | ||
479 | else | ||
480 | ns_pa_addr = sar_base + OMAP5_CPU1_WAKEUP_NS_PA_ADDR_OFFSET; | ||
481 | old_cpu1_ns_pa_addr = readl_relaxed(ns_pa_addr); | ||
482 | |||
483 | if (soc_is_omap443x()) | ||
470 | startup_pa = __pa_symbol(omap4_secondary_startup); | 484 | startup_pa = __pa_symbol(omap4_secondary_startup); |
471 | else if (cpu_is_omap446x()) | 485 | else if (soc_is_omap446x()) |
472 | startup_pa = __pa_symbol(omap4460_secondary_startup); | 486 | startup_pa = __pa_symbol(omap4460_secondary_startup); |
473 | else if ((__boot_cpu_mode & MODE_MASK) == HYP_MODE) | 487 | else if ((__boot_cpu_mode & MODE_MASK) == HYP_MODE) |
474 | startup_pa = __pa_symbol(omap5_secondary_hyp_startup); | 488 | startup_pa = __pa_symbol(omap5_secondary_hyp_startup); |
475 | else | 489 | else |
476 | startup_pa = __pa_symbol(omap5_secondary_startup); | 490 | startup_pa = __pa_symbol(omap5_secondary_startup); |
477 | 491 | ||
478 | if (cpu_is_omap44xx()) | 492 | if (soc_is_omap44xx()) |
479 | writel_relaxed(startup_pa, sar_base + | 493 | writel_relaxed(startup_pa, sar_base + |
480 | CPU1_WAKEUP_NS_PA_ADDR_OFFSET); | 494 | CPU1_WAKEUP_NS_PA_ADDR_OFFSET); |
481 | else | 495 | else |
diff --git a/arch/arm/mach-omap2/omap-smc.S b/arch/arm/mach-omap2/omap-smc.S index fd90125bffc7..72506e6cf9e7 100644 --- a/arch/arm/mach-omap2/omap-smc.S +++ b/arch/arm/mach-omap2/omap-smc.S | |||
@@ -94,6 +94,5 @@ ENTRY(omap_read_auxcoreboot0) | |||
94 | ldr r12, =0x103 | 94 | ldr r12, =0x103 |
95 | dsb | 95 | dsb |
96 | smc #0 | 96 | smc #0 |
97 | mov r0, r0, lsr #9 | ||
98 | ldmfd sp!, {r2-r12, pc} | 97 | ldmfd sp!, {r2-r12, pc} |
99 | ENDPROC(omap_read_auxcoreboot0) | 98 | ENDPROC(omap_read_auxcoreboot0) |
diff --git a/arch/arm/mach-omap2/omap-smp.c b/arch/arm/mach-omap2/omap-smp.c index 003353b0b794..3faf454ba487 100644 --- a/arch/arm/mach-omap2/omap-smp.c +++ b/arch/arm/mach-omap2/omap-smp.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #include <linux/io.h> | 21 | #include <linux/io.h> |
22 | #include <linux/irqchip/arm-gic.h> | 22 | #include <linux/irqchip/arm-gic.h> |
23 | 23 | ||
24 | #include <asm/sections.h> | ||
24 | #include <asm/smp_scu.h> | 25 | #include <asm/smp_scu.h> |
25 | #include <asm/virt.h> | 26 | #include <asm/virt.h> |
26 | 27 | ||
@@ -40,10 +41,14 @@ | |||
40 | 41 | ||
41 | #define OMAP5_CORE_COUNT 0x2 | 42 | #define OMAP5_CORE_COUNT 0x2 |
42 | 43 | ||
44 | #define AUX_CORE_BOOT0_GP_RELEASE 0x020 | ||
45 | #define AUX_CORE_BOOT0_HS_RELEASE 0x200 | ||
46 | |||
43 | struct omap_smp_config { | 47 | struct omap_smp_config { |
44 | unsigned long cpu1_rstctrl_pa; | 48 | unsigned long cpu1_rstctrl_pa; |
45 | void __iomem *cpu1_rstctrl_va; | 49 | void __iomem *cpu1_rstctrl_va; |
46 | void __iomem *scu_base; | 50 | void __iomem *scu_base; |
51 | void __iomem *wakeupgen_base; | ||
47 | void *startup_addr; | 52 | void *startup_addr; |
48 | }; | 53 | }; |
49 | 54 | ||
@@ -140,7 +145,6 @@ static int omap4_boot_secondary(unsigned int cpu, struct task_struct *idle) | |||
140 | static struct clockdomain *cpu1_clkdm; | 145 | static struct clockdomain *cpu1_clkdm; |
141 | static bool booted; | 146 | static bool booted; |
142 | static struct powerdomain *cpu1_pwrdm; | 147 | static struct powerdomain *cpu1_pwrdm; |
143 | void __iomem *base = omap_get_wakeupgen_base(); | ||
144 | 148 | ||
145 | /* | 149 | /* |
146 | * Set synchronisation state between this boot processor | 150 | * Set synchronisation state between this boot processor |
@@ -155,9 +159,11 @@ static int omap4_boot_secondary(unsigned int cpu, struct task_struct *idle) | |||
155 | * A barrier is added to ensure that write buffer is drained | 159 | * A barrier is added to ensure that write buffer is drained |
156 | */ | 160 | */ |
157 | if (omap_secure_apis_support()) | 161 | if (omap_secure_apis_support()) |
158 | omap_modify_auxcoreboot0(0x200, 0xfffffdff); | 162 | omap_modify_auxcoreboot0(AUX_CORE_BOOT0_HS_RELEASE, |
163 | 0xfffffdff); | ||
159 | else | 164 | else |
160 | writel_relaxed(0x20, base + OMAP_AUX_CORE_BOOT_0); | 165 | writel_relaxed(AUX_CORE_BOOT0_GP_RELEASE, |
166 | cfg.wakeupgen_base + OMAP_AUX_CORE_BOOT_0); | ||
161 | 167 | ||
162 | if (!cpu1_clkdm && !cpu1_pwrdm) { | 168 | if (!cpu1_clkdm && !cpu1_pwrdm) { |
163 | cpu1_clkdm = clkdm_lookup("mpu1_clkdm"); | 169 | cpu1_clkdm = clkdm_lookup("mpu1_clkdm"); |
@@ -261,9 +267,72 @@ static void __init omap4_smp_init_cpus(void) | |||
261 | set_cpu_possible(i, true); | 267 | set_cpu_possible(i, true); |
262 | } | 268 | } |
263 | 269 | ||
270 | /* | ||
271 | * For now, just make sure the start-up address is not within the booting | ||
272 | * kernel space as that means we just overwrote whatever secondary_startup() | ||
273 | * code there was. | ||
274 | */ | ||
275 | static bool __init omap4_smp_cpu1_startup_valid(unsigned long addr) | ||
276 | { | ||
277 | if ((addr >= __pa(PAGE_OFFSET)) && (addr <= __pa(__bss_start))) | ||
278 | return false; | ||
279 | |||
280 | return true; | ||
281 | } | ||
282 | |||
283 | /* | ||
284 | * We may need to reset CPU1 before configuring, otherwise kexec boot can end | ||
285 | * up trying to use old kernel startup address or suspend-resume will | ||
286 | * occasionally fail to bring up CPU1 on 4430 if CPU1 fails to enter deeper | ||
287 | * idle states. | ||
288 | */ | ||
289 | static void __init omap4_smp_maybe_reset_cpu1(struct omap_smp_config *c) | ||
290 | { | ||
291 | unsigned long cpu1_startup_pa, cpu1_ns_pa_addr; | ||
292 | bool needs_reset = false; | ||
293 | u32 released; | ||
294 | |||
295 | if (omap_secure_apis_support()) | ||
296 | released = omap_read_auxcoreboot0() & AUX_CORE_BOOT0_HS_RELEASE; | ||
297 | else | ||
298 | released = readl_relaxed(cfg.wakeupgen_base + | ||
299 | OMAP_AUX_CORE_BOOT_0) & | ||
300 | AUX_CORE_BOOT0_GP_RELEASE; | ||
301 | if (released) { | ||
302 | pr_warn("smp: CPU1 not parked?\n"); | ||
303 | |||
304 | return; | ||
305 | } | ||
306 | |||
307 | cpu1_startup_pa = readl_relaxed(cfg.wakeupgen_base + | ||
308 | OMAP_AUX_CORE_BOOT_1); | ||
309 | cpu1_ns_pa_addr = omap4_get_cpu1_ns_pa_addr(); | ||
310 | |||
311 | /* Did the configured secondary_startup() get overwritten? */ | ||
312 | if (!omap4_smp_cpu1_startup_valid(cpu1_startup_pa)) | ||
313 | needs_reset = true; | ||
314 | |||
315 | /* | ||
316 | * If omap4 or 5 has NS_PA_ADDR configured, CPU1 may be in a | ||
317 | * deeper idle state in WFI and will wake to an invalid address. | ||
318 | */ | ||
319 | if ((soc_is_omap44xx() || soc_is_omap54xx()) && | ||
320 | !omap4_smp_cpu1_startup_valid(cpu1_ns_pa_addr)) | ||
321 | needs_reset = true; | ||
322 | |||
323 | if (!needs_reset || !c->cpu1_rstctrl_va) | ||
324 | return; | ||
325 | |||
326 | pr_info("smp: CPU1 parked within kernel, needs reset (0x%lx 0x%lx)\n", | ||
327 | cpu1_startup_pa, cpu1_ns_pa_addr); | ||
328 | |||
329 | writel_relaxed(1, c->cpu1_rstctrl_va); | ||
330 | readl_relaxed(c->cpu1_rstctrl_va); | ||
331 | writel_relaxed(0, c->cpu1_rstctrl_va); | ||
332 | } | ||
333 | |||
264 | static void __init omap4_smp_prepare_cpus(unsigned int max_cpus) | 334 | static void __init omap4_smp_prepare_cpus(unsigned int max_cpus) |
265 | { | 335 | { |
266 | void __iomem *base = omap_get_wakeupgen_base(); | ||
267 | const struct omap_smp_config *c = NULL; | 336 | const struct omap_smp_config *c = NULL; |
268 | 337 | ||
269 | if (soc_is_omap443x()) | 338 | if (soc_is_omap443x()) |
@@ -281,6 +350,7 @@ static void __init omap4_smp_prepare_cpus(unsigned int max_cpus) | |||
281 | /* Must preserve cfg.scu_base set earlier */ | 350 | /* Must preserve cfg.scu_base set earlier */ |
282 | cfg.cpu1_rstctrl_pa = c->cpu1_rstctrl_pa; | 351 | cfg.cpu1_rstctrl_pa = c->cpu1_rstctrl_pa; |
283 | cfg.startup_addr = c->startup_addr; | 352 | cfg.startup_addr = c->startup_addr; |
353 | cfg.wakeupgen_base = omap_get_wakeupgen_base(); | ||
284 | 354 | ||
285 | if (soc_is_dra74x() || soc_is_omap54xx()) { | 355 | if (soc_is_dra74x() || soc_is_omap54xx()) { |
286 | if ((__boot_cpu_mode & MODE_MASK) == HYP_MODE) | 356 | if ((__boot_cpu_mode & MODE_MASK) == HYP_MODE) |
@@ -299,15 +369,7 @@ static void __init omap4_smp_prepare_cpus(unsigned int max_cpus) | |||
299 | if (cfg.scu_base) | 369 | if (cfg.scu_base) |
300 | scu_enable(cfg.scu_base); | 370 | scu_enable(cfg.scu_base); |
301 | 371 | ||
302 | /* | 372 | omap4_smp_maybe_reset_cpu1(&cfg); |
303 | * Reset CPU1 before configuring, otherwise kexec will | ||
304 | * end up trying to use old kernel startup address. | ||
305 | */ | ||
306 | if (cfg.cpu1_rstctrl_va) { | ||
307 | writel_relaxed(1, cfg.cpu1_rstctrl_va); | ||
308 | readl_relaxed(cfg.cpu1_rstctrl_va); | ||
309 | writel_relaxed(0, cfg.cpu1_rstctrl_va); | ||
310 | } | ||
311 | 373 | ||
312 | /* | 374 | /* |
313 | * Write the address of secondary startup routine into the | 375 | * Write the address of secondary startup routine into the |
@@ -319,7 +381,7 @@ static void __init omap4_smp_prepare_cpus(unsigned int max_cpus) | |||
319 | omap_auxcoreboot_addr(__pa_symbol(cfg.startup_addr)); | 381 | omap_auxcoreboot_addr(__pa_symbol(cfg.startup_addr)); |
320 | else | 382 | else |
321 | writel_relaxed(__pa_symbol(cfg.startup_addr), | 383 | writel_relaxed(__pa_symbol(cfg.startup_addr), |
322 | base + OMAP_AUX_CORE_BOOT_1); | 384 | cfg.wakeupgen_base + OMAP_AUX_CORE_BOOT_1); |
323 | } | 385 | } |
324 | 386 | ||
325 | const struct smp_operations omap4_smp_ops __initconst = { | 387 | const struct smp_operations omap4_smp_ops __initconst = { |
diff --git a/arch/arm/mach-omap2/omap_device.c b/arch/arm/mach-omap2/omap_device.c index e920dd83e443..f989145480c8 100644 --- a/arch/arm/mach-omap2/omap_device.c +++ b/arch/arm/mach-omap2/omap_device.c | |||
@@ -222,6 +222,14 @@ static int _omap_device_notifier_call(struct notifier_block *nb, | |||
222 | dev_err(dev, "failed to idle\n"); | 222 | dev_err(dev, "failed to idle\n"); |
223 | } | 223 | } |
224 | break; | 224 | break; |
225 | case BUS_NOTIFY_BIND_DRIVER: | ||
226 | od = to_omap_device(pdev); | ||
227 | if (od && (od->_state == OMAP_DEVICE_STATE_ENABLED) && | ||
228 | pm_runtime_status_suspended(dev)) { | ||
229 | od->_driver_status = BUS_NOTIFY_BIND_DRIVER; | ||
230 | pm_runtime_set_active(dev); | ||
231 | } | ||
232 | break; | ||
225 | case BUS_NOTIFY_ADD_DEVICE: | 233 | case BUS_NOTIFY_ADD_DEVICE: |
226 | if (pdev->dev.of_node) | 234 | if (pdev->dev.of_node) |
227 | omap_device_build_from_dt(pdev); | 235 | omap_device_build_from_dt(pdev); |
diff --git a/arch/arm/mach-orion5x/Kconfig b/arch/arm/mach-orion5x/Kconfig index 633442ad4e4c..2a7bb6ccdcb7 100644 --- a/arch/arm/mach-orion5x/Kconfig +++ b/arch/arm/mach-orion5x/Kconfig | |||
@@ -6,6 +6,7 @@ menuconfig ARCH_ORION5X | |||
6 | select GPIOLIB | 6 | select GPIOLIB |
7 | select MVEBU_MBUS | 7 | select MVEBU_MBUS |
8 | select PCI | 8 | select PCI |
9 | select PHYLIB if NETDEVICES | ||
9 | select PLAT_ORION_LEGACY | 10 | select PLAT_ORION_LEGACY |
10 | help | 11 | help |
11 | Support for the following Marvell Orion 5x series SoCs: | 12 | Support for the following Marvell Orion 5x series SoCs: |
diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c index 63eabb06f9f1..475811f5383a 100644 --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c | |||
@@ -935,13 +935,31 @@ static void arm_coherent_dma_free(struct device *dev, size_t size, void *cpu_add | |||
935 | __arm_dma_free(dev, size, cpu_addr, handle, attrs, true); | 935 | __arm_dma_free(dev, size, cpu_addr, handle, attrs, true); |
936 | } | 936 | } |
937 | 937 | ||
938 | /* | ||
939 | * The whole dma_get_sgtable() idea is fundamentally unsafe - it seems | ||
940 | * that the intention is to allow exporting memory allocated via the | ||
941 | * coherent DMA APIs through the dma_buf API, which only accepts a | ||
942 | * scattertable. This presents a couple of problems: | ||
943 | * 1. Not all memory allocated via the coherent DMA APIs is backed by | ||
944 | * a struct page | ||
945 | * 2. Passing coherent DMA memory into the streaming APIs is not allowed | ||
946 | * as we will try to flush the memory through a different alias to that | ||
947 | * actually being used (and the flushes are redundant.) | ||
948 | */ | ||
938 | int arm_dma_get_sgtable(struct device *dev, struct sg_table *sgt, | 949 | int arm_dma_get_sgtable(struct device *dev, struct sg_table *sgt, |
939 | void *cpu_addr, dma_addr_t handle, size_t size, | 950 | void *cpu_addr, dma_addr_t handle, size_t size, |
940 | unsigned long attrs) | 951 | unsigned long attrs) |
941 | { | 952 | { |
942 | struct page *page = pfn_to_page(dma_to_pfn(dev, handle)); | 953 | unsigned long pfn = dma_to_pfn(dev, handle); |
954 | struct page *page; | ||
943 | int ret; | 955 | int ret; |
944 | 956 | ||
957 | /* If the PFN is not valid, we do not have a struct page */ | ||
958 | if (!pfn_valid(pfn)) | ||
959 | return -ENXIO; | ||
960 | |||
961 | page = pfn_to_page(pfn); | ||
962 | |||
945 | ret = sg_alloc_table(sgt, 1, GFP_KERNEL); | 963 | ret = sg_alloc_table(sgt, 1, GFP_KERNEL); |
946 | if (unlikely(ret)) | 964 | if (unlikely(ret)) |
947 | return ret; | 965 | return ret; |
diff --git a/arch/arm/mm/nommu.c b/arch/arm/mm/nommu.c index 3b5c7aaf9c76..33a45bd96860 100644 --- a/arch/arm/mm/nommu.c +++ b/arch/arm/mm/nommu.c | |||
@@ -303,7 +303,10 @@ static inline void set_vbar(unsigned long val) | |||
303 | */ | 303 | */ |
304 | static inline bool security_extensions_enabled(void) | 304 | static inline bool security_extensions_enabled(void) |
305 | { | 305 | { |
306 | return !!cpuid_feature_extract(CPUID_EXT_PFR1, 4); | 306 | /* Check CPUID Identification Scheme before ID_PFR1 read */ |
307 | if ((read_cpuid_id() & 0x000f0000) == 0x000f0000) | ||
308 | return !!cpuid_feature_extract(CPUID_EXT_PFR1, 4); | ||
309 | return 0; | ||
307 | } | 310 | } |
308 | 311 | ||
309 | static unsigned long __init setup_vectors_base(void) | 312 | static unsigned long __init setup_vectors_base(void) |
diff --git a/arch/arm/plat-orion/common.c b/arch/arm/plat-orion/common.c index 9255b6d67ba5..aff6994950ba 100644 --- a/arch/arm/plat-orion/common.c +++ b/arch/arm/plat-orion/common.c | |||
@@ -468,6 +468,7 @@ void __init orion_ge11_init(struct mv643xx_eth_platform_data *eth_data, | |||
468 | eth_data, &orion_ge11); | 468 | eth_data, &orion_ge11); |
469 | } | 469 | } |
470 | 470 | ||
471 | #ifdef CONFIG_ARCH_ORION5X | ||
471 | /***************************************************************************** | 472 | /***************************************************************************** |
472 | * Ethernet switch | 473 | * Ethernet switch |
473 | ****************************************************************************/ | 474 | ****************************************************************************/ |
@@ -480,6 +481,9 @@ void __init orion_ge00_switch_init(struct dsa_chip_data *d) | |||
480 | struct mdio_board_info *bd; | 481 | struct mdio_board_info *bd; |
481 | unsigned int i; | 482 | unsigned int i; |
482 | 483 | ||
484 | if (!IS_BUILTIN(CONFIG_PHYLIB)) | ||
485 | return; | ||
486 | |||
483 | for (i = 0; i < ARRAY_SIZE(d->port_names); i++) | 487 | for (i = 0; i < ARRAY_SIZE(d->port_names); i++) |
484 | if (!strcmp(d->port_names[i], "cpu")) | 488 | if (!strcmp(d->port_names[i], "cpu")) |
485 | break; | 489 | break; |
@@ -493,6 +497,7 @@ void __init orion_ge00_switch_init(struct dsa_chip_data *d) | |||
493 | 497 | ||
494 | mdiobus_register_board_info(&orion_ge00_switch_board_info, 1); | 498 | mdiobus_register_board_info(&orion_ge00_switch_board_info, 1); |
495 | } | 499 | } |
500 | #endif | ||
496 | 501 | ||
497 | /***************************************************************************** | 502 | /***************************************************************************** |
498 | * I2C | 503 | * I2C |
diff --git a/arch/arm/probes/kprobes/core.c b/arch/arm/probes/kprobes/core.c index b6dc9d838a9a..ad1f4e6a9e33 100644 --- a/arch/arm/probes/kprobes/core.c +++ b/arch/arm/probes/kprobes/core.c | |||
@@ -266,11 +266,20 @@ void __kprobes kprobe_handler(struct pt_regs *regs) | |||
266 | #endif | 266 | #endif |
267 | 267 | ||
268 | if (p) { | 268 | if (p) { |
269 | if (cur) { | 269 | if (!p->ainsn.insn_check_cc(regs->ARM_cpsr)) { |
270 | /* | ||
271 | * Probe hit but conditional execution check failed, | ||
272 | * so just skip the instruction and continue as if | ||
273 | * nothing had happened. | ||
274 | * In this case, we can skip recursing check too. | ||
275 | */ | ||
276 | singlestep_skip(p, regs); | ||
277 | } else if (cur) { | ||
270 | /* Kprobe is pending, so we're recursing. */ | 278 | /* Kprobe is pending, so we're recursing. */ |
271 | switch (kcb->kprobe_status) { | 279 | switch (kcb->kprobe_status) { |
272 | case KPROBE_HIT_ACTIVE: | 280 | case KPROBE_HIT_ACTIVE: |
273 | case KPROBE_HIT_SSDONE: | 281 | case KPROBE_HIT_SSDONE: |
282 | case KPROBE_HIT_SS: | ||
274 | /* A pre- or post-handler probe got us here. */ | 283 | /* A pre- or post-handler probe got us here. */ |
275 | kprobes_inc_nmissed_count(p); | 284 | kprobes_inc_nmissed_count(p); |
276 | save_previous_kprobe(kcb); | 285 | save_previous_kprobe(kcb); |
@@ -279,11 +288,16 @@ void __kprobes kprobe_handler(struct pt_regs *regs) | |||
279 | singlestep(p, regs, kcb); | 288 | singlestep(p, regs, kcb); |
280 | restore_previous_kprobe(kcb); | 289 | restore_previous_kprobe(kcb); |
281 | break; | 290 | break; |
291 | case KPROBE_REENTER: | ||
292 | /* A nested probe was hit in FIQ, it is a BUG */ | ||
293 | pr_warn("Unrecoverable kprobe detected at %p.\n", | ||
294 | p->addr); | ||
295 | /* fall through */ | ||
282 | default: | 296 | default: |
283 | /* impossible cases */ | 297 | /* impossible cases */ |
284 | BUG(); | 298 | BUG(); |
285 | } | 299 | } |
286 | } else if (p->ainsn.insn_check_cc(regs->ARM_cpsr)) { | 300 | } else { |
287 | /* Probe hit and conditional execution check ok. */ | 301 | /* Probe hit and conditional execution check ok. */ |
288 | set_current_kprobe(p); | 302 | set_current_kprobe(p); |
289 | kcb->kprobe_status = KPROBE_HIT_ACTIVE; | 303 | kcb->kprobe_status = KPROBE_HIT_ACTIVE; |
@@ -304,13 +318,6 @@ void __kprobes kprobe_handler(struct pt_regs *regs) | |||
304 | } | 318 | } |
305 | reset_current_kprobe(); | 319 | reset_current_kprobe(); |
306 | } | 320 | } |
307 | } else { | ||
308 | /* | ||
309 | * Probe hit but conditional execution check failed, | ||
310 | * so just skip the instruction and continue as if | ||
311 | * nothing had happened. | ||
312 | */ | ||
313 | singlestep_skip(p, regs); | ||
314 | } | 321 | } |
315 | } else if (cur) { | 322 | } else if (cur) { |
316 | /* We probably hit a jprobe. Call its break handler. */ | 323 | /* We probably hit a jprobe. Call its break handler. */ |
@@ -434,6 +441,7 @@ static __used __kprobes void *trampoline_handler(struct pt_regs *regs) | |||
434 | struct hlist_node *tmp; | 441 | struct hlist_node *tmp; |
435 | unsigned long flags, orig_ret_address = 0; | 442 | unsigned long flags, orig_ret_address = 0; |
436 | unsigned long trampoline_address = (unsigned long)&kretprobe_trampoline; | 443 | unsigned long trampoline_address = (unsigned long)&kretprobe_trampoline; |
444 | kprobe_opcode_t *correct_ret_addr = NULL; | ||
437 | 445 | ||
438 | INIT_HLIST_HEAD(&empty_rp); | 446 | INIT_HLIST_HEAD(&empty_rp); |
439 | kretprobe_hash_lock(current, &head, &flags); | 447 | kretprobe_hash_lock(current, &head, &flags); |
@@ -456,14 +464,34 @@ static __used __kprobes void *trampoline_handler(struct pt_regs *regs) | |||
456 | /* another task is sharing our hash bucket */ | 464 | /* another task is sharing our hash bucket */ |
457 | continue; | 465 | continue; |
458 | 466 | ||
467 | orig_ret_address = (unsigned long)ri->ret_addr; | ||
468 | |||
469 | if (orig_ret_address != trampoline_address) | ||
470 | /* | ||
471 | * This is the real return address. Any other | ||
472 | * instances associated with this task are for | ||
473 | * other calls deeper on the call stack | ||
474 | */ | ||
475 | break; | ||
476 | } | ||
477 | |||
478 | kretprobe_assert(ri, orig_ret_address, trampoline_address); | ||
479 | |||
480 | correct_ret_addr = ri->ret_addr; | ||
481 | hlist_for_each_entry_safe(ri, tmp, head, hlist) { | ||
482 | if (ri->task != current) | ||
483 | /* another task is sharing our hash bucket */ | ||
484 | continue; | ||
485 | |||
486 | orig_ret_address = (unsigned long)ri->ret_addr; | ||
459 | if (ri->rp && ri->rp->handler) { | 487 | if (ri->rp && ri->rp->handler) { |
460 | __this_cpu_write(current_kprobe, &ri->rp->kp); | 488 | __this_cpu_write(current_kprobe, &ri->rp->kp); |
461 | get_kprobe_ctlblk()->kprobe_status = KPROBE_HIT_ACTIVE; | 489 | get_kprobe_ctlblk()->kprobe_status = KPROBE_HIT_ACTIVE; |
490 | ri->ret_addr = correct_ret_addr; | ||
462 | ri->rp->handler(ri, regs); | 491 | ri->rp->handler(ri, regs); |
463 | __this_cpu_write(current_kprobe, NULL); | 492 | __this_cpu_write(current_kprobe, NULL); |
464 | } | 493 | } |
465 | 494 | ||
466 | orig_ret_address = (unsigned long)ri->ret_addr; | ||
467 | recycle_rp_inst(ri, &empty_rp); | 495 | recycle_rp_inst(ri, &empty_rp); |
468 | 496 | ||
469 | if (orig_ret_address != trampoline_address) | 497 | if (orig_ret_address != trampoline_address) |
@@ -475,7 +503,6 @@ static __used __kprobes void *trampoline_handler(struct pt_regs *regs) | |||
475 | break; | 503 | break; |
476 | } | 504 | } |
477 | 505 | ||
478 | kretprobe_assert(ri, orig_ret_address, trampoline_address); | ||
479 | kretprobe_hash_unlock(current, &flags); | 506 | kretprobe_hash_unlock(current, &flags); |
480 | 507 | ||
481 | hlist_for_each_entry_safe(ri, tmp, &empty_rp, hlist) { | 508 | hlist_for_each_entry_safe(ri, tmp, &empty_rp, hlist) { |
diff --git a/arch/arm/probes/kprobes/test-core.c b/arch/arm/probes/kprobes/test-core.c index c893726aa52d..1c98a87786ca 100644 --- a/arch/arm/probes/kprobes/test-core.c +++ b/arch/arm/probes/kprobes/test-core.c | |||
@@ -977,7 +977,10 @@ static void coverage_end(void) | |||
977 | void __naked __kprobes_test_case_start(void) | 977 | void __naked __kprobes_test_case_start(void) |
978 | { | 978 | { |
979 | __asm__ __volatile__ ( | 979 | __asm__ __volatile__ ( |
980 | "stmdb sp!, {r4-r11} \n\t" | 980 | "mov r2, sp \n\t" |
981 | "bic r3, r2, #7 \n\t" | ||
982 | "mov sp, r3 \n\t" | ||
983 | "stmdb sp!, {r2-r11} \n\t" | ||
981 | "sub sp, sp, #"__stringify(TEST_MEMORY_SIZE)"\n\t" | 984 | "sub sp, sp, #"__stringify(TEST_MEMORY_SIZE)"\n\t" |
982 | "bic r0, lr, #1 @ r0 = inline data \n\t" | 985 | "bic r0, lr, #1 @ r0 = inline data \n\t" |
983 | "mov r1, sp \n\t" | 986 | "mov r1, sp \n\t" |
@@ -997,7 +1000,8 @@ void __naked __kprobes_test_case_end_32(void) | |||
997 | "movne pc, r0 \n\t" | 1000 | "movne pc, r0 \n\t" |
998 | "mov r0, r4 \n\t" | 1001 | "mov r0, r4 \n\t" |
999 | "add sp, sp, #"__stringify(TEST_MEMORY_SIZE)"\n\t" | 1002 | "add sp, sp, #"__stringify(TEST_MEMORY_SIZE)"\n\t" |
1000 | "ldmia sp!, {r4-r11} \n\t" | 1003 | "ldmia sp!, {r2-r11} \n\t" |
1004 | "mov sp, r2 \n\t" | ||
1001 | "mov pc, r0 \n\t" | 1005 | "mov pc, r0 \n\t" |
1002 | ); | 1006 | ); |
1003 | } | 1007 | } |
@@ -1013,7 +1017,8 @@ void __naked __kprobes_test_case_end_16(void) | |||
1013 | "bxne r0 \n\t" | 1017 | "bxne r0 \n\t" |
1014 | "mov r0, r4 \n\t" | 1018 | "mov r0, r4 \n\t" |
1015 | "add sp, sp, #"__stringify(TEST_MEMORY_SIZE)"\n\t" | 1019 | "add sp, sp, #"__stringify(TEST_MEMORY_SIZE)"\n\t" |
1016 | "ldmia sp!, {r4-r11} \n\t" | 1020 | "ldmia sp!, {r2-r11} \n\t" |
1021 | "mov sp, r2 \n\t" | ||
1017 | "bx r0 \n\t" | 1022 | "bx r0 \n\t" |
1018 | ); | 1023 | ); |
1019 | } | 1024 | } |
diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi b/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi index 1c64ea2d23f9..0565779e66fa 100644 --- a/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi +++ b/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi | |||
@@ -179,8 +179,10 @@ | |||
179 | usbphy: phy@01c19400 { | 179 | usbphy: phy@01c19400 { |
180 | compatible = "allwinner,sun50i-a64-usb-phy"; | 180 | compatible = "allwinner,sun50i-a64-usb-phy"; |
181 | reg = <0x01c19400 0x14>, | 181 | reg = <0x01c19400 0x14>, |
182 | <0x01c1a800 0x4>, | ||
182 | <0x01c1b800 0x4>; | 183 | <0x01c1b800 0x4>; |
183 | reg-names = "phy_ctrl", | 184 | reg-names = "phy_ctrl", |
185 | "pmu0", | ||
184 | "pmu1"; | 186 | "pmu1"; |
185 | clocks = <&ccu CLK_USB_PHY0>, | 187 | clocks = <&ccu CLK_USB_PHY0>, |
186 | <&ccu CLK_USB_PHY1>; | 188 | <&ccu CLK_USB_PHY1>; |
diff --git a/arch/arm64/include/asm/current.h b/arch/arm64/include/asm/current.h index 86c404171305..f6580d4afb0e 100644 --- a/arch/arm64/include/asm/current.h +++ b/arch/arm64/include/asm/current.h | |||
@@ -3,8 +3,6 @@ | |||
3 | 3 | ||
4 | #include <linux/compiler.h> | 4 | #include <linux/compiler.h> |
5 | 5 | ||
6 | #include <asm/sysreg.h> | ||
7 | |||
8 | #ifndef __ASSEMBLY__ | 6 | #ifndef __ASSEMBLY__ |
9 | 7 | ||
10 | struct task_struct; | 8 | struct task_struct; |
diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c index ef1caae02110..9b1036570586 100644 --- a/arch/arm64/kernel/smp.c +++ b/arch/arm64/kernel/smp.c | |||
@@ -944,7 +944,7 @@ static bool have_cpu_die(void) | |||
944 | #ifdef CONFIG_HOTPLUG_CPU | 944 | #ifdef CONFIG_HOTPLUG_CPU |
945 | int any_cpu = raw_smp_processor_id(); | 945 | int any_cpu = raw_smp_processor_id(); |
946 | 946 | ||
947 | if (cpu_ops[any_cpu]->cpu_die) | 947 | if (cpu_ops[any_cpu] && cpu_ops[any_cpu]->cpu_die) |
948 | return true; | 948 | return true; |
949 | #endif | 949 | #endif |
950 | return false; | 950 | return false; |
diff --git a/arch/arm64/kernel/vdso/.gitignore b/arch/arm64/kernel/vdso/.gitignore index b8cc94e9698b..f8b69d84238e 100644 --- a/arch/arm64/kernel/vdso/.gitignore +++ b/arch/arm64/kernel/vdso/.gitignore | |||
@@ -1,2 +1 @@ | |||
1 | vdso.lds | vdso.lds | |
2 | vdso-offsets.h | ||
diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c index 4bf899fb451b..1b35b8bddbfb 100644 --- a/arch/arm64/mm/fault.c +++ b/arch/arm64/mm/fault.c | |||
@@ -42,7 +42,20 @@ | |||
42 | #include <asm/pgtable.h> | 42 | #include <asm/pgtable.h> |
43 | #include <asm/tlbflush.h> | 43 | #include <asm/tlbflush.h> |
44 | 44 | ||
45 | static const char *fault_name(unsigned int esr); | 45 | struct fault_info { |
46 | int (*fn)(unsigned long addr, unsigned int esr, | ||
47 | struct pt_regs *regs); | ||
48 | int sig; | ||
49 | int code; | ||
50 | const char *name; | ||
51 | }; | ||
52 | |||
53 | static const struct fault_info fault_info[]; | ||
54 | |||
55 | static inline const struct fault_info *esr_to_fault_info(unsigned int esr) | ||
56 | { | ||
57 | return fault_info + (esr & 63); | ||
58 | } | ||
46 | 59 | ||
47 | #ifdef CONFIG_KPROBES | 60 | #ifdef CONFIG_KPROBES |
48 | static inline int notify_page_fault(struct pt_regs *regs, unsigned int esr) | 61 | static inline int notify_page_fault(struct pt_regs *regs, unsigned int esr) |
@@ -197,10 +210,12 @@ static void __do_user_fault(struct task_struct *tsk, unsigned long addr, | |||
197 | struct pt_regs *regs) | 210 | struct pt_regs *regs) |
198 | { | 211 | { |
199 | struct siginfo si; | 212 | struct siginfo si; |
213 | const struct fault_info *inf; | ||
200 | 214 | ||
201 | if (unhandled_signal(tsk, sig) && show_unhandled_signals_ratelimited()) { | 215 | if (unhandled_signal(tsk, sig) && show_unhandled_signals_ratelimited()) { |
216 | inf = esr_to_fault_info(esr); | ||
202 | pr_info("%s[%d]: unhandled %s (%d) at 0x%08lx, esr 0x%03x\n", | 217 | pr_info("%s[%d]: unhandled %s (%d) at 0x%08lx, esr 0x%03x\n", |
203 | tsk->comm, task_pid_nr(tsk), fault_name(esr), sig, | 218 | tsk->comm, task_pid_nr(tsk), inf->name, sig, |
204 | addr, esr); | 219 | addr, esr); |
205 | show_pte(tsk->mm, addr); | 220 | show_pte(tsk->mm, addr); |
206 | show_regs(regs); | 221 | show_regs(regs); |
@@ -219,14 +234,16 @@ static void do_bad_area(unsigned long addr, unsigned int esr, struct pt_regs *re | |||
219 | { | 234 | { |
220 | struct task_struct *tsk = current; | 235 | struct task_struct *tsk = current; |
221 | struct mm_struct *mm = tsk->active_mm; | 236 | struct mm_struct *mm = tsk->active_mm; |
237 | const struct fault_info *inf; | ||
222 | 238 | ||
223 | /* | 239 | /* |
224 | * If we are in kernel mode at this point, we have no context to | 240 | * If we are in kernel mode at this point, we have no context to |
225 | * handle this fault with. | 241 | * handle this fault with. |
226 | */ | 242 | */ |
227 | if (user_mode(regs)) | 243 | if (user_mode(regs)) { |
228 | __do_user_fault(tsk, addr, esr, SIGSEGV, SEGV_MAPERR, regs); | 244 | inf = esr_to_fault_info(esr); |
229 | else | 245 | __do_user_fault(tsk, addr, esr, inf->sig, inf->code, regs); |
246 | } else | ||
230 | __do_kernel_fault(mm, addr, esr, regs); | 247 | __do_kernel_fault(mm, addr, esr, regs); |
231 | } | 248 | } |
232 | 249 | ||
@@ -488,12 +505,7 @@ static int do_bad(unsigned long addr, unsigned int esr, struct pt_regs *regs) | |||
488 | return 1; | 505 | return 1; |
489 | } | 506 | } |
490 | 507 | ||
491 | static const struct fault_info { | 508 | static const struct fault_info fault_info[] = { |
492 | int (*fn)(unsigned long addr, unsigned int esr, struct pt_regs *regs); | ||
493 | int sig; | ||
494 | int code; | ||
495 | const char *name; | ||
496 | } fault_info[] = { | ||
497 | { do_bad, SIGBUS, 0, "ttbr address size fault" }, | 509 | { do_bad, SIGBUS, 0, "ttbr address size fault" }, |
498 | { do_bad, SIGBUS, 0, "level 1 address size fault" }, | 510 | { do_bad, SIGBUS, 0, "level 1 address size fault" }, |
499 | { do_bad, SIGBUS, 0, "level 2 address size fault" }, | 511 | { do_bad, SIGBUS, 0, "level 2 address size fault" }, |
@@ -560,19 +572,13 @@ static const struct fault_info { | |||
560 | { do_bad, SIGBUS, 0, "unknown 63" }, | 572 | { do_bad, SIGBUS, 0, "unknown 63" }, |
561 | }; | 573 | }; |
562 | 574 | ||
563 | static const char *fault_name(unsigned int esr) | ||
564 | { | ||
565 | const struct fault_info *inf = fault_info + (esr & 63); | ||
566 | return inf->name; | ||
567 | } | ||
568 | |||
569 | /* | 575 | /* |
570 | * Dispatch a data abort to the relevant handler. | 576 | * Dispatch a data abort to the relevant handler. |
571 | */ | 577 | */ |
572 | asmlinkage void __exception do_mem_abort(unsigned long addr, unsigned int esr, | 578 | asmlinkage void __exception do_mem_abort(unsigned long addr, unsigned int esr, |
573 | struct pt_regs *regs) | 579 | struct pt_regs *regs) |
574 | { | 580 | { |
575 | const struct fault_info *inf = fault_info + (esr & 63); | 581 | const struct fault_info *inf = esr_to_fault_info(esr); |
576 | struct siginfo info; | 582 | struct siginfo info; |
577 | 583 | ||
578 | if (!inf->fn(addr, esr, regs)) | 584 | if (!inf->fn(addr, esr, regs)) |
diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c index e25584d72396..7514a000e361 100644 --- a/arch/arm64/mm/hugetlbpage.c +++ b/arch/arm64/mm/hugetlbpage.c | |||
@@ -294,10 +294,6 @@ static __init int setup_hugepagesz(char *opt) | |||
294 | hugetlb_add_hstate(PMD_SHIFT - PAGE_SHIFT); | 294 | hugetlb_add_hstate(PMD_SHIFT - PAGE_SHIFT); |
295 | } else if (ps == PUD_SIZE) { | 295 | } else if (ps == PUD_SIZE) { |
296 | hugetlb_add_hstate(PUD_SHIFT - PAGE_SHIFT); | 296 | hugetlb_add_hstate(PUD_SHIFT - PAGE_SHIFT); |
297 | } else if (ps == (PAGE_SIZE * CONT_PTES)) { | ||
298 | hugetlb_add_hstate(CONT_PTE_SHIFT); | ||
299 | } else if (ps == (PMD_SIZE * CONT_PMDS)) { | ||
300 | hugetlb_add_hstate((PMD_SHIFT + CONT_PMD_SHIFT) - PAGE_SHIFT); | ||
301 | } else { | 297 | } else { |
302 | hugetlb_bad_size(); | 298 | hugetlb_bad_size(); |
303 | pr_err("hugepagesz: Unsupported page size %lu K\n", ps >> 10); | 299 | pr_err("hugepagesz: Unsupported page size %lu K\n", ps >> 10); |
@@ -306,13 +302,3 @@ static __init int setup_hugepagesz(char *opt) | |||
306 | return 1; | 302 | return 1; |
307 | } | 303 | } |
308 | __setup("hugepagesz=", setup_hugepagesz); | 304 | __setup("hugepagesz=", setup_hugepagesz); |
309 | |||
310 | #ifdef CONFIG_ARM64_64K_PAGES | ||
311 | static __init int add_default_hugepagesz(void) | ||
312 | { | ||
313 | if (size_to_hstate(CONT_PTES * PAGE_SIZE) == NULL) | ||
314 | hugetlb_add_hstate(CONT_PTE_SHIFT); | ||
315 | return 0; | ||
316 | } | ||
317 | arch_initcall(add_default_hugepagesz); | ||
318 | #endif | ||
diff --git a/arch/ia64/include/asm/asm-prototypes.h b/arch/ia64/include/asm/asm-prototypes.h new file mode 100644 index 000000000000..a2c139808cfe --- /dev/null +++ b/arch/ia64/include/asm/asm-prototypes.h | |||
@@ -0,0 +1,29 @@ | |||
1 | #ifndef _ASM_IA64_ASM_PROTOTYPES_H | ||
2 | #define _ASM_IA64_ASM_PROTOTYPES_H | ||
3 | |||
4 | #include <asm/cacheflush.h> | ||
5 | #include <asm/checksum.h> | ||
6 | #include <asm/esi.h> | ||
7 | #include <asm/ftrace.h> | ||
8 | #include <asm/page.h> | ||
9 | #include <asm/pal.h> | ||
10 | #include <asm/string.h> | ||
11 | #include <asm/uaccess.h> | ||
12 | #include <asm/unwind.h> | ||
13 | #include <asm/xor.h> | ||
14 | |||
15 | extern const char ia64_ivt[]; | ||
16 | |||
17 | signed int __divsi3(signed int, unsigned int); | ||
18 | signed int __modsi3(signed int, unsigned int); | ||
19 | |||
20 | signed long long __divdi3(signed long long, unsigned long long); | ||
21 | signed long long __moddi3(signed long long, unsigned long long); | ||
22 | |||
23 | unsigned int __udivsi3(unsigned int, unsigned int); | ||
24 | unsigned int __umodsi3(unsigned int, unsigned int); | ||
25 | |||
26 | unsigned long long __udivdi3(unsigned long long, unsigned long long); | ||
27 | unsigned long long __umoddi3(unsigned long long, unsigned long long); | ||
28 | |||
29 | #endif /* _ASM_IA64_ASM_PROTOTYPES_H */ | ||
diff --git a/arch/ia64/lib/Makefile b/arch/ia64/lib/Makefile index 1f3d3877618f..0a40b14407b1 100644 --- a/arch/ia64/lib/Makefile +++ b/arch/ia64/lib/Makefile | |||
@@ -24,25 +24,25 @@ AFLAGS___modsi3.o = -DMODULO | |||
24 | AFLAGS___umodsi3.o = -DUNSIGNED -DMODULO | 24 | AFLAGS___umodsi3.o = -DUNSIGNED -DMODULO |
25 | 25 | ||
26 | $(obj)/__divdi3.o: $(src)/idiv64.S FORCE | 26 | $(obj)/__divdi3.o: $(src)/idiv64.S FORCE |
27 | $(call if_changed_dep,as_o_S) | 27 | $(call if_changed_rule,as_o_S) |
28 | 28 | ||
29 | $(obj)/__udivdi3.o: $(src)/idiv64.S FORCE | 29 | $(obj)/__udivdi3.o: $(src)/idiv64.S FORCE |
30 | $(call if_changed_dep,as_o_S) | 30 | $(call if_changed_rule,as_o_S) |
31 | 31 | ||
32 | $(obj)/__moddi3.o: $(src)/idiv64.S FORCE | 32 | $(obj)/__moddi3.o: $(src)/idiv64.S FORCE |
33 | $(call if_changed_dep,as_o_S) | 33 | $(call if_changed_rule,as_o_S) |
34 | 34 | ||
35 | $(obj)/__umoddi3.o: $(src)/idiv64.S FORCE | 35 | $(obj)/__umoddi3.o: $(src)/idiv64.S FORCE |
36 | $(call if_changed_dep,as_o_S) | 36 | $(call if_changed_rule,as_o_S) |
37 | 37 | ||
38 | $(obj)/__divsi3.o: $(src)/idiv32.S FORCE | 38 | $(obj)/__divsi3.o: $(src)/idiv32.S FORCE |
39 | $(call if_changed_dep,as_o_S) | 39 | $(call if_changed_rule,as_o_S) |
40 | 40 | ||
41 | $(obj)/__udivsi3.o: $(src)/idiv32.S FORCE | 41 | $(obj)/__udivsi3.o: $(src)/idiv32.S FORCE |
42 | $(call if_changed_dep,as_o_S) | 42 | $(call if_changed_rule,as_o_S) |
43 | 43 | ||
44 | $(obj)/__modsi3.o: $(src)/idiv32.S FORCE | 44 | $(obj)/__modsi3.o: $(src)/idiv32.S FORCE |
45 | $(call if_changed_dep,as_o_S) | 45 | $(call if_changed_rule,as_o_S) |
46 | 46 | ||
47 | $(obj)/__umodsi3.o: $(src)/idiv32.S FORCE | 47 | $(obj)/__umodsi3.o: $(src)/idiv32.S FORCE |
48 | $(call if_changed_dep,as_o_S) | 48 | $(call if_changed_rule,as_o_S) |
diff --git a/arch/metag/include/asm/uaccess.h b/arch/metag/include/asm/uaccess.h index 273e61225c27..07238b39638c 100644 --- a/arch/metag/include/asm/uaccess.h +++ b/arch/metag/include/asm/uaccess.h | |||
@@ -197,20 +197,21 @@ extern long __must_check strnlen_user(const char __user *src, long count); | |||
197 | 197 | ||
198 | #define strlen_user(str) strnlen_user(str, 32767) | 198 | #define strlen_user(str) strnlen_user(str, 32767) |
199 | 199 | ||
200 | extern unsigned long __must_check __copy_user_zeroing(void *to, | 200 | extern unsigned long raw_copy_from_user(void *to, const void __user *from, |
201 | const void __user *from, | 201 | unsigned long n); |
202 | unsigned long n); | ||
203 | 202 | ||
204 | static inline unsigned long | 203 | static inline unsigned long |
205 | copy_from_user(void *to, const void __user *from, unsigned long n) | 204 | copy_from_user(void *to, const void __user *from, unsigned long n) |
206 | { | 205 | { |
206 | unsigned long res = n; | ||
207 | if (likely(access_ok(VERIFY_READ, from, n))) | 207 | if (likely(access_ok(VERIFY_READ, from, n))) |
208 | return __copy_user_zeroing(to, from, n); | 208 | res = raw_copy_from_user(to, from, n); |
209 | memset(to, 0, n); | 209 | if (unlikely(res)) |
210 | return n; | 210 | memset(to + (n - res), 0, res); |
211 | return res; | ||
211 | } | 212 | } |
212 | 213 | ||
213 | #define __copy_from_user(to, from, n) __copy_user_zeroing(to, from, n) | 214 | #define __copy_from_user(to, from, n) raw_copy_from_user(to, from, n) |
214 | #define __copy_from_user_inatomic __copy_from_user | 215 | #define __copy_from_user_inatomic __copy_from_user |
215 | 216 | ||
216 | extern unsigned long __must_check __copy_user(void __user *to, | 217 | extern unsigned long __must_check __copy_user(void __user *to, |
diff --git a/arch/metag/lib/usercopy.c b/arch/metag/lib/usercopy.c index b3ebfe9c8e88..2792fc621088 100644 --- a/arch/metag/lib/usercopy.c +++ b/arch/metag/lib/usercopy.c | |||
@@ -29,7 +29,6 @@ | |||
29 | COPY \ | 29 | COPY \ |
30 | "1:\n" \ | 30 | "1:\n" \ |
31 | " .section .fixup,\"ax\"\n" \ | 31 | " .section .fixup,\"ax\"\n" \ |
32 | " MOV D1Ar1,#0\n" \ | ||
33 | FIXUP \ | 32 | FIXUP \ |
34 | " MOVT D1Ar1,#HI(1b)\n" \ | 33 | " MOVT D1Ar1,#HI(1b)\n" \ |
35 | " JUMP D1Ar1,#LO(1b)\n" \ | 34 | " JUMP D1Ar1,#LO(1b)\n" \ |
@@ -260,27 +259,31 @@ | |||
260 | "MGETL D0FrT, D0.5, D0.6, D0.7, [%1++]\n" \ | 259 | "MGETL D0FrT, D0.5, D0.6, D0.7, [%1++]\n" \ |
261 | "22:\n" \ | 260 | "22:\n" \ |
262 | "MSETL [%0++], D0FrT, D0.5, D0.6, D0.7\n" \ | 261 | "MSETL [%0++], D0FrT, D0.5, D0.6, D0.7\n" \ |
263 | "SUB %3, %3, #32\n" \ | ||
264 | "23:\n" \ | 262 | "23:\n" \ |
265 | "MGETL D0FrT, D0.5, D0.6, D0.7, [%1++]\n" \ | 263 | "SUB %3, %3, #32\n" \ |
266 | "24:\n" \ | 264 | "24:\n" \ |
265 | "MGETL D0FrT, D0.5, D0.6, D0.7, [%1++]\n" \ | ||
266 | "25:\n" \ | ||
267 | "MSETL [%0++], D0FrT, D0.5, D0.6, D0.7\n" \ | 267 | "MSETL [%0++], D0FrT, D0.5, D0.6, D0.7\n" \ |
268 | "26:\n" \ | ||
268 | "SUB %3, %3, #32\n" \ | 269 | "SUB %3, %3, #32\n" \ |
269 | "DCACHE [%1+#-64], D0Ar6\n" \ | 270 | "DCACHE [%1+#-64], D0Ar6\n" \ |
270 | "BR $Lloop"id"\n" \ | 271 | "BR $Lloop"id"\n" \ |
271 | \ | 272 | \ |
272 | "MOV RAPF, %1\n" \ | 273 | "MOV RAPF, %1\n" \ |
273 | "25:\n" \ | 274 | "27:\n" \ |
274 | "MGETL D0FrT, D0.5, D0.6, D0.7, [%1++]\n" \ | 275 | "MGETL D0FrT, D0.5, D0.6, D0.7, [%1++]\n" \ |
275 | "26:\n" \ | 276 | "28:\n" \ |
276 | "MSETL [%0++], D0FrT, D0.5, D0.6, D0.7\n" \ | 277 | "MSETL [%0++], D0FrT, D0.5, D0.6, D0.7\n" \ |
278 | "29:\n" \ | ||
277 | "SUB %3, %3, #32\n" \ | 279 | "SUB %3, %3, #32\n" \ |
278 | "27:\n" \ | 280 | "30:\n" \ |
279 | "MGETL D0FrT, D0.5, D0.6, D0.7, [%1++]\n" \ | 281 | "MGETL D0FrT, D0.5, D0.6, D0.7, [%1++]\n" \ |
280 | "28:\n" \ | 282 | "31:\n" \ |
281 | "MSETL [%0++], D0FrT, D0.5, D0.6, D0.7\n" \ | 283 | "MSETL [%0++], D0FrT, D0.5, D0.6, D0.7\n" \ |
284 | "32:\n" \ | ||
282 | "SUB %0, %0, #8\n" \ | 285 | "SUB %0, %0, #8\n" \ |
283 | "29:\n" \ | 286 | "33:\n" \ |
284 | "SETL [%0++], D0.7, D1.7\n" \ | 287 | "SETL [%0++], D0.7, D1.7\n" \ |
285 | "SUB %3, %3, #32\n" \ | 288 | "SUB %3, %3, #32\n" \ |
286 | "1:" \ | 289 | "1:" \ |
@@ -312,11 +315,15 @@ | |||
312 | " .long 26b,3b\n" \ | 315 | " .long 26b,3b\n" \ |
313 | " .long 27b,3b\n" \ | 316 | " .long 27b,3b\n" \ |
314 | " .long 28b,3b\n" \ | 317 | " .long 28b,3b\n" \ |
315 | " .long 29b,4b\n" \ | 318 | " .long 29b,3b\n" \ |
319 | " .long 30b,3b\n" \ | ||
320 | " .long 31b,3b\n" \ | ||
321 | " .long 32b,3b\n" \ | ||
322 | " .long 33b,4b\n" \ | ||
316 | " .previous\n" \ | 323 | " .previous\n" \ |
317 | : "=r" (to), "=r" (from), "=r" (ret), "=d" (n) \ | 324 | : "=r" (to), "=r" (from), "=r" (ret), "=d" (n) \ |
318 | : "0" (to), "1" (from), "2" (ret), "3" (n) \ | 325 | : "0" (to), "1" (from), "2" (ret), "3" (n) \ |
319 | : "D1Ar1", "D0Ar2", "memory") | 326 | : "D1Ar1", "D0Ar2", "cc", "memory") |
320 | 327 | ||
321 | /* rewind 'to' and 'from' pointers when a fault occurs | 328 | /* rewind 'to' and 'from' pointers when a fault occurs |
322 | * | 329 | * |
@@ -342,7 +349,7 @@ | |||
342 | #define __asm_copy_to_user_64bit_rapf_loop(to, from, ret, n, id)\ | 349 | #define __asm_copy_to_user_64bit_rapf_loop(to, from, ret, n, id)\ |
343 | __asm_copy_user_64bit_rapf_loop(to, from, ret, n, id, \ | 350 | __asm_copy_user_64bit_rapf_loop(to, from, ret, n, id, \ |
344 | "LSR D0Ar2, D0Ar2, #8\n" \ | 351 | "LSR D0Ar2, D0Ar2, #8\n" \ |
345 | "AND D0Ar2, D0Ar2, #0x7\n" \ | 352 | "ANDS D0Ar2, D0Ar2, #0x7\n" \ |
346 | "ADDZ D0Ar2, D0Ar2, #4\n" \ | 353 | "ADDZ D0Ar2, D0Ar2, #4\n" \ |
347 | "SUB D0Ar2, D0Ar2, #1\n" \ | 354 | "SUB D0Ar2, D0Ar2, #1\n" \ |
348 | "MOV D1Ar1, #4\n" \ | 355 | "MOV D1Ar1, #4\n" \ |
@@ -403,47 +410,55 @@ | |||
403 | "MGETD D0FrT, D0.5, D0.6, D0.7, [%1++]\n" \ | 410 | "MGETD D0FrT, D0.5, D0.6, D0.7, [%1++]\n" \ |
404 | "22:\n" \ | 411 | "22:\n" \ |
405 | "MSETD [%0++], D0FrT, D0.5, D0.6, D0.7\n" \ | 412 | "MSETD [%0++], D0FrT, D0.5, D0.6, D0.7\n" \ |
406 | "SUB %3, %3, #16\n" \ | ||
407 | "23:\n" \ | 413 | "23:\n" \ |
408 | "MGETD D0FrT, D0.5, D0.6, D0.7, [%1++]\n" \ | ||
409 | "24:\n" \ | ||
410 | "MSETD [%0++], D0FrT, D0.5, D0.6, D0.7\n" \ | ||
411 | "SUB %3, %3, #16\n" \ | 414 | "SUB %3, %3, #16\n" \ |
412 | "25:\n" \ | 415 | "24:\n" \ |
413 | "MGETD D0FrT, D0.5, D0.6, D0.7, [%1++]\n" \ | 416 | "MGETD D0FrT, D0.5, D0.6, D0.7, [%1++]\n" \ |
414 | "26:\n" \ | 417 | "25:\n" \ |
415 | "MSETD [%0++], D0FrT, D0.5, D0.6, D0.7\n" \ | 418 | "MSETD [%0++], D0FrT, D0.5, D0.6, D0.7\n" \ |
419 | "26:\n" \ | ||
416 | "SUB %3, %3, #16\n" \ | 420 | "SUB %3, %3, #16\n" \ |
417 | "27:\n" \ | 421 | "27:\n" \ |
418 | "MGETD D0FrT, D0.5, D0.6, D0.7, [%1++]\n" \ | 422 | "MGETD D0FrT, D0.5, D0.6, D0.7, [%1++]\n" \ |
419 | "28:\n" \ | 423 | "28:\n" \ |
420 | "MSETD [%0++], D0FrT, D0.5, D0.6, D0.7\n" \ | 424 | "MSETD [%0++], D0FrT, D0.5, D0.6, D0.7\n" \ |
425 | "29:\n" \ | ||
426 | "SUB %3, %3, #16\n" \ | ||
427 | "30:\n" \ | ||
428 | "MGETD D0FrT, D0.5, D0.6, D0.7, [%1++]\n" \ | ||
429 | "31:\n" \ | ||
430 | "MSETD [%0++], D0FrT, D0.5, D0.6, D0.7\n" \ | ||
431 | "32:\n" \ | ||
421 | "SUB %3, %3, #16\n" \ | 432 | "SUB %3, %3, #16\n" \ |
422 | "DCACHE [%1+#-64], D0Ar6\n" \ | 433 | "DCACHE [%1+#-64], D0Ar6\n" \ |
423 | "BR $Lloop"id"\n" \ | 434 | "BR $Lloop"id"\n" \ |
424 | \ | 435 | \ |
425 | "MOV RAPF, %1\n" \ | 436 | "MOV RAPF, %1\n" \ |
426 | "29:\n" \ | 437 | "33:\n" \ |
427 | "MGETD D0FrT, D0.5, D0.6, D0.7, [%1++]\n" \ | 438 | "MGETD D0FrT, D0.5, D0.6, D0.7, [%1++]\n" \ |
428 | "30:\n" \ | 439 | "34:\n" \ |
429 | "MSETD [%0++], D0FrT, D0.5, D0.6, D0.7\n" \ | 440 | "MSETD [%0++], D0FrT, D0.5, D0.6, D0.7\n" \ |
441 | "35:\n" \ | ||
430 | "SUB %3, %3, #16\n" \ | 442 | "SUB %3, %3, #16\n" \ |
431 | "31:\n" \ | 443 | "36:\n" \ |
432 | "MGETD D0FrT, D0.5, D0.6, D0.7, [%1++]\n" \ | 444 | "MGETD D0FrT, D0.5, D0.6, D0.7, [%1++]\n" \ |
433 | "32:\n" \ | 445 | "37:\n" \ |
434 | "MSETD [%0++], D0FrT, D0.5, D0.6, D0.7\n" \ | 446 | "MSETD [%0++], D0FrT, D0.5, D0.6, D0.7\n" \ |
447 | "38:\n" \ | ||
435 | "SUB %3, %3, #16\n" \ | 448 | "SUB %3, %3, #16\n" \ |
436 | "33:\n" \ | 449 | "39:\n" \ |
437 | "MGETD D0FrT, D0.5, D0.6, D0.7, [%1++]\n" \ | 450 | "MGETD D0FrT, D0.5, D0.6, D0.7, [%1++]\n" \ |
438 | "34:\n" \ | 451 | "40:\n" \ |
439 | "MSETD [%0++], D0FrT, D0.5, D0.6, D0.7\n" \ | 452 | "MSETD [%0++], D0FrT, D0.5, D0.6, D0.7\n" \ |
453 | "41:\n" \ | ||
440 | "SUB %3, %3, #16\n" \ | 454 | "SUB %3, %3, #16\n" \ |
441 | "35:\n" \ | 455 | "42:\n" \ |
442 | "MGETD D0FrT, D0.5, D0.6, D0.7, [%1++]\n" \ | 456 | "MGETD D0FrT, D0.5, D0.6, D0.7, [%1++]\n" \ |
443 | "36:\n" \ | 457 | "43:\n" \ |
444 | "MSETD [%0++], D0FrT, D0.5, D0.6, D0.7\n" \ | 458 | "MSETD [%0++], D0FrT, D0.5, D0.6, D0.7\n" \ |
459 | "44:\n" \ | ||
445 | "SUB %0, %0, #4\n" \ | 460 | "SUB %0, %0, #4\n" \ |
446 | "37:\n" \ | 461 | "45:\n" \ |
447 | "SETD [%0++], D0.7\n" \ | 462 | "SETD [%0++], D0.7\n" \ |
448 | "SUB %3, %3, #16\n" \ | 463 | "SUB %3, %3, #16\n" \ |
449 | "1:" \ | 464 | "1:" \ |
@@ -483,11 +498,19 @@ | |||
483 | " .long 34b,3b\n" \ | 498 | " .long 34b,3b\n" \ |
484 | " .long 35b,3b\n" \ | 499 | " .long 35b,3b\n" \ |
485 | " .long 36b,3b\n" \ | 500 | " .long 36b,3b\n" \ |
486 | " .long 37b,4b\n" \ | 501 | " .long 37b,3b\n" \ |
502 | " .long 38b,3b\n" \ | ||
503 | " .long 39b,3b\n" \ | ||
504 | " .long 40b,3b\n" \ | ||
505 | " .long 41b,3b\n" \ | ||
506 | " .long 42b,3b\n" \ | ||
507 | " .long 43b,3b\n" \ | ||
508 | " .long 44b,3b\n" \ | ||
509 | " .long 45b,4b\n" \ | ||
487 | " .previous\n" \ | 510 | " .previous\n" \ |
488 | : "=r" (to), "=r" (from), "=r" (ret), "=d" (n) \ | 511 | : "=r" (to), "=r" (from), "=r" (ret), "=d" (n) \ |
489 | : "0" (to), "1" (from), "2" (ret), "3" (n) \ | 512 | : "0" (to), "1" (from), "2" (ret), "3" (n) \ |
490 | : "D1Ar1", "D0Ar2", "memory") | 513 | : "D1Ar1", "D0Ar2", "cc", "memory") |
491 | 514 | ||
492 | /* rewind 'to' and 'from' pointers when a fault occurs | 515 | /* rewind 'to' and 'from' pointers when a fault occurs |
493 | * | 516 | * |
@@ -513,7 +536,7 @@ | |||
513 | #define __asm_copy_to_user_32bit_rapf_loop(to, from, ret, n, id)\ | 536 | #define __asm_copy_to_user_32bit_rapf_loop(to, from, ret, n, id)\ |
514 | __asm_copy_user_32bit_rapf_loop(to, from, ret, n, id, \ | 537 | __asm_copy_user_32bit_rapf_loop(to, from, ret, n, id, \ |
515 | "LSR D0Ar2, D0Ar2, #8\n" \ | 538 | "LSR D0Ar2, D0Ar2, #8\n" \ |
516 | "AND D0Ar2, D0Ar2, #0x7\n" \ | 539 | "ANDS D0Ar2, D0Ar2, #0x7\n" \ |
517 | "ADDZ D0Ar2, D0Ar2, #4\n" \ | 540 | "ADDZ D0Ar2, D0Ar2, #4\n" \ |
518 | "SUB D0Ar2, D0Ar2, #1\n" \ | 541 | "SUB D0Ar2, D0Ar2, #1\n" \ |
519 | "MOV D1Ar1, #4\n" \ | 542 | "MOV D1Ar1, #4\n" \ |
@@ -538,23 +561,31 @@ unsigned long __copy_user(void __user *pdst, const void *psrc, | |||
538 | if ((unsigned long) src & 1) { | 561 | if ((unsigned long) src & 1) { |
539 | __asm_copy_to_user_1(dst, src, retn); | 562 | __asm_copy_to_user_1(dst, src, retn); |
540 | n--; | 563 | n--; |
564 | if (retn) | ||
565 | return retn + n; | ||
541 | } | 566 | } |
542 | if ((unsigned long) dst & 1) { | 567 | if ((unsigned long) dst & 1) { |
543 | /* Worst case - byte copy */ | 568 | /* Worst case - byte copy */ |
544 | while (n > 0) { | 569 | while (n > 0) { |
545 | __asm_copy_to_user_1(dst, src, retn); | 570 | __asm_copy_to_user_1(dst, src, retn); |
546 | n--; | 571 | n--; |
572 | if (retn) | ||
573 | return retn + n; | ||
547 | } | 574 | } |
548 | } | 575 | } |
549 | if (((unsigned long) src & 2) && n >= 2) { | 576 | if (((unsigned long) src & 2) && n >= 2) { |
550 | __asm_copy_to_user_2(dst, src, retn); | 577 | __asm_copy_to_user_2(dst, src, retn); |
551 | n -= 2; | 578 | n -= 2; |
579 | if (retn) | ||
580 | return retn + n; | ||
552 | } | 581 | } |
553 | if ((unsigned long) dst & 2) { | 582 | if ((unsigned long) dst & 2) { |
554 | /* Second worst case - word copy */ | 583 | /* Second worst case - word copy */ |
555 | while (n >= 2) { | 584 | while (n >= 2) { |
556 | __asm_copy_to_user_2(dst, src, retn); | 585 | __asm_copy_to_user_2(dst, src, retn); |
557 | n -= 2; | 586 | n -= 2; |
587 | if (retn) | ||
588 | return retn + n; | ||
558 | } | 589 | } |
559 | } | 590 | } |
560 | 591 | ||
@@ -569,6 +600,8 @@ unsigned long __copy_user(void __user *pdst, const void *psrc, | |||
569 | while (n >= 8) { | 600 | while (n >= 8) { |
570 | __asm_copy_to_user_8x64(dst, src, retn); | 601 | __asm_copy_to_user_8x64(dst, src, retn); |
571 | n -= 8; | 602 | n -= 8; |
603 | if (retn) | ||
604 | return retn + n; | ||
572 | } | 605 | } |
573 | } | 606 | } |
574 | if (n >= RAPF_MIN_BUF_SIZE) { | 607 | if (n >= RAPF_MIN_BUF_SIZE) { |
@@ -581,6 +614,8 @@ unsigned long __copy_user(void __user *pdst, const void *psrc, | |||
581 | while (n >= 8) { | 614 | while (n >= 8) { |
582 | __asm_copy_to_user_8x64(dst, src, retn); | 615 | __asm_copy_to_user_8x64(dst, src, retn); |
583 | n -= 8; | 616 | n -= 8; |
617 | if (retn) | ||
618 | return retn + n; | ||
584 | } | 619 | } |
585 | } | 620 | } |
586 | #endif | 621 | #endif |
@@ -588,11 +623,15 @@ unsigned long __copy_user(void __user *pdst, const void *psrc, | |||
588 | while (n >= 16) { | 623 | while (n >= 16) { |
589 | __asm_copy_to_user_16(dst, src, retn); | 624 | __asm_copy_to_user_16(dst, src, retn); |
590 | n -= 16; | 625 | n -= 16; |
626 | if (retn) | ||
627 | return retn + n; | ||
591 | } | 628 | } |
592 | 629 | ||
593 | while (n >= 4) { | 630 | while (n >= 4) { |
594 | __asm_copy_to_user_4(dst, src, retn); | 631 | __asm_copy_to_user_4(dst, src, retn); |
595 | n -= 4; | 632 | n -= 4; |
633 | if (retn) | ||
634 | return retn + n; | ||
596 | } | 635 | } |
597 | 636 | ||
598 | switch (n) { | 637 | switch (n) { |
@@ -609,6 +648,10 @@ unsigned long __copy_user(void __user *pdst, const void *psrc, | |||
609 | break; | 648 | break; |
610 | } | 649 | } |
611 | 650 | ||
651 | /* | ||
652 | * If we get here, retn correctly reflects the number of failing | ||
653 | * bytes. | ||
654 | */ | ||
612 | return retn; | 655 | return retn; |
613 | } | 656 | } |
614 | EXPORT_SYMBOL(__copy_user); | 657 | EXPORT_SYMBOL(__copy_user); |
@@ -617,16 +660,14 @@ EXPORT_SYMBOL(__copy_user); | |||
617 | __asm_copy_user_cont(to, from, ret, \ | 660 | __asm_copy_user_cont(to, from, ret, \ |
618 | " GETB D1Ar1,[%1++]\n" \ | 661 | " GETB D1Ar1,[%1++]\n" \ |
619 | "2: SETB [%0++],D1Ar1\n", \ | 662 | "2: SETB [%0++],D1Ar1\n", \ |
620 | "3: ADD %2,%2,#1\n" \ | 663 | "3: ADD %2,%2,#1\n", \ |
621 | " SETB [%0++],D1Ar1\n", \ | ||
622 | " .long 2b,3b\n") | 664 | " .long 2b,3b\n") |
623 | 665 | ||
624 | #define __asm_copy_from_user_2x_cont(to, from, ret, COPY, FIXUP, TENTRY) \ | 666 | #define __asm_copy_from_user_2x_cont(to, from, ret, COPY, FIXUP, TENTRY) \ |
625 | __asm_copy_user_cont(to, from, ret, \ | 667 | __asm_copy_user_cont(to, from, ret, \ |
626 | " GETW D1Ar1,[%1++]\n" \ | 668 | " GETW D1Ar1,[%1++]\n" \ |
627 | "2: SETW [%0++],D1Ar1\n" COPY, \ | 669 | "2: SETW [%0++],D1Ar1\n" COPY, \ |
628 | "3: ADD %2,%2,#2\n" \ | 670 | "3: ADD %2,%2,#2\n" FIXUP, \ |
629 | " SETW [%0++],D1Ar1\n" FIXUP, \ | ||
630 | " .long 2b,3b\n" TENTRY) | 671 | " .long 2b,3b\n" TENTRY) |
631 | 672 | ||
632 | #define __asm_copy_from_user_2(to, from, ret) \ | 673 | #define __asm_copy_from_user_2(to, from, ret) \ |
@@ -636,145 +677,26 @@ EXPORT_SYMBOL(__copy_user); | |||
636 | __asm_copy_from_user_2x_cont(to, from, ret, \ | 677 | __asm_copy_from_user_2x_cont(to, from, ret, \ |
637 | " GETB D1Ar1,[%1++]\n" \ | 678 | " GETB D1Ar1,[%1++]\n" \ |
638 | "4: SETB [%0++],D1Ar1\n", \ | 679 | "4: SETB [%0++],D1Ar1\n", \ |
639 | "5: ADD %2,%2,#1\n" \ | 680 | "5: ADD %2,%2,#1\n", \ |
640 | " SETB [%0++],D1Ar1\n", \ | ||
641 | " .long 4b,5b\n") | 681 | " .long 4b,5b\n") |
642 | 682 | ||
643 | #define __asm_copy_from_user_4x_cont(to, from, ret, COPY, FIXUP, TENTRY) \ | 683 | #define __asm_copy_from_user_4x_cont(to, from, ret, COPY, FIXUP, TENTRY) \ |
644 | __asm_copy_user_cont(to, from, ret, \ | 684 | __asm_copy_user_cont(to, from, ret, \ |
645 | " GETD D1Ar1,[%1++]\n" \ | 685 | " GETD D1Ar1,[%1++]\n" \ |
646 | "2: SETD [%0++],D1Ar1\n" COPY, \ | 686 | "2: SETD [%0++],D1Ar1\n" COPY, \ |
647 | "3: ADD %2,%2,#4\n" \ | 687 | "3: ADD %2,%2,#4\n" FIXUP, \ |
648 | " SETD [%0++],D1Ar1\n" FIXUP, \ | ||
649 | " .long 2b,3b\n" TENTRY) | 688 | " .long 2b,3b\n" TENTRY) |
650 | 689 | ||
651 | #define __asm_copy_from_user_4(to, from, ret) \ | 690 | #define __asm_copy_from_user_4(to, from, ret) \ |
652 | __asm_copy_from_user_4x_cont(to, from, ret, "", "", "") | 691 | __asm_copy_from_user_4x_cont(to, from, ret, "", "", "") |
653 | 692 | ||
654 | #define __asm_copy_from_user_5(to, from, ret) \ | ||
655 | __asm_copy_from_user_4x_cont(to, from, ret, \ | ||
656 | " GETB D1Ar1,[%1++]\n" \ | ||
657 | "4: SETB [%0++],D1Ar1\n", \ | ||
658 | "5: ADD %2,%2,#1\n" \ | ||
659 | " SETB [%0++],D1Ar1\n", \ | ||
660 | " .long 4b,5b\n") | ||
661 | |||
662 | #define __asm_copy_from_user_6x_cont(to, from, ret, COPY, FIXUP, TENTRY) \ | ||
663 | __asm_copy_from_user_4x_cont(to, from, ret, \ | ||
664 | " GETW D1Ar1,[%1++]\n" \ | ||
665 | "4: SETW [%0++],D1Ar1\n" COPY, \ | ||
666 | "5: ADD %2,%2,#2\n" \ | ||
667 | " SETW [%0++],D1Ar1\n" FIXUP, \ | ||
668 | " .long 4b,5b\n" TENTRY) | ||
669 | |||
670 | #define __asm_copy_from_user_6(to, from, ret) \ | ||
671 | __asm_copy_from_user_6x_cont(to, from, ret, "", "", "") | ||
672 | |||
673 | #define __asm_copy_from_user_7(to, from, ret) \ | ||
674 | __asm_copy_from_user_6x_cont(to, from, ret, \ | ||
675 | " GETB D1Ar1,[%1++]\n" \ | ||
676 | "6: SETB [%0++],D1Ar1\n", \ | ||
677 | "7: ADD %2,%2,#1\n" \ | ||
678 | " SETB [%0++],D1Ar1\n", \ | ||
679 | " .long 6b,7b\n") | ||
680 | |||
681 | #define __asm_copy_from_user_8x_cont(to, from, ret, COPY, FIXUP, TENTRY) \ | ||
682 | __asm_copy_from_user_4x_cont(to, from, ret, \ | ||
683 | " GETD D1Ar1,[%1++]\n" \ | ||
684 | "4: SETD [%0++],D1Ar1\n" COPY, \ | ||
685 | "5: ADD %2,%2,#4\n" \ | ||
686 | " SETD [%0++],D1Ar1\n" FIXUP, \ | ||
687 | " .long 4b,5b\n" TENTRY) | ||
688 | |||
689 | #define __asm_copy_from_user_8(to, from, ret) \ | ||
690 | __asm_copy_from_user_8x_cont(to, from, ret, "", "", "") | ||
691 | |||
692 | #define __asm_copy_from_user_9(to, from, ret) \ | ||
693 | __asm_copy_from_user_8x_cont(to, from, ret, \ | ||
694 | " GETB D1Ar1,[%1++]\n" \ | ||
695 | "6: SETB [%0++],D1Ar1\n", \ | ||
696 | "7: ADD %2,%2,#1\n" \ | ||
697 | " SETB [%0++],D1Ar1\n", \ | ||
698 | " .long 6b,7b\n") | ||
699 | |||
700 | #define __asm_copy_from_user_10x_cont(to, from, ret, COPY, FIXUP, TENTRY) \ | ||
701 | __asm_copy_from_user_8x_cont(to, from, ret, \ | ||
702 | " GETW D1Ar1,[%1++]\n" \ | ||
703 | "6: SETW [%0++],D1Ar1\n" COPY, \ | ||
704 | "7: ADD %2,%2,#2\n" \ | ||
705 | " SETW [%0++],D1Ar1\n" FIXUP, \ | ||
706 | " .long 6b,7b\n" TENTRY) | ||
707 | |||
708 | #define __asm_copy_from_user_10(to, from, ret) \ | ||
709 | __asm_copy_from_user_10x_cont(to, from, ret, "", "", "") | ||
710 | |||
711 | #define __asm_copy_from_user_11(to, from, ret) \ | ||
712 | __asm_copy_from_user_10x_cont(to, from, ret, \ | ||
713 | " GETB D1Ar1,[%1++]\n" \ | ||
714 | "8: SETB [%0++],D1Ar1\n", \ | ||
715 | "9: ADD %2,%2,#1\n" \ | ||
716 | " SETB [%0++],D1Ar1\n", \ | ||
717 | " .long 8b,9b\n") | ||
718 | |||
719 | #define __asm_copy_from_user_12x_cont(to, from, ret, COPY, FIXUP, TENTRY) \ | ||
720 | __asm_copy_from_user_8x_cont(to, from, ret, \ | ||
721 | " GETD D1Ar1,[%1++]\n" \ | ||
722 | "6: SETD [%0++],D1Ar1\n" COPY, \ | ||
723 | "7: ADD %2,%2,#4\n" \ | ||
724 | " SETD [%0++],D1Ar1\n" FIXUP, \ | ||
725 | " .long 6b,7b\n" TENTRY) | ||
726 | |||
727 | #define __asm_copy_from_user_12(to, from, ret) \ | ||
728 | __asm_copy_from_user_12x_cont(to, from, ret, "", "", "") | ||
729 | |||
730 | #define __asm_copy_from_user_13(to, from, ret) \ | ||
731 | __asm_copy_from_user_12x_cont(to, from, ret, \ | ||
732 | " GETB D1Ar1,[%1++]\n" \ | ||
733 | "8: SETB [%0++],D1Ar1\n", \ | ||
734 | "9: ADD %2,%2,#1\n" \ | ||
735 | " SETB [%0++],D1Ar1\n", \ | ||
736 | " .long 8b,9b\n") | ||
737 | |||
738 | #define __asm_copy_from_user_14x_cont(to, from, ret, COPY, FIXUP, TENTRY) \ | ||
739 | __asm_copy_from_user_12x_cont(to, from, ret, \ | ||
740 | " GETW D1Ar1,[%1++]\n" \ | ||
741 | "8: SETW [%0++],D1Ar1\n" COPY, \ | ||
742 | "9: ADD %2,%2,#2\n" \ | ||
743 | " SETW [%0++],D1Ar1\n" FIXUP, \ | ||
744 | " .long 8b,9b\n" TENTRY) | ||
745 | |||
746 | #define __asm_copy_from_user_14(to, from, ret) \ | ||
747 | __asm_copy_from_user_14x_cont(to, from, ret, "", "", "") | ||
748 | |||
749 | #define __asm_copy_from_user_15(to, from, ret) \ | ||
750 | __asm_copy_from_user_14x_cont(to, from, ret, \ | ||
751 | " GETB D1Ar1,[%1++]\n" \ | ||
752 | "10: SETB [%0++],D1Ar1\n", \ | ||
753 | "11: ADD %2,%2,#1\n" \ | ||
754 | " SETB [%0++],D1Ar1\n", \ | ||
755 | " .long 10b,11b\n") | ||
756 | |||
757 | #define __asm_copy_from_user_16x_cont(to, from, ret, COPY, FIXUP, TENTRY) \ | ||
758 | __asm_copy_from_user_12x_cont(to, from, ret, \ | ||
759 | " GETD D1Ar1,[%1++]\n" \ | ||
760 | "8: SETD [%0++],D1Ar1\n" COPY, \ | ||
761 | "9: ADD %2,%2,#4\n" \ | ||
762 | " SETD [%0++],D1Ar1\n" FIXUP, \ | ||
763 | " .long 8b,9b\n" TENTRY) | ||
764 | |||
765 | #define __asm_copy_from_user_16(to, from, ret) \ | ||
766 | __asm_copy_from_user_16x_cont(to, from, ret, "", "", "") | ||
767 | |||
768 | #define __asm_copy_from_user_8x64(to, from, ret) \ | 693 | #define __asm_copy_from_user_8x64(to, from, ret) \ |
769 | asm volatile ( \ | 694 | asm volatile ( \ |
770 | " GETL D0Ar2,D1Ar1,[%1++]\n" \ | 695 | " GETL D0Ar2,D1Ar1,[%1++]\n" \ |
771 | "2: SETL [%0++],D0Ar2,D1Ar1\n" \ | 696 | "2: SETL [%0++],D0Ar2,D1Ar1\n" \ |
772 | "1:\n" \ | 697 | "1:\n" \ |
773 | " .section .fixup,\"ax\"\n" \ | 698 | " .section .fixup,\"ax\"\n" \ |
774 | " MOV D1Ar1,#0\n" \ | ||
775 | " MOV D0Ar2,#0\n" \ | ||
776 | "3: ADD %2,%2,#8\n" \ | 699 | "3: ADD %2,%2,#8\n" \ |
777 | " SETL [%0++],D0Ar2,D1Ar1\n" \ | ||
778 | " MOVT D0Ar2,#HI(1b)\n" \ | 700 | " MOVT D0Ar2,#HI(1b)\n" \ |
779 | " JUMP D0Ar2,#LO(1b)\n" \ | 701 | " JUMP D0Ar2,#LO(1b)\n" \ |
780 | " .previous\n" \ | 702 | " .previous\n" \ |
@@ -789,36 +711,57 @@ EXPORT_SYMBOL(__copy_user); | |||
789 | * | 711 | * |
790 | * Rationale: | 712 | * Rationale: |
791 | * A fault occurs while reading from user buffer, which is the | 713 | * A fault occurs while reading from user buffer, which is the |
792 | * source. Since the fault is at a single address, we only | 714 | * source. |
793 | * need to rewind by 8 bytes. | ||
794 | * Since we don't write to kernel buffer until we read first, | 715 | * Since we don't write to kernel buffer until we read first, |
795 | * the kernel buffer is at the right state and needn't be | 716 | * the kernel buffer is at the right state and needn't be |
796 | * corrected. | 717 | * corrected, but the source must be rewound to the beginning of |
718 | * the block, which is LSM_STEP*8 bytes. | ||
719 | * LSM_STEP is bits 10:8 in TXSTATUS which is already read | ||
720 | * and stored in D0Ar2 | ||
721 | * | ||
722 | * NOTE: If a fault occurs at the last operation in M{G,S}ETL | ||
723 | * LSM_STEP will be 0. ie: we do 4 writes in our case, if | ||
724 | * a fault happens at the 4th write, LSM_STEP will be 0 | ||
725 | * instead of 4. The code copes with that. | ||
797 | */ | 726 | */ |
798 | #define __asm_copy_from_user_64bit_rapf_loop(to, from, ret, n, id) \ | 727 | #define __asm_copy_from_user_64bit_rapf_loop(to, from, ret, n, id) \ |
799 | __asm_copy_user_64bit_rapf_loop(to, from, ret, n, id, \ | 728 | __asm_copy_user_64bit_rapf_loop(to, from, ret, n, id, \ |
800 | "SUB %1, %1, #8\n") | 729 | "LSR D0Ar2, D0Ar2, #5\n" \ |
730 | "ANDS D0Ar2, D0Ar2, #0x38\n" \ | ||
731 | "ADDZ D0Ar2, D0Ar2, #32\n" \ | ||
732 | "SUB %1, %1, D0Ar2\n") | ||
801 | 733 | ||
802 | /* rewind 'from' pointer when a fault occurs | 734 | /* rewind 'from' pointer when a fault occurs |
803 | * | 735 | * |
804 | * Rationale: | 736 | * Rationale: |
805 | * A fault occurs while reading from user buffer, which is the | 737 | * A fault occurs while reading from user buffer, which is the |
806 | * source. Since the fault is at a single address, we only | 738 | * source. |
807 | * need to rewind by 4 bytes. | ||
808 | * Since we don't write to kernel buffer until we read first, | 739 | * Since we don't write to kernel buffer until we read first, |
809 | * the kernel buffer is at the right state and needn't be | 740 | * the kernel buffer is at the right state and needn't be |
810 | * corrected. | 741 | * corrected, but the source must be rewound to the beginning of |
742 | * the block, which is LSM_STEP*4 bytes. | ||
743 | * LSM_STEP is bits 10:8 in TXSTATUS which is already read | ||
744 | * and stored in D0Ar2 | ||
745 | * | ||
746 | * NOTE: If a fault occurs at the last operation in M{G,S}ETL | ||
747 | * LSM_STEP will be 0. ie: we do 4 writes in our case, if | ||
748 | * a fault happens at the 4th write, LSM_STEP will be 0 | ||
749 | * instead of 4. The code copes with that. | ||
811 | */ | 750 | */ |
812 | #define __asm_copy_from_user_32bit_rapf_loop(to, from, ret, n, id) \ | 751 | #define __asm_copy_from_user_32bit_rapf_loop(to, from, ret, n, id) \ |
813 | __asm_copy_user_32bit_rapf_loop(to, from, ret, n, id, \ | 752 | __asm_copy_user_32bit_rapf_loop(to, from, ret, n, id, \ |
814 | "SUB %1, %1, #4\n") | 753 | "LSR D0Ar2, D0Ar2, #6\n" \ |
754 | "ANDS D0Ar2, D0Ar2, #0x1c\n" \ | ||
755 | "ADDZ D0Ar2, D0Ar2, #16\n" \ | ||
756 | "SUB %1, %1, D0Ar2\n") | ||
815 | 757 | ||
816 | 758 | ||
817 | /* Copy from user to kernel, zeroing the bytes that were inaccessible in | 759 | /* |
818 | userland. The return-value is the number of bytes that were | 760 | * Copy from user to kernel. The return-value is the number of bytes that were |
819 | inaccessible. */ | 761 | * inaccessible. |
820 | unsigned long __copy_user_zeroing(void *pdst, const void __user *psrc, | 762 | */ |
821 | unsigned long n) | 763 | unsigned long raw_copy_from_user(void *pdst, const void __user *psrc, |
764 | unsigned long n) | ||
822 | { | 765 | { |
823 | register char *dst asm ("A0.2") = pdst; | 766 | register char *dst asm ("A0.2") = pdst; |
824 | register const char __user *src asm ("A1.2") = psrc; | 767 | register const char __user *src asm ("A1.2") = psrc; |
@@ -830,6 +773,8 @@ unsigned long __copy_user_zeroing(void *pdst, const void __user *psrc, | |||
830 | if ((unsigned long) src & 1) { | 773 | if ((unsigned long) src & 1) { |
831 | __asm_copy_from_user_1(dst, src, retn); | 774 | __asm_copy_from_user_1(dst, src, retn); |
832 | n--; | 775 | n--; |
776 | if (retn) | ||
777 | return retn + n; | ||
833 | } | 778 | } |
834 | if ((unsigned long) dst & 1) { | 779 | if ((unsigned long) dst & 1) { |
835 | /* Worst case - byte copy */ | 780 | /* Worst case - byte copy */ |
@@ -837,12 +782,14 @@ unsigned long __copy_user_zeroing(void *pdst, const void __user *psrc, | |||
837 | __asm_copy_from_user_1(dst, src, retn); | 782 | __asm_copy_from_user_1(dst, src, retn); |
838 | n--; | 783 | n--; |
839 | if (retn) | 784 | if (retn) |
840 | goto copy_exception_bytes; | 785 | return retn + n; |
841 | } | 786 | } |
842 | } | 787 | } |
843 | if (((unsigned long) src & 2) && n >= 2) { | 788 | if (((unsigned long) src & 2) && n >= 2) { |
844 | __asm_copy_from_user_2(dst, src, retn); | 789 | __asm_copy_from_user_2(dst, src, retn); |
845 | n -= 2; | 790 | n -= 2; |
791 | if (retn) | ||
792 | return retn + n; | ||
846 | } | 793 | } |
847 | if ((unsigned long) dst & 2) { | 794 | if ((unsigned long) dst & 2) { |
848 | /* Second worst case - word copy */ | 795 | /* Second worst case - word copy */ |
@@ -850,16 +797,10 @@ unsigned long __copy_user_zeroing(void *pdst, const void __user *psrc, | |||
850 | __asm_copy_from_user_2(dst, src, retn); | 797 | __asm_copy_from_user_2(dst, src, retn); |
851 | n -= 2; | 798 | n -= 2; |
852 | if (retn) | 799 | if (retn) |
853 | goto copy_exception_bytes; | 800 | return retn + n; |
854 | } | 801 | } |
855 | } | 802 | } |
856 | 803 | ||
857 | /* We only need one check after the unalignment-adjustments, | ||
858 | because if both adjustments were done, either both or | ||
859 | neither reference had an exception. */ | ||
860 | if (retn != 0) | ||
861 | goto copy_exception_bytes; | ||
862 | |||
863 | #ifdef USE_RAPF | 804 | #ifdef USE_RAPF |
864 | /* 64 bit copy loop */ | 805 | /* 64 bit copy loop */ |
865 | if (!(((unsigned long) src | (unsigned long) dst) & 7)) { | 806 | if (!(((unsigned long) src | (unsigned long) dst) & 7)) { |
@@ -872,7 +813,7 @@ unsigned long __copy_user_zeroing(void *pdst, const void __user *psrc, | |||
872 | __asm_copy_from_user_8x64(dst, src, retn); | 813 | __asm_copy_from_user_8x64(dst, src, retn); |
873 | n -= 8; | 814 | n -= 8; |
874 | if (retn) | 815 | if (retn) |
875 | goto copy_exception_bytes; | 816 | return retn + n; |
876 | } | 817 | } |
877 | } | 818 | } |
878 | 819 | ||
@@ -888,7 +829,7 @@ unsigned long __copy_user_zeroing(void *pdst, const void __user *psrc, | |||
888 | __asm_copy_from_user_8x64(dst, src, retn); | 829 | __asm_copy_from_user_8x64(dst, src, retn); |
889 | n -= 8; | 830 | n -= 8; |
890 | if (retn) | 831 | if (retn) |
891 | goto copy_exception_bytes; | 832 | return retn + n; |
892 | } | 833 | } |
893 | } | 834 | } |
894 | #endif | 835 | #endif |
@@ -898,7 +839,7 @@ unsigned long __copy_user_zeroing(void *pdst, const void __user *psrc, | |||
898 | n -= 4; | 839 | n -= 4; |
899 | 840 | ||
900 | if (retn) | 841 | if (retn) |
901 | goto copy_exception_bytes; | 842 | return retn + n; |
902 | } | 843 | } |
903 | 844 | ||
904 | /* If we get here, there were no memory read faults. */ | 845 | /* If we get here, there were no memory read faults. */ |
@@ -924,21 +865,8 @@ unsigned long __copy_user_zeroing(void *pdst, const void __user *psrc, | |||
924 | /* If we get here, retn correctly reflects the number of failing | 865 | /* If we get here, retn correctly reflects the number of failing |
925 | bytes. */ | 866 | bytes. */ |
926 | return retn; | 867 | return retn; |
927 | |||
928 | copy_exception_bytes: | ||
929 | /* We already have "retn" bytes cleared, and need to clear the | ||
930 | remaining "n" bytes. A non-optimized simple byte-for-byte in-line | ||
931 | memset is preferred here, since this isn't speed-critical code and | ||
932 | we'd rather have this a leaf-function than calling memset. */ | ||
933 | { | ||
934 | char *endp; | ||
935 | for (endp = dst + n; dst < endp; dst++) | ||
936 | *dst = 0; | ||
937 | } | ||
938 | |||
939 | return retn + n; | ||
940 | } | 868 | } |
941 | EXPORT_SYMBOL(__copy_user_zeroing); | 869 | EXPORT_SYMBOL(raw_copy_from_user); |
942 | 870 | ||
943 | #define __asm_clear_8x64(to, ret) \ | 871 | #define __asm_clear_8x64(to, ret) \ |
944 | asm volatile ( \ | 872 | asm volatile ( \ |
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index a008a9f03072..e0bb576410bb 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig | |||
@@ -1531,7 +1531,7 @@ config CPU_MIPS64_R6 | |||
1531 | select CPU_SUPPORTS_HIGHMEM | 1531 | select CPU_SUPPORTS_HIGHMEM |
1532 | select CPU_SUPPORTS_MSA | 1532 | select CPU_SUPPORTS_MSA |
1533 | select GENERIC_CSUM | 1533 | select GENERIC_CSUM |
1534 | select MIPS_O32_FP64_SUPPORT if MIPS32_O32 | 1534 | select MIPS_O32_FP64_SUPPORT if 32BIT || MIPS32_O32 |
1535 | select HAVE_KVM | 1535 | select HAVE_KVM |
1536 | help | 1536 | help |
1537 | Choose this option to build a kernel for release 6 or later of the | 1537 | Choose this option to build a kernel for release 6 or later of the |
diff --git a/arch/mips/Makefile b/arch/mips/Makefile index 8ef9c02747fa..02a1787c888c 100644 --- a/arch/mips/Makefile +++ b/arch/mips/Makefile | |||
@@ -489,7 +489,7 @@ $(generic_defconfigs): | |||
489 | $(Q)$(CONFIG_SHELL) $(srctree)/scripts/kconfig/merge_config.sh \ | 489 | $(Q)$(CONFIG_SHELL) $(srctree)/scripts/kconfig/merge_config.sh \ |
490 | -m -O $(objtree) $(srctree)/arch/$(ARCH)/configs/generic_defconfig $^ \ | 490 | -m -O $(objtree) $(srctree)/arch/$(ARCH)/configs/generic_defconfig $^ \ |
491 | $(foreach board,$(BOARDS),$(generic_config_dir)/board-$(board).config) | 491 | $(foreach board,$(BOARDS),$(generic_config_dir)/board-$(board).config) |
492 | $(Q)$(MAKE) olddefconfig | 492 | $(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig |
493 | 493 | ||
494 | # | 494 | # |
495 | # Prevent generic merge_config rules attempting to merge single fragments | 495 | # Prevent generic merge_config rules attempting to merge single fragments |
@@ -503,8 +503,8 @@ $(generic_config_dir)/%.config: ; | |||
503 | # | 503 | # |
504 | .PHONY: sead3_defconfig | 504 | .PHONY: sead3_defconfig |
505 | sead3_defconfig: | 505 | sead3_defconfig: |
506 | $(Q)$(MAKE) 32r2el_defconfig BOARDS=sead-3 | 506 | $(Q)$(MAKE) -f $(srctree)/Makefile 32r2el_defconfig BOARDS=sead-3 |
507 | 507 | ||
508 | .PHONY: sead3micro_defconfig | 508 | .PHONY: sead3micro_defconfig |
509 | sead3micro_defconfig: | 509 | sead3micro_defconfig: |
510 | $(Q)$(MAKE) micro32r2el_defconfig BOARDS=sead-3 | 510 | $(Q)$(MAKE) -f $(srctree)/Makefile micro32r2el_defconfig BOARDS=sead-3 |
diff --git a/arch/mips/include/asm/asm-prototypes.h b/arch/mips/include/asm/asm-prototypes.h index a160cf69bb92..6e28971fe73a 100644 --- a/arch/mips/include/asm/asm-prototypes.h +++ b/arch/mips/include/asm/asm-prototypes.h | |||
@@ -3,3 +3,4 @@ | |||
3 | #include <asm/fpu.h> | 3 | #include <asm/fpu.h> |
4 | #include <asm-generic/asm-prototypes.h> | 4 | #include <asm-generic/asm-prototypes.h> |
5 | #include <asm/uaccess.h> | 5 | #include <asm/uaccess.h> |
6 | #include <asm/ftrace.h> | ||
diff --git a/arch/mips/include/asm/fpu.h b/arch/mips/include/asm/fpu.h index f94455f964ec..a2813fe381cf 100644 --- a/arch/mips/include/asm/fpu.h +++ b/arch/mips/include/asm/fpu.h | |||
@@ -21,6 +21,7 @@ | |||
21 | #include <asm/cpu-features.h> | 21 | #include <asm/cpu-features.h> |
22 | #include <asm/fpu_emulator.h> | 22 | #include <asm/fpu_emulator.h> |
23 | #include <asm/hazards.h> | 23 | #include <asm/hazards.h> |
24 | #include <asm/ptrace.h> | ||
24 | #include <asm/processor.h> | 25 | #include <asm/processor.h> |
25 | #include <asm/current.h> | 26 | #include <asm/current.h> |
26 | #include <asm/msa.h> | 27 | #include <asm/msa.h> |
diff --git a/arch/mips/include/asm/irq.h b/arch/mips/include/asm/irq.h index 956db6e201d1..ddd1c918103b 100644 --- a/arch/mips/include/asm/irq.h +++ b/arch/mips/include/asm/irq.h | |||
@@ -18,9 +18,24 @@ | |||
18 | #include <irq.h> | 18 | #include <irq.h> |
19 | 19 | ||
20 | #define IRQ_STACK_SIZE THREAD_SIZE | 20 | #define IRQ_STACK_SIZE THREAD_SIZE |
21 | #define IRQ_STACK_START (IRQ_STACK_SIZE - sizeof(unsigned long)) | ||
21 | 22 | ||
22 | extern void *irq_stack[NR_CPUS]; | 23 | extern void *irq_stack[NR_CPUS]; |
23 | 24 | ||
25 | /* | ||
26 | * The highest address on the IRQ stack contains a dummy frame put down in | ||
27 | * genex.S (handle_int & except_vec_vi_handler) which is structured as follows: | ||
28 | * | ||
29 | * top ------------ | ||
30 | * | task sp | <- irq_stack[cpu] + IRQ_STACK_START | ||
31 | * ------------ | ||
32 | * | | <- First frame of IRQ context | ||
33 | * ------------ | ||
34 | * | ||
35 | * task sp holds a copy of the task stack pointer where the struct pt_regs | ||
36 | * from exception entry can be found. | ||
37 | */ | ||
38 | |||
24 | static inline bool on_irq_stack(int cpu, unsigned long sp) | 39 | static inline bool on_irq_stack(int cpu, unsigned long sp) |
25 | { | 40 | { |
26 | unsigned long low = (unsigned long)irq_stack[cpu]; | 41 | unsigned long low = (unsigned long)irq_stack[cpu]; |
diff --git a/arch/mips/include/asm/spinlock.h b/arch/mips/include/asm/spinlock.h index f485afe51514..a8df44d60607 100644 --- a/arch/mips/include/asm/spinlock.h +++ b/arch/mips/include/asm/spinlock.h | |||
@@ -127,7 +127,7 @@ static inline void arch_spin_lock(arch_spinlock_t *lock) | |||
127 | " andi %[ticket], %[ticket], 0xffff \n" | 127 | " andi %[ticket], %[ticket], 0xffff \n" |
128 | " bne %[ticket], %[my_ticket], 4f \n" | 128 | " bne %[ticket], %[my_ticket], 4f \n" |
129 | " subu %[ticket], %[my_ticket], %[ticket] \n" | 129 | " subu %[ticket], %[my_ticket], %[ticket] \n" |
130 | "2: \n" | 130 | "2: .insn \n" |
131 | " .subsection 2 \n" | 131 | " .subsection 2 \n" |
132 | "4: andi %[ticket], %[ticket], 0xffff \n" | 132 | "4: andi %[ticket], %[ticket], 0xffff \n" |
133 | " sll %[ticket], 5 \n" | 133 | " sll %[ticket], 5 \n" |
@@ -202,7 +202,7 @@ static inline unsigned int arch_spin_trylock(arch_spinlock_t *lock) | |||
202 | " sc %[ticket], %[ticket_ptr] \n" | 202 | " sc %[ticket], %[ticket_ptr] \n" |
203 | " beqz %[ticket], 1b \n" | 203 | " beqz %[ticket], 1b \n" |
204 | " li %[ticket], 1 \n" | 204 | " li %[ticket], 1 \n" |
205 | "2: \n" | 205 | "2: .insn \n" |
206 | " .subsection 2 \n" | 206 | " .subsection 2 \n" |
207 | "3: b 2b \n" | 207 | "3: b 2b \n" |
208 | " li %[ticket], 0 \n" | 208 | " li %[ticket], 0 \n" |
@@ -382,7 +382,7 @@ static inline int arch_read_trylock(arch_rwlock_t *rw) | |||
382 | " .set reorder \n" | 382 | " .set reorder \n" |
383 | __WEAK_LLSC_MB | 383 | __WEAK_LLSC_MB |
384 | " li %2, 1 \n" | 384 | " li %2, 1 \n" |
385 | "2: \n" | 385 | "2: .insn \n" |
386 | : "=" GCC_OFF_SMALL_ASM() (rw->lock), "=&r" (tmp), "=&r" (ret) | 386 | : "=" GCC_OFF_SMALL_ASM() (rw->lock), "=&r" (tmp), "=&r" (ret) |
387 | : GCC_OFF_SMALL_ASM() (rw->lock) | 387 | : GCC_OFF_SMALL_ASM() (rw->lock) |
388 | : "memory"); | 388 | : "memory"); |
@@ -422,7 +422,7 @@ static inline int arch_write_trylock(arch_rwlock_t *rw) | |||
422 | " lui %1, 0x8000 \n" | 422 | " lui %1, 0x8000 \n" |
423 | " sc %1, %0 \n" | 423 | " sc %1, %0 \n" |
424 | " li %2, 1 \n" | 424 | " li %2, 1 \n" |
425 | "2: \n" | 425 | "2: .insn \n" |
426 | : "=" GCC_OFF_SMALL_ASM() (rw->lock), "=&r" (tmp), | 426 | : "=" GCC_OFF_SMALL_ASM() (rw->lock), "=&r" (tmp), |
427 | "=&r" (ret) | 427 | "=&r" (ret) |
428 | : GCC_OFF_SMALL_ASM() (rw->lock) | 428 | : GCC_OFF_SMALL_ASM() (rw->lock) |
diff --git a/arch/mips/include/uapi/asm/unistd.h b/arch/mips/include/uapi/asm/unistd.h index 3e940dbe0262..78faf4292e90 100644 --- a/arch/mips/include/uapi/asm/unistd.h +++ b/arch/mips/include/uapi/asm/unistd.h | |||
@@ -386,17 +386,18 @@ | |||
386 | #define __NR_pkey_mprotect (__NR_Linux + 363) | 386 | #define __NR_pkey_mprotect (__NR_Linux + 363) |
387 | #define __NR_pkey_alloc (__NR_Linux + 364) | 387 | #define __NR_pkey_alloc (__NR_Linux + 364) |
388 | #define __NR_pkey_free (__NR_Linux + 365) | 388 | #define __NR_pkey_free (__NR_Linux + 365) |
389 | #define __NR_statx (__NR_Linux + 366) | ||
389 | 390 | ||
390 | 391 | ||
391 | /* | 392 | /* |
392 | * Offset of the last Linux o32 flavoured syscall | 393 | * Offset of the last Linux o32 flavoured syscall |
393 | */ | 394 | */ |
394 | #define __NR_Linux_syscalls 365 | 395 | #define __NR_Linux_syscalls 366 |
395 | 396 | ||
396 | #endif /* _MIPS_SIM == _MIPS_SIM_ABI32 */ | 397 | #endif /* _MIPS_SIM == _MIPS_SIM_ABI32 */ |
397 | 398 | ||
398 | #define __NR_O32_Linux 4000 | 399 | #define __NR_O32_Linux 4000 |
399 | #define __NR_O32_Linux_syscalls 365 | 400 | #define __NR_O32_Linux_syscalls 366 |
400 | 401 | ||
401 | #if _MIPS_SIM == _MIPS_SIM_ABI64 | 402 | #if _MIPS_SIM == _MIPS_SIM_ABI64 |
402 | 403 | ||
@@ -730,16 +731,17 @@ | |||
730 | #define __NR_pkey_mprotect (__NR_Linux + 323) | 731 | #define __NR_pkey_mprotect (__NR_Linux + 323) |
731 | #define __NR_pkey_alloc (__NR_Linux + 324) | 732 | #define __NR_pkey_alloc (__NR_Linux + 324) |
732 | #define __NR_pkey_free (__NR_Linux + 325) | 733 | #define __NR_pkey_free (__NR_Linux + 325) |
734 | #define __NR_statx (__NR_Linux + 326) | ||
733 | 735 | ||
734 | /* | 736 | /* |
735 | * Offset of the last Linux 64-bit flavoured syscall | 737 | * Offset of the last Linux 64-bit flavoured syscall |
736 | */ | 738 | */ |
737 | #define __NR_Linux_syscalls 325 | 739 | #define __NR_Linux_syscalls 326 |
738 | 740 | ||
739 | #endif /* _MIPS_SIM == _MIPS_SIM_ABI64 */ | 741 | #endif /* _MIPS_SIM == _MIPS_SIM_ABI64 */ |
740 | 742 | ||
741 | #define __NR_64_Linux 5000 | 743 | #define __NR_64_Linux 5000 |
742 | #define __NR_64_Linux_syscalls 325 | 744 | #define __NR_64_Linux_syscalls 326 |
743 | 745 | ||
744 | #if _MIPS_SIM == _MIPS_SIM_NABI32 | 746 | #if _MIPS_SIM == _MIPS_SIM_NABI32 |
745 | 747 | ||
@@ -1077,15 +1079,16 @@ | |||
1077 | #define __NR_pkey_mprotect (__NR_Linux + 327) | 1079 | #define __NR_pkey_mprotect (__NR_Linux + 327) |
1078 | #define __NR_pkey_alloc (__NR_Linux + 328) | 1080 | #define __NR_pkey_alloc (__NR_Linux + 328) |
1079 | #define __NR_pkey_free (__NR_Linux + 329) | 1081 | #define __NR_pkey_free (__NR_Linux + 329) |
1082 | #define __NR_statx (__NR_Linux + 330) | ||
1080 | 1083 | ||
1081 | /* | 1084 | /* |
1082 | * Offset of the last N32 flavoured syscall | 1085 | * Offset of the last N32 flavoured syscall |
1083 | */ | 1086 | */ |
1084 | #define __NR_Linux_syscalls 329 | 1087 | #define __NR_Linux_syscalls 330 |
1085 | 1088 | ||
1086 | #endif /* _MIPS_SIM == _MIPS_SIM_NABI32 */ | 1089 | #endif /* _MIPS_SIM == _MIPS_SIM_NABI32 */ |
1087 | 1090 | ||
1088 | #define __NR_N32_Linux 6000 | 1091 | #define __NR_N32_Linux 6000 |
1089 | #define __NR_N32_Linux_syscalls 329 | 1092 | #define __NR_N32_Linux_syscalls 330 |
1090 | 1093 | ||
1091 | #endif /* _UAPI_ASM_UNISTD_H */ | 1094 | #endif /* _UAPI_ASM_UNISTD_H */ |
diff --git a/arch/mips/kernel/asm-offsets.c b/arch/mips/kernel/asm-offsets.c index bb5c5d34ba81..a670c0c11875 100644 --- a/arch/mips/kernel/asm-offsets.c +++ b/arch/mips/kernel/asm-offsets.c | |||
@@ -102,6 +102,7 @@ void output_thread_info_defines(void) | |||
102 | DEFINE(_THREAD_SIZE, THREAD_SIZE); | 102 | DEFINE(_THREAD_SIZE, THREAD_SIZE); |
103 | DEFINE(_THREAD_MASK, THREAD_MASK); | 103 | DEFINE(_THREAD_MASK, THREAD_MASK); |
104 | DEFINE(_IRQ_STACK_SIZE, IRQ_STACK_SIZE); | 104 | DEFINE(_IRQ_STACK_SIZE, IRQ_STACK_SIZE); |
105 | DEFINE(_IRQ_STACK_START, IRQ_STACK_START); | ||
105 | BLANK(); | 106 | BLANK(); |
106 | } | 107 | } |
107 | 108 | ||
diff --git a/arch/mips/kernel/cevt-r4k.c b/arch/mips/kernel/cevt-r4k.c index 804d2a2a19fe..dd6a18bc10ab 100644 --- a/arch/mips/kernel/cevt-r4k.c +++ b/arch/mips/kernel/cevt-r4k.c | |||
@@ -80,7 +80,7 @@ static unsigned int calculate_min_delta(void) | |||
80 | } | 80 | } |
81 | 81 | ||
82 | /* Sorted insert of 75th percentile into buf2 */ | 82 | /* Sorted insert of 75th percentile into buf2 */ |
83 | for (k = 0; k < i; ++k) { | 83 | for (k = 0; k < i && k < ARRAY_SIZE(buf2); ++k) { |
84 | if (buf1[ARRAY_SIZE(buf1) - 1] < buf2[k]) { | 84 | if (buf1[ARRAY_SIZE(buf1) - 1] < buf2[k]) { |
85 | l = min_t(unsigned int, | 85 | l = min_t(unsigned int, |
86 | i, ARRAY_SIZE(buf2) - 1); | 86 | i, ARRAY_SIZE(buf2) - 1); |
diff --git a/arch/mips/kernel/cps-vec.S b/arch/mips/kernel/cps-vec.S index 59476a607add..a00e87b0256d 100644 --- a/arch/mips/kernel/cps-vec.S +++ b/arch/mips/kernel/cps-vec.S | |||
@@ -361,7 +361,7 @@ LEAF(mips_cps_get_bootcfg) | |||
361 | END(mips_cps_get_bootcfg) | 361 | END(mips_cps_get_bootcfg) |
362 | 362 | ||
363 | LEAF(mips_cps_boot_vpes) | 363 | LEAF(mips_cps_boot_vpes) |
364 | PTR_L ta2, COREBOOTCFG_VPEMASK(a0) | 364 | lw ta2, COREBOOTCFG_VPEMASK(a0) |
365 | PTR_L ta3, COREBOOTCFG_VPECONFIG(a0) | 365 | PTR_L ta3, COREBOOTCFG_VPECONFIG(a0) |
366 | 366 | ||
367 | #if defined(CONFIG_CPU_MIPSR6) | 367 | #if defined(CONFIG_CPU_MIPSR6) |
diff --git a/arch/mips/kernel/cpu-probe.c b/arch/mips/kernel/cpu-probe.c index 07718bb5fc9d..12422fd4af23 100644 --- a/arch/mips/kernel/cpu-probe.c +++ b/arch/mips/kernel/cpu-probe.c | |||
@@ -1824,7 +1824,7 @@ static inline void cpu_probe_loongson(struct cpuinfo_mips *c, unsigned int cpu) | |||
1824 | } | 1824 | } |
1825 | 1825 | ||
1826 | decode_configs(c); | 1826 | decode_configs(c); |
1827 | c->options |= MIPS_CPU_TLBINV | MIPS_CPU_LDPTE; | 1827 | c->options |= MIPS_CPU_FTLB | MIPS_CPU_TLBINV | MIPS_CPU_LDPTE; |
1828 | c->writecombine = _CACHE_UNCACHED_ACCELERATED; | 1828 | c->writecombine = _CACHE_UNCACHED_ACCELERATED; |
1829 | break; | 1829 | break; |
1830 | default: | 1830 | default: |
diff --git a/arch/mips/kernel/elf.c b/arch/mips/kernel/elf.c index 6430bff21fff..5c429d70e17f 100644 --- a/arch/mips/kernel/elf.c +++ b/arch/mips/kernel/elf.c | |||
@@ -257,7 +257,7 @@ int arch_check_elf(void *_ehdr, bool has_interpreter, void *_interp_ehdr, | |||
257 | else if ((prog_req.fr1 && prog_req.frdefault) || | 257 | else if ((prog_req.fr1 && prog_req.frdefault) || |
258 | (prog_req.single && !prog_req.frdefault)) | 258 | (prog_req.single && !prog_req.frdefault)) |
259 | /* Make sure 64-bit MIPS III/IV/64R1 will not pick FR1 */ | 259 | /* Make sure 64-bit MIPS III/IV/64R1 will not pick FR1 */ |
260 | state->overall_fp_mode = ((current_cpu_data.fpu_id & MIPS_FPIR_F64) && | 260 | state->overall_fp_mode = ((raw_current_cpu_data.fpu_id & MIPS_FPIR_F64) && |
261 | cpu_has_mips_r2_r6) ? | 261 | cpu_has_mips_r2_r6) ? |
262 | FP_FR1 : FP_FR0; | 262 | FP_FR1 : FP_FR0; |
263 | else if (prog_req.fr1) | 263 | else if (prog_req.fr1) |
diff --git a/arch/mips/kernel/genex.S b/arch/mips/kernel/genex.S index 7ec9612cb007..ae810da4d499 100644 --- a/arch/mips/kernel/genex.S +++ b/arch/mips/kernel/genex.S | |||
@@ -215,9 +215,11 @@ NESTED(handle_int, PT_SIZE, sp) | |||
215 | beq t0, t1, 2f | 215 | beq t0, t1, 2f |
216 | 216 | ||
217 | /* Switch to IRQ stack */ | 217 | /* Switch to IRQ stack */ |
218 | li t1, _IRQ_STACK_SIZE | 218 | li t1, _IRQ_STACK_START |
219 | PTR_ADD sp, t0, t1 | 219 | PTR_ADD sp, t0, t1 |
220 | 220 | ||
221 | /* Save task's sp on IRQ stack so that unwinding can follow it */ | ||
222 | LONG_S s1, 0(sp) | ||
221 | 2: | 223 | 2: |
222 | jal plat_irq_dispatch | 224 | jal plat_irq_dispatch |
223 | 225 | ||
@@ -325,9 +327,11 @@ NESTED(except_vec_vi_handler, 0, sp) | |||
325 | beq t0, t1, 2f | 327 | beq t0, t1, 2f |
326 | 328 | ||
327 | /* Switch to IRQ stack */ | 329 | /* Switch to IRQ stack */ |
328 | li t1, _IRQ_STACK_SIZE | 330 | li t1, _IRQ_STACK_START |
329 | PTR_ADD sp, t0, t1 | 331 | PTR_ADD sp, t0, t1 |
330 | 332 | ||
333 | /* Save task's sp on IRQ stack so that unwinding can follow it */ | ||
334 | LONG_S s1, 0(sp) | ||
331 | 2: | 335 | 2: |
332 | jalr v0 | 336 | jalr v0 |
333 | 337 | ||
@@ -519,7 +523,7 @@ NESTED(nmi_handler, PT_SIZE, sp) | |||
519 | BUILD_HANDLER reserved reserved sti verbose /* others */ | 523 | BUILD_HANDLER reserved reserved sti verbose /* others */ |
520 | 524 | ||
521 | .align 5 | 525 | .align 5 |
522 | LEAF(handle_ri_rdhwr_vivt) | 526 | LEAF(handle_ri_rdhwr_tlbp) |
523 | .set push | 527 | .set push |
524 | .set noat | 528 | .set noat |
525 | .set noreorder | 529 | .set noreorder |
@@ -538,7 +542,7 @@ NESTED(nmi_handler, PT_SIZE, sp) | |||
538 | .set pop | 542 | .set pop |
539 | bltz k1, handle_ri /* slow path */ | 543 | bltz k1, handle_ri /* slow path */ |
540 | /* fall thru */ | 544 | /* fall thru */ |
541 | END(handle_ri_rdhwr_vivt) | 545 | END(handle_ri_rdhwr_tlbp) |
542 | 546 | ||
543 | LEAF(handle_ri_rdhwr) | 547 | LEAF(handle_ri_rdhwr) |
544 | .set push | 548 | .set push |
diff --git a/arch/mips/kernel/kgdb.c b/arch/mips/kernel/kgdb.c index 1f4bd222ba76..eb6c0d582626 100644 --- a/arch/mips/kernel/kgdb.c +++ b/arch/mips/kernel/kgdb.c | |||
@@ -244,9 +244,6 @@ static int compute_signal(int tt) | |||
244 | void sleeping_thread_to_gdb_regs(unsigned long *gdb_regs, struct task_struct *p) | 244 | void sleeping_thread_to_gdb_regs(unsigned long *gdb_regs, struct task_struct *p) |
245 | { | 245 | { |
246 | int reg; | 246 | int reg; |
247 | struct thread_info *ti = task_thread_info(p); | ||
248 | unsigned long ksp = (unsigned long)ti + THREAD_SIZE - 32; | ||
249 | struct pt_regs *regs = (struct pt_regs *)ksp - 1; | ||
250 | #if (KGDB_GDB_REG_SIZE == 32) | 247 | #if (KGDB_GDB_REG_SIZE == 32) |
251 | u32 *ptr = (u32 *)gdb_regs; | 248 | u32 *ptr = (u32 *)gdb_regs; |
252 | #else | 249 | #else |
@@ -254,25 +251,46 @@ void sleeping_thread_to_gdb_regs(unsigned long *gdb_regs, struct task_struct *p) | |||
254 | #endif | 251 | #endif |
255 | 252 | ||
256 | for (reg = 0; reg < 16; reg++) | 253 | for (reg = 0; reg < 16; reg++) |
257 | *(ptr++) = regs->regs[reg]; | 254 | *(ptr++) = 0; |
258 | 255 | ||
259 | /* S0 - S7 */ | 256 | /* S0 - S7 */ |
260 | for (reg = 16; reg < 24; reg++) | 257 | *(ptr++) = p->thread.reg16; |
261 | *(ptr++) = regs->regs[reg]; | 258 | *(ptr++) = p->thread.reg17; |
259 | *(ptr++) = p->thread.reg18; | ||
260 | *(ptr++) = p->thread.reg19; | ||
261 | *(ptr++) = p->thread.reg20; | ||
262 | *(ptr++) = p->thread.reg21; | ||
263 | *(ptr++) = p->thread.reg22; | ||
264 | *(ptr++) = p->thread.reg23; | ||
262 | 265 | ||
263 | for (reg = 24; reg < 28; reg++) | 266 | for (reg = 24; reg < 28; reg++) |
264 | *(ptr++) = 0; | 267 | *(ptr++) = 0; |
265 | 268 | ||
266 | /* GP, SP, FP, RA */ | 269 | /* GP, SP, FP, RA */ |
267 | for (reg = 28; reg < 32; reg++) | 270 | *(ptr++) = (long)p; |
268 | *(ptr++) = regs->regs[reg]; | 271 | *(ptr++) = p->thread.reg29; |
269 | 272 | *(ptr++) = p->thread.reg30; | |
270 | *(ptr++) = regs->cp0_status; | 273 | *(ptr++) = p->thread.reg31; |
271 | *(ptr++) = regs->lo; | 274 | |
272 | *(ptr++) = regs->hi; | 275 | *(ptr++) = p->thread.cp0_status; |
273 | *(ptr++) = regs->cp0_badvaddr; | 276 | |
274 | *(ptr++) = regs->cp0_cause; | 277 | /* lo, hi */ |
275 | *(ptr++) = regs->cp0_epc; | 278 | *(ptr++) = 0; |
279 | *(ptr++) = 0; | ||
280 | |||
281 | /* | ||
282 | * BadVAddr, Cause | ||
283 | * Ideally these would come from the last exception frame up the stack | ||
284 | * but that requires unwinding, otherwise we can't know much for sure. | ||
285 | */ | ||
286 | *(ptr++) = 0; | ||
287 | *(ptr++) = 0; | ||
288 | |||
289 | /* | ||
290 | * PC | ||
291 | * use return address (RA), i.e. the moment after return from resume() | ||
292 | */ | ||
293 | *(ptr++) = p->thread.reg31; | ||
276 | } | 294 | } |
277 | 295 | ||
278 | void kgdb_arch_set_pc(struct pt_regs *regs, unsigned long pc) | 296 | void kgdb_arch_set_pc(struct pt_regs *regs, unsigned long pc) |
diff --git a/arch/mips/kernel/perf_event_mipsxx.c b/arch/mips/kernel/perf_event_mipsxx.c index 8c35b3152e1e..9452b02ce079 100644 --- a/arch/mips/kernel/perf_event_mipsxx.c +++ b/arch/mips/kernel/perf_event_mipsxx.c | |||
@@ -1446,6 +1446,11 @@ static int mipsxx_pmu_handle_shared_irq(void) | |||
1446 | HANDLE_COUNTER(0) | 1446 | HANDLE_COUNTER(0) |
1447 | } | 1447 | } |
1448 | 1448 | ||
1449 | #ifdef CONFIG_MIPS_PERF_SHARED_TC_COUNTERS | ||
1450 | read_unlock(&pmuint_rwlock); | ||
1451 | #endif | ||
1452 | resume_local_counters(); | ||
1453 | |||
1449 | /* | 1454 | /* |
1450 | * Do all the work for the pending perf events. We can do this | 1455 | * Do all the work for the pending perf events. We can do this |
1451 | * in here because the performance counter interrupt is a regular | 1456 | * in here because the performance counter interrupt is a regular |
@@ -1454,10 +1459,6 @@ static int mipsxx_pmu_handle_shared_irq(void) | |||
1454 | if (handled == IRQ_HANDLED) | 1459 | if (handled == IRQ_HANDLED) |
1455 | irq_work_run(); | 1460 | irq_work_run(); |
1456 | 1461 | ||
1457 | #ifdef CONFIG_MIPS_PERF_SHARED_TC_COUNTERS | ||
1458 | read_unlock(&pmuint_rwlock); | ||
1459 | #endif | ||
1460 | resume_local_counters(); | ||
1461 | return handled; | 1462 | return handled; |
1462 | } | 1463 | } |
1463 | 1464 | ||
diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c index fb6b6b650719..b68e10fc453d 100644 --- a/arch/mips/kernel/process.c +++ b/arch/mips/kernel/process.c | |||
@@ -488,31 +488,52 @@ unsigned long notrace unwind_stack_by_address(unsigned long stack_page, | |||
488 | unsigned long pc, | 488 | unsigned long pc, |
489 | unsigned long *ra) | 489 | unsigned long *ra) |
490 | { | 490 | { |
491 | unsigned long low, high, irq_stack_high; | ||
491 | struct mips_frame_info info; | 492 | struct mips_frame_info info; |
492 | unsigned long size, ofs; | 493 | unsigned long size, ofs; |
494 | struct pt_regs *regs; | ||
493 | int leaf; | 495 | int leaf; |
494 | extern void ret_from_irq(void); | ||
495 | extern void ret_from_exception(void); | ||
496 | 496 | ||
497 | if (!stack_page) | 497 | if (!stack_page) |
498 | return 0; | 498 | return 0; |
499 | 499 | ||
500 | /* | 500 | /* |
501 | * If we reached the bottom of interrupt context, | 501 | * IRQ stacks start at IRQ_STACK_START |
502 | * return saved pc in pt_regs. | 502 | * task stacks at THREAD_SIZE - 32 |
503 | */ | 503 | */ |
504 | if (pc == (unsigned long)ret_from_irq || | 504 | low = stack_page; |
505 | pc == (unsigned long)ret_from_exception) { | 505 | if (!preemptible() && on_irq_stack(raw_smp_processor_id(), *sp)) { |
506 | struct pt_regs *regs; | 506 | high = stack_page + IRQ_STACK_START; |
507 | if (*sp >= stack_page && | 507 | irq_stack_high = high; |
508 | *sp + sizeof(*regs) <= stack_page + THREAD_SIZE - 32) { | 508 | } else { |
509 | regs = (struct pt_regs *)*sp; | 509 | high = stack_page + THREAD_SIZE - 32; |
510 | pc = regs->cp0_epc; | 510 | irq_stack_high = 0; |
511 | if (!user_mode(regs) && __kernel_text_address(pc)) { | 511 | } |
512 | *sp = regs->regs[29]; | 512 | |
513 | *ra = regs->regs[31]; | 513 | /* |
514 | return pc; | 514 | * If we reached the top of the interrupt stack, start unwinding |
515 | } | 515 | * the interrupted task stack. |
516 | */ | ||
517 | if (unlikely(*sp == irq_stack_high)) { | ||
518 | unsigned long task_sp = *(unsigned long *)*sp; | ||
519 | |||
520 | /* | ||
521 | * Check that the pointer saved in the IRQ stack head points to | ||
522 | * something within the stack of the current task | ||
523 | */ | ||
524 | if (!object_is_on_stack((void *)task_sp)) | ||
525 | return 0; | ||
526 | |||
527 | /* | ||
528 | * Follow pointer to tasks kernel stack frame where interrupted | ||
529 | * state was saved. | ||
530 | */ | ||
531 | regs = (struct pt_regs *)task_sp; | ||
532 | pc = regs->cp0_epc; | ||
533 | if (!user_mode(regs) && __kernel_text_address(pc)) { | ||
534 | *sp = regs->regs[29]; | ||
535 | *ra = regs->regs[31]; | ||
536 | return pc; | ||
516 | } | 537 | } |
517 | return 0; | 538 | return 0; |
518 | } | 539 | } |
@@ -533,8 +554,7 @@ unsigned long notrace unwind_stack_by_address(unsigned long stack_page, | |||
533 | if (leaf < 0) | 554 | if (leaf < 0) |
534 | return 0; | 555 | return 0; |
535 | 556 | ||
536 | if (*sp < stack_page || | 557 | if (*sp < low || *sp + info.frame_size > high) |
537 | *sp + info.frame_size > stack_page + THREAD_SIZE - 32) | ||
538 | return 0; | 558 | return 0; |
539 | 559 | ||
540 | if (leaf) | 560 | if (leaf) |
diff --git a/arch/mips/kernel/relocate.c b/arch/mips/kernel/relocate.c index 9103bebc9a8e..2d1a0c438771 100644 --- a/arch/mips/kernel/relocate.c +++ b/arch/mips/kernel/relocate.c | |||
@@ -18,7 +18,7 @@ | |||
18 | #include <linux/kernel.h> | 18 | #include <linux/kernel.h> |
19 | #include <linux/libfdt.h> | 19 | #include <linux/libfdt.h> |
20 | #include <linux/of_fdt.h> | 20 | #include <linux/of_fdt.h> |
21 | #include <linux/sched.h> | 21 | #include <linux/sched/task.h> |
22 | #include <linux/start_kernel.h> | 22 | #include <linux/start_kernel.h> |
23 | #include <linux/string.h> | 23 | #include <linux/string.h> |
24 | #include <linux/printk.h> | 24 | #include <linux/printk.h> |
diff --git a/arch/mips/kernel/scall32-o32.S b/arch/mips/kernel/scall32-o32.S index c29d397eee86..80ed68b2c95e 100644 --- a/arch/mips/kernel/scall32-o32.S +++ b/arch/mips/kernel/scall32-o32.S | |||
@@ -600,3 +600,4 @@ EXPORT(sys_call_table) | |||
600 | PTR sys_pkey_mprotect | 600 | PTR sys_pkey_mprotect |
601 | PTR sys_pkey_alloc | 601 | PTR sys_pkey_alloc |
602 | PTR sys_pkey_free /* 4365 */ | 602 | PTR sys_pkey_free /* 4365 */ |
603 | PTR sys_statx | ||
diff --git a/arch/mips/kernel/scall64-64.S b/arch/mips/kernel/scall64-64.S index 0687f96ee912..49765b44aa9b 100644 --- a/arch/mips/kernel/scall64-64.S +++ b/arch/mips/kernel/scall64-64.S | |||
@@ -438,4 +438,5 @@ EXPORT(sys_call_table) | |||
438 | PTR sys_pkey_mprotect | 438 | PTR sys_pkey_mprotect |
439 | PTR sys_pkey_alloc | 439 | PTR sys_pkey_alloc |
440 | PTR sys_pkey_free /* 5325 */ | 440 | PTR sys_pkey_free /* 5325 */ |
441 | PTR sys_statx | ||
441 | .size sys_call_table,.-sys_call_table | 442 | .size sys_call_table,.-sys_call_table |
diff --git a/arch/mips/kernel/scall64-n32.S b/arch/mips/kernel/scall64-n32.S index 0331ba39a065..90bad2d1b2d3 100644 --- a/arch/mips/kernel/scall64-n32.S +++ b/arch/mips/kernel/scall64-n32.S | |||
@@ -433,4 +433,5 @@ EXPORT(sysn32_call_table) | |||
433 | PTR sys_pkey_mprotect | 433 | PTR sys_pkey_mprotect |
434 | PTR sys_pkey_alloc | 434 | PTR sys_pkey_alloc |
435 | PTR sys_pkey_free | 435 | PTR sys_pkey_free |
436 | PTR sys_statx /* 6330 */ | ||
436 | .size sysn32_call_table,.-sysn32_call_table | 437 | .size sysn32_call_table,.-sysn32_call_table |
diff --git a/arch/mips/kernel/scall64-o32.S b/arch/mips/kernel/scall64-o32.S index 5a47042dd25f..2dd70bd104e1 100644 --- a/arch/mips/kernel/scall64-o32.S +++ b/arch/mips/kernel/scall64-o32.S | |||
@@ -588,4 +588,5 @@ EXPORT(sys32_call_table) | |||
588 | PTR sys_pkey_mprotect | 588 | PTR sys_pkey_mprotect |
589 | PTR sys_pkey_alloc | 589 | PTR sys_pkey_alloc |
590 | PTR sys_pkey_free /* 4365 */ | 590 | PTR sys_pkey_free /* 4365 */ |
591 | PTR sys_statx | ||
591 | .size sys32_call_table,.-sys32_call_table | 592 | .size sys32_call_table,.-sys32_call_table |
diff --git a/arch/mips/kernel/smp-cps.c b/arch/mips/kernel/smp-cps.c index 6d45f05538c8..795b4aaf8927 100644 --- a/arch/mips/kernel/smp-cps.c +++ b/arch/mips/kernel/smp-cps.c | |||
@@ -422,13 +422,12 @@ void play_dead(void) | |||
422 | local_irq_disable(); | 422 | local_irq_disable(); |
423 | idle_task_exit(); | 423 | idle_task_exit(); |
424 | cpu = smp_processor_id(); | 424 | cpu = smp_processor_id(); |
425 | core = cpu_data[cpu].core; | ||
425 | cpu_death = CPU_DEATH_POWER; | 426 | cpu_death = CPU_DEATH_POWER; |
426 | 427 | ||
427 | pr_debug("CPU%d going offline\n", cpu); | 428 | pr_debug("CPU%d going offline\n", cpu); |
428 | 429 | ||
429 | if (cpu_has_mipsmt || cpu_has_vp) { | 430 | if (cpu_has_mipsmt || cpu_has_vp) { |
430 | core = cpu_data[cpu].core; | ||
431 | |||
432 | /* Look for another online VPE within the core */ | 431 | /* Look for another online VPE within the core */ |
433 | for_each_online_cpu(cpu_death_sibling) { | 432 | for_each_online_cpu(cpu_death_sibling) { |
434 | if (cpu_data[cpu_death_sibling].core != core) | 433 | if (cpu_data[cpu_death_sibling].core != core) |
diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c index c7d17cfb32f6..b49e7bf9f950 100644 --- a/arch/mips/kernel/traps.c +++ b/arch/mips/kernel/traps.c | |||
@@ -83,7 +83,7 @@ extern asmlinkage void handle_dbe(void); | |||
83 | extern asmlinkage void handle_sys(void); | 83 | extern asmlinkage void handle_sys(void); |
84 | extern asmlinkage void handle_bp(void); | 84 | extern asmlinkage void handle_bp(void); |
85 | extern asmlinkage void handle_ri(void); | 85 | extern asmlinkage void handle_ri(void); |
86 | extern asmlinkage void handle_ri_rdhwr_vivt(void); | 86 | extern asmlinkage void handle_ri_rdhwr_tlbp(void); |
87 | extern asmlinkage void handle_ri_rdhwr(void); | 87 | extern asmlinkage void handle_ri_rdhwr(void); |
88 | extern asmlinkage void handle_cpu(void); | 88 | extern asmlinkage void handle_cpu(void); |
89 | extern asmlinkage void handle_ov(void); | 89 | extern asmlinkage void handle_ov(void); |
@@ -2408,9 +2408,18 @@ void __init trap_init(void) | |||
2408 | 2408 | ||
2409 | set_except_vector(EXCCODE_SYS, handle_sys); | 2409 | set_except_vector(EXCCODE_SYS, handle_sys); |
2410 | set_except_vector(EXCCODE_BP, handle_bp); | 2410 | set_except_vector(EXCCODE_BP, handle_bp); |
2411 | set_except_vector(EXCCODE_RI, rdhwr_noopt ? handle_ri : | 2411 | |
2412 | (cpu_has_vtag_icache ? | 2412 | if (rdhwr_noopt) |
2413 | handle_ri_rdhwr_vivt : handle_ri_rdhwr)); | 2413 | set_except_vector(EXCCODE_RI, handle_ri); |
2414 | else { | ||
2415 | if (cpu_has_vtag_icache) | ||
2416 | set_except_vector(EXCCODE_RI, handle_ri_rdhwr_tlbp); | ||
2417 | else if (current_cpu_type() == CPU_LOONGSON3) | ||
2418 | set_except_vector(EXCCODE_RI, handle_ri_rdhwr_tlbp); | ||
2419 | else | ||
2420 | set_except_vector(EXCCODE_RI, handle_ri_rdhwr); | ||
2421 | } | ||
2422 | |||
2414 | set_except_vector(EXCCODE_CPU, handle_cpu); | 2423 | set_except_vector(EXCCODE_CPU, handle_cpu); |
2415 | set_except_vector(EXCCODE_OV, handle_ov); | 2424 | set_except_vector(EXCCODE_OV, handle_ov); |
2416 | set_except_vector(EXCCODE_TR, handle_tr); | 2425 | set_except_vector(EXCCODE_TR, handle_tr); |
diff --git a/arch/mips/lantiq/xway/sysctrl.c b/arch/mips/lantiq/xway/sysctrl.c index 3c3aa05891dd..95bec460b651 100644 --- a/arch/mips/lantiq/xway/sysctrl.c +++ b/arch/mips/lantiq/xway/sysctrl.c | |||
@@ -467,7 +467,7 @@ void __init ltq_soc_init(void) | |||
467 | 467 | ||
468 | if (!np_xbar) | 468 | if (!np_xbar) |
469 | panic("Failed to load xbar nodes from devicetree"); | 469 | panic("Failed to load xbar nodes from devicetree"); |
470 | if (of_address_to_resource(np_pmu, 0, &res_xbar)) | 470 | if (of_address_to_resource(np_xbar, 0, &res_xbar)) |
471 | panic("Failed to get xbar resources"); | 471 | panic("Failed to get xbar resources"); |
472 | if (!request_mem_region(res_xbar.start, resource_size(&res_xbar), | 472 | if (!request_mem_region(res_xbar.start, resource_size(&res_xbar), |
473 | res_xbar.name)) | 473 | res_xbar.name)) |
diff --git a/arch/mips/mm/c-r4k.c b/arch/mips/mm/c-r4k.c index e7f798d55fbc..3fe99cb271a9 100644 --- a/arch/mips/mm/c-r4k.c +++ b/arch/mips/mm/c-r4k.c | |||
@@ -1562,6 +1562,7 @@ static void probe_vcache(void) | |||
1562 | vcache_size = c->vcache.sets * c->vcache.ways * c->vcache.linesz; | 1562 | vcache_size = c->vcache.sets * c->vcache.ways * c->vcache.linesz; |
1563 | 1563 | ||
1564 | c->vcache.waybit = 0; | 1564 | c->vcache.waybit = 0; |
1565 | c->vcache.waysize = vcache_size / c->vcache.ways; | ||
1565 | 1566 | ||
1566 | pr_info("Unified victim cache %ldkB %s, linesize %d bytes.\n", | 1567 | pr_info("Unified victim cache %ldkB %s, linesize %d bytes.\n", |
1567 | vcache_size >> 10, way_string[c->vcache.ways], c->vcache.linesz); | 1568 | vcache_size >> 10, way_string[c->vcache.ways], c->vcache.linesz); |
@@ -1664,6 +1665,7 @@ static void __init loongson3_sc_init(void) | |||
1664 | /* Loongson-3 has 4 cores, 1MB scache for each. scaches are shared */ | 1665 | /* Loongson-3 has 4 cores, 1MB scache for each. scaches are shared */ |
1665 | scache_size *= 4; | 1666 | scache_size *= 4; |
1666 | c->scache.waybit = 0; | 1667 | c->scache.waybit = 0; |
1668 | c->scache.waysize = scache_size / c->scache.ways; | ||
1667 | pr_info("Unified secondary cache %ldkB %s, linesize %d bytes.\n", | 1669 | pr_info("Unified secondary cache %ldkB %s, linesize %d bytes.\n", |
1668 | scache_size >> 10, way_string[c->scache.ways], c->scache.linesz); | 1670 | scache_size >> 10, way_string[c->scache.ways], c->scache.linesz); |
1669 | if (scache_size) | 1671 | if (scache_size) |
diff --git a/arch/mips/mm/tlbex.c b/arch/mips/mm/tlbex.c index 9bfee8988eaf..4f642e07c2b1 100644 --- a/arch/mips/mm/tlbex.c +++ b/arch/mips/mm/tlbex.c | |||
@@ -760,7 +760,8 @@ static void build_huge_update_entries(u32 **p, unsigned int pte, | |||
760 | static void build_huge_handler_tail(u32 **p, struct uasm_reloc **r, | 760 | static void build_huge_handler_tail(u32 **p, struct uasm_reloc **r, |
761 | struct uasm_label **l, | 761 | struct uasm_label **l, |
762 | unsigned int pte, | 762 | unsigned int pte, |
763 | unsigned int ptr) | 763 | unsigned int ptr, |
764 | unsigned int flush) | ||
764 | { | 765 | { |
765 | #ifdef CONFIG_SMP | 766 | #ifdef CONFIG_SMP |
766 | UASM_i_SC(p, pte, 0, ptr); | 767 | UASM_i_SC(p, pte, 0, ptr); |
@@ -769,6 +770,22 @@ static void build_huge_handler_tail(u32 **p, struct uasm_reloc **r, | |||
769 | #else | 770 | #else |
770 | UASM_i_SW(p, pte, 0, ptr); | 771 | UASM_i_SW(p, pte, 0, ptr); |
771 | #endif | 772 | #endif |
773 | if (cpu_has_ftlb && flush) { | ||
774 | BUG_ON(!cpu_has_tlbinv); | ||
775 | |||
776 | UASM_i_MFC0(p, ptr, C0_ENTRYHI); | ||
777 | uasm_i_ori(p, ptr, ptr, MIPS_ENTRYHI_EHINV); | ||
778 | UASM_i_MTC0(p, ptr, C0_ENTRYHI); | ||
779 | build_tlb_write_entry(p, l, r, tlb_indexed); | ||
780 | |||
781 | uasm_i_xori(p, ptr, ptr, MIPS_ENTRYHI_EHINV); | ||
782 | UASM_i_MTC0(p, ptr, C0_ENTRYHI); | ||
783 | build_huge_update_entries(p, pte, ptr); | ||
784 | build_huge_tlb_write_entry(p, l, r, pte, tlb_random, 0); | ||
785 | |||
786 | return; | ||
787 | } | ||
788 | |||
772 | build_huge_update_entries(p, pte, ptr); | 789 | build_huge_update_entries(p, pte, ptr); |
773 | build_huge_tlb_write_entry(p, l, r, pte, tlb_indexed, 0); | 790 | build_huge_tlb_write_entry(p, l, r, pte, tlb_indexed, 0); |
774 | } | 791 | } |
@@ -2199,7 +2216,7 @@ static void build_r4000_tlb_load_handler(void) | |||
2199 | uasm_l_tlbl_goaround2(&l, p); | 2216 | uasm_l_tlbl_goaround2(&l, p); |
2200 | } | 2217 | } |
2201 | uasm_i_ori(&p, wr.r1, wr.r1, (_PAGE_ACCESSED | _PAGE_VALID)); | 2218 | uasm_i_ori(&p, wr.r1, wr.r1, (_PAGE_ACCESSED | _PAGE_VALID)); |
2202 | build_huge_handler_tail(&p, &r, &l, wr.r1, wr.r2); | 2219 | build_huge_handler_tail(&p, &r, &l, wr.r1, wr.r2, 1); |
2203 | #endif | 2220 | #endif |
2204 | 2221 | ||
2205 | uasm_l_nopage_tlbl(&l, p); | 2222 | uasm_l_nopage_tlbl(&l, p); |
@@ -2254,7 +2271,7 @@ static void build_r4000_tlb_store_handler(void) | |||
2254 | build_tlb_probe_entry(&p); | 2271 | build_tlb_probe_entry(&p); |
2255 | uasm_i_ori(&p, wr.r1, wr.r1, | 2272 | uasm_i_ori(&p, wr.r1, wr.r1, |
2256 | _PAGE_ACCESSED | _PAGE_MODIFIED | _PAGE_VALID | _PAGE_DIRTY); | 2273 | _PAGE_ACCESSED | _PAGE_MODIFIED | _PAGE_VALID | _PAGE_DIRTY); |
2257 | build_huge_handler_tail(&p, &r, &l, wr.r1, wr.r2); | 2274 | build_huge_handler_tail(&p, &r, &l, wr.r1, wr.r2, 1); |
2258 | #endif | 2275 | #endif |
2259 | 2276 | ||
2260 | uasm_l_nopage_tlbs(&l, p); | 2277 | uasm_l_nopage_tlbs(&l, p); |
@@ -2310,7 +2327,7 @@ static void build_r4000_tlb_modify_handler(void) | |||
2310 | build_tlb_probe_entry(&p); | 2327 | build_tlb_probe_entry(&p); |
2311 | uasm_i_ori(&p, wr.r1, wr.r1, | 2328 | uasm_i_ori(&p, wr.r1, wr.r1, |
2312 | _PAGE_ACCESSED | _PAGE_MODIFIED | _PAGE_VALID | _PAGE_DIRTY); | 2329 | _PAGE_ACCESSED | _PAGE_MODIFIED | _PAGE_VALID | _PAGE_DIRTY); |
2313 | build_huge_handler_tail(&p, &r, &l, wr.r1, wr.r2); | 2330 | build_huge_handler_tail(&p, &r, &l, wr.r1, wr.r2, 0); |
2314 | #endif | 2331 | #endif |
2315 | 2332 | ||
2316 | uasm_l_nopage_tlbm(&l, p); | 2333 | uasm_l_nopage_tlbm(&l, p); |
diff --git a/arch/mips/mti-malta/malta-int.c b/arch/mips/mti-malta/malta-int.c index cb675ec6f283..54f56d5a96c4 100644 --- a/arch/mips/mti-malta/malta-int.c +++ b/arch/mips/mti-malta/malta-int.c | |||
@@ -232,6 +232,17 @@ void __init arch_init_irq(void) | |||
232 | { | 232 | { |
233 | int corehi_irq; | 233 | int corehi_irq; |
234 | 234 | ||
235 | /* | ||
236 | * Preallocate the i8259's expected virq's here. Since irqchip_init() | ||
237 | * will probe the irqchips in hierarchial order, i8259 is probed last. | ||
238 | * If anything allocates a virq before the i8259 is probed, it will | ||
239 | * be given one of the i8259's expected range and consequently setup | ||
240 | * of the i8259 will fail. | ||
241 | */ | ||
242 | WARN(irq_alloc_descs(I8259A_IRQ_BASE, I8259A_IRQ_BASE, | ||
243 | 16, numa_node_id()) < 0, | ||
244 | "Cannot reserve i8259 virqs at IRQ%d\n", I8259A_IRQ_BASE); | ||
245 | |||
235 | i8259_set_poll(mips_pcibios_iack); | 246 | i8259_set_poll(mips_pcibios_iack); |
236 | irqchip_init(); | 247 | irqchip_init(); |
237 | 248 | ||
diff --git a/arch/mips/pci/pci-legacy.c b/arch/mips/pci/pci-legacy.c index 014649be158d..3a84f6c0c840 100644 --- a/arch/mips/pci/pci-legacy.c +++ b/arch/mips/pci/pci-legacy.c | |||
@@ -190,7 +190,7 @@ void register_pci_controller(struct pci_controller *hose) | |||
190 | } | 190 | } |
191 | 191 | ||
192 | INIT_LIST_HEAD(&hose->list); | 192 | INIT_LIST_HEAD(&hose->list); |
193 | list_add(&hose->list, &controllers); | 193 | list_add_tail(&hose->list, &controllers); |
194 | 194 | ||
195 | /* | 195 | /* |
196 | * Do not panic here but later - this might happen before console init. | 196 | * Do not panic here but later - this might happen before console init. |
diff --git a/arch/mips/ralink/rt3883.c b/arch/mips/ralink/rt3883.c index c4ffd43d3996..48ce701557a4 100644 --- a/arch/mips/ralink/rt3883.c +++ b/arch/mips/ralink/rt3883.c | |||
@@ -35,7 +35,7 @@ static struct rt2880_pmx_func uartlite_func[] = { FUNC("uartlite", 0, 15, 2) }; | |||
35 | static struct rt2880_pmx_func jtag_func[] = { FUNC("jtag", 0, 17, 5) }; | 35 | static struct rt2880_pmx_func jtag_func[] = { FUNC("jtag", 0, 17, 5) }; |
36 | static struct rt2880_pmx_func mdio_func[] = { FUNC("mdio", 0, 22, 2) }; | 36 | static struct rt2880_pmx_func mdio_func[] = { FUNC("mdio", 0, 22, 2) }; |
37 | static struct rt2880_pmx_func lna_a_func[] = { FUNC("lna a", 0, 32, 3) }; | 37 | static struct rt2880_pmx_func lna_a_func[] = { FUNC("lna a", 0, 32, 3) }; |
38 | static struct rt2880_pmx_func lna_g_func[] = { FUNC("lna a", 0, 35, 3) }; | 38 | static struct rt2880_pmx_func lna_g_func[] = { FUNC("lna g", 0, 35, 3) }; |
39 | static struct rt2880_pmx_func pci_func[] = { | 39 | static struct rt2880_pmx_func pci_func[] = { |
40 | FUNC("pci-dev", 0, 40, 32), | 40 | FUNC("pci-dev", 0, 40, 32), |
41 | FUNC("pci-host2", 1, 40, 32), | 41 | FUNC("pci-host2", 1, 40, 32), |
@@ -43,7 +43,7 @@ static struct rt2880_pmx_func pci_func[] = { | |||
43 | FUNC("pci-fnc", 3, 40, 32) | 43 | FUNC("pci-fnc", 3, 40, 32) |
44 | }; | 44 | }; |
45 | static struct rt2880_pmx_func ge1_func[] = { FUNC("ge1", 0, 72, 12) }; | 45 | static struct rt2880_pmx_func ge1_func[] = { FUNC("ge1", 0, 72, 12) }; |
46 | static struct rt2880_pmx_func ge2_func[] = { FUNC("ge1", 0, 84, 12) }; | 46 | static struct rt2880_pmx_func ge2_func[] = { FUNC("ge2", 0, 84, 12) }; |
47 | 47 | ||
48 | static struct rt2880_pmx_group rt3883_pinmux_data[] = { | 48 | static struct rt2880_pmx_group rt3883_pinmux_data[] = { |
49 | GRP("i2c", i2c_func, 1, RT3883_GPIO_MODE_I2C), | 49 | GRP("i2c", i2c_func, 1, RT3883_GPIO_MODE_I2C), |
diff --git a/arch/nios2/kernel/prom.c b/arch/nios2/kernel/prom.c index 367c5426157b..3901b80d4420 100644 --- a/arch/nios2/kernel/prom.c +++ b/arch/nios2/kernel/prom.c | |||
@@ -48,6 +48,13 @@ void * __init early_init_dt_alloc_memory_arch(u64 size, u64 align) | |||
48 | return alloc_bootmem_align(size, align); | 48 | return alloc_bootmem_align(size, align); |
49 | } | 49 | } |
50 | 50 | ||
51 | int __init early_init_dt_reserve_memory_arch(phys_addr_t base, phys_addr_t size, | ||
52 | bool nomap) | ||
53 | { | ||
54 | reserve_bootmem(base, size, BOOTMEM_DEFAULT); | ||
55 | return 0; | ||
56 | } | ||
57 | |||
51 | void __init early_init_devtree(void *params) | 58 | void __init early_init_devtree(void *params) |
52 | { | 59 | { |
53 | __be32 *dtb = (u32 *)__dtb_start; | 60 | __be32 *dtb = (u32 *)__dtb_start; |
diff --git a/arch/nios2/kernel/setup.c b/arch/nios2/kernel/setup.c index 6e57ffa5db27..6044d9be28b4 100644 --- a/arch/nios2/kernel/setup.c +++ b/arch/nios2/kernel/setup.c | |||
@@ -201,6 +201,9 @@ void __init setup_arch(char **cmdline_p) | |||
201 | } | 201 | } |
202 | #endif /* CONFIG_BLK_DEV_INITRD */ | 202 | #endif /* CONFIG_BLK_DEV_INITRD */ |
203 | 203 | ||
204 | early_init_fdt_reserve_self(); | ||
205 | early_init_fdt_scan_reserved_mem(); | ||
206 | |||
204 | unflatten_and_copy_device_tree(); | 207 | unflatten_and_copy_device_tree(); |
205 | 208 | ||
206 | setup_cpuinfo(); | 209 | setup_cpuinfo(); |
diff --git a/arch/parisc/include/asm/uaccess.h b/arch/parisc/include/asm/uaccess.h index edfbf9d6a6dd..cbd4f4af8108 100644 --- a/arch/parisc/include/asm/uaccess.h +++ b/arch/parisc/include/asm/uaccess.h | |||
@@ -39,10 +39,10 @@ | |||
39 | #define get_user __get_user | 39 | #define get_user __get_user |
40 | 40 | ||
41 | #if !defined(CONFIG_64BIT) | 41 | #if !defined(CONFIG_64BIT) |
42 | #define LDD_USER(ptr) __get_user_asm64(ptr) | 42 | #define LDD_USER(val, ptr) __get_user_asm64(val, ptr) |
43 | #define STD_USER(x, ptr) __put_user_asm64(x, ptr) | 43 | #define STD_USER(x, ptr) __put_user_asm64(x, ptr) |
44 | #else | 44 | #else |
45 | #define LDD_USER(ptr) __get_user_asm("ldd", ptr) | 45 | #define LDD_USER(val, ptr) __get_user_asm(val, "ldd", ptr) |
46 | #define STD_USER(x, ptr) __put_user_asm("std", x, ptr) | 46 | #define STD_USER(x, ptr) __put_user_asm("std", x, ptr) |
47 | #endif | 47 | #endif |
48 | 48 | ||
@@ -65,6 +65,15 @@ struct exception_table_entry { | |||
65 | ".previous\n" | 65 | ".previous\n" |
66 | 66 | ||
67 | /* | 67 | /* |
68 | * ASM_EXCEPTIONTABLE_ENTRY_EFAULT() creates a special exception table entry | ||
69 | * (with lowest bit set) for which the fault handler in fixup_exception() will | ||
70 | * load -EFAULT into %r8 for a read or write fault, and zeroes the target | ||
71 | * register in case of a read fault in get_user(). | ||
72 | */ | ||
73 | #define ASM_EXCEPTIONTABLE_ENTRY_EFAULT( fault_addr, except_addr )\ | ||
74 | ASM_EXCEPTIONTABLE_ENTRY( fault_addr, except_addr + 1) | ||
75 | |||
76 | /* | ||
68 | * The page fault handler stores, in a per-cpu area, the following information | 77 | * The page fault handler stores, in a per-cpu area, the following information |
69 | * if a fixup routine is available. | 78 | * if a fixup routine is available. |
70 | */ | 79 | */ |
@@ -88,92 +97,116 @@ struct exception_data { | |||
88 | " mtsp %0,%%sr2\n\t" \ | 97 | " mtsp %0,%%sr2\n\t" \ |
89 | : : "r"(get_fs()) : ) | 98 | : : "r"(get_fs()) : ) |
90 | 99 | ||
91 | #define __get_user(x, ptr) \ | 100 | #define __get_user_internal(val, ptr) \ |
92 | ({ \ | 101 | ({ \ |
93 | register long __gu_err __asm__ ("r8") = 0; \ | 102 | register long __gu_err __asm__ ("r8") = 0; \ |
94 | register long __gu_val __asm__ ("r9") = 0; \ | 103 | \ |
95 | \ | 104 | switch (sizeof(*(ptr))) { \ |
96 | load_sr2(); \ | 105 | case 1: __get_user_asm(val, "ldb", ptr); break; \ |
97 | switch (sizeof(*(ptr))) { \ | 106 | case 2: __get_user_asm(val, "ldh", ptr); break; \ |
98 | case 1: __get_user_asm("ldb", ptr); break; \ | 107 | case 4: __get_user_asm(val, "ldw", ptr); break; \ |
99 | case 2: __get_user_asm("ldh", ptr); break; \ | 108 | case 8: LDD_USER(val, ptr); break; \ |
100 | case 4: __get_user_asm("ldw", ptr); break; \ | 109 | default: BUILD_BUG(); \ |
101 | case 8: LDD_USER(ptr); break; \ | 110 | } \ |
102 | default: BUILD_BUG(); break; \ | 111 | \ |
103 | } \ | 112 | __gu_err; \ |
104 | \ | ||
105 | (x) = (__force __typeof__(*(ptr))) __gu_val; \ | ||
106 | __gu_err; \ | ||
107 | }) | 113 | }) |
108 | 114 | ||
109 | #define __get_user_asm(ldx, ptr) \ | 115 | #define __get_user(val, ptr) \ |
110 | __asm__("\n1:\t" ldx "\t0(%%sr2,%2),%0\n\t" \ | 116 | ({ \ |
111 | ASM_EXCEPTIONTABLE_ENTRY(1b, fixup_get_user_skip_1)\ | 117 | load_sr2(); \ |
118 | __get_user_internal(val, ptr); \ | ||
119 | }) | ||
120 | |||
121 | #define __get_user_asm(val, ldx, ptr) \ | ||
122 | { \ | ||
123 | register long __gu_val; \ | ||
124 | \ | ||
125 | __asm__("1: " ldx " 0(%%sr2,%2),%0\n" \ | ||
126 | "9:\n" \ | ||
127 | ASM_EXCEPTIONTABLE_ENTRY_EFAULT(1b, 9b) \ | ||
112 | : "=r"(__gu_val), "=r"(__gu_err) \ | 128 | : "=r"(__gu_val), "=r"(__gu_err) \ |
113 | : "r"(ptr), "1"(__gu_err) \ | 129 | : "r"(ptr), "1"(__gu_err)); \ |
114 | : "r1"); | 130 | \ |
131 | (val) = (__force __typeof__(*(ptr))) __gu_val; \ | ||
132 | } | ||
115 | 133 | ||
116 | #if !defined(CONFIG_64BIT) | 134 | #if !defined(CONFIG_64BIT) |
117 | 135 | ||
118 | #define __get_user_asm64(ptr) \ | 136 | #define __get_user_asm64(val, ptr) \ |
119 | __asm__("\n1:\tldw 0(%%sr2,%2),%0" \ | 137 | { \ |
120 | "\n2:\tldw 4(%%sr2,%2),%R0\n\t" \ | 138 | union { \ |
121 | ASM_EXCEPTIONTABLE_ENTRY(1b, fixup_get_user_skip_2)\ | 139 | unsigned long long l; \ |
122 | ASM_EXCEPTIONTABLE_ENTRY(2b, fixup_get_user_skip_1)\ | 140 | __typeof__(*(ptr)) t; \ |
123 | : "=r"(__gu_val), "=r"(__gu_err) \ | 141 | } __gu_tmp; \ |
124 | : "r"(ptr), "1"(__gu_err) \ | 142 | \ |
125 | : "r1"); | 143 | __asm__(" copy %%r0,%R0\n" \ |
144 | "1: ldw 0(%%sr2,%2),%0\n" \ | ||
145 | "2: ldw 4(%%sr2,%2),%R0\n" \ | ||
146 | "9:\n" \ | ||
147 | ASM_EXCEPTIONTABLE_ENTRY_EFAULT(1b, 9b) \ | ||
148 | ASM_EXCEPTIONTABLE_ENTRY_EFAULT(2b, 9b) \ | ||
149 | : "=&r"(__gu_tmp.l), "=r"(__gu_err) \ | ||
150 | : "r"(ptr), "1"(__gu_err)); \ | ||
151 | \ | ||
152 | (val) = __gu_tmp.t; \ | ||
153 | } | ||
126 | 154 | ||
127 | #endif /* !defined(CONFIG_64BIT) */ | 155 | #endif /* !defined(CONFIG_64BIT) */ |
128 | 156 | ||
129 | 157 | ||
130 | #define __put_user(x, ptr) \ | 158 | #define __put_user_internal(x, ptr) \ |
131 | ({ \ | 159 | ({ \ |
132 | register long __pu_err __asm__ ("r8") = 0; \ | 160 | register long __pu_err __asm__ ("r8") = 0; \ |
133 | __typeof__(*(ptr)) __x = (__typeof__(*(ptr)))(x); \ | 161 | __typeof__(*(ptr)) __x = (__typeof__(*(ptr)))(x); \ |
134 | \ | 162 | \ |
135 | load_sr2(); \ | ||
136 | switch (sizeof(*(ptr))) { \ | 163 | switch (sizeof(*(ptr))) { \ |
137 | case 1: __put_user_asm("stb", __x, ptr); break; \ | 164 | case 1: __put_user_asm("stb", __x, ptr); break; \ |
138 | case 2: __put_user_asm("sth", __x, ptr); break; \ | 165 | case 2: __put_user_asm("sth", __x, ptr); break; \ |
139 | case 4: __put_user_asm("stw", __x, ptr); break; \ | 166 | case 4: __put_user_asm("stw", __x, ptr); break; \ |
140 | case 8: STD_USER(__x, ptr); break; \ | 167 | case 8: STD_USER(__x, ptr); break; \ |
141 | default: BUILD_BUG(); break; \ | 168 | default: BUILD_BUG(); \ |
142 | } \ | 169 | } \ |
143 | \ | 170 | \ |
144 | __pu_err; \ | 171 | __pu_err; \ |
145 | }) | 172 | }) |
146 | 173 | ||
174 | #define __put_user(x, ptr) \ | ||
175 | ({ \ | ||
176 | load_sr2(); \ | ||
177 | __put_user_internal(x, ptr); \ | ||
178 | }) | ||
179 | |||
180 | |||
147 | /* | 181 | /* |
148 | * The "__put_user/kernel_asm()" macros tell gcc they read from memory | 182 | * The "__put_user/kernel_asm()" macros tell gcc they read from memory |
149 | * instead of writing. This is because they do not write to any memory | 183 | * instead of writing. This is because they do not write to any memory |
150 | * gcc knows about, so there are no aliasing issues. These macros must | 184 | * gcc knows about, so there are no aliasing issues. These macros must |
151 | * also be aware that "fixup_put_user_skip_[12]" are executed in the | 185 | * also be aware that fixups are executed in the context of the fault, |
152 | * context of the fault, and any registers used there must be listed | 186 | * and any registers used there must be listed as clobbers. |
153 | * as clobbers. In this case only "r1" is used by the current routines. | 187 | * r8 is already listed as err. |
154 | * r8/r9 are already listed as err/val. | ||
155 | */ | 188 | */ |
156 | 189 | ||
157 | #define __put_user_asm(stx, x, ptr) \ | 190 | #define __put_user_asm(stx, x, ptr) \ |
158 | __asm__ __volatile__ ( \ | 191 | __asm__ __volatile__ ( \ |
159 | "\n1:\t" stx "\t%2,0(%%sr2,%1)\n\t" \ | 192 | "1: " stx " %2,0(%%sr2,%1)\n" \ |
160 | ASM_EXCEPTIONTABLE_ENTRY(1b, fixup_put_user_skip_1)\ | 193 | "9:\n" \ |
194 | ASM_EXCEPTIONTABLE_ENTRY_EFAULT(1b, 9b) \ | ||
161 | : "=r"(__pu_err) \ | 195 | : "=r"(__pu_err) \ |
162 | : "r"(ptr), "r"(x), "0"(__pu_err) \ | 196 | : "r"(ptr), "r"(x), "0"(__pu_err)) |
163 | : "r1") | ||
164 | 197 | ||
165 | 198 | ||
166 | #if !defined(CONFIG_64BIT) | 199 | #if !defined(CONFIG_64BIT) |
167 | 200 | ||
168 | #define __put_user_asm64(__val, ptr) do { \ | 201 | #define __put_user_asm64(__val, ptr) do { \ |
169 | __asm__ __volatile__ ( \ | 202 | __asm__ __volatile__ ( \ |
170 | "\n1:\tstw %2,0(%%sr2,%1)" \ | 203 | "1: stw %2,0(%%sr2,%1)\n" \ |
171 | "\n2:\tstw %R2,4(%%sr2,%1)\n\t" \ | 204 | "2: stw %R2,4(%%sr2,%1)\n" \ |
172 | ASM_EXCEPTIONTABLE_ENTRY(1b, fixup_put_user_skip_2)\ | 205 | "9:\n" \ |
173 | ASM_EXCEPTIONTABLE_ENTRY(2b, fixup_put_user_skip_1)\ | 206 | ASM_EXCEPTIONTABLE_ENTRY_EFAULT(1b, 9b) \ |
207 | ASM_EXCEPTIONTABLE_ENTRY_EFAULT(2b, 9b) \ | ||
174 | : "=r"(__pu_err) \ | 208 | : "=r"(__pu_err) \ |
175 | : "r"(ptr), "r"(__val), "0"(__pu_err) \ | 209 | : "r"(ptr), "r"(__val), "0"(__pu_err)); \ |
176 | : "r1"); \ | ||
177 | } while (0) | 210 | } while (0) |
178 | 211 | ||
179 | #endif /* !defined(CONFIG_64BIT) */ | 212 | #endif /* !defined(CONFIG_64BIT) */ |
diff --git a/arch/parisc/kernel/parisc_ksyms.c b/arch/parisc/kernel/parisc_ksyms.c index 7484b3d11e0d..c6d6272a934f 100644 --- a/arch/parisc/kernel/parisc_ksyms.c +++ b/arch/parisc/kernel/parisc_ksyms.c | |||
@@ -47,16 +47,6 @@ EXPORT_SYMBOL(__cmpxchg_u64); | |||
47 | EXPORT_SYMBOL(lclear_user); | 47 | EXPORT_SYMBOL(lclear_user); |
48 | EXPORT_SYMBOL(lstrnlen_user); | 48 | EXPORT_SYMBOL(lstrnlen_user); |
49 | 49 | ||
50 | /* Global fixups - defined as int to avoid creation of function pointers */ | ||
51 | extern int fixup_get_user_skip_1; | ||
52 | extern int fixup_get_user_skip_2; | ||
53 | extern int fixup_put_user_skip_1; | ||
54 | extern int fixup_put_user_skip_2; | ||
55 | EXPORT_SYMBOL(fixup_get_user_skip_1); | ||
56 | EXPORT_SYMBOL(fixup_get_user_skip_2); | ||
57 | EXPORT_SYMBOL(fixup_put_user_skip_1); | ||
58 | EXPORT_SYMBOL(fixup_put_user_skip_2); | ||
59 | |||
60 | #ifndef CONFIG_64BIT | 50 | #ifndef CONFIG_64BIT |
61 | /* Needed so insmod can set dp value */ | 51 | /* Needed so insmod can set dp value */ |
62 | extern int $global$; | 52 | extern int $global$; |
diff --git a/arch/parisc/kernel/process.c b/arch/parisc/kernel/process.c index b76f503eee4a..4516a5b53f38 100644 --- a/arch/parisc/kernel/process.c +++ b/arch/parisc/kernel/process.c | |||
@@ -143,6 +143,8 @@ void machine_power_off(void) | |||
143 | printk(KERN_EMERG "System shut down completed.\n" | 143 | printk(KERN_EMERG "System shut down completed.\n" |
144 | "Please power this system off now."); | 144 | "Please power this system off now."); |
145 | 145 | ||
146 | /* prevent soft lockup/stalled CPU messages for endless loop. */ | ||
147 | rcu_sysrq_start(); | ||
146 | for (;;); | 148 | for (;;); |
147 | } | 149 | } |
148 | 150 | ||
diff --git a/arch/parisc/lib/Makefile b/arch/parisc/lib/Makefile index 8fa92b8d839a..f2dac4d73b1b 100644 --- a/arch/parisc/lib/Makefile +++ b/arch/parisc/lib/Makefile | |||
@@ -2,7 +2,7 @@ | |||
2 | # Makefile for parisc-specific library files | 2 | # Makefile for parisc-specific library files |
3 | # | 3 | # |
4 | 4 | ||
5 | lib-y := lusercopy.o bitops.o checksum.o io.o memset.o fixup.o memcpy.o \ | 5 | lib-y := lusercopy.o bitops.o checksum.o io.o memset.o memcpy.o \ |
6 | ucmpdi2.o delay.o | 6 | ucmpdi2.o delay.o |
7 | 7 | ||
8 | obj-y := iomap.o | 8 | obj-y := iomap.o |
diff --git a/arch/parisc/lib/fixup.S b/arch/parisc/lib/fixup.S deleted file mode 100644 index a5b72f22c7a6..000000000000 --- a/arch/parisc/lib/fixup.S +++ /dev/null | |||
@@ -1,98 +0,0 @@ | |||
1 | /* | ||
2 | * Linux/PA-RISC Project (http://www.parisc-linux.org/) | ||
3 | * | ||
4 | * Copyright (C) 2004 Randolph Chung <tausq@debian.org> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2, or (at your option) | ||
9 | * any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
19 | * | ||
20 | * Fixup routines for kernel exception handling. | ||
21 | */ | ||
22 | #include <asm/asm-offsets.h> | ||
23 | #include <asm/assembly.h> | ||
24 | #include <asm/errno.h> | ||
25 | #include <linux/linkage.h> | ||
26 | |||
27 | #ifdef CONFIG_SMP | ||
28 | .macro get_fault_ip t1 t2 | ||
29 | loadgp | ||
30 | addil LT%__per_cpu_offset,%r27 | ||
31 | LDREG RT%__per_cpu_offset(%r1),\t1 | ||
32 | /* t2 = smp_processor_id() */ | ||
33 | mfctl 30,\t2 | ||
34 | ldw TI_CPU(\t2),\t2 | ||
35 | #ifdef CONFIG_64BIT | ||
36 | extrd,u \t2,63,32,\t2 | ||
37 | #endif | ||
38 | /* t2 = &__per_cpu_offset[smp_processor_id()]; */ | ||
39 | LDREGX \t2(\t1),\t2 | ||
40 | addil LT%exception_data,%r27 | ||
41 | LDREG RT%exception_data(%r1),\t1 | ||
42 | /* t1 = this_cpu_ptr(&exception_data) */ | ||
43 | add,l \t1,\t2,\t1 | ||
44 | /* %r27 = t1->fault_gp - restore gp */ | ||
45 | LDREG EXCDATA_GP(\t1), %r27 | ||
46 | /* t1 = t1->fault_ip */ | ||
47 | LDREG EXCDATA_IP(\t1), \t1 | ||
48 | .endm | ||
49 | #else | ||
50 | .macro get_fault_ip t1 t2 | ||
51 | loadgp | ||
52 | /* t1 = this_cpu_ptr(&exception_data) */ | ||
53 | addil LT%exception_data,%r27 | ||
54 | LDREG RT%exception_data(%r1),\t2 | ||
55 | /* %r27 = t2->fault_gp - restore gp */ | ||
56 | LDREG EXCDATA_GP(\t2), %r27 | ||
57 | /* t1 = t2->fault_ip */ | ||
58 | LDREG EXCDATA_IP(\t2), \t1 | ||
59 | .endm | ||
60 | #endif | ||
61 | |||
62 | .level LEVEL | ||
63 | |||
64 | .text | ||
65 | .section .fixup, "ax" | ||
66 | |||
67 | /* get_user() fixups, store -EFAULT in r8, and 0 in r9 */ | ||
68 | ENTRY_CFI(fixup_get_user_skip_1) | ||
69 | get_fault_ip %r1,%r8 | ||
70 | ldo 4(%r1), %r1 | ||
71 | ldi -EFAULT, %r8 | ||
72 | bv %r0(%r1) | ||
73 | copy %r0, %r9 | ||
74 | ENDPROC_CFI(fixup_get_user_skip_1) | ||
75 | |||
76 | ENTRY_CFI(fixup_get_user_skip_2) | ||
77 | get_fault_ip %r1,%r8 | ||
78 | ldo 8(%r1), %r1 | ||
79 | ldi -EFAULT, %r8 | ||
80 | bv %r0(%r1) | ||
81 | copy %r0, %r9 | ||
82 | ENDPROC_CFI(fixup_get_user_skip_2) | ||
83 | |||
84 | /* put_user() fixups, store -EFAULT in r8 */ | ||
85 | ENTRY_CFI(fixup_put_user_skip_1) | ||
86 | get_fault_ip %r1,%r8 | ||
87 | ldo 4(%r1), %r1 | ||
88 | bv %r0(%r1) | ||
89 | ldi -EFAULT, %r8 | ||
90 | ENDPROC_CFI(fixup_put_user_skip_1) | ||
91 | |||
92 | ENTRY_CFI(fixup_put_user_skip_2) | ||
93 | get_fault_ip %r1,%r8 | ||
94 | ldo 8(%r1), %r1 | ||
95 | bv %r0(%r1) | ||
96 | ldi -EFAULT, %r8 | ||
97 | ENDPROC_CFI(fixup_put_user_skip_2) | ||
98 | |||
diff --git a/arch/parisc/lib/lusercopy.S b/arch/parisc/lib/lusercopy.S index 56845de6b5df..85c28bb80fb7 100644 --- a/arch/parisc/lib/lusercopy.S +++ b/arch/parisc/lib/lusercopy.S | |||
@@ -5,6 +5,8 @@ | |||
5 | * Copyright (C) 2000 Richard Hirst <rhirst with parisc-linux.org> | 5 | * Copyright (C) 2000 Richard Hirst <rhirst with parisc-linux.org> |
6 | * Copyright (C) 2001 Matthieu Delahaye <delahaym at esiee.fr> | 6 | * Copyright (C) 2001 Matthieu Delahaye <delahaym at esiee.fr> |
7 | * Copyright (C) 2003 Randolph Chung <tausq with parisc-linux.org> | 7 | * Copyright (C) 2003 Randolph Chung <tausq with parisc-linux.org> |
8 | * Copyright (C) 2017 Helge Deller <deller@gmx.de> | ||
9 | * Copyright (C) 2017 John David Anglin <dave.anglin@bell.net> | ||
8 | * | 10 | * |
9 | * | 11 | * |
10 | * This program is free software; you can redistribute it and/or modify | 12 | * This program is free software; you can redistribute it and/or modify |
@@ -132,4 +134,321 @@ ENDPROC_CFI(lstrnlen_user) | |||
132 | 134 | ||
133 | .procend | 135 | .procend |
134 | 136 | ||
137 | |||
138 | |||
139 | /* | ||
140 | * unsigned long pa_memcpy(void *dstp, const void *srcp, unsigned long len) | ||
141 | * | ||
142 | * Inputs: | ||
143 | * - sr1 already contains space of source region | ||
144 | * - sr2 already contains space of destination region | ||
145 | * | ||
146 | * Returns: | ||
147 | * - number of bytes that could not be copied. | ||
148 | * On success, this will be zero. | ||
149 | * | ||
150 | * This code is based on a C-implementation of a copy routine written by | ||
151 | * Randolph Chung, which in turn was derived from the glibc. | ||
152 | * | ||
153 | * Several strategies are tried to try to get the best performance for various | ||
154 | * conditions. In the optimal case, we copy by loops that copy 32- or 16-bytes | ||
155 | * at a time using general registers. Unaligned copies are handled either by | ||
156 | * aligning the destination and then using shift-and-write method, or in a few | ||
157 | * cases by falling back to a byte-at-a-time copy. | ||
158 | * | ||
159 | * Testing with various alignments and buffer sizes shows that this code is | ||
160 | * often >10x faster than a simple byte-at-a-time copy, even for strangely | ||
161 | * aligned operands. It is interesting to note that the glibc version of memcpy | ||
162 | * (written in C) is actually quite fast already. This routine is able to beat | ||
163 | * it by 30-40% for aligned copies because of the loop unrolling, but in some | ||
164 | * cases the glibc version is still slightly faster. This lends more | ||
165 | * credibility that gcc can generate very good code as long as we are careful. | ||
166 | * | ||
167 | * Possible optimizations: | ||
168 | * - add cache prefetching | ||
169 | * - try not to use the post-increment address modifiers; they may create | ||
170 | * additional interlocks. Assumption is that those were only efficient on old | ||
171 | * machines (pre PA8000 processors) | ||
172 | */ | ||
173 | |||
174 | dst = arg0 | ||
175 | src = arg1 | ||
176 | len = arg2 | ||
177 | end = arg3 | ||
178 | t1 = r19 | ||
179 | t2 = r20 | ||
180 | t3 = r21 | ||
181 | t4 = r22 | ||
182 | srcspc = sr1 | ||
183 | dstspc = sr2 | ||
184 | |||
185 | t0 = r1 | ||
186 | a1 = t1 | ||
187 | a2 = t2 | ||
188 | a3 = t3 | ||
189 | a0 = t4 | ||
190 | |||
191 | save_src = ret0 | ||
192 | save_dst = ret1 | ||
193 | save_len = r31 | ||
194 | |||
195 | ENTRY_CFI(pa_memcpy) | ||
196 | .proc | ||
197 | .callinfo NO_CALLS | ||
198 | .entry | ||
199 | |||
200 | /* Last destination address */ | ||
201 | add dst,len,end | ||
202 | |||
203 | /* short copy with less than 16 bytes? */ | ||
204 | cmpib,COND(>>=),n 15,len,.Lbyte_loop | ||
205 | |||
206 | /* same alignment? */ | ||
207 | xor src,dst,t0 | ||
208 | extru t0,31,2,t1 | ||
209 | cmpib,<>,n 0,t1,.Lunaligned_copy | ||
210 | |||
211 | #ifdef CONFIG_64BIT | ||
212 | /* only do 64-bit copies if we can get aligned. */ | ||
213 | extru t0,31,3,t1 | ||
214 | cmpib,<>,n 0,t1,.Lalign_loop32 | ||
215 | |||
216 | /* loop until we are 64-bit aligned */ | ||
217 | .Lalign_loop64: | ||
218 | extru dst,31,3,t1 | ||
219 | cmpib,=,n 0,t1,.Lcopy_loop_16_start | ||
220 | 20: ldb,ma 1(srcspc,src),t1 | ||
221 | 21: stb,ma t1,1(dstspc,dst) | ||
222 | b .Lalign_loop64 | ||
223 | ldo -1(len),len | ||
224 | |||
225 | ASM_EXCEPTIONTABLE_ENTRY(20b,.Lcopy_done) | ||
226 | ASM_EXCEPTIONTABLE_ENTRY(21b,.Lcopy_done) | ||
227 | |||
228 | .Lcopy_loop_16_start: | ||
229 | ldi 31,t0 | ||
230 | .Lcopy_loop_16: | ||
231 | cmpb,COND(>>=),n t0,len,.Lword_loop | ||
232 | |||
233 | 10: ldd 0(srcspc,src),t1 | ||
234 | 11: ldd 8(srcspc,src),t2 | ||
235 | ldo 16(src),src | ||
236 | 12: std,ma t1,8(dstspc,dst) | ||
237 | 13: std,ma t2,8(dstspc,dst) | ||
238 | 14: ldd 0(srcspc,src),t1 | ||
239 | 15: ldd 8(srcspc,src),t2 | ||
240 | ldo 16(src),src | ||
241 | 16: std,ma t1,8(dstspc,dst) | ||
242 | 17: std,ma t2,8(dstspc,dst) | ||
243 | |||
244 | ASM_EXCEPTIONTABLE_ENTRY(10b,.Lcopy_done) | ||
245 | ASM_EXCEPTIONTABLE_ENTRY(11b,.Lcopy16_fault) | ||
246 | ASM_EXCEPTIONTABLE_ENTRY(12b,.Lcopy_done) | ||
247 | ASM_EXCEPTIONTABLE_ENTRY(13b,.Lcopy_done) | ||
248 | ASM_EXCEPTIONTABLE_ENTRY(14b,.Lcopy_done) | ||
249 | ASM_EXCEPTIONTABLE_ENTRY(15b,.Lcopy16_fault) | ||
250 | ASM_EXCEPTIONTABLE_ENTRY(16b,.Lcopy_done) | ||
251 | ASM_EXCEPTIONTABLE_ENTRY(17b,.Lcopy_done) | ||
252 | |||
253 | b .Lcopy_loop_16 | ||
254 | ldo -32(len),len | ||
255 | |||
256 | .Lword_loop: | ||
257 | cmpib,COND(>>=),n 3,len,.Lbyte_loop | ||
258 | 20: ldw,ma 4(srcspc,src),t1 | ||
259 | 21: stw,ma t1,4(dstspc,dst) | ||
260 | b .Lword_loop | ||
261 | ldo -4(len),len | ||
262 | |||
263 | ASM_EXCEPTIONTABLE_ENTRY(20b,.Lcopy_done) | ||
264 | ASM_EXCEPTIONTABLE_ENTRY(21b,.Lcopy_done) | ||
265 | |||
266 | #endif /* CONFIG_64BIT */ | ||
267 | |||
268 | /* loop until we are 32-bit aligned */ | ||
269 | .Lalign_loop32: | ||
270 | extru dst,31,2,t1 | ||
271 | cmpib,=,n 0,t1,.Lcopy_loop_8 | ||
272 | 20: ldb,ma 1(srcspc,src),t1 | ||
273 | 21: stb,ma t1,1(dstspc,dst) | ||
274 | b .Lalign_loop32 | ||
275 | ldo -1(len),len | ||
276 | |||
277 | ASM_EXCEPTIONTABLE_ENTRY(20b,.Lcopy_done) | ||
278 | ASM_EXCEPTIONTABLE_ENTRY(21b,.Lcopy_done) | ||
279 | |||
280 | |||
281 | .Lcopy_loop_8: | ||
282 | cmpib,COND(>>=),n 15,len,.Lbyte_loop | ||
283 | |||
284 | 10: ldw 0(srcspc,src),t1 | ||
285 | 11: ldw 4(srcspc,src),t2 | ||
286 | 12: stw,ma t1,4(dstspc,dst) | ||
287 | 13: stw,ma t2,4(dstspc,dst) | ||
288 | 14: ldw 8(srcspc,src),t1 | ||
289 | 15: ldw 12(srcspc,src),t2 | ||
290 | ldo 16(src),src | ||
291 | 16: stw,ma t1,4(dstspc,dst) | ||
292 | 17: stw,ma t2,4(dstspc,dst) | ||
293 | |||
294 | ASM_EXCEPTIONTABLE_ENTRY(10b,.Lcopy_done) | ||
295 | ASM_EXCEPTIONTABLE_ENTRY(11b,.Lcopy8_fault) | ||
296 | ASM_EXCEPTIONTABLE_ENTRY(12b,.Lcopy_done) | ||
297 | ASM_EXCEPTIONTABLE_ENTRY(13b,.Lcopy_done) | ||
298 | ASM_EXCEPTIONTABLE_ENTRY(14b,.Lcopy_done) | ||
299 | ASM_EXCEPTIONTABLE_ENTRY(15b,.Lcopy8_fault) | ||
300 | ASM_EXCEPTIONTABLE_ENTRY(16b,.Lcopy_done) | ||
301 | ASM_EXCEPTIONTABLE_ENTRY(17b,.Lcopy_done) | ||
302 | |||
303 | b .Lcopy_loop_8 | ||
304 | ldo -16(len),len | ||
305 | |||
306 | .Lbyte_loop: | ||
307 | cmpclr,COND(<>) len,%r0,%r0 | ||
308 | b,n .Lcopy_done | ||
309 | 20: ldb 0(srcspc,src),t1 | ||
310 | ldo 1(src),src | ||
311 | 21: stb,ma t1,1(dstspc,dst) | ||
312 | b .Lbyte_loop | ||
313 | ldo -1(len),len | ||
314 | |||
315 | ASM_EXCEPTIONTABLE_ENTRY(20b,.Lcopy_done) | ||
316 | ASM_EXCEPTIONTABLE_ENTRY(21b,.Lcopy_done) | ||
317 | |||
318 | .Lcopy_done: | ||
319 | bv %r0(%r2) | ||
320 | sub end,dst,ret0 | ||
321 | |||
322 | |||
323 | /* src and dst are not aligned the same way. */ | ||
324 | /* need to go the hard way */ | ||
325 | .Lunaligned_copy: | ||
326 | /* align until dst is 32bit-word-aligned */ | ||
327 | extru dst,31,2,t1 | ||
328 | cmpib,=,n 0,t1,.Lcopy_dstaligned | ||
329 | 20: ldb 0(srcspc,src),t1 | ||
330 | ldo 1(src),src | ||
331 | 21: stb,ma t1,1(dstspc,dst) | ||
332 | b .Lunaligned_copy | ||
333 | ldo -1(len),len | ||
334 | |||
335 | ASM_EXCEPTIONTABLE_ENTRY(20b,.Lcopy_done) | ||
336 | ASM_EXCEPTIONTABLE_ENTRY(21b,.Lcopy_done) | ||
337 | |||
338 | .Lcopy_dstaligned: | ||
339 | |||
340 | /* store src, dst and len in safe place */ | ||
341 | copy src,save_src | ||
342 | copy dst,save_dst | ||
343 | copy len,save_len | ||
344 | |||
345 | /* len now needs give number of words to copy */ | ||
346 | SHRREG len,2,len | ||
347 | |||
348 | /* | ||
349 | * Copy from a not-aligned src to an aligned dst using shifts. | ||
350 | * Handles 4 words per loop. | ||
351 | */ | ||
352 | |||
353 | depw,z src,28,2,t0 | ||
354 | subi 32,t0,t0 | ||
355 | mtsar t0 | ||
356 | extru len,31,2,t0 | ||
357 | cmpib,= 2,t0,.Lcase2 | ||
358 | /* Make src aligned by rounding it down. */ | ||
359 | depi 0,31,2,src | ||
360 | |||
361 | cmpiclr,<> 3,t0,%r0 | ||
362 | b,n .Lcase3 | ||
363 | cmpiclr,<> 1,t0,%r0 | ||
364 | b,n .Lcase1 | ||
365 | .Lcase0: | ||
366 | cmpb,COND(=) %r0,len,.Lcda_finish | ||
367 | nop | ||
368 | |||
369 | 1: ldw,ma 4(srcspc,src), a3 | ||
370 | ASM_EXCEPTIONTABLE_ENTRY(1b,.Lcda_rdfault) | ||
371 | 1: ldw,ma 4(srcspc,src), a0 | ||
372 | ASM_EXCEPTIONTABLE_ENTRY(1b,.Lcda_rdfault) | ||
373 | b,n .Ldo3 | ||
374 | .Lcase1: | ||
375 | 1: ldw,ma 4(srcspc,src), a2 | ||
376 | ASM_EXCEPTIONTABLE_ENTRY(1b,.Lcda_rdfault) | ||
377 | 1: ldw,ma 4(srcspc,src), a3 | ||
378 | ASM_EXCEPTIONTABLE_ENTRY(1b,.Lcda_rdfault) | ||
379 | ldo -1(len),len | ||
380 | cmpb,COND(=),n %r0,len,.Ldo0 | ||
381 | .Ldo4: | ||
382 | 1: ldw,ma 4(srcspc,src), a0 | ||
383 | ASM_EXCEPTIONTABLE_ENTRY(1b,.Lcda_rdfault) | ||
384 | shrpw a2, a3, %sar, t0 | ||
385 | 1: stw,ma t0, 4(dstspc,dst) | ||
386 | ASM_EXCEPTIONTABLE_ENTRY(1b,.Lcopy_done) | ||
387 | .Ldo3: | ||
388 | 1: ldw,ma 4(srcspc,src), a1 | ||
389 | ASM_EXCEPTIONTABLE_ENTRY(1b,.Lcda_rdfault) | ||
390 | shrpw a3, a0, %sar, t0 | ||
391 | 1: stw,ma t0, 4(dstspc,dst) | ||
392 | ASM_EXCEPTIONTABLE_ENTRY(1b,.Lcopy_done) | ||
393 | .Ldo2: | ||
394 | 1: ldw,ma 4(srcspc,src), a2 | ||
395 | ASM_EXCEPTIONTABLE_ENTRY(1b,.Lcda_rdfault) | ||
396 | shrpw a0, a1, %sar, t0 | ||
397 | 1: stw,ma t0, 4(dstspc,dst) | ||
398 | ASM_EXCEPTIONTABLE_ENTRY(1b,.Lcopy_done) | ||
399 | .Ldo1: | ||
400 | 1: ldw,ma 4(srcspc,src), a3 | ||
401 | ASM_EXCEPTIONTABLE_ENTRY(1b,.Lcda_rdfault) | ||
402 | shrpw a1, a2, %sar, t0 | ||
403 | 1: stw,ma t0, 4(dstspc,dst) | ||
404 | ASM_EXCEPTIONTABLE_ENTRY(1b,.Lcopy_done) | ||
405 | ldo -4(len),len | ||
406 | cmpb,COND(<>) %r0,len,.Ldo4 | ||
407 | nop | ||
408 | .Ldo0: | ||
409 | shrpw a2, a3, %sar, t0 | ||
410 | 1: stw,ma t0, 4(dstspc,dst) | ||
411 | ASM_EXCEPTIONTABLE_ENTRY(1b,.Lcopy_done) | ||
412 | |||
413 | .Lcda_rdfault: | ||
414 | .Lcda_finish: | ||
415 | /* calculate new src, dst and len and jump to byte-copy loop */ | ||
416 | sub dst,save_dst,t0 | ||
417 | add save_src,t0,src | ||
418 | b .Lbyte_loop | ||
419 | sub save_len,t0,len | ||
420 | |||
421 | .Lcase3: | ||
422 | 1: ldw,ma 4(srcspc,src), a0 | ||
423 | ASM_EXCEPTIONTABLE_ENTRY(1b,.Lcda_rdfault) | ||
424 | 1: ldw,ma 4(srcspc,src), a1 | ||
425 | ASM_EXCEPTIONTABLE_ENTRY(1b,.Lcda_rdfault) | ||
426 | b .Ldo2 | ||
427 | ldo 1(len),len | ||
428 | .Lcase2: | ||
429 | 1: ldw,ma 4(srcspc,src), a1 | ||
430 | ASM_EXCEPTIONTABLE_ENTRY(1b,.Lcda_rdfault) | ||
431 | 1: ldw,ma 4(srcspc,src), a2 | ||
432 | ASM_EXCEPTIONTABLE_ENTRY(1b,.Lcda_rdfault) | ||
433 | b .Ldo1 | ||
434 | ldo 2(len),len | ||
435 | |||
436 | |||
437 | /* fault exception fixup handlers: */ | ||
438 | #ifdef CONFIG_64BIT | ||
439 | .Lcopy16_fault: | ||
440 | b .Lcopy_done | ||
441 | 10: std,ma t1,8(dstspc,dst) | ||
442 | ASM_EXCEPTIONTABLE_ENTRY(10b,.Lcopy_done) | ||
443 | #endif | ||
444 | |||
445 | .Lcopy8_fault: | ||
446 | b .Lcopy_done | ||
447 | 10: stw,ma t1,4(dstspc,dst) | ||
448 | ASM_EXCEPTIONTABLE_ENTRY(10b,.Lcopy_done) | ||
449 | |||
450 | .exit | ||
451 | ENDPROC_CFI(pa_memcpy) | ||
452 | .procend | ||
453 | |||
135 | .end | 454 | .end |
diff --git a/arch/parisc/lib/memcpy.c b/arch/parisc/lib/memcpy.c index f82ff10ed974..b3d47ec1d80a 100644 --- a/arch/parisc/lib/memcpy.c +++ b/arch/parisc/lib/memcpy.c | |||
@@ -2,7 +2,7 @@ | |||
2 | * Optimized memory copy routines. | 2 | * Optimized memory copy routines. |
3 | * | 3 | * |
4 | * Copyright (C) 2004 Randolph Chung <tausq@debian.org> | 4 | * Copyright (C) 2004 Randolph Chung <tausq@debian.org> |
5 | * Copyright (C) 2013 Helge Deller <deller@gmx.de> | 5 | * Copyright (C) 2013-2017 Helge Deller <deller@gmx.de> |
6 | * | 6 | * |
7 | * This program is free software; you can redistribute it and/or modify | 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 | 8 | * it under the terms of the GNU General Public License as published by |
@@ -21,474 +21,21 @@ | |||
21 | * Portions derived from the GNU C Library | 21 | * Portions derived from the GNU C Library |
22 | * Copyright (C) 1991, 1997, 2003 Free Software Foundation, Inc. | 22 | * Copyright (C) 1991, 1997, 2003 Free Software Foundation, Inc. |
23 | * | 23 | * |
24 | * Several strategies are tried to try to get the best performance for various | ||
25 | * conditions. In the optimal case, we copy 64-bytes in an unrolled loop using | ||
26 | * fp regs. This is followed by loops that copy 32- or 16-bytes at a time using | ||
27 | * general registers. Unaligned copies are handled either by aligning the | ||
28 | * destination and then using shift-and-write method, or in a few cases by | ||
29 | * falling back to a byte-at-a-time copy. | ||
30 | * | ||
31 | * I chose to implement this in C because it is easier to maintain and debug, | ||
32 | * and in my experiments it appears that the C code generated by gcc (3.3/3.4 | ||
33 | * at the time of writing) is fairly optimal. Unfortunately some of the | ||
34 | * semantics of the copy routine (exception handling) is difficult to express | ||
35 | * in C, so we have to play some tricks to get it to work. | ||
36 | * | ||
37 | * All the loads and stores are done via explicit asm() code in order to use | ||
38 | * the right space registers. | ||
39 | * | ||
40 | * Testing with various alignments and buffer sizes shows that this code is | ||
41 | * often >10x faster than a simple byte-at-a-time copy, even for strangely | ||
42 | * aligned operands. It is interesting to note that the glibc version | ||
43 | * of memcpy (written in C) is actually quite fast already. This routine is | ||
44 | * able to beat it by 30-40% for aligned copies because of the loop unrolling, | ||
45 | * but in some cases the glibc version is still slightly faster. This lends | ||
46 | * more credibility that gcc can generate very good code as long as we are | ||
47 | * careful. | ||
48 | * | ||
49 | * TODO: | ||
50 | * - cache prefetching needs more experimentation to get optimal settings | ||
51 | * - try not to use the post-increment address modifiers; they create additional | ||
52 | * interlocks | ||
53 | * - replace byte-copy loops with stybs sequences | ||
54 | */ | 24 | */ |
55 | 25 | ||
56 | #ifdef __KERNEL__ | ||
57 | #include <linux/module.h> | 26 | #include <linux/module.h> |
58 | #include <linux/compiler.h> | 27 | #include <linux/compiler.h> |
59 | #include <linux/uaccess.h> | 28 | #include <linux/uaccess.h> |
60 | #define s_space "%%sr1" | ||
61 | #define d_space "%%sr2" | ||
62 | #else | ||
63 | #include "memcpy.h" | ||
64 | #define s_space "%%sr0" | ||
65 | #define d_space "%%sr0" | ||
66 | #define pa_memcpy new2_copy | ||
67 | #endif | ||
68 | 29 | ||
69 | DECLARE_PER_CPU(struct exception_data, exception_data); | 30 | DECLARE_PER_CPU(struct exception_data, exception_data); |
70 | 31 | ||
71 | #define preserve_branch(label) do { \ | ||
72 | volatile int dummy = 0; \ | ||
73 | /* The following branch is never taken, it's just here to */ \ | ||
74 | /* prevent gcc from optimizing away our exception code. */ \ | ||
75 | if (unlikely(dummy != dummy)) \ | ||
76 | goto label; \ | ||
77 | } while (0) | ||
78 | |||
79 | #define get_user_space() (segment_eq(get_fs(), KERNEL_DS) ? 0 : mfsp(3)) | 32 | #define get_user_space() (segment_eq(get_fs(), KERNEL_DS) ? 0 : mfsp(3)) |
80 | #define get_kernel_space() (0) | 33 | #define get_kernel_space() (0) |
81 | 34 | ||
82 | #define MERGE(w0, sh_1, w1, sh_2) ({ \ | ||
83 | unsigned int _r; \ | ||
84 | asm volatile ( \ | ||
85 | "mtsar %3\n" \ | ||
86 | "shrpw %1, %2, %%sar, %0\n" \ | ||
87 | : "=r"(_r) \ | ||
88 | : "r"(w0), "r"(w1), "r"(sh_2) \ | ||
89 | ); \ | ||
90 | _r; \ | ||
91 | }) | ||
92 | #define THRESHOLD 16 | ||
93 | |||
94 | #ifdef DEBUG_MEMCPY | ||
95 | #define DPRINTF(fmt, args...) do { printk(KERN_DEBUG "%s:%d:%s ", __FILE__, __LINE__, __func__ ); printk(KERN_DEBUG fmt, ##args ); } while (0) | ||
96 | #else | ||
97 | #define DPRINTF(fmt, args...) | ||
98 | #endif | ||
99 | |||
100 | #define def_load_ai_insn(_insn,_sz,_tt,_s,_a,_t,_e) \ | ||
101 | __asm__ __volatile__ ( \ | ||
102 | "1:\t" #_insn ",ma " #_sz "(" _s ",%1), %0\n\t" \ | ||
103 | ASM_EXCEPTIONTABLE_ENTRY(1b,_e) \ | ||
104 | : _tt(_t), "+r"(_a) \ | ||
105 | : \ | ||
106 | : "r8") | ||
107 | |||
108 | #define def_store_ai_insn(_insn,_sz,_tt,_s,_a,_t,_e) \ | ||
109 | __asm__ __volatile__ ( \ | ||
110 | "1:\t" #_insn ",ma %1, " #_sz "(" _s ",%0)\n\t" \ | ||
111 | ASM_EXCEPTIONTABLE_ENTRY(1b,_e) \ | ||
112 | : "+r"(_a) \ | ||
113 | : _tt(_t) \ | ||
114 | : "r8") | ||
115 | |||
116 | #define ldbma(_s, _a, _t, _e) def_load_ai_insn(ldbs,1,"=r",_s,_a,_t,_e) | ||
117 | #define stbma(_s, _t, _a, _e) def_store_ai_insn(stbs,1,"r",_s,_a,_t,_e) | ||
118 | #define ldwma(_s, _a, _t, _e) def_load_ai_insn(ldw,4,"=r",_s,_a,_t,_e) | ||
119 | #define stwma(_s, _t, _a, _e) def_store_ai_insn(stw,4,"r",_s,_a,_t,_e) | ||
120 | #define flddma(_s, _a, _t, _e) def_load_ai_insn(fldd,8,"=f",_s,_a,_t,_e) | ||
121 | #define fstdma(_s, _t, _a, _e) def_store_ai_insn(fstd,8,"f",_s,_a,_t,_e) | ||
122 | |||
123 | #define def_load_insn(_insn,_tt,_s,_o,_a,_t,_e) \ | ||
124 | __asm__ __volatile__ ( \ | ||
125 | "1:\t" #_insn " " #_o "(" _s ",%1), %0\n\t" \ | ||
126 | ASM_EXCEPTIONTABLE_ENTRY(1b,_e) \ | ||
127 | : _tt(_t) \ | ||
128 | : "r"(_a) \ | ||
129 | : "r8") | ||
130 | |||
131 | #define def_store_insn(_insn,_tt,_s,_t,_o,_a,_e) \ | ||
132 | __asm__ __volatile__ ( \ | ||
133 | "1:\t" #_insn " %0, " #_o "(" _s ",%1)\n\t" \ | ||
134 | ASM_EXCEPTIONTABLE_ENTRY(1b,_e) \ | ||
135 | : \ | ||
136 | : _tt(_t), "r"(_a) \ | ||
137 | : "r8") | ||
138 | |||
139 | #define ldw(_s,_o,_a,_t,_e) def_load_insn(ldw,"=r",_s,_o,_a,_t,_e) | ||
140 | #define stw(_s,_t,_o,_a,_e) def_store_insn(stw,"r",_s,_t,_o,_a,_e) | ||
141 | |||
142 | #ifdef CONFIG_PREFETCH | ||
143 | static inline void prefetch_src(const void *addr) | ||
144 | { | ||
145 | __asm__("ldw 0(" s_space ",%0), %%r0" : : "r" (addr)); | ||
146 | } | ||
147 | |||
148 | static inline void prefetch_dst(const void *addr) | ||
149 | { | ||
150 | __asm__("ldd 0(" d_space ",%0), %%r0" : : "r" (addr)); | ||
151 | } | ||
152 | #else | ||
153 | #define prefetch_src(addr) do { } while(0) | ||
154 | #define prefetch_dst(addr) do { } while(0) | ||
155 | #endif | ||
156 | |||
157 | #define PA_MEMCPY_OK 0 | ||
158 | #define PA_MEMCPY_LOAD_ERROR 1 | ||
159 | #define PA_MEMCPY_STORE_ERROR 2 | ||
160 | |||
161 | /* Copy from a not-aligned src to an aligned dst, using shifts. Handles 4 words | ||
162 | * per loop. This code is derived from glibc. | ||
163 | */ | ||
164 | static noinline unsigned long copy_dstaligned(unsigned long dst, | ||
165 | unsigned long src, unsigned long len) | ||
166 | { | ||
167 | /* gcc complains that a2 and a3 may be uninitialized, but actually | ||
168 | * they cannot be. Initialize a2/a3 to shut gcc up. | ||
169 | */ | ||
170 | register unsigned int a0, a1, a2 = 0, a3 = 0; | ||
171 | int sh_1, sh_2; | ||
172 | |||
173 | /* prefetch_src((const void *)src); */ | ||
174 | |||
175 | /* Calculate how to shift a word read at the memory operation | ||
176 | aligned srcp to make it aligned for copy. */ | ||
177 | sh_1 = 8 * (src % sizeof(unsigned int)); | ||
178 | sh_2 = 8 * sizeof(unsigned int) - sh_1; | ||
179 | |||
180 | /* Make src aligned by rounding it down. */ | ||
181 | src &= -sizeof(unsigned int); | ||
182 | |||
183 | switch (len % 4) | ||
184 | { | ||
185 | case 2: | ||
186 | /* a1 = ((unsigned int *) src)[0]; | ||
187 | a2 = ((unsigned int *) src)[1]; */ | ||
188 | ldw(s_space, 0, src, a1, cda_ldw_exc); | ||
189 | ldw(s_space, 4, src, a2, cda_ldw_exc); | ||
190 | src -= 1 * sizeof(unsigned int); | ||
191 | dst -= 3 * sizeof(unsigned int); | ||
192 | len += 2; | ||
193 | goto do1; | ||
194 | case 3: | ||
195 | /* a0 = ((unsigned int *) src)[0]; | ||
196 | a1 = ((unsigned int *) src)[1]; */ | ||
197 | ldw(s_space, 0, src, a0, cda_ldw_exc); | ||
198 | ldw(s_space, 4, src, a1, cda_ldw_exc); | ||
199 | src -= 0 * sizeof(unsigned int); | ||
200 | dst -= 2 * sizeof(unsigned int); | ||
201 | len += 1; | ||
202 | goto do2; | ||
203 | case 0: | ||
204 | if (len == 0) | ||
205 | return PA_MEMCPY_OK; | ||
206 | /* a3 = ((unsigned int *) src)[0]; | ||
207 | a0 = ((unsigned int *) src)[1]; */ | ||
208 | ldw(s_space, 0, src, a3, cda_ldw_exc); | ||
209 | ldw(s_space, 4, src, a0, cda_ldw_exc); | ||
210 | src -=-1 * sizeof(unsigned int); | ||
211 | dst -= 1 * sizeof(unsigned int); | ||
212 | len += 0; | ||
213 | goto do3; | ||
214 | case 1: | ||
215 | /* a2 = ((unsigned int *) src)[0]; | ||
216 | a3 = ((unsigned int *) src)[1]; */ | ||
217 | ldw(s_space, 0, src, a2, cda_ldw_exc); | ||
218 | ldw(s_space, 4, src, a3, cda_ldw_exc); | ||
219 | src -=-2 * sizeof(unsigned int); | ||
220 | dst -= 0 * sizeof(unsigned int); | ||
221 | len -= 1; | ||
222 | if (len == 0) | ||
223 | goto do0; | ||
224 | goto do4; /* No-op. */ | ||
225 | } | ||
226 | |||
227 | do | ||
228 | { | ||
229 | /* prefetch_src((const void *)(src + 4 * sizeof(unsigned int))); */ | ||
230 | do4: | ||
231 | /* a0 = ((unsigned int *) src)[0]; */ | ||
232 | ldw(s_space, 0, src, a0, cda_ldw_exc); | ||
233 | /* ((unsigned int *) dst)[0] = MERGE (a2, sh_1, a3, sh_2); */ | ||
234 | stw(d_space, MERGE (a2, sh_1, a3, sh_2), 0, dst, cda_stw_exc); | ||
235 | do3: | ||
236 | /* a1 = ((unsigned int *) src)[1]; */ | ||
237 | ldw(s_space, 4, src, a1, cda_ldw_exc); | ||
238 | /* ((unsigned int *) dst)[1] = MERGE (a3, sh_1, a0, sh_2); */ | ||
239 | stw(d_space, MERGE (a3, sh_1, a0, sh_2), 4, dst, cda_stw_exc); | ||
240 | do2: | ||
241 | /* a2 = ((unsigned int *) src)[2]; */ | ||
242 | ldw(s_space, 8, src, a2, cda_ldw_exc); | ||
243 | /* ((unsigned int *) dst)[2] = MERGE (a0, sh_1, a1, sh_2); */ | ||
244 | stw(d_space, MERGE (a0, sh_1, a1, sh_2), 8, dst, cda_stw_exc); | ||
245 | do1: | ||
246 | /* a3 = ((unsigned int *) src)[3]; */ | ||
247 | ldw(s_space, 12, src, a3, cda_ldw_exc); | ||
248 | /* ((unsigned int *) dst)[3] = MERGE (a1, sh_1, a2, sh_2); */ | ||
249 | stw(d_space, MERGE (a1, sh_1, a2, sh_2), 12, dst, cda_stw_exc); | ||
250 | |||
251 | src += 4 * sizeof(unsigned int); | ||
252 | dst += 4 * sizeof(unsigned int); | ||
253 | len -= 4; | ||
254 | } | ||
255 | while (len != 0); | ||
256 | |||
257 | do0: | ||
258 | /* ((unsigned int *) dst)[0] = MERGE (a2, sh_1, a3, sh_2); */ | ||
259 | stw(d_space, MERGE (a2, sh_1, a3, sh_2), 0, dst, cda_stw_exc); | ||
260 | |||
261 | preserve_branch(handle_load_error); | ||
262 | preserve_branch(handle_store_error); | ||
263 | |||
264 | return PA_MEMCPY_OK; | ||
265 | |||
266 | handle_load_error: | ||
267 | __asm__ __volatile__ ("cda_ldw_exc:\n"); | ||
268 | return PA_MEMCPY_LOAD_ERROR; | ||
269 | |||
270 | handle_store_error: | ||
271 | __asm__ __volatile__ ("cda_stw_exc:\n"); | ||
272 | return PA_MEMCPY_STORE_ERROR; | ||
273 | } | ||
274 | |||
275 | |||
276 | /* Returns PA_MEMCPY_OK, PA_MEMCPY_LOAD_ERROR or PA_MEMCPY_STORE_ERROR. | ||
277 | * In case of an access fault the faulty address can be read from the per_cpu | ||
278 | * exception data struct. */ | ||
279 | static noinline unsigned long pa_memcpy_internal(void *dstp, const void *srcp, | ||
280 | unsigned long len) | ||
281 | { | ||
282 | register unsigned long src, dst, t1, t2, t3; | ||
283 | register unsigned char *pcs, *pcd; | ||
284 | register unsigned int *pws, *pwd; | ||
285 | register double *pds, *pdd; | ||
286 | unsigned long ret; | ||
287 | |||
288 | src = (unsigned long)srcp; | ||
289 | dst = (unsigned long)dstp; | ||
290 | pcs = (unsigned char *)srcp; | ||
291 | pcd = (unsigned char *)dstp; | ||
292 | |||
293 | /* prefetch_src((const void *)srcp); */ | ||
294 | |||
295 | if (len < THRESHOLD) | ||
296 | goto byte_copy; | ||
297 | |||
298 | /* Check alignment */ | ||
299 | t1 = (src ^ dst); | ||
300 | if (unlikely(t1 & (sizeof(double)-1))) | ||
301 | goto unaligned_copy; | ||
302 | |||
303 | /* src and dst have same alignment. */ | ||
304 | |||
305 | /* Copy bytes till we are double-aligned. */ | ||
306 | t2 = src & (sizeof(double) - 1); | ||
307 | if (unlikely(t2 != 0)) { | ||
308 | t2 = sizeof(double) - t2; | ||
309 | while (t2 && len) { | ||
310 | /* *pcd++ = *pcs++; */ | ||
311 | ldbma(s_space, pcs, t3, pmc_load_exc); | ||
312 | len--; | ||
313 | stbma(d_space, t3, pcd, pmc_store_exc); | ||
314 | t2--; | ||
315 | } | ||
316 | } | ||
317 | |||
318 | pds = (double *)pcs; | ||
319 | pdd = (double *)pcd; | ||
320 | |||
321 | #if 0 | ||
322 | /* Copy 8 doubles at a time */ | ||
323 | while (len >= 8*sizeof(double)) { | ||
324 | register double r1, r2, r3, r4, r5, r6, r7, r8; | ||
325 | /* prefetch_src((char *)pds + L1_CACHE_BYTES); */ | ||
326 | flddma(s_space, pds, r1, pmc_load_exc); | ||
327 | flddma(s_space, pds, r2, pmc_load_exc); | ||
328 | flddma(s_space, pds, r3, pmc_load_exc); | ||
329 | flddma(s_space, pds, r4, pmc_load_exc); | ||
330 | fstdma(d_space, r1, pdd, pmc_store_exc); | ||
331 | fstdma(d_space, r2, pdd, pmc_store_exc); | ||
332 | fstdma(d_space, r3, pdd, pmc_store_exc); | ||
333 | fstdma(d_space, r4, pdd, pmc_store_exc); | ||
334 | |||
335 | #if 0 | ||
336 | if (L1_CACHE_BYTES <= 32) | ||
337 | prefetch_src((char *)pds + L1_CACHE_BYTES); | ||
338 | #endif | ||
339 | flddma(s_space, pds, r5, pmc_load_exc); | ||
340 | flddma(s_space, pds, r6, pmc_load_exc); | ||
341 | flddma(s_space, pds, r7, pmc_load_exc); | ||
342 | flddma(s_space, pds, r8, pmc_load_exc); | ||
343 | fstdma(d_space, r5, pdd, pmc_store_exc); | ||
344 | fstdma(d_space, r6, pdd, pmc_store_exc); | ||
345 | fstdma(d_space, r7, pdd, pmc_store_exc); | ||
346 | fstdma(d_space, r8, pdd, pmc_store_exc); | ||
347 | len -= 8*sizeof(double); | ||
348 | } | ||
349 | #endif | ||
350 | |||
351 | pws = (unsigned int *)pds; | ||
352 | pwd = (unsigned int *)pdd; | ||
353 | |||
354 | word_copy: | ||
355 | while (len >= 8*sizeof(unsigned int)) { | ||
356 | register unsigned int r1,r2,r3,r4,r5,r6,r7,r8; | ||
357 | /* prefetch_src((char *)pws + L1_CACHE_BYTES); */ | ||
358 | ldwma(s_space, pws, r1, pmc_load_exc); | ||
359 | ldwma(s_space, pws, r2, pmc_load_exc); | ||
360 | ldwma(s_space, pws, r3, pmc_load_exc); | ||
361 | ldwma(s_space, pws, r4, pmc_load_exc); | ||
362 | stwma(d_space, r1, pwd, pmc_store_exc); | ||
363 | stwma(d_space, r2, pwd, pmc_store_exc); | ||
364 | stwma(d_space, r3, pwd, pmc_store_exc); | ||
365 | stwma(d_space, r4, pwd, pmc_store_exc); | ||
366 | |||
367 | ldwma(s_space, pws, r5, pmc_load_exc); | ||
368 | ldwma(s_space, pws, r6, pmc_load_exc); | ||
369 | ldwma(s_space, pws, r7, pmc_load_exc); | ||
370 | ldwma(s_space, pws, r8, pmc_load_exc); | ||
371 | stwma(d_space, r5, pwd, pmc_store_exc); | ||
372 | stwma(d_space, r6, pwd, pmc_store_exc); | ||
373 | stwma(d_space, r7, pwd, pmc_store_exc); | ||
374 | stwma(d_space, r8, pwd, pmc_store_exc); | ||
375 | len -= 8*sizeof(unsigned int); | ||
376 | } | ||
377 | |||
378 | while (len >= 4*sizeof(unsigned int)) { | ||
379 | register unsigned int r1,r2,r3,r4; | ||
380 | ldwma(s_space, pws, r1, pmc_load_exc); | ||
381 | ldwma(s_space, pws, r2, pmc_load_exc); | ||
382 | ldwma(s_space, pws, r3, pmc_load_exc); | ||
383 | ldwma(s_space, pws, r4, pmc_load_exc); | ||
384 | stwma(d_space, r1, pwd, pmc_store_exc); | ||
385 | stwma(d_space, r2, pwd, pmc_store_exc); | ||
386 | stwma(d_space, r3, pwd, pmc_store_exc); | ||
387 | stwma(d_space, r4, pwd, pmc_store_exc); | ||
388 | len -= 4*sizeof(unsigned int); | ||
389 | } | ||
390 | |||
391 | pcs = (unsigned char *)pws; | ||
392 | pcd = (unsigned char *)pwd; | ||
393 | |||
394 | byte_copy: | ||
395 | while (len) { | ||
396 | /* *pcd++ = *pcs++; */ | ||
397 | ldbma(s_space, pcs, t3, pmc_load_exc); | ||
398 | stbma(d_space, t3, pcd, pmc_store_exc); | ||
399 | len--; | ||
400 | } | ||
401 | |||
402 | return PA_MEMCPY_OK; | ||
403 | |||
404 | unaligned_copy: | ||
405 | /* possibly we are aligned on a word, but not on a double... */ | ||
406 | if (likely((t1 & (sizeof(unsigned int)-1)) == 0)) { | ||
407 | t2 = src & (sizeof(unsigned int) - 1); | ||
408 | |||
409 | if (unlikely(t2 != 0)) { | ||
410 | t2 = sizeof(unsigned int) - t2; | ||
411 | while (t2) { | ||
412 | /* *pcd++ = *pcs++; */ | ||
413 | ldbma(s_space, pcs, t3, pmc_load_exc); | ||
414 | stbma(d_space, t3, pcd, pmc_store_exc); | ||
415 | len--; | ||
416 | t2--; | ||
417 | } | ||
418 | } | ||
419 | |||
420 | pws = (unsigned int *)pcs; | ||
421 | pwd = (unsigned int *)pcd; | ||
422 | goto word_copy; | ||
423 | } | ||
424 | |||
425 | /* Align the destination. */ | ||
426 | if (unlikely((dst & (sizeof(unsigned int) - 1)) != 0)) { | ||
427 | t2 = sizeof(unsigned int) - (dst & (sizeof(unsigned int) - 1)); | ||
428 | while (t2) { | ||
429 | /* *pcd++ = *pcs++; */ | ||
430 | ldbma(s_space, pcs, t3, pmc_load_exc); | ||
431 | stbma(d_space, t3, pcd, pmc_store_exc); | ||
432 | len--; | ||
433 | t2--; | ||
434 | } | ||
435 | dst = (unsigned long)pcd; | ||
436 | src = (unsigned long)pcs; | ||
437 | } | ||
438 | |||
439 | ret = copy_dstaligned(dst, src, len / sizeof(unsigned int)); | ||
440 | if (ret) | ||
441 | return ret; | ||
442 | |||
443 | pcs += (len & -sizeof(unsigned int)); | ||
444 | pcd += (len & -sizeof(unsigned int)); | ||
445 | len %= sizeof(unsigned int); | ||
446 | |||
447 | preserve_branch(handle_load_error); | ||
448 | preserve_branch(handle_store_error); | ||
449 | |||
450 | goto byte_copy; | ||
451 | |||
452 | handle_load_error: | ||
453 | __asm__ __volatile__ ("pmc_load_exc:\n"); | ||
454 | return PA_MEMCPY_LOAD_ERROR; | ||
455 | |||
456 | handle_store_error: | ||
457 | __asm__ __volatile__ ("pmc_store_exc:\n"); | ||
458 | return PA_MEMCPY_STORE_ERROR; | ||
459 | } | ||
460 | |||
461 | |||
462 | /* Returns 0 for success, otherwise, returns number of bytes not transferred. */ | 35 | /* Returns 0 for success, otherwise, returns number of bytes not transferred. */ |
463 | static unsigned long pa_memcpy(void *dstp, const void *srcp, unsigned long len) | 36 | extern unsigned long pa_memcpy(void *dst, const void *src, |
464 | { | 37 | unsigned long len); |
465 | unsigned long ret, fault_addr, reference; | ||
466 | struct exception_data *d; | ||
467 | |||
468 | ret = pa_memcpy_internal(dstp, srcp, len); | ||
469 | if (likely(ret == PA_MEMCPY_OK)) | ||
470 | return 0; | ||
471 | |||
472 | /* if a load or store fault occured we can get the faulty addr */ | ||
473 | d = this_cpu_ptr(&exception_data); | ||
474 | fault_addr = d->fault_addr; | ||
475 | |||
476 | /* error in load or store? */ | ||
477 | if (ret == PA_MEMCPY_LOAD_ERROR) | ||
478 | reference = (unsigned long) srcp; | ||
479 | else | ||
480 | reference = (unsigned long) dstp; | ||
481 | 38 | ||
482 | DPRINTF("pa_memcpy: fault type = %lu, len=%lu fault_addr=%lu ref=%lu\n", | ||
483 | ret, len, fault_addr, reference); | ||
484 | |||
485 | if (fault_addr >= reference) | ||
486 | return len - (fault_addr - reference); | ||
487 | else | ||
488 | return len; | ||
489 | } | ||
490 | |||
491 | #ifdef __KERNEL__ | ||
492 | unsigned long __copy_to_user(void __user *dst, const void *src, | 39 | unsigned long __copy_to_user(void __user *dst, const void *src, |
493 | unsigned long len) | 40 | unsigned long len) |
494 | { | 41 | { |
@@ -537,5 +84,3 @@ long probe_kernel_read(void *dst, const void *src, size_t size) | |||
537 | 84 | ||
538 | return __probe_kernel_read(dst, src, size); | 85 | return __probe_kernel_read(dst, src, size); |
539 | } | 86 | } |
540 | |||
541 | #endif | ||
diff --git a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c index deab89a8915a..32ec22146141 100644 --- a/arch/parisc/mm/fault.c +++ b/arch/parisc/mm/fault.c | |||
@@ -150,6 +150,23 @@ int fixup_exception(struct pt_regs *regs) | |||
150 | d->fault_space = regs->isr; | 150 | d->fault_space = regs->isr; |
151 | d->fault_addr = regs->ior; | 151 | d->fault_addr = regs->ior; |
152 | 152 | ||
153 | /* | ||
154 | * Fix up get_user() and put_user(). | ||
155 | * ASM_EXCEPTIONTABLE_ENTRY_EFAULT() sets the least-significant | ||
156 | * bit in the relative address of the fixup routine to indicate | ||
157 | * that %r8 should be loaded with -EFAULT to report a userspace | ||
158 | * access error. | ||
159 | */ | ||
160 | if (fix->fixup & 1) { | ||
161 | regs->gr[8] = -EFAULT; | ||
162 | |||
163 | /* zero target register for get_user() */ | ||
164 | if (parisc_acctyp(0, regs->iir) == VM_READ) { | ||
165 | int treg = regs->iir & 0x1f; | ||
166 | regs->gr[treg] = 0; | ||
167 | } | ||
168 | } | ||
169 | |||
153 | regs->iaoq[0] = (unsigned long)&fix->fixup + fix->fixup; | 170 | regs->iaoq[0] = (unsigned long)&fix->fixup + fix->fixup; |
154 | regs->iaoq[0] &= ~3; | 171 | regs->iaoq[0] &= ~3; |
155 | /* | 172 | /* |
diff --git a/arch/powerpc/crypto/crc32c-vpmsum_glue.c b/arch/powerpc/crypto/crc32c-vpmsum_glue.c index 411994551afc..f058e0c3e4d4 100644 --- a/arch/powerpc/crypto/crc32c-vpmsum_glue.c +++ b/arch/powerpc/crypto/crc32c-vpmsum_glue.c | |||
@@ -33,10 +33,13 @@ static u32 crc32c_vpmsum(u32 crc, unsigned char const *p, size_t len) | |||
33 | } | 33 | } |
34 | 34 | ||
35 | if (len & ~VMX_ALIGN_MASK) { | 35 | if (len & ~VMX_ALIGN_MASK) { |
36 | preempt_disable(); | ||
36 | pagefault_disable(); | 37 | pagefault_disable(); |
37 | enable_kernel_altivec(); | 38 | enable_kernel_altivec(); |
38 | crc = __crc32c_vpmsum(crc, p, len & ~VMX_ALIGN_MASK); | 39 | crc = __crc32c_vpmsum(crc, p, len & ~VMX_ALIGN_MASK); |
40 | disable_kernel_altivec(); | ||
39 | pagefault_enable(); | 41 | pagefault_enable(); |
42 | preempt_enable(); | ||
40 | } | 43 | } |
41 | 44 | ||
42 | tail = len & VMX_ALIGN_MASK; | 45 | tail = len & VMX_ALIGN_MASK; |
diff --git a/arch/powerpc/include/asm/exception-64s.h b/arch/powerpc/include/asm/exception-64s.h index 14752eee3d0c..ed3beadd2cc5 100644 --- a/arch/powerpc/include/asm/exception-64s.h +++ b/arch/powerpc/include/asm/exception-64s.h | |||
@@ -236,9 +236,9 @@ END_FTR_SECTION_NESTED(ftr,ftr,943) | |||
236 | mtctr reg; \ | 236 | mtctr reg; \ |
237 | bctr | 237 | bctr |
238 | 238 | ||
239 | #define BRANCH_LINK_TO_FAR(reg, label) \ | 239 | #define BRANCH_LINK_TO_FAR(label) \ |
240 | __LOAD_FAR_HANDLER(reg, label); \ | 240 | __LOAD_FAR_HANDLER(r12, label); \ |
241 | mtctr reg; \ | 241 | mtctr r12; \ |
242 | bctrl | 242 | bctrl |
243 | 243 | ||
244 | /* | 244 | /* |
@@ -265,7 +265,7 @@ END_FTR_SECTION_NESTED(ftr,ftr,943) | |||
265 | #define BRANCH_TO_COMMON(reg, label) \ | 265 | #define BRANCH_TO_COMMON(reg, label) \ |
266 | b label | 266 | b label |
267 | 267 | ||
268 | #define BRANCH_LINK_TO_FAR(reg, label) \ | 268 | #define BRANCH_LINK_TO_FAR(label) \ |
269 | bl label | 269 | bl label |
270 | 270 | ||
271 | #define BRANCH_TO_KVM(reg, label) \ | 271 | #define BRANCH_TO_KVM(reg, label) \ |
diff --git a/arch/powerpc/kernel/align.c b/arch/powerpc/kernel/align.c index cbc7c42cdb74..ec7a8b099dd9 100644 --- a/arch/powerpc/kernel/align.c +++ b/arch/powerpc/kernel/align.c | |||
@@ -807,14 +807,25 @@ int fix_alignment(struct pt_regs *regs) | |||
807 | nb = aligninfo[instr].len; | 807 | nb = aligninfo[instr].len; |
808 | flags = aligninfo[instr].flags; | 808 | flags = aligninfo[instr].flags; |
809 | 809 | ||
810 | /* ldbrx/stdbrx overlap lfs/stfs in the DSISR unfortunately */ | 810 | /* |
811 | if (IS_XFORM(instruction) && ((instruction >> 1) & 0x3ff) == 532) { | 811 | * Handle some cases which give overlaps in the DSISR values. |
812 | nb = 8; | 812 | */ |
813 | flags = LD+SW; | 813 | if (IS_XFORM(instruction)) { |
814 | } else if (IS_XFORM(instruction) && | 814 | switch (get_xop(instruction)) { |
815 | ((instruction >> 1) & 0x3ff) == 660) { | 815 | case 532: /* ldbrx */ |
816 | nb = 8; | 816 | nb = 8; |
817 | flags = ST+SW; | 817 | flags = LD+SW; |
818 | break; | ||
819 | case 660: /* stdbrx */ | ||
820 | nb = 8; | ||
821 | flags = ST+SW; | ||
822 | break; | ||
823 | case 20: /* lwarx */ | ||
824 | case 84: /* ldarx */ | ||
825 | case 116: /* lharx */ | ||
826 | case 276: /* lqarx */ | ||
827 | return 0; /* not emulated ever */ | ||
828 | } | ||
818 | } | 829 | } |
819 | 830 | ||
820 | /* Byteswap little endian loads and stores */ | 831 | /* Byteswap little endian loads and stores */ |
diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S index 6432d4bf08c8..767ef6d68c9e 100644 --- a/arch/powerpc/kernel/entry_64.S +++ b/arch/powerpc/kernel/entry_64.S | |||
@@ -689,7 +689,7 @@ resume_kernel: | |||
689 | 689 | ||
690 | addi r8,r1,INT_FRAME_SIZE /* Get the kprobed function entry */ | 690 | addi r8,r1,INT_FRAME_SIZE /* Get the kprobed function entry */ |
691 | 691 | ||
692 | lwz r3,GPR1(r1) | 692 | ld r3,GPR1(r1) |
693 | subi r3,r3,INT_FRAME_SIZE /* dst: Allocate a trampoline exception frame */ | 693 | subi r3,r3,INT_FRAME_SIZE /* dst: Allocate a trampoline exception frame */ |
694 | mr r4,r1 /* src: current exception frame */ | 694 | mr r4,r1 /* src: current exception frame */ |
695 | mr r1,r3 /* Reroute the trampoline frame to r1 */ | 695 | mr r1,r3 /* Reroute the trampoline frame to r1 */ |
@@ -703,8 +703,8 @@ resume_kernel: | |||
703 | addi r6,r6,8 | 703 | addi r6,r6,8 |
704 | bdnz 2b | 704 | bdnz 2b |
705 | 705 | ||
706 | /* Do real store operation to complete stwu */ | 706 | /* Do real store operation to complete stdu */ |
707 | lwz r5,GPR1(r1) | 707 | ld r5,GPR1(r1) |
708 | std r8,0(r5) | 708 | std r8,0(r5) |
709 | 709 | ||
710 | /* Clear _TIF_EMULATE_STACK_STORE flag */ | 710 | /* Clear _TIF_EMULATE_STACK_STORE flag */ |
diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S index 857bf7c5b946..6353019966e6 100644 --- a/arch/powerpc/kernel/exceptions-64s.S +++ b/arch/powerpc/kernel/exceptions-64s.S | |||
@@ -982,7 +982,7 @@ TRAMP_REAL_BEGIN(hmi_exception_early) | |||
982 | EXCEPTION_PROLOG_COMMON_2(PACA_EXGEN) | 982 | EXCEPTION_PROLOG_COMMON_2(PACA_EXGEN) |
983 | EXCEPTION_PROLOG_COMMON_3(0xe60) | 983 | EXCEPTION_PROLOG_COMMON_3(0xe60) |
984 | addi r3,r1,STACK_FRAME_OVERHEAD | 984 | addi r3,r1,STACK_FRAME_OVERHEAD |
985 | BRANCH_LINK_TO_FAR(r4, hmi_exception_realmode) | 985 | BRANCH_LINK_TO_FAR(hmi_exception_realmode) /* Function call ABI */ |
986 | /* Windup the stack. */ | 986 | /* Windup the stack. */ |
987 | /* Move original HSRR0 and HSRR1 into the respective regs */ | 987 | /* Move original HSRR0 and HSRR1 into the respective regs */ |
988 | ld r9,_MSR(r1) | 988 | ld r9,_MSR(r1) |
diff --git a/arch/powerpc/kernel/misc_64.S b/arch/powerpc/kernel/misc_64.S index ae179cb1bb3c..c119044cad0d 100644 --- a/arch/powerpc/kernel/misc_64.S +++ b/arch/powerpc/kernel/misc_64.S | |||
@@ -67,7 +67,7 @@ PPC64_CACHES: | |||
67 | * flush all bytes from start through stop-1 inclusive | 67 | * flush all bytes from start through stop-1 inclusive |
68 | */ | 68 | */ |
69 | 69 | ||
70 | _GLOBAL(flush_icache_range) | 70 | _GLOBAL_TOC(flush_icache_range) |
71 | BEGIN_FTR_SECTION | 71 | BEGIN_FTR_SECTION |
72 | PURGE_PREFETCHED_INS | 72 | PURGE_PREFETCHED_INS |
73 | blr | 73 | blr |
@@ -120,7 +120,7 @@ EXPORT_SYMBOL(flush_icache_range) | |||
120 | * | 120 | * |
121 | * flush all bytes from start to stop-1 inclusive | 121 | * flush all bytes from start to stop-1 inclusive |
122 | */ | 122 | */ |
123 | _GLOBAL(flush_dcache_range) | 123 | _GLOBAL_TOC(flush_dcache_range) |
124 | 124 | ||
125 | /* | 125 | /* |
126 | * Flush the data cache to memory | 126 | * Flush the data cache to memory |
diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c index 9cfaa8b69b5f..f997154dfc41 100644 --- a/arch/powerpc/kernel/setup_64.c +++ b/arch/powerpc/kernel/setup_64.c | |||
@@ -236,6 +236,15 @@ static void cpu_ready_for_interrupts(void) | |||
236 | mtspr(SPRN_LPCR, lpcr | LPCR_AIL_3); | 236 | mtspr(SPRN_LPCR, lpcr | LPCR_AIL_3); |
237 | } | 237 | } |
238 | 238 | ||
239 | /* | ||
240 | * Fixup HFSCR:TM based on CPU features. The bit is set by our | ||
241 | * early asm init because at that point we haven't updated our | ||
242 | * CPU features from firmware and device-tree. Here we have, | ||
243 | * so let's do it. | ||
244 | */ | ||
245 | if (cpu_has_feature(CPU_FTR_HVMODE) && !cpu_has_feature(CPU_FTR_TM_COMP)) | ||
246 | mtspr(SPRN_HFSCR, mfspr(SPRN_HFSCR) & ~HFSCR_TM); | ||
247 | |||
239 | /* Set IR and DR in PACA MSR */ | 248 | /* Set IR and DR in PACA MSR */ |
240 | get_paca()->kernel_msr = MSR_KERNEL; | 249 | get_paca()->kernel_msr = MSR_KERNEL; |
241 | } | 250 | } |
diff --git a/arch/powerpc/kvm/book3s_64_mmu_hv.c b/arch/powerpc/kvm/book3s_64_mmu_hv.c index 8c68145ba1bd..710e491206ed 100644 --- a/arch/powerpc/kvm/book3s_64_mmu_hv.c +++ b/arch/powerpc/kvm/book3s_64_mmu_hv.c | |||
@@ -1487,6 +1487,10 @@ long kvm_vm_ioctl_resize_hpt_prepare(struct kvm *kvm, | |||
1487 | /* start new resize */ | 1487 | /* start new resize */ |
1488 | 1488 | ||
1489 | resize = kzalloc(sizeof(*resize), GFP_KERNEL); | 1489 | resize = kzalloc(sizeof(*resize), GFP_KERNEL); |
1490 | if (!resize) { | ||
1491 | ret = -ENOMEM; | ||
1492 | goto out; | ||
1493 | } | ||
1490 | resize->order = shift; | 1494 | resize->order = shift; |
1491 | resize->kvm = kvm; | 1495 | resize->kvm = kvm; |
1492 | INIT_WORK(&resize->work, resize_hpt_prepare_work); | 1496 | INIT_WORK(&resize->work, resize_hpt_prepare_work); |
diff --git a/arch/powerpc/mm/hash_native_64.c b/arch/powerpc/mm/hash_native_64.c index cc332608e656..65bb8f33b399 100644 --- a/arch/powerpc/mm/hash_native_64.c +++ b/arch/powerpc/mm/hash_native_64.c | |||
@@ -638,6 +638,10 @@ static void native_flush_hash_range(unsigned long number, int local) | |||
638 | unsigned long psize = batch->psize; | 638 | unsigned long psize = batch->psize; |
639 | int ssize = batch->ssize; | 639 | int ssize = batch->ssize; |
640 | int i; | 640 | int i; |
641 | unsigned int use_local; | ||
642 | |||
643 | use_local = local && mmu_has_feature(MMU_FTR_TLBIEL) && | ||
644 | mmu_psize_defs[psize].tlbiel && !cxl_ctx_in_use(); | ||
641 | 645 | ||
642 | local_irq_save(flags); | 646 | local_irq_save(flags); |
643 | 647 | ||
@@ -667,8 +671,7 @@ static void native_flush_hash_range(unsigned long number, int local) | |||
667 | } pte_iterate_hashed_end(); | 671 | } pte_iterate_hashed_end(); |
668 | } | 672 | } |
669 | 673 | ||
670 | if (mmu_has_feature(MMU_FTR_TLBIEL) && | 674 | if (use_local) { |
671 | mmu_psize_defs[psize].tlbiel && local) { | ||
672 | asm volatile("ptesync":::"memory"); | 675 | asm volatile("ptesync":::"memory"); |
673 | for (i = 0; i < number; i++) { | 676 | for (i = 0; i < number; i++) { |
674 | vpn = batch->vpn[i]; | 677 | vpn = batch->vpn[i]; |
diff --git a/arch/s390/boot/compressed/misc.c b/arch/s390/boot/compressed/misc.c index fa95041fa9f6..33ca29333e18 100644 --- a/arch/s390/boot/compressed/misc.c +++ b/arch/s390/boot/compressed/misc.c | |||
@@ -141,31 +141,34 @@ static void check_ipl_parmblock(void *start, unsigned long size) | |||
141 | 141 | ||
142 | unsigned long decompress_kernel(void) | 142 | unsigned long decompress_kernel(void) |
143 | { | 143 | { |
144 | unsigned long output_addr; | 144 | void *output, *kernel_end; |
145 | unsigned char *output; | ||
146 | 145 | ||
147 | output_addr = ((unsigned long) &_end + HEAP_SIZE + 4095UL) & -4096UL; | 146 | output = (void *) ALIGN((unsigned long) &_end + HEAP_SIZE, PAGE_SIZE); |
148 | check_ipl_parmblock((void *) 0, output_addr + SZ__bss_start); | 147 | kernel_end = output + SZ__bss_start; |
149 | memset(&_bss, 0, &_ebss - &_bss); | 148 | check_ipl_parmblock((void *) 0, (unsigned long) kernel_end); |
150 | free_mem_ptr = (unsigned long)&_end; | ||
151 | free_mem_end_ptr = free_mem_ptr + HEAP_SIZE; | ||
152 | output = (unsigned char *) output_addr; | ||
153 | 149 | ||
154 | #ifdef CONFIG_BLK_DEV_INITRD | 150 | #ifdef CONFIG_BLK_DEV_INITRD |
155 | /* | 151 | /* |
156 | * Move the initrd right behind the end of the decompressed | 152 | * Move the initrd right behind the end of the decompressed |
157 | * kernel image. | 153 | * kernel image. This also prevents initrd corruption caused by |
154 | * bss clearing since kernel_end will always be located behind the | ||
155 | * current bss section.. | ||
158 | */ | 156 | */ |
159 | if (INITRD_START && INITRD_SIZE && | 157 | if (INITRD_START && INITRD_SIZE && kernel_end > (void *) INITRD_START) { |
160 | INITRD_START < (unsigned long) output + SZ__bss_start) { | 158 | check_ipl_parmblock(kernel_end, INITRD_SIZE); |
161 | check_ipl_parmblock(output + SZ__bss_start, | 159 | memmove(kernel_end, (void *) INITRD_START, INITRD_SIZE); |
162 | INITRD_START + INITRD_SIZE); | 160 | INITRD_START = (unsigned long) kernel_end; |
163 | memmove(output + SZ__bss_start, | ||
164 | (void *) INITRD_START, INITRD_SIZE); | ||
165 | INITRD_START = (unsigned long) output + SZ__bss_start; | ||
166 | } | 161 | } |
167 | #endif | 162 | #endif |
168 | 163 | ||
164 | /* | ||
165 | * Clear bss section. free_mem_ptr and free_mem_end_ptr need to be | ||
166 | * initialized afterwards since they reside in bss. | ||
167 | */ | ||
168 | memset(&_bss, 0, &_ebss - &_bss); | ||
169 | free_mem_ptr = (unsigned long) &_end; | ||
170 | free_mem_end_ptr = free_mem_ptr + HEAP_SIZE; | ||
171 | |||
169 | puts("Uncompressing Linux... "); | 172 | puts("Uncompressing Linux... "); |
170 | __decompress(input_data, input_len, NULL, NULL, output, 0, NULL, error); | 173 | __decompress(input_data, input_len, NULL, NULL, output, 0, NULL, error); |
171 | puts("Ok, booting the kernel.\n"); | 174 | puts("Ok, booting the kernel.\n"); |
diff --git a/arch/s390/include/asm/pgtable.h b/arch/s390/include/asm/pgtable.h index 93e37b12e882..ecec682bb516 100644 --- a/arch/s390/include/asm/pgtable.h +++ b/arch/s390/include/asm/pgtable.h | |||
@@ -1051,6 +1051,8 @@ static inline void set_pte_at(struct mm_struct *mm, unsigned long addr, | |||
1051 | { | 1051 | { |
1052 | if (!MACHINE_HAS_NX) | 1052 | if (!MACHINE_HAS_NX) |
1053 | pte_val(entry) &= ~_PAGE_NOEXEC; | 1053 | pte_val(entry) &= ~_PAGE_NOEXEC; |
1054 | if (pte_present(entry)) | ||
1055 | pte_val(entry) &= ~_PAGE_UNUSED; | ||
1054 | if (mm_has_pgste(mm)) | 1056 | if (mm_has_pgste(mm)) |
1055 | ptep_set_pte_at(mm, addr, ptep, entry); | 1057 | ptep_set_pte_at(mm, addr, ptep, entry); |
1056 | else | 1058 | else |
diff --git a/arch/s390/include/asm/sections.h b/arch/s390/include/asm/sections.h index 5ce29fe100ba..fbd9116eb17b 100644 --- a/arch/s390/include/asm/sections.h +++ b/arch/s390/include/asm/sections.h | |||
@@ -4,6 +4,5 @@ | |||
4 | #include <asm-generic/sections.h> | 4 | #include <asm-generic/sections.h> |
5 | 5 | ||
6 | extern char _eshared[], _ehead[]; | 6 | extern char _eshared[], _ehead[]; |
7 | extern char __start_ro_after_init[], __end_ro_after_init[]; | ||
8 | 7 | ||
9 | #endif | 8 | #endif |
diff --git a/arch/s390/include/asm/uaccess.h b/arch/s390/include/asm/uaccess.h index 136932ff4250..3ea1554d04b3 100644 --- a/arch/s390/include/asm/uaccess.h +++ b/arch/s390/include/asm/uaccess.h | |||
@@ -147,7 +147,7 @@ unsigned long __must_check __copy_to_user(void __user *to, const void *from, | |||
147 | " jg 2b\n" \ | 147 | " jg 2b\n" \ |
148 | ".popsection\n" \ | 148 | ".popsection\n" \ |
149 | EX_TABLE(0b,3b) EX_TABLE(1b,3b) \ | 149 | EX_TABLE(0b,3b) EX_TABLE(1b,3b) \ |
150 | : "=d" (__rc), "=Q" (*(to)) \ | 150 | : "=d" (__rc), "+Q" (*(to)) \ |
151 | : "d" (size), "Q" (*(from)), \ | 151 | : "d" (size), "Q" (*(from)), \ |
152 | "d" (__reg0), "K" (-EFAULT) \ | 152 | "d" (__reg0), "K" (-EFAULT) \ |
153 | : "cc"); \ | 153 | : "cc"); \ |
diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c index 47a973b5b4f1..5dab859b0d54 100644 --- a/arch/s390/kernel/smp.c +++ b/arch/s390/kernel/smp.c | |||
@@ -909,13 +909,11 @@ void __init smp_prepare_boot_cpu(void) | |||
909 | { | 909 | { |
910 | struct pcpu *pcpu = pcpu_devices; | 910 | struct pcpu *pcpu = pcpu_devices; |
911 | 911 | ||
912 | WARN_ON(!cpu_present(0) || !cpu_online(0)); | ||
912 | pcpu->state = CPU_STATE_CONFIGURED; | 913 | pcpu->state = CPU_STATE_CONFIGURED; |
913 | pcpu->address = stap(); | ||
914 | pcpu->lowcore = (struct lowcore *)(unsigned long) store_prefix(); | 914 | pcpu->lowcore = (struct lowcore *)(unsigned long) store_prefix(); |
915 | S390_lowcore.percpu_offset = __per_cpu_offset[0]; | 915 | S390_lowcore.percpu_offset = __per_cpu_offset[0]; |
916 | smp_cpu_set_polarization(0, POLARIZATION_UNKNOWN); | 916 | smp_cpu_set_polarization(0, POLARIZATION_UNKNOWN); |
917 | set_cpu_present(0, true); | ||
918 | set_cpu_online(0, true); | ||
919 | } | 917 | } |
920 | 918 | ||
921 | void __init smp_cpus_done(unsigned int max_cpus) | 919 | void __init smp_cpus_done(unsigned int max_cpus) |
@@ -924,6 +922,7 @@ void __init smp_cpus_done(unsigned int max_cpus) | |||
924 | 922 | ||
925 | void __init smp_setup_processor_id(void) | 923 | void __init smp_setup_processor_id(void) |
926 | { | 924 | { |
925 | pcpu_devices[0].address = stap(); | ||
927 | S390_lowcore.cpu_nr = 0; | 926 | S390_lowcore.cpu_nr = 0; |
928 | S390_lowcore.spinlock_lockval = arch_spin_lockval(0); | 927 | S390_lowcore.spinlock_lockval = arch_spin_lockval(0); |
929 | } | 928 | } |
diff --git a/arch/s390/kernel/vmlinux.lds.S b/arch/s390/kernel/vmlinux.lds.S index 5ccf95396251..72307f108c40 100644 --- a/arch/s390/kernel/vmlinux.lds.S +++ b/arch/s390/kernel/vmlinux.lds.S | |||
@@ -63,11 +63,9 @@ SECTIONS | |||
63 | 63 | ||
64 | . = ALIGN(PAGE_SIZE); | 64 | . = ALIGN(PAGE_SIZE); |
65 | __start_ro_after_init = .; | 65 | __start_ro_after_init = .; |
66 | __start_data_ro_after_init = .; | ||
67 | .data..ro_after_init : { | 66 | .data..ro_after_init : { |
68 | *(.data..ro_after_init) | 67 | *(.data..ro_after_init) |
69 | } | 68 | } |
70 | __end_data_ro_after_init = .; | ||
71 | EXCEPTION_TABLE(16) | 69 | EXCEPTION_TABLE(16) |
72 | . = ALIGN(PAGE_SIZE); | 70 | . = ALIGN(PAGE_SIZE); |
73 | __end_ro_after_init = .; | 71 | __end_ro_after_init = .; |
diff --git a/arch/s390/kvm/gaccess.c b/arch/s390/kvm/gaccess.c index d55c829a5944..ddbffb715b40 100644 --- a/arch/s390/kvm/gaccess.c +++ b/arch/s390/kvm/gaccess.c | |||
@@ -168,8 +168,7 @@ union page_table_entry { | |||
168 | unsigned long z : 1; /* Zero Bit */ | 168 | unsigned long z : 1; /* Zero Bit */ |
169 | unsigned long i : 1; /* Page-Invalid Bit */ | 169 | unsigned long i : 1; /* Page-Invalid Bit */ |
170 | unsigned long p : 1; /* DAT-Protection Bit */ | 170 | unsigned long p : 1; /* DAT-Protection Bit */ |
171 | unsigned long co : 1; /* Change-Recording Override */ | 171 | unsigned long : 9; |
172 | unsigned long : 8; | ||
173 | }; | 172 | }; |
174 | }; | 173 | }; |
175 | 174 | ||
@@ -745,8 +744,6 @@ static unsigned long guest_translate(struct kvm_vcpu *vcpu, unsigned long gva, | |||
745 | return PGM_PAGE_TRANSLATION; | 744 | return PGM_PAGE_TRANSLATION; |
746 | if (pte.z) | 745 | if (pte.z) |
747 | return PGM_TRANSLATION_SPEC; | 746 | return PGM_TRANSLATION_SPEC; |
748 | if (pte.co && !edat1) | ||
749 | return PGM_TRANSLATION_SPEC; | ||
750 | dat_protection |= pte.p; | 747 | dat_protection |= pte.p; |
751 | raddr.pfra = pte.pfra; | 748 | raddr.pfra = pte.pfra; |
752 | real_address: | 749 | real_address: |
@@ -1182,7 +1179,7 @@ int kvm_s390_shadow_fault(struct kvm_vcpu *vcpu, struct gmap *sg, | |||
1182 | rc = gmap_read_table(sg->parent, pgt + vaddr.px * 8, &pte.val); | 1179 | rc = gmap_read_table(sg->parent, pgt + vaddr.px * 8, &pte.val); |
1183 | if (!rc && pte.i) | 1180 | if (!rc && pte.i) |
1184 | rc = PGM_PAGE_TRANSLATION; | 1181 | rc = PGM_PAGE_TRANSLATION; |
1185 | if (!rc && (pte.z || (pte.co && sg->edat_level < 1))) | 1182 | if (!rc && pte.z) |
1186 | rc = PGM_TRANSLATION_SPEC; | 1183 | rc = PGM_TRANSLATION_SPEC; |
1187 | shadow_page: | 1184 | shadow_page: |
1188 | pte.p |= dat_protection; | 1185 | pte.p |= dat_protection; |
diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig index 68ac5c7cd982..a59deaef21e5 100644 --- a/arch/sparc/Kconfig +++ b/arch/sparc/Kconfig | |||
@@ -43,7 +43,7 @@ config SPARC | |||
43 | select ARCH_HAS_SG_CHAIN | 43 | select ARCH_HAS_SG_CHAIN |
44 | select CPU_NO_EFFICIENT_FFS | 44 | select CPU_NO_EFFICIENT_FFS |
45 | select HAVE_ARCH_HARDENED_USERCOPY | 45 | select HAVE_ARCH_HARDENED_USERCOPY |
46 | select PROVE_LOCKING_SMALL if PROVE_LOCKING | 46 | select LOCKDEP_SMALL if LOCKDEP |
47 | select ARCH_WANT_RELAX_ORDER | 47 | select ARCH_WANT_RELAX_ORDER |
48 | 48 | ||
49 | config SPARC32 | 49 | config SPARC32 |
diff --git a/arch/sparc/include/asm/page_64.h b/arch/sparc/include/asm/page_64.h index f294dd42fc7d..5961b2d8398a 100644 --- a/arch/sparc/include/asm/page_64.h +++ b/arch/sparc/include/asm/page_64.h | |||
@@ -17,6 +17,7 @@ | |||
17 | 17 | ||
18 | #define HPAGE_SHIFT 23 | 18 | #define HPAGE_SHIFT 23 |
19 | #define REAL_HPAGE_SHIFT 22 | 19 | #define REAL_HPAGE_SHIFT 22 |
20 | #define HPAGE_2GB_SHIFT 31 | ||
20 | #define HPAGE_256MB_SHIFT 28 | 21 | #define HPAGE_256MB_SHIFT 28 |
21 | #define HPAGE_64K_SHIFT 16 | 22 | #define HPAGE_64K_SHIFT 16 |
22 | #define REAL_HPAGE_SIZE (_AC(1,UL) << REAL_HPAGE_SHIFT) | 23 | #define REAL_HPAGE_SIZE (_AC(1,UL) << REAL_HPAGE_SHIFT) |
@@ -27,7 +28,7 @@ | |||
27 | #define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT) | 28 | #define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT) |
28 | #define HAVE_ARCH_HUGETLB_UNMAPPED_AREA | 29 | #define HAVE_ARCH_HUGETLB_UNMAPPED_AREA |
29 | #define REAL_HPAGE_PER_HPAGE (_AC(1,UL) << (HPAGE_SHIFT - REAL_HPAGE_SHIFT)) | 30 | #define REAL_HPAGE_PER_HPAGE (_AC(1,UL) << (HPAGE_SHIFT - REAL_HPAGE_SHIFT)) |
30 | #define HUGE_MAX_HSTATE 3 | 31 | #define HUGE_MAX_HSTATE 4 |
31 | #endif | 32 | #endif |
32 | 33 | ||
33 | #ifndef __ASSEMBLY__ | 34 | #ifndef __ASSEMBLY__ |
diff --git a/arch/sparc/include/asm/pgtable_64.h b/arch/sparc/include/asm/pgtable_64.h index 8a598528ec1f..6fbd931f0570 100644 --- a/arch/sparc/include/asm/pgtable_64.h +++ b/arch/sparc/include/asm/pgtable_64.h | |||
@@ -679,26 +679,27 @@ static inline unsigned long pmd_pfn(pmd_t pmd) | |||
679 | return pte_pfn(pte); | 679 | return pte_pfn(pte); |
680 | } | 680 | } |
681 | 681 | ||
682 | #ifdef CONFIG_TRANSPARENT_HUGEPAGE | 682 | #define __HAVE_ARCH_PMD_WRITE |
683 | static inline unsigned long pmd_dirty(pmd_t pmd) | 683 | static inline unsigned long pmd_write(pmd_t pmd) |
684 | { | 684 | { |
685 | pte_t pte = __pte(pmd_val(pmd)); | 685 | pte_t pte = __pte(pmd_val(pmd)); |
686 | 686 | ||
687 | return pte_dirty(pte); | 687 | return pte_write(pte); |
688 | } | 688 | } |
689 | 689 | ||
690 | static inline unsigned long pmd_young(pmd_t pmd) | 690 | #ifdef CONFIG_TRANSPARENT_HUGEPAGE |
691 | static inline unsigned long pmd_dirty(pmd_t pmd) | ||
691 | { | 692 | { |
692 | pte_t pte = __pte(pmd_val(pmd)); | 693 | pte_t pte = __pte(pmd_val(pmd)); |
693 | 694 | ||
694 | return pte_young(pte); | 695 | return pte_dirty(pte); |
695 | } | 696 | } |
696 | 697 | ||
697 | static inline unsigned long pmd_write(pmd_t pmd) | 698 | static inline unsigned long pmd_young(pmd_t pmd) |
698 | { | 699 | { |
699 | pte_t pte = __pte(pmd_val(pmd)); | 700 | pte_t pte = __pte(pmd_val(pmd)); |
700 | 701 | ||
701 | return pte_write(pte); | 702 | return pte_young(pte); |
702 | } | 703 | } |
703 | 704 | ||
704 | static inline unsigned long pmd_trans_huge(pmd_t pmd) | 705 | static inline unsigned long pmd_trans_huge(pmd_t pmd) |
diff --git a/arch/sparc/include/asm/processor_32.h b/arch/sparc/include/asm/processor_32.h index 365d4cb267b4..dd27159819eb 100644 --- a/arch/sparc/include/asm/processor_32.h +++ b/arch/sparc/include/asm/processor_32.h | |||
@@ -18,12 +18,6 @@ | |||
18 | #include <asm/signal.h> | 18 | #include <asm/signal.h> |
19 | #include <asm/page.h> | 19 | #include <asm/page.h> |
20 | 20 | ||
21 | /* | ||
22 | * The sparc has no problems with write protection | ||
23 | */ | ||
24 | #define wp_works_ok 1 | ||
25 | #define wp_works_ok__is_a_macro /* for versions in ksyms.c */ | ||
26 | |||
27 | /* Whee, this is STACK_TOP + PAGE_SIZE and the lowest kernel address too... | 21 | /* Whee, this is STACK_TOP + PAGE_SIZE and the lowest kernel address too... |
28 | * That one page is used to protect kernel from intruders, so that | 22 | * That one page is used to protect kernel from intruders, so that |
29 | * we can make our access_ok test faster | 23 | * we can make our access_ok test faster |
diff --git a/arch/sparc/include/asm/processor_64.h b/arch/sparc/include/asm/processor_64.h index 6448cfc8292f..b58ee9018433 100644 --- a/arch/sparc/include/asm/processor_64.h +++ b/arch/sparc/include/asm/processor_64.h | |||
@@ -18,10 +18,6 @@ | |||
18 | #include <asm/ptrace.h> | 18 | #include <asm/ptrace.h> |
19 | #include <asm/page.h> | 19 | #include <asm/page.h> |
20 | 20 | ||
21 | /* The sparc has no problems with write protection */ | ||
22 | #define wp_works_ok 1 | ||
23 | #define wp_works_ok__is_a_macro /* for versions in ksyms.c */ | ||
24 | |||
25 | /* | 21 | /* |
26 | * User lives in his very own context, and cannot reference us. Note | 22 | * User lives in his very own context, and cannot reference us. Note |
27 | * that TASK_SIZE is a misnomer, it really gives maximum user virtual | 23 | * that TASK_SIZE is a misnomer, it really gives maximum user virtual |
diff --git a/arch/sparc/kernel/head_64.S b/arch/sparc/kernel/head_64.S index 6aa3da152c20..44101196d02b 100644 --- a/arch/sparc/kernel/head_64.S +++ b/arch/sparc/kernel/head_64.S | |||
@@ -96,6 +96,7 @@ sparc64_boot: | |||
96 | andn %g1, PSTATE_AM, %g1 | 96 | andn %g1, PSTATE_AM, %g1 |
97 | wrpr %g1, 0x0, %pstate | 97 | wrpr %g1, 0x0, %pstate |
98 | ba,a,pt %xcc, 1f | 98 | ba,a,pt %xcc, 1f |
99 | nop | ||
99 | 100 | ||
100 | .globl prom_finddev_name, prom_chosen_path, prom_root_node | 101 | .globl prom_finddev_name, prom_chosen_path, prom_root_node |
101 | .globl prom_getprop_name, prom_mmu_name, prom_peer_name | 102 | .globl prom_getprop_name, prom_mmu_name, prom_peer_name |
@@ -613,6 +614,7 @@ niagara_tlb_fixup: | |||
613 | nop | 614 | nop |
614 | 615 | ||
615 | ba,a,pt %xcc, 80f | 616 | ba,a,pt %xcc, 80f |
617 | nop | ||
616 | niagara4_patch: | 618 | niagara4_patch: |
617 | call niagara4_patch_copyops | 619 | call niagara4_patch_copyops |
618 | nop | 620 | nop |
@@ -622,6 +624,7 @@ niagara4_patch: | |||
622 | nop | 624 | nop |
623 | 625 | ||
624 | ba,a,pt %xcc, 80f | 626 | ba,a,pt %xcc, 80f |
627 | nop | ||
625 | 628 | ||
626 | niagara2_patch: | 629 | niagara2_patch: |
627 | call niagara2_patch_copyops | 630 | call niagara2_patch_copyops |
@@ -632,6 +635,7 @@ niagara2_patch: | |||
632 | nop | 635 | nop |
633 | 636 | ||
634 | ba,a,pt %xcc, 80f | 637 | ba,a,pt %xcc, 80f |
638 | nop | ||
635 | 639 | ||
636 | niagara_patch: | 640 | niagara_patch: |
637 | call niagara_patch_copyops | 641 | call niagara_patch_copyops |
diff --git a/arch/sparc/kernel/misctrap.S b/arch/sparc/kernel/misctrap.S index 34b4933900bf..9276d2f0dd86 100644 --- a/arch/sparc/kernel/misctrap.S +++ b/arch/sparc/kernel/misctrap.S | |||
@@ -82,6 +82,7 @@ do_stdfmna: | |||
82 | call handle_stdfmna | 82 | call handle_stdfmna |
83 | add %sp, PTREGS_OFF, %o0 | 83 | add %sp, PTREGS_OFF, %o0 |
84 | ba,a,pt %xcc, rtrap | 84 | ba,a,pt %xcc, rtrap |
85 | nop | ||
85 | .size do_stdfmna,.-do_stdfmna | 86 | .size do_stdfmna,.-do_stdfmna |
86 | 87 | ||
87 | .type breakpoint_trap,#function | 88 | .type breakpoint_trap,#function |
diff --git a/arch/sparc/kernel/rtrap_64.S b/arch/sparc/kernel/rtrap_64.S index 216948ca4382..709a82ebd294 100644 --- a/arch/sparc/kernel/rtrap_64.S +++ b/arch/sparc/kernel/rtrap_64.S | |||
@@ -237,6 +237,7 @@ rt_continue: ldx [%sp + PTREGS_OFF + PT_V9_G1], %g1 | |||
237 | bne,pt %xcc, user_rtt_fill_32bit | 237 | bne,pt %xcc, user_rtt_fill_32bit |
238 | wrpr %g1, %cwp | 238 | wrpr %g1, %cwp |
239 | ba,a,pt %xcc, user_rtt_fill_64bit | 239 | ba,a,pt %xcc, user_rtt_fill_64bit |
240 | nop | ||
240 | 241 | ||
241 | user_rtt_fill_fixup_dax: | 242 | user_rtt_fill_fixup_dax: |
242 | ba,pt %xcc, user_rtt_fill_fixup_common | 243 | ba,pt %xcc, user_rtt_fill_fixup_common |
diff --git a/arch/sparc/kernel/spiterrs.S b/arch/sparc/kernel/spiterrs.S index 4a73009f66a5..d7e540842809 100644 --- a/arch/sparc/kernel/spiterrs.S +++ b/arch/sparc/kernel/spiterrs.S | |||
@@ -86,6 +86,7 @@ __spitfire_cee_trap_continue: | |||
86 | rd %pc, %g7 | 86 | rd %pc, %g7 |
87 | 87 | ||
88 | ba,a,pt %xcc, 2f | 88 | ba,a,pt %xcc, 2f |
89 | nop | ||
89 | 90 | ||
90 | 1: ba,pt %xcc, etrap_irq | 91 | 1: ba,pt %xcc, etrap_irq |
91 | rd %pc, %g7 | 92 | rd %pc, %g7 |
diff --git a/arch/sparc/kernel/sun4v_tlb_miss.S b/arch/sparc/kernel/sun4v_tlb_miss.S index 6179e19bc9b9..c19f352f46c7 100644 --- a/arch/sparc/kernel/sun4v_tlb_miss.S +++ b/arch/sparc/kernel/sun4v_tlb_miss.S | |||
@@ -352,6 +352,7 @@ sun4v_mna: | |||
352 | call sun4v_do_mna | 352 | call sun4v_do_mna |
353 | add %sp, PTREGS_OFF, %o0 | 353 | add %sp, PTREGS_OFF, %o0 |
354 | ba,a,pt %xcc, rtrap | 354 | ba,a,pt %xcc, rtrap |
355 | nop | ||
355 | 356 | ||
356 | /* Privileged Action. */ | 357 | /* Privileged Action. */ |
357 | sun4v_privact: | 358 | sun4v_privact: |
diff --git a/arch/sparc/kernel/urtt_fill.S b/arch/sparc/kernel/urtt_fill.S index 5604a2b051d4..364af3250646 100644 --- a/arch/sparc/kernel/urtt_fill.S +++ b/arch/sparc/kernel/urtt_fill.S | |||
@@ -92,6 +92,7 @@ user_rtt_fill_fixup_common: | |||
92 | call sun4v_data_access_exception | 92 | call sun4v_data_access_exception |
93 | nop | 93 | nop |
94 | ba,a,pt %xcc, rtrap | 94 | ba,a,pt %xcc, rtrap |
95 | nop | ||
95 | 96 | ||
96 | 1: call spitfire_data_access_exception | 97 | 1: call spitfire_data_access_exception |
97 | nop | 98 | nop |
diff --git a/arch/sparc/kernel/winfixup.S b/arch/sparc/kernel/winfixup.S index 855019a8590e..1ee173cc3c39 100644 --- a/arch/sparc/kernel/winfixup.S +++ b/arch/sparc/kernel/winfixup.S | |||
@@ -152,6 +152,8 @@ fill_fixup_dax: | |||
152 | call sun4v_data_access_exception | 152 | call sun4v_data_access_exception |
153 | nop | 153 | nop |
154 | ba,a,pt %xcc, rtrap | 154 | ba,a,pt %xcc, rtrap |
155 | nop | ||
155 | 1: call spitfire_data_access_exception | 156 | 1: call spitfire_data_access_exception |
156 | nop | 157 | nop |
157 | ba,a,pt %xcc, rtrap | 158 | ba,a,pt %xcc, rtrap |
159 | nop | ||
diff --git a/arch/sparc/lib/NG2memcpy.S b/arch/sparc/lib/NG2memcpy.S index c629dbd121b6..64dcd6cdb606 100644 --- a/arch/sparc/lib/NG2memcpy.S +++ b/arch/sparc/lib/NG2memcpy.S | |||
@@ -326,11 +326,13 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */ | |||
326 | blu 170f | 326 | blu 170f |
327 | nop | 327 | nop |
328 | ba,a,pt %xcc, 180f | 328 | ba,a,pt %xcc, 180f |
329 | nop | ||
329 | 330 | ||
330 | 4: /* 32 <= low bits < 48 */ | 331 | 4: /* 32 <= low bits < 48 */ |
331 | blu 150f | 332 | blu 150f |
332 | nop | 333 | nop |
333 | ba,a,pt %xcc, 160f | 334 | ba,a,pt %xcc, 160f |
335 | nop | ||
334 | 5: /* 0 < low bits < 32 */ | 336 | 5: /* 0 < low bits < 32 */ |
335 | blu,a 6f | 337 | blu,a 6f |
336 | cmp %g2, 8 | 338 | cmp %g2, 8 |
@@ -338,6 +340,7 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */ | |||
338 | blu 130f | 340 | blu 130f |
339 | nop | 341 | nop |
340 | ba,a,pt %xcc, 140f | 342 | ba,a,pt %xcc, 140f |
343 | nop | ||
341 | 6: /* 0 < low bits < 16 */ | 344 | 6: /* 0 < low bits < 16 */ |
342 | bgeu 120f | 345 | bgeu 120f |
343 | nop | 346 | nop |
@@ -475,6 +478,7 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */ | |||
475 | brz,pt %o2, 85f | 478 | brz,pt %o2, 85f |
476 | sub %o0, %o1, GLOBAL_SPARE | 479 | sub %o0, %o1, GLOBAL_SPARE |
477 | ba,a,pt %XCC, 90f | 480 | ba,a,pt %XCC, 90f |
481 | nop | ||
478 | 482 | ||
479 | .align 64 | 483 | .align 64 |
480 | 75: /* 16 < len <= 64 */ | 484 | 75: /* 16 < len <= 64 */ |
diff --git a/arch/sparc/lib/NG4memcpy.S b/arch/sparc/lib/NG4memcpy.S index 75bb93b1437f..78ea962edcbe 100644 --- a/arch/sparc/lib/NG4memcpy.S +++ b/arch/sparc/lib/NG4memcpy.S | |||
@@ -530,4 +530,5 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */ | |||
530 | bne,pt %icc, 1b | 530 | bne,pt %icc, 1b |
531 | EX_ST(STORE(stb, %g1, %o0 - 0x01), NG4_retl_o2_plus_1) | 531 | EX_ST(STORE(stb, %g1, %o0 - 0x01), NG4_retl_o2_plus_1) |
532 | ba,a,pt %icc, .Lexit | 532 | ba,a,pt %icc, .Lexit |
533 | nop | ||
533 | .size FUNC_NAME, .-FUNC_NAME | 534 | .size FUNC_NAME, .-FUNC_NAME |
diff --git a/arch/sparc/lib/NG4memset.S b/arch/sparc/lib/NG4memset.S index 41da4bdd95cb..7c0c81f18837 100644 --- a/arch/sparc/lib/NG4memset.S +++ b/arch/sparc/lib/NG4memset.S | |||
@@ -102,4 +102,5 @@ NG4bzero: | |||
102 | bne,pt %icc, 1b | 102 | bne,pt %icc, 1b |
103 | add %o0, 0x30, %o0 | 103 | add %o0, 0x30, %o0 |
104 | ba,a,pt %icc, .Lpostloop | 104 | ba,a,pt %icc, .Lpostloop |
105 | nop | ||
105 | .size NG4bzero,.-NG4bzero | 106 | .size NG4bzero,.-NG4bzero |
diff --git a/arch/sparc/lib/NGmemcpy.S b/arch/sparc/lib/NGmemcpy.S index d88c4ed50a00..cd654a719b27 100644 --- a/arch/sparc/lib/NGmemcpy.S +++ b/arch/sparc/lib/NGmemcpy.S | |||
@@ -394,6 +394,7 @@ FUNC_NAME: /* %i0=dst, %i1=src, %i2=len */ | |||
394 | brz,pt %i2, 85f | 394 | brz,pt %i2, 85f |
395 | sub %o0, %i1, %i3 | 395 | sub %o0, %i1, %i3 |
396 | ba,a,pt %XCC, 90f | 396 | ba,a,pt %XCC, 90f |
397 | nop | ||
397 | 398 | ||
398 | .align 64 | 399 | .align 64 |
399 | 70: /* 16 < len <= 64 */ | 400 | 70: /* 16 < len <= 64 */ |
diff --git a/arch/sparc/mm/hugetlbpage.c b/arch/sparc/mm/hugetlbpage.c index 323bc6b6e3ad..7c29d38e6b99 100644 --- a/arch/sparc/mm/hugetlbpage.c +++ b/arch/sparc/mm/hugetlbpage.c | |||
@@ -143,6 +143,10 @@ static pte_t sun4v_hugepage_shift_to_tte(pte_t entry, unsigned int shift) | |||
143 | pte_val(entry) = pte_val(entry) & ~_PAGE_SZALL_4V; | 143 | pte_val(entry) = pte_val(entry) & ~_PAGE_SZALL_4V; |
144 | 144 | ||
145 | switch (shift) { | 145 | switch (shift) { |
146 | case HPAGE_2GB_SHIFT: | ||
147 | hugepage_size = _PAGE_SZ2GB_4V; | ||
148 | pte_val(entry) |= _PAGE_PMD_HUGE; | ||
149 | break; | ||
146 | case HPAGE_256MB_SHIFT: | 150 | case HPAGE_256MB_SHIFT: |
147 | hugepage_size = _PAGE_SZ256MB_4V; | 151 | hugepage_size = _PAGE_SZ256MB_4V; |
148 | pte_val(entry) |= _PAGE_PMD_HUGE; | 152 | pte_val(entry) |= _PAGE_PMD_HUGE; |
@@ -183,6 +187,9 @@ static unsigned int sun4v_huge_tte_to_shift(pte_t entry) | |||
183 | unsigned int shift; | 187 | unsigned int shift; |
184 | 188 | ||
185 | switch (tte_szbits) { | 189 | switch (tte_szbits) { |
190 | case _PAGE_SZ2GB_4V: | ||
191 | shift = HPAGE_2GB_SHIFT; | ||
192 | break; | ||
186 | case _PAGE_SZ256MB_4V: | 193 | case _PAGE_SZ256MB_4V: |
187 | shift = HPAGE_256MB_SHIFT; | 194 | shift = HPAGE_256MB_SHIFT; |
188 | break; | 195 | break; |
@@ -261,7 +268,7 @@ pte_t *huge_pte_alloc(struct mm_struct *mm, | |||
261 | if (!pmd) | 268 | if (!pmd) |
262 | return NULL; | 269 | return NULL; |
263 | 270 | ||
264 | if (sz == PMD_SHIFT) | 271 | if (sz >= PMD_SIZE) |
265 | pte = (pte_t *)pmd; | 272 | pte = (pte_t *)pmd; |
266 | else | 273 | else |
267 | pte = pte_alloc_map(mm, pmd, addr); | 274 | pte = pte_alloc_map(mm, pmd, addr); |
@@ -454,6 +461,22 @@ void hugetlb_free_pgd_range(struct mmu_gather *tlb, | |||
454 | pgd_t *pgd; | 461 | pgd_t *pgd; |
455 | unsigned long next; | 462 | unsigned long next; |
456 | 463 | ||
464 | addr &= PMD_MASK; | ||
465 | if (addr < floor) { | ||
466 | addr += PMD_SIZE; | ||
467 | if (!addr) | ||
468 | return; | ||
469 | } | ||
470 | if (ceiling) { | ||
471 | ceiling &= PMD_MASK; | ||
472 | if (!ceiling) | ||
473 | return; | ||
474 | } | ||
475 | if (end - 1 > ceiling - 1) | ||
476 | end -= PMD_SIZE; | ||
477 | if (addr > end - 1) | ||
478 | return; | ||
479 | |||
457 | pgd = pgd_offset(tlb->mm, addr); | 480 | pgd = pgd_offset(tlb->mm, addr); |
458 | do { | 481 | do { |
459 | next = pgd_addr_end(addr, end); | 482 | next = pgd_addr_end(addr, end); |
diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c index ccd455328989..0cda653ae007 100644 --- a/arch/sparc/mm/init_64.c +++ b/arch/sparc/mm/init_64.c | |||
@@ -337,6 +337,10 @@ static int __init setup_hugepagesz(char *string) | |||
337 | hugepage_shift = ilog2(hugepage_size); | 337 | hugepage_shift = ilog2(hugepage_size); |
338 | 338 | ||
339 | switch (hugepage_shift) { | 339 | switch (hugepage_shift) { |
340 | case HPAGE_2GB_SHIFT: | ||
341 | hv_pgsz_mask = HV_PGSZ_MASK_2GB; | ||
342 | hv_pgsz_idx = HV_PGSZ_IDX_2GB; | ||
343 | break; | ||
340 | case HPAGE_256MB_SHIFT: | 344 | case HPAGE_256MB_SHIFT: |
341 | hv_pgsz_mask = HV_PGSZ_MASK_256MB; | 345 | hv_pgsz_mask = HV_PGSZ_MASK_256MB; |
342 | hv_pgsz_idx = HV_PGSZ_IDX_256MB; | 346 | hv_pgsz_idx = HV_PGSZ_IDX_256MB; |
@@ -1563,7 +1567,7 @@ bool kern_addr_valid(unsigned long addr) | |||
1563 | if ((long)addr < 0L) { | 1567 | if ((long)addr < 0L) { |
1564 | unsigned long pa = __pa(addr); | 1568 | unsigned long pa = __pa(addr); |
1565 | 1569 | ||
1566 | if ((addr >> max_phys_bits) != 0UL) | 1570 | if ((pa >> max_phys_bits) != 0UL) |
1567 | return false; | 1571 | return false; |
1568 | 1572 | ||
1569 | return pfn_valid(pa >> PAGE_SHIFT); | 1573 | return pfn_valid(pa >> PAGE_SHIFT); |
diff --git a/arch/sparc/mm/srmmu.c b/arch/sparc/mm/srmmu.c index def82f6d626f..8e76ebba2986 100644 --- a/arch/sparc/mm/srmmu.c +++ b/arch/sparc/mm/srmmu.c | |||
@@ -54,6 +54,7 @@ | |||
54 | enum mbus_module srmmu_modtype; | 54 | enum mbus_module srmmu_modtype; |
55 | static unsigned int hwbug_bitmask; | 55 | static unsigned int hwbug_bitmask; |
56 | int vac_cache_size; | 56 | int vac_cache_size; |
57 | EXPORT_SYMBOL(vac_cache_size); | ||
57 | int vac_line_size; | 58 | int vac_line_size; |
58 | 59 | ||
59 | extern struct resource sparc_iomap; | 60 | extern struct resource sparc_iomap; |
diff --git a/arch/sparc/mm/tlb.c b/arch/sparc/mm/tlb.c index afda3bbf7854..ee8066c3d96c 100644 --- a/arch/sparc/mm/tlb.c +++ b/arch/sparc/mm/tlb.c | |||
@@ -154,7 +154,7 @@ static void tlb_batch_pmd_scan(struct mm_struct *mm, unsigned long vaddr, | |||
154 | if (pte_val(*pte) & _PAGE_VALID) { | 154 | if (pte_val(*pte) & _PAGE_VALID) { |
155 | bool exec = pte_exec(*pte); | 155 | bool exec = pte_exec(*pte); |
156 | 156 | ||
157 | tlb_batch_add_one(mm, vaddr, exec, false); | 157 | tlb_batch_add_one(mm, vaddr, exec, PAGE_SHIFT); |
158 | } | 158 | } |
159 | pte++; | 159 | pte++; |
160 | vaddr += PAGE_SIZE; | 160 | vaddr += PAGE_SIZE; |
@@ -209,9 +209,9 @@ void set_pmd_at(struct mm_struct *mm, unsigned long addr, | |||
209 | pte_t orig_pte = __pte(pmd_val(orig)); | 209 | pte_t orig_pte = __pte(pmd_val(orig)); |
210 | bool exec = pte_exec(orig_pte); | 210 | bool exec = pte_exec(orig_pte); |
211 | 211 | ||
212 | tlb_batch_add_one(mm, addr, exec, true); | 212 | tlb_batch_add_one(mm, addr, exec, REAL_HPAGE_SHIFT); |
213 | tlb_batch_add_one(mm, addr + REAL_HPAGE_SIZE, exec, | 213 | tlb_batch_add_one(mm, addr + REAL_HPAGE_SIZE, exec, |
214 | true); | 214 | REAL_HPAGE_SHIFT); |
215 | } else { | 215 | } else { |
216 | tlb_batch_pmd_scan(mm, addr, orig); | 216 | tlb_batch_pmd_scan(mm, addr, orig); |
217 | } | 217 | } |
diff --git a/arch/sparc/mm/tsb.c b/arch/sparc/mm/tsb.c index 0a04811f06b7..bedf08b22a47 100644 --- a/arch/sparc/mm/tsb.c +++ b/arch/sparc/mm/tsb.c | |||
@@ -122,7 +122,7 @@ void flush_tsb_user(struct tlb_batch *tb) | |||
122 | 122 | ||
123 | spin_lock_irqsave(&mm->context.lock, flags); | 123 | spin_lock_irqsave(&mm->context.lock, flags); |
124 | 124 | ||
125 | if (tb->hugepage_shift < HPAGE_SHIFT) { | 125 | if (tb->hugepage_shift < REAL_HPAGE_SHIFT) { |
126 | base = (unsigned long) mm->context.tsb_block[MM_TSB_BASE].tsb; | 126 | base = (unsigned long) mm->context.tsb_block[MM_TSB_BASE].tsb; |
127 | nentries = mm->context.tsb_block[MM_TSB_BASE].tsb_nentries; | 127 | nentries = mm->context.tsb_block[MM_TSB_BASE].tsb_nentries; |
128 | if (tlb_type == cheetah_plus || tlb_type == hypervisor) | 128 | if (tlb_type == cheetah_plus || tlb_type == hypervisor) |
@@ -155,7 +155,7 @@ void flush_tsb_user_page(struct mm_struct *mm, unsigned long vaddr, | |||
155 | 155 | ||
156 | spin_lock_irqsave(&mm->context.lock, flags); | 156 | spin_lock_irqsave(&mm->context.lock, flags); |
157 | 157 | ||
158 | if (hugepage_shift < HPAGE_SHIFT) { | 158 | if (hugepage_shift < REAL_HPAGE_SHIFT) { |
159 | base = (unsigned long) mm->context.tsb_block[MM_TSB_BASE].tsb; | 159 | base = (unsigned long) mm->context.tsb_block[MM_TSB_BASE].tsb; |
160 | nentries = mm->context.tsb_block[MM_TSB_BASE].tsb_nentries; | 160 | nentries = mm->context.tsb_block[MM_TSB_BASE].tsb_nentries; |
161 | if (tlb_type == cheetah_plus || tlb_type == hypervisor) | 161 | if (tlb_type == cheetah_plus || tlb_type == hypervisor) |
diff --git a/arch/x86/Makefile b/arch/x86/Makefile index 2d449337a360..a94a4d10f2df 100644 --- a/arch/x86/Makefile +++ b/arch/x86/Makefile | |||
@@ -120,10 +120,6 @@ else | |||
120 | # -funit-at-a-time shrinks the kernel .text considerably | 120 | # -funit-at-a-time shrinks the kernel .text considerably |
121 | # unfortunately it makes reading oopses harder. | 121 | # unfortunately it makes reading oopses harder. |
122 | KBUILD_CFLAGS += $(call cc-option,-funit-at-a-time) | 122 | KBUILD_CFLAGS += $(call cc-option,-funit-at-a-time) |
123 | |||
124 | # this works around some issues with generating unwind tables in older gccs | ||
125 | # newer gccs do it by default | ||
126 | KBUILD_CFLAGS += $(call cc-option,-maccumulate-outgoing-args) | ||
127 | endif | 123 | endif |
128 | 124 | ||
129 | ifdef CONFIG_X86_X32 | 125 | ifdef CONFIG_X86_X32 |
@@ -147,6 +143,37 @@ ifeq ($(CONFIG_KMEMCHECK),y) | |||
147 | KBUILD_CFLAGS += $(call cc-option,-fno-builtin-memcpy) | 143 | KBUILD_CFLAGS += $(call cc-option,-fno-builtin-memcpy) |
148 | endif | 144 | endif |
149 | 145 | ||
146 | # | ||
147 | # If the function graph tracer is used with mcount instead of fentry, | ||
148 | # '-maccumulate-outgoing-args' is needed to prevent a GCC bug | ||
149 | # (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=42109) | ||
150 | # | ||
151 | ifdef CONFIG_FUNCTION_GRAPH_TRACER | ||
152 | ifndef CONFIG_HAVE_FENTRY | ||
153 | ACCUMULATE_OUTGOING_ARGS := 1 | ||
154 | else | ||
155 | ifeq ($(call cc-option-yn, -mfentry), n) | ||
156 | ACCUMULATE_OUTGOING_ARGS := 1 | ||
157 | endif | ||
158 | endif | ||
159 | endif | ||
160 | |||
161 | # | ||
162 | # Jump labels need '-maccumulate-outgoing-args' for gcc < 4.5.2 to prevent a | ||
163 | # GCC bug (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=46226). There's no way | ||
164 | # to test for this bug at compile-time because the test case needs to execute, | ||
165 | # which is a no-go for cross compilers. So check the GCC version instead. | ||
166 | # | ||
167 | ifdef CONFIG_JUMP_LABEL | ||
168 | ifneq ($(ACCUMULATE_OUTGOING_ARGS), 1) | ||
169 | ACCUMULATE_OUTGOING_ARGS = $(call cc-if-fullversion, -lt, 040502, 1) | ||
170 | endif | ||
171 | endif | ||
172 | |||
173 | ifeq ($(ACCUMULATE_OUTGOING_ARGS), 1) | ||
174 | KBUILD_CFLAGS += -maccumulate-outgoing-args | ||
175 | endif | ||
176 | |||
150 | # Stackpointer is addressed different for 32 bit and 64 bit x86 | 177 | # Stackpointer is addressed different for 32 bit and 64 bit x86 |
151 | sp-$(CONFIG_X86_32) := esp | 178 | sp-$(CONFIG_X86_32) := esp |
152 | sp-$(CONFIG_X86_64) := rsp | 179 | sp-$(CONFIG_X86_64) := rsp |
diff --git a/arch/x86/Makefile_32.cpu b/arch/x86/Makefile_32.cpu index 6647ed49c66c..a45eb15b7cf2 100644 --- a/arch/x86/Makefile_32.cpu +++ b/arch/x86/Makefile_32.cpu | |||
@@ -45,24 +45,6 @@ cflags-$(CONFIG_MGEODE_LX) += $(call cc-option,-march=geode,-march=pentium-mmx) | |||
45 | # cpu entries | 45 | # cpu entries |
46 | cflags-$(CONFIG_X86_GENERIC) += $(call tune,generic,$(call tune,i686)) | 46 | cflags-$(CONFIG_X86_GENERIC) += $(call tune,generic,$(call tune,i686)) |
47 | 47 | ||
48 | # Work around the pentium-mmx code generator madness of gcc4.4.x which | ||
49 | # does stack alignment by generating horrible code _before_ the mcount | ||
50 | # prologue (push %ebp, mov %esp, %ebp) which breaks the function graph | ||
51 | # tracer assumptions. For i686, generic, core2 this is set by the | ||
52 | # compiler anyway | ||
53 | ifeq ($(CONFIG_FUNCTION_GRAPH_TRACER), y) | ||
54 | ADD_ACCUMULATE_OUTGOING_ARGS := y | ||
55 | endif | ||
56 | |||
57 | # Work around to a bug with asm goto with first implementations of it | ||
58 | # in gcc causing gcc to mess up the push and pop of the stack in some | ||
59 | # uses of asm goto. | ||
60 | ifeq ($(CONFIG_JUMP_LABEL), y) | ||
61 | ADD_ACCUMULATE_OUTGOING_ARGS := y | ||
62 | endif | ||
63 | |||
64 | cflags-$(ADD_ACCUMULATE_OUTGOING_ARGS) += $(call cc-option,-maccumulate-outgoing-args) | ||
65 | |||
66 | # Bug fix for binutils: this option is required in order to keep | 48 | # Bug fix for binutils: this option is required in order to keep |
67 | # binutils from generating NOPL instructions against our will. | 49 | # binutils from generating NOPL instructions against our will. |
68 | ifneq ($(CONFIG_X86_P6_NOP),y) | 50 | ifneq ($(CONFIG_X86_P6_NOP),y) |
diff --git a/arch/x86/boot/compressed/error.c b/arch/x86/boot/compressed/error.c index 6248740b68b5..31922023de49 100644 --- a/arch/x86/boot/compressed/error.c +++ b/arch/x86/boot/compressed/error.c | |||
@@ -4,6 +4,7 @@ | |||
4 | * memcpy() and memmove() are defined for the compressed boot environment. | 4 | * memcpy() and memmove() are defined for the compressed boot environment. |
5 | */ | 5 | */ |
6 | #include "misc.h" | 6 | #include "misc.h" |
7 | #include "error.h" | ||
7 | 8 | ||
8 | void warn(char *m) | 9 | void warn(char *m) |
9 | { | 10 | { |
diff --git a/arch/x86/entry/vdso/vdso32-setup.c b/arch/x86/entry/vdso/vdso32-setup.c index 7853b53959cd..3f9d1a83891a 100644 --- a/arch/x86/entry/vdso/vdso32-setup.c +++ b/arch/x86/entry/vdso/vdso32-setup.c | |||
@@ -30,8 +30,10 @@ static int __init vdso32_setup(char *s) | |||
30 | { | 30 | { |
31 | vdso32_enabled = simple_strtoul(s, NULL, 0); | 31 | vdso32_enabled = simple_strtoul(s, NULL, 0); |
32 | 32 | ||
33 | if (vdso32_enabled > 1) | 33 | if (vdso32_enabled > 1) { |
34 | pr_warn("vdso32 values other than 0 and 1 are no longer allowed; vdso disabled\n"); | 34 | pr_warn("vdso32 values other than 0 and 1 are no longer allowed; vdso disabled\n"); |
35 | vdso32_enabled = 0; | ||
36 | } | ||
35 | 37 | ||
36 | return 1; | 38 | return 1; |
37 | } | 39 | } |
@@ -62,13 +64,18 @@ subsys_initcall(sysenter_setup); | |||
62 | /* Register vsyscall32 into the ABI table */ | 64 | /* Register vsyscall32 into the ABI table */ |
63 | #include <linux/sysctl.h> | 65 | #include <linux/sysctl.h> |
64 | 66 | ||
67 | static const int zero; | ||
68 | static const int one = 1; | ||
69 | |||
65 | static struct ctl_table abi_table2[] = { | 70 | static struct ctl_table abi_table2[] = { |
66 | { | 71 | { |
67 | .procname = "vsyscall32", | 72 | .procname = "vsyscall32", |
68 | .data = &vdso32_enabled, | 73 | .data = &vdso32_enabled, |
69 | .maxlen = sizeof(int), | 74 | .maxlen = sizeof(int), |
70 | .mode = 0644, | 75 | .mode = 0644, |
71 | .proc_handler = proc_dointvec | 76 | .proc_handler = proc_dointvec_minmax, |
77 | .extra1 = (int *)&zero, | ||
78 | .extra2 = (int *)&one, | ||
72 | }, | 79 | }, |
73 | {} | 80 | {} |
74 | }; | 81 | }; |
diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c index 2aa1ad194db2..580b60f5ac83 100644 --- a/arch/x86/events/core.c +++ b/arch/x86/events/core.c | |||
@@ -2256,6 +2256,7 @@ void arch_perf_update_userpage(struct perf_event *event, | |||
2256 | struct perf_event_mmap_page *userpg, u64 now) | 2256 | struct perf_event_mmap_page *userpg, u64 now) |
2257 | { | 2257 | { |
2258 | struct cyc2ns_data *data; | 2258 | struct cyc2ns_data *data; |
2259 | u64 offset; | ||
2259 | 2260 | ||
2260 | userpg->cap_user_time = 0; | 2261 | userpg->cap_user_time = 0; |
2261 | userpg->cap_user_time_zero = 0; | 2262 | userpg->cap_user_time_zero = 0; |
@@ -2263,11 +2264,13 @@ void arch_perf_update_userpage(struct perf_event *event, | |||
2263 | !!(event->hw.flags & PERF_X86_EVENT_RDPMC_ALLOWED); | 2264 | !!(event->hw.flags & PERF_X86_EVENT_RDPMC_ALLOWED); |
2264 | userpg->pmc_width = x86_pmu.cntval_bits; | 2265 | userpg->pmc_width = x86_pmu.cntval_bits; |
2265 | 2266 | ||
2266 | if (!sched_clock_stable()) | 2267 | if (!using_native_sched_clock() || !sched_clock_stable()) |
2267 | return; | 2268 | return; |
2268 | 2269 | ||
2269 | data = cyc2ns_read_begin(); | 2270 | data = cyc2ns_read_begin(); |
2270 | 2271 | ||
2272 | offset = data->cyc2ns_offset + __sched_clock_offset; | ||
2273 | |||
2271 | /* | 2274 | /* |
2272 | * Internal timekeeping for enabled/running/stopped times | 2275 | * Internal timekeeping for enabled/running/stopped times |
2273 | * is always in the local_clock domain. | 2276 | * is always in the local_clock domain. |
@@ -2275,7 +2278,7 @@ void arch_perf_update_userpage(struct perf_event *event, | |||
2275 | userpg->cap_user_time = 1; | 2278 | userpg->cap_user_time = 1; |
2276 | userpg->time_mult = data->cyc2ns_mul; | 2279 | userpg->time_mult = data->cyc2ns_mul; |
2277 | userpg->time_shift = data->cyc2ns_shift; | 2280 | userpg->time_shift = data->cyc2ns_shift; |
2278 | userpg->time_offset = data->cyc2ns_offset - now; | 2281 | userpg->time_offset = offset - now; |
2279 | 2282 | ||
2280 | /* | 2283 | /* |
2281 | * cap_user_time_zero doesn't make sense when we're using a different | 2284 | * cap_user_time_zero doesn't make sense when we're using a different |
@@ -2283,7 +2286,7 @@ void arch_perf_update_userpage(struct perf_event *event, | |||
2283 | */ | 2286 | */ |
2284 | if (!event->attr.use_clockid) { | 2287 | if (!event->attr.use_clockid) { |
2285 | userpg->cap_user_time_zero = 1; | 2288 | userpg->cap_user_time_zero = 1; |
2286 | userpg->time_zero = data->cyc2ns_offset; | 2289 | userpg->time_zero = offset; |
2287 | } | 2290 | } |
2288 | 2291 | ||
2289 | cyc2ns_read_end(data); | 2292 | cyc2ns_read_end(data); |
diff --git a/arch/x86/events/intel/lbr.c b/arch/x86/events/intel/lbr.c index 81b321ace8e0..f924629836a8 100644 --- a/arch/x86/events/intel/lbr.c +++ b/arch/x86/events/intel/lbr.c | |||
@@ -507,6 +507,9 @@ static void intel_pmu_lbr_read_32(struct cpu_hw_events *cpuc) | |||
507 | cpuc->lbr_entries[i].to = msr_lastbranch.to; | 507 | cpuc->lbr_entries[i].to = msr_lastbranch.to; |
508 | cpuc->lbr_entries[i].mispred = 0; | 508 | cpuc->lbr_entries[i].mispred = 0; |
509 | cpuc->lbr_entries[i].predicted = 0; | 509 | cpuc->lbr_entries[i].predicted = 0; |
510 | cpuc->lbr_entries[i].in_tx = 0; | ||
511 | cpuc->lbr_entries[i].abort = 0; | ||
512 | cpuc->lbr_entries[i].cycles = 0; | ||
510 | cpuc->lbr_entries[i].reserved = 0; | 513 | cpuc->lbr_entries[i].reserved = 0; |
511 | } | 514 | } |
512 | cpuc->lbr_stack.nr = i; | 515 | cpuc->lbr_stack.nr = i; |
diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h index 9d49c18b5ea9..3762536619f8 100644 --- a/arch/x86/include/asm/elf.h +++ b/arch/x86/include/asm/elf.h | |||
@@ -287,7 +287,7 @@ struct task_struct; | |||
287 | 287 | ||
288 | #define ARCH_DLINFO_IA32 \ | 288 | #define ARCH_DLINFO_IA32 \ |
289 | do { \ | 289 | do { \ |
290 | if (vdso32_enabled) { \ | 290 | if (VDSO_CURRENT_BASE) { \ |
291 | NEW_AUX_ENT(AT_SYSINFO, VDSO_ENTRY); \ | 291 | NEW_AUX_ENT(AT_SYSINFO, VDSO_ENTRY); \ |
292 | NEW_AUX_ENT(AT_SYSINFO_EHDR, VDSO_CURRENT_BASE); \ | 292 | NEW_AUX_ENT(AT_SYSINFO_EHDR, VDSO_CURRENT_BASE); \ |
293 | } \ | 293 | } \ |
diff --git a/arch/x86/include/asm/pmem.h b/arch/x86/include/asm/pmem.h index 2c1ebeb4d737..529bb4a6487a 100644 --- a/arch/x86/include/asm/pmem.h +++ b/arch/x86/include/asm/pmem.h | |||
@@ -55,7 +55,8 @@ static inline int arch_memcpy_from_pmem(void *dst, const void *src, size_t n) | |||
55 | * @size: number of bytes to write back | 55 | * @size: number of bytes to write back |
56 | * | 56 | * |
57 | * Write back a cache range using the CLWB (cache line write back) | 57 | * Write back a cache range using the CLWB (cache line write back) |
58 | * instruction. | 58 | * instruction. Note that @size is internally rounded up to be cache |
59 | * line size aligned. | ||
59 | */ | 60 | */ |
60 | static inline void arch_wb_cache_pmem(void *addr, size_t size) | 61 | static inline void arch_wb_cache_pmem(void *addr, size_t size) |
61 | { | 62 | { |
@@ -69,15 +70,6 @@ static inline void arch_wb_cache_pmem(void *addr, size_t size) | |||
69 | clwb(p); | 70 | clwb(p); |
70 | } | 71 | } |
71 | 72 | ||
72 | /* | ||
73 | * copy_from_iter_nocache() on x86 only uses non-temporal stores for iovec | ||
74 | * iterators, so for other types (bvec & kvec) we must do a cache write-back. | ||
75 | */ | ||
76 | static inline bool __iter_needs_pmem_wb(struct iov_iter *i) | ||
77 | { | ||
78 | return iter_is_iovec(i) == false; | ||
79 | } | ||
80 | |||
81 | /** | 73 | /** |
82 | * arch_copy_from_iter_pmem - copy data from an iterator to PMEM | 74 | * arch_copy_from_iter_pmem - copy data from an iterator to PMEM |
83 | * @addr: PMEM destination address | 75 | * @addr: PMEM destination address |
@@ -94,7 +86,35 @@ static inline size_t arch_copy_from_iter_pmem(void *addr, size_t bytes, | |||
94 | /* TODO: skip the write-back by always using non-temporal stores */ | 86 | /* TODO: skip the write-back by always using non-temporal stores */ |
95 | len = copy_from_iter_nocache(addr, bytes, i); | 87 | len = copy_from_iter_nocache(addr, bytes, i); |
96 | 88 | ||
97 | if (__iter_needs_pmem_wb(i)) | 89 | /* |
90 | * In the iovec case on x86_64 copy_from_iter_nocache() uses | ||
91 | * non-temporal stores for the bulk of the transfer, but we need | ||
92 | * to manually flush if the transfer is unaligned. A cached | ||
93 | * memory copy is used when destination or size is not naturally | ||
94 | * aligned. That is: | ||
95 | * - Require 8-byte alignment when size is 8 bytes or larger. | ||
96 | * - Require 4-byte alignment when size is 4 bytes. | ||
97 | * | ||
98 | * In the non-iovec case the entire destination needs to be | ||
99 | * flushed. | ||
100 | */ | ||
101 | if (iter_is_iovec(i)) { | ||
102 | unsigned long flushed, dest = (unsigned long) addr; | ||
103 | |||
104 | if (bytes < 8) { | ||
105 | if (!IS_ALIGNED(dest, 4) || (bytes != 4)) | ||
106 | arch_wb_cache_pmem(addr, 1); | ||
107 | } else { | ||
108 | if (!IS_ALIGNED(dest, 8)) { | ||
109 | dest = ALIGN(dest, boot_cpu_data.x86_clflush_size); | ||
110 | arch_wb_cache_pmem(addr, 1); | ||
111 | } | ||
112 | |||
113 | flushed = dest - (unsigned long) addr; | ||
114 | if (bytes > flushed && !IS_ALIGNED(bytes - flushed, 8)) | ||
115 | arch_wb_cache_pmem(addr + bytes - 1, 1); | ||
116 | } | ||
117 | } else | ||
98 | arch_wb_cache_pmem(addr, bytes); | 118 | arch_wb_cache_pmem(addr, bytes); |
99 | 119 | ||
100 | return len; | 120 | return len; |
diff --git a/arch/x86/include/asm/timer.h b/arch/x86/include/asm/timer.h index a04eabd43d06..27e9f9d769b8 100644 --- a/arch/x86/include/asm/timer.h +++ b/arch/x86/include/asm/timer.h | |||
@@ -12,6 +12,8 @@ extern int recalibrate_cpu_khz(void); | |||
12 | 12 | ||
13 | extern int no_timer_check; | 13 | extern int no_timer_check; |
14 | 14 | ||
15 | extern bool using_native_sched_clock(void); | ||
16 | |||
15 | /* | 17 | /* |
16 | * We use the full linear equation: f(x) = a + b*x, in order to allow | 18 | * We use the full linear equation: f(x) = a + b*x, in order to allow |
17 | * a continuous function in the face of dynamic freq changes. | 19 | * a continuous function in the face of dynamic freq changes. |
diff --git a/arch/x86/include/asm/uv/uv_hub.h b/arch/x86/include/asm/uv/uv_hub.h index 72e8300b1e8a..9cffb44a3cf5 100644 --- a/arch/x86/include/asm/uv/uv_hub.h +++ b/arch/x86/include/asm/uv/uv_hub.h | |||
@@ -485,15 +485,17 @@ static inline unsigned long uv_soc_phys_ram_to_gpa(unsigned long paddr) | |||
485 | 485 | ||
486 | if (paddr < uv_hub_info->lowmem_remap_top) | 486 | if (paddr < uv_hub_info->lowmem_remap_top) |
487 | paddr |= uv_hub_info->lowmem_remap_base; | 487 | paddr |= uv_hub_info->lowmem_remap_base; |
488 | paddr |= uv_hub_info->gnode_upper; | 488 | |
489 | if (m_val) | 489 | if (m_val) { |
490 | paddr |= uv_hub_info->gnode_upper; | ||
490 | paddr = ((paddr << uv_hub_info->m_shift) | 491 | paddr = ((paddr << uv_hub_info->m_shift) |
491 | >> uv_hub_info->m_shift) | | 492 | >> uv_hub_info->m_shift) | |
492 | ((paddr >> uv_hub_info->m_val) | 493 | ((paddr >> uv_hub_info->m_val) |
493 | << uv_hub_info->n_lshift); | 494 | << uv_hub_info->n_lshift); |
494 | else | 495 | } else { |
495 | paddr |= uv_soc_phys_ram_to_nasid(paddr) | 496 | paddr |= uv_soc_phys_ram_to_nasid(paddr) |
496 | << uv_hub_info->gpa_shift; | 497 | << uv_hub_info->gpa_shift; |
498 | } | ||
497 | return paddr; | 499 | return paddr; |
498 | } | 500 | } |
499 | 501 | ||
diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c index e9f8f8cdd570..86f20cc0a65e 100644 --- a/arch/x86/kernel/apic/x2apic_uv_x.c +++ b/arch/x86/kernel/apic/x2apic_uv_x.c | |||
@@ -1105,7 +1105,8 @@ void __init uv_init_hub_info(struct uv_hub_info_s *hi) | |||
1105 | node_id.v = uv_read_local_mmr(UVH_NODE_ID); | 1105 | node_id.v = uv_read_local_mmr(UVH_NODE_ID); |
1106 | uv_cpuid.gnode_shift = max_t(unsigned int, uv_cpuid.gnode_shift, mn.n_val); | 1106 | uv_cpuid.gnode_shift = max_t(unsigned int, uv_cpuid.gnode_shift, mn.n_val); |
1107 | hi->gnode_extra = (node_id.s.node_id & ~((1 << uv_cpuid.gnode_shift) - 1)) >> 1; | 1107 | hi->gnode_extra = (node_id.s.node_id & ~((1 << uv_cpuid.gnode_shift) - 1)) >> 1; |
1108 | hi->gnode_upper = (unsigned long)hi->gnode_extra << mn.m_val; | 1108 | if (mn.m_val) |
1109 | hi->gnode_upper = (u64)hi->gnode_extra << mn.m_val; | ||
1109 | 1110 | ||
1110 | if (uv_gp_table) { | 1111 | if (uv_gp_table) { |
1111 | hi->global_mmr_base = uv_gp_table->mmr_base; | 1112 | hi->global_mmr_base = uv_gp_table->mmr_base; |
diff --git a/arch/x86/kernel/cpu/intel_rdt_schemata.c b/arch/x86/kernel/cpu/intel_rdt_schemata.c index f369cb8db0d5..badd2b31a560 100644 --- a/arch/x86/kernel/cpu/intel_rdt_schemata.c +++ b/arch/x86/kernel/cpu/intel_rdt_schemata.c | |||
@@ -200,11 +200,11 @@ ssize_t rdtgroup_schemata_write(struct kernfs_open_file *of, | |||
200 | } | 200 | } |
201 | 201 | ||
202 | out: | 202 | out: |
203 | rdtgroup_kn_unlock(of->kn); | ||
204 | for_each_enabled_rdt_resource(r) { | 203 | for_each_enabled_rdt_resource(r) { |
205 | kfree(r->tmp_cbms); | 204 | kfree(r->tmp_cbms); |
206 | r->tmp_cbms = NULL; | 205 | r->tmp_cbms = NULL; |
207 | } | 206 | } |
207 | rdtgroup_kn_unlock(of->kn); | ||
208 | return ret ?: nbytes; | 208 | return ret ?: nbytes; |
209 | } | 209 | } |
210 | 210 | ||
diff --git a/arch/x86/kernel/cpu/mcheck/mce-genpool.c b/arch/x86/kernel/cpu/mcheck/mce-genpool.c index 1e5a50c11d3c..217cd4449bc9 100644 --- a/arch/x86/kernel/cpu/mcheck/mce-genpool.c +++ b/arch/x86/kernel/cpu/mcheck/mce-genpool.c | |||
@@ -85,7 +85,7 @@ void mce_gen_pool_process(struct work_struct *__unused) | |||
85 | head = llist_reverse_order(head); | 85 | head = llist_reverse_order(head); |
86 | llist_for_each_entry_safe(node, tmp, head, llnode) { | 86 | llist_for_each_entry_safe(node, tmp, head, llnode) { |
87 | mce = &node->mce; | 87 | mce = &node->mce; |
88 | atomic_notifier_call_chain(&x86_mce_decoder_chain, 0, mce); | 88 | blocking_notifier_call_chain(&x86_mce_decoder_chain, 0, mce); |
89 | gen_pool_free(mce_evt_pool, (unsigned long)node, sizeof(*node)); | 89 | gen_pool_free(mce_evt_pool, (unsigned long)node, sizeof(*node)); |
90 | } | 90 | } |
91 | } | 91 | } |
diff --git a/arch/x86/kernel/cpu/mcheck/mce-internal.h b/arch/x86/kernel/cpu/mcheck/mce-internal.h index 903043e6a62b..19592ba1a320 100644 --- a/arch/x86/kernel/cpu/mcheck/mce-internal.h +++ b/arch/x86/kernel/cpu/mcheck/mce-internal.h | |||
@@ -13,7 +13,7 @@ enum severity_level { | |||
13 | MCE_PANIC_SEVERITY, | 13 | MCE_PANIC_SEVERITY, |
14 | }; | 14 | }; |
15 | 15 | ||
16 | extern struct atomic_notifier_head x86_mce_decoder_chain; | 16 | extern struct blocking_notifier_head x86_mce_decoder_chain; |
17 | 17 | ||
18 | #define ATTR_LEN 16 | 18 | #define ATTR_LEN 16 |
19 | #define INITIAL_CHECK_INTERVAL 5 * 60 /* 5 minutes */ | 19 | #define INITIAL_CHECK_INTERVAL 5 * 60 /* 5 minutes */ |
diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c index 8e9725c607ea..af44ebeb593f 100644 --- a/arch/x86/kernel/cpu/mcheck/mce.c +++ b/arch/x86/kernel/cpu/mcheck/mce.c | |||
@@ -54,6 +54,8 @@ | |||
54 | 54 | ||
55 | static DEFINE_MUTEX(mce_chrdev_read_mutex); | 55 | static DEFINE_MUTEX(mce_chrdev_read_mutex); |
56 | 56 | ||
57 | static int mce_chrdev_open_count; /* #times opened */ | ||
58 | |||
57 | #define mce_log_get_idx_check(p) \ | 59 | #define mce_log_get_idx_check(p) \ |
58 | ({ \ | 60 | ({ \ |
59 | RCU_LOCKDEP_WARN(!rcu_read_lock_sched_held() && \ | 61 | RCU_LOCKDEP_WARN(!rcu_read_lock_sched_held() && \ |
@@ -121,7 +123,7 @@ static void (*quirk_no_way_out)(int bank, struct mce *m, struct pt_regs *regs); | |||
121 | * CPU/chipset specific EDAC code can register a notifier call here to print | 123 | * CPU/chipset specific EDAC code can register a notifier call here to print |
122 | * MCE errors in a human-readable form. | 124 | * MCE errors in a human-readable form. |
123 | */ | 125 | */ |
124 | ATOMIC_NOTIFIER_HEAD(x86_mce_decoder_chain); | 126 | BLOCKING_NOTIFIER_HEAD(x86_mce_decoder_chain); |
125 | 127 | ||
126 | /* Do initial initialization of a struct mce */ | 128 | /* Do initial initialization of a struct mce */ |
127 | void mce_setup(struct mce *m) | 129 | void mce_setup(struct mce *m) |
@@ -218,7 +220,7 @@ void mce_register_decode_chain(struct notifier_block *nb) | |||
218 | 220 | ||
219 | WARN_ON(nb->priority > MCE_PRIO_LOWEST && nb->priority < MCE_PRIO_EDAC); | 221 | WARN_ON(nb->priority > MCE_PRIO_LOWEST && nb->priority < MCE_PRIO_EDAC); |
220 | 222 | ||
221 | atomic_notifier_chain_register(&x86_mce_decoder_chain, nb); | 223 | blocking_notifier_chain_register(&x86_mce_decoder_chain, nb); |
222 | } | 224 | } |
223 | EXPORT_SYMBOL_GPL(mce_register_decode_chain); | 225 | EXPORT_SYMBOL_GPL(mce_register_decode_chain); |
224 | 226 | ||
@@ -226,7 +228,7 @@ void mce_unregister_decode_chain(struct notifier_block *nb) | |||
226 | { | 228 | { |
227 | atomic_dec(&num_notifiers); | 229 | atomic_dec(&num_notifiers); |
228 | 230 | ||
229 | atomic_notifier_chain_unregister(&x86_mce_decoder_chain, nb); | 231 | blocking_notifier_chain_unregister(&x86_mce_decoder_chain, nb); |
230 | } | 232 | } |
231 | EXPORT_SYMBOL_GPL(mce_unregister_decode_chain); | 233 | EXPORT_SYMBOL_GPL(mce_unregister_decode_chain); |
232 | 234 | ||
@@ -319,18 +321,7 @@ static void __print_mce(struct mce *m) | |||
319 | 321 | ||
320 | static void print_mce(struct mce *m) | 322 | static void print_mce(struct mce *m) |
321 | { | 323 | { |
322 | int ret = 0; | ||
323 | |||
324 | __print_mce(m); | 324 | __print_mce(m); |
325 | |||
326 | /* | ||
327 | * Print out human-readable details about the MCE error, | ||
328 | * (if the CPU has an implementation for that) | ||
329 | */ | ||
330 | ret = atomic_notifier_call_chain(&x86_mce_decoder_chain, 0, m); | ||
331 | if (ret == NOTIFY_STOP) | ||
332 | return; | ||
333 | |||
334 | pr_emerg_ratelimited(HW_ERR "Run the above through 'mcelog --ascii'\n"); | 325 | pr_emerg_ratelimited(HW_ERR "Run the above through 'mcelog --ascii'\n"); |
335 | } | 326 | } |
336 | 327 | ||
@@ -598,6 +589,10 @@ static int mce_default_notifier(struct notifier_block *nb, unsigned long val, | |||
598 | if (atomic_read(&num_notifiers) > 2) | 589 | if (atomic_read(&num_notifiers) > 2) |
599 | return NOTIFY_DONE; | 590 | return NOTIFY_DONE; |
600 | 591 | ||
592 | /* Don't print when mcelog is running */ | ||
593 | if (mce_chrdev_open_count > 0) | ||
594 | return NOTIFY_DONE; | ||
595 | |||
601 | __print_mce(m); | 596 | __print_mce(m); |
602 | 597 | ||
603 | return NOTIFY_DONE; | 598 | return NOTIFY_DONE; |
@@ -1828,7 +1823,6 @@ void mcheck_cpu_clear(struct cpuinfo_x86 *c) | |||
1828 | */ | 1823 | */ |
1829 | 1824 | ||
1830 | static DEFINE_SPINLOCK(mce_chrdev_state_lock); | 1825 | static DEFINE_SPINLOCK(mce_chrdev_state_lock); |
1831 | static int mce_chrdev_open_count; /* #times opened */ | ||
1832 | static int mce_chrdev_open_exclu; /* already open exclusive? */ | 1826 | static int mce_chrdev_open_exclu; /* already open exclusive? */ |
1833 | 1827 | ||
1834 | static int mce_chrdev_open(struct inode *inode, struct file *file) | 1828 | static int mce_chrdev_open(struct inode *inode, struct file *file) |
diff --git a/arch/x86/kernel/cpu/mcheck/mce_amd.c b/arch/x86/kernel/cpu/mcheck/mce_amd.c index 524cc5780a77..6e4a047e4b68 100644 --- a/arch/x86/kernel/cpu/mcheck/mce_amd.c +++ b/arch/x86/kernel/cpu/mcheck/mce_amd.c | |||
@@ -60,7 +60,7 @@ static const char * const th_names[] = { | |||
60 | "load_store", | 60 | "load_store", |
61 | "insn_fetch", | 61 | "insn_fetch", |
62 | "combined_unit", | 62 | "combined_unit", |
63 | "", | 63 | "decode_unit", |
64 | "northbridge", | 64 | "northbridge", |
65 | "execution_unit", | 65 | "execution_unit", |
66 | }; | 66 | }; |
diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c index 8f3d9cf26ff9..cbd73eb42170 100644 --- a/arch/x86/kernel/ftrace.c +++ b/arch/x86/kernel/ftrace.c | |||
@@ -29,6 +29,12 @@ | |||
29 | #include <asm/ftrace.h> | 29 | #include <asm/ftrace.h> |
30 | #include <asm/nops.h> | 30 | #include <asm/nops.h> |
31 | 31 | ||
32 | #if defined(CONFIG_FUNCTION_GRAPH_TRACER) && \ | ||
33 | !defined(CC_USING_FENTRY) && \ | ||
34 | !defined(CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE) | ||
35 | # error The following combination is not supported: ((compiler missing -mfentry) || (CONFIG_X86_32 and !CONFIG_DYNAMIC_FTRACE)) && CONFIG_FUNCTION_GRAPH_TRACER && CONFIG_CC_OPTIMIZE_FOR_SIZE | ||
36 | #endif | ||
37 | |||
32 | #ifdef CONFIG_DYNAMIC_FTRACE | 38 | #ifdef CONFIG_DYNAMIC_FTRACE |
33 | 39 | ||
34 | int ftrace_arch_code_modify_prepare(void) | 40 | int ftrace_arch_code_modify_prepare(void) |
diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c index 396c042e9d0e..cc30a74e4adb 100644 --- a/arch/x86/kernel/signal.c +++ b/arch/x86/kernel/signal.c | |||
@@ -846,7 +846,7 @@ void signal_fault(struct pt_regs *regs, void __user *frame, char *where) | |||
846 | task_pid_nr(current) > 1 ? KERN_INFO : KERN_EMERG, | 846 | task_pid_nr(current) > 1 ? KERN_INFO : KERN_EMERG, |
847 | me->comm, me->pid, where, frame, | 847 | me->comm, me->pid, where, frame, |
848 | regs->ip, regs->sp, regs->orig_ax); | 848 | regs->ip, regs->sp, regs->orig_ax); |
849 | print_vma_addr(" in ", regs->ip); | 849 | print_vma_addr(KERN_CONT " in ", regs->ip); |
850 | pr_cont("\n"); | 850 | pr_cont("\n"); |
851 | } | 851 | } |
852 | 852 | ||
diff --git a/arch/x86/kernel/signal_compat.c b/arch/x86/kernel/signal_compat.c index ec1f756f9dc9..71beb28600d4 100644 --- a/arch/x86/kernel/signal_compat.c +++ b/arch/x86/kernel/signal_compat.c | |||
@@ -151,8 +151,8 @@ int __copy_siginfo_to_user32(compat_siginfo_t __user *to, const siginfo_t *from, | |||
151 | 151 | ||
152 | if (from->si_signo == SIGSEGV) { | 152 | if (from->si_signo == SIGSEGV) { |
153 | if (from->si_code == SEGV_BNDERR) { | 153 | if (from->si_code == SEGV_BNDERR) { |
154 | compat_uptr_t lower = (unsigned long)&to->si_lower; | 154 | compat_uptr_t lower = (unsigned long)from->si_lower; |
155 | compat_uptr_t upper = (unsigned long)&to->si_upper; | 155 | compat_uptr_t upper = (unsigned long)from->si_upper; |
156 | put_user_ex(lower, &to->si_lower); | 156 | put_user_ex(lower, &to->si_lower); |
157 | put_user_ex(upper, &to->si_upper); | 157 | put_user_ex(upper, &to->si_upper); |
158 | } | 158 | } |
diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c index 948443e115c1..4e496379a871 100644 --- a/arch/x86/kernel/traps.c +++ b/arch/x86/kernel/traps.c | |||
@@ -255,7 +255,7 @@ do_trap(int trapnr, int signr, char *str, struct pt_regs *regs, | |||
255 | pr_info("%s[%d] trap %s ip:%lx sp:%lx error:%lx", | 255 | pr_info("%s[%d] trap %s ip:%lx sp:%lx error:%lx", |
256 | tsk->comm, tsk->pid, str, | 256 | tsk->comm, tsk->pid, str, |
257 | regs->ip, regs->sp, error_code); | 257 | regs->ip, regs->sp, error_code); |
258 | print_vma_addr(" in ", regs->ip); | 258 | print_vma_addr(KERN_CONT " in ", regs->ip); |
259 | pr_cont("\n"); | 259 | pr_cont("\n"); |
260 | } | 260 | } |
261 | 261 | ||
@@ -519,7 +519,7 @@ do_general_protection(struct pt_regs *regs, long error_code) | |||
519 | pr_info("%s[%d] general protection ip:%lx sp:%lx error:%lx", | 519 | pr_info("%s[%d] general protection ip:%lx sp:%lx error:%lx", |
520 | tsk->comm, task_pid_nr(tsk), | 520 | tsk->comm, task_pid_nr(tsk), |
521 | regs->ip, regs->sp, error_code); | 521 | regs->ip, regs->sp, error_code); |
522 | print_vma_addr(" in ", regs->ip); | 522 | print_vma_addr(KERN_CONT " in ", regs->ip); |
523 | pr_cont("\n"); | 523 | pr_cont("\n"); |
524 | } | 524 | } |
525 | 525 | ||
diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c index c73a7f9e881a..714dfba6a1e7 100644 --- a/arch/x86/kernel/tsc.c +++ b/arch/x86/kernel/tsc.c | |||
@@ -328,7 +328,7 @@ unsigned long long sched_clock(void) | |||
328 | return paravirt_sched_clock(); | 328 | return paravirt_sched_clock(); |
329 | } | 329 | } |
330 | 330 | ||
331 | static inline bool using_native_sched_clock(void) | 331 | bool using_native_sched_clock(void) |
332 | { | 332 | { |
333 | return pv_time_ops.sched_clock == native_sched_clock; | 333 | return pv_time_ops.sched_clock == native_sched_clock; |
334 | } | 334 | } |
@@ -336,7 +336,7 @@ static inline bool using_native_sched_clock(void) | |||
336 | unsigned long long | 336 | unsigned long long |
337 | sched_clock(void) __attribute__((alias("native_sched_clock"))); | 337 | sched_clock(void) __attribute__((alias("native_sched_clock"))); |
338 | 338 | ||
339 | static inline bool using_native_sched_clock(void) { return true; } | 339 | bool using_native_sched_clock(void) { return true; } |
340 | #endif | 340 | #endif |
341 | 341 | ||
342 | int check_tsc_unstable(void) | 342 | int check_tsc_unstable(void) |
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 2ee00dbbbd51..259e9b28ccf8 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c | |||
@@ -8198,6 +8198,9 @@ static bool nested_vmx_exit_handled(struct kvm_vcpu *vcpu) | |||
8198 | return nested_cpu_has2(vmcs12, SECONDARY_EXEC_XSAVES); | 8198 | return nested_cpu_has2(vmcs12, SECONDARY_EXEC_XSAVES); |
8199 | case EXIT_REASON_PREEMPTION_TIMER: | 8199 | case EXIT_REASON_PREEMPTION_TIMER: |
8200 | return false; | 8200 | return false; |
8201 | case EXIT_REASON_PML_FULL: | ||
8202 | /* We don't expose PML support to L1. */ | ||
8203 | return false; | ||
8201 | default: | 8204 | default: |
8202 | return true; | 8205 | return true; |
8203 | } | 8206 | } |
@@ -10267,6 +10270,18 @@ static int prepare_vmcs02(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12, | |||
10267 | 10270 | ||
10268 | } | 10271 | } |
10269 | 10272 | ||
10273 | if (enable_pml) { | ||
10274 | /* | ||
10275 | * Conceptually we want to copy the PML address and index from | ||
10276 | * vmcs01 here, and then back to vmcs01 on nested vmexit. But, | ||
10277 | * since we always flush the log on each vmexit, this happens | ||
10278 | * to be equivalent to simply resetting the fields in vmcs02. | ||
10279 | */ | ||
10280 | ASSERT(vmx->pml_pg); | ||
10281 | vmcs_write64(PML_ADDRESS, page_to_phys(vmx->pml_pg)); | ||
10282 | vmcs_write16(GUEST_PML_INDEX, PML_ENTITY_NUM - 1); | ||
10283 | } | ||
10284 | |||
10270 | if (nested_cpu_has_ept(vmcs12)) { | 10285 | if (nested_cpu_has_ept(vmcs12)) { |
10271 | kvm_mmu_unload(vcpu); | 10286 | kvm_mmu_unload(vcpu); |
10272 | nested_ept_init_mmu_context(vcpu); | 10287 | nested_ept_init_mmu_context(vcpu); |
diff --git a/arch/x86/lib/memcpy_64.S b/arch/x86/lib/memcpy_64.S index 779782f58324..9a53a06e5a3e 100644 --- a/arch/x86/lib/memcpy_64.S +++ b/arch/x86/lib/memcpy_64.S | |||
@@ -290,7 +290,7 @@ EXPORT_SYMBOL_GPL(memcpy_mcsafe_unrolled) | |||
290 | _ASM_EXTABLE_FAULT(.L_copy_leading_bytes, .L_memcpy_mcsafe_fail) | 290 | _ASM_EXTABLE_FAULT(.L_copy_leading_bytes, .L_memcpy_mcsafe_fail) |
291 | _ASM_EXTABLE_FAULT(.L_cache_w0, .L_memcpy_mcsafe_fail) | 291 | _ASM_EXTABLE_FAULT(.L_cache_w0, .L_memcpy_mcsafe_fail) |
292 | _ASM_EXTABLE_FAULT(.L_cache_w1, .L_memcpy_mcsafe_fail) | 292 | _ASM_EXTABLE_FAULT(.L_cache_w1, .L_memcpy_mcsafe_fail) |
293 | _ASM_EXTABLE_FAULT(.L_cache_w3, .L_memcpy_mcsafe_fail) | 293 | _ASM_EXTABLE_FAULT(.L_cache_w2, .L_memcpy_mcsafe_fail) |
294 | _ASM_EXTABLE_FAULT(.L_cache_w3, .L_memcpy_mcsafe_fail) | 294 | _ASM_EXTABLE_FAULT(.L_cache_w3, .L_memcpy_mcsafe_fail) |
295 | _ASM_EXTABLE_FAULT(.L_cache_w4, .L_memcpy_mcsafe_fail) | 295 | _ASM_EXTABLE_FAULT(.L_cache_w4, .L_memcpy_mcsafe_fail) |
296 | _ASM_EXTABLE_FAULT(.L_cache_w5, .L_memcpy_mcsafe_fail) | 296 | _ASM_EXTABLE_FAULT(.L_cache_w5, .L_memcpy_mcsafe_fail) |
diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c index 22af912d66d2..889e7619a091 100644 --- a/arch/x86/mm/init.c +++ b/arch/x86/mm/init.c | |||
@@ -643,21 +643,40 @@ void __init init_mem_mapping(void) | |||
643 | * devmem_is_allowed() checks to see if /dev/mem access to a certain address | 643 | * devmem_is_allowed() checks to see if /dev/mem access to a certain address |
644 | * is valid. The argument is a physical page number. | 644 | * is valid. The argument is a physical page number. |
645 | * | 645 | * |
646 | * | 646 | * On x86, access has to be given to the first megabyte of RAM because that |
647 | * On x86, access has to be given to the first megabyte of ram because that area | 647 | * area traditionally contains BIOS code and data regions used by X, dosemu, |
648 | * contains BIOS code and data regions used by X and dosemu and similar apps. | 648 | * and similar apps. Since they map the entire memory range, the whole range |
649 | * Access has to be given to non-kernel-ram areas as well, these contain the PCI | 649 | * must be allowed (for mapping), but any areas that would otherwise be |
650 | * mmio resources as well as potential bios/acpi data regions. | 650 | * disallowed are flagged as being "zero filled" instead of rejected. |
651 | * Access has to be given to non-kernel-ram areas as well, these contain the | ||
652 | * PCI mmio resources as well as potential bios/acpi data regions. | ||
651 | */ | 653 | */ |
652 | int devmem_is_allowed(unsigned long pagenr) | 654 | int devmem_is_allowed(unsigned long pagenr) |
653 | { | 655 | { |
654 | if (pagenr < 256) | 656 | if (page_is_ram(pagenr)) { |
655 | return 1; | 657 | /* |
656 | if (iomem_is_exclusive(pagenr << PAGE_SHIFT)) | 658 | * For disallowed memory regions in the low 1MB range, |
659 | * request that the page be shown as all zeros. | ||
660 | */ | ||
661 | if (pagenr < 256) | ||
662 | return 2; | ||
663 | |||
664 | return 0; | ||
665 | } | ||
666 | |||
667 | /* | ||
668 | * This must follow RAM test, since System RAM is considered a | ||
669 | * restricted resource under CONFIG_STRICT_IOMEM. | ||
670 | */ | ||
671 | if (iomem_is_exclusive(pagenr << PAGE_SHIFT)) { | ||
672 | /* Low 1MB bypasses iomem restrictions. */ | ||
673 | if (pagenr < 256) | ||
674 | return 1; | ||
675 | |||
657 | return 0; | 676 | return 0; |
658 | if (!page_is_ram(pagenr)) | 677 | } |
659 | return 1; | 678 | |
660 | return 0; | 679 | return 1; |
661 | } | 680 | } |
662 | 681 | ||
663 | void free_init_pages(char *what, unsigned long begin, unsigned long end) | 682 | void free_init_pages(char *what, unsigned long begin, unsigned long end) |
diff --git a/arch/x86/mm/kaslr.c b/arch/x86/mm/kaslr.c index 887e57182716..aed206475aa7 100644 --- a/arch/x86/mm/kaslr.c +++ b/arch/x86/mm/kaslr.c | |||
@@ -48,7 +48,7 @@ static const unsigned long vaddr_start = __PAGE_OFFSET_BASE; | |||
48 | #if defined(CONFIG_X86_ESPFIX64) | 48 | #if defined(CONFIG_X86_ESPFIX64) |
49 | static const unsigned long vaddr_end = ESPFIX_BASE_ADDR; | 49 | static const unsigned long vaddr_end = ESPFIX_BASE_ADDR; |
50 | #elif defined(CONFIG_EFI) | 50 | #elif defined(CONFIG_EFI) |
51 | static const unsigned long vaddr_end = EFI_VA_START; | 51 | static const unsigned long vaddr_end = EFI_VA_END; |
52 | #else | 52 | #else |
53 | static const unsigned long vaddr_end = __START_KERNEL_map; | 53 | static const unsigned long vaddr_end = __START_KERNEL_map; |
54 | #endif | 54 | #endif |
@@ -105,7 +105,7 @@ void __init kernel_randomize_memory(void) | |||
105 | */ | 105 | */ |
106 | BUILD_BUG_ON(vaddr_start >= vaddr_end); | 106 | BUILD_BUG_ON(vaddr_start >= vaddr_end); |
107 | BUILD_BUG_ON(IS_ENABLED(CONFIG_X86_ESPFIX64) && | 107 | BUILD_BUG_ON(IS_ENABLED(CONFIG_X86_ESPFIX64) && |
108 | vaddr_end >= EFI_VA_START); | 108 | vaddr_end >= EFI_VA_END); |
109 | BUILD_BUG_ON((IS_ENABLED(CONFIG_X86_ESPFIX64) || | 109 | BUILD_BUG_ON((IS_ENABLED(CONFIG_X86_ESPFIX64) || |
110 | IS_ENABLED(CONFIG_EFI)) && | 110 | IS_ENABLED(CONFIG_EFI)) && |
111 | vaddr_end >= __START_KERNEL_map); | 111 | vaddr_end >= __START_KERNEL_map); |
diff --git a/arch/x86/platform/efi/quirks.c b/arch/x86/platform/efi/quirks.c index 30031d5293c4..cdfe8c628959 100644 --- a/arch/x86/platform/efi/quirks.c +++ b/arch/x86/platform/efi/quirks.c | |||
@@ -201,6 +201,10 @@ void __init efi_arch_mem_reserve(phys_addr_t addr, u64 size) | |||
201 | return; | 201 | return; |
202 | } | 202 | } |
203 | 203 | ||
204 | /* No need to reserve regions that will never be freed. */ | ||
205 | if (md.attribute & EFI_MEMORY_RUNTIME) | ||
206 | return; | ||
207 | |||
204 | size += addr % EFI_PAGE_SIZE; | 208 | size += addr % EFI_PAGE_SIZE; |
205 | size = round_up(size, EFI_PAGE_SIZE); | 209 | size = round_up(size, EFI_PAGE_SIZE); |
206 | addr = round_down(addr, EFI_PAGE_SIZE); | 210 | addr = round_down(addr, EFI_PAGE_SIZE); |
diff --git a/arch/x86/purgatory/Makefile b/arch/x86/purgatory/Makefile index 555b9fa0ad43..7dbdb780264d 100644 --- a/arch/x86/purgatory/Makefile +++ b/arch/x86/purgatory/Makefile | |||
@@ -8,6 +8,7 @@ PURGATORY_OBJS = $(addprefix $(obj)/,$(purgatory-y)) | |||
8 | LDFLAGS_purgatory.ro := -e purgatory_start -r --no-undefined -nostdlib -z nodefaultlib | 8 | LDFLAGS_purgatory.ro := -e purgatory_start -r --no-undefined -nostdlib -z nodefaultlib |
9 | targets += purgatory.ro | 9 | targets += purgatory.ro |
10 | 10 | ||
11 | KASAN_SANITIZE := n | ||
11 | KCOV_INSTRUMENT := n | 12 | KCOV_INSTRUMENT := n |
12 | 13 | ||
13 | # Default KBUILD_CFLAGS can have -pg option set when FTRACE is enabled. That | 14 | # Default KBUILD_CFLAGS can have -pg option set when FTRACE is enabled. That |
diff --git a/arch/xtensa/include/asm/page.h b/arch/xtensa/include/asm/page.h index 976b1d70edbc..4ddbfd57a7c8 100644 --- a/arch/xtensa/include/asm/page.h +++ b/arch/xtensa/include/asm/page.h | |||
@@ -164,8 +164,21 @@ void copy_user_highpage(struct page *to, struct page *from, | |||
164 | 164 | ||
165 | #define ARCH_PFN_OFFSET (PHYS_OFFSET >> PAGE_SHIFT) | 165 | #define ARCH_PFN_OFFSET (PHYS_OFFSET >> PAGE_SHIFT) |
166 | 166 | ||
167 | #ifdef CONFIG_MMU | ||
168 | static inline unsigned long ___pa(unsigned long va) | ||
169 | { | ||
170 | unsigned long off = va - PAGE_OFFSET; | ||
171 | |||
172 | if (off >= XCHAL_KSEG_SIZE) | ||
173 | off -= XCHAL_KSEG_SIZE; | ||
174 | |||
175 | return off + PHYS_OFFSET; | ||
176 | } | ||
177 | #define __pa(x) ___pa((unsigned long)(x)) | ||
178 | #else | ||
167 | #define __pa(x) \ | 179 | #define __pa(x) \ |
168 | ((unsigned long) (x) - PAGE_OFFSET + PHYS_OFFSET) | 180 | ((unsigned long) (x) - PAGE_OFFSET + PHYS_OFFSET) |
181 | #endif | ||
169 | #define __va(x) \ | 182 | #define __va(x) \ |
170 | ((void *)((unsigned long) (x) - PHYS_OFFSET + PAGE_OFFSET)) | 183 | ((void *)((unsigned long) (x) - PHYS_OFFSET + PAGE_OFFSET)) |
171 | #define pfn_valid(pfn) \ | 184 | #define pfn_valid(pfn) \ |
diff --git a/arch/xtensa/include/uapi/asm/unistd.h b/arch/xtensa/include/uapi/asm/unistd.h index cd400af4a6b2..6be7eb27fd29 100644 --- a/arch/xtensa/include/uapi/asm/unistd.h +++ b/arch/xtensa/include/uapi/asm/unistd.h | |||
@@ -774,7 +774,10 @@ __SYSCALL(349, sys_pkey_alloc, 2) | |||
774 | #define __NR_pkey_free 350 | 774 | #define __NR_pkey_free 350 |
775 | __SYSCALL(350, sys_pkey_free, 1) | 775 | __SYSCALL(350, sys_pkey_free, 1) |
776 | 776 | ||
777 | #define __NR_syscall_count 351 | 777 | #define __NR_statx 351 |
778 | __SYSCALL(351, sys_statx, 5) | ||
779 | |||
780 | #define __NR_syscall_count 352 | ||
778 | 781 | ||
779 | /* | 782 | /* |
780 | * sysxtensa syscall handler | 783 | * sysxtensa syscall handler |
diff --git a/arch/xtensa/kernel/traps.c b/arch/xtensa/kernel/traps.c index c82c43bff296..bae697a06a98 100644 --- a/arch/xtensa/kernel/traps.c +++ b/arch/xtensa/kernel/traps.c | |||
@@ -483,10 +483,8 @@ void show_regs(struct pt_regs * regs) | |||
483 | 483 | ||
484 | static int show_trace_cb(struct stackframe *frame, void *data) | 484 | static int show_trace_cb(struct stackframe *frame, void *data) |
485 | { | 485 | { |
486 | if (kernel_text_address(frame->pc)) { | 486 | if (kernel_text_address(frame->pc)) |
487 | pr_cont(" [<%08lx>]", frame->pc); | 487 | pr_cont(" [<%08lx>] %pB\n", frame->pc, (void *)frame->pc); |
488 | print_symbol(" %s\n", frame->pc); | ||
489 | } | ||
490 | return 0; | 488 | return 0; |
491 | } | 489 | } |
492 | 490 | ||
diff --git a/block/blk-mq.c b/block/blk-mq.c index e6aad49c1686..b75ef2392db7 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c | |||
@@ -2864,8 +2864,17 @@ bool blk_mq_poll(struct request_queue *q, blk_qc_t cookie) | |||
2864 | hctx = q->queue_hw_ctx[blk_qc_t_to_queue_num(cookie)]; | 2864 | hctx = q->queue_hw_ctx[blk_qc_t_to_queue_num(cookie)]; |
2865 | if (!blk_qc_t_is_internal(cookie)) | 2865 | if (!blk_qc_t_is_internal(cookie)) |
2866 | rq = blk_mq_tag_to_rq(hctx->tags, blk_qc_t_to_tag(cookie)); | 2866 | rq = blk_mq_tag_to_rq(hctx->tags, blk_qc_t_to_tag(cookie)); |
2867 | else | 2867 | else { |
2868 | rq = blk_mq_tag_to_rq(hctx->sched_tags, blk_qc_t_to_tag(cookie)); | 2868 | rq = blk_mq_tag_to_rq(hctx->sched_tags, blk_qc_t_to_tag(cookie)); |
2869 | /* | ||
2870 | * With scheduling, if the request has completed, we'll | ||
2871 | * get a NULL return here, as we clear the sched tag when | ||
2872 | * that happens. The request still remains valid, like always, | ||
2873 | * so we should be safe with just the NULL check. | ||
2874 | */ | ||
2875 | if (!rq) | ||
2876 | return false; | ||
2877 | } | ||
2869 | 2878 | ||
2870 | return __blk_mq_poll(hctx, rq); | 2879 | return __blk_mq_poll(hctx, rq); |
2871 | } | 2880 | } |
diff --git a/block/elevator.c b/block/elevator.c index fb50416b5aae..bf11e70f008b 100644 --- a/block/elevator.c +++ b/block/elevator.c | |||
@@ -1101,12 +1101,20 @@ int elevator_change(struct request_queue *q, const char *name) | |||
1101 | } | 1101 | } |
1102 | EXPORT_SYMBOL(elevator_change); | 1102 | EXPORT_SYMBOL(elevator_change); |
1103 | 1103 | ||
1104 | static inline bool elv_support_iosched(struct request_queue *q) | ||
1105 | { | ||
1106 | if (q->mq_ops && q->tag_set && (q->tag_set->flags & | ||
1107 | BLK_MQ_F_NO_SCHED)) | ||
1108 | return false; | ||
1109 | return true; | ||
1110 | } | ||
1111 | |||
1104 | ssize_t elv_iosched_store(struct request_queue *q, const char *name, | 1112 | ssize_t elv_iosched_store(struct request_queue *q, const char *name, |
1105 | size_t count) | 1113 | size_t count) |
1106 | { | 1114 | { |
1107 | int ret; | 1115 | int ret; |
1108 | 1116 | ||
1109 | if (!(q->mq_ops || q->request_fn)) | 1117 | if (!(q->mq_ops || q->request_fn) || !elv_support_iosched(q)) |
1110 | return count; | 1118 | return count; |
1111 | 1119 | ||
1112 | ret = __elevator_change(q, name); | 1120 | ret = __elevator_change(q, name); |
@@ -1138,7 +1146,7 @@ ssize_t elv_iosched_show(struct request_queue *q, char *name) | |||
1138 | len += sprintf(name+len, "[%s] ", elv->elevator_name); | 1146 | len += sprintf(name+len, "[%s] ", elv->elevator_name); |
1139 | continue; | 1147 | continue; |
1140 | } | 1148 | } |
1141 | if (__e->uses_mq && q->mq_ops) | 1149 | if (__e->uses_mq && q->mq_ops && elv_support_iosched(q)) |
1142 | len += sprintf(name+len, "%s ", __e->elevator_name); | 1150 | len += sprintf(name+len, "%s ", __e->elevator_name); |
1143 | else if (!__e->uses_mq && !q->mq_ops) | 1151 | else if (!__e->uses_mq && !q->mq_ops) |
1144 | len += sprintf(name+len, "%s ", __e->elevator_name); | 1152 | len += sprintf(name+len, "%s ", __e->elevator_name); |
diff --git a/crypto/ahash.c b/crypto/ahash.c index e58c4970c22b..826cd7ab4d4a 100644 --- a/crypto/ahash.c +++ b/crypto/ahash.c | |||
@@ -32,6 +32,7 @@ struct ahash_request_priv { | |||
32 | crypto_completion_t complete; | 32 | crypto_completion_t complete; |
33 | void *data; | 33 | void *data; |
34 | u8 *result; | 34 | u8 *result; |
35 | u32 flags; | ||
35 | void *ubuf[] CRYPTO_MINALIGN_ATTR; | 36 | void *ubuf[] CRYPTO_MINALIGN_ATTR; |
36 | }; | 37 | }; |
37 | 38 | ||
@@ -253,6 +254,8 @@ static int ahash_save_req(struct ahash_request *req, crypto_completion_t cplt) | |||
253 | priv->result = req->result; | 254 | priv->result = req->result; |
254 | priv->complete = req->base.complete; | 255 | priv->complete = req->base.complete; |
255 | priv->data = req->base.data; | 256 | priv->data = req->base.data; |
257 | priv->flags = req->base.flags; | ||
258 | |||
256 | /* | 259 | /* |
257 | * WARNING: We do not backup req->priv here! The req->priv | 260 | * WARNING: We do not backup req->priv here! The req->priv |
258 | * is for internal use of the Crypto API and the | 261 | * is for internal use of the Crypto API and the |
@@ -267,38 +270,44 @@ static int ahash_save_req(struct ahash_request *req, crypto_completion_t cplt) | |||
267 | return 0; | 270 | return 0; |
268 | } | 271 | } |
269 | 272 | ||
270 | static void ahash_restore_req(struct ahash_request *req) | 273 | static void ahash_restore_req(struct ahash_request *req, int err) |
271 | { | 274 | { |
272 | struct ahash_request_priv *priv = req->priv; | 275 | struct ahash_request_priv *priv = req->priv; |
273 | 276 | ||
277 | if (!err) | ||
278 | memcpy(priv->result, req->result, | ||
279 | crypto_ahash_digestsize(crypto_ahash_reqtfm(req))); | ||
280 | |||
274 | /* Restore the original crypto request. */ | 281 | /* Restore the original crypto request. */ |
275 | req->result = priv->result; | 282 | req->result = priv->result; |
276 | req->base.complete = priv->complete; | 283 | |
277 | req->base.data = priv->data; | 284 | ahash_request_set_callback(req, priv->flags, |
285 | priv->complete, priv->data); | ||
278 | req->priv = NULL; | 286 | req->priv = NULL; |
279 | 287 | ||
280 | /* Free the req->priv.priv from the ADJUSTED request. */ | 288 | /* Free the req->priv.priv from the ADJUSTED request. */ |
281 | kzfree(priv); | 289 | kzfree(priv); |
282 | } | 290 | } |
283 | 291 | ||
284 | static void ahash_op_unaligned_finish(struct ahash_request *req, int err) | 292 | static void ahash_notify_einprogress(struct ahash_request *req) |
285 | { | 293 | { |
286 | struct ahash_request_priv *priv = req->priv; | 294 | struct ahash_request_priv *priv = req->priv; |
295 | struct crypto_async_request oreq; | ||
287 | 296 | ||
288 | if (err == -EINPROGRESS) | 297 | oreq.data = priv->data; |
289 | return; | ||
290 | |||
291 | if (!err) | ||
292 | memcpy(priv->result, req->result, | ||
293 | crypto_ahash_digestsize(crypto_ahash_reqtfm(req))); | ||
294 | 298 | ||
295 | ahash_restore_req(req); | 299 | priv->complete(&oreq, -EINPROGRESS); |
296 | } | 300 | } |
297 | 301 | ||
298 | static void ahash_op_unaligned_done(struct crypto_async_request *req, int err) | 302 | static void ahash_op_unaligned_done(struct crypto_async_request *req, int err) |
299 | { | 303 | { |
300 | struct ahash_request *areq = req->data; | 304 | struct ahash_request *areq = req->data; |
301 | 305 | ||
306 | if (err == -EINPROGRESS) { | ||
307 | ahash_notify_einprogress(areq); | ||
308 | return; | ||
309 | } | ||
310 | |||
302 | /* | 311 | /* |
303 | * Restore the original request, see ahash_op_unaligned() for what | 312 | * Restore the original request, see ahash_op_unaligned() for what |
304 | * goes where. | 313 | * goes where. |
@@ -309,7 +318,7 @@ static void ahash_op_unaligned_done(struct crypto_async_request *req, int err) | |||
309 | */ | 318 | */ |
310 | 319 | ||
311 | /* First copy req->result into req->priv.result */ | 320 | /* First copy req->result into req->priv.result */ |
312 | ahash_op_unaligned_finish(areq, err); | 321 | ahash_restore_req(areq, err); |
313 | 322 | ||
314 | /* Complete the ORIGINAL request. */ | 323 | /* Complete the ORIGINAL request. */ |
315 | areq->base.complete(&areq->base, err); | 324 | areq->base.complete(&areq->base, err); |
@@ -325,7 +334,12 @@ static int ahash_op_unaligned(struct ahash_request *req, | |||
325 | return err; | 334 | return err; |
326 | 335 | ||
327 | err = op(req); | 336 | err = op(req); |
328 | ahash_op_unaligned_finish(req, err); | 337 | if (err == -EINPROGRESS || |
338 | (err == -EBUSY && (ahash_request_flags(req) & | ||
339 | CRYPTO_TFM_REQ_MAY_BACKLOG))) | ||
340 | return err; | ||
341 | |||
342 | ahash_restore_req(req, err); | ||
329 | 343 | ||
330 | return err; | 344 | return err; |
331 | } | 345 | } |
@@ -360,25 +374,14 @@ int crypto_ahash_digest(struct ahash_request *req) | |||
360 | } | 374 | } |
361 | EXPORT_SYMBOL_GPL(crypto_ahash_digest); | 375 | EXPORT_SYMBOL_GPL(crypto_ahash_digest); |
362 | 376 | ||
363 | static void ahash_def_finup_finish2(struct ahash_request *req, int err) | 377 | static void ahash_def_finup_done2(struct crypto_async_request *req, int err) |
364 | { | 378 | { |
365 | struct ahash_request_priv *priv = req->priv; | 379 | struct ahash_request *areq = req->data; |
366 | 380 | ||
367 | if (err == -EINPROGRESS) | 381 | if (err == -EINPROGRESS) |
368 | return; | 382 | return; |
369 | 383 | ||
370 | if (!err) | 384 | ahash_restore_req(areq, err); |
371 | memcpy(priv->result, req->result, | ||
372 | crypto_ahash_digestsize(crypto_ahash_reqtfm(req))); | ||
373 | |||
374 | ahash_restore_req(req); | ||
375 | } | ||
376 | |||
377 | static void ahash_def_finup_done2(struct crypto_async_request *req, int err) | ||
378 | { | ||
379 | struct ahash_request *areq = req->data; | ||
380 | |||
381 | ahash_def_finup_finish2(areq, err); | ||
382 | 385 | ||
383 | areq->base.complete(&areq->base, err); | 386 | areq->base.complete(&areq->base, err); |
384 | } | 387 | } |
@@ -389,11 +392,15 @@ static int ahash_def_finup_finish1(struct ahash_request *req, int err) | |||
389 | goto out; | 392 | goto out; |
390 | 393 | ||
391 | req->base.complete = ahash_def_finup_done2; | 394 | req->base.complete = ahash_def_finup_done2; |
392 | req->base.flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP; | 395 | |
393 | err = crypto_ahash_reqtfm(req)->final(req); | 396 | err = crypto_ahash_reqtfm(req)->final(req); |
397 | if (err == -EINPROGRESS || | ||
398 | (err == -EBUSY && (ahash_request_flags(req) & | ||
399 | CRYPTO_TFM_REQ_MAY_BACKLOG))) | ||
400 | return err; | ||
394 | 401 | ||
395 | out: | 402 | out: |
396 | ahash_def_finup_finish2(req, err); | 403 | ahash_restore_req(req, err); |
397 | return err; | 404 | return err; |
398 | } | 405 | } |
399 | 406 | ||
@@ -401,7 +408,16 @@ static void ahash_def_finup_done1(struct crypto_async_request *req, int err) | |||
401 | { | 408 | { |
402 | struct ahash_request *areq = req->data; | 409 | struct ahash_request *areq = req->data; |
403 | 410 | ||
411 | if (err == -EINPROGRESS) { | ||
412 | ahash_notify_einprogress(areq); | ||
413 | return; | ||
414 | } | ||
415 | |||
416 | areq->base.flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP; | ||
417 | |||
404 | err = ahash_def_finup_finish1(areq, err); | 418 | err = ahash_def_finup_finish1(areq, err); |
419 | if (areq->priv) | ||
420 | return; | ||
405 | 421 | ||
406 | areq->base.complete(&areq->base, err); | 422 | areq->base.complete(&areq->base, err); |
407 | } | 423 | } |
@@ -416,6 +432,11 @@ static int ahash_def_finup(struct ahash_request *req) | |||
416 | return err; | 432 | return err; |
417 | 433 | ||
418 | err = tfm->update(req); | 434 | err = tfm->update(req); |
435 | if (err == -EINPROGRESS || | ||
436 | (err == -EBUSY && (ahash_request_flags(req) & | ||
437 | CRYPTO_TFM_REQ_MAY_BACKLOG))) | ||
438 | return err; | ||
439 | |||
419 | return ahash_def_finup_finish1(req, err); | 440 | return ahash_def_finup_finish1(req, err); |
420 | } | 441 | } |
421 | 442 | ||
diff --git a/crypto/algif_aead.c b/crypto/algif_aead.c index 5a8053758657..ef59d9926ee9 100644 --- a/crypto/algif_aead.c +++ b/crypto/algif_aead.c | |||
@@ -40,6 +40,7 @@ struct aead_async_req { | |||
40 | struct aead_async_rsgl first_rsgl; | 40 | struct aead_async_rsgl first_rsgl; |
41 | struct list_head list; | 41 | struct list_head list; |
42 | struct kiocb *iocb; | 42 | struct kiocb *iocb; |
43 | struct sock *sk; | ||
43 | unsigned int tsgls; | 44 | unsigned int tsgls; |
44 | char iv[]; | 45 | char iv[]; |
45 | }; | 46 | }; |
@@ -379,12 +380,10 @@ unlock: | |||
379 | 380 | ||
380 | static void aead_async_cb(struct crypto_async_request *_req, int err) | 381 | static void aead_async_cb(struct crypto_async_request *_req, int err) |
381 | { | 382 | { |
382 | struct sock *sk = _req->data; | 383 | struct aead_request *req = _req->data; |
383 | struct alg_sock *ask = alg_sk(sk); | 384 | struct crypto_aead *tfm = crypto_aead_reqtfm(req); |
384 | struct aead_ctx *ctx = ask->private; | ||
385 | struct crypto_aead *tfm = crypto_aead_reqtfm(&ctx->aead_req); | ||
386 | struct aead_request *req = aead_request_cast(_req); | ||
387 | struct aead_async_req *areq = GET_ASYM_REQ(req, tfm); | 385 | struct aead_async_req *areq = GET_ASYM_REQ(req, tfm); |
386 | struct sock *sk = areq->sk; | ||
388 | struct scatterlist *sg = areq->tsgl; | 387 | struct scatterlist *sg = areq->tsgl; |
389 | struct aead_async_rsgl *rsgl; | 388 | struct aead_async_rsgl *rsgl; |
390 | struct kiocb *iocb = areq->iocb; | 389 | struct kiocb *iocb = areq->iocb; |
@@ -447,11 +446,12 @@ static int aead_recvmsg_async(struct socket *sock, struct msghdr *msg, | |||
447 | memset(&areq->first_rsgl, '\0', sizeof(areq->first_rsgl)); | 446 | memset(&areq->first_rsgl, '\0', sizeof(areq->first_rsgl)); |
448 | INIT_LIST_HEAD(&areq->list); | 447 | INIT_LIST_HEAD(&areq->list); |
449 | areq->iocb = msg->msg_iocb; | 448 | areq->iocb = msg->msg_iocb; |
449 | areq->sk = sk; | ||
450 | memcpy(areq->iv, ctx->iv, crypto_aead_ivsize(tfm)); | 450 | memcpy(areq->iv, ctx->iv, crypto_aead_ivsize(tfm)); |
451 | aead_request_set_tfm(req, tfm); | 451 | aead_request_set_tfm(req, tfm); |
452 | aead_request_set_ad(req, ctx->aead_assoclen); | 452 | aead_request_set_ad(req, ctx->aead_assoclen); |
453 | aead_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, | 453 | aead_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, |
454 | aead_async_cb, sk); | 454 | aead_async_cb, req); |
455 | used -= ctx->aead_assoclen; | 455 | used -= ctx->aead_assoclen; |
456 | 456 | ||
457 | /* take over all tx sgls from ctx */ | 457 | /* take over all tx sgls from ctx */ |
diff --git a/crypto/lrw.c b/crypto/lrw.c index ecd8474018e3..a8bfae4451bf 100644 --- a/crypto/lrw.c +++ b/crypto/lrw.c | |||
@@ -286,8 +286,11 @@ static int init_crypt(struct skcipher_request *req, crypto_completion_t done) | |||
286 | 286 | ||
287 | subreq->cryptlen = LRW_BUFFER_SIZE; | 287 | subreq->cryptlen = LRW_BUFFER_SIZE; |
288 | if (req->cryptlen > LRW_BUFFER_SIZE) { | 288 | if (req->cryptlen > LRW_BUFFER_SIZE) { |
289 | subreq->cryptlen = min(req->cryptlen, (unsigned)PAGE_SIZE); | 289 | unsigned int n = min(req->cryptlen, (unsigned int)PAGE_SIZE); |
290 | rctx->ext = kmalloc(subreq->cryptlen, gfp); | 290 | |
291 | rctx->ext = kmalloc(n, gfp); | ||
292 | if (rctx->ext) | ||
293 | subreq->cryptlen = n; | ||
291 | } | 294 | } |
292 | 295 | ||
293 | rctx->src = req->src; | 296 | rctx->src = req->src; |
@@ -342,6 +345,13 @@ static void encrypt_done(struct crypto_async_request *areq, int err) | |||
342 | struct rctx *rctx; | 345 | struct rctx *rctx; |
343 | 346 | ||
344 | rctx = skcipher_request_ctx(req); | 347 | rctx = skcipher_request_ctx(req); |
348 | |||
349 | if (err == -EINPROGRESS) { | ||
350 | if (rctx->left != req->cryptlen) | ||
351 | return; | ||
352 | goto out; | ||
353 | } | ||
354 | |||
345 | subreq = &rctx->subreq; | 355 | subreq = &rctx->subreq; |
346 | subreq->base.flags &= CRYPTO_TFM_REQ_MAY_BACKLOG; | 356 | subreq->base.flags &= CRYPTO_TFM_REQ_MAY_BACKLOG; |
347 | 357 | ||
@@ -349,6 +359,7 @@ static void encrypt_done(struct crypto_async_request *areq, int err) | |||
349 | if (rctx->left) | 359 | if (rctx->left) |
350 | return; | 360 | return; |
351 | 361 | ||
362 | out: | ||
352 | skcipher_request_complete(req, err); | 363 | skcipher_request_complete(req, err); |
353 | } | 364 | } |
354 | 365 | ||
@@ -386,6 +397,13 @@ static void decrypt_done(struct crypto_async_request *areq, int err) | |||
386 | struct rctx *rctx; | 397 | struct rctx *rctx; |
387 | 398 | ||
388 | rctx = skcipher_request_ctx(req); | 399 | rctx = skcipher_request_ctx(req); |
400 | |||
401 | if (err == -EINPROGRESS) { | ||
402 | if (rctx->left != req->cryptlen) | ||
403 | return; | ||
404 | goto out; | ||
405 | } | ||
406 | |||
389 | subreq = &rctx->subreq; | 407 | subreq = &rctx->subreq; |
390 | subreq->base.flags &= CRYPTO_TFM_REQ_MAY_BACKLOG; | 408 | subreq->base.flags &= CRYPTO_TFM_REQ_MAY_BACKLOG; |
391 | 409 | ||
@@ -393,6 +411,7 @@ static void decrypt_done(struct crypto_async_request *areq, int err) | |||
393 | if (rctx->left) | 411 | if (rctx->left) |
394 | return; | 412 | return; |
395 | 413 | ||
414 | out: | ||
396 | skcipher_request_complete(req, err); | 415 | skcipher_request_complete(req, err); |
397 | } | 416 | } |
398 | 417 | ||
diff --git a/crypto/xts.c b/crypto/xts.c index baeb34dd8582..89ace5ebc2da 100644 --- a/crypto/xts.c +++ b/crypto/xts.c | |||
@@ -230,8 +230,11 @@ static int init_crypt(struct skcipher_request *req, crypto_completion_t done) | |||
230 | 230 | ||
231 | subreq->cryptlen = XTS_BUFFER_SIZE; | 231 | subreq->cryptlen = XTS_BUFFER_SIZE; |
232 | if (req->cryptlen > XTS_BUFFER_SIZE) { | 232 | if (req->cryptlen > XTS_BUFFER_SIZE) { |
233 | subreq->cryptlen = min(req->cryptlen, (unsigned)PAGE_SIZE); | 233 | unsigned int n = min(req->cryptlen, (unsigned int)PAGE_SIZE); |
234 | rctx->ext = kmalloc(subreq->cryptlen, gfp); | 234 | |
235 | rctx->ext = kmalloc(n, gfp); | ||
236 | if (rctx->ext) | ||
237 | subreq->cryptlen = n; | ||
235 | } | 238 | } |
236 | 239 | ||
237 | rctx->src = req->src; | 240 | rctx->src = req->src; |
@@ -283,6 +286,13 @@ static void encrypt_done(struct crypto_async_request *areq, int err) | |||
283 | struct rctx *rctx; | 286 | struct rctx *rctx; |
284 | 287 | ||
285 | rctx = skcipher_request_ctx(req); | 288 | rctx = skcipher_request_ctx(req); |
289 | |||
290 | if (err == -EINPROGRESS) { | ||
291 | if (rctx->left != req->cryptlen) | ||
292 | return; | ||
293 | goto out; | ||
294 | } | ||
295 | |||
286 | subreq = &rctx->subreq; | 296 | subreq = &rctx->subreq; |
287 | subreq->base.flags &= CRYPTO_TFM_REQ_MAY_BACKLOG; | 297 | subreq->base.flags &= CRYPTO_TFM_REQ_MAY_BACKLOG; |
288 | 298 | ||
@@ -290,6 +300,7 @@ static void encrypt_done(struct crypto_async_request *areq, int err) | |||
290 | if (rctx->left) | 300 | if (rctx->left) |
291 | return; | 301 | return; |
292 | 302 | ||
303 | out: | ||
293 | skcipher_request_complete(req, err); | 304 | skcipher_request_complete(req, err); |
294 | } | 305 | } |
295 | 306 | ||
@@ -327,6 +338,13 @@ static void decrypt_done(struct crypto_async_request *areq, int err) | |||
327 | struct rctx *rctx; | 338 | struct rctx *rctx; |
328 | 339 | ||
329 | rctx = skcipher_request_ctx(req); | 340 | rctx = skcipher_request_ctx(req); |
341 | |||
342 | if (err == -EINPROGRESS) { | ||
343 | if (rctx->left != req->cryptlen) | ||
344 | return; | ||
345 | goto out; | ||
346 | } | ||
347 | |||
330 | subreq = &rctx->subreq; | 348 | subreq = &rctx->subreq; |
331 | subreq->base.flags &= CRYPTO_TFM_REQ_MAY_BACKLOG; | 349 | subreq->base.flags &= CRYPTO_TFM_REQ_MAY_BACKLOG; |
332 | 350 | ||
@@ -334,6 +352,7 @@ static void decrypt_done(struct crypto_async_request *areq, int err) | |||
334 | if (rctx->left) | 352 | if (rctx->left) |
335 | return; | 353 | return; |
336 | 354 | ||
355 | out: | ||
337 | skcipher_request_complete(req, err); | 356 | skcipher_request_complete(req, err); |
338 | } | 357 | } |
339 | 358 | ||
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile index a391bbc48105..d94f92f88ca1 100644 --- a/drivers/acpi/Makefile +++ b/drivers/acpi/Makefile | |||
@@ -2,7 +2,6 @@ | |||
2 | # Makefile for the Linux ACPI interpreter | 2 | # Makefile for the Linux ACPI interpreter |
3 | # | 3 | # |
4 | 4 | ||
5 | ccflags-y := -Os | ||
6 | ccflags-$(CONFIG_ACPI_DEBUG) += -DACPI_DEBUG_OUTPUT | 5 | ccflags-$(CONFIG_ACPI_DEBUG) += -DACPI_DEBUG_OUTPUT |
7 | 6 | ||
8 | # | 7 | # |
diff --git a/drivers/acpi/acpi_platform.c b/drivers/acpi/acpi_platform.c index b4c1a6a51da4..03250e1f1103 100644 --- a/drivers/acpi/acpi_platform.c +++ b/drivers/acpi/acpi_platform.c | |||
@@ -25,9 +25,11 @@ | |||
25 | ACPI_MODULE_NAME("platform"); | 25 | ACPI_MODULE_NAME("platform"); |
26 | 26 | ||
27 | static const struct acpi_device_id forbidden_id_list[] = { | 27 | static const struct acpi_device_id forbidden_id_list[] = { |
28 | {"PNP0000", 0}, /* PIC */ | 28 | {"PNP0000", 0}, /* PIC */ |
29 | {"PNP0100", 0}, /* Timer */ | 29 | {"PNP0100", 0}, /* Timer */ |
30 | {"PNP0200", 0}, /* AT DMA Controller */ | 30 | {"PNP0200", 0}, /* AT DMA Controller */ |
31 | {"ACPI0009", 0}, /* IOxAPIC */ | ||
32 | {"ACPI000A", 0}, /* IOAPIC */ | ||
31 | {"", 0}, | 33 | {"", 0}, |
32 | }; | 34 | }; |
33 | 35 | ||
diff --git a/drivers/acpi/acpica/utresrc.c b/drivers/acpi/acpica/utresrc.c index c86bae7b1d0f..ff096d9755b9 100644 --- a/drivers/acpi/acpica/utresrc.c +++ b/drivers/acpi/acpica/utresrc.c | |||
@@ -421,10 +421,8 @@ acpi_ut_walk_aml_resources(struct acpi_walk_state *walk_state, | |||
421 | 421 | ||
422 | ACPI_FUNCTION_TRACE(ut_walk_aml_resources); | 422 | ACPI_FUNCTION_TRACE(ut_walk_aml_resources); |
423 | 423 | ||
424 | /* | 424 | /* The absolute minimum resource template is one end_tag descriptor */ |
425 | * The absolute minimum resource template is one end_tag descriptor. | 425 | |
426 | * However, we will treat a lone end_tag as just a simple buffer. | ||
427 | */ | ||
428 | if (aml_length < sizeof(struct aml_resource_end_tag)) { | 426 | if (aml_length < sizeof(struct aml_resource_end_tag)) { |
429 | return_ACPI_STATUS(AE_AML_NO_RESOURCE_END_TAG); | 427 | return_ACPI_STATUS(AE_AML_NO_RESOURCE_END_TAG); |
430 | } | 428 | } |
@@ -456,8 +454,9 @@ acpi_ut_walk_aml_resources(struct acpi_walk_state *walk_state, | |||
456 | /* Invoke the user function */ | 454 | /* Invoke the user function */ |
457 | 455 | ||
458 | if (user_function) { | 456 | if (user_function) { |
459 | status = user_function(aml, length, offset, | 457 | status = |
460 | resource_index, context); | 458 | user_function(aml, length, offset, resource_index, |
459 | context); | ||
461 | if (ACPI_FAILURE(status)) { | 460 | if (ACPI_FAILURE(status)) { |
462 | return_ACPI_STATUS(status); | 461 | return_ACPI_STATUS(status); |
463 | } | 462 | } |
@@ -481,12 +480,6 @@ acpi_ut_walk_aml_resources(struct acpi_walk_state *walk_state, | |||
481 | *context = aml; | 480 | *context = aml; |
482 | } | 481 | } |
483 | 482 | ||
484 | /* Check if buffer is defined to be longer than the resource length */ | ||
485 | |||
486 | if (aml_length > (offset + length)) { | ||
487 | return_ACPI_STATUS(AE_AML_NO_RESOURCE_END_TAG); | ||
488 | } | ||
489 | |||
490 | /* Normal exit */ | 483 | /* Normal exit */ |
491 | 484 | ||
492 | return_ACPI_STATUS(AE_OK); | 485 | return_ACPI_STATUS(AE_OK); |
diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c index b192b42a8351..79b3c9c5a3bc 100644 --- a/drivers/acpi/apei/ghes.c +++ b/drivers/acpi/apei/ghes.c | |||
@@ -1073,6 +1073,7 @@ static int ghes_remove(struct platform_device *ghes_dev) | |||
1073 | if (list_empty(&ghes_sci)) | 1073 | if (list_empty(&ghes_sci)) |
1074 | unregister_acpi_hed_notifier(&ghes_notifier_sci); | 1074 | unregister_acpi_hed_notifier(&ghes_notifier_sci); |
1075 | mutex_unlock(&ghes_list_mutex); | 1075 | mutex_unlock(&ghes_list_mutex); |
1076 | synchronize_rcu(); | ||
1076 | break; | 1077 | break; |
1077 | case ACPI_HEST_NOTIFY_NMI: | 1078 | case ACPI_HEST_NOTIFY_NMI: |
1078 | ghes_nmi_remove(ghes); | 1079 | ghes_nmi_remove(ghes); |
diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c index fb19e1cdb641..edc8663b5db3 100644 --- a/drivers/acpi/glue.c +++ b/drivers/acpi/glue.c | |||
@@ -99,13 +99,13 @@ static int find_child_checks(struct acpi_device *adev, bool check_children) | |||
99 | return -ENODEV; | 99 | return -ENODEV; |
100 | 100 | ||
101 | /* | 101 | /* |
102 | * If the device has a _HID (or _CID) returning a valid ACPI/PNP | 102 | * If the device has a _HID returning a valid ACPI/PNP device ID, it is |
103 | * device ID, it is better to make it look less attractive here, so that | 103 | * better to make it look less attractive here, so that the other device |
104 | * the other device with the same _ADR value (that may not have a valid | 104 | * with the same _ADR value (that may not have a valid device ID) can be |
105 | * device ID) can be matched going forward. [This means a second spec | 105 | * matched going forward. [This means a second spec violation in a row, |
106 | * violation in a row, so whatever we do here is best effort anyway.] | 106 | * so whatever we do here is best effort anyway.] |
107 | */ | 107 | */ |
108 | return sta_present && list_empty(&adev->pnp.ids) ? | 108 | return sta_present && !adev->pnp.type.platform_id ? |
109 | FIND_CHILD_MAX_SCORE : FIND_CHILD_MIN_SCORE; | 109 | FIND_CHILD_MAX_SCORE : FIND_CHILD_MIN_SCORE; |
110 | } | 110 | } |
111 | 111 | ||
diff --git a/drivers/acpi/ioapic.c b/drivers/acpi/ioapic.c index 1120dfd625b8..7e4fbf9a53a3 100644 --- a/drivers/acpi/ioapic.c +++ b/drivers/acpi/ioapic.c | |||
@@ -45,6 +45,12 @@ static acpi_status setup_res(struct acpi_resource *acpi_res, void *data) | |||
45 | struct resource *res = data; | 45 | struct resource *res = data; |
46 | struct resource_win win; | 46 | struct resource_win win; |
47 | 47 | ||
48 | /* | ||
49 | * We might assign this to 'res' later, make sure all pointers are | ||
50 | * cleared before the resource is added to the global list | ||
51 | */ | ||
52 | memset(&win, 0, sizeof(win)); | ||
53 | |||
48 | res->flags = 0; | 54 | res->flags = 0; |
49 | if (acpi_dev_filter_resource_type(acpi_res, IORESOURCE_MEM)) | 55 | if (acpi_dev_filter_resource_type(acpi_res, IORESOURCE_MEM)) |
50 | return AE_OK; | 56 | return AE_OK; |
diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c index 662036bdc65e..c8ea9d698cd0 100644 --- a/drivers/acpi/nfit/core.c +++ b/drivers/acpi/nfit/core.c | |||
@@ -1617,7 +1617,11 @@ static int cmp_map(const void *m0, const void *m1) | |||
1617 | const struct nfit_set_info_map *map0 = m0; | 1617 | const struct nfit_set_info_map *map0 = m0; |
1618 | const struct nfit_set_info_map *map1 = m1; | 1618 | const struct nfit_set_info_map *map1 = m1; |
1619 | 1619 | ||
1620 | return map0->region_offset - map1->region_offset; | 1620 | if (map0->region_offset < map1->region_offset) |
1621 | return -1; | ||
1622 | else if (map0->region_offset > map1->region_offset) | ||
1623 | return 1; | ||
1624 | return 0; | ||
1621 | } | 1625 | } |
1622 | 1626 | ||
1623 | /* Retrieve the nth entry referencing this spa */ | 1627 | /* Retrieve the nth entry referencing this spa */ |
diff --git a/drivers/acpi/power.c b/drivers/acpi/power.c index fcd4ce6f78d5..1c2b846c5776 100644 --- a/drivers/acpi/power.c +++ b/drivers/acpi/power.c | |||
@@ -200,6 +200,7 @@ static int acpi_power_get_list_state(struct list_head *list, int *state) | |||
200 | return -EINVAL; | 200 | return -EINVAL; |
201 | 201 | ||
202 | /* The state of the list is 'on' IFF all resources are 'on'. */ | 202 | /* The state of the list is 'on' IFF all resources are 'on'. */ |
203 | cur_state = 0; | ||
203 | list_for_each_entry(entry, list, node) { | 204 | list_for_each_entry(entry, list, node) { |
204 | struct acpi_power_resource *resource = entry->resource; | 205 | struct acpi_power_resource *resource = entry->resource; |
205 | acpi_handle handle = resource->device.handle; | 206 | acpi_handle handle = resource->device.handle; |
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 192691880d55..2433569b02ef 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c | |||
@@ -1857,15 +1857,20 @@ static void acpi_bus_attach(struct acpi_device *device) | |||
1857 | return; | 1857 | return; |
1858 | 1858 | ||
1859 | device->flags.match_driver = true; | 1859 | device->flags.match_driver = true; |
1860 | if (!ret) { | 1860 | if (ret > 0) { |
1861 | ret = device_attach(&device->dev); | 1861 | acpi_device_set_enumerated(device); |
1862 | if (ret < 0) | 1862 | goto ok; |
1863 | return; | ||
1864 | |||
1865 | if (!ret && device->pnp.type.platform_id) | ||
1866 | acpi_default_enumeration(device); | ||
1867 | } | 1863 | } |
1868 | 1864 | ||
1865 | ret = device_attach(&device->dev); | ||
1866 | if (ret < 0) | ||
1867 | return; | ||
1868 | |||
1869 | if (ret > 0 || !device->pnp.type.platform_id) | ||
1870 | acpi_device_set_enumerated(device); | ||
1871 | else | ||
1872 | acpi_default_enumeration(device); | ||
1873 | |||
1869 | ok: | 1874 | ok: |
1870 | list_for_each_entry(child, &device->children, node) | 1875 | list_for_each_entry(child, &device->children, node) |
1871 | acpi_bus_attach(child); | 1876 | acpi_bus_attach(child); |
diff --git a/drivers/ata/pata_atiixp.c b/drivers/ata/pata_atiixp.c index 6c9aa95a9a05..49d705c9f0f7 100644 --- a/drivers/ata/pata_atiixp.c +++ b/drivers/ata/pata_atiixp.c | |||
@@ -278,11 +278,6 @@ static int atiixp_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
278 | }; | 278 | }; |
279 | const struct ata_port_info *ppi[] = { &info, &info }; | 279 | const struct ata_port_info *ppi[] = { &info, &info }; |
280 | 280 | ||
281 | /* SB600/700 don't have secondary port wired */ | ||
282 | if ((pdev->device == PCI_DEVICE_ID_ATI_IXP600_IDE) || | ||
283 | (pdev->device == PCI_DEVICE_ID_ATI_IXP700_IDE)) | ||
284 | ppi[1] = &ata_dummy_port_info; | ||
285 | |||
286 | return ata_pci_bmdma_init_one(pdev, ppi, &atiixp_sht, NULL, | 281 | return ata_pci_bmdma_init_one(pdev, ppi, &atiixp_sht, NULL, |
287 | ATA_HOST_PARALLEL_SCAN); | 282 | ATA_HOST_PARALLEL_SCAN); |
288 | } | 283 | } |
diff --git a/drivers/ata/sata_via.c b/drivers/ata/sata_via.c index 0636d84fbefe..f3f538eec7b3 100644 --- a/drivers/ata/sata_via.c +++ b/drivers/ata/sata_via.c | |||
@@ -644,14 +644,16 @@ static void svia_configure(struct pci_dev *pdev, int board_id, | |||
644 | pci_write_config_byte(pdev, SATA_NATIVE_MODE, tmp8); | 644 | pci_write_config_byte(pdev, SATA_NATIVE_MODE, tmp8); |
645 | } | 645 | } |
646 | 646 | ||
647 | /* enable IRQ on hotplug */ | 647 | if (board_id == vt6421) { |
648 | pci_read_config_byte(pdev, SVIA_MISC_3, &tmp8); | 648 | /* enable IRQ on hotplug */ |
649 | if ((tmp8 & SATA_HOTPLUG) != SATA_HOTPLUG) { | 649 | pci_read_config_byte(pdev, SVIA_MISC_3, &tmp8); |
650 | dev_dbg(&pdev->dev, | 650 | if ((tmp8 & SATA_HOTPLUG) != SATA_HOTPLUG) { |
651 | "enabling SATA hotplug (0x%x)\n", | 651 | dev_dbg(&pdev->dev, |
652 | (int) tmp8); | 652 | "enabling SATA hotplug (0x%x)\n", |
653 | tmp8 |= SATA_HOTPLUG; | 653 | (int) tmp8); |
654 | pci_write_config_byte(pdev, SVIA_MISC_3, tmp8); | 654 | tmp8 |= SATA_HOTPLUG; |
655 | pci_write_config_byte(pdev, SVIA_MISC_3, tmp8); | ||
656 | } | ||
655 | } | 657 | } |
656 | 658 | ||
657 | /* | 659 | /* |
diff --git a/drivers/block/mtip32xx/mtip32xx.c b/drivers/block/mtip32xx/mtip32xx.c index 54c8736038de..eba8bcd677fa 100644 --- a/drivers/block/mtip32xx/mtip32xx.c +++ b/drivers/block/mtip32xx/mtip32xx.c | |||
@@ -3970,7 +3970,7 @@ static int mtip_block_initialize(struct driver_data *dd) | |||
3970 | dd->tags.reserved_tags = 1; | 3970 | dd->tags.reserved_tags = 1; |
3971 | dd->tags.cmd_size = sizeof(struct mtip_cmd); | 3971 | dd->tags.cmd_size = sizeof(struct mtip_cmd); |
3972 | dd->tags.numa_node = dd->numa_node; | 3972 | dd->tags.numa_node = dd->numa_node; |
3973 | dd->tags.flags = BLK_MQ_F_SHOULD_MERGE; | 3973 | dd->tags.flags = BLK_MQ_F_SHOULD_MERGE | BLK_MQ_F_NO_SCHED; |
3974 | dd->tags.driver_data = dd; | 3974 | dd->tags.driver_data = dd; |
3975 | dd->tags.timeout = MTIP_NCQ_CMD_TIMEOUT_MS; | 3975 | dd->tags.timeout = MTIP_NCQ_CMD_TIMEOUT_MS; |
3976 | 3976 | ||
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c index 1710b06f04a7..6fac5fedd610 100644 --- a/drivers/block/zram/zram_drv.c +++ b/drivers/block/zram/zram_drv.c | |||
@@ -523,7 +523,7 @@ static int zram_decompress_page(struct zram *zram, char *mem, u32 index) | |||
523 | 523 | ||
524 | cmem = zs_map_object(meta->mem_pool, handle, ZS_MM_RO); | 524 | cmem = zs_map_object(meta->mem_pool, handle, ZS_MM_RO); |
525 | if (size == PAGE_SIZE) { | 525 | if (size == PAGE_SIZE) { |
526 | copy_page(mem, cmem); | 526 | memcpy(mem, cmem, PAGE_SIZE); |
527 | } else { | 527 | } else { |
528 | struct zcomp_strm *zstrm = zcomp_stream_get(zram->comp); | 528 | struct zcomp_strm *zstrm = zcomp_stream_get(zram->comp); |
529 | 529 | ||
@@ -717,7 +717,7 @@ compress_again: | |||
717 | 717 | ||
718 | if ((clen == PAGE_SIZE) && !is_partial_io(bvec)) { | 718 | if ((clen == PAGE_SIZE) && !is_partial_io(bvec)) { |
719 | src = kmap_atomic(page); | 719 | src = kmap_atomic(page); |
720 | copy_page(cmem, src); | 720 | memcpy(cmem, src, PAGE_SIZE); |
721 | kunmap_atomic(src); | 721 | kunmap_atomic(src); |
722 | } else { | 722 | } else { |
723 | memcpy(cmem, src, clen); | 723 | memcpy(cmem, src, clen); |
@@ -932,7 +932,7 @@ static int zram_rw_page(struct block_device *bdev, sector_t sector, | |||
932 | } | 932 | } |
933 | 933 | ||
934 | index = sector >> SECTORS_PER_PAGE_SHIFT; | 934 | index = sector >> SECTORS_PER_PAGE_SHIFT; |
935 | offset = sector & (SECTORS_PER_PAGE - 1) << SECTOR_SHIFT; | 935 | offset = (sector & (SECTORS_PER_PAGE - 1)) << SECTOR_SHIFT; |
936 | 936 | ||
937 | bv.bv_page = page; | 937 | bv.bv_page = page; |
938 | bv.bv_len = PAGE_SIZE; | 938 | bv.bv_len = PAGE_SIZE; |
diff --git a/drivers/char/mem.c b/drivers/char/mem.c index 6d9cc2d39d22..7e4a9d1296bb 100644 --- a/drivers/char/mem.c +++ b/drivers/char/mem.c | |||
@@ -60,6 +60,10 @@ static inline int valid_mmap_phys_addr_range(unsigned long pfn, size_t size) | |||
60 | #endif | 60 | #endif |
61 | 61 | ||
62 | #ifdef CONFIG_STRICT_DEVMEM | 62 | #ifdef CONFIG_STRICT_DEVMEM |
63 | static inline int page_is_allowed(unsigned long pfn) | ||
64 | { | ||
65 | return devmem_is_allowed(pfn); | ||
66 | } | ||
63 | static inline int range_is_allowed(unsigned long pfn, unsigned long size) | 67 | static inline int range_is_allowed(unsigned long pfn, unsigned long size) |
64 | { | 68 | { |
65 | u64 from = ((u64)pfn) << PAGE_SHIFT; | 69 | u64 from = ((u64)pfn) << PAGE_SHIFT; |
@@ -75,6 +79,10 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size) | |||
75 | return 1; | 79 | return 1; |
76 | } | 80 | } |
77 | #else | 81 | #else |
82 | static inline int page_is_allowed(unsigned long pfn) | ||
83 | { | ||
84 | return 1; | ||
85 | } | ||
78 | static inline int range_is_allowed(unsigned long pfn, unsigned long size) | 86 | static inline int range_is_allowed(unsigned long pfn, unsigned long size) |
79 | { | 87 | { |
80 | return 1; | 88 | return 1; |
@@ -122,23 +130,31 @@ static ssize_t read_mem(struct file *file, char __user *buf, | |||
122 | 130 | ||
123 | while (count > 0) { | 131 | while (count > 0) { |
124 | unsigned long remaining; | 132 | unsigned long remaining; |
133 | int allowed; | ||
125 | 134 | ||
126 | sz = size_inside_page(p, count); | 135 | sz = size_inside_page(p, count); |
127 | 136 | ||
128 | if (!range_is_allowed(p >> PAGE_SHIFT, count)) | 137 | allowed = page_is_allowed(p >> PAGE_SHIFT); |
138 | if (!allowed) | ||
129 | return -EPERM; | 139 | return -EPERM; |
140 | if (allowed == 2) { | ||
141 | /* Show zeros for restricted memory. */ | ||
142 | remaining = clear_user(buf, sz); | ||
143 | } else { | ||
144 | /* | ||
145 | * On ia64 if a page has been mapped somewhere as | ||
146 | * uncached, then it must also be accessed uncached | ||
147 | * by the kernel or data corruption may occur. | ||
148 | */ | ||
149 | ptr = xlate_dev_mem_ptr(p); | ||
150 | if (!ptr) | ||
151 | return -EFAULT; | ||
130 | 152 | ||
131 | /* | 153 | remaining = copy_to_user(buf, ptr, sz); |
132 | * On ia64 if a page has been mapped somewhere as uncached, then | 154 | |
133 | * it must also be accessed uncached by the kernel or data | 155 | unxlate_dev_mem_ptr(p, ptr); |
134 | * corruption may occur. | 156 | } |
135 | */ | ||
136 | ptr = xlate_dev_mem_ptr(p); | ||
137 | if (!ptr) | ||
138 | return -EFAULT; | ||
139 | 157 | ||
140 | remaining = copy_to_user(buf, ptr, sz); | ||
141 | unxlate_dev_mem_ptr(p, ptr); | ||
142 | if (remaining) | 158 | if (remaining) |
143 | return -EFAULT; | 159 | return -EFAULT; |
144 | 160 | ||
@@ -181,30 +197,36 @@ static ssize_t write_mem(struct file *file, const char __user *buf, | |||
181 | #endif | 197 | #endif |
182 | 198 | ||
183 | while (count > 0) { | 199 | while (count > 0) { |
200 | int allowed; | ||
201 | |||
184 | sz = size_inside_page(p, count); | 202 | sz = size_inside_page(p, count); |
185 | 203 | ||
186 | if (!range_is_allowed(p >> PAGE_SHIFT, sz)) | 204 | allowed = page_is_allowed(p >> PAGE_SHIFT); |
205 | if (!allowed) | ||
187 | return -EPERM; | 206 | return -EPERM; |
188 | 207 | ||
189 | /* | 208 | /* Skip actual writing when a page is marked as restricted. */ |
190 | * On ia64 if a page has been mapped somewhere as uncached, then | 209 | if (allowed == 1) { |
191 | * it must also be accessed uncached by the kernel or data | 210 | /* |
192 | * corruption may occur. | 211 | * On ia64 if a page has been mapped somewhere as |
193 | */ | 212 | * uncached, then it must also be accessed uncached |
194 | ptr = xlate_dev_mem_ptr(p); | 213 | * by the kernel or data corruption may occur. |
195 | if (!ptr) { | 214 | */ |
196 | if (written) | 215 | ptr = xlate_dev_mem_ptr(p); |
197 | break; | 216 | if (!ptr) { |
198 | return -EFAULT; | 217 | if (written) |
199 | } | 218 | break; |
219 | return -EFAULT; | ||
220 | } | ||
200 | 221 | ||
201 | copied = copy_from_user(ptr, buf, sz); | 222 | copied = copy_from_user(ptr, buf, sz); |
202 | unxlate_dev_mem_ptr(p, ptr); | 223 | unxlate_dev_mem_ptr(p, ptr); |
203 | if (copied) { | 224 | if (copied) { |
204 | written += sz - copied; | 225 | written += sz - copied; |
205 | if (written) | 226 | if (written) |
206 | break; | 227 | break; |
207 | return -EFAULT; | 228 | return -EFAULT; |
229 | } | ||
208 | } | 230 | } |
209 | 231 | ||
210 | buf += sz; | 232 | buf += sz; |
diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c index e9b7e0b3cabe..87fe111d0be6 100644 --- a/drivers/char/virtio_console.c +++ b/drivers/char/virtio_console.c | |||
@@ -2202,14 +2202,16 @@ static int virtcons_freeze(struct virtio_device *vdev) | |||
2202 | 2202 | ||
2203 | vdev->config->reset(vdev); | 2203 | vdev->config->reset(vdev); |
2204 | 2204 | ||
2205 | virtqueue_disable_cb(portdev->c_ivq); | 2205 | if (use_multiport(portdev)) |
2206 | virtqueue_disable_cb(portdev->c_ivq); | ||
2206 | cancel_work_sync(&portdev->control_work); | 2207 | cancel_work_sync(&portdev->control_work); |
2207 | cancel_work_sync(&portdev->config_work); | 2208 | cancel_work_sync(&portdev->config_work); |
2208 | /* | 2209 | /* |
2209 | * Once more: if control_work_handler() was running, it would | 2210 | * Once more: if control_work_handler() was running, it would |
2210 | * enable the cb as the last step. | 2211 | * enable the cb as the last step. |
2211 | */ | 2212 | */ |
2212 | virtqueue_disable_cb(portdev->c_ivq); | 2213 | if (use_multiport(portdev)) |
2214 | virtqueue_disable_cb(portdev->c_ivq); | ||
2213 | remove_controlq_data(portdev); | 2215 | remove_controlq_data(portdev); |
2214 | 2216 | ||
2215 | list_for_each_entry(port, &portdev->ports, list) { | 2217 | list_for_each_entry(port, &portdev->ports, list) { |
diff --git a/drivers/clk/clk-stm32f4.c b/drivers/clk/clk-stm32f4.c index ab609a76706f..cf9449b3dbd9 100644 --- a/drivers/clk/clk-stm32f4.c +++ b/drivers/clk/clk-stm32f4.c | |||
@@ -429,6 +429,13 @@ static const struct clk_div_table pll_divp_table[] = { | |||
429 | { 0, 2 }, { 1, 4 }, { 2, 6 }, { 3, 8 }, { 0 } | 429 | { 0, 2 }, { 1, 4 }, { 2, 6 }, { 3, 8 }, { 0 } |
430 | }; | 430 | }; |
431 | 431 | ||
432 | static const struct clk_div_table pll_divq_table[] = { | ||
433 | { 2, 2 }, { 3, 3 }, { 4, 4 }, { 5, 5 }, { 6, 6 }, { 7, 7 }, | ||
434 | { 8, 8 }, { 9, 9 }, { 10, 10 }, { 11, 11 }, { 12, 12 }, { 13, 13 }, | ||
435 | { 14, 14 }, { 15, 15 }, | ||
436 | { 0 } | ||
437 | }; | ||
438 | |||
432 | static const struct clk_div_table pll_divr_table[] = { | 439 | static const struct clk_div_table pll_divr_table[] = { |
433 | { 2, 2 }, { 3, 3 }, { 4, 4 }, { 5, 5 }, { 6, 6 }, { 7, 7 }, { 0 } | 440 | { 2, 2 }, { 3, 3 }, { 4, 4 }, { 5, 5 }, { 6, 6 }, { 7, 7 }, { 0 } |
434 | }; | 441 | }; |
@@ -496,9 +503,9 @@ struct stm32f4_div_data { | |||
496 | 503 | ||
497 | #define MAX_PLL_DIV 3 | 504 | #define MAX_PLL_DIV 3 |
498 | static const struct stm32f4_div_data div_data[MAX_PLL_DIV] = { | 505 | static const struct stm32f4_div_data div_data[MAX_PLL_DIV] = { |
499 | { 16, 2, 0, pll_divp_table }, | 506 | { 16, 2, 0, pll_divp_table }, |
500 | { 24, 4, CLK_DIVIDER_ONE_BASED, NULL }, | 507 | { 24, 4, 0, pll_divq_table }, |
501 | { 28, 3, 0, pll_divr_table }, | 508 | { 28, 3, 0, pll_divr_table }, |
502 | }; | 509 | }; |
503 | 510 | ||
504 | struct stm32f4_pll_data { | 511 | struct stm32f4_pll_data { |
diff --git a/drivers/clk/sunxi-ng/Kconfig b/drivers/clk/sunxi-ng/Kconfig index 72109d2cf41b..1c2357301017 100644 --- a/drivers/clk/sunxi-ng/Kconfig +++ b/drivers/clk/sunxi-ng/Kconfig | |||
@@ -1,6 +1,7 @@ | |||
1 | config SUNXI_CCU | 1 | config SUNXI_CCU |
2 | bool "Clock support for Allwinner SoCs" | 2 | bool "Clock support for Allwinner SoCs" |
3 | depends on ARCH_SUNXI || COMPILE_TEST | 3 | depends on ARCH_SUNXI || COMPILE_TEST |
4 | select RESET_CONTROLLER | ||
4 | default ARCH_SUNXI | 5 | default ARCH_SUNXI |
5 | 6 | ||
6 | if SUNXI_CCU | 7 | if SUNXI_CCU |
@@ -135,6 +136,7 @@ config SUN8I_V3S_CCU | |||
135 | config SUN9I_A80_CCU | 136 | config SUN9I_A80_CCU |
136 | bool "Support for the Allwinner A80 CCU" | 137 | bool "Support for the Allwinner A80 CCU" |
137 | select SUNXI_CCU_DIV | 138 | select SUNXI_CCU_DIV |
139 | select SUNXI_CCU_MULT | ||
138 | select SUNXI_CCU_GATE | 140 | select SUNXI_CCU_GATE |
139 | select SUNXI_CCU_NKMP | 141 | select SUNXI_CCU_NKMP |
140 | select SUNXI_CCU_NM | 142 | select SUNXI_CCU_NM |
diff --git a/drivers/clk/sunxi-ng/ccu-sun8i-a33.c b/drivers/clk/sunxi-ng/ccu-sun8i-a33.c index a7b3c08ed0e2..2c69b631967a 100644 --- a/drivers/clk/sunxi-ng/ccu-sun8i-a33.c +++ b/drivers/clk/sunxi-ng/ccu-sun8i-a33.c | |||
@@ -752,6 +752,13 @@ static const struct sunxi_ccu_desc sun8i_a33_ccu_desc = { | |||
752 | .num_resets = ARRAY_SIZE(sun8i_a33_ccu_resets), | 752 | .num_resets = ARRAY_SIZE(sun8i_a33_ccu_resets), |
753 | }; | 753 | }; |
754 | 754 | ||
755 | static struct ccu_pll_nb sun8i_a33_pll_cpu_nb = { | ||
756 | .common = &pll_cpux_clk.common, | ||
757 | /* copy from pll_cpux_clk */ | ||
758 | .enable = BIT(31), | ||
759 | .lock = BIT(28), | ||
760 | }; | ||
761 | |||
755 | static struct ccu_mux_nb sun8i_a33_cpu_nb = { | 762 | static struct ccu_mux_nb sun8i_a33_cpu_nb = { |
756 | .common = &cpux_clk.common, | 763 | .common = &cpux_clk.common, |
757 | .cm = &cpux_clk.mux, | 764 | .cm = &cpux_clk.mux, |
@@ -783,6 +790,10 @@ static void __init sun8i_a33_ccu_setup(struct device_node *node) | |||
783 | 790 | ||
784 | sunxi_ccu_probe(node, reg, &sun8i_a33_ccu_desc); | 791 | sunxi_ccu_probe(node, reg, &sun8i_a33_ccu_desc); |
785 | 792 | ||
793 | /* Gate then ungate PLL CPU after any rate changes */ | ||
794 | ccu_pll_notifier_register(&sun8i_a33_pll_cpu_nb); | ||
795 | |||
796 | /* Reparent CPU during PLL CPU rate changes */ | ||
786 | ccu_mux_notifier_register(pll_cpux_clk.common.hw.clk, | 797 | ccu_mux_notifier_register(pll_cpux_clk.common.hw.clk, |
787 | &sun8i_a33_cpu_nb); | 798 | &sun8i_a33_cpu_nb); |
788 | } | 799 | } |
diff --git a/drivers/clk/sunxi-ng/ccu_common.c b/drivers/clk/sunxi-ng/ccu_common.c index 8a47bafd7890..9d8724715a43 100644 --- a/drivers/clk/sunxi-ng/ccu_common.c +++ b/drivers/clk/sunxi-ng/ccu_common.c | |||
@@ -14,11 +14,13 @@ | |||
14 | * GNU General Public License for more details. | 14 | * GNU General Public License for more details. |
15 | */ | 15 | */ |
16 | 16 | ||
17 | #include <linux/clk.h> | ||
17 | #include <linux/clk-provider.h> | 18 | #include <linux/clk-provider.h> |
18 | #include <linux/iopoll.h> | 19 | #include <linux/iopoll.h> |
19 | #include <linux/slab.h> | 20 | #include <linux/slab.h> |
20 | 21 | ||
21 | #include "ccu_common.h" | 22 | #include "ccu_common.h" |
23 | #include "ccu_gate.h" | ||
22 | #include "ccu_reset.h" | 24 | #include "ccu_reset.h" |
23 | 25 | ||
24 | static DEFINE_SPINLOCK(ccu_lock); | 26 | static DEFINE_SPINLOCK(ccu_lock); |
@@ -39,6 +41,53 @@ void ccu_helper_wait_for_lock(struct ccu_common *common, u32 lock) | |||
39 | WARN_ON(readl_relaxed_poll_timeout(addr, reg, reg & lock, 100, 70000)); | 41 | WARN_ON(readl_relaxed_poll_timeout(addr, reg, reg & lock, 100, 70000)); |
40 | } | 42 | } |
41 | 43 | ||
44 | /* | ||
45 | * This clock notifier is called when the frequency of a PLL clock is | ||
46 | * changed. In common PLL designs, changes to the dividers take effect | ||
47 | * almost immediately, while changes to the multipliers (implemented | ||
48 | * as dividers in the feedback loop) take a few cycles to work into | ||
49 | * the feedback loop for the PLL to stablize. | ||
50 | * | ||
51 | * Sometimes when the PLL clock rate is changed, the decrease in the | ||
52 | * divider is too much for the decrease in the multiplier to catch up. | ||
53 | * The PLL clock rate will spike, and in some cases, might lock up | ||
54 | * completely. | ||
55 | * | ||
56 | * This notifier callback will gate and then ungate the clock, | ||
57 | * effectively resetting it, so it proceeds to work. Care must be | ||
58 | * taken to reparent consumers to other temporary clocks during the | ||
59 | * rate change, and that this notifier callback must be the first | ||
60 | * to be registered. | ||
61 | */ | ||
62 | static int ccu_pll_notifier_cb(struct notifier_block *nb, | ||
63 | unsigned long event, void *data) | ||
64 | { | ||
65 | struct ccu_pll_nb *pll = to_ccu_pll_nb(nb); | ||
66 | int ret = 0; | ||
67 | |||
68 | if (event != POST_RATE_CHANGE) | ||
69 | goto out; | ||
70 | |||
71 | ccu_gate_helper_disable(pll->common, pll->enable); | ||
72 | |||
73 | ret = ccu_gate_helper_enable(pll->common, pll->enable); | ||
74 | if (ret) | ||
75 | goto out; | ||
76 | |||
77 | ccu_helper_wait_for_lock(pll->common, pll->lock); | ||
78 | |||
79 | out: | ||
80 | return notifier_from_errno(ret); | ||
81 | } | ||
82 | |||
83 | int ccu_pll_notifier_register(struct ccu_pll_nb *pll_nb) | ||
84 | { | ||
85 | pll_nb->clk_nb.notifier_call = ccu_pll_notifier_cb; | ||
86 | |||
87 | return clk_notifier_register(pll_nb->common->hw.clk, | ||
88 | &pll_nb->clk_nb); | ||
89 | } | ||
90 | |||
42 | int sunxi_ccu_probe(struct device_node *node, void __iomem *reg, | 91 | int sunxi_ccu_probe(struct device_node *node, void __iomem *reg, |
43 | const struct sunxi_ccu_desc *desc) | 92 | const struct sunxi_ccu_desc *desc) |
44 | { | 93 | { |
diff --git a/drivers/clk/sunxi-ng/ccu_common.h b/drivers/clk/sunxi-ng/ccu_common.h index 73d81dc58fc5..d6fdd7a789aa 100644 --- a/drivers/clk/sunxi-ng/ccu_common.h +++ b/drivers/clk/sunxi-ng/ccu_common.h | |||
@@ -83,6 +83,18 @@ struct sunxi_ccu_desc { | |||
83 | 83 | ||
84 | void ccu_helper_wait_for_lock(struct ccu_common *common, u32 lock); | 84 | void ccu_helper_wait_for_lock(struct ccu_common *common, u32 lock); |
85 | 85 | ||
86 | struct ccu_pll_nb { | ||
87 | struct notifier_block clk_nb; | ||
88 | struct ccu_common *common; | ||
89 | |||
90 | u32 enable; | ||
91 | u32 lock; | ||
92 | }; | ||
93 | |||
94 | #define to_ccu_pll_nb(_nb) container_of(_nb, struct ccu_pll_nb, clk_nb) | ||
95 | |||
96 | int ccu_pll_notifier_register(struct ccu_pll_nb *pll_nb); | ||
97 | |||
86 | int sunxi_ccu_probe(struct device_node *node, void __iomem *reg, | 98 | int sunxi_ccu_probe(struct device_node *node, void __iomem *reg, |
87 | const struct sunxi_ccu_desc *desc); | 99 | const struct sunxi_ccu_desc *desc); |
88 | 100 | ||
diff --git a/drivers/clocksource/clkevt-probe.c b/drivers/clocksource/clkevt-probe.c index 8c30fec86094..eb89b502acbd 100644 --- a/drivers/clocksource/clkevt-probe.c +++ b/drivers/clocksource/clkevt-probe.c | |||
@@ -17,7 +17,7 @@ | |||
17 | 17 | ||
18 | #include <linux/init.h> | 18 | #include <linux/init.h> |
19 | #include <linux/of.h> | 19 | #include <linux/of.h> |
20 | #include <linux/clockchip.h> | 20 | #include <linux/clockchips.h> |
21 | 21 | ||
22 | extern struct of_device_id __clkevt_of_table[]; | 22 | extern struct of_device_id __clkevt_of_table[]; |
23 | 23 | ||
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 5dbdd261aa73..0e3f6496524d 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c | |||
@@ -918,11 +918,19 @@ static struct kobj_type ktype_cpufreq = { | |||
918 | .release = cpufreq_sysfs_release, | 918 | .release = cpufreq_sysfs_release, |
919 | }; | 919 | }; |
920 | 920 | ||
921 | static int add_cpu_dev_symlink(struct cpufreq_policy *policy, | 921 | static void add_cpu_dev_symlink(struct cpufreq_policy *policy, unsigned int cpu) |
922 | struct device *dev) | ||
923 | { | 922 | { |
923 | struct device *dev = get_cpu_device(cpu); | ||
924 | |||
925 | if (!dev) | ||
926 | return; | ||
927 | |||
928 | if (cpumask_test_and_set_cpu(cpu, policy->real_cpus)) | ||
929 | return; | ||
930 | |||
924 | dev_dbg(dev, "%s: Adding symlink\n", __func__); | 931 | dev_dbg(dev, "%s: Adding symlink\n", __func__); |
925 | return sysfs_create_link(&dev->kobj, &policy->kobj, "cpufreq"); | 932 | if (sysfs_create_link(&dev->kobj, &policy->kobj, "cpufreq")) |
933 | dev_err(dev, "cpufreq symlink creation failed\n"); | ||
926 | } | 934 | } |
927 | 935 | ||
928 | static void remove_cpu_dev_symlink(struct cpufreq_policy *policy, | 936 | static void remove_cpu_dev_symlink(struct cpufreq_policy *policy, |
@@ -1180,10 +1188,10 @@ static int cpufreq_online(unsigned int cpu) | |||
1180 | policy->user_policy.min = policy->min; | 1188 | policy->user_policy.min = policy->min; |
1181 | policy->user_policy.max = policy->max; | 1189 | policy->user_policy.max = policy->max; |
1182 | 1190 | ||
1183 | write_lock_irqsave(&cpufreq_driver_lock, flags); | 1191 | for_each_cpu(j, policy->related_cpus) { |
1184 | for_each_cpu(j, policy->related_cpus) | ||
1185 | per_cpu(cpufreq_cpu_data, j) = policy; | 1192 | per_cpu(cpufreq_cpu_data, j) = policy; |
1186 | write_unlock_irqrestore(&cpufreq_driver_lock, flags); | 1193 | add_cpu_dev_symlink(policy, j); |
1194 | } | ||
1187 | } else { | 1195 | } else { |
1188 | policy->min = policy->user_policy.min; | 1196 | policy->min = policy->user_policy.min; |
1189 | policy->max = policy->user_policy.max; | 1197 | policy->max = policy->user_policy.max; |
@@ -1275,13 +1283,15 @@ out_exit_policy: | |||
1275 | 1283 | ||
1276 | if (cpufreq_driver->exit) | 1284 | if (cpufreq_driver->exit) |
1277 | cpufreq_driver->exit(policy); | 1285 | cpufreq_driver->exit(policy); |
1286 | |||
1287 | for_each_cpu(j, policy->real_cpus) | ||
1288 | remove_cpu_dev_symlink(policy, get_cpu_device(j)); | ||
1289 | |||
1278 | out_free_policy: | 1290 | out_free_policy: |
1279 | cpufreq_policy_free(policy); | 1291 | cpufreq_policy_free(policy); |
1280 | return ret; | 1292 | return ret; |
1281 | } | 1293 | } |
1282 | 1294 | ||
1283 | static int cpufreq_offline(unsigned int cpu); | ||
1284 | |||
1285 | /** | 1295 | /** |
1286 | * cpufreq_add_dev - the cpufreq interface for a CPU device. | 1296 | * cpufreq_add_dev - the cpufreq interface for a CPU device. |
1287 | * @dev: CPU device. | 1297 | * @dev: CPU device. |
@@ -1303,16 +1313,10 @@ static int cpufreq_add_dev(struct device *dev, struct subsys_interface *sif) | |||
1303 | 1313 | ||
1304 | /* Create sysfs link on CPU registration */ | 1314 | /* Create sysfs link on CPU registration */ |
1305 | policy = per_cpu(cpufreq_cpu_data, cpu); | 1315 | policy = per_cpu(cpufreq_cpu_data, cpu); |
1306 | if (!policy || cpumask_test_and_set_cpu(cpu, policy->real_cpus)) | 1316 | if (policy) |
1307 | return 0; | 1317 | add_cpu_dev_symlink(policy, cpu); |
1308 | |||
1309 | ret = add_cpu_dev_symlink(policy, dev); | ||
1310 | if (ret) { | ||
1311 | cpumask_clear_cpu(cpu, policy->real_cpus); | ||
1312 | cpufreq_offline(cpu); | ||
1313 | } | ||
1314 | 1318 | ||
1315 | return ret; | 1319 | return 0; |
1316 | } | 1320 | } |
1317 | 1321 | ||
1318 | static int cpufreq_offline(unsigned int cpu) | 1322 | static int cpufreq_offline(unsigned int cpu) |
@@ -2394,6 +2398,20 @@ EXPORT_SYMBOL_GPL(cpufreq_boost_enabled); | |||
2394 | *********************************************************************/ | 2398 | *********************************************************************/ |
2395 | static enum cpuhp_state hp_online; | 2399 | static enum cpuhp_state hp_online; |
2396 | 2400 | ||
2401 | static int cpuhp_cpufreq_online(unsigned int cpu) | ||
2402 | { | ||
2403 | cpufreq_online(cpu); | ||
2404 | |||
2405 | return 0; | ||
2406 | } | ||
2407 | |||
2408 | static int cpuhp_cpufreq_offline(unsigned int cpu) | ||
2409 | { | ||
2410 | cpufreq_offline(cpu); | ||
2411 | |||
2412 | return 0; | ||
2413 | } | ||
2414 | |||
2397 | /** | 2415 | /** |
2398 | * cpufreq_register_driver - register a CPU Frequency driver | 2416 | * cpufreq_register_driver - register a CPU Frequency driver |
2399 | * @driver_data: A struct cpufreq_driver containing the values# | 2417 | * @driver_data: A struct cpufreq_driver containing the values# |
@@ -2456,8 +2474,8 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data) | |||
2456 | } | 2474 | } |
2457 | 2475 | ||
2458 | ret = cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN, "cpufreq:online", | 2476 | ret = cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN, "cpufreq:online", |
2459 | cpufreq_online, | 2477 | cpuhp_cpufreq_online, |
2460 | cpufreq_offline); | 2478 | cpuhp_cpufreq_offline); |
2461 | if (ret < 0) | 2479 | if (ret < 0) |
2462 | goto err_if_unreg; | 2480 | goto err_if_unreg; |
2463 | hp_online = ret; | 2481 | hp_online = ret; |
diff --git a/drivers/cpuidle/cpuidle-powernv.c b/drivers/cpuidle/cpuidle-powernv.c index 370593006f5f..cda8f62d555b 100644 --- a/drivers/cpuidle/cpuidle-powernv.c +++ b/drivers/cpuidle/cpuidle-powernv.c | |||
@@ -175,6 +175,24 @@ static int powernv_cpuidle_driver_init(void) | |||
175 | drv->state_count += 1; | 175 | drv->state_count += 1; |
176 | } | 176 | } |
177 | 177 | ||
178 | /* | ||
179 | * On the PowerNV platform cpu_present may be less than cpu_possible in | ||
180 | * cases when firmware detects the CPU, but it is not available to the | ||
181 | * OS. If CONFIG_HOTPLUG_CPU=n, then such CPUs are not hotplugable at | ||
182 | * run time and hence cpu_devices are not created for those CPUs by the | ||
183 | * generic topology_init(). | ||
184 | * | ||
185 | * drv->cpumask defaults to cpu_possible_mask in | ||
186 | * __cpuidle_driver_init(). This breaks cpuidle on PowerNV where | ||
187 | * cpu_devices are not created for CPUs in cpu_possible_mask that | ||
188 | * cannot be hot-added later at run time. | ||
189 | * | ||
190 | * Trying cpuidle_register_device() on a CPU without a cpu_device is | ||
191 | * incorrect, so pass a correct CPU mask to the generic cpuidle driver. | ||
192 | */ | ||
193 | |||
194 | drv->cpumask = (struct cpumask *)cpu_present_mask; | ||
195 | |||
178 | return 0; | 196 | return 0; |
179 | } | 197 | } |
180 | 198 | ||
diff --git a/drivers/crypto/caam/caampkc.c b/drivers/crypto/caam/caampkc.c index 32100c4851dd..49cbdcba7883 100644 --- a/drivers/crypto/caam/caampkc.c +++ b/drivers/crypto/caam/caampkc.c | |||
@@ -506,7 +506,7 @@ static int caam_rsa_init_tfm(struct crypto_akcipher *tfm) | |||
506 | ctx->dev = caam_jr_alloc(); | 506 | ctx->dev = caam_jr_alloc(); |
507 | 507 | ||
508 | if (IS_ERR(ctx->dev)) { | 508 | if (IS_ERR(ctx->dev)) { |
509 | dev_err(ctx->dev, "Job Ring Device allocation for transform failed\n"); | 509 | pr_err("Job Ring Device allocation for transform failed\n"); |
510 | return PTR_ERR(ctx->dev); | 510 | return PTR_ERR(ctx->dev); |
511 | } | 511 | } |
512 | 512 | ||
diff --git a/drivers/crypto/caam/ctrl.c b/drivers/crypto/caam/ctrl.c index fef39f9f41ee..5d7f73d60515 100644 --- a/drivers/crypto/caam/ctrl.c +++ b/drivers/crypto/caam/ctrl.c | |||
@@ -281,7 +281,8 @@ static int deinstantiate_rng(struct device *ctrldev, int state_handle_mask) | |||
281 | /* Try to run it through DECO0 */ | 281 | /* Try to run it through DECO0 */ |
282 | ret = run_descriptor_deco0(ctrldev, desc, &status); | 282 | ret = run_descriptor_deco0(ctrldev, desc, &status); |
283 | 283 | ||
284 | if (ret || status) { | 284 | if (ret || |
285 | (status && status != JRSTA_SSRC_JUMP_HALT_CC)) { | ||
285 | dev_err(ctrldev, | 286 | dev_err(ctrldev, |
286 | "Failed to deinstantiate RNG4 SH%d\n", | 287 | "Failed to deinstantiate RNG4 SH%d\n", |
287 | sh_idx); | 288 | sh_idx); |
@@ -301,15 +302,13 @@ static int caam_remove(struct platform_device *pdev) | |||
301 | struct device *ctrldev; | 302 | struct device *ctrldev; |
302 | struct caam_drv_private *ctrlpriv; | 303 | struct caam_drv_private *ctrlpriv; |
303 | struct caam_ctrl __iomem *ctrl; | 304 | struct caam_ctrl __iomem *ctrl; |
304 | int ring; | ||
305 | 305 | ||
306 | ctrldev = &pdev->dev; | 306 | ctrldev = &pdev->dev; |
307 | ctrlpriv = dev_get_drvdata(ctrldev); | 307 | ctrlpriv = dev_get_drvdata(ctrldev); |
308 | ctrl = (struct caam_ctrl __iomem *)ctrlpriv->ctrl; | 308 | ctrl = (struct caam_ctrl __iomem *)ctrlpriv->ctrl; |
309 | 309 | ||
310 | /* Remove platform devices for JobRs */ | 310 | /* Remove platform devices under the crypto node */ |
311 | for (ring = 0; ring < ctrlpriv->total_jobrs; ring++) | 311 | of_platform_depopulate(ctrldev); |
312 | of_device_unregister(ctrlpriv->jrpdev[ring]); | ||
313 | 312 | ||
314 | /* De-initialize RNG state handles initialized by this driver. */ | 313 | /* De-initialize RNG state handles initialized by this driver. */ |
315 | if (ctrlpriv->rng4_sh_init) | 314 | if (ctrlpriv->rng4_sh_init) |
@@ -418,10 +417,21 @@ DEFINE_SIMPLE_ATTRIBUTE(caam_fops_u32_ro, caam_debugfs_u32_get, NULL, "%llu\n"); | |||
418 | DEFINE_SIMPLE_ATTRIBUTE(caam_fops_u64_ro, caam_debugfs_u64_get, NULL, "%llu\n"); | 417 | DEFINE_SIMPLE_ATTRIBUTE(caam_fops_u64_ro, caam_debugfs_u64_get, NULL, "%llu\n"); |
419 | #endif | 418 | #endif |
420 | 419 | ||
420 | static const struct of_device_id caam_match[] = { | ||
421 | { | ||
422 | .compatible = "fsl,sec-v4.0", | ||
423 | }, | ||
424 | { | ||
425 | .compatible = "fsl,sec4.0", | ||
426 | }, | ||
427 | {}, | ||
428 | }; | ||
429 | MODULE_DEVICE_TABLE(of, caam_match); | ||
430 | |||
421 | /* Probe routine for CAAM top (controller) level */ | 431 | /* Probe routine for CAAM top (controller) level */ |
422 | static int caam_probe(struct platform_device *pdev) | 432 | static int caam_probe(struct platform_device *pdev) |
423 | { | 433 | { |
424 | int ret, ring, ridx, rspec, gen_sk, ent_delay = RTSDCTL_ENT_DLY_MIN; | 434 | int ret, ring, gen_sk, ent_delay = RTSDCTL_ENT_DLY_MIN; |
425 | u64 caam_id; | 435 | u64 caam_id; |
426 | struct device *dev; | 436 | struct device *dev; |
427 | struct device_node *nprop, *np; | 437 | struct device_node *nprop, *np; |
@@ -597,47 +607,24 @@ static int caam_probe(struct platform_device *pdev) | |||
597 | goto iounmap_ctrl; | 607 | goto iounmap_ctrl; |
598 | } | 608 | } |
599 | 609 | ||
600 | /* | 610 | ret = of_platform_populate(nprop, caam_match, NULL, dev); |
601 | * Detect and enable JobRs | 611 | if (ret) { |
602 | * First, find out how many ring spec'ed, allocate references | 612 | dev_err(dev, "JR platform devices creation error\n"); |
603 | * for all, then go probe each one. | ||
604 | */ | ||
605 | rspec = 0; | ||
606 | for_each_available_child_of_node(nprop, np) | ||
607 | if (of_device_is_compatible(np, "fsl,sec-v4.0-job-ring") || | ||
608 | of_device_is_compatible(np, "fsl,sec4.0-job-ring")) | ||
609 | rspec++; | ||
610 | |||
611 | ctrlpriv->jrpdev = devm_kcalloc(&pdev->dev, rspec, | ||
612 | sizeof(*ctrlpriv->jrpdev), GFP_KERNEL); | ||
613 | if (ctrlpriv->jrpdev == NULL) { | ||
614 | ret = -ENOMEM; | ||
615 | goto iounmap_ctrl; | 613 | goto iounmap_ctrl; |
616 | } | 614 | } |
617 | 615 | ||
618 | ring = 0; | 616 | ring = 0; |
619 | ridx = 0; | ||
620 | ctrlpriv->total_jobrs = 0; | ||
621 | for_each_available_child_of_node(nprop, np) | 617 | for_each_available_child_of_node(nprop, np) |
622 | if (of_device_is_compatible(np, "fsl,sec-v4.0-job-ring") || | 618 | if (of_device_is_compatible(np, "fsl,sec-v4.0-job-ring") || |
623 | of_device_is_compatible(np, "fsl,sec4.0-job-ring")) { | 619 | of_device_is_compatible(np, "fsl,sec4.0-job-ring")) { |
624 | ctrlpriv->jrpdev[ring] = | ||
625 | of_platform_device_create(np, NULL, dev); | ||
626 | if (!ctrlpriv->jrpdev[ring]) { | ||
627 | pr_warn("JR physical index %d: Platform device creation error\n", | ||
628 | ridx); | ||
629 | ridx++; | ||
630 | continue; | ||
631 | } | ||
632 | ctrlpriv->jr[ring] = (struct caam_job_ring __iomem __force *) | 620 | ctrlpriv->jr[ring] = (struct caam_job_ring __iomem __force *) |
633 | ((__force uint8_t *)ctrl + | 621 | ((__force uint8_t *)ctrl + |
634 | (ridx + JR_BLOCK_NUMBER) * | 622 | (ring + JR_BLOCK_NUMBER) * |
635 | BLOCK_OFFSET | 623 | BLOCK_OFFSET |
636 | ); | 624 | ); |
637 | ctrlpriv->total_jobrs++; | 625 | ctrlpriv->total_jobrs++; |
638 | ring++; | 626 | ring++; |
639 | ridx++; | 627 | } |
640 | } | ||
641 | 628 | ||
642 | /* Check to see if QI present. If so, enable */ | 629 | /* Check to see if QI present. If so, enable */ |
643 | ctrlpriv->qi_present = | 630 | ctrlpriv->qi_present = |
@@ -847,17 +834,6 @@ disable_caam_ipg: | |||
847 | return ret; | 834 | return ret; |
848 | } | 835 | } |
849 | 836 | ||
850 | static struct of_device_id caam_match[] = { | ||
851 | { | ||
852 | .compatible = "fsl,sec-v4.0", | ||
853 | }, | ||
854 | { | ||
855 | .compatible = "fsl,sec4.0", | ||
856 | }, | ||
857 | {}, | ||
858 | }; | ||
859 | MODULE_DEVICE_TABLE(of, caam_match); | ||
860 | |||
861 | static struct platform_driver caam_driver = { | 837 | static struct platform_driver caam_driver = { |
862 | .driver = { | 838 | .driver = { |
863 | .name = "caam", | 839 | .name = "caam", |
diff --git a/drivers/crypto/caam/intern.h b/drivers/crypto/caam/intern.h index e2bcacc1a921..dbed8baeebe5 100644 --- a/drivers/crypto/caam/intern.h +++ b/drivers/crypto/caam/intern.h | |||
@@ -66,7 +66,6 @@ struct caam_drv_private_jr { | |||
66 | struct caam_drv_private { | 66 | struct caam_drv_private { |
67 | 67 | ||
68 | struct device *dev; | 68 | struct device *dev; |
69 | struct platform_device **jrpdev; /* Alloc'ed array per sub-device */ | ||
70 | struct platform_device *pdev; | 69 | struct platform_device *pdev; |
71 | 70 | ||
72 | /* Physical-presence section */ | 71 | /* Physical-presence section */ |
diff --git a/drivers/crypto/ccp/ccp-dev-v5.c b/drivers/crypto/ccp/ccp-dev-v5.c index 41cc853f8569..fc08b4ed69d9 100644 --- a/drivers/crypto/ccp/ccp-dev-v5.c +++ b/drivers/crypto/ccp/ccp-dev-v5.c | |||
@@ -1015,6 +1015,7 @@ const struct ccp_vdata ccpv5a = { | |||
1015 | 1015 | ||
1016 | const struct ccp_vdata ccpv5b = { | 1016 | const struct ccp_vdata ccpv5b = { |
1017 | .version = CCP_VERSION(5, 0), | 1017 | .version = CCP_VERSION(5, 0), |
1018 | .dma_chan_attr = DMA_PRIVATE, | ||
1018 | .setup = ccp5other_config, | 1019 | .setup = ccp5other_config, |
1019 | .perform = &ccp5_actions, | 1020 | .perform = &ccp5_actions, |
1020 | .bar = 2, | 1021 | .bar = 2, |
diff --git a/drivers/crypto/ccp/ccp-dev.h b/drivers/crypto/ccp/ccp-dev.h index 2b5c01fade05..aa36f3f81860 100644 --- a/drivers/crypto/ccp/ccp-dev.h +++ b/drivers/crypto/ccp/ccp-dev.h | |||
@@ -179,6 +179,10 @@ | |||
179 | 179 | ||
180 | /* ------------------------ General CCP Defines ------------------------ */ | 180 | /* ------------------------ General CCP Defines ------------------------ */ |
181 | 181 | ||
182 | #define CCP_DMA_DFLT 0x0 | ||
183 | #define CCP_DMA_PRIV 0x1 | ||
184 | #define CCP_DMA_PUB 0x2 | ||
185 | |||
182 | #define CCP_DMAPOOL_MAX_SIZE 64 | 186 | #define CCP_DMAPOOL_MAX_SIZE 64 |
183 | #define CCP_DMAPOOL_ALIGN BIT(5) | 187 | #define CCP_DMAPOOL_ALIGN BIT(5) |
184 | 188 | ||
@@ -636,6 +640,7 @@ struct ccp_actions { | |||
636 | /* Structure to hold CCP version-specific values */ | 640 | /* Structure to hold CCP version-specific values */ |
637 | struct ccp_vdata { | 641 | struct ccp_vdata { |
638 | const unsigned int version; | 642 | const unsigned int version; |
643 | const unsigned int dma_chan_attr; | ||
639 | void (*setup)(struct ccp_device *); | 644 | void (*setup)(struct ccp_device *); |
640 | const struct ccp_actions *perform; | 645 | const struct ccp_actions *perform; |
641 | const unsigned int bar; | 646 | const unsigned int bar; |
diff --git a/drivers/crypto/ccp/ccp-dmaengine.c b/drivers/crypto/ccp/ccp-dmaengine.c index 8d0eeb46d4a2..e00be01fbf5a 100644 --- a/drivers/crypto/ccp/ccp-dmaengine.c +++ b/drivers/crypto/ccp/ccp-dmaengine.c | |||
@@ -10,6 +10,7 @@ | |||
10 | * published by the Free Software Foundation. | 10 | * published by the Free Software Foundation. |
11 | */ | 11 | */ |
12 | 12 | ||
13 | #include <linux/module.h> | ||
13 | #include <linux/kernel.h> | 14 | #include <linux/kernel.h> |
14 | #include <linux/dmaengine.h> | 15 | #include <linux/dmaengine.h> |
15 | #include <linux/spinlock.h> | 16 | #include <linux/spinlock.h> |
@@ -25,6 +26,37 @@ | |||
25 | (mask == 0) ? 64 : fls64(mask); \ | 26 | (mask == 0) ? 64 : fls64(mask); \ |
26 | }) | 27 | }) |
27 | 28 | ||
29 | /* The CCP as a DMA provider can be configured for public or private | ||
30 | * channels. Default is specified in the vdata for the device (PCI ID). | ||
31 | * This module parameter will override for all channels on all devices: | ||
32 | * dma_chan_attr = 0x2 to force all channels public | ||
33 | * = 0x1 to force all channels private | ||
34 | * = 0x0 to defer to the vdata setting | ||
35 | * = any other value: warning, revert to 0x0 | ||
36 | */ | ||
37 | static unsigned int dma_chan_attr = CCP_DMA_DFLT; | ||
38 | module_param(dma_chan_attr, uint, 0444); | ||
39 | MODULE_PARM_DESC(dma_chan_attr, "Set DMA channel visibility: 0 (default) = device defaults, 1 = make private, 2 = make public"); | ||
40 | |||
41 | unsigned int ccp_get_dma_chan_attr(struct ccp_device *ccp) | ||
42 | { | ||
43 | switch (dma_chan_attr) { | ||
44 | case CCP_DMA_DFLT: | ||
45 | return ccp->vdata->dma_chan_attr; | ||
46 | |||
47 | case CCP_DMA_PRIV: | ||
48 | return DMA_PRIVATE; | ||
49 | |||
50 | case CCP_DMA_PUB: | ||
51 | return 0; | ||
52 | |||
53 | default: | ||
54 | dev_info_once(ccp->dev, "Invalid value for dma_chan_attr: %d\n", | ||
55 | dma_chan_attr); | ||
56 | return ccp->vdata->dma_chan_attr; | ||
57 | } | ||
58 | } | ||
59 | |||
28 | static void ccp_free_cmd_resources(struct ccp_device *ccp, | 60 | static void ccp_free_cmd_resources(struct ccp_device *ccp, |
29 | struct list_head *list) | 61 | struct list_head *list) |
30 | { | 62 | { |
@@ -675,6 +707,15 @@ int ccp_dmaengine_register(struct ccp_device *ccp) | |||
675 | dma_cap_set(DMA_SG, dma_dev->cap_mask); | 707 | dma_cap_set(DMA_SG, dma_dev->cap_mask); |
676 | dma_cap_set(DMA_INTERRUPT, dma_dev->cap_mask); | 708 | dma_cap_set(DMA_INTERRUPT, dma_dev->cap_mask); |
677 | 709 | ||
710 | /* The DMA channels for this device can be set to public or private, | ||
711 | * and overridden by the module parameter dma_chan_attr. | ||
712 | * Default: according to the value in vdata (dma_chan_attr=0) | ||
713 | * dma_chan_attr=0x1: all channels private (override vdata) | ||
714 | * dma_chan_attr=0x2: all channels public (override vdata) | ||
715 | */ | ||
716 | if (ccp_get_dma_chan_attr(ccp) == DMA_PRIVATE) | ||
717 | dma_cap_set(DMA_PRIVATE, dma_dev->cap_mask); | ||
718 | |||
678 | INIT_LIST_HEAD(&dma_dev->channels); | 719 | INIT_LIST_HEAD(&dma_dev->channels); |
679 | for (i = 0; i < ccp->cmd_q_count; i++) { | 720 | for (i = 0; i < ccp->cmd_q_count; i++) { |
680 | chan = ccp->ccp_dma_chan + i; | 721 | chan = ccp->ccp_dma_chan + i; |
diff --git a/drivers/dax/Kconfig b/drivers/dax/Kconfig index 3e2ab3b14eea..9e95bf94eb13 100644 --- a/drivers/dax/Kconfig +++ b/drivers/dax/Kconfig | |||
@@ -2,6 +2,7 @@ menuconfig DEV_DAX | |||
2 | tristate "DAX: direct access to differentiated memory" | 2 | tristate "DAX: direct access to differentiated memory" |
3 | default m if NVDIMM_DAX | 3 | default m if NVDIMM_DAX |
4 | depends on TRANSPARENT_HUGEPAGE | 4 | depends on TRANSPARENT_HUGEPAGE |
5 | select SRCU | ||
5 | help | 6 | help |
6 | Support raw access to differentiated (persistence, bandwidth, | 7 | Support raw access to differentiated (persistence, bandwidth, |
7 | latency...) memory via an mmap(2) capable character | 8 | latency...) memory via an mmap(2) capable character |
diff --git a/drivers/dax/dax.c b/drivers/dax/dax.c index 80c6db279ae1..806f180c80d8 100644 --- a/drivers/dax/dax.c +++ b/drivers/dax/dax.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include "dax.h" | 25 | #include "dax.h" |
26 | 26 | ||
27 | static dev_t dax_devt; | 27 | static dev_t dax_devt; |
28 | DEFINE_STATIC_SRCU(dax_srcu); | ||
28 | static struct class *dax_class; | 29 | static struct class *dax_class; |
29 | static DEFINE_IDA(dax_minor_ida); | 30 | static DEFINE_IDA(dax_minor_ida); |
30 | static int nr_dax = CONFIG_NR_DEV_DAX; | 31 | static int nr_dax = CONFIG_NR_DEV_DAX; |
@@ -60,7 +61,7 @@ struct dax_region { | |||
60 | * @region - parent region | 61 | * @region - parent region |
61 | * @dev - device backing the character device | 62 | * @dev - device backing the character device |
62 | * @cdev - core chardev data | 63 | * @cdev - core chardev data |
63 | * @alive - !alive + rcu grace period == no new mappings can be established | 64 | * @alive - !alive + srcu grace period == no new mappings can be established |
64 | * @id - child id in the region | 65 | * @id - child id in the region |
65 | * @num_resources - number of physical address extents in this device | 66 | * @num_resources - number of physical address extents in this device |
66 | * @res - array of physical address ranges | 67 | * @res - array of physical address ranges |
@@ -569,7 +570,7 @@ static int __dax_dev_pud_fault(struct dax_dev *dax_dev, struct vm_fault *vmf) | |||
569 | static int dax_dev_huge_fault(struct vm_fault *vmf, | 570 | static int dax_dev_huge_fault(struct vm_fault *vmf, |
570 | enum page_entry_size pe_size) | 571 | enum page_entry_size pe_size) |
571 | { | 572 | { |
572 | int rc; | 573 | int rc, id; |
573 | struct file *filp = vmf->vma->vm_file; | 574 | struct file *filp = vmf->vma->vm_file; |
574 | struct dax_dev *dax_dev = filp->private_data; | 575 | struct dax_dev *dax_dev = filp->private_data; |
575 | 576 | ||
@@ -578,7 +579,7 @@ static int dax_dev_huge_fault(struct vm_fault *vmf, | |||
578 | ? "write" : "read", | 579 | ? "write" : "read", |
579 | vmf->vma->vm_start, vmf->vma->vm_end); | 580 | vmf->vma->vm_start, vmf->vma->vm_end); |
580 | 581 | ||
581 | rcu_read_lock(); | 582 | id = srcu_read_lock(&dax_srcu); |
582 | switch (pe_size) { | 583 | switch (pe_size) { |
583 | case PE_SIZE_PTE: | 584 | case PE_SIZE_PTE: |
584 | rc = __dax_dev_pte_fault(dax_dev, vmf); | 585 | rc = __dax_dev_pte_fault(dax_dev, vmf); |
@@ -592,7 +593,7 @@ static int dax_dev_huge_fault(struct vm_fault *vmf, | |||
592 | default: | 593 | default: |
593 | return VM_FAULT_FALLBACK; | 594 | return VM_FAULT_FALLBACK; |
594 | } | 595 | } |
595 | rcu_read_unlock(); | 596 | srcu_read_unlock(&dax_srcu, id); |
596 | 597 | ||
597 | return rc; | 598 | return rc; |
598 | } | 599 | } |
@@ -713,11 +714,11 @@ static void unregister_dax_dev(void *dev) | |||
713 | * Note, rcu is not protecting the liveness of dax_dev, rcu is | 714 | * Note, rcu is not protecting the liveness of dax_dev, rcu is |
714 | * ensuring that any fault handlers that might have seen | 715 | * ensuring that any fault handlers that might have seen |
715 | * dax_dev->alive == true, have completed. Any fault handlers | 716 | * dax_dev->alive == true, have completed. Any fault handlers |
716 | * that start after synchronize_rcu() has started will abort | 717 | * that start after synchronize_srcu() has started will abort |
717 | * upon seeing dax_dev->alive == false. | 718 | * upon seeing dax_dev->alive == false. |
718 | */ | 719 | */ |
719 | dax_dev->alive = false; | 720 | dax_dev->alive = false; |
720 | synchronize_rcu(); | 721 | synchronize_srcu(&dax_srcu); |
721 | unmap_mapping_range(dax_dev->inode->i_mapping, 0, 0, 1); | 722 | unmap_mapping_range(dax_dev->inode->i_mapping, 0, 0, 1); |
722 | cdev_del(cdev); | 723 | cdev_del(cdev); |
723 | device_unregister(dev); | 724 | device_unregister(dev); |
diff --git a/drivers/dma/bcm2835-dma.c b/drivers/dma/bcm2835-dma.c index e18dc596cf24..6204cc32d09c 100644 --- a/drivers/dma/bcm2835-dma.c +++ b/drivers/dma/bcm2835-dma.c | |||
@@ -251,8 +251,11 @@ static void bcm2835_dma_create_cb_set_length( | |||
251 | */ | 251 | */ |
252 | 252 | ||
253 | /* have we filled in period_length yet? */ | 253 | /* have we filled in period_length yet? */ |
254 | if (*total_len + control_block->length < period_len) | 254 | if (*total_len + control_block->length < period_len) { |
255 | /* update number of bytes in this period so far */ | ||
256 | *total_len += control_block->length; | ||
255 | return; | 257 | return; |
258 | } | ||
256 | 259 | ||
257 | /* calculate the length that remains to reach period_length */ | 260 | /* calculate the length that remains to reach period_length */ |
258 | control_block->length = period_len - *total_len; | 261 | control_block->length = period_len - *total_len; |
diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c index 24e0221fd66d..d9118ec23025 100644 --- a/drivers/dma/dmaengine.c +++ b/drivers/dma/dmaengine.c | |||
@@ -1108,12 +1108,14 @@ static struct dmaengine_unmap_pool *__get_unmap_pool(int nr) | |||
1108 | switch (order) { | 1108 | switch (order) { |
1109 | case 0 ... 1: | 1109 | case 0 ... 1: |
1110 | return &unmap_pool[0]; | 1110 | return &unmap_pool[0]; |
1111 | #if IS_ENABLED(CONFIG_DMA_ENGINE_RAID) | ||
1111 | case 2 ... 4: | 1112 | case 2 ... 4: |
1112 | return &unmap_pool[1]; | 1113 | return &unmap_pool[1]; |
1113 | case 5 ... 7: | 1114 | case 5 ... 7: |
1114 | return &unmap_pool[2]; | 1115 | return &unmap_pool[2]; |
1115 | case 8: | 1116 | case 8: |
1116 | return &unmap_pool[3]; | 1117 | return &unmap_pool[3]; |
1118 | #endif | ||
1117 | default: | 1119 | default: |
1118 | BUG(); | 1120 | BUG(); |
1119 | return NULL; | 1121 | return NULL; |
diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c index e7d404059b73..b372aad3b449 100644 --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c | |||
@@ -389,7 +389,6 @@ int __init efi_mem_desc_lookup(u64 phys_addr, efi_memory_desc_t *out_md) | |||
389 | return 0; | 389 | return 0; |
390 | } | 390 | } |
391 | } | 391 | } |
392 | pr_err_once("requested map not found.\n"); | ||
393 | return -ENOENT; | 392 | return -ENOENT; |
394 | } | 393 | } |
395 | 394 | ||
diff --git a/drivers/firmware/efi/esrt.c b/drivers/firmware/efi/esrt.c index 08b026864d4e..8554d7aec31c 100644 --- a/drivers/firmware/efi/esrt.c +++ b/drivers/firmware/efi/esrt.c | |||
@@ -254,7 +254,7 @@ void __init efi_esrt_init(void) | |||
254 | 254 | ||
255 | rc = efi_mem_desc_lookup(efi.esrt, &md); | 255 | rc = efi_mem_desc_lookup(efi.esrt, &md); |
256 | if (rc < 0) { | 256 | if (rc < 0) { |
257 | pr_err("ESRT header is not in the memory map.\n"); | 257 | pr_warn("ESRT header is not in the memory map.\n"); |
258 | return; | 258 | return; |
259 | } | 259 | } |
260 | 260 | ||
diff --git a/drivers/firmware/efi/libstub/gop.c b/drivers/firmware/efi/libstub/gop.c index 932742e4cf23..24c461dea7af 100644 --- a/drivers/firmware/efi/libstub/gop.c +++ b/drivers/firmware/efi/libstub/gop.c | |||
@@ -149,7 +149,8 @@ setup_gop32(efi_system_table_t *sys_table_arg, struct screen_info *si, | |||
149 | 149 | ||
150 | status = __gop_query32(sys_table_arg, gop32, &info, &size, | 150 | status = __gop_query32(sys_table_arg, gop32, &info, &size, |
151 | ¤t_fb_base); | 151 | ¤t_fb_base); |
152 | if (status == EFI_SUCCESS && (!first_gop || conout_found)) { | 152 | if (status == EFI_SUCCESS && (!first_gop || conout_found) && |
153 | info->pixel_format != PIXEL_BLT_ONLY) { | ||
153 | /* | 154 | /* |
154 | * Systems that use the UEFI Console Splitter may | 155 | * Systems that use the UEFI Console Splitter may |
155 | * provide multiple GOP devices, not all of which are | 156 | * provide multiple GOP devices, not all of which are |
@@ -266,7 +267,8 @@ setup_gop64(efi_system_table_t *sys_table_arg, struct screen_info *si, | |||
266 | 267 | ||
267 | status = __gop_query64(sys_table_arg, gop64, &info, &size, | 268 | status = __gop_query64(sys_table_arg, gop64, &info, &size, |
268 | ¤t_fb_base); | 269 | ¤t_fb_base); |
269 | if (status == EFI_SUCCESS && (!first_gop || conout_found)) { | 270 | if (status == EFI_SUCCESS && (!first_gop || conout_found) && |
271 | info->pixel_format != PIXEL_BLT_ONLY) { | ||
270 | /* | 272 | /* |
271 | * Systems that use the UEFI Console Splitter may | 273 | * Systems that use the UEFI Console Splitter may |
272 | * provide multiple GOP devices, not all of which are | 274 | * provide multiple GOP devices, not all of which are |
diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c index 9b37a3692b3f..2bd683e2be02 100644 --- a/drivers/gpio/gpiolib-acpi.c +++ b/drivers/gpio/gpiolib-acpi.c | |||
@@ -266,6 +266,9 @@ static acpi_status acpi_gpiochip_request_interrupt(struct acpi_resource *ares, | |||
266 | goto fail_free_event; | 266 | goto fail_free_event; |
267 | } | 267 | } |
268 | 268 | ||
269 | if (agpio->wake_capable == ACPI_WAKE_CAPABLE) | ||
270 | enable_irq_wake(irq); | ||
271 | |||
269 | list_add_tail(&event->node, &acpi_gpio->events); | 272 | list_add_tail(&event->node, &acpi_gpio->events); |
270 | return AE_OK; | 273 | return AE_OK; |
271 | 274 | ||
@@ -339,6 +342,9 @@ void acpi_gpiochip_free_interrupts(struct gpio_chip *chip) | |||
339 | list_for_each_entry_safe_reverse(event, ep, &acpi_gpio->events, node) { | 342 | list_for_each_entry_safe_reverse(event, ep, &acpi_gpio->events, node) { |
340 | struct gpio_desc *desc; | 343 | struct gpio_desc *desc; |
341 | 344 | ||
345 | if (irqd_is_wakeup_set(irq_get_irq_data(event->irq))) | ||
346 | disable_irq_wake(event->irq); | ||
347 | |||
342 | free_irq(event->irq, event); | 348 | free_irq(event->irq, event); |
343 | desc = event->desc; | 349 | desc = event->desc; |
344 | if (WARN_ON(IS_ERR(desc))) | 350 | if (WARN_ON(IS_ERR(desc))) |
@@ -571,8 +577,10 @@ struct gpio_desc *acpi_find_gpio(struct device *dev, | |||
571 | } | 577 | } |
572 | 578 | ||
573 | desc = acpi_get_gpiod_by_index(adev, propname, idx, &info); | 579 | desc = acpi_get_gpiod_by_index(adev, propname, idx, &info); |
574 | if (!IS_ERR(desc) || (PTR_ERR(desc) == -EPROBE_DEFER)) | 580 | if (!IS_ERR(desc)) |
575 | break; | 581 | break; |
582 | if (PTR_ERR(desc) == -EPROBE_DEFER) | ||
583 | return ERR_CAST(desc); | ||
576 | } | 584 | } |
577 | 585 | ||
578 | /* Then from plain _CRS GPIOs */ | 586 | /* Then from plain _CRS GPIOs */ |
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c index 130d7d517a19..b78d9239e48f 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c | |||
@@ -1311,15 +1311,15 @@ int etnaviv_gpu_submit(struct etnaviv_gpu *gpu, | |||
1311 | goto out_pm_put; | 1311 | goto out_pm_put; |
1312 | } | 1312 | } |
1313 | 1313 | ||
1314 | mutex_lock(&gpu->lock); | ||
1315 | |||
1314 | fence = etnaviv_gpu_fence_alloc(gpu); | 1316 | fence = etnaviv_gpu_fence_alloc(gpu); |
1315 | if (!fence) { | 1317 | if (!fence) { |
1316 | event_free(gpu, event); | 1318 | event_free(gpu, event); |
1317 | ret = -ENOMEM; | 1319 | ret = -ENOMEM; |
1318 | goto out_pm_put; | 1320 | goto out_unlock; |
1319 | } | 1321 | } |
1320 | 1322 | ||
1321 | mutex_lock(&gpu->lock); | ||
1322 | |||
1323 | gpu->event[event].fence = fence; | 1323 | gpu->event[event].fence = fence; |
1324 | submit->fence = fence->seqno; | 1324 | submit->fence = fence->seqno; |
1325 | gpu->active_fence = submit->fence; | 1325 | gpu->active_fence = submit->fence; |
@@ -1357,6 +1357,7 @@ int etnaviv_gpu_submit(struct etnaviv_gpu *gpu, | |||
1357 | hangcheck_timer_reset(gpu); | 1357 | hangcheck_timer_reset(gpu); |
1358 | ret = 0; | 1358 | ret = 0; |
1359 | 1359 | ||
1360 | out_unlock: | ||
1360 | mutex_unlock(&gpu->lock); | 1361 | mutex_unlock(&gpu->lock); |
1361 | 1362 | ||
1362 | out_pm_put: | 1363 | out_pm_put: |
diff --git a/drivers/gpu/drm/i915/gvt/cfg_space.c b/drivers/gpu/drm/i915/gvt/cfg_space.c index b7d7721e72fa..40af17ec6312 100644 --- a/drivers/gpu/drm/i915/gvt/cfg_space.c +++ b/drivers/gpu/drm/i915/gvt/cfg_space.c | |||
@@ -285,9 +285,6 @@ int intel_vgpu_emulate_cfg_write(struct intel_vgpu *vgpu, unsigned int offset, | |||
285 | { | 285 | { |
286 | int ret; | 286 | int ret; |
287 | 287 | ||
288 | if (vgpu->failsafe) | ||
289 | return 0; | ||
290 | |||
291 | if (WARN_ON(bytes > 4)) | 288 | if (WARN_ON(bytes > 4)) |
292 | return -EINVAL; | 289 | return -EINVAL; |
293 | 290 | ||
diff --git a/drivers/gpu/drm/i915/gvt/edid.c b/drivers/gpu/drm/i915/gvt/edid.c index f1648fe5e5ea..42cd09ec63fa 100644 --- a/drivers/gpu/drm/i915/gvt/edid.c +++ b/drivers/gpu/drm/i915/gvt/edid.c | |||
@@ -495,7 +495,8 @@ void intel_gvt_i2c_handle_aux_ch_write(struct intel_vgpu *vgpu, | |||
495 | unsigned char val = edid_get_byte(vgpu); | 495 | unsigned char val = edid_get_byte(vgpu); |
496 | 496 | ||
497 | aux_data_for_write = (val << 16); | 497 | aux_data_for_write = (val << 16); |
498 | } | 498 | } else |
499 | aux_data_for_write = (0xff << 16); | ||
499 | } | 500 | } |
500 | /* write the return value in AUX_CH_DATA reg which includes: | 501 | /* write the return value in AUX_CH_DATA reg which includes: |
501 | * ACK of I2C_WRITE | 502 | * ACK of I2C_WRITE |
diff --git a/drivers/gpu/drm/i915/gvt/execlist.c b/drivers/gpu/drm/i915/gvt/execlist.c index f1f426a97aa9..d186c157f65f 100644 --- a/drivers/gpu/drm/i915/gvt/execlist.c +++ b/drivers/gpu/drm/i915/gvt/execlist.c | |||
@@ -775,7 +775,8 @@ static void init_vgpu_execlist(struct intel_vgpu *vgpu, int ring_id) | |||
775 | _EL_OFFSET_STATUS_PTR); | 775 | _EL_OFFSET_STATUS_PTR); |
776 | 776 | ||
777 | ctx_status_ptr.dw = vgpu_vreg(vgpu, ctx_status_ptr_reg); | 777 | ctx_status_ptr.dw = vgpu_vreg(vgpu, ctx_status_ptr_reg); |
778 | ctx_status_ptr.read_ptr = ctx_status_ptr.write_ptr = 0x7; | 778 | ctx_status_ptr.read_ptr = 0; |
779 | ctx_status_ptr.write_ptr = 0x7; | ||
779 | vgpu_vreg(vgpu, ctx_status_ptr_reg) = ctx_status_ptr.dw; | 780 | vgpu_vreg(vgpu, ctx_status_ptr_reg) = ctx_status_ptr.dw; |
780 | } | 781 | } |
781 | 782 | ||
diff --git a/drivers/gpu/drm/i915/gvt/firmware.c b/drivers/gpu/drm/i915/gvt/firmware.c index 933a7c211a1c..dce8d15f706f 100644 --- a/drivers/gpu/drm/i915/gvt/firmware.c +++ b/drivers/gpu/drm/i915/gvt/firmware.c | |||
@@ -75,11 +75,11 @@ static int expose_firmware_sysfs(struct intel_gvt *gvt) | |||
75 | struct gvt_firmware_header *h; | 75 | struct gvt_firmware_header *h; |
76 | void *firmware; | 76 | void *firmware; |
77 | void *p; | 77 | void *p; |
78 | unsigned long size; | 78 | unsigned long size, crc32_start; |
79 | int i; | 79 | int i; |
80 | int ret; | 80 | int ret; |
81 | 81 | ||
82 | size = sizeof(*h) + info->mmio_size + info->cfg_space_size - 1; | 82 | size = sizeof(*h) + info->mmio_size + info->cfg_space_size; |
83 | firmware = vzalloc(size); | 83 | firmware = vzalloc(size); |
84 | if (!firmware) | 84 | if (!firmware) |
85 | return -ENOMEM; | 85 | return -ENOMEM; |
@@ -112,6 +112,9 @@ static int expose_firmware_sysfs(struct intel_gvt *gvt) | |||
112 | 112 | ||
113 | memcpy(gvt->firmware.mmio, p, info->mmio_size); | 113 | memcpy(gvt->firmware.mmio, p, info->mmio_size); |
114 | 114 | ||
115 | crc32_start = offsetof(struct gvt_firmware_header, crc32) + 4; | ||
116 | h->crc32 = crc32_le(0, firmware + crc32_start, size - crc32_start); | ||
117 | |||
115 | firmware_attr.size = size; | 118 | firmware_attr.size = size; |
116 | firmware_attr.private = firmware; | 119 | firmware_attr.private = firmware; |
117 | 120 | ||
@@ -234,7 +237,7 @@ int intel_gvt_load_firmware(struct intel_gvt *gvt) | |||
234 | 237 | ||
235 | firmware->mmio = mem; | 238 | firmware->mmio = mem; |
236 | 239 | ||
237 | sprintf(path, "%s/vid_0x%04x_did_0x%04x_rid_0x%04x.golden_hw_state", | 240 | sprintf(path, "%s/vid_0x%04x_did_0x%04x_rid_0x%02x.golden_hw_state", |
238 | GVT_FIRMWARE_PATH, pdev->vendor, pdev->device, | 241 | GVT_FIRMWARE_PATH, pdev->vendor, pdev->device, |
239 | pdev->revision); | 242 | pdev->revision); |
240 | 243 | ||
diff --git a/drivers/gpu/drm/i915/gvt/gtt.c b/drivers/gpu/drm/i915/gvt/gtt.c index da7312715824..b832bea64e03 100644 --- a/drivers/gpu/drm/i915/gvt/gtt.c +++ b/drivers/gpu/drm/i915/gvt/gtt.c | |||
@@ -1837,11 +1837,15 @@ static int emulate_gtt_mmio_write(struct intel_vgpu *vgpu, unsigned int off, | |||
1837 | ret = gtt_entry_p2m(vgpu, &e, &m); | 1837 | ret = gtt_entry_p2m(vgpu, &e, &m); |
1838 | if (ret) { | 1838 | if (ret) { |
1839 | gvt_vgpu_err("fail to translate guest gtt entry\n"); | 1839 | gvt_vgpu_err("fail to translate guest gtt entry\n"); |
1840 | return ret; | 1840 | /* guest driver may read/write the entry when partial |
1841 | * update the entry in this situation p2m will fail | ||
1842 | * settting the shadow entry to point to a scratch page | ||
1843 | */ | ||
1844 | ops->set_pfn(&m, gvt->gtt.scratch_ggtt_mfn); | ||
1841 | } | 1845 | } |
1842 | } else { | 1846 | } else { |
1843 | m = e; | 1847 | m = e; |
1844 | m.val64 = 0; | 1848 | ops->set_pfn(&m, gvt->gtt.scratch_ggtt_mfn); |
1845 | } | 1849 | } |
1846 | 1850 | ||
1847 | ggtt_set_shadow_entry(ggtt_mm, &m, g_gtt_index); | 1851 | ggtt_set_shadow_entry(ggtt_mm, &m, g_gtt_index); |
diff --git a/drivers/gpu/drm/i915/gvt/gvt.c b/drivers/gpu/drm/i915/gvt/gvt.c index 3b9d59e457ba..ef3baa0c4754 100644 --- a/drivers/gpu/drm/i915/gvt/gvt.c +++ b/drivers/gpu/drm/i915/gvt/gvt.c | |||
@@ -52,6 +52,8 @@ static const struct intel_gvt_ops intel_gvt_ops = { | |||
52 | .vgpu_create = intel_gvt_create_vgpu, | 52 | .vgpu_create = intel_gvt_create_vgpu, |
53 | .vgpu_destroy = intel_gvt_destroy_vgpu, | 53 | .vgpu_destroy = intel_gvt_destroy_vgpu, |
54 | .vgpu_reset = intel_gvt_reset_vgpu, | 54 | .vgpu_reset = intel_gvt_reset_vgpu, |
55 | .vgpu_activate = intel_gvt_activate_vgpu, | ||
56 | .vgpu_deactivate = intel_gvt_deactivate_vgpu, | ||
55 | }; | 57 | }; |
56 | 58 | ||
57 | /** | 59 | /** |
diff --git a/drivers/gpu/drm/i915/gvt/gvt.h b/drivers/gpu/drm/i915/gvt/gvt.h index 6dfc48b63b71..becae2fa3b29 100644 --- a/drivers/gpu/drm/i915/gvt/gvt.h +++ b/drivers/gpu/drm/i915/gvt/gvt.h | |||
@@ -382,7 +382,8 @@ void intel_gvt_destroy_vgpu(struct intel_vgpu *vgpu); | |||
382 | void intel_gvt_reset_vgpu_locked(struct intel_vgpu *vgpu, bool dmlr, | 382 | void intel_gvt_reset_vgpu_locked(struct intel_vgpu *vgpu, bool dmlr, |
383 | unsigned int engine_mask); | 383 | unsigned int engine_mask); |
384 | void intel_gvt_reset_vgpu(struct intel_vgpu *vgpu); | 384 | void intel_gvt_reset_vgpu(struct intel_vgpu *vgpu); |
385 | 385 | void intel_gvt_activate_vgpu(struct intel_vgpu *vgpu); | |
386 | void intel_gvt_deactivate_vgpu(struct intel_vgpu *vgpu); | ||
386 | 387 | ||
387 | /* validating GM functions */ | 388 | /* validating GM functions */ |
388 | #define vgpu_gmadr_is_aperture(vgpu, gmadr) \ | 389 | #define vgpu_gmadr_is_aperture(vgpu, gmadr) \ |
@@ -449,6 +450,8 @@ struct intel_gvt_ops { | |||
449 | struct intel_vgpu_type *); | 450 | struct intel_vgpu_type *); |
450 | void (*vgpu_destroy)(struct intel_vgpu *); | 451 | void (*vgpu_destroy)(struct intel_vgpu *); |
451 | void (*vgpu_reset)(struct intel_vgpu *); | 452 | void (*vgpu_reset)(struct intel_vgpu *); |
453 | void (*vgpu_activate)(struct intel_vgpu *); | ||
454 | void (*vgpu_deactivate)(struct intel_vgpu *); | ||
452 | }; | 455 | }; |
453 | 456 | ||
454 | 457 | ||
diff --git a/drivers/gpu/drm/i915/gvt/handlers.c b/drivers/gpu/drm/i915/gvt/handlers.c index eaff45d417e8..6da9ae1618e3 100644 --- a/drivers/gpu/drm/i915/gvt/handlers.c +++ b/drivers/gpu/drm/i915/gvt/handlers.c | |||
@@ -970,6 +970,14 @@ static int dp_aux_ch_ctl_mmio_write(struct intel_vgpu *vgpu, | |||
970 | return 0; | 970 | return 0; |
971 | } | 971 | } |
972 | 972 | ||
973 | static int mbctl_write(struct intel_vgpu *vgpu, unsigned int offset, | ||
974 | void *p_data, unsigned int bytes) | ||
975 | { | ||
976 | *(u32 *)p_data &= (~GEN6_MBCTL_ENABLE_BOOT_FETCH); | ||
977 | write_vreg(vgpu, offset, p_data, bytes); | ||
978 | return 0; | ||
979 | } | ||
980 | |||
973 | static int vga_control_mmio_write(struct intel_vgpu *vgpu, unsigned int offset, | 981 | static int vga_control_mmio_write(struct intel_vgpu *vgpu, unsigned int offset, |
974 | void *p_data, unsigned int bytes) | 982 | void *p_data, unsigned int bytes) |
975 | { | 983 | { |
@@ -2238,7 +2246,7 @@ static int init_generic_mmio_info(struct intel_gvt *gvt) | |||
2238 | MMIO_D(0x7180, D_ALL); | 2246 | MMIO_D(0x7180, D_ALL); |
2239 | MMIO_D(0x7408, D_ALL); | 2247 | MMIO_D(0x7408, D_ALL); |
2240 | MMIO_D(0x7c00, D_ALL); | 2248 | MMIO_D(0x7c00, D_ALL); |
2241 | MMIO_D(GEN6_MBCTL, D_ALL); | 2249 | MMIO_DH(GEN6_MBCTL, D_ALL, NULL, mbctl_write); |
2242 | MMIO_D(0x911c, D_ALL); | 2250 | MMIO_D(0x911c, D_ALL); |
2243 | MMIO_D(0x9120, D_ALL); | 2251 | MMIO_D(0x9120, D_ALL); |
2244 | MMIO_DFH(GEN7_UCGCTL4, D_ALL, F_CMD_ACCESS, NULL, NULL); | 2252 | MMIO_DFH(GEN7_UCGCTL4, D_ALL, F_CMD_ACCESS, NULL, NULL); |
diff --git a/drivers/gpu/drm/i915/gvt/kvmgt.c b/drivers/gpu/drm/i915/gvt/kvmgt.c index 1ea3eb270de8..e466259034e2 100644 --- a/drivers/gpu/drm/i915/gvt/kvmgt.c +++ b/drivers/gpu/drm/i915/gvt/kvmgt.c | |||
@@ -544,6 +544,8 @@ static int intel_vgpu_open(struct mdev_device *mdev) | |||
544 | if (ret) | 544 | if (ret) |
545 | goto undo_group; | 545 | goto undo_group; |
546 | 546 | ||
547 | intel_gvt_ops->vgpu_activate(vgpu); | ||
548 | |||
547 | atomic_set(&vgpu->vdev.released, 0); | 549 | atomic_set(&vgpu->vdev.released, 0); |
548 | return ret; | 550 | return ret; |
549 | 551 | ||
@@ -569,6 +571,8 @@ static void __intel_vgpu_release(struct intel_vgpu *vgpu) | |||
569 | if (atomic_cmpxchg(&vgpu->vdev.released, 0, 1)) | 571 | if (atomic_cmpxchg(&vgpu->vdev.released, 0, 1)) |
570 | return; | 572 | return; |
571 | 573 | ||
574 | intel_gvt_ops->vgpu_deactivate(vgpu); | ||
575 | |||
572 | ret = vfio_unregister_notifier(mdev_dev(vgpu->vdev.mdev), VFIO_IOMMU_NOTIFY, | 576 | ret = vfio_unregister_notifier(mdev_dev(vgpu->vdev.mdev), VFIO_IOMMU_NOTIFY, |
573 | &vgpu->vdev.iommu_notifier); | 577 | &vgpu->vdev.iommu_notifier); |
574 | WARN(ret, "vfio_unregister_notifier for iommu failed: %d\n", ret); | 578 | WARN(ret, "vfio_unregister_notifier for iommu failed: %d\n", ret); |
@@ -1326,6 +1330,7 @@ static int kvmgt_guest_init(struct mdev_device *mdev) | |||
1326 | vgpu->handle = (unsigned long)info; | 1330 | vgpu->handle = (unsigned long)info; |
1327 | info->vgpu = vgpu; | 1331 | info->vgpu = vgpu; |
1328 | info->kvm = kvm; | 1332 | info->kvm = kvm; |
1333 | kvm_get_kvm(info->kvm); | ||
1329 | 1334 | ||
1330 | kvmgt_protect_table_init(info); | 1335 | kvmgt_protect_table_init(info); |
1331 | gvt_cache_init(vgpu); | 1336 | gvt_cache_init(vgpu); |
@@ -1339,14 +1344,8 @@ static int kvmgt_guest_init(struct mdev_device *mdev) | |||
1339 | 1344 | ||
1340 | static bool kvmgt_guest_exit(struct kvmgt_guest_info *info) | 1345 | static bool kvmgt_guest_exit(struct kvmgt_guest_info *info) |
1341 | { | 1346 | { |
1342 | struct intel_vgpu *vgpu = info->vgpu; | ||
1343 | |||
1344 | if (!info) { | ||
1345 | gvt_vgpu_err("kvmgt_guest_info invalid\n"); | ||
1346 | return false; | ||
1347 | } | ||
1348 | |||
1349 | kvm_page_track_unregister_notifier(info->kvm, &info->track_node); | 1347 | kvm_page_track_unregister_notifier(info->kvm, &info->track_node); |
1348 | kvm_put_kvm(info->kvm); | ||
1350 | kvmgt_protect_table_destroy(info); | 1349 | kvmgt_protect_table_destroy(info); |
1351 | gvt_cache_destroy(info->vgpu); | 1350 | gvt_cache_destroy(info->vgpu); |
1352 | vfree(info); | 1351 | vfree(info); |
diff --git a/drivers/gpu/drm/i915/gvt/render.c b/drivers/gpu/drm/i915/gvt/render.c index 95ee091ce085..0beb83563b08 100644 --- a/drivers/gpu/drm/i915/gvt/render.c +++ b/drivers/gpu/drm/i915/gvt/render.c | |||
@@ -207,7 +207,7 @@ static void load_mocs(struct intel_vgpu *vgpu, int ring_id) | |||
207 | l3_offset.reg = 0xb020; | 207 | l3_offset.reg = 0xb020; |
208 | for (i = 0; i < 32; i++) { | 208 | for (i = 0; i < 32; i++) { |
209 | gen9_render_mocs_L3[i] = I915_READ(l3_offset); | 209 | gen9_render_mocs_L3[i] = I915_READ(l3_offset); |
210 | I915_WRITE(l3_offset, vgpu_vreg(vgpu, offset)); | 210 | I915_WRITE(l3_offset, vgpu_vreg(vgpu, l3_offset)); |
211 | POSTING_READ(l3_offset); | 211 | POSTING_READ(l3_offset); |
212 | l3_offset.reg += 4; | 212 | l3_offset.reg += 4; |
213 | } | 213 | } |
diff --git a/drivers/gpu/drm/i915/gvt/scheduler.c b/drivers/gpu/drm/i915/gvt/scheduler.c index c4353ed86d4b..a44782412f2c 100644 --- a/drivers/gpu/drm/i915/gvt/scheduler.c +++ b/drivers/gpu/drm/i915/gvt/scheduler.c | |||
@@ -127,6 +127,11 @@ static int populate_shadow_context(struct intel_vgpu_workload *workload) | |||
127 | return 0; | 127 | return 0; |
128 | } | 128 | } |
129 | 129 | ||
130 | static inline bool is_gvt_request(struct drm_i915_gem_request *req) | ||
131 | { | ||
132 | return i915_gem_context_force_single_submission(req->ctx); | ||
133 | } | ||
134 | |||
130 | static int shadow_context_status_change(struct notifier_block *nb, | 135 | static int shadow_context_status_change(struct notifier_block *nb, |
131 | unsigned long action, void *data) | 136 | unsigned long action, void *data) |
132 | { | 137 | { |
@@ -137,7 +142,7 @@ static int shadow_context_status_change(struct notifier_block *nb, | |||
137 | struct intel_vgpu_workload *workload = | 142 | struct intel_vgpu_workload *workload = |
138 | scheduler->current_workload[req->engine->id]; | 143 | scheduler->current_workload[req->engine->id]; |
139 | 144 | ||
140 | if (unlikely(!workload)) | 145 | if (!is_gvt_request(req) || unlikely(!workload)) |
141 | return NOTIFY_OK; | 146 | return NOTIFY_OK; |
142 | 147 | ||
143 | switch (action) { | 148 | switch (action) { |
diff --git a/drivers/gpu/drm/i915/gvt/vgpu.c b/drivers/gpu/drm/i915/gvt/vgpu.c index 41cfa5ccae84..649ef280cc9a 100644 --- a/drivers/gpu/drm/i915/gvt/vgpu.c +++ b/drivers/gpu/drm/i915/gvt/vgpu.c | |||
@@ -72,7 +72,7 @@ static struct { | |||
72 | char *name; | 72 | char *name; |
73 | } vgpu_types[] = { | 73 | } vgpu_types[] = { |
74 | /* Fixed vGPU type table */ | 74 | /* Fixed vGPU type table */ |
75 | { MB_TO_BYTES(64), MB_TO_BYTES(512), 4, GVT_EDID_1024_768, "8" }, | 75 | { MB_TO_BYTES(64), MB_TO_BYTES(384), 4, GVT_EDID_1024_768, "8" }, |
76 | { MB_TO_BYTES(128), MB_TO_BYTES(512), 4, GVT_EDID_1920_1200, "4" }, | 76 | { MB_TO_BYTES(128), MB_TO_BYTES(512), 4, GVT_EDID_1920_1200, "4" }, |
77 | { MB_TO_BYTES(256), MB_TO_BYTES(1024), 4, GVT_EDID_1920_1200, "2" }, | 77 | { MB_TO_BYTES(256), MB_TO_BYTES(1024), 4, GVT_EDID_1920_1200, "2" }, |
78 | { MB_TO_BYTES(512), MB_TO_BYTES(2048), 4, GVT_EDID_1920_1200, "1" }, | 78 | { MB_TO_BYTES(512), MB_TO_BYTES(2048), 4, GVT_EDID_1920_1200, "1" }, |
@@ -179,20 +179,34 @@ static void intel_gvt_update_vgpu_types(struct intel_gvt *gvt) | |||
179 | } | 179 | } |
180 | 180 | ||
181 | /** | 181 | /** |
182 | * intel_gvt_destroy_vgpu - destroy a virtual GPU | 182 | * intel_gvt_active_vgpu - activate a virtual GPU |
183 | * @vgpu: virtual GPU | 183 | * @vgpu: virtual GPU |
184 | * | 184 | * |
185 | * This function is called when user wants to destroy a virtual GPU. | 185 | * This function is called when user wants to activate a virtual GPU. |
186 | * | 186 | * |
187 | */ | 187 | */ |
188 | void intel_gvt_destroy_vgpu(struct intel_vgpu *vgpu) | 188 | void intel_gvt_activate_vgpu(struct intel_vgpu *vgpu) |
189 | { | ||
190 | mutex_lock(&vgpu->gvt->lock); | ||
191 | vgpu->active = true; | ||
192 | mutex_unlock(&vgpu->gvt->lock); | ||
193 | } | ||
194 | |||
195 | /** | ||
196 | * intel_gvt_deactive_vgpu - deactivate a virtual GPU | ||
197 | * @vgpu: virtual GPU | ||
198 | * | ||
199 | * This function is called when user wants to deactivate a virtual GPU. | ||
200 | * All virtual GPU runtime information will be destroyed. | ||
201 | * | ||
202 | */ | ||
203 | void intel_gvt_deactivate_vgpu(struct intel_vgpu *vgpu) | ||
189 | { | 204 | { |
190 | struct intel_gvt *gvt = vgpu->gvt; | 205 | struct intel_gvt *gvt = vgpu->gvt; |
191 | 206 | ||
192 | mutex_lock(&gvt->lock); | 207 | mutex_lock(&gvt->lock); |
193 | 208 | ||
194 | vgpu->active = false; | 209 | vgpu->active = false; |
195 | idr_remove(&gvt->vgpu_idr, vgpu->id); | ||
196 | 210 | ||
197 | if (atomic_read(&vgpu->running_workload_num)) { | 211 | if (atomic_read(&vgpu->running_workload_num)) { |
198 | mutex_unlock(&gvt->lock); | 212 | mutex_unlock(&gvt->lock); |
@@ -201,6 +215,26 @@ void intel_gvt_destroy_vgpu(struct intel_vgpu *vgpu) | |||
201 | } | 215 | } |
202 | 216 | ||
203 | intel_vgpu_stop_schedule(vgpu); | 217 | intel_vgpu_stop_schedule(vgpu); |
218 | |||
219 | mutex_unlock(&gvt->lock); | ||
220 | } | ||
221 | |||
222 | /** | ||
223 | * intel_gvt_destroy_vgpu - destroy a virtual GPU | ||
224 | * @vgpu: virtual GPU | ||
225 | * | ||
226 | * This function is called when user wants to destroy a virtual GPU. | ||
227 | * | ||
228 | */ | ||
229 | void intel_gvt_destroy_vgpu(struct intel_vgpu *vgpu) | ||
230 | { | ||
231 | struct intel_gvt *gvt = vgpu->gvt; | ||
232 | |||
233 | mutex_lock(&gvt->lock); | ||
234 | |||
235 | WARN(vgpu->active, "vGPU is still active!\n"); | ||
236 | |||
237 | idr_remove(&gvt->vgpu_idr, vgpu->id); | ||
204 | intel_vgpu_clean_sched_policy(vgpu); | 238 | intel_vgpu_clean_sched_policy(vgpu); |
205 | intel_vgpu_clean_gvt_context(vgpu); | 239 | intel_vgpu_clean_gvt_context(vgpu); |
206 | intel_vgpu_clean_execlist(vgpu); | 240 | intel_vgpu_clean_execlist(vgpu); |
@@ -277,7 +311,6 @@ static struct intel_vgpu *__intel_gvt_create_vgpu(struct intel_gvt *gvt, | |||
277 | if (ret) | 311 | if (ret) |
278 | goto out_clean_shadow_ctx; | 312 | goto out_clean_shadow_ctx; |
279 | 313 | ||
280 | vgpu->active = true; | ||
281 | mutex_unlock(&gvt->lock); | 314 | mutex_unlock(&gvt->lock); |
282 | 315 | ||
283 | return vgpu; | 316 | return vgpu; |
diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c index 1c75402a59c1..5c089b3c2a7e 100644 --- a/drivers/gpu/drm/i915/i915_drv.c +++ b/drivers/gpu/drm/i915/i915_drv.c | |||
@@ -1434,8 +1434,6 @@ static int i915_drm_suspend(struct drm_device *dev) | |||
1434 | goto out; | 1434 | goto out; |
1435 | } | 1435 | } |
1436 | 1436 | ||
1437 | intel_guc_suspend(dev_priv); | ||
1438 | |||
1439 | intel_display_suspend(dev); | 1437 | intel_display_suspend(dev); |
1440 | 1438 | ||
1441 | intel_dp_mst_suspend(dev); | 1439 | intel_dp_mst_suspend(dev); |
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index 1e53c31b6826..46fcd8b7080a 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h | |||
@@ -806,6 +806,7 @@ struct intel_csr { | |||
806 | func(has_resource_streamer); \ | 806 | func(has_resource_streamer); \ |
807 | func(has_runtime_pm); \ | 807 | func(has_runtime_pm); \ |
808 | func(has_snoop); \ | 808 | func(has_snoop); \ |
809 | func(unfenced_needs_alignment); \ | ||
809 | func(cursor_needs_physical); \ | 810 | func(cursor_needs_physical); \ |
810 | func(hws_needs_physical); \ | 811 | func(hws_needs_physical); \ |
811 | func(overlay_needs_physical); \ | 812 | func(overlay_needs_physical); \ |
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index 67b1fc5a0331..fe531f904062 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c | |||
@@ -4348,6 +4348,8 @@ int i915_gem_suspend(struct drm_i915_private *dev_priv) | |||
4348 | i915_gem_context_lost(dev_priv); | 4348 | i915_gem_context_lost(dev_priv); |
4349 | mutex_unlock(&dev->struct_mutex); | 4349 | mutex_unlock(&dev->struct_mutex); |
4350 | 4350 | ||
4351 | intel_guc_suspend(dev_priv); | ||
4352 | |||
4351 | cancel_delayed_work_sync(&dev_priv->gpu_error.hangcheck_work); | 4353 | cancel_delayed_work_sync(&dev_priv->gpu_error.hangcheck_work); |
4352 | cancel_delayed_work_sync(&dev_priv->gt.retire_work); | 4354 | cancel_delayed_work_sync(&dev_priv->gt.retire_work); |
4353 | 4355 | ||
diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c index 30e0675fd7da..15a15d00a6bf 100644 --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c | |||
@@ -888,6 +888,7 @@ i915_gem_execbuffer_reserve(struct intel_engine_cs *engine, | |||
888 | struct list_head ordered_vmas; | 888 | struct list_head ordered_vmas; |
889 | struct list_head pinned_vmas; | 889 | struct list_head pinned_vmas; |
890 | bool has_fenced_gpu_access = INTEL_GEN(engine->i915) < 4; | 890 | bool has_fenced_gpu_access = INTEL_GEN(engine->i915) < 4; |
891 | bool needs_unfenced_map = INTEL_INFO(engine->i915)->unfenced_needs_alignment; | ||
891 | int retry; | 892 | int retry; |
892 | 893 | ||
893 | vm = list_first_entry(vmas, struct i915_vma, exec_list)->vm; | 894 | vm = list_first_entry(vmas, struct i915_vma, exec_list)->vm; |
@@ -908,7 +909,8 @@ i915_gem_execbuffer_reserve(struct intel_engine_cs *engine, | |||
908 | if (!has_fenced_gpu_access) | 909 | if (!has_fenced_gpu_access) |
909 | entry->flags &= ~EXEC_OBJECT_NEEDS_FENCE; | 910 | entry->flags &= ~EXEC_OBJECT_NEEDS_FENCE; |
910 | need_fence = | 911 | need_fence = |
911 | entry->flags & EXEC_OBJECT_NEEDS_FENCE && | 912 | (entry->flags & EXEC_OBJECT_NEEDS_FENCE || |
913 | needs_unfenced_map) && | ||
912 | i915_gem_object_is_tiled(obj); | 914 | i915_gem_object_is_tiled(obj); |
913 | need_mappable = need_fence || need_reloc_mappable(vma); | 915 | need_mappable = need_fence || need_reloc_mappable(vma); |
914 | 916 | ||
diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c index 2801a4d56324..96e45a4d5441 100644 --- a/drivers/gpu/drm/i915/i915_gem_gtt.c +++ b/drivers/gpu/drm/i915/i915_gem_gtt.c | |||
@@ -2704,7 +2704,7 @@ void i915_gem_gtt_finish_pages(struct drm_i915_gem_object *obj, | |||
2704 | struct i915_ggtt *ggtt = &dev_priv->ggtt; | 2704 | struct i915_ggtt *ggtt = &dev_priv->ggtt; |
2705 | 2705 | ||
2706 | if (unlikely(ggtt->do_idle_maps)) { | 2706 | if (unlikely(ggtt->do_idle_maps)) { |
2707 | if (i915_gem_wait_for_idle(dev_priv, I915_WAIT_LOCKED)) { | 2707 | if (i915_gem_wait_for_idle(dev_priv, 0)) { |
2708 | DRM_ERROR("Failed to wait for idle; VT'd may hang.\n"); | 2708 | DRM_ERROR("Failed to wait for idle; VT'd may hang.\n"); |
2709 | /* Wait a bit, in hopes it avoids the hang */ | 2709 | /* Wait a bit, in hopes it avoids the hang */ |
2710 | udelay(10); | 2710 | udelay(10); |
diff --git a/drivers/gpu/drm/i915/i915_gem_request.c b/drivers/gpu/drm/i915/i915_gem_request.c index e7c3c0318ff6..da70bfe97ec5 100644 --- a/drivers/gpu/drm/i915/i915_gem_request.c +++ b/drivers/gpu/drm/i915/i915_gem_request.c | |||
@@ -37,6 +37,17 @@ static const char *i915_fence_get_driver_name(struct dma_fence *fence) | |||
37 | 37 | ||
38 | static const char *i915_fence_get_timeline_name(struct dma_fence *fence) | 38 | static const char *i915_fence_get_timeline_name(struct dma_fence *fence) |
39 | { | 39 | { |
40 | /* The timeline struct (as part of the ppgtt underneath a context) | ||
41 | * may be freed when the request is no longer in use by the GPU. | ||
42 | * We could extend the life of a context to beyond that of all | ||
43 | * fences, possibly keeping the hw resource around indefinitely, | ||
44 | * or we just give them a false name. Since | ||
45 | * dma_fence_ops.get_timeline_name is a debug feature, the occasional | ||
46 | * lie seems justifiable. | ||
47 | */ | ||
48 | if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags)) | ||
49 | return "signaled"; | ||
50 | |||
40 | return to_request(fence)->timeline->common->name; | 51 | return to_request(fence)->timeline->common->name; |
41 | } | 52 | } |
42 | 53 | ||
diff --git a/drivers/gpu/drm/i915/i915_gem_shrinker.c b/drivers/gpu/drm/i915/i915_gem_shrinker.c index d5d2b4c6ed38..70b3832a79dd 100644 --- a/drivers/gpu/drm/i915/i915_gem_shrinker.c +++ b/drivers/gpu/drm/i915/i915_gem_shrinker.c | |||
@@ -53,6 +53,17 @@ static bool i915_gem_shrinker_lock(struct drm_device *dev, bool *unlock) | |||
53 | BUG(); | 53 | BUG(); |
54 | } | 54 | } |
55 | 55 | ||
56 | static void i915_gem_shrinker_unlock(struct drm_device *dev, bool unlock) | ||
57 | { | ||
58 | if (!unlock) | ||
59 | return; | ||
60 | |||
61 | mutex_unlock(&dev->struct_mutex); | ||
62 | |||
63 | /* expedite the RCU grace period to free some request slabs */ | ||
64 | synchronize_rcu_expedited(); | ||
65 | } | ||
66 | |||
56 | static bool any_vma_pinned(struct drm_i915_gem_object *obj) | 67 | static bool any_vma_pinned(struct drm_i915_gem_object *obj) |
57 | { | 68 | { |
58 | struct i915_vma *vma; | 69 | struct i915_vma *vma; |
@@ -232,11 +243,8 @@ i915_gem_shrink(struct drm_i915_private *dev_priv, | |||
232 | intel_runtime_pm_put(dev_priv); | 243 | intel_runtime_pm_put(dev_priv); |
233 | 244 | ||
234 | i915_gem_retire_requests(dev_priv); | 245 | i915_gem_retire_requests(dev_priv); |
235 | if (unlock) | ||
236 | mutex_unlock(&dev_priv->drm.struct_mutex); | ||
237 | 246 | ||
238 | /* expedite the RCU grace period to free some request slabs */ | 247 | i915_gem_shrinker_unlock(&dev_priv->drm, unlock); |
239 | synchronize_rcu_expedited(); | ||
240 | 248 | ||
241 | return count; | 249 | return count; |
242 | } | 250 | } |
@@ -293,8 +301,7 @@ i915_gem_shrinker_count(struct shrinker *shrinker, struct shrink_control *sc) | |||
293 | count += obj->base.size >> PAGE_SHIFT; | 301 | count += obj->base.size >> PAGE_SHIFT; |
294 | } | 302 | } |
295 | 303 | ||
296 | if (unlock) | 304 | i915_gem_shrinker_unlock(dev, unlock); |
297 | mutex_unlock(&dev->struct_mutex); | ||
298 | 305 | ||
299 | return count; | 306 | return count; |
300 | } | 307 | } |
@@ -321,8 +328,8 @@ i915_gem_shrinker_scan(struct shrinker *shrinker, struct shrink_control *sc) | |||
321 | sc->nr_to_scan - freed, | 328 | sc->nr_to_scan - freed, |
322 | I915_SHRINK_BOUND | | 329 | I915_SHRINK_BOUND | |
323 | I915_SHRINK_UNBOUND); | 330 | I915_SHRINK_UNBOUND); |
324 | if (unlock) | 331 | |
325 | mutex_unlock(&dev->struct_mutex); | 332 | i915_gem_shrinker_unlock(dev, unlock); |
326 | 333 | ||
327 | return freed; | 334 | return freed; |
328 | } | 335 | } |
@@ -364,8 +371,7 @@ i915_gem_shrinker_unlock_uninterruptible(struct drm_i915_private *dev_priv, | |||
364 | struct shrinker_lock_uninterruptible *slu) | 371 | struct shrinker_lock_uninterruptible *slu) |
365 | { | 372 | { |
366 | dev_priv->mm.interruptible = slu->was_interruptible; | 373 | dev_priv->mm.interruptible = slu->was_interruptible; |
367 | if (slu->unlock) | 374 | i915_gem_shrinker_unlock(&dev_priv->drm, slu->unlock); |
368 | mutex_unlock(&dev_priv->drm.struct_mutex); | ||
369 | } | 375 | } |
370 | 376 | ||
371 | static int | 377 | static int |
diff --git a/drivers/gpu/drm/i915/i915_pci.c b/drivers/gpu/drm/i915/i915_pci.c index ecb487b5356f..9bbbd4e83e3c 100644 --- a/drivers/gpu/drm/i915/i915_pci.c +++ b/drivers/gpu/drm/i915/i915_pci.c | |||
@@ -60,6 +60,7 @@ | |||
60 | .has_overlay = 1, .overlay_needs_physical = 1, \ | 60 | .has_overlay = 1, .overlay_needs_physical = 1, \ |
61 | .has_gmch_display = 1, \ | 61 | .has_gmch_display = 1, \ |
62 | .hws_needs_physical = 1, \ | 62 | .hws_needs_physical = 1, \ |
63 | .unfenced_needs_alignment = 1, \ | ||
63 | .ring_mask = RENDER_RING, \ | 64 | .ring_mask = RENDER_RING, \ |
64 | GEN_DEFAULT_PIPEOFFSETS, \ | 65 | GEN_DEFAULT_PIPEOFFSETS, \ |
65 | CURSOR_OFFSETS | 66 | CURSOR_OFFSETS |
@@ -101,6 +102,7 @@ static const struct intel_device_info intel_i915g_info = { | |||
101 | .platform = INTEL_I915G, .cursor_needs_physical = 1, | 102 | .platform = INTEL_I915G, .cursor_needs_physical = 1, |
102 | .has_overlay = 1, .overlay_needs_physical = 1, | 103 | .has_overlay = 1, .overlay_needs_physical = 1, |
103 | .hws_needs_physical = 1, | 104 | .hws_needs_physical = 1, |
105 | .unfenced_needs_alignment = 1, | ||
104 | }; | 106 | }; |
105 | 107 | ||
106 | static const struct intel_device_info intel_i915gm_info = { | 108 | static const struct intel_device_info intel_i915gm_info = { |
@@ -112,6 +114,7 @@ static const struct intel_device_info intel_i915gm_info = { | |||
112 | .supports_tv = 1, | 114 | .supports_tv = 1, |
113 | .has_fbc = 1, | 115 | .has_fbc = 1, |
114 | .hws_needs_physical = 1, | 116 | .hws_needs_physical = 1, |
117 | .unfenced_needs_alignment = 1, | ||
115 | }; | 118 | }; |
116 | 119 | ||
117 | static const struct intel_device_info intel_i945g_info = { | 120 | static const struct intel_device_info intel_i945g_info = { |
@@ -120,6 +123,7 @@ static const struct intel_device_info intel_i945g_info = { | |||
120 | .has_hotplug = 1, .cursor_needs_physical = 1, | 123 | .has_hotplug = 1, .cursor_needs_physical = 1, |
121 | .has_overlay = 1, .overlay_needs_physical = 1, | 124 | .has_overlay = 1, .overlay_needs_physical = 1, |
122 | .hws_needs_physical = 1, | 125 | .hws_needs_physical = 1, |
126 | .unfenced_needs_alignment = 1, | ||
123 | }; | 127 | }; |
124 | 128 | ||
125 | static const struct intel_device_info intel_i945gm_info = { | 129 | static const struct intel_device_info intel_i945gm_info = { |
@@ -130,6 +134,7 @@ static const struct intel_device_info intel_i945gm_info = { | |||
130 | .supports_tv = 1, | 134 | .supports_tv = 1, |
131 | .has_fbc = 1, | 135 | .has_fbc = 1, |
132 | .hws_needs_physical = 1, | 136 | .hws_needs_physical = 1, |
137 | .unfenced_needs_alignment = 1, | ||
133 | }; | 138 | }; |
134 | 139 | ||
135 | static const struct intel_device_info intel_g33_info = { | 140 | static const struct intel_device_info intel_g33_info = { |
diff --git a/drivers/gpu/drm/i915/i915_perf.c b/drivers/gpu/drm/i915/i915_perf.c index a1b7eec58be2..70964ca9251e 100644 --- a/drivers/gpu/drm/i915/i915_perf.c +++ b/drivers/gpu/drm/i915/i915_perf.c | |||
@@ -1705,7 +1705,7 @@ i915_perf_open_ioctl_locked(struct drm_i915_private *dev_priv, | |||
1705 | */ | 1705 | */ |
1706 | if (WARN_ON(stream->sample_flags != props->sample_flags)) { | 1706 | if (WARN_ON(stream->sample_flags != props->sample_flags)) { |
1707 | ret = -ENODEV; | 1707 | ret = -ENODEV; |
1708 | goto err_alloc; | 1708 | goto err_flags; |
1709 | } | 1709 | } |
1710 | 1710 | ||
1711 | list_add(&stream->link, &dev_priv->perf.streams); | 1711 | list_add(&stream->link, &dev_priv->perf.streams); |
@@ -1728,6 +1728,7 @@ i915_perf_open_ioctl_locked(struct drm_i915_private *dev_priv, | |||
1728 | 1728 | ||
1729 | err_open: | 1729 | err_open: |
1730 | list_del(&stream->link); | 1730 | list_del(&stream->link); |
1731 | err_flags: | ||
1731 | if (stream->ops->destroy) | 1732 | if (stream->ops->destroy) |
1732 | stream->ops->destroy(stream); | 1733 | stream->ops->destroy(stream); |
1733 | err_alloc: | 1734 | err_alloc: |
@@ -1793,6 +1794,11 @@ static int read_properties_unlocked(struct drm_i915_private *dev_priv, | |||
1793 | if (ret) | 1794 | if (ret) |
1794 | return ret; | 1795 | return ret; |
1795 | 1796 | ||
1797 | if (id == 0 || id >= DRM_I915_PERF_PROP_MAX) { | ||
1798 | DRM_DEBUG("Unknown i915 perf property ID\n"); | ||
1799 | return -EINVAL; | ||
1800 | } | ||
1801 | |||
1796 | switch ((enum drm_i915_perf_property_id)id) { | 1802 | switch ((enum drm_i915_perf_property_id)id) { |
1797 | case DRM_I915_PERF_PROP_CTX_HANDLE: | 1803 | case DRM_I915_PERF_PROP_CTX_HANDLE: |
1798 | props->single_context = 1; | 1804 | props->single_context = 1; |
@@ -1862,9 +1868,8 @@ static int read_properties_unlocked(struct drm_i915_private *dev_priv, | |||
1862 | props->oa_periodic = true; | 1868 | props->oa_periodic = true; |
1863 | props->oa_period_exponent = value; | 1869 | props->oa_period_exponent = value; |
1864 | break; | 1870 | break; |
1865 | default: | 1871 | case DRM_I915_PERF_PROP_MAX: |
1866 | MISSING_CASE(id); | 1872 | MISSING_CASE(id); |
1867 | DRM_DEBUG("Unknown i915 perf property ID\n"); | ||
1868 | return -EINVAL; | 1873 | return -EINVAL; |
1869 | } | 1874 | } |
1870 | 1875 | ||
diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c index 471af3b480ad..47517a02f0a4 100644 --- a/drivers/gpu/drm/i915/intel_lrc.c +++ b/drivers/gpu/drm/i915/intel_lrc.c | |||
@@ -670,15 +670,14 @@ static void execlists_submit_request(struct drm_i915_gem_request *request) | |||
670 | static struct intel_engine_cs * | 670 | static struct intel_engine_cs * |
671 | pt_lock_engine(struct i915_priotree *pt, struct intel_engine_cs *locked) | 671 | pt_lock_engine(struct i915_priotree *pt, struct intel_engine_cs *locked) |
672 | { | 672 | { |
673 | struct intel_engine_cs *engine; | 673 | struct intel_engine_cs *engine = |
674 | container_of(pt, struct drm_i915_gem_request, priotree)->engine; | ||
675 | |||
676 | GEM_BUG_ON(!locked); | ||
674 | 677 | ||
675 | engine = container_of(pt, | ||
676 | struct drm_i915_gem_request, | ||
677 | priotree)->engine; | ||
678 | if (engine != locked) { | 678 | if (engine != locked) { |
679 | if (locked) | 679 | spin_unlock(&locked->timeline->lock); |
680 | spin_unlock_irq(&locked->timeline->lock); | 680 | spin_lock(&engine->timeline->lock); |
681 | spin_lock_irq(&engine->timeline->lock); | ||
682 | } | 681 | } |
683 | 682 | ||
684 | return engine; | 683 | return engine; |
@@ -686,7 +685,7 @@ pt_lock_engine(struct i915_priotree *pt, struct intel_engine_cs *locked) | |||
686 | 685 | ||
687 | static void execlists_schedule(struct drm_i915_gem_request *request, int prio) | 686 | static void execlists_schedule(struct drm_i915_gem_request *request, int prio) |
688 | { | 687 | { |
689 | struct intel_engine_cs *engine = NULL; | 688 | struct intel_engine_cs *engine; |
690 | struct i915_dependency *dep, *p; | 689 | struct i915_dependency *dep, *p; |
691 | struct i915_dependency stack; | 690 | struct i915_dependency stack; |
692 | LIST_HEAD(dfs); | 691 | LIST_HEAD(dfs); |
@@ -720,26 +719,23 @@ static void execlists_schedule(struct drm_i915_gem_request *request, int prio) | |||
720 | list_for_each_entry_safe(dep, p, &dfs, dfs_link) { | 719 | list_for_each_entry_safe(dep, p, &dfs, dfs_link) { |
721 | struct i915_priotree *pt = dep->signaler; | 720 | struct i915_priotree *pt = dep->signaler; |
722 | 721 | ||
723 | list_for_each_entry(p, &pt->signalers_list, signal_link) | 722 | /* Within an engine, there can be no cycle, but we may |
723 | * refer to the same dependency chain multiple times | ||
724 | * (redundant dependencies are not eliminated) and across | ||
725 | * engines. | ||
726 | */ | ||
727 | list_for_each_entry(p, &pt->signalers_list, signal_link) { | ||
728 | GEM_BUG_ON(p->signaler->priority < pt->priority); | ||
724 | if (prio > READ_ONCE(p->signaler->priority)) | 729 | if (prio > READ_ONCE(p->signaler->priority)) |
725 | list_move_tail(&p->dfs_link, &dfs); | 730 | list_move_tail(&p->dfs_link, &dfs); |
731 | } | ||
726 | 732 | ||
727 | list_safe_reset_next(dep, p, dfs_link); | 733 | list_safe_reset_next(dep, p, dfs_link); |
728 | if (!RB_EMPTY_NODE(&pt->node)) | ||
729 | continue; | ||
730 | |||
731 | engine = pt_lock_engine(pt, engine); | ||
732 | |||
733 | /* If it is not already in the rbtree, we can update the | ||
734 | * priority inplace and skip over it (and its dependencies) | ||
735 | * if it is referenced *again* as we descend the dfs. | ||
736 | */ | ||
737 | if (prio > pt->priority && RB_EMPTY_NODE(&pt->node)) { | ||
738 | pt->priority = prio; | ||
739 | list_del_init(&dep->dfs_link); | ||
740 | } | ||
741 | } | 734 | } |
742 | 735 | ||
736 | engine = request->engine; | ||
737 | spin_lock_irq(&engine->timeline->lock); | ||
738 | |||
743 | /* Fifo and depth-first replacement ensure our deps execute before us */ | 739 | /* Fifo and depth-first replacement ensure our deps execute before us */ |
744 | list_for_each_entry_safe_reverse(dep, p, &dfs, dfs_link) { | 740 | list_for_each_entry_safe_reverse(dep, p, &dfs, dfs_link) { |
745 | struct i915_priotree *pt = dep->signaler; | 741 | struct i915_priotree *pt = dep->signaler; |
@@ -751,16 +747,15 @@ static void execlists_schedule(struct drm_i915_gem_request *request, int prio) | |||
751 | if (prio <= pt->priority) | 747 | if (prio <= pt->priority) |
752 | continue; | 748 | continue; |
753 | 749 | ||
754 | GEM_BUG_ON(RB_EMPTY_NODE(&pt->node)); | ||
755 | |||
756 | pt->priority = prio; | 750 | pt->priority = prio; |
757 | rb_erase(&pt->node, &engine->execlist_queue); | 751 | if (!RB_EMPTY_NODE(&pt->node)) { |
758 | if (insert_request(pt, &engine->execlist_queue)) | 752 | rb_erase(&pt->node, &engine->execlist_queue); |
759 | engine->execlist_first = &pt->node; | 753 | if (insert_request(pt, &engine->execlist_queue)) |
754 | engine->execlist_first = &pt->node; | ||
755 | } | ||
760 | } | 756 | } |
761 | 757 | ||
762 | if (engine) | 758 | spin_unlock_irq(&engine->timeline->lock); |
763 | spin_unlock_irq(&engine->timeline->lock); | ||
764 | 759 | ||
765 | /* XXX Do we need to preempt to make room for us and our deps? */ | 760 | /* XXX Do we need to preempt to make room for us and our deps? */ |
766 | } | 761 | } |
@@ -1440,7 +1435,9 @@ static void reset_common_ring(struct intel_engine_cs *engine, | |||
1440 | GEM_BUG_ON(request->ctx != port[0].request->ctx); | 1435 | GEM_BUG_ON(request->ctx != port[0].request->ctx); |
1441 | 1436 | ||
1442 | /* Reset WaIdleLiteRestore:bdw,skl as well */ | 1437 | /* Reset WaIdleLiteRestore:bdw,skl as well */ |
1443 | request->tail = request->wa_tail - WA_TAIL_DWORDS * sizeof(u32); | 1438 | request->tail = |
1439 | intel_ring_wrap(request->ring, | ||
1440 | request->wa_tail - WA_TAIL_DWORDS*sizeof(u32)); | ||
1444 | } | 1441 | } |
1445 | 1442 | ||
1446 | static int intel_logical_ring_emit_pdps(struct drm_i915_gem_request *req) | 1443 | static int intel_logical_ring_emit_pdps(struct drm_i915_gem_request *req) |
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c index 91bc4abf5d3e..6c5f9958197d 100644 --- a/drivers/gpu/drm/i915/intel_ringbuffer.c +++ b/drivers/gpu/drm/i915/intel_ringbuffer.c | |||
@@ -2024,6 +2024,8 @@ static int intel_ring_context_pin(struct intel_engine_cs *engine, | |||
2024 | ret = context_pin(ctx, flags); | 2024 | ret = context_pin(ctx, flags); |
2025 | if (ret) | 2025 | if (ret) |
2026 | goto error; | 2026 | goto error; |
2027 | |||
2028 | ce->state->obj->mm.dirty = true; | ||
2027 | } | 2029 | } |
2028 | 2030 | ||
2029 | /* The kernel context is only used as a placeholder for flushing the | 2031 | /* The kernel context is only used as a placeholder for flushing the |
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.h b/drivers/gpu/drm/i915/intel_ringbuffer.h index 13dccb18cd43..8cb2078c5bfc 100644 --- a/drivers/gpu/drm/i915/intel_ringbuffer.h +++ b/drivers/gpu/drm/i915/intel_ringbuffer.h | |||
@@ -521,11 +521,17 @@ static inline void intel_ring_advance(struct intel_ring *ring) | |||
521 | */ | 521 | */ |
522 | } | 522 | } |
523 | 523 | ||
524 | static inline u32 | ||
525 | intel_ring_wrap(const struct intel_ring *ring, u32 pos) | ||
526 | { | ||
527 | return pos & (ring->size - 1); | ||
528 | } | ||
529 | |||
524 | static inline u32 intel_ring_offset(struct intel_ring *ring, void *addr) | 530 | static inline u32 intel_ring_offset(struct intel_ring *ring, void *addr) |
525 | { | 531 | { |
526 | /* Don't write ring->size (equivalent to 0) as that hangs some GPUs. */ | 532 | /* Don't write ring->size (equivalent to 0) as that hangs some GPUs. */ |
527 | u32 offset = addr - ring->vaddr; | 533 | u32 offset = addr - ring->vaddr; |
528 | return offset & (ring->size - 1); | 534 | return intel_ring_wrap(ring, offset); |
529 | } | 535 | } |
530 | 536 | ||
531 | int __intel_ring_space(int head, int tail, int size); | 537 | int __intel_ring_space(int head, int tail, int size); |
diff --git a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c index 4414cf73735d..36602ac7e248 100644 --- a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c +++ b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* Copyright (c) 2016 The Linux Foundation. All rights reserved. | 1 | /* Copyright (c) 2016-2017 The Linux Foundation. All rights reserved. |
2 | * | 2 | * |
3 | * This program is free software; you can redistribute it and/or modify | 3 | * This program is free software; you can redistribute it and/or modify |
4 | * it under the terms of the GNU General Public License version 2 and | 4 | * it under the terms of the GNU General Public License version 2 and |
@@ -534,7 +534,7 @@ static void a5xx_destroy(struct msm_gpu *gpu) | |||
534 | } | 534 | } |
535 | 535 | ||
536 | if (a5xx_gpu->gpmu_bo) { | 536 | if (a5xx_gpu->gpmu_bo) { |
537 | if (a5xx_gpu->gpmu_bo) | 537 | if (a5xx_gpu->gpmu_iova) |
538 | msm_gem_put_iova(a5xx_gpu->gpmu_bo, gpu->id); | 538 | msm_gem_put_iova(a5xx_gpu->gpmu_bo, gpu->id); |
539 | drm_gem_object_unreference_unlocked(a5xx_gpu->gpmu_bo); | 539 | drm_gem_object_unreference_unlocked(a5xx_gpu->gpmu_bo); |
540 | } | 540 | } |
@@ -860,7 +860,9 @@ static const struct adreno_gpu_funcs funcs = { | |||
860 | .idle = a5xx_idle, | 860 | .idle = a5xx_idle, |
861 | .irq = a5xx_irq, | 861 | .irq = a5xx_irq, |
862 | .destroy = a5xx_destroy, | 862 | .destroy = a5xx_destroy, |
863 | #ifdef CONFIG_DEBUG_FS | ||
863 | .show = a5xx_show, | 864 | .show = a5xx_show, |
865 | #endif | ||
864 | }, | 866 | }, |
865 | .get_timestamp = a5xx_get_timestamp, | 867 | .get_timestamp = a5xx_get_timestamp, |
866 | }; | 868 | }; |
diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.c b/drivers/gpu/drm/msm/adreno/adreno_gpu.c index c9bd1e6225f4..5ae65426b4e5 100644 --- a/drivers/gpu/drm/msm/adreno/adreno_gpu.c +++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.c | |||
@@ -418,18 +418,27 @@ int adreno_gpu_init(struct drm_device *drm, struct platform_device *pdev, | |||
418 | return 0; | 418 | return 0; |
419 | } | 419 | } |
420 | 420 | ||
421 | void adreno_gpu_cleanup(struct adreno_gpu *gpu) | 421 | void adreno_gpu_cleanup(struct adreno_gpu *adreno_gpu) |
422 | { | 422 | { |
423 | if (gpu->memptrs_bo) { | 423 | struct msm_gpu *gpu = &adreno_gpu->base; |
424 | if (gpu->memptrs) | 424 | |
425 | msm_gem_put_vaddr(gpu->memptrs_bo); | 425 | if (adreno_gpu->memptrs_bo) { |
426 | if (adreno_gpu->memptrs) | ||
427 | msm_gem_put_vaddr(adreno_gpu->memptrs_bo); | ||
428 | |||
429 | if (adreno_gpu->memptrs_iova) | ||
430 | msm_gem_put_iova(adreno_gpu->memptrs_bo, gpu->id); | ||
431 | |||
432 | drm_gem_object_unreference_unlocked(adreno_gpu->memptrs_bo); | ||
433 | } | ||
434 | release_firmware(adreno_gpu->pm4); | ||
435 | release_firmware(adreno_gpu->pfp); | ||
426 | 436 | ||
427 | if (gpu->memptrs_iova) | 437 | msm_gpu_cleanup(gpu); |
428 | msm_gem_put_iova(gpu->memptrs_bo, gpu->base.id); | ||
429 | 438 | ||
430 | drm_gem_object_unreference_unlocked(gpu->memptrs_bo); | 439 | if (gpu->aspace) { |
440 | gpu->aspace->mmu->funcs->detach(gpu->aspace->mmu, | ||
441 | iommu_ports, ARRAY_SIZE(iommu_ports)); | ||
442 | msm_gem_address_space_destroy(gpu->aspace); | ||
431 | } | 443 | } |
432 | release_firmware(gpu->pm4); | ||
433 | release_firmware(gpu->pfp); | ||
434 | msm_gpu_cleanup(&gpu->base); | ||
435 | } | 444 | } |
diff --git a/drivers/gpu/drm/msm/dsi/dsi_manager.c b/drivers/gpu/drm/msm/dsi/dsi_manager.c index 921270ea6059..a879ffa534b4 100644 --- a/drivers/gpu/drm/msm/dsi/dsi_manager.c +++ b/drivers/gpu/drm/msm/dsi/dsi_manager.c | |||
@@ -171,7 +171,7 @@ dsi_mgr_phy_enable(int id, | |||
171 | } | 171 | } |
172 | } | 172 | } |
173 | } else { | 173 | } else { |
174 | msm_dsi_host_reset_phy(mdsi->host); | 174 | msm_dsi_host_reset_phy(msm_dsi->host); |
175 | ret = enable_phy(msm_dsi, src_pll_id, &shared_timings[id]); | 175 | ret = enable_phy(msm_dsi, src_pll_id, &shared_timings[id]); |
176 | if (ret) | 176 | if (ret) |
177 | return ret; | 177 | return ret; |
diff --git a/drivers/gpu/drm/msm/hdmi/hdmi_audio.c b/drivers/gpu/drm/msm/hdmi/hdmi_audio.c index a54d3bb5baad..8177e8511afd 100644 --- a/drivers/gpu/drm/msm/hdmi/hdmi_audio.c +++ b/drivers/gpu/drm/msm/hdmi/hdmi_audio.c | |||
@@ -18,13 +18,6 @@ | |||
18 | #include <linux/hdmi.h> | 18 | #include <linux/hdmi.h> |
19 | #include "hdmi.h" | 19 | #include "hdmi.h" |
20 | 20 | ||
21 | |||
22 | /* Supported HDMI Audio channels */ | ||
23 | #define MSM_HDMI_AUDIO_CHANNEL_2 0 | ||
24 | #define MSM_HDMI_AUDIO_CHANNEL_4 1 | ||
25 | #define MSM_HDMI_AUDIO_CHANNEL_6 2 | ||
26 | #define MSM_HDMI_AUDIO_CHANNEL_8 3 | ||
27 | |||
28 | /* maps MSM_HDMI_AUDIO_CHANNEL_n consts used by audio driver to # of channels: */ | 21 | /* maps MSM_HDMI_AUDIO_CHANNEL_n consts used by audio driver to # of channels: */ |
29 | static int nchannels[] = { 2, 4, 6, 8 }; | 22 | static int nchannels[] = { 2, 4, 6, 8 }; |
30 | 23 | ||
diff --git a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_pipe.h b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_pipe.h index 611da7a660c9..238901987e00 100644 --- a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_pipe.h +++ b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_pipe.h | |||
@@ -18,7 +18,8 @@ | |||
18 | #ifndef __MDP5_PIPE_H__ | 18 | #ifndef __MDP5_PIPE_H__ |
19 | #define __MDP5_PIPE_H__ | 19 | #define __MDP5_PIPE_H__ |
20 | 20 | ||
21 | #define SSPP_MAX (SSPP_RGB3 + 1) /* TODO: Add SSPP_MAX in mdp5.xml.h */ | 21 | /* TODO: Add SSPP_MAX in mdp5.xml.h */ |
22 | #define SSPP_MAX (SSPP_CURSOR1 + 1) | ||
22 | 23 | ||
23 | /* represents a hw pipe, which is dynamically assigned to a plane */ | 24 | /* represents a hw pipe, which is dynamically assigned to a plane */ |
24 | struct mdp5_hw_pipe { | 25 | struct mdp5_hw_pipe { |
diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c index 59811f29607d..68e509b3b9e4 100644 --- a/drivers/gpu/drm/msm/msm_gem.c +++ b/drivers/gpu/drm/msm/msm_gem.c | |||
@@ -812,6 +812,12 @@ struct drm_gem_object *msm_gem_new(struct drm_device *dev, | |||
812 | 812 | ||
813 | size = PAGE_ALIGN(size); | 813 | size = PAGE_ALIGN(size); |
814 | 814 | ||
815 | /* Disallow zero sized objects as they make the underlying | ||
816 | * infrastructure grumpy | ||
817 | */ | ||
818 | if (size == 0) | ||
819 | return ERR_PTR(-EINVAL); | ||
820 | |||
815 | ret = msm_gem_new_impl(dev, size, flags, NULL, &obj); | 821 | ret = msm_gem_new_impl(dev, size, flags, NULL, &obj); |
816 | if (ret) | 822 | if (ret) |
817 | goto fail; | 823 | goto fail; |
diff --git a/drivers/gpu/drm/msm/msm_gpu.c b/drivers/gpu/drm/msm/msm_gpu.c index 99e05aacbee1..af5b6ba4095b 100644 --- a/drivers/gpu/drm/msm/msm_gpu.c +++ b/drivers/gpu/drm/msm/msm_gpu.c | |||
@@ -706,9 +706,6 @@ void msm_gpu_cleanup(struct msm_gpu *gpu) | |||
706 | msm_ringbuffer_destroy(gpu->rb); | 706 | msm_ringbuffer_destroy(gpu->rb); |
707 | } | 707 | } |
708 | 708 | ||
709 | if (gpu->aspace) | ||
710 | msm_gem_address_space_destroy(gpu->aspace); | ||
711 | |||
712 | if (gpu->fctx) | 709 | if (gpu->fctx) |
713 | msm_fence_context_free(gpu->fctx); | 710 | msm_fence_context_free(gpu->fctx); |
714 | } | 711 | } |
diff --git a/drivers/gpu/drm/nouveau/nv50_display.c b/drivers/gpu/drm/nouveau/nv50_display.c index 0b4440ffbeae..a9182d5e6011 100644 --- a/drivers/gpu/drm/nouveau/nv50_display.c +++ b/drivers/gpu/drm/nouveau/nv50_display.c | |||
@@ -995,7 +995,6 @@ nv50_wndw_atomic_destroy_state(struct drm_plane *plane, | |||
995 | { | 995 | { |
996 | struct nv50_wndw_atom *asyw = nv50_wndw_atom(state); | 996 | struct nv50_wndw_atom *asyw = nv50_wndw_atom(state); |
997 | __drm_atomic_helper_plane_destroy_state(&asyw->state); | 997 | __drm_atomic_helper_plane_destroy_state(&asyw->state); |
998 | dma_fence_put(asyw->state.fence); | ||
999 | kfree(asyw); | 998 | kfree(asyw); |
1000 | } | 999 | } |
1001 | 1000 | ||
@@ -1007,7 +1006,6 @@ nv50_wndw_atomic_duplicate_state(struct drm_plane *plane) | |||
1007 | if (!(asyw = kmalloc(sizeof(*asyw), GFP_KERNEL))) | 1006 | if (!(asyw = kmalloc(sizeof(*asyw), GFP_KERNEL))) |
1008 | return NULL; | 1007 | return NULL; |
1009 | __drm_atomic_helper_plane_duplicate_state(plane, &asyw->state); | 1008 | __drm_atomic_helper_plane_duplicate_state(plane, &asyw->state); |
1010 | asyw->state.fence = NULL; | ||
1011 | asyw->interval = 1; | 1009 | asyw->interval = 1; |
1012 | asyw->sema = armw->sema; | 1010 | asyw->sema = armw->sema; |
1013 | asyw->ntfy = armw->ntfy; | 1011 | asyw->ntfy = armw->ntfy; |
@@ -2036,6 +2034,7 @@ nv50_head_atomic_check_mode(struct nv50_head *head, struct nv50_head_atom *asyh) | |||
2036 | u32 vbackp = (mode->vtotal - mode->vsync_end) * vscan / ilace; | 2034 | u32 vbackp = (mode->vtotal - mode->vsync_end) * vscan / ilace; |
2037 | u32 hfrontp = mode->hsync_start - mode->hdisplay; | 2035 | u32 hfrontp = mode->hsync_start - mode->hdisplay; |
2038 | u32 vfrontp = (mode->vsync_start - mode->vdisplay) * vscan / ilace; | 2036 | u32 vfrontp = (mode->vsync_start - mode->vdisplay) * vscan / ilace; |
2037 | u32 blankus; | ||
2039 | struct nv50_head_mode *m = &asyh->mode; | 2038 | struct nv50_head_mode *m = &asyh->mode; |
2040 | 2039 | ||
2041 | m->h.active = mode->htotal; | 2040 | m->h.active = mode->htotal; |
@@ -2049,9 +2048,10 @@ nv50_head_atomic_check_mode(struct nv50_head *head, struct nv50_head_atom *asyh) | |||
2049 | m->v.blanks = m->v.active - vfrontp - 1; | 2048 | m->v.blanks = m->v.active - vfrontp - 1; |
2050 | 2049 | ||
2051 | /*XXX: Safe underestimate, even "0" works */ | 2050 | /*XXX: Safe underestimate, even "0" works */ |
2052 | m->v.blankus = (m->v.active - mode->vdisplay - 2) * m->h.active; | 2051 | blankus = (m->v.active - mode->vdisplay - 2) * m->h.active; |
2053 | m->v.blankus *= 1000; | 2052 | blankus *= 1000; |
2054 | m->v.blankus /= mode->clock; | 2053 | blankus /= mode->clock; |
2054 | m->v.blankus = blankus; | ||
2055 | 2055 | ||
2056 | if (mode->flags & DRM_MODE_FLAG_INTERLACE) { | 2056 | if (mode->flags & DRM_MODE_FLAG_INTERLACE) { |
2057 | m->v.blank2e = m->v.active + m->v.synce + vbackp; | 2057 | m->v.blank2e = m->v.active + m->v.synce + vbackp; |
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/device/base.c b/drivers/gpu/drm/nouveau/nvkm/engine/device/base.c index 273562dd6bbd..3b86a7399567 100644 --- a/drivers/gpu/drm/nouveau/nvkm/engine/device/base.c +++ b/drivers/gpu/drm/nouveau/nvkm/engine/device/base.c | |||
@@ -714,7 +714,7 @@ nv4a_chipset = { | |||
714 | .i2c = nv04_i2c_new, | 714 | .i2c = nv04_i2c_new, |
715 | .imem = nv40_instmem_new, | 715 | .imem = nv40_instmem_new, |
716 | .mc = nv44_mc_new, | 716 | .mc = nv44_mc_new, |
717 | .mmu = nv44_mmu_new, | 717 | .mmu = nv04_mmu_new, |
718 | .pci = nv40_pci_new, | 718 | .pci = nv40_pci_new, |
719 | .therm = nv40_therm_new, | 719 | .therm = nv40_therm_new, |
720 | .timer = nv41_timer_new, | 720 | .timer = nv41_timer_new, |
@@ -2271,6 +2271,35 @@ nv136_chipset = { | |||
2271 | .fifo = gp100_fifo_new, | 2271 | .fifo = gp100_fifo_new, |
2272 | }; | 2272 | }; |
2273 | 2273 | ||
2274 | static const struct nvkm_device_chip | ||
2275 | nv137_chipset = { | ||
2276 | .name = "GP107", | ||
2277 | .bar = gf100_bar_new, | ||
2278 | .bios = nvkm_bios_new, | ||
2279 | .bus = gf100_bus_new, | ||
2280 | .devinit = gm200_devinit_new, | ||
2281 | .fb = gp102_fb_new, | ||
2282 | .fuse = gm107_fuse_new, | ||
2283 | .gpio = gk104_gpio_new, | ||
2284 | .i2c = gm200_i2c_new, | ||
2285 | .ibus = gm200_ibus_new, | ||
2286 | .imem = nv50_instmem_new, | ||
2287 | .ltc = gp100_ltc_new, | ||
2288 | .mc = gp100_mc_new, | ||
2289 | .mmu = gf100_mmu_new, | ||
2290 | .pci = gp100_pci_new, | ||
2291 | .pmu = gp102_pmu_new, | ||
2292 | .timer = gk20a_timer_new, | ||
2293 | .top = gk104_top_new, | ||
2294 | .ce[0] = gp102_ce_new, | ||
2295 | .ce[1] = gp102_ce_new, | ||
2296 | .ce[2] = gp102_ce_new, | ||
2297 | .ce[3] = gp102_ce_new, | ||
2298 | .disp = gp102_disp_new, | ||
2299 | .dma = gf119_dma_new, | ||
2300 | .fifo = gp100_fifo_new, | ||
2301 | }; | ||
2302 | |||
2274 | static int | 2303 | static int |
2275 | nvkm_device_event_ctor(struct nvkm_object *object, void *data, u32 size, | 2304 | nvkm_device_event_ctor(struct nvkm_object *object, void *data, u32 size, |
2276 | struct nvkm_notify *notify) | 2305 | struct nvkm_notify *notify) |
@@ -2708,6 +2737,7 @@ nvkm_device_ctor(const struct nvkm_device_func *func, | |||
2708 | case 0x132: device->chip = &nv132_chipset; break; | 2737 | case 0x132: device->chip = &nv132_chipset; break; |
2709 | case 0x134: device->chip = &nv134_chipset; break; | 2738 | case 0x134: device->chip = &nv134_chipset; break; |
2710 | case 0x136: device->chip = &nv136_chipset; break; | 2739 | case 0x136: device->chip = &nv136_chipset; break; |
2740 | case 0x137: device->chip = &nv137_chipset; break; | ||
2711 | default: | 2741 | default: |
2712 | nvdev_error(device, "unknown chipset (%08x)\n", boot0); | 2742 | nvdev_error(device, "unknown chipset (%08x)\n", boot0); |
2713 | goto done; | 2743 | goto done; |
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/mpeg/nv31.c b/drivers/gpu/drm/nouveau/nvkm/engine/mpeg/nv31.c index 003ac915eaad..8a8895246d26 100644 --- a/drivers/gpu/drm/nouveau/nvkm/engine/mpeg/nv31.c +++ b/drivers/gpu/drm/nouveau/nvkm/engine/mpeg/nv31.c | |||
@@ -198,7 +198,7 @@ nv31_mpeg_intr(struct nvkm_engine *engine) | |||
198 | } | 198 | } |
199 | 199 | ||
200 | if (type == 0x00000010) { | 200 | if (type == 0x00000010) { |
201 | if (!nv31_mpeg_mthd(mpeg, mthd, data)) | 201 | if (nv31_mpeg_mthd(mpeg, mthd, data)) |
202 | show &= ~0x01000000; | 202 | show &= ~0x01000000; |
203 | } | 203 | } |
204 | } | 204 | } |
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/mpeg/nv44.c b/drivers/gpu/drm/nouveau/nvkm/engine/mpeg/nv44.c index e536f37e24b0..c3cf02ed468e 100644 --- a/drivers/gpu/drm/nouveau/nvkm/engine/mpeg/nv44.c +++ b/drivers/gpu/drm/nouveau/nvkm/engine/mpeg/nv44.c | |||
@@ -172,7 +172,7 @@ nv44_mpeg_intr(struct nvkm_engine *engine) | |||
172 | } | 172 | } |
173 | 173 | ||
174 | if (type == 0x00000010) { | 174 | if (type == 0x00000010) { |
175 | if (!nv44_mpeg_mthd(subdev->device, mthd, data)) | 175 | if (nv44_mpeg_mthd(subdev->device, mthd, data)) |
176 | show &= ~0x01000000; | 176 | show &= ~0x01000000; |
177 | } | 177 | } |
178 | } | 178 | } |
diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c index 684f1703aa5c..aaa3e80fecb4 100644 --- a/drivers/gpu/drm/radeon/radeon_ttm.c +++ b/drivers/gpu/drm/radeon/radeon_ttm.c | |||
@@ -213,8 +213,8 @@ static void radeon_evict_flags(struct ttm_buffer_object *bo, | |||
213 | rbo->placement.num_busy_placement = 0; | 213 | rbo->placement.num_busy_placement = 0; |
214 | for (i = 0; i < rbo->placement.num_placement; i++) { | 214 | for (i = 0; i < rbo->placement.num_placement; i++) { |
215 | if (rbo->placements[i].flags & TTM_PL_FLAG_VRAM) { | 215 | if (rbo->placements[i].flags & TTM_PL_FLAG_VRAM) { |
216 | if (rbo->placements[0].fpfn < fpfn) | 216 | if (rbo->placements[i].fpfn < fpfn) |
217 | rbo->placements[0].fpfn = fpfn; | 217 | rbo->placements[i].fpfn = fpfn; |
218 | } else { | 218 | } else { |
219 | rbo->placement.busy_placement = | 219 | rbo->placement.busy_placement = |
220 | &rbo->placements[i]; | 220 | &rbo->placements[i]; |
diff --git a/drivers/gpu/drm/ttm/ttm_object.c b/drivers/gpu/drm/ttm/ttm_object.c index fdb451e3ec01..26a7ad0f4789 100644 --- a/drivers/gpu/drm/ttm/ttm_object.c +++ b/drivers/gpu/drm/ttm/ttm_object.c | |||
@@ -179,7 +179,7 @@ int ttm_base_object_init(struct ttm_object_file *tfile, | |||
179 | if (unlikely(ret != 0)) | 179 | if (unlikely(ret != 0)) |
180 | goto out_err0; | 180 | goto out_err0; |
181 | 181 | ||
182 | ret = ttm_ref_object_add(tfile, base, TTM_REF_USAGE, NULL); | 182 | ret = ttm_ref_object_add(tfile, base, TTM_REF_USAGE, NULL, false); |
183 | if (unlikely(ret != 0)) | 183 | if (unlikely(ret != 0)) |
184 | goto out_err1; | 184 | goto out_err1; |
185 | 185 | ||
@@ -318,7 +318,8 @@ EXPORT_SYMBOL(ttm_ref_object_exists); | |||
318 | 318 | ||
319 | int ttm_ref_object_add(struct ttm_object_file *tfile, | 319 | int ttm_ref_object_add(struct ttm_object_file *tfile, |
320 | struct ttm_base_object *base, | 320 | struct ttm_base_object *base, |
321 | enum ttm_ref_type ref_type, bool *existed) | 321 | enum ttm_ref_type ref_type, bool *existed, |
322 | bool require_existed) | ||
322 | { | 323 | { |
323 | struct drm_open_hash *ht = &tfile->ref_hash[ref_type]; | 324 | struct drm_open_hash *ht = &tfile->ref_hash[ref_type]; |
324 | struct ttm_ref_object *ref; | 325 | struct ttm_ref_object *ref; |
@@ -345,6 +346,9 @@ int ttm_ref_object_add(struct ttm_object_file *tfile, | |||
345 | } | 346 | } |
346 | 347 | ||
347 | rcu_read_unlock(); | 348 | rcu_read_unlock(); |
349 | if (require_existed) | ||
350 | return -EPERM; | ||
351 | |||
348 | ret = ttm_mem_global_alloc(mem_glob, sizeof(*ref), | 352 | ret = ttm_mem_global_alloc(mem_glob, sizeof(*ref), |
349 | false, false); | 353 | false, false); |
350 | if (unlikely(ret != 0)) | 354 | if (unlikely(ret != 0)) |
@@ -449,10 +453,10 @@ void ttm_object_file_release(struct ttm_object_file **p_tfile) | |||
449 | ttm_ref_object_release(&ref->kref); | 453 | ttm_ref_object_release(&ref->kref); |
450 | } | 454 | } |
451 | 455 | ||
456 | spin_unlock(&tfile->lock); | ||
452 | for (i = 0; i < TTM_REF_NUM; ++i) | 457 | for (i = 0; i < TTM_REF_NUM; ++i) |
453 | drm_ht_remove(&tfile->ref_hash[i]); | 458 | drm_ht_remove(&tfile->ref_hash[i]); |
454 | 459 | ||
455 | spin_unlock(&tfile->lock); | ||
456 | ttm_object_file_unref(&tfile); | 460 | ttm_object_file_unref(&tfile); |
457 | } | 461 | } |
458 | EXPORT_SYMBOL(ttm_object_file_release); | 462 | EXPORT_SYMBOL(ttm_object_file_release); |
@@ -529,9 +533,7 @@ void ttm_object_device_release(struct ttm_object_device **p_tdev) | |||
529 | 533 | ||
530 | *p_tdev = NULL; | 534 | *p_tdev = NULL; |
531 | 535 | ||
532 | spin_lock(&tdev->object_lock); | ||
533 | drm_ht_remove(&tdev->object_hash); | 536 | drm_ht_remove(&tdev->object_hash); |
534 | spin_unlock(&tdev->object_lock); | ||
535 | 537 | ||
536 | kfree(tdev); | 538 | kfree(tdev); |
537 | } | 539 | } |
@@ -635,7 +637,7 @@ int ttm_prime_fd_to_handle(struct ttm_object_file *tfile, | |||
635 | prime = (struct ttm_prime_object *) dma_buf->priv; | 637 | prime = (struct ttm_prime_object *) dma_buf->priv; |
636 | base = &prime->base; | 638 | base = &prime->base; |
637 | *handle = base->hash.key; | 639 | *handle = base->hash.key; |
638 | ret = ttm_ref_object_add(tfile, base, TTM_REF_USAGE, NULL); | 640 | ret = ttm_ref_object_add(tfile, base, TTM_REF_USAGE, NULL, false); |
639 | 641 | ||
640 | dma_buf_put(dma_buf); | 642 | dma_buf_put(dma_buf); |
641 | 643 | ||
diff --git a/drivers/gpu/drm/udl/udl_transfer.c b/drivers/gpu/drm/udl/udl_transfer.c index 917dcb978c2c..0c87b1ac6b68 100644 --- a/drivers/gpu/drm/udl/udl_transfer.c +++ b/drivers/gpu/drm/udl/udl_transfer.c | |||
@@ -14,6 +14,7 @@ | |||
14 | #include <linux/slab.h> | 14 | #include <linux/slab.h> |
15 | #include <linux/fb.h> | 15 | #include <linux/fb.h> |
16 | #include <linux/prefetch.h> | 16 | #include <linux/prefetch.h> |
17 | #include <asm/unaligned.h> | ||
17 | 18 | ||
18 | #include <drm/drmP.h> | 19 | #include <drm/drmP.h> |
19 | #include "udl_drv.h" | 20 | #include "udl_drv.h" |
@@ -163,7 +164,7 @@ static void udl_compress_hline16( | |||
163 | const u8 *const start = pixel; | 164 | const u8 *const start = pixel; |
164 | const uint16_t repeating_pixel_val16 = pixel_val16; | 165 | const uint16_t repeating_pixel_val16 = pixel_val16; |
165 | 166 | ||
166 | *(uint16_t *)cmd = cpu_to_be16(pixel_val16); | 167 | put_unaligned_be16(pixel_val16, cmd); |
167 | 168 | ||
168 | cmd += 2; | 169 | cmd += 2; |
169 | pixel += bpp; | 170 | pixel += bpp; |
diff --git a/drivers/gpu/drm/vc4/vc4_crtc.c b/drivers/gpu/drm/vc4/vc4_crtc.c index 0c06844af445..9fcf05ca492b 100644 --- a/drivers/gpu/drm/vc4/vc4_crtc.c +++ b/drivers/gpu/drm/vc4/vc4_crtc.c | |||
@@ -846,6 +846,17 @@ static void vc4_crtc_destroy_state(struct drm_crtc *crtc, | |||
846 | drm_atomic_helper_crtc_destroy_state(crtc, state); | 846 | drm_atomic_helper_crtc_destroy_state(crtc, state); |
847 | } | 847 | } |
848 | 848 | ||
849 | static void | ||
850 | vc4_crtc_reset(struct drm_crtc *crtc) | ||
851 | { | ||
852 | if (crtc->state) | ||
853 | __drm_atomic_helper_crtc_destroy_state(crtc->state); | ||
854 | |||
855 | crtc->state = kzalloc(sizeof(struct vc4_crtc_state), GFP_KERNEL); | ||
856 | if (crtc->state) | ||
857 | crtc->state->crtc = crtc; | ||
858 | } | ||
859 | |||
849 | static const struct drm_crtc_funcs vc4_crtc_funcs = { | 860 | static const struct drm_crtc_funcs vc4_crtc_funcs = { |
850 | .set_config = drm_atomic_helper_set_config, | 861 | .set_config = drm_atomic_helper_set_config, |
851 | .destroy = vc4_crtc_destroy, | 862 | .destroy = vc4_crtc_destroy, |
@@ -853,7 +864,7 @@ static const struct drm_crtc_funcs vc4_crtc_funcs = { | |||
853 | .set_property = NULL, | 864 | .set_property = NULL, |
854 | .cursor_set = NULL, /* handled by drm_mode_cursor_universal */ | 865 | .cursor_set = NULL, /* handled by drm_mode_cursor_universal */ |
855 | .cursor_move = NULL, /* handled by drm_mode_cursor_universal */ | 866 | .cursor_move = NULL, /* handled by drm_mode_cursor_universal */ |
856 | .reset = drm_atomic_helper_crtc_reset, | 867 | .reset = vc4_crtc_reset, |
857 | .atomic_duplicate_state = vc4_crtc_duplicate_state, | 868 | .atomic_duplicate_state = vc4_crtc_duplicate_state, |
858 | .atomic_destroy_state = vc4_crtc_destroy_state, | 869 | .atomic_destroy_state = vc4_crtc_destroy_state, |
859 | .gamma_set = vc4_crtc_gamma_set, | 870 | .gamma_set = vc4_crtc_gamma_set, |
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c index 6541dd8b82dc..6b2708b4eafe 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c | |||
@@ -538,7 +538,7 @@ int vmw_fence_create(struct vmw_fence_manager *fman, | |||
538 | struct vmw_fence_obj **p_fence) | 538 | struct vmw_fence_obj **p_fence) |
539 | { | 539 | { |
540 | struct vmw_fence_obj *fence; | 540 | struct vmw_fence_obj *fence; |
541 | int ret; | 541 | int ret; |
542 | 542 | ||
543 | fence = kzalloc(sizeof(*fence), GFP_KERNEL); | 543 | fence = kzalloc(sizeof(*fence), GFP_KERNEL); |
544 | if (unlikely(fence == NULL)) | 544 | if (unlikely(fence == NULL)) |
@@ -701,6 +701,41 @@ void vmw_fence_fifo_up(struct vmw_fence_manager *fman) | |||
701 | } | 701 | } |
702 | 702 | ||
703 | 703 | ||
704 | /** | ||
705 | * vmw_fence_obj_lookup - Look up a user-space fence object | ||
706 | * | ||
707 | * @tfile: A struct ttm_object_file identifying the caller. | ||
708 | * @handle: A handle identifying the fence object. | ||
709 | * @return: A struct vmw_user_fence base ttm object on success or | ||
710 | * an error pointer on failure. | ||
711 | * | ||
712 | * The fence object is looked up and type-checked. The caller needs | ||
713 | * to have opened the fence object first, but since that happens on | ||
714 | * creation and fence objects aren't shareable, that's not an | ||
715 | * issue currently. | ||
716 | */ | ||
717 | static struct ttm_base_object * | ||
718 | vmw_fence_obj_lookup(struct ttm_object_file *tfile, u32 handle) | ||
719 | { | ||
720 | struct ttm_base_object *base = ttm_base_object_lookup(tfile, handle); | ||
721 | |||
722 | if (!base) { | ||
723 | pr_err("Invalid fence object handle 0x%08lx.\n", | ||
724 | (unsigned long)handle); | ||
725 | return ERR_PTR(-EINVAL); | ||
726 | } | ||
727 | |||
728 | if (base->refcount_release != vmw_user_fence_base_release) { | ||
729 | pr_err("Invalid fence object handle 0x%08lx.\n", | ||
730 | (unsigned long)handle); | ||
731 | ttm_base_object_unref(&base); | ||
732 | return ERR_PTR(-EINVAL); | ||
733 | } | ||
734 | |||
735 | return base; | ||
736 | } | ||
737 | |||
738 | |||
704 | int vmw_fence_obj_wait_ioctl(struct drm_device *dev, void *data, | 739 | int vmw_fence_obj_wait_ioctl(struct drm_device *dev, void *data, |
705 | struct drm_file *file_priv) | 740 | struct drm_file *file_priv) |
706 | { | 741 | { |
@@ -726,13 +761,9 @@ int vmw_fence_obj_wait_ioctl(struct drm_device *dev, void *data, | |||
726 | arg->kernel_cookie = jiffies + wait_timeout; | 761 | arg->kernel_cookie = jiffies + wait_timeout; |
727 | } | 762 | } |
728 | 763 | ||
729 | base = ttm_base_object_lookup(tfile, arg->handle); | 764 | base = vmw_fence_obj_lookup(tfile, arg->handle); |
730 | if (unlikely(base == NULL)) { | 765 | if (IS_ERR(base)) |
731 | printk(KERN_ERR "Wait invalid fence object handle " | 766 | return PTR_ERR(base); |
732 | "0x%08lx.\n", | ||
733 | (unsigned long)arg->handle); | ||
734 | return -EINVAL; | ||
735 | } | ||
736 | 767 | ||
737 | fence = &(container_of(base, struct vmw_user_fence, base)->fence); | 768 | fence = &(container_of(base, struct vmw_user_fence, base)->fence); |
738 | 769 | ||
@@ -771,13 +802,9 @@ int vmw_fence_obj_signaled_ioctl(struct drm_device *dev, void *data, | |||
771 | struct ttm_object_file *tfile = vmw_fpriv(file_priv)->tfile; | 802 | struct ttm_object_file *tfile = vmw_fpriv(file_priv)->tfile; |
772 | struct vmw_private *dev_priv = vmw_priv(dev); | 803 | struct vmw_private *dev_priv = vmw_priv(dev); |
773 | 804 | ||
774 | base = ttm_base_object_lookup(tfile, arg->handle); | 805 | base = vmw_fence_obj_lookup(tfile, arg->handle); |
775 | if (unlikely(base == NULL)) { | 806 | if (IS_ERR(base)) |
776 | printk(KERN_ERR "Fence signaled invalid fence object handle " | 807 | return PTR_ERR(base); |
777 | "0x%08lx.\n", | ||
778 | (unsigned long)arg->handle); | ||
779 | return -EINVAL; | ||
780 | } | ||
781 | 808 | ||
782 | fence = &(container_of(base, struct vmw_user_fence, base)->fence); | 809 | fence = &(container_of(base, struct vmw_user_fence, base)->fence); |
783 | fman = fman_from_fence(fence); | 810 | fman = fman_from_fence(fence); |
@@ -1024,6 +1051,7 @@ int vmw_fence_event_ioctl(struct drm_device *dev, void *data, | |||
1024 | (struct drm_vmw_fence_event_arg *) data; | 1051 | (struct drm_vmw_fence_event_arg *) data; |
1025 | struct vmw_fence_obj *fence = NULL; | 1052 | struct vmw_fence_obj *fence = NULL; |
1026 | struct vmw_fpriv *vmw_fp = vmw_fpriv(file_priv); | 1053 | struct vmw_fpriv *vmw_fp = vmw_fpriv(file_priv); |
1054 | struct ttm_object_file *tfile = vmw_fp->tfile; | ||
1027 | struct drm_vmw_fence_rep __user *user_fence_rep = | 1055 | struct drm_vmw_fence_rep __user *user_fence_rep = |
1028 | (struct drm_vmw_fence_rep __user *)(unsigned long) | 1056 | (struct drm_vmw_fence_rep __user *)(unsigned long) |
1029 | arg->fence_rep; | 1057 | arg->fence_rep; |
@@ -1037,24 +1065,18 @@ int vmw_fence_event_ioctl(struct drm_device *dev, void *data, | |||
1037 | */ | 1065 | */ |
1038 | if (arg->handle) { | 1066 | if (arg->handle) { |
1039 | struct ttm_base_object *base = | 1067 | struct ttm_base_object *base = |
1040 | ttm_base_object_lookup_for_ref(dev_priv->tdev, | 1068 | vmw_fence_obj_lookup(tfile, arg->handle); |
1041 | arg->handle); | 1069 | |
1042 | 1070 | if (IS_ERR(base)) | |
1043 | if (unlikely(base == NULL)) { | 1071 | return PTR_ERR(base); |
1044 | DRM_ERROR("Fence event invalid fence object handle " | 1072 | |
1045 | "0x%08lx.\n", | ||
1046 | (unsigned long)arg->handle); | ||
1047 | return -EINVAL; | ||
1048 | } | ||
1049 | fence = &(container_of(base, struct vmw_user_fence, | 1073 | fence = &(container_of(base, struct vmw_user_fence, |
1050 | base)->fence); | 1074 | base)->fence); |
1051 | (void) vmw_fence_obj_reference(fence); | 1075 | (void) vmw_fence_obj_reference(fence); |
1052 | 1076 | ||
1053 | if (user_fence_rep != NULL) { | 1077 | if (user_fence_rep != NULL) { |
1054 | bool existed; | ||
1055 | |||
1056 | ret = ttm_ref_object_add(vmw_fp->tfile, base, | 1078 | ret = ttm_ref_object_add(vmw_fp->tfile, base, |
1057 | TTM_REF_USAGE, &existed); | 1079 | TTM_REF_USAGE, NULL, false); |
1058 | if (unlikely(ret != 0)) { | 1080 | if (unlikely(ret != 0)) { |
1059 | DRM_ERROR("Failed to reference a fence " | 1081 | DRM_ERROR("Failed to reference a fence " |
1060 | "object.\n"); | 1082 | "object.\n"); |
@@ -1097,8 +1119,7 @@ int vmw_fence_event_ioctl(struct drm_device *dev, void *data, | |||
1097 | return 0; | 1119 | return 0; |
1098 | out_no_create: | 1120 | out_no_create: |
1099 | if (user_fence_rep != NULL) | 1121 | if (user_fence_rep != NULL) |
1100 | ttm_ref_object_base_unref(vmw_fpriv(file_priv)->tfile, | 1122 | ttm_ref_object_base_unref(tfile, handle, TTM_REF_USAGE); |
1101 | handle, TTM_REF_USAGE); | ||
1102 | out_no_ref_obj: | 1123 | out_no_ref_obj: |
1103 | vmw_fence_obj_unreference(&fence); | 1124 | vmw_fence_obj_unreference(&fence); |
1104 | return ret; | 1125 | return ret; |
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c index b8c6a03c8c54..5ec24fd801cd 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c | |||
@@ -114,8 +114,6 @@ int vmw_getparam_ioctl(struct drm_device *dev, void *data, | |||
114 | param->value = dev_priv->has_dx; | 114 | param->value = dev_priv->has_dx; |
115 | break; | 115 | break; |
116 | default: | 116 | default: |
117 | DRM_ERROR("Illegal vmwgfx get param request: %d\n", | ||
118 | param->param); | ||
119 | return -EINVAL; | 117 | return -EINVAL; |
120 | } | 118 | } |
121 | 119 | ||
@@ -186,7 +184,7 @@ int vmw_get_cap_3d_ioctl(struct drm_device *dev, void *data, | |||
186 | bool gb_objects = !!(dev_priv->capabilities & SVGA_CAP_GBOBJECTS); | 184 | bool gb_objects = !!(dev_priv->capabilities & SVGA_CAP_GBOBJECTS); |
187 | struct vmw_fpriv *vmw_fp = vmw_fpriv(file_priv); | 185 | struct vmw_fpriv *vmw_fp = vmw_fpriv(file_priv); |
188 | 186 | ||
189 | if (unlikely(arg->pad64 != 0)) { | 187 | if (unlikely(arg->pad64 != 0 || arg->max_size == 0)) { |
190 | DRM_ERROR("Illegal GET_3D_CAP argument.\n"); | 188 | DRM_ERROR("Illegal GET_3D_CAP argument.\n"); |
191 | return -EINVAL; | 189 | return -EINVAL; |
192 | } | 190 | } |
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c b/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c index 65b3f0369636..bf23153d4f55 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c | |||
@@ -589,7 +589,7 @@ static int vmw_user_dmabuf_synccpu_grab(struct vmw_user_dma_buffer *user_bo, | |||
589 | return ret; | 589 | return ret; |
590 | 590 | ||
591 | ret = ttm_ref_object_add(tfile, &user_bo->prime.base, | 591 | ret = ttm_ref_object_add(tfile, &user_bo->prime.base, |
592 | TTM_REF_SYNCCPU_WRITE, &existed); | 592 | TTM_REF_SYNCCPU_WRITE, &existed, false); |
593 | if (ret != 0 || existed) | 593 | if (ret != 0 || existed) |
594 | ttm_bo_synccpu_write_release(&user_bo->dma.base); | 594 | ttm_bo_synccpu_write_release(&user_bo->dma.base); |
595 | 595 | ||
@@ -773,7 +773,7 @@ int vmw_user_dmabuf_reference(struct ttm_object_file *tfile, | |||
773 | 773 | ||
774 | *handle = user_bo->prime.base.hash.key; | 774 | *handle = user_bo->prime.base.hash.key; |
775 | return ttm_ref_object_add(tfile, &user_bo->prime.base, | 775 | return ttm_ref_object_add(tfile, &user_bo->prime.base, |
776 | TTM_REF_USAGE, NULL); | 776 | TTM_REF_USAGE, NULL, false); |
777 | } | 777 | } |
778 | 778 | ||
779 | /* | 779 | /* |
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c index b445ce9b9757..05fa092c942b 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c | |||
@@ -713,11 +713,14 @@ int vmw_surface_define_ioctl(struct drm_device *dev, void *data, | |||
713 | 128; | 713 | 128; |
714 | 714 | ||
715 | num_sizes = 0; | 715 | num_sizes = 0; |
716 | for (i = 0; i < DRM_VMW_MAX_SURFACE_FACES; ++i) | 716 | for (i = 0; i < DRM_VMW_MAX_SURFACE_FACES; ++i) { |
717 | if (req->mip_levels[i] > DRM_VMW_MAX_MIP_LEVELS) | ||
718 | return -EINVAL; | ||
717 | num_sizes += req->mip_levels[i]; | 719 | num_sizes += req->mip_levels[i]; |
720 | } | ||
718 | 721 | ||
719 | if (num_sizes > DRM_VMW_MAX_SURFACE_FACES * | 722 | if (num_sizes > DRM_VMW_MAX_SURFACE_FACES * DRM_VMW_MAX_MIP_LEVELS || |
720 | DRM_VMW_MAX_MIP_LEVELS) | 723 | num_sizes == 0) |
721 | return -EINVAL; | 724 | return -EINVAL; |
722 | 725 | ||
723 | size = vmw_user_surface_size + 128 + | 726 | size = vmw_user_surface_size + 128 + |
@@ -891,17 +894,16 @@ vmw_surface_handle_reference(struct vmw_private *dev_priv, | |||
891 | uint32_t handle; | 894 | uint32_t handle; |
892 | struct ttm_base_object *base; | 895 | struct ttm_base_object *base; |
893 | int ret; | 896 | int ret; |
897 | bool require_exist = false; | ||
894 | 898 | ||
895 | if (handle_type == DRM_VMW_HANDLE_PRIME) { | 899 | if (handle_type == DRM_VMW_HANDLE_PRIME) { |
896 | ret = ttm_prime_fd_to_handle(tfile, u_handle, &handle); | 900 | ret = ttm_prime_fd_to_handle(tfile, u_handle, &handle); |
897 | if (unlikely(ret != 0)) | 901 | if (unlikely(ret != 0)) |
898 | return ret; | 902 | return ret; |
899 | } else { | 903 | } else { |
900 | if (unlikely(drm_is_render_client(file_priv))) { | 904 | if (unlikely(drm_is_render_client(file_priv))) |
901 | DRM_ERROR("Render client refused legacy " | 905 | require_exist = true; |
902 | "surface reference.\n"); | 906 | |
903 | return -EACCES; | ||
904 | } | ||
905 | if (ACCESS_ONCE(vmw_fpriv(file_priv)->locked_master)) { | 907 | if (ACCESS_ONCE(vmw_fpriv(file_priv)->locked_master)) { |
906 | DRM_ERROR("Locked master refused legacy " | 908 | DRM_ERROR("Locked master refused legacy " |
907 | "surface reference.\n"); | 909 | "surface reference.\n"); |
@@ -929,17 +931,14 @@ vmw_surface_handle_reference(struct vmw_private *dev_priv, | |||
929 | 931 | ||
930 | /* | 932 | /* |
931 | * Make sure the surface creator has the same | 933 | * Make sure the surface creator has the same |
932 | * authenticating master. | 934 | * authenticating master, or is already registered with us. |
933 | */ | 935 | */ |
934 | if (drm_is_primary_client(file_priv) && | 936 | if (drm_is_primary_client(file_priv) && |
935 | user_srf->master != file_priv->master) { | 937 | user_srf->master != file_priv->master) |
936 | DRM_ERROR("Trying to reference surface outside of" | 938 | require_exist = true; |
937 | " master domain.\n"); | ||
938 | ret = -EACCES; | ||
939 | goto out_bad_resource; | ||
940 | } | ||
941 | 939 | ||
942 | ret = ttm_ref_object_add(tfile, base, TTM_REF_USAGE, NULL); | 940 | ret = ttm_ref_object_add(tfile, base, TTM_REF_USAGE, NULL, |
941 | require_exist); | ||
943 | if (unlikely(ret != 0)) { | 942 | if (unlikely(ret != 0)) { |
944 | DRM_ERROR("Could not add a reference to a surface.\n"); | 943 | DRM_ERROR("Could not add a reference to a surface.\n"); |
945 | goto out_bad_resource; | 944 | goto out_bad_resource; |
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index 3ceb4a2af381..d162f0dc76e3 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c | |||
@@ -819,8 +819,7 @@ static int hid_scan_report(struct hid_device *hid) | |||
819 | hid->group = HID_GROUP_WACOM; | 819 | hid->group = HID_GROUP_WACOM; |
820 | break; | 820 | break; |
821 | case USB_VENDOR_ID_SYNAPTICS: | 821 | case USB_VENDOR_ID_SYNAPTICS: |
822 | if (hid->group == HID_GROUP_GENERIC || | 822 | if (hid->group == HID_GROUP_GENERIC) |
823 | hid->group == HID_GROUP_MULTITOUCH_WIN_8) | ||
824 | if ((parser->scan_flags & HID_SCAN_FLAG_VENDOR_SPECIFIC) | 823 | if ((parser->scan_flags & HID_SCAN_FLAG_VENDOR_SPECIFIC) |
825 | && (parser->scan_flags & HID_SCAN_FLAG_GD_POINTER)) | 824 | && (parser->scan_flags & HID_SCAN_FLAG_GD_POINTER)) |
826 | /* | 825 | /* |
@@ -2096,6 +2095,7 @@ static const struct hid_device_id hid_have_special_driver[] = { | |||
2096 | { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UGEE_TABLET_45) }, | 2095 | { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UGEE_TABLET_45) }, |
2097 | { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_DRAWIMAGE_G3) }, | 2096 | { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_DRAWIMAGE_G3) }, |
2098 | { HID_USB_DEVICE(USB_VENDOR_ID_UGTIZER, USB_DEVICE_ID_UGTIZER_TABLET_GP0610) }, | 2097 | { HID_USB_DEVICE(USB_VENDOR_ID_UGTIZER, USB_DEVICE_ID_UGTIZER_TABLET_GP0610) }, |
2098 | { HID_USB_DEVICE(USB_VENDOR_ID_UGEE, USB_DEVICE_ID_UGEE_TABLET_EX07S) }, | ||
2099 | { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_SMARTJOY_PLUS) }, | 2099 | { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_SMARTJOY_PLUS) }, |
2100 | { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_SUPER_JOY_BOX_3) }, | 2100 | { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_SUPER_JOY_BOX_3) }, |
2101 | { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_DUAL_USB_JOYPAD) }, | 2101 | { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_DUAL_USB_JOYPAD) }, |
@@ -2112,6 +2112,7 @@ static const struct hid_device_id hid_have_special_driver[] = { | |||
2112 | { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_SIRIUS_BATTERY_FREE_TABLET) }, | 2112 | { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_SIRIUS_BATTERY_FREE_TABLET) }, |
2113 | { HID_USB_DEVICE(USB_VENDOR_ID_X_TENSIONS, USB_DEVICE_ID_SPEEDLINK_VAD_CEZANNE) }, | 2113 | { HID_USB_DEVICE(USB_VENDOR_ID_X_TENSIONS, USB_DEVICE_ID_SPEEDLINK_VAD_CEZANNE) }, |
2114 | { HID_USB_DEVICE(USB_VENDOR_ID_XIN_MO, USB_DEVICE_ID_XIN_MO_DUAL_ARCADE) }, | 2114 | { HID_USB_DEVICE(USB_VENDOR_ID_XIN_MO, USB_DEVICE_ID_XIN_MO_DUAL_ARCADE) }, |
2115 | { HID_USB_DEVICE(USB_VENDOR_ID_XIN_MO, USB_DEVICE_ID_THT_2P_ARCADE) }, | ||
2115 | { HID_USB_DEVICE(USB_VENDOR_ID_ZEROPLUS, 0x0005) }, | 2116 | { HID_USB_DEVICE(USB_VENDOR_ID_ZEROPLUS, 0x0005) }, |
2116 | { HID_USB_DEVICE(USB_VENDOR_ID_ZEROPLUS, 0x0030) }, | 2117 | { HID_USB_DEVICE(USB_VENDOR_ID_ZEROPLUS, 0x0030) }, |
2117 | { HID_USB_DEVICE(USB_VENDOR_ID_ZYDACRON, USB_DEVICE_ID_ZYDACRON_REMOTE_CONTROL) }, | 2118 | { HID_USB_DEVICE(USB_VENDOR_ID_ZYDACRON, USB_DEVICE_ID_ZYDACRON_REMOTE_CONTROL) }, |
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h index 0e2e7c571d22..b26c030926c1 100644 --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h | |||
@@ -1028,6 +1028,9 @@ | |||
1028 | #define USB_DEVICE_ID_UGEE_TABLET_45 0x0045 | 1028 | #define USB_DEVICE_ID_UGEE_TABLET_45 0x0045 |
1029 | #define USB_DEVICE_ID_YIYNOVA_TABLET 0x004d | 1029 | #define USB_DEVICE_ID_YIYNOVA_TABLET 0x004d |
1030 | 1030 | ||
1031 | #define USB_VENDOR_ID_UGEE 0x28bd | ||
1032 | #define USB_DEVICE_ID_UGEE_TABLET_EX07S 0x0071 | ||
1033 | |||
1031 | #define USB_VENDOR_ID_UNITEC 0x227d | 1034 | #define USB_VENDOR_ID_UNITEC 0x227d |
1032 | #define USB_DEVICE_ID_UNITEC_USB_TOUCH_0709 0x0709 | 1035 | #define USB_DEVICE_ID_UNITEC_USB_TOUCH_0709 0x0709 |
1033 | #define USB_DEVICE_ID_UNITEC_USB_TOUCH_0A19 0x0a19 | 1036 | #define USB_DEVICE_ID_UNITEC_USB_TOUCH_0A19 0x0a19 |
@@ -1082,6 +1085,7 @@ | |||
1082 | 1085 | ||
1083 | #define USB_VENDOR_ID_XIN_MO 0x16c0 | 1086 | #define USB_VENDOR_ID_XIN_MO 0x16c0 |
1084 | #define USB_DEVICE_ID_XIN_MO_DUAL_ARCADE 0x05e1 | 1087 | #define USB_DEVICE_ID_XIN_MO_DUAL_ARCADE 0x05e1 |
1088 | #define USB_DEVICE_ID_THT_2P_ARCADE 0x75e1 | ||
1085 | 1089 | ||
1086 | #define USB_VENDOR_ID_XIROKU 0x1477 | 1090 | #define USB_VENDOR_ID_XIROKU 0x1477 |
1087 | #define USB_DEVICE_ID_XIROKU_SPX 0x1006 | 1091 | #define USB_DEVICE_ID_XIROKU_SPX 0x1006 |
diff --git a/drivers/hid/hid-uclogic.c b/drivers/hid/hid-uclogic.c index 1509d7287ff3..e3e6e5c893cc 100644 --- a/drivers/hid/hid-uclogic.c +++ b/drivers/hid/hid-uclogic.c | |||
@@ -977,6 +977,7 @@ static int uclogic_probe(struct hid_device *hdev, | |||
977 | } | 977 | } |
978 | break; | 978 | break; |
979 | case USB_DEVICE_ID_UGTIZER_TABLET_GP0610: | 979 | case USB_DEVICE_ID_UGTIZER_TABLET_GP0610: |
980 | case USB_DEVICE_ID_UGEE_TABLET_EX07S: | ||
980 | /* If this is the pen interface */ | 981 | /* If this is the pen interface */ |
981 | if (intf->cur_altsetting->desc.bInterfaceNumber == 1) { | 982 | if (intf->cur_altsetting->desc.bInterfaceNumber == 1) { |
982 | rc = uclogic_tablet_enable(hdev); | 983 | rc = uclogic_tablet_enable(hdev); |
@@ -1069,6 +1070,7 @@ static const struct hid_device_id uclogic_devices[] = { | |||
1069 | { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UGEE_TABLET_45) }, | 1070 | { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UGEE_TABLET_45) }, |
1070 | { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_DRAWIMAGE_G3) }, | 1071 | { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_DRAWIMAGE_G3) }, |
1071 | { HID_USB_DEVICE(USB_VENDOR_ID_UGTIZER, USB_DEVICE_ID_UGTIZER_TABLET_GP0610) }, | 1072 | { HID_USB_DEVICE(USB_VENDOR_ID_UGTIZER, USB_DEVICE_ID_UGTIZER_TABLET_GP0610) }, |
1073 | { HID_USB_DEVICE(USB_VENDOR_ID_UGEE, USB_DEVICE_ID_UGEE_TABLET_EX07S) }, | ||
1072 | { } | 1074 | { } |
1073 | }; | 1075 | }; |
1074 | MODULE_DEVICE_TABLE(hid, uclogic_devices); | 1076 | MODULE_DEVICE_TABLE(hid, uclogic_devices); |
diff --git a/drivers/hid/hid-xinmo.c b/drivers/hid/hid-xinmo.c index 7df5227a7e61..9ad7731d2e10 100644 --- a/drivers/hid/hid-xinmo.c +++ b/drivers/hid/hid-xinmo.c | |||
@@ -46,6 +46,7 @@ static int xinmo_event(struct hid_device *hdev, struct hid_field *field, | |||
46 | 46 | ||
47 | static const struct hid_device_id xinmo_devices[] = { | 47 | static const struct hid_device_id xinmo_devices[] = { |
48 | { HID_USB_DEVICE(USB_VENDOR_ID_XIN_MO, USB_DEVICE_ID_XIN_MO_DUAL_ARCADE) }, | 48 | { HID_USB_DEVICE(USB_VENDOR_ID_XIN_MO, USB_DEVICE_ID_XIN_MO_DUAL_ARCADE) }, |
49 | { HID_USB_DEVICE(USB_VENDOR_ID_XIN_MO, USB_DEVICE_ID_THT_2P_ARCADE) }, | ||
49 | { } | 50 | { } |
50 | }; | 51 | }; |
51 | 52 | ||
diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c index 994bddc55b82..e2666ef84dc1 100644 --- a/drivers/hid/wacom_sys.c +++ b/drivers/hid/wacom_sys.c | |||
@@ -2165,6 +2165,14 @@ static int wacom_parse_and_register(struct wacom *wacom, bool wireless) | |||
2165 | 2165 | ||
2166 | wacom_update_name(wacom, wireless ? " (WL)" : ""); | 2166 | wacom_update_name(wacom, wireless ? " (WL)" : ""); |
2167 | 2167 | ||
2168 | /* pen only Bamboo neither support touch nor pad */ | ||
2169 | if ((features->type == BAMBOO_PEN) && | ||
2170 | ((features->device_type & WACOM_DEVICETYPE_TOUCH) || | ||
2171 | (features->device_type & WACOM_DEVICETYPE_PAD))) { | ||
2172 | error = -ENODEV; | ||
2173 | goto fail; | ||
2174 | } | ||
2175 | |||
2168 | error = wacom_add_shared_data(hdev); | 2176 | error = wacom_add_shared_data(hdev); |
2169 | if (error) | 2177 | if (error) |
2170 | goto fail; | 2178 | goto fail; |
@@ -2208,14 +2216,8 @@ static int wacom_parse_and_register(struct wacom *wacom, bool wireless) | |||
2208 | /* touch only Bamboo doesn't support pen */ | 2216 | /* touch only Bamboo doesn't support pen */ |
2209 | if ((features->type == BAMBOO_TOUCH) && | 2217 | if ((features->type == BAMBOO_TOUCH) && |
2210 | (features->device_type & WACOM_DEVICETYPE_PEN)) { | 2218 | (features->device_type & WACOM_DEVICETYPE_PEN)) { |
2211 | error = -ENODEV; | 2219 | cancel_delayed_work_sync(&wacom->init_work); |
2212 | goto fail_quirks; | 2220 | _wacom_query_tablet_data(wacom); |
2213 | } | ||
2214 | |||
2215 | /* pen only Bamboo neither support touch nor pad */ | ||
2216 | if ((features->type == BAMBOO_PEN) && | ||
2217 | ((features->device_type & WACOM_DEVICETYPE_TOUCH) || | ||
2218 | (features->device_type & WACOM_DEVICETYPE_PAD))) { | ||
2219 | error = -ENODEV; | 2221 | error = -ENODEV; |
2220 | goto fail_quirks; | 2222 | goto fail_quirks; |
2221 | } | 2223 | } |
diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c index 94250c293be2..c68ac65db7ff 100644 --- a/drivers/hid/wacom_wac.c +++ b/drivers/hid/wacom_wac.c | |||
@@ -2006,7 +2006,7 @@ static void wacom_wac_pen_event(struct hid_device *hdev, struct hid_field *field | |||
2006 | return; | 2006 | return; |
2007 | case HID_DG_TOOLSERIALNUMBER: | 2007 | case HID_DG_TOOLSERIALNUMBER: |
2008 | wacom_wac->serial[0] = (wacom_wac->serial[0] & ~0xFFFFFFFFULL); | 2008 | wacom_wac->serial[0] = (wacom_wac->serial[0] & ~0xFFFFFFFFULL); |
2009 | wacom_wac->serial[0] |= value; | 2009 | wacom_wac->serial[0] |= (__u32)value; |
2010 | return; | 2010 | return; |
2011 | case WACOM_HID_WD_SENSE: | 2011 | case WACOM_HID_WD_SENSE: |
2012 | wacom_wac->hid_data.sense_state = value; | 2012 | wacom_wac->hid_data.sense_state = value; |
@@ -2176,6 +2176,16 @@ static void wacom_wac_finger_usage_mapping(struct hid_device *hdev, | |||
2176 | wacom_wac->hid_data.cc_index = field->index; | 2176 | wacom_wac->hid_data.cc_index = field->index; |
2177 | wacom_wac->hid_data.cc_value_index = usage->usage_index; | 2177 | wacom_wac->hid_data.cc_value_index = usage->usage_index; |
2178 | break; | 2178 | break; |
2179 | case HID_DG_CONTACTID: | ||
2180 | if ((field->logical_maximum - field->logical_minimum) < touch_max) { | ||
2181 | /* | ||
2182 | * The HID descriptor for G11 sensors leaves logical | ||
2183 | * maximum set to '1' despite it being a multitouch | ||
2184 | * device. Override to a sensible number. | ||
2185 | */ | ||
2186 | field->logical_maximum = 255; | ||
2187 | } | ||
2188 | break; | ||
2179 | } | 2189 | } |
2180 | } | 2190 | } |
2181 | 2191 | ||
diff --git a/drivers/i2c/muxes/i2c-mux-pca954x.c b/drivers/i2c/muxes/i2c-mux-pca954x.c index dfc1c0e37c40..ad31d21da316 100644 --- a/drivers/i2c/muxes/i2c-mux-pca954x.c +++ b/drivers/i2c/muxes/i2c-mux-pca954x.c | |||
@@ -35,7 +35,6 @@ | |||
35 | * warranty of any kind, whether express or implied. | 35 | * warranty of any kind, whether express or implied. |
36 | */ | 36 | */ |
37 | 37 | ||
38 | #include <linux/acpi.h> | ||
39 | #include <linux/device.h> | 38 | #include <linux/device.h> |
40 | #include <linux/gpio/consumer.h> | 39 | #include <linux/gpio/consumer.h> |
41 | #include <linux/i2c.h> | 40 | #include <linux/i2c.h> |
@@ -117,6 +116,10 @@ static const struct chip_desc chips[] = { | |||
117 | .has_irq = 1, | 116 | .has_irq = 1, |
118 | .muxtype = pca954x_isswi, | 117 | .muxtype = pca954x_isswi, |
119 | }, | 118 | }, |
119 | [pca_9546] = { | ||
120 | .nchans = 4, | ||
121 | .muxtype = pca954x_isswi, | ||
122 | }, | ||
120 | [pca_9547] = { | 123 | [pca_9547] = { |
121 | .nchans = 8, | 124 | .nchans = 8, |
122 | .enable = 0x8, | 125 | .enable = 0x8, |
@@ -134,28 +137,13 @@ static const struct i2c_device_id pca954x_id[] = { | |||
134 | { "pca9543", pca_9543 }, | 137 | { "pca9543", pca_9543 }, |
135 | { "pca9544", pca_9544 }, | 138 | { "pca9544", pca_9544 }, |
136 | { "pca9545", pca_9545 }, | 139 | { "pca9545", pca_9545 }, |
137 | { "pca9546", pca_9545 }, | 140 | { "pca9546", pca_9546 }, |
138 | { "pca9547", pca_9547 }, | 141 | { "pca9547", pca_9547 }, |
139 | { "pca9548", pca_9548 }, | 142 | { "pca9548", pca_9548 }, |
140 | { } | 143 | { } |
141 | }; | 144 | }; |
142 | MODULE_DEVICE_TABLE(i2c, pca954x_id); | 145 | MODULE_DEVICE_TABLE(i2c, pca954x_id); |
143 | 146 | ||
144 | #ifdef CONFIG_ACPI | ||
145 | static const struct acpi_device_id pca954x_acpi_ids[] = { | ||
146 | { .id = "PCA9540", .driver_data = pca_9540 }, | ||
147 | { .id = "PCA9542", .driver_data = pca_9542 }, | ||
148 | { .id = "PCA9543", .driver_data = pca_9543 }, | ||
149 | { .id = "PCA9544", .driver_data = pca_9544 }, | ||
150 | { .id = "PCA9545", .driver_data = pca_9545 }, | ||
151 | { .id = "PCA9546", .driver_data = pca_9545 }, | ||
152 | { .id = "PCA9547", .driver_data = pca_9547 }, | ||
153 | { .id = "PCA9548", .driver_data = pca_9548 }, | ||
154 | { } | ||
155 | }; | ||
156 | MODULE_DEVICE_TABLE(acpi, pca954x_acpi_ids); | ||
157 | #endif | ||
158 | |||
159 | #ifdef CONFIG_OF | 147 | #ifdef CONFIG_OF |
160 | static const struct of_device_id pca954x_of_match[] = { | 148 | static const struct of_device_id pca954x_of_match[] = { |
161 | { .compatible = "nxp,pca9540", .data = &chips[pca_9540] }, | 149 | { .compatible = "nxp,pca9540", .data = &chips[pca_9540] }, |
@@ -393,17 +381,8 @@ static int pca954x_probe(struct i2c_client *client, | |||
393 | match = of_match_device(of_match_ptr(pca954x_of_match), &client->dev); | 381 | match = of_match_device(of_match_ptr(pca954x_of_match), &client->dev); |
394 | if (match) | 382 | if (match) |
395 | data->chip = of_device_get_match_data(&client->dev); | 383 | data->chip = of_device_get_match_data(&client->dev); |
396 | else if (id) | 384 | else |
397 | data->chip = &chips[id->driver_data]; | 385 | data->chip = &chips[id->driver_data]; |
398 | else { | ||
399 | const struct acpi_device_id *acpi_id; | ||
400 | |||
401 | acpi_id = acpi_match_device(ACPI_PTR(pca954x_acpi_ids), | ||
402 | &client->dev); | ||
403 | if (!acpi_id) | ||
404 | return -ENODEV; | ||
405 | data->chip = &chips[acpi_id->driver_data]; | ||
406 | } | ||
407 | 386 | ||
408 | data->last_chan = 0; /* force the first selection */ | 387 | data->last_chan = 0; /* force the first selection */ |
409 | 388 | ||
@@ -492,7 +471,6 @@ static struct i2c_driver pca954x_driver = { | |||
492 | .name = "pca954x", | 471 | .name = "pca954x", |
493 | .pm = &pca954x_pm, | 472 | .pm = &pca954x_pm, |
494 | .of_match_table = of_match_ptr(pca954x_of_match), | 473 | .of_match_table = of_match_ptr(pca954x_of_match), |
495 | .acpi_match_table = ACPI_PTR(pca954x_acpi_ids), | ||
496 | }, | 474 | }, |
497 | .probe = pca954x_probe, | 475 | .probe = pca954x_probe, |
498 | .remove = pca954x_remove, | 476 | .remove = pca954x_remove, |
diff --git a/drivers/iio/accel/hid-sensor-accel-3d.c b/drivers/iio/accel/hid-sensor-accel-3d.c index ca5759c0c318..43a6cb078193 100644 --- a/drivers/iio/accel/hid-sensor-accel-3d.c +++ b/drivers/iio/accel/hid-sensor-accel-3d.c | |||
@@ -370,10 +370,12 @@ static int hid_accel_3d_probe(struct platform_device *pdev) | |||
370 | name = "accel_3d"; | 370 | name = "accel_3d"; |
371 | channel_spec = accel_3d_channels; | 371 | channel_spec = accel_3d_channels; |
372 | channel_size = sizeof(accel_3d_channels); | 372 | channel_size = sizeof(accel_3d_channels); |
373 | indio_dev->num_channels = ARRAY_SIZE(accel_3d_channels); | ||
373 | } else { | 374 | } else { |
374 | name = "gravity"; | 375 | name = "gravity"; |
375 | channel_spec = gravity_channels; | 376 | channel_spec = gravity_channels; |
376 | channel_size = sizeof(gravity_channels); | 377 | channel_size = sizeof(gravity_channels); |
378 | indio_dev->num_channels = ARRAY_SIZE(gravity_channels); | ||
377 | } | 379 | } |
378 | ret = hid_sensor_parse_common_attributes(hsdev, hsdev->usage, | 380 | ret = hid_sensor_parse_common_attributes(hsdev, hsdev->usage, |
379 | &accel_state->common_attributes); | 381 | &accel_state->common_attributes); |
@@ -395,7 +397,6 @@ static int hid_accel_3d_probe(struct platform_device *pdev) | |||
395 | goto error_free_dev_mem; | 397 | goto error_free_dev_mem; |
396 | } | 398 | } |
397 | 399 | ||
398 | indio_dev->num_channels = ARRAY_SIZE(accel_3d_channels); | ||
399 | indio_dev->dev.parent = &pdev->dev; | 400 | indio_dev->dev.parent = &pdev->dev; |
400 | indio_dev->info = &accel_3d_info; | 401 | indio_dev->info = &accel_3d_info; |
401 | indio_dev->name = name; | 402 | indio_dev->name = name; |
diff --git a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c index d6c372bb433b..c17596f7ed2c 100644 --- a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c +++ b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c | |||
@@ -61,7 +61,7 @@ static int cros_ec_sensors_read(struct iio_dev *indio_dev, | |||
61 | ret = st->core.read_ec_sensors_data(indio_dev, 1 << idx, &data); | 61 | ret = st->core.read_ec_sensors_data(indio_dev, 1 << idx, &data); |
62 | if (ret < 0) | 62 | if (ret < 0) |
63 | break; | 63 | break; |
64 | 64 | ret = IIO_VAL_INT; | |
65 | *val = data; | 65 | *val = data; |
66 | break; | 66 | break; |
67 | case IIO_CHAN_INFO_CALIBBIAS: | 67 | case IIO_CHAN_INFO_CALIBBIAS: |
@@ -76,7 +76,7 @@ static int cros_ec_sensors_read(struct iio_dev *indio_dev, | |||
76 | for (i = CROS_EC_SENSOR_X; i < CROS_EC_SENSOR_MAX_AXIS; i++) | 76 | for (i = CROS_EC_SENSOR_X; i < CROS_EC_SENSOR_MAX_AXIS; i++) |
77 | st->core.calib[i] = | 77 | st->core.calib[i] = |
78 | st->core.resp->sensor_offset.offset[i]; | 78 | st->core.resp->sensor_offset.offset[i]; |
79 | 79 | ret = IIO_VAL_INT; | |
80 | *val = st->core.calib[idx]; | 80 | *val = st->core.calib[idx]; |
81 | break; | 81 | break; |
82 | case IIO_CHAN_INFO_SCALE: | 82 | case IIO_CHAN_INFO_SCALE: |
diff --git a/drivers/iio/common/hid-sensors/hid-sensor-attributes.c b/drivers/iio/common/hid-sensors/hid-sensor-attributes.c index 7afdac42ed42..01e02b9926d4 100644 --- a/drivers/iio/common/hid-sensors/hid-sensor-attributes.c +++ b/drivers/iio/common/hid-sensors/hid-sensor-attributes.c | |||
@@ -379,6 +379,8 @@ int hid_sensor_parse_common_attributes(struct hid_sensor_hub_device *hsdev, | |||
379 | { | 379 | { |
380 | 380 | ||
381 | struct hid_sensor_hub_attribute_info timestamp; | 381 | struct hid_sensor_hub_attribute_info timestamp; |
382 | s32 value; | ||
383 | int ret; | ||
382 | 384 | ||
383 | hid_sensor_get_reporting_interval(hsdev, usage_id, st); | 385 | hid_sensor_get_reporting_interval(hsdev, usage_id, st); |
384 | 386 | ||
@@ -417,6 +419,14 @@ int hid_sensor_parse_common_attributes(struct hid_sensor_hub_device *hsdev, | |||
417 | st->sensitivity.index, st->sensitivity.report_id, | 419 | st->sensitivity.index, st->sensitivity.report_id, |
418 | timestamp.index, timestamp.report_id); | 420 | timestamp.index, timestamp.report_id); |
419 | 421 | ||
422 | ret = sensor_hub_get_feature(hsdev, | ||
423 | st->power_state.report_id, | ||
424 | st->power_state.index, sizeof(value), &value); | ||
425 | if (ret < 0) | ||
426 | return ret; | ||
427 | if (value < 0) | ||
428 | return -EINVAL; | ||
429 | |||
420 | return 0; | 430 | return 0; |
421 | } | 431 | } |
422 | EXPORT_SYMBOL(hid_sensor_parse_common_attributes); | 432 | EXPORT_SYMBOL(hid_sensor_parse_common_attributes); |
diff --git a/drivers/iio/gyro/bmg160_core.c b/drivers/iio/gyro/bmg160_core.c index f7fcfa886f72..821919dd245b 100644 --- a/drivers/iio/gyro/bmg160_core.c +++ b/drivers/iio/gyro/bmg160_core.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include <linux/iio/trigger_consumer.h> | 27 | #include <linux/iio/trigger_consumer.h> |
28 | #include <linux/iio/triggered_buffer.h> | 28 | #include <linux/iio/triggered_buffer.h> |
29 | #include <linux/regmap.h> | 29 | #include <linux/regmap.h> |
30 | #include <linux/delay.h> | ||
30 | #include "bmg160.h" | 31 | #include "bmg160.h" |
31 | 32 | ||
32 | #define BMG160_IRQ_NAME "bmg160_event" | 33 | #define BMG160_IRQ_NAME "bmg160_event" |
@@ -52,6 +53,9 @@ | |||
52 | #define BMG160_DEF_BW 100 | 53 | #define BMG160_DEF_BW 100 |
53 | #define BMG160_REG_PMU_BW_RES BIT(7) | 54 | #define BMG160_REG_PMU_BW_RES BIT(7) |
54 | 55 | ||
56 | #define BMG160_GYRO_REG_RESET 0x14 | ||
57 | #define BMG160_GYRO_RESET_VAL 0xb6 | ||
58 | |||
55 | #define BMG160_REG_INT_MAP_0 0x17 | 59 | #define BMG160_REG_INT_MAP_0 0x17 |
56 | #define BMG160_INT_MAP_0_BIT_ANY BIT(1) | 60 | #define BMG160_INT_MAP_0_BIT_ANY BIT(1) |
57 | 61 | ||
@@ -236,6 +240,14 @@ static int bmg160_chip_init(struct bmg160_data *data) | |||
236 | int ret; | 240 | int ret; |
237 | unsigned int val; | 241 | unsigned int val; |
238 | 242 | ||
243 | /* | ||
244 | * Reset chip to get it in a known good state. A delay of 30ms after | ||
245 | * reset is required according to the datasheet. | ||
246 | */ | ||
247 | regmap_write(data->regmap, BMG160_GYRO_REG_RESET, | ||
248 | BMG160_GYRO_RESET_VAL); | ||
249 | usleep_range(30000, 30700); | ||
250 | |||
239 | ret = regmap_read(data->regmap, BMG160_REG_CHIP_ID, &val); | 251 | ret = regmap_read(data->regmap, BMG160_REG_CHIP_ID, &val); |
240 | if (ret < 0) { | 252 | if (ret < 0) { |
241 | dev_err(dev, "Error reading reg_chip_id\n"); | 253 | dev_err(dev, "Error reading reg_chip_id\n"); |
diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c index d18ded45bedd..3ff91e02fee3 100644 --- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c | |||
@@ -610,10 +610,9 @@ static ssize_t __iio_format_value(char *buf, size_t len, unsigned int type, | |||
610 | tmp0 = (int)div_s64_rem(tmp, 1000000000, &tmp1); | 610 | tmp0 = (int)div_s64_rem(tmp, 1000000000, &tmp1); |
611 | return snprintf(buf, len, "%d.%09u", tmp0, abs(tmp1)); | 611 | return snprintf(buf, len, "%d.%09u", tmp0, abs(tmp1)); |
612 | case IIO_VAL_FRACTIONAL_LOG2: | 612 | case IIO_VAL_FRACTIONAL_LOG2: |
613 | tmp = (s64)vals[0] * 1000000000LL >> vals[1]; | 613 | tmp = shift_right((s64)vals[0] * 1000000000LL, vals[1]); |
614 | tmp1 = do_div(tmp, 1000000000LL); | 614 | tmp0 = (int)div_s64_rem(tmp, 1000000000LL, &tmp1); |
615 | tmp0 = tmp; | 615 | return snprintf(buf, len, "%d.%09u", tmp0, abs(tmp1)); |
616 | return snprintf(buf, len, "%d.%09u", tmp0, tmp1); | ||
617 | case IIO_VAL_INT_MULTIPLE: | 616 | case IIO_VAL_INT_MULTIPLE: |
618 | { | 617 | { |
619 | int i; | 618 | int i; |
diff --git a/drivers/iio/pressure/st_pressure_core.c b/drivers/iio/pressure/st_pressure_core.c index 5f2680855552..fd0edca0e656 100644 --- a/drivers/iio/pressure/st_pressure_core.c +++ b/drivers/iio/pressure/st_pressure_core.c | |||
@@ -457,6 +457,7 @@ static const struct st_sensor_settings st_press_sensors_settings[] = { | |||
457 | .addr_stat_drdy = ST_SENSORS_DEFAULT_STAT_ADDR, | 457 | .addr_stat_drdy = ST_SENSORS_DEFAULT_STAT_ADDR, |
458 | }, | 458 | }, |
459 | .multi_read_bit = true, | 459 | .multi_read_bit = true, |
460 | .bootime = 2, | ||
460 | }, | 461 | }, |
461 | }; | 462 | }; |
462 | 463 | ||
diff --git a/drivers/infiniband/ulp/isert/ib_isert.c b/drivers/infiniband/ulp/isert/ib_isert.c index 91cbe86b25c8..fcbed35e95a8 100644 --- a/drivers/infiniband/ulp/isert/ib_isert.c +++ b/drivers/infiniband/ulp/isert/ib_isert.c | |||
@@ -817,6 +817,7 @@ isert_post_recvm(struct isert_conn *isert_conn, u32 count) | |||
817 | rx_wr->sg_list = &rx_desc->rx_sg; | 817 | rx_wr->sg_list = &rx_desc->rx_sg; |
818 | rx_wr->num_sge = 1; | 818 | rx_wr->num_sge = 1; |
819 | rx_wr->next = rx_wr + 1; | 819 | rx_wr->next = rx_wr + 1; |
820 | rx_desc->in_use = false; | ||
820 | } | 821 | } |
821 | rx_wr--; | 822 | rx_wr--; |
822 | rx_wr->next = NULL; /* mark end of work requests list */ | 823 | rx_wr->next = NULL; /* mark end of work requests list */ |
@@ -835,6 +836,15 @@ isert_post_recv(struct isert_conn *isert_conn, struct iser_rx_desc *rx_desc) | |||
835 | struct ib_recv_wr *rx_wr_failed, rx_wr; | 836 | struct ib_recv_wr *rx_wr_failed, rx_wr; |
836 | int ret; | 837 | int ret; |
837 | 838 | ||
839 | if (!rx_desc->in_use) { | ||
840 | /* | ||
841 | * if the descriptor is not in-use we already reposted it | ||
842 | * for recv, so just silently return | ||
843 | */ | ||
844 | return 0; | ||
845 | } | ||
846 | |||
847 | rx_desc->in_use = false; | ||
838 | rx_wr.wr_cqe = &rx_desc->rx_cqe; | 848 | rx_wr.wr_cqe = &rx_desc->rx_cqe; |
839 | rx_wr.sg_list = &rx_desc->rx_sg; | 849 | rx_wr.sg_list = &rx_desc->rx_sg; |
840 | rx_wr.num_sge = 1; | 850 | rx_wr.num_sge = 1; |
@@ -1397,6 +1407,8 @@ isert_recv_done(struct ib_cq *cq, struct ib_wc *wc) | |||
1397 | return; | 1407 | return; |
1398 | } | 1408 | } |
1399 | 1409 | ||
1410 | rx_desc->in_use = true; | ||
1411 | |||
1400 | ib_dma_sync_single_for_cpu(ib_dev, rx_desc->dma_addr, | 1412 | ib_dma_sync_single_for_cpu(ib_dev, rx_desc->dma_addr, |
1401 | ISER_RX_PAYLOAD_SIZE, DMA_FROM_DEVICE); | 1413 | ISER_RX_PAYLOAD_SIZE, DMA_FROM_DEVICE); |
1402 | 1414 | ||
@@ -1659,10 +1671,23 @@ isert_rdma_write_done(struct ib_cq *cq, struct ib_wc *wc) | |||
1659 | ret = isert_check_pi_status(cmd, isert_cmd->rw.sig->sig_mr); | 1671 | ret = isert_check_pi_status(cmd, isert_cmd->rw.sig->sig_mr); |
1660 | isert_rdma_rw_ctx_destroy(isert_cmd, isert_conn); | 1672 | isert_rdma_rw_ctx_destroy(isert_cmd, isert_conn); |
1661 | 1673 | ||
1662 | if (ret) | 1674 | if (ret) { |
1663 | transport_send_check_condition_and_sense(cmd, cmd->pi_err, 0); | 1675 | /* |
1664 | else | 1676 | * transport_generic_request_failure() expects to have |
1665 | isert_put_response(isert_conn->conn, isert_cmd->iscsi_cmd); | 1677 | * plus two references to handle queue-full, so re-add |
1678 | * one here as target-core will have already dropped | ||
1679 | * it after the first isert_put_datain() callback. | ||
1680 | */ | ||
1681 | kref_get(&cmd->cmd_kref); | ||
1682 | transport_generic_request_failure(cmd, cmd->pi_err); | ||
1683 | } else { | ||
1684 | /* | ||
1685 | * XXX: isert_put_response() failure is not retried. | ||
1686 | */ | ||
1687 | ret = isert_put_response(isert_conn->conn, isert_cmd->iscsi_cmd); | ||
1688 | if (ret) | ||
1689 | pr_warn_ratelimited("isert_put_response() ret: %d\n", ret); | ||
1690 | } | ||
1666 | } | 1691 | } |
1667 | 1692 | ||
1668 | static void | 1693 | static void |
@@ -1699,13 +1724,15 @@ isert_rdma_read_done(struct ib_cq *cq, struct ib_wc *wc) | |||
1699 | cmd->i_state = ISTATE_RECEIVED_LAST_DATAOUT; | 1724 | cmd->i_state = ISTATE_RECEIVED_LAST_DATAOUT; |
1700 | spin_unlock_bh(&cmd->istate_lock); | 1725 | spin_unlock_bh(&cmd->istate_lock); |
1701 | 1726 | ||
1702 | if (ret) { | 1727 | /* |
1703 | target_put_sess_cmd(se_cmd); | 1728 | * transport_generic_request_failure() will drop the extra |
1704 | transport_send_check_condition_and_sense(se_cmd, | 1729 | * se_cmd->cmd_kref reference after T10-PI error, and handle |
1705 | se_cmd->pi_err, 0); | 1730 | * any non-zero ->queue_status() callback error retries. |
1706 | } else { | 1731 | */ |
1732 | if (ret) | ||
1733 | transport_generic_request_failure(se_cmd, se_cmd->pi_err); | ||
1734 | else | ||
1707 | target_execute_cmd(se_cmd); | 1735 | target_execute_cmd(se_cmd); |
1708 | } | ||
1709 | } | 1736 | } |
1710 | 1737 | ||
1711 | static void | 1738 | static void |
@@ -2171,26 +2198,28 @@ isert_put_datain(struct iscsi_conn *conn, struct iscsi_cmd *cmd) | |||
2171 | chain_wr = &isert_cmd->tx_desc.send_wr; | 2198 | chain_wr = &isert_cmd->tx_desc.send_wr; |
2172 | } | 2199 | } |
2173 | 2200 | ||
2174 | isert_rdma_rw_ctx_post(isert_cmd, isert_conn, cqe, chain_wr); | 2201 | rc = isert_rdma_rw_ctx_post(isert_cmd, isert_conn, cqe, chain_wr); |
2175 | isert_dbg("Cmd: %p posted RDMA_WRITE for iSER Data READ\n", isert_cmd); | 2202 | isert_dbg("Cmd: %p posted RDMA_WRITE for iSER Data READ rc: %d\n", |
2176 | return 1; | 2203 | isert_cmd, rc); |
2204 | return rc; | ||
2177 | } | 2205 | } |
2178 | 2206 | ||
2179 | static int | 2207 | static int |
2180 | isert_get_dataout(struct iscsi_conn *conn, struct iscsi_cmd *cmd, bool recovery) | 2208 | isert_get_dataout(struct iscsi_conn *conn, struct iscsi_cmd *cmd, bool recovery) |
2181 | { | 2209 | { |
2182 | struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd); | 2210 | struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd); |
2211 | int ret; | ||
2183 | 2212 | ||
2184 | isert_dbg("Cmd: %p RDMA_READ data_length: %u write_data_done: %u\n", | 2213 | isert_dbg("Cmd: %p RDMA_READ data_length: %u write_data_done: %u\n", |
2185 | isert_cmd, cmd->se_cmd.data_length, cmd->write_data_done); | 2214 | isert_cmd, cmd->se_cmd.data_length, cmd->write_data_done); |
2186 | 2215 | ||
2187 | isert_cmd->tx_desc.tx_cqe.done = isert_rdma_read_done; | 2216 | isert_cmd->tx_desc.tx_cqe.done = isert_rdma_read_done; |
2188 | isert_rdma_rw_ctx_post(isert_cmd, conn->context, | 2217 | ret = isert_rdma_rw_ctx_post(isert_cmd, conn->context, |
2189 | &isert_cmd->tx_desc.tx_cqe, NULL); | 2218 | &isert_cmd->tx_desc.tx_cqe, NULL); |
2190 | 2219 | ||
2191 | isert_dbg("Cmd: %p posted RDMA_READ memory for ISER Data WRITE\n", | 2220 | isert_dbg("Cmd: %p posted RDMA_READ memory for ISER Data WRITE rc: %d\n", |
2192 | isert_cmd); | 2221 | isert_cmd, ret); |
2193 | return 0; | 2222 | return ret; |
2194 | } | 2223 | } |
2195 | 2224 | ||
2196 | static int | 2225 | static int |
diff --git a/drivers/infiniband/ulp/isert/ib_isert.h b/drivers/infiniband/ulp/isert/ib_isert.h index c02ada57d7f5..87d994de8c91 100644 --- a/drivers/infiniband/ulp/isert/ib_isert.h +++ b/drivers/infiniband/ulp/isert/ib_isert.h | |||
@@ -60,7 +60,7 @@ | |||
60 | 60 | ||
61 | #define ISER_RX_PAD_SIZE (ISCSI_DEF_MAX_RECV_SEG_LEN + 4096 - \ | 61 | #define ISER_RX_PAD_SIZE (ISCSI_DEF_MAX_RECV_SEG_LEN + 4096 - \ |
62 | (ISER_RX_PAYLOAD_SIZE + sizeof(u64) + sizeof(struct ib_sge) + \ | 62 | (ISER_RX_PAYLOAD_SIZE + sizeof(u64) + sizeof(struct ib_sge) + \ |
63 | sizeof(struct ib_cqe))) | 63 | sizeof(struct ib_cqe) + sizeof(bool))) |
64 | 64 | ||
65 | #define ISCSI_ISER_SG_TABLESIZE 256 | 65 | #define ISCSI_ISER_SG_TABLESIZE 256 |
66 | 66 | ||
@@ -85,6 +85,7 @@ struct iser_rx_desc { | |||
85 | u64 dma_addr; | 85 | u64 dma_addr; |
86 | struct ib_sge rx_sg; | 86 | struct ib_sge rx_sg; |
87 | struct ib_cqe rx_cqe; | 87 | struct ib_cqe rx_cqe; |
88 | bool in_use; | ||
88 | char pad[ISER_RX_PAD_SIZE]; | 89 | char pad[ISER_RX_PAD_SIZE]; |
89 | } __packed; | 90 | } __packed; |
90 | 91 | ||
diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c index 155fcb3b6230..153b1ee13e03 100644 --- a/drivers/input/joystick/xpad.c +++ b/drivers/input/joystick/xpad.c | |||
@@ -202,6 +202,7 @@ static const struct xpad_device { | |||
202 | { 0x1430, 0x8888, "TX6500+ Dance Pad (first generation)", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX }, | 202 | { 0x1430, 0x8888, "TX6500+ Dance Pad (first generation)", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX }, |
203 | { 0x146b, 0x0601, "BigBen Interactive XBOX 360 Controller", 0, XTYPE_XBOX360 }, | 203 | { 0x146b, 0x0601, "BigBen Interactive XBOX 360 Controller", 0, XTYPE_XBOX360 }, |
204 | { 0x1532, 0x0037, "Razer Sabertooth", 0, XTYPE_XBOX360 }, | 204 | { 0x1532, 0x0037, "Razer Sabertooth", 0, XTYPE_XBOX360 }, |
205 | { 0x1532, 0x0a03, "Razer Wildcat", 0, XTYPE_XBOXONE }, | ||
205 | { 0x15e4, 0x3f00, "Power A Mini Pro Elite", 0, XTYPE_XBOX360 }, | 206 | { 0x15e4, 0x3f00, "Power A Mini Pro Elite", 0, XTYPE_XBOX360 }, |
206 | { 0x15e4, 0x3f0a, "Xbox Airflo wired controller", 0, XTYPE_XBOX360 }, | 207 | { 0x15e4, 0x3f0a, "Xbox Airflo wired controller", 0, XTYPE_XBOX360 }, |
207 | { 0x15e4, 0x3f10, "Batarang Xbox 360 controller", 0, XTYPE_XBOX360 }, | 208 | { 0x15e4, 0x3f10, "Batarang Xbox 360 controller", 0, XTYPE_XBOX360 }, |
@@ -326,6 +327,7 @@ static struct usb_device_id xpad_table[] = { | |||
326 | XPAD_XBOX360_VENDOR(0x1430), /* RedOctane X-Box 360 controllers */ | 327 | XPAD_XBOX360_VENDOR(0x1430), /* RedOctane X-Box 360 controllers */ |
327 | XPAD_XBOX360_VENDOR(0x146b), /* BigBen Interactive Controllers */ | 328 | XPAD_XBOX360_VENDOR(0x146b), /* BigBen Interactive Controllers */ |
328 | XPAD_XBOX360_VENDOR(0x1532), /* Razer Sabertooth */ | 329 | XPAD_XBOX360_VENDOR(0x1532), /* Razer Sabertooth */ |
330 | XPAD_XBOXONE_VENDOR(0x1532), /* Razer Wildcat */ | ||
329 | XPAD_XBOX360_VENDOR(0x15e4), /* Numark X-Box 360 controllers */ | 331 | XPAD_XBOX360_VENDOR(0x15e4), /* Numark X-Box 360 controllers */ |
330 | XPAD_XBOX360_VENDOR(0x162e), /* Joytech X-Box 360 controllers */ | 332 | XPAD_XBOX360_VENDOR(0x162e), /* Joytech X-Box 360 controllers */ |
331 | XPAD_XBOX360_VENDOR(0x1689), /* Razer Onza */ | 333 | XPAD_XBOX360_VENDOR(0x1689), /* Razer Onza */ |
diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c index efc8ec342351..e73d968023f7 100644 --- a/drivers/input/mouse/elantech.c +++ b/drivers/input/mouse/elantech.c | |||
@@ -1118,6 +1118,7 @@ static int elantech_get_resolution_v4(struct psmouse *psmouse, | |||
1118 | * Asus UX32VD 0x361f02 00, 15, 0e clickpad | 1118 | * Asus UX32VD 0x361f02 00, 15, 0e clickpad |
1119 | * Avatar AVIU-145A2 0x361f00 ? clickpad | 1119 | * Avatar AVIU-145A2 0x361f00 ? clickpad |
1120 | * Fujitsu LIFEBOOK E544 0x470f00 d0, 12, 09 2 hw buttons | 1120 | * Fujitsu LIFEBOOK E544 0x470f00 d0, 12, 09 2 hw buttons |
1121 | * Fujitsu LIFEBOOK E547 0x470f00 50, 12, 09 2 hw buttons | ||
1121 | * Fujitsu LIFEBOOK E554 0x570f01 40, 14, 0c 2 hw buttons | 1122 | * Fujitsu LIFEBOOK E554 0x570f01 40, 14, 0c 2 hw buttons |
1122 | * Fujitsu T725 0x470f01 05, 12, 09 2 hw buttons | 1123 | * Fujitsu T725 0x470f01 05, 12, 09 2 hw buttons |
1123 | * Fujitsu H730 0x570f00 c0, 14, 0c 3 hw buttons (**) | 1124 | * Fujitsu H730 0x570f00 c0, 14, 0c 3 hw buttons (**) |
@@ -1524,6 +1525,13 @@ static const struct dmi_system_id elantech_dmi_force_crc_enabled[] = { | |||
1524 | }, | 1525 | }, |
1525 | }, | 1526 | }, |
1526 | { | 1527 | { |
1528 | /* Fujitsu LIFEBOOK E547 does not work with crc_enabled == 0 */ | ||
1529 | .matches = { | ||
1530 | DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"), | ||
1531 | DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK E547"), | ||
1532 | }, | ||
1533 | }, | ||
1534 | { | ||
1527 | /* Fujitsu LIFEBOOK E554 does not work with crc_enabled == 0 */ | 1535 | /* Fujitsu LIFEBOOK E554 does not work with crc_enabled == 0 */ |
1528 | .matches = { | 1536 | .matches = { |
1529 | DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"), | 1537 | DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"), |
diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig index 125528f39e92..8162121bb1bc 100644 --- a/drivers/irqchip/Kconfig +++ b/drivers/irqchip/Kconfig | |||
@@ -262,6 +262,7 @@ config IRQ_MXS | |||
262 | 262 | ||
263 | config MVEBU_ODMI | 263 | config MVEBU_ODMI |
264 | bool | 264 | bool |
265 | select GENERIC_MSI_IRQ_DOMAIN | ||
265 | 266 | ||
266 | config MVEBU_PIC | 267 | config MVEBU_PIC |
267 | bool | 268 | bool |
diff --git a/drivers/irqchip/irq-imx-gpcv2.c b/drivers/irqchip/irq-imx-gpcv2.c index 15af9a9753e5..2d203b422129 100644 --- a/drivers/irqchip/irq-imx-gpcv2.c +++ b/drivers/irqchip/irq-imx-gpcv2.c | |||
@@ -230,6 +230,8 @@ static int __init imx_gpcv2_irqchip_init(struct device_node *node, | |||
230 | return -ENOMEM; | 230 | return -ENOMEM; |
231 | } | 231 | } |
232 | 232 | ||
233 | raw_spin_lock_init(&cd->rlock); | ||
234 | |||
233 | cd->gpc_base = of_iomap(node, 0); | 235 | cd->gpc_base = of_iomap(node, 0); |
234 | if (!cd->gpc_base) { | 236 | if (!cd->gpc_base) { |
235 | pr_err("fsl-gpcv2: unable to map gpc registers\n"); | 237 | pr_err("fsl-gpcv2: unable to map gpc registers\n"); |
diff --git a/drivers/irqchip/irq-mips-gic.c b/drivers/irqchip/irq-mips-gic.c index 11d12bccc4e7..cd20df12d63d 100644 --- a/drivers/irqchip/irq-mips-gic.c +++ b/drivers/irqchip/irq-mips-gic.c | |||
@@ -991,8 +991,12 @@ static void __init gic_map_single_int(struct device_node *node, | |||
991 | 991 | ||
992 | static void __init gic_map_interrupts(struct device_node *node) | 992 | static void __init gic_map_interrupts(struct device_node *node) |
993 | { | 993 | { |
994 | gic_map_single_int(node, GIC_LOCAL_INT_WD); | ||
995 | gic_map_single_int(node, GIC_LOCAL_INT_COMPARE); | ||
994 | gic_map_single_int(node, GIC_LOCAL_INT_TIMER); | 996 | gic_map_single_int(node, GIC_LOCAL_INT_TIMER); |
995 | gic_map_single_int(node, GIC_LOCAL_INT_PERFCTR); | 997 | gic_map_single_int(node, GIC_LOCAL_INT_PERFCTR); |
998 | gic_map_single_int(node, GIC_LOCAL_INT_SWINT0); | ||
999 | gic_map_single_int(node, GIC_LOCAL_INT_SWINT1); | ||
996 | gic_map_single_int(node, GIC_LOCAL_INT_FDC); | 1000 | gic_map_single_int(node, GIC_LOCAL_INT_FDC); |
997 | } | 1001 | } |
998 | 1002 | ||
diff --git a/drivers/isdn/capi/kcapi.c b/drivers/isdn/capi/kcapi.c index 1dfd1085a04f..9ca691d6c13b 100644 --- a/drivers/isdn/capi/kcapi.c +++ b/drivers/isdn/capi/kcapi.c | |||
@@ -1032,6 +1032,7 @@ static int old_capi_manufacturer(unsigned int cmd, void __user *data) | |||
1032 | sizeof(avmb1_carddef)))) | 1032 | sizeof(avmb1_carddef)))) |
1033 | return -EFAULT; | 1033 | return -EFAULT; |
1034 | cdef.cardtype = AVM_CARDTYPE_B1; | 1034 | cdef.cardtype = AVM_CARDTYPE_B1; |
1035 | cdef.cardnr = 0; | ||
1035 | } else { | 1036 | } else { |
1036 | if ((retval = copy_from_user(&cdef, data, | 1037 | if ((retval = copy_from_user(&cdef, data, |
1037 | sizeof(avmb1_extcarddef)))) | 1038 | sizeof(avmb1_extcarddef)))) |
diff --git a/drivers/md/dm-cache-metadata.c b/drivers/md/dm-cache-metadata.c index e4c2c1a1e993..6735c8d6a445 100644 --- a/drivers/md/dm-cache-metadata.c +++ b/drivers/md/dm-cache-metadata.c | |||
@@ -932,7 +932,7 @@ static int blocks_are_clean_separate_dirty(struct dm_cache_metadata *cmd, | |||
932 | *result = true; | 932 | *result = true; |
933 | 933 | ||
934 | r = dm_bitset_cursor_begin(&cmd->dirty_info, cmd->dirty_root, | 934 | r = dm_bitset_cursor_begin(&cmd->dirty_info, cmd->dirty_root, |
935 | from_cblock(begin), &cmd->dirty_cursor); | 935 | from_cblock(cmd->cache_blocks), &cmd->dirty_cursor); |
936 | if (r) { | 936 | if (r) { |
937 | DMERR("%s: dm_bitset_cursor_begin for dirty failed", __func__); | 937 | DMERR("%s: dm_bitset_cursor_begin for dirty failed", __func__); |
938 | return r; | 938 | return r; |
@@ -959,14 +959,16 @@ static int blocks_are_clean_separate_dirty(struct dm_cache_metadata *cmd, | |||
959 | return 0; | 959 | return 0; |
960 | } | 960 | } |
961 | 961 | ||
962 | begin = to_cblock(from_cblock(begin) + 1); | ||
963 | if (begin == end) | ||
964 | break; | ||
965 | |||
962 | r = dm_bitset_cursor_next(&cmd->dirty_cursor); | 966 | r = dm_bitset_cursor_next(&cmd->dirty_cursor); |
963 | if (r) { | 967 | if (r) { |
964 | DMERR("%s: dm_bitset_cursor_next for dirty failed", __func__); | 968 | DMERR("%s: dm_bitset_cursor_next for dirty failed", __func__); |
965 | dm_bitset_cursor_end(&cmd->dirty_cursor); | 969 | dm_bitset_cursor_end(&cmd->dirty_cursor); |
966 | return r; | 970 | return r; |
967 | } | 971 | } |
968 | |||
969 | begin = to_cblock(from_cblock(begin) + 1); | ||
970 | } | 972 | } |
971 | 973 | ||
972 | dm_bitset_cursor_end(&cmd->dirty_cursor); | 974 | dm_bitset_cursor_end(&cmd->dirty_cursor); |
diff --git a/drivers/md/dm-raid.c b/drivers/md/dm-raid.c index 468f1380de1d..2dae3e5b851c 100644 --- a/drivers/md/dm-raid.c +++ b/drivers/md/dm-raid.c | |||
@@ -3726,7 +3726,7 @@ static int raid_preresume(struct dm_target *ti) | |||
3726 | return r; | 3726 | return r; |
3727 | 3727 | ||
3728 | /* Resize bitmap to adjust to changed region size (aka MD bitmap chunksize) */ | 3728 | /* Resize bitmap to adjust to changed region size (aka MD bitmap chunksize) */ |
3729 | if (test_bit(RT_FLAG_RS_BITMAP_LOADED, &rs->runtime_flags) && | 3729 | if (test_bit(RT_FLAG_RS_BITMAP_LOADED, &rs->runtime_flags) && mddev->bitmap && |
3730 | mddev->bitmap_info.chunksize != to_bytes(rs->requested_bitmap_chunk_sectors)) { | 3730 | mddev->bitmap_info.chunksize != to_bytes(rs->requested_bitmap_chunk_sectors)) { |
3731 | r = bitmap_resize(mddev->bitmap, mddev->dev_sectors, | 3731 | r = bitmap_resize(mddev->bitmap, mddev->dev_sectors, |
3732 | to_bytes(rs->requested_bitmap_chunk_sectors), 0); | 3732 | to_bytes(rs->requested_bitmap_chunk_sectors), 0); |
diff --git a/drivers/md/dm-verity-fec.c b/drivers/md/dm-verity-fec.c index 0f0eb8a3d922..78f36012eaca 100644 --- a/drivers/md/dm-verity-fec.c +++ b/drivers/md/dm-verity-fec.c | |||
@@ -146,8 +146,6 @@ static int fec_decode_bufs(struct dm_verity *v, struct dm_verity_fec_io *fio, | |||
146 | block = fec_buffer_rs_block(v, fio, n, i); | 146 | block = fec_buffer_rs_block(v, fio, n, i); |
147 | res = fec_decode_rs8(v, fio, block, &par[offset], neras); | 147 | res = fec_decode_rs8(v, fio, block, &par[offset], neras); |
148 | if (res < 0) { | 148 | if (res < 0) { |
149 | dm_bufio_release(buf); | ||
150 | |||
151 | r = res; | 149 | r = res; |
152 | goto error; | 150 | goto error; |
153 | } | 151 | } |
@@ -172,6 +170,8 @@ static int fec_decode_bufs(struct dm_verity *v, struct dm_verity_fec_io *fio, | |||
172 | done: | 170 | done: |
173 | r = corrected; | 171 | r = corrected; |
174 | error: | 172 | error: |
173 | dm_bufio_release(buf); | ||
174 | |||
175 | if (r < 0 && neras) | 175 | if (r < 0 && neras) |
176 | DMERR_LIMIT("%s: FEC %llu: failed to correct: %d", | 176 | DMERR_LIMIT("%s: FEC %llu: failed to correct: %d", |
177 | v->data_dev->name, (unsigned long long)rsb, r); | 177 | v->data_dev->name, (unsigned long long)rsb, r); |
@@ -269,7 +269,7 @@ static int fec_read_bufs(struct dm_verity *v, struct dm_verity_io *io, | |||
269 | &is_zero) == 0) { | 269 | &is_zero) == 0) { |
270 | /* skip known zero blocks entirely */ | 270 | /* skip known zero blocks entirely */ |
271 | if (is_zero) | 271 | if (is_zero) |
272 | continue; | 272 | goto done; |
273 | 273 | ||
274 | /* | 274 | /* |
275 | * skip if we have already found the theoretical | 275 | * skip if we have already found the theoretical |
@@ -439,6 +439,13 @@ int verity_fec_decode(struct dm_verity *v, struct dm_verity_io *io, | |||
439 | if (!verity_fec_is_enabled(v)) | 439 | if (!verity_fec_is_enabled(v)) |
440 | return -EOPNOTSUPP; | 440 | return -EOPNOTSUPP; |
441 | 441 | ||
442 | if (fio->level >= DM_VERITY_FEC_MAX_RECURSION) { | ||
443 | DMWARN_LIMIT("%s: FEC: recursion too deep", v->data_dev->name); | ||
444 | return -EIO; | ||
445 | } | ||
446 | |||
447 | fio->level++; | ||
448 | |||
442 | if (type == DM_VERITY_BLOCK_TYPE_METADATA) | 449 | if (type == DM_VERITY_BLOCK_TYPE_METADATA) |
443 | block += v->data_blocks; | 450 | block += v->data_blocks; |
444 | 451 | ||
@@ -470,7 +477,7 @@ int verity_fec_decode(struct dm_verity *v, struct dm_verity_io *io, | |||
470 | if (r < 0) { | 477 | if (r < 0) { |
471 | r = fec_decode_rsb(v, io, fio, rsb, offset, true); | 478 | r = fec_decode_rsb(v, io, fio, rsb, offset, true); |
472 | if (r < 0) | 479 | if (r < 0) |
473 | return r; | 480 | goto done; |
474 | } | 481 | } |
475 | 482 | ||
476 | if (dest) | 483 | if (dest) |
@@ -480,6 +487,8 @@ int verity_fec_decode(struct dm_verity *v, struct dm_verity_io *io, | |||
480 | r = verity_for_bv_block(v, io, iter, fec_bv_copy); | 487 | r = verity_for_bv_block(v, io, iter, fec_bv_copy); |
481 | } | 488 | } |
482 | 489 | ||
490 | done: | ||
491 | fio->level--; | ||
483 | return r; | 492 | return r; |
484 | } | 493 | } |
485 | 494 | ||
@@ -520,6 +529,7 @@ void verity_fec_init_io(struct dm_verity_io *io) | |||
520 | memset(fio->bufs, 0, sizeof(fio->bufs)); | 529 | memset(fio->bufs, 0, sizeof(fio->bufs)); |
521 | fio->nbufs = 0; | 530 | fio->nbufs = 0; |
522 | fio->output = NULL; | 531 | fio->output = NULL; |
532 | fio->level = 0; | ||
523 | } | 533 | } |
524 | 534 | ||
525 | /* | 535 | /* |
diff --git a/drivers/md/dm-verity-fec.h b/drivers/md/dm-verity-fec.h index 7fa0298b995e..bb31ce87a933 100644 --- a/drivers/md/dm-verity-fec.h +++ b/drivers/md/dm-verity-fec.h | |||
@@ -27,6 +27,9 @@ | |||
27 | #define DM_VERITY_FEC_BUF_MAX \ | 27 | #define DM_VERITY_FEC_BUF_MAX \ |
28 | (1 << (PAGE_SHIFT - DM_VERITY_FEC_BUF_RS_BITS)) | 28 | (1 << (PAGE_SHIFT - DM_VERITY_FEC_BUF_RS_BITS)) |
29 | 29 | ||
30 | /* maximum recursion level for verity_fec_decode */ | ||
31 | #define DM_VERITY_FEC_MAX_RECURSION 4 | ||
32 | |||
30 | #define DM_VERITY_OPT_FEC_DEV "use_fec_from_device" | 33 | #define DM_VERITY_OPT_FEC_DEV "use_fec_from_device" |
31 | #define DM_VERITY_OPT_FEC_BLOCKS "fec_blocks" | 34 | #define DM_VERITY_OPT_FEC_BLOCKS "fec_blocks" |
32 | #define DM_VERITY_OPT_FEC_START "fec_start" | 35 | #define DM_VERITY_OPT_FEC_START "fec_start" |
@@ -58,6 +61,7 @@ struct dm_verity_fec_io { | |||
58 | unsigned nbufs; /* number of buffers allocated */ | 61 | unsigned nbufs; /* number of buffers allocated */ |
59 | u8 *output; /* buffer for corrected output */ | 62 | u8 *output; /* buffer for corrected output */ |
60 | size_t output_pos; | 63 | size_t output_pos; |
64 | unsigned level; /* recursion level */ | ||
61 | }; | 65 | }; |
62 | 66 | ||
63 | #ifdef CONFIG_DM_VERITY_FEC | 67 | #ifdef CONFIG_DM_VERITY_FEC |
diff --git a/drivers/mmc/core/sdio_bus.c b/drivers/mmc/core/sdio_bus.c index e992a7f8a16f..2b32b88949ba 100644 --- a/drivers/mmc/core/sdio_bus.c +++ b/drivers/mmc/core/sdio_bus.c | |||
@@ -267,7 +267,7 @@ static void sdio_release_func(struct device *dev) | |||
267 | sdio_free_func_cis(func); | 267 | sdio_free_func_cis(func); |
268 | 268 | ||
269 | kfree(func->info); | 269 | kfree(func->info); |
270 | 270 | kfree(func->tmpbuf); | |
271 | kfree(func); | 271 | kfree(func); |
272 | } | 272 | } |
273 | 273 | ||
@@ -282,6 +282,16 @@ struct sdio_func *sdio_alloc_func(struct mmc_card *card) | |||
282 | if (!func) | 282 | if (!func) |
283 | return ERR_PTR(-ENOMEM); | 283 | return ERR_PTR(-ENOMEM); |
284 | 284 | ||
285 | /* | ||
286 | * allocate buffer separately to make sure it's properly aligned for | ||
287 | * DMA usage (incl. 64 bit DMA) | ||
288 | */ | ||
289 | func->tmpbuf = kmalloc(4, GFP_KERNEL); | ||
290 | if (!func->tmpbuf) { | ||
291 | kfree(func); | ||
292 | return ERR_PTR(-ENOMEM); | ||
293 | } | ||
294 | |||
285 | func->card = card; | 295 | func->card = card; |
286 | 296 | ||
287 | device_initialize(&func->dev); | 297 | device_initialize(&func->dev); |
diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c index a9ac0b457313..8718432751c5 100644 --- a/drivers/mmc/host/dw_mmc.c +++ b/drivers/mmc/host/dw_mmc.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <linux/ioport.h> | 22 | #include <linux/ioport.h> |
23 | #include <linux/module.h> | 23 | #include <linux/module.h> |
24 | #include <linux/platform_device.h> | 24 | #include <linux/platform_device.h> |
25 | #include <linux/pm_runtime.h> | ||
25 | #include <linux/seq_file.h> | 26 | #include <linux/seq_file.h> |
26 | #include <linux/slab.h> | 27 | #include <linux/slab.h> |
27 | #include <linux/stat.h> | 28 | #include <linux/stat.h> |
@@ -1621,10 +1622,16 @@ static void dw_mci_init_card(struct mmc_host *mmc, struct mmc_card *card) | |||
1621 | 1622 | ||
1622 | if (card->type == MMC_TYPE_SDIO || | 1623 | if (card->type == MMC_TYPE_SDIO || |
1623 | card->type == MMC_TYPE_SD_COMBO) { | 1624 | card->type == MMC_TYPE_SD_COMBO) { |
1624 | set_bit(DW_MMC_CARD_NO_LOW_PWR, &slot->flags); | 1625 | if (!test_bit(DW_MMC_CARD_NO_LOW_PWR, &slot->flags)) { |
1626 | pm_runtime_get_noresume(mmc->parent); | ||
1627 | set_bit(DW_MMC_CARD_NO_LOW_PWR, &slot->flags); | ||
1628 | } | ||
1625 | clk_en_a = clk_en_a_old & ~clken_low_pwr; | 1629 | clk_en_a = clk_en_a_old & ~clken_low_pwr; |
1626 | } else { | 1630 | } else { |
1627 | clear_bit(DW_MMC_CARD_NO_LOW_PWR, &slot->flags); | 1631 | if (test_bit(DW_MMC_CARD_NO_LOW_PWR, &slot->flags)) { |
1632 | pm_runtime_put_noidle(mmc->parent); | ||
1633 | clear_bit(DW_MMC_CARD_NO_LOW_PWR, &slot->flags); | ||
1634 | } | ||
1628 | clk_en_a = clk_en_a_old | clken_low_pwr; | 1635 | clk_en_a = clk_en_a_old | clken_low_pwr; |
1629 | } | 1636 | } |
1630 | 1637 | ||
diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c index 7123ef96ed18..445fc47dc3e7 100644 --- a/drivers/mmc/host/sdhci-esdhc-imx.c +++ b/drivers/mmc/host/sdhci-esdhc-imx.c | |||
@@ -830,6 +830,7 @@ static int esdhc_change_pinstate(struct sdhci_host *host, | |||
830 | 830 | ||
831 | switch (uhs) { | 831 | switch (uhs) { |
832 | case MMC_TIMING_UHS_SDR50: | 832 | case MMC_TIMING_UHS_SDR50: |
833 | case MMC_TIMING_UHS_DDR50: | ||
833 | pinctrl = imx_data->pins_100mhz; | 834 | pinctrl = imx_data->pins_100mhz; |
834 | break; | 835 | break; |
835 | case MMC_TIMING_UHS_SDR104: | 836 | case MMC_TIMING_UHS_SDR104: |
diff --git a/drivers/mmc/host/sdhci-of-at91.c b/drivers/mmc/host/sdhci-of-at91.c index 7fd964256faa..d5430ed02a67 100644 --- a/drivers/mmc/host/sdhci-of-at91.c +++ b/drivers/mmc/host/sdhci-of-at91.c | |||
@@ -29,6 +29,8 @@ | |||
29 | 29 | ||
30 | #include "sdhci-pltfm.h" | 30 | #include "sdhci-pltfm.h" |
31 | 31 | ||
32 | #define SDMMC_MC1R 0x204 | ||
33 | #define SDMMC_MC1R_DDR BIT(3) | ||
32 | #define SDMMC_CACR 0x230 | 34 | #define SDMMC_CACR 0x230 |
33 | #define SDMMC_CACR_CAPWREN BIT(0) | 35 | #define SDMMC_CACR_CAPWREN BIT(0) |
34 | #define SDMMC_CACR_KEY (0x46 << 8) | 36 | #define SDMMC_CACR_KEY (0x46 << 8) |
@@ -103,11 +105,18 @@ static void sdhci_at91_set_power(struct sdhci_host *host, unsigned char mode, | |||
103 | sdhci_set_power_noreg(host, mode, vdd); | 105 | sdhci_set_power_noreg(host, mode, vdd); |
104 | } | 106 | } |
105 | 107 | ||
108 | void sdhci_at91_set_uhs_signaling(struct sdhci_host *host, unsigned int timing) | ||
109 | { | ||
110 | if (timing == MMC_TIMING_MMC_DDR52) | ||
111 | sdhci_writeb(host, SDMMC_MC1R_DDR, SDMMC_MC1R); | ||
112 | sdhci_set_uhs_signaling(host, timing); | ||
113 | } | ||
114 | |||
106 | static const struct sdhci_ops sdhci_at91_sama5d2_ops = { | 115 | static const struct sdhci_ops sdhci_at91_sama5d2_ops = { |
107 | .set_clock = sdhci_at91_set_clock, | 116 | .set_clock = sdhci_at91_set_clock, |
108 | .set_bus_width = sdhci_set_bus_width, | 117 | .set_bus_width = sdhci_set_bus_width, |
109 | .reset = sdhci_reset, | 118 | .reset = sdhci_reset, |
110 | .set_uhs_signaling = sdhci_set_uhs_signaling, | 119 | .set_uhs_signaling = sdhci_at91_set_uhs_signaling, |
111 | .set_power = sdhci_at91_set_power, | 120 | .set_power = sdhci_at91_set_power, |
112 | }; | 121 | }; |
113 | 122 | ||
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 9c1a099afbbe..63bc33a54d0d 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c | |||
@@ -1830,6 +1830,9 @@ static void sdhci_enable_sdio_irq(struct mmc_host *mmc, int enable) | |||
1830 | struct sdhci_host *host = mmc_priv(mmc); | 1830 | struct sdhci_host *host = mmc_priv(mmc); |
1831 | unsigned long flags; | 1831 | unsigned long flags; |
1832 | 1832 | ||
1833 | if (enable) | ||
1834 | pm_runtime_get_noresume(host->mmc->parent); | ||
1835 | |||
1833 | spin_lock_irqsave(&host->lock, flags); | 1836 | spin_lock_irqsave(&host->lock, flags); |
1834 | if (enable) | 1837 | if (enable) |
1835 | host->flags |= SDHCI_SDIO_IRQ_ENABLED; | 1838 | host->flags |= SDHCI_SDIO_IRQ_ENABLED; |
@@ -1838,6 +1841,9 @@ static void sdhci_enable_sdio_irq(struct mmc_host *mmc, int enable) | |||
1838 | 1841 | ||
1839 | sdhci_enable_sdio_irq_nolock(host, enable); | 1842 | sdhci_enable_sdio_irq_nolock(host, enable); |
1840 | spin_unlock_irqrestore(&host->lock, flags); | 1843 | spin_unlock_irqrestore(&host->lock, flags); |
1844 | |||
1845 | if (!enable) | ||
1846 | pm_runtime_put_noidle(host->mmc->parent); | ||
1841 | } | 1847 | } |
1842 | 1848 | ||
1843 | static int sdhci_start_signal_voltage_switch(struct mmc_host *mmc, | 1849 | static int sdhci_start_signal_voltage_switch(struct mmc_host *mmc, |
diff --git a/drivers/mtd/ubi/upd.c b/drivers/mtd/ubi/upd.c index 0134ba32a057..39712560b4c1 100644 --- a/drivers/mtd/ubi/upd.c +++ b/drivers/mtd/ubi/upd.c | |||
@@ -148,11 +148,11 @@ int ubi_start_update(struct ubi_device *ubi, struct ubi_volume *vol, | |||
148 | return err; | 148 | return err; |
149 | } | 149 | } |
150 | 150 | ||
151 | if (bytes == 0) { | 151 | err = ubi_wl_flush(ubi, UBI_ALL, UBI_ALL); |
152 | err = ubi_wl_flush(ubi, UBI_ALL, UBI_ALL); | 152 | if (err) |
153 | if (err) | 153 | return err; |
154 | return err; | ||
155 | 154 | ||
155 | if (bytes == 0) { | ||
156 | err = clear_update_marker(ubi, vol, 0); | 156 | err = clear_update_marker(ubi, vol, 0); |
157 | if (err) | 157 | if (err) |
158 | return err; | 158 | return err; |
diff --git a/drivers/net/can/ifi_canfd/ifi_canfd.c b/drivers/net/can/ifi_canfd/ifi_canfd.c index 138f5ae75c0b..4d1fe8d95042 100644 --- a/drivers/net/can/ifi_canfd/ifi_canfd.c +++ b/drivers/net/can/ifi_canfd/ifi_canfd.c | |||
@@ -557,7 +557,7 @@ static int ifi_canfd_poll(struct napi_struct *napi, int quota) | |||
557 | int work_done = 0; | 557 | int work_done = 0; |
558 | 558 | ||
559 | u32 stcmd = readl(priv->base + IFI_CANFD_STCMD); | 559 | u32 stcmd = readl(priv->base + IFI_CANFD_STCMD); |
560 | u32 rxstcmd = readl(priv->base + IFI_CANFD_STCMD); | 560 | u32 rxstcmd = readl(priv->base + IFI_CANFD_RXSTCMD); |
561 | u32 errctr = readl(priv->base + IFI_CANFD_ERROR_CTR); | 561 | u32 errctr = readl(priv->base + IFI_CANFD_ERROR_CTR); |
562 | 562 | ||
563 | /* Handle bus state changes */ | 563 | /* Handle bus state changes */ |
diff --git a/drivers/net/can/rcar/rcar_can.c b/drivers/net/can/rcar/rcar_can.c index caed4e6960f8..11662f479e76 100644 --- a/drivers/net/can/rcar/rcar_can.c +++ b/drivers/net/can/rcar/rcar_can.c | |||
@@ -826,8 +826,7 @@ static int rcar_can_probe(struct platform_device *pdev) | |||
826 | 826 | ||
827 | devm_can_led_init(ndev); | 827 | devm_can_led_init(ndev); |
828 | 828 | ||
829 | dev_info(&pdev->dev, "device registered (regs @ %p, IRQ%d)\n", | 829 | dev_info(&pdev->dev, "device registered (IRQ%d)\n", ndev->irq); |
830 | priv->regs, ndev->irq); | ||
831 | 830 | ||
832 | return 0; | 831 | return 0; |
833 | fail_candev: | 832 | fail_candev: |
diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_main.c b/drivers/net/ethernet/aquantia/atlantic/aq_main.c index d05fbfdce5e5..5d6c40d86775 100644 --- a/drivers/net/ethernet/aquantia/atlantic/aq_main.c +++ b/drivers/net/ethernet/aquantia/atlantic/aq_main.c | |||
@@ -100,11 +100,6 @@ static int aq_ndev_change_mtu(struct net_device *ndev, int new_mtu) | |||
100 | goto err_exit; | 100 | goto err_exit; |
101 | ndev->mtu = new_mtu; | 101 | ndev->mtu = new_mtu; |
102 | 102 | ||
103 | if (netif_running(ndev)) { | ||
104 | aq_ndev_close(ndev); | ||
105 | aq_ndev_open(ndev); | ||
106 | } | ||
107 | |||
108 | err_exit: | 103 | err_exit: |
109 | return err; | 104 | return err; |
110 | } | 105 | } |
diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_nic.c b/drivers/net/ethernet/aquantia/atlantic/aq_nic.c index ee78444bfb88..cdb02991f249 100644 --- a/drivers/net/ethernet/aquantia/atlantic/aq_nic.c +++ b/drivers/net/ethernet/aquantia/atlantic/aq_nic.c | |||
@@ -487,6 +487,9 @@ static unsigned int aq_nic_map_skb(struct aq_nic_s *self, | |||
487 | dx_buff->mss = skb_shinfo(skb)->gso_size; | 487 | dx_buff->mss = skb_shinfo(skb)->gso_size; |
488 | dx_buff->is_txc = 1U; | 488 | dx_buff->is_txc = 1U; |
489 | 489 | ||
490 | dx_buff->is_ipv6 = | ||
491 | (ip_hdr(skb)->version == 6) ? 1U : 0U; | ||
492 | |||
490 | dx = aq_ring_next_dx(ring, dx); | 493 | dx = aq_ring_next_dx(ring, dx); |
491 | dx_buff = &ring->buff_ring[dx]; | 494 | dx_buff = &ring->buff_ring[dx]; |
492 | ++ret; | 495 | ++ret; |
@@ -510,10 +513,22 @@ static unsigned int aq_nic_map_skb(struct aq_nic_s *self, | |||
510 | if (skb->ip_summed == CHECKSUM_PARTIAL) { | 513 | if (skb->ip_summed == CHECKSUM_PARTIAL) { |
511 | dx_buff->is_ip_cso = (htons(ETH_P_IP) == skb->protocol) ? | 514 | dx_buff->is_ip_cso = (htons(ETH_P_IP) == skb->protocol) ? |
512 | 1U : 0U; | 515 | 1U : 0U; |
513 | dx_buff->is_tcp_cso = | 516 | |
514 | (ip_hdr(skb)->protocol == IPPROTO_TCP) ? 1U : 0U; | 517 | if (ip_hdr(skb)->version == 4) { |
515 | dx_buff->is_udp_cso = | 518 | dx_buff->is_tcp_cso = |
516 | (ip_hdr(skb)->protocol == IPPROTO_UDP) ? 1U : 0U; | 519 | (ip_hdr(skb)->protocol == IPPROTO_TCP) ? |
520 | 1U : 0U; | ||
521 | dx_buff->is_udp_cso = | ||
522 | (ip_hdr(skb)->protocol == IPPROTO_UDP) ? | ||
523 | 1U : 0U; | ||
524 | } else if (ip_hdr(skb)->version == 6) { | ||
525 | dx_buff->is_tcp_cso = | ||
526 | (ipv6_hdr(skb)->nexthdr == NEXTHDR_TCP) ? | ||
527 | 1U : 0U; | ||
528 | dx_buff->is_udp_cso = | ||
529 | (ipv6_hdr(skb)->nexthdr == NEXTHDR_UDP) ? | ||
530 | 1U : 0U; | ||
531 | } | ||
517 | } | 532 | } |
518 | 533 | ||
519 | for (; nr_frags--; ++frag_count) { | 534 | for (; nr_frags--; ++frag_count) { |
diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_ring.c b/drivers/net/ethernet/aquantia/atlantic/aq_ring.c index 0358e6072d45..3a8a4aa13687 100644 --- a/drivers/net/ethernet/aquantia/atlantic/aq_ring.c +++ b/drivers/net/ethernet/aquantia/atlantic/aq_ring.c | |||
@@ -101,6 +101,7 @@ int aq_ring_init(struct aq_ring_s *self) | |||
101 | self->hw_head = 0; | 101 | self->hw_head = 0; |
102 | self->sw_head = 0; | 102 | self->sw_head = 0; |
103 | self->sw_tail = 0; | 103 | self->sw_tail = 0; |
104 | spin_lock_init(&self->header.lock); | ||
104 | return 0; | 105 | return 0; |
105 | } | 106 | } |
106 | 107 | ||
diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_ring.h b/drivers/net/ethernet/aquantia/atlantic/aq_ring.h index 257254645068..eecd6d1c4d73 100644 --- a/drivers/net/ethernet/aquantia/atlantic/aq_ring.h +++ b/drivers/net/ethernet/aquantia/atlantic/aq_ring.h | |||
@@ -58,7 +58,8 @@ struct __packed aq_ring_buff_s { | |||
58 | u8 len_l2; | 58 | u8 len_l2; |
59 | u8 len_l3; | 59 | u8 len_l3; |
60 | u8 len_l4; | 60 | u8 len_l4; |
61 | u8 rsvd2; | 61 | u8 is_ipv6:1; |
62 | u8 rsvd2:7; | ||
62 | u32 len_pkt; | 63 | u32 len_pkt; |
63 | }; | 64 | }; |
64 | }; | 65 | }; |
diff --git a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_a0.c b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_a0.c index a2b746a2dd50..4ee15ff06a44 100644 --- a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_a0.c +++ b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_a0.c | |||
@@ -433,6 +433,9 @@ static int hw_atl_a0_hw_ring_tx_xmit(struct aq_hw_s *self, | |||
433 | buff->len_l3 + | 433 | buff->len_l3 + |
434 | buff->len_l2); | 434 | buff->len_l2); |
435 | is_gso = true; | 435 | is_gso = true; |
436 | |||
437 | if (buff->is_ipv6) | ||
438 | txd->ctl |= HW_ATL_A0_TXD_CTL_CMD_IPV6; | ||
436 | } else { | 439 | } else { |
437 | buff_pa_len = buff->len; | 440 | buff_pa_len = buff->len; |
438 | 441 | ||
@@ -458,6 +461,7 @@ static int hw_atl_a0_hw_ring_tx_xmit(struct aq_hw_s *self, | |||
458 | if (unlikely(buff->is_eop)) { | 461 | if (unlikely(buff->is_eop)) { |
459 | txd->ctl |= HW_ATL_A0_TXD_CTL_EOP; | 462 | txd->ctl |= HW_ATL_A0_TXD_CTL_EOP; |
460 | txd->ctl |= HW_ATL_A0_TXD_CTL_CMD_WB; | 463 | txd->ctl |= HW_ATL_A0_TXD_CTL_CMD_WB; |
464 | is_gso = false; | ||
461 | } | 465 | } |
462 | } | 466 | } |
463 | 467 | ||
diff --git a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c index cab2931dab9a..42150708191d 100644 --- a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c +++ b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c | |||
@@ -471,6 +471,9 @@ static int hw_atl_b0_hw_ring_tx_xmit(struct aq_hw_s *self, | |||
471 | buff->len_l3 + | 471 | buff->len_l3 + |
472 | buff->len_l2); | 472 | buff->len_l2); |
473 | is_gso = true; | 473 | is_gso = true; |
474 | |||
475 | if (buff->is_ipv6) | ||
476 | txd->ctl |= HW_ATL_B0_TXD_CTL_CMD_IPV6; | ||
474 | } else { | 477 | } else { |
475 | buff_pa_len = buff->len; | 478 | buff_pa_len = buff->len; |
476 | 479 | ||
@@ -496,6 +499,7 @@ static int hw_atl_b0_hw_ring_tx_xmit(struct aq_hw_s *self, | |||
496 | if (unlikely(buff->is_eop)) { | 499 | if (unlikely(buff->is_eop)) { |
497 | txd->ctl |= HW_ATL_B0_TXD_CTL_EOP; | 500 | txd->ctl |= HW_ATL_B0_TXD_CTL_EOP; |
498 | txd->ctl |= HW_ATL_B0_TXD_CTL_CMD_WB; | 501 | txd->ctl |= HW_ATL_B0_TXD_CTL_CMD_WB; |
502 | is_gso = false; | ||
499 | } | 503 | } |
500 | } | 504 | } |
501 | 505 | ||
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h index 0a23034bbe3f..352beff796ae 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h | |||
@@ -2277,7 +2277,7 @@ void bnx2x_igu_clear_sb_gen(struct bnx2x *bp, u8 func, u8 idu_sb_id, | |||
2277 | GENERAL_ATTEN_OFFSET(LATCHED_ATTN_RBCP) | \ | 2277 | GENERAL_ATTEN_OFFSET(LATCHED_ATTN_RBCP) | \ |
2278 | GENERAL_ATTEN_OFFSET(LATCHED_ATTN_RSVD_GRC)) | 2278 | GENERAL_ATTEN_OFFSET(LATCHED_ATTN_RSVD_GRC)) |
2279 | 2279 | ||
2280 | #define HW_INTERRUT_ASSERT_SET_0 \ | 2280 | #define HW_INTERRUPT_ASSERT_SET_0 \ |
2281 | (AEU_INPUTS_ATTN_BITS_TSDM_HW_INTERRUPT | \ | 2281 | (AEU_INPUTS_ATTN_BITS_TSDM_HW_INTERRUPT | \ |
2282 | AEU_INPUTS_ATTN_BITS_TCM_HW_INTERRUPT | \ | 2282 | AEU_INPUTS_ATTN_BITS_TCM_HW_INTERRUPT | \ |
2283 | AEU_INPUTS_ATTN_BITS_TSEMI_HW_INTERRUPT | \ | 2283 | AEU_INPUTS_ATTN_BITS_TSEMI_HW_INTERRUPT | \ |
@@ -2290,7 +2290,7 @@ void bnx2x_igu_clear_sb_gen(struct bnx2x *bp, u8 func, u8 idu_sb_id, | |||
2290 | AEU_INPUTS_ATTN_BITS_TSEMI_PARITY_ERROR |\ | 2290 | AEU_INPUTS_ATTN_BITS_TSEMI_PARITY_ERROR |\ |
2291 | AEU_INPUTS_ATTN_BITS_TCM_PARITY_ERROR |\ | 2291 | AEU_INPUTS_ATTN_BITS_TCM_PARITY_ERROR |\ |
2292 | AEU_INPUTS_ATTN_BITS_PBCLIENT_PARITY_ERROR) | 2292 | AEU_INPUTS_ATTN_BITS_PBCLIENT_PARITY_ERROR) |
2293 | #define HW_INTERRUT_ASSERT_SET_1 \ | 2293 | #define HW_INTERRUPT_ASSERT_SET_1 \ |
2294 | (AEU_INPUTS_ATTN_BITS_QM_HW_INTERRUPT | \ | 2294 | (AEU_INPUTS_ATTN_BITS_QM_HW_INTERRUPT | \ |
2295 | AEU_INPUTS_ATTN_BITS_TIMERS_HW_INTERRUPT | \ | 2295 | AEU_INPUTS_ATTN_BITS_TIMERS_HW_INTERRUPT | \ |
2296 | AEU_INPUTS_ATTN_BITS_XSDM_HW_INTERRUPT | \ | 2296 | AEU_INPUTS_ATTN_BITS_XSDM_HW_INTERRUPT | \ |
@@ -2318,7 +2318,7 @@ void bnx2x_igu_clear_sb_gen(struct bnx2x *bp, u8 func, u8 idu_sb_id, | |||
2318 | AEU_INPUTS_ATTN_BITS_UPB_PARITY_ERROR | \ | 2318 | AEU_INPUTS_ATTN_BITS_UPB_PARITY_ERROR | \ |
2319 | AEU_INPUTS_ATTN_BITS_CSDM_PARITY_ERROR |\ | 2319 | AEU_INPUTS_ATTN_BITS_CSDM_PARITY_ERROR |\ |
2320 | AEU_INPUTS_ATTN_BITS_CCM_PARITY_ERROR) | 2320 | AEU_INPUTS_ATTN_BITS_CCM_PARITY_ERROR) |
2321 | #define HW_INTERRUT_ASSERT_SET_2 \ | 2321 | #define HW_INTERRUPT_ASSERT_SET_2 \ |
2322 | (AEU_INPUTS_ATTN_BITS_CSEMI_HW_INTERRUPT | \ | 2322 | (AEU_INPUTS_ATTN_BITS_CSEMI_HW_INTERRUPT | \ |
2323 | AEU_INPUTS_ATTN_BITS_CDU_HW_INTERRUPT | \ | 2323 | AEU_INPUTS_ATTN_BITS_CDU_HW_INTERRUPT | \ |
2324 | AEU_INPUTS_ATTN_BITS_DMAE_HW_INTERRUPT | \ | 2324 | AEU_INPUTS_ATTN_BITS_DMAE_HW_INTERRUPT | \ |
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c index ac76fc251d26..a851f95c307a 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | |||
@@ -4166,14 +4166,14 @@ static void bnx2x_attn_int_deasserted0(struct bnx2x *bp, u32 attn) | |||
4166 | bnx2x_release_phy_lock(bp); | 4166 | bnx2x_release_phy_lock(bp); |
4167 | } | 4167 | } |
4168 | 4168 | ||
4169 | if (attn & HW_INTERRUT_ASSERT_SET_0) { | 4169 | if (attn & HW_INTERRUPT_ASSERT_SET_0) { |
4170 | 4170 | ||
4171 | val = REG_RD(bp, reg_offset); | 4171 | val = REG_RD(bp, reg_offset); |
4172 | val &= ~(attn & HW_INTERRUT_ASSERT_SET_0); | 4172 | val &= ~(attn & HW_INTERRUPT_ASSERT_SET_0); |
4173 | REG_WR(bp, reg_offset, val); | 4173 | REG_WR(bp, reg_offset, val); |
4174 | 4174 | ||
4175 | BNX2X_ERR("FATAL HW block attention set0 0x%x\n", | 4175 | BNX2X_ERR("FATAL HW block attention set0 0x%x\n", |
4176 | (u32)(attn & HW_INTERRUT_ASSERT_SET_0)); | 4176 | (u32)(attn & HW_INTERRUPT_ASSERT_SET_0)); |
4177 | bnx2x_panic(); | 4177 | bnx2x_panic(); |
4178 | } | 4178 | } |
4179 | } | 4179 | } |
@@ -4191,7 +4191,7 @@ static void bnx2x_attn_int_deasserted1(struct bnx2x *bp, u32 attn) | |||
4191 | BNX2X_ERR("FATAL error from DORQ\n"); | 4191 | BNX2X_ERR("FATAL error from DORQ\n"); |
4192 | } | 4192 | } |
4193 | 4193 | ||
4194 | if (attn & HW_INTERRUT_ASSERT_SET_1) { | 4194 | if (attn & HW_INTERRUPT_ASSERT_SET_1) { |
4195 | 4195 | ||
4196 | int port = BP_PORT(bp); | 4196 | int port = BP_PORT(bp); |
4197 | int reg_offset; | 4197 | int reg_offset; |
@@ -4200,11 +4200,11 @@ static void bnx2x_attn_int_deasserted1(struct bnx2x *bp, u32 attn) | |||
4200 | MISC_REG_AEU_ENABLE1_FUNC_0_OUT_1); | 4200 | MISC_REG_AEU_ENABLE1_FUNC_0_OUT_1); |
4201 | 4201 | ||
4202 | val = REG_RD(bp, reg_offset); | 4202 | val = REG_RD(bp, reg_offset); |
4203 | val &= ~(attn & HW_INTERRUT_ASSERT_SET_1); | 4203 | val &= ~(attn & HW_INTERRUPT_ASSERT_SET_1); |
4204 | REG_WR(bp, reg_offset, val); | 4204 | REG_WR(bp, reg_offset, val); |
4205 | 4205 | ||
4206 | BNX2X_ERR("FATAL HW block attention set1 0x%x\n", | 4206 | BNX2X_ERR("FATAL HW block attention set1 0x%x\n", |
4207 | (u32)(attn & HW_INTERRUT_ASSERT_SET_1)); | 4207 | (u32)(attn & HW_INTERRUPT_ASSERT_SET_1)); |
4208 | bnx2x_panic(); | 4208 | bnx2x_panic(); |
4209 | } | 4209 | } |
4210 | } | 4210 | } |
@@ -4235,7 +4235,7 @@ static void bnx2x_attn_int_deasserted2(struct bnx2x *bp, u32 attn) | |||
4235 | } | 4235 | } |
4236 | } | 4236 | } |
4237 | 4237 | ||
4238 | if (attn & HW_INTERRUT_ASSERT_SET_2) { | 4238 | if (attn & HW_INTERRUPT_ASSERT_SET_2) { |
4239 | 4239 | ||
4240 | int port = BP_PORT(bp); | 4240 | int port = BP_PORT(bp); |
4241 | int reg_offset; | 4241 | int reg_offset; |
@@ -4244,11 +4244,11 @@ static void bnx2x_attn_int_deasserted2(struct bnx2x *bp, u32 attn) | |||
4244 | MISC_REG_AEU_ENABLE1_FUNC_0_OUT_2); | 4244 | MISC_REG_AEU_ENABLE1_FUNC_0_OUT_2); |
4245 | 4245 | ||
4246 | val = REG_RD(bp, reg_offset); | 4246 | val = REG_RD(bp, reg_offset); |
4247 | val &= ~(attn & HW_INTERRUT_ASSERT_SET_2); | 4247 | val &= ~(attn & HW_INTERRUPT_ASSERT_SET_2); |
4248 | REG_WR(bp, reg_offset, val); | 4248 | REG_WR(bp, reg_offset, val); |
4249 | 4249 | ||
4250 | BNX2X_ERR("FATAL HW block attention set2 0x%x\n", | 4250 | BNX2X_ERR("FATAL HW block attention set2 0x%x\n", |
4251 | (u32)(attn & HW_INTERRUT_ASSERT_SET_2)); | 4251 | (u32)(attn & HW_INTERRUPT_ASSERT_SET_2)); |
4252 | bnx2x_panic(); | 4252 | bnx2x_panic(); |
4253 | } | 4253 | } |
4254 | } | 4254 | } |
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 32de4589d16a..1f1e54ba0ecb 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c | |||
@@ -1983,20 +1983,25 @@ static void bnxt_free_rx_skbs(struct bnxt *bp) | |||
1983 | 1983 | ||
1984 | for (j = 0; j < max_idx; j++) { | 1984 | for (j = 0; j < max_idx; j++) { |
1985 | struct bnxt_sw_rx_bd *rx_buf = &rxr->rx_buf_ring[j]; | 1985 | struct bnxt_sw_rx_bd *rx_buf = &rxr->rx_buf_ring[j]; |
1986 | dma_addr_t mapping = rx_buf->mapping; | ||
1986 | void *data = rx_buf->data; | 1987 | void *data = rx_buf->data; |
1987 | 1988 | ||
1988 | if (!data) | 1989 | if (!data) |
1989 | continue; | 1990 | continue; |
1990 | 1991 | ||
1991 | dma_unmap_single(&pdev->dev, rx_buf->mapping, | ||
1992 | bp->rx_buf_use_size, bp->rx_dir); | ||
1993 | |||
1994 | rx_buf->data = NULL; | 1992 | rx_buf->data = NULL; |
1995 | 1993 | ||
1996 | if (BNXT_RX_PAGE_MODE(bp)) | 1994 | if (BNXT_RX_PAGE_MODE(bp)) { |
1995 | mapping -= bp->rx_dma_offset; | ||
1996 | dma_unmap_page(&pdev->dev, mapping, | ||
1997 | PAGE_SIZE, bp->rx_dir); | ||
1997 | __free_page(data); | 1998 | __free_page(data); |
1998 | else | 1999 | } else { |
2000 | dma_unmap_single(&pdev->dev, mapping, | ||
2001 | bp->rx_buf_use_size, | ||
2002 | bp->rx_dir); | ||
1999 | kfree(data); | 2003 | kfree(data); |
2004 | } | ||
2000 | } | 2005 | } |
2001 | 2006 | ||
2002 | for (j = 0; j < max_agg_idx; j++) { | 2007 | for (j = 0; j < max_agg_idx; j++) { |
@@ -2455,6 +2460,18 @@ static int bnxt_init_one_rx_ring(struct bnxt *bp, int ring_nr) | |||
2455 | return 0; | 2460 | return 0; |
2456 | } | 2461 | } |
2457 | 2462 | ||
2463 | static void bnxt_init_cp_rings(struct bnxt *bp) | ||
2464 | { | ||
2465 | int i; | ||
2466 | |||
2467 | for (i = 0; i < bp->cp_nr_rings; i++) { | ||
2468 | struct bnxt_cp_ring_info *cpr = &bp->bnapi[i]->cp_ring; | ||
2469 | struct bnxt_ring_struct *ring = &cpr->cp_ring_struct; | ||
2470 | |||
2471 | ring->fw_ring_id = INVALID_HW_RING_ID; | ||
2472 | } | ||
2473 | } | ||
2474 | |||
2458 | static int bnxt_init_rx_rings(struct bnxt *bp) | 2475 | static int bnxt_init_rx_rings(struct bnxt *bp) |
2459 | { | 2476 | { |
2460 | int i, rc = 0; | 2477 | int i, rc = 0; |
@@ -4732,7 +4749,7 @@ static int bnxt_set_tpa(struct bnxt *bp, bool set_tpa) | |||
4732 | rc = bnxt_hwrm_vnic_set_tpa(bp, i, tpa_flags); | 4749 | rc = bnxt_hwrm_vnic_set_tpa(bp, i, tpa_flags); |
4733 | if (rc) { | 4750 | if (rc) { |
4734 | netdev_err(bp->dev, "hwrm vnic set tpa failure rc for vnic %d: %x\n", | 4751 | netdev_err(bp->dev, "hwrm vnic set tpa failure rc for vnic %d: %x\n", |
4735 | rc, i); | 4752 | i, rc); |
4736 | return rc; | 4753 | return rc; |
4737 | } | 4754 | } |
4738 | } | 4755 | } |
@@ -5006,6 +5023,7 @@ static int bnxt_shutdown_nic(struct bnxt *bp, bool irq_re_init) | |||
5006 | 5023 | ||
5007 | static int bnxt_init_nic(struct bnxt *bp, bool irq_re_init) | 5024 | static int bnxt_init_nic(struct bnxt *bp, bool irq_re_init) |
5008 | { | 5025 | { |
5026 | bnxt_init_cp_rings(bp); | ||
5009 | bnxt_init_rx_rings(bp); | 5027 | bnxt_init_rx_rings(bp); |
5010 | bnxt_init_tx_rings(bp); | 5028 | bnxt_init_tx_rings(bp); |
5011 | bnxt_init_ring_grps(bp, irq_re_init); | 5029 | bnxt_init_ring_grps(bp, irq_re_init); |
diff --git a/drivers/net/ethernet/brocade/bna/bfa_ioc.c b/drivers/net/ethernet/brocade/bna/bfa_ioc.c index 9e59663a6ead..0f6811860ad5 100644 --- a/drivers/net/ethernet/brocade/bna/bfa_ioc.c +++ b/drivers/net/ethernet/brocade/bna/bfa_ioc.c | |||
@@ -1930,13 +1930,13 @@ static void | |||
1930 | bfa_ioc_send_enable(struct bfa_ioc *ioc) | 1930 | bfa_ioc_send_enable(struct bfa_ioc *ioc) |
1931 | { | 1931 | { |
1932 | struct bfi_ioc_ctrl_req enable_req; | 1932 | struct bfi_ioc_ctrl_req enable_req; |
1933 | struct timeval tv; | ||
1934 | 1933 | ||
1935 | bfi_h2i_set(enable_req.mh, BFI_MC_IOC, BFI_IOC_H2I_ENABLE_REQ, | 1934 | bfi_h2i_set(enable_req.mh, BFI_MC_IOC, BFI_IOC_H2I_ENABLE_REQ, |
1936 | bfa_ioc_portid(ioc)); | 1935 | bfa_ioc_portid(ioc)); |
1937 | enable_req.clscode = htons(ioc->clscode); | 1936 | enable_req.clscode = htons(ioc->clscode); |
1938 | do_gettimeofday(&tv); | 1937 | enable_req.rsvd = htons(0); |
1939 | enable_req.tv_sec = ntohl(tv.tv_sec); | 1938 | /* overflow in 2106 */ |
1939 | enable_req.tv_sec = ntohl(ktime_get_real_seconds()); | ||
1940 | bfa_ioc_mbox_send(ioc, &enable_req, sizeof(struct bfi_ioc_ctrl_req)); | 1940 | bfa_ioc_mbox_send(ioc, &enable_req, sizeof(struct bfi_ioc_ctrl_req)); |
1941 | } | 1941 | } |
1942 | 1942 | ||
@@ -1947,6 +1947,10 @@ bfa_ioc_send_disable(struct bfa_ioc *ioc) | |||
1947 | 1947 | ||
1948 | bfi_h2i_set(disable_req.mh, BFI_MC_IOC, BFI_IOC_H2I_DISABLE_REQ, | 1948 | bfi_h2i_set(disable_req.mh, BFI_MC_IOC, BFI_IOC_H2I_DISABLE_REQ, |
1949 | bfa_ioc_portid(ioc)); | 1949 | bfa_ioc_portid(ioc)); |
1950 | disable_req.clscode = htons(ioc->clscode); | ||
1951 | disable_req.rsvd = htons(0); | ||
1952 | /* overflow in 2106 */ | ||
1953 | disable_req.tv_sec = ntohl(ktime_get_real_seconds()); | ||
1950 | bfa_ioc_mbox_send(ioc, &disable_req, sizeof(struct bfi_ioc_ctrl_req)); | 1954 | bfa_ioc_mbox_send(ioc, &disable_req, sizeof(struct bfi_ioc_ctrl_req)); |
1951 | } | 1955 | } |
1952 | 1956 | ||
diff --git a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c index 64a1095e4d14..a0ca68ce3fbb 100644 --- a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c +++ b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c | |||
@@ -134,6 +134,7 @@ static void set_max_bgx_per_node(struct pci_dev *pdev) | |||
134 | pci_read_config_word(pdev, PCI_SUBSYSTEM_ID, &sdevid); | 134 | pci_read_config_word(pdev, PCI_SUBSYSTEM_ID, &sdevid); |
135 | switch (sdevid) { | 135 | switch (sdevid) { |
136 | case PCI_SUBSYS_DEVID_81XX_BGX: | 136 | case PCI_SUBSYS_DEVID_81XX_BGX: |
137 | case PCI_SUBSYS_DEVID_81XX_RGX: | ||
137 | max_bgx_per_node = MAX_BGX_PER_CN81XX; | 138 | max_bgx_per_node = MAX_BGX_PER_CN81XX; |
138 | break; | 139 | break; |
139 | case PCI_SUBSYS_DEVID_83XX_BGX: | 140 | case PCI_SUBSYS_DEVID_83XX_BGX: |
diff --git a/drivers/net/ethernet/cavium/thunder/thunder_bgx.h b/drivers/net/ethernet/cavium/thunder/thunder_bgx.h index c5080f2cead5..6b7fe6fdd13b 100644 --- a/drivers/net/ethernet/cavium/thunder/thunder_bgx.h +++ b/drivers/net/ethernet/cavium/thunder/thunder_bgx.h | |||
@@ -16,6 +16,7 @@ | |||
16 | /* Subsystem device IDs */ | 16 | /* Subsystem device IDs */ |
17 | #define PCI_SUBSYS_DEVID_88XX_BGX 0xA126 | 17 | #define PCI_SUBSYS_DEVID_88XX_BGX 0xA126 |
18 | #define PCI_SUBSYS_DEVID_81XX_BGX 0xA226 | 18 | #define PCI_SUBSYS_DEVID_81XX_BGX 0xA226 |
19 | #define PCI_SUBSYS_DEVID_81XX_RGX 0xA254 | ||
19 | #define PCI_SUBSYS_DEVID_83XX_BGX 0xA326 | 20 | #define PCI_SUBSYS_DEVID_83XX_BGX 0xA326 |
20 | 21 | ||
21 | #define MAX_BGX_THUNDER 8 /* Max 2 nodes, 4 per node */ | 22 | #define MAX_BGX_THUNDER 8 /* Max 2 nodes, 4 per node */ |
diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c b/drivers/net/ethernet/emulex/benet/be_cmds.c index 30e855004c57..02dd5246dfae 100644 --- a/drivers/net/ethernet/emulex/benet/be_cmds.c +++ b/drivers/net/ethernet/emulex/benet/be_cmds.c | |||
@@ -4939,8 +4939,9 @@ static int | |||
4939 | __be_cmd_set_logical_link_config(struct be_adapter *adapter, | 4939 | __be_cmd_set_logical_link_config(struct be_adapter *adapter, |
4940 | int link_state, int version, u8 domain) | 4940 | int link_state, int version, u8 domain) |
4941 | { | 4941 | { |
4942 | struct be_mcc_wrb *wrb; | ||
4943 | struct be_cmd_req_set_ll_link *req; | 4942 | struct be_cmd_req_set_ll_link *req; |
4943 | struct be_mcc_wrb *wrb; | ||
4944 | u32 link_config = 0; | ||
4944 | int status; | 4945 | int status; |
4945 | 4946 | ||
4946 | mutex_lock(&adapter->mcc_lock); | 4947 | mutex_lock(&adapter->mcc_lock); |
@@ -4962,10 +4963,12 @@ __be_cmd_set_logical_link_config(struct be_adapter *adapter, | |||
4962 | 4963 | ||
4963 | if (link_state == IFLA_VF_LINK_STATE_ENABLE || | 4964 | if (link_state == IFLA_VF_LINK_STATE_ENABLE || |
4964 | link_state == IFLA_VF_LINK_STATE_AUTO) | 4965 | link_state == IFLA_VF_LINK_STATE_AUTO) |
4965 | req->link_config |= PLINK_ENABLE; | 4966 | link_config |= PLINK_ENABLE; |
4966 | 4967 | ||
4967 | if (link_state == IFLA_VF_LINK_STATE_AUTO) | 4968 | if (link_state == IFLA_VF_LINK_STATE_AUTO) |
4968 | req->link_config |= PLINK_TRACK; | 4969 | link_config |= PLINK_TRACK; |
4970 | |||
4971 | req->link_config = cpu_to_le32(link_config); | ||
4969 | 4972 | ||
4970 | status = be_mcc_notify_wait(adapter); | 4973 | status = be_mcc_notify_wait(adapter); |
4971 | err: | 4974 | err: |
diff --git a/drivers/net/ethernet/ezchip/nps_enet.c b/drivers/net/ethernet/ezchip/nps_enet.c index 992ebe973d25..f819843e2bae 100644 --- a/drivers/net/ethernet/ezchip/nps_enet.c +++ b/drivers/net/ethernet/ezchip/nps_enet.c | |||
@@ -189,11 +189,9 @@ static int nps_enet_poll(struct napi_struct *napi, int budget) | |||
189 | 189 | ||
190 | nps_enet_tx_handler(ndev); | 190 | nps_enet_tx_handler(ndev); |
191 | work_done = nps_enet_rx_handler(ndev); | 191 | work_done = nps_enet_rx_handler(ndev); |
192 | if (work_done < budget) { | 192 | if ((work_done < budget) && napi_complete_done(napi, work_done)) { |
193 | u32 buf_int_enable_value = 0; | 193 | u32 buf_int_enable_value = 0; |
194 | 194 | ||
195 | napi_complete_done(napi, work_done); | ||
196 | |||
197 | /* set tx_done and rx_rdy bits */ | 195 | /* set tx_done and rx_rdy bits */ |
198 | buf_int_enable_value |= NPS_ENET_ENABLE << RX_RDY_SHIFT; | 196 | buf_int_enable_value |= NPS_ENET_ENABLE << RX_RDY_SHIFT; |
199 | buf_int_enable_value |= NPS_ENET_ENABLE << TX_DONE_SHIFT; | 197 | buf_int_enable_value |= NPS_ENET_ENABLE << TX_DONE_SHIFT; |
diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c index 928b0df2b8e0..ade6b3e4ed13 100644 --- a/drivers/net/ethernet/faraday/ftgmac100.c +++ b/drivers/net/ethernet/faraday/ftgmac100.c | |||
@@ -28,8 +28,10 @@ | |||
28 | #include <linux/io.h> | 28 | #include <linux/io.h> |
29 | #include <linux/module.h> | 29 | #include <linux/module.h> |
30 | #include <linux/netdevice.h> | 30 | #include <linux/netdevice.h> |
31 | #include <linux/of.h> | ||
31 | #include <linux/phy.h> | 32 | #include <linux/phy.h> |
32 | #include <linux/platform_device.h> | 33 | #include <linux/platform_device.h> |
34 | #include <linux/property.h> | ||
33 | #include <net/ip.h> | 35 | #include <net/ip.h> |
34 | #include <net/ncsi.h> | 36 | #include <net/ncsi.h> |
35 | 37 | ||
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c index 3239d27143b9..bdd8cdd732fb 100644 --- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c +++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c | |||
@@ -82,9 +82,12 @@ void hns_mac_get_link_status(struct hns_mac_cb *mac_cb, u32 *link_status) | |||
82 | else | 82 | else |
83 | *link_status = 0; | 83 | *link_status = 0; |
84 | 84 | ||
85 | ret = mac_cb->dsaf_dev->misc_op->get_sfp_prsnt(mac_cb, &sfp_prsnt); | 85 | if (mac_cb->media_type == HNAE_MEDIA_TYPE_FIBER) { |
86 | if (!ret) | 86 | ret = mac_cb->dsaf_dev->misc_op->get_sfp_prsnt(mac_cb, |
87 | *link_status = *link_status && sfp_prsnt; | 87 | &sfp_prsnt); |
88 | if (!ret) | ||
89 | *link_status = *link_status && sfp_prsnt; | ||
90 | } | ||
88 | 91 | ||
89 | mac_cb->link = *link_status; | 92 | mac_cb->link = *link_status; |
90 | } | 93 | } |
@@ -855,7 +858,7 @@ static int hns_mac_get_info(struct hns_mac_cb *mac_cb) | |||
855 | of_node_put(np); | 858 | of_node_put(np); |
856 | 859 | ||
857 | np = of_parse_phandle(to_of_node(mac_cb->fw_port), | 860 | np = of_parse_phandle(to_of_node(mac_cb->fw_port), |
858 | "serdes-syscon", 0); | 861 | "serdes-syscon", 0); |
859 | syscon = syscon_node_to_regmap(np); | 862 | syscon = syscon_node_to_regmap(np); |
860 | of_node_put(np); | 863 | of_node_put(np); |
861 | if (IS_ERR_OR_NULL(syscon)) { | 864 | if (IS_ERR_OR_NULL(syscon)) { |
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c index 90dbda792614..403ea9db6dbd 100644 --- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c +++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c | |||
@@ -1519,6 +1519,7 @@ static void hns_dsaf_set_mac_key( | |||
1519 | mac_key->high.bits.mac_3 = addr[3]; | 1519 | mac_key->high.bits.mac_3 = addr[3]; |
1520 | mac_key->low.bits.mac_4 = addr[4]; | 1520 | mac_key->low.bits.mac_4 = addr[4]; |
1521 | mac_key->low.bits.mac_5 = addr[5]; | 1521 | mac_key->low.bits.mac_5 = addr[5]; |
1522 | mac_key->low.bits.port_vlan = 0; | ||
1522 | dsaf_set_field(mac_key->low.bits.port_vlan, DSAF_TBL_TCAM_KEY_VLAN_M, | 1523 | dsaf_set_field(mac_key->low.bits.port_vlan, DSAF_TBL_TCAM_KEY_VLAN_M, |
1523 | DSAF_TBL_TCAM_KEY_VLAN_S, vlan_id); | 1524 | DSAF_TBL_TCAM_KEY_VLAN_S, vlan_id); |
1524 | dsaf_set_field(mac_key->low.bits.port_vlan, DSAF_TBL_TCAM_KEY_PORT_M, | 1525 | dsaf_set_field(mac_key->low.bits.port_vlan, DSAF_TBL_TCAM_KEY_PORT_M, |
@@ -2924,10 +2925,11 @@ void hns_dsaf_set_promisc_tcam(struct dsaf_device *dsaf_dev, | |||
2924 | /* find the tcam entry index for promisc */ | 2925 | /* find the tcam entry index for promisc */ |
2925 | entry_index = dsaf_promisc_tcam_entry(port); | 2926 | entry_index = dsaf_promisc_tcam_entry(port); |
2926 | 2927 | ||
2928 | memset(&tbl_tcam_data, 0, sizeof(tbl_tcam_data)); | ||
2929 | memset(&tbl_tcam_mask, 0, sizeof(tbl_tcam_mask)); | ||
2930 | |||
2927 | /* config key mask */ | 2931 | /* config key mask */ |
2928 | if (enable) { | 2932 | if (enable) { |
2929 | memset(&tbl_tcam_data, 0, sizeof(tbl_tcam_data)); | ||
2930 | memset(&tbl_tcam_mask, 0, sizeof(tbl_tcam_mask)); | ||
2931 | dsaf_set_field(tbl_tcam_data.low.bits.port_vlan, | 2933 | dsaf_set_field(tbl_tcam_data.low.bits.port_vlan, |
2932 | DSAF_TBL_TCAM_KEY_PORT_M, | 2934 | DSAF_TBL_TCAM_KEY_PORT_M, |
2933 | DSAF_TBL_TCAM_KEY_PORT_S, port); | 2935 | DSAF_TBL_TCAM_KEY_PORT_S, port); |
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c index a2c22d084ce9..e13aa064a8e9 100644 --- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c +++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c | |||
@@ -461,6 +461,32 @@ int hns_mac_get_sfp_prsnt(struct hns_mac_cb *mac_cb, int *sfp_prsnt) | |||
461 | return 0; | 461 | return 0; |
462 | } | 462 | } |
463 | 463 | ||
464 | int hns_mac_get_sfp_prsnt_acpi(struct hns_mac_cb *mac_cb, int *sfp_prsnt) | ||
465 | { | ||
466 | union acpi_object *obj; | ||
467 | union acpi_object obj_args, argv4; | ||
468 | |||
469 | obj_args.integer.type = ACPI_TYPE_INTEGER; | ||
470 | obj_args.integer.value = mac_cb->mac_id; | ||
471 | |||
472 | argv4.type = ACPI_TYPE_PACKAGE, | ||
473 | argv4.package.count = 1, | ||
474 | argv4.package.elements = &obj_args, | ||
475 | |||
476 | obj = acpi_evaluate_dsm(ACPI_HANDLE(mac_cb->dev), | ||
477 | hns_dsaf_acpi_dsm_uuid, 0, | ||
478 | HNS_OP_GET_SFP_STAT_FUNC, &argv4); | ||
479 | |||
480 | if (!obj || obj->type != ACPI_TYPE_INTEGER) | ||
481 | return -ENODEV; | ||
482 | |||
483 | *sfp_prsnt = obj->integer.value; | ||
484 | |||
485 | ACPI_FREE(obj); | ||
486 | |||
487 | return 0; | ||
488 | } | ||
489 | |||
464 | /** | 490 | /** |
465 | * hns_mac_config_sds_loopback - set loop back for serdes | 491 | * hns_mac_config_sds_loopback - set loop back for serdes |
466 | * @mac_cb: mac control block | 492 | * @mac_cb: mac control block |
@@ -592,7 +618,7 @@ struct dsaf_misc_op *hns_misc_op_get(struct dsaf_device *dsaf_dev) | |||
592 | misc_op->hns_dsaf_roce_srst = hns_dsaf_roce_srst_acpi; | 618 | misc_op->hns_dsaf_roce_srst = hns_dsaf_roce_srst_acpi; |
593 | 619 | ||
594 | misc_op->get_phy_if = hns_mac_get_phy_if_acpi; | 620 | misc_op->get_phy_if = hns_mac_get_phy_if_acpi; |
595 | misc_op->get_sfp_prsnt = hns_mac_get_sfp_prsnt; | 621 | misc_op->get_sfp_prsnt = hns_mac_get_sfp_prsnt_acpi; |
596 | 622 | ||
597 | misc_op->cfg_serdes_loopback = hns_mac_config_sds_loopback_acpi; | 623 | misc_op->cfg_serdes_loopback = hns_mac_config_sds_loopback_acpi; |
598 | } else { | 624 | } else { |
diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c index 2175cced402f..e9af89ad039c 100644 --- a/drivers/net/ethernet/intel/e1000e/netdev.c +++ b/drivers/net/ethernet/intel/e1000e/netdev.c | |||
@@ -6274,8 +6274,8 @@ static int e1000e_pm_freeze(struct device *dev) | |||
6274 | /* Quiesce the device without resetting the hardware */ | 6274 | /* Quiesce the device without resetting the hardware */ |
6275 | e1000e_down(adapter, false); | 6275 | e1000e_down(adapter, false); |
6276 | e1000_free_irq(adapter); | 6276 | e1000_free_irq(adapter); |
6277 | e1000e_reset_interrupt_capability(adapter); | ||
6278 | } | 6277 | } |
6278 | e1000e_reset_interrupt_capability(adapter); | ||
6279 | 6279 | ||
6280 | /* Allow time for pending master requests to run */ | 6280 | /* Allow time for pending master requests to run */ |
6281 | e1000e_disable_pcie_master(&adapter->hw); | 6281 | e1000e_disable_pcie_master(&adapter->hw); |
diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c index e8a8351c8ea9..82a95cc2c8ee 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_main.c +++ b/drivers/net/ethernet/intel/i40e/i40e_main.c | |||
@@ -4438,8 +4438,12 @@ static void i40e_napi_enable_all(struct i40e_vsi *vsi) | |||
4438 | if (!vsi->netdev) | 4438 | if (!vsi->netdev) |
4439 | return; | 4439 | return; |
4440 | 4440 | ||
4441 | for (q_idx = 0; q_idx < vsi->num_q_vectors; q_idx++) | 4441 | for (q_idx = 0; q_idx < vsi->num_q_vectors; q_idx++) { |
4442 | napi_enable(&vsi->q_vectors[q_idx]->napi); | 4442 | struct i40e_q_vector *q_vector = vsi->q_vectors[q_idx]; |
4443 | |||
4444 | if (q_vector->rx.ring || q_vector->tx.ring) | ||
4445 | napi_enable(&q_vector->napi); | ||
4446 | } | ||
4443 | } | 4447 | } |
4444 | 4448 | ||
4445 | /** | 4449 | /** |
@@ -4453,8 +4457,12 @@ static void i40e_napi_disable_all(struct i40e_vsi *vsi) | |||
4453 | if (!vsi->netdev) | 4457 | if (!vsi->netdev) |
4454 | return; | 4458 | return; |
4455 | 4459 | ||
4456 | for (q_idx = 0; q_idx < vsi->num_q_vectors; q_idx++) | 4460 | for (q_idx = 0; q_idx < vsi->num_q_vectors; q_idx++) { |
4457 | napi_disable(&vsi->q_vectors[q_idx]->napi); | 4461 | struct i40e_q_vector *q_vector = vsi->q_vectors[q_idx]; |
4462 | |||
4463 | if (q_vector->rx.ring || q_vector->tx.ring) | ||
4464 | napi_disable(&q_vector->napi); | ||
4465 | } | ||
4458 | } | 4466 | } |
4459 | 4467 | ||
4460 | /** | 4468 | /** |
diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c index 9e757684816d..93949139e62c 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c | |||
@@ -613,7 +613,7 @@ static int mtk_tx_map(struct sk_buff *skb, struct net_device *dev, | |||
613 | struct mtk_mac *mac = netdev_priv(dev); | 613 | struct mtk_mac *mac = netdev_priv(dev); |
614 | struct mtk_eth *eth = mac->hw; | 614 | struct mtk_eth *eth = mac->hw; |
615 | struct mtk_tx_dma *itxd, *txd; | 615 | struct mtk_tx_dma *itxd, *txd; |
616 | struct mtk_tx_buf *tx_buf; | 616 | struct mtk_tx_buf *itx_buf, *tx_buf; |
617 | dma_addr_t mapped_addr; | 617 | dma_addr_t mapped_addr; |
618 | unsigned int nr_frags; | 618 | unsigned int nr_frags; |
619 | int i, n_desc = 1; | 619 | int i, n_desc = 1; |
@@ -627,8 +627,8 @@ static int mtk_tx_map(struct sk_buff *skb, struct net_device *dev, | |||
627 | fport = (mac->id + 1) << TX_DMA_FPORT_SHIFT; | 627 | fport = (mac->id + 1) << TX_DMA_FPORT_SHIFT; |
628 | txd4 |= fport; | 628 | txd4 |= fport; |
629 | 629 | ||
630 | tx_buf = mtk_desc_to_tx_buf(ring, itxd); | 630 | itx_buf = mtk_desc_to_tx_buf(ring, itxd); |
631 | memset(tx_buf, 0, sizeof(*tx_buf)); | 631 | memset(itx_buf, 0, sizeof(*itx_buf)); |
632 | 632 | ||
633 | if (gso) | 633 | if (gso) |
634 | txd4 |= TX_DMA_TSO; | 634 | txd4 |= TX_DMA_TSO; |
@@ -647,9 +647,11 @@ static int mtk_tx_map(struct sk_buff *skb, struct net_device *dev, | |||
647 | return -ENOMEM; | 647 | return -ENOMEM; |
648 | 648 | ||
649 | WRITE_ONCE(itxd->txd1, mapped_addr); | 649 | WRITE_ONCE(itxd->txd1, mapped_addr); |
650 | tx_buf->flags |= MTK_TX_FLAGS_SINGLE0; | 650 | itx_buf->flags |= MTK_TX_FLAGS_SINGLE0; |
651 | dma_unmap_addr_set(tx_buf, dma_addr0, mapped_addr); | 651 | itx_buf->flags |= (!mac->id) ? MTK_TX_FLAGS_FPORT0 : |
652 | dma_unmap_len_set(tx_buf, dma_len0, skb_headlen(skb)); | 652 | MTK_TX_FLAGS_FPORT1; |
653 | dma_unmap_addr_set(itx_buf, dma_addr0, mapped_addr); | ||
654 | dma_unmap_len_set(itx_buf, dma_len0, skb_headlen(skb)); | ||
653 | 655 | ||
654 | /* TX SG offload */ | 656 | /* TX SG offload */ |
655 | txd = itxd; | 657 | txd = itxd; |
@@ -685,11 +687,13 @@ static int mtk_tx_map(struct sk_buff *skb, struct net_device *dev, | |||
685 | last_frag * TX_DMA_LS0)); | 687 | last_frag * TX_DMA_LS0)); |
686 | WRITE_ONCE(txd->txd4, fport); | 688 | WRITE_ONCE(txd->txd4, fport); |
687 | 689 | ||
688 | tx_buf->skb = (struct sk_buff *)MTK_DMA_DUMMY_DESC; | ||
689 | tx_buf = mtk_desc_to_tx_buf(ring, txd); | 690 | tx_buf = mtk_desc_to_tx_buf(ring, txd); |
690 | memset(tx_buf, 0, sizeof(*tx_buf)); | 691 | memset(tx_buf, 0, sizeof(*tx_buf)); |
691 | 692 | tx_buf->skb = (struct sk_buff *)MTK_DMA_DUMMY_DESC; | |
692 | tx_buf->flags |= MTK_TX_FLAGS_PAGE0; | 693 | tx_buf->flags |= MTK_TX_FLAGS_PAGE0; |
694 | tx_buf->flags |= (!mac->id) ? MTK_TX_FLAGS_FPORT0 : | ||
695 | MTK_TX_FLAGS_FPORT1; | ||
696 | |||
693 | dma_unmap_addr_set(tx_buf, dma_addr0, mapped_addr); | 697 | dma_unmap_addr_set(tx_buf, dma_addr0, mapped_addr); |
694 | dma_unmap_len_set(tx_buf, dma_len0, frag_map_size); | 698 | dma_unmap_len_set(tx_buf, dma_len0, frag_map_size); |
695 | frag_size -= frag_map_size; | 699 | frag_size -= frag_map_size; |
@@ -698,7 +702,7 @@ static int mtk_tx_map(struct sk_buff *skb, struct net_device *dev, | |||
698 | } | 702 | } |
699 | 703 | ||
700 | /* store skb to cleanup */ | 704 | /* store skb to cleanup */ |
701 | tx_buf->skb = skb; | 705 | itx_buf->skb = skb; |
702 | 706 | ||
703 | WRITE_ONCE(itxd->txd4, txd4); | 707 | WRITE_ONCE(itxd->txd4, txd4); |
704 | WRITE_ONCE(itxd->txd3, (TX_DMA_SWC | TX_DMA_PLEN0(skb_headlen(skb)) | | 708 | WRITE_ONCE(itxd->txd3, (TX_DMA_SWC | TX_DMA_PLEN0(skb_headlen(skb)) | |
@@ -1012,17 +1016,16 @@ static int mtk_poll_tx(struct mtk_eth *eth, int budget) | |||
1012 | 1016 | ||
1013 | while ((cpu != dma) && budget) { | 1017 | while ((cpu != dma) && budget) { |
1014 | u32 next_cpu = desc->txd2; | 1018 | u32 next_cpu = desc->txd2; |
1015 | int mac; | 1019 | int mac = 0; |
1016 | 1020 | ||
1017 | desc = mtk_qdma_phys_to_virt(ring, desc->txd2); | 1021 | desc = mtk_qdma_phys_to_virt(ring, desc->txd2); |
1018 | if ((desc->txd3 & TX_DMA_OWNER_CPU) == 0) | 1022 | if ((desc->txd3 & TX_DMA_OWNER_CPU) == 0) |
1019 | break; | 1023 | break; |
1020 | 1024 | ||
1021 | mac = (desc->txd4 >> TX_DMA_FPORT_SHIFT) & | ||
1022 | TX_DMA_FPORT_MASK; | ||
1023 | mac--; | ||
1024 | |||
1025 | tx_buf = mtk_desc_to_tx_buf(ring, desc); | 1025 | tx_buf = mtk_desc_to_tx_buf(ring, desc); |
1026 | if (tx_buf->flags & MTK_TX_FLAGS_FPORT1) | ||
1027 | mac = 1; | ||
1028 | |||
1026 | skb = tx_buf->skb; | 1029 | skb = tx_buf->skb; |
1027 | if (!skb) { | 1030 | if (!skb) { |
1028 | condition = 1; | 1031 | condition = 1; |
diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.h b/drivers/net/ethernet/mediatek/mtk_eth_soc.h index 99b1c8e9f16f..08285a96ff70 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h | |||
@@ -406,12 +406,18 @@ struct mtk_hw_stats { | |||
406 | struct u64_stats_sync syncp; | 406 | struct u64_stats_sync syncp; |
407 | }; | 407 | }; |
408 | 408 | ||
409 | /* PDMA descriptor can point at 1-2 segments. This enum allows us to track how | ||
410 | * memory was allocated so that it can be freed properly | ||
411 | */ | ||
412 | enum mtk_tx_flags { | 409 | enum mtk_tx_flags { |
410 | /* PDMA descriptor can point at 1-2 segments. This enum allows us to | ||
411 | * track how memory was allocated so that it can be freed properly. | ||
412 | */ | ||
413 | MTK_TX_FLAGS_SINGLE0 = 0x01, | 413 | MTK_TX_FLAGS_SINGLE0 = 0x01, |
414 | MTK_TX_FLAGS_PAGE0 = 0x02, | 414 | MTK_TX_FLAGS_PAGE0 = 0x02, |
415 | |||
416 | /* MTK_TX_FLAGS_FPORTx allows tracking which port the transmitted | ||
417 | * SKB out instead of looking up through hardware TX descriptor. | ||
418 | */ | ||
419 | MTK_TX_FLAGS_FPORT0 = 0x04, | ||
420 | MTK_TX_FLAGS_FPORT1 = 0x08, | ||
415 | }; | 421 | }; |
416 | 422 | ||
417 | /* This enum allows us to identify how the clock is defined on the array of the | 423 | /* This enum allows us to identify how the clock is defined on the array of the |
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lag.c b/drivers/net/ethernet/mellanox/mlx5/core/lag.c index 55957246c0e8..b5d5519542e8 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/lag.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/lag.c | |||
@@ -294,7 +294,7 @@ static int mlx5_handle_changeupper_event(struct mlx5_lag *ldev, | |||
294 | struct netdev_notifier_changeupper_info *info) | 294 | struct netdev_notifier_changeupper_info *info) |
295 | { | 295 | { |
296 | struct net_device *upper = info->upper_dev, *ndev_tmp; | 296 | struct net_device *upper = info->upper_dev, *ndev_tmp; |
297 | struct netdev_lag_upper_info *lag_upper_info; | 297 | struct netdev_lag_upper_info *lag_upper_info = NULL; |
298 | bool is_bonded; | 298 | bool is_bonded; |
299 | int bond_status = 0; | 299 | int bond_status = 0; |
300 | int num_slaves = 0; | 300 | int num_slaves = 0; |
@@ -303,7 +303,8 @@ static int mlx5_handle_changeupper_event(struct mlx5_lag *ldev, | |||
303 | if (!netif_is_lag_master(upper)) | 303 | if (!netif_is_lag_master(upper)) |
304 | return 0; | 304 | return 0; |
305 | 305 | ||
306 | lag_upper_info = info->upper_info; | 306 | if (info->linking) |
307 | lag_upper_info = info->upper_info; | ||
307 | 308 | ||
308 | /* The event may still be of interest if the slave does not belong to | 309 | /* The event may still be of interest if the slave does not belong to |
309 | * us, but is enslaved to a master which has one or more of our netdevs | 310 | * us, but is enslaved to a master which has one or more of our netdevs |
diff --git a/drivers/net/ethernet/moxa/moxart_ether.c b/drivers/net/ethernet/moxa/moxart_ether.c index 06c9f4100cb9..6ad44be08b33 100644 --- a/drivers/net/ethernet/moxa/moxart_ether.c +++ b/drivers/net/ethernet/moxa/moxart_ether.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include <linux/of_irq.h> | 25 | #include <linux/of_irq.h> |
26 | #include <linux/crc32.h> | 26 | #include <linux/crc32.h> |
27 | #include <linux/crc32c.h> | 27 | #include <linux/crc32c.h> |
28 | #include <linux/circ_buf.h> | ||
28 | 29 | ||
29 | #include "moxart_ether.h" | 30 | #include "moxart_ether.h" |
30 | 31 | ||
@@ -278,6 +279,13 @@ rx_next: | |||
278 | return rx; | 279 | return rx; |
279 | } | 280 | } |
280 | 281 | ||
282 | static int moxart_tx_queue_space(struct net_device *ndev) | ||
283 | { | ||
284 | struct moxart_mac_priv_t *priv = netdev_priv(ndev); | ||
285 | |||
286 | return CIRC_SPACE(priv->tx_head, priv->tx_tail, TX_DESC_NUM); | ||
287 | } | ||
288 | |||
281 | static void moxart_tx_finished(struct net_device *ndev) | 289 | static void moxart_tx_finished(struct net_device *ndev) |
282 | { | 290 | { |
283 | struct moxart_mac_priv_t *priv = netdev_priv(ndev); | 291 | struct moxart_mac_priv_t *priv = netdev_priv(ndev); |
@@ -297,6 +305,9 @@ static void moxart_tx_finished(struct net_device *ndev) | |||
297 | tx_tail = TX_NEXT(tx_tail); | 305 | tx_tail = TX_NEXT(tx_tail); |
298 | } | 306 | } |
299 | priv->tx_tail = tx_tail; | 307 | priv->tx_tail = tx_tail; |
308 | if (netif_queue_stopped(ndev) && | ||
309 | moxart_tx_queue_space(ndev) >= TX_WAKE_THRESHOLD) | ||
310 | netif_wake_queue(ndev); | ||
300 | } | 311 | } |
301 | 312 | ||
302 | static irqreturn_t moxart_mac_interrupt(int irq, void *dev_id) | 313 | static irqreturn_t moxart_mac_interrupt(int irq, void *dev_id) |
@@ -324,13 +335,18 @@ static int moxart_mac_start_xmit(struct sk_buff *skb, struct net_device *ndev) | |||
324 | struct moxart_mac_priv_t *priv = netdev_priv(ndev); | 335 | struct moxart_mac_priv_t *priv = netdev_priv(ndev); |
325 | void *desc; | 336 | void *desc; |
326 | unsigned int len; | 337 | unsigned int len; |
327 | unsigned int tx_head = priv->tx_head; | 338 | unsigned int tx_head; |
328 | u32 txdes1; | 339 | u32 txdes1; |
329 | int ret = NETDEV_TX_BUSY; | 340 | int ret = NETDEV_TX_BUSY; |
330 | 341 | ||
342 | spin_lock_irq(&priv->txlock); | ||
343 | |||
344 | tx_head = priv->tx_head; | ||
331 | desc = priv->tx_desc_base + (TX_REG_DESC_SIZE * tx_head); | 345 | desc = priv->tx_desc_base + (TX_REG_DESC_SIZE * tx_head); |
332 | 346 | ||
333 | spin_lock_irq(&priv->txlock); | 347 | if (moxart_tx_queue_space(ndev) == 1) |
348 | netif_stop_queue(ndev); | ||
349 | |||
334 | if (moxart_desc_read(desc + TX_REG_OFFSET_DESC0) & TX_DESC0_DMA_OWN) { | 350 | if (moxart_desc_read(desc + TX_REG_OFFSET_DESC0) & TX_DESC0_DMA_OWN) { |
335 | net_dbg_ratelimited("no TX space for packet\n"); | 351 | net_dbg_ratelimited("no TX space for packet\n"); |
336 | priv->stats.tx_dropped++; | 352 | priv->stats.tx_dropped++; |
diff --git a/drivers/net/ethernet/moxa/moxart_ether.h b/drivers/net/ethernet/moxa/moxart_ether.h index 93a9563ac7c6..afc32ec998c0 100644 --- a/drivers/net/ethernet/moxa/moxart_ether.h +++ b/drivers/net/ethernet/moxa/moxart_ether.h | |||
@@ -59,6 +59,7 @@ | |||
59 | #define TX_NEXT(N) (((N) + 1) & (TX_DESC_NUM_MASK)) | 59 | #define TX_NEXT(N) (((N) + 1) & (TX_DESC_NUM_MASK)) |
60 | #define TX_BUF_SIZE 1600 | 60 | #define TX_BUF_SIZE 1600 |
61 | #define TX_BUF_SIZE_MAX (TX_DESC1_BUF_SIZE_MASK+1) | 61 | #define TX_BUF_SIZE_MAX (TX_DESC1_BUF_SIZE_MASK+1) |
62 | #define TX_WAKE_THRESHOLD 16 | ||
62 | 63 | ||
63 | #define RX_DESC_NUM 64 | 64 | #define RX_DESC_NUM 64 |
64 | #define RX_DESC_NUM_MASK (RX_DESC_NUM-1) | 65 | #define RX_DESC_NUM_MASK (RX_DESC_NUM-1) |
diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c index 9179a99563af..a41377e26c07 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c +++ b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c | |||
@@ -3275,9 +3275,10 @@ void nfp_net_netdev_clean(struct net_device *netdev) | |||
3275 | { | 3275 | { |
3276 | struct nfp_net *nn = netdev_priv(netdev); | 3276 | struct nfp_net *nn = netdev_priv(netdev); |
3277 | 3277 | ||
3278 | unregister_netdev(nn->netdev); | ||
3279 | |||
3278 | if (nn->xdp_prog) | 3280 | if (nn->xdp_prog) |
3279 | bpf_prog_put(nn->xdp_prog); | 3281 | bpf_prog_put(nn->xdp_prog); |
3280 | if (nn->bpf_offload_xdp) | 3282 | if (nn->bpf_offload_xdp) |
3281 | nfp_net_xdp_offload(nn, NULL); | 3283 | nfp_net_xdp_offload(nn, NULL); |
3282 | unregister_netdev(nn->netdev); | ||
3283 | } | 3284 | } |
diff --git a/drivers/net/ethernet/qlogic/qed/qed_dcbx.c b/drivers/net/ethernet/qlogic/qed/qed_dcbx.c index 5bd36a4a8fcd..a6e2bbe629bd 100644 --- a/drivers/net/ethernet/qlogic/qed/qed_dcbx.c +++ b/drivers/net/ethernet/qlogic/qed/qed_dcbx.c | |||
@@ -583,6 +583,13 @@ qed_dcbx_get_ets_data(struct qed_hwfn *p_hwfn, | |||
583 | p_params->ets_cbs, | 583 | p_params->ets_cbs, |
584 | p_ets->pri_tc_tbl[0], p_params->max_ets_tc); | 584 | p_ets->pri_tc_tbl[0], p_params->max_ets_tc); |
585 | 585 | ||
586 | if (p_params->ets_enabled && !p_params->max_ets_tc) { | ||
587 | p_params->max_ets_tc = QED_MAX_PFC_PRIORITIES; | ||
588 | DP_VERBOSE(p_hwfn, QED_MSG_DCB, | ||
589 | "ETS params: max_ets_tc is forced to %d\n", | ||
590 | p_params->max_ets_tc); | ||
591 | } | ||
592 | |||
586 | /* 8 bit tsa and bw data corresponding to each of the 8 TC's are | 593 | /* 8 bit tsa and bw data corresponding to each of the 8 TC's are |
587 | * encoded in a type u32 array of size 2. | 594 | * encoded in a type u32 array of size 2. |
588 | */ | 595 | */ |
@@ -1001,6 +1008,8 @@ qed_dcbx_set_pfc_data(struct qed_hwfn *p_hwfn, | |||
1001 | u8 pfc_map = 0; | 1008 | u8 pfc_map = 0; |
1002 | int i; | 1009 | int i; |
1003 | 1010 | ||
1011 | *pfc &= ~DCBX_PFC_ERROR_MASK; | ||
1012 | |||
1004 | if (p_params->pfc.willing) | 1013 | if (p_params->pfc.willing) |
1005 | *pfc |= DCBX_PFC_WILLING_MASK; | 1014 | *pfc |= DCBX_PFC_WILLING_MASK; |
1006 | else | 1015 | else |
@@ -1255,7 +1264,7 @@ static struct qed_dcbx_get *qed_dcbnl_get_dcbx(struct qed_hwfn *hwfn, | |||
1255 | { | 1264 | { |
1256 | struct qed_dcbx_get *dcbx_info; | 1265 | struct qed_dcbx_get *dcbx_info; |
1257 | 1266 | ||
1258 | dcbx_info = kzalloc(sizeof(*dcbx_info), GFP_KERNEL); | 1267 | dcbx_info = kmalloc(sizeof(*dcbx_info), GFP_ATOMIC); |
1259 | if (!dcbx_info) | 1268 | if (!dcbx_info) |
1260 | return NULL; | 1269 | return NULL; |
1261 | 1270 | ||
@@ -2073,6 +2082,8 @@ static int qed_dcbnl_ieee_setpfc(struct qed_dev *cdev, struct ieee_pfc *pfc) | |||
2073 | for (i = 0; i < QED_MAX_PFC_PRIORITIES; i++) | 2082 | for (i = 0; i < QED_MAX_PFC_PRIORITIES; i++) |
2074 | dcbx_set.config.params.pfc.prio[i] = !!(pfc->pfc_en & BIT(i)); | 2083 | dcbx_set.config.params.pfc.prio[i] = !!(pfc->pfc_en & BIT(i)); |
2075 | 2084 | ||
2085 | dcbx_set.config.params.pfc.max_tc = pfc->pfc_cap; | ||
2086 | |||
2076 | ptt = qed_ptt_acquire(hwfn); | 2087 | ptt = qed_ptt_acquire(hwfn); |
2077 | if (!ptt) | 2088 | if (!ptt) |
2078 | return -EINVAL; | 2089 | return -EINVAL; |
diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c index 54248775f227..f68c4db656ed 100644 --- a/drivers/net/ethernet/renesas/sh_eth.c +++ b/drivers/net/ethernet/renesas/sh_eth.c | |||
@@ -1127,12 +1127,70 @@ static struct mdiobb_ops bb_ops = { | |||
1127 | .get_mdio_data = sh_get_mdio, | 1127 | .get_mdio_data = sh_get_mdio, |
1128 | }; | 1128 | }; |
1129 | 1129 | ||
1130 | /* free Tx skb function */ | ||
1131 | static int sh_eth_tx_free(struct net_device *ndev, bool sent_only) | ||
1132 | { | ||
1133 | struct sh_eth_private *mdp = netdev_priv(ndev); | ||
1134 | struct sh_eth_txdesc *txdesc; | ||
1135 | int free_num = 0; | ||
1136 | int entry; | ||
1137 | bool sent; | ||
1138 | |||
1139 | for (; mdp->cur_tx - mdp->dirty_tx > 0; mdp->dirty_tx++) { | ||
1140 | entry = mdp->dirty_tx % mdp->num_tx_ring; | ||
1141 | txdesc = &mdp->tx_ring[entry]; | ||
1142 | sent = !(txdesc->status & cpu_to_le32(TD_TACT)); | ||
1143 | if (sent_only && !sent) | ||
1144 | break; | ||
1145 | /* TACT bit must be checked before all the following reads */ | ||
1146 | dma_rmb(); | ||
1147 | netif_info(mdp, tx_done, ndev, | ||
1148 | "tx entry %d status 0x%08x\n", | ||
1149 | entry, le32_to_cpu(txdesc->status)); | ||
1150 | /* Free the original skb. */ | ||
1151 | if (mdp->tx_skbuff[entry]) { | ||
1152 | dma_unmap_single(&ndev->dev, le32_to_cpu(txdesc->addr), | ||
1153 | le32_to_cpu(txdesc->len) >> 16, | ||
1154 | DMA_TO_DEVICE); | ||
1155 | dev_kfree_skb_irq(mdp->tx_skbuff[entry]); | ||
1156 | mdp->tx_skbuff[entry] = NULL; | ||
1157 | free_num++; | ||
1158 | } | ||
1159 | txdesc->status = cpu_to_le32(TD_TFP); | ||
1160 | if (entry >= mdp->num_tx_ring - 1) | ||
1161 | txdesc->status |= cpu_to_le32(TD_TDLE); | ||
1162 | |||
1163 | if (sent) { | ||
1164 | ndev->stats.tx_packets++; | ||
1165 | ndev->stats.tx_bytes += le32_to_cpu(txdesc->len) >> 16; | ||
1166 | } | ||
1167 | } | ||
1168 | return free_num; | ||
1169 | } | ||
1170 | |||
1130 | /* free skb and descriptor buffer */ | 1171 | /* free skb and descriptor buffer */ |
1131 | static void sh_eth_ring_free(struct net_device *ndev) | 1172 | static void sh_eth_ring_free(struct net_device *ndev) |
1132 | { | 1173 | { |
1133 | struct sh_eth_private *mdp = netdev_priv(ndev); | 1174 | struct sh_eth_private *mdp = netdev_priv(ndev); |
1134 | int ringsize, i; | 1175 | int ringsize, i; |
1135 | 1176 | ||
1177 | if (mdp->rx_ring) { | ||
1178 | for (i = 0; i < mdp->num_rx_ring; i++) { | ||
1179 | if (mdp->rx_skbuff[i]) { | ||
1180 | struct sh_eth_rxdesc *rxdesc = &mdp->rx_ring[i]; | ||
1181 | |||
1182 | dma_unmap_single(&ndev->dev, | ||
1183 | le32_to_cpu(rxdesc->addr), | ||
1184 | ALIGN(mdp->rx_buf_sz, 32), | ||
1185 | DMA_FROM_DEVICE); | ||
1186 | } | ||
1187 | } | ||
1188 | ringsize = sizeof(struct sh_eth_rxdesc) * mdp->num_rx_ring; | ||
1189 | dma_free_coherent(NULL, ringsize, mdp->rx_ring, | ||
1190 | mdp->rx_desc_dma); | ||
1191 | mdp->rx_ring = NULL; | ||
1192 | } | ||
1193 | |||
1136 | /* Free Rx skb ringbuffer */ | 1194 | /* Free Rx skb ringbuffer */ |
1137 | if (mdp->rx_skbuff) { | 1195 | if (mdp->rx_skbuff) { |
1138 | for (i = 0; i < mdp->num_rx_ring; i++) | 1196 | for (i = 0; i < mdp->num_rx_ring; i++) |
@@ -1141,27 +1199,18 @@ static void sh_eth_ring_free(struct net_device *ndev) | |||
1141 | kfree(mdp->rx_skbuff); | 1199 | kfree(mdp->rx_skbuff); |
1142 | mdp->rx_skbuff = NULL; | 1200 | mdp->rx_skbuff = NULL; |
1143 | 1201 | ||
1144 | /* Free Tx skb ringbuffer */ | ||
1145 | if (mdp->tx_skbuff) { | ||
1146 | for (i = 0; i < mdp->num_tx_ring; i++) | ||
1147 | dev_kfree_skb(mdp->tx_skbuff[i]); | ||
1148 | } | ||
1149 | kfree(mdp->tx_skbuff); | ||
1150 | mdp->tx_skbuff = NULL; | ||
1151 | |||
1152 | if (mdp->rx_ring) { | ||
1153 | ringsize = sizeof(struct sh_eth_rxdesc) * mdp->num_rx_ring; | ||
1154 | dma_free_coherent(NULL, ringsize, mdp->rx_ring, | ||
1155 | mdp->rx_desc_dma); | ||
1156 | mdp->rx_ring = NULL; | ||
1157 | } | ||
1158 | |||
1159 | if (mdp->tx_ring) { | 1202 | if (mdp->tx_ring) { |
1203 | sh_eth_tx_free(ndev, false); | ||
1204 | |||
1160 | ringsize = sizeof(struct sh_eth_txdesc) * mdp->num_tx_ring; | 1205 | ringsize = sizeof(struct sh_eth_txdesc) * mdp->num_tx_ring; |
1161 | dma_free_coherent(NULL, ringsize, mdp->tx_ring, | 1206 | dma_free_coherent(NULL, ringsize, mdp->tx_ring, |
1162 | mdp->tx_desc_dma); | 1207 | mdp->tx_desc_dma); |
1163 | mdp->tx_ring = NULL; | 1208 | mdp->tx_ring = NULL; |
1164 | } | 1209 | } |
1210 | |||
1211 | /* Free Tx skb ringbuffer */ | ||
1212 | kfree(mdp->tx_skbuff); | ||
1213 | mdp->tx_skbuff = NULL; | ||
1165 | } | 1214 | } |
1166 | 1215 | ||
1167 | /* format skb and descriptor buffer */ | 1216 | /* format skb and descriptor buffer */ |
@@ -1409,43 +1458,6 @@ static void sh_eth_dev_exit(struct net_device *ndev) | |||
1409 | update_mac_address(ndev); | 1458 | update_mac_address(ndev); |
1410 | } | 1459 | } |
1411 | 1460 | ||
1412 | /* free Tx skb function */ | ||
1413 | static int sh_eth_txfree(struct net_device *ndev) | ||
1414 | { | ||
1415 | struct sh_eth_private *mdp = netdev_priv(ndev); | ||
1416 | struct sh_eth_txdesc *txdesc; | ||
1417 | int free_num = 0; | ||
1418 | int entry; | ||
1419 | |||
1420 | for (; mdp->cur_tx - mdp->dirty_tx > 0; mdp->dirty_tx++) { | ||
1421 | entry = mdp->dirty_tx % mdp->num_tx_ring; | ||
1422 | txdesc = &mdp->tx_ring[entry]; | ||
1423 | if (txdesc->status & cpu_to_le32(TD_TACT)) | ||
1424 | break; | ||
1425 | /* TACT bit must be checked before all the following reads */ | ||
1426 | dma_rmb(); | ||
1427 | netif_info(mdp, tx_done, ndev, | ||
1428 | "tx entry %d status 0x%08x\n", | ||
1429 | entry, le32_to_cpu(txdesc->status)); | ||
1430 | /* Free the original skb. */ | ||
1431 | if (mdp->tx_skbuff[entry]) { | ||
1432 | dma_unmap_single(&ndev->dev, le32_to_cpu(txdesc->addr), | ||
1433 | le32_to_cpu(txdesc->len) >> 16, | ||
1434 | DMA_TO_DEVICE); | ||
1435 | dev_kfree_skb_irq(mdp->tx_skbuff[entry]); | ||
1436 | mdp->tx_skbuff[entry] = NULL; | ||
1437 | free_num++; | ||
1438 | } | ||
1439 | txdesc->status = cpu_to_le32(TD_TFP); | ||
1440 | if (entry >= mdp->num_tx_ring - 1) | ||
1441 | txdesc->status |= cpu_to_le32(TD_TDLE); | ||
1442 | |||
1443 | ndev->stats.tx_packets++; | ||
1444 | ndev->stats.tx_bytes += le32_to_cpu(txdesc->len) >> 16; | ||
1445 | } | ||
1446 | return free_num; | ||
1447 | } | ||
1448 | |||
1449 | /* Packet receive function */ | 1461 | /* Packet receive function */ |
1450 | static int sh_eth_rx(struct net_device *ndev, u32 intr_status, int *quota) | 1462 | static int sh_eth_rx(struct net_device *ndev, u32 intr_status, int *quota) |
1451 | { | 1463 | { |
@@ -1690,7 +1702,7 @@ static void sh_eth_error(struct net_device *ndev, u32 intr_status) | |||
1690 | intr_status, mdp->cur_tx, mdp->dirty_tx, | 1702 | intr_status, mdp->cur_tx, mdp->dirty_tx, |
1691 | (u32)ndev->state, edtrr); | 1703 | (u32)ndev->state, edtrr); |
1692 | /* dirty buffer free */ | 1704 | /* dirty buffer free */ |
1693 | sh_eth_txfree(ndev); | 1705 | sh_eth_tx_free(ndev, true); |
1694 | 1706 | ||
1695 | /* SH7712 BUG */ | 1707 | /* SH7712 BUG */ |
1696 | if (edtrr ^ sh_eth_get_edtrr_trns(mdp)) { | 1708 | if (edtrr ^ sh_eth_get_edtrr_trns(mdp)) { |
@@ -1751,7 +1763,7 @@ static irqreturn_t sh_eth_interrupt(int irq, void *netdev) | |||
1751 | /* Clear Tx interrupts */ | 1763 | /* Clear Tx interrupts */ |
1752 | sh_eth_write(ndev, intr_status & cd->tx_check, EESR); | 1764 | sh_eth_write(ndev, intr_status & cd->tx_check, EESR); |
1753 | 1765 | ||
1754 | sh_eth_txfree(ndev); | 1766 | sh_eth_tx_free(ndev, true); |
1755 | netif_wake_queue(ndev); | 1767 | netif_wake_queue(ndev); |
1756 | } | 1768 | } |
1757 | 1769 | ||
@@ -2412,7 +2424,7 @@ static int sh_eth_start_xmit(struct sk_buff *skb, struct net_device *ndev) | |||
2412 | 2424 | ||
2413 | spin_lock_irqsave(&mdp->lock, flags); | 2425 | spin_lock_irqsave(&mdp->lock, flags); |
2414 | if ((mdp->cur_tx - mdp->dirty_tx) >= (mdp->num_tx_ring - 4)) { | 2426 | if ((mdp->cur_tx - mdp->dirty_tx) >= (mdp->num_tx_ring - 4)) { |
2415 | if (!sh_eth_txfree(ndev)) { | 2427 | if (!sh_eth_tx_free(ndev, true)) { |
2416 | netif_warn(mdp, tx_queued, ndev, "TxFD exhausted.\n"); | 2428 | netif_warn(mdp, tx_queued, ndev, "TxFD exhausted.\n"); |
2417 | netif_stop_queue(ndev); | 2429 | netif_stop_queue(ndev); |
2418 | spin_unlock_irqrestore(&mdp->lock, flags); | 2430 | spin_unlock_irqrestore(&mdp->lock, flags); |
diff --git a/drivers/net/ethernet/rocker/rocker_ofdpa.c b/drivers/net/ethernet/rocker/rocker_ofdpa.c index 7cd76b6b5cb9..2ae852454780 100644 --- a/drivers/net/ethernet/rocker/rocker_ofdpa.c +++ b/drivers/net/ethernet/rocker/rocker_ofdpa.c | |||
@@ -2216,18 +2216,15 @@ static int ofdpa_port_stp_update(struct ofdpa_port *ofdpa_port, | |||
2216 | { | 2216 | { |
2217 | bool want[OFDPA_CTRL_MAX] = { 0, }; | 2217 | bool want[OFDPA_CTRL_MAX] = { 0, }; |
2218 | bool prev_ctrls[OFDPA_CTRL_MAX]; | 2218 | bool prev_ctrls[OFDPA_CTRL_MAX]; |
2219 | u8 uninitialized_var(prev_state); | 2219 | u8 prev_state; |
2220 | int err; | 2220 | int err; |
2221 | int i; | 2221 | int i; |
2222 | 2222 | ||
2223 | if (switchdev_trans_ph_prepare(trans)) { | 2223 | prev_state = ofdpa_port->stp_state; |
2224 | memcpy(prev_ctrls, ofdpa_port->ctrls, sizeof(prev_ctrls)); | 2224 | if (prev_state == state) |
2225 | prev_state = ofdpa_port->stp_state; | ||
2226 | } | ||
2227 | |||
2228 | if (ofdpa_port->stp_state == state) | ||
2229 | return 0; | 2225 | return 0; |
2230 | 2226 | ||
2227 | memcpy(prev_ctrls, ofdpa_port->ctrls, sizeof(prev_ctrls)); | ||
2231 | ofdpa_port->stp_state = state; | 2228 | ofdpa_port->stp_state = state; |
2232 | 2229 | ||
2233 | switch (state) { | 2230 | switch (state) { |
diff --git a/drivers/net/ethernet/sfc/efx.c b/drivers/net/ethernet/sfc/efx.c index 50d28261b6b9..b9cb697b2818 100644 --- a/drivers/net/ethernet/sfc/efx.c +++ b/drivers/net/ethernet/sfc/efx.c | |||
@@ -1371,6 +1371,13 @@ static unsigned int efx_wanted_parallelism(struct efx_nic *efx) | |||
1371 | free_cpumask_var(thread_mask); | 1371 | free_cpumask_var(thread_mask); |
1372 | } | 1372 | } |
1373 | 1373 | ||
1374 | if (count > EFX_MAX_RX_QUEUES) { | ||
1375 | netif_cond_dbg(efx, probe, efx->net_dev, !rss_cpus, warn, | ||
1376 | "Reducing number of rx queues from %u to %u.\n", | ||
1377 | count, EFX_MAX_RX_QUEUES); | ||
1378 | count = EFX_MAX_RX_QUEUES; | ||
1379 | } | ||
1380 | |||
1374 | /* If RSS is requested for the PF *and* VFs then we can't write RSS | 1381 | /* If RSS is requested for the PF *and* VFs then we can't write RSS |
1375 | * table entries that are inaccessible to VFs | 1382 | * table entries that are inaccessible to VFs |
1376 | */ | 1383 | */ |
diff --git a/drivers/net/ethernet/sfc/falcon/efx.c b/drivers/net/ethernet/sfc/falcon/efx.c index f5e5cd1659a1..29614da91cbf 100644 --- a/drivers/net/ethernet/sfc/falcon/efx.c +++ b/drivers/net/ethernet/sfc/falcon/efx.c | |||
@@ -1354,6 +1354,13 @@ static unsigned int ef4_wanted_parallelism(struct ef4_nic *efx) | |||
1354 | free_cpumask_var(thread_mask); | 1354 | free_cpumask_var(thread_mask); |
1355 | } | 1355 | } |
1356 | 1356 | ||
1357 | if (count > EF4_MAX_RX_QUEUES) { | ||
1358 | netif_cond_dbg(efx, probe, efx->net_dev, !rss_cpus, warn, | ||
1359 | "Reducing number of rx queues from %u to %u.\n", | ||
1360 | count, EF4_MAX_RX_QUEUES); | ||
1361 | count = EF4_MAX_RX_QUEUES; | ||
1362 | } | ||
1363 | |||
1357 | return count; | 1364 | return count; |
1358 | } | 1365 | } |
1359 | 1366 | ||
diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c index 9f3d9c67e3fe..fa674a8bda0c 100644 --- a/drivers/net/ethernet/ti/cpsw.c +++ b/drivers/net/ethernet/ti/cpsw.c | |||
@@ -1267,6 +1267,7 @@ static void soft_reset_slave(struct cpsw_slave *slave) | |||
1267 | static void cpsw_slave_open(struct cpsw_slave *slave, struct cpsw_priv *priv) | 1267 | static void cpsw_slave_open(struct cpsw_slave *slave, struct cpsw_priv *priv) |
1268 | { | 1268 | { |
1269 | u32 slave_port; | 1269 | u32 slave_port; |
1270 | struct phy_device *phy; | ||
1270 | struct cpsw_common *cpsw = priv->cpsw; | 1271 | struct cpsw_common *cpsw = priv->cpsw; |
1271 | 1272 | ||
1272 | soft_reset_slave(slave); | 1273 | soft_reset_slave(slave); |
@@ -1300,27 +1301,28 @@ static void cpsw_slave_open(struct cpsw_slave *slave, struct cpsw_priv *priv) | |||
1300 | 1 << slave_port, 0, 0, ALE_MCAST_FWD_2); | 1301 | 1 << slave_port, 0, 0, ALE_MCAST_FWD_2); |
1301 | 1302 | ||
1302 | if (slave->data->phy_node) { | 1303 | if (slave->data->phy_node) { |
1303 | slave->phy = of_phy_connect(priv->ndev, slave->data->phy_node, | 1304 | phy = of_phy_connect(priv->ndev, slave->data->phy_node, |
1304 | &cpsw_adjust_link, 0, slave->data->phy_if); | 1305 | &cpsw_adjust_link, 0, slave->data->phy_if); |
1305 | if (!slave->phy) { | 1306 | if (!phy) { |
1306 | dev_err(priv->dev, "phy \"%s\" not found on slave %d\n", | 1307 | dev_err(priv->dev, "phy \"%s\" not found on slave %d\n", |
1307 | slave->data->phy_node->full_name, | 1308 | slave->data->phy_node->full_name, |
1308 | slave->slave_num); | 1309 | slave->slave_num); |
1309 | return; | 1310 | return; |
1310 | } | 1311 | } |
1311 | } else { | 1312 | } else { |
1312 | slave->phy = phy_connect(priv->ndev, slave->data->phy_id, | 1313 | phy = phy_connect(priv->ndev, slave->data->phy_id, |
1313 | &cpsw_adjust_link, slave->data->phy_if); | 1314 | &cpsw_adjust_link, slave->data->phy_if); |
1314 | if (IS_ERR(slave->phy)) { | 1315 | if (IS_ERR(phy)) { |
1315 | dev_err(priv->dev, | 1316 | dev_err(priv->dev, |
1316 | "phy \"%s\" not found on slave %d, err %ld\n", | 1317 | "phy \"%s\" not found on slave %d, err %ld\n", |
1317 | slave->data->phy_id, slave->slave_num, | 1318 | slave->data->phy_id, slave->slave_num, |
1318 | PTR_ERR(slave->phy)); | 1319 | PTR_ERR(phy)); |
1319 | slave->phy = NULL; | ||
1320 | return; | 1320 | return; |
1321 | } | 1321 | } |
1322 | } | 1322 | } |
1323 | 1323 | ||
1324 | slave->phy = phy; | ||
1325 | |||
1324 | phy_attached_info(slave->phy); | 1326 | phy_attached_info(slave->phy); |
1325 | 1327 | ||
1326 | phy_start(slave->phy); | 1328 | phy_start(slave->phy); |
@@ -1817,6 +1819,8 @@ static void cpsw_ndo_tx_timeout(struct net_device *ndev) | |||
1817 | } | 1819 | } |
1818 | 1820 | ||
1819 | cpsw_intr_enable(cpsw); | 1821 | cpsw_intr_enable(cpsw); |
1822 | netif_trans_update(ndev); | ||
1823 | netif_tx_wake_all_queues(ndev); | ||
1820 | } | 1824 | } |
1821 | 1825 | ||
1822 | static int cpsw_ndo_set_mac_address(struct net_device *ndev, void *p) | 1826 | static int cpsw_ndo_set_mac_address(struct net_device *ndev, void *p) |
diff --git a/drivers/net/irda/vlsi_ir.c b/drivers/net/irda/vlsi_ir.c index ffedad2a360a..15b920086251 100644 --- a/drivers/net/irda/vlsi_ir.c +++ b/drivers/net/irda/vlsi_ir.c | |||
@@ -418,8 +418,9 @@ static struct vlsi_ring *vlsi_alloc_ring(struct pci_dev *pdev, struct ring_descr | |||
418 | memset(rd, 0, sizeof(*rd)); | 418 | memset(rd, 0, sizeof(*rd)); |
419 | rd->hw = hwmap + i; | 419 | rd->hw = hwmap + i; |
420 | rd->buf = kmalloc(len, GFP_KERNEL|GFP_DMA); | 420 | rd->buf = kmalloc(len, GFP_KERNEL|GFP_DMA); |
421 | if (rd->buf == NULL || | 421 | if (rd->buf) |
422 | !(busaddr = pci_map_single(pdev, rd->buf, len, dir))) { | 422 | busaddr = pci_map_single(pdev, rd->buf, len, dir); |
423 | if (rd->buf == NULL || pci_dma_mapping_error(pdev, busaddr)) { | ||
423 | if (rd->buf) { | 424 | if (rd->buf) { |
424 | net_err_ratelimited("%s: failed to create PCI-MAP for %p\n", | 425 | net_err_ratelimited("%s: failed to create PCI-MAP for %p\n", |
425 | __func__, rd->buf); | 426 | __func__, rd->buf); |
@@ -430,8 +431,7 @@ static struct vlsi_ring *vlsi_alloc_ring(struct pci_dev *pdev, struct ring_descr | |||
430 | rd = r->rd + j; | 431 | rd = r->rd + j; |
431 | busaddr = rd_get_addr(rd); | 432 | busaddr = rd_get_addr(rd); |
432 | rd_set_addr_status(rd, 0, 0); | 433 | rd_set_addr_status(rd, 0, 0); |
433 | if (busaddr) | 434 | pci_unmap_single(pdev, busaddr, len, dir); |
434 | pci_unmap_single(pdev, busaddr, len, dir); | ||
435 | kfree(rd->buf); | 435 | kfree(rd->buf); |
436 | rd->buf = NULL; | 436 | rd->buf = NULL; |
437 | } | 437 | } |
diff --git a/drivers/net/phy/dp83640.c b/drivers/net/phy/dp83640.c index e2460a57e4b1..ed0d10f54f26 100644 --- a/drivers/net/phy/dp83640.c +++ b/drivers/net/phy/dp83640.c | |||
@@ -1438,8 +1438,6 @@ static bool dp83640_rxtstamp(struct phy_device *phydev, | |||
1438 | skb_info->tmo = jiffies + SKB_TIMESTAMP_TIMEOUT; | 1438 | skb_info->tmo = jiffies + SKB_TIMESTAMP_TIMEOUT; |
1439 | skb_queue_tail(&dp83640->rx_queue, skb); | 1439 | skb_queue_tail(&dp83640->rx_queue, skb); |
1440 | schedule_delayed_work(&dp83640->ts_work, SKB_TIMESTAMP_TIMEOUT); | 1440 | schedule_delayed_work(&dp83640->ts_work, SKB_TIMESTAMP_TIMEOUT); |
1441 | } else { | ||
1442 | netif_rx_ni(skb); | ||
1443 | } | 1441 | } |
1444 | 1442 | ||
1445 | return true; | 1443 | return true; |
diff --git a/drivers/net/phy/mdio-boardinfo.c b/drivers/net/phy/mdio-boardinfo.c index 6b988f77da08..61941e29daae 100644 --- a/drivers/net/phy/mdio-boardinfo.c +++ b/drivers/net/phy/mdio-boardinfo.c | |||
@@ -84,3 +84,4 @@ int mdiobus_register_board_info(const struct mdio_board_info *info, | |||
84 | 84 | ||
85 | return 0; | 85 | return 0; |
86 | } | 86 | } |
87 | EXPORT_SYMBOL(mdiobus_register_board_info); | ||
diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c index 6742070ca676..1326d99771c1 100644 --- a/drivers/net/phy/micrel.c +++ b/drivers/net/phy/micrel.c | |||
@@ -798,9 +798,6 @@ static struct phy_driver ksphy_driver[] = { | |||
798 | .read_status = genphy_read_status, | 798 | .read_status = genphy_read_status, |
799 | .ack_interrupt = kszphy_ack_interrupt, | 799 | .ack_interrupt = kszphy_ack_interrupt, |
800 | .config_intr = kszphy_config_intr, | 800 | .config_intr = kszphy_config_intr, |
801 | .get_sset_count = kszphy_get_sset_count, | ||
802 | .get_strings = kszphy_get_strings, | ||
803 | .get_stats = kszphy_get_stats, | ||
804 | .suspend = genphy_suspend, | 801 | .suspend = genphy_suspend, |
805 | .resume = genphy_resume, | 802 | .resume = genphy_resume, |
806 | }, { | 803 | }, { |
@@ -940,9 +937,6 @@ static struct phy_driver ksphy_driver[] = { | |||
940 | .read_status = genphy_read_status, | 937 | .read_status = genphy_read_status, |
941 | .ack_interrupt = kszphy_ack_interrupt, | 938 | .ack_interrupt = kszphy_ack_interrupt, |
942 | .config_intr = kszphy_config_intr, | 939 | .config_intr = kszphy_config_intr, |
943 | .get_sset_count = kszphy_get_sset_count, | ||
944 | .get_strings = kszphy_get_strings, | ||
945 | .get_stats = kszphy_get_stats, | ||
946 | .suspend = genphy_suspend, | 940 | .suspend = genphy_suspend, |
947 | .resume = genphy_resume, | 941 | .resume = genphy_resume, |
948 | }, { | 942 | }, { |
@@ -952,6 +946,7 @@ static struct phy_driver ksphy_driver[] = { | |||
952 | .features = PHY_GBIT_FEATURES, | 946 | .features = PHY_GBIT_FEATURES, |
953 | .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT, | 947 | .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT, |
954 | .driver_data = &ksz9021_type, | 948 | .driver_data = &ksz9021_type, |
949 | .probe = kszphy_probe, | ||
955 | .config_init = ksz9021_config_init, | 950 | .config_init = ksz9021_config_init, |
956 | .config_aneg = genphy_config_aneg, | 951 | .config_aneg = genphy_config_aneg, |
957 | .read_status = genphy_read_status, | 952 | .read_status = genphy_read_status, |
@@ -971,6 +966,7 @@ static struct phy_driver ksphy_driver[] = { | |||
971 | .features = PHY_GBIT_FEATURES, | 966 | .features = PHY_GBIT_FEATURES, |
972 | .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT, | 967 | .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT, |
973 | .driver_data = &ksz9021_type, | 968 | .driver_data = &ksz9021_type, |
969 | .probe = kszphy_probe, | ||
974 | .config_init = ksz9031_config_init, | 970 | .config_init = ksz9031_config_init, |
975 | .config_aneg = genphy_config_aneg, | 971 | .config_aneg = genphy_config_aneg, |
976 | .read_status = ksz9031_read_status, | 972 | .read_status = ksz9031_read_status, |
@@ -989,9 +985,6 @@ static struct phy_driver ksphy_driver[] = { | |||
989 | .config_init = kszphy_config_init, | 985 | .config_init = kszphy_config_init, |
990 | .config_aneg = ksz8873mll_config_aneg, | 986 | .config_aneg = ksz8873mll_config_aneg, |
991 | .read_status = ksz8873mll_read_status, | 987 | .read_status = ksz8873mll_read_status, |
992 | .get_sset_count = kszphy_get_sset_count, | ||
993 | .get_strings = kszphy_get_strings, | ||
994 | .get_stats = kszphy_get_stats, | ||
995 | .suspend = genphy_suspend, | 988 | .suspend = genphy_suspend, |
996 | .resume = genphy_resume, | 989 | .resume = genphy_resume, |
997 | }, { | 990 | }, { |
@@ -1003,9 +996,6 @@ static struct phy_driver ksphy_driver[] = { | |||
1003 | .config_init = kszphy_config_init, | 996 | .config_init = kszphy_config_init, |
1004 | .config_aneg = genphy_config_aneg, | 997 | .config_aneg = genphy_config_aneg, |
1005 | .read_status = genphy_read_status, | 998 | .read_status = genphy_read_status, |
1006 | .get_sset_count = kszphy_get_sset_count, | ||
1007 | .get_strings = kszphy_get_strings, | ||
1008 | .get_stats = kszphy_get_stats, | ||
1009 | .suspend = genphy_suspend, | 999 | .suspend = genphy_suspend, |
1010 | .resume = genphy_resume, | 1000 | .resume = genphy_resume, |
1011 | }, { | 1001 | }, { |
@@ -1017,9 +1007,6 @@ static struct phy_driver ksphy_driver[] = { | |||
1017 | .config_init = kszphy_config_init, | 1007 | .config_init = kszphy_config_init, |
1018 | .config_aneg = ksz8873mll_config_aneg, | 1008 | .config_aneg = ksz8873mll_config_aneg, |
1019 | .read_status = ksz8873mll_read_status, | 1009 | .read_status = ksz8873mll_read_status, |
1020 | .get_sset_count = kszphy_get_sset_count, | ||
1021 | .get_strings = kszphy_get_strings, | ||
1022 | .get_stats = kszphy_get_stats, | ||
1023 | .suspend = genphy_suspend, | 1010 | .suspend = genphy_suspend, |
1024 | .resume = genphy_resume, | 1011 | .resume = genphy_resume, |
1025 | } }; | 1012 | } }; |
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index 1be69d8bc909..a2bfc82e95d7 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c | |||
@@ -681,7 +681,7 @@ void phy_stop_machine(struct phy_device *phydev) | |||
681 | cancel_delayed_work_sync(&phydev->state_queue); | 681 | cancel_delayed_work_sync(&phydev->state_queue); |
682 | 682 | ||
683 | mutex_lock(&phydev->lock); | 683 | mutex_lock(&phydev->lock); |
684 | if (phydev->state > PHY_UP) | 684 | if (phydev->state > PHY_UP && phydev->state != PHY_HALTED) |
685 | phydev->state = PHY_UP; | 685 | phydev->state = PHY_UP; |
686 | mutex_unlock(&phydev->lock); | 686 | mutex_unlock(&phydev->lock); |
687 | } | 687 | } |
diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c index 1b52520715ae..f8c81f12d988 100644 --- a/drivers/net/team/team.c +++ b/drivers/net/team/team.c | |||
@@ -990,7 +990,7 @@ static void team_port_disable(struct team *team, | |||
990 | #define TEAM_ENC_FEATURES (NETIF_F_HW_CSUM | NETIF_F_SG | \ | 990 | #define TEAM_ENC_FEATURES (NETIF_F_HW_CSUM | NETIF_F_SG | \ |
991 | NETIF_F_RXCSUM | NETIF_F_ALL_TSO) | 991 | NETIF_F_RXCSUM | NETIF_F_ALL_TSO) |
992 | 992 | ||
993 | static void ___team_compute_features(struct team *team) | 993 | static void __team_compute_features(struct team *team) |
994 | { | 994 | { |
995 | struct team_port *port; | 995 | struct team_port *port; |
996 | u32 vlan_features = TEAM_VLAN_FEATURES & NETIF_F_ALL_FOR_ALL; | 996 | u32 vlan_features = TEAM_VLAN_FEATURES & NETIF_F_ALL_FOR_ALL; |
@@ -1023,16 +1023,10 @@ static void ___team_compute_features(struct team *team) | |||
1023 | team->dev->priv_flags |= IFF_XMIT_DST_RELEASE; | 1023 | team->dev->priv_flags |= IFF_XMIT_DST_RELEASE; |
1024 | } | 1024 | } |
1025 | 1025 | ||
1026 | static void __team_compute_features(struct team *team) | ||
1027 | { | ||
1028 | ___team_compute_features(team); | ||
1029 | netdev_change_features(team->dev); | ||
1030 | } | ||
1031 | |||
1032 | static void team_compute_features(struct team *team) | 1026 | static void team_compute_features(struct team *team) |
1033 | { | 1027 | { |
1034 | mutex_lock(&team->lock); | 1028 | mutex_lock(&team->lock); |
1035 | ___team_compute_features(team); | 1029 | __team_compute_features(team); |
1036 | mutex_unlock(&team->lock); | 1030 | mutex_unlock(&team->lock); |
1037 | netdev_change_features(team->dev); | 1031 | netdev_change_features(team->dev); |
1038 | } | 1032 | } |
@@ -1641,6 +1635,7 @@ static void team_uninit(struct net_device *dev) | |||
1641 | team_notify_peers_fini(team); | 1635 | team_notify_peers_fini(team); |
1642 | team_queue_override_fini(team); | 1636 | team_queue_override_fini(team); |
1643 | mutex_unlock(&team->lock); | 1637 | mutex_unlock(&team->lock); |
1638 | netdev_change_features(dev); | ||
1644 | } | 1639 | } |
1645 | 1640 | ||
1646 | static void team_destructor(struct net_device *dev) | 1641 | static void team_destructor(struct net_device *dev) |
@@ -1928,6 +1923,10 @@ static int team_add_slave(struct net_device *dev, struct net_device *port_dev) | |||
1928 | mutex_lock(&team->lock); | 1923 | mutex_lock(&team->lock); |
1929 | err = team_port_add(team, port_dev); | 1924 | err = team_port_add(team, port_dev); |
1930 | mutex_unlock(&team->lock); | 1925 | mutex_unlock(&team->lock); |
1926 | |||
1927 | if (!err) | ||
1928 | netdev_change_features(dev); | ||
1929 | |||
1931 | return err; | 1930 | return err; |
1932 | } | 1931 | } |
1933 | 1932 | ||
@@ -1939,6 +1938,10 @@ static int team_del_slave(struct net_device *dev, struct net_device *port_dev) | |||
1939 | mutex_lock(&team->lock); | 1938 | mutex_lock(&team->lock); |
1940 | err = team_port_del(team, port_dev); | 1939 | err = team_port_del(team, port_dev); |
1941 | mutex_unlock(&team->lock); | 1940 | mutex_unlock(&team->lock); |
1941 | |||
1942 | if (!err) | ||
1943 | netdev_change_features(dev); | ||
1944 | |||
1942 | return err; | 1945 | return err; |
1943 | } | 1946 | } |
1944 | 1947 | ||
diff --git a/drivers/net/usb/cdc_ether.c b/drivers/net/usb/cdc_ether.c index f5552aaaa77a..f3ae88fdf332 100644 --- a/drivers/net/usb/cdc_ether.c +++ b/drivers/net/usb/cdc_ether.c | |||
@@ -532,6 +532,7 @@ static const struct driver_info wwan_info = { | |||
532 | #define LENOVO_VENDOR_ID 0x17ef | 532 | #define LENOVO_VENDOR_ID 0x17ef |
533 | #define NVIDIA_VENDOR_ID 0x0955 | 533 | #define NVIDIA_VENDOR_ID 0x0955 |
534 | #define HP_VENDOR_ID 0x03f0 | 534 | #define HP_VENDOR_ID 0x03f0 |
535 | #define MICROSOFT_VENDOR_ID 0x045e | ||
535 | 536 | ||
536 | static const struct usb_device_id products[] = { | 537 | static const struct usb_device_id products[] = { |
537 | /* BLACKLIST !! | 538 | /* BLACKLIST !! |
@@ -761,6 +762,20 @@ static const struct usb_device_id products[] = { | |||
761 | .driver_info = 0, | 762 | .driver_info = 0, |
762 | }, | 763 | }, |
763 | 764 | ||
765 | /* Microsoft Surface 2 dock (based on Realtek RTL8152) */ | ||
766 | { | ||
767 | USB_DEVICE_AND_INTERFACE_INFO(MICROSOFT_VENDOR_ID, 0x07ab, USB_CLASS_COMM, | ||
768 | USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE), | ||
769 | .driver_info = 0, | ||
770 | }, | ||
771 | |||
772 | /* Microsoft Surface 3 dock (based on Realtek RTL8153) */ | ||
773 | { | ||
774 | USB_DEVICE_AND_INTERFACE_INFO(MICROSOFT_VENDOR_ID, 0x07c6, USB_CLASS_COMM, | ||
775 | USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE), | ||
776 | .driver_info = 0, | ||
777 | }, | ||
778 | |||
764 | /* WHITELIST!!! | 779 | /* WHITELIST!!! |
765 | * | 780 | * |
766 | * CDC Ether uses two interfaces, not necessarily consecutive. | 781 | * CDC Ether uses two interfaces, not necessarily consecutive. |
diff --git a/drivers/net/usb/ch9200.c b/drivers/net/usb/ch9200.c index 8a40202c0a17..c4f1c363e24b 100644 --- a/drivers/net/usb/ch9200.c +++ b/drivers/net/usb/ch9200.c | |||
@@ -254,14 +254,9 @@ static struct sk_buff *ch9200_tx_fixup(struct usbnet *dev, struct sk_buff *skb, | |||
254 | tx_overhead = 0x40; | 254 | tx_overhead = 0x40; |
255 | 255 | ||
256 | len = skb->len; | 256 | len = skb->len; |
257 | if (skb_headroom(skb) < tx_overhead) { | 257 | if (skb_cow_head(skb, tx_overhead)) { |
258 | struct sk_buff *skb2; | ||
259 | |||
260 | skb2 = skb_copy_expand(skb, tx_overhead, 0, flags); | ||
261 | dev_kfree_skb_any(skb); | 258 | dev_kfree_skb_any(skb); |
262 | skb = skb2; | 259 | return NULL; |
263 | if (!skb) | ||
264 | return NULL; | ||
265 | } | 260 | } |
266 | 261 | ||
267 | __skb_push(skb, tx_overhead); | 262 | __skb_push(skb, tx_overhead); |
diff --git a/drivers/net/usb/cx82310_eth.c b/drivers/net/usb/cx82310_eth.c index e221bfcee76b..947bea81d924 100644 --- a/drivers/net/usb/cx82310_eth.c +++ b/drivers/net/usb/cx82310_eth.c | |||
@@ -293,12 +293,9 @@ static struct sk_buff *cx82310_tx_fixup(struct usbnet *dev, struct sk_buff *skb, | |||
293 | { | 293 | { |
294 | int len = skb->len; | 294 | int len = skb->len; |
295 | 295 | ||
296 | if (skb_headroom(skb) < 2) { | 296 | if (skb_cow_head(skb, 2)) { |
297 | struct sk_buff *skb2 = skb_copy_expand(skb, 2, 0, flags); | ||
298 | dev_kfree_skb_any(skb); | 297 | dev_kfree_skb_any(skb); |
299 | skb = skb2; | 298 | return NULL; |
300 | if (!skb) | ||
301 | return NULL; | ||
302 | } | 299 | } |
303 | skb_push(skb, 2); | 300 | skb_push(skb, 2); |
304 | 301 | ||
diff --git a/drivers/net/usb/kaweth.c b/drivers/net/usb/kaweth.c index 876f02f4945e..2a2c3edb6bad 100644 --- a/drivers/net/usb/kaweth.c +++ b/drivers/net/usb/kaweth.c | |||
@@ -803,18 +803,12 @@ static netdev_tx_t kaweth_start_xmit(struct sk_buff *skb, | |||
803 | } | 803 | } |
804 | 804 | ||
805 | /* We now decide whether we can put our special header into the sk_buff */ | 805 | /* We now decide whether we can put our special header into the sk_buff */ |
806 | if (skb_cloned(skb) || skb_headroom(skb) < 2) { | 806 | if (skb_cow_head(skb, 2)) { |
807 | /* no such luck - we make our own */ | 807 | kaweth->stats.tx_errors++; |
808 | struct sk_buff *copied_skb; | 808 | netif_start_queue(net); |
809 | copied_skb = skb_copy_expand(skb, 2, 0, GFP_ATOMIC); | 809 | spin_unlock_irq(&kaweth->device_lock); |
810 | dev_kfree_skb_irq(skb); | 810 | dev_kfree_skb_any(skb); |
811 | skb = copied_skb; | 811 | return NETDEV_TX_OK; |
812 | if (!copied_skb) { | ||
813 | kaweth->stats.tx_errors++; | ||
814 | netif_start_queue(net); | ||
815 | spin_unlock_irq(&kaweth->device_lock); | ||
816 | return NETDEV_TX_OK; | ||
817 | } | ||
818 | } | 812 | } |
819 | 813 | ||
820 | private_header = (__le16 *)__skb_push(skb, 2); | 814 | private_header = (__le16 *)__skb_push(skb, 2); |
diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c index 9889a70ff4f6..636f48f19d1e 100644 --- a/drivers/net/usb/lan78xx.c +++ b/drivers/net/usb/lan78xx.c | |||
@@ -2607,14 +2607,9 @@ static struct sk_buff *lan78xx_tx_prep(struct lan78xx_net *dev, | |||
2607 | { | 2607 | { |
2608 | u32 tx_cmd_a, tx_cmd_b; | 2608 | u32 tx_cmd_a, tx_cmd_b; |
2609 | 2609 | ||
2610 | if (skb_headroom(skb) < TX_OVERHEAD) { | 2610 | if (skb_cow_head(skb, TX_OVERHEAD)) { |
2611 | struct sk_buff *skb2; | ||
2612 | |||
2613 | skb2 = skb_copy_expand(skb, TX_OVERHEAD, 0, flags); | ||
2614 | dev_kfree_skb_any(skb); | 2611 | dev_kfree_skb_any(skb); |
2615 | skb = skb2; | 2612 | return NULL; |
2616 | if (!skb) | ||
2617 | return NULL; | ||
2618 | } | 2613 | } |
2619 | 2614 | ||
2620 | if (lan78xx_linearize(skb) < 0) | 2615 | if (lan78xx_linearize(skb) < 0) |
diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c index 156f7f85e486..2474618404f5 100644 --- a/drivers/net/usb/qmi_wwan.c +++ b/drivers/net/usb/qmi_wwan.c | |||
@@ -908,7 +908,7 @@ static const struct usb_device_id products[] = { | |||
908 | {QMI_FIXED_INTF(0x2357, 0x9000, 4)}, /* TP-LINK MA260 */ | 908 | {QMI_FIXED_INTF(0x2357, 0x9000, 4)}, /* TP-LINK MA260 */ |
909 | {QMI_QUIRK_SET_DTR(0x1bc7, 0x1040, 2)}, /* Telit LE922A */ | 909 | {QMI_QUIRK_SET_DTR(0x1bc7, 0x1040, 2)}, /* Telit LE922A */ |
910 | {QMI_FIXED_INTF(0x1bc7, 0x1200, 5)}, /* Telit LE920 */ | 910 | {QMI_FIXED_INTF(0x1bc7, 0x1200, 5)}, /* Telit LE920 */ |
911 | {QMI_FIXED_INTF(0x1bc7, 0x1201, 2)}, /* Telit LE920 */ | 911 | {QMI_QUIRK_SET_DTR(0x1bc7, 0x1201, 2)}, /* Telit LE920, LE920A4 */ |
912 | {QMI_FIXED_INTF(0x1c9e, 0x9b01, 3)}, /* XS Stick W100-2 from 4G Systems */ | 912 | {QMI_FIXED_INTF(0x1c9e, 0x9b01, 3)}, /* XS Stick W100-2 from 4G Systems */ |
913 | {QMI_FIXED_INTF(0x0b3c, 0xc000, 4)}, /* Olivetti Olicard 100 */ | 913 | {QMI_FIXED_INTF(0x0b3c, 0xc000, 4)}, /* Olivetti Olicard 100 */ |
914 | {QMI_FIXED_INTF(0x0b3c, 0xc001, 4)}, /* Olivetti Olicard 120 */ | 914 | {QMI_FIXED_INTF(0x0b3c, 0xc001, 4)}, /* Olivetti Olicard 120 */ |
diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c index 0b1b9188625d..07f788c49d57 100644 --- a/drivers/net/usb/r8152.c +++ b/drivers/net/usb/r8152.c | |||
@@ -517,6 +517,7 @@ enum rtl8152_flags { | |||
517 | 517 | ||
518 | /* Define these values to match your device */ | 518 | /* Define these values to match your device */ |
519 | #define VENDOR_ID_REALTEK 0x0bda | 519 | #define VENDOR_ID_REALTEK 0x0bda |
520 | #define VENDOR_ID_MICROSOFT 0x045e | ||
520 | #define VENDOR_ID_SAMSUNG 0x04e8 | 521 | #define VENDOR_ID_SAMSUNG 0x04e8 |
521 | #define VENDOR_ID_LENOVO 0x17ef | 522 | #define VENDOR_ID_LENOVO 0x17ef |
522 | #define VENDOR_ID_NVIDIA 0x0955 | 523 | #define VENDOR_ID_NVIDIA 0x0955 |
@@ -1294,6 +1295,7 @@ static void intr_callback(struct urb *urb) | |||
1294 | } | 1295 | } |
1295 | } else { | 1296 | } else { |
1296 | if (netif_carrier_ok(tp->netdev)) { | 1297 | if (netif_carrier_ok(tp->netdev)) { |
1298 | netif_stop_queue(tp->netdev); | ||
1297 | set_bit(RTL8152_LINK_CHG, &tp->flags); | 1299 | set_bit(RTL8152_LINK_CHG, &tp->flags); |
1298 | schedule_delayed_work(&tp->schedule, 0); | 1300 | schedule_delayed_work(&tp->schedule, 0); |
1299 | } | 1301 | } |
@@ -3169,6 +3171,9 @@ static void set_carrier(struct r8152 *tp) | |||
3169 | napi_enable(&tp->napi); | 3171 | napi_enable(&tp->napi); |
3170 | netif_wake_queue(netdev); | 3172 | netif_wake_queue(netdev); |
3171 | netif_info(tp, link, netdev, "carrier on\n"); | 3173 | netif_info(tp, link, netdev, "carrier on\n"); |
3174 | } else if (netif_queue_stopped(netdev) && | ||
3175 | skb_queue_len(&tp->tx_queue) < tp->tx_qlen) { | ||
3176 | netif_wake_queue(netdev); | ||
3172 | } | 3177 | } |
3173 | } else { | 3178 | } else { |
3174 | if (netif_carrier_ok(netdev)) { | 3179 | if (netif_carrier_ok(netdev)) { |
@@ -3702,8 +3707,18 @@ static int rtl8152_resume(struct usb_interface *intf) | |||
3702 | tp->rtl_ops.autosuspend_en(tp, false); | 3707 | tp->rtl_ops.autosuspend_en(tp, false); |
3703 | napi_disable(&tp->napi); | 3708 | napi_disable(&tp->napi); |
3704 | set_bit(WORK_ENABLE, &tp->flags); | 3709 | set_bit(WORK_ENABLE, &tp->flags); |
3705 | if (netif_carrier_ok(tp->netdev)) | 3710 | |
3706 | rtl_start_rx(tp); | 3711 | if (netif_carrier_ok(tp->netdev)) { |
3712 | if (rtl8152_get_speed(tp) & LINK_STATUS) { | ||
3713 | rtl_start_rx(tp); | ||
3714 | } else { | ||
3715 | netif_carrier_off(tp->netdev); | ||
3716 | tp->rtl_ops.disable(tp); | ||
3717 | netif_info(tp, link, tp->netdev, | ||
3718 | "linking down\n"); | ||
3719 | } | ||
3720 | } | ||
3721 | |||
3707 | napi_enable(&tp->napi); | 3722 | napi_enable(&tp->napi); |
3708 | clear_bit(SELECTIVE_SUSPEND, &tp->flags); | 3723 | clear_bit(SELECTIVE_SUSPEND, &tp->flags); |
3709 | smp_mb__after_atomic(); | 3724 | smp_mb__after_atomic(); |
@@ -4507,6 +4522,8 @@ static void rtl8152_disconnect(struct usb_interface *intf) | |||
4507 | static struct usb_device_id rtl8152_table[] = { | 4522 | static struct usb_device_id rtl8152_table[] = { |
4508 | {REALTEK_USB_DEVICE(VENDOR_ID_REALTEK, 0x8152)}, | 4523 | {REALTEK_USB_DEVICE(VENDOR_ID_REALTEK, 0x8152)}, |
4509 | {REALTEK_USB_DEVICE(VENDOR_ID_REALTEK, 0x8153)}, | 4524 | {REALTEK_USB_DEVICE(VENDOR_ID_REALTEK, 0x8153)}, |
4525 | {REALTEK_USB_DEVICE(VENDOR_ID_MICROSOFT, 0x07ab)}, | ||
4526 | {REALTEK_USB_DEVICE(VENDOR_ID_MICROSOFT, 0x07c6)}, | ||
4510 | {REALTEK_USB_DEVICE(VENDOR_ID_SAMSUNG, 0xa101)}, | 4527 | {REALTEK_USB_DEVICE(VENDOR_ID_SAMSUNG, 0xa101)}, |
4511 | {REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x304f)}, | 4528 | {REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x304f)}, |
4512 | {REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x3062)}, | 4529 | {REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x3062)}, |
diff --git a/drivers/net/usb/smsc75xx.c b/drivers/net/usb/smsc75xx.c index 0b17b40d7a4f..190de9a90f73 100644 --- a/drivers/net/usb/smsc75xx.c +++ b/drivers/net/usb/smsc75xx.c | |||
@@ -2203,13 +2203,9 @@ static struct sk_buff *smsc75xx_tx_fixup(struct usbnet *dev, | |||
2203 | { | 2203 | { |
2204 | u32 tx_cmd_a, tx_cmd_b; | 2204 | u32 tx_cmd_a, tx_cmd_b; |
2205 | 2205 | ||
2206 | if (skb_headroom(skb) < SMSC75XX_TX_OVERHEAD) { | 2206 | if (skb_cow_head(skb, SMSC75XX_TX_OVERHEAD)) { |
2207 | struct sk_buff *skb2 = | ||
2208 | skb_copy_expand(skb, SMSC75XX_TX_OVERHEAD, 0, flags); | ||
2209 | dev_kfree_skb_any(skb); | 2207 | dev_kfree_skb_any(skb); |
2210 | skb = skb2; | 2208 | return NULL; |
2211 | if (!skb) | ||
2212 | return NULL; | ||
2213 | } | 2209 | } |
2214 | 2210 | ||
2215 | tx_cmd_a = (u32)(skb->len & TX_CMD_A_LEN) | TX_CMD_A_FCS; | 2211 | tx_cmd_a = (u32)(skb->len & TX_CMD_A_LEN) | TX_CMD_A_FCS; |
diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c index 831aa33d078a..5f19fb0f025d 100644 --- a/drivers/net/usb/smsc95xx.c +++ b/drivers/net/usb/smsc95xx.c | |||
@@ -2001,13 +2001,13 @@ static struct sk_buff *smsc95xx_tx_fixup(struct usbnet *dev, | |||
2001 | /* We do not advertise SG, so skbs should be already linearized */ | 2001 | /* We do not advertise SG, so skbs should be already linearized */ |
2002 | BUG_ON(skb_shinfo(skb)->nr_frags); | 2002 | BUG_ON(skb_shinfo(skb)->nr_frags); |
2003 | 2003 | ||
2004 | if (skb_headroom(skb) < overhead) { | 2004 | /* Make writable and expand header space by overhead if required */ |
2005 | struct sk_buff *skb2 = skb_copy_expand(skb, | 2005 | if (skb_cow_head(skb, overhead)) { |
2006 | overhead, 0, flags); | 2006 | /* Must deallocate here as returning NULL to indicate error |
2007 | * means the skb won't be deallocated in the caller. | ||
2008 | */ | ||
2007 | dev_kfree_skb_any(skb); | 2009 | dev_kfree_skb_any(skb); |
2008 | skb = skb2; | 2010 | return NULL; |
2009 | if (!skb) | ||
2010 | return NULL; | ||
2011 | } | 2011 | } |
2012 | 2012 | ||
2013 | if (csum) { | 2013 | if (csum) { |
diff --git a/drivers/net/usb/sr9700.c b/drivers/net/usb/sr9700.c index 4a1e9c489f1f..aadfe1d1c37e 100644 --- a/drivers/net/usb/sr9700.c +++ b/drivers/net/usb/sr9700.c | |||
@@ -456,14 +456,9 @@ static struct sk_buff *sr9700_tx_fixup(struct usbnet *dev, struct sk_buff *skb, | |||
456 | 456 | ||
457 | len = skb->len; | 457 | len = skb->len; |
458 | 458 | ||
459 | if (skb_headroom(skb) < SR_TX_OVERHEAD) { | 459 | if (skb_cow_head(skb, SR_TX_OVERHEAD)) { |
460 | struct sk_buff *skb2; | ||
461 | |||
462 | skb2 = skb_copy_expand(skb, SR_TX_OVERHEAD, 0, flags); | ||
463 | dev_kfree_skb_any(skb); | 460 | dev_kfree_skb_any(skb); |
464 | skb = skb2; | 461 | return NULL; |
465 | if (!skb) | ||
466 | return NULL; | ||
467 | } | 462 | } |
468 | 463 | ||
469 | __skb_push(skb, SR_TX_OVERHEAD); | 464 | __skb_push(skb, SR_TX_OVERHEAD); |
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c index 3de65ea6531a..453244805c52 100644 --- a/drivers/net/usb/usbnet.c +++ b/drivers/net/usb/usbnet.c | |||
@@ -1929,7 +1929,7 @@ static int __usbnet_read_cmd(struct usbnet *dev, u8 cmd, u8 reqtype, | |||
1929 | " value=0x%04x index=0x%04x size=%d\n", | 1929 | " value=0x%04x index=0x%04x size=%d\n", |
1930 | cmd, reqtype, value, index, size); | 1930 | cmd, reqtype, value, index, size); |
1931 | 1931 | ||
1932 | if (data) { | 1932 | if (size) { |
1933 | buf = kmalloc(size, GFP_KERNEL); | 1933 | buf = kmalloc(size, GFP_KERNEL); |
1934 | if (!buf) | 1934 | if (!buf) |
1935 | goto out; | 1935 | goto out; |
@@ -1938,8 +1938,13 @@ static int __usbnet_read_cmd(struct usbnet *dev, u8 cmd, u8 reqtype, | |||
1938 | err = usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0), | 1938 | err = usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0), |
1939 | cmd, reqtype, value, index, buf, size, | 1939 | cmd, reqtype, value, index, buf, size, |
1940 | USB_CTRL_GET_TIMEOUT); | 1940 | USB_CTRL_GET_TIMEOUT); |
1941 | if (err > 0 && err <= size) | 1941 | if (err > 0 && err <= size) { |
1942 | memcpy(data, buf, err); | 1942 | if (data) |
1943 | memcpy(data, buf, err); | ||
1944 | else | ||
1945 | netdev_dbg(dev->net, | ||
1946 | "Huh? Data requested but thrown away.\n"); | ||
1947 | } | ||
1943 | kfree(buf); | 1948 | kfree(buf); |
1944 | out: | 1949 | out: |
1945 | return err; | 1950 | return err; |
@@ -1960,7 +1965,13 @@ static int __usbnet_write_cmd(struct usbnet *dev, u8 cmd, u8 reqtype, | |||
1960 | buf = kmemdup(data, size, GFP_KERNEL); | 1965 | buf = kmemdup(data, size, GFP_KERNEL); |
1961 | if (!buf) | 1966 | if (!buf) |
1962 | goto out; | 1967 | goto out; |
1963 | } | 1968 | } else { |
1969 | if (size) { | ||
1970 | WARN_ON_ONCE(1); | ||
1971 | err = -EINVAL; | ||
1972 | goto out; | ||
1973 | } | ||
1974 | } | ||
1964 | 1975 | ||
1965 | err = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, 0), | 1976 | err = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, 0), |
1966 | cmd, reqtype, value, index, buf, size, | 1977 | cmd, reqtype, value, index, buf, size, |
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index ea9890d61967..f36584616e7d 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c | |||
@@ -2230,14 +2230,8 @@ static bool virtnet_validate_features(struct virtio_device *vdev) | |||
2230 | #define MIN_MTU ETH_MIN_MTU | 2230 | #define MIN_MTU ETH_MIN_MTU |
2231 | #define MAX_MTU ETH_MAX_MTU | 2231 | #define MAX_MTU ETH_MAX_MTU |
2232 | 2232 | ||
2233 | static int virtnet_probe(struct virtio_device *vdev) | 2233 | static int virtnet_validate(struct virtio_device *vdev) |
2234 | { | 2234 | { |
2235 | int i, err; | ||
2236 | struct net_device *dev; | ||
2237 | struct virtnet_info *vi; | ||
2238 | u16 max_queue_pairs; | ||
2239 | int mtu; | ||
2240 | |||
2241 | if (!vdev->config->get) { | 2235 | if (!vdev->config->get) { |
2242 | dev_err(&vdev->dev, "%s failure: config access disabled\n", | 2236 | dev_err(&vdev->dev, "%s failure: config access disabled\n", |
2243 | __func__); | 2237 | __func__); |
@@ -2247,6 +2241,25 @@ static int virtnet_probe(struct virtio_device *vdev) | |||
2247 | if (!virtnet_validate_features(vdev)) | 2241 | if (!virtnet_validate_features(vdev)) |
2248 | return -EINVAL; | 2242 | return -EINVAL; |
2249 | 2243 | ||
2244 | if (virtio_has_feature(vdev, VIRTIO_NET_F_MTU)) { | ||
2245 | int mtu = virtio_cread16(vdev, | ||
2246 | offsetof(struct virtio_net_config, | ||
2247 | mtu)); | ||
2248 | if (mtu < MIN_MTU) | ||
2249 | __virtio_clear_bit(vdev, VIRTIO_NET_F_MTU); | ||
2250 | } | ||
2251 | |||
2252 | return 0; | ||
2253 | } | ||
2254 | |||
2255 | static int virtnet_probe(struct virtio_device *vdev) | ||
2256 | { | ||
2257 | int i, err; | ||
2258 | struct net_device *dev; | ||
2259 | struct virtnet_info *vi; | ||
2260 | u16 max_queue_pairs; | ||
2261 | int mtu; | ||
2262 | |||
2250 | /* Find if host supports multiqueue virtio_net device */ | 2263 | /* Find if host supports multiqueue virtio_net device */ |
2251 | err = virtio_cread_feature(vdev, VIRTIO_NET_F_MQ, | 2264 | err = virtio_cread_feature(vdev, VIRTIO_NET_F_MQ, |
2252 | struct virtio_net_config, | 2265 | struct virtio_net_config, |
@@ -2362,11 +2375,20 @@ static int virtnet_probe(struct virtio_device *vdev) | |||
2362 | offsetof(struct virtio_net_config, | 2375 | offsetof(struct virtio_net_config, |
2363 | mtu)); | 2376 | mtu)); |
2364 | if (mtu < dev->min_mtu) { | 2377 | if (mtu < dev->min_mtu) { |
2365 | __virtio_clear_bit(vdev, VIRTIO_NET_F_MTU); | 2378 | /* Should never trigger: MTU was previously validated |
2366 | } else { | 2379 | * in virtnet_validate. |
2367 | dev->mtu = mtu; | 2380 | */ |
2368 | dev->max_mtu = mtu; | 2381 | dev_err(&vdev->dev, "device MTU appears to have changed " |
2382 | "it is now %d < %d", mtu, dev->min_mtu); | ||
2383 | goto free_stats; | ||
2369 | } | 2384 | } |
2385 | |||
2386 | dev->mtu = mtu; | ||
2387 | dev->max_mtu = mtu; | ||
2388 | |||
2389 | /* TODO: size buffers correctly in this case. */ | ||
2390 | if (dev->mtu > ETH_DATA_LEN) | ||
2391 | vi->big_packets = true; | ||
2370 | } | 2392 | } |
2371 | 2393 | ||
2372 | if (vi->any_header_sg) | 2394 | if (vi->any_header_sg) |
@@ -2544,6 +2566,7 @@ static struct virtio_driver virtio_net_driver = { | |||
2544 | .driver.name = KBUILD_MODNAME, | 2566 | .driver.name = KBUILD_MODNAME, |
2545 | .driver.owner = THIS_MODULE, | 2567 | .driver.owner = THIS_MODULE, |
2546 | .id_table = id_table, | 2568 | .id_table = id_table, |
2569 | .validate = virtnet_validate, | ||
2547 | .probe = virtnet_probe, | 2570 | .probe = virtnet_probe, |
2548 | .remove = virtnet_remove, | 2571 | .remove = virtnet_remove, |
2549 | .config_changed = virtnet_config_changed, | 2572 | .config_changed = virtnet_config_changed, |
diff --git a/drivers/net/vrf.c b/drivers/net/vrf.c index d6988db1930d..7d909c8183e9 100644 --- a/drivers/net/vrf.c +++ b/drivers/net/vrf.c | |||
@@ -1128,7 +1128,7 @@ static int vrf_fib_rule(const struct net_device *dev, __u8 family, bool add_it) | |||
1128 | goto nla_put_failure; | 1128 | goto nla_put_failure; |
1129 | 1129 | ||
1130 | /* rule only needs to appear once */ | 1130 | /* rule only needs to appear once */ |
1131 | nlh->nlmsg_flags &= NLM_F_EXCL; | 1131 | nlh->nlmsg_flags |= NLM_F_EXCL; |
1132 | 1132 | ||
1133 | frh = nlmsg_data(nlh); | 1133 | frh = nlmsg_data(nlh); |
1134 | memset(frh, 0, sizeof(*frh)); | 1134 | memset(frh, 0, sizeof(*frh)); |
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c index de19c7c92bc6..85d949e03f79 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c | |||
@@ -2238,14 +2238,16 @@ int brcmf_p2p_del_vif(struct wiphy *wiphy, struct wireless_dev *wdev) | |||
2238 | struct brcmf_cfg80211_info *cfg = wiphy_priv(wiphy); | 2238 | struct brcmf_cfg80211_info *cfg = wiphy_priv(wiphy); |
2239 | struct brcmf_p2p_info *p2p = &cfg->p2p; | 2239 | struct brcmf_p2p_info *p2p = &cfg->p2p; |
2240 | struct brcmf_cfg80211_vif *vif; | 2240 | struct brcmf_cfg80211_vif *vif; |
2241 | enum nl80211_iftype iftype; | ||
2241 | bool wait_for_disable = false; | 2242 | bool wait_for_disable = false; |
2242 | int err; | 2243 | int err; |
2243 | 2244 | ||
2244 | brcmf_dbg(TRACE, "delete P2P vif\n"); | 2245 | brcmf_dbg(TRACE, "delete P2P vif\n"); |
2245 | vif = container_of(wdev, struct brcmf_cfg80211_vif, wdev); | 2246 | vif = container_of(wdev, struct brcmf_cfg80211_vif, wdev); |
2246 | 2247 | ||
2248 | iftype = vif->wdev.iftype; | ||
2247 | brcmf_cfg80211_arm_vif_event(cfg, vif); | 2249 | brcmf_cfg80211_arm_vif_event(cfg, vif); |
2248 | switch (vif->wdev.iftype) { | 2250 | switch (iftype) { |
2249 | case NL80211_IFTYPE_P2P_CLIENT: | 2251 | case NL80211_IFTYPE_P2P_CLIENT: |
2250 | if (test_bit(BRCMF_VIF_STATUS_DISCONNECTING, &vif->sme_state)) | 2252 | if (test_bit(BRCMF_VIF_STATUS_DISCONNECTING, &vif->sme_state)) |
2251 | wait_for_disable = true; | 2253 | wait_for_disable = true; |
@@ -2275,7 +2277,7 @@ int brcmf_p2p_del_vif(struct wiphy *wiphy, struct wireless_dev *wdev) | |||
2275 | BRCMF_P2P_DISABLE_TIMEOUT); | 2277 | BRCMF_P2P_DISABLE_TIMEOUT); |
2276 | 2278 | ||
2277 | err = 0; | 2279 | err = 0; |
2278 | if (vif->wdev.iftype != NL80211_IFTYPE_P2P_DEVICE) { | 2280 | if (iftype != NL80211_IFTYPE_P2P_DEVICE) { |
2279 | brcmf_vif_clear_mgmt_ies(vif); | 2281 | brcmf_vif_clear_mgmt_ies(vif); |
2280 | err = brcmf_p2p_release_p2p_if(vif); | 2282 | err = brcmf_p2p_release_p2p_if(vif); |
2281 | } | 2283 | } |
@@ -2291,7 +2293,7 @@ int brcmf_p2p_del_vif(struct wiphy *wiphy, struct wireless_dev *wdev) | |||
2291 | brcmf_remove_interface(vif->ifp, true); | 2293 | brcmf_remove_interface(vif->ifp, true); |
2292 | 2294 | ||
2293 | brcmf_cfg80211_arm_vif_event(cfg, NULL); | 2295 | brcmf_cfg80211_arm_vif_event(cfg, NULL); |
2294 | if (vif->wdev.iftype != NL80211_IFTYPE_P2P_DEVICE) | 2296 | if (iftype != NL80211_IFTYPE_P2P_DEVICE) |
2295 | p2p->bss_idx[P2PAPI_BSSCFG_CONNECTION].vif = NULL; | 2297 | p2p->bss_idx[P2PAPI_BSSCFG_CONNECTION].vif = NULL; |
2296 | 2298 | ||
2297 | return err; | 2299 | return err; |
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c b/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c index a260cd503200..077bfd8f4c0c 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c | |||
@@ -1056,6 +1056,8 @@ static ssize_t iwl_dbgfs_fw_dbg_collect_write(struct iwl_mvm *mvm, | |||
1056 | 1056 | ||
1057 | if (ret) | 1057 | if (ret) |
1058 | return ret; | 1058 | return ret; |
1059 | if (count == 0) | ||
1060 | return 0; | ||
1059 | 1061 | ||
1060 | iwl_mvm_fw_dbg_collect(mvm, FW_DBG_TRIGGER_USER, buf, | 1062 | iwl_mvm_fw_dbg_collect(mvm, FW_DBG_TRIGGER_USER, buf, |
1061 | (count - 1), NULL); | 1063 | (count - 1), NULL); |
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c b/drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c index 99132ea16ede..c5734e1a02d2 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c | |||
@@ -216,7 +216,8 @@ u32 iwl_mvm_mac_get_queues_mask(struct ieee80211_vif *vif) | |||
216 | qmask |= BIT(vif->hw_queue[ac]); | 216 | qmask |= BIT(vif->hw_queue[ac]); |
217 | } | 217 | } |
218 | 218 | ||
219 | if (vif->type == NL80211_IFTYPE_AP) | 219 | if (vif->type == NL80211_IFTYPE_AP || |
220 | vif->type == NL80211_IFTYPE_ADHOC) | ||
220 | qmask |= BIT(vif->cab_queue); | 221 | qmask |= BIT(vif->cab_queue); |
221 | 222 | ||
222 | return qmask; | 223 | return qmask; |
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c index 6927caecd48e..486dcceed17a 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c | |||
@@ -2401,7 +2401,7 @@ void iwl_mvm_sta_pm_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb) | |||
2401 | return; | 2401 | return; |
2402 | 2402 | ||
2403 | rcu_read_lock(); | 2403 | rcu_read_lock(); |
2404 | sta = mvm->fw_id_to_mac_id[notif->sta_id]; | 2404 | sta = rcu_dereference(mvm->fw_id_to_mac_id[notif->sta_id]); |
2405 | if (WARN_ON(IS_ERR_OR_NULL(sta))) { | 2405 | if (WARN_ON(IS_ERR_OR_NULL(sta))) { |
2406 | rcu_read_unlock(); | 2406 | rcu_read_unlock(); |
2407 | return; | 2407 | return; |
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/sta.c b/drivers/net/wireless/intel/iwlwifi/mvm/sta.c index b51a2853cc80..9d28db7f56aa 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/sta.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/sta.c | |||
@@ -1806,7 +1806,8 @@ int iwl_mvm_send_add_bcast_sta(struct iwl_mvm *mvm, struct ieee80211_vif *vif) | |||
1806 | iwl_mvm_get_wd_timeout(mvm, vif, false, false); | 1806 | iwl_mvm_get_wd_timeout(mvm, vif, false, false); |
1807 | int queue; | 1807 | int queue; |
1808 | 1808 | ||
1809 | if (vif->type == NL80211_IFTYPE_AP) | 1809 | if (vif->type == NL80211_IFTYPE_AP || |
1810 | vif->type == NL80211_IFTYPE_ADHOC) | ||
1810 | queue = IWL_MVM_DQA_AP_PROBE_RESP_QUEUE; | 1811 | queue = IWL_MVM_DQA_AP_PROBE_RESP_QUEUE; |
1811 | else if (vif->type == NL80211_IFTYPE_P2P_DEVICE) | 1812 | else if (vif->type == NL80211_IFTYPE_P2P_DEVICE) |
1812 | queue = IWL_MVM_DQA_P2P_DEVICE_QUEUE; | 1813 | queue = IWL_MVM_DQA_P2P_DEVICE_QUEUE; |
@@ -1837,7 +1838,8 @@ int iwl_mvm_send_add_bcast_sta(struct iwl_mvm *mvm, struct ieee80211_vif *vif) | |||
1837 | * enabled-cab_queue to the mask) | 1838 | * enabled-cab_queue to the mask) |
1838 | */ | 1839 | */ |
1839 | if (iwl_mvm_is_dqa_supported(mvm) && | 1840 | if (iwl_mvm_is_dqa_supported(mvm) && |
1840 | vif->type == NL80211_IFTYPE_AP) { | 1841 | (vif->type == NL80211_IFTYPE_AP || |
1842 | vif->type == NL80211_IFTYPE_ADHOC)) { | ||
1841 | struct iwl_trans_txq_scd_cfg cfg = { | 1843 | struct iwl_trans_txq_scd_cfg cfg = { |
1842 | .fifo = IWL_MVM_TX_FIFO_MCAST, | 1844 | .fifo = IWL_MVM_TX_FIFO_MCAST, |
1843 | .sta_id = mvmvif->bcast_sta.sta_id, | 1845 | .sta_id = mvmvif->bcast_sta.sta_id, |
@@ -1862,7 +1864,8 @@ static void iwl_mvm_free_bcast_sta_queues(struct iwl_mvm *mvm, | |||
1862 | 1864 | ||
1863 | lockdep_assert_held(&mvm->mutex); | 1865 | lockdep_assert_held(&mvm->mutex); |
1864 | 1866 | ||
1865 | if (vif->type == NL80211_IFTYPE_AP) | 1867 | if (vif->type == NL80211_IFTYPE_AP || |
1868 | vif->type == NL80211_IFTYPE_ADHOC) | ||
1866 | iwl_mvm_disable_txq(mvm, vif->cab_queue, vif->cab_queue, | 1869 | iwl_mvm_disable_txq(mvm, vif->cab_queue, vif->cab_queue, |
1867 | IWL_MAX_TID_COUNT, 0); | 1870 | IWL_MAX_TID_COUNT, 0); |
1868 | 1871 | ||
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/tx.c b/drivers/net/wireless/intel/iwlwifi/mvm/tx.c index 3f37075f4cde..1ba0a6f55503 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/tx.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/tx.c | |||
@@ -506,6 +506,7 @@ static int iwl_mvm_get_ctrl_vif_queue(struct iwl_mvm *mvm, | |||
506 | 506 | ||
507 | switch (info->control.vif->type) { | 507 | switch (info->control.vif->type) { |
508 | case NL80211_IFTYPE_AP: | 508 | case NL80211_IFTYPE_AP: |
509 | case NL80211_IFTYPE_ADHOC: | ||
509 | /* | 510 | /* |
510 | * Handle legacy hostapd as well, where station may be added | 511 | * Handle legacy hostapd as well, where station may be added |
511 | * only after assoc. Take care of the case where we send a | 512 | * only after assoc. Take care of the case where we send a |
@@ -517,7 +518,8 @@ static int iwl_mvm_get_ctrl_vif_queue(struct iwl_mvm *mvm, | |||
517 | if (info->hw_queue == info->control.vif->cab_queue) | 518 | if (info->hw_queue == info->control.vif->cab_queue) |
518 | return info->hw_queue; | 519 | return info->hw_queue; |
519 | 520 | ||
520 | WARN_ONCE(1, "fc=0x%02x", le16_to_cpu(fc)); | 521 | WARN_ONCE(info->control.vif->type != NL80211_IFTYPE_ADHOC, |
522 | "fc=0x%02x", le16_to_cpu(fc)); | ||
521 | return IWL_MVM_DQA_AP_PROBE_RESP_QUEUE; | 523 | return IWL_MVM_DQA_AP_PROBE_RESP_QUEUE; |
522 | case NL80211_IFTYPE_P2P_DEVICE: | 524 | case NL80211_IFTYPE_P2P_DEVICE: |
523 | if (ieee80211_is_mgmt(fc)) | 525 | if (ieee80211_is_mgmt(fc)) |
@@ -584,7 +586,8 @@ int iwl_mvm_tx_skb_non_sta(struct iwl_mvm *mvm, struct sk_buff *skb) | |||
584 | iwl_mvm_vif_from_mac80211(info.control.vif); | 586 | iwl_mvm_vif_from_mac80211(info.control.vif); |
585 | 587 | ||
586 | if (info.control.vif->type == NL80211_IFTYPE_P2P_DEVICE || | 588 | if (info.control.vif->type == NL80211_IFTYPE_P2P_DEVICE || |
587 | info.control.vif->type == NL80211_IFTYPE_AP) { | 589 | info.control.vif->type == NL80211_IFTYPE_AP || |
590 | info.control.vif->type == NL80211_IFTYPE_ADHOC) { | ||
588 | sta_id = mvmvif->bcast_sta.sta_id; | 591 | sta_id = mvmvif->bcast_sta.sta_id; |
589 | queue = iwl_mvm_get_ctrl_vif_queue(mvm, &info, | 592 | queue = iwl_mvm_get_ctrl_vif_queue(mvm, &info, |
590 | hdr->frame_control); | 593 | hdr->frame_control); |
diff --git a/drivers/net/wireless/realtek/rtlwifi/base.c b/drivers/net/wireless/realtek/rtlwifi/base.c index caea350f05aa..bdc379178e87 100644 --- a/drivers/net/wireless/realtek/rtlwifi/base.c +++ b/drivers/net/wireless/realtek/rtlwifi/base.c | |||
@@ -1742,12 +1742,14 @@ void rtl_c2hcmd_enqueue(struct ieee80211_hw *hw, u8 tag, u8 len, u8 *val) | |||
1742 | unsigned long flags; | 1742 | unsigned long flags; |
1743 | struct rtl_c2hcmd *c2hcmd; | 1743 | struct rtl_c2hcmd *c2hcmd; |
1744 | 1744 | ||
1745 | c2hcmd = kmalloc(sizeof(*c2hcmd), GFP_KERNEL); | 1745 | c2hcmd = kmalloc(sizeof(*c2hcmd), |
1746 | in_interrupt() ? GFP_ATOMIC : GFP_KERNEL); | ||
1746 | 1747 | ||
1747 | if (!c2hcmd) | 1748 | if (!c2hcmd) |
1748 | goto label_err; | 1749 | goto label_err; |
1749 | 1750 | ||
1750 | c2hcmd->val = kmalloc(len, GFP_KERNEL); | 1751 | c2hcmd->val = kmalloc(len, |
1752 | in_interrupt() ? GFP_ATOMIC : GFP_KERNEL); | ||
1751 | 1753 | ||
1752 | if (!c2hcmd->val) | 1754 | if (!c2hcmd->val) |
1753 | goto label_err2; | 1755 | goto label_err2; |
diff --git a/drivers/nvdimm/bus.c b/drivers/nvdimm/bus.c index 23d4a1728cdf..351bac8f6503 100644 --- a/drivers/nvdimm/bus.c +++ b/drivers/nvdimm/bus.c | |||
@@ -934,8 +934,14 @@ static int __nd_ioctl(struct nvdimm_bus *nvdimm_bus, struct nvdimm *nvdimm, | |||
934 | rc = nd_desc->ndctl(nd_desc, nvdimm, cmd, buf, buf_len, NULL); | 934 | rc = nd_desc->ndctl(nd_desc, nvdimm, cmd, buf, buf_len, NULL); |
935 | if (rc < 0) | 935 | if (rc < 0) |
936 | goto out_unlock; | 936 | goto out_unlock; |
937 | nvdimm_bus_unlock(&nvdimm_bus->dev); | ||
938 | |||
937 | if (copy_to_user(p, buf, buf_len)) | 939 | if (copy_to_user(p, buf, buf_len)) |
938 | rc = -EFAULT; | 940 | rc = -EFAULT; |
941 | |||
942 | vfree(buf); | ||
943 | return rc; | ||
944 | |||
939 | out_unlock: | 945 | out_unlock: |
940 | nvdimm_bus_unlock(&nvdimm_bus->dev); | 946 | nvdimm_bus_unlock(&nvdimm_bus->dev); |
941 | out: | 947 | out: |
diff --git a/drivers/nvdimm/claim.c b/drivers/nvdimm/claim.c index b3323c0697f6..ca6d572c48fc 100644 --- a/drivers/nvdimm/claim.c +++ b/drivers/nvdimm/claim.c | |||
@@ -243,7 +243,15 @@ static int nsio_rw_bytes(struct nd_namespace_common *ndns, | |||
243 | } | 243 | } |
244 | 244 | ||
245 | if (unlikely(is_bad_pmem(&nsio->bb, sector, sz_align))) { | 245 | if (unlikely(is_bad_pmem(&nsio->bb, sector, sz_align))) { |
246 | if (IS_ALIGNED(offset, 512) && IS_ALIGNED(size, 512)) { | 246 | /* |
247 | * FIXME: nsio_rw_bytes() may be called from atomic | ||
248 | * context in the btt case and nvdimm_clear_poison() | ||
249 | * takes a sleeping lock. Until the locking can be | ||
250 | * reworked this capability requires that the namespace | ||
251 | * is not claimed by btt. | ||
252 | */ | ||
253 | if (IS_ALIGNED(offset, 512) && IS_ALIGNED(size, 512) | ||
254 | && (!ndns->claim || !is_nd_btt(ndns->claim))) { | ||
247 | long cleared; | 255 | long cleared; |
248 | 256 | ||
249 | cleared = nvdimm_clear_poison(&ndns->dev, offset, size); | 257 | cleared = nvdimm_clear_poison(&ndns->dev, offset, size); |
diff --git a/drivers/nvdimm/dimm_devs.c b/drivers/nvdimm/dimm_devs.c index 0eedc49e0d47..8b721321be5b 100644 --- a/drivers/nvdimm/dimm_devs.c +++ b/drivers/nvdimm/dimm_devs.c | |||
@@ -395,7 +395,7 @@ EXPORT_SYMBOL_GPL(nvdimm_create); | |||
395 | 395 | ||
396 | int alias_dpa_busy(struct device *dev, void *data) | 396 | int alias_dpa_busy(struct device *dev, void *data) |
397 | { | 397 | { |
398 | resource_size_t map_end, blk_start, new, busy; | 398 | resource_size_t map_end, blk_start, new; |
399 | struct blk_alloc_info *info = data; | 399 | struct blk_alloc_info *info = data; |
400 | struct nd_mapping *nd_mapping; | 400 | struct nd_mapping *nd_mapping; |
401 | struct nd_region *nd_region; | 401 | struct nd_region *nd_region; |
@@ -436,29 +436,19 @@ int alias_dpa_busy(struct device *dev, void *data) | |||
436 | retry: | 436 | retry: |
437 | /* | 437 | /* |
438 | * Find the free dpa from the end of the last pmem allocation to | 438 | * Find the free dpa from the end of the last pmem allocation to |
439 | * the end of the interleave-set mapping that is not already | 439 | * the end of the interleave-set mapping. |
440 | * covered by a blk allocation. | ||
441 | */ | 440 | */ |
442 | busy = 0; | ||
443 | for_each_dpa_resource(ndd, res) { | 441 | for_each_dpa_resource(ndd, res) { |
442 | if (strncmp(res->name, "pmem", 4) != 0) | ||
443 | continue; | ||
444 | if ((res->start >= blk_start && res->start < map_end) | 444 | if ((res->start >= blk_start && res->start < map_end) |
445 | || (res->end >= blk_start | 445 | || (res->end >= blk_start |
446 | && res->end <= map_end)) { | 446 | && res->end <= map_end)) { |
447 | if (strncmp(res->name, "pmem", 4) == 0) { | 447 | new = max(blk_start, min(map_end + 1, res->end + 1)); |
448 | new = max(blk_start, min(map_end + 1, | 448 | if (new != blk_start) { |
449 | res->end + 1)); | 449 | blk_start = new; |
450 | if (new != blk_start) { | 450 | goto retry; |
451 | blk_start = new; | 451 | } |
452 | goto retry; | ||
453 | } | ||
454 | } else | ||
455 | busy += min(map_end, res->end) | ||
456 | - max(nd_mapping->start, res->start) + 1; | ||
457 | } else if (nd_mapping->start > res->start | ||
458 | && map_end < res->end) { | ||
459 | /* total eclipse of the PMEM region mapping */ | ||
460 | busy += nd_mapping->size; | ||
461 | break; | ||
462 | } | 452 | } |
463 | } | 453 | } |
464 | 454 | ||
@@ -470,52 +460,11 @@ int alias_dpa_busy(struct device *dev, void *data) | |||
470 | return 1; | 460 | return 1; |
471 | } | 461 | } |
472 | 462 | ||
473 | info->available -= blk_start - nd_mapping->start + busy; | 463 | info->available -= blk_start - nd_mapping->start; |
474 | 464 | ||
475 | return 0; | 465 | return 0; |
476 | } | 466 | } |
477 | 467 | ||
478 | static int blk_dpa_busy(struct device *dev, void *data) | ||
479 | { | ||
480 | struct blk_alloc_info *info = data; | ||
481 | struct nd_mapping *nd_mapping; | ||
482 | struct nd_region *nd_region; | ||
483 | resource_size_t map_end; | ||
484 | int i; | ||
485 | |||
486 | if (!is_nd_pmem(dev)) | ||
487 | return 0; | ||
488 | |||
489 | nd_region = to_nd_region(dev); | ||
490 | for (i = 0; i < nd_region->ndr_mappings; i++) { | ||
491 | nd_mapping = &nd_region->mapping[i]; | ||
492 | if (nd_mapping->nvdimm == info->nd_mapping->nvdimm) | ||
493 | break; | ||
494 | } | ||
495 | |||
496 | if (i >= nd_region->ndr_mappings) | ||
497 | return 0; | ||
498 | |||
499 | map_end = nd_mapping->start + nd_mapping->size - 1; | ||
500 | if (info->res->start >= nd_mapping->start | ||
501 | && info->res->start < map_end) { | ||
502 | if (info->res->end <= map_end) { | ||
503 | info->busy = 0; | ||
504 | return 1; | ||
505 | } else { | ||
506 | info->busy -= info->res->end - map_end; | ||
507 | return 0; | ||
508 | } | ||
509 | } else if (info->res->end >= nd_mapping->start | ||
510 | && info->res->end <= map_end) { | ||
511 | info->busy -= nd_mapping->start - info->res->start; | ||
512 | return 0; | ||
513 | } else { | ||
514 | info->busy -= nd_mapping->size; | ||
515 | return 0; | ||
516 | } | ||
517 | } | ||
518 | |||
519 | /** | 468 | /** |
520 | * nd_blk_available_dpa - account the unused dpa of BLK region | 469 | * nd_blk_available_dpa - account the unused dpa of BLK region |
521 | * @nd_mapping: container of dpa-resource-root + labels | 470 | * @nd_mapping: container of dpa-resource-root + labels |
@@ -545,11 +494,7 @@ resource_size_t nd_blk_available_dpa(struct nd_region *nd_region) | |||
545 | for_each_dpa_resource(ndd, res) { | 494 | for_each_dpa_resource(ndd, res) { |
546 | if (strncmp(res->name, "blk", 3) != 0) | 495 | if (strncmp(res->name, "blk", 3) != 0) |
547 | continue; | 496 | continue; |
548 | 497 | info.available -= resource_size(res); | |
549 | info.res = res; | ||
550 | info.busy = resource_size(res); | ||
551 | device_for_each_child(&nvdimm_bus->dev, &info, blk_dpa_busy); | ||
552 | info.available -= info.busy; | ||
553 | } | 498 | } |
554 | 499 | ||
555 | return info.available; | 500 | return info.available; |
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 263946b23628..bf6729b1d8bf 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c | |||
@@ -1374,6 +1374,14 @@ static void nvme_configure_apst(struct nvme_ctrl *ctrl) | |||
1374 | table->entries[state] = target; | 1374 | table->entries[state] = target; |
1375 | 1375 | ||
1376 | /* | 1376 | /* |
1377 | * Don't allow transitions to the deepest state | ||
1378 | * if it's quirked off. | ||
1379 | */ | ||
1380 | if (state == ctrl->npss && | ||
1381 | (ctrl->quirks & NVME_QUIRK_NO_DEEPEST_PS)) | ||
1382 | continue; | ||
1383 | |||
1384 | /* | ||
1377 | * Is this state a useful non-operational state for | 1385 | * Is this state a useful non-operational state for |
1378 | * higher-power states to autonomously transition to? | 1386 | * higher-power states to autonomously transition to? |
1379 | */ | 1387 | */ |
@@ -1445,16 +1453,15 @@ struct nvme_core_quirk_entry { | |||
1445 | }; | 1453 | }; |
1446 | 1454 | ||
1447 | static const struct nvme_core_quirk_entry core_quirks[] = { | 1455 | static const struct nvme_core_quirk_entry core_quirks[] = { |
1448 | /* | ||
1449 | * Seen on a Samsung "SM951 NVMe SAMSUNG 256GB": using APST causes | ||
1450 | * the controller to go out to lunch. It dies when the watchdog | ||
1451 | * timer reads CSTS and gets 0xffffffff. | ||
1452 | */ | ||
1453 | { | 1456 | { |
1454 | .vid = 0x144d, | 1457 | /* |
1455 | .fr = "BXW75D0Q", | 1458 | * This Toshiba device seems to die using any APST states. See: |
1459 | * https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1678184/comments/11 | ||
1460 | */ | ||
1461 | .vid = 0x1179, | ||
1462 | .mn = "THNSF5256GPUK TOSHIBA", | ||
1456 | .quirks = NVME_QUIRK_NO_APST, | 1463 | .quirks = NVME_QUIRK_NO_APST, |
1457 | }, | 1464 | } |
1458 | }; | 1465 | }; |
1459 | 1466 | ||
1460 | /* match is null-terminated but idstr is space-padded. */ | 1467 | /* match is null-terminated but idstr is space-padded. */ |
diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c index 596b3a453b54..ecc1048de837 100644 --- a/drivers/nvme/host/fc.c +++ b/drivers/nvme/host/fc.c | |||
@@ -2056,7 +2056,7 @@ nvme_fc_configure_admin_queue(struct nvme_fc_ctrl *ctrl) | |||
2056 | } | 2056 | } |
2057 | 2057 | ||
2058 | ctrl->ctrl.sqsize = | 2058 | ctrl->ctrl.sqsize = |
2059 | min_t(int, NVME_CAP_MQES(ctrl->cap) + 1, ctrl->ctrl.sqsize); | 2059 | min_t(int, NVME_CAP_MQES(ctrl->cap), ctrl->ctrl.sqsize); |
2060 | 2060 | ||
2061 | error = nvme_enable_ctrl(&ctrl->ctrl, ctrl->cap); | 2061 | error = nvme_enable_ctrl(&ctrl->ctrl, ctrl->cap); |
2062 | if (error) | 2062 | if (error) |
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h index c6ef6c30e2f0..29c708ca9621 100644 --- a/drivers/nvme/host/nvme.h +++ b/drivers/nvme/host/nvme.h | |||
@@ -71,6 +71,11 @@ enum nvme_quirks { | |||
71 | * APST should not be used. | 71 | * APST should not be used. |
72 | */ | 72 | */ |
73 | NVME_QUIRK_NO_APST = (1 << 4), | 73 | NVME_QUIRK_NO_APST = (1 << 4), |
74 | |||
75 | /* | ||
76 | * The deepest sleep state should not be used. | ||
77 | */ | ||
78 | NVME_QUIRK_NO_DEEPEST_PS = (1 << 5), | ||
74 | }; | 79 | }; |
75 | 80 | ||
76 | /* | 81 | /* |
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index 212f7e0db84f..c8541c3dcd19 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <linux/blk-mq-pci.h> | 19 | #include <linux/blk-mq-pci.h> |
20 | #include <linux/cpu.h> | 20 | #include <linux/cpu.h> |
21 | #include <linux/delay.h> | 21 | #include <linux/delay.h> |
22 | #include <linux/dmi.h> | ||
22 | #include <linux/errno.h> | 23 | #include <linux/errno.h> |
23 | #include <linux/fs.h> | 24 | #include <linux/fs.h> |
24 | #include <linux/genhd.h> | 25 | #include <linux/genhd.h> |
@@ -2070,10 +2071,31 @@ static int nvme_dev_map(struct nvme_dev *dev) | |||
2070 | return -ENODEV; | 2071 | return -ENODEV; |
2071 | } | 2072 | } |
2072 | 2073 | ||
2074 | static unsigned long check_dell_samsung_bug(struct pci_dev *pdev) | ||
2075 | { | ||
2076 | if (pdev->vendor == 0x144d && pdev->device == 0xa802) { | ||
2077 | /* | ||
2078 | * Several Samsung devices seem to drop off the PCIe bus | ||
2079 | * randomly when APST is on and uses the deepest sleep state. | ||
2080 | * This has been observed on a Samsung "SM951 NVMe SAMSUNG | ||
2081 | * 256GB", a "PM951 NVMe SAMSUNG 512GB", and a "Samsung SSD | ||
2082 | * 950 PRO 256GB", but it seems to be restricted to two Dell | ||
2083 | * laptops. | ||
2084 | */ | ||
2085 | if (dmi_match(DMI_SYS_VENDOR, "Dell Inc.") && | ||
2086 | (dmi_match(DMI_PRODUCT_NAME, "XPS 15 9550") || | ||
2087 | dmi_match(DMI_PRODUCT_NAME, "Precision 5510"))) | ||
2088 | return NVME_QUIRK_NO_DEEPEST_PS; | ||
2089 | } | ||
2090 | |||
2091 | return 0; | ||
2092 | } | ||
2093 | |||
2073 | static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id) | 2094 | static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id) |
2074 | { | 2095 | { |
2075 | int node, result = -ENOMEM; | 2096 | int node, result = -ENOMEM; |
2076 | struct nvme_dev *dev; | 2097 | struct nvme_dev *dev; |
2098 | unsigned long quirks = id->driver_data; | ||
2077 | 2099 | ||
2078 | node = dev_to_node(&pdev->dev); | 2100 | node = dev_to_node(&pdev->dev); |
2079 | if (node == NUMA_NO_NODE) | 2101 | if (node == NUMA_NO_NODE) |
@@ -2105,8 +2127,10 @@ static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id) | |||
2105 | if (result) | 2127 | if (result) |
2106 | goto put_pci; | 2128 | goto put_pci; |
2107 | 2129 | ||
2130 | quirks |= check_dell_samsung_bug(pdev); | ||
2131 | |||
2108 | result = nvme_init_ctrl(&dev->ctrl, &pdev->dev, &nvme_pci_ctrl_ops, | 2132 | result = nvme_init_ctrl(&dev->ctrl, &pdev->dev, &nvme_pci_ctrl_ops, |
2109 | id->driver_data); | 2133 | quirks); |
2110 | if (result) | 2134 | if (result) |
2111 | goto release_pools; | 2135 | goto release_pools; |
2112 | 2136 | ||
diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c index 53b611f9ba5d..29cf88ac3f61 100644 --- a/drivers/nvme/host/rdma.c +++ b/drivers/nvme/host/rdma.c | |||
@@ -1599,7 +1599,7 @@ static int nvme_rdma_configure_admin_queue(struct nvme_rdma_ctrl *ctrl) | |||
1599 | } | 1599 | } |
1600 | 1600 | ||
1601 | ctrl->ctrl.sqsize = | 1601 | ctrl->ctrl.sqsize = |
1602 | min_t(int, NVME_CAP_MQES(ctrl->cap) + 1, ctrl->ctrl.sqsize); | 1602 | min_t(int, NVME_CAP_MQES(ctrl->cap), ctrl->ctrl.sqsize); |
1603 | 1603 | ||
1604 | error = nvme_enable_ctrl(&ctrl->ctrl, ctrl->cap); | 1604 | error = nvme_enable_ctrl(&ctrl->ctrl, ctrl->cap); |
1605 | if (error) | 1605 | if (error) |
diff --git a/drivers/nvme/target/loop.c b/drivers/nvme/target/loop.c index 8260ee1f8e48..304f1c87c160 100644 --- a/drivers/nvme/target/loop.c +++ b/drivers/nvme/target/loop.c | |||
@@ -405,7 +405,7 @@ static int nvme_loop_configure_admin_queue(struct nvme_loop_ctrl *ctrl) | |||
405 | } | 405 | } |
406 | 406 | ||
407 | ctrl->ctrl.sqsize = | 407 | ctrl->ctrl.sqsize = |
408 | min_t(int, NVME_CAP_MQES(ctrl->cap) + 1, ctrl->ctrl.sqsize); | 408 | min_t(int, NVME_CAP_MQES(ctrl->cap), ctrl->ctrl.sqsize); |
409 | 409 | ||
410 | error = nvme_enable_ctrl(&ctrl->ctrl, ctrl->cap); | 410 | error = nvme_enable_ctrl(&ctrl->ctrl, ctrl->cap); |
411 | if (error) | 411 | if (error) |
diff --git a/drivers/pci/dwc/Kconfig b/drivers/pci/dwc/Kconfig index dfb8a69afc28..d2d2ba5b8a68 100644 --- a/drivers/pci/dwc/Kconfig +++ b/drivers/pci/dwc/Kconfig | |||
@@ -89,6 +89,7 @@ config PCI_HISI | |||
89 | depends on PCI_MSI_IRQ_DOMAIN | 89 | depends on PCI_MSI_IRQ_DOMAIN |
90 | select PCIEPORTBUS | 90 | select PCIEPORTBUS |
91 | select PCIE_DW_HOST | 91 | select PCIE_DW_HOST |
92 | select PCI_HOST_COMMON | ||
92 | help | 93 | help |
93 | Say Y here if you want PCIe controller support on HiSilicon | 94 | Say Y here if you want PCIe controller support on HiSilicon |
94 | Hip05 and Hip06 SoCs | 95 | Hip05 and Hip06 SoCs |
diff --git a/drivers/pci/dwc/pcie-artpec6.c b/drivers/pci/dwc/pcie-artpec6.c index fcd3ef845883..6d23683c0892 100644 --- a/drivers/pci/dwc/pcie-artpec6.c +++ b/drivers/pci/dwc/pcie-artpec6.c | |||
@@ -234,6 +234,9 @@ static int artpec6_add_pcie_port(struct artpec6_pcie *artpec6_pcie, | |||
234 | return 0; | 234 | return 0; |
235 | } | 235 | } |
236 | 236 | ||
237 | static const struct dw_pcie_ops dw_pcie_ops = { | ||
238 | }; | ||
239 | |||
237 | static int artpec6_pcie_probe(struct platform_device *pdev) | 240 | static int artpec6_pcie_probe(struct platform_device *pdev) |
238 | { | 241 | { |
239 | struct device *dev = &pdev->dev; | 242 | struct device *dev = &pdev->dev; |
@@ -252,6 +255,7 @@ static int artpec6_pcie_probe(struct platform_device *pdev) | |||
252 | return -ENOMEM; | 255 | return -ENOMEM; |
253 | 256 | ||
254 | pci->dev = dev; | 257 | pci->dev = dev; |
258 | pci->ops = &dw_pcie_ops; | ||
255 | 259 | ||
256 | artpec6_pcie->pci = pci; | 260 | artpec6_pcie->pci = pci; |
257 | 261 | ||
diff --git a/drivers/pci/dwc/pcie-designware-plat.c b/drivers/pci/dwc/pcie-designware-plat.c index b6c832ba39dd..f20d494922ab 100644 --- a/drivers/pci/dwc/pcie-designware-plat.c +++ b/drivers/pci/dwc/pcie-designware-plat.c | |||
@@ -86,6 +86,9 @@ static int dw_plat_add_pcie_port(struct pcie_port *pp, | |||
86 | return 0; | 86 | return 0; |
87 | } | 87 | } |
88 | 88 | ||
89 | static const struct dw_pcie_ops dw_pcie_ops = { | ||
90 | }; | ||
91 | |||
89 | static int dw_plat_pcie_probe(struct platform_device *pdev) | 92 | static int dw_plat_pcie_probe(struct platform_device *pdev) |
90 | { | 93 | { |
91 | struct device *dev = &pdev->dev; | 94 | struct device *dev = &pdev->dev; |
@@ -103,6 +106,7 @@ static int dw_plat_pcie_probe(struct platform_device *pdev) | |||
103 | return -ENOMEM; | 106 | return -ENOMEM; |
104 | 107 | ||
105 | pci->dev = dev; | 108 | pci->dev = dev; |
109 | pci->ops = &dw_pcie_ops; | ||
106 | 110 | ||
107 | dw_plat_pcie->pci = pci; | 111 | dw_plat_pcie->pci = pci; |
108 | 112 | ||
diff --git a/drivers/pci/dwc/pcie-hisi.c b/drivers/pci/dwc/pcie-hisi.c index fd66a3199db7..cf9d6a9d9fd4 100644 --- a/drivers/pci/dwc/pcie-hisi.c +++ b/drivers/pci/dwc/pcie-hisi.c | |||
@@ -380,9 +380,13 @@ struct pci_ecam_ops hisi_pcie_platform_ops = { | |||
380 | 380 | ||
381 | static const struct of_device_id hisi_pcie_almost_ecam_of_match[] = { | 381 | static const struct of_device_id hisi_pcie_almost_ecam_of_match[] = { |
382 | { | 382 | { |
383 | .compatible = "hisilicon,pcie-almost-ecam", | 383 | .compatible = "hisilicon,hip06-pcie-ecam", |
384 | .data = (void *) &hisi_pcie_platform_ops, | 384 | .data = (void *) &hisi_pcie_platform_ops, |
385 | }, | 385 | }, |
386 | { | ||
387 | .compatible = "hisilicon,hip07-pcie-ecam", | ||
388 | .data = (void *) &hisi_pcie_platform_ops, | ||
389 | }, | ||
386 | {}, | 390 | {}, |
387 | }; | 391 | }; |
388 | 392 | ||
diff --git a/drivers/pci/host/pci-thunder-pem.c b/drivers/pci/host/pci-thunder-pem.c index 52b5bdccf5f0..6e031b522529 100644 --- a/drivers/pci/host/pci-thunder-pem.c +++ b/drivers/pci/host/pci-thunder-pem.c | |||
@@ -14,6 +14,7 @@ | |||
14 | * Copyright (C) 2015 - 2016 Cavium, Inc. | 14 | * Copyright (C) 2015 - 2016 Cavium, Inc. |
15 | */ | 15 | */ |
16 | 16 | ||
17 | #include <linux/bitfield.h> | ||
17 | #include <linux/kernel.h> | 18 | #include <linux/kernel.h> |
18 | #include <linux/init.h> | 19 | #include <linux/init.h> |
19 | #include <linux/of_address.h> | 20 | #include <linux/of_address.h> |
@@ -334,6 +335,49 @@ static int thunder_pem_init(struct device *dev, struct pci_config_window *cfg, | |||
334 | 335 | ||
335 | #if defined(CONFIG_ACPI) && defined(CONFIG_PCI_QUIRKS) | 336 | #if defined(CONFIG_ACPI) && defined(CONFIG_PCI_QUIRKS) |
336 | 337 | ||
338 | #define PEM_RES_BASE 0x87e0c0000000UL | ||
339 | #define PEM_NODE_MASK GENMASK(45, 44) | ||
340 | #define PEM_INDX_MASK GENMASK(26, 24) | ||
341 | #define PEM_MIN_DOM_IN_NODE 4 | ||
342 | #define PEM_MAX_DOM_IN_NODE 10 | ||
343 | |||
344 | static void thunder_pem_reserve_range(struct device *dev, int seg, | ||
345 | struct resource *r) | ||
346 | { | ||
347 | resource_size_t start = r->start, end = r->end; | ||
348 | struct resource *res; | ||
349 | const char *regionid; | ||
350 | |||
351 | regionid = kasprintf(GFP_KERNEL, "PEM RC:%d", seg); | ||
352 | if (!regionid) | ||
353 | return; | ||
354 | |||
355 | res = request_mem_region(start, end - start + 1, regionid); | ||
356 | if (res) | ||
357 | res->flags &= ~IORESOURCE_BUSY; | ||
358 | else | ||
359 | kfree(regionid); | ||
360 | |||
361 | dev_info(dev, "%pR %s reserved\n", r, | ||
362 | res ? "has been" : "could not be"); | ||
363 | } | ||
364 | |||
365 | static void thunder_pem_legacy_fw(struct acpi_pci_root *root, | ||
366 | struct resource *res_pem) | ||
367 | { | ||
368 | int node = acpi_get_node(root->device->handle); | ||
369 | int index; | ||
370 | |||
371 | if (node == NUMA_NO_NODE) | ||
372 | node = 0; | ||
373 | |||
374 | index = root->segment - PEM_MIN_DOM_IN_NODE; | ||
375 | index -= node * PEM_MAX_DOM_IN_NODE; | ||
376 | res_pem->start = PEM_RES_BASE | FIELD_PREP(PEM_NODE_MASK, node) | | ||
377 | FIELD_PREP(PEM_INDX_MASK, index); | ||
378 | res_pem->flags = IORESOURCE_MEM; | ||
379 | } | ||
380 | |||
337 | static int thunder_pem_acpi_init(struct pci_config_window *cfg) | 381 | static int thunder_pem_acpi_init(struct pci_config_window *cfg) |
338 | { | 382 | { |
339 | struct device *dev = cfg->parent; | 383 | struct device *dev = cfg->parent; |
@@ -346,10 +390,24 @@ static int thunder_pem_acpi_init(struct pci_config_window *cfg) | |||
346 | if (!res_pem) | 390 | if (!res_pem) |
347 | return -ENOMEM; | 391 | return -ENOMEM; |
348 | 392 | ||
349 | ret = acpi_get_rc_resources(dev, "THRX0002", root->segment, res_pem); | 393 | ret = acpi_get_rc_resources(dev, "CAVA02B", root->segment, res_pem); |
394 | |||
395 | /* | ||
396 | * If we fail to gather resources it means that we run with old | ||
397 | * FW where we need to calculate PEM-specific resources manually. | ||
398 | */ | ||
350 | if (ret) { | 399 | if (ret) { |
351 | dev_err(dev, "can't get rc base address\n"); | 400 | thunder_pem_legacy_fw(root, res_pem); |
352 | return ret; | 401 | /* |
402 | * Reserve 64K size PEM specific resources. The full 16M range | ||
403 | * size is required for thunder_pem_init() call. | ||
404 | */ | ||
405 | res_pem->end = res_pem->start + SZ_64K - 1; | ||
406 | thunder_pem_reserve_range(dev, root->segment, res_pem); | ||
407 | res_pem->end = res_pem->start + SZ_16M - 1; | ||
408 | |||
409 | /* Reserve PCI configuration space as well. */ | ||
410 | thunder_pem_reserve_range(dev, root->segment, &cfg->res); | ||
353 | } | 411 | } |
354 | 412 | ||
355 | return thunder_pem_init(dev, cfg, res_pem); | 413 | return thunder_pem_init(dev, cfg, res_pem); |
diff --git a/drivers/pci/host/pcie-iproc-bcma.c b/drivers/pci/host/pcie-iproc-bcma.c index bd4c9ec25edc..384c27e664fe 100644 --- a/drivers/pci/host/pcie-iproc-bcma.c +++ b/drivers/pci/host/pcie-iproc-bcma.c | |||
@@ -44,8 +44,7 @@ static int iproc_pcie_bcma_probe(struct bcma_device *bdev) | |||
44 | { | 44 | { |
45 | struct device *dev = &bdev->dev; | 45 | struct device *dev = &bdev->dev; |
46 | struct iproc_pcie *pcie; | 46 | struct iproc_pcie *pcie; |
47 | LIST_HEAD(res); | 47 | LIST_HEAD(resources); |
48 | struct resource res_mem; | ||
49 | int ret; | 48 | int ret; |
50 | 49 | ||
51 | pcie = devm_kzalloc(dev, sizeof(*pcie), GFP_KERNEL); | 50 | pcie = devm_kzalloc(dev, sizeof(*pcie), GFP_KERNEL); |
@@ -63,22 +62,23 @@ static int iproc_pcie_bcma_probe(struct bcma_device *bdev) | |||
63 | 62 | ||
64 | pcie->base_addr = bdev->addr; | 63 | pcie->base_addr = bdev->addr; |
65 | 64 | ||
66 | res_mem.start = bdev->addr_s[0]; | 65 | pcie->mem.start = bdev->addr_s[0]; |
67 | res_mem.end = bdev->addr_s[0] + SZ_128M - 1; | 66 | pcie->mem.end = bdev->addr_s[0] + SZ_128M - 1; |
68 | res_mem.name = "PCIe MEM space"; | 67 | pcie->mem.name = "PCIe MEM space"; |
69 | res_mem.flags = IORESOURCE_MEM; | 68 | pcie->mem.flags = IORESOURCE_MEM; |
70 | pci_add_resource(&res, &res_mem); | 69 | pci_add_resource(&resources, &pcie->mem); |
71 | 70 | ||
72 | pcie->map_irq = iproc_pcie_bcma_map_irq; | 71 | pcie->map_irq = iproc_pcie_bcma_map_irq; |
73 | 72 | ||
74 | ret = iproc_pcie_setup(pcie, &res); | 73 | ret = iproc_pcie_setup(pcie, &resources); |
75 | if (ret) | 74 | if (ret) { |
76 | dev_err(dev, "PCIe controller setup failed\n"); | 75 | dev_err(dev, "PCIe controller setup failed\n"); |
77 | 76 | pci_free_resource_list(&resources); | |
78 | pci_free_resource_list(&res); | 77 | return ret; |
78 | } | ||
79 | 79 | ||
80 | bcma_set_drvdata(bdev, pcie); | 80 | bcma_set_drvdata(bdev, pcie); |
81 | return ret; | 81 | return 0; |
82 | } | 82 | } |
83 | 83 | ||
84 | static void iproc_pcie_bcma_remove(struct bcma_device *bdev) | 84 | static void iproc_pcie_bcma_remove(struct bcma_device *bdev) |
diff --git a/drivers/pci/host/pcie-iproc-platform.c b/drivers/pci/host/pcie-iproc-platform.c index f4909bb0b2ad..8c6a327ca6cd 100644 --- a/drivers/pci/host/pcie-iproc-platform.c +++ b/drivers/pci/host/pcie-iproc-platform.c | |||
@@ -51,7 +51,7 @@ static int iproc_pcie_pltfm_probe(struct platform_device *pdev) | |||
51 | struct device_node *np = dev->of_node; | 51 | struct device_node *np = dev->of_node; |
52 | struct resource reg; | 52 | struct resource reg; |
53 | resource_size_t iobase = 0; | 53 | resource_size_t iobase = 0; |
54 | LIST_HEAD(res); | 54 | LIST_HEAD(resources); |
55 | int ret; | 55 | int ret; |
56 | 56 | ||
57 | pcie = devm_kzalloc(dev, sizeof(*pcie), GFP_KERNEL); | 57 | pcie = devm_kzalloc(dev, sizeof(*pcie), GFP_KERNEL); |
@@ -96,10 +96,10 @@ static int iproc_pcie_pltfm_probe(struct platform_device *pdev) | |||
96 | pcie->phy = NULL; | 96 | pcie->phy = NULL; |
97 | } | 97 | } |
98 | 98 | ||
99 | ret = of_pci_get_host_bridge_resources(np, 0, 0xff, &res, &iobase); | 99 | ret = of_pci_get_host_bridge_resources(np, 0, 0xff, &resources, |
100 | &iobase); | ||
100 | if (ret) { | 101 | if (ret) { |
101 | dev_err(dev, | 102 | dev_err(dev, "unable to get PCI host bridge resources\n"); |
102 | "unable to get PCI host bridge resources\n"); | ||
103 | return ret; | 103 | return ret; |
104 | } | 104 | } |
105 | 105 | ||
@@ -112,14 +112,15 @@ static int iproc_pcie_pltfm_probe(struct platform_device *pdev) | |||
112 | pcie->map_irq = of_irq_parse_and_map_pci; | 112 | pcie->map_irq = of_irq_parse_and_map_pci; |
113 | } | 113 | } |
114 | 114 | ||
115 | ret = iproc_pcie_setup(pcie, &res); | 115 | ret = iproc_pcie_setup(pcie, &resources); |
116 | if (ret) | 116 | if (ret) { |
117 | dev_err(dev, "PCIe controller setup failed\n"); | 117 | dev_err(dev, "PCIe controller setup failed\n"); |
118 | 118 | pci_free_resource_list(&resources); | |
119 | pci_free_resource_list(&res); | 119 | return ret; |
120 | } | ||
120 | 121 | ||
121 | platform_set_drvdata(pdev, pcie); | 122 | platform_set_drvdata(pdev, pcie); |
122 | return ret; | 123 | return 0; |
123 | } | 124 | } |
124 | 125 | ||
125 | static int iproc_pcie_pltfm_remove(struct platform_device *pdev) | 126 | static int iproc_pcie_pltfm_remove(struct platform_device *pdev) |
diff --git a/drivers/pci/host/pcie-iproc.h b/drivers/pci/host/pcie-iproc.h index 04fed8e907f1..0bbe2ea44f3e 100644 --- a/drivers/pci/host/pcie-iproc.h +++ b/drivers/pci/host/pcie-iproc.h | |||
@@ -90,6 +90,7 @@ struct iproc_pcie { | |||
90 | #ifdef CONFIG_ARM | 90 | #ifdef CONFIG_ARM |
91 | struct pci_sys_data sysdata; | 91 | struct pci_sys_data sysdata; |
92 | #endif | 92 | #endif |
93 | struct resource mem; | ||
93 | struct pci_bus *root_bus; | 94 | struct pci_bus *root_bus; |
94 | struct phy *phy; | 95 | struct phy *phy; |
95 | int (*map_irq)(const struct pci_dev *, u8, u8); | 96 | int (*map_irq)(const struct pci_dev *, u8, u8); |
diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c index d69046537b75..32822b0d9cd0 100644 --- a/drivers/pinctrl/core.c +++ b/drivers/pinctrl/core.c | |||
@@ -2010,29 +2010,57 @@ out_err: | |||
2010 | return ERR_PTR(ret); | 2010 | return ERR_PTR(ret); |
2011 | } | 2011 | } |
2012 | 2012 | ||
2013 | static int pinctrl_create_and_start(struct pinctrl_dev *pctldev) | 2013 | static int pinctrl_claim_hogs(struct pinctrl_dev *pctldev) |
2014 | { | 2014 | { |
2015 | pctldev->p = create_pinctrl(pctldev->dev, pctldev); | 2015 | pctldev->p = create_pinctrl(pctldev->dev, pctldev); |
2016 | if (!IS_ERR(pctldev->p)) { | 2016 | if (PTR_ERR(pctldev->p) == -ENODEV) { |
2017 | kref_get(&pctldev->p->users); | 2017 | dev_dbg(pctldev->dev, "no hogs found\n"); |
2018 | pctldev->hog_default = | ||
2019 | pinctrl_lookup_state(pctldev->p, PINCTRL_STATE_DEFAULT); | ||
2020 | if (IS_ERR(pctldev->hog_default)) { | ||
2021 | dev_dbg(pctldev->dev, | ||
2022 | "failed to lookup the default state\n"); | ||
2023 | } else { | ||
2024 | if (pinctrl_select_state(pctldev->p, | ||
2025 | pctldev->hog_default)) | ||
2026 | dev_err(pctldev->dev, | ||
2027 | "failed to select default state\n"); | ||
2028 | } | ||
2029 | 2018 | ||
2030 | pctldev->hog_sleep = | 2019 | return 0; |
2031 | pinctrl_lookup_state(pctldev->p, | 2020 | } |
2032 | PINCTRL_STATE_SLEEP); | 2021 | |
2033 | if (IS_ERR(pctldev->hog_sleep)) | 2022 | if (IS_ERR(pctldev->p)) { |
2034 | dev_dbg(pctldev->dev, | 2023 | dev_err(pctldev->dev, "error claiming hogs: %li\n", |
2035 | "failed to lookup the sleep state\n"); | 2024 | PTR_ERR(pctldev->p)); |
2025 | |||
2026 | return PTR_ERR(pctldev->p); | ||
2027 | } | ||
2028 | |||
2029 | kref_get(&pctldev->p->users); | ||
2030 | pctldev->hog_default = | ||
2031 | pinctrl_lookup_state(pctldev->p, PINCTRL_STATE_DEFAULT); | ||
2032 | if (IS_ERR(pctldev->hog_default)) { | ||
2033 | dev_dbg(pctldev->dev, | ||
2034 | "failed to lookup the default state\n"); | ||
2035 | } else { | ||
2036 | if (pinctrl_select_state(pctldev->p, | ||
2037 | pctldev->hog_default)) | ||
2038 | dev_err(pctldev->dev, | ||
2039 | "failed to select default state\n"); | ||
2040 | } | ||
2041 | |||
2042 | pctldev->hog_sleep = | ||
2043 | pinctrl_lookup_state(pctldev->p, | ||
2044 | PINCTRL_STATE_SLEEP); | ||
2045 | if (IS_ERR(pctldev->hog_sleep)) | ||
2046 | dev_dbg(pctldev->dev, | ||
2047 | "failed to lookup the sleep state\n"); | ||
2048 | |||
2049 | return 0; | ||
2050 | } | ||
2051 | |||
2052 | int pinctrl_enable(struct pinctrl_dev *pctldev) | ||
2053 | { | ||
2054 | int error; | ||
2055 | |||
2056 | error = pinctrl_claim_hogs(pctldev); | ||
2057 | if (error) { | ||
2058 | dev_err(pctldev->dev, "could not claim hogs: %i\n", | ||
2059 | error); | ||
2060 | mutex_destroy(&pctldev->mutex); | ||
2061 | kfree(pctldev); | ||
2062 | |||
2063 | return error; | ||
2036 | } | 2064 | } |
2037 | 2065 | ||
2038 | mutex_lock(&pinctrldev_list_mutex); | 2066 | mutex_lock(&pinctrldev_list_mutex); |
@@ -2043,6 +2071,7 @@ static int pinctrl_create_and_start(struct pinctrl_dev *pctldev) | |||
2043 | 2071 | ||
2044 | return 0; | 2072 | return 0; |
2045 | } | 2073 | } |
2074 | EXPORT_SYMBOL_GPL(pinctrl_enable); | ||
2046 | 2075 | ||
2047 | /** | 2076 | /** |
2048 | * pinctrl_register() - register a pin controller device | 2077 | * pinctrl_register() - register a pin controller device |
@@ -2065,25 +2094,30 @@ struct pinctrl_dev *pinctrl_register(struct pinctrl_desc *pctldesc, | |||
2065 | if (IS_ERR(pctldev)) | 2094 | if (IS_ERR(pctldev)) |
2066 | return pctldev; | 2095 | return pctldev; |
2067 | 2096 | ||
2068 | error = pinctrl_create_and_start(pctldev); | 2097 | error = pinctrl_enable(pctldev); |
2069 | if (error) { | 2098 | if (error) |
2070 | mutex_destroy(&pctldev->mutex); | ||
2071 | kfree(pctldev); | ||
2072 | |||
2073 | return ERR_PTR(error); | 2099 | return ERR_PTR(error); |
2074 | } | ||
2075 | 2100 | ||
2076 | return pctldev; | 2101 | return pctldev; |
2077 | 2102 | ||
2078 | } | 2103 | } |
2079 | EXPORT_SYMBOL_GPL(pinctrl_register); | 2104 | EXPORT_SYMBOL_GPL(pinctrl_register); |
2080 | 2105 | ||
2106 | /** | ||
2107 | * pinctrl_register_and_init() - register and init pin controller device | ||
2108 | * @pctldesc: descriptor for this pin controller | ||
2109 | * @dev: parent device for this pin controller | ||
2110 | * @driver_data: private pin controller data for this pin controller | ||
2111 | * @pctldev: pin controller device | ||
2112 | * | ||
2113 | * Note that pinctrl_enable() still needs to be manually called after | ||
2114 | * this once the driver is ready. | ||
2115 | */ | ||
2081 | int pinctrl_register_and_init(struct pinctrl_desc *pctldesc, | 2116 | int pinctrl_register_and_init(struct pinctrl_desc *pctldesc, |
2082 | struct device *dev, void *driver_data, | 2117 | struct device *dev, void *driver_data, |
2083 | struct pinctrl_dev **pctldev) | 2118 | struct pinctrl_dev **pctldev) |
2084 | { | 2119 | { |
2085 | struct pinctrl_dev *p; | 2120 | struct pinctrl_dev *p; |
2086 | int error; | ||
2087 | 2121 | ||
2088 | p = pinctrl_init_controller(pctldesc, dev, driver_data); | 2122 | p = pinctrl_init_controller(pctldesc, dev, driver_data); |
2089 | if (IS_ERR(p)) | 2123 | if (IS_ERR(p)) |
@@ -2097,15 +2131,6 @@ int pinctrl_register_and_init(struct pinctrl_desc *pctldesc, | |||
2097 | */ | 2131 | */ |
2098 | *pctldev = p; | 2132 | *pctldev = p; |
2099 | 2133 | ||
2100 | error = pinctrl_create_and_start(p); | ||
2101 | if (error) { | ||
2102 | mutex_destroy(&p->mutex); | ||
2103 | kfree(p); | ||
2104 | *pctldev = NULL; | ||
2105 | |||
2106 | return error; | ||
2107 | } | ||
2108 | |||
2109 | return 0; | 2134 | return 0; |
2110 | } | 2135 | } |
2111 | EXPORT_SYMBOL_GPL(pinctrl_register_and_init); | 2136 | EXPORT_SYMBOL_GPL(pinctrl_register_and_init); |
diff --git a/drivers/pinctrl/freescale/pinctrl-imx.c b/drivers/pinctrl/freescale/pinctrl-imx.c index a7ace9e1ad81..74bd90dfd7b1 100644 --- a/drivers/pinctrl/freescale/pinctrl-imx.c +++ b/drivers/pinctrl/freescale/pinctrl-imx.c | |||
@@ -790,7 +790,7 @@ int imx_pinctrl_probe(struct platform_device *pdev, | |||
790 | 790 | ||
791 | dev_info(&pdev->dev, "initialized IMX pinctrl driver\n"); | 791 | dev_info(&pdev->dev, "initialized IMX pinctrl driver\n"); |
792 | 792 | ||
793 | return 0; | 793 | return pinctrl_enable(ipctl->pctl); |
794 | 794 | ||
795 | free: | 795 | free: |
796 | imx_free_resources(ipctl); | 796 | imx_free_resources(ipctl); |
diff --git a/drivers/pinctrl/intel/pinctrl-cherryview.c b/drivers/pinctrl/intel/pinctrl-cherryview.c index f80134e3e0b6..9ff790174906 100644 --- a/drivers/pinctrl/intel/pinctrl-cherryview.c +++ b/drivers/pinctrl/intel/pinctrl-cherryview.c | |||
@@ -13,6 +13,7 @@ | |||
13 | * published by the Free Software Foundation. | 13 | * published by the Free Software Foundation. |
14 | */ | 14 | */ |
15 | 15 | ||
16 | #include <linux/dmi.h> | ||
16 | #include <linux/kernel.h> | 17 | #include <linux/kernel.h> |
17 | #include <linux/module.h> | 18 | #include <linux/module.h> |
18 | #include <linux/init.h> | 19 | #include <linux/init.h> |
@@ -1524,10 +1525,31 @@ static void chv_gpio_irq_handler(struct irq_desc *desc) | |||
1524 | chained_irq_exit(chip, desc); | 1525 | chained_irq_exit(chip, desc); |
1525 | } | 1526 | } |
1526 | 1527 | ||
1528 | /* | ||
1529 | * Certain machines seem to hardcode Linux IRQ numbers in their ACPI | ||
1530 | * tables. Since we leave GPIOs that are not capable of generating | ||
1531 | * interrupts out of the irqdomain the numbering will be different and | ||
1532 | * cause devices using the hardcoded IRQ numbers fail. In order not to | ||
1533 | * break such machines we will only mask pins from irqdomain if the machine | ||
1534 | * is not listed below. | ||
1535 | */ | ||
1536 | static const struct dmi_system_id chv_no_valid_mask[] = { | ||
1537 | { | ||
1538 | /* See https://bugzilla.kernel.org/show_bug.cgi?id=194945 */ | ||
1539 | .ident = "Acer Chromebook (CYAN)", | ||
1540 | .matches = { | ||
1541 | DMI_MATCH(DMI_SYS_VENDOR, "GOOGLE"), | ||
1542 | DMI_MATCH(DMI_PRODUCT_NAME, "Edgar"), | ||
1543 | DMI_MATCH(DMI_BIOS_DATE, "05/21/2016"), | ||
1544 | }, | ||
1545 | } | ||
1546 | }; | ||
1547 | |||
1527 | static int chv_gpio_probe(struct chv_pinctrl *pctrl, int irq) | 1548 | static int chv_gpio_probe(struct chv_pinctrl *pctrl, int irq) |
1528 | { | 1549 | { |
1529 | const struct chv_gpio_pinrange *range; | 1550 | const struct chv_gpio_pinrange *range; |
1530 | struct gpio_chip *chip = &pctrl->chip; | 1551 | struct gpio_chip *chip = &pctrl->chip; |
1552 | bool need_valid_mask = !dmi_check_system(chv_no_valid_mask); | ||
1531 | int ret, i, offset; | 1553 | int ret, i, offset; |
1532 | 1554 | ||
1533 | *chip = chv_gpio_chip; | 1555 | *chip = chv_gpio_chip; |
@@ -1536,7 +1558,7 @@ static int chv_gpio_probe(struct chv_pinctrl *pctrl, int irq) | |||
1536 | chip->label = dev_name(pctrl->dev); | 1558 | chip->label = dev_name(pctrl->dev); |
1537 | chip->parent = pctrl->dev; | 1559 | chip->parent = pctrl->dev; |
1538 | chip->base = -1; | 1560 | chip->base = -1; |
1539 | chip->irq_need_valid_mask = true; | 1561 | chip->irq_need_valid_mask = need_valid_mask; |
1540 | 1562 | ||
1541 | ret = devm_gpiochip_add_data(pctrl->dev, chip, pctrl); | 1563 | ret = devm_gpiochip_add_data(pctrl->dev, chip, pctrl); |
1542 | if (ret) { | 1564 | if (ret) { |
@@ -1567,7 +1589,7 @@ static int chv_gpio_probe(struct chv_pinctrl *pctrl, int irq) | |||
1567 | intsel &= CHV_PADCTRL0_INTSEL_MASK; | 1589 | intsel &= CHV_PADCTRL0_INTSEL_MASK; |
1568 | intsel >>= CHV_PADCTRL0_INTSEL_SHIFT; | 1590 | intsel >>= CHV_PADCTRL0_INTSEL_SHIFT; |
1569 | 1591 | ||
1570 | if (intsel >= pctrl->community->nirqs) | 1592 | if (need_valid_mask && intsel >= pctrl->community->nirqs) |
1571 | clear_bit(i, chip->irq_valid_mask); | 1593 | clear_bit(i, chip->irq_valid_mask); |
1572 | } | 1594 | } |
1573 | 1595 | ||
diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c index 8b2d45e85bae..9c267dcda094 100644 --- a/drivers/pinctrl/pinctrl-single.c +++ b/drivers/pinctrl/pinctrl-single.c | |||
@@ -1781,7 +1781,7 @@ static int pcs_probe(struct platform_device *pdev) | |||
1781 | dev_info(pcs->dev, "%i pins at pa %p size %u\n", | 1781 | dev_info(pcs->dev, "%i pins at pa %p size %u\n", |
1782 | pcs->desc.npins, pcs->base, pcs->size); | 1782 | pcs->desc.npins, pcs->base, pcs->size); |
1783 | 1783 | ||
1784 | return 0; | 1784 | return pinctrl_enable(pcs->pctl); |
1785 | 1785 | ||
1786 | free: | 1786 | free: |
1787 | pcs_free_resources(pcs); | 1787 | pcs_free_resources(pcs); |
diff --git a/drivers/pinctrl/samsung/pinctrl-exynos.c b/drivers/pinctrl/samsung/pinctrl-exynos.c index f9b49967f512..63e51b56a22a 100644 --- a/drivers/pinctrl/samsung/pinctrl-exynos.c +++ b/drivers/pinctrl/samsung/pinctrl-exynos.c | |||
@@ -1468,82 +1468,82 @@ const struct samsung_pin_ctrl exynos5420_pin_ctrl[] __initconst = { | |||
1468 | 1468 | ||
1469 | /* pin banks of exynos5433 pin-controller - ALIVE */ | 1469 | /* pin banks of exynos5433 pin-controller - ALIVE */ |
1470 | static const struct samsung_pin_bank_data exynos5433_pin_banks0[] __initconst = { | 1470 | static const struct samsung_pin_bank_data exynos5433_pin_banks0[] __initconst = { |
1471 | EXYNOS_PIN_BANK_EINTW(8, 0x000, "gpa0", 0x00), | 1471 | EXYNOS5433_PIN_BANK_EINTW(8, 0x000, "gpa0", 0x00), |
1472 | EXYNOS_PIN_BANK_EINTW(8, 0x020, "gpa1", 0x04), | 1472 | EXYNOS5433_PIN_BANK_EINTW(8, 0x020, "gpa1", 0x04), |
1473 | EXYNOS_PIN_BANK_EINTW(8, 0x040, "gpa2", 0x08), | 1473 | EXYNOS5433_PIN_BANK_EINTW(8, 0x040, "gpa2", 0x08), |
1474 | EXYNOS_PIN_BANK_EINTW(8, 0x060, "gpa3", 0x0c), | 1474 | EXYNOS5433_PIN_BANK_EINTW(8, 0x060, "gpa3", 0x0c), |
1475 | EXYNOS_PIN_BANK_EINTW_EXT(8, 0x020, "gpf1", 0x1004, 1), | 1475 | EXYNOS5433_PIN_BANK_EINTW_EXT(8, 0x020, "gpf1", 0x1004, 1), |
1476 | EXYNOS_PIN_BANK_EINTW_EXT(4, 0x040, "gpf2", 0x1008, 1), | 1476 | EXYNOS5433_PIN_BANK_EINTW_EXT(4, 0x040, "gpf2", 0x1008, 1), |
1477 | EXYNOS_PIN_BANK_EINTW_EXT(4, 0x060, "gpf3", 0x100c, 1), | 1477 | EXYNOS5433_PIN_BANK_EINTW_EXT(4, 0x060, "gpf3", 0x100c, 1), |
1478 | EXYNOS_PIN_BANK_EINTW_EXT(8, 0x080, "gpf4", 0x1010, 1), | 1478 | EXYNOS5433_PIN_BANK_EINTW_EXT(8, 0x080, "gpf4", 0x1010, 1), |
1479 | EXYNOS_PIN_BANK_EINTW_EXT(8, 0x0a0, "gpf5", 0x1014, 1), | 1479 | EXYNOS5433_PIN_BANK_EINTW_EXT(8, 0x0a0, "gpf5", 0x1014, 1), |
1480 | }; | 1480 | }; |
1481 | 1481 | ||
1482 | /* pin banks of exynos5433 pin-controller - AUD */ | 1482 | /* pin banks of exynos5433 pin-controller - AUD */ |
1483 | static const struct samsung_pin_bank_data exynos5433_pin_banks1[] __initconst = { | 1483 | static const struct samsung_pin_bank_data exynos5433_pin_banks1[] __initconst = { |
1484 | EXYNOS_PIN_BANK_EINTG(7, 0x000, "gpz0", 0x00), | 1484 | EXYNOS5433_PIN_BANK_EINTG(7, 0x000, "gpz0", 0x00), |
1485 | EXYNOS_PIN_BANK_EINTG(4, 0x020, "gpz1", 0x04), | 1485 | EXYNOS5433_PIN_BANK_EINTG(4, 0x020, "gpz1", 0x04), |
1486 | }; | 1486 | }; |
1487 | 1487 | ||
1488 | /* pin banks of exynos5433 pin-controller - CPIF */ | 1488 | /* pin banks of exynos5433 pin-controller - CPIF */ |
1489 | static const struct samsung_pin_bank_data exynos5433_pin_banks2[] __initconst = { | 1489 | static const struct samsung_pin_bank_data exynos5433_pin_banks2[] __initconst = { |
1490 | EXYNOS_PIN_BANK_EINTG(2, 0x000, "gpv6", 0x00), | 1490 | EXYNOS5433_PIN_BANK_EINTG(2, 0x000, "gpv6", 0x00), |
1491 | }; | 1491 | }; |
1492 | 1492 | ||
1493 | /* pin banks of exynos5433 pin-controller - eSE */ | 1493 | /* pin banks of exynos5433 pin-controller - eSE */ |
1494 | static const struct samsung_pin_bank_data exynos5433_pin_banks3[] __initconst = { | 1494 | static const struct samsung_pin_bank_data exynos5433_pin_banks3[] __initconst = { |
1495 | EXYNOS_PIN_BANK_EINTG(3, 0x000, "gpj2", 0x00), | 1495 | EXYNOS5433_PIN_BANK_EINTG(3, 0x000, "gpj2", 0x00), |
1496 | }; | 1496 | }; |
1497 | 1497 | ||
1498 | /* pin banks of exynos5433 pin-controller - FINGER */ | 1498 | /* pin banks of exynos5433 pin-controller - FINGER */ |
1499 | static const struct samsung_pin_bank_data exynos5433_pin_banks4[] __initconst = { | 1499 | static const struct samsung_pin_bank_data exynos5433_pin_banks4[] __initconst = { |
1500 | EXYNOS_PIN_BANK_EINTG(4, 0x000, "gpd5", 0x00), | 1500 | EXYNOS5433_PIN_BANK_EINTG(4, 0x000, "gpd5", 0x00), |
1501 | }; | 1501 | }; |
1502 | 1502 | ||
1503 | /* pin banks of exynos5433 pin-controller - FSYS */ | 1503 | /* pin banks of exynos5433 pin-controller - FSYS */ |
1504 | static const struct samsung_pin_bank_data exynos5433_pin_banks5[] __initconst = { | 1504 | static const struct samsung_pin_bank_data exynos5433_pin_banks5[] __initconst = { |
1505 | EXYNOS_PIN_BANK_EINTG(6, 0x000, "gph1", 0x00), | 1505 | EXYNOS5433_PIN_BANK_EINTG(6, 0x000, "gph1", 0x00), |
1506 | EXYNOS_PIN_BANK_EINTG(7, 0x020, "gpr4", 0x04), | 1506 | EXYNOS5433_PIN_BANK_EINTG(7, 0x020, "gpr4", 0x04), |
1507 | EXYNOS_PIN_BANK_EINTG(5, 0x040, "gpr0", 0x08), | 1507 | EXYNOS5433_PIN_BANK_EINTG(5, 0x040, "gpr0", 0x08), |
1508 | EXYNOS_PIN_BANK_EINTG(8, 0x060, "gpr1", 0x0c), | 1508 | EXYNOS5433_PIN_BANK_EINTG(8, 0x060, "gpr1", 0x0c), |
1509 | EXYNOS_PIN_BANK_EINTG(2, 0x080, "gpr2", 0x10), | 1509 | EXYNOS5433_PIN_BANK_EINTG(2, 0x080, "gpr2", 0x10), |
1510 | EXYNOS_PIN_BANK_EINTG(8, 0x0a0, "gpr3", 0x14), | 1510 | EXYNOS5433_PIN_BANK_EINTG(8, 0x0a0, "gpr3", 0x14), |
1511 | }; | 1511 | }; |
1512 | 1512 | ||
1513 | /* pin banks of exynos5433 pin-controller - IMEM */ | 1513 | /* pin banks of exynos5433 pin-controller - IMEM */ |
1514 | static const struct samsung_pin_bank_data exynos5433_pin_banks6[] __initconst = { | 1514 | static const struct samsung_pin_bank_data exynos5433_pin_banks6[] __initconst = { |
1515 | EXYNOS_PIN_BANK_EINTG(8, 0x000, "gpf0", 0x00), | 1515 | EXYNOS5433_PIN_BANK_EINTG(8, 0x000, "gpf0", 0x00), |
1516 | }; | 1516 | }; |
1517 | 1517 | ||
1518 | /* pin banks of exynos5433 pin-controller - NFC */ | 1518 | /* pin banks of exynos5433 pin-controller - NFC */ |
1519 | static const struct samsung_pin_bank_data exynos5433_pin_banks7[] __initconst = { | 1519 | static const struct samsung_pin_bank_data exynos5433_pin_banks7[] __initconst = { |
1520 | EXYNOS_PIN_BANK_EINTG(3, 0x000, "gpj0", 0x00), | 1520 | EXYNOS5433_PIN_BANK_EINTG(3, 0x000, "gpj0", 0x00), |
1521 | }; | 1521 | }; |
1522 | 1522 | ||
1523 | /* pin banks of exynos5433 pin-controller - PERIC */ | 1523 | /* pin banks of exynos5433 pin-controller - PERIC */ |
1524 | static const struct samsung_pin_bank_data exynos5433_pin_banks8[] __initconst = { | 1524 | static const struct samsung_pin_bank_data exynos5433_pin_banks8[] __initconst = { |
1525 | EXYNOS_PIN_BANK_EINTG(6, 0x000, "gpv7", 0x00), | 1525 | EXYNOS5433_PIN_BANK_EINTG(6, 0x000, "gpv7", 0x00), |
1526 | EXYNOS_PIN_BANK_EINTG(5, 0x020, "gpb0", 0x04), | 1526 | EXYNOS5433_PIN_BANK_EINTG(5, 0x020, "gpb0", 0x04), |
1527 | EXYNOS_PIN_BANK_EINTG(8, 0x040, "gpc0", 0x08), | 1527 | EXYNOS5433_PIN_BANK_EINTG(8, 0x040, "gpc0", 0x08), |
1528 | EXYNOS_PIN_BANK_EINTG(2, 0x060, "gpc1", 0x0c), | 1528 | EXYNOS5433_PIN_BANK_EINTG(2, 0x060, "gpc1", 0x0c), |
1529 | EXYNOS_PIN_BANK_EINTG(6, 0x080, "gpc2", 0x10), | 1529 | EXYNOS5433_PIN_BANK_EINTG(6, 0x080, "gpc2", 0x10), |
1530 | EXYNOS_PIN_BANK_EINTG(8, 0x0a0, "gpc3", 0x14), | 1530 | EXYNOS5433_PIN_BANK_EINTG(8, 0x0a0, "gpc3", 0x14), |
1531 | EXYNOS_PIN_BANK_EINTG(2, 0x0c0, "gpg0", 0x18), | 1531 | EXYNOS5433_PIN_BANK_EINTG(2, 0x0c0, "gpg0", 0x18), |
1532 | EXYNOS_PIN_BANK_EINTG(4, 0x0e0, "gpd0", 0x1c), | 1532 | EXYNOS5433_PIN_BANK_EINTG(4, 0x0e0, "gpd0", 0x1c), |
1533 | EXYNOS_PIN_BANK_EINTG(6, 0x100, "gpd1", 0x20), | 1533 | EXYNOS5433_PIN_BANK_EINTG(6, 0x100, "gpd1", 0x20), |
1534 | EXYNOS_PIN_BANK_EINTG(8, 0x120, "gpd2", 0x24), | 1534 | EXYNOS5433_PIN_BANK_EINTG(8, 0x120, "gpd2", 0x24), |
1535 | EXYNOS_PIN_BANK_EINTG(5, 0x140, "gpd4", 0x28), | 1535 | EXYNOS5433_PIN_BANK_EINTG(5, 0x140, "gpd4", 0x28), |
1536 | EXYNOS_PIN_BANK_EINTG(2, 0x160, "gpd8", 0x2c), | 1536 | EXYNOS5433_PIN_BANK_EINTG(2, 0x160, "gpd8", 0x2c), |
1537 | EXYNOS_PIN_BANK_EINTG(7, 0x180, "gpd6", 0x30), | 1537 | EXYNOS5433_PIN_BANK_EINTG(7, 0x180, "gpd6", 0x30), |
1538 | EXYNOS_PIN_BANK_EINTG(3, 0x1a0, "gpd7", 0x34), | 1538 | EXYNOS5433_PIN_BANK_EINTG(3, 0x1a0, "gpd7", 0x34), |
1539 | EXYNOS_PIN_BANK_EINTG(5, 0x1c0, "gpg1", 0x38), | 1539 | EXYNOS5433_PIN_BANK_EINTG(5, 0x1c0, "gpg1", 0x38), |
1540 | EXYNOS_PIN_BANK_EINTG(2, 0x1e0, "gpg2", 0x3c), | 1540 | EXYNOS5433_PIN_BANK_EINTG(2, 0x1e0, "gpg2", 0x3c), |
1541 | EXYNOS_PIN_BANK_EINTG(8, 0x200, "gpg3", 0x40), | 1541 | EXYNOS5433_PIN_BANK_EINTG(8, 0x200, "gpg3", 0x40), |
1542 | }; | 1542 | }; |
1543 | 1543 | ||
1544 | /* pin banks of exynos5433 pin-controller - TOUCH */ | 1544 | /* pin banks of exynos5433 pin-controller - TOUCH */ |
1545 | static const struct samsung_pin_bank_data exynos5433_pin_banks9[] __initconst = { | 1545 | static const struct samsung_pin_bank_data exynos5433_pin_banks9[] __initconst = { |
1546 | EXYNOS_PIN_BANK_EINTG(3, 0x000, "gpj1", 0x00), | 1546 | EXYNOS5433_PIN_BANK_EINTG(3, 0x000, "gpj1", 0x00), |
1547 | }; | 1547 | }; |
1548 | 1548 | ||
1549 | /* | 1549 | /* |
diff --git a/drivers/pinctrl/samsung/pinctrl-exynos.h b/drivers/pinctrl/samsung/pinctrl-exynos.h index a473092fb8d2..cd046eb7d705 100644 --- a/drivers/pinctrl/samsung/pinctrl-exynos.h +++ b/drivers/pinctrl/samsung/pinctrl-exynos.h | |||
@@ -79,17 +79,6 @@ | |||
79 | .name = id \ | 79 | .name = id \ |
80 | } | 80 | } |
81 | 81 | ||
82 | #define EXYNOS_PIN_BANK_EINTW_EXT(pins, reg, id, offs, pctl_idx) \ | ||
83 | { \ | ||
84 | .type = &bank_type_alive, \ | ||
85 | .pctl_offset = reg, \ | ||
86 | .nr_pins = pins, \ | ||
87 | .eint_type = EINT_TYPE_WKUP, \ | ||
88 | .eint_offset = offs, \ | ||
89 | .name = id, \ | ||
90 | .pctl_res_idx = pctl_idx, \ | ||
91 | } \ | ||
92 | |||
93 | #define EXYNOS5433_PIN_BANK_EINTG(pins, reg, id, offs) \ | 82 | #define EXYNOS5433_PIN_BANK_EINTG(pins, reg, id, offs) \ |
94 | { \ | 83 | { \ |
95 | .type = &exynos5433_bank_type_off, \ | 84 | .type = &exynos5433_bank_type_off, \ |
diff --git a/drivers/pinctrl/sh-pfc/pinctrl.c b/drivers/pinctrl/sh-pfc/pinctrl.c index 08150a321be6..a70157f0acf4 100644 --- a/drivers/pinctrl/sh-pfc/pinctrl.c +++ b/drivers/pinctrl/sh-pfc/pinctrl.c | |||
@@ -816,6 +816,13 @@ int sh_pfc_register_pinctrl(struct sh_pfc *pfc) | |||
816 | pmx->pctl_desc.pins = pmx->pins; | 816 | pmx->pctl_desc.pins = pmx->pins; |
817 | pmx->pctl_desc.npins = pfc->info->nr_pins; | 817 | pmx->pctl_desc.npins = pfc->info->nr_pins; |
818 | 818 | ||
819 | return devm_pinctrl_register_and_init(pfc->dev, &pmx->pctl_desc, pmx, | 819 | ret = devm_pinctrl_register_and_init(pfc->dev, &pmx->pctl_desc, pmx, |
820 | &pmx->pctl); | 820 | &pmx->pctl); |
821 | if (ret) { | ||
822 | dev_err(pfc->dev, "could not register: %i\n", ret); | ||
823 | |||
824 | return ret; | ||
825 | } | ||
826 | |||
827 | return pinctrl_enable(pmx->pctl); | ||
821 | } | 828 | } |
diff --git a/drivers/pinctrl/ti/pinctrl-ti-iodelay.c b/drivers/pinctrl/ti/pinctrl-ti-iodelay.c index 717e3404900c..362c50918c13 100644 --- a/drivers/pinctrl/ti/pinctrl-ti-iodelay.c +++ b/drivers/pinctrl/ti/pinctrl-ti-iodelay.c | |||
@@ -893,6 +893,8 @@ static int ti_iodelay_probe(struct platform_device *pdev) | |||
893 | 893 | ||
894 | platform_set_drvdata(pdev, iod); | 894 | platform_set_drvdata(pdev, iod); |
895 | 895 | ||
896 | return pinctrl_enable(iod->pctl); | ||
897 | |||
896 | exit_out: | 898 | exit_out: |
897 | of_node_put(np); | 899 | of_node_put(np); |
898 | return ret; | 900 | return ret; |
diff --git a/drivers/pwm/pwm-lpss-pci.c b/drivers/pwm/pwm-lpss-pci.c index 053088b9b66e..c1527cb645be 100644 --- a/drivers/pwm/pwm-lpss-pci.c +++ b/drivers/pwm/pwm-lpss-pci.c | |||
@@ -36,6 +36,14 @@ static const struct pwm_lpss_boardinfo pwm_lpss_bxt_info = { | |||
36 | .clk_rate = 19200000, | 36 | .clk_rate = 19200000, |
37 | .npwm = 4, | 37 | .npwm = 4, |
38 | .base_unit_bits = 22, | 38 | .base_unit_bits = 22, |
39 | .bypass = true, | ||
40 | }; | ||
41 | |||
42 | /* Tangier */ | ||
43 | static const struct pwm_lpss_boardinfo pwm_lpss_tng_info = { | ||
44 | .clk_rate = 19200000, | ||
45 | .npwm = 4, | ||
46 | .base_unit_bits = 22, | ||
39 | }; | 47 | }; |
40 | 48 | ||
41 | static int pwm_lpss_probe_pci(struct pci_dev *pdev, | 49 | static int pwm_lpss_probe_pci(struct pci_dev *pdev, |
@@ -97,7 +105,7 @@ static const struct pci_device_id pwm_lpss_pci_ids[] = { | |||
97 | { PCI_VDEVICE(INTEL, 0x0ac8), (unsigned long)&pwm_lpss_bxt_info}, | 105 | { PCI_VDEVICE(INTEL, 0x0ac8), (unsigned long)&pwm_lpss_bxt_info}, |
98 | { PCI_VDEVICE(INTEL, 0x0f08), (unsigned long)&pwm_lpss_byt_info}, | 106 | { PCI_VDEVICE(INTEL, 0x0f08), (unsigned long)&pwm_lpss_byt_info}, |
99 | { PCI_VDEVICE(INTEL, 0x0f09), (unsigned long)&pwm_lpss_byt_info}, | 107 | { PCI_VDEVICE(INTEL, 0x0f09), (unsigned long)&pwm_lpss_byt_info}, |
100 | { PCI_VDEVICE(INTEL, 0x11a5), (unsigned long)&pwm_lpss_bxt_info}, | 108 | { PCI_VDEVICE(INTEL, 0x11a5), (unsigned long)&pwm_lpss_tng_info}, |
101 | { PCI_VDEVICE(INTEL, 0x1ac8), (unsigned long)&pwm_lpss_bxt_info}, | 109 | { PCI_VDEVICE(INTEL, 0x1ac8), (unsigned long)&pwm_lpss_bxt_info}, |
102 | { PCI_VDEVICE(INTEL, 0x2288), (unsigned long)&pwm_lpss_bsw_info}, | 110 | { PCI_VDEVICE(INTEL, 0x2288), (unsigned long)&pwm_lpss_bsw_info}, |
103 | { PCI_VDEVICE(INTEL, 0x2289), (unsigned long)&pwm_lpss_bsw_info}, | 111 | { PCI_VDEVICE(INTEL, 0x2289), (unsigned long)&pwm_lpss_bsw_info}, |
diff --git a/drivers/pwm/pwm-lpss-platform.c b/drivers/pwm/pwm-lpss-platform.c index b22b6fdadb9a..5d6ed1507d29 100644 --- a/drivers/pwm/pwm-lpss-platform.c +++ b/drivers/pwm/pwm-lpss-platform.c | |||
@@ -37,6 +37,7 @@ static const struct pwm_lpss_boardinfo pwm_lpss_bxt_info = { | |||
37 | .clk_rate = 19200000, | 37 | .clk_rate = 19200000, |
38 | .npwm = 4, | 38 | .npwm = 4, |
39 | .base_unit_bits = 22, | 39 | .base_unit_bits = 22, |
40 | .bypass = true, | ||
40 | }; | 41 | }; |
41 | 42 | ||
42 | static int pwm_lpss_probe_platform(struct platform_device *pdev) | 43 | static int pwm_lpss_probe_platform(struct platform_device *pdev) |
diff --git a/drivers/pwm/pwm-lpss.c b/drivers/pwm/pwm-lpss.c index 689d2c1cbead..8db0d40ccacd 100644 --- a/drivers/pwm/pwm-lpss.c +++ b/drivers/pwm/pwm-lpss.c | |||
@@ -57,7 +57,7 @@ static inline void pwm_lpss_write(const struct pwm_device *pwm, u32 value) | |||
57 | writel(value, lpwm->regs + pwm->hwpwm * PWM_SIZE + PWM); | 57 | writel(value, lpwm->regs + pwm->hwpwm * PWM_SIZE + PWM); |
58 | } | 58 | } |
59 | 59 | ||
60 | static int pwm_lpss_update(struct pwm_device *pwm) | 60 | static int pwm_lpss_wait_for_update(struct pwm_device *pwm) |
61 | { | 61 | { |
62 | struct pwm_lpss_chip *lpwm = to_lpwm(pwm->chip); | 62 | struct pwm_lpss_chip *lpwm = to_lpwm(pwm->chip); |
63 | const void __iomem *addr = lpwm->regs + pwm->hwpwm * PWM_SIZE + PWM; | 63 | const void __iomem *addr = lpwm->regs + pwm->hwpwm * PWM_SIZE + PWM; |
@@ -65,8 +65,6 @@ static int pwm_lpss_update(struct pwm_device *pwm) | |||
65 | u32 val; | 65 | u32 val; |
66 | int err; | 66 | int err; |
67 | 67 | ||
68 | pwm_lpss_write(pwm, pwm_lpss_read(pwm) | PWM_SW_UPDATE); | ||
69 | |||
70 | /* | 68 | /* |
71 | * PWM Configuration register has SW_UPDATE bit that is set when a new | 69 | * PWM Configuration register has SW_UPDATE bit that is set when a new |
72 | * configuration is written to the register. The bit is automatically | 70 | * configuration is written to the register. The bit is automatically |
@@ -122,6 +120,12 @@ static void pwm_lpss_prepare(struct pwm_lpss_chip *lpwm, struct pwm_device *pwm, | |||
122 | pwm_lpss_write(pwm, ctrl); | 120 | pwm_lpss_write(pwm, ctrl); |
123 | } | 121 | } |
124 | 122 | ||
123 | static inline void pwm_lpss_cond_enable(struct pwm_device *pwm, bool cond) | ||
124 | { | ||
125 | if (cond) | ||
126 | pwm_lpss_write(pwm, pwm_lpss_read(pwm) | PWM_ENABLE); | ||
127 | } | ||
128 | |||
125 | static int pwm_lpss_apply(struct pwm_chip *chip, struct pwm_device *pwm, | 129 | static int pwm_lpss_apply(struct pwm_chip *chip, struct pwm_device *pwm, |
126 | struct pwm_state *state) | 130 | struct pwm_state *state) |
127 | { | 131 | { |
@@ -137,18 +141,21 @@ static int pwm_lpss_apply(struct pwm_chip *chip, struct pwm_device *pwm, | |||
137 | return ret; | 141 | return ret; |
138 | } | 142 | } |
139 | pwm_lpss_prepare(lpwm, pwm, state->duty_cycle, state->period); | 143 | pwm_lpss_prepare(lpwm, pwm, state->duty_cycle, state->period); |
140 | ret = pwm_lpss_update(pwm); | 144 | pwm_lpss_write(pwm, pwm_lpss_read(pwm) | PWM_SW_UPDATE); |
145 | pwm_lpss_cond_enable(pwm, lpwm->info->bypass == false); | ||
146 | ret = pwm_lpss_wait_for_update(pwm); | ||
141 | if (ret) { | 147 | if (ret) { |
142 | pm_runtime_put(chip->dev); | 148 | pm_runtime_put(chip->dev); |
143 | return ret; | 149 | return ret; |
144 | } | 150 | } |
145 | pwm_lpss_write(pwm, pwm_lpss_read(pwm) | PWM_ENABLE); | 151 | pwm_lpss_cond_enable(pwm, lpwm->info->bypass == true); |
146 | } else { | 152 | } else { |
147 | ret = pwm_lpss_is_updating(pwm); | 153 | ret = pwm_lpss_is_updating(pwm); |
148 | if (ret) | 154 | if (ret) |
149 | return ret; | 155 | return ret; |
150 | pwm_lpss_prepare(lpwm, pwm, state->duty_cycle, state->period); | 156 | pwm_lpss_prepare(lpwm, pwm, state->duty_cycle, state->period); |
151 | return pwm_lpss_update(pwm); | 157 | pwm_lpss_write(pwm, pwm_lpss_read(pwm) | PWM_SW_UPDATE); |
158 | return pwm_lpss_wait_for_update(pwm); | ||
152 | } | 159 | } |
153 | } else if (pwm_is_enabled(pwm)) { | 160 | } else if (pwm_is_enabled(pwm)) { |
154 | pwm_lpss_write(pwm, pwm_lpss_read(pwm) & ~PWM_ENABLE); | 161 | pwm_lpss_write(pwm, pwm_lpss_read(pwm) & ~PWM_ENABLE); |
diff --git a/drivers/pwm/pwm-lpss.h b/drivers/pwm/pwm-lpss.h index c94cd7c2695d..98306bb02cfe 100644 --- a/drivers/pwm/pwm-lpss.h +++ b/drivers/pwm/pwm-lpss.h | |||
@@ -22,6 +22,7 @@ struct pwm_lpss_boardinfo { | |||
22 | unsigned long clk_rate; | 22 | unsigned long clk_rate; |
23 | unsigned int npwm; | 23 | unsigned int npwm; |
24 | unsigned long base_unit_bits; | 24 | unsigned long base_unit_bits; |
25 | bool bypass; | ||
25 | }; | 26 | }; |
26 | 27 | ||
27 | struct pwm_lpss_chip *pwm_lpss_probe(struct device *dev, struct resource *r, | 28 | struct pwm_lpss_chip *pwm_lpss_probe(struct device *dev, struct resource *r, |
diff --git a/drivers/pwm/pwm-rockchip.c b/drivers/pwm/pwm-rockchip.c index ef89df1f7336..744d56197286 100644 --- a/drivers/pwm/pwm-rockchip.c +++ b/drivers/pwm/pwm-rockchip.c | |||
@@ -191,6 +191,28 @@ static int rockchip_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, | |||
191 | return 0; | 191 | return 0; |
192 | } | 192 | } |
193 | 193 | ||
194 | static int rockchip_pwm_enable(struct pwm_chip *chip, | ||
195 | struct pwm_device *pwm, | ||
196 | bool enable, | ||
197 | enum pwm_polarity polarity) | ||
198 | { | ||
199 | struct rockchip_pwm_chip *pc = to_rockchip_pwm_chip(chip); | ||
200 | int ret; | ||
201 | |||
202 | if (enable) { | ||
203 | ret = clk_enable(pc->clk); | ||
204 | if (ret) | ||
205 | return ret; | ||
206 | } | ||
207 | |||
208 | pc->data->set_enable(chip, pwm, enable, polarity); | ||
209 | |||
210 | if (!enable) | ||
211 | clk_disable(pc->clk); | ||
212 | |||
213 | return 0; | ||
214 | } | ||
215 | |||
194 | static int rockchip_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, | 216 | static int rockchip_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, |
195 | struct pwm_state *state) | 217 | struct pwm_state *state) |
196 | { | 218 | { |
@@ -207,22 +229,26 @@ static int rockchip_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, | |||
207 | return ret; | 229 | return ret; |
208 | 230 | ||
209 | if (state->polarity != curstate.polarity && enabled) { | 231 | if (state->polarity != curstate.polarity && enabled) { |
210 | pc->data->set_enable(chip, pwm, false, state->polarity); | 232 | ret = rockchip_pwm_enable(chip, pwm, false, state->polarity); |
233 | if (ret) | ||
234 | goto out; | ||
211 | enabled = false; | 235 | enabled = false; |
212 | } | 236 | } |
213 | 237 | ||
214 | ret = rockchip_pwm_config(chip, pwm, state->duty_cycle, state->period); | 238 | ret = rockchip_pwm_config(chip, pwm, state->duty_cycle, state->period); |
215 | if (ret) { | 239 | if (ret) { |
216 | if (enabled != curstate.enabled) | 240 | if (enabled != curstate.enabled) |
217 | pc->data->set_enable(chip, pwm, !enabled, | 241 | rockchip_pwm_enable(chip, pwm, !enabled, |
218 | state->polarity); | 242 | state->polarity); |
219 | |||
220 | goto out; | 243 | goto out; |
221 | } | 244 | } |
222 | 245 | ||
223 | if (state->enabled != enabled) | 246 | if (state->enabled != enabled) { |
224 | pc->data->set_enable(chip, pwm, state->enabled, | 247 | ret = rockchip_pwm_enable(chip, pwm, state->enabled, |
225 | state->polarity); | 248 | state->polarity); |
249 | if (ret) | ||
250 | goto out; | ||
251 | } | ||
226 | 252 | ||
227 | /* | 253 | /* |
228 | * Update the state with the real hardware, which can differ a bit | 254 | * Update the state with the real hardware, which can differ a bit |
diff --git a/drivers/rapidio/devices/tsi721.c b/drivers/rapidio/devices/tsi721.c index 9d19b9a62011..315a4be8dc1e 100644 --- a/drivers/rapidio/devices/tsi721.c +++ b/drivers/rapidio/devices/tsi721.c | |||
@@ -37,8 +37,8 @@ | |||
37 | #include "tsi721.h" | 37 | #include "tsi721.h" |
38 | 38 | ||
39 | #ifdef DEBUG | 39 | #ifdef DEBUG |
40 | u32 dbg_level; | 40 | u32 tsi_dbg_level; |
41 | module_param(dbg_level, uint, S_IWUSR | S_IRUGO); | 41 | module_param_named(dbg_level, tsi_dbg_level, uint, S_IWUSR | S_IRUGO); |
42 | MODULE_PARM_DESC(dbg_level, "Debugging output level (default 0 = none)"); | 42 | MODULE_PARM_DESC(dbg_level, "Debugging output level (default 0 = none)"); |
43 | #endif | 43 | #endif |
44 | 44 | ||
diff --git a/drivers/rapidio/devices/tsi721.h b/drivers/rapidio/devices/tsi721.h index 5941437cbdd1..957eadc58150 100644 --- a/drivers/rapidio/devices/tsi721.h +++ b/drivers/rapidio/devices/tsi721.h | |||
@@ -40,11 +40,11 @@ enum { | |||
40 | }; | 40 | }; |
41 | 41 | ||
42 | #ifdef DEBUG | 42 | #ifdef DEBUG |
43 | extern u32 dbg_level; | 43 | extern u32 tsi_dbg_level; |
44 | 44 | ||
45 | #define tsi_debug(level, dev, fmt, arg...) \ | 45 | #define tsi_debug(level, dev, fmt, arg...) \ |
46 | do { \ | 46 | do { \ |
47 | if (DBG_##level & dbg_level) \ | 47 | if (DBG_##level & tsi_dbg_level) \ |
48 | dev_dbg(dev, "%s: " fmt "\n", __func__, ##arg); \ | 48 | dev_dbg(dev, "%s: " fmt "\n", __func__, ##arg); \ |
49 | } while (0) | 49 | } while (0) |
50 | #else | 50 | #else |
diff --git a/drivers/reset/core.c b/drivers/reset/core.c index f1e5e65388bb..cd739d2fa160 100644 --- a/drivers/reset/core.c +++ b/drivers/reset/core.c | |||
@@ -275,7 +275,7 @@ int reset_control_status(struct reset_control *rstc) | |||
275 | } | 275 | } |
276 | EXPORT_SYMBOL_GPL(reset_control_status); | 276 | EXPORT_SYMBOL_GPL(reset_control_status); |
277 | 277 | ||
278 | static struct reset_control *__reset_control_get( | 278 | static struct reset_control *__reset_control_get_internal( |
279 | struct reset_controller_dev *rcdev, | 279 | struct reset_controller_dev *rcdev, |
280 | unsigned int index, bool shared) | 280 | unsigned int index, bool shared) |
281 | { | 281 | { |
@@ -308,7 +308,7 @@ static struct reset_control *__reset_control_get( | |||
308 | return rstc; | 308 | return rstc; |
309 | } | 309 | } |
310 | 310 | ||
311 | static void __reset_control_put(struct reset_control *rstc) | 311 | static void __reset_control_put_internal(struct reset_control *rstc) |
312 | { | 312 | { |
313 | lockdep_assert_held(&reset_list_mutex); | 313 | lockdep_assert_held(&reset_list_mutex); |
314 | 314 | ||
@@ -377,7 +377,7 @@ struct reset_control *__of_reset_control_get(struct device_node *node, | |||
377 | } | 377 | } |
378 | 378 | ||
379 | /* reset_list_mutex also protects the rcdev's reset_control list */ | 379 | /* reset_list_mutex also protects the rcdev's reset_control list */ |
380 | rstc = __reset_control_get(rcdev, rstc_id, shared); | 380 | rstc = __reset_control_get_internal(rcdev, rstc_id, shared); |
381 | 381 | ||
382 | mutex_unlock(&reset_list_mutex); | 382 | mutex_unlock(&reset_list_mutex); |
383 | 383 | ||
@@ -385,6 +385,17 @@ struct reset_control *__of_reset_control_get(struct device_node *node, | |||
385 | } | 385 | } |
386 | EXPORT_SYMBOL_GPL(__of_reset_control_get); | 386 | EXPORT_SYMBOL_GPL(__of_reset_control_get); |
387 | 387 | ||
388 | struct reset_control *__reset_control_get(struct device *dev, const char *id, | ||
389 | int index, bool shared, bool optional) | ||
390 | { | ||
391 | if (dev->of_node) | ||
392 | return __of_reset_control_get(dev->of_node, id, index, shared, | ||
393 | optional); | ||
394 | |||
395 | return optional ? NULL : ERR_PTR(-EINVAL); | ||
396 | } | ||
397 | EXPORT_SYMBOL_GPL(__reset_control_get); | ||
398 | |||
388 | /** | 399 | /** |
389 | * reset_control_put - free the reset controller | 400 | * reset_control_put - free the reset controller |
390 | * @rstc: reset controller | 401 | * @rstc: reset controller |
@@ -396,7 +407,7 @@ void reset_control_put(struct reset_control *rstc) | |||
396 | return; | 407 | return; |
397 | 408 | ||
398 | mutex_lock(&reset_list_mutex); | 409 | mutex_lock(&reset_list_mutex); |
399 | __reset_control_put(rstc); | 410 | __reset_control_put_internal(rstc); |
400 | mutex_unlock(&reset_list_mutex); | 411 | mutex_unlock(&reset_list_mutex); |
401 | } | 412 | } |
402 | EXPORT_SYMBOL_GPL(reset_control_put); | 413 | EXPORT_SYMBOL_GPL(reset_control_put); |
@@ -417,8 +428,7 @@ struct reset_control *__devm_reset_control_get(struct device *dev, | |||
417 | if (!ptr) | 428 | if (!ptr) |
418 | return ERR_PTR(-ENOMEM); | 429 | return ERR_PTR(-ENOMEM); |
419 | 430 | ||
420 | rstc = __of_reset_control_get(dev ? dev->of_node : NULL, | 431 | rstc = __reset_control_get(dev, id, index, shared, optional); |
421 | id, index, shared, optional); | ||
422 | if (!IS_ERR(rstc)) { | 432 | if (!IS_ERR(rstc)) { |
423 | *ptr = rstc; | 433 | *ptr = rstc; |
424 | devres_add(dev, ptr); | 434 | devres_add(dev, ptr); |
diff --git a/drivers/s390/crypto/pkey_api.c b/drivers/s390/crypto/pkey_api.c index 40f1136f5568..058db724b5a2 100644 --- a/drivers/s390/crypto/pkey_api.c +++ b/drivers/s390/crypto/pkey_api.c | |||
@@ -572,6 +572,12 @@ int pkey_sec2protkey(u16 cardnr, u16 domain, | |||
572 | rc = -EIO; | 572 | rc = -EIO; |
573 | goto out; | 573 | goto out; |
574 | } | 574 | } |
575 | if (prepcblk->ccp_rscode != 0) { | ||
576 | DEBUG_WARN( | ||
577 | "pkey_sec2protkey unwrap secure key warning, card response %d/%d\n", | ||
578 | (int) prepcblk->ccp_rtcode, | ||
579 | (int) prepcblk->ccp_rscode); | ||
580 | } | ||
575 | 581 | ||
576 | /* process response cprb param block */ | 582 | /* process response cprb param block */ |
577 | prepcblk->rpl_parmb = ((u8 *) prepcblk) + sizeof(struct CPRBX); | 583 | prepcblk->rpl_parmb = ((u8 *) prepcblk) + sizeof(struct CPRBX); |
@@ -761,9 +767,10 @@ out: | |||
761 | } | 767 | } |
762 | 768 | ||
763 | /* | 769 | /* |
764 | * Fetch just the mkvp value via query_crypto_facility from adapter. | 770 | * Fetch the current and old mkvp values via |
771 | * query_crypto_facility from adapter. | ||
765 | */ | 772 | */ |
766 | static int fetch_mkvp(u16 cardnr, u16 domain, u64 *mkvp) | 773 | static int fetch_mkvp(u16 cardnr, u16 domain, u64 mkvp[2]) |
767 | { | 774 | { |
768 | int rc, found = 0; | 775 | int rc, found = 0; |
769 | size_t rlen, vlen; | 776 | size_t rlen, vlen; |
@@ -779,9 +786,10 @@ static int fetch_mkvp(u16 cardnr, u16 domain, u64 *mkvp) | |||
779 | rc = query_crypto_facility(cardnr, domain, "STATICSA", | 786 | rc = query_crypto_facility(cardnr, domain, "STATICSA", |
780 | rarray, &rlen, varray, &vlen); | 787 | rarray, &rlen, varray, &vlen); |
781 | if (rc == 0 && rlen > 8*8 && vlen > 184+8) { | 788 | if (rc == 0 && rlen > 8*8 && vlen > 184+8) { |
782 | if (rarray[64] == '2') { | 789 | if (rarray[8*8] == '2') { |
783 | /* current master key state is valid */ | 790 | /* current master key state is valid */ |
784 | *mkvp = *((u64 *)(varray + 184)); | 791 | mkvp[0] = *((u64 *)(varray + 184)); |
792 | mkvp[1] = *((u64 *)(varray + 172)); | ||
785 | found = 1; | 793 | found = 1; |
786 | } | 794 | } |
787 | } | 795 | } |
@@ -796,14 +804,14 @@ struct mkvp_info { | |||
796 | struct list_head list; | 804 | struct list_head list; |
797 | u16 cardnr; | 805 | u16 cardnr; |
798 | u16 domain; | 806 | u16 domain; |
799 | u64 mkvp; | 807 | u64 mkvp[2]; |
800 | }; | 808 | }; |
801 | 809 | ||
802 | /* a list with mkvp_info entries */ | 810 | /* a list with mkvp_info entries */ |
803 | static LIST_HEAD(mkvp_list); | 811 | static LIST_HEAD(mkvp_list); |
804 | static DEFINE_SPINLOCK(mkvp_list_lock); | 812 | static DEFINE_SPINLOCK(mkvp_list_lock); |
805 | 813 | ||
806 | static int mkvp_cache_fetch(u16 cardnr, u16 domain, u64 *mkvp) | 814 | static int mkvp_cache_fetch(u16 cardnr, u16 domain, u64 mkvp[2]) |
807 | { | 815 | { |
808 | int rc = -ENOENT; | 816 | int rc = -ENOENT; |
809 | struct mkvp_info *ptr; | 817 | struct mkvp_info *ptr; |
@@ -812,7 +820,7 @@ static int mkvp_cache_fetch(u16 cardnr, u16 domain, u64 *mkvp) | |||
812 | list_for_each_entry(ptr, &mkvp_list, list) { | 820 | list_for_each_entry(ptr, &mkvp_list, list) { |
813 | if (ptr->cardnr == cardnr && | 821 | if (ptr->cardnr == cardnr && |
814 | ptr->domain == domain) { | 822 | ptr->domain == domain) { |
815 | *mkvp = ptr->mkvp; | 823 | memcpy(mkvp, ptr->mkvp, 2 * sizeof(u64)); |
816 | rc = 0; | 824 | rc = 0; |
817 | break; | 825 | break; |
818 | } | 826 | } |
@@ -822,7 +830,7 @@ static int mkvp_cache_fetch(u16 cardnr, u16 domain, u64 *mkvp) | |||
822 | return rc; | 830 | return rc; |
823 | } | 831 | } |
824 | 832 | ||
825 | static void mkvp_cache_update(u16 cardnr, u16 domain, u64 mkvp) | 833 | static void mkvp_cache_update(u16 cardnr, u16 domain, u64 mkvp[2]) |
826 | { | 834 | { |
827 | int found = 0; | 835 | int found = 0; |
828 | struct mkvp_info *ptr; | 836 | struct mkvp_info *ptr; |
@@ -831,7 +839,7 @@ static void mkvp_cache_update(u16 cardnr, u16 domain, u64 mkvp) | |||
831 | list_for_each_entry(ptr, &mkvp_list, list) { | 839 | list_for_each_entry(ptr, &mkvp_list, list) { |
832 | if (ptr->cardnr == cardnr && | 840 | if (ptr->cardnr == cardnr && |
833 | ptr->domain == domain) { | 841 | ptr->domain == domain) { |
834 | ptr->mkvp = mkvp; | 842 | memcpy(ptr->mkvp, mkvp, 2 * sizeof(u64)); |
835 | found = 1; | 843 | found = 1; |
836 | break; | 844 | break; |
837 | } | 845 | } |
@@ -844,7 +852,7 @@ static void mkvp_cache_update(u16 cardnr, u16 domain, u64 mkvp) | |||
844 | } | 852 | } |
845 | ptr->cardnr = cardnr; | 853 | ptr->cardnr = cardnr; |
846 | ptr->domain = domain; | 854 | ptr->domain = domain; |
847 | ptr->mkvp = mkvp; | 855 | memcpy(ptr->mkvp, mkvp, 2 * sizeof(u64)); |
848 | list_add(&ptr->list, &mkvp_list); | 856 | list_add(&ptr->list, &mkvp_list); |
849 | } | 857 | } |
850 | spin_unlock_bh(&mkvp_list_lock); | 858 | spin_unlock_bh(&mkvp_list_lock); |
@@ -888,8 +896,8 @@ int pkey_findcard(const struct pkey_seckey *seckey, | |||
888 | struct secaeskeytoken *t = (struct secaeskeytoken *) seckey; | 896 | struct secaeskeytoken *t = (struct secaeskeytoken *) seckey; |
889 | struct zcrypt_device_matrix *device_matrix; | 897 | struct zcrypt_device_matrix *device_matrix; |
890 | u16 card, dom; | 898 | u16 card, dom; |
891 | u64 mkvp; | 899 | u64 mkvp[2]; |
892 | int i, rc; | 900 | int i, rc, oi = -1; |
893 | 901 | ||
894 | /* mkvp must not be zero */ | 902 | /* mkvp must not be zero */ |
895 | if (t->mkvp == 0) | 903 | if (t->mkvp == 0) |
@@ -910,14 +918,14 @@ int pkey_findcard(const struct pkey_seckey *seckey, | |||
910 | device_matrix->device[i].functions & 0x04) { | 918 | device_matrix->device[i].functions & 0x04) { |
911 | /* an enabled CCA Coprocessor card */ | 919 | /* an enabled CCA Coprocessor card */ |
912 | /* try cached mkvp */ | 920 | /* try cached mkvp */ |
913 | if (mkvp_cache_fetch(card, dom, &mkvp) == 0 && | 921 | if (mkvp_cache_fetch(card, dom, mkvp) == 0 && |
914 | t->mkvp == mkvp) { | 922 | t->mkvp == mkvp[0]) { |
915 | if (!verify) | 923 | if (!verify) |
916 | break; | 924 | break; |
917 | /* verify: fetch mkvp from adapter */ | 925 | /* verify: fetch mkvp from adapter */ |
918 | if (fetch_mkvp(card, dom, &mkvp) == 0) { | 926 | if (fetch_mkvp(card, dom, mkvp) == 0) { |
919 | mkvp_cache_update(card, dom, mkvp); | 927 | mkvp_cache_update(card, dom, mkvp); |
920 | if (t->mkvp == mkvp) | 928 | if (t->mkvp == mkvp[0]) |
921 | break; | 929 | break; |
922 | } | 930 | } |
923 | } | 931 | } |
@@ -936,14 +944,21 @@ int pkey_findcard(const struct pkey_seckey *seckey, | |||
936 | card = AP_QID_CARD(device_matrix->device[i].qid); | 944 | card = AP_QID_CARD(device_matrix->device[i].qid); |
937 | dom = AP_QID_QUEUE(device_matrix->device[i].qid); | 945 | dom = AP_QID_QUEUE(device_matrix->device[i].qid); |
938 | /* fresh fetch mkvp from adapter */ | 946 | /* fresh fetch mkvp from adapter */ |
939 | if (fetch_mkvp(card, dom, &mkvp) == 0) { | 947 | if (fetch_mkvp(card, dom, mkvp) == 0) { |
940 | mkvp_cache_update(card, dom, mkvp); | 948 | mkvp_cache_update(card, dom, mkvp); |
941 | if (t->mkvp == mkvp) | 949 | if (t->mkvp == mkvp[0]) |
942 | break; | 950 | break; |
951 | if (t->mkvp == mkvp[1] && oi < 0) | ||
952 | oi = i; | ||
943 | } | 953 | } |
944 | } | 954 | } |
955 | if (i >= MAX_ZDEV_ENTRIES && oi >= 0) { | ||
956 | /* old mkvp matched, use this card then */ | ||
957 | card = AP_QID_CARD(device_matrix->device[oi].qid); | ||
958 | dom = AP_QID_QUEUE(device_matrix->device[oi].qid); | ||
959 | } | ||
945 | } | 960 | } |
946 | if (i < MAX_ZDEV_ENTRIES) { | 961 | if (i < MAX_ZDEV_ENTRIES || oi >= 0) { |
947 | if (pcardnr) | 962 | if (pcardnr) |
948 | *pcardnr = card; | 963 | *pcardnr = card; |
949 | if (pdomain) | 964 | if (pdomain) |
diff --git a/drivers/s390/net/qeth_core.h b/drivers/s390/net/qeth_core.h index e7addea8741b..d9561e39c3b2 100644 --- a/drivers/s390/net/qeth_core.h +++ b/drivers/s390/net/qeth_core.h | |||
@@ -961,7 +961,8 @@ int qeth_bridgeport_query_ports(struct qeth_card *card, | |||
961 | int qeth_bridgeport_setrole(struct qeth_card *card, enum qeth_sbp_roles role); | 961 | int qeth_bridgeport_setrole(struct qeth_card *card, enum qeth_sbp_roles role); |
962 | int qeth_bridgeport_an_set(struct qeth_card *card, int enable); | 962 | int qeth_bridgeport_an_set(struct qeth_card *card, int enable); |
963 | int qeth_get_priority_queue(struct qeth_card *, struct sk_buff *, int, int); | 963 | int qeth_get_priority_queue(struct qeth_card *, struct sk_buff *, int, int); |
964 | int qeth_get_elements_no(struct qeth_card *, struct sk_buff *, int); | 964 | int qeth_get_elements_no(struct qeth_card *card, struct sk_buff *skb, |
965 | int extra_elems, int data_offset); | ||
965 | int qeth_get_elements_for_frags(struct sk_buff *); | 966 | int qeth_get_elements_for_frags(struct sk_buff *); |
966 | int qeth_do_send_packet_fast(struct qeth_card *, struct qeth_qdio_out_q *, | 967 | int qeth_do_send_packet_fast(struct qeth_card *, struct qeth_qdio_out_q *, |
967 | struct sk_buff *, struct qeth_hdr *, int, int, int); | 968 | struct sk_buff *, struct qeth_hdr *, int, int, int); |
diff --git a/drivers/s390/net/qeth_core_main.c b/drivers/s390/net/qeth_core_main.c index 315d8a2db7c0..9a5f99ccb122 100644 --- a/drivers/s390/net/qeth_core_main.c +++ b/drivers/s390/net/qeth_core_main.c | |||
@@ -3837,6 +3837,7 @@ EXPORT_SYMBOL_GPL(qeth_get_elements_for_frags); | |||
3837 | * @card: qeth card structure, to check max. elems. | 3837 | * @card: qeth card structure, to check max. elems. |
3838 | * @skb: SKB address | 3838 | * @skb: SKB address |
3839 | * @extra_elems: extra elems needed, to check against max. | 3839 | * @extra_elems: extra elems needed, to check against max. |
3840 | * @data_offset: range starts at skb->data + data_offset | ||
3840 | * | 3841 | * |
3841 | * Returns the number of pages, and thus QDIO buffer elements, needed to cover | 3842 | * Returns the number of pages, and thus QDIO buffer elements, needed to cover |
3842 | * skb data, including linear part and fragments. Checks if the result plus | 3843 | * skb data, including linear part and fragments. Checks if the result plus |
@@ -3844,10 +3845,10 @@ EXPORT_SYMBOL_GPL(qeth_get_elements_for_frags); | |||
3844 | * Note: extra_elems is not included in the returned result. | 3845 | * Note: extra_elems is not included in the returned result. |
3845 | */ | 3846 | */ |
3846 | int qeth_get_elements_no(struct qeth_card *card, | 3847 | int qeth_get_elements_no(struct qeth_card *card, |
3847 | struct sk_buff *skb, int extra_elems) | 3848 | struct sk_buff *skb, int extra_elems, int data_offset) |
3848 | { | 3849 | { |
3849 | int elements = qeth_get_elements_for_range( | 3850 | int elements = qeth_get_elements_for_range( |
3850 | (addr_t)skb->data, | 3851 | (addr_t)skb->data + data_offset, |
3851 | (addr_t)skb->data + skb_headlen(skb)) + | 3852 | (addr_t)skb->data + skb_headlen(skb)) + |
3852 | qeth_get_elements_for_frags(skb); | 3853 | qeth_get_elements_for_frags(skb); |
3853 | 3854 | ||
diff --git a/drivers/s390/net/qeth_l2_main.c b/drivers/s390/net/qeth_l2_main.c index bea483307618..af4e6a639fec 100644 --- a/drivers/s390/net/qeth_l2_main.c +++ b/drivers/s390/net/qeth_l2_main.c | |||
@@ -849,7 +849,7 @@ static int qeth_l2_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
849 | * chaining we can not send long frag lists | 849 | * chaining we can not send long frag lists |
850 | */ | 850 | */ |
851 | if ((card->info.type != QETH_CARD_TYPE_IQD) && | 851 | if ((card->info.type != QETH_CARD_TYPE_IQD) && |
852 | !qeth_get_elements_no(card, new_skb, 0)) { | 852 | !qeth_get_elements_no(card, new_skb, 0, 0)) { |
853 | int lin_rc = skb_linearize(new_skb); | 853 | int lin_rc = skb_linearize(new_skb); |
854 | 854 | ||
855 | if (card->options.performance_stats) { | 855 | if (card->options.performance_stats) { |
@@ -894,7 +894,8 @@ static int qeth_l2_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
894 | } | 894 | } |
895 | } | 895 | } |
896 | 896 | ||
897 | elements = qeth_get_elements_no(card, new_skb, elements_needed); | 897 | elements = qeth_get_elements_no(card, new_skb, elements_needed, |
898 | (data_offset > 0) ? data_offset : 0); | ||
898 | if (!elements) { | 899 | if (!elements) { |
899 | if (data_offset >= 0) | 900 | if (data_offset >= 0) |
900 | kmem_cache_free(qeth_core_header_cache, hdr); | 901 | kmem_cache_free(qeth_core_header_cache, hdr); |
diff --git a/drivers/s390/net/qeth_l3_main.c b/drivers/s390/net/qeth_l3_main.c index 06d0addcc058..653f0fb76573 100644 --- a/drivers/s390/net/qeth_l3_main.c +++ b/drivers/s390/net/qeth_l3_main.c | |||
@@ -2609,17 +2609,13 @@ static void qeth_l3_fill_af_iucv_hdr(struct qeth_card *card, | |||
2609 | char daddr[16]; | 2609 | char daddr[16]; |
2610 | struct af_iucv_trans_hdr *iucv_hdr; | 2610 | struct af_iucv_trans_hdr *iucv_hdr; |
2611 | 2611 | ||
2612 | skb_pull(skb, 14); | ||
2613 | card->dev->header_ops->create(skb, card->dev, 0, | ||
2614 | card->dev->dev_addr, card->dev->dev_addr, | ||
2615 | card->dev->addr_len); | ||
2616 | skb_pull(skb, 14); | ||
2617 | iucv_hdr = (struct af_iucv_trans_hdr *)skb->data; | ||
2618 | memset(hdr, 0, sizeof(struct qeth_hdr)); | 2612 | memset(hdr, 0, sizeof(struct qeth_hdr)); |
2619 | hdr->hdr.l3.id = QETH_HEADER_TYPE_LAYER3; | 2613 | hdr->hdr.l3.id = QETH_HEADER_TYPE_LAYER3; |
2620 | hdr->hdr.l3.ext_flags = 0; | 2614 | hdr->hdr.l3.ext_flags = 0; |
2621 | hdr->hdr.l3.length = skb->len; | 2615 | hdr->hdr.l3.length = skb->len - ETH_HLEN; |
2622 | hdr->hdr.l3.flags = QETH_HDR_IPV6 | QETH_CAST_UNICAST; | 2616 | hdr->hdr.l3.flags = QETH_HDR_IPV6 | QETH_CAST_UNICAST; |
2617 | |||
2618 | iucv_hdr = (struct af_iucv_trans_hdr *) (skb->data + ETH_HLEN); | ||
2623 | memset(daddr, 0, sizeof(daddr)); | 2619 | memset(daddr, 0, sizeof(daddr)); |
2624 | daddr[0] = 0xfe; | 2620 | daddr[0] = 0xfe; |
2625 | daddr[1] = 0x80; | 2621 | daddr[1] = 0x80; |
@@ -2823,10 +2819,7 @@ static int qeth_l3_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
2823 | if ((card->info.type == QETH_CARD_TYPE_IQD) && | 2819 | if ((card->info.type == QETH_CARD_TYPE_IQD) && |
2824 | !skb_is_nonlinear(skb)) { | 2820 | !skb_is_nonlinear(skb)) { |
2825 | new_skb = skb; | 2821 | new_skb = skb; |
2826 | if (new_skb->protocol == ETH_P_AF_IUCV) | 2822 | data_offset = ETH_HLEN; |
2827 | data_offset = 0; | ||
2828 | else | ||
2829 | data_offset = ETH_HLEN; | ||
2830 | hdr = kmem_cache_alloc(qeth_core_header_cache, GFP_ATOMIC); | 2823 | hdr = kmem_cache_alloc(qeth_core_header_cache, GFP_ATOMIC); |
2831 | if (!hdr) | 2824 | if (!hdr) |
2832 | goto tx_drop; | 2825 | goto tx_drop; |
@@ -2867,7 +2860,7 @@ static int qeth_l3_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
2867 | */ | 2860 | */ |
2868 | if ((card->info.type != QETH_CARD_TYPE_IQD) && | 2861 | if ((card->info.type != QETH_CARD_TYPE_IQD) && |
2869 | ((use_tso && !qeth_l3_get_elements_no_tso(card, new_skb, 1)) || | 2862 | ((use_tso && !qeth_l3_get_elements_no_tso(card, new_skb, 1)) || |
2870 | (!use_tso && !qeth_get_elements_no(card, new_skb, 0)))) { | 2863 | (!use_tso && !qeth_get_elements_no(card, new_skb, 0, 0)))) { |
2871 | int lin_rc = skb_linearize(new_skb); | 2864 | int lin_rc = skb_linearize(new_skb); |
2872 | 2865 | ||
2873 | if (card->options.performance_stats) { | 2866 | if (card->options.performance_stats) { |
@@ -2909,7 +2902,8 @@ static int qeth_l3_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
2909 | 2902 | ||
2910 | elements = use_tso ? | 2903 | elements = use_tso ? |
2911 | qeth_l3_get_elements_no_tso(card, new_skb, hdr_elements) : | 2904 | qeth_l3_get_elements_no_tso(card, new_skb, hdr_elements) : |
2912 | qeth_get_elements_no(card, new_skb, hdr_elements); | 2905 | qeth_get_elements_no(card, new_skb, hdr_elements, |
2906 | (data_offset > 0) ? data_offset : 0); | ||
2913 | if (!elements) { | 2907 | if (!elements) { |
2914 | if (data_offset >= 0) | 2908 | if (data_offset >= 0) |
2915 | kmem_cache_free(qeth_core_header_cache, hdr); | 2909 | kmem_cache_free(qeth_core_header_cache, hdr); |
diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h index d036a806f31c..d281492009fb 100644 --- a/drivers/scsi/aacraid/aacraid.h +++ b/drivers/scsi/aacraid/aacraid.h | |||
@@ -1690,9 +1690,6 @@ struct aac_dev | |||
1690 | #define aac_adapter_sync_cmd(dev, command, p1, p2, p3, p4, p5, p6, status, r1, r2, r3, r4) \ | 1690 | #define aac_adapter_sync_cmd(dev, command, p1, p2, p3, p4, p5, p6, status, r1, r2, r3, r4) \ |
1691 | (dev)->a_ops.adapter_sync_cmd(dev, command, p1, p2, p3, p4, p5, p6, status, r1, r2, r3, r4) | 1691 | (dev)->a_ops.adapter_sync_cmd(dev, command, p1, p2, p3, p4, p5, p6, status, r1, r2, r3, r4) |
1692 | 1692 | ||
1693 | #define aac_adapter_check_health(dev) \ | ||
1694 | (dev)->a_ops.adapter_check_health(dev) | ||
1695 | |||
1696 | #define aac_adapter_restart(dev, bled, reset_type) \ | 1693 | #define aac_adapter_restart(dev, bled, reset_type) \ |
1697 | ((dev)->a_ops.adapter_restart(dev, bled, reset_type)) | 1694 | ((dev)->a_ops.adapter_restart(dev, bled, reset_type)) |
1698 | 1695 | ||
@@ -2615,6 +2612,14 @@ static inline unsigned int cap_to_cyls(sector_t capacity, unsigned divisor) | |||
2615 | return capacity; | 2612 | return capacity; |
2616 | } | 2613 | } |
2617 | 2614 | ||
2615 | static inline int aac_adapter_check_health(struct aac_dev *dev) | ||
2616 | { | ||
2617 | if (unlikely(pci_channel_offline(dev->pdev))) | ||
2618 | return -1; | ||
2619 | |||
2620 | return (dev)->a_ops.adapter_check_health(dev); | ||
2621 | } | ||
2622 | |||
2618 | /* SCp.phase values */ | 2623 | /* SCp.phase values */ |
2619 | #define AAC_OWNER_MIDLEVEL 0x101 | 2624 | #define AAC_OWNER_MIDLEVEL 0x101 |
2620 | #define AAC_OWNER_LOWLEVEL 0x102 | 2625 | #define AAC_OWNER_LOWLEVEL 0x102 |
diff --git a/drivers/scsi/aacraid/commsup.c b/drivers/scsi/aacraid/commsup.c index a3ad04293487..1f4918355fdb 100644 --- a/drivers/scsi/aacraid/commsup.c +++ b/drivers/scsi/aacraid/commsup.c | |||
@@ -1873,7 +1873,8 @@ int aac_check_health(struct aac_dev * aac) | |||
1873 | spin_unlock_irqrestore(&aac->fib_lock, flagv); | 1873 | spin_unlock_irqrestore(&aac->fib_lock, flagv); |
1874 | 1874 | ||
1875 | if (BlinkLED < 0) { | 1875 | if (BlinkLED < 0) { |
1876 | printk(KERN_ERR "%s: Host adapter dead %d\n", aac->name, BlinkLED); | 1876 | printk(KERN_ERR "%s: Host adapter is dead (or got a PCI error) %d\n", |
1877 | aac->name, BlinkLED); | ||
1877 | goto out; | 1878 | goto out; |
1878 | } | 1879 | } |
1879 | 1880 | ||
@@ -2056,7 +2057,6 @@ static int fillup_pools(struct aac_dev *dev, struct hw_fib **hw_fib_pool, | |||
2056 | { | 2057 | { |
2057 | struct hw_fib **hw_fib_p; | 2058 | struct hw_fib **hw_fib_p; |
2058 | struct fib **fib_p; | 2059 | struct fib **fib_p; |
2059 | int rcode = 1; | ||
2060 | 2060 | ||
2061 | hw_fib_p = hw_fib_pool; | 2061 | hw_fib_p = hw_fib_pool; |
2062 | fib_p = fib_pool; | 2062 | fib_p = fib_pool; |
@@ -2074,11 +2074,11 @@ static int fillup_pools(struct aac_dev *dev, struct hw_fib **hw_fib_pool, | |||
2074 | } | 2074 | } |
2075 | } | 2075 | } |
2076 | 2076 | ||
2077 | /* | ||
2078 | * Get the actual number of allocated fibs | ||
2079 | */ | ||
2077 | num = hw_fib_p - hw_fib_pool; | 2080 | num = hw_fib_p - hw_fib_pool; |
2078 | if (!num) | 2081 | return num; |
2079 | rcode = 0; | ||
2080 | |||
2081 | return rcode; | ||
2082 | } | 2082 | } |
2083 | 2083 | ||
2084 | static void wakeup_fibctx_threads(struct aac_dev *dev, | 2084 | static void wakeup_fibctx_threads(struct aac_dev *dev, |
@@ -2186,7 +2186,6 @@ static void aac_process_events(struct aac_dev *dev) | |||
2186 | struct fib *fib; | 2186 | struct fib *fib; |
2187 | unsigned long flags; | 2187 | unsigned long flags; |
2188 | spinlock_t *t_lock; | 2188 | spinlock_t *t_lock; |
2189 | unsigned int rcode; | ||
2190 | 2189 | ||
2191 | t_lock = dev->queues->queue[HostNormCmdQueue].lock; | 2190 | t_lock = dev->queues->queue[HostNormCmdQueue].lock; |
2192 | spin_lock_irqsave(t_lock, flags); | 2191 | spin_lock_irqsave(t_lock, flags); |
@@ -2269,8 +2268,8 @@ static void aac_process_events(struct aac_dev *dev) | |||
2269 | * Fill up fib pointer pools with actual fibs | 2268 | * Fill up fib pointer pools with actual fibs |
2270 | * and hw_fibs | 2269 | * and hw_fibs |
2271 | */ | 2270 | */ |
2272 | rcode = fillup_pools(dev, hw_fib_pool, fib_pool, num); | 2271 | num = fillup_pools(dev, hw_fib_pool, fib_pool, num); |
2273 | if (!rcode) | 2272 | if (!num) |
2274 | goto free_mem; | 2273 | goto free_mem; |
2275 | 2274 | ||
2276 | /* | 2275 | /* |
diff --git a/drivers/scsi/device_handler/scsi_dh_alua.c b/drivers/scsi/device_handler/scsi_dh_alua.c index 48e200102221..c01b47e5b55a 100644 --- a/drivers/scsi/device_handler/scsi_dh_alua.c +++ b/drivers/scsi/device_handler/scsi_dh_alua.c | |||
@@ -113,7 +113,7 @@ struct alua_queue_data { | |||
113 | #define ALUA_POLICY_SWITCH_ALL 1 | 113 | #define ALUA_POLICY_SWITCH_ALL 1 |
114 | 114 | ||
115 | static void alua_rtpg_work(struct work_struct *work); | 115 | static void alua_rtpg_work(struct work_struct *work); |
116 | static void alua_rtpg_queue(struct alua_port_group *pg, | 116 | static bool alua_rtpg_queue(struct alua_port_group *pg, |
117 | struct scsi_device *sdev, | 117 | struct scsi_device *sdev, |
118 | struct alua_queue_data *qdata, bool force); | 118 | struct alua_queue_data *qdata, bool force); |
119 | static void alua_check(struct scsi_device *sdev, bool force); | 119 | static void alua_check(struct scsi_device *sdev, bool force); |
@@ -862,7 +862,13 @@ static void alua_rtpg_work(struct work_struct *work) | |||
862 | kref_put(&pg->kref, release_port_group); | 862 | kref_put(&pg->kref, release_port_group); |
863 | } | 863 | } |
864 | 864 | ||
865 | static void alua_rtpg_queue(struct alua_port_group *pg, | 865 | /** |
866 | * alua_rtpg_queue() - cause RTPG to be submitted asynchronously | ||
867 | * | ||
868 | * Returns true if and only if alua_rtpg_work() will be called asynchronously. | ||
869 | * That function is responsible for calling @qdata->fn(). | ||
870 | */ | ||
871 | static bool alua_rtpg_queue(struct alua_port_group *pg, | ||
866 | struct scsi_device *sdev, | 872 | struct scsi_device *sdev, |
867 | struct alua_queue_data *qdata, bool force) | 873 | struct alua_queue_data *qdata, bool force) |
868 | { | 874 | { |
@@ -870,8 +876,8 @@ static void alua_rtpg_queue(struct alua_port_group *pg, | |||
870 | unsigned long flags; | 876 | unsigned long flags; |
871 | struct workqueue_struct *alua_wq = kaluad_wq; | 877 | struct workqueue_struct *alua_wq = kaluad_wq; |
872 | 878 | ||
873 | if (!pg) | 879 | if (WARN_ON_ONCE(!pg) || scsi_device_get(sdev)) |
874 | return; | 880 | return false; |
875 | 881 | ||
876 | spin_lock_irqsave(&pg->lock, flags); | 882 | spin_lock_irqsave(&pg->lock, flags); |
877 | if (qdata) { | 883 | if (qdata) { |
@@ -884,14 +890,12 @@ static void alua_rtpg_queue(struct alua_port_group *pg, | |||
884 | pg->flags |= ALUA_PG_RUN_RTPG; | 890 | pg->flags |= ALUA_PG_RUN_RTPG; |
885 | kref_get(&pg->kref); | 891 | kref_get(&pg->kref); |
886 | pg->rtpg_sdev = sdev; | 892 | pg->rtpg_sdev = sdev; |
887 | scsi_device_get(sdev); | ||
888 | start_queue = 1; | 893 | start_queue = 1; |
889 | } else if (!(pg->flags & ALUA_PG_RUN_RTPG) && force) { | 894 | } else if (!(pg->flags & ALUA_PG_RUN_RTPG) && force) { |
890 | pg->flags |= ALUA_PG_RUN_RTPG; | 895 | pg->flags |= ALUA_PG_RUN_RTPG; |
891 | /* Do not queue if the worker is already running */ | 896 | /* Do not queue if the worker is already running */ |
892 | if (!(pg->flags & ALUA_PG_RUNNING)) { | 897 | if (!(pg->flags & ALUA_PG_RUNNING)) { |
893 | kref_get(&pg->kref); | 898 | kref_get(&pg->kref); |
894 | sdev = NULL; | ||
895 | start_queue = 1; | 899 | start_queue = 1; |
896 | } | 900 | } |
897 | } | 901 | } |
@@ -900,13 +904,17 @@ static void alua_rtpg_queue(struct alua_port_group *pg, | |||
900 | alua_wq = kaluad_sync_wq; | 904 | alua_wq = kaluad_sync_wq; |
901 | spin_unlock_irqrestore(&pg->lock, flags); | 905 | spin_unlock_irqrestore(&pg->lock, flags); |
902 | 906 | ||
903 | if (start_queue && | 907 | if (start_queue) { |
904 | !queue_delayed_work(alua_wq, &pg->rtpg_work, | 908 | if (queue_delayed_work(alua_wq, &pg->rtpg_work, |
905 | msecs_to_jiffies(ALUA_RTPG_DELAY_MSECS))) { | 909 | msecs_to_jiffies(ALUA_RTPG_DELAY_MSECS))) |
906 | if (sdev) | 910 | sdev = NULL; |
907 | scsi_device_put(sdev); | 911 | else |
908 | kref_put(&pg->kref, release_port_group); | 912 | kref_put(&pg->kref, release_port_group); |
909 | } | 913 | } |
914 | if (sdev) | ||
915 | scsi_device_put(sdev); | ||
916 | |||
917 | return true; | ||
910 | } | 918 | } |
911 | 919 | ||
912 | /* | 920 | /* |
@@ -1007,11 +1015,13 @@ static int alua_activate(struct scsi_device *sdev, | |||
1007 | mutex_unlock(&h->init_mutex); | 1015 | mutex_unlock(&h->init_mutex); |
1008 | goto out; | 1016 | goto out; |
1009 | } | 1017 | } |
1010 | fn = NULL; | ||
1011 | rcu_read_unlock(); | 1018 | rcu_read_unlock(); |
1012 | mutex_unlock(&h->init_mutex); | 1019 | mutex_unlock(&h->init_mutex); |
1013 | 1020 | ||
1014 | alua_rtpg_queue(pg, sdev, qdata, true); | 1021 | if (alua_rtpg_queue(pg, sdev, qdata, true)) |
1022 | fn = NULL; | ||
1023 | else | ||
1024 | err = SCSI_DH_DEV_OFFLINED; | ||
1015 | kref_put(&pg->kref, release_port_group); | 1025 | kref_put(&pg->kref, release_port_group); |
1016 | out: | 1026 | out: |
1017 | if (fn) | 1027 | if (fn) |
diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c index 0d0be7754a65..9d659aaace15 100644 --- a/drivers/scsi/hpsa.c +++ b/drivers/scsi/hpsa.c | |||
@@ -3885,6 +3885,7 @@ static int hpsa_update_device_info(struct ctlr_info *h, | |||
3885 | if (h->fw_support & MISC_FW_RAID_OFFLOAD_BASIC) | 3885 | if (h->fw_support & MISC_FW_RAID_OFFLOAD_BASIC) |
3886 | hpsa_get_ioaccel_status(h, scsi3addr, this_device); | 3886 | hpsa_get_ioaccel_status(h, scsi3addr, this_device); |
3887 | volume_offline = hpsa_volume_offline(h, scsi3addr); | 3887 | volume_offline = hpsa_volume_offline(h, scsi3addr); |
3888 | this_device->volume_offline = volume_offline; | ||
3888 | if (volume_offline == HPSA_LV_FAILED) { | 3889 | if (volume_offline == HPSA_LV_FAILED) { |
3889 | rc = HPSA_LV_FAILED; | 3890 | rc = HPSA_LV_FAILED; |
3890 | dev_err(&h->pdev->dev, | 3891 | dev_err(&h->pdev->dev, |
diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c index b29afafc2885..5d5e272fd815 100644 --- a/drivers/scsi/ipr.c +++ b/drivers/scsi/ipr.c | |||
@@ -6293,7 +6293,12 @@ static void ipr_erp_start(struct ipr_ioa_cfg *ioa_cfg, | |||
6293 | break; | 6293 | break; |
6294 | case IPR_IOASC_MED_DO_NOT_REALLOC: /* prevent retries */ | 6294 | case IPR_IOASC_MED_DO_NOT_REALLOC: /* prevent retries */ |
6295 | case IPR_IOASA_IR_DUAL_IOA_DISABLED: | 6295 | case IPR_IOASA_IR_DUAL_IOA_DISABLED: |
6296 | scsi_cmd->result |= (DID_PASSTHROUGH << 16); | 6296 | /* |
6297 | * exception: do not set DID_PASSTHROUGH on CHECK CONDITION | ||
6298 | * so SCSI mid-layer and upper layers handle it accordingly. | ||
6299 | */ | ||
6300 | if (scsi_cmd->result != SAM_STAT_CHECK_CONDITION) | ||
6301 | scsi_cmd->result |= (DID_PASSTHROUGH << 16); | ||
6297 | break; | 6302 | break; |
6298 | case IPR_IOASC_BUS_WAS_RESET: | 6303 | case IPR_IOASC_BUS_WAS_RESET: |
6299 | case IPR_IOASC_BUS_WAS_RESET_BY_OTHER: | 6304 | case IPR_IOASC_BUS_WAS_RESET_BY_OTHER: |
diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c index 763f012fdeca..87f5e694dbed 100644 --- a/drivers/scsi/libsas/sas_ata.c +++ b/drivers/scsi/libsas/sas_ata.c | |||
@@ -221,7 +221,7 @@ static unsigned int sas_ata_qc_issue(struct ata_queued_cmd *qc) | |||
221 | task->num_scatter = qc->n_elem; | 221 | task->num_scatter = qc->n_elem; |
222 | } else { | 222 | } else { |
223 | for_each_sg(qc->sg, sg, qc->n_elem, si) | 223 | for_each_sg(qc->sg, sg, qc->n_elem, si) |
224 | xfer += sg->length; | 224 | xfer += sg_dma_len(sg); |
225 | 225 | ||
226 | task->total_xfer_len = xfer; | 226 | task->total_xfer_len = xfer; |
227 | task->num_scatter = si; | 227 | task->num_scatter = si; |
diff --git a/drivers/scsi/lpfc/lpfc_debugfs.h b/drivers/scsi/lpfc/lpfc_debugfs.h index c05f56c3023f..7b7d314af0e0 100644 --- a/drivers/scsi/lpfc/lpfc_debugfs.h +++ b/drivers/scsi/lpfc/lpfc_debugfs.h | |||
@@ -44,14 +44,6 @@ | |||
44 | /* hbqinfo output buffer size */ | 44 | /* hbqinfo output buffer size */ |
45 | #define LPFC_HBQINFO_SIZE 8192 | 45 | #define LPFC_HBQINFO_SIZE 8192 |
46 | 46 | ||
47 | enum { | ||
48 | DUMP_FCP, | ||
49 | DUMP_NVME, | ||
50 | DUMP_MBX, | ||
51 | DUMP_ELS, | ||
52 | DUMP_NVMELS, | ||
53 | }; | ||
54 | |||
55 | /* nvmestat output buffer size */ | 47 | /* nvmestat output buffer size */ |
56 | #define LPFC_NVMESTAT_SIZE 8192 | 48 | #define LPFC_NVMESTAT_SIZE 8192 |
57 | #define LPFC_NVMEKTIME_SIZE 8192 | 49 | #define LPFC_NVMEKTIME_SIZE 8192 |
@@ -283,8 +275,22 @@ struct lpfc_idiag { | |||
283 | struct lpfc_idiag_offset offset; | 275 | struct lpfc_idiag_offset offset; |
284 | void *ptr_private; | 276 | void *ptr_private; |
285 | }; | 277 | }; |
278 | |||
279 | #else | ||
280 | |||
281 | #define lpfc_nvmeio_data(phba, fmt, arg...) \ | ||
282 | no_printk(fmt, ##arg) | ||
283 | |||
286 | #endif | 284 | #endif |
287 | 285 | ||
286 | enum { | ||
287 | DUMP_FCP, | ||
288 | DUMP_NVME, | ||
289 | DUMP_MBX, | ||
290 | DUMP_ELS, | ||
291 | DUMP_NVMELS, | ||
292 | }; | ||
293 | |||
288 | /* Mask for discovery_trace */ | 294 | /* Mask for discovery_trace */ |
289 | #define LPFC_DISC_TRC_ELS_CMD 0x1 /* Trace ELS commands */ | 295 | #define LPFC_DISC_TRC_ELS_CMD 0x1 /* Trace ELS commands */ |
290 | #define LPFC_DISC_TRC_ELS_RSP 0x2 /* Trace ELS response */ | 296 | #define LPFC_DISC_TRC_ELS_RSP 0x2 /* Trace ELS response */ |
diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c index d9c61d030034..a5ca37e45fb6 100644 --- a/drivers/scsi/lpfc/lpfc_els.c +++ b/drivers/scsi/lpfc/lpfc_els.c | |||
@@ -7968,7 +7968,8 @@ lpfc_els_unsol_buffer(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, | |||
7968 | did, vport->port_state, ndlp->nlp_flag); | 7968 | did, vport->port_state, ndlp->nlp_flag); |
7969 | 7969 | ||
7970 | phba->fc_stat.elsRcvPRLI++; | 7970 | phba->fc_stat.elsRcvPRLI++; |
7971 | if (vport->port_state < LPFC_DISC_AUTH) { | 7971 | if ((vport->port_state < LPFC_DISC_AUTH) && |
7972 | (vport->fc_flag & FC_FABRIC)) { | ||
7972 | rjt_err = LSRJT_UNABLE_TPC; | 7973 | rjt_err = LSRJT_UNABLE_TPC; |
7973 | rjt_exp = LSEXP_NOTHING_MORE; | 7974 | rjt_exp = LSEXP_NOTHING_MORE; |
7974 | break; | 7975 | break; |
diff --git a/drivers/scsi/lpfc/lpfc_nvmet.c b/drivers/scsi/lpfc/lpfc_nvmet.c index d488c3318d4b..b2333b3889c7 100644 --- a/drivers/scsi/lpfc/lpfc_nvmet.c +++ b/drivers/scsi/lpfc/lpfc_nvmet.c | |||
@@ -518,7 +518,7 @@ lpfc_nvmet_xmt_fcp_op(struct nvmet_fc_target_port *tgtport, | |||
518 | struct lpfc_hba *phba = ctxp->phba; | 518 | struct lpfc_hba *phba = ctxp->phba; |
519 | struct lpfc_iocbq *nvmewqeq; | 519 | struct lpfc_iocbq *nvmewqeq; |
520 | unsigned long iflags; | 520 | unsigned long iflags; |
521 | int rc, id; | 521 | int rc; |
522 | 522 | ||
523 | #ifdef CONFIG_SCSI_LPFC_DEBUG_FS | 523 | #ifdef CONFIG_SCSI_LPFC_DEBUG_FS |
524 | if (phba->ktime_on) { | 524 | if (phba->ktime_on) { |
@@ -528,7 +528,7 @@ lpfc_nvmet_xmt_fcp_op(struct nvmet_fc_target_port *tgtport, | |||
528 | ctxp->ts_nvme_data = ktime_get_ns(); | 528 | ctxp->ts_nvme_data = ktime_get_ns(); |
529 | } | 529 | } |
530 | if (phba->cpucheck_on & LPFC_CHECK_NVMET_IO) { | 530 | if (phba->cpucheck_on & LPFC_CHECK_NVMET_IO) { |
531 | id = smp_processor_id(); | 531 | int id = smp_processor_id(); |
532 | ctxp->cpu = id; | 532 | ctxp->cpu = id; |
533 | if (id < LPFC_CHECK_CPU_CNT) | 533 | if (id < LPFC_CHECK_CPU_CNT) |
534 | phba->cpucheck_xmt_io[id]++; | 534 | phba->cpucheck_xmt_io[id]++; |
diff --git a/drivers/scsi/qedf/qedf_fip.c b/drivers/scsi/qedf/qedf_fip.c index ed58b9104f58..e10b91cc3c62 100644 --- a/drivers/scsi/qedf/qedf_fip.c +++ b/drivers/scsi/qedf/qedf_fip.c | |||
@@ -99,7 +99,8 @@ static void qedf_fcoe_process_vlan_resp(struct qedf_ctx *qedf, | |||
99 | qedf_set_vlan_id(qedf, vid); | 99 | qedf_set_vlan_id(qedf, vid); |
100 | 100 | ||
101 | /* Inform waiter that it's ok to call fcoe_ctlr_link up() */ | 101 | /* Inform waiter that it's ok to call fcoe_ctlr_link up() */ |
102 | complete(&qedf->fipvlan_compl); | 102 | if (!completion_done(&qedf->fipvlan_compl)) |
103 | complete(&qedf->fipvlan_compl); | ||
103 | } | 104 | } |
104 | } | 105 | } |
105 | 106 | ||
diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c index 8e2a160490e6..cceddd995a4b 100644 --- a/drivers/scsi/qedf/qedf_main.c +++ b/drivers/scsi/qedf/qedf_main.c | |||
@@ -2803,6 +2803,7 @@ static int __qedf_probe(struct pci_dev *pdev, int mode) | |||
2803 | atomic_set(&qedf->num_offloads, 0); | 2803 | atomic_set(&qedf->num_offloads, 0); |
2804 | qedf->stop_io_on_error = false; | 2804 | qedf->stop_io_on_error = false; |
2805 | pci_set_drvdata(pdev, qedf); | 2805 | pci_set_drvdata(pdev, qedf); |
2806 | init_completion(&qedf->fipvlan_compl); | ||
2806 | 2807 | ||
2807 | QEDF_INFO(&(qedf->dbg_ctx), QEDF_LOG_INFO, | 2808 | QEDF_INFO(&(qedf->dbg_ctx), QEDF_LOG_INFO, |
2808 | "QLogic FastLinQ FCoE Module qedf %s, " | 2809 | "QLogic FastLinQ FCoE Module qedf %s, " |
diff --git a/drivers/scsi/qedi/qedi_main.c b/drivers/scsi/qedi/qedi_main.c index 8e3d92807cb8..92775a8b74b1 100644 --- a/drivers/scsi/qedi/qedi_main.c +++ b/drivers/scsi/qedi/qedi_main.c | |||
@@ -2007,6 +2007,7 @@ static void qedi_remove(struct pci_dev *pdev) | |||
2007 | 2007 | ||
2008 | static struct pci_device_id qedi_pci_tbl[] = { | 2008 | static struct pci_device_id qedi_pci_tbl[] = { |
2009 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, 0x165E) }, | 2009 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, 0x165E) }, |
2010 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, 0x8084) }, | ||
2010 | { 0 }, | 2011 | { 0 }, |
2011 | }; | 2012 | }; |
2012 | MODULE_DEVICE_TABLE(pci, qedi_pci_tbl); | 2013 | MODULE_DEVICE_TABLE(pci, qedi_pci_tbl); |
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index 41d5b09f7326..83d61d2142e9 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c | |||
@@ -1160,8 +1160,13 @@ static inline | |||
1160 | uint32_t qla2x00_isp_reg_stat(struct qla_hw_data *ha) | 1160 | uint32_t qla2x00_isp_reg_stat(struct qla_hw_data *ha) |
1161 | { | 1161 | { |
1162 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; | 1162 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; |
1163 | struct device_reg_82xx __iomem *reg82 = &ha->iobase->isp82; | ||
1163 | 1164 | ||
1164 | return ((RD_REG_DWORD(®->host_status)) == ISP_REG_DISCONNECT); | 1165 | if (IS_P3P_TYPE(ha)) |
1166 | return ((RD_REG_DWORD(®82->host_int)) == ISP_REG_DISCONNECT); | ||
1167 | else | ||
1168 | return ((RD_REG_DWORD(®->host_status)) == | ||
1169 | ISP_REG_DISCONNECT); | ||
1165 | } | 1170 | } |
1166 | 1171 | ||
1167 | /************************************************************************** | 1172 | /************************************************************************** |
@@ -1651,7 +1656,8 @@ qla2x00_abort_all_cmds(scsi_qla_host_t *vha, int res) | |||
1651 | /* Don't abort commands in adapter during EEH | 1656 | /* Don't abort commands in adapter during EEH |
1652 | * recovery as it's not accessible/responding. | 1657 | * recovery as it's not accessible/responding. |
1653 | */ | 1658 | */ |
1654 | if (GET_CMD_SP(sp) && !ha->flags.eeh_busy) { | 1659 | if (GET_CMD_SP(sp) && !ha->flags.eeh_busy && |
1660 | (sp->type == SRB_SCSI_CMD)) { | ||
1655 | /* Get a reference to the sp and drop the lock. | 1661 | /* Get a reference to the sp and drop the lock. |
1656 | * The reference ensures this sp->done() call | 1662 | * The reference ensures this sp->done() call |
1657 | * - and not the call in qla2xxx_eh_abort() - | 1663 | * - and not the call in qla2xxx_eh_abort() - |
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 4a20e6098f7c..abc391e00f7d 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c | |||
@@ -1060,10 +1060,10 @@ int scsi_init_io(struct scsi_cmnd *cmd) | |||
1060 | struct scsi_device *sdev = cmd->device; | 1060 | struct scsi_device *sdev = cmd->device; |
1061 | struct request *rq = cmd->request; | 1061 | struct request *rq = cmd->request; |
1062 | bool is_mq = (rq->mq_ctx != NULL); | 1062 | bool is_mq = (rq->mq_ctx != NULL); |
1063 | int error; | 1063 | int error = BLKPREP_KILL; |
1064 | 1064 | ||
1065 | if (WARN_ON_ONCE(!blk_rq_nr_phys_segments(rq))) | 1065 | if (WARN_ON_ONCE(!blk_rq_nr_phys_segments(rq))) |
1066 | return -EINVAL; | 1066 | goto err_exit; |
1067 | 1067 | ||
1068 | error = scsi_init_sgtable(rq, &cmd->sdb); | 1068 | error = scsi_init_sgtable(rq, &cmd->sdb); |
1069 | if (error) | 1069 | if (error) |
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 8cf34a8e3eea..0dc95e102e69 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c | |||
@@ -2179,6 +2179,22 @@ static void read_capacity_error(struct scsi_disk *sdkp, struct scsi_device *sdp, | |||
2179 | 2179 | ||
2180 | #define READ_CAPACITY_RETRIES_ON_RESET 10 | 2180 | #define READ_CAPACITY_RETRIES_ON_RESET 10 |
2181 | 2181 | ||
2182 | /* | ||
2183 | * Ensure that we don't overflow sector_t when CONFIG_LBDAF is not set | ||
2184 | * and the reported logical block size is bigger than 512 bytes. Note | ||
2185 | * that last_sector is a u64 and therefore logical_to_sectors() is not | ||
2186 | * applicable. | ||
2187 | */ | ||
2188 | static bool sd_addressable_capacity(u64 lba, unsigned int sector_size) | ||
2189 | { | ||
2190 | u64 last_sector = (lba + 1ULL) << (ilog2(sector_size) - 9); | ||
2191 | |||
2192 | if (sizeof(sector_t) == 4 && last_sector > U32_MAX) | ||
2193 | return false; | ||
2194 | |||
2195 | return true; | ||
2196 | } | ||
2197 | |||
2182 | static int read_capacity_16(struct scsi_disk *sdkp, struct scsi_device *sdp, | 2198 | static int read_capacity_16(struct scsi_disk *sdkp, struct scsi_device *sdp, |
2183 | unsigned char *buffer) | 2199 | unsigned char *buffer) |
2184 | { | 2200 | { |
@@ -2244,7 +2260,7 @@ static int read_capacity_16(struct scsi_disk *sdkp, struct scsi_device *sdp, | |||
2244 | return -ENODEV; | 2260 | return -ENODEV; |
2245 | } | 2261 | } |
2246 | 2262 | ||
2247 | if ((sizeof(sdkp->capacity) == 4) && (lba >= 0xffffffffULL)) { | 2263 | if (!sd_addressable_capacity(lba, sector_size)) { |
2248 | sd_printk(KERN_ERR, sdkp, "Too big for this kernel. Use a " | 2264 | sd_printk(KERN_ERR, sdkp, "Too big for this kernel. Use a " |
2249 | "kernel compiled with support for large block " | 2265 | "kernel compiled with support for large block " |
2250 | "devices.\n"); | 2266 | "devices.\n"); |
@@ -2333,7 +2349,7 @@ static int read_capacity_10(struct scsi_disk *sdkp, struct scsi_device *sdp, | |||
2333 | return sector_size; | 2349 | return sector_size; |
2334 | } | 2350 | } |
2335 | 2351 | ||
2336 | if ((sizeof(sdkp->capacity) == 4) && (lba == 0xffffffff)) { | 2352 | if (!sd_addressable_capacity(lba, sector_size)) { |
2337 | sd_printk(KERN_ERR, sdkp, "Too big for this kernel. Use a " | 2353 | sd_printk(KERN_ERR, sdkp, "Too big for this kernel. Use a " |
2338 | "kernel compiled with support for large block " | 2354 | "kernel compiled with support for large block " |
2339 | "devices.\n"); | 2355 | "devices.\n"); |
@@ -3033,7 +3049,8 @@ static int sd_revalidate_disk(struct gendisk *disk) | |||
3033 | q->limits.io_opt = logical_to_bytes(sdp, sdkp->opt_xfer_blocks); | 3049 | q->limits.io_opt = logical_to_bytes(sdp, sdkp->opt_xfer_blocks); |
3034 | rw_max = logical_to_sectors(sdp, sdkp->opt_xfer_blocks); | 3050 | rw_max = logical_to_sectors(sdp, sdkp->opt_xfer_blocks); |
3035 | } else | 3051 | } else |
3036 | rw_max = BLK_DEF_MAX_SECTORS; | 3052 | rw_max = min_not_zero(logical_to_sectors(sdp, dev_max), |
3053 | (sector_t)BLK_DEF_MAX_SECTORS); | ||
3037 | 3054 | ||
3038 | /* Combine with controller limits */ | 3055 | /* Combine with controller limits */ |
3039 | q->limits.max_sectors = min(rw_max, queue_max_hw_sectors(q)); | 3056 | q->limits.max_sectors = min(rw_max, queue_max_hw_sectors(q)); |
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index 90ee9d926deb..504504beaa5e 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c | |||
@@ -996,6 +996,8 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg) | |||
996 | result = get_user(val, ip); | 996 | result = get_user(val, ip); |
997 | if (result) | 997 | if (result) |
998 | return result; | 998 | return result; |
999 | if (val > SG_MAX_CDB_SIZE) | ||
1000 | return -ENOMEM; | ||
999 | sfp->next_cmd_len = (val > 0) ? val : 0; | 1001 | sfp->next_cmd_len = (val > 0) ? val : 0; |
1000 | return 0; | 1002 | return 0; |
1001 | case SG_GET_VERSION_NUM: | 1003 | case SG_GET_VERSION_NUM: |
diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c index 0b29b9329b1c..a8f630213a1a 100644 --- a/drivers/scsi/sr.c +++ b/drivers/scsi/sr.c | |||
@@ -836,6 +836,7 @@ static void get_capabilities(struct scsi_cd *cd) | |||
836 | unsigned char *buffer; | 836 | unsigned char *buffer; |
837 | struct scsi_mode_data data; | 837 | struct scsi_mode_data data; |
838 | struct scsi_sense_hdr sshdr; | 838 | struct scsi_sense_hdr sshdr; |
839 | unsigned int ms_len = 128; | ||
839 | int rc, n; | 840 | int rc, n; |
840 | 841 | ||
841 | static const char *loadmech[] = | 842 | static const char *loadmech[] = |
@@ -862,10 +863,11 @@ static void get_capabilities(struct scsi_cd *cd) | |||
862 | scsi_test_unit_ready(cd->device, SR_TIMEOUT, MAX_RETRIES, &sshdr); | 863 | scsi_test_unit_ready(cd->device, SR_TIMEOUT, MAX_RETRIES, &sshdr); |
863 | 864 | ||
864 | /* ask for mode page 0x2a */ | 865 | /* ask for mode page 0x2a */ |
865 | rc = scsi_mode_sense(cd->device, 0, 0x2a, buffer, 128, | 866 | rc = scsi_mode_sense(cd->device, 0, 0x2a, buffer, ms_len, |
866 | SR_TIMEOUT, 3, &data, NULL); | 867 | SR_TIMEOUT, 3, &data, NULL); |
867 | 868 | ||
868 | if (!scsi_status_is_good(rc)) { | 869 | if (!scsi_status_is_good(rc) || data.length > ms_len || |
870 | data.header_length + data.block_descriptor_length > data.length) { | ||
869 | /* failed, drive doesn't have capabilities mode page */ | 871 | /* failed, drive doesn't have capabilities mode page */ |
870 | cd->cdi.speed = 1; | 872 | cd->cdi.speed = 1; |
871 | cd->cdi.mask |= (CDC_CD_R | CDC_CD_RW | CDC_DVD_R | | 873 | cd->cdi.mask |= (CDC_CD_R | CDC_CD_RW | CDC_DVD_R | |
diff --git a/drivers/scsi/ufs/ufshcd-pltfrm.c b/drivers/scsi/ufs/ufshcd-pltfrm.c index a72a4ba78125..8e5e6c04c035 100644 --- a/drivers/scsi/ufs/ufshcd-pltfrm.c +++ b/drivers/scsi/ufs/ufshcd-pltfrm.c | |||
@@ -309,8 +309,8 @@ int ufshcd_pltfrm_init(struct platform_device *pdev, | |||
309 | 309 | ||
310 | mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 310 | mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
311 | mmio_base = devm_ioremap_resource(dev, mem_res); | 311 | mmio_base = devm_ioremap_resource(dev, mem_res); |
312 | if (IS_ERR(*(void **)&mmio_base)) { | 312 | if (IS_ERR(mmio_base)) { |
313 | err = PTR_ERR(*(void **)&mmio_base); | 313 | err = PTR_ERR(mmio_base); |
314 | goto out; | 314 | goto out; |
315 | } | 315 | } |
316 | 316 | ||
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index e8c26e6e6237..096e95b911bd 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c | |||
@@ -4662,8 +4662,6 @@ static void __ufshcd_transfer_req_compl(struct ufs_hba *hba, | |||
4662 | } | 4662 | } |
4663 | if (ufshcd_is_clkscaling_supported(hba)) | 4663 | if (ufshcd_is_clkscaling_supported(hba)) |
4664 | hba->clk_scaling.active_reqs--; | 4664 | hba->clk_scaling.active_reqs--; |
4665 | if (ufshcd_is_clkscaling_supported(hba)) | ||
4666 | hba->clk_scaling.active_reqs--; | ||
4667 | } | 4665 | } |
4668 | 4666 | ||
4669 | /* clear corresponding bits of completed commands */ | 4667 | /* clear corresponding bits of completed commands */ |
diff --git a/drivers/staging/android/ashmem.c b/drivers/staging/android/ashmem.c index 7cbad0d45b9c..6ba270e0494d 100644 --- a/drivers/staging/android/ashmem.c +++ b/drivers/staging/android/ashmem.c | |||
@@ -409,6 +409,7 @@ static int ashmem_mmap(struct file *file, struct vm_area_struct *vma) | |||
409 | ret = PTR_ERR(vmfile); | 409 | ret = PTR_ERR(vmfile); |
410 | goto out; | 410 | goto out; |
411 | } | 411 | } |
412 | vmfile->f_mode |= FMODE_LSEEK; | ||
412 | asma->file = vmfile; | 413 | asma->file = vmfile; |
413 | } | 414 | } |
414 | get_file(asma->file); | 415 | get_file(asma->file); |
diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c index a91802432f2f..e3f9ed3690b7 100644 --- a/drivers/target/iscsi/iscsi_target.c +++ b/drivers/target/iscsi/iscsi_target.c | |||
@@ -485,8 +485,7 @@ static void iscsit_get_rx_pdu(struct iscsi_conn *); | |||
485 | 485 | ||
486 | int iscsit_queue_rsp(struct iscsi_conn *conn, struct iscsi_cmd *cmd) | 486 | int iscsit_queue_rsp(struct iscsi_conn *conn, struct iscsi_cmd *cmd) |
487 | { | 487 | { |
488 | iscsit_add_cmd_to_response_queue(cmd, cmd->conn, cmd->i_state); | 488 | return iscsit_add_cmd_to_response_queue(cmd, cmd->conn, cmd->i_state); |
489 | return 0; | ||
490 | } | 489 | } |
491 | EXPORT_SYMBOL(iscsit_queue_rsp); | 490 | EXPORT_SYMBOL(iscsit_queue_rsp); |
492 | 491 | ||
diff --git a/drivers/target/iscsi/iscsi_target_configfs.c b/drivers/target/iscsi/iscsi_target_configfs.c index f30c27b83c5e..5798810197ec 100644 --- a/drivers/target/iscsi/iscsi_target_configfs.c +++ b/drivers/target/iscsi/iscsi_target_configfs.c | |||
@@ -1376,11 +1376,10 @@ static u32 lio_sess_get_initiator_sid( | |||
1376 | static int lio_queue_data_in(struct se_cmd *se_cmd) | 1376 | static int lio_queue_data_in(struct se_cmd *se_cmd) |
1377 | { | 1377 | { |
1378 | struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd); | 1378 | struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd); |
1379 | struct iscsi_conn *conn = cmd->conn; | ||
1379 | 1380 | ||
1380 | cmd->i_state = ISTATE_SEND_DATAIN; | 1381 | cmd->i_state = ISTATE_SEND_DATAIN; |
1381 | cmd->conn->conn_transport->iscsit_queue_data_in(cmd->conn, cmd); | 1382 | return conn->conn_transport->iscsit_queue_data_in(conn, cmd); |
1382 | |||
1383 | return 0; | ||
1384 | } | 1383 | } |
1385 | 1384 | ||
1386 | static int lio_write_pending(struct se_cmd *se_cmd) | 1385 | static int lio_write_pending(struct se_cmd *se_cmd) |
@@ -1409,16 +1408,14 @@ static int lio_write_pending_status(struct se_cmd *se_cmd) | |||
1409 | static int lio_queue_status(struct se_cmd *se_cmd) | 1408 | static int lio_queue_status(struct se_cmd *se_cmd) |
1410 | { | 1409 | { |
1411 | struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd); | 1410 | struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd); |
1411 | struct iscsi_conn *conn = cmd->conn; | ||
1412 | 1412 | ||
1413 | cmd->i_state = ISTATE_SEND_STATUS; | 1413 | cmd->i_state = ISTATE_SEND_STATUS; |
1414 | 1414 | ||
1415 | if (cmd->se_cmd.scsi_status || cmd->sense_reason) { | 1415 | if (cmd->se_cmd.scsi_status || cmd->sense_reason) { |
1416 | iscsit_add_cmd_to_response_queue(cmd, cmd->conn, cmd->i_state); | 1416 | return iscsit_add_cmd_to_response_queue(cmd, conn, cmd->i_state); |
1417 | return 0; | ||
1418 | } | 1417 | } |
1419 | cmd->conn->conn_transport->iscsit_queue_status(cmd->conn, cmd); | 1418 | return conn->conn_transport->iscsit_queue_status(conn, cmd); |
1420 | |||
1421 | return 0; | ||
1422 | } | 1419 | } |
1423 | 1420 | ||
1424 | static void lio_queue_tm_rsp(struct se_cmd *se_cmd) | 1421 | static void lio_queue_tm_rsp(struct se_cmd *se_cmd) |
diff --git a/drivers/target/iscsi/iscsi_target_parameters.c b/drivers/target/iscsi/iscsi_target_parameters.c index e65bf78ceef3..fce627628200 100644 --- a/drivers/target/iscsi/iscsi_target_parameters.c +++ b/drivers/target/iscsi/iscsi_target_parameters.c | |||
@@ -782,22 +782,6 @@ static void iscsi_check_proposer_for_optional_reply(struct iscsi_param *param) | |||
782 | if (!strcmp(param->name, MAXRECVDATASEGMENTLENGTH)) | 782 | if (!strcmp(param->name, MAXRECVDATASEGMENTLENGTH)) |
783 | SET_PSTATE_REPLY_OPTIONAL(param); | 783 | SET_PSTATE_REPLY_OPTIONAL(param); |
784 | /* | 784 | /* |
785 | * The GlobalSAN iSCSI Initiator for MacOSX does | ||
786 | * not respond to MaxBurstLength, FirstBurstLength, | ||
787 | * DefaultTime2Wait or DefaultTime2Retain parameter keys. | ||
788 | * So, we set them to 'reply optional' here, and assume the | ||
789 | * the defaults from iscsi_parameters.h if the initiator | ||
790 | * is not RFC compliant and the keys are not negotiated. | ||
791 | */ | ||
792 | if (!strcmp(param->name, MAXBURSTLENGTH)) | ||
793 | SET_PSTATE_REPLY_OPTIONAL(param); | ||
794 | if (!strcmp(param->name, FIRSTBURSTLENGTH)) | ||
795 | SET_PSTATE_REPLY_OPTIONAL(param); | ||
796 | if (!strcmp(param->name, DEFAULTTIME2WAIT)) | ||
797 | SET_PSTATE_REPLY_OPTIONAL(param); | ||
798 | if (!strcmp(param->name, DEFAULTTIME2RETAIN)) | ||
799 | SET_PSTATE_REPLY_OPTIONAL(param); | ||
800 | /* | ||
801 | * Required for gPXE iSCSI boot client | 785 | * Required for gPXE iSCSI boot client |
802 | */ | 786 | */ |
803 | if (!strcmp(param->name, MAXCONNECTIONS)) | 787 | if (!strcmp(param->name, MAXCONNECTIONS)) |
diff --git a/drivers/target/iscsi/iscsi_target_util.c b/drivers/target/iscsi/iscsi_target_util.c index 5041a9c8bdcb..7d3e2fcc26a0 100644 --- a/drivers/target/iscsi/iscsi_target_util.c +++ b/drivers/target/iscsi/iscsi_target_util.c | |||
@@ -567,7 +567,7 @@ static void iscsit_remove_cmd_from_immediate_queue( | |||
567 | } | 567 | } |
568 | } | 568 | } |
569 | 569 | ||
570 | void iscsit_add_cmd_to_response_queue( | 570 | int iscsit_add_cmd_to_response_queue( |
571 | struct iscsi_cmd *cmd, | 571 | struct iscsi_cmd *cmd, |
572 | struct iscsi_conn *conn, | 572 | struct iscsi_conn *conn, |
573 | u8 state) | 573 | u8 state) |
@@ -578,7 +578,7 @@ void iscsit_add_cmd_to_response_queue( | |||
578 | if (!qr) { | 578 | if (!qr) { |
579 | pr_err("Unable to allocate memory for" | 579 | pr_err("Unable to allocate memory for" |
580 | " struct iscsi_queue_req\n"); | 580 | " struct iscsi_queue_req\n"); |
581 | return; | 581 | return -ENOMEM; |
582 | } | 582 | } |
583 | INIT_LIST_HEAD(&qr->qr_list); | 583 | INIT_LIST_HEAD(&qr->qr_list); |
584 | qr->cmd = cmd; | 584 | qr->cmd = cmd; |
@@ -590,6 +590,7 @@ void iscsit_add_cmd_to_response_queue( | |||
590 | spin_unlock_bh(&conn->response_queue_lock); | 590 | spin_unlock_bh(&conn->response_queue_lock); |
591 | 591 | ||
592 | wake_up(&conn->queues_wq); | 592 | wake_up(&conn->queues_wq); |
593 | return 0; | ||
593 | } | 594 | } |
594 | 595 | ||
595 | struct iscsi_queue_req *iscsit_get_cmd_from_response_queue(struct iscsi_conn *conn) | 596 | struct iscsi_queue_req *iscsit_get_cmd_from_response_queue(struct iscsi_conn *conn) |
@@ -737,21 +738,23 @@ void iscsit_free_cmd(struct iscsi_cmd *cmd, bool shutdown) | |||
737 | { | 738 | { |
738 | struct se_cmd *se_cmd = NULL; | 739 | struct se_cmd *se_cmd = NULL; |
739 | int rc; | 740 | int rc; |
741 | bool op_scsi = false; | ||
740 | /* | 742 | /* |
741 | * Determine if a struct se_cmd is associated with | 743 | * Determine if a struct se_cmd is associated with |
742 | * this struct iscsi_cmd. | 744 | * this struct iscsi_cmd. |
743 | */ | 745 | */ |
744 | switch (cmd->iscsi_opcode) { | 746 | switch (cmd->iscsi_opcode) { |
745 | case ISCSI_OP_SCSI_CMD: | 747 | case ISCSI_OP_SCSI_CMD: |
746 | se_cmd = &cmd->se_cmd; | 748 | op_scsi = true; |
747 | __iscsit_free_cmd(cmd, true, shutdown); | ||
748 | /* | 749 | /* |
749 | * Fallthrough | 750 | * Fallthrough |
750 | */ | 751 | */ |
751 | case ISCSI_OP_SCSI_TMFUNC: | 752 | case ISCSI_OP_SCSI_TMFUNC: |
752 | rc = transport_generic_free_cmd(&cmd->se_cmd, shutdown); | 753 | se_cmd = &cmd->se_cmd; |
753 | if (!rc && shutdown && se_cmd && se_cmd->se_sess) { | 754 | __iscsit_free_cmd(cmd, op_scsi, shutdown); |
754 | __iscsit_free_cmd(cmd, true, shutdown); | 755 | rc = transport_generic_free_cmd(se_cmd, shutdown); |
756 | if (!rc && shutdown && se_cmd->se_sess) { | ||
757 | __iscsit_free_cmd(cmd, op_scsi, shutdown); | ||
755 | target_put_sess_cmd(se_cmd); | 758 | target_put_sess_cmd(se_cmd); |
756 | } | 759 | } |
757 | break; | 760 | break; |
diff --git a/drivers/target/iscsi/iscsi_target_util.h b/drivers/target/iscsi/iscsi_target_util.h index 8ff08856516a..9e4197af8708 100644 --- a/drivers/target/iscsi/iscsi_target_util.h +++ b/drivers/target/iscsi/iscsi_target_util.h | |||
@@ -31,7 +31,7 @@ extern int iscsit_find_cmd_for_recovery(struct iscsi_session *, struct iscsi_cmd | |||
31 | struct iscsi_conn_recovery **, itt_t); | 31 | struct iscsi_conn_recovery **, itt_t); |
32 | extern void iscsit_add_cmd_to_immediate_queue(struct iscsi_cmd *, struct iscsi_conn *, u8); | 32 | extern void iscsit_add_cmd_to_immediate_queue(struct iscsi_cmd *, struct iscsi_conn *, u8); |
33 | extern struct iscsi_queue_req *iscsit_get_cmd_from_immediate_queue(struct iscsi_conn *); | 33 | extern struct iscsi_queue_req *iscsit_get_cmd_from_immediate_queue(struct iscsi_conn *); |
34 | extern void iscsit_add_cmd_to_response_queue(struct iscsi_cmd *, struct iscsi_conn *, u8); | 34 | extern int iscsit_add_cmd_to_response_queue(struct iscsi_cmd *, struct iscsi_conn *, u8); |
35 | extern struct iscsi_queue_req *iscsit_get_cmd_from_response_queue(struct iscsi_conn *); | 35 | extern struct iscsi_queue_req *iscsit_get_cmd_from_response_queue(struct iscsi_conn *); |
36 | extern void iscsit_remove_cmd_from_tx_queues(struct iscsi_cmd *, struct iscsi_conn *); | 36 | extern void iscsit_remove_cmd_from_tx_queues(struct iscsi_cmd *, struct iscsi_conn *); |
37 | extern bool iscsit_conn_all_queues_empty(struct iscsi_conn *); | 37 | extern bool iscsit_conn_all_queues_empty(struct iscsi_conn *); |
diff --git a/drivers/target/target_core_alua.c b/drivers/target/target_core_alua.c index fd7c16a7ca6e..fc4a9c303d55 100644 --- a/drivers/target/target_core_alua.c +++ b/drivers/target/target_core_alua.c | |||
@@ -197,8 +197,7 @@ target_emulate_report_target_port_groups(struct se_cmd *cmd) | |||
197 | /* | 197 | /* |
198 | * Set the ASYMMETRIC ACCESS State | 198 | * Set the ASYMMETRIC ACCESS State |
199 | */ | 199 | */ |
200 | buf[off++] |= (atomic_read( | 200 | buf[off++] |= tg_pt_gp->tg_pt_gp_alua_access_state & 0xff; |
201 | &tg_pt_gp->tg_pt_gp_alua_access_state) & 0xff); | ||
202 | /* | 201 | /* |
203 | * Set supported ASYMMETRIC ACCESS State bits | 202 | * Set supported ASYMMETRIC ACCESS State bits |
204 | */ | 203 | */ |
@@ -710,7 +709,7 @@ target_alua_state_check(struct se_cmd *cmd) | |||
710 | 709 | ||
711 | spin_lock(&lun->lun_tg_pt_gp_lock); | 710 | spin_lock(&lun->lun_tg_pt_gp_lock); |
712 | tg_pt_gp = lun->lun_tg_pt_gp; | 711 | tg_pt_gp = lun->lun_tg_pt_gp; |
713 | out_alua_state = atomic_read(&tg_pt_gp->tg_pt_gp_alua_access_state); | 712 | out_alua_state = tg_pt_gp->tg_pt_gp_alua_access_state; |
714 | nonop_delay_msecs = tg_pt_gp->tg_pt_gp_nonop_delay_msecs; | 713 | nonop_delay_msecs = tg_pt_gp->tg_pt_gp_nonop_delay_msecs; |
715 | 714 | ||
716 | // XXX: keeps using tg_pt_gp witout reference after unlock | 715 | // XXX: keeps using tg_pt_gp witout reference after unlock |
@@ -911,7 +910,7 @@ static int core_alua_write_tpg_metadata( | |||
911 | } | 910 | } |
912 | 911 | ||
913 | /* | 912 | /* |
914 | * Called with tg_pt_gp->tg_pt_gp_md_mutex held | 913 | * Called with tg_pt_gp->tg_pt_gp_transition_mutex held |
915 | */ | 914 | */ |
916 | static int core_alua_update_tpg_primary_metadata( | 915 | static int core_alua_update_tpg_primary_metadata( |
917 | struct t10_alua_tg_pt_gp *tg_pt_gp) | 916 | struct t10_alua_tg_pt_gp *tg_pt_gp) |
@@ -934,7 +933,7 @@ static int core_alua_update_tpg_primary_metadata( | |||
934 | "alua_access_state=0x%02x\n" | 933 | "alua_access_state=0x%02x\n" |
935 | "alua_access_status=0x%02x\n", | 934 | "alua_access_status=0x%02x\n", |
936 | tg_pt_gp->tg_pt_gp_id, | 935 | tg_pt_gp->tg_pt_gp_id, |
937 | tg_pt_gp->tg_pt_gp_alua_pending_state, | 936 | tg_pt_gp->tg_pt_gp_alua_access_state, |
938 | tg_pt_gp->tg_pt_gp_alua_access_status); | 937 | tg_pt_gp->tg_pt_gp_alua_access_status); |
939 | 938 | ||
940 | snprintf(path, ALUA_METADATA_PATH_LEN, | 939 | snprintf(path, ALUA_METADATA_PATH_LEN, |
@@ -1013,93 +1012,41 @@ static void core_alua_queue_state_change_ua(struct t10_alua_tg_pt_gp *tg_pt_gp) | |||
1013 | spin_unlock(&tg_pt_gp->tg_pt_gp_lock); | 1012 | spin_unlock(&tg_pt_gp->tg_pt_gp_lock); |
1014 | } | 1013 | } |
1015 | 1014 | ||
1016 | static void core_alua_do_transition_tg_pt_work(struct work_struct *work) | ||
1017 | { | ||
1018 | struct t10_alua_tg_pt_gp *tg_pt_gp = container_of(work, | ||
1019 | struct t10_alua_tg_pt_gp, tg_pt_gp_transition_work); | ||
1020 | struct se_device *dev = tg_pt_gp->tg_pt_gp_dev; | ||
1021 | bool explicit = (tg_pt_gp->tg_pt_gp_alua_access_status == | ||
1022 | ALUA_STATUS_ALTERED_BY_EXPLICIT_STPG); | ||
1023 | |||
1024 | /* | ||
1025 | * Update the ALUA metadata buf that has been allocated in | ||
1026 | * core_alua_do_port_transition(), this metadata will be written | ||
1027 | * to struct file. | ||
1028 | * | ||
1029 | * Note that there is the case where we do not want to update the | ||
1030 | * metadata when the saved metadata is being parsed in userspace | ||
1031 | * when setting the existing port access state and access status. | ||
1032 | * | ||
1033 | * Also note that the failure to write out the ALUA metadata to | ||
1034 | * struct file does NOT affect the actual ALUA transition. | ||
1035 | */ | ||
1036 | if (tg_pt_gp->tg_pt_gp_write_metadata) { | ||
1037 | mutex_lock(&tg_pt_gp->tg_pt_gp_md_mutex); | ||
1038 | core_alua_update_tpg_primary_metadata(tg_pt_gp); | ||
1039 | mutex_unlock(&tg_pt_gp->tg_pt_gp_md_mutex); | ||
1040 | } | ||
1041 | /* | ||
1042 | * Set the current primary ALUA access state to the requested new state | ||
1043 | */ | ||
1044 | atomic_set(&tg_pt_gp->tg_pt_gp_alua_access_state, | ||
1045 | tg_pt_gp->tg_pt_gp_alua_pending_state); | ||
1046 | |||
1047 | pr_debug("Successful %s ALUA transition TG PT Group: %s ID: %hu" | ||
1048 | " from primary access state %s to %s\n", (explicit) ? "explicit" : | ||
1049 | "implicit", config_item_name(&tg_pt_gp->tg_pt_gp_group.cg_item), | ||
1050 | tg_pt_gp->tg_pt_gp_id, | ||
1051 | core_alua_dump_state(tg_pt_gp->tg_pt_gp_alua_previous_state), | ||
1052 | core_alua_dump_state(tg_pt_gp->tg_pt_gp_alua_pending_state)); | ||
1053 | |||
1054 | core_alua_queue_state_change_ua(tg_pt_gp); | ||
1055 | |||
1056 | spin_lock(&dev->t10_alua.tg_pt_gps_lock); | ||
1057 | atomic_dec(&tg_pt_gp->tg_pt_gp_ref_cnt); | ||
1058 | spin_unlock(&dev->t10_alua.tg_pt_gps_lock); | ||
1059 | |||
1060 | if (tg_pt_gp->tg_pt_gp_transition_complete) | ||
1061 | complete(tg_pt_gp->tg_pt_gp_transition_complete); | ||
1062 | } | ||
1063 | |||
1064 | static int core_alua_do_transition_tg_pt( | 1015 | static int core_alua_do_transition_tg_pt( |
1065 | struct t10_alua_tg_pt_gp *tg_pt_gp, | 1016 | struct t10_alua_tg_pt_gp *tg_pt_gp, |
1066 | int new_state, | 1017 | int new_state, |
1067 | int explicit) | 1018 | int explicit) |
1068 | { | 1019 | { |
1069 | struct se_device *dev = tg_pt_gp->tg_pt_gp_dev; | 1020 | int prev_state; |
1070 | DECLARE_COMPLETION_ONSTACK(wait); | ||
1071 | 1021 | ||
1022 | mutex_lock(&tg_pt_gp->tg_pt_gp_transition_mutex); | ||
1072 | /* Nothing to be done here */ | 1023 | /* Nothing to be done here */ |
1073 | if (atomic_read(&tg_pt_gp->tg_pt_gp_alua_access_state) == new_state) | 1024 | if (tg_pt_gp->tg_pt_gp_alua_access_state == new_state) { |
1025 | mutex_unlock(&tg_pt_gp->tg_pt_gp_transition_mutex); | ||
1074 | return 0; | 1026 | return 0; |
1027 | } | ||
1075 | 1028 | ||
1076 | if (explicit && new_state == ALUA_ACCESS_STATE_TRANSITION) | 1029 | if (explicit && new_state == ALUA_ACCESS_STATE_TRANSITION) { |
1030 | mutex_unlock(&tg_pt_gp->tg_pt_gp_transition_mutex); | ||
1077 | return -EAGAIN; | 1031 | return -EAGAIN; |
1078 | 1032 | } | |
1079 | /* | ||
1080 | * Flush any pending transitions | ||
1081 | */ | ||
1082 | if (!explicit) | ||
1083 | flush_work(&tg_pt_gp->tg_pt_gp_transition_work); | ||
1084 | 1033 | ||
1085 | /* | 1034 | /* |
1086 | * Save the old primary ALUA access state, and set the current state | 1035 | * Save the old primary ALUA access state, and set the current state |
1087 | * to ALUA_ACCESS_STATE_TRANSITION. | 1036 | * to ALUA_ACCESS_STATE_TRANSITION. |
1088 | */ | 1037 | */ |
1089 | atomic_set(&tg_pt_gp->tg_pt_gp_alua_access_state, | 1038 | prev_state = tg_pt_gp->tg_pt_gp_alua_access_state; |
1090 | ALUA_ACCESS_STATE_TRANSITION); | 1039 | tg_pt_gp->tg_pt_gp_alua_access_state = ALUA_ACCESS_STATE_TRANSITION; |
1091 | tg_pt_gp->tg_pt_gp_alua_access_status = (explicit) ? | 1040 | tg_pt_gp->tg_pt_gp_alua_access_status = (explicit) ? |
1092 | ALUA_STATUS_ALTERED_BY_EXPLICIT_STPG : | 1041 | ALUA_STATUS_ALTERED_BY_EXPLICIT_STPG : |
1093 | ALUA_STATUS_ALTERED_BY_IMPLICIT_ALUA; | 1042 | ALUA_STATUS_ALTERED_BY_IMPLICIT_ALUA; |
1094 | 1043 | ||
1095 | core_alua_queue_state_change_ua(tg_pt_gp); | 1044 | core_alua_queue_state_change_ua(tg_pt_gp); |
1096 | 1045 | ||
1097 | if (new_state == ALUA_ACCESS_STATE_TRANSITION) | 1046 | if (new_state == ALUA_ACCESS_STATE_TRANSITION) { |
1047 | mutex_unlock(&tg_pt_gp->tg_pt_gp_transition_mutex); | ||
1098 | return 0; | 1048 | return 0; |
1099 | 1049 | } | |
1100 | tg_pt_gp->tg_pt_gp_alua_previous_state = | ||
1101 | atomic_read(&tg_pt_gp->tg_pt_gp_alua_access_state); | ||
1102 | tg_pt_gp->tg_pt_gp_alua_pending_state = new_state; | ||
1103 | 1050 | ||
1104 | /* | 1051 | /* |
1105 | * Check for the optional ALUA primary state transition delay | 1052 | * Check for the optional ALUA primary state transition delay |
@@ -1108,19 +1055,36 @@ static int core_alua_do_transition_tg_pt( | |||
1108 | msleep_interruptible(tg_pt_gp->tg_pt_gp_trans_delay_msecs); | 1055 | msleep_interruptible(tg_pt_gp->tg_pt_gp_trans_delay_msecs); |
1109 | 1056 | ||
1110 | /* | 1057 | /* |
1111 | * Take a reference for workqueue item | 1058 | * Set the current primary ALUA access state to the requested new state |
1112 | */ | 1059 | */ |
1113 | spin_lock(&dev->t10_alua.tg_pt_gps_lock); | 1060 | tg_pt_gp->tg_pt_gp_alua_access_state = new_state; |
1114 | atomic_inc(&tg_pt_gp->tg_pt_gp_ref_cnt); | ||
1115 | spin_unlock(&dev->t10_alua.tg_pt_gps_lock); | ||
1116 | 1061 | ||
1117 | schedule_work(&tg_pt_gp->tg_pt_gp_transition_work); | 1062 | /* |
1118 | if (explicit) { | 1063 | * Update the ALUA metadata buf that has been allocated in |
1119 | tg_pt_gp->tg_pt_gp_transition_complete = &wait; | 1064 | * core_alua_do_port_transition(), this metadata will be written |
1120 | wait_for_completion(&wait); | 1065 | * to struct file. |
1121 | tg_pt_gp->tg_pt_gp_transition_complete = NULL; | 1066 | * |
1067 | * Note that there is the case where we do not want to update the | ||
1068 | * metadata when the saved metadata is being parsed in userspace | ||
1069 | * when setting the existing port access state and access status. | ||
1070 | * | ||
1071 | * Also note that the failure to write out the ALUA metadata to | ||
1072 | * struct file does NOT affect the actual ALUA transition. | ||
1073 | */ | ||
1074 | if (tg_pt_gp->tg_pt_gp_write_metadata) { | ||
1075 | core_alua_update_tpg_primary_metadata(tg_pt_gp); | ||
1122 | } | 1076 | } |
1123 | 1077 | ||
1078 | pr_debug("Successful %s ALUA transition TG PT Group: %s ID: %hu" | ||
1079 | " from primary access state %s to %s\n", (explicit) ? "explicit" : | ||
1080 | "implicit", config_item_name(&tg_pt_gp->tg_pt_gp_group.cg_item), | ||
1081 | tg_pt_gp->tg_pt_gp_id, | ||
1082 | core_alua_dump_state(prev_state), | ||
1083 | core_alua_dump_state(new_state)); | ||
1084 | |||
1085 | core_alua_queue_state_change_ua(tg_pt_gp); | ||
1086 | |||
1087 | mutex_unlock(&tg_pt_gp->tg_pt_gp_transition_mutex); | ||
1124 | return 0; | 1088 | return 0; |
1125 | } | 1089 | } |
1126 | 1090 | ||
@@ -1685,14 +1649,12 @@ struct t10_alua_tg_pt_gp *core_alua_allocate_tg_pt_gp(struct se_device *dev, | |||
1685 | } | 1649 | } |
1686 | INIT_LIST_HEAD(&tg_pt_gp->tg_pt_gp_list); | 1650 | INIT_LIST_HEAD(&tg_pt_gp->tg_pt_gp_list); |
1687 | INIT_LIST_HEAD(&tg_pt_gp->tg_pt_gp_lun_list); | 1651 | INIT_LIST_HEAD(&tg_pt_gp->tg_pt_gp_lun_list); |
1688 | mutex_init(&tg_pt_gp->tg_pt_gp_md_mutex); | 1652 | mutex_init(&tg_pt_gp->tg_pt_gp_transition_mutex); |
1689 | spin_lock_init(&tg_pt_gp->tg_pt_gp_lock); | 1653 | spin_lock_init(&tg_pt_gp->tg_pt_gp_lock); |
1690 | atomic_set(&tg_pt_gp->tg_pt_gp_ref_cnt, 0); | 1654 | atomic_set(&tg_pt_gp->tg_pt_gp_ref_cnt, 0); |
1691 | INIT_WORK(&tg_pt_gp->tg_pt_gp_transition_work, | ||
1692 | core_alua_do_transition_tg_pt_work); | ||
1693 | tg_pt_gp->tg_pt_gp_dev = dev; | 1655 | tg_pt_gp->tg_pt_gp_dev = dev; |
1694 | atomic_set(&tg_pt_gp->tg_pt_gp_alua_access_state, | 1656 | tg_pt_gp->tg_pt_gp_alua_access_state = |
1695 | ALUA_ACCESS_STATE_ACTIVE_OPTIMIZED); | 1657 | ALUA_ACCESS_STATE_ACTIVE_OPTIMIZED; |
1696 | /* | 1658 | /* |
1697 | * Enable both explicit and implicit ALUA support by default | 1659 | * Enable both explicit and implicit ALUA support by default |
1698 | */ | 1660 | */ |
@@ -1797,8 +1759,6 @@ void core_alua_free_tg_pt_gp( | |||
1797 | dev->t10_alua.alua_tg_pt_gps_counter--; | 1759 | dev->t10_alua.alua_tg_pt_gps_counter--; |
1798 | spin_unlock(&dev->t10_alua.tg_pt_gps_lock); | 1760 | spin_unlock(&dev->t10_alua.tg_pt_gps_lock); |
1799 | 1761 | ||
1800 | flush_work(&tg_pt_gp->tg_pt_gp_transition_work); | ||
1801 | |||
1802 | /* | 1762 | /* |
1803 | * Allow a struct t10_alua_tg_pt_gp_member * referenced by | 1763 | * Allow a struct t10_alua_tg_pt_gp_member * referenced by |
1804 | * core_alua_get_tg_pt_gp_by_name() in | 1764 | * core_alua_get_tg_pt_gp_by_name() in |
@@ -1938,8 +1898,8 @@ ssize_t core_alua_show_tg_pt_gp_info(struct se_lun *lun, char *page) | |||
1938 | "Primary Access Status: %s\nTG Port Secondary Access" | 1898 | "Primary Access Status: %s\nTG Port Secondary Access" |
1939 | " State: %s\nTG Port Secondary Access Status: %s\n", | 1899 | " State: %s\nTG Port Secondary Access Status: %s\n", |
1940 | config_item_name(tg_pt_ci), tg_pt_gp->tg_pt_gp_id, | 1900 | config_item_name(tg_pt_ci), tg_pt_gp->tg_pt_gp_id, |
1941 | core_alua_dump_state(atomic_read( | 1901 | core_alua_dump_state( |
1942 | &tg_pt_gp->tg_pt_gp_alua_access_state)), | 1902 | tg_pt_gp->tg_pt_gp_alua_access_state), |
1943 | core_alua_dump_status( | 1903 | core_alua_dump_status( |
1944 | tg_pt_gp->tg_pt_gp_alua_access_status), | 1904 | tg_pt_gp->tg_pt_gp_alua_access_status), |
1945 | atomic_read(&lun->lun_tg_pt_secondary_offline) ? | 1905 | atomic_read(&lun->lun_tg_pt_secondary_offline) ? |
diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c index 38b5025e4c7a..70657fd56440 100644 --- a/drivers/target/target_core_configfs.c +++ b/drivers/target/target_core_configfs.c | |||
@@ -2392,7 +2392,7 @@ static ssize_t target_tg_pt_gp_alua_access_state_show(struct config_item *item, | |||
2392 | char *page) | 2392 | char *page) |
2393 | { | 2393 | { |
2394 | return sprintf(page, "%d\n", | 2394 | return sprintf(page, "%d\n", |
2395 | atomic_read(&to_tg_pt_gp(item)->tg_pt_gp_alua_access_state)); | 2395 | to_tg_pt_gp(item)->tg_pt_gp_alua_access_state); |
2396 | } | 2396 | } |
2397 | 2397 | ||
2398 | static ssize_t target_tg_pt_gp_alua_access_state_store(struct config_item *item, | 2398 | static ssize_t target_tg_pt_gp_alua_access_state_store(struct config_item *item, |
diff --git a/drivers/target/target_core_fabric_configfs.c b/drivers/target/target_core_fabric_configfs.c index d8a16ca6baa5..d1e6cab8e3d3 100644 --- a/drivers/target/target_core_fabric_configfs.c +++ b/drivers/target/target_core_fabric_configfs.c | |||
@@ -92,6 +92,11 @@ static int target_fabric_mappedlun_link( | |||
92 | pr_err("Source se_lun->lun_se_dev does not exist\n"); | 92 | pr_err("Source se_lun->lun_se_dev does not exist\n"); |
93 | return -EINVAL; | 93 | return -EINVAL; |
94 | } | 94 | } |
95 | if (lun->lun_shutdown) { | ||
96 | pr_err("Unable to create mappedlun symlink because" | ||
97 | " lun->lun_shutdown=true\n"); | ||
98 | return -EINVAL; | ||
99 | } | ||
95 | se_tpg = lun->lun_tpg; | 100 | se_tpg = lun->lun_tpg; |
96 | 101 | ||
97 | nacl_ci = &lun_acl_ci->ci_parent->ci_group->cg_item; | 102 | nacl_ci = &lun_acl_ci->ci_parent->ci_group->cg_item; |
diff --git a/drivers/target/target_core_tpg.c b/drivers/target/target_core_tpg.c index 6fb191914f45..dfaef4d3b2d2 100644 --- a/drivers/target/target_core_tpg.c +++ b/drivers/target/target_core_tpg.c | |||
@@ -642,6 +642,8 @@ void core_tpg_remove_lun( | |||
642 | */ | 642 | */ |
643 | struct se_device *dev = rcu_dereference_raw(lun->lun_se_dev); | 643 | struct se_device *dev = rcu_dereference_raw(lun->lun_se_dev); |
644 | 644 | ||
645 | lun->lun_shutdown = true; | ||
646 | |||
645 | core_clear_lun_from_tpg(lun, tpg); | 647 | core_clear_lun_from_tpg(lun, tpg); |
646 | /* | 648 | /* |
647 | * Wait for any active I/O references to percpu se_lun->lun_ref to | 649 | * Wait for any active I/O references to percpu se_lun->lun_ref to |
@@ -663,6 +665,8 @@ void core_tpg_remove_lun( | |||
663 | } | 665 | } |
664 | if (!(dev->se_hba->hba_flags & HBA_FLAGS_INTERNAL_USE)) | 666 | if (!(dev->se_hba->hba_flags & HBA_FLAGS_INTERNAL_USE)) |
665 | hlist_del_rcu(&lun->link); | 667 | hlist_del_rcu(&lun->link); |
668 | |||
669 | lun->lun_shutdown = false; | ||
666 | mutex_unlock(&tpg->tpg_lun_mutex); | 670 | mutex_unlock(&tpg->tpg_lun_mutex); |
667 | 671 | ||
668 | percpu_ref_exit(&lun->lun_ref); | 672 | percpu_ref_exit(&lun->lun_ref); |
diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index b1a3cdb29468..a0cd56ee5fe9 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c | |||
@@ -64,8 +64,9 @@ struct kmem_cache *t10_alua_lba_map_cache; | |||
64 | struct kmem_cache *t10_alua_lba_map_mem_cache; | 64 | struct kmem_cache *t10_alua_lba_map_mem_cache; |
65 | 65 | ||
66 | static void transport_complete_task_attr(struct se_cmd *cmd); | 66 | static void transport_complete_task_attr(struct se_cmd *cmd); |
67 | static int translate_sense_reason(struct se_cmd *cmd, sense_reason_t reason); | ||
67 | static void transport_handle_queue_full(struct se_cmd *cmd, | 68 | static void transport_handle_queue_full(struct se_cmd *cmd, |
68 | struct se_device *dev); | 69 | struct se_device *dev, int err, bool write_pending); |
69 | static int transport_put_cmd(struct se_cmd *cmd); | 70 | static int transport_put_cmd(struct se_cmd *cmd); |
70 | static void target_complete_ok_work(struct work_struct *work); | 71 | static void target_complete_ok_work(struct work_struct *work); |
71 | 72 | ||
@@ -804,7 +805,8 @@ void target_qf_do_work(struct work_struct *work) | |||
804 | 805 | ||
805 | if (cmd->t_state == TRANSPORT_COMPLETE_QF_WP) | 806 | if (cmd->t_state == TRANSPORT_COMPLETE_QF_WP) |
806 | transport_write_pending_qf(cmd); | 807 | transport_write_pending_qf(cmd); |
807 | else if (cmd->t_state == TRANSPORT_COMPLETE_QF_OK) | 808 | else if (cmd->t_state == TRANSPORT_COMPLETE_QF_OK || |
809 | cmd->t_state == TRANSPORT_COMPLETE_QF_ERR) | ||
808 | transport_complete_qf(cmd); | 810 | transport_complete_qf(cmd); |
809 | } | 811 | } |
810 | } | 812 | } |
@@ -1719,7 +1721,7 @@ void transport_generic_request_failure(struct se_cmd *cmd, | |||
1719 | } | 1721 | } |
1720 | trace_target_cmd_complete(cmd); | 1722 | trace_target_cmd_complete(cmd); |
1721 | ret = cmd->se_tfo->queue_status(cmd); | 1723 | ret = cmd->se_tfo->queue_status(cmd); |
1722 | if (ret == -EAGAIN || ret == -ENOMEM) | 1724 | if (ret) |
1723 | goto queue_full; | 1725 | goto queue_full; |
1724 | goto check_stop; | 1726 | goto check_stop; |
1725 | default: | 1727 | default: |
@@ -1730,7 +1732,7 @@ void transport_generic_request_failure(struct se_cmd *cmd, | |||
1730 | } | 1732 | } |
1731 | 1733 | ||
1732 | ret = transport_send_check_condition_and_sense(cmd, sense_reason, 0); | 1734 | ret = transport_send_check_condition_and_sense(cmd, sense_reason, 0); |
1733 | if (ret == -EAGAIN || ret == -ENOMEM) | 1735 | if (ret) |
1734 | goto queue_full; | 1736 | goto queue_full; |
1735 | 1737 | ||
1736 | check_stop: | 1738 | check_stop: |
@@ -1739,8 +1741,7 @@ check_stop: | |||
1739 | return; | 1741 | return; |
1740 | 1742 | ||
1741 | queue_full: | 1743 | queue_full: |
1742 | cmd->t_state = TRANSPORT_COMPLETE_QF_OK; | 1744 | transport_handle_queue_full(cmd, cmd->se_dev, ret, false); |
1743 | transport_handle_queue_full(cmd, cmd->se_dev); | ||
1744 | } | 1745 | } |
1745 | EXPORT_SYMBOL(transport_generic_request_failure); | 1746 | EXPORT_SYMBOL(transport_generic_request_failure); |
1746 | 1747 | ||
@@ -1977,13 +1978,29 @@ static void transport_complete_qf(struct se_cmd *cmd) | |||
1977 | int ret = 0; | 1978 | int ret = 0; |
1978 | 1979 | ||
1979 | transport_complete_task_attr(cmd); | 1980 | transport_complete_task_attr(cmd); |
1981 | /* | ||
1982 | * If a fabric driver ->write_pending() or ->queue_data_in() callback | ||
1983 | * has returned neither -ENOMEM or -EAGAIN, assume it's fatal and | ||
1984 | * the same callbacks should not be retried. Return CHECK_CONDITION | ||
1985 | * if a scsi_status is not already set. | ||
1986 | * | ||
1987 | * If a fabric driver ->queue_status() has returned non zero, always | ||
1988 | * keep retrying no matter what.. | ||
1989 | */ | ||
1990 | if (cmd->t_state == TRANSPORT_COMPLETE_QF_ERR) { | ||
1991 | if (cmd->scsi_status) | ||
1992 | goto queue_status; | ||
1980 | 1993 | ||
1981 | if (cmd->se_cmd_flags & SCF_TRANSPORT_TASK_SENSE) { | 1994 | cmd->se_cmd_flags |= SCF_EMULATED_TASK_SENSE; |
1982 | trace_target_cmd_complete(cmd); | 1995 | cmd->scsi_status = SAM_STAT_CHECK_CONDITION; |
1983 | ret = cmd->se_tfo->queue_status(cmd); | 1996 | cmd->scsi_sense_length = TRANSPORT_SENSE_BUFFER; |
1984 | goto out; | 1997 | translate_sense_reason(cmd, TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE); |
1998 | goto queue_status; | ||
1985 | } | 1999 | } |
1986 | 2000 | ||
2001 | if (cmd->se_cmd_flags & SCF_TRANSPORT_TASK_SENSE) | ||
2002 | goto queue_status; | ||
2003 | |||
1987 | switch (cmd->data_direction) { | 2004 | switch (cmd->data_direction) { |
1988 | case DMA_FROM_DEVICE: | 2005 | case DMA_FROM_DEVICE: |
1989 | if (cmd->scsi_status) | 2006 | if (cmd->scsi_status) |
@@ -2007,19 +2024,33 @@ queue_status: | |||
2007 | break; | 2024 | break; |
2008 | } | 2025 | } |
2009 | 2026 | ||
2010 | out: | ||
2011 | if (ret < 0) { | 2027 | if (ret < 0) { |
2012 | transport_handle_queue_full(cmd, cmd->se_dev); | 2028 | transport_handle_queue_full(cmd, cmd->se_dev, ret, false); |
2013 | return; | 2029 | return; |
2014 | } | 2030 | } |
2015 | transport_lun_remove_cmd(cmd); | 2031 | transport_lun_remove_cmd(cmd); |
2016 | transport_cmd_check_stop_to_fabric(cmd); | 2032 | transport_cmd_check_stop_to_fabric(cmd); |
2017 | } | 2033 | } |
2018 | 2034 | ||
2019 | static void transport_handle_queue_full( | 2035 | static void transport_handle_queue_full(struct se_cmd *cmd, struct se_device *dev, |
2020 | struct se_cmd *cmd, | 2036 | int err, bool write_pending) |
2021 | struct se_device *dev) | ||
2022 | { | 2037 | { |
2038 | /* | ||
2039 | * -EAGAIN or -ENOMEM signals retry of ->write_pending() and/or | ||
2040 | * ->queue_data_in() callbacks from new process context. | ||
2041 | * | ||
2042 | * Otherwise for other errors, transport_complete_qf() will send | ||
2043 | * CHECK_CONDITION via ->queue_status() instead of attempting to | ||
2044 | * retry associated fabric driver data-transfer callbacks. | ||
2045 | */ | ||
2046 | if (err == -EAGAIN || err == -ENOMEM) { | ||
2047 | cmd->t_state = (write_pending) ? TRANSPORT_COMPLETE_QF_WP : | ||
2048 | TRANSPORT_COMPLETE_QF_OK; | ||
2049 | } else { | ||
2050 | pr_warn_ratelimited("Got unknown fabric queue status: %d\n", err); | ||
2051 | cmd->t_state = TRANSPORT_COMPLETE_QF_ERR; | ||
2052 | } | ||
2053 | |||
2023 | spin_lock_irq(&dev->qf_cmd_lock); | 2054 | spin_lock_irq(&dev->qf_cmd_lock); |
2024 | list_add_tail(&cmd->se_qf_node, &cmd->se_dev->qf_cmd_list); | 2055 | list_add_tail(&cmd->se_qf_node, &cmd->se_dev->qf_cmd_list); |
2025 | atomic_inc_mb(&dev->dev_qf_count); | 2056 | atomic_inc_mb(&dev->dev_qf_count); |
@@ -2083,7 +2114,7 @@ static void target_complete_ok_work(struct work_struct *work) | |||
2083 | WARN_ON(!cmd->scsi_status); | 2114 | WARN_ON(!cmd->scsi_status); |
2084 | ret = transport_send_check_condition_and_sense( | 2115 | ret = transport_send_check_condition_and_sense( |
2085 | cmd, 0, 1); | 2116 | cmd, 0, 1); |
2086 | if (ret == -EAGAIN || ret == -ENOMEM) | 2117 | if (ret) |
2087 | goto queue_full; | 2118 | goto queue_full; |
2088 | 2119 | ||
2089 | transport_lun_remove_cmd(cmd); | 2120 | transport_lun_remove_cmd(cmd); |
@@ -2109,7 +2140,7 @@ static void target_complete_ok_work(struct work_struct *work) | |||
2109 | } else if (rc) { | 2140 | } else if (rc) { |
2110 | ret = transport_send_check_condition_and_sense(cmd, | 2141 | ret = transport_send_check_condition_and_sense(cmd, |
2111 | rc, 0); | 2142 | rc, 0); |
2112 | if (ret == -EAGAIN || ret == -ENOMEM) | 2143 | if (ret) |
2113 | goto queue_full; | 2144 | goto queue_full; |
2114 | 2145 | ||
2115 | transport_lun_remove_cmd(cmd); | 2146 | transport_lun_remove_cmd(cmd); |
@@ -2134,7 +2165,7 @@ queue_rsp: | |||
2134 | if (target_read_prot_action(cmd)) { | 2165 | if (target_read_prot_action(cmd)) { |
2135 | ret = transport_send_check_condition_and_sense(cmd, | 2166 | ret = transport_send_check_condition_and_sense(cmd, |
2136 | cmd->pi_err, 0); | 2167 | cmd->pi_err, 0); |
2137 | if (ret == -EAGAIN || ret == -ENOMEM) | 2168 | if (ret) |
2138 | goto queue_full; | 2169 | goto queue_full; |
2139 | 2170 | ||
2140 | transport_lun_remove_cmd(cmd); | 2171 | transport_lun_remove_cmd(cmd); |
@@ -2144,7 +2175,7 @@ queue_rsp: | |||
2144 | 2175 | ||
2145 | trace_target_cmd_complete(cmd); | 2176 | trace_target_cmd_complete(cmd); |
2146 | ret = cmd->se_tfo->queue_data_in(cmd); | 2177 | ret = cmd->se_tfo->queue_data_in(cmd); |
2147 | if (ret == -EAGAIN || ret == -ENOMEM) | 2178 | if (ret) |
2148 | goto queue_full; | 2179 | goto queue_full; |
2149 | break; | 2180 | break; |
2150 | case DMA_TO_DEVICE: | 2181 | case DMA_TO_DEVICE: |
@@ -2157,7 +2188,7 @@ queue_rsp: | |||
2157 | atomic_long_add(cmd->data_length, | 2188 | atomic_long_add(cmd->data_length, |
2158 | &cmd->se_lun->lun_stats.tx_data_octets); | 2189 | &cmd->se_lun->lun_stats.tx_data_octets); |
2159 | ret = cmd->se_tfo->queue_data_in(cmd); | 2190 | ret = cmd->se_tfo->queue_data_in(cmd); |
2160 | if (ret == -EAGAIN || ret == -ENOMEM) | 2191 | if (ret) |
2161 | goto queue_full; | 2192 | goto queue_full; |
2162 | break; | 2193 | break; |
2163 | } | 2194 | } |
@@ -2166,7 +2197,7 @@ queue_rsp: | |||
2166 | queue_status: | 2197 | queue_status: |
2167 | trace_target_cmd_complete(cmd); | 2198 | trace_target_cmd_complete(cmd); |
2168 | ret = cmd->se_tfo->queue_status(cmd); | 2199 | ret = cmd->se_tfo->queue_status(cmd); |
2169 | if (ret == -EAGAIN || ret == -ENOMEM) | 2200 | if (ret) |
2170 | goto queue_full; | 2201 | goto queue_full; |
2171 | break; | 2202 | break; |
2172 | default: | 2203 | default: |
@@ -2180,8 +2211,8 @@ queue_status: | |||
2180 | queue_full: | 2211 | queue_full: |
2181 | pr_debug("Handling complete_ok QUEUE_FULL: se_cmd: %p," | 2212 | pr_debug("Handling complete_ok QUEUE_FULL: se_cmd: %p," |
2182 | " data_direction: %d\n", cmd, cmd->data_direction); | 2213 | " data_direction: %d\n", cmd, cmd->data_direction); |
2183 | cmd->t_state = TRANSPORT_COMPLETE_QF_OK; | 2214 | |
2184 | transport_handle_queue_full(cmd, cmd->se_dev); | 2215 | transport_handle_queue_full(cmd, cmd->se_dev, ret, false); |
2185 | } | 2216 | } |
2186 | 2217 | ||
2187 | void target_free_sgl(struct scatterlist *sgl, int nents) | 2218 | void target_free_sgl(struct scatterlist *sgl, int nents) |
@@ -2449,18 +2480,14 @@ transport_generic_new_cmd(struct se_cmd *cmd) | |||
2449 | spin_unlock_irqrestore(&cmd->t_state_lock, flags); | 2480 | spin_unlock_irqrestore(&cmd->t_state_lock, flags); |
2450 | 2481 | ||
2451 | ret = cmd->se_tfo->write_pending(cmd); | 2482 | ret = cmd->se_tfo->write_pending(cmd); |
2452 | if (ret == -EAGAIN || ret == -ENOMEM) | 2483 | if (ret) |
2453 | goto queue_full; | 2484 | goto queue_full; |
2454 | 2485 | ||
2455 | /* fabric drivers should only return -EAGAIN or -ENOMEM as error */ | 2486 | return 0; |
2456 | WARN_ON(ret); | ||
2457 | |||
2458 | return (!ret) ? 0 : TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; | ||
2459 | 2487 | ||
2460 | queue_full: | 2488 | queue_full: |
2461 | pr_debug("Handling write_pending QUEUE__FULL: se_cmd: %p\n", cmd); | 2489 | pr_debug("Handling write_pending QUEUE__FULL: se_cmd: %p\n", cmd); |
2462 | cmd->t_state = TRANSPORT_COMPLETE_QF_WP; | 2490 | transport_handle_queue_full(cmd, cmd->se_dev, ret, true); |
2463 | transport_handle_queue_full(cmd, cmd->se_dev); | ||
2464 | return 0; | 2491 | return 0; |
2465 | } | 2492 | } |
2466 | EXPORT_SYMBOL(transport_generic_new_cmd); | 2493 | EXPORT_SYMBOL(transport_generic_new_cmd); |
@@ -2470,10 +2497,10 @@ static void transport_write_pending_qf(struct se_cmd *cmd) | |||
2470 | int ret; | 2497 | int ret; |
2471 | 2498 | ||
2472 | ret = cmd->se_tfo->write_pending(cmd); | 2499 | ret = cmd->se_tfo->write_pending(cmd); |
2473 | if (ret == -EAGAIN || ret == -ENOMEM) { | 2500 | if (ret) { |
2474 | pr_debug("Handling write_pending QUEUE__FULL: se_cmd: %p\n", | 2501 | pr_debug("Handling write_pending QUEUE__FULL: se_cmd: %p\n", |
2475 | cmd); | 2502 | cmd); |
2476 | transport_handle_queue_full(cmd, cmd->se_dev); | 2503 | transport_handle_queue_full(cmd, cmd->se_dev, ret, true); |
2477 | } | 2504 | } |
2478 | } | 2505 | } |
2479 | 2506 | ||
@@ -3011,6 +3038,8 @@ static int __transport_check_aborted_status(struct se_cmd *cmd, int send_status) | |||
3011 | __releases(&cmd->t_state_lock) | 3038 | __releases(&cmd->t_state_lock) |
3012 | __acquires(&cmd->t_state_lock) | 3039 | __acquires(&cmd->t_state_lock) |
3013 | { | 3040 | { |
3041 | int ret; | ||
3042 | |||
3014 | assert_spin_locked(&cmd->t_state_lock); | 3043 | assert_spin_locked(&cmd->t_state_lock); |
3015 | WARN_ON_ONCE(!irqs_disabled()); | 3044 | WARN_ON_ONCE(!irqs_disabled()); |
3016 | 3045 | ||
@@ -3034,7 +3063,9 @@ static int __transport_check_aborted_status(struct se_cmd *cmd, int send_status) | |||
3034 | trace_target_cmd_complete(cmd); | 3063 | trace_target_cmd_complete(cmd); |
3035 | 3064 | ||
3036 | spin_unlock_irq(&cmd->t_state_lock); | 3065 | spin_unlock_irq(&cmd->t_state_lock); |
3037 | cmd->se_tfo->queue_status(cmd); | 3066 | ret = cmd->se_tfo->queue_status(cmd); |
3067 | if (ret) | ||
3068 | transport_handle_queue_full(cmd, cmd->se_dev, ret, false); | ||
3038 | spin_lock_irq(&cmd->t_state_lock); | 3069 | spin_lock_irq(&cmd->t_state_lock); |
3039 | 3070 | ||
3040 | return 1; | 3071 | return 1; |
@@ -3055,6 +3086,7 @@ EXPORT_SYMBOL(transport_check_aborted_status); | |||
3055 | void transport_send_task_abort(struct se_cmd *cmd) | 3086 | void transport_send_task_abort(struct se_cmd *cmd) |
3056 | { | 3087 | { |
3057 | unsigned long flags; | 3088 | unsigned long flags; |
3089 | int ret; | ||
3058 | 3090 | ||
3059 | spin_lock_irqsave(&cmd->t_state_lock, flags); | 3091 | spin_lock_irqsave(&cmd->t_state_lock, flags); |
3060 | if (cmd->se_cmd_flags & (SCF_SENT_CHECK_CONDITION)) { | 3092 | if (cmd->se_cmd_flags & (SCF_SENT_CHECK_CONDITION)) { |
@@ -3090,7 +3122,9 @@ send_abort: | |||
3090 | cmd->t_task_cdb[0], cmd->tag); | 3122 | cmd->t_task_cdb[0], cmd->tag); |
3091 | 3123 | ||
3092 | trace_target_cmd_complete(cmd); | 3124 | trace_target_cmd_complete(cmd); |
3093 | cmd->se_tfo->queue_status(cmd); | 3125 | ret = cmd->se_tfo->queue_status(cmd); |
3126 | if (ret) | ||
3127 | transport_handle_queue_full(cmd, cmd->se_dev, ret, false); | ||
3094 | } | 3128 | } |
3095 | 3129 | ||
3096 | static void target_tmr_work(struct work_struct *work) | 3130 | static void target_tmr_work(struct work_struct *work) |
diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c index c6874c38a10b..f615c3bbb73e 100644 --- a/drivers/target/target_core_user.c +++ b/drivers/target/target_core_user.c | |||
@@ -311,24 +311,50 @@ static void free_data_area(struct tcmu_dev *udev, struct tcmu_cmd *cmd) | |||
311 | DATA_BLOCK_BITS); | 311 | DATA_BLOCK_BITS); |
312 | } | 312 | } |
313 | 313 | ||
314 | static void gather_data_area(struct tcmu_dev *udev, unsigned long *cmd_bitmap, | 314 | static void gather_data_area(struct tcmu_dev *udev, struct tcmu_cmd *cmd, |
315 | struct scatterlist *data_sg, unsigned int data_nents) | 315 | bool bidi) |
316 | { | 316 | { |
317 | struct se_cmd *se_cmd = cmd->se_cmd; | ||
317 | int i, block; | 318 | int i, block; |
318 | int block_remaining = 0; | 319 | int block_remaining = 0; |
319 | void *from, *to; | 320 | void *from, *to; |
320 | size_t copy_bytes, from_offset; | 321 | size_t copy_bytes, from_offset; |
321 | struct scatterlist *sg; | 322 | struct scatterlist *sg, *data_sg; |
323 | unsigned int data_nents; | ||
324 | DECLARE_BITMAP(bitmap, DATA_BLOCK_BITS); | ||
325 | |||
326 | bitmap_copy(bitmap, cmd->data_bitmap, DATA_BLOCK_BITS); | ||
327 | |||
328 | if (!bidi) { | ||
329 | data_sg = se_cmd->t_data_sg; | ||
330 | data_nents = se_cmd->t_data_nents; | ||
331 | } else { | ||
332 | uint32_t count; | ||
333 | |||
334 | /* | ||
335 | * For bidi case, the first count blocks are for Data-Out | ||
336 | * buffer blocks, and before gathering the Data-In buffer | ||
337 | * the Data-Out buffer blocks should be discarded. | ||
338 | */ | ||
339 | count = DIV_ROUND_UP(se_cmd->data_length, DATA_BLOCK_SIZE); | ||
340 | while (count--) { | ||
341 | block = find_first_bit(bitmap, DATA_BLOCK_BITS); | ||
342 | clear_bit(block, bitmap); | ||
343 | } | ||
344 | |||
345 | data_sg = se_cmd->t_bidi_data_sg; | ||
346 | data_nents = se_cmd->t_bidi_data_nents; | ||
347 | } | ||
322 | 348 | ||
323 | for_each_sg(data_sg, sg, data_nents, i) { | 349 | for_each_sg(data_sg, sg, data_nents, i) { |
324 | int sg_remaining = sg->length; | 350 | int sg_remaining = sg->length; |
325 | to = kmap_atomic(sg_page(sg)) + sg->offset; | 351 | to = kmap_atomic(sg_page(sg)) + sg->offset; |
326 | while (sg_remaining > 0) { | 352 | while (sg_remaining > 0) { |
327 | if (block_remaining == 0) { | 353 | if (block_remaining == 0) { |
328 | block = find_first_bit(cmd_bitmap, | 354 | block = find_first_bit(bitmap, |
329 | DATA_BLOCK_BITS); | 355 | DATA_BLOCK_BITS); |
330 | block_remaining = DATA_BLOCK_SIZE; | 356 | block_remaining = DATA_BLOCK_SIZE; |
331 | clear_bit(block, cmd_bitmap); | 357 | clear_bit(block, bitmap); |
332 | } | 358 | } |
333 | copy_bytes = min_t(size_t, sg_remaining, | 359 | copy_bytes = min_t(size_t, sg_remaining, |
334 | block_remaining); | 360 | block_remaining); |
@@ -394,6 +420,27 @@ static bool is_ring_space_avail(struct tcmu_dev *udev, size_t cmd_size, size_t d | |||
394 | return true; | 420 | return true; |
395 | } | 421 | } |
396 | 422 | ||
423 | static inline size_t tcmu_cmd_get_data_length(struct tcmu_cmd *tcmu_cmd) | ||
424 | { | ||
425 | struct se_cmd *se_cmd = tcmu_cmd->se_cmd; | ||
426 | size_t data_length = round_up(se_cmd->data_length, DATA_BLOCK_SIZE); | ||
427 | |||
428 | if (se_cmd->se_cmd_flags & SCF_BIDI) { | ||
429 | BUG_ON(!(se_cmd->t_bidi_data_sg && se_cmd->t_bidi_data_nents)); | ||
430 | data_length += round_up(se_cmd->t_bidi_data_sg->length, | ||
431 | DATA_BLOCK_SIZE); | ||
432 | } | ||
433 | |||
434 | return data_length; | ||
435 | } | ||
436 | |||
437 | static inline uint32_t tcmu_cmd_get_block_cnt(struct tcmu_cmd *tcmu_cmd) | ||
438 | { | ||
439 | size_t data_length = tcmu_cmd_get_data_length(tcmu_cmd); | ||
440 | |||
441 | return data_length / DATA_BLOCK_SIZE; | ||
442 | } | ||
443 | |||
397 | static sense_reason_t | 444 | static sense_reason_t |
398 | tcmu_queue_cmd_ring(struct tcmu_cmd *tcmu_cmd) | 445 | tcmu_queue_cmd_ring(struct tcmu_cmd *tcmu_cmd) |
399 | { | 446 | { |
@@ -407,7 +454,7 @@ tcmu_queue_cmd_ring(struct tcmu_cmd *tcmu_cmd) | |||
407 | uint32_t cmd_head; | 454 | uint32_t cmd_head; |
408 | uint64_t cdb_off; | 455 | uint64_t cdb_off; |
409 | bool copy_to_data_area; | 456 | bool copy_to_data_area; |
410 | size_t data_length; | 457 | size_t data_length = tcmu_cmd_get_data_length(tcmu_cmd); |
411 | DECLARE_BITMAP(old_bitmap, DATA_BLOCK_BITS); | 458 | DECLARE_BITMAP(old_bitmap, DATA_BLOCK_BITS); |
412 | 459 | ||
413 | if (test_bit(TCMU_DEV_BIT_BROKEN, &udev->flags)) | 460 | if (test_bit(TCMU_DEV_BIT_BROKEN, &udev->flags)) |
@@ -421,8 +468,7 @@ tcmu_queue_cmd_ring(struct tcmu_cmd *tcmu_cmd) | |||
421 | * expensive to tell how many regions are freed in the bitmap | 468 | * expensive to tell how many regions are freed in the bitmap |
422 | */ | 469 | */ |
423 | base_command_size = max(offsetof(struct tcmu_cmd_entry, | 470 | base_command_size = max(offsetof(struct tcmu_cmd_entry, |
424 | req.iov[se_cmd->t_bidi_data_nents + | 471 | req.iov[tcmu_cmd_get_block_cnt(tcmu_cmd)]), |
425 | se_cmd->t_data_nents]), | ||
426 | sizeof(struct tcmu_cmd_entry)); | 472 | sizeof(struct tcmu_cmd_entry)); |
427 | command_size = base_command_size | 473 | command_size = base_command_size |
428 | + round_up(scsi_command_size(se_cmd->t_task_cdb), TCMU_OP_ALIGN_SIZE); | 474 | + round_up(scsi_command_size(se_cmd->t_task_cdb), TCMU_OP_ALIGN_SIZE); |
@@ -433,11 +479,6 @@ tcmu_queue_cmd_ring(struct tcmu_cmd *tcmu_cmd) | |||
433 | 479 | ||
434 | mb = udev->mb_addr; | 480 | mb = udev->mb_addr; |
435 | cmd_head = mb->cmd_head % udev->cmdr_size; /* UAM */ | 481 | cmd_head = mb->cmd_head % udev->cmdr_size; /* UAM */ |
436 | data_length = se_cmd->data_length; | ||
437 | if (se_cmd->se_cmd_flags & SCF_BIDI) { | ||
438 | BUG_ON(!(se_cmd->t_bidi_data_sg && se_cmd->t_bidi_data_nents)); | ||
439 | data_length += se_cmd->t_bidi_data_sg->length; | ||
440 | } | ||
441 | if ((command_size > (udev->cmdr_size / 2)) || | 482 | if ((command_size > (udev->cmdr_size / 2)) || |
442 | data_length > udev->data_size) { | 483 | data_length > udev->data_size) { |
443 | pr_warn("TCMU: Request of size %zu/%zu is too big for %u/%zu " | 484 | pr_warn("TCMU: Request of size %zu/%zu is too big for %u/%zu " |
@@ -511,11 +552,14 @@ tcmu_queue_cmd_ring(struct tcmu_cmd *tcmu_cmd) | |||
511 | entry->req.iov_dif_cnt = 0; | 552 | entry->req.iov_dif_cnt = 0; |
512 | 553 | ||
513 | /* Handle BIDI commands */ | 554 | /* Handle BIDI commands */ |
514 | iov_cnt = 0; | 555 | if (se_cmd->se_cmd_flags & SCF_BIDI) { |
515 | alloc_and_scatter_data_area(udev, se_cmd->t_bidi_data_sg, | 556 | iov_cnt = 0; |
516 | se_cmd->t_bidi_data_nents, &iov, &iov_cnt, false); | 557 | iov++; |
517 | entry->req.iov_bidi_cnt = iov_cnt; | 558 | alloc_and_scatter_data_area(udev, se_cmd->t_bidi_data_sg, |
518 | 559 | se_cmd->t_bidi_data_nents, &iov, &iov_cnt, | |
560 | false); | ||
561 | entry->req.iov_bidi_cnt = iov_cnt; | ||
562 | } | ||
519 | /* cmd's data_bitmap is what changed in process */ | 563 | /* cmd's data_bitmap is what changed in process */ |
520 | bitmap_xor(tcmu_cmd->data_bitmap, old_bitmap, udev->data_bitmap, | 564 | bitmap_xor(tcmu_cmd->data_bitmap, old_bitmap, udev->data_bitmap, |
521 | DATA_BLOCK_BITS); | 565 | DATA_BLOCK_BITS); |
@@ -592,19 +636,11 @@ static void tcmu_handle_completion(struct tcmu_cmd *cmd, struct tcmu_cmd_entry * | |||
592 | se_cmd->scsi_sense_length); | 636 | se_cmd->scsi_sense_length); |
593 | free_data_area(udev, cmd); | 637 | free_data_area(udev, cmd); |
594 | } else if (se_cmd->se_cmd_flags & SCF_BIDI) { | 638 | } else if (se_cmd->se_cmd_flags & SCF_BIDI) { |
595 | DECLARE_BITMAP(bitmap, DATA_BLOCK_BITS); | ||
596 | |||
597 | /* Get Data-In buffer before clean up */ | 639 | /* Get Data-In buffer before clean up */ |
598 | bitmap_copy(bitmap, cmd->data_bitmap, DATA_BLOCK_BITS); | 640 | gather_data_area(udev, cmd, true); |
599 | gather_data_area(udev, bitmap, | ||
600 | se_cmd->t_bidi_data_sg, se_cmd->t_bidi_data_nents); | ||
601 | free_data_area(udev, cmd); | 641 | free_data_area(udev, cmd); |
602 | } else if (se_cmd->data_direction == DMA_FROM_DEVICE) { | 642 | } else if (se_cmd->data_direction == DMA_FROM_DEVICE) { |
603 | DECLARE_BITMAP(bitmap, DATA_BLOCK_BITS); | 643 | gather_data_area(udev, cmd, false); |
604 | |||
605 | bitmap_copy(bitmap, cmd->data_bitmap, DATA_BLOCK_BITS); | ||
606 | gather_data_area(udev, bitmap, | ||
607 | se_cmd->t_data_sg, se_cmd->t_data_nents); | ||
608 | free_data_area(udev, cmd); | 644 | free_data_area(udev, cmd); |
609 | } else if (se_cmd->data_direction == DMA_TO_DEVICE) { | 645 | } else if (se_cmd->data_direction == DMA_TO_DEVICE) { |
610 | free_data_area(udev, cmd); | 646 | free_data_area(udev, cmd); |
@@ -1196,11 +1232,6 @@ static ssize_t tcmu_cmd_time_out_store(struct config_item *item, const char *pag | |||
1196 | if (ret < 0) | 1232 | if (ret < 0) |
1197 | return ret; | 1233 | return ret; |
1198 | 1234 | ||
1199 | if (!val) { | ||
1200 | pr_err("Illegal value for cmd_time_out\n"); | ||
1201 | return -EINVAL; | ||
1202 | } | ||
1203 | |||
1204 | udev->cmd_time_out = val * MSEC_PER_SEC; | 1235 | udev->cmd_time_out = val * MSEC_PER_SEC; |
1205 | return count; | 1236 | return count; |
1206 | } | 1237 | } |
diff --git a/drivers/tty/serial/8250/Kconfig b/drivers/tty/serial/8250/Kconfig index a65fb8197aec..0e3f529d50e9 100644 --- a/drivers/tty/serial/8250/Kconfig +++ b/drivers/tty/serial/8250/Kconfig | |||
@@ -128,9 +128,13 @@ config SERIAL_8250_PCI | |||
128 | by the parport_serial driver, enabled with CONFIG_PARPORT_SERIAL. | 128 | by the parport_serial driver, enabled with CONFIG_PARPORT_SERIAL. |
129 | 129 | ||
130 | config SERIAL_8250_EXAR | 130 | config SERIAL_8250_EXAR |
131 | tristate "8250/16550 PCI device support" | 131 | tristate "8250/16550 Exar/Commtech PCI/PCIe device support" |
132 | depends on SERIAL_8250_PCI | 132 | depends on SERIAL_8250_PCI |
133 | default SERIAL_8250 | 133 | default SERIAL_8250 |
134 | help | ||
135 | This builds support for XR17C1xx, XR17V3xx and some Commtech | ||
136 | 422x PCIe serial cards that are not covered by the more generic | ||
137 | SERIAL_8250_PCI option. | ||
134 | 138 | ||
135 | config SERIAL_8250_HP300 | 139 | config SERIAL_8250_HP300 |
136 | tristate | 140 | tristate |
diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c index 56f92d7348bf..b0a377725d63 100644 --- a/drivers/tty/serial/amba-pl011.c +++ b/drivers/tty/serial/amba-pl011.c | |||
@@ -2452,18 +2452,37 @@ static void pl011_early_write(struct console *con, const char *s, unsigned n) | |||
2452 | uart_console_write(&dev->port, s, n, pl011_putc); | 2452 | uart_console_write(&dev->port, s, n, pl011_putc); |
2453 | } | 2453 | } |
2454 | 2454 | ||
2455 | /* | ||
2456 | * On non-ACPI systems, earlycon is enabled by specifying | ||
2457 | * "earlycon=pl011,<address>" on the kernel command line. | ||
2458 | * | ||
2459 | * On ACPI ARM64 systems, an "early" console is enabled via the SPCR table, | ||
2460 | * by specifying only "earlycon" on the command line. Because it requires | ||
2461 | * SPCR, the console starts after ACPI is parsed, which is later than a | ||
2462 | * traditional early console. | ||
2463 | * | ||
2464 | * To get the traditional early console that starts before ACPI is parsed, | ||
2465 | * specify the full "earlycon=pl011,<address>" option. | ||
2466 | */ | ||
2455 | static int __init pl011_early_console_setup(struct earlycon_device *device, | 2467 | static int __init pl011_early_console_setup(struct earlycon_device *device, |
2456 | const char *opt) | 2468 | const char *opt) |
2457 | { | 2469 | { |
2458 | if (!device->port.membase) | 2470 | if (!device->port.membase) |
2459 | return -ENODEV; | 2471 | return -ENODEV; |
2460 | 2472 | ||
2461 | device->con->write = qdf2400_e44_present ? | 2473 | /* On QDF2400 SOCs affected by Erratum 44, the "qdf2400_e44" must |
2462 | qdf2400_e44_early_write : pl011_early_write; | 2474 | * also be specified, e.g. "earlycon=pl011,<address>,qdf2400_e44". |
2475 | */ | ||
2476 | if (!strcmp(device->options, "qdf2400_e44")) | ||
2477 | device->con->write = qdf2400_e44_early_write; | ||
2478 | else | ||
2479 | device->con->write = pl011_early_write; | ||
2480 | |||
2463 | return 0; | 2481 | return 0; |
2464 | } | 2482 | } |
2465 | OF_EARLYCON_DECLARE(pl011, "arm,pl011", pl011_early_console_setup); | 2483 | OF_EARLYCON_DECLARE(pl011, "arm,pl011", pl011_early_console_setup); |
2466 | OF_EARLYCON_DECLARE(pl011, "arm,sbsa-uart", pl011_early_console_setup); | 2484 | OF_EARLYCON_DECLARE(pl011, "arm,sbsa-uart", pl011_early_console_setup); |
2485 | EARLYCON_DECLARE(qdf2400_e44, pl011_early_console_setup); | ||
2467 | 2486 | ||
2468 | #else | 2487 | #else |
2469 | #define AMBA_CONSOLE NULL | 2488 | #define AMBA_CONSOLE NULL |
diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c index dcebb28ffbc4..1f50a83ef958 100644 --- a/drivers/tty/serial/atmel_serial.c +++ b/drivers/tty/serial/atmel_serial.c | |||
@@ -1951,6 +1951,11 @@ static void atmel_flush_buffer(struct uart_port *port) | |||
1951 | atmel_uart_writel(port, ATMEL_PDC_TCR, 0); | 1951 | atmel_uart_writel(port, ATMEL_PDC_TCR, 0); |
1952 | atmel_port->pdc_tx.ofs = 0; | 1952 | atmel_port->pdc_tx.ofs = 0; |
1953 | } | 1953 | } |
1954 | /* | ||
1955 | * in uart_flush_buffer(), the xmit circular buffer has just | ||
1956 | * been cleared, so we have to reset tx_len accordingly. | ||
1957 | */ | ||
1958 | atmel_port->tx_len = 0; | ||
1954 | } | 1959 | } |
1955 | 1960 | ||
1956 | /* | 1961 | /* |
@@ -2483,6 +2488,9 @@ static void atmel_console_write(struct console *co, const char *s, u_int count) | |||
2483 | pdc_tx = atmel_uart_readl(port, ATMEL_PDC_PTSR) & ATMEL_PDC_TXTEN; | 2488 | pdc_tx = atmel_uart_readl(port, ATMEL_PDC_PTSR) & ATMEL_PDC_TXTEN; |
2484 | atmel_uart_writel(port, ATMEL_PDC_PTCR, ATMEL_PDC_TXTDIS); | 2489 | atmel_uart_writel(port, ATMEL_PDC_PTCR, ATMEL_PDC_TXTDIS); |
2485 | 2490 | ||
2491 | /* Make sure that tx path is actually able to send characters */ | ||
2492 | atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXEN); | ||
2493 | |||
2486 | uart_console_write(port, s, count, atmel_console_putchar); | 2494 | uart_console_write(port, s, count, atmel_console_putchar); |
2487 | 2495 | ||
2488 | /* | 2496 | /* |
diff --git a/drivers/tty/serial/mxs-auart.c b/drivers/tty/serial/mxs-auart.c index 6989b227d134..be94246b6fcc 100644 --- a/drivers/tty/serial/mxs-auart.c +++ b/drivers/tty/serial/mxs-auart.c | |||
@@ -1088,7 +1088,7 @@ static void mxs_auart_settermios(struct uart_port *u, | |||
1088 | AUART_LINECTRL_BAUD_DIV_MAX); | 1088 | AUART_LINECTRL_BAUD_DIV_MAX); |
1089 | baud_max = u->uartclk * 32 / AUART_LINECTRL_BAUD_DIV_MIN; | 1089 | baud_max = u->uartclk * 32 / AUART_LINECTRL_BAUD_DIV_MIN; |
1090 | baud = uart_get_baud_rate(u, termios, old, baud_min, baud_max); | 1090 | baud = uart_get_baud_rate(u, termios, old, baud_min, baud_max); |
1091 | div = u->uartclk * 32 / baud; | 1091 | div = DIV_ROUND_CLOSEST(u->uartclk * 32, baud); |
1092 | } | 1092 | } |
1093 | 1093 | ||
1094 | ctrl |= AUART_LINECTRL_BAUD_DIVFRAC(div & 0x3F); | 1094 | ctrl |= AUART_LINECTRL_BAUD_DIVFRAC(div & 0x3F); |
diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c index b0500a0a87b8..e4603b09863a 100644 --- a/drivers/tty/tty_ldisc.c +++ b/drivers/tty/tty_ldisc.c | |||
@@ -492,6 +492,41 @@ static void tty_ldisc_close(struct tty_struct *tty, struct tty_ldisc *ld) | |||
492 | } | 492 | } |
493 | 493 | ||
494 | /** | 494 | /** |
495 | * tty_ldisc_restore - helper for tty ldisc change | ||
496 | * @tty: tty to recover | ||
497 | * @old: previous ldisc | ||
498 | * | ||
499 | * Restore the previous line discipline or N_TTY when a line discipline | ||
500 | * change fails due to an open error | ||
501 | */ | ||
502 | |||
503 | static void tty_ldisc_restore(struct tty_struct *tty, struct tty_ldisc *old) | ||
504 | { | ||
505 | struct tty_ldisc *new_ldisc; | ||
506 | int r; | ||
507 | |||
508 | /* There is an outstanding reference here so this is safe */ | ||
509 | old = tty_ldisc_get(tty, old->ops->num); | ||
510 | WARN_ON(IS_ERR(old)); | ||
511 | tty->ldisc = old; | ||
512 | tty_set_termios_ldisc(tty, old->ops->num); | ||
513 | if (tty_ldisc_open(tty, old) < 0) { | ||
514 | tty_ldisc_put(old); | ||
515 | /* This driver is always present */ | ||
516 | new_ldisc = tty_ldisc_get(tty, N_TTY); | ||
517 | if (IS_ERR(new_ldisc)) | ||
518 | panic("n_tty: get"); | ||
519 | tty->ldisc = new_ldisc; | ||
520 | tty_set_termios_ldisc(tty, N_TTY); | ||
521 | r = tty_ldisc_open(tty, new_ldisc); | ||
522 | if (r < 0) | ||
523 | panic("Couldn't open N_TTY ldisc for " | ||
524 | "%s --- error %d.", | ||
525 | tty_name(tty), r); | ||
526 | } | ||
527 | } | ||
528 | |||
529 | /** | ||
495 | * tty_set_ldisc - set line discipline | 530 | * tty_set_ldisc - set line discipline |
496 | * @tty: the terminal to set | 531 | * @tty: the terminal to set |
497 | * @ldisc: the line discipline | 532 | * @ldisc: the line discipline |
@@ -504,7 +539,12 @@ static void tty_ldisc_close(struct tty_struct *tty, struct tty_ldisc *ld) | |||
504 | 539 | ||
505 | int tty_set_ldisc(struct tty_struct *tty, int disc) | 540 | int tty_set_ldisc(struct tty_struct *tty, int disc) |
506 | { | 541 | { |
507 | int retval, old_disc; | 542 | int retval; |
543 | struct tty_ldisc *old_ldisc, *new_ldisc; | ||
544 | |||
545 | new_ldisc = tty_ldisc_get(tty, disc); | ||
546 | if (IS_ERR(new_ldisc)) | ||
547 | return PTR_ERR(new_ldisc); | ||
508 | 548 | ||
509 | tty_lock(tty); | 549 | tty_lock(tty); |
510 | retval = tty_ldisc_lock(tty, 5 * HZ); | 550 | retval = tty_ldisc_lock(tty, 5 * HZ); |
@@ -517,8 +557,7 @@ int tty_set_ldisc(struct tty_struct *tty, int disc) | |||
517 | } | 557 | } |
518 | 558 | ||
519 | /* Check the no-op case */ | 559 | /* Check the no-op case */ |
520 | old_disc = tty->ldisc->ops->num; | 560 | if (tty->ldisc->ops->num == disc) |
521 | if (old_disc == disc) | ||
522 | goto out; | 561 | goto out; |
523 | 562 | ||
524 | if (test_bit(TTY_HUPPED, &tty->flags)) { | 563 | if (test_bit(TTY_HUPPED, &tty->flags)) { |
@@ -527,25 +566,34 @@ int tty_set_ldisc(struct tty_struct *tty, int disc) | |||
527 | goto out; | 566 | goto out; |
528 | } | 567 | } |
529 | 568 | ||
530 | retval = tty_ldisc_reinit(tty, disc); | 569 | old_ldisc = tty->ldisc; |
570 | |||
571 | /* Shutdown the old discipline. */ | ||
572 | tty_ldisc_close(tty, old_ldisc); | ||
573 | |||
574 | /* Now set up the new line discipline. */ | ||
575 | tty->ldisc = new_ldisc; | ||
576 | tty_set_termios_ldisc(tty, disc); | ||
577 | |||
578 | retval = tty_ldisc_open(tty, new_ldisc); | ||
531 | if (retval < 0) { | 579 | if (retval < 0) { |
532 | /* Back to the old one or N_TTY if we can't */ | 580 | /* Back to the old one or N_TTY if we can't */ |
533 | if (tty_ldisc_reinit(tty, old_disc) < 0) { | 581 | tty_ldisc_put(new_ldisc); |
534 | pr_err("tty: TIOCSETD failed, reinitializing N_TTY\n"); | 582 | tty_ldisc_restore(tty, old_ldisc); |
535 | if (tty_ldisc_reinit(tty, N_TTY) < 0) { | ||
536 | /* At this point we have tty->ldisc == NULL. */ | ||
537 | pr_err("tty: reinitializing N_TTY failed\n"); | ||
538 | } | ||
539 | } | ||
540 | } | 583 | } |
541 | 584 | ||
542 | if (tty->ldisc && tty->ldisc->ops->num != old_disc && | 585 | if (tty->ldisc->ops->num != old_ldisc->ops->num && tty->ops->set_ldisc) { |
543 | tty->ops->set_ldisc) { | ||
544 | down_read(&tty->termios_rwsem); | 586 | down_read(&tty->termios_rwsem); |
545 | tty->ops->set_ldisc(tty); | 587 | tty->ops->set_ldisc(tty); |
546 | up_read(&tty->termios_rwsem); | 588 | up_read(&tty->termios_rwsem); |
547 | } | 589 | } |
548 | 590 | ||
591 | /* At this point we hold a reference to the new ldisc and a | ||
592 | reference to the old ldisc, or we hold two references to | ||
593 | the old ldisc (if it was restored as part of error cleanup | ||
594 | above). In either case, releasing a single reference from | ||
595 | the old ldisc is correct. */ | ||
596 | new_ldisc = old_ldisc; | ||
549 | out: | 597 | out: |
550 | tty_ldisc_unlock(tty); | 598 | tty_ldisc_unlock(tty); |
551 | 599 | ||
@@ -553,6 +601,7 @@ out: | |||
553 | already running */ | 601 | already running */ |
554 | tty_buffer_restart_work(tty->port); | 602 | tty_buffer_restart_work(tty->port); |
555 | err: | 603 | err: |
604 | tty_ldisc_put(new_ldisc); /* drop the extra reference */ | ||
556 | tty_unlock(tty); | 605 | tty_unlock(tty); |
557 | return retval; | 606 | return retval; |
558 | } | 607 | } |
@@ -613,8 +662,10 @@ int tty_ldisc_reinit(struct tty_struct *tty, int disc) | |||
613 | int retval; | 662 | int retval; |
614 | 663 | ||
615 | ld = tty_ldisc_get(tty, disc); | 664 | ld = tty_ldisc_get(tty, disc); |
616 | if (IS_ERR(ld)) | 665 | if (IS_ERR(ld)) { |
666 | BUG_ON(disc == N_TTY); | ||
617 | return PTR_ERR(ld); | 667 | return PTR_ERR(ld); |
668 | } | ||
618 | 669 | ||
619 | if (tty->ldisc) { | 670 | if (tty->ldisc) { |
620 | tty_ldisc_close(tty, tty->ldisc); | 671 | tty_ldisc_close(tty, tty->ldisc); |
@@ -626,8 +677,10 @@ int tty_ldisc_reinit(struct tty_struct *tty, int disc) | |||
626 | tty_set_termios_ldisc(tty, disc); | 677 | tty_set_termios_ldisc(tty, disc); |
627 | retval = tty_ldisc_open(tty, tty->ldisc); | 678 | retval = tty_ldisc_open(tty, tty->ldisc); |
628 | if (retval) { | 679 | if (retval) { |
629 | tty_ldisc_put(tty->ldisc); | 680 | if (!WARN_ON(disc == N_TTY)) { |
630 | tty->ldisc = NULL; | 681 | tty_ldisc_put(tty->ldisc); |
682 | tty->ldisc = NULL; | ||
683 | } | ||
631 | } | 684 | } |
632 | return retval; | 685 | return retval; |
633 | } | 686 | } |
diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c index c5f0fc906136..8af8d9542663 100644 --- a/drivers/tty/vt/keyboard.c +++ b/drivers/tty/vt/keyboard.c | |||
@@ -28,7 +28,6 @@ | |||
28 | #include <linux/module.h> | 28 | #include <linux/module.h> |
29 | #include <linux/sched/signal.h> | 29 | #include <linux/sched/signal.h> |
30 | #include <linux/sched/debug.h> | 30 | #include <linux/sched/debug.h> |
31 | #include <linux/sched/debug.h> | ||
32 | #include <linux/tty.h> | 31 | #include <linux/tty.h> |
33 | #include <linux/tty_flip.h> | 32 | #include <linux/tty_flip.h> |
34 | #include <linux/mm.h> | 33 | #include <linux/mm.h> |
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index 612fab6e54fb..79bdca5cb9c7 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c | |||
@@ -520,8 +520,10 @@ static int rh_call_control (struct usb_hcd *hcd, struct urb *urb) | |||
520 | */ | 520 | */ |
521 | tbuf_size = max_t(u16, sizeof(struct usb_hub_descriptor), wLength); | 521 | tbuf_size = max_t(u16, sizeof(struct usb_hub_descriptor), wLength); |
522 | tbuf = kzalloc(tbuf_size, GFP_KERNEL); | 522 | tbuf = kzalloc(tbuf_size, GFP_KERNEL); |
523 | if (!tbuf) | 523 | if (!tbuf) { |
524 | return -ENOMEM; | 524 | status = -ENOMEM; |
525 | goto err_alloc; | ||
526 | } | ||
525 | 527 | ||
526 | bufp = tbuf; | 528 | bufp = tbuf; |
527 | 529 | ||
@@ -734,6 +736,7 @@ error: | |||
734 | } | 736 | } |
735 | 737 | ||
736 | kfree(tbuf); | 738 | kfree(tbuf); |
739 | err_alloc: | ||
737 | 740 | ||
738 | /* any errors get returned through the urb completion */ | 741 | /* any errors get returned through the urb completion */ |
739 | spin_lock_irq(&hcd_root_hub_lock); | 742 | spin_lock_irq(&hcd_root_hub_lock); |
diff --git a/drivers/usb/gadget/function/f_tcm.c b/drivers/usb/gadget/function/f_tcm.c index d2351139342f..a82e2bd5ea34 100644 --- a/drivers/usb/gadget/function/f_tcm.c +++ b/drivers/usb/gadget/function/f_tcm.c | |||
@@ -373,7 +373,7 @@ static void bot_cleanup_old_alt(struct f_uas *fu) | |||
373 | usb_ep_free_request(fu->ep_in, fu->bot_req_in); | 373 | usb_ep_free_request(fu->ep_in, fu->bot_req_in); |
374 | usb_ep_free_request(fu->ep_out, fu->bot_req_out); | 374 | usb_ep_free_request(fu->ep_out, fu->bot_req_out); |
375 | usb_ep_free_request(fu->ep_out, fu->cmd.req); | 375 | usb_ep_free_request(fu->ep_out, fu->cmd.req); |
376 | usb_ep_free_request(fu->ep_out, fu->bot_status.req); | 376 | usb_ep_free_request(fu->ep_in, fu->bot_status.req); |
377 | 377 | ||
378 | kfree(fu->cmd.buf); | 378 | kfree(fu->cmd.buf); |
379 | 379 | ||
diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c index bd02a6cd8e2c..6ed468fa7d5e 100644 --- a/drivers/usb/host/xhci-plat.c +++ b/drivers/usb/host/xhci-plat.c | |||
@@ -344,6 +344,7 @@ MODULE_DEVICE_TABLE(acpi, usb_xhci_acpi_match); | |||
344 | static struct platform_driver usb_xhci_driver = { | 344 | static struct platform_driver usb_xhci_driver = { |
345 | .probe = xhci_plat_probe, | 345 | .probe = xhci_plat_probe, |
346 | .remove = xhci_plat_remove, | 346 | .remove = xhci_plat_remove, |
347 | .shutdown = usb_hcd_platform_shutdown, | ||
347 | .driver = { | 348 | .driver = { |
348 | .name = "xhci-hcd", | 349 | .name = "xhci-hcd", |
349 | .pm = DEV_PM_OPS, | 350 | .pm = DEV_PM_OPS, |
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index d9936c771fa0..a3309aa02993 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c | |||
@@ -1989,6 +1989,9 @@ static int process_ctrl_td(struct xhci_hcd *xhci, struct xhci_td *td, | |||
1989 | case TRB_NORMAL: | 1989 | case TRB_NORMAL: |
1990 | td->urb->actual_length = requested - remaining; | 1990 | td->urb->actual_length = requested - remaining; |
1991 | goto finish_td; | 1991 | goto finish_td; |
1992 | case TRB_STATUS: | ||
1993 | td->urb->actual_length = requested; | ||
1994 | goto finish_td; | ||
1992 | default: | 1995 | default: |
1993 | xhci_warn(xhci, "WARN: unexpected TRB Type %d\n", | 1996 | xhci_warn(xhci, "WARN: unexpected TRB Type %d\n", |
1994 | trb_type); | 1997 | trb_type); |
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 50aee8b7718b..953fd8f62df0 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c | |||
@@ -1477,6 +1477,7 @@ int xhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) | |||
1477 | struct xhci_ring *ep_ring; | 1477 | struct xhci_ring *ep_ring; |
1478 | struct xhci_virt_ep *ep; | 1478 | struct xhci_virt_ep *ep; |
1479 | struct xhci_command *command; | 1479 | struct xhci_command *command; |
1480 | struct xhci_virt_device *vdev; | ||
1480 | 1481 | ||
1481 | xhci = hcd_to_xhci(hcd); | 1482 | xhci = hcd_to_xhci(hcd); |
1482 | spin_lock_irqsave(&xhci->lock, flags); | 1483 | spin_lock_irqsave(&xhci->lock, flags); |
@@ -1485,15 +1486,27 @@ int xhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) | |||
1485 | 1486 | ||
1486 | /* Make sure the URB hasn't completed or been unlinked already */ | 1487 | /* Make sure the URB hasn't completed or been unlinked already */ |
1487 | ret = usb_hcd_check_unlink_urb(hcd, urb, status); | 1488 | ret = usb_hcd_check_unlink_urb(hcd, urb, status); |
1488 | if (ret || !urb->hcpriv) | 1489 | if (ret) |
1489 | goto done; | 1490 | goto done; |
1491 | |||
1492 | /* give back URB now if we can't queue it for cancel */ | ||
1493 | vdev = xhci->devs[urb->dev->slot_id]; | ||
1494 | urb_priv = urb->hcpriv; | ||
1495 | if (!vdev || !urb_priv) | ||
1496 | goto err_giveback; | ||
1497 | |||
1498 | ep_index = xhci_get_endpoint_index(&urb->ep->desc); | ||
1499 | ep = &vdev->eps[ep_index]; | ||
1500 | ep_ring = xhci_urb_to_transfer_ring(xhci, urb); | ||
1501 | if (!ep || !ep_ring) | ||
1502 | goto err_giveback; | ||
1503 | |||
1490 | temp = readl(&xhci->op_regs->status); | 1504 | temp = readl(&xhci->op_regs->status); |
1491 | if (temp == 0xffffffff || (xhci->xhc_state & XHCI_STATE_HALTED)) { | 1505 | if (temp == 0xffffffff || (xhci->xhc_state & XHCI_STATE_HALTED)) { |
1492 | xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb, | 1506 | xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb, |
1493 | "HW died, freeing TD."); | 1507 | "HW died, freeing TD."); |
1494 | urb_priv = urb->hcpriv; | ||
1495 | for (i = urb_priv->num_tds_done; | 1508 | for (i = urb_priv->num_tds_done; |
1496 | i < urb_priv->num_tds && xhci->devs[urb->dev->slot_id]; | 1509 | i < urb_priv->num_tds; |
1497 | i++) { | 1510 | i++) { |
1498 | td = &urb_priv->td[i]; | 1511 | td = &urb_priv->td[i]; |
1499 | if (!list_empty(&td->td_list)) | 1512 | if (!list_empty(&td->td_list)) |
@@ -1501,23 +1514,9 @@ int xhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) | |||
1501 | if (!list_empty(&td->cancelled_td_list)) | 1514 | if (!list_empty(&td->cancelled_td_list)) |
1502 | list_del_init(&td->cancelled_td_list); | 1515 | list_del_init(&td->cancelled_td_list); |
1503 | } | 1516 | } |
1504 | 1517 | goto err_giveback; | |
1505 | usb_hcd_unlink_urb_from_ep(hcd, urb); | ||
1506 | spin_unlock_irqrestore(&xhci->lock, flags); | ||
1507 | usb_hcd_giveback_urb(hcd, urb, -ESHUTDOWN); | ||
1508 | xhci_urb_free_priv(urb_priv); | ||
1509 | return ret; | ||
1510 | } | 1518 | } |
1511 | 1519 | ||
1512 | ep_index = xhci_get_endpoint_index(&urb->ep->desc); | ||
1513 | ep = &xhci->devs[urb->dev->slot_id]->eps[ep_index]; | ||
1514 | ep_ring = xhci_urb_to_transfer_ring(xhci, urb); | ||
1515 | if (!ep_ring) { | ||
1516 | ret = -EINVAL; | ||
1517 | goto done; | ||
1518 | } | ||
1519 | |||
1520 | urb_priv = urb->hcpriv; | ||
1521 | i = urb_priv->num_tds_done; | 1520 | i = urb_priv->num_tds_done; |
1522 | if (i < urb_priv->num_tds) | 1521 | if (i < urb_priv->num_tds) |
1523 | xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb, | 1522 | xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb, |
@@ -1554,6 +1553,14 @@ int xhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) | |||
1554 | done: | 1553 | done: |
1555 | spin_unlock_irqrestore(&xhci->lock, flags); | 1554 | spin_unlock_irqrestore(&xhci->lock, flags); |
1556 | return ret; | 1555 | return ret; |
1556 | |||
1557 | err_giveback: | ||
1558 | if (urb_priv) | ||
1559 | xhci_urb_free_priv(urb_priv); | ||
1560 | usb_hcd_unlink_urb_from_ep(hcd, urb); | ||
1561 | spin_unlock_irqrestore(&xhci->lock, flags); | ||
1562 | usb_hcd_giveback_urb(hcd, urb, -ESHUTDOWN); | ||
1563 | return ret; | ||
1557 | } | 1564 | } |
1558 | 1565 | ||
1559 | /* Drop an endpoint from a new bandwidth configuration for this device. | 1566 | /* Drop an endpoint from a new bandwidth configuration for this device. |
diff --git a/drivers/usb/phy/phy-isp1301.c b/drivers/usb/phy/phy-isp1301.c index b3b33cf7ddf6..f333024660b4 100644 --- a/drivers/usb/phy/phy-isp1301.c +++ b/drivers/usb/phy/phy-isp1301.c | |||
@@ -136,7 +136,7 @@ static int isp1301_remove(struct i2c_client *client) | |||
136 | static struct i2c_driver isp1301_driver = { | 136 | static struct i2c_driver isp1301_driver = { |
137 | .driver = { | 137 | .driver = { |
138 | .name = DRV_NAME, | 138 | .name = DRV_NAME, |
139 | .of_match_table = of_match_ptr(isp1301_of_match), | 139 | .of_match_table = isp1301_of_match, |
140 | }, | 140 | }, |
141 | .probe = isp1301_probe, | 141 | .probe = isp1301_probe, |
142 | .remove = isp1301_remove, | 142 | .remove = isp1301_remove, |
diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c index d7efcb632f7d..002f1ce22bd0 100644 --- a/drivers/video/backlight/pwm_bl.c +++ b/drivers/video/backlight/pwm_bl.c | |||
@@ -297,14 +297,15 @@ static int pwm_backlight_probe(struct platform_device *pdev) | |||
297 | } | 297 | } |
298 | 298 | ||
299 | /* | 299 | /* |
300 | * If the GPIO is configured as input, change the direction to output | 300 | * If the GPIO is not known to be already configured as output, that |
301 | * and set the GPIO as active. | 301 | * is, if gpiod_get_direction returns either GPIOF_DIR_IN or -EINVAL, |
302 | * change the direction to output and set the GPIO as active. | ||
302 | * Do not force the GPIO to active when it was already output as it | 303 | * Do not force the GPIO to active when it was already output as it |
303 | * could cause backlight flickering or we would enable the backlight too | 304 | * could cause backlight flickering or we would enable the backlight too |
304 | * early. Leave the decision of the initial backlight state for later. | 305 | * early. Leave the decision of the initial backlight state for later. |
305 | */ | 306 | */ |
306 | if (pb->enable_gpio && | 307 | if (pb->enable_gpio && |
307 | gpiod_get_direction(pb->enable_gpio) == GPIOF_DIR_IN) | 308 | gpiod_get_direction(pb->enable_gpio) != GPIOF_DIR_OUT) |
308 | gpiod_direction_output(pb->enable_gpio, 1); | 309 | gpiod_direction_output(pb->enable_gpio, 1); |
309 | 310 | ||
310 | pb->power_supply = devm_regulator_get(&pdev->dev, "power"); | 311 | pb->power_supply = devm_regulator_get(&pdev->dev, "power"); |
diff --git a/drivers/video/fbdev/efifb.c b/drivers/video/fbdev/efifb.c index 8c4dc1e1f94f..b827a8113e26 100644 --- a/drivers/video/fbdev/efifb.c +++ b/drivers/video/fbdev/efifb.c | |||
@@ -10,6 +10,7 @@ | |||
10 | #include <linux/efi.h> | 10 | #include <linux/efi.h> |
11 | #include <linux/errno.h> | 11 | #include <linux/errno.h> |
12 | #include <linux/fb.h> | 12 | #include <linux/fb.h> |
13 | #include <linux/pci.h> | ||
13 | #include <linux/platform_device.h> | 14 | #include <linux/platform_device.h> |
14 | #include <linux/screen_info.h> | 15 | #include <linux/screen_info.h> |
15 | #include <video/vga.h> | 16 | #include <video/vga.h> |
@@ -143,6 +144,8 @@ static struct attribute *efifb_attrs[] = { | |||
143 | }; | 144 | }; |
144 | ATTRIBUTE_GROUPS(efifb); | 145 | ATTRIBUTE_GROUPS(efifb); |
145 | 146 | ||
147 | static bool pci_dev_disabled; /* FB base matches BAR of a disabled device */ | ||
148 | |||
146 | static int efifb_probe(struct platform_device *dev) | 149 | static int efifb_probe(struct platform_device *dev) |
147 | { | 150 | { |
148 | struct fb_info *info; | 151 | struct fb_info *info; |
@@ -152,7 +155,7 @@ static int efifb_probe(struct platform_device *dev) | |||
152 | unsigned int size_total; | 155 | unsigned int size_total; |
153 | char *option = NULL; | 156 | char *option = NULL; |
154 | 157 | ||
155 | if (screen_info.orig_video_isVGA != VIDEO_TYPE_EFI) | 158 | if (screen_info.orig_video_isVGA != VIDEO_TYPE_EFI || pci_dev_disabled) |
156 | return -ENODEV; | 159 | return -ENODEV; |
157 | 160 | ||
158 | if (fb_get_options("efifb", &option)) | 161 | if (fb_get_options("efifb", &option)) |
@@ -360,3 +363,64 @@ static struct platform_driver efifb_driver = { | |||
360 | }; | 363 | }; |
361 | 364 | ||
362 | builtin_platform_driver(efifb_driver); | 365 | builtin_platform_driver(efifb_driver); |
366 | |||
367 | #if defined(CONFIG_PCI) && !defined(CONFIG_X86) | ||
368 | |||
369 | static bool pci_bar_found; /* did we find a BAR matching the efifb base? */ | ||
370 | |||
371 | static void claim_efifb_bar(struct pci_dev *dev, int idx) | ||
372 | { | ||
373 | u16 word; | ||
374 | |||
375 | pci_bar_found = true; | ||
376 | |||
377 | pci_read_config_word(dev, PCI_COMMAND, &word); | ||
378 | if (!(word & PCI_COMMAND_MEMORY)) { | ||
379 | pci_dev_disabled = true; | ||
380 | dev_err(&dev->dev, | ||
381 | "BAR %d: assigned to efifb but device is disabled!\n", | ||
382 | idx); | ||
383 | return; | ||
384 | } | ||
385 | |||
386 | if (pci_claim_resource(dev, idx)) { | ||
387 | pci_dev_disabled = true; | ||
388 | dev_err(&dev->dev, | ||
389 | "BAR %d: failed to claim resource for efifb!\n", idx); | ||
390 | return; | ||
391 | } | ||
392 | |||
393 | dev_info(&dev->dev, "BAR %d: assigned to efifb\n", idx); | ||
394 | } | ||
395 | |||
396 | static void efifb_fixup_resources(struct pci_dev *dev) | ||
397 | { | ||
398 | u64 base = screen_info.lfb_base; | ||
399 | u64 size = screen_info.lfb_size; | ||
400 | int i; | ||
401 | |||
402 | if (pci_bar_found || screen_info.orig_video_isVGA != VIDEO_TYPE_EFI) | ||
403 | return; | ||
404 | |||
405 | if (screen_info.capabilities & VIDEO_CAPABILITY_64BIT_BASE) | ||
406 | base |= (u64)screen_info.ext_lfb_base << 32; | ||
407 | |||
408 | if (!base) | ||
409 | return; | ||
410 | |||
411 | for (i = 0; i < PCI_STD_RESOURCE_END; i++) { | ||
412 | struct resource *res = &dev->resource[i]; | ||
413 | |||
414 | if (!(res->flags & IORESOURCE_MEM)) | ||
415 | continue; | ||
416 | |||
417 | if (res->start <= base && res->end >= base + size - 1) { | ||
418 | claim_efifb_bar(dev, i); | ||
419 | break; | ||
420 | } | ||
421 | } | ||
422 | } | ||
423 | DECLARE_PCI_FIXUP_CLASS_HEADER(PCI_ANY_ID, PCI_ANY_ID, PCI_BASE_CLASS_DISPLAY, | ||
424 | 16, efifb_fixup_resources); | ||
425 | |||
426 | #endif | ||
diff --git a/drivers/video/fbdev/omap/omapfb_main.c b/drivers/video/fbdev/omap/omapfb_main.c index 1abba07b84b3..f4cbfb3b8a09 100644 --- a/drivers/video/fbdev/omap/omapfb_main.c +++ b/drivers/video/fbdev/omap/omapfb_main.c | |||
@@ -1608,19 +1608,6 @@ static int omapfb_find_ctrl(struct omapfb_device *fbdev) | |||
1608 | return 0; | 1608 | return 0; |
1609 | } | 1609 | } |
1610 | 1610 | ||
1611 | static void check_required_callbacks(struct omapfb_device *fbdev) | ||
1612 | { | ||
1613 | #define _C(x) (fbdev->ctrl->x != NULL) | ||
1614 | #define _P(x) (fbdev->panel->x != NULL) | ||
1615 | BUG_ON(fbdev->ctrl == NULL || fbdev->panel == NULL); | ||
1616 | BUG_ON(!(_C(init) && _C(cleanup) && _C(get_caps) && | ||
1617 | _C(set_update_mode) && _C(setup_plane) && _C(enable_plane) && | ||
1618 | _P(init) && _P(cleanup) && _P(enable) && _P(disable) && | ||
1619 | _P(get_caps))); | ||
1620 | #undef _P | ||
1621 | #undef _C | ||
1622 | } | ||
1623 | |||
1624 | /* | 1611 | /* |
1625 | * Called by LDM binding to probe and attach a new device. | 1612 | * Called by LDM binding to probe and attach a new device. |
1626 | * Initialization sequence: | 1613 | * Initialization sequence: |
@@ -1705,8 +1692,6 @@ static int omapfb_do_probe(struct platform_device *pdev, | |||
1705 | omapfb_ops.fb_mmap = omapfb_mmap; | 1692 | omapfb_ops.fb_mmap = omapfb_mmap; |
1706 | init_state++; | 1693 | init_state++; |
1707 | 1694 | ||
1708 | check_required_callbacks(fbdev); | ||
1709 | |||
1710 | r = planes_init(fbdev); | 1695 | r = planes_init(fbdev); |
1711 | if (r) | 1696 | if (r) |
1712 | goto cleanup; | 1697 | goto cleanup; |
diff --git a/drivers/video/fbdev/ssd1307fb.c b/drivers/video/fbdev/ssd1307fb.c index bd017b57c47f..f599520374dd 100644 --- a/drivers/video/fbdev/ssd1307fb.c +++ b/drivers/video/fbdev/ssd1307fb.c | |||
@@ -578,10 +578,14 @@ static int ssd1307fb_probe(struct i2c_client *client, | |||
578 | 578 | ||
579 | par->vbat_reg = devm_regulator_get_optional(&client->dev, "vbat"); | 579 | par->vbat_reg = devm_regulator_get_optional(&client->dev, "vbat"); |
580 | if (IS_ERR(par->vbat_reg)) { | 580 | if (IS_ERR(par->vbat_reg)) { |
581 | dev_err(&client->dev, "failed to get VBAT regulator: %ld\n", | ||
582 | PTR_ERR(par->vbat_reg)); | ||
583 | ret = PTR_ERR(par->vbat_reg); | 581 | ret = PTR_ERR(par->vbat_reg); |
584 | goto fb_alloc_error; | 582 | if (ret == -ENODEV) { |
583 | par->vbat_reg = NULL; | ||
584 | } else { | ||
585 | dev_err(&client->dev, "failed to get VBAT regulator: %d\n", | ||
586 | ret); | ||
587 | goto fb_alloc_error; | ||
588 | } | ||
585 | } | 589 | } |
586 | 590 | ||
587 | if (of_property_read_u32(node, "solomon,width", &par->width)) | 591 | if (of_property_read_u32(node, "solomon,width", &par->width)) |
@@ -668,10 +672,13 @@ static int ssd1307fb_probe(struct i2c_client *client, | |||
668 | udelay(4); | 672 | udelay(4); |
669 | } | 673 | } |
670 | 674 | ||
671 | ret = regulator_enable(par->vbat_reg); | 675 | if (par->vbat_reg) { |
672 | if (ret) { | 676 | ret = regulator_enable(par->vbat_reg); |
673 | dev_err(&client->dev, "failed to enable VBAT: %d\n", ret); | 677 | if (ret) { |
674 | goto reset_oled_error; | 678 | dev_err(&client->dev, "failed to enable VBAT: %d\n", |
679 | ret); | ||
680 | goto reset_oled_error; | ||
681 | } | ||
675 | } | 682 | } |
676 | 683 | ||
677 | ret = ssd1307fb_init(par); | 684 | ret = ssd1307fb_init(par); |
@@ -710,7 +717,8 @@ panel_init_error: | |||
710 | pwm_put(par->pwm); | 717 | pwm_put(par->pwm); |
711 | }; | 718 | }; |
712 | regulator_enable_error: | 719 | regulator_enable_error: |
713 | regulator_disable(par->vbat_reg); | 720 | if (par->vbat_reg) |
721 | regulator_disable(par->vbat_reg); | ||
714 | reset_oled_error: | 722 | reset_oled_error: |
715 | fb_deferred_io_cleanup(info); | 723 | fb_deferred_io_cleanup(info); |
716 | fb_alloc_error: | 724 | fb_alloc_error: |
diff --git a/drivers/video/fbdev/xen-fbfront.c b/drivers/video/fbdev/xen-fbfront.c index d0115a7af0a9..3ee309c50b2d 100644 --- a/drivers/video/fbdev/xen-fbfront.c +++ b/drivers/video/fbdev/xen-fbfront.c | |||
@@ -643,7 +643,6 @@ static void xenfb_backend_changed(struct xenbus_device *dev, | |||
643 | break; | 643 | break; |
644 | 644 | ||
645 | case XenbusStateInitWait: | 645 | case XenbusStateInitWait: |
646 | InitWait: | ||
647 | xenbus_switch_state(dev, XenbusStateConnected); | 646 | xenbus_switch_state(dev, XenbusStateConnected); |
648 | break; | 647 | break; |
649 | 648 | ||
@@ -654,7 +653,8 @@ InitWait: | |||
654 | * get Connected twice here. | 653 | * get Connected twice here. |
655 | */ | 654 | */ |
656 | if (dev->state != XenbusStateConnected) | 655 | if (dev->state != XenbusStateConnected) |
657 | goto InitWait; /* no InitWait seen yet, fudge it */ | 656 | /* no InitWait seen yet, fudge it */ |
657 | xenbus_switch_state(dev, XenbusStateConnected); | ||
658 | 658 | ||
659 | if (xenbus_read_unsigned(info->xbdev->otherend, | 659 | if (xenbus_read_unsigned(info->xbdev->otherend, |
660 | "request-update", 0)) | 660 | "request-update", 0)) |
diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c index 400d70b69379..48230a5e12f2 100644 --- a/drivers/virtio/virtio.c +++ b/drivers/virtio/virtio.c | |||
@@ -232,6 +232,12 @@ static int virtio_dev_probe(struct device *_d) | |||
232 | if (device_features & (1ULL << i)) | 232 | if (device_features & (1ULL << i)) |
233 | __virtio_set_bit(dev, i); | 233 | __virtio_set_bit(dev, i); |
234 | 234 | ||
235 | if (drv->validate) { | ||
236 | err = drv->validate(dev); | ||
237 | if (err) | ||
238 | goto err; | ||
239 | } | ||
240 | |||
235 | err = virtio_finalize_features(dev); | 241 | err = virtio_finalize_features(dev); |
236 | if (err) | 242 | if (err) |
237 | goto err; | 243 | goto err; |
diff --git a/drivers/virtio/virtio_pci_common.c b/drivers/virtio/virtio_pci_common.c index 590534910dc6..698d5d06fa03 100644 --- a/drivers/virtio/virtio_pci_common.c +++ b/drivers/virtio/virtio_pci_common.c | |||
@@ -33,8 +33,10 @@ void vp_synchronize_vectors(struct virtio_device *vdev) | |||
33 | struct virtio_pci_device *vp_dev = to_vp_device(vdev); | 33 | struct virtio_pci_device *vp_dev = to_vp_device(vdev); |
34 | int i; | 34 | int i; |
35 | 35 | ||
36 | synchronize_irq(pci_irq_vector(vp_dev->pci_dev, 0)); | 36 | if (vp_dev->intx_enabled) |
37 | for (i = 1; i < vp_dev->msix_vectors; i++) | 37 | synchronize_irq(vp_dev->pci_dev->irq); |
38 | |||
39 | for (i = 0; i < vp_dev->msix_vectors; ++i) | ||
38 | synchronize_irq(pci_irq_vector(vp_dev->pci_dev, i)); | 40 | synchronize_irq(pci_irq_vector(vp_dev->pci_dev, i)); |
39 | } | 41 | } |
40 | 42 | ||
@@ -60,13 +62,16 @@ static irqreturn_t vp_config_changed(int irq, void *opaque) | |||
60 | static irqreturn_t vp_vring_interrupt(int irq, void *opaque) | 62 | static irqreturn_t vp_vring_interrupt(int irq, void *opaque) |
61 | { | 63 | { |
62 | struct virtio_pci_device *vp_dev = opaque; | 64 | struct virtio_pci_device *vp_dev = opaque; |
65 | struct virtio_pci_vq_info *info; | ||
63 | irqreturn_t ret = IRQ_NONE; | 66 | irqreturn_t ret = IRQ_NONE; |
64 | struct virtqueue *vq; | 67 | unsigned long flags; |
65 | 68 | ||
66 | list_for_each_entry(vq, &vp_dev->vdev.vqs, list) { | 69 | spin_lock_irqsave(&vp_dev->lock, flags); |
67 | if (vq->callback && vring_interrupt(irq, vq) == IRQ_HANDLED) | 70 | list_for_each_entry(info, &vp_dev->virtqueues, node) { |
71 | if (vring_interrupt(irq, info->vq) == IRQ_HANDLED) | ||
68 | ret = IRQ_HANDLED; | 72 | ret = IRQ_HANDLED; |
69 | } | 73 | } |
74 | spin_unlock_irqrestore(&vp_dev->lock, flags); | ||
70 | 75 | ||
71 | return ret; | 76 | return ret; |
72 | } | 77 | } |
@@ -97,186 +102,244 @@ static irqreturn_t vp_interrupt(int irq, void *opaque) | |||
97 | return vp_vring_interrupt(irq, opaque); | 102 | return vp_vring_interrupt(irq, opaque); |
98 | } | 103 | } |
99 | 104 | ||
100 | static void vp_remove_vqs(struct virtio_device *vdev) | 105 | static int vp_request_msix_vectors(struct virtio_device *vdev, int nvectors, |
106 | bool per_vq_vectors, struct irq_affinity *desc) | ||
101 | { | 107 | { |
102 | struct virtio_pci_device *vp_dev = to_vp_device(vdev); | 108 | struct virtio_pci_device *vp_dev = to_vp_device(vdev); |
103 | struct virtqueue *vq, *n; | 109 | const char *name = dev_name(&vp_dev->vdev.dev); |
110 | unsigned i, v; | ||
111 | int err = -ENOMEM; | ||
104 | 112 | ||
105 | list_for_each_entry_safe(vq, n, &vdev->vqs, list) { | 113 | vp_dev->msix_vectors = nvectors; |
106 | if (vp_dev->msix_vector_map) { | ||
107 | int v = vp_dev->msix_vector_map[vq->index]; | ||
108 | 114 | ||
109 | if (v != VIRTIO_MSI_NO_VECTOR) | 115 | vp_dev->msix_names = kmalloc(nvectors * sizeof *vp_dev->msix_names, |
110 | free_irq(pci_irq_vector(vp_dev->pci_dev, v), | 116 | GFP_KERNEL); |
111 | vq); | 117 | if (!vp_dev->msix_names) |
112 | } | 118 | goto error; |
113 | vp_dev->del_vq(vq); | 119 | vp_dev->msix_affinity_masks |
120 | = kzalloc(nvectors * sizeof *vp_dev->msix_affinity_masks, | ||
121 | GFP_KERNEL); | ||
122 | if (!vp_dev->msix_affinity_masks) | ||
123 | goto error; | ||
124 | for (i = 0; i < nvectors; ++i) | ||
125 | if (!alloc_cpumask_var(&vp_dev->msix_affinity_masks[i], | ||
126 | GFP_KERNEL)) | ||
127 | goto error; | ||
128 | |||
129 | err = pci_alloc_irq_vectors_affinity(vp_dev->pci_dev, nvectors, | ||
130 | nvectors, PCI_IRQ_MSIX | | ||
131 | (desc ? PCI_IRQ_AFFINITY : 0), | ||
132 | desc); | ||
133 | if (err < 0) | ||
134 | goto error; | ||
135 | vp_dev->msix_enabled = 1; | ||
136 | |||
137 | /* Set the vector used for configuration */ | ||
138 | v = vp_dev->msix_used_vectors; | ||
139 | snprintf(vp_dev->msix_names[v], sizeof *vp_dev->msix_names, | ||
140 | "%s-config", name); | ||
141 | err = request_irq(pci_irq_vector(vp_dev->pci_dev, v), | ||
142 | vp_config_changed, 0, vp_dev->msix_names[v], | ||
143 | vp_dev); | ||
144 | if (err) | ||
145 | goto error; | ||
146 | ++vp_dev->msix_used_vectors; | ||
147 | |||
148 | v = vp_dev->config_vector(vp_dev, v); | ||
149 | /* Verify we had enough resources to assign the vector */ | ||
150 | if (v == VIRTIO_MSI_NO_VECTOR) { | ||
151 | err = -EBUSY; | ||
152 | goto error; | ||
114 | } | 153 | } |
154 | |||
155 | if (!per_vq_vectors) { | ||
156 | /* Shared vector for all VQs */ | ||
157 | v = vp_dev->msix_used_vectors; | ||
158 | snprintf(vp_dev->msix_names[v], sizeof *vp_dev->msix_names, | ||
159 | "%s-virtqueues", name); | ||
160 | err = request_irq(pci_irq_vector(vp_dev->pci_dev, v), | ||
161 | vp_vring_interrupt, 0, vp_dev->msix_names[v], | ||
162 | vp_dev); | ||
163 | if (err) | ||
164 | goto error; | ||
165 | ++vp_dev->msix_used_vectors; | ||
166 | } | ||
167 | return 0; | ||
168 | error: | ||
169 | return err; | ||
170 | } | ||
171 | |||
172 | static struct virtqueue *vp_setup_vq(struct virtio_device *vdev, unsigned index, | ||
173 | void (*callback)(struct virtqueue *vq), | ||
174 | const char *name, | ||
175 | u16 msix_vec) | ||
176 | { | ||
177 | struct virtio_pci_device *vp_dev = to_vp_device(vdev); | ||
178 | struct virtio_pci_vq_info *info = kmalloc(sizeof *info, GFP_KERNEL); | ||
179 | struct virtqueue *vq; | ||
180 | unsigned long flags; | ||
181 | |||
182 | /* fill out our structure that represents an active queue */ | ||
183 | if (!info) | ||
184 | return ERR_PTR(-ENOMEM); | ||
185 | |||
186 | vq = vp_dev->setup_vq(vp_dev, info, index, callback, name, | ||
187 | msix_vec); | ||
188 | if (IS_ERR(vq)) | ||
189 | goto out_info; | ||
190 | |||
191 | info->vq = vq; | ||
192 | if (callback) { | ||
193 | spin_lock_irqsave(&vp_dev->lock, flags); | ||
194 | list_add(&info->node, &vp_dev->virtqueues); | ||
195 | spin_unlock_irqrestore(&vp_dev->lock, flags); | ||
196 | } else { | ||
197 | INIT_LIST_HEAD(&info->node); | ||
198 | } | ||
199 | |||
200 | vp_dev->vqs[index] = info; | ||
201 | return vq; | ||
202 | |||
203 | out_info: | ||
204 | kfree(info); | ||
205 | return vq; | ||
206 | } | ||
207 | |||
208 | static void vp_del_vq(struct virtqueue *vq) | ||
209 | { | ||
210 | struct virtio_pci_device *vp_dev = to_vp_device(vq->vdev); | ||
211 | struct virtio_pci_vq_info *info = vp_dev->vqs[vq->index]; | ||
212 | unsigned long flags; | ||
213 | |||
214 | spin_lock_irqsave(&vp_dev->lock, flags); | ||
215 | list_del(&info->node); | ||
216 | spin_unlock_irqrestore(&vp_dev->lock, flags); | ||
217 | |||
218 | vp_dev->del_vq(info); | ||
219 | kfree(info); | ||
115 | } | 220 | } |
116 | 221 | ||
117 | /* the config->del_vqs() implementation */ | 222 | /* the config->del_vqs() implementation */ |
118 | void vp_del_vqs(struct virtio_device *vdev) | 223 | void vp_del_vqs(struct virtio_device *vdev) |
119 | { | 224 | { |
120 | struct virtio_pci_device *vp_dev = to_vp_device(vdev); | 225 | struct virtio_pci_device *vp_dev = to_vp_device(vdev); |
226 | struct virtqueue *vq, *n; | ||
121 | int i; | 227 | int i; |
122 | 228 | ||
123 | if (WARN_ON_ONCE(list_empty_careful(&vdev->vqs))) | 229 | list_for_each_entry_safe(vq, n, &vdev->vqs, list) { |
124 | return; | 230 | if (vp_dev->per_vq_vectors) { |
231 | int v = vp_dev->vqs[vq->index]->msix_vector; | ||
125 | 232 | ||
126 | vp_remove_vqs(vdev); | 233 | if (v != VIRTIO_MSI_NO_VECTOR) { |
234 | int irq = pci_irq_vector(vp_dev->pci_dev, v); | ||
235 | |||
236 | irq_set_affinity_hint(irq, NULL); | ||
237 | free_irq(irq, vq); | ||
238 | } | ||
239 | } | ||
240 | vp_del_vq(vq); | ||
241 | } | ||
242 | vp_dev->per_vq_vectors = false; | ||
243 | |||
244 | if (vp_dev->intx_enabled) { | ||
245 | free_irq(vp_dev->pci_dev->irq, vp_dev); | ||
246 | vp_dev->intx_enabled = 0; | ||
247 | } | ||
127 | 248 | ||
128 | if (vp_dev->pci_dev->msix_enabled) { | 249 | for (i = 0; i < vp_dev->msix_used_vectors; ++i) |
129 | for (i = 0; i < vp_dev->msix_vectors; i++) | 250 | free_irq(pci_irq_vector(vp_dev->pci_dev, i), vp_dev); |
251 | |||
252 | for (i = 0; i < vp_dev->msix_vectors; i++) | ||
253 | if (vp_dev->msix_affinity_masks[i]) | ||
130 | free_cpumask_var(vp_dev->msix_affinity_masks[i]); | 254 | free_cpumask_var(vp_dev->msix_affinity_masks[i]); |
131 | 255 | ||
256 | if (vp_dev->msix_enabled) { | ||
132 | /* Disable the vector used for configuration */ | 257 | /* Disable the vector used for configuration */ |
133 | vp_dev->config_vector(vp_dev, VIRTIO_MSI_NO_VECTOR); | 258 | vp_dev->config_vector(vp_dev, VIRTIO_MSI_NO_VECTOR); |
134 | 259 | ||
135 | kfree(vp_dev->msix_affinity_masks); | 260 | pci_free_irq_vectors(vp_dev->pci_dev); |
136 | kfree(vp_dev->msix_names); | 261 | vp_dev->msix_enabled = 0; |
137 | kfree(vp_dev->msix_vector_map); | ||
138 | } | 262 | } |
139 | 263 | ||
140 | free_irq(pci_irq_vector(vp_dev->pci_dev, 0), vp_dev); | 264 | vp_dev->msix_vectors = 0; |
141 | pci_free_irq_vectors(vp_dev->pci_dev); | 265 | vp_dev->msix_used_vectors = 0; |
266 | kfree(vp_dev->msix_names); | ||
267 | vp_dev->msix_names = NULL; | ||
268 | kfree(vp_dev->msix_affinity_masks); | ||
269 | vp_dev->msix_affinity_masks = NULL; | ||
270 | kfree(vp_dev->vqs); | ||
271 | vp_dev->vqs = NULL; | ||
142 | } | 272 | } |
143 | 273 | ||
144 | static int vp_find_vqs_msix(struct virtio_device *vdev, unsigned nvqs, | 274 | static int vp_find_vqs_msix(struct virtio_device *vdev, unsigned nvqs, |
145 | struct virtqueue *vqs[], vq_callback_t *callbacks[], | 275 | struct virtqueue *vqs[], vq_callback_t *callbacks[], |
146 | const char * const names[], struct irq_affinity *desc) | 276 | const char * const names[], bool per_vq_vectors, |
277 | struct irq_affinity *desc) | ||
147 | { | 278 | { |
148 | struct virtio_pci_device *vp_dev = to_vp_device(vdev); | 279 | struct virtio_pci_device *vp_dev = to_vp_device(vdev); |
149 | const char *name = dev_name(&vp_dev->vdev.dev); | ||
150 | int i, j, err = -ENOMEM, allocated_vectors, nvectors; | ||
151 | unsigned flags = PCI_IRQ_MSIX; | ||
152 | bool shared = false; | ||
153 | u16 msix_vec; | 280 | u16 msix_vec; |
281 | int i, err, nvectors, allocated_vectors; | ||
154 | 282 | ||
155 | if (desc) { | 283 | vp_dev->vqs = kcalloc(nvqs, sizeof(*vp_dev->vqs), GFP_KERNEL); |
156 | flags |= PCI_IRQ_AFFINITY; | 284 | if (!vp_dev->vqs) |
157 | desc->pre_vectors++; /* virtio config vector */ | 285 | return -ENOMEM; |
158 | } | ||
159 | |||
160 | nvectors = 1; | ||
161 | for (i = 0; i < nvqs; i++) | ||
162 | if (callbacks[i]) | ||
163 | nvectors++; | ||
164 | |||
165 | /* Try one vector per queue first. */ | ||
166 | err = pci_alloc_irq_vectors_affinity(vp_dev->pci_dev, nvectors, | ||
167 | nvectors, flags, desc); | ||
168 | if (err < 0) { | ||
169 | /* Fallback to one vector for config, one shared for queues. */ | ||
170 | shared = true; | ||
171 | err = pci_alloc_irq_vectors(vp_dev->pci_dev, 2, 2, | ||
172 | PCI_IRQ_MSIX); | ||
173 | if (err < 0) | ||
174 | return err; | ||
175 | } | ||
176 | if (err < 0) | ||
177 | return err; | ||
178 | |||
179 | vp_dev->msix_vectors = nvectors; | ||
180 | vp_dev->msix_names = kmalloc_array(nvectors, | ||
181 | sizeof(*vp_dev->msix_names), GFP_KERNEL); | ||
182 | if (!vp_dev->msix_names) | ||
183 | goto out_free_irq_vectors; | ||
184 | |||
185 | vp_dev->msix_affinity_masks = kcalloc(nvectors, | ||
186 | sizeof(*vp_dev->msix_affinity_masks), GFP_KERNEL); | ||
187 | if (!vp_dev->msix_affinity_masks) | ||
188 | goto out_free_msix_names; | ||
189 | 286 | ||
190 | for (i = 0; i < nvectors; ++i) { | 287 | if (per_vq_vectors) { |
191 | if (!alloc_cpumask_var(&vp_dev->msix_affinity_masks[i], | 288 | /* Best option: one for change interrupt, one per vq. */ |
192 | GFP_KERNEL)) | 289 | nvectors = 1; |
193 | goto out_free_msix_affinity_masks; | 290 | for (i = 0; i < nvqs; ++i) |
291 | if (callbacks[i]) | ||
292 | ++nvectors; | ||
293 | } else { | ||
294 | /* Second best: one for change, shared for all vqs. */ | ||
295 | nvectors = 2; | ||
194 | } | 296 | } |
195 | 297 | ||
196 | /* Set the vector used for configuration */ | 298 | err = vp_request_msix_vectors(vdev, nvectors, per_vq_vectors, |
197 | snprintf(vp_dev->msix_names[0], sizeof(*vp_dev->msix_names), | 299 | per_vq_vectors ? desc : NULL); |
198 | "%s-config", name); | ||
199 | err = request_irq(pci_irq_vector(vp_dev->pci_dev, 0), vp_config_changed, | ||
200 | 0, vp_dev->msix_names[0], vp_dev); | ||
201 | if (err) | 300 | if (err) |
202 | goto out_free_msix_affinity_masks; | 301 | goto error_find; |
203 | 302 | ||
204 | /* Verify we had enough resources to assign the vector */ | 303 | vp_dev->per_vq_vectors = per_vq_vectors; |
205 | if (vp_dev->config_vector(vp_dev, 0) == VIRTIO_MSI_NO_VECTOR) { | 304 | allocated_vectors = vp_dev->msix_used_vectors; |
206 | err = -EBUSY; | ||
207 | goto out_free_config_irq; | ||
208 | } | ||
209 | |||
210 | vp_dev->msix_vector_map = kmalloc_array(nvqs, | ||
211 | sizeof(*vp_dev->msix_vector_map), GFP_KERNEL); | ||
212 | if (!vp_dev->msix_vector_map) | ||
213 | goto out_disable_config_irq; | ||
214 | |||
215 | allocated_vectors = j = 1; /* vector 0 is the config interrupt */ | ||
216 | for (i = 0; i < nvqs; ++i) { | 305 | for (i = 0; i < nvqs; ++i) { |
217 | if (!names[i]) { | 306 | if (!names[i]) { |
218 | vqs[i] = NULL; | 307 | vqs[i] = NULL; |
219 | continue; | 308 | continue; |
220 | } | 309 | } |
221 | 310 | ||
222 | if (callbacks[i]) | 311 | if (!callbacks[i]) |
223 | msix_vec = allocated_vectors; | ||
224 | else | ||
225 | msix_vec = VIRTIO_MSI_NO_VECTOR; | 312 | msix_vec = VIRTIO_MSI_NO_VECTOR; |
226 | 313 | else if (vp_dev->per_vq_vectors) | |
227 | vqs[i] = vp_dev->setup_vq(vp_dev, i, callbacks[i], names[i], | 314 | msix_vec = allocated_vectors++; |
228 | msix_vec); | 315 | else |
316 | msix_vec = VP_MSIX_VQ_VECTOR; | ||
317 | vqs[i] = vp_setup_vq(vdev, i, callbacks[i], names[i], | ||
318 | msix_vec); | ||
229 | if (IS_ERR(vqs[i])) { | 319 | if (IS_ERR(vqs[i])) { |
230 | err = PTR_ERR(vqs[i]); | 320 | err = PTR_ERR(vqs[i]); |
231 | goto out_remove_vqs; | 321 | goto error_find; |
232 | } | 322 | } |
233 | 323 | ||
234 | if (msix_vec == VIRTIO_MSI_NO_VECTOR) { | 324 | if (!vp_dev->per_vq_vectors || msix_vec == VIRTIO_MSI_NO_VECTOR) |
235 | vp_dev->msix_vector_map[i] = VIRTIO_MSI_NO_VECTOR; | ||
236 | continue; | 325 | continue; |
237 | } | ||
238 | 326 | ||
239 | snprintf(vp_dev->msix_names[j], | 327 | /* allocate per-vq irq if available and necessary */ |
240 | sizeof(*vp_dev->msix_names), "%s-%s", | 328 | snprintf(vp_dev->msix_names[msix_vec], |
329 | sizeof *vp_dev->msix_names, | ||
330 | "%s-%s", | ||
241 | dev_name(&vp_dev->vdev.dev), names[i]); | 331 | dev_name(&vp_dev->vdev.dev), names[i]); |
242 | err = request_irq(pci_irq_vector(vp_dev->pci_dev, msix_vec), | 332 | err = request_irq(pci_irq_vector(vp_dev->pci_dev, msix_vec), |
243 | vring_interrupt, IRQF_SHARED, | 333 | vring_interrupt, 0, |
244 | vp_dev->msix_names[j], vqs[i]); | 334 | vp_dev->msix_names[msix_vec], |
245 | if (err) { | 335 | vqs[i]); |
246 | /* don't free this irq on error */ | 336 | if (err) |
247 | vp_dev->msix_vector_map[i] = VIRTIO_MSI_NO_VECTOR; | 337 | goto error_find; |
248 | goto out_remove_vqs; | ||
249 | } | ||
250 | vp_dev->msix_vector_map[i] = msix_vec; | ||
251 | j++; | ||
252 | |||
253 | /* | ||
254 | * Use a different vector for each queue if they are available, | ||
255 | * else share the same vector for all VQs. | ||
256 | */ | ||
257 | if (!shared) | ||
258 | allocated_vectors++; | ||
259 | } | 338 | } |
260 | |||
261 | return 0; | 339 | return 0; |
262 | 340 | ||
263 | out_remove_vqs: | 341 | error_find: |
264 | vp_remove_vqs(vdev); | 342 | vp_del_vqs(vdev); |
265 | kfree(vp_dev->msix_vector_map); | ||
266 | out_disable_config_irq: | ||
267 | vp_dev->config_vector(vp_dev, VIRTIO_MSI_NO_VECTOR); | ||
268 | out_free_config_irq: | ||
269 | free_irq(pci_irq_vector(vp_dev->pci_dev, 0), vp_dev); | ||
270 | out_free_msix_affinity_masks: | ||
271 | for (i = 0; i < nvectors; i++) { | ||
272 | if (vp_dev->msix_affinity_masks[i]) | ||
273 | free_cpumask_var(vp_dev->msix_affinity_masks[i]); | ||
274 | } | ||
275 | kfree(vp_dev->msix_affinity_masks); | ||
276 | out_free_msix_names: | ||
277 | kfree(vp_dev->msix_names); | ||
278 | out_free_irq_vectors: | ||
279 | pci_free_irq_vectors(vp_dev->pci_dev); | ||
280 | return err; | 343 | return err; |
281 | } | 344 | } |
282 | 345 | ||
@@ -287,29 +350,33 @@ static int vp_find_vqs_intx(struct virtio_device *vdev, unsigned nvqs, | |||
287 | struct virtio_pci_device *vp_dev = to_vp_device(vdev); | 350 | struct virtio_pci_device *vp_dev = to_vp_device(vdev); |
288 | int i, err; | 351 | int i, err; |
289 | 352 | ||
353 | vp_dev->vqs = kcalloc(nvqs, sizeof(*vp_dev->vqs), GFP_KERNEL); | ||
354 | if (!vp_dev->vqs) | ||
355 | return -ENOMEM; | ||
356 | |||
290 | err = request_irq(vp_dev->pci_dev->irq, vp_interrupt, IRQF_SHARED, | 357 | err = request_irq(vp_dev->pci_dev->irq, vp_interrupt, IRQF_SHARED, |
291 | dev_name(&vdev->dev), vp_dev); | 358 | dev_name(&vdev->dev), vp_dev); |
292 | if (err) | 359 | if (err) |
293 | return err; | 360 | goto out_del_vqs; |
294 | 361 | ||
362 | vp_dev->intx_enabled = 1; | ||
363 | vp_dev->per_vq_vectors = false; | ||
295 | for (i = 0; i < nvqs; ++i) { | 364 | for (i = 0; i < nvqs; ++i) { |
296 | if (!names[i]) { | 365 | if (!names[i]) { |
297 | vqs[i] = NULL; | 366 | vqs[i] = NULL; |
298 | continue; | 367 | continue; |
299 | } | 368 | } |
300 | vqs[i] = vp_dev->setup_vq(vp_dev, i, callbacks[i], names[i], | 369 | vqs[i] = vp_setup_vq(vdev, i, callbacks[i], names[i], |
301 | VIRTIO_MSI_NO_VECTOR); | 370 | VIRTIO_MSI_NO_VECTOR); |
302 | if (IS_ERR(vqs[i])) { | 371 | if (IS_ERR(vqs[i])) { |
303 | err = PTR_ERR(vqs[i]); | 372 | err = PTR_ERR(vqs[i]); |
304 | goto out_remove_vqs; | 373 | goto out_del_vqs; |
305 | } | 374 | } |
306 | } | 375 | } |
307 | 376 | ||
308 | return 0; | 377 | return 0; |
309 | 378 | out_del_vqs: | |
310 | out_remove_vqs: | 379 | vp_del_vqs(vdev); |
311 | vp_remove_vqs(vdev); | ||
312 | free_irq(pci_irq_vector(vp_dev->pci_dev, 0), vp_dev); | ||
313 | return err; | 380 | return err; |
314 | } | 381 | } |
315 | 382 | ||
@@ -320,9 +387,15 @@ int vp_find_vqs(struct virtio_device *vdev, unsigned nvqs, | |||
320 | { | 387 | { |
321 | int err; | 388 | int err; |
322 | 389 | ||
323 | err = vp_find_vqs_msix(vdev, nvqs, vqs, callbacks, names, desc); | 390 | /* Try MSI-X with one vector per queue. */ |
391 | err = vp_find_vqs_msix(vdev, nvqs, vqs, callbacks, names, true, desc); | ||
324 | if (!err) | 392 | if (!err) |
325 | return 0; | 393 | return 0; |
394 | /* Fallback: MSI-X with one vector for config, one shared for queues. */ | ||
395 | err = vp_find_vqs_msix(vdev, nvqs, vqs, callbacks, names, false, desc); | ||
396 | if (!err) | ||
397 | return 0; | ||
398 | /* Finally fall back to regular interrupts. */ | ||
326 | return vp_find_vqs_intx(vdev, nvqs, vqs, callbacks, names); | 399 | return vp_find_vqs_intx(vdev, nvqs, vqs, callbacks, names); |
327 | } | 400 | } |
328 | 401 | ||
@@ -342,15 +415,16 @@ int vp_set_vq_affinity(struct virtqueue *vq, int cpu) | |||
342 | { | 415 | { |
343 | struct virtio_device *vdev = vq->vdev; | 416 | struct virtio_device *vdev = vq->vdev; |
344 | struct virtio_pci_device *vp_dev = to_vp_device(vdev); | 417 | struct virtio_pci_device *vp_dev = to_vp_device(vdev); |
418 | struct virtio_pci_vq_info *info = vp_dev->vqs[vq->index]; | ||
419 | struct cpumask *mask; | ||
420 | unsigned int irq; | ||
345 | 421 | ||
346 | if (!vq->callback) | 422 | if (!vq->callback) |
347 | return -EINVAL; | 423 | return -EINVAL; |
348 | 424 | ||
349 | if (vp_dev->pci_dev->msix_enabled) { | 425 | if (vp_dev->msix_enabled) { |
350 | int vec = vp_dev->msix_vector_map[vq->index]; | 426 | mask = vp_dev->msix_affinity_masks[info->msix_vector]; |
351 | struct cpumask *mask = vp_dev->msix_affinity_masks[vec]; | 427 | irq = pci_irq_vector(vp_dev->pci_dev, info->msix_vector); |
352 | unsigned int irq = pci_irq_vector(vp_dev->pci_dev, vec); | ||
353 | |||
354 | if (cpu == -1) | 428 | if (cpu == -1) |
355 | irq_set_affinity_hint(irq, NULL); | 429 | irq_set_affinity_hint(irq, NULL); |
356 | else { | 430 | else { |
@@ -365,12 +439,13 @@ int vp_set_vq_affinity(struct virtqueue *vq, int cpu) | |||
365 | const struct cpumask *vp_get_vq_affinity(struct virtio_device *vdev, int index) | 439 | const struct cpumask *vp_get_vq_affinity(struct virtio_device *vdev, int index) |
366 | { | 440 | { |
367 | struct virtio_pci_device *vp_dev = to_vp_device(vdev); | 441 | struct virtio_pci_device *vp_dev = to_vp_device(vdev); |
368 | unsigned int *map = vp_dev->msix_vector_map; | ||
369 | 442 | ||
370 | if (!map || map[index] == VIRTIO_MSI_NO_VECTOR) | 443 | if (!vp_dev->per_vq_vectors || |
444 | vp_dev->vqs[index]->msix_vector == VIRTIO_MSI_NO_VECTOR) | ||
371 | return NULL; | 445 | return NULL; |
372 | 446 | ||
373 | return pci_irq_get_affinity(vp_dev->pci_dev, map[index]); | 447 | return pci_irq_get_affinity(vp_dev->pci_dev, |
448 | vp_dev->vqs[index]->msix_vector); | ||
374 | } | 449 | } |
375 | 450 | ||
376 | #ifdef CONFIG_PM_SLEEP | 451 | #ifdef CONFIG_PM_SLEEP |
@@ -441,6 +516,8 @@ static int virtio_pci_probe(struct pci_dev *pci_dev, | |||
441 | vp_dev->vdev.dev.parent = &pci_dev->dev; | 516 | vp_dev->vdev.dev.parent = &pci_dev->dev; |
442 | vp_dev->vdev.dev.release = virtio_pci_release_dev; | 517 | vp_dev->vdev.dev.release = virtio_pci_release_dev; |
443 | vp_dev->pci_dev = pci_dev; | 518 | vp_dev->pci_dev = pci_dev; |
519 | INIT_LIST_HEAD(&vp_dev->virtqueues); | ||
520 | spin_lock_init(&vp_dev->lock); | ||
444 | 521 | ||
445 | /* enable the device */ | 522 | /* enable the device */ |
446 | rc = pci_enable_device(pci_dev); | 523 | rc = pci_enable_device(pci_dev); |
diff --git a/drivers/virtio/virtio_pci_common.h b/drivers/virtio/virtio_pci_common.h index ac8c9d788964..e96334aec1e0 100644 --- a/drivers/virtio/virtio_pci_common.h +++ b/drivers/virtio/virtio_pci_common.h | |||
@@ -31,6 +31,17 @@ | |||
31 | #include <linux/highmem.h> | 31 | #include <linux/highmem.h> |
32 | #include <linux/spinlock.h> | 32 | #include <linux/spinlock.h> |
33 | 33 | ||
34 | struct virtio_pci_vq_info { | ||
35 | /* the actual virtqueue */ | ||
36 | struct virtqueue *vq; | ||
37 | |||
38 | /* the list node for the virtqueues list */ | ||
39 | struct list_head node; | ||
40 | |||
41 | /* MSI-X vector (or none) */ | ||
42 | unsigned msix_vector; | ||
43 | }; | ||
44 | |||
34 | /* Our device structure */ | 45 | /* Our device structure */ |
35 | struct virtio_pci_device { | 46 | struct virtio_pci_device { |
36 | struct virtio_device vdev; | 47 | struct virtio_device vdev; |
@@ -64,25 +75,47 @@ struct virtio_pci_device { | |||
64 | /* the IO mapping for the PCI config space */ | 75 | /* the IO mapping for the PCI config space */ |
65 | void __iomem *ioaddr; | 76 | void __iomem *ioaddr; |
66 | 77 | ||
78 | /* a list of queues so we can dispatch IRQs */ | ||
79 | spinlock_t lock; | ||
80 | struct list_head virtqueues; | ||
81 | |||
82 | /* array of all queues for house-keeping */ | ||
83 | struct virtio_pci_vq_info **vqs; | ||
84 | |||
85 | /* MSI-X support */ | ||
86 | int msix_enabled; | ||
87 | int intx_enabled; | ||
67 | cpumask_var_t *msix_affinity_masks; | 88 | cpumask_var_t *msix_affinity_masks; |
68 | /* Name strings for interrupts. This size should be enough, | 89 | /* Name strings for interrupts. This size should be enough, |
69 | * and I'm too lazy to allocate each name separately. */ | 90 | * and I'm too lazy to allocate each name separately. */ |
70 | char (*msix_names)[256]; | 91 | char (*msix_names)[256]; |
71 | /* Total Number of MSI-X vectors (including per-VQ ones). */ | 92 | /* Number of available vectors */ |
72 | int msix_vectors; | 93 | unsigned msix_vectors; |
73 | /* Map of per-VQ MSI-X vectors, may be NULL */ | 94 | /* Vectors allocated, excluding per-vq vectors if any */ |
74 | unsigned *msix_vector_map; | 95 | unsigned msix_used_vectors; |
96 | |||
97 | /* Whether we have vector per vq */ | ||
98 | bool per_vq_vectors; | ||
75 | 99 | ||
76 | struct virtqueue *(*setup_vq)(struct virtio_pci_device *vp_dev, | 100 | struct virtqueue *(*setup_vq)(struct virtio_pci_device *vp_dev, |
101 | struct virtio_pci_vq_info *info, | ||
77 | unsigned idx, | 102 | unsigned idx, |
78 | void (*callback)(struct virtqueue *vq), | 103 | void (*callback)(struct virtqueue *vq), |
79 | const char *name, | 104 | const char *name, |
80 | u16 msix_vec); | 105 | u16 msix_vec); |
81 | void (*del_vq)(struct virtqueue *vq); | 106 | void (*del_vq)(struct virtio_pci_vq_info *info); |
82 | 107 | ||
83 | u16 (*config_vector)(struct virtio_pci_device *vp_dev, u16 vector); | 108 | u16 (*config_vector)(struct virtio_pci_device *vp_dev, u16 vector); |
84 | }; | 109 | }; |
85 | 110 | ||
111 | /* Constants for MSI-X */ | ||
112 | /* Use first vector for configuration changes, second and the rest for | ||
113 | * virtqueues Thus, we need at least 2 vectors for MSI. */ | ||
114 | enum { | ||
115 | VP_MSIX_CONFIG_VECTOR = 0, | ||
116 | VP_MSIX_VQ_VECTOR = 1, | ||
117 | }; | ||
118 | |||
86 | /* Convert a generic virtio device to our structure */ | 119 | /* Convert a generic virtio device to our structure */ |
87 | static struct virtio_pci_device *to_vp_device(struct virtio_device *vdev) | 120 | static struct virtio_pci_device *to_vp_device(struct virtio_device *vdev) |
88 | { | 121 | { |
diff --git a/drivers/virtio/virtio_pci_legacy.c b/drivers/virtio/virtio_pci_legacy.c index f7362c5fe18a..4bfa48fb1324 100644 --- a/drivers/virtio/virtio_pci_legacy.c +++ b/drivers/virtio/virtio_pci_legacy.c | |||
@@ -112,6 +112,7 @@ static u16 vp_config_vector(struct virtio_pci_device *vp_dev, u16 vector) | |||
112 | } | 112 | } |
113 | 113 | ||
114 | static struct virtqueue *setup_vq(struct virtio_pci_device *vp_dev, | 114 | static struct virtqueue *setup_vq(struct virtio_pci_device *vp_dev, |
115 | struct virtio_pci_vq_info *info, | ||
115 | unsigned index, | 116 | unsigned index, |
116 | void (*callback)(struct virtqueue *vq), | 117 | void (*callback)(struct virtqueue *vq), |
117 | const char *name, | 118 | const char *name, |
@@ -129,6 +130,8 @@ static struct virtqueue *setup_vq(struct virtio_pci_device *vp_dev, | |||
129 | if (!num || ioread32(vp_dev->ioaddr + VIRTIO_PCI_QUEUE_PFN)) | 130 | if (!num || ioread32(vp_dev->ioaddr + VIRTIO_PCI_QUEUE_PFN)) |
130 | return ERR_PTR(-ENOENT); | 131 | return ERR_PTR(-ENOENT); |
131 | 132 | ||
133 | info->msix_vector = msix_vec; | ||
134 | |||
132 | /* create the vring */ | 135 | /* create the vring */ |
133 | vq = vring_create_virtqueue(index, num, | 136 | vq = vring_create_virtqueue(index, num, |
134 | VIRTIO_PCI_VRING_ALIGN, &vp_dev->vdev, | 137 | VIRTIO_PCI_VRING_ALIGN, &vp_dev->vdev, |
@@ -159,13 +162,14 @@ out_deactivate: | |||
159 | return ERR_PTR(err); | 162 | return ERR_PTR(err); |
160 | } | 163 | } |
161 | 164 | ||
162 | static void del_vq(struct virtqueue *vq) | 165 | static void del_vq(struct virtio_pci_vq_info *info) |
163 | { | 166 | { |
167 | struct virtqueue *vq = info->vq; | ||
164 | struct virtio_pci_device *vp_dev = to_vp_device(vq->vdev); | 168 | struct virtio_pci_device *vp_dev = to_vp_device(vq->vdev); |
165 | 169 | ||
166 | iowrite16(vq->index, vp_dev->ioaddr + VIRTIO_PCI_QUEUE_SEL); | 170 | iowrite16(vq->index, vp_dev->ioaddr + VIRTIO_PCI_QUEUE_SEL); |
167 | 171 | ||
168 | if (vp_dev->pci_dev->msix_enabled) { | 172 | if (vp_dev->msix_enabled) { |
169 | iowrite16(VIRTIO_MSI_NO_VECTOR, | 173 | iowrite16(VIRTIO_MSI_NO_VECTOR, |
170 | vp_dev->ioaddr + VIRTIO_MSI_QUEUE_VECTOR); | 174 | vp_dev->ioaddr + VIRTIO_MSI_QUEUE_VECTOR); |
171 | /* Flush the write out to device */ | 175 | /* Flush the write out to device */ |
diff --git a/drivers/virtio/virtio_pci_modern.c b/drivers/virtio/virtio_pci_modern.c index 7bc3004b840e..8978f109d2d7 100644 --- a/drivers/virtio/virtio_pci_modern.c +++ b/drivers/virtio/virtio_pci_modern.c | |||
@@ -293,6 +293,7 @@ static u16 vp_config_vector(struct virtio_pci_device *vp_dev, u16 vector) | |||
293 | } | 293 | } |
294 | 294 | ||
295 | static struct virtqueue *setup_vq(struct virtio_pci_device *vp_dev, | 295 | static struct virtqueue *setup_vq(struct virtio_pci_device *vp_dev, |
296 | struct virtio_pci_vq_info *info, | ||
296 | unsigned index, | 297 | unsigned index, |
297 | void (*callback)(struct virtqueue *vq), | 298 | void (*callback)(struct virtqueue *vq), |
298 | const char *name, | 299 | const char *name, |
@@ -322,6 +323,8 @@ static struct virtqueue *setup_vq(struct virtio_pci_device *vp_dev, | |||
322 | /* get offset of notification word for this vq */ | 323 | /* get offset of notification word for this vq */ |
323 | off = vp_ioread16(&cfg->queue_notify_off); | 324 | off = vp_ioread16(&cfg->queue_notify_off); |
324 | 325 | ||
326 | info->msix_vector = msix_vec; | ||
327 | |||
325 | /* create the vring */ | 328 | /* create the vring */ |
326 | vq = vring_create_virtqueue(index, num, | 329 | vq = vring_create_virtqueue(index, num, |
327 | SMP_CACHE_BYTES, &vp_dev->vdev, | 330 | SMP_CACHE_BYTES, &vp_dev->vdev, |
@@ -405,13 +408,14 @@ static int vp_modern_find_vqs(struct virtio_device *vdev, unsigned nvqs, | |||
405 | return 0; | 408 | return 0; |
406 | } | 409 | } |
407 | 410 | ||
408 | static void del_vq(struct virtqueue *vq) | 411 | static void del_vq(struct virtio_pci_vq_info *info) |
409 | { | 412 | { |
413 | struct virtqueue *vq = info->vq; | ||
410 | struct virtio_pci_device *vp_dev = to_vp_device(vq->vdev); | 414 | struct virtio_pci_device *vp_dev = to_vp_device(vq->vdev); |
411 | 415 | ||
412 | vp_iowrite16(vq->index, &vp_dev->common->queue_select); | 416 | vp_iowrite16(vq->index, &vp_dev->common->queue_select); |
413 | 417 | ||
414 | if (vp_dev->pci_dev->msix_enabled) { | 418 | if (vp_dev->msix_enabled) { |
415 | vp_iowrite16(VIRTIO_MSI_NO_VECTOR, | 419 | vp_iowrite16(VIRTIO_MSI_NO_VECTOR, |
416 | &vp_dev->common->queue_msix_vector); | 420 | &vp_dev->common->queue_msix_vector); |
417 | /* Flush the write out to device */ | 421 | /* Flush the write out to device */ |
diff --git a/drivers/xen/xenbus/xenbus_dev_frontend.c b/drivers/xen/xenbus/xenbus_dev_frontend.c index 1f4733b80c87..f3b089b7c0b6 100644 --- a/drivers/xen/xenbus/xenbus_dev_frontend.c +++ b/drivers/xen/xenbus/xenbus_dev_frontend.c | |||
@@ -442,8 +442,10 @@ static int xenbus_write_transaction(unsigned msg_type, | |||
442 | return xenbus_command_reply(u, XS_ERROR, "ENOENT"); | 442 | return xenbus_command_reply(u, XS_ERROR, "ENOENT"); |
443 | 443 | ||
444 | rc = xenbus_dev_request_and_reply(&u->u.msg, u); | 444 | rc = xenbus_dev_request_and_reply(&u->u.msg, u); |
445 | if (rc) | 445 | if (rc && trans) { |
446 | list_del(&trans->list); | ||
446 | kfree(trans); | 447 | kfree(trans); |
448 | } | ||
447 | 449 | ||
448 | out: | 450 | out: |
449 | return rc; | 451 | return rc; |
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index f6019ce20035..3e21211e99c3 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h | |||
@@ -1258,7 +1258,7 @@ struct btrfs_root { | |||
1258 | atomic_t will_be_snapshoted; | 1258 | atomic_t will_be_snapshoted; |
1259 | 1259 | ||
1260 | /* For qgroup metadata space reserve */ | 1260 | /* For qgroup metadata space reserve */ |
1261 | atomic_t qgroup_meta_rsv; | 1261 | atomic64_t qgroup_meta_rsv; |
1262 | }; | 1262 | }; |
1263 | static inline u32 btrfs_inode_sectorsize(const struct inode *inode) | 1263 | static inline u32 btrfs_inode_sectorsize(const struct inode *inode) |
1264 | { | 1264 | { |
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index a7d8c342f604..061c1d1f774f 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c | |||
@@ -1342,7 +1342,7 @@ static void __setup_root(struct btrfs_root *root, struct btrfs_fs_info *fs_info, | |||
1342 | atomic_set(&root->orphan_inodes, 0); | 1342 | atomic_set(&root->orphan_inodes, 0); |
1343 | atomic_set(&root->refs, 1); | 1343 | atomic_set(&root->refs, 1); |
1344 | atomic_set(&root->will_be_snapshoted, 0); | 1344 | atomic_set(&root->will_be_snapshoted, 0); |
1345 | atomic_set(&root->qgroup_meta_rsv, 0); | 1345 | atomic64_set(&root->qgroup_meta_rsv, 0); |
1346 | root->log_transid = 0; | 1346 | root->log_transid = 0; |
1347 | root->log_transid_committed = -1; | 1347 | root->log_transid_committed = -1; |
1348 | root->last_log_commit = 0; | 1348 | root->last_log_commit = 0; |
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 8df797432740..27fdb250b446 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c | |||
@@ -2584,26 +2584,36 @@ static void end_bio_extent_readpage(struct bio *bio) | |||
2584 | 2584 | ||
2585 | if (tree->ops) { | 2585 | if (tree->ops) { |
2586 | ret = tree->ops->readpage_io_failed_hook(page, mirror); | 2586 | ret = tree->ops->readpage_io_failed_hook(page, mirror); |
2587 | if (!ret && !bio->bi_error) | 2587 | if (ret == -EAGAIN) { |
2588 | uptodate = 1; | 2588 | /* |
2589 | } else { | 2589 | * Data inode's readpage_io_failed_hook() always |
2590 | * returns -EAGAIN. | ||
2591 | * | ||
2592 | * The generic bio_readpage_error handles errors | ||
2593 | * the following way: If possible, new read | ||
2594 | * requests are created and submitted and will | ||
2595 | * end up in end_bio_extent_readpage as well (if | ||
2596 | * we're lucky, not in the !uptodate case). In | ||
2597 | * that case it returns 0 and we just go on with | ||
2598 | * the next page in our bio. If it can't handle | ||
2599 | * the error it will return -EIO and we remain | ||
2600 | * responsible for that page. | ||
2601 | */ | ||
2602 | ret = bio_readpage_error(bio, offset, page, | ||
2603 | start, end, mirror); | ||
2604 | if (ret == 0) { | ||
2605 | uptodate = !bio->bi_error; | ||
2606 | offset += len; | ||
2607 | continue; | ||
2608 | } | ||
2609 | } | ||
2610 | |||
2590 | /* | 2611 | /* |
2591 | * The generic bio_readpage_error handles errors the | 2612 | * metadata's readpage_io_failed_hook() always returns |
2592 | * following way: If possible, new read requests are | 2613 | * -EIO and fixes nothing. -EIO is also returned if |
2593 | * created and submitted and will end up in | 2614 | * data inode error could not be fixed. |
2594 | * end_bio_extent_readpage as well (if we're lucky, not | ||
2595 | * in the !uptodate case). In that case it returns 0 and | ||
2596 | * we just go on with the next page in our bio. If it | ||
2597 | * can't handle the error it will return -EIO and we | ||
2598 | * remain responsible for that page. | ||
2599 | */ | 2615 | */ |
2600 | ret = bio_readpage_error(bio, offset, page, start, end, | 2616 | ASSERT(ret == -EIO); |
2601 | mirror); | ||
2602 | if (ret == 0) { | ||
2603 | uptodate = !bio->bi_error; | ||
2604 | offset += len; | ||
2605 | continue; | ||
2606 | } | ||
2607 | } | 2617 | } |
2608 | readpage_ok: | 2618 | readpage_ok: |
2609 | if (likely(uptodate)) { | 2619 | if (likely(uptodate)) { |
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 231503935652..5e71f1ea3391 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -7910,7 +7910,6 @@ struct btrfs_retry_complete { | |||
7910 | static void btrfs_retry_endio_nocsum(struct bio *bio) | 7910 | static void btrfs_retry_endio_nocsum(struct bio *bio) |
7911 | { | 7911 | { |
7912 | struct btrfs_retry_complete *done = bio->bi_private; | 7912 | struct btrfs_retry_complete *done = bio->bi_private; |
7913 | struct inode *inode; | ||
7914 | struct bio_vec *bvec; | 7913 | struct bio_vec *bvec; |
7915 | int i; | 7914 | int i; |
7916 | 7915 | ||
@@ -7918,12 +7917,12 @@ static void btrfs_retry_endio_nocsum(struct bio *bio) | |||
7918 | goto end; | 7917 | goto end; |
7919 | 7918 | ||
7920 | ASSERT(bio->bi_vcnt == 1); | 7919 | ASSERT(bio->bi_vcnt == 1); |
7921 | inode = bio->bi_io_vec->bv_page->mapping->host; | 7920 | ASSERT(bio->bi_io_vec->bv_len == btrfs_inode_sectorsize(done->inode)); |
7922 | ASSERT(bio->bi_io_vec->bv_len == btrfs_inode_sectorsize(inode)); | ||
7923 | 7921 | ||
7924 | done->uptodate = 1; | 7922 | done->uptodate = 1; |
7925 | bio_for_each_segment_all(bvec, bio, i) | 7923 | bio_for_each_segment_all(bvec, bio, i) |
7926 | clean_io_failure(BTRFS_I(done->inode), done->start, bvec->bv_page, 0); | 7924 | clean_io_failure(BTRFS_I(done->inode), done->start, |
7925 | bvec->bv_page, 0); | ||
7927 | end: | 7926 | end: |
7928 | complete(&done->done); | 7927 | complete(&done->done); |
7929 | bio_put(bio); | 7928 | bio_put(bio); |
@@ -7973,8 +7972,10 @@ next_block_or_try_again: | |||
7973 | 7972 | ||
7974 | start += sectorsize; | 7973 | start += sectorsize; |
7975 | 7974 | ||
7976 | if (nr_sectors--) { | 7975 | nr_sectors--; |
7976 | if (nr_sectors) { | ||
7977 | pgoff += sectorsize; | 7977 | pgoff += sectorsize; |
7978 | ASSERT(pgoff < PAGE_SIZE); | ||
7978 | goto next_block_or_try_again; | 7979 | goto next_block_or_try_again; |
7979 | } | 7980 | } |
7980 | } | 7981 | } |
@@ -7986,9 +7987,7 @@ static void btrfs_retry_endio(struct bio *bio) | |||
7986 | { | 7987 | { |
7987 | struct btrfs_retry_complete *done = bio->bi_private; | 7988 | struct btrfs_retry_complete *done = bio->bi_private; |
7988 | struct btrfs_io_bio *io_bio = btrfs_io_bio(bio); | 7989 | struct btrfs_io_bio *io_bio = btrfs_io_bio(bio); |
7989 | struct inode *inode; | ||
7990 | struct bio_vec *bvec; | 7990 | struct bio_vec *bvec; |
7991 | u64 start; | ||
7992 | int uptodate; | 7991 | int uptodate; |
7993 | int ret; | 7992 | int ret; |
7994 | int i; | 7993 | int i; |
@@ -7998,11 +7997,8 @@ static void btrfs_retry_endio(struct bio *bio) | |||
7998 | 7997 | ||
7999 | uptodate = 1; | 7998 | uptodate = 1; |
8000 | 7999 | ||
8001 | start = done->start; | ||
8002 | |||
8003 | ASSERT(bio->bi_vcnt == 1); | 8000 | ASSERT(bio->bi_vcnt == 1); |
8004 | inode = bio->bi_io_vec->bv_page->mapping->host; | 8001 | ASSERT(bio->bi_io_vec->bv_len == btrfs_inode_sectorsize(done->inode)); |
8005 | ASSERT(bio->bi_io_vec->bv_len == btrfs_inode_sectorsize(inode)); | ||
8006 | 8002 | ||
8007 | bio_for_each_segment_all(bvec, bio, i) { | 8003 | bio_for_each_segment_all(bvec, bio, i) { |
8008 | ret = __readpage_endio_check(done->inode, io_bio, i, | 8004 | ret = __readpage_endio_check(done->inode, io_bio, i, |
@@ -8080,8 +8076,10 @@ next: | |||
8080 | 8076 | ||
8081 | ASSERT(nr_sectors); | 8077 | ASSERT(nr_sectors); |
8082 | 8078 | ||
8083 | if (--nr_sectors) { | 8079 | nr_sectors--; |
8080 | if (nr_sectors) { | ||
8084 | pgoff += sectorsize; | 8081 | pgoff += sectorsize; |
8082 | ASSERT(pgoff < PAGE_SIZE); | ||
8085 | goto next_block; | 8083 | goto next_block; |
8086 | } | 8084 | } |
8087 | } | 8085 | } |
@@ -10523,9 +10521,9 @@ out_inode: | |||
10523 | } | 10521 | } |
10524 | 10522 | ||
10525 | __attribute__((const)) | 10523 | __attribute__((const)) |
10526 | static int dummy_readpage_io_failed_hook(struct page *page, int failed_mirror) | 10524 | static int btrfs_readpage_io_failed_hook(struct page *page, int failed_mirror) |
10527 | { | 10525 | { |
10528 | return 0; | 10526 | return -EAGAIN; |
10529 | } | 10527 | } |
10530 | 10528 | ||
10531 | static const struct inode_operations btrfs_dir_inode_operations = { | 10529 | static const struct inode_operations btrfs_dir_inode_operations = { |
@@ -10570,7 +10568,7 @@ static const struct extent_io_ops btrfs_extent_io_ops = { | |||
10570 | .submit_bio_hook = btrfs_submit_bio_hook, | 10568 | .submit_bio_hook = btrfs_submit_bio_hook, |
10571 | .readpage_end_io_hook = btrfs_readpage_end_io_hook, | 10569 | .readpage_end_io_hook = btrfs_readpage_end_io_hook, |
10572 | .merge_bio_hook = btrfs_merge_bio_hook, | 10570 | .merge_bio_hook = btrfs_merge_bio_hook, |
10573 | .readpage_io_failed_hook = dummy_readpage_io_failed_hook, | 10571 | .readpage_io_failed_hook = btrfs_readpage_io_failed_hook, |
10574 | 10572 | ||
10575 | /* optional callbacks */ | 10573 | /* optional callbacks */ |
10576 | .fill_delalloc = run_delalloc_range, | 10574 | .fill_delalloc = run_delalloc_range, |
diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c index a5da750c1087..a59801dc2a34 100644 --- a/fs/btrfs/qgroup.c +++ b/fs/btrfs/qgroup.c | |||
@@ -2948,20 +2948,20 @@ int btrfs_qgroup_reserve_meta(struct btrfs_root *root, int num_bytes, | |||
2948 | ret = qgroup_reserve(root, num_bytes, enforce); | 2948 | ret = qgroup_reserve(root, num_bytes, enforce); |
2949 | if (ret < 0) | 2949 | if (ret < 0) |
2950 | return ret; | 2950 | return ret; |
2951 | atomic_add(num_bytes, &root->qgroup_meta_rsv); | 2951 | atomic64_add(num_bytes, &root->qgroup_meta_rsv); |
2952 | return ret; | 2952 | return ret; |
2953 | } | 2953 | } |
2954 | 2954 | ||
2955 | void btrfs_qgroup_free_meta_all(struct btrfs_root *root) | 2955 | void btrfs_qgroup_free_meta_all(struct btrfs_root *root) |
2956 | { | 2956 | { |
2957 | struct btrfs_fs_info *fs_info = root->fs_info; | 2957 | struct btrfs_fs_info *fs_info = root->fs_info; |
2958 | int reserved; | 2958 | u64 reserved; |
2959 | 2959 | ||
2960 | if (!test_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags) || | 2960 | if (!test_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags) || |
2961 | !is_fstree(root->objectid)) | 2961 | !is_fstree(root->objectid)) |
2962 | return; | 2962 | return; |
2963 | 2963 | ||
2964 | reserved = atomic_xchg(&root->qgroup_meta_rsv, 0); | 2964 | reserved = atomic64_xchg(&root->qgroup_meta_rsv, 0); |
2965 | if (reserved == 0) | 2965 | if (reserved == 0) |
2966 | return; | 2966 | return; |
2967 | btrfs_qgroup_free_refroot(fs_info, root->objectid, reserved); | 2967 | btrfs_qgroup_free_refroot(fs_info, root->objectid, reserved); |
@@ -2976,8 +2976,8 @@ void btrfs_qgroup_free_meta(struct btrfs_root *root, int num_bytes) | |||
2976 | return; | 2976 | return; |
2977 | 2977 | ||
2978 | BUG_ON(num_bytes != round_down(num_bytes, fs_info->nodesize)); | 2978 | BUG_ON(num_bytes != round_down(num_bytes, fs_info->nodesize)); |
2979 | WARN_ON(atomic_read(&root->qgroup_meta_rsv) < num_bytes); | 2979 | WARN_ON(atomic64_read(&root->qgroup_meta_rsv) < num_bytes); |
2980 | atomic_sub(num_bytes, &root->qgroup_meta_rsv); | 2980 | atomic64_sub(num_bytes, &root->qgroup_meta_rsv); |
2981 | btrfs_qgroup_free_refroot(fs_info, root->objectid, num_bytes); | 2981 | btrfs_qgroup_free_refroot(fs_info, root->objectid, num_bytes); |
2982 | } | 2982 | } |
2983 | 2983 | ||
diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c index 456c8901489b..a60d5bfb8a49 100644 --- a/fs/btrfs/send.c +++ b/fs/btrfs/send.c | |||
@@ -6305,8 +6305,13 @@ long btrfs_ioctl_send(struct file *mnt_file, void __user *arg_) | |||
6305 | goto out; | 6305 | goto out; |
6306 | } | 6306 | } |
6307 | 6307 | ||
6308 | /* | ||
6309 | * Check that we don't overflow at later allocations, we request | ||
6310 | * clone_sources_count + 1 items, and compare to unsigned long inside | ||
6311 | * access_ok. | ||
6312 | */ | ||
6308 | if (arg->clone_sources_count > | 6313 | if (arg->clone_sources_count > |
6309 | ULLONG_MAX / sizeof(*arg->clone_sources)) { | 6314 | ULONG_MAX / sizeof(struct clone_root) - 1) { |
6310 | ret = -EINVAL; | 6315 | ret = -EINVAL; |
6311 | goto out; | 6316 | goto out; |
6312 | } | 6317 | } |
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index e0a7503ab31e..72a053c9a7f0 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c | |||
@@ -549,16 +549,19 @@ int btrfs_parse_options(struct btrfs_fs_info *info, char *options, | |||
549 | case Opt_ssd: | 549 | case Opt_ssd: |
550 | btrfs_set_and_info(info, SSD, | 550 | btrfs_set_and_info(info, SSD, |
551 | "use ssd allocation scheme"); | 551 | "use ssd allocation scheme"); |
552 | btrfs_clear_opt(info->mount_opt, NOSSD); | ||
552 | break; | 553 | break; |
553 | case Opt_ssd_spread: | 554 | case Opt_ssd_spread: |
554 | btrfs_set_and_info(info, SSD_SPREAD, | 555 | btrfs_set_and_info(info, SSD_SPREAD, |
555 | "use spread ssd allocation scheme"); | 556 | "use spread ssd allocation scheme"); |
556 | btrfs_set_opt(info->mount_opt, SSD); | 557 | btrfs_set_opt(info->mount_opt, SSD); |
558 | btrfs_clear_opt(info->mount_opt, NOSSD); | ||
557 | break; | 559 | break; |
558 | case Opt_nossd: | 560 | case Opt_nossd: |
559 | btrfs_set_and_info(info, NOSSD, | 561 | btrfs_set_and_info(info, NOSSD, |
560 | "not using ssd allocation scheme"); | 562 | "not using ssd allocation scheme"); |
561 | btrfs_clear_opt(info->mount_opt, SSD); | 563 | btrfs_clear_opt(info->mount_opt, SSD); |
564 | btrfs_clear_opt(info->mount_opt, SSD_SPREAD); | ||
562 | break; | 565 | break; |
563 | case Opt_barrier: | 566 | case Opt_barrier: |
564 | btrfs_clear_and_info(info, NOBARRIER, | 567 | btrfs_clear_and_info(info, NOBARRIER, |
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 73d56eef5e60..ab8a66d852f9 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c | |||
@@ -6213,7 +6213,7 @@ int btrfs_map_bio(struct btrfs_fs_info *fs_info, struct bio *bio, | |||
6213 | for (dev_nr = 0; dev_nr < total_devs; dev_nr++) { | 6213 | for (dev_nr = 0; dev_nr < total_devs; dev_nr++) { |
6214 | dev = bbio->stripes[dev_nr].dev; | 6214 | dev = bbio->stripes[dev_nr].dev; |
6215 | if (!dev || !dev->bdev || | 6215 | if (!dev || !dev->bdev || |
6216 | (bio_op(bio) == REQ_OP_WRITE && !dev->writeable)) { | 6216 | (bio_op(first_bio) == REQ_OP_WRITE && !dev->writeable)) { |
6217 | bbio_error(bbio, first_bio, logical); | 6217 | bbio_error(bbio, first_bio, logical); |
6218 | continue; | 6218 | continue; |
6219 | } | 6219 | } |
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index 502eab6bdbc4..34fee9fb7e4f 100644 --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c | |||
@@ -977,6 +977,86 @@ out: | |||
977 | return rc; | 977 | return rc; |
978 | } | 978 | } |
979 | 979 | ||
980 | ssize_t cifs_file_copychunk_range(unsigned int xid, | ||
981 | struct file *src_file, loff_t off, | ||
982 | struct file *dst_file, loff_t destoff, | ||
983 | size_t len, unsigned int flags) | ||
984 | { | ||
985 | struct inode *src_inode = file_inode(src_file); | ||
986 | struct inode *target_inode = file_inode(dst_file); | ||
987 | struct cifsFileInfo *smb_file_src; | ||
988 | struct cifsFileInfo *smb_file_target; | ||
989 | struct cifs_tcon *src_tcon; | ||
990 | struct cifs_tcon *target_tcon; | ||
991 | ssize_t rc; | ||
992 | |||
993 | cifs_dbg(FYI, "copychunk range\n"); | ||
994 | |||
995 | if (src_inode == target_inode) { | ||
996 | rc = -EINVAL; | ||
997 | goto out; | ||
998 | } | ||
999 | |||
1000 | if (!src_file->private_data || !dst_file->private_data) { | ||
1001 | rc = -EBADF; | ||
1002 | cifs_dbg(VFS, "missing cifsFileInfo on copy range src file\n"); | ||
1003 | goto out; | ||
1004 | } | ||
1005 | |||
1006 | rc = -EXDEV; | ||
1007 | smb_file_target = dst_file->private_data; | ||
1008 | smb_file_src = src_file->private_data; | ||
1009 | src_tcon = tlink_tcon(smb_file_src->tlink); | ||
1010 | target_tcon = tlink_tcon(smb_file_target->tlink); | ||
1011 | |||
1012 | if (src_tcon->ses != target_tcon->ses) { | ||
1013 | cifs_dbg(VFS, "source and target of copy not on same server\n"); | ||
1014 | goto out; | ||
1015 | } | ||
1016 | |||
1017 | /* | ||
1018 | * Note: cifs case is easier than btrfs since server responsible for | ||
1019 | * checks for proper open modes and file type and if it wants | ||
1020 | * server could even support copy of range where source = target | ||
1021 | */ | ||
1022 | lock_two_nondirectories(target_inode, src_inode); | ||
1023 | |||
1024 | cifs_dbg(FYI, "about to flush pages\n"); | ||
1025 | /* should we flush first and last page first */ | ||
1026 | truncate_inode_pages(&target_inode->i_data, 0); | ||
1027 | |||
1028 | if (target_tcon->ses->server->ops->copychunk_range) | ||
1029 | rc = target_tcon->ses->server->ops->copychunk_range(xid, | ||
1030 | smb_file_src, smb_file_target, off, len, destoff); | ||
1031 | else | ||
1032 | rc = -EOPNOTSUPP; | ||
1033 | |||
1034 | /* force revalidate of size and timestamps of target file now | ||
1035 | * that target is updated on the server | ||
1036 | */ | ||
1037 | CIFS_I(target_inode)->time = 0; | ||
1038 | /* although unlocking in the reverse order from locking is not | ||
1039 | * strictly necessary here it is a little cleaner to be consistent | ||
1040 | */ | ||
1041 | unlock_two_nondirectories(src_inode, target_inode); | ||
1042 | |||
1043 | out: | ||
1044 | return rc; | ||
1045 | } | ||
1046 | |||
1047 | static ssize_t cifs_copy_file_range(struct file *src_file, loff_t off, | ||
1048 | struct file *dst_file, loff_t destoff, | ||
1049 | size_t len, unsigned int flags) | ||
1050 | { | ||
1051 | unsigned int xid = get_xid(); | ||
1052 | ssize_t rc; | ||
1053 | |||
1054 | rc = cifs_file_copychunk_range(xid, src_file, off, dst_file, destoff, | ||
1055 | len, flags); | ||
1056 | free_xid(xid); | ||
1057 | return rc; | ||
1058 | } | ||
1059 | |||
980 | const struct file_operations cifs_file_ops = { | 1060 | const struct file_operations cifs_file_ops = { |
981 | .read_iter = cifs_loose_read_iter, | 1061 | .read_iter = cifs_loose_read_iter, |
982 | .write_iter = cifs_file_write_iter, | 1062 | .write_iter = cifs_file_write_iter, |
@@ -989,6 +1069,7 @@ const struct file_operations cifs_file_ops = { | |||
989 | .splice_read = generic_file_splice_read, | 1069 | .splice_read = generic_file_splice_read, |
990 | .llseek = cifs_llseek, | 1070 | .llseek = cifs_llseek, |
991 | .unlocked_ioctl = cifs_ioctl, | 1071 | .unlocked_ioctl = cifs_ioctl, |
1072 | .copy_file_range = cifs_copy_file_range, | ||
992 | .clone_file_range = cifs_clone_file_range, | 1073 | .clone_file_range = cifs_clone_file_range, |
993 | .setlease = cifs_setlease, | 1074 | .setlease = cifs_setlease, |
994 | .fallocate = cifs_fallocate, | 1075 | .fallocate = cifs_fallocate, |
@@ -1006,6 +1087,7 @@ const struct file_operations cifs_file_strict_ops = { | |||
1006 | .splice_read = generic_file_splice_read, | 1087 | .splice_read = generic_file_splice_read, |
1007 | .llseek = cifs_llseek, | 1088 | .llseek = cifs_llseek, |
1008 | .unlocked_ioctl = cifs_ioctl, | 1089 | .unlocked_ioctl = cifs_ioctl, |
1090 | .copy_file_range = cifs_copy_file_range, | ||
1009 | .clone_file_range = cifs_clone_file_range, | 1091 | .clone_file_range = cifs_clone_file_range, |
1010 | .setlease = cifs_setlease, | 1092 | .setlease = cifs_setlease, |
1011 | .fallocate = cifs_fallocate, | 1093 | .fallocate = cifs_fallocate, |
@@ -1023,6 +1105,7 @@ const struct file_operations cifs_file_direct_ops = { | |||
1023 | .mmap = cifs_file_mmap, | 1105 | .mmap = cifs_file_mmap, |
1024 | .splice_read = generic_file_splice_read, | 1106 | .splice_read = generic_file_splice_read, |
1025 | .unlocked_ioctl = cifs_ioctl, | 1107 | .unlocked_ioctl = cifs_ioctl, |
1108 | .copy_file_range = cifs_copy_file_range, | ||
1026 | .clone_file_range = cifs_clone_file_range, | 1109 | .clone_file_range = cifs_clone_file_range, |
1027 | .llseek = cifs_llseek, | 1110 | .llseek = cifs_llseek, |
1028 | .setlease = cifs_setlease, | 1111 | .setlease = cifs_setlease, |
@@ -1040,6 +1123,7 @@ const struct file_operations cifs_file_nobrl_ops = { | |||
1040 | .splice_read = generic_file_splice_read, | 1123 | .splice_read = generic_file_splice_read, |
1041 | .llseek = cifs_llseek, | 1124 | .llseek = cifs_llseek, |
1042 | .unlocked_ioctl = cifs_ioctl, | 1125 | .unlocked_ioctl = cifs_ioctl, |
1126 | .copy_file_range = cifs_copy_file_range, | ||
1043 | .clone_file_range = cifs_clone_file_range, | 1127 | .clone_file_range = cifs_clone_file_range, |
1044 | .setlease = cifs_setlease, | 1128 | .setlease = cifs_setlease, |
1045 | .fallocate = cifs_fallocate, | 1129 | .fallocate = cifs_fallocate, |
@@ -1056,6 +1140,7 @@ const struct file_operations cifs_file_strict_nobrl_ops = { | |||
1056 | .splice_read = generic_file_splice_read, | 1140 | .splice_read = generic_file_splice_read, |
1057 | .llseek = cifs_llseek, | 1141 | .llseek = cifs_llseek, |
1058 | .unlocked_ioctl = cifs_ioctl, | 1142 | .unlocked_ioctl = cifs_ioctl, |
1143 | .copy_file_range = cifs_copy_file_range, | ||
1059 | .clone_file_range = cifs_clone_file_range, | 1144 | .clone_file_range = cifs_clone_file_range, |
1060 | .setlease = cifs_setlease, | 1145 | .setlease = cifs_setlease, |
1061 | .fallocate = cifs_fallocate, | 1146 | .fallocate = cifs_fallocate, |
@@ -1072,6 +1157,7 @@ const struct file_operations cifs_file_direct_nobrl_ops = { | |||
1072 | .mmap = cifs_file_mmap, | 1157 | .mmap = cifs_file_mmap, |
1073 | .splice_read = generic_file_splice_read, | 1158 | .splice_read = generic_file_splice_read, |
1074 | .unlocked_ioctl = cifs_ioctl, | 1159 | .unlocked_ioctl = cifs_ioctl, |
1160 | .copy_file_range = cifs_copy_file_range, | ||
1075 | .clone_file_range = cifs_clone_file_range, | 1161 | .clone_file_range = cifs_clone_file_range, |
1076 | .llseek = cifs_llseek, | 1162 | .llseek = cifs_llseek, |
1077 | .setlease = cifs_setlease, | 1163 | .setlease = cifs_setlease, |
@@ -1083,6 +1169,7 @@ const struct file_operations cifs_dir_ops = { | |||
1083 | .release = cifs_closedir, | 1169 | .release = cifs_closedir, |
1084 | .read = generic_read_dir, | 1170 | .read = generic_read_dir, |
1085 | .unlocked_ioctl = cifs_ioctl, | 1171 | .unlocked_ioctl = cifs_ioctl, |
1172 | .copy_file_range = cifs_copy_file_range, | ||
1086 | .clone_file_range = cifs_clone_file_range, | 1173 | .clone_file_range = cifs_clone_file_range, |
1087 | .llseek = generic_file_llseek, | 1174 | .llseek = generic_file_llseek, |
1088 | }; | 1175 | }; |
diff --git a/fs/cifs/cifsfs.h b/fs/cifs/cifsfs.h index da717fee3026..30bf89b1fd9a 100644 --- a/fs/cifs/cifsfs.h +++ b/fs/cifs/cifsfs.h | |||
@@ -139,6 +139,11 @@ extern ssize_t cifs_listxattr(struct dentry *, char *, size_t); | |||
139 | # define cifs_listxattr NULL | 139 | # define cifs_listxattr NULL |
140 | #endif | 140 | #endif |
141 | 141 | ||
142 | extern ssize_t cifs_file_copychunk_range(unsigned int xid, | ||
143 | struct file *src_file, loff_t off, | ||
144 | struct file *dst_file, loff_t destoff, | ||
145 | size_t len, unsigned int flags); | ||
146 | |||
142 | extern long cifs_ioctl(struct file *filep, unsigned int cmd, unsigned long arg); | 147 | extern long cifs_ioctl(struct file *filep, unsigned int cmd, unsigned long arg); |
143 | #ifdef CONFIG_CIFS_NFSD_EXPORT | 148 | #ifdef CONFIG_CIFS_NFSD_EXPORT |
144 | extern const struct export_operations cifs_export_ops; | 149 | extern const struct export_operations cifs_export_ops; |
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h index d42dd3288647..37f5a41cc50c 100644 --- a/fs/cifs/cifsglob.h +++ b/fs/cifs/cifsglob.h | |||
@@ -243,6 +243,7 @@ struct smb_version_operations { | |||
243 | /* verify the message */ | 243 | /* verify the message */ |
244 | int (*check_message)(char *, unsigned int, struct TCP_Server_Info *); | 244 | int (*check_message)(char *, unsigned int, struct TCP_Server_Info *); |
245 | bool (*is_oplock_break)(char *, struct TCP_Server_Info *); | 245 | bool (*is_oplock_break)(char *, struct TCP_Server_Info *); |
246 | int (*handle_cancelled_mid)(char *, struct TCP_Server_Info *); | ||
246 | void (*downgrade_oplock)(struct TCP_Server_Info *, | 247 | void (*downgrade_oplock)(struct TCP_Server_Info *, |
247 | struct cifsInodeInfo *, bool); | 248 | struct cifsInodeInfo *, bool); |
248 | /* process transaction2 response */ | 249 | /* process transaction2 response */ |
@@ -407,9 +408,10 @@ struct smb_version_operations { | |||
407 | char * (*create_lease_buf)(u8 *, u8); | 408 | char * (*create_lease_buf)(u8 *, u8); |
408 | /* parse lease context buffer and return oplock/epoch info */ | 409 | /* parse lease context buffer and return oplock/epoch info */ |
409 | __u8 (*parse_lease_buf)(void *, unsigned int *); | 410 | __u8 (*parse_lease_buf)(void *, unsigned int *); |
410 | int (*clone_range)(const unsigned int, struct cifsFileInfo *src_file, | 411 | ssize_t (*copychunk_range)(const unsigned int, |
411 | struct cifsFileInfo *target_file, u64 src_off, u64 len, | 412 | struct cifsFileInfo *src_file, |
412 | u64 dest_off); | 413 | struct cifsFileInfo *target_file, |
414 | u64 src_off, u64 len, u64 dest_off); | ||
413 | int (*duplicate_extents)(const unsigned int, struct cifsFileInfo *src, | 415 | int (*duplicate_extents)(const unsigned int, struct cifsFileInfo *src, |
414 | struct cifsFileInfo *target_file, u64 src_off, u64 len, | 416 | struct cifsFileInfo *target_file, u64 src_off, u64 len, |
415 | u64 dest_off); | 417 | u64 dest_off); |
@@ -946,7 +948,6 @@ struct cifs_tcon { | |||
946 | bool use_persistent:1; /* use persistent instead of durable handles */ | 948 | bool use_persistent:1; /* use persistent instead of durable handles */ |
947 | #ifdef CONFIG_CIFS_SMB2 | 949 | #ifdef CONFIG_CIFS_SMB2 |
948 | bool print:1; /* set if connection to printer share */ | 950 | bool print:1; /* set if connection to printer share */ |
949 | bool bad_network_name:1; /* set if ret status STATUS_BAD_NETWORK_NAME */ | ||
950 | __le32 capabilities; | 951 | __le32 capabilities; |
951 | __u32 share_flags; | 952 | __u32 share_flags; |
952 | __u32 maximal_access; | 953 | __u32 maximal_access; |
@@ -1343,6 +1344,7 @@ struct mid_q_entry { | |||
1343 | void *callback_data; /* general purpose pointer for callback */ | 1344 | void *callback_data; /* general purpose pointer for callback */ |
1344 | void *resp_buf; /* pointer to received SMB header */ | 1345 | void *resp_buf; /* pointer to received SMB header */ |
1345 | int mid_state; /* wish this were enum but can not pass to wait_event */ | 1346 | int mid_state; /* wish this were enum but can not pass to wait_event */ |
1347 | unsigned int mid_flags; | ||
1346 | __le16 command; /* smb command code */ | 1348 | __le16 command; /* smb command code */ |
1347 | bool large_buf:1; /* if valid response, is pointer to large buf */ | 1349 | bool large_buf:1; /* if valid response, is pointer to large buf */ |
1348 | bool multiRsp:1; /* multiple trans2 responses for one request */ | 1350 | bool multiRsp:1; /* multiple trans2 responses for one request */ |
@@ -1350,6 +1352,12 @@ struct mid_q_entry { | |||
1350 | bool decrypted:1; /* decrypted entry */ | 1352 | bool decrypted:1; /* decrypted entry */ |
1351 | }; | 1353 | }; |
1352 | 1354 | ||
1355 | struct close_cancelled_open { | ||
1356 | struct cifs_fid fid; | ||
1357 | struct cifs_tcon *tcon; | ||
1358 | struct work_struct work; | ||
1359 | }; | ||
1360 | |||
1353 | /* Make code in transport.c a little cleaner by moving | 1361 | /* Make code in transport.c a little cleaner by moving |
1354 | update of optional stats into function below */ | 1362 | update of optional stats into function below */ |
1355 | #ifdef CONFIG_CIFS_STATS2 | 1363 | #ifdef CONFIG_CIFS_STATS2 |
@@ -1481,6 +1489,9 @@ static inline void free_dfs_info_array(struct dfs_info3_param *param, | |||
1481 | #define MID_RESPONSE_MALFORMED 0x10 | 1489 | #define MID_RESPONSE_MALFORMED 0x10 |
1482 | #define MID_SHUTDOWN 0x20 | 1490 | #define MID_SHUTDOWN 0x20 |
1483 | 1491 | ||
1492 | /* Flags */ | ||
1493 | #define MID_WAIT_CANCELLED 1 /* Cancelled while waiting for response */ | ||
1494 | |||
1484 | /* Types of response buffer returned from SendReceive2 */ | 1495 | /* Types of response buffer returned from SendReceive2 */ |
1485 | #define CIFS_NO_BUFFER 0 /* Response buffer not returned */ | 1496 | #define CIFS_NO_BUFFER 0 /* Response buffer not returned */ |
1486 | #define CIFS_SMALL_BUFFER 1 | 1497 | #define CIFS_SMALL_BUFFER 1 |
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c index 066950671929..5d21f00ae341 100644 --- a/fs/cifs/cifssmb.c +++ b/fs/cifs/cifssmb.c | |||
@@ -1428,6 +1428,8 @@ cifs_readv_discard(struct TCP_Server_Info *server, struct mid_q_entry *mid) | |||
1428 | 1428 | ||
1429 | length = cifs_discard_remaining_data(server); | 1429 | length = cifs_discard_remaining_data(server); |
1430 | dequeue_mid(mid, rdata->result); | 1430 | dequeue_mid(mid, rdata->result); |
1431 | mid->resp_buf = server->smallbuf; | ||
1432 | server->smallbuf = NULL; | ||
1431 | return length; | 1433 | return length; |
1432 | } | 1434 | } |
1433 | 1435 | ||
@@ -1541,6 +1543,8 @@ cifs_readv_receive(struct TCP_Server_Info *server, struct mid_q_entry *mid) | |||
1541 | return cifs_readv_discard(server, mid); | 1543 | return cifs_readv_discard(server, mid); |
1542 | 1544 | ||
1543 | dequeue_mid(mid, false); | 1545 | dequeue_mid(mid, false); |
1546 | mid->resp_buf = server->smallbuf; | ||
1547 | server->smallbuf = NULL; | ||
1544 | return length; | 1548 | return length; |
1545 | } | 1549 | } |
1546 | 1550 | ||
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 7f50c8949401..b3c9d8c310f2 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c | |||
@@ -904,10 +904,19 @@ cifs_demultiplex_thread(void *p) | |||
904 | 904 | ||
905 | server->lstrp = jiffies; | 905 | server->lstrp = jiffies; |
906 | if (mid_entry != NULL) { | 906 | if (mid_entry != NULL) { |
907 | if ((mid_entry->mid_flags & MID_WAIT_CANCELLED) && | ||
908 | mid_entry->mid_state == MID_RESPONSE_RECEIVED && | ||
909 | server->ops->handle_cancelled_mid) | ||
910 | server->ops->handle_cancelled_mid( | ||
911 | mid_entry->resp_buf, | ||
912 | server); | ||
913 | |||
907 | if (!mid_entry->multiRsp || mid_entry->multiEnd) | 914 | if (!mid_entry->multiRsp || mid_entry->multiEnd) |
908 | mid_entry->callback(mid_entry); | 915 | mid_entry->callback(mid_entry); |
909 | } else if (!server->ops->is_oplock_break || | 916 | } else if (server->ops->is_oplock_break && |
910 | !server->ops->is_oplock_break(buf, server)) { | 917 | server->ops->is_oplock_break(buf, server)) { |
918 | cifs_dbg(FYI, "Received oplock break\n"); | ||
919 | } else { | ||
911 | cifs_dbg(VFS, "No task to wake, unknown frame received! NumMids %d\n", | 920 | cifs_dbg(VFS, "No task to wake, unknown frame received! NumMids %d\n", |
912 | atomic_read(&midCount)); | 921 | atomic_read(&midCount)); |
913 | cifs_dump_mem("Received Data is: ", buf, | 922 | cifs_dump_mem("Received Data is: ", buf, |
@@ -3739,6 +3748,9 @@ try_mount_again: | |||
3739 | if (IS_ERR(tcon)) { | 3748 | if (IS_ERR(tcon)) { |
3740 | rc = PTR_ERR(tcon); | 3749 | rc = PTR_ERR(tcon); |
3741 | tcon = NULL; | 3750 | tcon = NULL; |
3751 | if (rc == -EACCES) | ||
3752 | goto mount_fail_check; | ||
3753 | |||
3742 | goto remote_path_check; | 3754 | goto remote_path_check; |
3743 | } | 3755 | } |
3744 | 3756 | ||
diff --git a/fs/cifs/file.c b/fs/cifs/file.c index aa3debbba826..21d404535739 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c | |||
@@ -2597,7 +2597,7 @@ cifs_write_from_iter(loff_t offset, size_t len, struct iov_iter *from, | |||
2597 | wdata->credits = credits; | 2597 | wdata->credits = credits; |
2598 | 2598 | ||
2599 | if (!wdata->cfile->invalidHandle || | 2599 | if (!wdata->cfile->invalidHandle || |
2600 | !cifs_reopen_file(wdata->cfile, false)) | 2600 | !(rc = cifs_reopen_file(wdata->cfile, false))) |
2601 | rc = server->ops->async_writev(wdata, | 2601 | rc = server->ops->async_writev(wdata, |
2602 | cifs_uncached_writedata_release); | 2602 | cifs_uncached_writedata_release); |
2603 | if (rc) { | 2603 | if (rc) { |
@@ -3022,7 +3022,7 @@ cifs_send_async_read(loff_t offset, size_t len, struct cifsFileInfo *open_file, | |||
3022 | rdata->credits = credits; | 3022 | rdata->credits = credits; |
3023 | 3023 | ||
3024 | if (!rdata->cfile->invalidHandle || | 3024 | if (!rdata->cfile->invalidHandle || |
3025 | !cifs_reopen_file(rdata->cfile, true)) | 3025 | !(rc = cifs_reopen_file(rdata->cfile, true))) |
3026 | rc = server->ops->async_readv(rdata); | 3026 | rc = server->ops->async_readv(rdata); |
3027 | error: | 3027 | error: |
3028 | if (rc) { | 3028 | if (rc) { |
@@ -3617,7 +3617,7 @@ static int cifs_readpages(struct file *file, struct address_space *mapping, | |||
3617 | } | 3617 | } |
3618 | 3618 | ||
3619 | if (!rdata->cfile->invalidHandle || | 3619 | if (!rdata->cfile->invalidHandle || |
3620 | !cifs_reopen_file(rdata->cfile, true)) | 3620 | !(rc = cifs_reopen_file(rdata->cfile, true))) |
3621 | rc = server->ops->async_readv(rdata); | 3621 | rc = server->ops->async_readv(rdata); |
3622 | if (rc) { | 3622 | if (rc) { |
3623 | add_credits_and_wake_if(server, rdata->credits, 0); | 3623 | add_credits_and_wake_if(server, rdata->credits, 0); |
diff --git a/fs/cifs/ioctl.c b/fs/cifs/ioctl.c index 001528781b6b..265c45fe4ea5 100644 --- a/fs/cifs/ioctl.c +++ b/fs/cifs/ioctl.c | |||
@@ -34,71 +34,14 @@ | |||
34 | #include "cifs_ioctl.h" | 34 | #include "cifs_ioctl.h" |
35 | #include <linux/btrfs.h> | 35 | #include <linux/btrfs.h> |
36 | 36 | ||
37 | static int cifs_file_clone_range(unsigned int xid, struct file *src_file, | 37 | static long cifs_ioctl_copychunk(unsigned int xid, struct file *dst_file, |
38 | struct file *dst_file) | ||
39 | { | ||
40 | struct inode *src_inode = file_inode(src_file); | ||
41 | struct inode *target_inode = file_inode(dst_file); | ||
42 | struct cifsFileInfo *smb_file_src; | ||
43 | struct cifsFileInfo *smb_file_target; | ||
44 | struct cifs_tcon *src_tcon; | ||
45 | struct cifs_tcon *target_tcon; | ||
46 | int rc; | ||
47 | |||
48 | cifs_dbg(FYI, "ioctl clone range\n"); | ||
49 | |||
50 | if (!src_file->private_data || !dst_file->private_data) { | ||
51 | rc = -EBADF; | ||
52 | cifs_dbg(VFS, "missing cifsFileInfo on copy range src file\n"); | ||
53 | goto out; | ||
54 | } | ||
55 | |||
56 | rc = -EXDEV; | ||
57 | smb_file_target = dst_file->private_data; | ||
58 | smb_file_src = src_file->private_data; | ||
59 | src_tcon = tlink_tcon(smb_file_src->tlink); | ||
60 | target_tcon = tlink_tcon(smb_file_target->tlink); | ||
61 | |||
62 | if (src_tcon->ses != target_tcon->ses) { | ||
63 | cifs_dbg(VFS, "source and target of copy not on same server\n"); | ||
64 | goto out; | ||
65 | } | ||
66 | |||
67 | /* | ||
68 | * Note: cifs case is easier than btrfs since server responsible for | ||
69 | * checks for proper open modes and file type and if it wants | ||
70 | * server could even support copy of range where source = target | ||
71 | */ | ||
72 | lock_two_nondirectories(target_inode, src_inode); | ||
73 | |||
74 | cifs_dbg(FYI, "about to flush pages\n"); | ||
75 | /* should we flush first and last page first */ | ||
76 | truncate_inode_pages(&target_inode->i_data, 0); | ||
77 | |||
78 | if (target_tcon->ses->server->ops->clone_range) | ||
79 | rc = target_tcon->ses->server->ops->clone_range(xid, | ||
80 | smb_file_src, smb_file_target, 0, src_inode->i_size, 0); | ||
81 | else | ||
82 | rc = -EOPNOTSUPP; | ||
83 | |||
84 | /* force revalidate of size and timestamps of target file now | ||
85 | that target is updated on the server */ | ||
86 | CIFS_I(target_inode)->time = 0; | ||
87 | /* although unlocking in the reverse order from locking is not | ||
88 | strictly necessary here it is a little cleaner to be consistent */ | ||
89 | unlock_two_nondirectories(src_inode, target_inode); | ||
90 | out: | ||
91 | return rc; | ||
92 | } | ||
93 | |||
94 | static long cifs_ioctl_clone(unsigned int xid, struct file *dst_file, | ||
95 | unsigned long srcfd) | 38 | unsigned long srcfd) |
96 | { | 39 | { |
97 | int rc; | 40 | int rc; |
98 | struct fd src_file; | 41 | struct fd src_file; |
99 | struct inode *src_inode; | 42 | struct inode *src_inode; |
100 | 43 | ||
101 | cifs_dbg(FYI, "ioctl clone range\n"); | 44 | cifs_dbg(FYI, "ioctl copychunk range\n"); |
102 | /* the destination must be opened for writing */ | 45 | /* the destination must be opened for writing */ |
103 | if (!(dst_file->f_mode & FMODE_WRITE)) { | 46 | if (!(dst_file->f_mode & FMODE_WRITE)) { |
104 | cifs_dbg(FYI, "file target not open for write\n"); | 47 | cifs_dbg(FYI, "file target not open for write\n"); |
@@ -129,7 +72,8 @@ static long cifs_ioctl_clone(unsigned int xid, struct file *dst_file, | |||
129 | if (S_ISDIR(src_inode->i_mode)) | 72 | if (S_ISDIR(src_inode->i_mode)) |
130 | goto out_fput; | 73 | goto out_fput; |
131 | 74 | ||
132 | rc = cifs_file_clone_range(xid, src_file.file, dst_file); | 75 | rc = cifs_file_copychunk_range(xid, src_file.file, 0, dst_file, 0, |
76 | src_inode->i_size, 0); | ||
133 | 77 | ||
134 | out_fput: | 78 | out_fput: |
135 | fdput(src_file); | 79 | fdput(src_file); |
@@ -251,7 +195,7 @@ long cifs_ioctl(struct file *filep, unsigned int command, unsigned long arg) | |||
251 | } | 195 | } |
252 | break; | 196 | break; |
253 | case CIFS_IOC_COPYCHUNK_FILE: | 197 | case CIFS_IOC_COPYCHUNK_FILE: |
254 | rc = cifs_ioctl_clone(xid, filep, arg); | 198 | rc = cifs_ioctl_copychunk(xid, filep, arg); |
255 | break; | 199 | break; |
256 | case CIFS_IOC_SET_INTEGRITY: | 200 | case CIFS_IOC_SET_INTEGRITY: |
257 | if (pSMBFile == NULL) | 201 | if (pSMBFile == NULL) |
diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c index cc93ba4da9b5..27bc360c7ffd 100644 --- a/fs/cifs/smb1ops.c +++ b/fs/cifs/smb1ops.c | |||
@@ -1015,6 +1015,15 @@ cifs_dir_needs_close(struct cifsFileInfo *cfile) | |||
1015 | return !cfile->srch_inf.endOfSearch && !cfile->invalidHandle; | 1015 | return !cfile->srch_inf.endOfSearch && !cfile->invalidHandle; |
1016 | } | 1016 | } |
1017 | 1017 | ||
1018 | static bool | ||
1019 | cifs_can_echo(struct TCP_Server_Info *server) | ||
1020 | { | ||
1021 | if (server->tcpStatus == CifsGood) | ||
1022 | return true; | ||
1023 | |||
1024 | return false; | ||
1025 | } | ||
1026 | |||
1018 | struct smb_version_operations smb1_operations = { | 1027 | struct smb_version_operations smb1_operations = { |
1019 | .send_cancel = send_nt_cancel, | 1028 | .send_cancel = send_nt_cancel, |
1020 | .compare_fids = cifs_compare_fids, | 1029 | .compare_fids = cifs_compare_fids, |
@@ -1049,6 +1058,7 @@ struct smb_version_operations smb1_operations = { | |||
1049 | .get_dfs_refer = CIFSGetDFSRefer, | 1058 | .get_dfs_refer = CIFSGetDFSRefer, |
1050 | .qfs_tcon = cifs_qfs_tcon, | 1059 | .qfs_tcon = cifs_qfs_tcon, |
1051 | .is_path_accessible = cifs_is_path_accessible, | 1060 | .is_path_accessible = cifs_is_path_accessible, |
1061 | .can_echo = cifs_can_echo, | ||
1052 | .query_path_info = cifs_query_path_info, | 1062 | .query_path_info = cifs_query_path_info, |
1053 | .query_file_info = cifs_query_file_info, | 1063 | .query_file_info = cifs_query_file_info, |
1054 | .get_srv_inum = cifs_get_srv_inum, | 1064 | .get_srv_inum = cifs_get_srv_inum, |
diff --git a/fs/cifs/smb2misc.c b/fs/cifs/smb2misc.c index fd516ea8b8f8..1a04b3a5beb1 100644 --- a/fs/cifs/smb2misc.c +++ b/fs/cifs/smb2misc.c | |||
@@ -659,3 +659,49 @@ smb2_is_valid_oplock_break(char *buffer, struct TCP_Server_Info *server) | |||
659 | cifs_dbg(FYI, "Can not process oplock break for non-existent connection\n"); | 659 | cifs_dbg(FYI, "Can not process oplock break for non-existent connection\n"); |
660 | return false; | 660 | return false; |
661 | } | 661 | } |
662 | |||
663 | void | ||
664 | smb2_cancelled_close_fid(struct work_struct *work) | ||
665 | { | ||
666 | struct close_cancelled_open *cancelled = container_of(work, | ||
667 | struct close_cancelled_open, work); | ||
668 | |||
669 | cifs_dbg(VFS, "Close unmatched open\n"); | ||
670 | |||
671 | SMB2_close(0, cancelled->tcon, cancelled->fid.persistent_fid, | ||
672 | cancelled->fid.volatile_fid); | ||
673 | cifs_put_tcon(cancelled->tcon); | ||
674 | kfree(cancelled); | ||
675 | } | ||
676 | |||
677 | int | ||
678 | smb2_handle_cancelled_mid(char *buffer, struct TCP_Server_Info *server) | ||
679 | { | ||
680 | struct smb2_sync_hdr *sync_hdr = get_sync_hdr(buffer); | ||
681 | struct smb2_create_rsp *rsp = (struct smb2_create_rsp *)buffer; | ||
682 | struct cifs_tcon *tcon; | ||
683 | struct close_cancelled_open *cancelled; | ||
684 | |||
685 | if (sync_hdr->Command != SMB2_CREATE || | ||
686 | sync_hdr->Status != STATUS_SUCCESS) | ||
687 | return 0; | ||
688 | |||
689 | cancelled = kzalloc(sizeof(*cancelled), GFP_KERNEL); | ||
690 | if (!cancelled) | ||
691 | return -ENOMEM; | ||
692 | |||
693 | tcon = smb2_find_smb_tcon(server, sync_hdr->SessionId, | ||
694 | sync_hdr->TreeId); | ||
695 | if (!tcon) { | ||
696 | kfree(cancelled); | ||
697 | return -ENOENT; | ||
698 | } | ||
699 | |||
700 | cancelled->fid.persistent_fid = rsp->PersistentFileId; | ||
701 | cancelled->fid.volatile_fid = rsp->VolatileFileId; | ||
702 | cancelled->tcon = tcon; | ||
703 | INIT_WORK(&cancelled->work, smb2_cancelled_close_fid); | ||
704 | queue_work(cifsiod_wq, &cancelled->work); | ||
705 | |||
706 | return 0; | ||
707 | } | ||
diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c index 0231108d9387..152e37f2ad92 100644 --- a/fs/cifs/smb2ops.c +++ b/fs/cifs/smb2ops.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #include <linux/vfs.h> | 21 | #include <linux/vfs.h> |
22 | #include <linux/falloc.h> | 22 | #include <linux/falloc.h> |
23 | #include <linux/scatterlist.h> | 23 | #include <linux/scatterlist.h> |
24 | #include <linux/uuid.h> | ||
24 | #include <crypto/aead.h> | 25 | #include <crypto/aead.h> |
25 | #include "cifsglob.h" | 26 | #include "cifsglob.h" |
26 | #include "smb2pdu.h" | 27 | #include "smb2pdu.h" |
@@ -592,8 +593,8 @@ req_res_key_exit: | |||
592 | return rc; | 593 | return rc; |
593 | } | 594 | } |
594 | 595 | ||
595 | static int | 596 | static ssize_t |
596 | smb2_clone_range(const unsigned int xid, | 597 | smb2_copychunk_range(const unsigned int xid, |
597 | struct cifsFileInfo *srcfile, | 598 | struct cifsFileInfo *srcfile, |
598 | struct cifsFileInfo *trgtfile, u64 src_off, | 599 | struct cifsFileInfo *trgtfile, u64 src_off, |
599 | u64 len, u64 dest_off) | 600 | u64 len, u64 dest_off) |
@@ -605,13 +606,14 @@ smb2_clone_range(const unsigned int xid, | |||
605 | struct cifs_tcon *tcon; | 606 | struct cifs_tcon *tcon; |
606 | int chunks_copied = 0; | 607 | int chunks_copied = 0; |
607 | bool chunk_sizes_updated = false; | 608 | bool chunk_sizes_updated = false; |
609 | ssize_t bytes_written, total_bytes_written = 0; | ||
608 | 610 | ||
609 | pcchunk = kmalloc(sizeof(struct copychunk_ioctl), GFP_KERNEL); | 611 | pcchunk = kmalloc(sizeof(struct copychunk_ioctl), GFP_KERNEL); |
610 | 612 | ||
611 | if (pcchunk == NULL) | 613 | if (pcchunk == NULL) |
612 | return -ENOMEM; | 614 | return -ENOMEM; |
613 | 615 | ||
614 | cifs_dbg(FYI, "in smb2_clone_range - about to call request res key\n"); | 616 | cifs_dbg(FYI, "in smb2_copychunk_range - about to call request res key\n"); |
615 | /* Request a key from the server to identify the source of the copy */ | 617 | /* Request a key from the server to identify the source of the copy */ |
616 | rc = SMB2_request_res_key(xid, tlink_tcon(srcfile->tlink), | 618 | rc = SMB2_request_res_key(xid, tlink_tcon(srcfile->tlink), |
617 | srcfile->fid.persistent_fid, | 619 | srcfile->fid.persistent_fid, |
@@ -669,14 +671,16 @@ smb2_clone_range(const unsigned int xid, | |||
669 | } | 671 | } |
670 | chunks_copied++; | 672 | chunks_copied++; |
671 | 673 | ||
672 | src_off += le32_to_cpu(retbuf->TotalBytesWritten); | 674 | bytes_written = le32_to_cpu(retbuf->TotalBytesWritten); |
673 | dest_off += le32_to_cpu(retbuf->TotalBytesWritten); | 675 | src_off += bytes_written; |
674 | len -= le32_to_cpu(retbuf->TotalBytesWritten); | 676 | dest_off += bytes_written; |
677 | len -= bytes_written; | ||
678 | total_bytes_written += bytes_written; | ||
675 | 679 | ||
676 | cifs_dbg(FYI, "Chunks %d PartialChunk %d Total %d\n", | 680 | cifs_dbg(FYI, "Chunks %d PartialChunk %d Total %zu\n", |
677 | le32_to_cpu(retbuf->ChunksWritten), | 681 | le32_to_cpu(retbuf->ChunksWritten), |
678 | le32_to_cpu(retbuf->ChunkBytesWritten), | 682 | le32_to_cpu(retbuf->ChunkBytesWritten), |
679 | le32_to_cpu(retbuf->TotalBytesWritten)); | 683 | bytes_written); |
680 | } else if (rc == -EINVAL) { | 684 | } else if (rc == -EINVAL) { |
681 | if (ret_data_len != sizeof(struct copychunk_ioctl_rsp)) | 685 | if (ret_data_len != sizeof(struct copychunk_ioctl_rsp)) |
682 | goto cchunk_out; | 686 | goto cchunk_out; |
@@ -713,7 +717,10 @@ smb2_clone_range(const unsigned int xid, | |||
713 | cchunk_out: | 717 | cchunk_out: |
714 | kfree(pcchunk); | 718 | kfree(pcchunk); |
715 | kfree(retbuf); | 719 | kfree(retbuf); |
716 | return rc; | 720 | if (rc) |
721 | return rc; | ||
722 | else | ||
723 | return total_bytes_written; | ||
717 | } | 724 | } |
718 | 725 | ||
719 | static int | 726 | static int |
@@ -2322,6 +2329,7 @@ struct smb_version_operations smb20_operations = { | |||
2322 | .clear_stats = smb2_clear_stats, | 2329 | .clear_stats = smb2_clear_stats, |
2323 | .print_stats = smb2_print_stats, | 2330 | .print_stats = smb2_print_stats, |
2324 | .is_oplock_break = smb2_is_valid_oplock_break, | 2331 | .is_oplock_break = smb2_is_valid_oplock_break, |
2332 | .handle_cancelled_mid = smb2_handle_cancelled_mid, | ||
2325 | .downgrade_oplock = smb2_downgrade_oplock, | 2333 | .downgrade_oplock = smb2_downgrade_oplock, |
2326 | .need_neg = smb2_need_neg, | 2334 | .need_neg = smb2_need_neg, |
2327 | .negotiate = smb2_negotiate, | 2335 | .negotiate = smb2_negotiate, |
@@ -2377,7 +2385,7 @@ struct smb_version_operations smb20_operations = { | |||
2377 | .set_oplock_level = smb2_set_oplock_level, | 2385 | .set_oplock_level = smb2_set_oplock_level, |
2378 | .create_lease_buf = smb2_create_lease_buf, | 2386 | .create_lease_buf = smb2_create_lease_buf, |
2379 | .parse_lease_buf = smb2_parse_lease_buf, | 2387 | .parse_lease_buf = smb2_parse_lease_buf, |
2380 | .clone_range = smb2_clone_range, | 2388 | .copychunk_range = smb2_copychunk_range, |
2381 | .wp_retry_size = smb2_wp_retry_size, | 2389 | .wp_retry_size = smb2_wp_retry_size, |
2382 | .dir_needs_close = smb2_dir_needs_close, | 2390 | .dir_needs_close = smb2_dir_needs_close, |
2383 | .get_dfs_refer = smb2_get_dfs_refer, | 2391 | .get_dfs_refer = smb2_get_dfs_refer, |
@@ -2404,6 +2412,7 @@ struct smb_version_operations smb21_operations = { | |||
2404 | .clear_stats = smb2_clear_stats, | 2412 | .clear_stats = smb2_clear_stats, |
2405 | .print_stats = smb2_print_stats, | 2413 | .print_stats = smb2_print_stats, |
2406 | .is_oplock_break = smb2_is_valid_oplock_break, | 2414 | .is_oplock_break = smb2_is_valid_oplock_break, |
2415 | .handle_cancelled_mid = smb2_handle_cancelled_mid, | ||
2407 | .downgrade_oplock = smb2_downgrade_oplock, | 2416 | .downgrade_oplock = smb2_downgrade_oplock, |
2408 | .need_neg = smb2_need_neg, | 2417 | .need_neg = smb2_need_neg, |
2409 | .negotiate = smb2_negotiate, | 2418 | .negotiate = smb2_negotiate, |
@@ -2459,7 +2468,7 @@ struct smb_version_operations smb21_operations = { | |||
2459 | .set_oplock_level = smb21_set_oplock_level, | 2468 | .set_oplock_level = smb21_set_oplock_level, |
2460 | .create_lease_buf = smb2_create_lease_buf, | 2469 | .create_lease_buf = smb2_create_lease_buf, |
2461 | .parse_lease_buf = smb2_parse_lease_buf, | 2470 | .parse_lease_buf = smb2_parse_lease_buf, |
2462 | .clone_range = smb2_clone_range, | 2471 | .copychunk_range = smb2_copychunk_range, |
2463 | .wp_retry_size = smb2_wp_retry_size, | 2472 | .wp_retry_size = smb2_wp_retry_size, |
2464 | .dir_needs_close = smb2_dir_needs_close, | 2473 | .dir_needs_close = smb2_dir_needs_close, |
2465 | .enum_snapshots = smb3_enum_snapshots, | 2474 | .enum_snapshots = smb3_enum_snapshots, |
@@ -2488,6 +2497,7 @@ struct smb_version_operations smb30_operations = { | |||
2488 | .print_stats = smb2_print_stats, | 2497 | .print_stats = smb2_print_stats, |
2489 | .dump_share_caps = smb2_dump_share_caps, | 2498 | .dump_share_caps = smb2_dump_share_caps, |
2490 | .is_oplock_break = smb2_is_valid_oplock_break, | 2499 | .is_oplock_break = smb2_is_valid_oplock_break, |
2500 | .handle_cancelled_mid = smb2_handle_cancelled_mid, | ||
2491 | .downgrade_oplock = smb2_downgrade_oplock, | 2501 | .downgrade_oplock = smb2_downgrade_oplock, |
2492 | .need_neg = smb2_need_neg, | 2502 | .need_neg = smb2_need_neg, |
2493 | .negotiate = smb2_negotiate, | 2503 | .negotiate = smb2_negotiate, |
@@ -2545,7 +2555,7 @@ struct smb_version_operations smb30_operations = { | |||
2545 | .set_oplock_level = smb3_set_oplock_level, | 2555 | .set_oplock_level = smb3_set_oplock_level, |
2546 | .create_lease_buf = smb3_create_lease_buf, | 2556 | .create_lease_buf = smb3_create_lease_buf, |
2547 | .parse_lease_buf = smb3_parse_lease_buf, | 2557 | .parse_lease_buf = smb3_parse_lease_buf, |
2548 | .clone_range = smb2_clone_range, | 2558 | .copychunk_range = smb2_copychunk_range, |
2549 | .duplicate_extents = smb2_duplicate_extents, | 2559 | .duplicate_extents = smb2_duplicate_extents, |
2550 | .validate_negotiate = smb3_validate_negotiate, | 2560 | .validate_negotiate = smb3_validate_negotiate, |
2551 | .wp_retry_size = smb2_wp_retry_size, | 2561 | .wp_retry_size = smb2_wp_retry_size, |
@@ -2582,6 +2592,7 @@ struct smb_version_operations smb311_operations = { | |||
2582 | .print_stats = smb2_print_stats, | 2592 | .print_stats = smb2_print_stats, |
2583 | .dump_share_caps = smb2_dump_share_caps, | 2593 | .dump_share_caps = smb2_dump_share_caps, |
2584 | .is_oplock_break = smb2_is_valid_oplock_break, | 2594 | .is_oplock_break = smb2_is_valid_oplock_break, |
2595 | .handle_cancelled_mid = smb2_handle_cancelled_mid, | ||
2585 | .downgrade_oplock = smb2_downgrade_oplock, | 2596 | .downgrade_oplock = smb2_downgrade_oplock, |
2586 | .need_neg = smb2_need_neg, | 2597 | .need_neg = smb2_need_neg, |
2587 | .negotiate = smb2_negotiate, | 2598 | .negotiate = smb2_negotiate, |
@@ -2639,7 +2650,7 @@ struct smb_version_operations smb311_operations = { | |||
2639 | .set_oplock_level = smb3_set_oplock_level, | 2650 | .set_oplock_level = smb3_set_oplock_level, |
2640 | .create_lease_buf = smb3_create_lease_buf, | 2651 | .create_lease_buf = smb3_create_lease_buf, |
2641 | .parse_lease_buf = smb3_parse_lease_buf, | 2652 | .parse_lease_buf = smb3_parse_lease_buf, |
2642 | .clone_range = smb2_clone_range, | 2653 | .copychunk_range = smb2_copychunk_range, |
2643 | .duplicate_extents = smb2_duplicate_extents, | 2654 | .duplicate_extents = smb2_duplicate_extents, |
2644 | /* .validate_negotiate = smb3_validate_negotiate, */ /* not used in 3.11 */ | 2655 | /* .validate_negotiate = smb3_validate_negotiate, */ /* not used in 3.11 */ |
2645 | .wp_retry_size = smb2_wp_retry_size, | 2656 | .wp_retry_size = smb2_wp_retry_size, |
diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c index 7446496850a3..02da648041fc 100644 --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c | |||
@@ -562,8 +562,10 @@ SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses) | |||
562 | * but for time being this is our only auth choice so doesn't matter. | 562 | * but for time being this is our only auth choice so doesn't matter. |
563 | * We just found a server which sets blob length to zero expecting raw. | 563 | * We just found a server which sets blob length to zero expecting raw. |
564 | */ | 564 | */ |
565 | if (blob_length == 0) | 565 | if (blob_length == 0) { |
566 | cifs_dbg(FYI, "missing security blob on negprot\n"); | 566 | cifs_dbg(FYI, "missing security blob on negprot\n"); |
567 | server->sec_ntlmssp = true; | ||
568 | } | ||
567 | 569 | ||
568 | rc = cifs_enable_signing(server, ses->sign); | 570 | rc = cifs_enable_signing(server, ses->sign); |
569 | if (rc) | 571 | if (rc) |
@@ -1171,9 +1173,6 @@ SMB2_tcon(const unsigned int xid, struct cifs_ses *ses, const char *tree, | |||
1171 | else | 1173 | else |
1172 | return -EIO; | 1174 | return -EIO; |
1173 | 1175 | ||
1174 | if (tcon && tcon->bad_network_name) | ||
1175 | return -ENOENT; | ||
1176 | |||
1177 | unc_path = kmalloc(MAX_SHARENAME_LENGTH * 2, GFP_KERNEL); | 1176 | unc_path = kmalloc(MAX_SHARENAME_LENGTH * 2, GFP_KERNEL); |
1178 | if (unc_path == NULL) | 1177 | if (unc_path == NULL) |
1179 | return -ENOMEM; | 1178 | return -ENOMEM; |
@@ -1185,6 +1184,10 @@ SMB2_tcon(const unsigned int xid, struct cifs_ses *ses, const char *tree, | |||
1185 | return -EINVAL; | 1184 | return -EINVAL; |
1186 | } | 1185 | } |
1187 | 1186 | ||
1187 | /* SMB2 TREE_CONNECT request must be called with TreeId == 0 */ | ||
1188 | if (tcon) | ||
1189 | tcon->tid = 0; | ||
1190 | |||
1188 | rc = small_smb2_init(SMB2_TREE_CONNECT, tcon, (void **) &req); | 1191 | rc = small_smb2_init(SMB2_TREE_CONNECT, tcon, (void **) &req); |
1189 | if (rc) { | 1192 | if (rc) { |
1190 | kfree(unc_path); | 1193 | kfree(unc_path); |
@@ -1273,8 +1276,6 @@ tcon_exit: | |||
1273 | tcon_error_exit: | 1276 | tcon_error_exit: |
1274 | if (rsp->hdr.sync_hdr.Status == STATUS_BAD_NETWORK_NAME) { | 1277 | if (rsp->hdr.sync_hdr.Status == STATUS_BAD_NETWORK_NAME) { |
1275 | cifs_dbg(VFS, "BAD_NETWORK_NAME: %s\n", tree); | 1278 | cifs_dbg(VFS, "BAD_NETWORK_NAME: %s\n", tree); |
1276 | if (tcon) | ||
1277 | tcon->bad_network_name = true; | ||
1278 | } | 1279 | } |
1279 | goto tcon_exit; | 1280 | goto tcon_exit; |
1280 | } | 1281 | } |
@@ -2177,6 +2178,9 @@ void smb2_reconnect_server(struct work_struct *work) | |||
2177 | struct cifs_tcon *tcon, *tcon2; | 2178 | struct cifs_tcon *tcon, *tcon2; |
2178 | struct list_head tmp_list; | 2179 | struct list_head tmp_list; |
2179 | int tcon_exist = false; | 2180 | int tcon_exist = false; |
2181 | int rc; | ||
2182 | int resched = false; | ||
2183 | |||
2180 | 2184 | ||
2181 | /* Prevent simultaneous reconnects that can corrupt tcon->rlist list */ | 2185 | /* Prevent simultaneous reconnects that can corrupt tcon->rlist list */ |
2182 | mutex_lock(&server->reconnect_mutex); | 2186 | mutex_lock(&server->reconnect_mutex); |
@@ -2204,13 +2208,18 @@ void smb2_reconnect_server(struct work_struct *work) | |||
2204 | spin_unlock(&cifs_tcp_ses_lock); | 2208 | spin_unlock(&cifs_tcp_ses_lock); |
2205 | 2209 | ||
2206 | list_for_each_entry_safe(tcon, tcon2, &tmp_list, rlist) { | 2210 | list_for_each_entry_safe(tcon, tcon2, &tmp_list, rlist) { |
2207 | if (!smb2_reconnect(SMB2_INTERNAL_CMD, tcon)) | 2211 | rc = smb2_reconnect(SMB2_INTERNAL_CMD, tcon); |
2212 | if (!rc) | ||
2208 | cifs_reopen_persistent_handles(tcon); | 2213 | cifs_reopen_persistent_handles(tcon); |
2214 | else | ||
2215 | resched = true; | ||
2209 | list_del_init(&tcon->rlist); | 2216 | list_del_init(&tcon->rlist); |
2210 | cifs_put_tcon(tcon); | 2217 | cifs_put_tcon(tcon); |
2211 | } | 2218 | } |
2212 | 2219 | ||
2213 | cifs_dbg(FYI, "Reconnecting tcons finished\n"); | 2220 | cifs_dbg(FYI, "Reconnecting tcons finished\n"); |
2221 | if (resched) | ||
2222 | queue_delayed_work(cifsiod_wq, &server->reconnect, 2 * HZ); | ||
2214 | mutex_unlock(&server->reconnect_mutex); | 2223 | mutex_unlock(&server->reconnect_mutex); |
2215 | 2224 | ||
2216 | /* now we can safely release srv struct */ | 2225 | /* now we can safely release srv struct */ |
diff --git a/fs/cifs/smb2proto.h b/fs/cifs/smb2proto.h index 69e35873b1de..6853454fc871 100644 --- a/fs/cifs/smb2proto.h +++ b/fs/cifs/smb2proto.h | |||
@@ -48,6 +48,10 @@ extern struct mid_q_entry *smb2_setup_request(struct cifs_ses *ses, | |||
48 | struct smb_rqst *rqst); | 48 | struct smb_rqst *rqst); |
49 | extern struct mid_q_entry *smb2_setup_async_request( | 49 | extern struct mid_q_entry *smb2_setup_async_request( |
50 | struct TCP_Server_Info *server, struct smb_rqst *rqst); | 50 | struct TCP_Server_Info *server, struct smb_rqst *rqst); |
51 | extern struct cifs_ses *smb2_find_smb_ses(struct TCP_Server_Info *server, | ||
52 | __u64 ses_id); | ||
53 | extern struct cifs_tcon *smb2_find_smb_tcon(struct TCP_Server_Info *server, | ||
54 | __u64 ses_id, __u32 tid); | ||
51 | extern int smb2_calc_signature(struct smb_rqst *rqst, | 55 | extern int smb2_calc_signature(struct smb_rqst *rqst, |
52 | struct TCP_Server_Info *server); | 56 | struct TCP_Server_Info *server); |
53 | extern int smb3_calc_signature(struct smb_rqst *rqst, | 57 | extern int smb3_calc_signature(struct smb_rqst *rqst, |
@@ -164,6 +168,9 @@ extern int SMB2_set_compression(const unsigned int xid, struct cifs_tcon *tcon, | |||
164 | extern int SMB2_oplock_break(const unsigned int xid, struct cifs_tcon *tcon, | 168 | extern int SMB2_oplock_break(const unsigned int xid, struct cifs_tcon *tcon, |
165 | const u64 persistent_fid, const u64 volatile_fid, | 169 | const u64 persistent_fid, const u64 volatile_fid, |
166 | const __u8 oplock_level); | 170 | const __u8 oplock_level); |
171 | extern int smb2_handle_cancelled_mid(char *buffer, | ||
172 | struct TCP_Server_Info *server); | ||
173 | void smb2_cancelled_close_fid(struct work_struct *work); | ||
167 | extern int SMB2_QFS_info(const unsigned int xid, struct cifs_tcon *tcon, | 174 | extern int SMB2_QFS_info(const unsigned int xid, struct cifs_tcon *tcon, |
168 | u64 persistent_file_id, u64 volatile_file_id, | 175 | u64 persistent_file_id, u64 volatile_file_id, |
169 | struct kstatfs *FSData); | 176 | struct kstatfs *FSData); |
diff --git a/fs/cifs/smb2transport.c b/fs/cifs/smb2transport.c index 7c3bb1bd7eed..506b67fc93d9 100644 --- a/fs/cifs/smb2transport.c +++ b/fs/cifs/smb2transport.c | |||
@@ -115,23 +115,70 @@ smb3_crypto_shash_allocate(struct TCP_Server_Info *server) | |||
115 | return 0; | 115 | return 0; |
116 | } | 116 | } |
117 | 117 | ||
118 | struct cifs_ses * | 118 | static struct cifs_ses * |
119 | smb2_find_smb_ses(struct TCP_Server_Info *server, __u64 ses_id) | 119 | smb2_find_smb_ses_unlocked(struct TCP_Server_Info *server, __u64 ses_id) |
120 | { | 120 | { |
121 | struct cifs_ses *ses; | 121 | struct cifs_ses *ses; |
122 | 122 | ||
123 | spin_lock(&cifs_tcp_ses_lock); | ||
124 | list_for_each_entry(ses, &server->smb_ses_list, smb_ses_list) { | 123 | list_for_each_entry(ses, &server->smb_ses_list, smb_ses_list) { |
125 | if (ses->Suid != ses_id) | 124 | if (ses->Suid != ses_id) |
126 | continue; | 125 | continue; |
127 | spin_unlock(&cifs_tcp_ses_lock); | ||
128 | return ses; | 126 | return ses; |
129 | } | 127 | } |
128 | |||
129 | return NULL; | ||
130 | } | ||
131 | |||
132 | struct cifs_ses * | ||
133 | smb2_find_smb_ses(struct TCP_Server_Info *server, __u64 ses_id) | ||
134 | { | ||
135 | struct cifs_ses *ses; | ||
136 | |||
137 | spin_lock(&cifs_tcp_ses_lock); | ||
138 | ses = smb2_find_smb_ses_unlocked(server, ses_id); | ||
130 | spin_unlock(&cifs_tcp_ses_lock); | 139 | spin_unlock(&cifs_tcp_ses_lock); |
131 | 140 | ||
141 | return ses; | ||
142 | } | ||
143 | |||
144 | static struct cifs_tcon * | ||
145 | smb2_find_smb_sess_tcon_unlocked(struct cifs_ses *ses, __u32 tid) | ||
146 | { | ||
147 | struct cifs_tcon *tcon; | ||
148 | |||
149 | list_for_each_entry(tcon, &ses->tcon_list, tcon_list) { | ||
150 | if (tcon->tid != tid) | ||
151 | continue; | ||
152 | ++tcon->tc_count; | ||
153 | return tcon; | ||
154 | } | ||
155 | |||
132 | return NULL; | 156 | return NULL; |
133 | } | 157 | } |
134 | 158 | ||
159 | /* | ||
160 | * Obtain tcon corresponding to the tid in the given | ||
161 | * cifs_ses | ||
162 | */ | ||
163 | |||
164 | struct cifs_tcon * | ||
165 | smb2_find_smb_tcon(struct TCP_Server_Info *server, __u64 ses_id, __u32 tid) | ||
166 | { | ||
167 | struct cifs_ses *ses; | ||
168 | struct cifs_tcon *tcon; | ||
169 | |||
170 | spin_lock(&cifs_tcp_ses_lock); | ||
171 | ses = smb2_find_smb_ses_unlocked(server, ses_id); | ||
172 | if (!ses) { | ||
173 | spin_unlock(&cifs_tcp_ses_lock); | ||
174 | return NULL; | ||
175 | } | ||
176 | tcon = smb2_find_smb_sess_tcon_unlocked(ses, tid); | ||
177 | spin_unlock(&cifs_tcp_ses_lock); | ||
178 | |||
179 | return tcon; | ||
180 | } | ||
181 | |||
135 | int | 182 | int |
136 | smb2_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server) | 183 | smb2_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server) |
137 | { | 184 | { |
diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c index 526f0533cb4e..f6e13a977fc8 100644 --- a/fs/cifs/transport.c +++ b/fs/cifs/transport.c | |||
@@ -752,9 +752,11 @@ cifs_send_recv(const unsigned int xid, struct cifs_ses *ses, | |||
752 | 752 | ||
753 | rc = wait_for_response(ses->server, midQ); | 753 | rc = wait_for_response(ses->server, midQ); |
754 | if (rc != 0) { | 754 | if (rc != 0) { |
755 | cifs_dbg(FYI, "Cancelling wait for mid %llu\n", midQ->mid); | ||
755 | send_cancel(ses->server, rqst, midQ); | 756 | send_cancel(ses->server, rqst, midQ); |
756 | spin_lock(&GlobalMid_Lock); | 757 | spin_lock(&GlobalMid_Lock); |
757 | if (midQ->mid_state == MID_REQUEST_SUBMITTED) { | 758 | if (midQ->mid_state == MID_REQUEST_SUBMITTED) { |
759 | midQ->mid_flags |= MID_WAIT_CANCELLED; | ||
758 | midQ->callback = DeleteMidQEntry; | 760 | midQ->callback = DeleteMidQEntry; |
759 | spin_unlock(&GlobalMid_Lock); | 761 | spin_unlock(&GlobalMid_Lock); |
760 | add_credits(ses->server, 1, optype); | 762 | add_credits(ses->server, 1, optype); |
@@ -373,6 +373,22 @@ restart: | |||
373 | } | 373 | } |
374 | spin_lock_irq(&mapping->tree_lock); | 374 | spin_lock_irq(&mapping->tree_lock); |
375 | 375 | ||
376 | if (!entry) { | ||
377 | /* | ||
378 | * We needed to drop the page_tree lock while calling | ||
379 | * radix_tree_preload() and we didn't have an entry to | ||
380 | * lock. See if another thread inserted an entry at | ||
381 | * our index during this time. | ||
382 | */ | ||
383 | entry = __radix_tree_lookup(&mapping->page_tree, index, | ||
384 | NULL, &slot); | ||
385 | if (entry) { | ||
386 | radix_tree_preload_end(); | ||
387 | spin_unlock_irq(&mapping->tree_lock); | ||
388 | goto restart; | ||
389 | } | ||
390 | } | ||
391 | |||
376 | if (pmd_downgrade) { | 392 | if (pmd_downgrade) { |
377 | radix_tree_delete(&mapping->page_tree, index); | 393 | radix_tree_delete(&mapping->page_tree, index); |
378 | mapping->nrexceptional--; | 394 | mapping->nrexceptional--; |
@@ -388,19 +404,12 @@ restart: | |||
388 | if (err) { | 404 | if (err) { |
389 | spin_unlock_irq(&mapping->tree_lock); | 405 | spin_unlock_irq(&mapping->tree_lock); |
390 | /* | 406 | /* |
391 | * Someone already created the entry? This is a | 407 | * Our insertion of a DAX entry failed, most likely |
392 | * normal failure when inserting PMDs in a range | 408 | * because we were inserting a PMD entry and it |
393 | * that already contains PTEs. In that case we want | 409 | * collided with a PTE sized entry at a different |
394 | * to return -EEXIST immediately. | 410 | * index in the PMD range. We haven't inserted |
395 | */ | 411 | * anything into the radix tree and have no waiters to |
396 | if (err == -EEXIST && !(size_flag & RADIX_DAX_PMD)) | 412 | * wake. |
397 | goto restart; | ||
398 | /* | ||
399 | * Our insertion of a DAX PMD entry failed, most | ||
400 | * likely because it collided with a PTE sized entry | ||
401 | * at a different index in the PMD range. We haven't | ||
402 | * inserted anything into the radix tree and have no | ||
403 | * waiters to wake. | ||
404 | */ | 413 | */ |
405 | return ERR_PTR(err); | 414 | return ERR_PTR(err); |
406 | } | 415 | } |
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index f493af666591..fb69ee2388db 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h | |||
@@ -2466,6 +2466,7 @@ extern int ext4_setattr(struct dentry *, struct iattr *); | |||
2466 | extern int ext4_getattr(const struct path *, struct kstat *, u32, unsigned int); | 2466 | extern int ext4_getattr(const struct path *, struct kstat *, u32, unsigned int); |
2467 | extern void ext4_evict_inode(struct inode *); | 2467 | extern void ext4_evict_inode(struct inode *); |
2468 | extern void ext4_clear_inode(struct inode *); | 2468 | extern void ext4_clear_inode(struct inode *); |
2469 | extern int ext4_file_getattr(const struct path *, struct kstat *, u32, unsigned int); | ||
2469 | extern int ext4_sync_inode(handle_t *, struct inode *); | 2470 | extern int ext4_sync_inode(handle_t *, struct inode *); |
2470 | extern void ext4_dirty_inode(struct inode *, int); | 2471 | extern void ext4_dirty_inode(struct inode *, int); |
2471 | extern int ext4_change_inode_journal_flag(struct inode *, int); | 2472 | extern int ext4_change_inode_journal_flag(struct inode *, int); |
diff --git a/fs/ext4/file.c b/fs/ext4/file.c index 8210c1f43556..cefa9835f275 100644 --- a/fs/ext4/file.c +++ b/fs/ext4/file.c | |||
@@ -744,7 +744,7 @@ const struct file_operations ext4_file_operations = { | |||
744 | 744 | ||
745 | const struct inode_operations ext4_file_inode_operations = { | 745 | const struct inode_operations ext4_file_inode_operations = { |
746 | .setattr = ext4_setattr, | 746 | .setattr = ext4_setattr, |
747 | .getattr = ext4_getattr, | 747 | .getattr = ext4_file_getattr, |
748 | .listxattr = ext4_listxattr, | 748 | .listxattr = ext4_listxattr, |
749 | .get_acl = ext4_get_acl, | 749 | .get_acl = ext4_get_acl, |
750 | .set_acl = ext4_set_acl, | 750 | .set_acl = ext4_set_acl, |
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 4247d8d25687..b9ffa9f4191f 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c | |||
@@ -5390,11 +5390,46 @@ err_out: | |||
5390 | int ext4_getattr(const struct path *path, struct kstat *stat, | 5390 | int ext4_getattr(const struct path *path, struct kstat *stat, |
5391 | u32 request_mask, unsigned int query_flags) | 5391 | u32 request_mask, unsigned int query_flags) |
5392 | { | 5392 | { |
5393 | struct inode *inode; | 5393 | struct inode *inode = d_inode(path->dentry); |
5394 | unsigned long long delalloc_blocks; | 5394 | struct ext4_inode *raw_inode; |
5395 | struct ext4_inode_info *ei = EXT4_I(inode); | ||
5396 | unsigned int flags; | ||
5397 | |||
5398 | if (EXT4_FITS_IN_INODE(raw_inode, ei, i_crtime)) { | ||
5399 | stat->result_mask |= STATX_BTIME; | ||
5400 | stat->btime.tv_sec = ei->i_crtime.tv_sec; | ||
5401 | stat->btime.tv_nsec = ei->i_crtime.tv_nsec; | ||
5402 | } | ||
5403 | |||
5404 | flags = ei->i_flags & EXT4_FL_USER_VISIBLE; | ||
5405 | if (flags & EXT4_APPEND_FL) | ||
5406 | stat->attributes |= STATX_ATTR_APPEND; | ||
5407 | if (flags & EXT4_COMPR_FL) | ||
5408 | stat->attributes |= STATX_ATTR_COMPRESSED; | ||
5409 | if (flags & EXT4_ENCRYPT_FL) | ||
5410 | stat->attributes |= STATX_ATTR_ENCRYPTED; | ||
5411 | if (flags & EXT4_IMMUTABLE_FL) | ||
5412 | stat->attributes |= STATX_ATTR_IMMUTABLE; | ||
5413 | if (flags & EXT4_NODUMP_FL) | ||
5414 | stat->attributes |= STATX_ATTR_NODUMP; | ||
5415 | |||
5416 | stat->attributes_mask |= (STATX_ATTR_APPEND | | ||
5417 | STATX_ATTR_COMPRESSED | | ||
5418 | STATX_ATTR_ENCRYPTED | | ||
5419 | STATX_ATTR_IMMUTABLE | | ||
5420 | STATX_ATTR_NODUMP); | ||
5395 | 5421 | ||
5396 | inode = d_inode(path->dentry); | ||
5397 | generic_fillattr(inode, stat); | 5422 | generic_fillattr(inode, stat); |
5423 | return 0; | ||
5424 | } | ||
5425 | |||
5426 | int ext4_file_getattr(const struct path *path, struct kstat *stat, | ||
5427 | u32 request_mask, unsigned int query_flags) | ||
5428 | { | ||
5429 | struct inode *inode = d_inode(path->dentry); | ||
5430 | u64 delalloc_blocks; | ||
5431 | |||
5432 | ext4_getattr(path, stat, request_mask, query_flags); | ||
5398 | 5433 | ||
5399 | /* | 5434 | /* |
5400 | * If there is inline data in the inode, the inode will normally not | 5435 | * If there is inline data in the inode, the inode will normally not |
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c index 6ad612c576fc..07e5e1405771 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c | |||
@@ -3912,6 +3912,7 @@ const struct inode_operations ext4_dir_inode_operations = { | |||
3912 | .tmpfile = ext4_tmpfile, | 3912 | .tmpfile = ext4_tmpfile, |
3913 | .rename = ext4_rename2, | 3913 | .rename = ext4_rename2, |
3914 | .setattr = ext4_setattr, | 3914 | .setattr = ext4_setattr, |
3915 | .getattr = ext4_getattr, | ||
3915 | .listxattr = ext4_listxattr, | 3916 | .listxattr = ext4_listxattr, |
3916 | .get_acl = ext4_get_acl, | 3917 | .get_acl = ext4_get_acl, |
3917 | .set_acl = ext4_set_acl, | 3918 | .set_acl = ext4_set_acl, |
@@ -3920,6 +3921,7 @@ const struct inode_operations ext4_dir_inode_operations = { | |||
3920 | 3921 | ||
3921 | const struct inode_operations ext4_special_inode_operations = { | 3922 | const struct inode_operations ext4_special_inode_operations = { |
3922 | .setattr = ext4_setattr, | 3923 | .setattr = ext4_setattr, |
3924 | .getattr = ext4_getattr, | ||
3923 | .listxattr = ext4_listxattr, | 3925 | .listxattr = ext4_listxattr, |
3924 | .get_acl = ext4_get_acl, | 3926 | .get_acl = ext4_get_acl, |
3925 | .set_acl = ext4_set_acl, | 3927 | .set_acl = ext4_set_acl, |
diff --git a/fs/ext4/symlink.c b/fs/ext4/symlink.c index 73b184d161fc..5c8fc53cb0e5 100644 --- a/fs/ext4/symlink.c +++ b/fs/ext4/symlink.c | |||
@@ -85,17 +85,20 @@ errout: | |||
85 | const struct inode_operations ext4_encrypted_symlink_inode_operations = { | 85 | const struct inode_operations ext4_encrypted_symlink_inode_operations = { |
86 | .get_link = ext4_encrypted_get_link, | 86 | .get_link = ext4_encrypted_get_link, |
87 | .setattr = ext4_setattr, | 87 | .setattr = ext4_setattr, |
88 | .getattr = ext4_getattr, | ||
88 | .listxattr = ext4_listxattr, | 89 | .listxattr = ext4_listxattr, |
89 | }; | 90 | }; |
90 | 91 | ||
91 | const struct inode_operations ext4_symlink_inode_operations = { | 92 | const struct inode_operations ext4_symlink_inode_operations = { |
92 | .get_link = page_get_link, | 93 | .get_link = page_get_link, |
93 | .setattr = ext4_setattr, | 94 | .setattr = ext4_setattr, |
95 | .getattr = ext4_getattr, | ||
94 | .listxattr = ext4_listxattr, | 96 | .listxattr = ext4_listxattr, |
95 | }; | 97 | }; |
96 | 98 | ||
97 | const struct inode_operations ext4_fast_symlink_inode_operations = { | 99 | const struct inode_operations ext4_fast_symlink_inode_operations = { |
98 | .get_link = simple_get_link, | 100 | .get_link = simple_get_link, |
99 | .setattr = ext4_setattr, | 101 | .setattr = ext4_setattr, |
102 | .getattr = ext4_getattr, | ||
100 | .listxattr = ext4_listxattr, | 103 | .listxattr = ext4_listxattr, |
101 | }; | 104 | }; |
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index 8f96461236f6..dde861387a40 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c | |||
@@ -136,17 +136,26 @@ static int hugetlbfs_file_mmap(struct file *file, struct vm_area_struct *vma) | |||
136 | vma->vm_flags |= VM_HUGETLB | VM_DONTEXPAND; | 136 | vma->vm_flags |= VM_HUGETLB | VM_DONTEXPAND; |
137 | vma->vm_ops = &hugetlb_vm_ops; | 137 | vma->vm_ops = &hugetlb_vm_ops; |
138 | 138 | ||
139 | /* | ||
140 | * Offset passed to mmap (before page shift) could have been | ||
141 | * negative when represented as a (l)off_t. | ||
142 | */ | ||
143 | if (((loff_t)vma->vm_pgoff << PAGE_SHIFT) < 0) | ||
144 | return -EINVAL; | ||
145 | |||
139 | if (vma->vm_pgoff & (~huge_page_mask(h) >> PAGE_SHIFT)) | 146 | if (vma->vm_pgoff & (~huge_page_mask(h) >> PAGE_SHIFT)) |
140 | return -EINVAL; | 147 | return -EINVAL; |
141 | 148 | ||
142 | vma_len = (loff_t)(vma->vm_end - vma->vm_start); | 149 | vma_len = (loff_t)(vma->vm_end - vma->vm_start); |
150 | len = vma_len + ((loff_t)vma->vm_pgoff << PAGE_SHIFT); | ||
151 | /* check for overflow */ | ||
152 | if (len < vma_len) | ||
153 | return -EINVAL; | ||
143 | 154 | ||
144 | inode_lock(inode); | 155 | inode_lock(inode); |
145 | file_accessed(file); | 156 | file_accessed(file); |
146 | 157 | ||
147 | ret = -ENOMEM; | 158 | ret = -ENOMEM; |
148 | len = vma_len + ((loff_t)vma->vm_pgoff << PAGE_SHIFT); | ||
149 | |||
150 | if (hugetlb_reserve_pages(inode, | 159 | if (hugetlb_reserve_pages(inode, |
151 | vma->vm_pgoff >> huge_page_order(h), | 160 | vma->vm_pgoff >> huge_page_order(h), |
152 | len >> huge_page_shift(h), vma, | 161 | len >> huge_page_shift(h), vma, |
@@ -155,7 +164,7 @@ static int hugetlbfs_file_mmap(struct file *file, struct vm_area_struct *vma) | |||
155 | 164 | ||
156 | ret = 0; | 165 | ret = 0; |
157 | if (vma->vm_flags & VM_WRITE && inode->i_size < len) | 166 | if (vma->vm_flags & VM_WRITE && inode->i_size < len) |
158 | inode->i_size = len; | 167 | i_size_write(inode, len); |
159 | out: | 168 | out: |
160 | inode_unlock(inode); | 169 | inode_unlock(inode); |
161 | 170 | ||
@@ -695,14 +704,11 @@ static struct inode *hugetlbfs_get_root(struct super_block *sb, | |||
695 | 704 | ||
696 | inode = new_inode(sb); | 705 | inode = new_inode(sb); |
697 | if (inode) { | 706 | if (inode) { |
698 | struct hugetlbfs_inode_info *info; | ||
699 | inode->i_ino = get_next_ino(); | 707 | inode->i_ino = get_next_ino(); |
700 | inode->i_mode = S_IFDIR | config->mode; | 708 | inode->i_mode = S_IFDIR | config->mode; |
701 | inode->i_uid = config->uid; | 709 | inode->i_uid = config->uid; |
702 | inode->i_gid = config->gid; | 710 | inode->i_gid = config->gid; |
703 | inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode); | 711 | inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode); |
704 | info = HUGETLBFS_I(inode); | ||
705 | mpol_shared_policy_init(&info->policy, NULL); | ||
706 | inode->i_op = &hugetlbfs_dir_inode_operations; | 712 | inode->i_op = &hugetlbfs_dir_inode_operations; |
707 | inode->i_fop = &simple_dir_operations; | 713 | inode->i_fop = &simple_dir_operations; |
708 | /* directory inodes start off with i_nlink == 2 (for "." entry) */ | 714 | /* directory inodes start off with i_nlink == 2 (for "." entry) */ |
@@ -733,7 +739,6 @@ static struct inode *hugetlbfs_get_inode(struct super_block *sb, | |||
733 | 739 | ||
734 | inode = new_inode(sb); | 740 | inode = new_inode(sb); |
735 | if (inode) { | 741 | if (inode) { |
736 | struct hugetlbfs_inode_info *info; | ||
737 | inode->i_ino = get_next_ino(); | 742 | inode->i_ino = get_next_ino(); |
738 | inode_init_owner(inode, dir, mode); | 743 | inode_init_owner(inode, dir, mode); |
739 | lockdep_set_class(&inode->i_mapping->i_mmap_rwsem, | 744 | lockdep_set_class(&inode->i_mapping->i_mmap_rwsem, |
@@ -741,15 +746,6 @@ static struct inode *hugetlbfs_get_inode(struct super_block *sb, | |||
741 | inode->i_mapping->a_ops = &hugetlbfs_aops; | 746 | inode->i_mapping->a_ops = &hugetlbfs_aops; |
742 | inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode); | 747 | inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode); |
743 | inode->i_mapping->private_data = resv_map; | 748 | inode->i_mapping->private_data = resv_map; |
744 | info = HUGETLBFS_I(inode); | ||
745 | /* | ||
746 | * The policy is initialized here even if we are creating a | ||
747 | * private inode because initialization simply creates an | ||
748 | * an empty rb tree and calls rwlock_init(), later when we | ||
749 | * call mpol_free_shared_policy() it will just return because | ||
750 | * the rb tree will still be empty. | ||
751 | */ | ||
752 | mpol_shared_policy_init(&info->policy, NULL); | ||
753 | switch (mode & S_IFMT) { | 749 | switch (mode & S_IFMT) { |
754 | default: | 750 | default: |
755 | init_special_inode(inode, mode, dev); | 751 | init_special_inode(inode, mode, dev); |
@@ -937,6 +933,18 @@ static struct inode *hugetlbfs_alloc_inode(struct super_block *sb) | |||
937 | hugetlbfs_inc_free_inodes(sbinfo); | 933 | hugetlbfs_inc_free_inodes(sbinfo); |
938 | return NULL; | 934 | return NULL; |
939 | } | 935 | } |
936 | |||
937 | /* | ||
938 | * Any time after allocation, hugetlbfs_destroy_inode can be called | ||
939 | * for the inode. mpol_free_shared_policy is unconditionally called | ||
940 | * as part of hugetlbfs_destroy_inode. So, initialize policy here | ||
941 | * in case of a quick call to destroy. | ||
942 | * | ||
943 | * Note that the policy is initialized even if we are creating a | ||
944 | * private inode. This simplifies hugetlbfs_destroy_inode. | ||
945 | */ | ||
946 | mpol_shared_policy_init(&p->policy, NULL); | ||
947 | |||
940 | return &p->vfs_inode; | 948 | return &p->vfs_inode; |
941 | } | 949 | } |
942 | 950 | ||
diff --git a/fs/namei.c b/fs/namei.c index d41fab78798b..19dcf62133cc 100644 --- a/fs/namei.c +++ b/fs/namei.c | |||
@@ -2145,6 +2145,9 @@ static const char *path_init(struct nameidata *nd, unsigned flags) | |||
2145 | int retval = 0; | 2145 | int retval = 0; |
2146 | const char *s = nd->name->name; | 2146 | const char *s = nd->name->name; |
2147 | 2147 | ||
2148 | if (!*s) | ||
2149 | flags &= ~LOOKUP_RCU; | ||
2150 | |||
2148 | nd->last_type = LAST_ROOT; /* if there are only slashes... */ | 2151 | nd->last_type = LAST_ROOT; /* if there are only slashes... */ |
2149 | nd->flags = flags | LOOKUP_JUMPED | LOOKUP_PARENT; | 2152 | nd->flags = flags | LOOKUP_JUMPED | LOOKUP_PARENT; |
2150 | nd->depth = 0; | 2153 | nd->depth = 0; |
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index fb499a3f21b5..f92ba8d6c556 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c | |||
@@ -2055,7 +2055,7 @@ int nfs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
2055 | { | 2055 | { |
2056 | struct inode *old_inode = d_inode(old_dentry); | 2056 | struct inode *old_inode = d_inode(old_dentry); |
2057 | struct inode *new_inode = d_inode(new_dentry); | 2057 | struct inode *new_inode = d_inode(new_dentry); |
2058 | struct dentry *dentry = NULL, *rehash = NULL; | 2058 | struct dentry *dentry = NULL; |
2059 | struct rpc_task *task; | 2059 | struct rpc_task *task; |
2060 | int error = -EBUSY; | 2060 | int error = -EBUSY; |
2061 | 2061 | ||
@@ -2078,10 +2078,8 @@ int nfs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
2078 | * To prevent any new references to the target during the | 2078 | * To prevent any new references to the target during the |
2079 | * rename, we unhash the dentry in advance. | 2079 | * rename, we unhash the dentry in advance. |
2080 | */ | 2080 | */ |
2081 | if (!d_unhashed(new_dentry)) { | 2081 | if (!d_unhashed(new_dentry)) |
2082 | d_drop(new_dentry); | 2082 | d_drop(new_dentry); |
2083 | rehash = new_dentry; | ||
2084 | } | ||
2085 | 2083 | ||
2086 | if (d_count(new_dentry) > 2) { | 2084 | if (d_count(new_dentry) > 2) { |
2087 | int err; | 2085 | int err; |
@@ -2098,7 +2096,6 @@ int nfs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
2098 | goto out; | 2096 | goto out; |
2099 | 2097 | ||
2100 | new_dentry = dentry; | 2098 | new_dentry = dentry; |
2101 | rehash = NULL; | ||
2102 | new_inode = NULL; | 2099 | new_inode = NULL; |
2103 | } | 2100 | } |
2104 | } | 2101 | } |
@@ -2119,8 +2116,6 @@ int nfs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
2119 | error = task->tk_status; | 2116 | error = task->tk_status; |
2120 | rpc_put_task(task); | 2117 | rpc_put_task(task); |
2121 | out: | 2118 | out: |
2122 | if (rehash) | ||
2123 | d_rehash(rehash); | ||
2124 | trace_nfs_rename_exit(old_dir, old_dentry, | 2119 | trace_nfs_rename_exit(old_dir, old_dentry, |
2125 | new_dir, new_dentry, error); | 2120 | new_dir, new_dentry, error); |
2126 | /* new dentry created? */ | 2121 | /* new dentry created? */ |
diff --git a/fs/nfs/filelayout/filelayout.c b/fs/nfs/filelayout/filelayout.c index 44347f4bdc15..acd30baca461 100644 --- a/fs/nfs/filelayout/filelayout.c +++ b/fs/nfs/filelayout/filelayout.c | |||
@@ -202,10 +202,10 @@ static int filelayout_async_handle_error(struct rpc_task *task, | |||
202 | task->tk_status); | 202 | task->tk_status); |
203 | nfs4_mark_deviceid_unavailable(devid); | 203 | nfs4_mark_deviceid_unavailable(devid); |
204 | pnfs_error_mark_layout_for_return(inode, lseg); | 204 | pnfs_error_mark_layout_for_return(inode, lseg); |
205 | pnfs_set_lo_fail(lseg); | ||
206 | rpc_wake_up(&tbl->slot_tbl_waitq); | 205 | rpc_wake_up(&tbl->slot_tbl_waitq); |
207 | /* fall through */ | 206 | /* fall through */ |
208 | default: | 207 | default: |
208 | pnfs_set_lo_fail(lseg); | ||
209 | reset: | 209 | reset: |
210 | dprintk("%s Retry through MDS. Error %d\n", __func__, | 210 | dprintk("%s Retry through MDS. Error %d\n", __func__, |
211 | task->tk_status); | 211 | task->tk_status); |
@@ -560,6 +560,50 @@ filelayout_write_pagelist(struct nfs_pgio_header *hdr, int sync) | |||
560 | return PNFS_ATTEMPTED; | 560 | return PNFS_ATTEMPTED; |
561 | } | 561 | } |
562 | 562 | ||
563 | static int | ||
564 | filelayout_check_deviceid(struct pnfs_layout_hdr *lo, | ||
565 | struct nfs4_filelayout_segment *fl, | ||
566 | gfp_t gfp_flags) | ||
567 | { | ||
568 | struct nfs4_deviceid_node *d; | ||
569 | struct nfs4_file_layout_dsaddr *dsaddr; | ||
570 | int status = -EINVAL; | ||
571 | |||
572 | /* find and reference the deviceid */ | ||
573 | d = nfs4_find_get_deviceid(NFS_SERVER(lo->plh_inode), &fl->deviceid, | ||
574 | lo->plh_lc_cred, gfp_flags); | ||
575 | if (d == NULL) | ||
576 | goto out; | ||
577 | |||
578 | dsaddr = container_of(d, struct nfs4_file_layout_dsaddr, id_node); | ||
579 | /* Found deviceid is unavailable */ | ||
580 | if (filelayout_test_devid_unavailable(&dsaddr->id_node)) | ||
581 | goto out_put; | ||
582 | |||
583 | fl->dsaddr = dsaddr; | ||
584 | |||
585 | if (fl->first_stripe_index >= dsaddr->stripe_count) { | ||
586 | dprintk("%s Bad first_stripe_index %u\n", | ||
587 | __func__, fl->first_stripe_index); | ||
588 | goto out_put; | ||
589 | } | ||
590 | |||
591 | if ((fl->stripe_type == STRIPE_SPARSE && | ||
592 | fl->num_fh > 1 && fl->num_fh != dsaddr->ds_num) || | ||
593 | (fl->stripe_type == STRIPE_DENSE && | ||
594 | fl->num_fh != dsaddr->stripe_count)) { | ||
595 | dprintk("%s num_fh %u not valid for given packing\n", | ||
596 | __func__, fl->num_fh); | ||
597 | goto out_put; | ||
598 | } | ||
599 | status = 0; | ||
600 | out: | ||
601 | return status; | ||
602 | out_put: | ||
603 | nfs4_fl_put_deviceid(dsaddr); | ||
604 | goto out; | ||
605 | } | ||
606 | |||
563 | /* | 607 | /* |
564 | * filelayout_check_layout() | 608 | * filelayout_check_layout() |
565 | * | 609 | * |
@@ -572,11 +616,8 @@ static int | |||
572 | filelayout_check_layout(struct pnfs_layout_hdr *lo, | 616 | filelayout_check_layout(struct pnfs_layout_hdr *lo, |
573 | struct nfs4_filelayout_segment *fl, | 617 | struct nfs4_filelayout_segment *fl, |
574 | struct nfs4_layoutget_res *lgr, | 618 | struct nfs4_layoutget_res *lgr, |
575 | struct nfs4_deviceid *id, | ||
576 | gfp_t gfp_flags) | 619 | gfp_t gfp_flags) |
577 | { | 620 | { |
578 | struct nfs4_deviceid_node *d; | ||
579 | struct nfs4_file_layout_dsaddr *dsaddr; | ||
580 | int status = -EINVAL; | 621 | int status = -EINVAL; |
581 | 622 | ||
582 | dprintk("--> %s\n", __func__); | 623 | dprintk("--> %s\n", __func__); |
@@ -601,41 +642,10 @@ filelayout_check_layout(struct pnfs_layout_hdr *lo, | |||
601 | goto out; | 642 | goto out; |
602 | } | 643 | } |
603 | 644 | ||
604 | /* find and reference the deviceid */ | ||
605 | d = nfs4_find_get_deviceid(NFS_SERVER(lo->plh_inode), id, | ||
606 | lo->plh_lc_cred, gfp_flags); | ||
607 | if (d == NULL) | ||
608 | goto out; | ||
609 | |||
610 | dsaddr = container_of(d, struct nfs4_file_layout_dsaddr, id_node); | ||
611 | /* Found deviceid is unavailable */ | ||
612 | if (filelayout_test_devid_unavailable(&dsaddr->id_node)) | ||
613 | goto out_put; | ||
614 | |||
615 | fl->dsaddr = dsaddr; | ||
616 | |||
617 | if (fl->first_stripe_index >= dsaddr->stripe_count) { | ||
618 | dprintk("%s Bad first_stripe_index %u\n", | ||
619 | __func__, fl->first_stripe_index); | ||
620 | goto out_put; | ||
621 | } | ||
622 | |||
623 | if ((fl->stripe_type == STRIPE_SPARSE && | ||
624 | fl->num_fh > 1 && fl->num_fh != dsaddr->ds_num) || | ||
625 | (fl->stripe_type == STRIPE_DENSE && | ||
626 | fl->num_fh != dsaddr->stripe_count)) { | ||
627 | dprintk("%s num_fh %u not valid for given packing\n", | ||
628 | __func__, fl->num_fh); | ||
629 | goto out_put; | ||
630 | } | ||
631 | |||
632 | status = 0; | 645 | status = 0; |
633 | out: | 646 | out: |
634 | dprintk("--> %s returns %d\n", __func__, status); | 647 | dprintk("--> %s returns %d\n", __func__, status); |
635 | return status; | 648 | return status; |
636 | out_put: | ||
637 | nfs4_fl_put_deviceid(dsaddr); | ||
638 | goto out; | ||
639 | } | 649 | } |
640 | 650 | ||
641 | static void _filelayout_free_lseg(struct nfs4_filelayout_segment *fl) | 651 | static void _filelayout_free_lseg(struct nfs4_filelayout_segment *fl) |
@@ -657,7 +667,6 @@ static int | |||
657 | filelayout_decode_layout(struct pnfs_layout_hdr *flo, | 667 | filelayout_decode_layout(struct pnfs_layout_hdr *flo, |
658 | struct nfs4_filelayout_segment *fl, | 668 | struct nfs4_filelayout_segment *fl, |
659 | struct nfs4_layoutget_res *lgr, | 669 | struct nfs4_layoutget_res *lgr, |
660 | struct nfs4_deviceid *id, | ||
661 | gfp_t gfp_flags) | 670 | gfp_t gfp_flags) |
662 | { | 671 | { |
663 | struct xdr_stream stream; | 672 | struct xdr_stream stream; |
@@ -682,9 +691,9 @@ filelayout_decode_layout(struct pnfs_layout_hdr *flo, | |||
682 | if (unlikely(!p)) | 691 | if (unlikely(!p)) |
683 | goto out_err; | 692 | goto out_err; |
684 | 693 | ||
685 | memcpy(id, p, sizeof(*id)); | 694 | memcpy(&fl->deviceid, p, sizeof(fl->deviceid)); |
686 | p += XDR_QUADLEN(NFS4_DEVICEID4_SIZE); | 695 | p += XDR_QUADLEN(NFS4_DEVICEID4_SIZE); |
687 | nfs4_print_deviceid(id); | 696 | nfs4_print_deviceid(&fl->deviceid); |
688 | 697 | ||
689 | nfl_util = be32_to_cpup(p++); | 698 | nfl_util = be32_to_cpup(p++); |
690 | if (nfl_util & NFL4_UFLG_COMMIT_THRU_MDS) | 699 | if (nfl_util & NFL4_UFLG_COMMIT_THRU_MDS) |
@@ -831,15 +840,14 @@ filelayout_alloc_lseg(struct pnfs_layout_hdr *layoutid, | |||
831 | { | 840 | { |
832 | struct nfs4_filelayout_segment *fl; | 841 | struct nfs4_filelayout_segment *fl; |
833 | int rc; | 842 | int rc; |
834 | struct nfs4_deviceid id; | ||
835 | 843 | ||
836 | dprintk("--> %s\n", __func__); | 844 | dprintk("--> %s\n", __func__); |
837 | fl = kzalloc(sizeof(*fl), gfp_flags); | 845 | fl = kzalloc(sizeof(*fl), gfp_flags); |
838 | if (!fl) | 846 | if (!fl) |
839 | return NULL; | 847 | return NULL; |
840 | 848 | ||
841 | rc = filelayout_decode_layout(layoutid, fl, lgr, &id, gfp_flags); | 849 | rc = filelayout_decode_layout(layoutid, fl, lgr, gfp_flags); |
842 | if (rc != 0 || filelayout_check_layout(layoutid, fl, lgr, &id, gfp_flags)) { | 850 | if (rc != 0 || filelayout_check_layout(layoutid, fl, lgr, gfp_flags)) { |
843 | _filelayout_free_lseg(fl); | 851 | _filelayout_free_lseg(fl); |
844 | return NULL; | 852 | return NULL; |
845 | } | 853 | } |
@@ -888,18 +896,51 @@ filelayout_pg_test(struct nfs_pageio_descriptor *pgio, struct nfs_page *prev, | |||
888 | return min(stripe_unit - (unsigned int)stripe_offset, size); | 896 | return min(stripe_unit - (unsigned int)stripe_offset, size); |
889 | } | 897 | } |
890 | 898 | ||
899 | static struct pnfs_layout_segment * | ||
900 | fl_pnfs_update_layout(struct inode *ino, | ||
901 | struct nfs_open_context *ctx, | ||
902 | loff_t pos, | ||
903 | u64 count, | ||
904 | enum pnfs_iomode iomode, | ||
905 | bool strict_iomode, | ||
906 | gfp_t gfp_flags) | ||
907 | { | ||
908 | struct pnfs_layout_segment *lseg = NULL; | ||
909 | struct pnfs_layout_hdr *lo; | ||
910 | struct nfs4_filelayout_segment *fl; | ||
911 | int status; | ||
912 | |||
913 | lseg = pnfs_update_layout(ino, ctx, pos, count, iomode, strict_iomode, | ||
914 | gfp_flags); | ||
915 | if (!lseg) | ||
916 | lseg = ERR_PTR(-ENOMEM); | ||
917 | if (IS_ERR(lseg)) | ||
918 | goto out; | ||
919 | |||
920 | lo = NFS_I(ino)->layout; | ||
921 | fl = FILELAYOUT_LSEG(lseg); | ||
922 | |||
923 | status = filelayout_check_deviceid(lo, fl, gfp_flags); | ||
924 | if (status) | ||
925 | lseg = ERR_PTR(status); | ||
926 | out: | ||
927 | if (IS_ERR(lseg)) | ||
928 | pnfs_put_lseg(lseg); | ||
929 | return lseg; | ||
930 | } | ||
931 | |||
891 | static void | 932 | static void |
892 | filelayout_pg_init_read(struct nfs_pageio_descriptor *pgio, | 933 | filelayout_pg_init_read(struct nfs_pageio_descriptor *pgio, |
893 | struct nfs_page *req) | 934 | struct nfs_page *req) |
894 | { | 935 | { |
895 | if (!pgio->pg_lseg) { | 936 | if (!pgio->pg_lseg) { |
896 | pgio->pg_lseg = pnfs_update_layout(pgio->pg_inode, | 937 | pgio->pg_lseg = fl_pnfs_update_layout(pgio->pg_inode, |
897 | req->wb_context, | 938 | req->wb_context, |
898 | 0, | 939 | 0, |
899 | NFS4_MAX_UINT64, | 940 | NFS4_MAX_UINT64, |
900 | IOMODE_READ, | 941 | IOMODE_READ, |
901 | false, | 942 | false, |
902 | GFP_KERNEL); | 943 | GFP_KERNEL); |
903 | if (IS_ERR(pgio->pg_lseg)) { | 944 | if (IS_ERR(pgio->pg_lseg)) { |
904 | pgio->pg_error = PTR_ERR(pgio->pg_lseg); | 945 | pgio->pg_error = PTR_ERR(pgio->pg_lseg); |
905 | pgio->pg_lseg = NULL; | 946 | pgio->pg_lseg = NULL; |
@@ -919,13 +960,13 @@ filelayout_pg_init_write(struct nfs_pageio_descriptor *pgio, | |||
919 | int status; | 960 | int status; |
920 | 961 | ||
921 | if (!pgio->pg_lseg) { | 962 | if (!pgio->pg_lseg) { |
922 | pgio->pg_lseg = pnfs_update_layout(pgio->pg_inode, | 963 | pgio->pg_lseg = fl_pnfs_update_layout(pgio->pg_inode, |
923 | req->wb_context, | 964 | req->wb_context, |
924 | 0, | 965 | 0, |
925 | NFS4_MAX_UINT64, | 966 | NFS4_MAX_UINT64, |
926 | IOMODE_RW, | 967 | IOMODE_RW, |
927 | false, | 968 | false, |
928 | GFP_NOFS); | 969 | GFP_NOFS); |
929 | if (IS_ERR(pgio->pg_lseg)) { | 970 | if (IS_ERR(pgio->pg_lseg)) { |
930 | pgio->pg_error = PTR_ERR(pgio->pg_lseg); | 971 | pgio->pg_error = PTR_ERR(pgio->pg_lseg); |
931 | pgio->pg_lseg = NULL; | 972 | pgio->pg_lseg = NULL; |
diff --git a/fs/nfs/filelayout/filelayout.h b/fs/nfs/filelayout/filelayout.h index 2896cb833a11..79323b5dab0c 100644 --- a/fs/nfs/filelayout/filelayout.h +++ b/fs/nfs/filelayout/filelayout.h | |||
@@ -55,15 +55,16 @@ struct nfs4_file_layout_dsaddr { | |||
55 | }; | 55 | }; |
56 | 56 | ||
57 | struct nfs4_filelayout_segment { | 57 | struct nfs4_filelayout_segment { |
58 | struct pnfs_layout_segment generic_hdr; | 58 | struct pnfs_layout_segment generic_hdr; |
59 | u32 stripe_type; | 59 | u32 stripe_type; |
60 | u32 commit_through_mds; | 60 | u32 commit_through_mds; |
61 | u32 stripe_unit; | 61 | u32 stripe_unit; |
62 | u32 first_stripe_index; | 62 | u32 first_stripe_index; |
63 | u64 pattern_offset; | 63 | u64 pattern_offset; |
64 | struct nfs4_file_layout_dsaddr *dsaddr; /* Point to GETDEVINFO data */ | 64 | struct nfs4_deviceid deviceid; |
65 | unsigned int num_fh; | 65 | struct nfs4_file_layout_dsaddr *dsaddr; /* Point to GETDEVINFO data */ |
66 | struct nfs_fh **fh_array; | 66 | unsigned int num_fh; |
67 | struct nfs_fh **fh_array; | ||
67 | }; | 68 | }; |
68 | 69 | ||
69 | struct nfs4_filelayout { | 70 | struct nfs4_filelayout { |
diff --git a/fs/nfs/flexfilelayout/flexfilelayoutdev.c b/fs/nfs/flexfilelayout/flexfilelayoutdev.c index 85fde93dff77..457cfeb1d5c1 100644 --- a/fs/nfs/flexfilelayout/flexfilelayoutdev.c +++ b/fs/nfs/flexfilelayout/flexfilelayoutdev.c | |||
@@ -208,6 +208,10 @@ static bool ff_layout_mirror_valid(struct pnfs_layout_segment *lseg, | |||
208 | } else | 208 | } else |
209 | goto outerr; | 209 | goto outerr; |
210 | } | 210 | } |
211 | |||
212 | if (IS_ERR(mirror->mirror_ds)) | ||
213 | goto outerr; | ||
214 | |||
211 | if (mirror->mirror_ds->ds == NULL) { | 215 | if (mirror->mirror_ds->ds == NULL) { |
212 | struct nfs4_deviceid_node *devid; | 216 | struct nfs4_deviceid_node *devid; |
213 | devid = &mirror->mirror_ds->id_node; | 217 | devid = &mirror->mirror_ds->id_node; |
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index c780d98035cc..201ca3f2c4ba 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c | |||
@@ -2442,17 +2442,14 @@ static void nfs41_check_delegation_stateid(struct nfs4_state *state) | |||
2442 | } | 2442 | } |
2443 | 2443 | ||
2444 | nfs4_stateid_copy(&stateid, &delegation->stateid); | 2444 | nfs4_stateid_copy(&stateid, &delegation->stateid); |
2445 | if (test_bit(NFS_DELEGATION_REVOKED, &delegation->flags)) { | 2445 | if (test_bit(NFS_DELEGATION_REVOKED, &delegation->flags) || |
2446 | !test_and_clear_bit(NFS_DELEGATION_TEST_EXPIRED, | ||
2447 | &delegation->flags)) { | ||
2446 | rcu_read_unlock(); | 2448 | rcu_read_unlock(); |
2447 | nfs_finish_clear_delegation_stateid(state, &stateid); | 2449 | nfs_finish_clear_delegation_stateid(state, &stateid); |
2448 | return; | 2450 | return; |
2449 | } | 2451 | } |
2450 | 2452 | ||
2451 | if (!test_and_clear_bit(NFS_DELEGATION_TEST_EXPIRED, &delegation->flags)) { | ||
2452 | rcu_read_unlock(); | ||
2453 | return; | ||
2454 | } | ||
2455 | |||
2456 | cred = get_rpccred(delegation->cred); | 2453 | cred = get_rpccred(delegation->cred); |
2457 | rcu_read_unlock(); | 2454 | rcu_read_unlock(); |
2458 | status = nfs41_test_and_free_expired_stateid(server, &stateid, cred); | 2455 | status = nfs41_test_and_free_expired_stateid(server, &stateid, cred); |
diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c index cbeeda1e94a2..d86031b6ad79 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c | |||
@@ -2489,7 +2489,7 @@ bool nfsd4_spo_must_allow(struct svc_rqst *rqstp) | |||
2489 | 2489 | ||
2490 | int nfsd4_max_reply(struct svc_rqst *rqstp, struct nfsd4_op *op) | 2490 | int nfsd4_max_reply(struct svc_rqst *rqstp, struct nfsd4_op *op) |
2491 | { | 2491 | { |
2492 | if (op->opnum == OP_ILLEGAL) | 2492 | if (op->opnum == OP_ILLEGAL || op->status == nfserr_notsupp) |
2493 | return op_encode_hdr_size * sizeof(__be32); | 2493 | return op_encode_hdr_size * sizeof(__be32); |
2494 | 2494 | ||
2495 | BUG_ON(OPDESC(op)->op_rsize_bop == NULL); | 2495 | BUG_ON(OPDESC(op)->op_rsize_bop == NULL); |
diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c index 73e75ac90525..8bf8f667a8cf 100644 --- a/fs/nfsd/nfsctl.c +++ b/fs/nfsd/nfsctl.c | |||
@@ -538,13 +538,21 @@ out_free: | |||
538 | 538 | ||
539 | static ssize_t | 539 | static ssize_t |
540 | nfsd_print_version_support(char *buf, int remaining, const char *sep, | 540 | nfsd_print_version_support(char *buf, int remaining, const char *sep, |
541 | unsigned vers, unsigned minor) | 541 | unsigned vers, int minor) |
542 | { | 542 | { |
543 | const char *format = (minor == 0) ? "%s%c%u" : "%s%c%u.%u"; | 543 | const char *format = minor < 0 ? "%s%c%u" : "%s%c%u.%u"; |
544 | bool supported = !!nfsd_vers(vers, NFSD_TEST); | 544 | bool supported = !!nfsd_vers(vers, NFSD_TEST); |
545 | 545 | ||
546 | if (vers == 4 && !nfsd_minorversion(minor, NFSD_TEST)) | 546 | if (vers == 4 && minor >= 0 && |
547 | !nfsd_minorversion(minor, NFSD_TEST)) | ||
547 | supported = false; | 548 | supported = false; |
549 | if (minor == 0 && supported) | ||
550 | /* | ||
551 | * special case for backward compatability. | ||
552 | * +4.0 is never reported, it is implied by | ||
553 | * +4, unless -4.0 is present. | ||
554 | */ | ||
555 | return 0; | ||
548 | return snprintf(buf, remaining, format, sep, | 556 | return snprintf(buf, remaining, format, sep, |
549 | supported ? '+' : '-', vers, minor); | 557 | supported ? '+' : '-', vers, minor); |
550 | } | 558 | } |
@@ -554,7 +562,6 @@ static ssize_t __write_versions(struct file *file, char *buf, size_t size) | |||
554 | char *mesg = buf; | 562 | char *mesg = buf; |
555 | char *vers, *minorp, sign; | 563 | char *vers, *minorp, sign; |
556 | int len, num, remaining; | 564 | int len, num, remaining; |
557 | unsigned minor; | ||
558 | ssize_t tlen = 0; | 565 | ssize_t tlen = 0; |
559 | char *sep; | 566 | char *sep; |
560 | struct nfsd_net *nn = net_generic(netns(file), nfsd_net_id); | 567 | struct nfsd_net *nn = net_generic(netns(file), nfsd_net_id); |
@@ -575,6 +582,7 @@ static ssize_t __write_versions(struct file *file, char *buf, size_t size) | |||
575 | if (len <= 0) return -EINVAL; | 582 | if (len <= 0) return -EINVAL; |
576 | do { | 583 | do { |
577 | enum vers_op cmd; | 584 | enum vers_op cmd; |
585 | unsigned minor; | ||
578 | sign = *vers; | 586 | sign = *vers; |
579 | if (sign == '+' || sign == '-') | 587 | if (sign == '+' || sign == '-') |
580 | num = simple_strtol((vers+1), &minorp, 0); | 588 | num = simple_strtol((vers+1), &minorp, 0); |
@@ -585,8 +593,8 @@ static ssize_t __write_versions(struct file *file, char *buf, size_t size) | |||
585 | return -EINVAL; | 593 | return -EINVAL; |
586 | if (kstrtouint(minorp+1, 0, &minor) < 0) | 594 | if (kstrtouint(minorp+1, 0, &minor) < 0) |
587 | return -EINVAL; | 595 | return -EINVAL; |
588 | } else | 596 | } |
589 | minor = 0; | 597 | |
590 | cmd = sign == '-' ? NFSD_CLEAR : NFSD_SET; | 598 | cmd = sign == '-' ? NFSD_CLEAR : NFSD_SET; |
591 | switch(num) { | 599 | switch(num) { |
592 | case 2: | 600 | case 2: |
@@ -594,8 +602,20 @@ static ssize_t __write_versions(struct file *file, char *buf, size_t size) | |||
594 | nfsd_vers(num, cmd); | 602 | nfsd_vers(num, cmd); |
595 | break; | 603 | break; |
596 | case 4: | 604 | case 4: |
597 | if (nfsd_minorversion(minor, cmd) >= 0) | 605 | if (*minorp == '.') { |
598 | break; | 606 | if (nfsd_minorversion(minor, cmd) < 0) |
607 | return -EINVAL; | ||
608 | } else if ((cmd == NFSD_SET) != nfsd_vers(num, NFSD_TEST)) { | ||
609 | /* | ||
610 | * Either we have +4 and no minors are enabled, | ||
611 | * or we have -4 and at least one minor is enabled. | ||
612 | * In either case, propagate 'cmd' to all minors. | ||
613 | */ | ||
614 | minor = 0; | ||
615 | while (nfsd_minorversion(minor, cmd) >= 0) | ||
616 | minor++; | ||
617 | } | ||
618 | break; | ||
599 | default: | 619 | default: |
600 | return -EINVAL; | 620 | return -EINVAL; |
601 | } | 621 | } |
@@ -612,9 +632,11 @@ static ssize_t __write_versions(struct file *file, char *buf, size_t size) | |||
612 | sep = ""; | 632 | sep = ""; |
613 | remaining = SIMPLE_TRANSACTION_LIMIT; | 633 | remaining = SIMPLE_TRANSACTION_LIMIT; |
614 | for (num=2 ; num <= 4 ; num++) { | 634 | for (num=2 ; num <= 4 ; num++) { |
635 | int minor; | ||
615 | if (!nfsd_vers(num, NFSD_AVAIL)) | 636 | if (!nfsd_vers(num, NFSD_AVAIL)) |
616 | continue; | 637 | continue; |
617 | minor = 0; | 638 | |
639 | minor = -1; | ||
618 | do { | 640 | do { |
619 | len = nfsd_print_version_support(buf, remaining, | 641 | len = nfsd_print_version_support(buf, remaining, |
620 | sep, num, minor); | 642 | sep, num, minor); |
@@ -624,7 +646,8 @@ static ssize_t __write_versions(struct file *file, char *buf, size_t size) | |||
624 | buf += len; | 646 | buf += len; |
625 | tlen += len; | 647 | tlen += len; |
626 | minor++; | 648 | minor++; |
627 | sep = " "; | 649 | if (len) |
650 | sep = " "; | ||
628 | } while (num == 4 && minor <= NFSD_SUPPORTED_MINOR_VERSION); | 651 | } while (num == 4 && minor <= NFSD_SUPPORTED_MINOR_VERSION); |
629 | } | 652 | } |
630 | out: | 653 | out: |
diff --git a/fs/nfsd/nfsproc.c b/fs/nfsd/nfsproc.c index fa82b7707e85..03a7e9da4da0 100644 --- a/fs/nfsd/nfsproc.c +++ b/fs/nfsd/nfsproc.c | |||
@@ -786,6 +786,7 @@ nfserrno (int errno) | |||
786 | { nfserr_serverfault, -ESERVERFAULT }, | 786 | { nfserr_serverfault, -ESERVERFAULT }, |
787 | { nfserr_serverfault, -ENFILE }, | 787 | { nfserr_serverfault, -ENFILE }, |
788 | { nfserr_io, -EUCLEAN }, | 788 | { nfserr_io, -EUCLEAN }, |
789 | { nfserr_perm, -ENOKEY }, | ||
789 | }; | 790 | }; |
790 | int i; | 791 | int i; |
791 | 792 | ||
diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c index 786a4a2cb2d7..31e1f9593457 100644 --- a/fs/nfsd/nfssvc.c +++ b/fs/nfsd/nfssvc.c | |||
@@ -167,7 +167,8 @@ nfsd_adjust_nfsd_versions4(void) | |||
167 | 167 | ||
168 | int nfsd_minorversion(u32 minorversion, enum vers_op change) | 168 | int nfsd_minorversion(u32 minorversion, enum vers_op change) |
169 | { | 169 | { |
170 | if (minorversion > NFSD_SUPPORTED_MINOR_VERSION) | 170 | if (minorversion > NFSD_SUPPORTED_MINOR_VERSION && |
171 | change != NFSD_AVAIL) | ||
171 | return -1; | 172 | return -1; |
172 | switch(change) { | 173 | switch(change) { |
173 | case NFSD_SET: | 174 | case NFSD_SET: |
@@ -415,23 +416,20 @@ static void nfsd_last_thread(struct svc_serv *serv, struct net *net) | |||
415 | 416 | ||
416 | void nfsd_reset_versions(void) | 417 | void nfsd_reset_versions(void) |
417 | { | 418 | { |
418 | int found_one = 0; | ||
419 | int i; | 419 | int i; |
420 | 420 | ||
421 | for (i = NFSD_MINVERS; i < NFSD_NRVERS; i++) { | 421 | for (i = 0; i < NFSD_NRVERS; i++) |
422 | if (nfsd_program.pg_vers[i]) | 422 | if (nfsd_vers(i, NFSD_TEST)) |
423 | found_one = 1; | 423 | return; |
424 | } | ||
425 | 424 | ||
426 | if (!found_one) { | 425 | for (i = 0; i < NFSD_NRVERS; i++) |
427 | for (i = NFSD_MINVERS; i < NFSD_NRVERS; i++) | 426 | if (i != 4) |
428 | nfsd_program.pg_vers[i] = nfsd_version[i]; | 427 | nfsd_vers(i, NFSD_SET); |
429 | #if defined(CONFIG_NFSD_V2_ACL) || defined(CONFIG_NFSD_V3_ACL) | 428 | else { |
430 | for (i = NFSD_ACL_MINVERS; i < NFSD_ACL_NRVERS; i++) | 429 | int minor = 0; |
431 | nfsd_acl_program.pg_vers[i] = | 430 | while (nfsd_minorversion(minor, NFSD_SET) >= 0) |
432 | nfsd_acl_version[i]; | 431 | minor++; |
433 | #endif | 432 | } |
434 | } | ||
435 | } | 433 | } |
436 | 434 | ||
437 | /* | 435 | /* |
@@ -91,6 +91,7 @@ slow: | |||
91 | return ERR_PTR(-ENOMEM); | 91 | return ERR_PTR(-ENOMEM); |
92 | } | 92 | } |
93 | d_instantiate(dentry, inode); | 93 | d_instantiate(dentry, inode); |
94 | dentry->d_flags |= DCACHE_RCUACCESS; | ||
94 | dentry->d_fsdata = (void *)ns->ops; | 95 | dentry->d_fsdata = (void *)ns->ops; |
95 | d = atomic_long_cmpxchg(&ns->stashed, 0, (unsigned long)dentry); | 96 | d = atomic_long_cmpxchg(&ns->stashed, 0, (unsigned long)dentry); |
96 | if (d) { | 97 | if (d) { |
diff --git a/fs/orangefs/devorangefs-req.c b/fs/orangefs/devorangefs-req.c index c4ab6fdf17a0..e1534c9bab16 100644 --- a/fs/orangefs/devorangefs-req.c +++ b/fs/orangefs/devorangefs-req.c | |||
@@ -208,14 +208,19 @@ restart: | |||
208 | continue; | 208 | continue; |
209 | /* | 209 | /* |
210 | * Skip ops whose filesystem we don't know about unless | 210 | * Skip ops whose filesystem we don't know about unless |
211 | * it is being mounted. | 211 | * it is being mounted or unmounted. It is possible for |
212 | * a filesystem we don't know about to be unmounted if | ||
213 | * it fails to mount in the kernel after userspace has | ||
214 | * been sent the mount request. | ||
212 | */ | 215 | */ |
213 | /* XXX: is there a better way to detect this? */ | 216 | /* XXX: is there a better way to detect this? */ |
214 | } else if (ret == -1 && | 217 | } else if (ret == -1 && |
215 | !(op->upcall.type == | 218 | !(op->upcall.type == |
216 | ORANGEFS_VFS_OP_FS_MOUNT || | 219 | ORANGEFS_VFS_OP_FS_MOUNT || |
217 | op->upcall.type == | 220 | op->upcall.type == |
218 | ORANGEFS_VFS_OP_GETATTR)) { | 221 | ORANGEFS_VFS_OP_GETATTR || |
222 | op->upcall.type == | ||
223 | ORANGEFS_VFS_OP_FS_UMOUNT)) { | ||
219 | gossip_debug(GOSSIP_DEV_DEBUG, | 224 | gossip_debug(GOSSIP_DEV_DEBUG, |
220 | "orangefs: skipping op tag %llu %s\n", | 225 | "orangefs: skipping op tag %llu %s\n", |
221 | llu(op->tag), get_opname_string(op)); | 226 | llu(op->tag), get_opname_string(op)); |
diff --git a/fs/orangefs/orangefs-kernel.h b/fs/orangefs/orangefs-kernel.h index 5e48a0be9761..8afac46fcc87 100644 --- a/fs/orangefs/orangefs-kernel.h +++ b/fs/orangefs/orangefs-kernel.h | |||
@@ -249,6 +249,7 @@ struct orangefs_sb_info_s { | |||
249 | char devname[ORANGEFS_MAX_SERVER_ADDR_LEN]; | 249 | char devname[ORANGEFS_MAX_SERVER_ADDR_LEN]; |
250 | struct super_block *sb; | 250 | struct super_block *sb; |
251 | int mount_pending; | 251 | int mount_pending; |
252 | int no_list; | ||
252 | struct list_head list; | 253 | struct list_head list; |
253 | }; | 254 | }; |
254 | 255 | ||
diff --git a/fs/orangefs/super.c b/fs/orangefs/super.c index 67c24351a67f..629d8c917fa6 100644 --- a/fs/orangefs/super.c +++ b/fs/orangefs/super.c | |||
@@ -263,8 +263,13 @@ int orangefs_remount(struct orangefs_sb_info_s *orangefs_sb) | |||
263 | if (!new_op) | 263 | if (!new_op) |
264 | return -ENOMEM; | 264 | return -ENOMEM; |
265 | new_op->upcall.req.features.features = 0; | 265 | new_op->upcall.req.features.features = 0; |
266 | ret = service_operation(new_op, "orangefs_features", 0); | 266 | ret = service_operation(new_op, "orangefs_features", |
267 | orangefs_features = new_op->downcall.resp.features.features; | 267 | ORANGEFS_OP_PRIORITY | ORANGEFS_OP_NO_MUTEX); |
268 | if (!ret) | ||
269 | orangefs_features = | ||
270 | new_op->downcall.resp.features.features; | ||
271 | else | ||
272 | orangefs_features = 0; | ||
268 | op_release(new_op); | 273 | op_release(new_op); |
269 | } else { | 274 | } else { |
270 | orangefs_features = 0; | 275 | orangefs_features = 0; |
@@ -488,7 +493,7 @@ struct dentry *orangefs_mount(struct file_system_type *fst, | |||
488 | 493 | ||
489 | if (ret) { | 494 | if (ret) { |
490 | d = ERR_PTR(ret); | 495 | d = ERR_PTR(ret); |
491 | goto free_op; | 496 | goto free_sb_and_op; |
492 | } | 497 | } |
493 | 498 | ||
494 | /* | 499 | /* |
@@ -514,6 +519,9 @@ struct dentry *orangefs_mount(struct file_system_type *fst, | |||
514 | spin_unlock(&orangefs_superblocks_lock); | 519 | spin_unlock(&orangefs_superblocks_lock); |
515 | op_release(new_op); | 520 | op_release(new_op); |
516 | 521 | ||
522 | /* Must be removed from the list now. */ | ||
523 | ORANGEFS_SB(sb)->no_list = 0; | ||
524 | |||
517 | if (orangefs_userspace_version >= 20906) { | 525 | if (orangefs_userspace_version >= 20906) { |
518 | new_op = op_alloc(ORANGEFS_VFS_OP_FEATURES); | 526 | new_op = op_alloc(ORANGEFS_VFS_OP_FEATURES); |
519 | if (!new_op) | 527 | if (!new_op) |
@@ -528,6 +536,10 @@ struct dentry *orangefs_mount(struct file_system_type *fst, | |||
528 | 536 | ||
529 | return dget(sb->s_root); | 537 | return dget(sb->s_root); |
530 | 538 | ||
539 | free_sb_and_op: | ||
540 | /* Will call orangefs_kill_sb with sb not in list. */ | ||
541 | ORANGEFS_SB(sb)->no_list = 1; | ||
542 | deactivate_locked_super(sb); | ||
531 | free_op: | 543 | free_op: |
532 | gossip_err("orangefs_mount: mount request failed with %d\n", ret); | 544 | gossip_err("orangefs_mount: mount request failed with %d\n", ret); |
533 | if (ret == -EINVAL) { | 545 | if (ret == -EINVAL) { |
@@ -553,12 +565,14 @@ void orangefs_kill_sb(struct super_block *sb) | |||
553 | */ | 565 | */ |
554 | orangefs_unmount_sb(sb); | 566 | orangefs_unmount_sb(sb); |
555 | 567 | ||
556 | /* remove the sb from our list of orangefs specific sb's */ | 568 | if (!ORANGEFS_SB(sb)->no_list) { |
557 | 569 | /* remove the sb from our list of orangefs specific sb's */ | |
558 | spin_lock(&orangefs_superblocks_lock); | 570 | spin_lock(&orangefs_superblocks_lock); |
559 | __list_del_entry(&ORANGEFS_SB(sb)->list); /* not list_del_init */ | 571 | /* not list_del_init */ |
560 | ORANGEFS_SB(sb)->list.prev = NULL; | 572 | __list_del_entry(&ORANGEFS_SB(sb)->list); |
561 | spin_unlock(&orangefs_superblocks_lock); | 573 | ORANGEFS_SB(sb)->list.prev = NULL; |
574 | spin_unlock(&orangefs_superblocks_lock); | ||
575 | } | ||
562 | 576 | ||
563 | /* | 577 | /* |
564 | * make sure that ORANGEFS_DEV_REMOUNT_ALL loop that might've seen us | 578 | * make sure that ORANGEFS_DEV_REMOUNT_ALL loop that might've seen us |
diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c index 8f91ec66baa3..d04ea4349909 100644 --- a/fs/proc/proc_sysctl.c +++ b/fs/proc/proc_sysctl.c | |||
@@ -1074,6 +1074,7 @@ static int sysctl_check_table(const char *path, struct ctl_table *table) | |||
1074 | 1074 | ||
1075 | if ((table->proc_handler == proc_dostring) || | 1075 | if ((table->proc_handler == proc_dostring) || |
1076 | (table->proc_handler == proc_dointvec) || | 1076 | (table->proc_handler == proc_dointvec) || |
1077 | (table->proc_handler == proc_douintvec) || | ||
1077 | (table->proc_handler == proc_dointvec_minmax) || | 1078 | (table->proc_handler == proc_dointvec_minmax) || |
1078 | (table->proc_handler == proc_dointvec_jiffies) || | 1079 | (table->proc_handler == proc_dointvec_jiffies) || |
1079 | (table->proc_handler == proc_dointvec_userhz_jiffies) || | 1080 | (table->proc_handler == proc_dointvec_userhz_jiffies) || |
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index f08bd31c1081..312578089544 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c | |||
@@ -900,7 +900,14 @@ static inline void clear_soft_dirty(struct vm_area_struct *vma, | |||
900 | static inline void clear_soft_dirty_pmd(struct vm_area_struct *vma, | 900 | static inline void clear_soft_dirty_pmd(struct vm_area_struct *vma, |
901 | unsigned long addr, pmd_t *pmdp) | 901 | unsigned long addr, pmd_t *pmdp) |
902 | { | 902 | { |
903 | pmd_t pmd = pmdp_huge_get_and_clear(vma->vm_mm, addr, pmdp); | 903 | pmd_t pmd = *pmdp; |
904 | |||
905 | /* See comment in change_huge_pmd() */ | ||
906 | pmdp_invalidate(vma, addr, pmdp); | ||
907 | if (pmd_dirty(*pmdp)) | ||
908 | pmd = pmd_mkdirty(pmd); | ||
909 | if (pmd_young(*pmdp)) | ||
910 | pmd = pmd_mkyoung(pmd); | ||
904 | 911 | ||
905 | pmd = pmd_wrprotect(pmd); | 912 | pmd = pmd_wrprotect(pmd); |
906 | pmd = pmd_clear_soft_dirty(pmd); | 913 | pmd = pmd_clear_soft_dirty(pmd); |
@@ -130,9 +130,13 @@ EXPORT_SYMBOL(vfs_getattr); | |||
130 | int vfs_statx_fd(unsigned int fd, struct kstat *stat, | 130 | int vfs_statx_fd(unsigned int fd, struct kstat *stat, |
131 | u32 request_mask, unsigned int query_flags) | 131 | u32 request_mask, unsigned int query_flags) |
132 | { | 132 | { |
133 | struct fd f = fdget_raw(fd); | 133 | struct fd f; |
134 | int error = -EBADF; | 134 | int error = -EBADF; |
135 | 135 | ||
136 | if (query_flags & ~KSTAT_QUERY_FLAGS) | ||
137 | return -EINVAL; | ||
138 | |||
139 | f = fdget_raw(fd); | ||
136 | if (f.file) { | 140 | if (f.file) { |
137 | error = vfs_getattr(&f.file->f_path, stat, | 141 | error = vfs_getattr(&f.file->f_path, stat, |
138 | request_mask, query_flags); | 142 | request_mask, query_flags); |
@@ -155,9 +159,6 @@ EXPORT_SYMBOL(vfs_statx_fd); | |||
155 | * Additionally, the use of AT_SYMLINK_NOFOLLOW in flags will prevent a symlink | 159 | * Additionally, the use of AT_SYMLINK_NOFOLLOW in flags will prevent a symlink |
156 | * at the given name from being referenced. | 160 | * at the given name from being referenced. |
157 | * | 161 | * |
158 | * The caller must have preset stat->request_mask as for vfs_getattr(). The | ||
159 | * flags are also used to load up stat->query_flags. | ||
160 | * | ||
161 | * 0 will be returned on success, and a -ve error code if unsuccessful. | 162 | * 0 will be returned on success, and a -ve error code if unsuccessful. |
162 | */ | 163 | */ |
163 | int vfs_statx(int dfd, const char __user *filename, int flags, | 164 | int vfs_statx(int dfd, const char __user *filename, int flags, |
@@ -509,46 +510,38 @@ SYSCALL_DEFINE4(fstatat64, int, dfd, const char __user *, filename, | |||
509 | } | 510 | } |
510 | #endif /* __ARCH_WANT_STAT64 || __ARCH_WANT_COMPAT_STAT64 */ | 511 | #endif /* __ARCH_WANT_STAT64 || __ARCH_WANT_COMPAT_STAT64 */ |
511 | 512 | ||
512 | static inline int __put_timestamp(struct timespec *kts, | 513 | static noinline_for_stack int |
513 | struct statx_timestamp __user *uts) | 514 | cp_statx(const struct kstat *stat, struct statx __user *buffer) |
514 | { | ||
515 | return (__put_user(kts->tv_sec, &uts->tv_sec ) || | ||
516 | __put_user(kts->tv_nsec, &uts->tv_nsec ) || | ||
517 | __put_user(0, &uts->__reserved )); | ||
518 | } | ||
519 | |||
520 | /* | ||
521 | * Set the statx results. | ||
522 | */ | ||
523 | static long statx_set_result(struct kstat *stat, struct statx __user *buffer) | ||
524 | { | 515 | { |
525 | uid_t uid = from_kuid_munged(current_user_ns(), stat->uid); | 516 | struct statx tmp; |
526 | gid_t gid = from_kgid_munged(current_user_ns(), stat->gid); | 517 | |
527 | 518 | memset(&tmp, 0, sizeof(tmp)); | |
528 | if (__put_user(stat->result_mask, &buffer->stx_mask ) || | 519 | |
529 | __put_user(stat->mode, &buffer->stx_mode ) || | 520 | tmp.stx_mask = stat->result_mask; |
530 | __clear_user(&buffer->__spare0, sizeof(buffer->__spare0)) || | 521 | tmp.stx_blksize = stat->blksize; |
531 | __put_user(stat->nlink, &buffer->stx_nlink ) || | 522 | tmp.stx_attributes = stat->attributes; |
532 | __put_user(uid, &buffer->stx_uid ) || | 523 | tmp.stx_nlink = stat->nlink; |
533 | __put_user(gid, &buffer->stx_gid ) || | 524 | tmp.stx_uid = from_kuid_munged(current_user_ns(), stat->uid); |
534 | __put_user(stat->attributes, &buffer->stx_attributes ) || | 525 | tmp.stx_gid = from_kgid_munged(current_user_ns(), stat->gid); |
535 | __put_user(stat->blksize, &buffer->stx_blksize ) || | 526 | tmp.stx_mode = stat->mode; |
536 | __put_user(MAJOR(stat->rdev), &buffer->stx_rdev_major ) || | 527 | tmp.stx_ino = stat->ino; |
537 | __put_user(MINOR(stat->rdev), &buffer->stx_rdev_minor ) || | 528 | tmp.stx_size = stat->size; |
538 | __put_user(MAJOR(stat->dev), &buffer->stx_dev_major ) || | 529 | tmp.stx_blocks = stat->blocks; |
539 | __put_user(MINOR(stat->dev), &buffer->stx_dev_minor ) || | 530 | tmp.stx_attributes_mask = stat->attributes_mask; |
540 | __put_timestamp(&stat->atime, &buffer->stx_atime ) || | 531 | tmp.stx_atime.tv_sec = stat->atime.tv_sec; |
541 | __put_timestamp(&stat->btime, &buffer->stx_btime ) || | 532 | tmp.stx_atime.tv_nsec = stat->atime.tv_nsec; |
542 | __put_timestamp(&stat->ctime, &buffer->stx_ctime ) || | 533 | tmp.stx_btime.tv_sec = stat->btime.tv_sec; |
543 | __put_timestamp(&stat->mtime, &buffer->stx_mtime ) || | 534 | tmp.stx_btime.tv_nsec = stat->btime.tv_nsec; |
544 | __put_user(stat->ino, &buffer->stx_ino ) || | 535 | tmp.stx_ctime.tv_sec = stat->ctime.tv_sec; |
545 | __put_user(stat->size, &buffer->stx_size ) || | 536 | tmp.stx_ctime.tv_nsec = stat->ctime.tv_nsec; |
546 | __put_user(stat->blocks, &buffer->stx_blocks ) || | 537 | tmp.stx_mtime.tv_sec = stat->mtime.tv_sec; |
547 | __clear_user(&buffer->__spare1, sizeof(buffer->__spare1)) || | 538 | tmp.stx_mtime.tv_nsec = stat->mtime.tv_nsec; |
548 | __clear_user(&buffer->__spare2, sizeof(buffer->__spare2))) | 539 | tmp.stx_rdev_major = MAJOR(stat->rdev); |
549 | return -EFAULT; | 540 | tmp.stx_rdev_minor = MINOR(stat->rdev); |
550 | 541 | tmp.stx_dev_major = MAJOR(stat->dev); | |
551 | return 0; | 542 | tmp.stx_dev_minor = MINOR(stat->dev); |
543 | |||
544 | return copy_to_user(buffer, &tmp, sizeof(tmp)) ? -EFAULT : 0; | ||
552 | } | 545 | } |
553 | 546 | ||
554 | /** | 547 | /** |
@@ -570,10 +563,10 @@ SYSCALL_DEFINE5(statx, | |||
570 | struct kstat stat; | 563 | struct kstat stat; |
571 | int error; | 564 | int error; |
572 | 565 | ||
566 | if (mask & STATX__RESERVED) | ||
567 | return -EINVAL; | ||
573 | if ((flags & AT_STATX_SYNC_TYPE) == AT_STATX_SYNC_TYPE) | 568 | if ((flags & AT_STATX_SYNC_TYPE) == AT_STATX_SYNC_TYPE) |
574 | return -EINVAL; | 569 | return -EINVAL; |
575 | if (!access_ok(VERIFY_WRITE, buffer, sizeof(*buffer))) | ||
576 | return -EFAULT; | ||
577 | 570 | ||
578 | if (filename) | 571 | if (filename) |
579 | error = vfs_statx(dfd, filename, flags, &stat, mask); | 572 | error = vfs_statx(dfd, filename, flags, &stat, mask); |
@@ -581,7 +574,8 @@ SYSCALL_DEFINE5(statx, | |||
581 | error = vfs_statx_fd(dfd, &stat, mask, flags); | 574 | error = vfs_statx_fd(dfd, &stat, mask, flags); |
582 | if (error) | 575 | if (error) |
583 | return error; | 576 | return error; |
584 | return statx_set_result(&stat, buffer); | 577 | |
578 | return cp_statx(&stat, buffer); | ||
585 | } | 579 | } |
586 | 580 | ||
587 | /* Caller is here responsible for sufficient locking (ie. inode->i_lock) */ | 581 | /* Caller is here responsible for sufficient locking (ie. inode->i_lock) */ |
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c index b803213d1307..39c75a86c67f 100644 --- a/fs/sysfs/file.c +++ b/fs/sysfs/file.c | |||
@@ -108,7 +108,7 @@ static ssize_t sysfs_kf_read(struct kernfs_open_file *of, char *buf, | |||
108 | { | 108 | { |
109 | const struct sysfs_ops *ops = sysfs_file_ops(of->kn); | 109 | const struct sysfs_ops *ops = sysfs_file_ops(of->kn); |
110 | struct kobject *kobj = of->kn->parent->priv; | 110 | struct kobject *kobj = of->kn->parent->priv; |
111 | size_t len; | 111 | ssize_t len; |
112 | 112 | ||
113 | /* | 113 | /* |
114 | * If buf != of->prealloc_buf, we don't know how | 114 | * If buf != of->prealloc_buf, we don't know how |
@@ -117,13 +117,15 @@ static ssize_t sysfs_kf_read(struct kernfs_open_file *of, char *buf, | |||
117 | if (WARN_ON_ONCE(buf != of->prealloc_buf)) | 117 | if (WARN_ON_ONCE(buf != of->prealloc_buf)) |
118 | return 0; | 118 | return 0; |
119 | len = ops->show(kobj, of->kn->priv, buf); | 119 | len = ops->show(kobj, of->kn->priv, buf); |
120 | if (len < 0) | ||
121 | return len; | ||
120 | if (pos) { | 122 | if (pos) { |
121 | if (len <= pos) | 123 | if (len <= pos) |
122 | return 0; | 124 | return 0; |
123 | len -= pos; | 125 | len -= pos; |
124 | memmove(buf, buf + pos, len); | 126 | memmove(buf, buf + pos, len); |
125 | } | 127 | } |
126 | return min(count, len); | 128 | return min_t(ssize_t, count, len); |
127 | } | 129 | } |
128 | 130 | ||
129 | /* kernfs write callback for regular sysfs files */ | 131 | /* kernfs write callback for regular sysfs files */ |
diff --git a/fs/ubifs/debug.c b/fs/ubifs/debug.c index 1e712a364680..718b749fa11a 100644 --- a/fs/ubifs/debug.c +++ b/fs/ubifs/debug.c | |||
@@ -32,6 +32,7 @@ | |||
32 | #include <linux/math64.h> | 32 | #include <linux/math64.h> |
33 | #include <linux/uaccess.h> | 33 | #include <linux/uaccess.h> |
34 | #include <linux/random.h> | 34 | #include <linux/random.h> |
35 | #include <linux/ctype.h> | ||
35 | #include "ubifs.h" | 36 | #include "ubifs.h" |
36 | 37 | ||
37 | static DEFINE_SPINLOCK(dbg_lock); | 38 | static DEFINE_SPINLOCK(dbg_lock); |
@@ -286,8 +287,10 @@ void ubifs_dump_inode(struct ubifs_info *c, const struct inode *inode) | |||
286 | break; | 287 | break; |
287 | } | 288 | } |
288 | 289 | ||
289 | pr_err("\t%d: %s (%s)\n", | 290 | pr_err("\t%d: inode %llu, type %s, len %d\n", |
290 | count++, dent->name, get_dent_type(dent->type)); | 291 | count++, (unsigned long long) le64_to_cpu(dent->inum), |
292 | get_dent_type(dent->type), | ||
293 | le16_to_cpu(dent->nlen)); | ||
291 | 294 | ||
292 | fname_name(&nm) = dent->name; | 295 | fname_name(&nm) = dent->name; |
293 | fname_len(&nm) = le16_to_cpu(dent->nlen); | 296 | fname_len(&nm) = le16_to_cpu(dent->nlen); |
@@ -464,7 +467,8 @@ void ubifs_dump_node(const struct ubifs_info *c, const void *node) | |||
464 | pr_err("(bad name length, not printing, bad or corrupted node)"); | 467 | pr_err("(bad name length, not printing, bad or corrupted node)"); |
465 | else { | 468 | else { |
466 | for (i = 0; i < nlen && dent->name[i]; i++) | 469 | for (i = 0; i < nlen && dent->name[i]; i++) |
467 | pr_cont("%c", dent->name[i]); | 470 | pr_cont("%c", isprint(dent->name[i]) ? |
471 | dent->name[i] : '?'); | ||
468 | } | 472 | } |
469 | pr_cont("\n"); | 473 | pr_cont("\n"); |
470 | 474 | ||
diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c index 30825d882aa9..b777bddaa1dd 100644 --- a/fs/ubifs/dir.c +++ b/fs/ubifs/dir.c | |||
@@ -606,8 +606,8 @@ static int ubifs_readdir(struct file *file, struct dir_context *ctx) | |||
606 | } | 606 | } |
607 | 607 | ||
608 | while (1) { | 608 | while (1) { |
609 | dbg_gen("feed '%s', ino %llu, new f_pos %#x", | 609 | dbg_gen("ino %llu, new f_pos %#x", |
610 | dent->name, (unsigned long long)le64_to_cpu(dent->inum), | 610 | (unsigned long long)le64_to_cpu(dent->inum), |
611 | key_hash_flash(c, &dent->key)); | 611 | key_hash_flash(c, &dent->key)); |
612 | ubifs_assert(le64_to_cpu(dent->ch.sqnum) > | 612 | ubifs_assert(le64_to_cpu(dent->ch.sqnum) > |
613 | ubifs_inode(dir)->creat_sqnum); | 613 | ubifs_inode(dir)->creat_sqnum); |
@@ -748,6 +748,11 @@ static int ubifs_link(struct dentry *old_dentry, struct inode *dir, | |||
748 | goto out_fname; | 748 | goto out_fname; |
749 | 749 | ||
750 | lock_2_inodes(dir, inode); | 750 | lock_2_inodes(dir, inode); |
751 | |||
752 | /* Handle O_TMPFILE corner case, it is allowed to link a O_TMPFILE. */ | ||
753 | if (inode->i_nlink == 0) | ||
754 | ubifs_delete_orphan(c, inode->i_ino); | ||
755 | |||
751 | inc_nlink(inode); | 756 | inc_nlink(inode); |
752 | ihold(inode); | 757 | ihold(inode); |
753 | inode->i_ctime = ubifs_current_time(inode); | 758 | inode->i_ctime = ubifs_current_time(inode); |
@@ -768,6 +773,8 @@ out_cancel: | |||
768 | dir->i_size -= sz_change; | 773 | dir->i_size -= sz_change; |
769 | dir_ui->ui_size = dir->i_size; | 774 | dir_ui->ui_size = dir->i_size; |
770 | drop_nlink(inode); | 775 | drop_nlink(inode); |
776 | if (inode->i_nlink == 0) | ||
777 | ubifs_add_orphan(c, inode->i_ino); | ||
771 | unlock_2_inodes(dir, inode); | 778 | unlock_2_inodes(dir, inode); |
772 | ubifs_release_budget(c, &req); | 779 | ubifs_release_budget(c, &req); |
773 | iput(inode); | 780 | iput(inode); |
@@ -1068,8 +1075,10 @@ static int ubifs_mknod(struct inode *dir, struct dentry *dentry, | |||
1068 | } | 1075 | } |
1069 | 1076 | ||
1070 | err = fscrypt_setup_filename(dir, &dentry->d_name, 0, &nm); | 1077 | err = fscrypt_setup_filename(dir, &dentry->d_name, 0, &nm); |
1071 | if (err) | 1078 | if (err) { |
1079 | kfree(dev); | ||
1072 | goto out_budg; | 1080 | goto out_budg; |
1081 | } | ||
1073 | 1082 | ||
1074 | sz_change = CALC_DENT_SIZE(fname_len(&nm)); | 1083 | sz_change = CALC_DENT_SIZE(fname_len(&nm)); |
1075 | 1084 | ||
@@ -1316,9 +1325,6 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
1316 | unsigned int uninitialized_var(saved_nlink); | 1325 | unsigned int uninitialized_var(saved_nlink); |
1317 | struct fscrypt_name old_nm, new_nm; | 1326 | struct fscrypt_name old_nm, new_nm; |
1318 | 1327 | ||
1319 | if (flags & ~RENAME_NOREPLACE) | ||
1320 | return -EINVAL; | ||
1321 | |||
1322 | /* | 1328 | /* |
1323 | * Budget request settings: deletion direntry, new direntry, removing | 1329 | * Budget request settings: deletion direntry, new direntry, removing |
1324 | * the old inode, and changing old and new parent directory inodes. | 1330 | * the old inode, and changing old and new parent directory inodes. |
diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c index 1d227b0fcf49..f7555fc25877 100644 --- a/fs/userfaultfd.c +++ b/fs/userfaultfd.c | |||
@@ -1756,7 +1756,7 @@ static void userfaultfd_show_fdinfo(struct seq_file *m, struct file *f) | |||
1756 | * protocols: aa:... bb:... | 1756 | * protocols: aa:... bb:... |
1757 | */ | 1757 | */ |
1758 | seq_printf(m, "pending:\t%lu\ntotal:\t%lu\nAPI:\t%Lx:%x:%Lx\n", | 1758 | seq_printf(m, "pending:\t%lu\ntotal:\t%lu\nAPI:\t%Lx:%x:%Lx\n", |
1759 | pending, total, UFFD_API, UFFD_API_FEATURES, | 1759 | pending, total, UFFD_API, ctx->features, |
1760 | UFFD_API_IOCTLS|UFFD_API_RANGE_IOCTLS); | 1760 | UFFD_API_IOCTLS|UFFD_API_RANGE_IOCTLS); |
1761 | } | 1761 | } |
1762 | #endif | 1762 | #endif |
diff --git a/fs/xfs/libxfs/xfs_dir2_priv.h b/fs/xfs/libxfs/xfs_dir2_priv.h index eb00bc133bca..39f8604f764e 100644 --- a/fs/xfs/libxfs/xfs_dir2_priv.h +++ b/fs/xfs/libxfs/xfs_dir2_priv.h | |||
@@ -125,8 +125,7 @@ extern int xfs_dir2_sf_create(struct xfs_da_args *args, xfs_ino_t pino); | |||
125 | extern int xfs_dir2_sf_lookup(struct xfs_da_args *args); | 125 | extern int xfs_dir2_sf_lookup(struct xfs_da_args *args); |
126 | extern int xfs_dir2_sf_removename(struct xfs_da_args *args); | 126 | extern int xfs_dir2_sf_removename(struct xfs_da_args *args); |
127 | extern int xfs_dir2_sf_replace(struct xfs_da_args *args); | 127 | extern int xfs_dir2_sf_replace(struct xfs_da_args *args); |
128 | extern int xfs_dir2_sf_verify(struct xfs_mount *mp, struct xfs_dir2_sf_hdr *sfp, | 128 | extern int xfs_dir2_sf_verify(struct xfs_inode *ip); |
129 | int size); | ||
130 | 129 | ||
131 | /* xfs_dir2_readdir.c */ | 130 | /* xfs_dir2_readdir.c */ |
132 | extern int xfs_readdir(struct xfs_inode *dp, struct dir_context *ctx, | 131 | extern int xfs_readdir(struct xfs_inode *dp, struct dir_context *ctx, |
diff --git a/fs/xfs/libxfs/xfs_dir2_sf.c b/fs/xfs/libxfs/xfs_dir2_sf.c index 96b45cd6c63f..e84af093b2ab 100644 --- a/fs/xfs/libxfs/xfs_dir2_sf.c +++ b/fs/xfs/libxfs/xfs_dir2_sf.c | |||
@@ -632,36 +632,49 @@ xfs_dir2_sf_check( | |||
632 | /* Verify the consistency of an inline directory. */ | 632 | /* Verify the consistency of an inline directory. */ |
633 | int | 633 | int |
634 | xfs_dir2_sf_verify( | 634 | xfs_dir2_sf_verify( |
635 | struct xfs_mount *mp, | 635 | struct xfs_inode *ip) |
636 | struct xfs_dir2_sf_hdr *sfp, | ||
637 | int size) | ||
638 | { | 636 | { |
637 | struct xfs_mount *mp = ip->i_mount; | ||
638 | struct xfs_dir2_sf_hdr *sfp; | ||
639 | struct xfs_dir2_sf_entry *sfep; | 639 | struct xfs_dir2_sf_entry *sfep; |
640 | struct xfs_dir2_sf_entry *next_sfep; | 640 | struct xfs_dir2_sf_entry *next_sfep; |
641 | char *endp; | 641 | char *endp; |
642 | const struct xfs_dir_ops *dops; | 642 | const struct xfs_dir_ops *dops; |
643 | struct xfs_ifork *ifp; | ||
643 | xfs_ino_t ino; | 644 | xfs_ino_t ino; |
644 | int i; | 645 | int i; |
645 | int i8count; | 646 | int i8count; |
646 | int offset; | 647 | int offset; |
648 | int size; | ||
649 | int error; | ||
647 | __uint8_t filetype; | 650 | __uint8_t filetype; |
648 | 651 | ||
652 | ASSERT(ip->i_d.di_format == XFS_DINODE_FMT_LOCAL); | ||
653 | /* | ||
654 | * xfs_iread calls us before xfs_setup_inode sets up ip->d_ops, | ||
655 | * so we can only trust the mountpoint to have the right pointer. | ||
656 | */ | ||
649 | dops = xfs_dir_get_ops(mp, NULL); | 657 | dops = xfs_dir_get_ops(mp, NULL); |
650 | 658 | ||
659 | ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK); | ||
660 | sfp = (struct xfs_dir2_sf_hdr *)ifp->if_u1.if_data; | ||
661 | size = ifp->if_bytes; | ||
662 | |||
651 | /* | 663 | /* |
652 | * Give up if the directory is way too short. | 664 | * Give up if the directory is way too short. |
653 | */ | 665 | */ |
654 | XFS_WANT_CORRUPTED_RETURN(mp, size > | 666 | if (size <= offsetof(struct xfs_dir2_sf_hdr, parent) || |
655 | offsetof(struct xfs_dir2_sf_hdr, parent)); | 667 | size < xfs_dir2_sf_hdr_size(sfp->i8count)) |
656 | XFS_WANT_CORRUPTED_RETURN(mp, size >= | 668 | return -EFSCORRUPTED; |
657 | xfs_dir2_sf_hdr_size(sfp->i8count)); | ||
658 | 669 | ||
659 | endp = (char *)sfp + size; | 670 | endp = (char *)sfp + size; |
660 | 671 | ||
661 | /* Check .. entry */ | 672 | /* Check .. entry */ |
662 | ino = dops->sf_get_parent_ino(sfp); | 673 | ino = dops->sf_get_parent_ino(sfp); |
663 | i8count = ino > XFS_DIR2_MAX_SHORT_INUM; | 674 | i8count = ino > XFS_DIR2_MAX_SHORT_INUM; |
664 | XFS_WANT_CORRUPTED_RETURN(mp, !xfs_dir_ino_validate(mp, ino)); | 675 | error = xfs_dir_ino_validate(mp, ino); |
676 | if (error) | ||
677 | return error; | ||
665 | offset = dops->data_first_offset; | 678 | offset = dops->data_first_offset; |
666 | 679 | ||
667 | /* Check all reported entries */ | 680 | /* Check all reported entries */ |
@@ -672,12 +685,12 @@ xfs_dir2_sf_verify( | |||
672 | * Check the fixed-offset parts of the structure are | 685 | * Check the fixed-offset parts of the structure are |
673 | * within the data buffer. | 686 | * within the data buffer. |
674 | */ | 687 | */ |
675 | XFS_WANT_CORRUPTED_RETURN(mp, | 688 | if (((char *)sfep + sizeof(*sfep)) >= endp) |
676 | ((char *)sfep + sizeof(*sfep)) < endp); | 689 | return -EFSCORRUPTED; |
677 | 690 | ||
678 | /* Don't allow names with known bad length. */ | 691 | /* Don't allow names with known bad length. */ |
679 | XFS_WANT_CORRUPTED_RETURN(mp, sfep->namelen > 0); | 692 | if (sfep->namelen == 0) |
680 | XFS_WANT_CORRUPTED_RETURN(mp, sfep->namelen < MAXNAMELEN); | 693 | return -EFSCORRUPTED; |
681 | 694 | ||
682 | /* | 695 | /* |
683 | * Check that the variable-length part of the structure is | 696 | * Check that the variable-length part of the structure is |
@@ -685,33 +698,39 @@ xfs_dir2_sf_verify( | |||
685 | * name component, so nextentry is an acceptable test. | 698 | * name component, so nextentry is an acceptable test. |
686 | */ | 699 | */ |
687 | next_sfep = dops->sf_nextentry(sfp, sfep); | 700 | next_sfep = dops->sf_nextentry(sfp, sfep); |
688 | XFS_WANT_CORRUPTED_RETURN(mp, endp >= (char *)next_sfep); | 701 | if (endp < (char *)next_sfep) |
702 | return -EFSCORRUPTED; | ||
689 | 703 | ||
690 | /* Check that the offsets always increase. */ | 704 | /* Check that the offsets always increase. */ |
691 | XFS_WANT_CORRUPTED_RETURN(mp, | 705 | if (xfs_dir2_sf_get_offset(sfep) < offset) |
692 | xfs_dir2_sf_get_offset(sfep) >= offset); | 706 | return -EFSCORRUPTED; |
693 | 707 | ||
694 | /* Check the inode number. */ | 708 | /* Check the inode number. */ |
695 | ino = dops->sf_get_ino(sfp, sfep); | 709 | ino = dops->sf_get_ino(sfp, sfep); |
696 | i8count += ino > XFS_DIR2_MAX_SHORT_INUM; | 710 | i8count += ino > XFS_DIR2_MAX_SHORT_INUM; |
697 | XFS_WANT_CORRUPTED_RETURN(mp, !xfs_dir_ino_validate(mp, ino)); | 711 | error = xfs_dir_ino_validate(mp, ino); |
712 | if (error) | ||
713 | return error; | ||
698 | 714 | ||
699 | /* Check the file type. */ | 715 | /* Check the file type. */ |
700 | filetype = dops->sf_get_ftype(sfep); | 716 | filetype = dops->sf_get_ftype(sfep); |
701 | XFS_WANT_CORRUPTED_RETURN(mp, filetype < XFS_DIR3_FT_MAX); | 717 | if (filetype >= XFS_DIR3_FT_MAX) |
718 | return -EFSCORRUPTED; | ||
702 | 719 | ||
703 | offset = xfs_dir2_sf_get_offset(sfep) + | 720 | offset = xfs_dir2_sf_get_offset(sfep) + |
704 | dops->data_entsize(sfep->namelen); | 721 | dops->data_entsize(sfep->namelen); |
705 | 722 | ||
706 | sfep = next_sfep; | 723 | sfep = next_sfep; |
707 | } | 724 | } |
708 | XFS_WANT_CORRUPTED_RETURN(mp, i8count == sfp->i8count); | 725 | if (i8count != sfp->i8count) |
709 | XFS_WANT_CORRUPTED_RETURN(mp, (void *)sfep == (void *)endp); | 726 | return -EFSCORRUPTED; |
727 | if ((void *)sfep != (void *)endp) | ||
728 | return -EFSCORRUPTED; | ||
710 | 729 | ||
711 | /* Make sure this whole thing ought to be in local format. */ | 730 | /* Make sure this whole thing ought to be in local format. */ |
712 | XFS_WANT_CORRUPTED_RETURN(mp, offset + | 731 | if (offset + (sfp->count + 2) * (uint)sizeof(xfs_dir2_leaf_entry_t) + |
713 | (sfp->count + 2) * (uint)sizeof(xfs_dir2_leaf_entry_t) + | 732 | (uint)sizeof(xfs_dir2_block_tail_t) > mp->m_dir_geo->blksize) |
714 | (uint)sizeof(xfs_dir2_block_tail_t) <= mp->m_dir_geo->blksize); | 733 | return -EFSCORRUPTED; |
715 | 734 | ||
716 | return 0; | 735 | return 0; |
717 | } | 736 | } |
diff --git a/fs/xfs/libxfs/xfs_inode_fork.c b/fs/xfs/libxfs/xfs_inode_fork.c index 9653e964eda4..8a37efe04de3 100644 --- a/fs/xfs/libxfs/xfs_inode_fork.c +++ b/fs/xfs/libxfs/xfs_inode_fork.c | |||
@@ -212,6 +212,16 @@ xfs_iformat_fork( | |||
212 | if (error) | 212 | if (error) |
213 | return error; | 213 | return error; |
214 | 214 | ||
215 | /* Check inline dir contents. */ | ||
216 | if (S_ISDIR(VFS_I(ip)->i_mode) && | ||
217 | dip->di_format == XFS_DINODE_FMT_LOCAL) { | ||
218 | error = xfs_dir2_sf_verify(ip); | ||
219 | if (error) { | ||
220 | xfs_idestroy_fork(ip, XFS_DATA_FORK); | ||
221 | return error; | ||
222 | } | ||
223 | } | ||
224 | |||
215 | if (xfs_is_reflink_inode(ip)) { | 225 | if (xfs_is_reflink_inode(ip)) { |
216 | ASSERT(ip->i_cowfp == NULL); | 226 | ASSERT(ip->i_cowfp == NULL); |
217 | xfs_ifork_init_cow(ip); | 227 | xfs_ifork_init_cow(ip); |
@@ -322,8 +332,6 @@ xfs_iformat_local( | |||
322 | int whichfork, | 332 | int whichfork, |
323 | int size) | 333 | int size) |
324 | { | 334 | { |
325 | int error; | ||
326 | |||
327 | /* | 335 | /* |
328 | * If the size is unreasonable, then something | 336 | * If the size is unreasonable, then something |
329 | * is wrong and we just bail out rather than crash in | 337 | * is wrong and we just bail out rather than crash in |
@@ -339,14 +347,6 @@ xfs_iformat_local( | |||
339 | return -EFSCORRUPTED; | 347 | return -EFSCORRUPTED; |
340 | } | 348 | } |
341 | 349 | ||
342 | if (S_ISDIR(VFS_I(ip)->i_mode) && whichfork == XFS_DATA_FORK) { | ||
343 | error = xfs_dir2_sf_verify(ip->i_mount, | ||
344 | (struct xfs_dir2_sf_hdr *)XFS_DFORK_DPTR(dip), | ||
345 | size); | ||
346 | if (error) | ||
347 | return error; | ||
348 | } | ||
349 | |||
350 | xfs_init_local_fork(ip, whichfork, XFS_DFORK_PTR(dip, whichfork), size); | 350 | xfs_init_local_fork(ip, whichfork, XFS_DFORK_PTR(dip, whichfork), size); |
351 | return 0; | 351 | return 0; |
352 | } | 352 | } |
@@ -867,7 +867,7 @@ xfs_iextents_copy( | |||
867 | * In these cases, the format always takes precedence, because the | 867 | * In these cases, the format always takes precedence, because the |
868 | * format indicates the current state of the fork. | 868 | * format indicates the current state of the fork. |
869 | */ | 869 | */ |
870 | int | 870 | void |
871 | xfs_iflush_fork( | 871 | xfs_iflush_fork( |
872 | xfs_inode_t *ip, | 872 | xfs_inode_t *ip, |
873 | xfs_dinode_t *dip, | 873 | xfs_dinode_t *dip, |
@@ -877,7 +877,6 @@ xfs_iflush_fork( | |||
877 | char *cp; | 877 | char *cp; |
878 | xfs_ifork_t *ifp; | 878 | xfs_ifork_t *ifp; |
879 | xfs_mount_t *mp; | 879 | xfs_mount_t *mp; |
880 | int error; | ||
881 | static const short brootflag[2] = | 880 | static const short brootflag[2] = |
882 | { XFS_ILOG_DBROOT, XFS_ILOG_ABROOT }; | 881 | { XFS_ILOG_DBROOT, XFS_ILOG_ABROOT }; |
883 | static const short dataflag[2] = | 882 | static const short dataflag[2] = |
@@ -886,7 +885,7 @@ xfs_iflush_fork( | |||
886 | { XFS_ILOG_DEXT, XFS_ILOG_AEXT }; | 885 | { XFS_ILOG_DEXT, XFS_ILOG_AEXT }; |
887 | 886 | ||
888 | if (!iip) | 887 | if (!iip) |
889 | return 0; | 888 | return; |
890 | ifp = XFS_IFORK_PTR(ip, whichfork); | 889 | ifp = XFS_IFORK_PTR(ip, whichfork); |
891 | /* | 890 | /* |
892 | * This can happen if we gave up in iformat in an error path, | 891 | * This can happen if we gave up in iformat in an error path, |
@@ -894,19 +893,12 @@ xfs_iflush_fork( | |||
894 | */ | 893 | */ |
895 | if (!ifp) { | 894 | if (!ifp) { |
896 | ASSERT(whichfork == XFS_ATTR_FORK); | 895 | ASSERT(whichfork == XFS_ATTR_FORK); |
897 | return 0; | 896 | return; |
898 | } | 897 | } |
899 | cp = XFS_DFORK_PTR(dip, whichfork); | 898 | cp = XFS_DFORK_PTR(dip, whichfork); |
900 | mp = ip->i_mount; | 899 | mp = ip->i_mount; |
901 | switch (XFS_IFORK_FORMAT(ip, whichfork)) { | 900 | switch (XFS_IFORK_FORMAT(ip, whichfork)) { |
902 | case XFS_DINODE_FMT_LOCAL: | 901 | case XFS_DINODE_FMT_LOCAL: |
903 | if (S_ISDIR(VFS_I(ip)->i_mode) && whichfork == XFS_DATA_FORK) { | ||
904 | error = xfs_dir2_sf_verify(mp, | ||
905 | (struct xfs_dir2_sf_hdr *)ifp->if_u1.if_data, | ||
906 | ifp->if_bytes); | ||
907 | if (error) | ||
908 | return error; | ||
909 | } | ||
910 | if ((iip->ili_fields & dataflag[whichfork]) && | 902 | if ((iip->ili_fields & dataflag[whichfork]) && |
911 | (ifp->if_bytes > 0)) { | 903 | (ifp->if_bytes > 0)) { |
912 | ASSERT(ifp->if_u1.if_data != NULL); | 904 | ASSERT(ifp->if_u1.if_data != NULL); |
@@ -959,7 +951,6 @@ xfs_iflush_fork( | |||
959 | ASSERT(0); | 951 | ASSERT(0); |
960 | break; | 952 | break; |
961 | } | 953 | } |
962 | return 0; | ||
963 | } | 954 | } |
964 | 955 | ||
965 | /* | 956 | /* |
diff --git a/fs/xfs/libxfs/xfs_inode_fork.h b/fs/xfs/libxfs/xfs_inode_fork.h index 132dc59fdde6..7fb8365326d1 100644 --- a/fs/xfs/libxfs/xfs_inode_fork.h +++ b/fs/xfs/libxfs/xfs_inode_fork.h | |||
@@ -140,7 +140,7 @@ typedef struct xfs_ifork { | |||
140 | struct xfs_ifork *xfs_iext_state_to_fork(struct xfs_inode *ip, int state); | 140 | struct xfs_ifork *xfs_iext_state_to_fork(struct xfs_inode *ip, int state); |
141 | 141 | ||
142 | int xfs_iformat_fork(struct xfs_inode *, struct xfs_dinode *); | 142 | int xfs_iformat_fork(struct xfs_inode *, struct xfs_dinode *); |
143 | int xfs_iflush_fork(struct xfs_inode *, struct xfs_dinode *, | 143 | void xfs_iflush_fork(struct xfs_inode *, struct xfs_dinode *, |
144 | struct xfs_inode_log_item *, int); | 144 | struct xfs_inode_log_item *, int); |
145 | void xfs_idestroy_fork(struct xfs_inode *, int); | 145 | void xfs_idestroy_fork(struct xfs_inode *, int); |
146 | void xfs_idata_realloc(struct xfs_inode *, int, int); | 146 | void xfs_idata_realloc(struct xfs_inode *, int, int); |
diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c index 142bbbe06114..8795e9cd867c 100644 --- a/fs/xfs/xfs_bmap_util.c +++ b/fs/xfs/xfs_bmap_util.c | |||
@@ -1311,8 +1311,16 @@ xfs_free_file_space( | |||
1311 | /* | 1311 | /* |
1312 | * Now that we've unmap all full blocks we'll have to zero out any | 1312 | * Now that we've unmap all full blocks we'll have to zero out any |
1313 | * partial block at the beginning and/or end. xfs_zero_range is | 1313 | * partial block at the beginning and/or end. xfs_zero_range is |
1314 | * smart enough to skip any holes, including those we just created. | 1314 | * smart enough to skip any holes, including those we just created, |
1315 | * but we must take care not to zero beyond EOF and enlarge i_size. | ||
1315 | */ | 1316 | */ |
1317 | |||
1318 | if (offset >= XFS_ISIZE(ip)) | ||
1319 | return 0; | ||
1320 | |||
1321 | if (offset + len > XFS_ISIZE(ip)) | ||
1322 | len = XFS_ISIZE(ip) - offset; | ||
1323 | |||
1316 | return xfs_zero_range(ip, offset, len, NULL); | 1324 | return xfs_zero_range(ip, offset, len, NULL); |
1317 | } | 1325 | } |
1318 | 1326 | ||
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index c7fe2c2123ab..7605d8396596 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c | |||
@@ -50,6 +50,7 @@ | |||
50 | #include "xfs_log.h" | 50 | #include "xfs_log.h" |
51 | #include "xfs_bmap_btree.h" | 51 | #include "xfs_bmap_btree.h" |
52 | #include "xfs_reflink.h" | 52 | #include "xfs_reflink.h" |
53 | #include "xfs_dir2_priv.h" | ||
53 | 54 | ||
54 | kmem_zone_t *xfs_inode_zone; | 55 | kmem_zone_t *xfs_inode_zone; |
55 | 56 | ||
@@ -3475,7 +3476,6 @@ xfs_iflush_int( | |||
3475 | struct xfs_inode_log_item *iip = ip->i_itemp; | 3476 | struct xfs_inode_log_item *iip = ip->i_itemp; |
3476 | struct xfs_dinode *dip; | 3477 | struct xfs_dinode *dip; |
3477 | struct xfs_mount *mp = ip->i_mount; | 3478 | struct xfs_mount *mp = ip->i_mount; |
3478 | int error; | ||
3479 | 3479 | ||
3480 | ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL|XFS_ILOCK_SHARED)); | 3480 | ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL|XFS_ILOCK_SHARED)); |
3481 | ASSERT(xfs_isiflocked(ip)); | 3481 | ASSERT(xfs_isiflocked(ip)); |
@@ -3547,6 +3547,12 @@ xfs_iflush_int( | |||
3547 | if (ip->i_d.di_version < 3) | 3547 | if (ip->i_d.di_version < 3) |
3548 | ip->i_d.di_flushiter++; | 3548 | ip->i_d.di_flushiter++; |
3549 | 3549 | ||
3550 | /* Check the inline directory data. */ | ||
3551 | if (S_ISDIR(VFS_I(ip)->i_mode) && | ||
3552 | ip->i_d.di_format == XFS_DINODE_FMT_LOCAL && | ||
3553 | xfs_dir2_sf_verify(ip)) | ||
3554 | goto corrupt_out; | ||
3555 | |||
3550 | /* | 3556 | /* |
3551 | * Copy the dirty parts of the inode into the on-disk inode. We always | 3557 | * Copy the dirty parts of the inode into the on-disk inode. We always |
3552 | * copy out the core of the inode, because if the inode is dirty at all | 3558 | * copy out the core of the inode, because if the inode is dirty at all |
@@ -3558,14 +3564,9 @@ xfs_iflush_int( | |||
3558 | if (ip->i_d.di_flushiter == DI_MAX_FLUSH) | 3564 | if (ip->i_d.di_flushiter == DI_MAX_FLUSH) |
3559 | ip->i_d.di_flushiter = 0; | 3565 | ip->i_d.di_flushiter = 0; |
3560 | 3566 | ||
3561 | error = xfs_iflush_fork(ip, dip, iip, XFS_DATA_FORK); | 3567 | xfs_iflush_fork(ip, dip, iip, XFS_DATA_FORK); |
3562 | if (error) | 3568 | if (XFS_IFORK_Q(ip)) |
3563 | return error; | 3569 | xfs_iflush_fork(ip, dip, iip, XFS_ATTR_FORK); |
3564 | if (XFS_IFORK_Q(ip)) { | ||
3565 | error = xfs_iflush_fork(ip, dip, iip, XFS_ATTR_FORK); | ||
3566 | if (error) | ||
3567 | return error; | ||
3568 | } | ||
3569 | xfs_inobp_check(mp, bp); | 3570 | xfs_inobp_check(mp, bp); |
3570 | 3571 | ||
3571 | /* | 3572 | /* |
diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index 229cc6a6d8ef..ebfc13350f9a 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c | |||
@@ -516,6 +516,20 @@ xfs_vn_getattr( | |||
516 | stat->blocks = | 516 | stat->blocks = |
517 | XFS_FSB_TO_BB(mp, ip->i_d.di_nblocks + ip->i_delayed_blks); | 517 | XFS_FSB_TO_BB(mp, ip->i_d.di_nblocks + ip->i_delayed_blks); |
518 | 518 | ||
519 | if (ip->i_d.di_version == 3) { | ||
520 | if (request_mask & STATX_BTIME) { | ||
521 | stat->result_mask |= STATX_BTIME; | ||
522 | stat->btime.tv_sec = ip->i_d.di_crtime.t_sec; | ||
523 | stat->btime.tv_nsec = ip->i_d.di_crtime.t_nsec; | ||
524 | } | ||
525 | } | ||
526 | |||
527 | if (ip->i_d.di_flags & XFS_DIFLAG_IMMUTABLE) | ||
528 | stat->attributes |= STATX_ATTR_IMMUTABLE; | ||
529 | if (ip->i_d.di_flags & XFS_DIFLAG_APPEND) | ||
530 | stat->attributes |= STATX_ATTR_APPEND; | ||
531 | if (ip->i_d.di_flags & XFS_DIFLAG_NODUMP) | ||
532 | stat->attributes |= STATX_ATTR_NODUMP; | ||
519 | 533 | ||
520 | switch (inode->i_mode & S_IFMT) { | 534 | switch (inode->i_mode & S_IFMT) { |
521 | case S_IFBLK: | 535 | case S_IFBLK: |
diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c index 2a6d9b1558e0..26d67ce3c18d 100644 --- a/fs/xfs/xfs_itable.c +++ b/fs/xfs/xfs_itable.c | |||
@@ -583,7 +583,7 @@ xfs_inumbers( | |||
583 | return error; | 583 | return error; |
584 | 584 | ||
585 | bcount = MIN(left, (int)(PAGE_SIZE / sizeof(*buffer))); | 585 | bcount = MIN(left, (int)(PAGE_SIZE / sizeof(*buffer))); |
586 | buffer = kmem_alloc(bcount * sizeof(*buffer), KM_SLEEP); | 586 | buffer = kmem_zalloc(bcount * sizeof(*buffer), KM_SLEEP); |
587 | do { | 587 | do { |
588 | struct xfs_inobt_rec_incore r; | 588 | struct xfs_inobt_rec_incore r; |
589 | int stat; | 589 | int stat; |
diff --git a/include/asm-generic/sections.h b/include/asm-generic/sections.h index 4df64a1fc09e..532372c6cf15 100644 --- a/include/asm-generic/sections.h +++ b/include/asm-generic/sections.h | |||
@@ -14,8 +14,8 @@ | |||
14 | * [_sdata, _edata]: contains .data.* sections, may also contain .rodata.* | 14 | * [_sdata, _edata]: contains .data.* sections, may also contain .rodata.* |
15 | * and/or .init.* sections. | 15 | * and/or .init.* sections. |
16 | * [__start_rodata, __end_rodata]: contains .rodata.* sections | 16 | * [__start_rodata, __end_rodata]: contains .rodata.* sections |
17 | * [__start_data_ro_after_init, __end_data_ro_after_init]: | 17 | * [__start_ro_after_init, __end_ro_after_init]: |
18 | * contains data.ro_after_init section | 18 | * contains .data..ro_after_init section |
19 | * [__init_begin, __init_end]: contains .init.* sections, but .init.text.* | 19 | * [__init_begin, __init_end]: contains .init.* sections, but .init.text.* |
20 | * may be out of this range on some architectures. | 20 | * may be out of this range on some architectures. |
21 | * [_sinittext, _einittext]: contains .init.text.* sections | 21 | * [_sinittext, _einittext]: contains .init.text.* sections |
@@ -33,7 +33,7 @@ extern char _data[], _sdata[], _edata[]; | |||
33 | extern char __bss_start[], __bss_stop[]; | 33 | extern char __bss_start[], __bss_stop[]; |
34 | extern char __init_begin[], __init_end[]; | 34 | extern char __init_begin[], __init_end[]; |
35 | extern char _sinittext[], _einittext[]; | 35 | extern char _sinittext[], _einittext[]; |
36 | extern char __start_data_ro_after_init[], __end_data_ro_after_init[]; | 36 | extern char __start_ro_after_init[], __end_ro_after_init[]; |
37 | extern char _end[]; | 37 | extern char _end[]; |
38 | extern char __per_cpu_load[], __per_cpu_start[], __per_cpu_end[]; | 38 | extern char __per_cpu_load[], __per_cpu_start[], __per_cpu_end[]; |
39 | extern char __kprobes_text_start[], __kprobes_text_end[]; | 39 | extern char __kprobes_text_start[], __kprobes_text_end[]; |
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h index 0968d13b3885..143db9c523e2 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h | |||
@@ -173,6 +173,7 @@ | |||
173 | KEEP(*(__##name##_of_table_end)) | 173 | KEEP(*(__##name##_of_table_end)) |
174 | 174 | ||
175 | #define CLKSRC_OF_TABLES() OF_TABLE(CONFIG_CLKSRC_OF, clksrc) | 175 | #define CLKSRC_OF_TABLES() OF_TABLE(CONFIG_CLKSRC_OF, clksrc) |
176 | #define CLKEVT_OF_TABLES() OF_TABLE(CONFIG_CLKEVT_OF, clkevt) | ||
176 | #define IRQCHIP_OF_MATCH_TABLE() OF_TABLE(CONFIG_IRQCHIP, irqchip) | 177 | #define IRQCHIP_OF_MATCH_TABLE() OF_TABLE(CONFIG_IRQCHIP, irqchip) |
177 | #define CLK_OF_TABLES() OF_TABLE(CONFIG_COMMON_CLK, clk) | 178 | #define CLK_OF_TABLES() OF_TABLE(CONFIG_COMMON_CLK, clk) |
178 | #define IOMMU_OF_TABLES() OF_TABLE(CONFIG_OF_IOMMU, iommu) | 179 | #define IOMMU_OF_TABLES() OF_TABLE(CONFIG_OF_IOMMU, iommu) |
@@ -260,9 +261,9 @@ | |||
260 | */ | 261 | */ |
261 | #ifndef RO_AFTER_INIT_DATA | 262 | #ifndef RO_AFTER_INIT_DATA |
262 | #define RO_AFTER_INIT_DATA \ | 263 | #define RO_AFTER_INIT_DATA \ |
263 | __start_data_ro_after_init = .; \ | 264 | VMLINUX_SYMBOL(__start_ro_after_init) = .; \ |
264 | *(.data..ro_after_init) \ | 265 | *(.data..ro_after_init) \ |
265 | __end_data_ro_after_init = .; | 266 | VMLINUX_SYMBOL(__end_ro_after_init) = .; |
266 | #endif | 267 | #endif |
267 | 268 | ||
268 | /* | 269 | /* |
@@ -559,6 +560,7 @@ | |||
559 | CLK_OF_TABLES() \ | 560 | CLK_OF_TABLES() \ |
560 | RESERVEDMEM_OF_TABLES() \ | 561 | RESERVEDMEM_OF_TABLES() \ |
561 | CLKSRC_OF_TABLES() \ | 562 | CLKSRC_OF_TABLES() \ |
563 | CLKEVT_OF_TABLES() \ | ||
562 | IOMMU_OF_TABLES() \ | 564 | IOMMU_OF_TABLES() \ |
563 | CPU_METHOD_OF_TABLES() \ | 565 | CPU_METHOD_OF_TABLES() \ |
564 | CPUIDLE_METHOD_OF_TABLES() \ | 566 | CPUIDLE_METHOD_OF_TABLES() \ |
diff --git a/include/crypto/internal/hash.h b/include/crypto/internal/hash.h index 1d4f365d8f03..f6d9af3efa45 100644 --- a/include/crypto/internal/hash.h +++ b/include/crypto/internal/hash.h | |||
@@ -166,6 +166,16 @@ static inline struct ahash_instance *ahash_alloc_instance( | |||
166 | return crypto_alloc_instance2(name, alg, ahash_instance_headroom()); | 166 | return crypto_alloc_instance2(name, alg, ahash_instance_headroom()); |
167 | } | 167 | } |
168 | 168 | ||
169 | static inline void ahash_request_complete(struct ahash_request *req, int err) | ||
170 | { | ||
171 | req->base.complete(&req->base, err); | ||
172 | } | ||
173 | |||
174 | static inline u32 ahash_request_flags(struct ahash_request *req) | ||
175 | { | ||
176 | return req->base.flags; | ||
177 | } | ||
178 | |||
169 | static inline struct crypto_ahash *crypto_spawn_ahash( | 179 | static inline struct crypto_ahash *crypto_spawn_ahash( |
170 | struct crypto_ahash_spawn *spawn) | 180 | struct crypto_ahash_spawn *spawn) |
171 | { | 181 | { |
diff --git a/include/drm/ttm/ttm_object.h b/include/drm/ttm/ttm_object.h index ed953f98f0e1..1487011fe057 100644 --- a/include/drm/ttm/ttm_object.h +++ b/include/drm/ttm/ttm_object.h | |||
@@ -229,6 +229,8 @@ extern void ttm_base_object_unref(struct ttm_base_object **p_base); | |||
229 | * @ref_type: The type of reference. | 229 | * @ref_type: The type of reference. |
230 | * @existed: Upon completion, indicates that an identical reference object | 230 | * @existed: Upon completion, indicates that an identical reference object |
231 | * already existed, and the refcount was upped on that object instead. | 231 | * already existed, and the refcount was upped on that object instead. |
232 | * @require_existed: Fail with -EPERM if an identical ref object didn't | ||
233 | * already exist. | ||
232 | * | 234 | * |
233 | * Checks that the base object is shareable and adds a ref object to it. | 235 | * Checks that the base object is shareable and adds a ref object to it. |
234 | * | 236 | * |
@@ -243,7 +245,8 @@ extern void ttm_base_object_unref(struct ttm_base_object **p_base); | |||
243 | */ | 245 | */ |
244 | extern int ttm_ref_object_add(struct ttm_object_file *tfile, | 246 | extern int ttm_ref_object_add(struct ttm_object_file *tfile, |
245 | struct ttm_base_object *base, | 247 | struct ttm_base_object *base, |
246 | enum ttm_ref_type ref_type, bool *existed); | 248 | enum ttm_ref_type ref_type, bool *existed, |
249 | bool require_existed); | ||
247 | 250 | ||
248 | extern bool ttm_ref_object_exists(struct ttm_object_file *tfile, | 251 | extern bool ttm_ref_object_exists(struct ttm_object_file *tfile, |
249 | struct ttm_base_object *base); | 252 | struct ttm_base_object *base); |
diff --git a/include/kvm/arm_vgic.h b/include/kvm/arm_vgic.h index b72dd2ad5f44..c0b3d999c266 100644 --- a/include/kvm/arm_vgic.h +++ b/include/kvm/arm_vgic.h | |||
@@ -295,6 +295,7 @@ void kvm_vgic_vcpu_early_init(struct kvm_vcpu *vcpu); | |||
295 | void kvm_vgic_vcpu_destroy(struct kvm_vcpu *vcpu); | 295 | void kvm_vgic_vcpu_destroy(struct kvm_vcpu *vcpu); |
296 | int kvm_vgic_map_resources(struct kvm *kvm); | 296 | int kvm_vgic_map_resources(struct kvm *kvm); |
297 | int kvm_vgic_hyp_init(void); | 297 | int kvm_vgic_hyp_init(void); |
298 | void kvm_vgic_init_cpu_hardware(void); | ||
298 | 299 | ||
299 | int kvm_vgic_inject_irq(struct kvm *kvm, int cpuid, unsigned int intid, | 300 | int kvm_vgic_inject_irq(struct kvm *kvm, int cpuid, unsigned int intid, |
300 | bool level); | 301 | bool level); |
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 6c247861cb66..ba3884f26288 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h | |||
@@ -1655,12 +1655,36 @@ static inline bool bios_segs_mergeable(struct request_queue *q, | |||
1655 | return true; | 1655 | return true; |
1656 | } | 1656 | } |
1657 | 1657 | ||
1658 | static inline bool bio_will_gap(struct request_queue *q, struct bio *prev, | 1658 | static inline bool bio_will_gap(struct request_queue *q, |
1659 | struct bio *next) | 1659 | struct request *prev_rq, |
1660 | struct bio *prev, | ||
1661 | struct bio *next) | ||
1660 | { | 1662 | { |
1661 | if (bio_has_data(prev) && queue_virt_boundary(q)) { | 1663 | if (bio_has_data(prev) && queue_virt_boundary(q)) { |
1662 | struct bio_vec pb, nb; | 1664 | struct bio_vec pb, nb; |
1663 | 1665 | ||
1666 | /* | ||
1667 | * don't merge if the 1st bio starts with non-zero | ||
1668 | * offset, otherwise it is quite difficult to respect | ||
1669 | * sg gap limit. We work hard to merge a huge number of small | ||
1670 | * single bios in case of mkfs. | ||
1671 | */ | ||
1672 | if (prev_rq) | ||
1673 | bio_get_first_bvec(prev_rq->bio, &pb); | ||
1674 | else | ||
1675 | bio_get_first_bvec(prev, &pb); | ||
1676 | if (pb.bv_offset) | ||
1677 | return true; | ||
1678 | |||
1679 | /* | ||
1680 | * We don't need to worry about the situation that the | ||
1681 | * merged segment ends in unaligned virt boundary: | ||
1682 | * | ||
1683 | * - if 'pb' ends aligned, the merged segment ends aligned | ||
1684 | * - if 'pb' ends unaligned, the next bio must include | ||
1685 | * one single bvec of 'nb', otherwise the 'nb' can't | ||
1686 | * merge with 'pb' | ||
1687 | */ | ||
1664 | bio_get_last_bvec(prev, &pb); | 1688 | bio_get_last_bvec(prev, &pb); |
1665 | bio_get_first_bvec(next, &nb); | 1689 | bio_get_first_bvec(next, &nb); |
1666 | 1690 | ||
@@ -1673,12 +1697,12 @@ static inline bool bio_will_gap(struct request_queue *q, struct bio *prev, | |||
1673 | 1697 | ||
1674 | static inline bool req_gap_back_merge(struct request *req, struct bio *bio) | 1698 | static inline bool req_gap_back_merge(struct request *req, struct bio *bio) |
1675 | { | 1699 | { |
1676 | return bio_will_gap(req->q, req->biotail, bio); | 1700 | return bio_will_gap(req->q, req, req->biotail, bio); |
1677 | } | 1701 | } |
1678 | 1702 | ||
1679 | static inline bool req_gap_front_merge(struct request *req, struct bio *bio) | 1703 | static inline bool req_gap_front_merge(struct request *req, struct bio *bio) |
1680 | { | 1704 | { |
1681 | return bio_will_gap(req->q, bio, req->bio); | 1705 | return bio_will_gap(req->q, NULL, bio, req->bio); |
1682 | } | 1706 | } |
1683 | 1707 | ||
1684 | int kblockd_schedule_work(struct work_struct *work); | 1708 | int kblockd_schedule_work(struct work_struct *work); |
diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h index f6b43fbb141c..af9c86e958bd 100644 --- a/include/linux/cgroup.h +++ b/include/linux/cgroup.h | |||
@@ -570,6 +570,25 @@ static inline void pr_cont_cgroup_path(struct cgroup *cgrp) | |||
570 | pr_cont_kernfs_path(cgrp->kn); | 570 | pr_cont_kernfs_path(cgrp->kn); |
571 | } | 571 | } |
572 | 572 | ||
573 | static inline void cgroup_init_kthreadd(void) | ||
574 | { | ||
575 | /* | ||
576 | * kthreadd is inherited by all kthreads, keep it in the root so | ||
577 | * that the new kthreads are guaranteed to stay in the root until | ||
578 | * initialization is finished. | ||
579 | */ | ||
580 | current->no_cgroup_migration = 1; | ||
581 | } | ||
582 | |||
583 | static inline void cgroup_kthread_ready(void) | ||
584 | { | ||
585 | /* | ||
586 | * This kthread finished initialization. The creator should have | ||
587 | * set PF_NO_SETAFFINITY if this kthread should stay in the root. | ||
588 | */ | ||
589 | current->no_cgroup_migration = 0; | ||
590 | } | ||
591 | |||
573 | #else /* !CONFIG_CGROUPS */ | 592 | #else /* !CONFIG_CGROUPS */ |
574 | 593 | ||
575 | struct cgroup_subsys_state; | 594 | struct cgroup_subsys_state; |
@@ -590,6 +609,8 @@ static inline void cgroup_free(struct task_struct *p) {} | |||
590 | 609 | ||
591 | static inline int cgroup_init_early(void) { return 0; } | 610 | static inline int cgroup_init_early(void) { return 0; } |
592 | static inline int cgroup_init(void) { return 0; } | 611 | static inline int cgroup_init(void) { return 0; } |
612 | static inline void cgroup_init_kthreadd(void) {} | ||
613 | static inline void cgroup_kthread_ready(void) {} | ||
593 | 614 | ||
594 | static inline bool task_under_cgroup_hierarchy(struct task_struct *task, | 615 | static inline bool task_under_cgroup_hierarchy(struct task_struct *task, |
595 | struct cgroup *ancestor) | 616 | struct cgroup *ancestor) |
diff --git a/include/linux/clockchips.h b/include/linux/clockchips.h index 5d3053c34fb3..6d7edc3082f9 100644 --- a/include/linux/clockchips.h +++ b/include/linux/clockchips.h | |||
@@ -229,7 +229,7 @@ static inline void tick_setup_hrtimer_broadcast(void) { } | |||
229 | 229 | ||
230 | #ifdef CONFIG_CLKEVT_PROBE | 230 | #ifdef CONFIG_CLKEVT_PROBE |
231 | extern int clockevent_probe(void); | 231 | extern int clockevent_probe(void); |
232 | #els | 232 | #else |
233 | static inline int clockevent_probe(void) { return 0; } | 233 | static inline int clockevent_probe(void) { return 0; } |
234 | #endif | 234 | #endif |
235 | 235 | ||
diff --git a/include/linux/irqchip/arm-gic.h b/include/linux/irqchip/arm-gic.h index eafc965b3eb8..dc30f3d057eb 100644 --- a/include/linux/irqchip/arm-gic.h +++ b/include/linux/irqchip/arm-gic.h | |||
@@ -96,6 +96,9 @@ | |||
96 | #define GICH_MISR_EOI (1 << 0) | 96 | #define GICH_MISR_EOI (1 << 0) |
97 | #define GICH_MISR_U (1 << 1) | 97 | #define GICH_MISR_U (1 << 1) |
98 | 98 | ||
99 | #define GICV_PMR_PRIORITY_SHIFT 3 | ||
100 | #define GICV_PMR_PRIORITY_MASK (0x1f << GICV_PMR_PRIORITY_SHIFT) | ||
101 | |||
99 | #ifndef __ASSEMBLY__ | 102 | #ifndef __ASSEMBLY__ |
100 | 103 | ||
101 | #include <linux/irqdomain.h> | 104 | #include <linux/irqdomain.h> |
diff --git a/include/linux/kasan.h b/include/linux/kasan.h index 5734480c9590..a5c7046f26b4 100644 --- a/include/linux/kasan.h +++ b/include/linux/kasan.h | |||
@@ -76,6 +76,9 @@ size_t ksize(const void *); | |||
76 | static inline void kasan_unpoison_slab(const void *ptr) { ksize(ptr); } | 76 | static inline void kasan_unpoison_slab(const void *ptr) { ksize(ptr); } |
77 | size_t kasan_metadata_size(struct kmem_cache *cache); | 77 | size_t kasan_metadata_size(struct kmem_cache *cache); |
78 | 78 | ||
79 | bool kasan_save_enable_multi_shot(void); | ||
80 | void kasan_restore_multi_shot(bool enabled); | ||
81 | |||
79 | #else /* CONFIG_KASAN */ | 82 | #else /* CONFIG_KASAN */ |
80 | 83 | ||
81 | static inline void kasan_unpoison_shadow(const void *address, size_t size) {} | 84 | static inline void kasan_unpoison_shadow(const void *address, size_t size) {} |
diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 5af377303880..bb7250c45cb8 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h | |||
@@ -740,6 +740,12 @@ static inline bool mem_cgroup_oom_synchronize(bool wait) | |||
740 | return false; | 740 | return false; |
741 | } | 741 | } |
742 | 742 | ||
743 | static inline void mem_cgroup_update_page_stat(struct page *page, | ||
744 | enum mem_cgroup_stat_index idx, | ||
745 | int nr) | ||
746 | { | ||
747 | } | ||
748 | |||
743 | static inline void mem_cgroup_inc_page_stat(struct page *page, | 749 | static inline void mem_cgroup_inc_page_stat(struct page *page, |
744 | enum mem_cgroup_stat_index idx) | 750 | enum mem_cgroup_stat_index idx) |
745 | { | 751 | { |
diff --git a/include/linux/mfd/cros_ec.h b/include/linux/mfd/cros_ec.h index 7a01c94496f1..3eef9fb9968a 100644 --- a/include/linux/mfd/cros_ec.h +++ b/include/linux/mfd/cros_ec.h | |||
@@ -35,10 +35,11 @@ | |||
35 | * Max bus-specific overhead incurred by request/responses. | 35 | * Max bus-specific overhead incurred by request/responses. |
36 | * I2C requires 1 additional byte for requests. | 36 | * I2C requires 1 additional byte for requests. |
37 | * I2C requires 2 additional bytes for responses. | 37 | * I2C requires 2 additional bytes for responses. |
38 | * SPI requires up to 32 additional bytes for responses. | ||
38 | * */ | 39 | * */ |
39 | #define EC_PROTO_VERSION_UNKNOWN 0 | 40 | #define EC_PROTO_VERSION_UNKNOWN 0 |
40 | #define EC_MAX_REQUEST_OVERHEAD 1 | 41 | #define EC_MAX_REQUEST_OVERHEAD 1 |
41 | #define EC_MAX_RESPONSE_OVERHEAD 2 | 42 | #define EC_MAX_RESPONSE_OVERHEAD 32 |
42 | 43 | ||
43 | /* | 44 | /* |
44 | * Command interface between EC and AP, for LPC, I2C and SPI interfaces. | 45 | * Command interface between EC and AP, for LPC, I2C and SPI interfaces. |
diff --git a/include/linux/mm.h b/include/linux/mm.h index 5f01c88f0800..00a8fa7e366a 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h | |||
@@ -32,6 +32,8 @@ struct user_struct; | |||
32 | struct writeback_control; | 32 | struct writeback_control; |
33 | struct bdi_writeback; | 33 | struct bdi_writeback; |
34 | 34 | ||
35 | void init_mm_internals(void); | ||
36 | |||
35 | #ifndef CONFIG_NEED_MULTIPLE_NODES /* Don't use mapnrs, do it properly */ | 37 | #ifndef CONFIG_NEED_MULTIPLE_NODES /* Don't use mapnrs, do it properly */ |
36 | extern unsigned long max_mapnr; | 38 | extern unsigned long max_mapnr; |
37 | 39 | ||
diff --git a/include/linux/mmc/sdio_func.h b/include/linux/mmc/sdio_func.h index aab032a6ae61..97ca105347a6 100644 --- a/include/linux/mmc/sdio_func.h +++ b/include/linux/mmc/sdio_func.h | |||
@@ -53,7 +53,7 @@ struct sdio_func { | |||
53 | unsigned int state; /* function state */ | 53 | unsigned int state; /* function state */ |
54 | #define SDIO_STATE_PRESENT (1<<0) /* present in sysfs */ | 54 | #define SDIO_STATE_PRESENT (1<<0) /* present in sysfs */ |
55 | 55 | ||
56 | u8 tmpbuf[4]; /* DMA:able scratch buffer */ | 56 | u8 *tmpbuf; /* DMA:able scratch buffer */ |
57 | 57 | ||
58 | unsigned num_info; /* number of info strings */ | 58 | unsigned num_info; /* number of info strings */ |
59 | const char **info; /* info strings */ | 59 | const char **info; /* info strings */ |
diff --git a/include/linux/mmu_notifier.h b/include/linux/mmu_notifier.h index 51891fb0d3ce..c91b3bcd158f 100644 --- a/include/linux/mmu_notifier.h +++ b/include/linux/mmu_notifier.h | |||
@@ -394,18 +394,6 @@ static inline void mmu_notifier_mm_destroy(struct mm_struct *mm) | |||
394 | ___pud; \ | 394 | ___pud; \ |
395 | }) | 395 | }) |
396 | 396 | ||
397 | #define pmdp_huge_get_and_clear_notify(__mm, __haddr, __pmd) \ | ||
398 | ({ \ | ||
399 | unsigned long ___haddr = __haddr & HPAGE_PMD_MASK; \ | ||
400 | pmd_t ___pmd; \ | ||
401 | \ | ||
402 | ___pmd = pmdp_huge_get_and_clear(__mm, __haddr, __pmd); \ | ||
403 | mmu_notifier_invalidate_range(__mm, ___haddr, \ | ||
404 | ___haddr + HPAGE_PMD_SIZE); \ | ||
405 | \ | ||
406 | ___pmd; \ | ||
407 | }) | ||
408 | |||
409 | /* | 397 | /* |
410 | * set_pte_at_notify() sets the pte _after_ running the notifier. | 398 | * set_pte_at_notify() sets the pte _after_ running the notifier. |
411 | * This is safe to start by updating the secondary MMUs, because the primary MMU | 399 | * This is safe to start by updating the secondary MMUs, because the primary MMU |
@@ -489,7 +477,6 @@ static inline void mmu_notifier_mm_destroy(struct mm_struct *mm) | |||
489 | #define ptep_clear_flush_notify ptep_clear_flush | 477 | #define ptep_clear_flush_notify ptep_clear_flush |
490 | #define pmdp_huge_clear_flush_notify pmdp_huge_clear_flush | 478 | #define pmdp_huge_clear_flush_notify pmdp_huge_clear_flush |
491 | #define pudp_huge_clear_flush_notify pudp_huge_clear_flush | 479 | #define pudp_huge_clear_flush_notify pudp_huge_clear_flush |
492 | #define pmdp_huge_get_and_clear_notify pmdp_huge_get_and_clear | ||
493 | #define set_pte_at_notify set_pte_at | 480 | #define set_pte_at_notify set_pte_at |
494 | 481 | ||
495 | #endif /* CONFIG_MMU_NOTIFIER */ | 482 | #endif /* CONFIG_MMU_NOTIFIER */ |
diff --git a/include/linux/pinctrl/pinctrl.h b/include/linux/pinctrl/pinctrl.h index 8ce2d87a238b..5e45385c5bdc 100644 --- a/include/linux/pinctrl/pinctrl.h +++ b/include/linux/pinctrl/pinctrl.h | |||
@@ -145,8 +145,9 @@ struct pinctrl_desc { | |||
145 | extern int pinctrl_register_and_init(struct pinctrl_desc *pctldesc, | 145 | extern int pinctrl_register_and_init(struct pinctrl_desc *pctldesc, |
146 | struct device *dev, void *driver_data, | 146 | struct device *dev, void *driver_data, |
147 | struct pinctrl_dev **pctldev); | 147 | struct pinctrl_dev **pctldev); |
148 | extern int pinctrl_enable(struct pinctrl_dev *pctldev); | ||
148 | 149 | ||
149 | /* Please use pinctrl_register_and_init() instead */ | 150 | /* Please use pinctrl_register_and_init() and pinctrl_enable() instead */ |
150 | extern struct pinctrl_dev *pinctrl_register(struct pinctrl_desc *pctldesc, | 151 | extern struct pinctrl_dev *pinctrl_register(struct pinctrl_desc *pctldesc, |
151 | struct device *dev, void *driver_data); | 152 | struct device *dev, void *driver_data); |
152 | 153 | ||
diff --git a/include/linux/reset.h b/include/linux/reset.h index 96fb139bdd08..13d8681210d5 100644 --- a/include/linux/reset.h +++ b/include/linux/reset.h | |||
@@ -15,6 +15,9 @@ int reset_control_status(struct reset_control *rstc); | |||
15 | struct reset_control *__of_reset_control_get(struct device_node *node, | 15 | struct reset_control *__of_reset_control_get(struct device_node *node, |
16 | const char *id, int index, bool shared, | 16 | const char *id, int index, bool shared, |
17 | bool optional); | 17 | bool optional); |
18 | struct reset_control *__reset_control_get(struct device *dev, const char *id, | ||
19 | int index, bool shared, | ||
20 | bool optional); | ||
18 | void reset_control_put(struct reset_control *rstc); | 21 | void reset_control_put(struct reset_control *rstc); |
19 | struct reset_control *__devm_reset_control_get(struct device *dev, | 22 | struct reset_control *__devm_reset_control_get(struct device *dev, |
20 | const char *id, int index, bool shared, | 23 | const char *id, int index, bool shared, |
@@ -72,6 +75,13 @@ static inline struct reset_control *__of_reset_control_get( | |||
72 | return optional ? NULL : ERR_PTR(-ENOTSUPP); | 75 | return optional ? NULL : ERR_PTR(-ENOTSUPP); |
73 | } | 76 | } |
74 | 77 | ||
78 | static inline struct reset_control *__reset_control_get( | ||
79 | struct device *dev, const char *id, | ||
80 | int index, bool shared, bool optional) | ||
81 | { | ||
82 | return optional ? NULL : ERR_PTR(-ENOTSUPP); | ||
83 | } | ||
84 | |||
75 | static inline struct reset_control *__devm_reset_control_get( | 85 | static inline struct reset_control *__devm_reset_control_get( |
76 | struct device *dev, const char *id, | 86 | struct device *dev, const char *id, |
77 | int index, bool shared, bool optional) | 87 | int index, bool shared, bool optional) |
@@ -102,8 +112,7 @@ __must_check reset_control_get_exclusive(struct device *dev, const char *id) | |||
102 | #ifndef CONFIG_RESET_CONTROLLER | 112 | #ifndef CONFIG_RESET_CONTROLLER |
103 | WARN_ON(1); | 113 | WARN_ON(1); |
104 | #endif | 114 | #endif |
105 | return __of_reset_control_get(dev ? dev->of_node : NULL, id, 0, false, | 115 | return __reset_control_get(dev, id, 0, false, false); |
106 | false); | ||
107 | } | 116 | } |
108 | 117 | ||
109 | /** | 118 | /** |
@@ -131,22 +140,19 @@ __must_check reset_control_get_exclusive(struct device *dev, const char *id) | |||
131 | static inline struct reset_control *reset_control_get_shared( | 140 | static inline struct reset_control *reset_control_get_shared( |
132 | struct device *dev, const char *id) | 141 | struct device *dev, const char *id) |
133 | { | 142 | { |
134 | return __of_reset_control_get(dev ? dev->of_node : NULL, id, 0, true, | 143 | return __reset_control_get(dev, id, 0, true, false); |
135 | false); | ||
136 | } | 144 | } |
137 | 145 | ||
138 | static inline struct reset_control *reset_control_get_optional_exclusive( | 146 | static inline struct reset_control *reset_control_get_optional_exclusive( |
139 | struct device *dev, const char *id) | 147 | struct device *dev, const char *id) |
140 | { | 148 | { |
141 | return __of_reset_control_get(dev ? dev->of_node : NULL, id, 0, false, | 149 | return __reset_control_get(dev, id, 0, false, true); |
142 | true); | ||
143 | } | 150 | } |
144 | 151 | ||
145 | static inline struct reset_control *reset_control_get_optional_shared( | 152 | static inline struct reset_control *reset_control_get_optional_shared( |
146 | struct device *dev, const char *id) | 153 | struct device *dev, const char *id) |
147 | { | 154 | { |
148 | return __of_reset_control_get(dev ? dev->of_node : NULL, id, 0, true, | 155 | return __reset_control_get(dev, id, 0, true, true); |
149 | true); | ||
150 | } | 156 | } |
151 | 157 | ||
152 | /** | 158 | /** |
diff --git a/include/linux/sched.h b/include/linux/sched.h index d67eee84fd43..4cf9a59a4d08 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h | |||
@@ -604,6 +604,10 @@ struct task_struct { | |||
604 | #ifdef CONFIG_COMPAT_BRK | 604 | #ifdef CONFIG_COMPAT_BRK |
605 | unsigned brk_randomized:1; | 605 | unsigned brk_randomized:1; |
606 | #endif | 606 | #endif |
607 | #ifdef CONFIG_CGROUPS | ||
608 | /* disallow userland-initiated cgroup migration */ | ||
609 | unsigned no_cgroup_migration:1; | ||
610 | #endif | ||
607 | 611 | ||
608 | unsigned long atomic_flags; /* Flags requiring atomic access. */ | 612 | unsigned long atomic_flags; /* Flags requiring atomic access. */ |
609 | 613 | ||
diff --git a/include/linux/sched/clock.h b/include/linux/sched/clock.h index 4a68c6791207..34fe92ce1ebd 100644 --- a/include/linux/sched/clock.h +++ b/include/linux/sched/clock.h | |||
@@ -54,15 +54,16 @@ static inline u64 local_clock(void) | |||
54 | } | 54 | } |
55 | #else | 55 | #else |
56 | extern void sched_clock_init_late(void); | 56 | extern void sched_clock_init_late(void); |
57 | /* | ||
58 | * Architectures can set this to 1 if they have specified | ||
59 | * CONFIG_HAVE_UNSTABLE_SCHED_CLOCK in their arch Kconfig, | ||
60 | * but then during bootup it turns out that sched_clock() | ||
61 | * is reliable after all: | ||
62 | */ | ||
63 | extern int sched_clock_stable(void); | 57 | extern int sched_clock_stable(void); |
64 | extern void clear_sched_clock_stable(void); | 58 | extern void clear_sched_clock_stable(void); |
65 | 59 | ||
60 | /* | ||
61 | * When sched_clock_stable(), __sched_clock_offset provides the offset | ||
62 | * between local_clock() and sched_clock(). | ||
63 | */ | ||
64 | extern u64 __sched_clock_offset; | ||
65 | |||
66 | |||
66 | extern void sched_clock_tick(void); | 67 | extern void sched_clock_tick(void); |
67 | extern void sched_clock_idle_sleep_event(void); | 68 | extern void sched_clock_idle_sleep_event(void); |
68 | extern void sched_clock_idle_wakeup_event(u64 delta_ns); | 69 | extern void sched_clock_idle_wakeup_event(u64 delta_ns); |
diff --git a/include/linux/stat.h b/include/linux/stat.h index c76e524fb34b..64b6b3aece21 100644 --- a/include/linux/stat.h +++ b/include/linux/stat.h | |||
@@ -26,6 +26,7 @@ struct kstat { | |||
26 | unsigned int nlink; | 26 | unsigned int nlink; |
27 | uint32_t blksize; /* Preferred I/O size */ | 27 | uint32_t blksize; /* Preferred I/O size */ |
28 | u64 attributes; | 28 | u64 attributes; |
29 | u64 attributes_mask; | ||
29 | #define KSTAT_ATTR_FS_IOC_FLAGS \ | 30 | #define KSTAT_ATTR_FS_IOC_FLAGS \ |
30 | (STATX_ATTR_COMPRESSED | \ | 31 | (STATX_ATTR_COMPRESSED | \ |
31 | STATX_ATTR_IMMUTABLE | \ | 32 | STATX_ATTR_IMMUTABLE | \ |
diff --git a/include/linux/uio.h b/include/linux/uio.h index 804e34c6f981..f2d36a3d3005 100644 --- a/include/linux/uio.h +++ b/include/linux/uio.h | |||
@@ -39,7 +39,10 @@ struct iov_iter { | |||
39 | }; | 39 | }; |
40 | union { | 40 | union { |
41 | unsigned long nr_segs; | 41 | unsigned long nr_segs; |
42 | int idx; | 42 | struct { |
43 | int idx; | ||
44 | int start_idx; | ||
45 | }; | ||
43 | }; | 46 | }; |
44 | }; | 47 | }; |
45 | 48 | ||
@@ -81,6 +84,7 @@ unsigned long iov_shorten(struct iovec *iov, unsigned long nr_segs, size_t to); | |||
81 | size_t iov_iter_copy_from_user_atomic(struct page *page, | 84 | size_t iov_iter_copy_from_user_atomic(struct page *page, |
82 | struct iov_iter *i, unsigned long offset, size_t bytes); | 85 | struct iov_iter *i, unsigned long offset, size_t bytes); |
83 | void iov_iter_advance(struct iov_iter *i, size_t bytes); | 86 | void iov_iter_advance(struct iov_iter *i, size_t bytes); |
87 | void iov_iter_revert(struct iov_iter *i, size_t bytes); | ||
84 | int iov_iter_fault_in_readable(struct iov_iter *i, size_t bytes); | 88 | int iov_iter_fault_in_readable(struct iov_iter *i, size_t bytes); |
85 | size_t iov_iter_single_seg_count(const struct iov_iter *i); | 89 | size_t iov_iter_single_seg_count(const struct iov_iter *i); |
86 | size_t copy_page_to_iter(struct page *page, size_t offset, size_t bytes, | 90 | size_t copy_page_to_iter(struct page *page, size_t offset, size_t bytes, |
diff --git a/include/linux/virtio.h b/include/linux/virtio.h index 04b0d3f95043..7edfbdb55a99 100644 --- a/include/linux/virtio.h +++ b/include/linux/virtio.h | |||
@@ -167,6 +167,7 @@ struct virtio_driver { | |||
167 | unsigned int feature_table_size; | 167 | unsigned int feature_table_size; |
168 | const unsigned int *feature_table_legacy; | 168 | const unsigned int *feature_table_legacy; |
169 | unsigned int feature_table_size_legacy; | 169 | unsigned int feature_table_size_legacy; |
170 | int (*validate)(struct virtio_device *dev); | ||
170 | int (*probe)(struct virtio_device *dev); | 171 | int (*probe)(struct virtio_device *dev); |
171 | void (*scan)(struct virtio_device *dev); | 172 | void (*scan)(struct virtio_device *dev); |
172 | void (*remove)(struct virtio_device *dev); | 173 | void (*remove)(struct virtio_device *dev); |
diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h index 1f71ee5ab518..069582ee5d7f 100644 --- a/include/net/sctp/sctp.h +++ b/include/net/sctp/sctp.h | |||
@@ -448,10 +448,9 @@ static inline int sctp_frag_point(const struct sctp_association *asoc, int pmtu) | |||
448 | return frag; | 448 | return frag; |
449 | } | 449 | } |
450 | 450 | ||
451 | static inline void sctp_assoc_pending_pmtu(struct sock *sk, struct sctp_association *asoc) | 451 | static inline void sctp_assoc_pending_pmtu(struct sctp_association *asoc) |
452 | { | 452 | { |
453 | 453 | sctp_assoc_sync_pmtu(asoc); | |
454 | sctp_assoc_sync_pmtu(sk, asoc); | ||
455 | asoc->pmtu_pending = 0; | 454 | asoc->pmtu_pending = 0; |
456 | } | 455 | } |
457 | 456 | ||
@@ -596,12 +595,23 @@ static inline void sctp_v4_map_v6(union sctp_addr *addr) | |||
596 | */ | 595 | */ |
597 | static inline struct dst_entry *sctp_transport_dst_check(struct sctp_transport *t) | 596 | static inline struct dst_entry *sctp_transport_dst_check(struct sctp_transport *t) |
598 | { | 597 | { |
599 | if (t->dst && (!dst_check(t->dst, t->dst_cookie) || | 598 | if (t->dst && !dst_check(t->dst, t->dst_cookie)) |
600 | t->pathmtu != max_t(size_t, SCTP_TRUNC4(dst_mtu(t->dst)), | ||
601 | SCTP_DEFAULT_MINSEGMENT))) | ||
602 | sctp_transport_dst_release(t); | 599 | sctp_transport_dst_release(t); |
603 | 600 | ||
604 | return t->dst; | 601 | return t->dst; |
605 | } | 602 | } |
606 | 603 | ||
604 | static inline bool sctp_transport_pmtu_check(struct sctp_transport *t) | ||
605 | { | ||
606 | __u32 pmtu = max_t(size_t, SCTP_TRUNC4(dst_mtu(t->dst)), | ||
607 | SCTP_DEFAULT_MINSEGMENT); | ||
608 | |||
609 | if (t->pathmtu == pmtu) | ||
610 | return true; | ||
611 | |||
612 | t->pathmtu = pmtu; | ||
613 | |||
614 | return false; | ||
615 | } | ||
616 | |||
607 | #endif /* __net_sctp_h__ */ | 617 | #endif /* __net_sctp_h__ */ |
diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h index 592decebac75..138f8615acf0 100644 --- a/include/net/sctp/structs.h +++ b/include/net/sctp/structs.h | |||
@@ -377,7 +377,8 @@ typedef struct sctp_sender_hb_info { | |||
377 | __u64 hb_nonce; | 377 | __u64 hb_nonce; |
378 | } sctp_sender_hb_info_t; | 378 | } sctp_sender_hb_info_t; |
379 | 379 | ||
380 | struct sctp_stream *sctp_stream_new(__u16 incnt, __u16 outcnt, gfp_t gfp); | 380 | int sctp_stream_new(struct sctp_association *asoc, gfp_t gfp); |
381 | int sctp_stream_init(struct sctp_association *asoc, gfp_t gfp); | ||
381 | void sctp_stream_free(struct sctp_stream *stream); | 382 | void sctp_stream_free(struct sctp_stream *stream); |
382 | void sctp_stream_clear(struct sctp_stream *stream); | 383 | void sctp_stream_clear(struct sctp_stream *stream); |
383 | 384 | ||
@@ -499,7 +500,6 @@ struct sctp_datamsg { | |||
499 | /* Did the messenge fail to send? */ | 500 | /* Did the messenge fail to send? */ |
500 | int send_error; | 501 | int send_error; |
501 | u8 send_failed:1, | 502 | u8 send_failed:1, |
502 | force_delay:1, | ||
503 | can_delay; /* should this message be Nagle delayed */ | 503 | can_delay; /* should this message be Nagle delayed */ |
504 | }; | 504 | }; |
505 | 505 | ||
@@ -952,8 +952,8 @@ void sctp_transport_lower_cwnd(struct sctp_transport *, sctp_lower_cwnd_t); | |||
952 | void sctp_transport_burst_limited(struct sctp_transport *); | 952 | void sctp_transport_burst_limited(struct sctp_transport *); |
953 | void sctp_transport_burst_reset(struct sctp_transport *); | 953 | void sctp_transport_burst_reset(struct sctp_transport *); |
954 | unsigned long sctp_transport_timeout(struct sctp_transport *); | 954 | unsigned long sctp_transport_timeout(struct sctp_transport *); |
955 | void sctp_transport_reset(struct sctp_transport *); | 955 | void sctp_transport_reset(struct sctp_transport *t); |
956 | void sctp_transport_update_pmtu(struct sock *, struct sctp_transport *, u32); | 956 | void sctp_transport_update_pmtu(struct sctp_transport *t, u32 pmtu); |
957 | void sctp_transport_immediate_rtx(struct sctp_transport *); | 957 | void sctp_transport_immediate_rtx(struct sctp_transport *); |
958 | void sctp_transport_dst_release(struct sctp_transport *t); | 958 | void sctp_transport_dst_release(struct sctp_transport *t); |
959 | void sctp_transport_dst_confirm(struct sctp_transport *t); | 959 | void sctp_transport_dst_confirm(struct sctp_transport *t); |
@@ -1878,6 +1878,7 @@ struct sctp_association { | |||
1878 | 1878 | ||
1879 | __u8 need_ecne:1, /* Need to send an ECNE Chunk? */ | 1879 | __u8 need_ecne:1, /* Need to send an ECNE Chunk? */ |
1880 | temp:1, /* Is it a temporary association? */ | 1880 | temp:1, /* Is it a temporary association? */ |
1881 | force_delay:1, | ||
1881 | prsctp_enable:1, | 1882 | prsctp_enable:1, |
1882 | reconf_enable:1; | 1883 | reconf_enable:1; |
1883 | 1884 | ||
@@ -1953,7 +1954,7 @@ void sctp_assoc_update(struct sctp_association *old, | |||
1953 | 1954 | ||
1954 | __u32 sctp_association_get_next_tsn(struct sctp_association *); | 1955 | __u32 sctp_association_get_next_tsn(struct sctp_association *); |
1955 | 1956 | ||
1956 | void sctp_assoc_sync_pmtu(struct sock *, struct sctp_association *); | 1957 | void sctp_assoc_sync_pmtu(struct sctp_association *asoc); |
1957 | void sctp_assoc_rwnd_increase(struct sctp_association *, unsigned int); | 1958 | void sctp_assoc_rwnd_increase(struct sctp_association *, unsigned int); |
1958 | void sctp_assoc_rwnd_decrease(struct sctp_association *, unsigned int); | 1959 | void sctp_assoc_rwnd_decrease(struct sctp_association *, unsigned int); |
1959 | void sctp_assoc_set_primary(struct sctp_association *, | 1960 | void sctp_assoc_set_primary(struct sctp_association *, |
diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h index 4b784b6e21c0..ccfad0e9c2cd 100644 --- a/include/target/target_core_base.h +++ b/include/target/target_core_base.h | |||
@@ -117,6 +117,7 @@ enum transport_state_table { | |||
117 | TRANSPORT_ISTATE_PROCESSING = 11, | 117 | TRANSPORT_ISTATE_PROCESSING = 11, |
118 | TRANSPORT_COMPLETE_QF_WP = 18, | 118 | TRANSPORT_COMPLETE_QF_WP = 18, |
119 | TRANSPORT_COMPLETE_QF_OK = 19, | 119 | TRANSPORT_COMPLETE_QF_OK = 19, |
120 | TRANSPORT_COMPLETE_QF_ERR = 20, | ||
120 | }; | 121 | }; |
121 | 122 | ||
122 | /* Used for struct se_cmd->se_cmd_flags */ | 123 | /* Used for struct se_cmd->se_cmd_flags */ |
@@ -279,8 +280,6 @@ struct t10_alua_tg_pt_gp { | |||
279 | u16 tg_pt_gp_id; | 280 | u16 tg_pt_gp_id; |
280 | int tg_pt_gp_valid_id; | 281 | int tg_pt_gp_valid_id; |
281 | int tg_pt_gp_alua_supported_states; | 282 | int tg_pt_gp_alua_supported_states; |
282 | int tg_pt_gp_alua_pending_state; | ||
283 | int tg_pt_gp_alua_previous_state; | ||
284 | int tg_pt_gp_alua_access_status; | 283 | int tg_pt_gp_alua_access_status; |
285 | int tg_pt_gp_alua_access_type; | 284 | int tg_pt_gp_alua_access_type; |
286 | int tg_pt_gp_nonop_delay_msecs; | 285 | int tg_pt_gp_nonop_delay_msecs; |
@@ -289,18 +288,16 @@ struct t10_alua_tg_pt_gp { | |||
289 | int tg_pt_gp_pref; | 288 | int tg_pt_gp_pref; |
290 | int tg_pt_gp_write_metadata; | 289 | int tg_pt_gp_write_metadata; |
291 | u32 tg_pt_gp_members; | 290 | u32 tg_pt_gp_members; |
292 | atomic_t tg_pt_gp_alua_access_state; | 291 | int tg_pt_gp_alua_access_state; |
293 | atomic_t tg_pt_gp_ref_cnt; | 292 | atomic_t tg_pt_gp_ref_cnt; |
294 | spinlock_t tg_pt_gp_lock; | 293 | spinlock_t tg_pt_gp_lock; |
295 | struct mutex tg_pt_gp_md_mutex; | 294 | struct mutex tg_pt_gp_transition_mutex; |
296 | struct se_device *tg_pt_gp_dev; | 295 | struct se_device *tg_pt_gp_dev; |
297 | struct config_group tg_pt_gp_group; | 296 | struct config_group tg_pt_gp_group; |
298 | struct list_head tg_pt_gp_list; | 297 | struct list_head tg_pt_gp_list; |
299 | struct list_head tg_pt_gp_lun_list; | 298 | struct list_head tg_pt_gp_lun_list; |
300 | struct se_lun *tg_pt_gp_alua_lun; | 299 | struct se_lun *tg_pt_gp_alua_lun; |
301 | struct se_node_acl *tg_pt_gp_alua_nacl; | 300 | struct se_node_acl *tg_pt_gp_alua_nacl; |
302 | struct work_struct tg_pt_gp_transition_work; | ||
303 | struct completion *tg_pt_gp_transition_complete; | ||
304 | }; | 301 | }; |
305 | 302 | ||
306 | struct t10_vpd { | 303 | struct t10_vpd { |
@@ -705,6 +702,7 @@ struct se_lun { | |||
705 | u64 unpacked_lun; | 702 | u64 unpacked_lun; |
706 | #define SE_LUN_LINK_MAGIC 0xffff7771 | 703 | #define SE_LUN_LINK_MAGIC 0xffff7771 |
707 | u32 lun_link_magic; | 704 | u32 lun_link_magic; |
705 | bool lun_shutdown; | ||
708 | bool lun_access_ro; | 706 | bool lun_access_ro; |
709 | u32 lun_index; | 707 | u32 lun_index; |
710 | 708 | ||
diff --git a/include/uapi/linux/Kbuild b/include/uapi/linux/Kbuild index dd9820b1c779..f8d9fed17ba9 100644 --- a/include/uapi/linux/Kbuild +++ b/include/uapi/linux/Kbuild | |||
@@ -445,6 +445,7 @@ header-y += unistd.h | |||
445 | header-y += unix_diag.h | 445 | header-y += unix_diag.h |
446 | header-y += usbdevice_fs.h | 446 | header-y += usbdevice_fs.h |
447 | header-y += usbip.h | 447 | header-y += usbip.h |
448 | header-y += userio.h | ||
448 | header-y += utime.h | 449 | header-y += utime.h |
449 | header-y += utsname.h | 450 | header-y += utsname.h |
450 | header-y += uuid.h | 451 | header-y += uuid.h |
diff --git a/include/uapi/linux/ipv6_route.h b/include/uapi/linux/ipv6_route.h index 85bbb1799df3..d496c02e14bc 100644 --- a/include/uapi/linux/ipv6_route.h +++ b/include/uapi/linux/ipv6_route.h | |||
@@ -35,7 +35,7 @@ | |||
35 | #define RTF_PREF(pref) ((pref) << 27) | 35 | #define RTF_PREF(pref) ((pref) << 27) |
36 | #define RTF_PREF_MASK 0x18000000 | 36 | #define RTF_PREF_MASK 0x18000000 |
37 | 37 | ||
38 | #define RTF_PCPU 0x40000000 | 38 | #define RTF_PCPU 0x40000000 /* read-only: can not be set by user */ |
39 | #define RTF_LOCAL 0x80000000 | 39 | #define RTF_LOCAL 0x80000000 |
40 | 40 | ||
41 | 41 | ||
diff --git a/include/uapi/linux/stat.h b/include/uapi/linux/stat.h index 51a6b86e3700..d538897b8e08 100644 --- a/include/uapi/linux/stat.h +++ b/include/uapi/linux/stat.h | |||
@@ -114,7 +114,7 @@ struct statx { | |||
114 | __u64 stx_ino; /* Inode number */ | 114 | __u64 stx_ino; /* Inode number */ |
115 | __u64 stx_size; /* File size */ | 115 | __u64 stx_size; /* File size */ |
116 | __u64 stx_blocks; /* Number of 512-byte blocks allocated */ | 116 | __u64 stx_blocks; /* Number of 512-byte blocks allocated */ |
117 | __u64 __spare1[1]; | 117 | __u64 stx_attributes_mask; /* Mask to show what's supported in stx_attributes */ |
118 | /* 0x40 */ | 118 | /* 0x40 */ |
119 | struct statx_timestamp stx_atime; /* Last access time */ | 119 | struct statx_timestamp stx_atime; /* Last access time */ |
120 | struct statx_timestamp stx_btime; /* File creation time */ | 120 | struct statx_timestamp stx_btime; /* File creation time */ |
@@ -152,9 +152,10 @@ struct statx { | |||
152 | #define STATX_BASIC_STATS 0x000007ffU /* The stuff in the normal stat struct */ | 152 | #define STATX_BASIC_STATS 0x000007ffU /* The stuff in the normal stat struct */ |
153 | #define STATX_BTIME 0x00000800U /* Want/got stx_btime */ | 153 | #define STATX_BTIME 0x00000800U /* Want/got stx_btime */ |
154 | #define STATX_ALL 0x00000fffU /* All currently supported flags */ | 154 | #define STATX_ALL 0x00000fffU /* All currently supported flags */ |
155 | #define STATX__RESERVED 0x80000000U /* Reserved for future struct statx expansion */ | ||
155 | 156 | ||
156 | /* | 157 | /* |
157 | * Attributes to be found in stx_attributes | 158 | * Attributes to be found in stx_attributes and masked in stx_attributes_mask. |
158 | * | 159 | * |
159 | * These give information about the features or the state of a file that might | 160 | * These give information about the features or the state of a file that might |
160 | * be of use to ordinary userspace programs such as GUIs or ls rather than | 161 | * be of use to ordinary userspace programs such as GUIs or ls rather than |
diff --git a/include/uapi/linux/virtio_pci.h b/include/uapi/linux/virtio_pci.h index 15b4385a2be1..90007a1abcab 100644 --- a/include/uapi/linux/virtio_pci.h +++ b/include/uapi/linux/virtio_pci.h | |||
@@ -79,7 +79,7 @@ | |||
79 | * configuration space */ | 79 | * configuration space */ |
80 | #define VIRTIO_PCI_CONFIG_OFF(msix_enabled) ((msix_enabled) ? 24 : 20) | 80 | #define VIRTIO_PCI_CONFIG_OFF(msix_enabled) ((msix_enabled) ? 24 : 20) |
81 | /* Deprecated: please use VIRTIO_PCI_CONFIG_OFF instead */ | 81 | /* Deprecated: please use VIRTIO_PCI_CONFIG_OFF instead */ |
82 | #define VIRTIO_PCI_CONFIG(dev) VIRTIO_PCI_CONFIG_OFF((dev)->pci_dev->msix_enabled) | 82 | #define VIRTIO_PCI_CONFIG(dev) VIRTIO_PCI_CONFIG_OFF((dev)->msix_enabled) |
83 | 83 | ||
84 | /* Virtio ABI version, this must match exactly */ | 84 | /* Virtio ABI version, this must match exactly */ |
85 | #define VIRTIO_PCI_ABI_VERSION 0 | 85 | #define VIRTIO_PCI_ABI_VERSION 0 |
diff --git a/init/main.c b/init/main.c index f9c9d9948203..b0c11cbf5ddf 100644 --- a/init/main.c +++ b/init/main.c | |||
@@ -1022,6 +1022,8 @@ static noinline void __init kernel_init_freeable(void) | |||
1022 | 1022 | ||
1023 | workqueue_init(); | 1023 | workqueue_init(); |
1024 | 1024 | ||
1025 | init_mm_internals(); | ||
1026 | |||
1025 | do_pre_smp_initcalls(); | 1027 | do_pre_smp_initcalls(); |
1026 | lockup_detector_init(); | 1028 | lockup_detector_init(); |
1027 | 1029 | ||
diff --git a/kernel/audit.c b/kernel/audit.c index 2f4964cfde0b..a871bf80fde1 100644 --- a/kernel/audit.c +++ b/kernel/audit.c | |||
@@ -160,7 +160,6 @@ static LIST_HEAD(audit_freelist); | |||
160 | 160 | ||
161 | /* queue msgs to send via kauditd_task */ | 161 | /* queue msgs to send via kauditd_task */ |
162 | static struct sk_buff_head audit_queue; | 162 | static struct sk_buff_head audit_queue; |
163 | static void kauditd_hold_skb(struct sk_buff *skb); | ||
164 | /* queue msgs due to temporary unicast send problems */ | 163 | /* queue msgs due to temporary unicast send problems */ |
165 | static struct sk_buff_head audit_retry_queue; | 164 | static struct sk_buff_head audit_retry_queue; |
166 | /* queue msgs waiting for new auditd connection */ | 165 | /* queue msgs waiting for new auditd connection */ |
@@ -454,30 +453,6 @@ static void auditd_set(int pid, u32 portid, struct net *net) | |||
454 | } | 453 | } |
455 | 454 | ||
456 | /** | 455 | /** |
457 | * auditd_reset - Disconnect the auditd connection | ||
458 | * | ||
459 | * Description: | ||
460 | * Break the auditd/kauditd connection and move all the queued records into the | ||
461 | * hold queue in case auditd reconnects. | ||
462 | */ | ||
463 | static void auditd_reset(void) | ||
464 | { | ||
465 | struct sk_buff *skb; | ||
466 | |||
467 | /* if it isn't already broken, break the connection */ | ||
468 | rcu_read_lock(); | ||
469 | if (auditd_conn.pid) | ||
470 | auditd_set(0, 0, NULL); | ||
471 | rcu_read_unlock(); | ||
472 | |||
473 | /* flush all of the main and retry queues to the hold queue */ | ||
474 | while ((skb = skb_dequeue(&audit_retry_queue))) | ||
475 | kauditd_hold_skb(skb); | ||
476 | while ((skb = skb_dequeue(&audit_queue))) | ||
477 | kauditd_hold_skb(skb); | ||
478 | } | ||
479 | |||
480 | /** | ||
481 | * kauditd_print_skb - Print the audit record to the ring buffer | 456 | * kauditd_print_skb - Print the audit record to the ring buffer |
482 | * @skb: audit record | 457 | * @skb: audit record |
483 | * | 458 | * |
@@ -505,9 +480,6 @@ static void kauditd_rehold_skb(struct sk_buff *skb) | |||
505 | { | 480 | { |
506 | /* put the record back in the queue at the same place */ | 481 | /* put the record back in the queue at the same place */ |
507 | skb_queue_head(&audit_hold_queue, skb); | 482 | skb_queue_head(&audit_hold_queue, skb); |
508 | |||
509 | /* fail the auditd connection */ | ||
510 | auditd_reset(); | ||
511 | } | 483 | } |
512 | 484 | ||
513 | /** | 485 | /** |
@@ -544,9 +516,6 @@ static void kauditd_hold_skb(struct sk_buff *skb) | |||
544 | /* we have no other options - drop the message */ | 516 | /* we have no other options - drop the message */ |
545 | audit_log_lost("kauditd hold queue overflow"); | 517 | audit_log_lost("kauditd hold queue overflow"); |
546 | kfree_skb(skb); | 518 | kfree_skb(skb); |
547 | |||
548 | /* fail the auditd connection */ | ||
549 | auditd_reset(); | ||
550 | } | 519 | } |
551 | 520 | ||
552 | /** | 521 | /** |
@@ -567,6 +536,30 @@ static void kauditd_retry_skb(struct sk_buff *skb) | |||
567 | } | 536 | } |
568 | 537 | ||
569 | /** | 538 | /** |
539 | * auditd_reset - Disconnect the auditd connection | ||
540 | * | ||
541 | * Description: | ||
542 | * Break the auditd/kauditd connection and move all the queued records into the | ||
543 | * hold queue in case auditd reconnects. | ||
544 | */ | ||
545 | static void auditd_reset(void) | ||
546 | { | ||
547 | struct sk_buff *skb; | ||
548 | |||
549 | /* if it isn't already broken, break the connection */ | ||
550 | rcu_read_lock(); | ||
551 | if (auditd_conn.pid) | ||
552 | auditd_set(0, 0, NULL); | ||
553 | rcu_read_unlock(); | ||
554 | |||
555 | /* flush all of the main and retry queues to the hold queue */ | ||
556 | while ((skb = skb_dequeue(&audit_retry_queue))) | ||
557 | kauditd_hold_skb(skb); | ||
558 | while ((skb = skb_dequeue(&audit_queue))) | ||
559 | kauditd_hold_skb(skb); | ||
560 | } | ||
561 | |||
562 | /** | ||
570 | * auditd_send_unicast_skb - Send a record via unicast to auditd | 563 | * auditd_send_unicast_skb - Send a record via unicast to auditd |
571 | * @skb: audit record | 564 | * @skb: audit record |
572 | * | 565 | * |
@@ -758,6 +751,7 @@ static int kauditd_thread(void *dummy) | |||
758 | NULL, kauditd_rehold_skb); | 751 | NULL, kauditd_rehold_skb); |
759 | if (rc < 0) { | 752 | if (rc < 0) { |
760 | sk = NULL; | 753 | sk = NULL; |
754 | auditd_reset(); | ||
761 | goto main_queue; | 755 | goto main_queue; |
762 | } | 756 | } |
763 | 757 | ||
@@ -767,6 +761,7 @@ static int kauditd_thread(void *dummy) | |||
767 | NULL, kauditd_hold_skb); | 761 | NULL, kauditd_hold_skb); |
768 | if (rc < 0) { | 762 | if (rc < 0) { |
769 | sk = NULL; | 763 | sk = NULL; |
764 | auditd_reset(); | ||
770 | goto main_queue; | 765 | goto main_queue; |
771 | } | 766 | } |
772 | 767 | ||
@@ -775,16 +770,18 @@ main_queue: | |||
775 | * unicast, dump failed record sends to the retry queue; if | 770 | * unicast, dump failed record sends to the retry queue; if |
776 | * sk == NULL due to previous failures we will just do the | 771 | * sk == NULL due to previous failures we will just do the |
777 | * multicast send and move the record to the retry queue */ | 772 | * multicast send and move the record to the retry queue */ |
778 | kauditd_send_queue(sk, portid, &audit_queue, 1, | 773 | rc = kauditd_send_queue(sk, portid, &audit_queue, 1, |
779 | kauditd_send_multicast_skb, | 774 | kauditd_send_multicast_skb, |
780 | kauditd_retry_skb); | 775 | kauditd_retry_skb); |
776 | if (sk == NULL || rc < 0) | ||
777 | auditd_reset(); | ||
778 | sk = NULL; | ||
781 | 779 | ||
782 | /* drop our netns reference, no auditd sends past this line */ | 780 | /* drop our netns reference, no auditd sends past this line */ |
783 | if (net) { | 781 | if (net) { |
784 | put_net(net); | 782 | put_net(net); |
785 | net = NULL; | 783 | net = NULL; |
786 | } | 784 | } |
787 | sk = NULL; | ||
788 | 785 | ||
789 | /* we have processed all the queues so wake everyone */ | 786 | /* we have processed all the queues so wake everyone */ |
790 | wake_up(&audit_backlog_wait); | 787 | wake_up(&audit_backlog_wait); |
diff --git a/kernel/audit.h b/kernel/audit.h index 0f1cf6d1878a..0d87f8ab8778 100644 --- a/kernel/audit.h +++ b/kernel/audit.h | |||
@@ -333,13 +333,7 @@ extern u32 audit_sig_sid; | |||
333 | extern int audit_filter(int msgtype, unsigned int listtype); | 333 | extern int audit_filter(int msgtype, unsigned int listtype); |
334 | 334 | ||
335 | #ifdef CONFIG_AUDITSYSCALL | 335 | #ifdef CONFIG_AUDITSYSCALL |
336 | extern int __audit_signal_info(int sig, struct task_struct *t); | 336 | extern int audit_signal_info(int sig, struct task_struct *t); |
337 | static inline int audit_signal_info(int sig, struct task_struct *t) | ||
338 | { | ||
339 | if (auditd_test_task(t) || (audit_signals && !audit_dummy_context())) | ||
340 | return __audit_signal_info(sig, t); | ||
341 | return 0; | ||
342 | } | ||
343 | extern void audit_filter_inodes(struct task_struct *, struct audit_context *); | 337 | extern void audit_filter_inodes(struct task_struct *, struct audit_context *); |
344 | extern struct list_head *audit_killed_trees(void); | 338 | extern struct list_head *audit_killed_trees(void); |
345 | #else | 339 | #else |
diff --git a/kernel/auditsc.c b/kernel/auditsc.c index e59ffc7fc522..1c2333155893 100644 --- a/kernel/auditsc.c +++ b/kernel/auditsc.c | |||
@@ -2249,26 +2249,27 @@ void __audit_ptrace(struct task_struct *t) | |||
2249 | * If the audit subsystem is being terminated, record the task (pid) | 2249 | * If the audit subsystem is being terminated, record the task (pid) |
2250 | * and uid that is doing that. | 2250 | * and uid that is doing that. |
2251 | */ | 2251 | */ |
2252 | int __audit_signal_info(int sig, struct task_struct *t) | 2252 | int audit_signal_info(int sig, struct task_struct *t) |
2253 | { | 2253 | { |
2254 | struct audit_aux_data_pids *axp; | 2254 | struct audit_aux_data_pids *axp; |
2255 | struct task_struct *tsk = current; | 2255 | struct task_struct *tsk = current; |
2256 | struct audit_context *ctx = tsk->audit_context; | 2256 | struct audit_context *ctx = tsk->audit_context; |
2257 | kuid_t uid = current_uid(), t_uid = task_uid(t); | 2257 | kuid_t uid = current_uid(), t_uid = task_uid(t); |
2258 | 2258 | ||
2259 | if (auditd_test_task(t)) { | 2259 | if (auditd_test_task(t) && |
2260 | if (sig == SIGTERM || sig == SIGHUP || sig == SIGUSR1 || sig == SIGUSR2) { | 2260 | (sig == SIGTERM || sig == SIGHUP || |
2261 | audit_sig_pid = task_tgid_nr(tsk); | 2261 | sig == SIGUSR1 || sig == SIGUSR2)) { |
2262 | if (uid_valid(tsk->loginuid)) | 2262 | audit_sig_pid = task_tgid_nr(tsk); |
2263 | audit_sig_uid = tsk->loginuid; | 2263 | if (uid_valid(tsk->loginuid)) |
2264 | else | 2264 | audit_sig_uid = tsk->loginuid; |
2265 | audit_sig_uid = uid; | 2265 | else |
2266 | security_task_getsecid(tsk, &audit_sig_sid); | 2266 | audit_sig_uid = uid; |
2267 | } | 2267 | security_task_getsecid(tsk, &audit_sig_sid); |
2268 | if (!audit_signals || audit_dummy_context()) | ||
2269 | return 0; | ||
2270 | } | 2268 | } |
2271 | 2269 | ||
2270 | if (!audit_signals || audit_dummy_context()) | ||
2271 | return 0; | ||
2272 | |||
2272 | /* optimize the common case by putting first signal recipient directly | 2273 | /* optimize the common case by putting first signal recipient directly |
2273 | * in audit_context */ | 2274 | * in audit_context */ |
2274 | if (!ctx->target_pid) { | 2275 | if (!ctx->target_pid) { |
diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c index f45827e205d3..b4f1cb0c5ac7 100644 --- a/kernel/bpf/core.c +++ b/kernel/bpf/core.c | |||
@@ -1162,12 +1162,12 @@ out: | |||
1162 | LD_ABS_W: /* BPF_R0 = ntohl(*(u32 *) (skb->data + imm32)) */ | 1162 | LD_ABS_W: /* BPF_R0 = ntohl(*(u32 *) (skb->data + imm32)) */ |
1163 | off = IMM; | 1163 | off = IMM; |
1164 | load_word: | 1164 | load_word: |
1165 | /* BPF_LD + BPD_ABS and BPF_LD + BPF_IND insns are | 1165 | /* BPF_LD + BPD_ABS and BPF_LD + BPF_IND insns are only |
1166 | * only appearing in the programs where ctx == | 1166 | * appearing in the programs where ctx == skb |
1167 | * skb. All programs keep 'ctx' in regs[BPF_REG_CTX] | 1167 | * (see may_access_skb() in the verifier). All programs |
1168 | * == BPF_R6, bpf_convert_filter() saves it in BPF_R6, | 1168 | * keep 'ctx' in regs[BPF_REG_CTX] == BPF_R6, |
1169 | * internal BPF verifier will check that BPF_R6 == | 1169 | * bpf_convert_filter() saves it in BPF_R6, internal BPF |
1170 | * ctx. | 1170 | * verifier will check that BPF_R6 == ctx. |
1171 | * | 1171 | * |
1172 | * BPF_ABS and BPF_IND are wrappers of function calls, | 1172 | * BPF_ABS and BPF_IND are wrappers of function calls, |
1173 | * so they scratch BPF_R1-BPF_R5 registers, preserve | 1173 | * so they scratch BPF_R1-BPF_R5 registers, preserve |
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c index 7af0dcc5d755..821f9e807de5 100644 --- a/kernel/bpf/syscall.c +++ b/kernel/bpf/syscall.c | |||
@@ -617,6 +617,14 @@ static void fixup_bpf_calls(struct bpf_prog *prog) | |||
617 | if (insn->imm == BPF_FUNC_xdp_adjust_head) | 617 | if (insn->imm == BPF_FUNC_xdp_adjust_head) |
618 | prog->xdp_adjust_head = 1; | 618 | prog->xdp_adjust_head = 1; |
619 | if (insn->imm == BPF_FUNC_tail_call) { | 619 | if (insn->imm == BPF_FUNC_tail_call) { |
620 | /* If we tail call into other programs, we | ||
621 | * cannot make any assumptions since they | ||
622 | * can be replaced dynamically during runtime | ||
623 | * in the program array. | ||
624 | */ | ||
625 | prog->cb_access = 1; | ||
626 | prog->xdp_adjust_head = 1; | ||
627 | |||
620 | /* mark bpf_tail_call as different opcode | 628 | /* mark bpf_tail_call as different opcode |
621 | * to avoid conditional branch in | 629 | * to avoid conditional branch in |
622 | * interpeter for every normal call | 630 | * interpeter for every normal call |
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index 796b68d00119..a834068a400e 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c | |||
@@ -765,38 +765,56 @@ static bool is_pointer_value(struct bpf_verifier_env *env, int regno) | |||
765 | } | 765 | } |
766 | } | 766 | } |
767 | 767 | ||
768 | static int check_ptr_alignment(struct bpf_verifier_env *env, | 768 | static int check_pkt_ptr_alignment(const struct bpf_reg_state *reg, |
769 | struct bpf_reg_state *reg, int off, int size) | 769 | int off, int size) |
770 | { | 770 | { |
771 | if (reg->type != PTR_TO_PACKET && reg->type != PTR_TO_MAP_VALUE_ADJ) { | ||
772 | if (off % size != 0) { | ||
773 | verbose("misaligned access off %d size %d\n", | ||
774 | off, size); | ||
775 | return -EACCES; | ||
776 | } else { | ||
777 | return 0; | ||
778 | } | ||
779 | } | ||
780 | |||
781 | if (IS_ENABLED(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)) | ||
782 | /* misaligned access to packet is ok on x86,arm,arm64 */ | ||
783 | return 0; | ||
784 | |||
785 | if (reg->id && size != 1) { | 771 | if (reg->id && size != 1) { |
786 | verbose("Unknown packet alignment. Only byte-sized access allowed\n"); | 772 | verbose("Unknown alignment. Only byte-sized access allowed in packet access.\n"); |
787 | return -EACCES; | 773 | return -EACCES; |
788 | } | 774 | } |
789 | 775 | ||
790 | /* skb->data is NET_IP_ALIGN-ed */ | 776 | /* skb->data is NET_IP_ALIGN-ed */ |
791 | if (reg->type == PTR_TO_PACKET && | 777 | if ((NET_IP_ALIGN + reg->off + off) % size != 0) { |
792 | (NET_IP_ALIGN + reg->off + off) % size != 0) { | ||
793 | verbose("misaligned packet access off %d+%d+%d size %d\n", | 778 | verbose("misaligned packet access off %d+%d+%d size %d\n", |
794 | NET_IP_ALIGN, reg->off, off, size); | 779 | NET_IP_ALIGN, reg->off, off, size); |
795 | return -EACCES; | 780 | return -EACCES; |
796 | } | 781 | } |
782 | |||
797 | return 0; | 783 | return 0; |
798 | } | 784 | } |
799 | 785 | ||
786 | static int check_val_ptr_alignment(const struct bpf_reg_state *reg, | ||
787 | int size) | ||
788 | { | ||
789 | if (size != 1) { | ||
790 | verbose("Unknown alignment. Only byte-sized access allowed in value access.\n"); | ||
791 | return -EACCES; | ||
792 | } | ||
793 | |||
794 | return 0; | ||
795 | } | ||
796 | |||
797 | static int check_ptr_alignment(const struct bpf_reg_state *reg, | ||
798 | int off, int size) | ||
799 | { | ||
800 | switch (reg->type) { | ||
801 | case PTR_TO_PACKET: | ||
802 | return IS_ENABLED(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) ? 0 : | ||
803 | check_pkt_ptr_alignment(reg, off, size); | ||
804 | case PTR_TO_MAP_VALUE_ADJ: | ||
805 | return IS_ENABLED(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) ? 0 : | ||
806 | check_val_ptr_alignment(reg, size); | ||
807 | default: | ||
808 | if (off % size != 0) { | ||
809 | verbose("misaligned access off %d size %d\n", | ||
810 | off, size); | ||
811 | return -EACCES; | ||
812 | } | ||
813 | |||
814 | return 0; | ||
815 | } | ||
816 | } | ||
817 | |||
800 | /* check whether memory at (regno + off) is accessible for t = (read | write) | 818 | /* check whether memory at (regno + off) is accessible for t = (read | write) |
801 | * if t==write, value_regno is a register which value is stored into memory | 819 | * if t==write, value_regno is a register which value is stored into memory |
802 | * if t==read, value_regno is a register which will receive the value from memory | 820 | * if t==read, value_regno is a register which will receive the value from memory |
@@ -818,7 +836,7 @@ static int check_mem_access(struct bpf_verifier_env *env, u32 regno, int off, | |||
818 | if (size < 0) | 836 | if (size < 0) |
819 | return size; | 837 | return size; |
820 | 838 | ||
821 | err = check_ptr_alignment(env, reg, off, size); | 839 | err = check_ptr_alignment(reg, off, size); |
822 | if (err) | 840 | if (err) |
823 | return err; | 841 | return err; |
824 | 842 | ||
@@ -1925,6 +1943,7 @@ static int check_alu_op(struct bpf_verifier_env *env, struct bpf_insn *insn) | |||
1925 | * register as unknown. | 1943 | * register as unknown. |
1926 | */ | 1944 | */ |
1927 | if (env->allow_ptr_leaks && | 1945 | if (env->allow_ptr_leaks && |
1946 | BPF_CLASS(insn->code) == BPF_ALU64 && opcode == BPF_ADD && | ||
1928 | (dst_reg->type == PTR_TO_MAP_VALUE || | 1947 | (dst_reg->type == PTR_TO_MAP_VALUE || |
1929 | dst_reg->type == PTR_TO_MAP_VALUE_ADJ)) | 1948 | dst_reg->type == PTR_TO_MAP_VALUE_ADJ)) |
1930 | dst_reg->type = PTR_TO_MAP_VALUE_ADJ; | 1949 | dst_reg->type = PTR_TO_MAP_VALUE_ADJ; |
@@ -1973,14 +1992,15 @@ static void find_good_pkt_pointers(struct bpf_verifier_state *state, | |||
1973 | 1992 | ||
1974 | for (i = 0; i < MAX_BPF_REG; i++) | 1993 | for (i = 0; i < MAX_BPF_REG; i++) |
1975 | if (regs[i].type == PTR_TO_PACKET && regs[i].id == dst_reg->id) | 1994 | if (regs[i].type == PTR_TO_PACKET && regs[i].id == dst_reg->id) |
1976 | regs[i].range = dst_reg->off; | 1995 | /* keep the maximum range already checked */ |
1996 | regs[i].range = max(regs[i].range, dst_reg->off); | ||
1977 | 1997 | ||
1978 | for (i = 0; i < MAX_BPF_STACK; i += BPF_REG_SIZE) { | 1998 | for (i = 0; i < MAX_BPF_STACK; i += BPF_REG_SIZE) { |
1979 | if (state->stack_slot_type[i] != STACK_SPILL) | 1999 | if (state->stack_slot_type[i] != STACK_SPILL) |
1980 | continue; | 2000 | continue; |
1981 | reg = &state->spilled_regs[i / BPF_REG_SIZE]; | 2001 | reg = &state->spilled_regs[i / BPF_REG_SIZE]; |
1982 | if (reg->type == PTR_TO_PACKET && reg->id == dst_reg->id) | 2002 | if (reg->type == PTR_TO_PACKET && reg->id == dst_reg->id) |
1983 | reg->range = dst_reg->off; | 2003 | reg->range = max(reg->range, dst_reg->off); |
1984 | } | 2004 | } |
1985 | } | 2005 | } |
1986 | 2006 | ||
diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c index 48851327a15e..687f5e0194ef 100644 --- a/kernel/cgroup/cgroup.c +++ b/kernel/cgroup/cgroup.c | |||
@@ -2425,11 +2425,12 @@ ssize_t __cgroup_procs_write(struct kernfs_open_file *of, char *buf, | |||
2425 | tsk = tsk->group_leader; | 2425 | tsk = tsk->group_leader; |
2426 | 2426 | ||
2427 | /* | 2427 | /* |
2428 | * Workqueue threads may acquire PF_NO_SETAFFINITY and become | 2428 | * kthreads may acquire PF_NO_SETAFFINITY during initialization. |
2429 | * trapped in a cpuset, or RT worker may be born in a cgroup | 2429 | * If userland migrates such a kthread to a non-root cgroup, it can |
2430 | * with no rt_runtime allocated. Just say no. | 2430 | * become trapped in a cpuset, or RT kthread may be born in a |
2431 | * cgroup with no rt_runtime allocated. Just say no. | ||
2431 | */ | 2432 | */ |
2432 | if (tsk == kthreadd_task || (tsk->flags & PF_NO_SETAFFINITY)) { | 2433 | if (tsk->no_cgroup_migration || (tsk->flags & PF_NO_SETAFFINITY)) { |
2433 | ret = -EINVAL; | 2434 | ret = -EINVAL; |
2434 | goto out_unlock_rcu; | 2435 | goto out_unlock_rcu; |
2435 | } | 2436 | } |
diff --git a/kernel/irq/affinity.c b/kernel/irq/affinity.c index 4544b115f5eb..e2d356dd7581 100644 --- a/kernel/irq/affinity.c +++ b/kernel/irq/affinity.c | |||
@@ -59,7 +59,7 @@ static int get_nodes_in_cpumask(const struct cpumask *mask, nodemask_t *nodemsk) | |||
59 | struct cpumask * | 59 | struct cpumask * |
60 | irq_create_affinity_masks(int nvecs, const struct irq_affinity *affd) | 60 | irq_create_affinity_masks(int nvecs, const struct irq_affinity *affd) |
61 | { | 61 | { |
62 | int n, nodes, vecs_per_node, cpus_per_vec, extra_vecs, curvec; | 62 | int n, nodes, cpus_per_vec, extra_vecs, curvec; |
63 | int affv = nvecs - affd->pre_vectors - affd->post_vectors; | 63 | int affv = nvecs - affd->pre_vectors - affd->post_vectors; |
64 | int last_affv = affv + affd->pre_vectors; | 64 | int last_affv = affv + affd->pre_vectors; |
65 | nodemask_t nodemsk = NODE_MASK_NONE; | 65 | nodemask_t nodemsk = NODE_MASK_NONE; |
@@ -94,19 +94,21 @@ irq_create_affinity_masks(int nvecs, const struct irq_affinity *affd) | |||
94 | goto done; | 94 | goto done; |
95 | } | 95 | } |
96 | 96 | ||
97 | /* Spread the vectors per node */ | ||
98 | vecs_per_node = affv / nodes; | ||
99 | /* Account for rounding errors */ | ||
100 | extra_vecs = affv - (nodes * vecs_per_node); | ||
101 | |||
102 | for_each_node_mask(n, nodemsk) { | 97 | for_each_node_mask(n, nodemsk) { |
103 | int ncpus, v, vecs_to_assign = vecs_per_node; | 98 | int ncpus, v, vecs_to_assign, vecs_per_node; |
99 | |||
100 | /* Spread the vectors per node */ | ||
101 | vecs_per_node = (affv - (curvec - affd->pre_vectors)) / nodes; | ||
104 | 102 | ||
105 | /* Get the cpus on this node which are in the mask */ | 103 | /* Get the cpus on this node which are in the mask */ |
106 | cpumask_and(nmsk, cpu_online_mask, cpumask_of_node(n)); | 104 | cpumask_and(nmsk, cpu_online_mask, cpumask_of_node(n)); |
107 | 105 | ||
108 | /* Calculate the number of cpus per vector */ | 106 | /* Calculate the number of cpus per vector */ |
109 | ncpus = cpumask_weight(nmsk); | 107 | ncpus = cpumask_weight(nmsk); |
108 | vecs_to_assign = min(vecs_per_node, ncpus); | ||
109 | |||
110 | /* Account for rounding errors */ | ||
111 | extra_vecs = ncpus - vecs_to_assign * (ncpus / vecs_to_assign); | ||
110 | 112 | ||
111 | for (v = 0; curvec < last_affv && v < vecs_to_assign; | 113 | for (v = 0; curvec < last_affv && v < vecs_to_assign; |
112 | curvec++, v++) { | 114 | curvec++, v++) { |
@@ -115,14 +117,14 @@ irq_create_affinity_masks(int nvecs, const struct irq_affinity *affd) | |||
115 | /* Account for extra vectors to compensate rounding errors */ | 117 | /* Account for extra vectors to compensate rounding errors */ |
116 | if (extra_vecs) { | 118 | if (extra_vecs) { |
117 | cpus_per_vec++; | 119 | cpus_per_vec++; |
118 | if (!--extra_vecs) | 120 | --extra_vecs; |
119 | vecs_per_node++; | ||
120 | } | 121 | } |
121 | irq_spread_init_one(masks + curvec, nmsk, cpus_per_vec); | 122 | irq_spread_init_one(masks + curvec, nmsk, cpus_per_vec); |
122 | } | 123 | } |
123 | 124 | ||
124 | if (curvec >= last_affv) | 125 | if (curvec >= last_affv) |
125 | break; | 126 | break; |
127 | --nodes; | ||
126 | } | 128 | } |
127 | 129 | ||
128 | done: | 130 | done: |
diff --git a/kernel/kthread.c b/kernel/kthread.c index 2f26adea0f84..26db528c1d88 100644 --- a/kernel/kthread.c +++ b/kernel/kthread.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <linux/freezer.h> | 20 | #include <linux/freezer.h> |
21 | #include <linux/ptrace.h> | 21 | #include <linux/ptrace.h> |
22 | #include <linux/uaccess.h> | 22 | #include <linux/uaccess.h> |
23 | #include <linux/cgroup.h> | ||
23 | #include <trace/events/sched.h> | 24 | #include <trace/events/sched.h> |
24 | 25 | ||
25 | static DEFINE_SPINLOCK(kthread_create_lock); | 26 | static DEFINE_SPINLOCK(kthread_create_lock); |
@@ -225,6 +226,7 @@ static int kthread(void *_create) | |||
225 | 226 | ||
226 | ret = -EINTR; | 227 | ret = -EINTR; |
227 | if (!test_bit(KTHREAD_SHOULD_STOP, &self->flags)) { | 228 | if (!test_bit(KTHREAD_SHOULD_STOP, &self->flags)) { |
229 | cgroup_kthread_ready(); | ||
228 | __kthread_parkme(self); | 230 | __kthread_parkme(self); |
229 | ret = threadfn(data); | 231 | ret = threadfn(data); |
230 | } | 232 | } |
@@ -538,6 +540,7 @@ int kthreadd(void *unused) | |||
538 | set_mems_allowed(node_states[N_MEMORY]); | 540 | set_mems_allowed(node_states[N_MEMORY]); |
539 | 541 | ||
540 | current->flags |= PF_NOFREEZE; | 542 | current->flags |= PF_NOFREEZE; |
543 | cgroup_init_kthreadd(); | ||
541 | 544 | ||
542 | for (;;) { | 545 | for (;;) { |
543 | set_current_state(TASK_INTERRUPTIBLE); | 546 | set_current_state(TASK_INTERRUPTIBLE); |
diff --git a/kernel/locking/lockdep_internals.h b/kernel/locking/lockdep_internals.h index c2b88490d857..c08fbd2f5ba9 100644 --- a/kernel/locking/lockdep_internals.h +++ b/kernel/locking/lockdep_internals.h | |||
@@ -46,13 +46,13 @@ enum { | |||
46 | (LOCKF_USED_IN_HARDIRQ_READ | LOCKF_USED_IN_SOFTIRQ_READ) | 46 | (LOCKF_USED_IN_HARDIRQ_READ | LOCKF_USED_IN_SOFTIRQ_READ) |
47 | 47 | ||
48 | /* | 48 | /* |
49 | * CONFIG_PROVE_LOCKING_SMALL is defined for sparc. Sparc requires .text, | 49 | * CONFIG_LOCKDEP_SMALL is defined for sparc. Sparc requires .text, |
50 | * .data and .bss to fit in required 32MB limit for the kernel. With | 50 | * .data and .bss to fit in required 32MB limit for the kernel. With |
51 | * PROVE_LOCKING we could go over this limit and cause system boot-up problems. | 51 | * CONFIG_LOCKDEP we could go over this limit and cause system boot-up problems. |
52 | * So, reduce the static allocations for lockdeps related structures so that | 52 | * So, reduce the static allocations for lockdeps related structures so that |
53 | * everything fits in current required size limit. | 53 | * everything fits in current required size limit. |
54 | */ | 54 | */ |
55 | #ifdef CONFIG_PROVE_LOCKING_SMALL | 55 | #ifdef CONFIG_LOCKDEP_SMALL |
56 | /* | 56 | /* |
57 | * MAX_LOCKDEP_ENTRIES is the maximum number of lock dependencies | 57 | * MAX_LOCKDEP_ENTRIES is the maximum number of lock dependencies |
58 | * we track. | 58 | * we track. |
diff --git a/kernel/padata.c b/kernel/padata.c index 05316c9f32da..3202aa17492c 100644 --- a/kernel/padata.c +++ b/kernel/padata.c | |||
@@ -186,19 +186,20 @@ static struct padata_priv *padata_get_next(struct parallel_data *pd) | |||
186 | 186 | ||
187 | reorder = &next_queue->reorder; | 187 | reorder = &next_queue->reorder; |
188 | 188 | ||
189 | spin_lock(&reorder->lock); | ||
189 | if (!list_empty(&reorder->list)) { | 190 | if (!list_empty(&reorder->list)) { |
190 | padata = list_entry(reorder->list.next, | 191 | padata = list_entry(reorder->list.next, |
191 | struct padata_priv, list); | 192 | struct padata_priv, list); |
192 | 193 | ||
193 | spin_lock(&reorder->lock); | ||
194 | list_del_init(&padata->list); | 194 | list_del_init(&padata->list); |
195 | atomic_dec(&pd->reorder_objects); | 195 | atomic_dec(&pd->reorder_objects); |
196 | spin_unlock(&reorder->lock); | ||
197 | 196 | ||
198 | pd->processed++; | 197 | pd->processed++; |
199 | 198 | ||
199 | spin_unlock(&reorder->lock); | ||
200 | goto out; | 200 | goto out; |
201 | } | 201 | } |
202 | spin_unlock(&reorder->lock); | ||
202 | 203 | ||
203 | if (__this_cpu_read(pd->pqueue->cpu_index) == next_queue->cpu_index) { | 204 | if (__this_cpu_read(pd->pqueue->cpu_index) == next_queue->cpu_index) { |
204 | padata = ERR_PTR(-ENODATA); | 205 | padata = ERR_PTR(-ENODATA); |
diff --git a/kernel/ptrace.c b/kernel/ptrace.c index 0af928712174..266ddcc1d8bb 100644 --- a/kernel/ptrace.c +++ b/kernel/ptrace.c | |||
@@ -184,11 +184,17 @@ static void ptrace_unfreeze_traced(struct task_struct *task) | |||
184 | 184 | ||
185 | WARN_ON(!task->ptrace || task->parent != current); | 185 | WARN_ON(!task->ptrace || task->parent != current); |
186 | 186 | ||
187 | /* | ||
188 | * PTRACE_LISTEN can allow ptrace_trap_notify to wake us up remotely. | ||
189 | * Recheck state under the lock to close this race. | ||
190 | */ | ||
187 | spin_lock_irq(&task->sighand->siglock); | 191 | spin_lock_irq(&task->sighand->siglock); |
188 | if (__fatal_signal_pending(task)) | 192 | if (task->state == __TASK_TRACED) { |
189 | wake_up_state(task, __TASK_TRACED); | 193 | if (__fatal_signal_pending(task)) |
190 | else | 194 | wake_up_state(task, __TASK_TRACED); |
191 | task->state = TASK_TRACED; | 195 | else |
196 | task->state = TASK_TRACED; | ||
197 | } | ||
192 | spin_unlock_irq(&task->sighand->siglock); | 198 | spin_unlock_irq(&task->sighand->siglock); |
193 | } | 199 | } |
194 | 200 | ||
diff --git a/kernel/sched/clock.c b/kernel/sched/clock.c index a08795e21628..00a45c45beca 100644 --- a/kernel/sched/clock.c +++ b/kernel/sched/clock.c | |||
@@ -96,10 +96,10 @@ static DEFINE_STATIC_KEY_FALSE(__sched_clock_stable); | |||
96 | static int __sched_clock_stable_early = 1; | 96 | static int __sched_clock_stable_early = 1; |
97 | 97 | ||
98 | /* | 98 | /* |
99 | * We want: ktime_get_ns() + gtod_offset == sched_clock() + raw_offset | 99 | * We want: ktime_get_ns() + __gtod_offset == sched_clock() + __sched_clock_offset |
100 | */ | 100 | */ |
101 | static __read_mostly u64 raw_offset; | 101 | __read_mostly u64 __sched_clock_offset; |
102 | static __read_mostly u64 gtod_offset; | 102 | static __read_mostly u64 __gtod_offset; |
103 | 103 | ||
104 | struct sched_clock_data { | 104 | struct sched_clock_data { |
105 | u64 tick_raw; | 105 | u64 tick_raw; |
@@ -131,17 +131,24 @@ static void __set_sched_clock_stable(void) | |||
131 | /* | 131 | /* |
132 | * Attempt to make the (initial) unstable->stable transition continuous. | 132 | * Attempt to make the (initial) unstable->stable transition continuous. |
133 | */ | 133 | */ |
134 | raw_offset = (scd->tick_gtod + gtod_offset) - (scd->tick_raw); | 134 | __sched_clock_offset = (scd->tick_gtod + __gtod_offset) - (scd->tick_raw); |
135 | 135 | ||
136 | printk(KERN_INFO "sched_clock: Marking stable (%lld, %lld)->(%lld, %lld)\n", | 136 | printk(KERN_INFO "sched_clock: Marking stable (%lld, %lld)->(%lld, %lld)\n", |
137 | scd->tick_gtod, gtod_offset, | 137 | scd->tick_gtod, __gtod_offset, |
138 | scd->tick_raw, raw_offset); | 138 | scd->tick_raw, __sched_clock_offset); |
139 | 139 | ||
140 | static_branch_enable(&__sched_clock_stable); | 140 | static_branch_enable(&__sched_clock_stable); |
141 | tick_dep_clear(TICK_DEP_BIT_CLOCK_UNSTABLE); | 141 | tick_dep_clear(TICK_DEP_BIT_CLOCK_UNSTABLE); |
142 | } | 142 | } |
143 | 143 | ||
144 | static void __clear_sched_clock_stable(struct work_struct *work) | 144 | static void __sched_clock_work(struct work_struct *work) |
145 | { | ||
146 | static_branch_disable(&__sched_clock_stable); | ||
147 | } | ||
148 | |||
149 | static DECLARE_WORK(sched_clock_work, __sched_clock_work); | ||
150 | |||
151 | static void __clear_sched_clock_stable(void) | ||
145 | { | 152 | { |
146 | struct sched_clock_data *scd = this_scd(); | 153 | struct sched_clock_data *scd = this_scd(); |
147 | 154 | ||
@@ -154,17 +161,17 @@ static void __clear_sched_clock_stable(struct work_struct *work) | |||
154 | * | 161 | * |
155 | * Still do what we can. | 162 | * Still do what we can. |
156 | */ | 163 | */ |
157 | gtod_offset = (scd->tick_raw + raw_offset) - (scd->tick_gtod); | 164 | __gtod_offset = (scd->tick_raw + __sched_clock_offset) - (scd->tick_gtod); |
158 | 165 | ||
159 | printk(KERN_INFO "sched_clock: Marking unstable (%lld, %lld)<-(%lld, %lld)\n", | 166 | printk(KERN_INFO "sched_clock: Marking unstable (%lld, %lld)<-(%lld, %lld)\n", |
160 | scd->tick_gtod, gtod_offset, | 167 | scd->tick_gtod, __gtod_offset, |
161 | scd->tick_raw, raw_offset); | 168 | scd->tick_raw, __sched_clock_offset); |
162 | 169 | ||
163 | static_branch_disable(&__sched_clock_stable); | ||
164 | tick_dep_set(TICK_DEP_BIT_CLOCK_UNSTABLE); | 170 | tick_dep_set(TICK_DEP_BIT_CLOCK_UNSTABLE); |
165 | } | ||
166 | 171 | ||
167 | static DECLARE_WORK(sched_clock_work, __clear_sched_clock_stable); | 172 | if (sched_clock_stable()) |
173 | schedule_work(&sched_clock_work); | ||
174 | } | ||
168 | 175 | ||
169 | void clear_sched_clock_stable(void) | 176 | void clear_sched_clock_stable(void) |
170 | { | 177 | { |
@@ -173,7 +180,7 @@ void clear_sched_clock_stable(void) | |||
173 | smp_mb(); /* matches sched_clock_init_late() */ | 180 | smp_mb(); /* matches sched_clock_init_late() */ |
174 | 181 | ||
175 | if (sched_clock_running == 2) | 182 | if (sched_clock_running == 2) |
176 | schedule_work(&sched_clock_work); | 183 | __clear_sched_clock_stable(); |
177 | } | 184 | } |
178 | 185 | ||
179 | void sched_clock_init_late(void) | 186 | void sched_clock_init_late(void) |
@@ -214,7 +221,7 @@ static inline u64 wrap_max(u64 x, u64 y) | |||
214 | */ | 221 | */ |
215 | static u64 sched_clock_local(struct sched_clock_data *scd) | 222 | static u64 sched_clock_local(struct sched_clock_data *scd) |
216 | { | 223 | { |
217 | u64 now, clock, old_clock, min_clock, max_clock; | 224 | u64 now, clock, old_clock, min_clock, max_clock, gtod; |
218 | s64 delta; | 225 | s64 delta; |
219 | 226 | ||
220 | again: | 227 | again: |
@@ -231,9 +238,10 @@ again: | |||
231 | * scd->tick_gtod + TICK_NSEC); | 238 | * scd->tick_gtod + TICK_NSEC); |
232 | */ | 239 | */ |
233 | 240 | ||
234 | clock = scd->tick_gtod + gtod_offset + delta; | 241 | gtod = scd->tick_gtod + __gtod_offset; |
235 | min_clock = wrap_max(scd->tick_gtod, old_clock); | 242 | clock = gtod + delta; |
236 | max_clock = wrap_max(old_clock, scd->tick_gtod + TICK_NSEC); | 243 | min_clock = wrap_max(gtod, old_clock); |
244 | max_clock = wrap_max(old_clock, gtod + TICK_NSEC); | ||
237 | 245 | ||
238 | clock = wrap_max(clock, min_clock); | 246 | clock = wrap_max(clock, min_clock); |
239 | clock = wrap_min(clock, max_clock); | 247 | clock = wrap_min(clock, max_clock); |
@@ -317,7 +325,7 @@ u64 sched_clock_cpu(int cpu) | |||
317 | u64 clock; | 325 | u64 clock; |
318 | 326 | ||
319 | if (sched_clock_stable()) | 327 | if (sched_clock_stable()) |
320 | return sched_clock() + raw_offset; | 328 | return sched_clock() + __sched_clock_offset; |
321 | 329 | ||
322 | if (unlikely(!sched_clock_running)) | 330 | if (unlikely(!sched_clock_running)) |
323 | return 0ull; | 331 | return 0ull; |
diff --git a/kernel/sysctl.c b/kernel/sysctl.c index acf0a5a06da7..8c8714fcb53c 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c | |||
@@ -2133,9 +2133,12 @@ static int do_proc_douintvec_conv(bool *negp, unsigned long *lvalp, | |||
2133 | if (write) { | 2133 | if (write) { |
2134 | if (*negp) | 2134 | if (*negp) |
2135 | return -EINVAL; | 2135 | return -EINVAL; |
2136 | if (*lvalp > UINT_MAX) | ||
2137 | return -EINVAL; | ||
2136 | *valp = *lvalp; | 2138 | *valp = *lvalp; |
2137 | } else { | 2139 | } else { |
2138 | unsigned int val = *valp; | 2140 | unsigned int val = *valp; |
2141 | *negp = false; | ||
2139 | *lvalp = (unsigned long)val; | 2142 | *lvalp = (unsigned long)val; |
2140 | } | 2143 | } |
2141 | return 0; | 2144 | return 0; |
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index b9691ee8f6c1..dd3e91d68dc7 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c | |||
@@ -3755,23 +3755,24 @@ static void __enable_ftrace_function_probe(struct ftrace_ops_hash *old_hash) | |||
3755 | ftrace_probe_registered = 1; | 3755 | ftrace_probe_registered = 1; |
3756 | } | 3756 | } |
3757 | 3757 | ||
3758 | static void __disable_ftrace_function_probe(void) | 3758 | static bool __disable_ftrace_function_probe(void) |
3759 | { | 3759 | { |
3760 | int i; | 3760 | int i; |
3761 | 3761 | ||
3762 | if (!ftrace_probe_registered) | 3762 | if (!ftrace_probe_registered) |
3763 | return; | 3763 | return false; |
3764 | 3764 | ||
3765 | for (i = 0; i < FTRACE_FUNC_HASHSIZE; i++) { | 3765 | for (i = 0; i < FTRACE_FUNC_HASHSIZE; i++) { |
3766 | struct hlist_head *hhd = &ftrace_func_hash[i]; | 3766 | struct hlist_head *hhd = &ftrace_func_hash[i]; |
3767 | if (hhd->first) | 3767 | if (hhd->first) |
3768 | return; | 3768 | return false; |
3769 | } | 3769 | } |
3770 | 3770 | ||
3771 | /* no more funcs left */ | 3771 | /* no more funcs left */ |
3772 | ftrace_shutdown(&trace_probe_ops, 0); | 3772 | ftrace_shutdown(&trace_probe_ops, 0); |
3773 | 3773 | ||
3774 | ftrace_probe_registered = 0; | 3774 | ftrace_probe_registered = 0; |
3775 | return true; | ||
3775 | } | 3776 | } |
3776 | 3777 | ||
3777 | 3778 | ||
@@ -3901,6 +3902,7 @@ static void | |||
3901 | __unregister_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops, | 3902 | __unregister_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops, |
3902 | void *data, int flags) | 3903 | void *data, int flags) |
3903 | { | 3904 | { |
3905 | struct ftrace_ops_hash old_hash_ops; | ||
3904 | struct ftrace_func_entry *rec_entry; | 3906 | struct ftrace_func_entry *rec_entry; |
3905 | struct ftrace_func_probe *entry; | 3907 | struct ftrace_func_probe *entry; |
3906 | struct ftrace_func_probe *p; | 3908 | struct ftrace_func_probe *p; |
@@ -3912,6 +3914,7 @@ __unregister_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops, | |||
3912 | struct hlist_node *tmp; | 3914 | struct hlist_node *tmp; |
3913 | char str[KSYM_SYMBOL_LEN]; | 3915 | char str[KSYM_SYMBOL_LEN]; |
3914 | int i, ret; | 3916 | int i, ret; |
3917 | bool disabled; | ||
3915 | 3918 | ||
3916 | if (glob && (strcmp(glob, "*") == 0 || !strlen(glob))) | 3919 | if (glob && (strcmp(glob, "*") == 0 || !strlen(glob))) |
3917 | func_g.search = NULL; | 3920 | func_g.search = NULL; |
@@ -3930,6 +3933,10 @@ __unregister_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops, | |||
3930 | 3933 | ||
3931 | mutex_lock(&trace_probe_ops.func_hash->regex_lock); | 3934 | mutex_lock(&trace_probe_ops.func_hash->regex_lock); |
3932 | 3935 | ||
3936 | old_hash_ops.filter_hash = old_hash; | ||
3937 | /* Probes only have filters */ | ||
3938 | old_hash_ops.notrace_hash = NULL; | ||
3939 | |||
3933 | hash = alloc_and_copy_ftrace_hash(FTRACE_HASH_DEFAULT_BITS, *orig_hash); | 3940 | hash = alloc_and_copy_ftrace_hash(FTRACE_HASH_DEFAULT_BITS, *orig_hash); |
3934 | if (!hash) | 3941 | if (!hash) |
3935 | /* Hmm, should report this somehow */ | 3942 | /* Hmm, should report this somehow */ |
@@ -3967,12 +3974,17 @@ __unregister_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops, | |||
3967 | } | 3974 | } |
3968 | } | 3975 | } |
3969 | mutex_lock(&ftrace_lock); | 3976 | mutex_lock(&ftrace_lock); |
3970 | __disable_ftrace_function_probe(); | 3977 | disabled = __disable_ftrace_function_probe(); |
3971 | /* | 3978 | /* |
3972 | * Remove after the disable is called. Otherwise, if the last | 3979 | * Remove after the disable is called. Otherwise, if the last |
3973 | * probe is removed, a null hash means *all enabled*. | 3980 | * probe is removed, a null hash means *all enabled*. |
3974 | */ | 3981 | */ |
3975 | ret = ftrace_hash_move(&trace_probe_ops, 1, orig_hash, hash); | 3982 | ret = ftrace_hash_move(&trace_probe_ops, 1, orig_hash, hash); |
3983 | |||
3984 | /* still need to update the function call sites */ | ||
3985 | if (ftrace_enabled && !disabled) | ||
3986 | ftrace_run_modify_code(&trace_probe_ops, FTRACE_UPDATE_CALLS, | ||
3987 | &old_hash_ops); | ||
3976 | synchronize_sched(); | 3988 | synchronize_sched(); |
3977 | if (!ret) | 3989 | if (!ret) |
3978 | free_ftrace_hash_rcu(old_hash); | 3990 | free_ftrace_hash_rcu(old_hash); |
@@ -5554,6 +5566,15 @@ static void clear_ftrace_pids(struct trace_array *tr) | |||
5554 | trace_free_pid_list(pid_list); | 5566 | trace_free_pid_list(pid_list); |
5555 | } | 5567 | } |
5556 | 5568 | ||
5569 | void ftrace_clear_pids(struct trace_array *tr) | ||
5570 | { | ||
5571 | mutex_lock(&ftrace_lock); | ||
5572 | |||
5573 | clear_ftrace_pids(tr); | ||
5574 | |||
5575 | mutex_unlock(&ftrace_lock); | ||
5576 | } | ||
5577 | |||
5557 | static void ftrace_pid_reset(struct trace_array *tr) | 5578 | static void ftrace_pid_reset(struct trace_array *tr) |
5558 | { | 5579 | { |
5559 | mutex_lock(&ftrace_lock); | 5580 | mutex_lock(&ftrace_lock); |
diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c index 96fc3c043ad6..ca47a4fa2986 100644 --- a/kernel/trace/ring_buffer.c +++ b/kernel/trace/ring_buffer.c | |||
@@ -3405,11 +3405,23 @@ EXPORT_SYMBOL_GPL(ring_buffer_iter_reset); | |||
3405 | int ring_buffer_iter_empty(struct ring_buffer_iter *iter) | 3405 | int ring_buffer_iter_empty(struct ring_buffer_iter *iter) |
3406 | { | 3406 | { |
3407 | struct ring_buffer_per_cpu *cpu_buffer; | 3407 | struct ring_buffer_per_cpu *cpu_buffer; |
3408 | struct buffer_page *reader; | ||
3409 | struct buffer_page *head_page; | ||
3410 | struct buffer_page *commit_page; | ||
3411 | unsigned commit; | ||
3408 | 3412 | ||
3409 | cpu_buffer = iter->cpu_buffer; | 3413 | cpu_buffer = iter->cpu_buffer; |
3410 | 3414 | ||
3411 | return iter->head_page == cpu_buffer->commit_page && | 3415 | /* Remember, trace recording is off when iterator is in use */ |
3412 | iter->head == rb_commit_index(cpu_buffer); | 3416 | reader = cpu_buffer->reader_page; |
3417 | head_page = cpu_buffer->head_page; | ||
3418 | commit_page = cpu_buffer->commit_page; | ||
3419 | commit = rb_page_commit(commit_page); | ||
3420 | |||
3421 | return ((iter->head_page == commit_page && iter->head == commit) || | ||
3422 | (iter->head_page == reader && commit_page == head_page && | ||
3423 | head_page->read == commit && | ||
3424 | iter->head == rb_page_commit(cpu_buffer->reader_page))); | ||
3413 | } | 3425 | } |
3414 | EXPORT_SYMBOL_GPL(ring_buffer_iter_empty); | 3426 | EXPORT_SYMBOL_GPL(ring_buffer_iter_empty); |
3415 | 3427 | ||
@@ -4826,9 +4838,9 @@ static __init int test_ringbuffer(void) | |||
4826 | rb_data[cpu].cnt = cpu; | 4838 | rb_data[cpu].cnt = cpu; |
4827 | rb_threads[cpu] = kthread_create(rb_test, &rb_data[cpu], | 4839 | rb_threads[cpu] = kthread_create(rb_test, &rb_data[cpu], |
4828 | "rbtester/%d", cpu); | 4840 | "rbtester/%d", cpu); |
4829 | if (WARN_ON(!rb_threads[cpu])) { | 4841 | if (WARN_ON(IS_ERR(rb_threads[cpu]))) { |
4830 | pr_cont("FAILED\n"); | 4842 | pr_cont("FAILED\n"); |
4831 | ret = -1; | 4843 | ret = PTR_ERR(rb_threads[cpu]); |
4832 | goto out_free; | 4844 | goto out_free; |
4833 | } | 4845 | } |
4834 | 4846 | ||
@@ -4838,9 +4850,9 @@ static __init int test_ringbuffer(void) | |||
4838 | 4850 | ||
4839 | /* Now create the rb hammer! */ | 4851 | /* Now create the rb hammer! */ |
4840 | rb_hammer = kthread_run(rb_hammer_test, NULL, "rbhammer"); | 4852 | rb_hammer = kthread_run(rb_hammer_test, NULL, "rbhammer"); |
4841 | if (WARN_ON(!rb_hammer)) { | 4853 | if (WARN_ON(IS_ERR(rb_hammer))) { |
4842 | pr_cont("FAILED\n"); | 4854 | pr_cont("FAILED\n"); |
4843 | ret = -1; | 4855 | ret = PTR_ERR(rb_hammer); |
4844 | goto out_free; | 4856 | goto out_free; |
4845 | } | 4857 | } |
4846 | 4858 | ||
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index f35109514a01..0ad75e9698f6 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c | |||
@@ -6733,11 +6733,13 @@ ftrace_trace_snapshot_callback(struct ftrace_hash *hash, | |||
6733 | return ret; | 6733 | return ret; |
6734 | 6734 | ||
6735 | out_reg: | 6735 | out_reg: |
6736 | ret = register_ftrace_function_probe(glob, ops, count); | 6736 | ret = alloc_snapshot(&global_trace); |
6737 | if (ret < 0) | ||
6738 | goto out; | ||
6737 | 6739 | ||
6738 | if (ret >= 0) | 6740 | ret = register_ftrace_function_probe(glob, ops, count); |
6739 | alloc_snapshot(&global_trace); | ||
6740 | 6741 | ||
6742 | out: | ||
6741 | return ret < 0 ? ret : 0; | 6743 | return ret < 0 ? ret : 0; |
6742 | } | 6744 | } |
6743 | 6745 | ||
@@ -7402,6 +7404,7 @@ static int instance_rmdir(const char *name) | |||
7402 | 7404 | ||
7403 | tracing_set_nop(tr); | 7405 | tracing_set_nop(tr); |
7404 | event_trace_del_tracer(tr); | 7406 | event_trace_del_tracer(tr); |
7407 | ftrace_clear_pids(tr); | ||
7405 | ftrace_destroy_function_files(tr); | 7408 | ftrace_destroy_function_files(tr); |
7406 | tracefs_remove_recursive(tr->dir); | 7409 | tracefs_remove_recursive(tr->dir); |
7407 | free_trace_buffers(tr); | 7410 | free_trace_buffers(tr); |
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h index ae1cce91fead..d19d52d600d6 100644 --- a/kernel/trace/trace.h +++ b/kernel/trace/trace.h | |||
@@ -896,6 +896,7 @@ int using_ftrace_ops_list_func(void); | |||
896 | void ftrace_init_tracefs(struct trace_array *tr, struct dentry *d_tracer); | 896 | void ftrace_init_tracefs(struct trace_array *tr, struct dentry *d_tracer); |
897 | void ftrace_init_tracefs_toplevel(struct trace_array *tr, | 897 | void ftrace_init_tracefs_toplevel(struct trace_array *tr, |
898 | struct dentry *d_tracer); | 898 | struct dentry *d_tracer); |
899 | void ftrace_clear_pids(struct trace_array *tr); | ||
899 | #else | 900 | #else |
900 | static inline int ftrace_trace_task(struct trace_array *tr) | 901 | static inline int ftrace_trace_task(struct trace_array *tr) |
901 | { | 902 | { |
@@ -914,6 +915,7 @@ ftrace_init_global_array_ops(struct trace_array *tr) { } | |||
914 | static inline void ftrace_reset_array_ops(struct trace_array *tr) { } | 915 | static inline void ftrace_reset_array_ops(struct trace_array *tr) { } |
915 | static inline void ftrace_init_tracefs(struct trace_array *tr, struct dentry *d) { } | 916 | static inline void ftrace_init_tracefs(struct trace_array *tr, struct dentry *d) { } |
916 | static inline void ftrace_init_tracefs_toplevel(struct trace_array *tr, struct dentry *d) { } | 917 | static inline void ftrace_init_tracefs_toplevel(struct trace_array *tr, struct dentry *d) { } |
918 | static inline void ftrace_clear_pids(struct trace_array *tr) { } | ||
917 | /* ftace_func_t type is not defined, use macro instead of static inline */ | 919 | /* ftace_func_t type is not defined, use macro instead of static inline */ |
918 | #define ftrace_init_array_ops(tr, func) do { } while (0) | 920 | #define ftrace_init_array_ops(tr, func) do { } while (0) |
919 | #endif /* CONFIG_FUNCTION_TRACER */ | 921 | #endif /* CONFIG_FUNCTION_TRACER */ |
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 97d62c2da6c2..fa16c0f82d6e 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug | |||
@@ -1103,9 +1103,6 @@ config PROVE_LOCKING | |||
1103 | 1103 | ||
1104 | For more details, see Documentation/locking/lockdep-design.txt. | 1104 | For more details, see Documentation/locking/lockdep-design.txt. |
1105 | 1105 | ||
1106 | config PROVE_LOCKING_SMALL | ||
1107 | bool | ||
1108 | |||
1109 | config LOCKDEP | 1106 | config LOCKDEP |
1110 | bool | 1107 | bool |
1111 | depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT | 1108 | depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT |
@@ -1114,6 +1111,9 @@ config LOCKDEP | |||
1114 | select KALLSYMS | 1111 | select KALLSYMS |
1115 | select KALLSYMS_ALL | 1112 | select KALLSYMS_ALL |
1116 | 1113 | ||
1114 | config LOCKDEP_SMALL | ||
1115 | bool | ||
1116 | |||
1117 | config LOCK_STAT | 1117 | config LOCK_STAT |
1118 | bool "Lock usage statistics" | 1118 | bool "Lock usage statistics" |
1119 | depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT | 1119 | depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT |
diff --git a/lib/iov_iter.c b/lib/iov_iter.c index e68604ae3ced..60abc44385b7 100644 --- a/lib/iov_iter.c +++ b/lib/iov_iter.c | |||
@@ -786,6 +786,68 @@ void iov_iter_advance(struct iov_iter *i, size_t size) | |||
786 | } | 786 | } |
787 | EXPORT_SYMBOL(iov_iter_advance); | 787 | EXPORT_SYMBOL(iov_iter_advance); |
788 | 788 | ||
789 | void iov_iter_revert(struct iov_iter *i, size_t unroll) | ||
790 | { | ||
791 | if (!unroll) | ||
792 | return; | ||
793 | i->count += unroll; | ||
794 | if (unlikely(i->type & ITER_PIPE)) { | ||
795 | struct pipe_inode_info *pipe = i->pipe; | ||
796 | int idx = i->idx; | ||
797 | size_t off = i->iov_offset; | ||
798 | while (1) { | ||
799 | size_t n = off - pipe->bufs[idx].offset; | ||
800 | if (unroll < n) { | ||
801 | off -= (n - unroll); | ||
802 | break; | ||
803 | } | ||
804 | unroll -= n; | ||
805 | if (!unroll && idx == i->start_idx) { | ||
806 | off = 0; | ||
807 | break; | ||
808 | } | ||
809 | if (!idx--) | ||
810 | idx = pipe->buffers - 1; | ||
811 | off = pipe->bufs[idx].offset + pipe->bufs[idx].len; | ||
812 | } | ||
813 | i->iov_offset = off; | ||
814 | i->idx = idx; | ||
815 | pipe_truncate(i); | ||
816 | return; | ||
817 | } | ||
818 | if (unroll <= i->iov_offset) { | ||
819 | i->iov_offset -= unroll; | ||
820 | return; | ||
821 | } | ||
822 | unroll -= i->iov_offset; | ||
823 | if (i->type & ITER_BVEC) { | ||
824 | const struct bio_vec *bvec = i->bvec; | ||
825 | while (1) { | ||
826 | size_t n = (--bvec)->bv_len; | ||
827 | i->nr_segs++; | ||
828 | if (unroll <= n) { | ||
829 | i->bvec = bvec; | ||
830 | i->iov_offset = n - unroll; | ||
831 | return; | ||
832 | } | ||
833 | unroll -= n; | ||
834 | } | ||
835 | } else { /* same logics for iovec and kvec */ | ||
836 | const struct iovec *iov = i->iov; | ||
837 | while (1) { | ||
838 | size_t n = (--iov)->iov_len; | ||
839 | i->nr_segs++; | ||
840 | if (unroll <= n) { | ||
841 | i->iov = iov; | ||
842 | i->iov_offset = n - unroll; | ||
843 | return; | ||
844 | } | ||
845 | unroll -= n; | ||
846 | } | ||
847 | } | ||
848 | } | ||
849 | EXPORT_SYMBOL(iov_iter_revert); | ||
850 | |||
789 | /* | 851 | /* |
790 | * Return the count of just the current iov_iter segment. | 852 | * Return the count of just the current iov_iter segment. |
791 | */ | 853 | */ |
@@ -839,6 +901,7 @@ void iov_iter_pipe(struct iov_iter *i, int direction, | |||
839 | i->idx = (pipe->curbuf + pipe->nrbufs) & (pipe->buffers - 1); | 901 | i->idx = (pipe->curbuf + pipe->nrbufs) & (pipe->buffers - 1); |
840 | i->iov_offset = 0; | 902 | i->iov_offset = 0; |
841 | i->count = count; | 903 | i->count = count; |
904 | i->start_idx = i->idx; | ||
842 | } | 905 | } |
843 | EXPORT_SYMBOL(iov_iter_pipe); | 906 | EXPORT_SYMBOL(iov_iter_pipe); |
844 | 907 | ||
diff --git a/lib/syscall.c b/lib/syscall.c index 17d5ff5fa6a3..2c6cd1b5c3ea 100644 --- a/lib/syscall.c +++ b/lib/syscall.c | |||
@@ -12,6 +12,7 @@ static int collect_syscall(struct task_struct *target, long *callno, | |||
12 | 12 | ||
13 | if (!try_get_task_stack(target)) { | 13 | if (!try_get_task_stack(target)) { |
14 | /* Task has no stack, so the task isn't in a syscall. */ | 14 | /* Task has no stack, so the task isn't in a syscall. */ |
15 | *sp = *pc = 0; | ||
15 | *callno = -1; | 16 | *callno = -1; |
16 | return 0; | 17 | return 0; |
17 | } | 18 | } |
diff --git a/lib/test_kasan.c b/lib/test_kasan.c index 0b1d3140fbb8..a25c9763fce1 100644 --- a/lib/test_kasan.c +++ b/lib/test_kasan.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <linux/string.h> | 20 | #include <linux/string.h> |
21 | #include <linux/uaccess.h> | 21 | #include <linux/uaccess.h> |
22 | #include <linux/module.h> | 22 | #include <linux/module.h> |
23 | #include <linux/kasan.h> | ||
23 | 24 | ||
24 | /* | 25 | /* |
25 | * Note: test functions are marked noinline so that their names appear in | 26 | * Note: test functions are marked noinline so that their names appear in |
@@ -474,6 +475,12 @@ static noinline void __init use_after_scope_test(void) | |||
474 | 475 | ||
475 | static int __init kmalloc_tests_init(void) | 476 | static int __init kmalloc_tests_init(void) |
476 | { | 477 | { |
478 | /* | ||
479 | * Temporarily enable multi-shot mode. Otherwise, we'd only get a | ||
480 | * report for the first case. | ||
481 | */ | ||
482 | bool multishot = kasan_save_enable_multi_shot(); | ||
483 | |||
477 | kmalloc_oob_right(); | 484 | kmalloc_oob_right(); |
478 | kmalloc_oob_left(); | 485 | kmalloc_oob_left(); |
479 | kmalloc_node_oob_right(); | 486 | kmalloc_node_oob_right(); |
@@ -499,6 +506,9 @@ static int __init kmalloc_tests_init(void) | |||
499 | ksize_unpoisons_memory(); | 506 | ksize_unpoisons_memory(); |
500 | copy_user_test(); | 507 | copy_user_test(); |
501 | use_after_scope_test(); | 508 | use_after_scope_test(); |
509 | |||
510 | kasan_restore_multi_shot(multishot); | ||
511 | |||
502 | return -EAGAIN; | 512 | return -EAGAIN; |
503 | } | 513 | } |
504 | 514 | ||
diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 1ebc93e179f3..f3c4f9d22821 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c | |||
@@ -240,18 +240,18 @@ static ssize_t defrag_store(struct kobject *kobj, | |||
240 | clear_bit(TRANSPARENT_HUGEPAGE_DEFRAG_KSWAPD_OR_MADV_FLAG, &transparent_hugepage_flags); | 240 | clear_bit(TRANSPARENT_HUGEPAGE_DEFRAG_KSWAPD_OR_MADV_FLAG, &transparent_hugepage_flags); |
241 | clear_bit(TRANSPARENT_HUGEPAGE_DEFRAG_REQ_MADV_FLAG, &transparent_hugepage_flags); | 241 | clear_bit(TRANSPARENT_HUGEPAGE_DEFRAG_REQ_MADV_FLAG, &transparent_hugepage_flags); |
242 | set_bit(TRANSPARENT_HUGEPAGE_DEFRAG_DIRECT_FLAG, &transparent_hugepage_flags); | 242 | set_bit(TRANSPARENT_HUGEPAGE_DEFRAG_DIRECT_FLAG, &transparent_hugepage_flags); |
243 | } else if (!memcmp("defer", buf, | ||
244 | min(sizeof("defer")-1, count))) { | ||
245 | clear_bit(TRANSPARENT_HUGEPAGE_DEFRAG_DIRECT_FLAG, &transparent_hugepage_flags); | ||
246 | clear_bit(TRANSPARENT_HUGEPAGE_DEFRAG_KSWAPD_OR_MADV_FLAG, &transparent_hugepage_flags); | ||
247 | clear_bit(TRANSPARENT_HUGEPAGE_DEFRAG_REQ_MADV_FLAG, &transparent_hugepage_flags); | ||
248 | set_bit(TRANSPARENT_HUGEPAGE_DEFRAG_KSWAPD_FLAG, &transparent_hugepage_flags); | ||
249 | } else if (!memcmp("defer+madvise", buf, | 243 | } else if (!memcmp("defer+madvise", buf, |
250 | min(sizeof("defer+madvise")-1, count))) { | 244 | min(sizeof("defer+madvise")-1, count))) { |
251 | clear_bit(TRANSPARENT_HUGEPAGE_DEFRAG_DIRECT_FLAG, &transparent_hugepage_flags); | 245 | clear_bit(TRANSPARENT_HUGEPAGE_DEFRAG_DIRECT_FLAG, &transparent_hugepage_flags); |
252 | clear_bit(TRANSPARENT_HUGEPAGE_DEFRAG_KSWAPD_FLAG, &transparent_hugepage_flags); | 246 | clear_bit(TRANSPARENT_HUGEPAGE_DEFRAG_KSWAPD_FLAG, &transparent_hugepage_flags); |
253 | clear_bit(TRANSPARENT_HUGEPAGE_DEFRAG_REQ_MADV_FLAG, &transparent_hugepage_flags); | 247 | clear_bit(TRANSPARENT_HUGEPAGE_DEFRAG_REQ_MADV_FLAG, &transparent_hugepage_flags); |
254 | set_bit(TRANSPARENT_HUGEPAGE_DEFRAG_KSWAPD_OR_MADV_FLAG, &transparent_hugepage_flags); | 248 | set_bit(TRANSPARENT_HUGEPAGE_DEFRAG_KSWAPD_OR_MADV_FLAG, &transparent_hugepage_flags); |
249 | } else if (!memcmp("defer", buf, | ||
250 | min(sizeof("defer")-1, count))) { | ||
251 | clear_bit(TRANSPARENT_HUGEPAGE_DEFRAG_DIRECT_FLAG, &transparent_hugepage_flags); | ||
252 | clear_bit(TRANSPARENT_HUGEPAGE_DEFRAG_KSWAPD_OR_MADV_FLAG, &transparent_hugepage_flags); | ||
253 | clear_bit(TRANSPARENT_HUGEPAGE_DEFRAG_REQ_MADV_FLAG, &transparent_hugepage_flags); | ||
254 | set_bit(TRANSPARENT_HUGEPAGE_DEFRAG_KSWAPD_FLAG, &transparent_hugepage_flags); | ||
255 | } else if (!memcmp("madvise", buf, | 255 | } else if (!memcmp("madvise", buf, |
256 | min(sizeof("madvise")-1, count))) { | 256 | min(sizeof("madvise")-1, count))) { |
257 | clear_bit(TRANSPARENT_HUGEPAGE_DEFRAG_DIRECT_FLAG, &transparent_hugepage_flags); | 257 | clear_bit(TRANSPARENT_HUGEPAGE_DEFRAG_DIRECT_FLAG, &transparent_hugepage_flags); |
@@ -1568,8 +1568,7 @@ bool madvise_free_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma, | |||
1568 | deactivate_page(page); | 1568 | deactivate_page(page); |
1569 | 1569 | ||
1570 | if (pmd_young(orig_pmd) || pmd_dirty(orig_pmd)) { | 1570 | if (pmd_young(orig_pmd) || pmd_dirty(orig_pmd)) { |
1571 | orig_pmd = pmdp_huge_get_and_clear_full(tlb->mm, addr, pmd, | 1571 | pmdp_invalidate(vma, addr, pmd); |
1572 | tlb->fullmm); | ||
1573 | orig_pmd = pmd_mkold(orig_pmd); | 1572 | orig_pmd = pmd_mkold(orig_pmd); |
1574 | orig_pmd = pmd_mkclean(orig_pmd); | 1573 | orig_pmd = pmd_mkclean(orig_pmd); |
1575 | 1574 | ||
@@ -1724,37 +1723,69 @@ int change_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd, | |||
1724 | { | 1723 | { |
1725 | struct mm_struct *mm = vma->vm_mm; | 1724 | struct mm_struct *mm = vma->vm_mm; |
1726 | spinlock_t *ptl; | 1725 | spinlock_t *ptl; |
1727 | int ret = 0; | 1726 | pmd_t entry; |
1727 | bool preserve_write; | ||
1728 | int ret; | ||
1728 | 1729 | ||
1729 | ptl = __pmd_trans_huge_lock(pmd, vma); | 1730 | ptl = __pmd_trans_huge_lock(pmd, vma); |
1730 | if (ptl) { | 1731 | if (!ptl) |
1731 | pmd_t entry; | 1732 | return 0; |
1732 | bool preserve_write = prot_numa && pmd_write(*pmd); | ||
1733 | ret = 1; | ||
1734 | 1733 | ||
1735 | /* | 1734 | preserve_write = prot_numa && pmd_write(*pmd); |
1736 | * Avoid trapping faults against the zero page. The read-only | 1735 | ret = 1; |
1737 | * data is likely to be read-cached on the local CPU and | ||
1738 | * local/remote hits to the zero page are not interesting. | ||
1739 | */ | ||
1740 | if (prot_numa && is_huge_zero_pmd(*pmd)) { | ||
1741 | spin_unlock(ptl); | ||
1742 | return ret; | ||
1743 | } | ||
1744 | 1736 | ||
1745 | if (!prot_numa || !pmd_protnone(*pmd)) { | 1737 | /* |
1746 | entry = pmdp_huge_get_and_clear_notify(mm, addr, pmd); | 1738 | * Avoid trapping faults against the zero page. The read-only |
1747 | entry = pmd_modify(entry, newprot); | 1739 | * data is likely to be read-cached on the local CPU and |
1748 | if (preserve_write) | 1740 | * local/remote hits to the zero page are not interesting. |
1749 | entry = pmd_mk_savedwrite(entry); | 1741 | */ |
1750 | ret = HPAGE_PMD_NR; | 1742 | if (prot_numa && is_huge_zero_pmd(*pmd)) |
1751 | set_pmd_at(mm, addr, pmd, entry); | 1743 | goto unlock; |
1752 | BUG_ON(vma_is_anonymous(vma) && !preserve_write && | 1744 | |
1753 | pmd_write(entry)); | 1745 | if (prot_numa && pmd_protnone(*pmd)) |
1754 | } | 1746 | goto unlock; |
1755 | spin_unlock(ptl); | 1747 | |
1756 | } | 1748 | /* |
1749 | * In case prot_numa, we are under down_read(mmap_sem). It's critical | ||
1750 | * to not clear pmd intermittently to avoid race with MADV_DONTNEED | ||
1751 | * which is also under down_read(mmap_sem): | ||
1752 | * | ||
1753 | * CPU0: CPU1: | ||
1754 | * change_huge_pmd(prot_numa=1) | ||
1755 | * pmdp_huge_get_and_clear_notify() | ||
1756 | * madvise_dontneed() | ||
1757 | * zap_pmd_range() | ||
1758 | * pmd_trans_huge(*pmd) == 0 (without ptl) | ||
1759 | * // skip the pmd | ||
1760 | * set_pmd_at(); | ||
1761 | * // pmd is re-established | ||
1762 | * | ||
1763 | * The race makes MADV_DONTNEED miss the huge pmd and don't clear it | ||
1764 | * which may break userspace. | ||
1765 | * | ||
1766 | * pmdp_invalidate() is required to make sure we don't miss | ||
1767 | * dirty/young flags set by hardware. | ||
1768 | */ | ||
1769 | entry = *pmd; | ||
1770 | pmdp_invalidate(vma, addr, pmd); | ||
1757 | 1771 | ||
1772 | /* | ||
1773 | * Recover dirty/young flags. It relies on pmdp_invalidate to not | ||
1774 | * corrupt them. | ||
1775 | */ | ||
1776 | if (pmd_dirty(*pmd)) | ||
1777 | entry = pmd_mkdirty(entry); | ||
1778 | if (pmd_young(*pmd)) | ||
1779 | entry = pmd_mkyoung(entry); | ||
1780 | |||
1781 | entry = pmd_modify(entry, newprot); | ||
1782 | if (preserve_write) | ||
1783 | entry = pmd_mk_savedwrite(entry); | ||
1784 | ret = HPAGE_PMD_NR; | ||
1785 | set_pmd_at(mm, addr, pmd, entry); | ||
1786 | BUG_ON(vma_is_anonymous(vma) && !preserve_write && pmd_write(entry)); | ||
1787 | unlock: | ||
1788 | spin_unlock(ptl); | ||
1758 | return ret; | 1789 | return ret; |
1759 | } | 1790 | } |
1760 | 1791 | ||
diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 3d0aab9ee80d..e5828875f7bb 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c | |||
@@ -4403,7 +4403,9 @@ int hugetlb_reserve_pages(struct inode *inode, | |||
4403 | return 0; | 4403 | return 0; |
4404 | out_err: | 4404 | out_err: |
4405 | if (!vma || vma->vm_flags & VM_MAYSHARE) | 4405 | if (!vma || vma->vm_flags & VM_MAYSHARE) |
4406 | region_abort(resv_map, from, to); | 4406 | /* Don't call region_abort if region_chg failed */ |
4407 | if (chg >= 0) | ||
4408 | region_abort(resv_map, from, to); | ||
4407 | if (vma && is_vma_resv_set(vma, HPAGE_RESV_OWNER)) | 4409 | if (vma && is_vma_resv_set(vma, HPAGE_RESV_OWNER)) |
4408 | kref_put(&resv_map->refs, resv_map_release); | 4410 | kref_put(&resv_map->refs, resv_map_release); |
4409 | return ret; | 4411 | return ret; |
@@ -4651,6 +4653,7 @@ follow_huge_pmd(struct mm_struct *mm, unsigned long address, | |||
4651 | { | 4653 | { |
4652 | struct page *page = NULL; | 4654 | struct page *page = NULL; |
4653 | spinlock_t *ptl; | 4655 | spinlock_t *ptl; |
4656 | pte_t pte; | ||
4654 | retry: | 4657 | retry: |
4655 | ptl = pmd_lockptr(mm, pmd); | 4658 | ptl = pmd_lockptr(mm, pmd); |
4656 | spin_lock(ptl); | 4659 | spin_lock(ptl); |
@@ -4660,12 +4663,13 @@ retry: | |||
4660 | */ | 4663 | */ |
4661 | if (!pmd_huge(*pmd)) | 4664 | if (!pmd_huge(*pmd)) |
4662 | goto out; | 4665 | goto out; |
4663 | if (pmd_present(*pmd)) { | 4666 | pte = huge_ptep_get((pte_t *)pmd); |
4667 | if (pte_present(pte)) { | ||
4664 | page = pmd_page(*pmd) + ((address & ~PMD_MASK) >> PAGE_SHIFT); | 4668 | page = pmd_page(*pmd) + ((address & ~PMD_MASK) >> PAGE_SHIFT); |
4665 | if (flags & FOLL_GET) | 4669 | if (flags & FOLL_GET) |
4666 | get_page(page); | 4670 | get_page(page); |
4667 | } else { | 4671 | } else { |
4668 | if (is_hugetlb_entry_migration(huge_ptep_get((pte_t *)pmd))) { | 4672 | if (is_hugetlb_entry_migration(pte)) { |
4669 | spin_unlock(ptl); | 4673 | spin_unlock(ptl); |
4670 | __migration_entry_wait(mm, (pte_t *)pmd, ptl); | 4674 | __migration_entry_wait(mm, (pte_t *)pmd, ptl); |
4671 | goto retry; | 4675 | goto retry; |
diff --git a/mm/internal.h b/mm/internal.h index ccfc2a2969f4..266efaeaa370 100644 --- a/mm/internal.h +++ b/mm/internal.h | |||
@@ -481,6 +481,13 @@ unsigned long reclaim_clean_pages_from_list(struct zone *zone, | |||
481 | enum ttu_flags; | 481 | enum ttu_flags; |
482 | struct tlbflush_unmap_batch; | 482 | struct tlbflush_unmap_batch; |
483 | 483 | ||
484 | |||
485 | /* | ||
486 | * only for MM internal work items which do not depend on | ||
487 | * any allocations or locks which might depend on allocations | ||
488 | */ | ||
489 | extern struct workqueue_struct *mm_percpu_wq; | ||
490 | |||
484 | #ifdef CONFIG_ARCH_WANT_BATCHED_UNMAP_TLB_FLUSH | 491 | #ifdef CONFIG_ARCH_WANT_BATCHED_UNMAP_TLB_FLUSH |
485 | void try_to_unmap_flush(void); | 492 | void try_to_unmap_flush(void); |
486 | void try_to_unmap_flush_dirty(void); | 493 | void try_to_unmap_flush_dirty(void); |
diff --git a/mm/kasan/kasan.h b/mm/kasan/kasan.h index 1c260e6b3b3c..dd2dea8eb077 100644 --- a/mm/kasan/kasan.h +++ b/mm/kasan/kasan.h | |||
@@ -96,11 +96,6 @@ static inline const void *kasan_shadow_to_mem(const void *shadow_addr) | |||
96 | << KASAN_SHADOW_SCALE_SHIFT); | 96 | << KASAN_SHADOW_SCALE_SHIFT); |
97 | } | 97 | } |
98 | 98 | ||
99 | static inline bool kasan_report_enabled(void) | ||
100 | { | ||
101 | return !current->kasan_depth; | ||
102 | } | ||
103 | |||
104 | void kasan_report(unsigned long addr, size_t size, | 99 | void kasan_report(unsigned long addr, size_t size, |
105 | bool is_write, unsigned long ip); | 100 | bool is_write, unsigned long ip); |
106 | void kasan_report_double_free(struct kmem_cache *cache, void *object, | 101 | void kasan_report_double_free(struct kmem_cache *cache, void *object, |
diff --git a/mm/kasan/report.c b/mm/kasan/report.c index f479365530b6..ab42a0803f16 100644 --- a/mm/kasan/report.c +++ b/mm/kasan/report.c | |||
@@ -13,7 +13,9 @@ | |||
13 | * | 13 | * |
14 | */ | 14 | */ |
15 | 15 | ||
16 | #include <linux/bitops.h> | ||
16 | #include <linux/ftrace.h> | 17 | #include <linux/ftrace.h> |
18 | #include <linux/init.h> | ||
17 | #include <linux/kernel.h> | 19 | #include <linux/kernel.h> |
18 | #include <linux/mm.h> | 20 | #include <linux/mm.h> |
19 | #include <linux/printk.h> | 21 | #include <linux/printk.h> |
@@ -293,6 +295,40 @@ static void kasan_report_error(struct kasan_access_info *info) | |||
293 | kasan_end_report(&flags); | 295 | kasan_end_report(&flags); |
294 | } | 296 | } |
295 | 297 | ||
298 | static unsigned long kasan_flags; | ||
299 | |||
300 | #define KASAN_BIT_REPORTED 0 | ||
301 | #define KASAN_BIT_MULTI_SHOT 1 | ||
302 | |||
303 | bool kasan_save_enable_multi_shot(void) | ||
304 | { | ||
305 | return test_and_set_bit(KASAN_BIT_MULTI_SHOT, &kasan_flags); | ||
306 | } | ||
307 | EXPORT_SYMBOL_GPL(kasan_save_enable_multi_shot); | ||
308 | |||
309 | void kasan_restore_multi_shot(bool enabled) | ||
310 | { | ||
311 | if (!enabled) | ||
312 | clear_bit(KASAN_BIT_MULTI_SHOT, &kasan_flags); | ||
313 | } | ||
314 | EXPORT_SYMBOL_GPL(kasan_restore_multi_shot); | ||
315 | |||
316 | static int __init kasan_set_multi_shot(char *str) | ||
317 | { | ||
318 | set_bit(KASAN_BIT_MULTI_SHOT, &kasan_flags); | ||
319 | return 1; | ||
320 | } | ||
321 | __setup("kasan_multi_shot", kasan_set_multi_shot); | ||
322 | |||
323 | static inline bool kasan_report_enabled(void) | ||
324 | { | ||
325 | if (current->kasan_depth) | ||
326 | return false; | ||
327 | if (test_bit(KASAN_BIT_MULTI_SHOT, &kasan_flags)) | ||
328 | return true; | ||
329 | return !test_and_set_bit(KASAN_BIT_REPORTED, &kasan_flags); | ||
330 | } | ||
331 | |||
296 | void kasan_report(unsigned long addr, size_t size, | 332 | void kasan_report(unsigned long addr, size_t size, |
297 | bool is_write, unsigned long ip) | 333 | bool is_write, unsigned long ip) |
298 | { | 334 | { |
diff --git a/mm/kmemleak.c b/mm/kmemleak.c index 26c874e90b12..20036d4f9f13 100644 --- a/mm/kmemleak.c +++ b/mm/kmemleak.c | |||
@@ -1416,7 +1416,7 @@ static void kmemleak_scan(void) | |||
1416 | /* data/bss scanning */ | 1416 | /* data/bss scanning */ |
1417 | scan_large_block(_sdata, _edata); | 1417 | scan_large_block(_sdata, _edata); |
1418 | scan_large_block(__bss_start, __bss_stop); | 1418 | scan_large_block(__bss_start, __bss_stop); |
1419 | scan_large_block(__start_data_ro_after_init, __end_data_ro_after_init); | 1419 | scan_large_block(__start_ro_after_init, __end_ro_after_init); |
1420 | 1420 | ||
1421 | #ifdef CONFIG_SMP | 1421 | #ifdef CONFIG_SMP |
1422 | /* per-cpu sections scanning */ | 1422 | /* per-cpu sections scanning */ |
diff --git a/mm/mempolicy.c b/mm/mempolicy.c index 75b2745bac41..37d0b334bfe9 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c | |||
@@ -1529,7 +1529,6 @@ COMPAT_SYSCALL_DEFINE5(get_mempolicy, int __user *, policy, | |||
1529 | COMPAT_SYSCALL_DEFINE3(set_mempolicy, int, mode, compat_ulong_t __user *, nmask, | 1529 | COMPAT_SYSCALL_DEFINE3(set_mempolicy, int, mode, compat_ulong_t __user *, nmask, |
1530 | compat_ulong_t, maxnode) | 1530 | compat_ulong_t, maxnode) |
1531 | { | 1531 | { |
1532 | long err = 0; | ||
1533 | unsigned long __user *nm = NULL; | 1532 | unsigned long __user *nm = NULL; |
1534 | unsigned long nr_bits, alloc_size; | 1533 | unsigned long nr_bits, alloc_size; |
1535 | DECLARE_BITMAP(bm, MAX_NUMNODES); | 1534 | DECLARE_BITMAP(bm, MAX_NUMNODES); |
@@ -1538,14 +1537,13 @@ COMPAT_SYSCALL_DEFINE3(set_mempolicy, int, mode, compat_ulong_t __user *, nmask, | |||
1538 | alloc_size = ALIGN(nr_bits, BITS_PER_LONG) / 8; | 1537 | alloc_size = ALIGN(nr_bits, BITS_PER_LONG) / 8; |
1539 | 1538 | ||
1540 | if (nmask) { | 1539 | if (nmask) { |
1541 | err = compat_get_bitmap(bm, nmask, nr_bits); | 1540 | if (compat_get_bitmap(bm, nmask, nr_bits)) |
1541 | return -EFAULT; | ||
1542 | nm = compat_alloc_user_space(alloc_size); | 1542 | nm = compat_alloc_user_space(alloc_size); |
1543 | err |= copy_to_user(nm, bm, alloc_size); | 1543 | if (copy_to_user(nm, bm, alloc_size)) |
1544 | return -EFAULT; | ||
1544 | } | 1545 | } |
1545 | 1546 | ||
1546 | if (err) | ||
1547 | return -EFAULT; | ||
1548 | |||
1549 | return sys_set_mempolicy(mode, nm, nr_bits+1); | 1547 | return sys_set_mempolicy(mode, nm, nr_bits+1); |
1550 | } | 1548 | } |
1551 | 1549 | ||
@@ -1553,7 +1551,6 @@ COMPAT_SYSCALL_DEFINE6(mbind, compat_ulong_t, start, compat_ulong_t, len, | |||
1553 | compat_ulong_t, mode, compat_ulong_t __user *, nmask, | 1551 | compat_ulong_t, mode, compat_ulong_t __user *, nmask, |
1554 | compat_ulong_t, maxnode, compat_ulong_t, flags) | 1552 | compat_ulong_t, maxnode, compat_ulong_t, flags) |
1555 | { | 1553 | { |
1556 | long err = 0; | ||
1557 | unsigned long __user *nm = NULL; | 1554 | unsigned long __user *nm = NULL; |
1558 | unsigned long nr_bits, alloc_size; | 1555 | unsigned long nr_bits, alloc_size; |
1559 | nodemask_t bm; | 1556 | nodemask_t bm; |
@@ -1562,14 +1559,13 @@ COMPAT_SYSCALL_DEFINE6(mbind, compat_ulong_t, start, compat_ulong_t, len, | |||
1562 | alloc_size = ALIGN(nr_bits, BITS_PER_LONG) / 8; | 1559 | alloc_size = ALIGN(nr_bits, BITS_PER_LONG) / 8; |
1563 | 1560 | ||
1564 | if (nmask) { | 1561 | if (nmask) { |
1565 | err = compat_get_bitmap(nodes_addr(bm), nmask, nr_bits); | 1562 | if (compat_get_bitmap(nodes_addr(bm), nmask, nr_bits)) |
1563 | return -EFAULT; | ||
1566 | nm = compat_alloc_user_space(alloc_size); | 1564 | nm = compat_alloc_user_space(alloc_size); |
1567 | err |= copy_to_user(nm, nodes_addr(bm), alloc_size); | 1565 | if (copy_to_user(nm, nodes_addr(bm), alloc_size)) |
1566 | return -EFAULT; | ||
1568 | } | 1567 | } |
1569 | 1568 | ||
1570 | if (err) | ||
1571 | return -EFAULT; | ||
1572 | |||
1573 | return sys_mbind(start, len, mode, nm, nr_bits+1, flags); | 1569 | return sys_mbind(start, len, mode, nm, nr_bits+1, flags); |
1574 | } | 1570 | } |
1575 | 1571 | ||
diff --git a/mm/migrate.c b/mm/migrate.c index 9a0897a14d37..738f1d5f8350 100644 --- a/mm/migrate.c +++ b/mm/migrate.c | |||
@@ -184,9 +184,9 @@ void putback_movable_pages(struct list_head *l) | |||
184 | unlock_page(page); | 184 | unlock_page(page); |
185 | put_page(page); | 185 | put_page(page); |
186 | } else { | 186 | } else { |
187 | putback_lru_page(page); | ||
188 | dec_node_page_state(page, NR_ISOLATED_ANON + | 187 | dec_node_page_state(page, NR_ISOLATED_ANON + |
189 | page_is_file_cache(page)); | 188 | page_is_file_cache(page)); |
189 | putback_lru_page(page); | ||
190 | } | 190 | } |
191 | } | 191 | } |
192 | } | 192 | } |
@@ -209,8 +209,11 @@ static int remove_migration_pte(struct page *page, struct vm_area_struct *vma, | |||
209 | 209 | ||
210 | VM_BUG_ON_PAGE(PageTail(page), page); | 210 | VM_BUG_ON_PAGE(PageTail(page), page); |
211 | while (page_vma_mapped_walk(&pvmw)) { | 211 | while (page_vma_mapped_walk(&pvmw)) { |
212 | new = page - pvmw.page->index + | 212 | if (PageKsm(page)) |
213 | linear_page_index(vma, pvmw.address); | 213 | new = page; |
214 | else | ||
215 | new = page - pvmw.page->index + | ||
216 | linear_page_index(vma, pvmw.address); | ||
214 | 217 | ||
215 | get_page(new); | 218 | get_page(new); |
216 | pte = pte_mkold(mk_pte(new, READ_ONCE(vma->vm_page_prot))); | 219 | pte = pte_mkold(mk_pte(new, READ_ONCE(vma->vm_page_prot))); |
diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 6cbde310abed..07efbc3a8656 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c | |||
@@ -1090,10 +1090,10 @@ static void free_pcppages_bulk(struct zone *zone, int count, | |||
1090 | { | 1090 | { |
1091 | int migratetype = 0; | 1091 | int migratetype = 0; |
1092 | int batch_free = 0; | 1092 | int batch_free = 0; |
1093 | unsigned long nr_scanned, flags; | 1093 | unsigned long nr_scanned; |
1094 | bool isolated_pageblocks; | 1094 | bool isolated_pageblocks; |
1095 | 1095 | ||
1096 | spin_lock_irqsave(&zone->lock, flags); | 1096 | spin_lock(&zone->lock); |
1097 | isolated_pageblocks = has_isolate_pageblock(zone); | 1097 | isolated_pageblocks = has_isolate_pageblock(zone); |
1098 | nr_scanned = node_page_state(zone->zone_pgdat, NR_PAGES_SCANNED); | 1098 | nr_scanned = node_page_state(zone->zone_pgdat, NR_PAGES_SCANNED); |
1099 | if (nr_scanned) | 1099 | if (nr_scanned) |
@@ -1142,7 +1142,7 @@ static void free_pcppages_bulk(struct zone *zone, int count, | |||
1142 | trace_mm_page_pcpu_drain(page, 0, mt); | 1142 | trace_mm_page_pcpu_drain(page, 0, mt); |
1143 | } while (--count && --batch_free && !list_empty(list)); | 1143 | } while (--count && --batch_free && !list_empty(list)); |
1144 | } | 1144 | } |
1145 | spin_unlock_irqrestore(&zone->lock, flags); | 1145 | spin_unlock(&zone->lock); |
1146 | } | 1146 | } |
1147 | 1147 | ||
1148 | static void free_one_page(struct zone *zone, | 1148 | static void free_one_page(struct zone *zone, |
@@ -1150,9 +1150,8 @@ static void free_one_page(struct zone *zone, | |||
1150 | unsigned int order, | 1150 | unsigned int order, |
1151 | int migratetype) | 1151 | int migratetype) |
1152 | { | 1152 | { |
1153 | unsigned long nr_scanned, flags; | 1153 | unsigned long nr_scanned; |
1154 | spin_lock_irqsave(&zone->lock, flags); | 1154 | spin_lock(&zone->lock); |
1155 | __count_vm_events(PGFREE, 1 << order); | ||
1156 | nr_scanned = node_page_state(zone->zone_pgdat, NR_PAGES_SCANNED); | 1155 | nr_scanned = node_page_state(zone->zone_pgdat, NR_PAGES_SCANNED); |
1157 | if (nr_scanned) | 1156 | if (nr_scanned) |
1158 | __mod_node_page_state(zone->zone_pgdat, NR_PAGES_SCANNED, -nr_scanned); | 1157 | __mod_node_page_state(zone->zone_pgdat, NR_PAGES_SCANNED, -nr_scanned); |
@@ -1162,7 +1161,7 @@ static void free_one_page(struct zone *zone, | |||
1162 | migratetype = get_pfnblock_migratetype(page, pfn); | 1161 | migratetype = get_pfnblock_migratetype(page, pfn); |
1163 | } | 1162 | } |
1164 | __free_one_page(page, pfn, zone, order, migratetype); | 1163 | __free_one_page(page, pfn, zone, order, migratetype); |
1165 | spin_unlock_irqrestore(&zone->lock, flags); | 1164 | spin_unlock(&zone->lock); |
1166 | } | 1165 | } |
1167 | 1166 | ||
1168 | static void __meminit __init_single_page(struct page *page, unsigned long pfn, | 1167 | static void __meminit __init_single_page(struct page *page, unsigned long pfn, |
@@ -1240,6 +1239,7 @@ void __meminit reserve_bootmem_region(phys_addr_t start, phys_addr_t end) | |||
1240 | 1239 | ||
1241 | static void __free_pages_ok(struct page *page, unsigned int order) | 1240 | static void __free_pages_ok(struct page *page, unsigned int order) |
1242 | { | 1241 | { |
1242 | unsigned long flags; | ||
1243 | int migratetype; | 1243 | int migratetype; |
1244 | unsigned long pfn = page_to_pfn(page); | 1244 | unsigned long pfn = page_to_pfn(page); |
1245 | 1245 | ||
@@ -1247,7 +1247,10 @@ static void __free_pages_ok(struct page *page, unsigned int order) | |||
1247 | return; | 1247 | return; |
1248 | 1248 | ||
1249 | migratetype = get_pfnblock_migratetype(page, pfn); | 1249 | migratetype = get_pfnblock_migratetype(page, pfn); |
1250 | local_irq_save(flags); | ||
1251 | __count_vm_events(PGFREE, 1 << order); | ||
1250 | free_one_page(page_zone(page), page, pfn, order, migratetype); | 1252 | free_one_page(page_zone(page), page, pfn, order, migratetype); |
1253 | local_irq_restore(flags); | ||
1251 | } | 1254 | } |
1252 | 1255 | ||
1253 | static void __init __free_pages_boot_core(struct page *page, unsigned int order) | 1256 | static void __init __free_pages_boot_core(struct page *page, unsigned int order) |
@@ -2219,9 +2222,8 @@ static int rmqueue_bulk(struct zone *zone, unsigned int order, | |||
2219 | int migratetype, bool cold) | 2222 | int migratetype, bool cold) |
2220 | { | 2223 | { |
2221 | int i, alloced = 0; | 2224 | int i, alloced = 0; |
2222 | unsigned long flags; | ||
2223 | 2225 | ||
2224 | spin_lock_irqsave(&zone->lock, flags); | 2226 | spin_lock(&zone->lock); |
2225 | for (i = 0; i < count; ++i) { | 2227 | for (i = 0; i < count; ++i) { |
2226 | struct page *page = __rmqueue(zone, order, migratetype); | 2228 | struct page *page = __rmqueue(zone, order, migratetype); |
2227 | if (unlikely(page == NULL)) | 2229 | if (unlikely(page == NULL)) |
@@ -2257,7 +2259,7 @@ static int rmqueue_bulk(struct zone *zone, unsigned int order, | |||
2257 | * pages added to the pcp list. | 2259 | * pages added to the pcp list. |
2258 | */ | 2260 | */ |
2259 | __mod_zone_page_state(zone, NR_FREE_PAGES, -(i << order)); | 2261 | __mod_zone_page_state(zone, NR_FREE_PAGES, -(i << order)); |
2260 | spin_unlock_irqrestore(&zone->lock, flags); | 2262 | spin_unlock(&zone->lock); |
2261 | return alloced; | 2263 | return alloced; |
2262 | } | 2264 | } |
2263 | 2265 | ||
@@ -2373,6 +2375,13 @@ void drain_all_pages(struct zone *zone) | |||
2373 | */ | 2375 | */ |
2374 | static cpumask_t cpus_with_pcps; | 2376 | static cpumask_t cpus_with_pcps; |
2375 | 2377 | ||
2378 | /* | ||
2379 | * Make sure nobody triggers this path before mm_percpu_wq is fully | ||
2380 | * initialized. | ||
2381 | */ | ||
2382 | if (WARN_ON_ONCE(!mm_percpu_wq)) | ||
2383 | return; | ||
2384 | |||
2376 | /* Workqueues cannot recurse */ | 2385 | /* Workqueues cannot recurse */ |
2377 | if (current->flags & PF_WQ_WORKER) | 2386 | if (current->flags & PF_WQ_WORKER) |
2378 | return; | 2387 | return; |
@@ -2422,7 +2431,7 @@ void drain_all_pages(struct zone *zone) | |||
2422 | for_each_cpu(cpu, &cpus_with_pcps) { | 2431 | for_each_cpu(cpu, &cpus_with_pcps) { |
2423 | struct work_struct *work = per_cpu_ptr(&pcpu_drain, cpu); | 2432 | struct work_struct *work = per_cpu_ptr(&pcpu_drain, cpu); |
2424 | INIT_WORK(work, drain_local_pages_wq); | 2433 | INIT_WORK(work, drain_local_pages_wq); |
2425 | schedule_work_on(cpu, work); | 2434 | queue_work_on(cpu, mm_percpu_wq, work); |
2426 | } | 2435 | } |
2427 | for_each_cpu(cpu, &cpus_with_pcps) | 2436 | for_each_cpu(cpu, &cpus_with_pcps) |
2428 | flush_work(per_cpu_ptr(&pcpu_drain, cpu)); | 2437 | flush_work(per_cpu_ptr(&pcpu_drain, cpu)); |
@@ -2478,20 +2487,17 @@ void free_hot_cold_page(struct page *page, bool cold) | |||
2478 | { | 2487 | { |
2479 | struct zone *zone = page_zone(page); | 2488 | struct zone *zone = page_zone(page); |
2480 | struct per_cpu_pages *pcp; | 2489 | struct per_cpu_pages *pcp; |
2490 | unsigned long flags; | ||
2481 | unsigned long pfn = page_to_pfn(page); | 2491 | unsigned long pfn = page_to_pfn(page); |
2482 | int migratetype; | 2492 | int migratetype; |
2483 | 2493 | ||
2484 | if (in_interrupt()) { | ||
2485 | __free_pages_ok(page, 0); | ||
2486 | return; | ||
2487 | } | ||
2488 | |||
2489 | if (!free_pcp_prepare(page)) | 2494 | if (!free_pcp_prepare(page)) |
2490 | return; | 2495 | return; |
2491 | 2496 | ||
2492 | migratetype = get_pfnblock_migratetype(page, pfn); | 2497 | migratetype = get_pfnblock_migratetype(page, pfn); |
2493 | set_pcppage_migratetype(page, migratetype); | 2498 | set_pcppage_migratetype(page, migratetype); |
2494 | preempt_disable(); | 2499 | local_irq_save(flags); |
2500 | __count_vm_event(PGFREE); | ||
2495 | 2501 | ||
2496 | /* | 2502 | /* |
2497 | * We only track unmovable, reclaimable and movable on pcp lists. | 2503 | * We only track unmovable, reclaimable and movable on pcp lists. |
@@ -2508,7 +2514,6 @@ void free_hot_cold_page(struct page *page, bool cold) | |||
2508 | migratetype = MIGRATE_MOVABLE; | 2514 | migratetype = MIGRATE_MOVABLE; |
2509 | } | 2515 | } |
2510 | 2516 | ||
2511 | __count_vm_event(PGFREE); | ||
2512 | pcp = &this_cpu_ptr(zone->pageset)->pcp; | 2517 | pcp = &this_cpu_ptr(zone->pageset)->pcp; |
2513 | if (!cold) | 2518 | if (!cold) |
2514 | list_add(&page->lru, &pcp->lists[migratetype]); | 2519 | list_add(&page->lru, &pcp->lists[migratetype]); |
@@ -2522,7 +2527,7 @@ void free_hot_cold_page(struct page *page, bool cold) | |||
2522 | } | 2527 | } |
2523 | 2528 | ||
2524 | out: | 2529 | out: |
2525 | preempt_enable(); | 2530 | local_irq_restore(flags); |
2526 | } | 2531 | } |
2527 | 2532 | ||
2528 | /* | 2533 | /* |
@@ -2647,8 +2652,6 @@ static struct page *__rmqueue_pcplist(struct zone *zone, int migratetype, | |||
2647 | { | 2652 | { |
2648 | struct page *page; | 2653 | struct page *page; |
2649 | 2654 | ||
2650 | VM_BUG_ON(in_interrupt()); | ||
2651 | |||
2652 | do { | 2655 | do { |
2653 | if (list_empty(list)) { | 2656 | if (list_empty(list)) { |
2654 | pcp->count += rmqueue_bulk(zone, 0, | 2657 | pcp->count += rmqueue_bulk(zone, 0, |
@@ -2679,8 +2682,9 @@ static struct page *rmqueue_pcplist(struct zone *preferred_zone, | |||
2679 | struct list_head *list; | 2682 | struct list_head *list; |
2680 | bool cold = ((gfp_flags & __GFP_COLD) != 0); | 2683 | bool cold = ((gfp_flags & __GFP_COLD) != 0); |
2681 | struct page *page; | 2684 | struct page *page; |
2685 | unsigned long flags; | ||
2682 | 2686 | ||
2683 | preempt_disable(); | 2687 | local_irq_save(flags); |
2684 | pcp = &this_cpu_ptr(zone->pageset)->pcp; | 2688 | pcp = &this_cpu_ptr(zone->pageset)->pcp; |
2685 | list = &pcp->lists[migratetype]; | 2689 | list = &pcp->lists[migratetype]; |
2686 | page = __rmqueue_pcplist(zone, migratetype, cold, pcp, list); | 2690 | page = __rmqueue_pcplist(zone, migratetype, cold, pcp, list); |
@@ -2688,7 +2692,7 @@ static struct page *rmqueue_pcplist(struct zone *preferred_zone, | |||
2688 | __count_zid_vm_events(PGALLOC, page_zonenum(page), 1 << order); | 2692 | __count_zid_vm_events(PGALLOC, page_zonenum(page), 1 << order); |
2689 | zone_statistics(preferred_zone, zone); | 2693 | zone_statistics(preferred_zone, zone); |
2690 | } | 2694 | } |
2691 | preempt_enable(); | 2695 | local_irq_restore(flags); |
2692 | return page; | 2696 | return page; |
2693 | } | 2697 | } |
2694 | 2698 | ||
@@ -2704,7 +2708,7 @@ struct page *rmqueue(struct zone *preferred_zone, | |||
2704 | unsigned long flags; | 2708 | unsigned long flags; |
2705 | struct page *page; | 2709 | struct page *page; |
2706 | 2710 | ||
2707 | if (likely(order == 0) && !in_interrupt()) { | 2711 | if (likely(order == 0)) { |
2708 | page = rmqueue_pcplist(preferred_zone, zone, order, | 2712 | page = rmqueue_pcplist(preferred_zone, zone, order, |
2709 | gfp_flags, migratetype); | 2713 | gfp_flags, migratetype); |
2710 | goto out; | 2714 | goto out; |
@@ -4519,13 +4523,13 @@ void show_free_areas(unsigned int filter, nodemask_t *nodemask) | |||
4519 | K(node_page_state(pgdat, NR_FILE_MAPPED)), | 4523 | K(node_page_state(pgdat, NR_FILE_MAPPED)), |
4520 | K(node_page_state(pgdat, NR_FILE_DIRTY)), | 4524 | K(node_page_state(pgdat, NR_FILE_DIRTY)), |
4521 | K(node_page_state(pgdat, NR_WRITEBACK)), | 4525 | K(node_page_state(pgdat, NR_WRITEBACK)), |
4526 | K(node_page_state(pgdat, NR_SHMEM)), | ||
4522 | #ifdef CONFIG_TRANSPARENT_HUGEPAGE | 4527 | #ifdef CONFIG_TRANSPARENT_HUGEPAGE |
4523 | K(node_page_state(pgdat, NR_SHMEM_THPS) * HPAGE_PMD_NR), | 4528 | K(node_page_state(pgdat, NR_SHMEM_THPS) * HPAGE_PMD_NR), |
4524 | K(node_page_state(pgdat, NR_SHMEM_PMDMAPPED) | 4529 | K(node_page_state(pgdat, NR_SHMEM_PMDMAPPED) |
4525 | * HPAGE_PMD_NR), | 4530 | * HPAGE_PMD_NR), |
4526 | K(node_page_state(pgdat, NR_ANON_THPS) * HPAGE_PMD_NR), | 4531 | K(node_page_state(pgdat, NR_ANON_THPS) * HPAGE_PMD_NR), |
4527 | #endif | 4532 | #endif |
4528 | K(node_page_state(pgdat, NR_SHMEM)), | ||
4529 | K(node_page_state(pgdat, NR_WRITEBACK_TEMP)), | 4533 | K(node_page_state(pgdat, NR_WRITEBACK_TEMP)), |
4530 | K(node_page_state(pgdat, NR_UNSTABLE_NFS)), | 4534 | K(node_page_state(pgdat, NR_UNSTABLE_NFS)), |
4531 | node_page_state(pgdat, NR_PAGES_SCANNED), | 4535 | node_page_state(pgdat, NR_PAGES_SCANNED), |
diff --git a/mm/page_vma_mapped.c b/mm/page_vma_mapped.c index c4c9def8ffea..de9c40d7304a 100644 --- a/mm/page_vma_mapped.c +++ b/mm/page_vma_mapped.c | |||
@@ -111,12 +111,8 @@ bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw) | |||
111 | if (pvmw->pmd && !pvmw->pte) | 111 | if (pvmw->pmd && !pvmw->pte) |
112 | return not_found(pvmw); | 112 | return not_found(pvmw); |
113 | 113 | ||
114 | /* Only for THP, seek to next pte entry makes sense */ | 114 | if (pvmw->pte) |
115 | if (pvmw->pte) { | ||
116 | if (!PageTransHuge(pvmw->page) || PageHuge(pvmw->page)) | ||
117 | return not_found(pvmw); | ||
118 | goto next_pte; | 115 | goto next_pte; |
119 | } | ||
120 | 116 | ||
121 | if (unlikely(PageHuge(pvmw->page))) { | 117 | if (unlikely(PageHuge(pvmw->page))) { |
122 | /* when pud is not present, pte will be NULL */ | 118 | /* when pud is not present, pte will be NULL */ |
@@ -165,9 +161,14 @@ restart: | |||
165 | while (1) { | 161 | while (1) { |
166 | if (check_pte(pvmw)) | 162 | if (check_pte(pvmw)) |
167 | return true; | 163 | return true; |
168 | next_pte: do { | 164 | next_pte: |
165 | /* Seek to next pte only makes sense for THP */ | ||
166 | if (!PageTransHuge(pvmw->page) || PageHuge(pvmw->page)) | ||
167 | return not_found(pvmw); | ||
168 | do { | ||
169 | pvmw->address += PAGE_SIZE; | 169 | pvmw->address += PAGE_SIZE; |
170 | if (pvmw->address >= | 170 | if (pvmw->address >= pvmw->vma->vm_end || |
171 | pvmw->address >= | ||
171 | __vma_address(pvmw->page, pvmw->vma) + | 172 | __vma_address(pvmw->page, pvmw->vma) + |
172 | hpage_nr_pages(pvmw->page) * PAGE_SIZE) | 173 | hpage_nr_pages(pvmw->page) * PAGE_SIZE) |
173 | return not_found(pvmw); | 174 | return not_found(pvmw); |
@@ -1159,7 +1159,7 @@ void page_add_file_rmap(struct page *page, bool compound) | |||
1159 | goto out; | 1159 | goto out; |
1160 | } | 1160 | } |
1161 | __mod_node_page_state(page_pgdat(page), NR_FILE_MAPPED, nr); | 1161 | __mod_node_page_state(page_pgdat(page), NR_FILE_MAPPED, nr); |
1162 | mem_cgroup_inc_page_stat(page, MEM_CGROUP_STAT_FILE_MAPPED); | 1162 | mem_cgroup_update_page_stat(page, MEM_CGROUP_STAT_FILE_MAPPED, nr); |
1163 | out: | 1163 | out: |
1164 | unlock_page_memcg(page); | 1164 | unlock_page_memcg(page); |
1165 | } | 1165 | } |
@@ -1199,7 +1199,7 @@ static void page_remove_file_rmap(struct page *page, bool compound) | |||
1199 | * pte lock(a spinlock) is held, which implies preemption disabled. | 1199 | * pte lock(a spinlock) is held, which implies preemption disabled. |
1200 | */ | 1200 | */ |
1201 | __mod_node_page_state(page_pgdat(page), NR_FILE_MAPPED, -nr); | 1201 | __mod_node_page_state(page_pgdat(page), NR_FILE_MAPPED, -nr); |
1202 | mem_cgroup_dec_page_stat(page, MEM_CGROUP_STAT_FILE_MAPPED); | 1202 | mem_cgroup_update_page_stat(page, MEM_CGROUP_STAT_FILE_MAPPED, -nr); |
1203 | 1203 | ||
1204 | if (unlikely(PageMlocked(page))) | 1204 | if (unlikely(PageMlocked(page))) |
1205 | clear_page_mlock(page); | 1205 | clear_page_mlock(page); |
@@ -670,30 +670,19 @@ static void lru_add_drain_per_cpu(struct work_struct *dummy) | |||
670 | 670 | ||
671 | static DEFINE_PER_CPU(struct work_struct, lru_add_drain_work); | 671 | static DEFINE_PER_CPU(struct work_struct, lru_add_drain_work); |
672 | 672 | ||
673 | /* | ||
674 | * lru_add_drain_wq is used to do lru_add_drain_all() from a WQ_MEM_RECLAIM | ||
675 | * workqueue, aiding in getting memory freed. | ||
676 | */ | ||
677 | static struct workqueue_struct *lru_add_drain_wq; | ||
678 | |||
679 | static int __init lru_init(void) | ||
680 | { | ||
681 | lru_add_drain_wq = alloc_workqueue("lru-add-drain", WQ_MEM_RECLAIM, 0); | ||
682 | |||
683 | if (WARN(!lru_add_drain_wq, | ||
684 | "Failed to create workqueue lru_add_drain_wq")) | ||
685 | return -ENOMEM; | ||
686 | |||
687 | return 0; | ||
688 | } | ||
689 | early_initcall(lru_init); | ||
690 | |||
691 | void lru_add_drain_all(void) | 673 | void lru_add_drain_all(void) |
692 | { | 674 | { |
693 | static DEFINE_MUTEX(lock); | 675 | static DEFINE_MUTEX(lock); |
694 | static struct cpumask has_work; | 676 | static struct cpumask has_work; |
695 | int cpu; | 677 | int cpu; |
696 | 678 | ||
679 | /* | ||
680 | * Make sure nobody triggers this path before mm_percpu_wq is fully | ||
681 | * initialized. | ||
682 | */ | ||
683 | if (WARN_ON(!mm_percpu_wq)) | ||
684 | return; | ||
685 | |||
697 | mutex_lock(&lock); | 686 | mutex_lock(&lock); |
698 | get_online_cpus(); | 687 | get_online_cpus(); |
699 | cpumask_clear(&has_work); | 688 | cpumask_clear(&has_work); |
@@ -707,7 +696,7 @@ void lru_add_drain_all(void) | |||
707 | pagevec_count(&per_cpu(lru_deactivate_pvecs, cpu)) || | 696 | pagevec_count(&per_cpu(lru_deactivate_pvecs, cpu)) || |
708 | need_activate_page_drain(cpu)) { | 697 | need_activate_page_drain(cpu)) { |
709 | INIT_WORK(work, lru_add_drain_per_cpu); | 698 | INIT_WORK(work, lru_add_drain_per_cpu); |
710 | queue_work_on(cpu, lru_add_drain_wq, work); | 699 | queue_work_on(cpu, mm_percpu_wq, work); |
711 | cpumask_set_cpu(cpu, &has_work); | 700 | cpumask_set_cpu(cpu, &has_work); |
712 | } | 701 | } |
713 | } | 702 | } |
diff --git a/mm/swap_cgroup.c b/mm/swap_cgroup.c index 310ac0b8f974..ac6318a064d3 100644 --- a/mm/swap_cgroup.c +++ b/mm/swap_cgroup.c | |||
@@ -201,6 +201,8 @@ void swap_cgroup_swapoff(int type) | |||
201 | struct page *page = map[i]; | 201 | struct page *page = map[i]; |
202 | if (page) | 202 | if (page) |
203 | __free_page(page); | 203 | __free_page(page); |
204 | if (!(i % SWAP_CLUSTER_MAX)) | ||
205 | cond_resched(); | ||
204 | } | 206 | } |
205 | vfree(map); | 207 | vfree(map); |
206 | } | 208 | } |
diff --git a/mm/vmstat.c b/mm/vmstat.c index b1947f0cbee2..5a4f5c5a31e8 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c | |||
@@ -1552,7 +1552,6 @@ static const struct file_operations proc_vmstat_file_operations = { | |||
1552 | #endif /* CONFIG_PROC_FS */ | 1552 | #endif /* CONFIG_PROC_FS */ |
1553 | 1553 | ||
1554 | #ifdef CONFIG_SMP | 1554 | #ifdef CONFIG_SMP |
1555 | static struct workqueue_struct *vmstat_wq; | ||
1556 | static DEFINE_PER_CPU(struct delayed_work, vmstat_work); | 1555 | static DEFINE_PER_CPU(struct delayed_work, vmstat_work); |
1557 | int sysctl_stat_interval __read_mostly = HZ; | 1556 | int sysctl_stat_interval __read_mostly = HZ; |
1558 | 1557 | ||
@@ -1623,7 +1622,7 @@ static void vmstat_update(struct work_struct *w) | |||
1623 | * to occur in the future. Keep on running the | 1622 | * to occur in the future. Keep on running the |
1624 | * update worker thread. | 1623 | * update worker thread. |
1625 | */ | 1624 | */ |
1626 | queue_delayed_work_on(smp_processor_id(), vmstat_wq, | 1625 | queue_delayed_work_on(smp_processor_id(), mm_percpu_wq, |
1627 | this_cpu_ptr(&vmstat_work), | 1626 | this_cpu_ptr(&vmstat_work), |
1628 | round_jiffies_relative(sysctl_stat_interval)); | 1627 | round_jiffies_relative(sysctl_stat_interval)); |
1629 | } | 1628 | } |
@@ -1702,7 +1701,7 @@ static void vmstat_shepherd(struct work_struct *w) | |||
1702 | struct delayed_work *dw = &per_cpu(vmstat_work, cpu); | 1701 | struct delayed_work *dw = &per_cpu(vmstat_work, cpu); |
1703 | 1702 | ||
1704 | if (!delayed_work_pending(dw) && need_update(cpu)) | 1703 | if (!delayed_work_pending(dw) && need_update(cpu)) |
1705 | queue_delayed_work_on(cpu, vmstat_wq, dw, 0); | 1704 | queue_delayed_work_on(cpu, mm_percpu_wq, dw, 0); |
1706 | } | 1705 | } |
1707 | put_online_cpus(); | 1706 | put_online_cpus(); |
1708 | 1707 | ||
@@ -1718,7 +1717,6 @@ static void __init start_shepherd_timer(void) | |||
1718 | INIT_DEFERRABLE_WORK(per_cpu_ptr(&vmstat_work, cpu), | 1717 | INIT_DEFERRABLE_WORK(per_cpu_ptr(&vmstat_work, cpu), |
1719 | vmstat_update); | 1718 | vmstat_update); |
1720 | 1719 | ||
1721 | vmstat_wq = alloc_workqueue("vmstat", WQ_FREEZABLE|WQ_MEM_RECLAIM, 0); | ||
1722 | schedule_delayed_work(&shepherd, | 1720 | schedule_delayed_work(&shepherd, |
1723 | round_jiffies_relative(sysctl_stat_interval)); | 1721 | round_jiffies_relative(sysctl_stat_interval)); |
1724 | } | 1722 | } |
@@ -1764,11 +1762,15 @@ static int vmstat_cpu_dead(unsigned int cpu) | |||
1764 | 1762 | ||
1765 | #endif | 1763 | #endif |
1766 | 1764 | ||
1767 | static int __init setup_vmstat(void) | 1765 | struct workqueue_struct *mm_percpu_wq; |
1766 | |||
1767 | void __init init_mm_internals(void) | ||
1768 | { | 1768 | { |
1769 | #ifdef CONFIG_SMP | 1769 | int ret __maybe_unused; |
1770 | int ret; | 1770 | |
1771 | mm_percpu_wq = alloc_workqueue("mm_percpu_wq", WQ_MEM_RECLAIM, 0); | ||
1771 | 1772 | ||
1773 | #ifdef CONFIG_SMP | ||
1772 | ret = cpuhp_setup_state_nocalls(CPUHP_MM_VMSTAT_DEAD, "mm/vmstat:dead", | 1774 | ret = cpuhp_setup_state_nocalls(CPUHP_MM_VMSTAT_DEAD, "mm/vmstat:dead", |
1773 | NULL, vmstat_cpu_dead); | 1775 | NULL, vmstat_cpu_dead); |
1774 | if (ret < 0) | 1776 | if (ret < 0) |
@@ -1792,9 +1794,7 @@ static int __init setup_vmstat(void) | |||
1792 | proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations); | 1794 | proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations); |
1793 | proc_create("zoneinfo", S_IRUGO, NULL, &proc_zoneinfo_file_operations); | 1795 | proc_create("zoneinfo", S_IRUGO, NULL, &proc_zoneinfo_file_operations); |
1794 | #endif | 1796 | #endif |
1795 | return 0; | ||
1796 | } | 1797 | } |
1797 | module_init(setup_vmstat) | ||
1798 | 1798 | ||
1799 | #if defined(CONFIG_DEBUG_FS) && defined(CONFIG_COMPACTION) | 1799 | #if defined(CONFIG_DEBUG_FS) && defined(CONFIG_COMPACTION) |
1800 | 1800 | ||
diff --git a/mm/workingset.c b/mm/workingset.c index ac839fca0e76..eda05c71fa49 100644 --- a/mm/workingset.c +++ b/mm/workingset.c | |||
@@ -532,7 +532,7 @@ static int __init workingset_init(void) | |||
532 | pr_info("workingset: timestamp_bits=%d max_order=%d bucket_order=%u\n", | 532 | pr_info("workingset: timestamp_bits=%d max_order=%d bucket_order=%u\n", |
533 | timestamp_bits, max_order, bucket_order); | 533 | timestamp_bits, max_order, bucket_order); |
534 | 534 | ||
535 | ret = list_lru_init_key(&shadow_nodes, &shadow_nodes_key); | 535 | ret = __list_lru_init(&shadow_nodes, true, &shadow_nodes_key); |
536 | if (ret) | 536 | if (ret) |
537 | goto err; | 537 | goto err; |
538 | ret = register_shrinker(&workingset_shadow_shrinker); | 538 | ret = register_shrinker(&workingset_shadow_shrinker); |
diff --git a/mm/z3fold.c b/mm/z3fold.c index f9492bccfd79..54f63c4a809a 100644 --- a/mm/z3fold.c +++ b/mm/z3fold.c | |||
@@ -185,6 +185,12 @@ static inline void z3fold_page_lock(struct z3fold_header *zhdr) | |||
185 | spin_lock(&zhdr->page_lock); | 185 | spin_lock(&zhdr->page_lock); |
186 | } | 186 | } |
187 | 187 | ||
188 | /* Try to lock a z3fold page */ | ||
189 | static inline int z3fold_page_trylock(struct z3fold_header *zhdr) | ||
190 | { | ||
191 | return spin_trylock(&zhdr->page_lock); | ||
192 | } | ||
193 | |||
188 | /* Unlock a z3fold page */ | 194 | /* Unlock a z3fold page */ |
189 | static inline void z3fold_page_unlock(struct z3fold_header *zhdr) | 195 | static inline void z3fold_page_unlock(struct z3fold_header *zhdr) |
190 | { | 196 | { |
@@ -385,7 +391,7 @@ static int z3fold_alloc(struct z3fold_pool *pool, size_t size, gfp_t gfp, | |||
385 | spin_lock(&pool->lock); | 391 | spin_lock(&pool->lock); |
386 | zhdr = list_first_entry_or_null(&pool->unbuddied[i], | 392 | zhdr = list_first_entry_or_null(&pool->unbuddied[i], |
387 | struct z3fold_header, buddy); | 393 | struct z3fold_header, buddy); |
388 | if (!zhdr) { | 394 | if (!zhdr || !z3fold_page_trylock(zhdr)) { |
389 | spin_unlock(&pool->lock); | 395 | spin_unlock(&pool->lock); |
390 | continue; | 396 | continue; |
391 | } | 397 | } |
@@ -394,7 +400,6 @@ static int z3fold_alloc(struct z3fold_pool *pool, size_t size, gfp_t gfp, | |||
394 | spin_unlock(&pool->lock); | 400 | spin_unlock(&pool->lock); |
395 | 401 | ||
396 | page = virt_to_page(zhdr); | 402 | page = virt_to_page(zhdr); |
397 | z3fold_page_lock(zhdr); | ||
398 | if (zhdr->first_chunks == 0) { | 403 | if (zhdr->first_chunks == 0) { |
399 | if (zhdr->middle_chunks != 0 && | 404 | if (zhdr->middle_chunks != 0 && |
400 | chunks >= zhdr->start_middle) | 405 | chunks >= zhdr->start_middle) |
diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index b7ee9c34dbd6..d41edd28298b 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c | |||
@@ -276,7 +276,7 @@ struct zs_pool { | |||
276 | struct zspage { | 276 | struct zspage { |
277 | struct { | 277 | struct { |
278 | unsigned int fullness:FULLNESS_BITS; | 278 | unsigned int fullness:FULLNESS_BITS; |
279 | unsigned int class:CLASS_BITS; | 279 | unsigned int class:CLASS_BITS + 1; |
280 | unsigned int isolated:ISOLATED_BITS; | 280 | unsigned int isolated:ISOLATED_BITS; |
281 | unsigned int magic:MAGIC_VAL_BITS; | 281 | unsigned int magic:MAGIC_VAL_BITS; |
282 | }; | 282 | }; |
diff --git a/net/bridge/br_device.c b/net/bridge/br_device.c index ea71513fca21..90f49a194249 100644 --- a/net/bridge/br_device.c +++ b/net/bridge/br_device.c | |||
@@ -119,6 +119,15 @@ static int br_dev_init(struct net_device *dev) | |||
119 | return err; | 119 | return err; |
120 | } | 120 | } |
121 | 121 | ||
122 | static void br_dev_uninit(struct net_device *dev) | ||
123 | { | ||
124 | struct net_bridge *br = netdev_priv(dev); | ||
125 | |||
126 | br_multicast_uninit_stats(br); | ||
127 | br_vlan_flush(br); | ||
128 | free_percpu(br->stats); | ||
129 | } | ||
130 | |||
122 | static int br_dev_open(struct net_device *dev) | 131 | static int br_dev_open(struct net_device *dev) |
123 | { | 132 | { |
124 | struct net_bridge *br = netdev_priv(dev); | 133 | struct net_bridge *br = netdev_priv(dev); |
@@ -332,6 +341,7 @@ static const struct net_device_ops br_netdev_ops = { | |||
332 | .ndo_open = br_dev_open, | 341 | .ndo_open = br_dev_open, |
333 | .ndo_stop = br_dev_stop, | 342 | .ndo_stop = br_dev_stop, |
334 | .ndo_init = br_dev_init, | 343 | .ndo_init = br_dev_init, |
344 | .ndo_uninit = br_dev_uninit, | ||
335 | .ndo_start_xmit = br_dev_xmit, | 345 | .ndo_start_xmit = br_dev_xmit, |
336 | .ndo_get_stats64 = br_get_stats64, | 346 | .ndo_get_stats64 = br_get_stats64, |
337 | .ndo_set_mac_address = br_set_mac_address, | 347 | .ndo_set_mac_address = br_set_mac_address, |
@@ -356,14 +366,6 @@ static const struct net_device_ops br_netdev_ops = { | |||
356 | .ndo_features_check = passthru_features_check, | 366 | .ndo_features_check = passthru_features_check, |
357 | }; | 367 | }; |
358 | 368 | ||
359 | static void br_dev_free(struct net_device *dev) | ||
360 | { | ||
361 | struct net_bridge *br = netdev_priv(dev); | ||
362 | |||
363 | free_percpu(br->stats); | ||
364 | free_netdev(dev); | ||
365 | } | ||
366 | |||
367 | static struct device_type br_type = { | 369 | static struct device_type br_type = { |
368 | .name = "bridge", | 370 | .name = "bridge", |
369 | }; | 371 | }; |
@@ -376,7 +378,7 @@ void br_dev_setup(struct net_device *dev) | |||
376 | ether_setup(dev); | 378 | ether_setup(dev); |
377 | 379 | ||
378 | dev->netdev_ops = &br_netdev_ops; | 380 | dev->netdev_ops = &br_netdev_ops; |
379 | dev->destructor = br_dev_free; | 381 | dev->destructor = free_netdev; |
380 | dev->ethtool_ops = &br_ethtool_ops; | 382 | dev->ethtool_ops = &br_ethtool_ops; |
381 | SET_NETDEV_DEVTYPE(dev, &br_type); | 383 | SET_NETDEV_DEVTYPE(dev, &br_type); |
382 | dev->priv_flags = IFF_EBRIDGE | IFF_NO_QUEUE; | 384 | dev->priv_flags = IFF_EBRIDGE | IFF_NO_QUEUE; |
diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c index 8ac1770aa222..56a2a72e7738 100644 --- a/net/bridge/br_if.c +++ b/net/bridge/br_if.c | |||
@@ -311,7 +311,6 @@ void br_dev_delete(struct net_device *dev, struct list_head *head) | |||
311 | 311 | ||
312 | br_fdb_delete_by_port(br, NULL, 0, 1); | 312 | br_fdb_delete_by_port(br, NULL, 0, 1); |
313 | 313 | ||
314 | br_vlan_flush(br); | ||
315 | br_multicast_dev_del(br); | 314 | br_multicast_dev_del(br); |
316 | cancel_delayed_work_sync(&br->gc_work); | 315 | cancel_delayed_work_sync(&br->gc_work); |
317 | 316 | ||
diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c index b760f2620abf..faa7261a992f 100644 --- a/net/bridge/br_multicast.c +++ b/net/bridge/br_multicast.c | |||
@@ -2031,8 +2031,6 @@ void br_multicast_dev_del(struct net_bridge *br) | |||
2031 | 2031 | ||
2032 | out: | 2032 | out: |
2033 | spin_unlock_bh(&br->multicast_lock); | 2033 | spin_unlock_bh(&br->multicast_lock); |
2034 | |||
2035 | free_percpu(br->mcast_stats); | ||
2036 | } | 2034 | } |
2037 | 2035 | ||
2038 | int br_multicast_set_router(struct net_bridge *br, unsigned long val) | 2036 | int br_multicast_set_router(struct net_bridge *br, unsigned long val) |
@@ -2531,6 +2529,11 @@ int br_multicast_init_stats(struct net_bridge *br) | |||
2531 | return 0; | 2529 | return 0; |
2532 | } | 2530 | } |
2533 | 2531 | ||
2532 | void br_multicast_uninit_stats(struct net_bridge *br) | ||
2533 | { | ||
2534 | free_percpu(br->mcast_stats); | ||
2535 | } | ||
2536 | |||
2534 | static void mcast_stats_add_dir(u64 *dst, u64 *src) | 2537 | static void mcast_stats_add_dir(u64 *dst, u64 *src) |
2535 | { | 2538 | { |
2536 | dst[BR_MCAST_DIR_RX] += src[BR_MCAST_DIR_RX]; | 2539 | dst[BR_MCAST_DIR_RX] += src[BR_MCAST_DIR_RX]; |
diff --git a/net/bridge/br_netlink.c b/net/bridge/br_netlink.c index a8f6acd23e30..225ef7d53701 100644 --- a/net/bridge/br_netlink.c +++ b/net/bridge/br_netlink.c | |||
@@ -1165,11 +1165,14 @@ static int br_dev_newlink(struct net *src_net, struct net_device *dev, | |||
1165 | spin_unlock_bh(&br->lock); | 1165 | spin_unlock_bh(&br->lock); |
1166 | } | 1166 | } |
1167 | 1167 | ||
1168 | err = br_changelink(dev, tb, data); | 1168 | err = register_netdevice(dev); |
1169 | if (err) | 1169 | if (err) |
1170 | return err; | 1170 | return err; |
1171 | 1171 | ||
1172 | return register_netdevice(dev); | 1172 | err = br_changelink(dev, tb, data); |
1173 | if (err) | ||
1174 | unregister_netdevice(dev); | ||
1175 | return err; | ||
1173 | } | 1176 | } |
1174 | 1177 | ||
1175 | static size_t br_get_size(const struct net_device *brdev) | 1178 | static size_t br_get_size(const struct net_device *brdev) |
diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h index 61368186edea..0d177280aa84 100644 --- a/net/bridge/br_private.h +++ b/net/bridge/br_private.h | |||
@@ -620,6 +620,7 @@ void br_rtr_notify(struct net_device *dev, struct net_bridge_port *port, | |||
620 | void br_multicast_count(struct net_bridge *br, const struct net_bridge_port *p, | 620 | void br_multicast_count(struct net_bridge *br, const struct net_bridge_port *p, |
621 | const struct sk_buff *skb, u8 type, u8 dir); | 621 | const struct sk_buff *skb, u8 type, u8 dir); |
622 | int br_multicast_init_stats(struct net_bridge *br); | 622 | int br_multicast_init_stats(struct net_bridge *br); |
623 | void br_multicast_uninit_stats(struct net_bridge *br); | ||
623 | void br_multicast_get_stats(const struct net_bridge *br, | 624 | void br_multicast_get_stats(const struct net_bridge *br, |
624 | const struct net_bridge_port *p, | 625 | const struct net_bridge_port *p, |
625 | struct br_mcast_stats *dest); | 626 | struct br_mcast_stats *dest); |
@@ -760,6 +761,10 @@ static inline int br_multicast_init_stats(struct net_bridge *br) | |||
760 | return 0; | 761 | return 0; |
761 | } | 762 | } |
762 | 763 | ||
764 | static inline void br_multicast_uninit_stats(struct net_bridge *br) | ||
765 | { | ||
766 | } | ||
767 | |||
763 | static inline int br_multicast_igmp_type(const struct sk_buff *skb) | 768 | static inline int br_multicast_igmp_type(const struct sk_buff *skb) |
764 | { | 769 | { |
765 | return 0; | 770 | return 0; |
diff --git a/net/core/datagram.c b/net/core/datagram.c index ea633342ab0d..f4947e737f34 100644 --- a/net/core/datagram.c +++ b/net/core/datagram.c | |||
@@ -398,7 +398,7 @@ int skb_copy_datagram_iter(const struct sk_buff *skb, int offset, | |||
398 | struct iov_iter *to, int len) | 398 | struct iov_iter *to, int len) |
399 | { | 399 | { |
400 | int start = skb_headlen(skb); | 400 | int start = skb_headlen(skb); |
401 | int i, copy = start - offset; | 401 | int i, copy = start - offset, start_off = offset, n; |
402 | struct sk_buff *frag_iter; | 402 | struct sk_buff *frag_iter; |
403 | 403 | ||
404 | trace_skb_copy_datagram_iovec(skb, len); | 404 | trace_skb_copy_datagram_iovec(skb, len); |
@@ -407,11 +407,12 @@ int skb_copy_datagram_iter(const struct sk_buff *skb, int offset, | |||
407 | if (copy > 0) { | 407 | if (copy > 0) { |
408 | if (copy > len) | 408 | if (copy > len) |
409 | copy = len; | 409 | copy = len; |
410 | if (copy_to_iter(skb->data + offset, copy, to) != copy) | 410 | n = copy_to_iter(skb->data + offset, copy, to); |
411 | offset += n; | ||
412 | if (n != copy) | ||
411 | goto short_copy; | 413 | goto short_copy; |
412 | if ((len -= copy) == 0) | 414 | if ((len -= copy) == 0) |
413 | return 0; | 415 | return 0; |
414 | offset += copy; | ||
415 | } | 416 | } |
416 | 417 | ||
417 | /* Copy paged appendix. Hmm... why does this look so complicated? */ | 418 | /* Copy paged appendix. Hmm... why does this look so complicated? */ |
@@ -425,13 +426,14 @@ int skb_copy_datagram_iter(const struct sk_buff *skb, int offset, | |||
425 | if ((copy = end - offset) > 0) { | 426 | if ((copy = end - offset) > 0) { |
426 | if (copy > len) | 427 | if (copy > len) |
427 | copy = len; | 428 | copy = len; |
428 | if (copy_page_to_iter(skb_frag_page(frag), | 429 | n = copy_page_to_iter(skb_frag_page(frag), |
429 | frag->page_offset + offset - | 430 | frag->page_offset + offset - |
430 | start, copy, to) != copy) | 431 | start, copy, to); |
432 | offset += n; | ||
433 | if (n != copy) | ||
431 | goto short_copy; | 434 | goto short_copy; |
432 | if (!(len -= copy)) | 435 | if (!(len -= copy)) |
433 | return 0; | 436 | return 0; |
434 | offset += copy; | ||
435 | } | 437 | } |
436 | start = end; | 438 | start = end; |
437 | } | 439 | } |
@@ -463,6 +465,7 @@ int skb_copy_datagram_iter(const struct sk_buff *skb, int offset, | |||
463 | */ | 465 | */ |
464 | 466 | ||
465 | fault: | 467 | fault: |
468 | iov_iter_revert(to, offset - start_off); | ||
466 | return -EFAULT; | 469 | return -EFAULT; |
467 | 470 | ||
468 | short_copy: | 471 | short_copy: |
@@ -613,7 +616,7 @@ static int skb_copy_and_csum_datagram(const struct sk_buff *skb, int offset, | |||
613 | __wsum *csump) | 616 | __wsum *csump) |
614 | { | 617 | { |
615 | int start = skb_headlen(skb); | 618 | int start = skb_headlen(skb); |
616 | int i, copy = start - offset; | 619 | int i, copy = start - offset, start_off = offset; |
617 | struct sk_buff *frag_iter; | 620 | struct sk_buff *frag_iter; |
618 | int pos = 0; | 621 | int pos = 0; |
619 | int n; | 622 | int n; |
@@ -623,11 +626,11 @@ static int skb_copy_and_csum_datagram(const struct sk_buff *skb, int offset, | |||
623 | if (copy > len) | 626 | if (copy > len) |
624 | copy = len; | 627 | copy = len; |
625 | n = csum_and_copy_to_iter(skb->data + offset, copy, csump, to); | 628 | n = csum_and_copy_to_iter(skb->data + offset, copy, csump, to); |
629 | offset += n; | ||
626 | if (n != copy) | 630 | if (n != copy) |
627 | goto fault; | 631 | goto fault; |
628 | if ((len -= copy) == 0) | 632 | if ((len -= copy) == 0) |
629 | return 0; | 633 | return 0; |
630 | offset += copy; | ||
631 | pos = copy; | 634 | pos = copy; |
632 | } | 635 | } |
633 | 636 | ||
@@ -649,12 +652,12 @@ static int skb_copy_and_csum_datagram(const struct sk_buff *skb, int offset, | |||
649 | offset - start, copy, | 652 | offset - start, copy, |
650 | &csum2, to); | 653 | &csum2, to); |
651 | kunmap(page); | 654 | kunmap(page); |
655 | offset += n; | ||
652 | if (n != copy) | 656 | if (n != copy) |
653 | goto fault; | 657 | goto fault; |
654 | *csump = csum_block_add(*csump, csum2, pos); | 658 | *csump = csum_block_add(*csump, csum2, pos); |
655 | if (!(len -= copy)) | 659 | if (!(len -= copy)) |
656 | return 0; | 660 | return 0; |
657 | offset += copy; | ||
658 | pos += copy; | 661 | pos += copy; |
659 | } | 662 | } |
660 | start = end; | 663 | start = end; |
@@ -687,6 +690,7 @@ static int skb_copy_and_csum_datagram(const struct sk_buff *skb, int offset, | |||
687 | return 0; | 690 | return 0; |
688 | 691 | ||
689 | fault: | 692 | fault: |
693 | iov_iter_revert(to, offset - start_off); | ||
690 | return -EFAULT; | 694 | return -EFAULT; |
691 | } | 695 | } |
692 | 696 | ||
@@ -771,6 +775,7 @@ int skb_copy_and_csum_datagram_msg(struct sk_buff *skb, | |||
771 | } | 775 | } |
772 | return 0; | 776 | return 0; |
773 | csum_error: | 777 | csum_error: |
778 | iov_iter_revert(&msg->msg_iter, chunk); | ||
774 | return -EINVAL; | 779 | return -EINVAL; |
775 | fault: | 780 | fault: |
776 | return -EFAULT; | 781 | return -EFAULT; |
diff --git a/net/core/dev.c b/net/core/dev.c index 7869ae3837ca..533a6d6f6092 100644 --- a/net/core/dev.c +++ b/net/core/dev.c | |||
@@ -6757,7 +6757,6 @@ int dev_change_xdp_fd(struct net_device *dev, int fd, u32 flags) | |||
6757 | 6757 | ||
6758 | return err; | 6758 | return err; |
6759 | } | 6759 | } |
6760 | EXPORT_SYMBOL(dev_change_xdp_fd); | ||
6761 | 6760 | ||
6762 | /** | 6761 | /** |
6763 | * dev_new_index - allocate an ifindex | 6762 | * dev_new_index - allocate an ifindex |
diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c index c35aae13c8d2..d98d4998213d 100644 --- a/net/core/flow_dissector.c +++ b/net/core/flow_dissector.c | |||
@@ -390,7 +390,7 @@ mpls: | |||
390 | unsigned char ar_tip[4]; | 390 | unsigned char ar_tip[4]; |
391 | } *arp_eth, _arp_eth; | 391 | } *arp_eth, _arp_eth; |
392 | const struct arphdr *arp; | 392 | const struct arphdr *arp; |
393 | struct arphdr *_arp; | 393 | struct arphdr _arp; |
394 | 394 | ||
395 | arp = __skb_header_pointer(skb, nhoff, sizeof(_arp), data, | 395 | arp = __skb_header_pointer(skb, nhoff, sizeof(_arp), data, |
396 | hlen, &_arp); | 396 | hlen, &_arp); |
diff --git a/net/core/neighbour.c b/net/core/neighbour.c index e7c12caa20c8..4526cbd7e28a 100644 --- a/net/core/neighbour.c +++ b/net/core/neighbour.c | |||
@@ -860,7 +860,8 @@ static void neigh_probe(struct neighbour *neigh) | |||
860 | if (skb) | 860 | if (skb) |
861 | skb = skb_clone(skb, GFP_ATOMIC); | 861 | skb = skb_clone(skb, GFP_ATOMIC); |
862 | write_unlock(&neigh->lock); | 862 | write_unlock(&neigh->lock); |
863 | neigh->ops->solicit(neigh, skb); | 863 | if (neigh->ops->solicit) |
864 | neigh->ops->solicit(neigh, skb); | ||
864 | atomic_inc(&neigh->probes); | 865 | atomic_inc(&neigh->probes); |
865 | kfree_skb(skb); | 866 | kfree_skb(skb); |
866 | } | 867 | } |
diff --git a/net/core/netpoll.c b/net/core/netpoll.c index 9424673009c1..29be2466970c 100644 --- a/net/core/netpoll.c +++ b/net/core/netpoll.c | |||
@@ -105,15 +105,21 @@ static void queue_process(struct work_struct *work) | |||
105 | while ((skb = skb_dequeue(&npinfo->txq))) { | 105 | while ((skb = skb_dequeue(&npinfo->txq))) { |
106 | struct net_device *dev = skb->dev; | 106 | struct net_device *dev = skb->dev; |
107 | struct netdev_queue *txq; | 107 | struct netdev_queue *txq; |
108 | unsigned int q_index; | ||
108 | 109 | ||
109 | if (!netif_device_present(dev) || !netif_running(dev)) { | 110 | if (!netif_device_present(dev) || !netif_running(dev)) { |
110 | kfree_skb(skb); | 111 | kfree_skb(skb); |
111 | continue; | 112 | continue; |
112 | } | 113 | } |
113 | 114 | ||
114 | txq = skb_get_tx_queue(dev, skb); | ||
115 | |||
116 | local_irq_save(flags); | 115 | local_irq_save(flags); |
116 | /* check if skb->queue_mapping is still valid */ | ||
117 | q_index = skb_get_queue_mapping(skb); | ||
118 | if (unlikely(q_index >= dev->real_num_tx_queues)) { | ||
119 | q_index = q_index % dev->real_num_tx_queues; | ||
120 | skb_set_queue_mapping(skb, q_index); | ||
121 | } | ||
122 | txq = netdev_get_tx_queue(dev, q_index); | ||
117 | HARD_TX_LOCK(dev, txq, smp_processor_id()); | 123 | HARD_TX_LOCK(dev, txq, smp_processor_id()); |
118 | if (netif_xmit_frozen_or_stopped(txq) || | 124 | if (netif_xmit_frozen_or_stopped(txq) || |
119 | netpoll_start_xmit(skb, dev, txq) != NETDEV_TX_OK) { | 125 | netpoll_start_xmit(skb, dev, txq) != NETDEV_TX_OK) { |
diff --git a/net/core/secure_seq.c b/net/core/secure_seq.c index 758f140b6bed..d28da7d363f1 100644 --- a/net/core/secure_seq.c +++ b/net/core/secure_seq.c | |||
@@ -20,9 +20,11 @@ | |||
20 | #include <net/tcp.h> | 20 | #include <net/tcp.h> |
21 | 21 | ||
22 | static siphash_key_t net_secret __read_mostly; | 22 | static siphash_key_t net_secret __read_mostly; |
23 | static siphash_key_t ts_secret __read_mostly; | ||
23 | 24 | ||
24 | static __always_inline void net_secret_init(void) | 25 | static __always_inline void net_secret_init(void) |
25 | { | 26 | { |
27 | net_get_random_once(&ts_secret, sizeof(ts_secret)); | ||
26 | net_get_random_once(&net_secret, sizeof(net_secret)); | 28 | net_get_random_once(&net_secret, sizeof(net_secret)); |
27 | } | 29 | } |
28 | #endif | 30 | #endif |
@@ -45,6 +47,23 @@ static u32 seq_scale(u32 seq) | |||
45 | #endif | 47 | #endif |
46 | 48 | ||
47 | #if IS_ENABLED(CONFIG_IPV6) | 49 | #if IS_ENABLED(CONFIG_IPV6) |
50 | static u32 secure_tcpv6_ts_off(const __be32 *saddr, const __be32 *daddr) | ||
51 | { | ||
52 | const struct { | ||
53 | struct in6_addr saddr; | ||
54 | struct in6_addr daddr; | ||
55 | } __aligned(SIPHASH_ALIGNMENT) combined = { | ||
56 | .saddr = *(struct in6_addr *)saddr, | ||
57 | .daddr = *(struct in6_addr *)daddr, | ||
58 | }; | ||
59 | |||
60 | if (sysctl_tcp_timestamps != 1) | ||
61 | return 0; | ||
62 | |||
63 | return siphash(&combined, offsetofend(typeof(combined), daddr), | ||
64 | &ts_secret); | ||
65 | } | ||
66 | |||
48 | u32 secure_tcpv6_sequence_number(const __be32 *saddr, const __be32 *daddr, | 67 | u32 secure_tcpv6_sequence_number(const __be32 *saddr, const __be32 *daddr, |
49 | __be16 sport, __be16 dport, u32 *tsoff) | 68 | __be16 sport, __be16 dport, u32 *tsoff) |
50 | { | 69 | { |
@@ -63,7 +82,7 @@ u32 secure_tcpv6_sequence_number(const __be32 *saddr, const __be32 *daddr, | |||
63 | net_secret_init(); | 82 | net_secret_init(); |
64 | hash = siphash(&combined, offsetofend(typeof(combined), dport), | 83 | hash = siphash(&combined, offsetofend(typeof(combined), dport), |
65 | &net_secret); | 84 | &net_secret); |
66 | *tsoff = sysctl_tcp_timestamps == 1 ? (hash >> 32) : 0; | 85 | *tsoff = secure_tcpv6_ts_off(saddr, daddr); |
67 | return seq_scale(hash); | 86 | return seq_scale(hash); |
68 | } | 87 | } |
69 | EXPORT_SYMBOL(secure_tcpv6_sequence_number); | 88 | EXPORT_SYMBOL(secure_tcpv6_sequence_number); |
@@ -88,6 +107,14 @@ EXPORT_SYMBOL(secure_ipv6_port_ephemeral); | |||
88 | #endif | 107 | #endif |
89 | 108 | ||
90 | #ifdef CONFIG_INET | 109 | #ifdef CONFIG_INET |
110 | static u32 secure_tcp_ts_off(__be32 saddr, __be32 daddr) | ||
111 | { | ||
112 | if (sysctl_tcp_timestamps != 1) | ||
113 | return 0; | ||
114 | |||
115 | return siphash_2u32((__force u32)saddr, (__force u32)daddr, | ||
116 | &ts_secret); | ||
117 | } | ||
91 | 118 | ||
92 | /* secure_tcp_sequence_number(a, b, 0, d) == secure_ipv4_port_ephemeral(a, b, d), | 119 | /* secure_tcp_sequence_number(a, b, 0, d) == secure_ipv4_port_ephemeral(a, b, d), |
93 | * but fortunately, `sport' cannot be 0 in any circumstances. If this changes, | 120 | * but fortunately, `sport' cannot be 0 in any circumstances. If this changes, |
@@ -103,7 +130,7 @@ u32 secure_tcp_sequence_number(__be32 saddr, __be32 daddr, | |||
103 | hash = siphash_3u32((__force u32)saddr, (__force u32)daddr, | 130 | hash = siphash_3u32((__force u32)saddr, (__force u32)daddr, |
104 | (__force u32)sport << 16 | (__force u32)dport, | 131 | (__force u32)sport << 16 | (__force u32)dport, |
105 | &net_secret); | 132 | &net_secret); |
106 | *tsoff = sysctl_tcp_timestamps == 1 ? (hash >> 32) : 0; | 133 | *tsoff = secure_tcp_ts_off(saddr, daddr); |
107 | return seq_scale(hash); | 134 | return seq_scale(hash); |
108 | } | 135 | } |
109 | 136 | ||
diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 9f781092fda9..f86bf69cfb8d 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c | |||
@@ -3082,22 +3082,32 @@ struct sk_buff *skb_segment(struct sk_buff *head_skb, | |||
3082 | if (sg && csum && (mss != GSO_BY_FRAGS)) { | 3082 | if (sg && csum && (mss != GSO_BY_FRAGS)) { |
3083 | if (!(features & NETIF_F_GSO_PARTIAL)) { | 3083 | if (!(features & NETIF_F_GSO_PARTIAL)) { |
3084 | struct sk_buff *iter; | 3084 | struct sk_buff *iter; |
3085 | unsigned int frag_len; | ||
3085 | 3086 | ||
3086 | if (!list_skb || | 3087 | if (!list_skb || |
3087 | !net_gso_ok(features, skb_shinfo(head_skb)->gso_type)) | 3088 | !net_gso_ok(features, skb_shinfo(head_skb)->gso_type)) |
3088 | goto normal; | 3089 | goto normal; |
3089 | 3090 | ||
3090 | /* Split the buffer at the frag_list pointer. | 3091 | /* If we get here then all the required |
3091 | * This is based on the assumption that all | 3092 | * GSO features except frag_list are supported. |
3092 | * buffers in the chain excluding the last | 3093 | * Try to split the SKB to multiple GSO SKBs |
3093 | * containing the same amount of data. | 3094 | * with no frag_list. |
3095 | * Currently we can do that only when the buffers don't | ||
3096 | * have a linear part and all the buffers except | ||
3097 | * the last are of the same length. | ||
3094 | */ | 3098 | */ |
3099 | frag_len = list_skb->len; | ||
3095 | skb_walk_frags(head_skb, iter) { | 3100 | skb_walk_frags(head_skb, iter) { |
3101 | if (frag_len != iter->len && iter->next) | ||
3102 | goto normal; | ||
3096 | if (skb_headlen(iter)) | 3103 | if (skb_headlen(iter)) |
3097 | goto normal; | 3104 | goto normal; |
3098 | 3105 | ||
3099 | len -= iter->len; | 3106 | len -= iter->len; |
3100 | } | 3107 | } |
3108 | |||
3109 | if (len != frag_len) | ||
3110 | goto normal; | ||
3101 | } | 3111 | } |
3102 | 3112 | ||
3103 | /* GSO partial only requires that we trim off any excess that | 3113 | /* GSO partial only requires that we trim off any excess that |
@@ -3807,6 +3817,7 @@ static void __skb_complete_tx_timestamp(struct sk_buff *skb, | |||
3807 | serr->ee.ee_origin = SO_EE_ORIGIN_TIMESTAMPING; | 3817 | serr->ee.ee_origin = SO_EE_ORIGIN_TIMESTAMPING; |
3808 | serr->ee.ee_info = tstype; | 3818 | serr->ee.ee_info = tstype; |
3809 | serr->opt_stats = opt_stats; | 3819 | serr->opt_stats = opt_stats; |
3820 | serr->header.h4.iif = skb->dev ? skb->dev->ifindex : 0; | ||
3810 | if (sk->sk_tsflags & SOF_TIMESTAMPING_OPT_ID) { | 3821 | if (sk->sk_tsflags & SOF_TIMESTAMPING_OPT_ID) { |
3811 | serr->ee.ee_data = skb_shinfo(skb)->tskey; | 3822 | serr->ee.ee_data = skb_shinfo(skb)->tskey; |
3812 | if (sk->sk_protocol == IPPROTO_TCP && | 3823 | if (sk->sk_protocol == IPPROTO_TCP && |
diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c index 4ead336e14ea..7f9cc400eca0 100644 --- a/net/core/sysctl_net_core.c +++ b/net/core/sysctl_net_core.c | |||
@@ -408,14 +408,16 @@ static struct ctl_table net_core_table[] = { | |||
408 | .data = &sysctl_net_busy_poll, | 408 | .data = &sysctl_net_busy_poll, |
409 | .maxlen = sizeof(unsigned int), | 409 | .maxlen = sizeof(unsigned int), |
410 | .mode = 0644, | 410 | .mode = 0644, |
411 | .proc_handler = proc_dointvec | 411 | .proc_handler = proc_dointvec_minmax, |
412 | .extra1 = &zero, | ||
412 | }, | 413 | }, |
413 | { | 414 | { |
414 | .procname = "busy_read", | 415 | .procname = "busy_read", |
415 | .data = &sysctl_net_busy_read, | 416 | .data = &sysctl_net_busy_read, |
416 | .maxlen = sizeof(unsigned int), | 417 | .maxlen = sizeof(unsigned int), |
417 | .mode = 0644, | 418 | .mode = 0644, |
418 | .proc_handler = proc_dointvec | 419 | .proc_handler = proc_dointvec_minmax, |
420 | .extra1 = &zero, | ||
419 | }, | 421 | }, |
420 | #endif | 422 | #endif |
421 | #ifdef CONFIG_NET_SCHED | 423 | #ifdef CONFIG_NET_SCHED |
diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c index ebd953bc5607..1d46d05efb0f 100644 --- a/net/ipv4/ip_sockglue.c +++ b/net/ipv4/ip_sockglue.c | |||
@@ -488,16 +488,15 @@ static bool ipv4_datagram_support_cmsg(const struct sock *sk, | |||
488 | return false; | 488 | return false; |
489 | 489 | ||
490 | /* Support IP_PKTINFO on tstamp packets if requested, to correlate | 490 | /* Support IP_PKTINFO on tstamp packets if requested, to correlate |
491 | * timestamp with egress dev. Not possible for packets without dev | 491 | * timestamp with egress dev. Not possible for packets without iif |
492 | * or without payload (SOF_TIMESTAMPING_OPT_TSONLY). | 492 | * or without payload (SOF_TIMESTAMPING_OPT_TSONLY). |
493 | */ | 493 | */ |
494 | if ((!(sk->sk_tsflags & SOF_TIMESTAMPING_OPT_CMSG)) || | 494 | info = PKTINFO_SKB_CB(skb); |
495 | (!skb->dev)) | 495 | if (!(sk->sk_tsflags & SOF_TIMESTAMPING_OPT_CMSG) || |
496 | !info->ipi_ifindex) | ||
496 | return false; | 497 | return false; |
497 | 498 | ||
498 | info = PKTINFO_SKB_CB(skb); | ||
499 | info->ipi_spec_dst.s_addr = ip_hdr(skb)->saddr; | 499 | info->ipi_spec_dst.s_addr = ip_hdr(skb)->saddr; |
500 | info->ipi_ifindex = skb->dev->ifindex; | ||
501 | return true; | 500 | return true; |
502 | } | 501 | } |
503 | 502 | ||
@@ -591,6 +590,7 @@ static bool setsockopt_needs_rtnl(int optname) | |||
591 | case MCAST_LEAVE_GROUP: | 590 | case MCAST_LEAVE_GROUP: |
592 | case MCAST_LEAVE_SOURCE_GROUP: | 591 | case MCAST_LEAVE_SOURCE_GROUP: |
593 | case MCAST_UNBLOCK_SOURCE: | 592 | case MCAST_UNBLOCK_SOURCE: |
593 | case IP_ROUTER_ALERT: | ||
594 | return true; | 594 | return true; |
595 | } | 595 | } |
596 | return false; | 596 | return false; |
diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c index fd9f34bbd740..dfb2ab2dd3c8 100644 --- a/net/ipv4/ipconfig.c +++ b/net/ipv4/ipconfig.c | |||
@@ -306,7 +306,7 @@ static void __init ic_close_devs(void) | |||
306 | while ((d = next)) { | 306 | while ((d = next)) { |
307 | next = d->next; | 307 | next = d->next; |
308 | dev = d->dev; | 308 | dev = d->dev; |
309 | if ((!ic_dev || dev != ic_dev->dev) && !netdev_uses_dsa(dev)) { | 309 | if (d != ic_dev && !netdev_uses_dsa(dev)) { |
310 | pr_debug("IP-Config: Downing %s\n", dev->name); | 310 | pr_debug("IP-Config: Downing %s\n", dev->name); |
311 | dev_change_flags(dev, d->flags); | 311 | dev_change_flags(dev, d->flags); |
312 | } | 312 | } |
diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c index c0317c940bcd..b036e85e093b 100644 --- a/net/ipv4/ipmr.c +++ b/net/ipv4/ipmr.c | |||
@@ -1278,7 +1278,7 @@ static void mrtsock_destruct(struct sock *sk) | |||
1278 | struct net *net = sock_net(sk); | 1278 | struct net *net = sock_net(sk); |
1279 | struct mr_table *mrt; | 1279 | struct mr_table *mrt; |
1280 | 1280 | ||
1281 | rtnl_lock(); | 1281 | ASSERT_RTNL(); |
1282 | ipmr_for_each_table(mrt, net) { | 1282 | ipmr_for_each_table(mrt, net) { |
1283 | if (sk == rtnl_dereference(mrt->mroute_sk)) { | 1283 | if (sk == rtnl_dereference(mrt->mroute_sk)) { |
1284 | IPV4_DEVCONF_ALL(net, MC_FORWARDING)--; | 1284 | IPV4_DEVCONF_ALL(net, MC_FORWARDING)--; |
@@ -1289,7 +1289,6 @@ static void mrtsock_destruct(struct sock *sk) | |||
1289 | mroute_clean_tables(mrt, false); | 1289 | mroute_clean_tables(mrt, false); |
1290 | } | 1290 | } |
1291 | } | 1291 | } |
1292 | rtnl_unlock(); | ||
1293 | } | 1292 | } |
1294 | 1293 | ||
1295 | /* Socket options and virtual interface manipulation. The whole | 1294 | /* Socket options and virtual interface manipulation. The whole |
@@ -1353,13 +1352,8 @@ int ip_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, | |||
1353 | if (sk != rcu_access_pointer(mrt->mroute_sk)) { | 1352 | if (sk != rcu_access_pointer(mrt->mroute_sk)) { |
1354 | ret = -EACCES; | 1353 | ret = -EACCES; |
1355 | } else { | 1354 | } else { |
1356 | /* We need to unlock here because mrtsock_destruct takes | ||
1357 | * care of rtnl itself and we can't change that due to | ||
1358 | * the IP_ROUTER_ALERT setsockopt which runs without it. | ||
1359 | */ | ||
1360 | rtnl_unlock(); | ||
1361 | ret = ip_ra_control(sk, 0, NULL); | 1355 | ret = ip_ra_control(sk, 0, NULL); |
1362 | goto out; | 1356 | goto out_unlock; |
1363 | } | 1357 | } |
1364 | break; | 1358 | break; |
1365 | case MRT_ADD_VIF: | 1359 | case MRT_ADD_VIF: |
@@ -1470,7 +1464,6 @@ int ip_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, | |||
1470 | } | 1464 | } |
1471 | out_unlock: | 1465 | out_unlock: |
1472 | rtnl_unlock(); | 1466 | rtnl_unlock(); |
1473 | out: | ||
1474 | return ret; | 1467 | return ret; |
1475 | } | 1468 | } |
1476 | 1469 | ||
diff --git a/net/ipv4/netfilter/ipt_CLUSTERIP.c b/net/ipv4/netfilter/ipt_CLUSTERIP.c index 52f26459efc3..9b8841316e7b 100644 --- a/net/ipv4/netfilter/ipt_CLUSTERIP.c +++ b/net/ipv4/netfilter/ipt_CLUSTERIP.c | |||
@@ -461,7 +461,7 @@ static void clusterip_tg_destroy(const struct xt_tgdtor_param *par) | |||
461 | 461 | ||
462 | clusterip_config_put(cipinfo->config); | 462 | clusterip_config_put(cipinfo->config); |
463 | 463 | ||
464 | nf_ct_netns_get(par->net, par->family); | 464 | nf_ct_netns_put(par->net, par->family); |
465 | } | 465 | } |
466 | 466 | ||
467 | #ifdef CONFIG_COMPAT | 467 | #ifdef CONFIG_COMPAT |
diff --git a/net/ipv4/netfilter/nf_nat_snmp_basic.c b/net/ipv4/netfilter/nf_nat_snmp_basic.c index c9b52c361da2..53e49f5011d3 100644 --- a/net/ipv4/netfilter/nf_nat_snmp_basic.c +++ b/net/ipv4/netfilter/nf_nat_snmp_basic.c | |||
@@ -1260,16 +1260,6 @@ static const struct nf_conntrack_expect_policy snmp_exp_policy = { | |||
1260 | .timeout = 180, | 1260 | .timeout = 180, |
1261 | }; | 1261 | }; |
1262 | 1262 | ||
1263 | static struct nf_conntrack_helper snmp_helper __read_mostly = { | ||
1264 | .me = THIS_MODULE, | ||
1265 | .help = help, | ||
1266 | .expect_policy = &snmp_exp_policy, | ||
1267 | .name = "snmp", | ||
1268 | .tuple.src.l3num = AF_INET, | ||
1269 | .tuple.src.u.udp.port = cpu_to_be16(SNMP_PORT), | ||
1270 | .tuple.dst.protonum = IPPROTO_UDP, | ||
1271 | }; | ||
1272 | |||
1273 | static struct nf_conntrack_helper snmp_trap_helper __read_mostly = { | 1263 | static struct nf_conntrack_helper snmp_trap_helper __read_mostly = { |
1274 | .me = THIS_MODULE, | 1264 | .me = THIS_MODULE, |
1275 | .help = help, | 1265 | .help = help, |
@@ -1288,22 +1278,16 @@ static struct nf_conntrack_helper snmp_trap_helper __read_mostly = { | |||
1288 | 1278 | ||
1289 | static int __init nf_nat_snmp_basic_init(void) | 1279 | static int __init nf_nat_snmp_basic_init(void) |
1290 | { | 1280 | { |
1291 | int ret = 0; | ||
1292 | |||
1293 | BUG_ON(nf_nat_snmp_hook != NULL); | 1281 | BUG_ON(nf_nat_snmp_hook != NULL); |
1294 | RCU_INIT_POINTER(nf_nat_snmp_hook, help); | 1282 | RCU_INIT_POINTER(nf_nat_snmp_hook, help); |
1295 | 1283 | ||
1296 | ret = nf_conntrack_helper_register(&snmp_trap_helper); | 1284 | return nf_conntrack_helper_register(&snmp_trap_helper); |
1297 | if (ret < 0) { | ||
1298 | nf_conntrack_helper_unregister(&snmp_helper); | ||
1299 | return ret; | ||
1300 | } | ||
1301 | return ret; | ||
1302 | } | 1285 | } |
1303 | 1286 | ||
1304 | static void __exit nf_nat_snmp_basic_fini(void) | 1287 | static void __exit nf_nat_snmp_basic_fini(void) |
1305 | { | 1288 | { |
1306 | RCU_INIT_POINTER(nf_nat_snmp_hook, NULL); | 1289 | RCU_INIT_POINTER(nf_nat_snmp_hook, NULL); |
1290 | synchronize_rcu(); | ||
1307 | nf_conntrack_helper_unregister(&snmp_trap_helper); | 1291 | nf_conntrack_helper_unregister(&snmp_trap_helper); |
1308 | } | 1292 | } |
1309 | 1293 | ||
diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c index 2af6244b83e2..ccfbce13a633 100644 --- a/net/ipv4/ping.c +++ b/net/ipv4/ping.c | |||
@@ -156,17 +156,18 @@ int ping_hash(struct sock *sk) | |||
156 | void ping_unhash(struct sock *sk) | 156 | void ping_unhash(struct sock *sk) |
157 | { | 157 | { |
158 | struct inet_sock *isk = inet_sk(sk); | 158 | struct inet_sock *isk = inet_sk(sk); |
159 | |||
159 | pr_debug("ping_unhash(isk=%p,isk->num=%u)\n", isk, isk->inet_num); | 160 | pr_debug("ping_unhash(isk=%p,isk->num=%u)\n", isk, isk->inet_num); |
161 | write_lock_bh(&ping_table.lock); | ||
160 | if (sk_hashed(sk)) { | 162 | if (sk_hashed(sk)) { |
161 | write_lock_bh(&ping_table.lock); | ||
162 | hlist_nulls_del(&sk->sk_nulls_node); | 163 | hlist_nulls_del(&sk->sk_nulls_node); |
163 | sk_nulls_node_init(&sk->sk_nulls_node); | 164 | sk_nulls_node_init(&sk->sk_nulls_node); |
164 | sock_put(sk); | 165 | sock_put(sk); |
165 | isk->inet_num = 0; | 166 | isk->inet_num = 0; |
166 | isk->inet_sport = 0; | 167 | isk->inet_sport = 0; |
167 | sock_prot_inuse_add(sock_net(sk), sk->sk_prot, -1); | 168 | sock_prot_inuse_add(sock_net(sk), sk->sk_prot, -1); |
168 | write_unlock_bh(&ping_table.lock); | ||
169 | } | 169 | } |
170 | write_unlock_bh(&ping_table.lock); | ||
170 | } | 171 | } |
171 | EXPORT_SYMBOL_GPL(ping_unhash); | 172 | EXPORT_SYMBOL_GPL(ping_unhash); |
172 | 173 | ||
diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c index 8119e1f66e03..9d943974de2b 100644 --- a/net/ipv4/raw.c +++ b/net/ipv4/raw.c | |||
@@ -682,7 +682,9 @@ static void raw_close(struct sock *sk, long timeout) | |||
682 | /* | 682 | /* |
683 | * Raw sockets may have direct kernel references. Kill them. | 683 | * Raw sockets may have direct kernel references. Kill them. |
684 | */ | 684 | */ |
685 | rtnl_lock(); | ||
685 | ip_ra_control(sk, 0, NULL); | 686 | ip_ra_control(sk, 0, NULL); |
687 | rtnl_unlock(); | ||
686 | 688 | ||
687 | sk_common_release(sk); | 689 | sk_common_release(sk); |
688 | } | 690 | } |
diff --git a/net/ipv4/route.c b/net/ipv4/route.c index 8471dd116771..acd69cfe2951 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c | |||
@@ -2620,7 +2620,7 @@ static int inet_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh) | |||
2620 | skb_reset_network_header(skb); | 2620 | skb_reset_network_header(skb); |
2621 | 2621 | ||
2622 | /* Bugfix: need to give ip_route_input enough of an IP header to not gag. */ | 2622 | /* Bugfix: need to give ip_route_input enough of an IP header to not gag. */ |
2623 | ip_hdr(skb)->protocol = IPPROTO_ICMP; | 2623 | ip_hdr(skb)->protocol = IPPROTO_UDP; |
2624 | skb_reserve(skb, MAX_HEADER + sizeof(struct iphdr)); | 2624 | skb_reserve(skb, MAX_HEADER + sizeof(struct iphdr)); |
2625 | 2625 | ||
2626 | src = tb[RTA_SRC] ? nla_get_in_addr(tb[RTA_SRC]) : 0; | 2626 | src = tb[RTA_SRC] ? nla_get_in_addr(tb[RTA_SRC]) : 0; |
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 1e319a525d51..40ba4249a586 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c | |||
@@ -2322,6 +2322,7 @@ int tcp_disconnect(struct sock *sk, int flags) | |||
2322 | tcp_init_send_head(sk); | 2322 | tcp_init_send_head(sk); |
2323 | memset(&tp->rx_opt, 0, sizeof(tp->rx_opt)); | 2323 | memset(&tp->rx_opt, 0, sizeof(tp->rx_opt)); |
2324 | __sk_dst_reset(sk); | 2324 | __sk_dst_reset(sk); |
2325 | tcp_saved_syn_free(tp); | ||
2325 | 2326 | ||
2326 | /* Clean up fastopen related fields */ | 2327 | /* Clean up fastopen related fields */ |
2327 | tcp_free_fastopen_req(tp); | 2328 | tcp_free_fastopen_req(tp); |
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index c43119726a62..659d1baefb2b 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c | |||
@@ -126,7 +126,8 @@ int sysctl_tcp_invalid_ratelimit __read_mostly = HZ/2; | |||
126 | #define REXMIT_LOST 1 /* retransmit packets marked lost */ | 126 | #define REXMIT_LOST 1 /* retransmit packets marked lost */ |
127 | #define REXMIT_NEW 2 /* FRTO-style transmit of unsent/new packets */ | 127 | #define REXMIT_NEW 2 /* FRTO-style transmit of unsent/new packets */ |
128 | 128 | ||
129 | static void tcp_gro_dev_warn(struct sock *sk, const struct sk_buff *skb) | 129 | static void tcp_gro_dev_warn(struct sock *sk, const struct sk_buff *skb, |
130 | unsigned int len) | ||
130 | { | 131 | { |
131 | static bool __once __read_mostly; | 132 | static bool __once __read_mostly; |
132 | 133 | ||
@@ -137,8 +138,9 @@ static void tcp_gro_dev_warn(struct sock *sk, const struct sk_buff *skb) | |||
137 | 138 | ||
138 | rcu_read_lock(); | 139 | rcu_read_lock(); |
139 | dev = dev_get_by_index_rcu(sock_net(sk), skb->skb_iif); | 140 | dev = dev_get_by_index_rcu(sock_net(sk), skb->skb_iif); |
140 | pr_warn("%s: Driver has suspect GRO implementation, TCP performance may be compromised.\n", | 141 | if (!dev || len >= dev->mtu) |
141 | dev ? dev->name : "Unknown driver"); | 142 | pr_warn("%s: Driver has suspect GRO implementation, TCP performance may be compromised.\n", |
143 | dev ? dev->name : "Unknown driver"); | ||
142 | rcu_read_unlock(); | 144 | rcu_read_unlock(); |
143 | } | 145 | } |
144 | } | 146 | } |
@@ -161,8 +163,10 @@ static void tcp_measure_rcv_mss(struct sock *sk, const struct sk_buff *skb) | |||
161 | if (len >= icsk->icsk_ack.rcv_mss) { | 163 | if (len >= icsk->icsk_ack.rcv_mss) { |
162 | icsk->icsk_ack.rcv_mss = min_t(unsigned int, len, | 164 | icsk->icsk_ack.rcv_mss = min_t(unsigned int, len, |
163 | tcp_sk(sk)->advmss); | 165 | tcp_sk(sk)->advmss); |
164 | if (unlikely(icsk->icsk_ack.rcv_mss != len)) | 166 | /* Account for possibly-removed options */ |
165 | tcp_gro_dev_warn(sk, skb); | 167 | if (unlikely(len > icsk->icsk_ack.rcv_mss + |
168 | MAX_TCP_OPTION_SPACE)) | ||
169 | tcp_gro_dev_warn(sk, skb, len); | ||
166 | } else { | 170 | } else { |
167 | /* Otherwise, we make more careful check taking into account, | 171 | /* Otherwise, we make more careful check taking into account, |
168 | * that SACKs block is variable. | 172 | * that SACKs block is variable. |
@@ -874,22 +878,11 @@ static void tcp_update_reordering(struct sock *sk, const int metric, | |||
874 | const int ts) | 878 | const int ts) |
875 | { | 879 | { |
876 | struct tcp_sock *tp = tcp_sk(sk); | 880 | struct tcp_sock *tp = tcp_sk(sk); |
877 | if (metric > tp->reordering) { | 881 | int mib_idx; |
878 | int mib_idx; | ||
879 | 882 | ||
883 | if (metric > tp->reordering) { | ||
880 | tp->reordering = min(sysctl_tcp_max_reordering, metric); | 884 | tp->reordering = min(sysctl_tcp_max_reordering, metric); |
881 | 885 | ||
882 | /* This exciting event is worth to be remembered. 8) */ | ||
883 | if (ts) | ||
884 | mib_idx = LINUX_MIB_TCPTSREORDER; | ||
885 | else if (tcp_is_reno(tp)) | ||
886 | mib_idx = LINUX_MIB_TCPRENOREORDER; | ||
887 | else if (tcp_is_fack(tp)) | ||
888 | mib_idx = LINUX_MIB_TCPFACKREORDER; | ||
889 | else | ||
890 | mib_idx = LINUX_MIB_TCPSACKREORDER; | ||
891 | |||
892 | NET_INC_STATS(sock_net(sk), mib_idx); | ||
893 | #if FASTRETRANS_DEBUG > 1 | 886 | #if FASTRETRANS_DEBUG > 1 |
894 | pr_debug("Disorder%d %d %u f%u s%u rr%d\n", | 887 | pr_debug("Disorder%d %d %u f%u s%u rr%d\n", |
895 | tp->rx_opt.sack_ok, inet_csk(sk)->icsk_ca_state, | 888 | tp->rx_opt.sack_ok, inet_csk(sk)->icsk_ca_state, |
@@ -902,6 +895,18 @@ static void tcp_update_reordering(struct sock *sk, const int metric, | |||
902 | } | 895 | } |
903 | 896 | ||
904 | tp->rack.reord = 1; | 897 | tp->rack.reord = 1; |
898 | |||
899 | /* This exciting event is worth to be remembered. 8) */ | ||
900 | if (ts) | ||
901 | mib_idx = LINUX_MIB_TCPTSREORDER; | ||
902 | else if (tcp_is_reno(tp)) | ||
903 | mib_idx = LINUX_MIB_TCPRENOREORDER; | ||
904 | else if (tcp_is_fack(tp)) | ||
905 | mib_idx = LINUX_MIB_TCPFACKREORDER; | ||
906 | else | ||
907 | mib_idx = LINUX_MIB_TCPSACKREORDER; | ||
908 | |||
909 | NET_INC_STATS(sock_net(sk), mib_idx); | ||
905 | } | 910 | } |
906 | 911 | ||
907 | /* This must be called before lost_out is incremented */ | 912 | /* This must be called before lost_out is incremented */ |
@@ -1930,6 +1935,7 @@ void tcp_enter_loss(struct sock *sk) | |||
1930 | struct tcp_sock *tp = tcp_sk(sk); | 1935 | struct tcp_sock *tp = tcp_sk(sk); |
1931 | struct net *net = sock_net(sk); | 1936 | struct net *net = sock_net(sk); |
1932 | struct sk_buff *skb; | 1937 | struct sk_buff *skb; |
1938 | bool new_recovery = icsk->icsk_ca_state < TCP_CA_Recovery; | ||
1933 | bool is_reneg; /* is receiver reneging on SACKs? */ | 1939 | bool is_reneg; /* is receiver reneging on SACKs? */ |
1934 | bool mark_lost; | 1940 | bool mark_lost; |
1935 | 1941 | ||
@@ -1989,15 +1995,18 @@ void tcp_enter_loss(struct sock *sk) | |||
1989 | tp->high_seq = tp->snd_nxt; | 1995 | tp->high_seq = tp->snd_nxt; |
1990 | tcp_ecn_queue_cwr(tp); | 1996 | tcp_ecn_queue_cwr(tp); |
1991 | 1997 | ||
1992 | /* F-RTO RFC5682 sec 3.1 step 1 mandates to disable F-RTO | 1998 | /* F-RTO RFC5682 sec 3.1 step 1: retransmit SND.UNA if no previous |
1993 | * if a previous recovery is underway, otherwise it may incorrectly | 1999 | * loss recovery is underway except recurring timeout(s) on |
1994 | * call a timeout spurious if some previously retransmitted packets | 2000 | * the same SND.UNA (sec 3.2). Disable F-RTO on path MTU probing |
1995 | * are s/acked (sec 3.2). We do not apply that retriction since | 2001 | * |
1996 | * retransmitted skbs are permanently tagged with TCPCB_EVER_RETRANS | 2002 | * In theory F-RTO can be used repeatedly during loss recovery. |
1997 | * so FLAG_ORIG_SACK_ACKED is always correct. But we do disable F-RTO | 2003 | * In practice this interacts badly with broken middle-boxes that |
1998 | * on PTMU discovery to avoid sending new data. | 2004 | * falsely raise the receive window, which results in repeated |
2005 | * timeouts and stop-and-go behavior. | ||
1999 | */ | 2006 | */ |
2000 | tp->frto = sysctl_tcp_frto && !inet_csk(sk)->icsk_mtup.probe_size; | 2007 | tp->frto = sysctl_tcp_frto && |
2008 | (new_recovery || icsk->icsk_retransmits) && | ||
2009 | !inet_csk(sk)->icsk_mtup.probe_size; | ||
2001 | } | 2010 | } |
2002 | 2011 | ||
2003 | /* If ACK arrived pointing to a remembered SACK, it means that our | 2012 | /* If ACK arrived pointing to a remembered SACK, it means that our |
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index 22548b5f05cb..c3c082ed3879 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c | |||
@@ -2999,6 +2999,8 @@ void tcp_send_active_reset(struct sock *sk, gfp_t priority) | |||
2999 | { | 2999 | { |
3000 | struct sk_buff *skb; | 3000 | struct sk_buff *skb; |
3001 | 3001 | ||
3002 | TCP_INC_STATS(sock_net(sk), TCP_MIB_OUTRSTS); | ||
3003 | |||
3002 | /* NOTE: No TCP options attached and we never retransmit this. */ | 3004 | /* NOTE: No TCP options attached and we never retransmit this. */ |
3003 | skb = alloc_skb(MAX_TCP_HEADER, priority); | 3005 | skb = alloc_skb(MAX_TCP_HEADER, priority); |
3004 | if (!skb) { | 3006 | if (!skb) { |
@@ -3014,8 +3016,6 @@ void tcp_send_active_reset(struct sock *sk, gfp_t priority) | |||
3014 | /* Send it off. */ | 3016 | /* Send it off. */ |
3015 | if (tcp_transmit_skb(sk, skb, 0, priority)) | 3017 | if (tcp_transmit_skb(sk, skb, 0, priority)) |
3016 | NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPABORTFAILED); | 3018 | NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPABORTFAILED); |
3017 | |||
3018 | TCP_INC_STATS(sock_net(sk), TCP_MIB_OUTRSTS); | ||
3019 | } | 3019 | } |
3020 | 3020 | ||
3021 | /* Send a crossed SYN-ACK during socket establishment. | 3021 | /* Send a crossed SYN-ACK during socket establishment. |
diff --git a/net/ipv4/tcp_recovery.c b/net/ipv4/tcp_recovery.c index 4ecb38ae8504..d8acbd9f477a 100644 --- a/net/ipv4/tcp_recovery.c +++ b/net/ipv4/tcp_recovery.c | |||
@@ -12,7 +12,8 @@ static void tcp_rack_mark_skb_lost(struct sock *sk, struct sk_buff *skb) | |||
12 | /* Account for retransmits that are lost again */ | 12 | /* Account for retransmits that are lost again */ |
13 | TCP_SKB_CB(skb)->sacked &= ~TCPCB_SACKED_RETRANS; | 13 | TCP_SKB_CB(skb)->sacked &= ~TCPCB_SACKED_RETRANS; |
14 | tp->retrans_out -= tcp_skb_pcount(skb); | 14 | tp->retrans_out -= tcp_skb_pcount(skb); |
15 | NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPLOSTRETRANSMIT); | 15 | NET_ADD_STATS(sock_net(sk), LINUX_MIB_TCPLOSTRETRANSMIT, |
16 | tcp_skb_pcount(skb)); | ||
16 | } | 17 | } |
17 | } | 18 | } |
18 | 19 | ||
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c index 363172527e43..80ce478c4851 100644 --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c | |||
@@ -3626,14 +3626,19 @@ restart: | |||
3626 | INIT_LIST_HEAD(&del_list); | 3626 | INIT_LIST_HEAD(&del_list); |
3627 | list_for_each_entry_safe(ifa, tmp, &idev->addr_list, if_list) { | 3627 | list_for_each_entry_safe(ifa, tmp, &idev->addr_list, if_list) { |
3628 | struct rt6_info *rt = NULL; | 3628 | struct rt6_info *rt = NULL; |
3629 | bool keep; | ||
3629 | 3630 | ||
3630 | addrconf_del_dad_work(ifa); | 3631 | addrconf_del_dad_work(ifa); |
3631 | 3632 | ||
3633 | keep = keep_addr && (ifa->flags & IFA_F_PERMANENT) && | ||
3634 | !addr_is_local(&ifa->addr); | ||
3635 | if (!keep) | ||
3636 | list_move(&ifa->if_list, &del_list); | ||
3637 | |||
3632 | write_unlock_bh(&idev->lock); | 3638 | write_unlock_bh(&idev->lock); |
3633 | spin_lock_bh(&ifa->lock); | 3639 | spin_lock_bh(&ifa->lock); |
3634 | 3640 | ||
3635 | if (keep_addr && (ifa->flags & IFA_F_PERMANENT) && | 3641 | if (keep) { |
3636 | !addr_is_local(&ifa->addr)) { | ||
3637 | /* set state to skip the notifier below */ | 3642 | /* set state to skip the notifier below */ |
3638 | state = INET6_IFADDR_STATE_DEAD; | 3643 | state = INET6_IFADDR_STATE_DEAD; |
3639 | ifa->state = 0; | 3644 | ifa->state = 0; |
@@ -3645,8 +3650,6 @@ restart: | |||
3645 | } else { | 3650 | } else { |
3646 | state = ifa->state; | 3651 | state = ifa->state; |
3647 | ifa->state = INET6_IFADDR_STATE_DEAD; | 3652 | ifa->state = INET6_IFADDR_STATE_DEAD; |
3648 | |||
3649 | list_move(&ifa->if_list, &del_list); | ||
3650 | } | 3653 | } |
3651 | 3654 | ||
3652 | spin_unlock_bh(&ifa->lock); | 3655 | spin_unlock_bh(&ifa->lock); |
diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c index eec27f87efac..e011122ebd43 100644 --- a/net/ipv6/datagram.c +++ b/net/ipv6/datagram.c | |||
@@ -405,9 +405,6 @@ static inline bool ipv6_datagram_support_addr(struct sock_exterr_skb *serr) | |||
405 | * At one point, excluding local errors was a quick test to identify icmp/icmp6 | 405 | * At one point, excluding local errors was a quick test to identify icmp/icmp6 |
406 | * errors. This is no longer true, but the test remained, so the v6 stack, | 406 | * errors. This is no longer true, but the test remained, so the v6 stack, |
407 | * unlike v4, also honors cmsg requests on all wifi and timestamp errors. | 407 | * unlike v4, also honors cmsg requests on all wifi and timestamp errors. |
408 | * | ||
409 | * Timestamp code paths do not initialize the fields expected by cmsg: | ||
410 | * the PKTINFO fields in skb->cb[]. Fill those in here. | ||
411 | */ | 408 | */ |
412 | static bool ip6_datagram_support_cmsg(struct sk_buff *skb, | 409 | static bool ip6_datagram_support_cmsg(struct sk_buff *skb, |
413 | struct sock_exterr_skb *serr) | 410 | struct sock_exterr_skb *serr) |
@@ -419,14 +416,9 @@ static bool ip6_datagram_support_cmsg(struct sk_buff *skb, | |||
419 | if (serr->ee.ee_origin == SO_EE_ORIGIN_LOCAL) | 416 | if (serr->ee.ee_origin == SO_EE_ORIGIN_LOCAL) |
420 | return false; | 417 | return false; |
421 | 418 | ||
422 | if (!skb->dev) | 419 | if (!IP6CB(skb)->iif) |
423 | return false; | 420 | return false; |
424 | 421 | ||
425 | if (skb->protocol == htons(ETH_P_IPV6)) | ||
426 | IP6CB(skb)->iif = skb->dev->ifindex; | ||
427 | else | ||
428 | PKTINFO_SKB_CB(skb)->ipi_ifindex = skb->dev->ifindex; | ||
429 | |||
430 | return true; | 422 | return true; |
431 | } | 423 | } |
432 | 424 | ||
diff --git a/net/ipv6/exthdrs.c b/net/ipv6/exthdrs.c index 275cac628a95..25192a3b0cd7 100644 --- a/net/ipv6/exthdrs.c +++ b/net/ipv6/exthdrs.c | |||
@@ -388,7 +388,6 @@ looped_back: | |||
388 | icmpv6_param_prob(skb, ICMPV6_HDR_FIELD, | 388 | icmpv6_param_prob(skb, ICMPV6_HDR_FIELD, |
389 | ((&hdr->segments_left) - | 389 | ((&hdr->segments_left) - |
390 | skb_network_header(skb))); | 390 | skb_network_header(skb))); |
391 | kfree_skb(skb); | ||
392 | return -1; | 391 | return -1; |
393 | } | 392 | } |
394 | 393 | ||
diff --git a/net/ipv6/ip6_input.c b/net/ipv6/ip6_input.c index aacfb4bce153..c45b12b4431c 100644 --- a/net/ipv6/ip6_input.c +++ b/net/ipv6/ip6_input.c | |||
@@ -122,11 +122,14 @@ int ipv6_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt | |||
122 | max_t(unsigned short, 1, skb_shinfo(skb)->gso_segs)); | 122 | max_t(unsigned short, 1, skb_shinfo(skb)->gso_segs)); |
123 | /* | 123 | /* |
124 | * RFC4291 2.5.3 | 124 | * RFC4291 2.5.3 |
125 | * The loopback address must not be used as the source address in IPv6 | ||
126 | * packets that are sent outside of a single node. [..] | ||
125 | * A packet received on an interface with a destination address | 127 | * A packet received on an interface with a destination address |
126 | * of loopback must be dropped. | 128 | * of loopback must be dropped. |
127 | */ | 129 | */ |
128 | if (!(dev->flags & IFF_LOOPBACK) && | 130 | if ((ipv6_addr_loopback(&hdr->saddr) || |
129 | ipv6_addr_loopback(&hdr->daddr)) | 131 | ipv6_addr_loopback(&hdr->daddr)) && |
132 | !(dev->flags & IFF_LOOPBACK)) | ||
130 | goto err; | 133 | goto err; |
131 | 134 | ||
132 | /* RFC4291 Errata ID: 3480 | 135 | /* RFC4291 Errata ID: 3480 |
diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c index 6ba6c900ebcf..bf34d0950752 100644 --- a/net/ipv6/ip6mr.c +++ b/net/ipv6/ip6mr.c | |||
@@ -774,7 +774,8 @@ failure: | |||
774 | * Delete a VIF entry | 774 | * Delete a VIF entry |
775 | */ | 775 | */ |
776 | 776 | ||
777 | static int mif6_delete(struct mr6_table *mrt, int vifi, struct list_head *head) | 777 | static int mif6_delete(struct mr6_table *mrt, int vifi, int notify, |
778 | struct list_head *head) | ||
778 | { | 779 | { |
779 | struct mif_device *v; | 780 | struct mif_device *v; |
780 | struct net_device *dev; | 781 | struct net_device *dev; |
@@ -820,7 +821,7 @@ static int mif6_delete(struct mr6_table *mrt, int vifi, struct list_head *head) | |||
820 | dev->ifindex, &in6_dev->cnf); | 821 | dev->ifindex, &in6_dev->cnf); |
821 | } | 822 | } |
822 | 823 | ||
823 | if (v->flags & MIFF_REGISTER) | 824 | if ((v->flags & MIFF_REGISTER) && !notify) |
824 | unregister_netdevice_queue(dev, head); | 825 | unregister_netdevice_queue(dev, head); |
825 | 826 | ||
826 | dev_put(dev); | 827 | dev_put(dev); |
@@ -1331,7 +1332,6 @@ static int ip6mr_device_event(struct notifier_block *this, | |||
1331 | struct mr6_table *mrt; | 1332 | struct mr6_table *mrt; |
1332 | struct mif_device *v; | 1333 | struct mif_device *v; |
1333 | int ct; | 1334 | int ct; |
1334 | LIST_HEAD(list); | ||
1335 | 1335 | ||
1336 | if (event != NETDEV_UNREGISTER) | 1336 | if (event != NETDEV_UNREGISTER) |
1337 | return NOTIFY_DONE; | 1337 | return NOTIFY_DONE; |
@@ -1340,10 +1340,9 @@ static int ip6mr_device_event(struct notifier_block *this, | |||
1340 | v = &mrt->vif6_table[0]; | 1340 | v = &mrt->vif6_table[0]; |
1341 | for (ct = 0; ct < mrt->maxvif; ct++, v++) { | 1341 | for (ct = 0; ct < mrt->maxvif; ct++, v++) { |
1342 | if (v->dev == dev) | 1342 | if (v->dev == dev) |
1343 | mif6_delete(mrt, ct, &list); | 1343 | mif6_delete(mrt, ct, 1, NULL); |
1344 | } | 1344 | } |
1345 | } | 1345 | } |
1346 | unregister_netdevice_many(&list); | ||
1347 | 1346 | ||
1348 | return NOTIFY_DONE; | 1347 | return NOTIFY_DONE; |
1349 | } | 1348 | } |
@@ -1552,7 +1551,7 @@ static void mroute_clean_tables(struct mr6_table *mrt, bool all) | |||
1552 | for (i = 0; i < mrt->maxvif; i++) { | 1551 | for (i = 0; i < mrt->maxvif; i++) { |
1553 | if (!all && (mrt->vif6_table[i].flags & VIFF_STATIC)) | 1552 | if (!all && (mrt->vif6_table[i].flags & VIFF_STATIC)) |
1554 | continue; | 1553 | continue; |
1555 | mif6_delete(mrt, i, &list); | 1554 | mif6_delete(mrt, i, 0, &list); |
1556 | } | 1555 | } |
1557 | unregister_netdevice_many(&list); | 1556 | unregister_netdevice_many(&list); |
1558 | 1557 | ||
@@ -1707,7 +1706,7 @@ int ip6_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, uns | |||
1707 | if (copy_from_user(&mifi, optval, sizeof(mifi_t))) | 1706 | if (copy_from_user(&mifi, optval, sizeof(mifi_t))) |
1708 | return -EFAULT; | 1707 | return -EFAULT; |
1709 | rtnl_lock(); | 1708 | rtnl_lock(); |
1710 | ret = mif6_delete(mrt, mifi, NULL); | 1709 | ret = mif6_delete(mrt, mifi, 0, NULL); |
1711 | rtnl_unlock(); | 1710 | rtnl_unlock(); |
1712 | return ret; | 1711 | return ret; |
1713 | 1712 | ||
diff --git a/net/ipv6/route.c b/net/ipv6/route.c index 9db1418993f2..fb174b590fd3 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c | |||
@@ -1854,6 +1854,10 @@ static struct rt6_info *ip6_route_info_create(struct fib6_config *cfg) | |||
1854 | int addr_type; | 1854 | int addr_type; |
1855 | int err = -EINVAL; | 1855 | int err = -EINVAL; |
1856 | 1856 | ||
1857 | /* RTF_PCPU is an internal flag; can not be set by userspace */ | ||
1858 | if (cfg->fc_flags & RTF_PCPU) | ||
1859 | goto out; | ||
1860 | |||
1857 | if (cfg->fc_dst_len > 128 || cfg->fc_src_len > 128) | 1861 | if (cfg->fc_dst_len > 128 || cfg->fc_src_len > 128) |
1858 | goto out; | 1862 | goto out; |
1859 | #ifndef CONFIG_IPV6_SUBTREES | 1863 | #ifndef CONFIG_IPV6_SUBTREES |
diff --git a/net/ipv6/seg6.c b/net/ipv6/seg6.c index a855eb325b03..5f44ffed2576 100644 --- a/net/ipv6/seg6.c +++ b/net/ipv6/seg6.c | |||
@@ -53,6 +53,9 @@ bool seg6_validate_srh(struct ipv6_sr_hdr *srh, int len) | |||
53 | struct sr6_tlv *tlv; | 53 | struct sr6_tlv *tlv; |
54 | unsigned int tlv_len; | 54 | unsigned int tlv_len; |
55 | 55 | ||
56 | if (trailing < sizeof(*tlv)) | ||
57 | return false; | ||
58 | |||
56 | tlv = (struct sr6_tlv *)((unsigned char *)srh + tlv_offset); | 59 | tlv = (struct sr6_tlv *)((unsigned char *)srh + tlv_offset); |
57 | tlv_len = sizeof(*tlv) + tlv->len; | 60 | tlv_len = sizeof(*tlv) + tlv->len; |
58 | 61 | ||
diff --git a/net/kcm/kcmsock.c b/net/kcm/kcmsock.c index 309062f3debe..31762f76cdb5 100644 --- a/net/kcm/kcmsock.c +++ b/net/kcm/kcmsock.c | |||
@@ -1687,7 +1687,7 @@ static int kcm_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) | |||
1687 | struct kcm_attach info; | 1687 | struct kcm_attach info; |
1688 | 1688 | ||
1689 | if (copy_from_user(&info, (void __user *)arg, sizeof(info))) | 1689 | if (copy_from_user(&info, (void __user *)arg, sizeof(info))) |
1690 | err = -EFAULT; | 1690 | return -EFAULT; |
1691 | 1691 | ||
1692 | err = kcm_attach_ioctl(sock, &info); | 1692 | err = kcm_attach_ioctl(sock, &info); |
1693 | 1693 | ||
@@ -1697,7 +1697,7 @@ static int kcm_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) | |||
1697 | struct kcm_unattach info; | 1697 | struct kcm_unattach info; |
1698 | 1698 | ||
1699 | if (copy_from_user(&info, (void __user *)arg, sizeof(info))) | 1699 | if (copy_from_user(&info, (void __user *)arg, sizeof(info))) |
1700 | err = -EFAULT; | 1700 | return -EFAULT; |
1701 | 1701 | ||
1702 | err = kcm_unattach_ioctl(sock, &info); | 1702 | err = kcm_unattach_ioctl(sock, &info); |
1703 | 1703 | ||
@@ -1708,7 +1708,7 @@ static int kcm_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) | |||
1708 | struct socket *newsock = NULL; | 1708 | struct socket *newsock = NULL; |
1709 | 1709 | ||
1710 | if (copy_from_user(&info, (void __user *)arg, sizeof(info))) | 1710 | if (copy_from_user(&info, (void __user *)arg, sizeof(info))) |
1711 | err = -EFAULT; | 1711 | return -EFAULT; |
1712 | 1712 | ||
1713 | err = kcm_clone(sock, &info, &newsock); | 1713 | err = kcm_clone(sock, &info, &newsock); |
1714 | 1714 | ||
diff --git a/net/key/af_key.c b/net/key/af_key.c index c6252ed42c1d..be8cecc65002 100644 --- a/net/key/af_key.c +++ b/net/key/af_key.c | |||
@@ -63,8 +63,13 @@ struct pfkey_sock { | |||
63 | } u; | 63 | } u; |
64 | struct sk_buff *skb; | 64 | struct sk_buff *skb; |
65 | } dump; | 65 | } dump; |
66 | struct mutex dump_lock; | ||
66 | }; | 67 | }; |
67 | 68 | ||
69 | static int parse_sockaddr_pair(struct sockaddr *sa, int ext_len, | ||
70 | xfrm_address_t *saddr, xfrm_address_t *daddr, | ||
71 | u16 *family); | ||
72 | |||
68 | static inline struct pfkey_sock *pfkey_sk(struct sock *sk) | 73 | static inline struct pfkey_sock *pfkey_sk(struct sock *sk) |
69 | { | 74 | { |
70 | return (struct pfkey_sock *)sk; | 75 | return (struct pfkey_sock *)sk; |
@@ -139,6 +144,7 @@ static int pfkey_create(struct net *net, struct socket *sock, int protocol, | |||
139 | { | 144 | { |
140 | struct netns_pfkey *net_pfkey = net_generic(net, pfkey_net_id); | 145 | struct netns_pfkey *net_pfkey = net_generic(net, pfkey_net_id); |
141 | struct sock *sk; | 146 | struct sock *sk; |
147 | struct pfkey_sock *pfk; | ||
142 | int err; | 148 | int err; |
143 | 149 | ||
144 | if (!ns_capable(net->user_ns, CAP_NET_ADMIN)) | 150 | if (!ns_capable(net->user_ns, CAP_NET_ADMIN)) |
@@ -153,6 +159,9 @@ static int pfkey_create(struct net *net, struct socket *sock, int protocol, | |||
153 | if (sk == NULL) | 159 | if (sk == NULL) |
154 | goto out; | 160 | goto out; |
155 | 161 | ||
162 | pfk = pfkey_sk(sk); | ||
163 | mutex_init(&pfk->dump_lock); | ||
164 | |||
156 | sock->ops = &pfkey_ops; | 165 | sock->ops = &pfkey_ops; |
157 | sock_init_data(sock, sk); | 166 | sock_init_data(sock, sk); |
158 | 167 | ||
@@ -281,13 +290,23 @@ static int pfkey_do_dump(struct pfkey_sock *pfk) | |||
281 | struct sadb_msg *hdr; | 290 | struct sadb_msg *hdr; |
282 | int rc; | 291 | int rc; |
283 | 292 | ||
293 | mutex_lock(&pfk->dump_lock); | ||
294 | if (!pfk->dump.dump) { | ||
295 | rc = 0; | ||
296 | goto out; | ||
297 | } | ||
298 | |||
284 | rc = pfk->dump.dump(pfk); | 299 | rc = pfk->dump.dump(pfk); |
285 | if (rc == -ENOBUFS) | 300 | if (rc == -ENOBUFS) { |
286 | return 0; | 301 | rc = 0; |
302 | goto out; | ||
303 | } | ||
287 | 304 | ||
288 | if (pfk->dump.skb) { | 305 | if (pfk->dump.skb) { |
289 | if (!pfkey_can_dump(&pfk->sk)) | 306 | if (!pfkey_can_dump(&pfk->sk)) { |
290 | return 0; | 307 | rc = 0; |
308 | goto out; | ||
309 | } | ||
291 | 310 | ||
292 | hdr = (struct sadb_msg *) pfk->dump.skb->data; | 311 | hdr = (struct sadb_msg *) pfk->dump.skb->data; |
293 | hdr->sadb_msg_seq = 0; | 312 | hdr->sadb_msg_seq = 0; |
@@ -298,6 +317,9 @@ static int pfkey_do_dump(struct pfkey_sock *pfk) | |||
298 | } | 317 | } |
299 | 318 | ||
300 | pfkey_terminate_dump(pfk); | 319 | pfkey_terminate_dump(pfk); |
320 | |||
321 | out: | ||
322 | mutex_unlock(&pfk->dump_lock); | ||
301 | return rc; | 323 | return rc; |
302 | } | 324 | } |
303 | 325 | ||
@@ -1793,19 +1815,26 @@ static int pfkey_dump(struct sock *sk, struct sk_buff *skb, const struct sadb_ms | |||
1793 | struct xfrm_address_filter *filter = NULL; | 1815 | struct xfrm_address_filter *filter = NULL; |
1794 | struct pfkey_sock *pfk = pfkey_sk(sk); | 1816 | struct pfkey_sock *pfk = pfkey_sk(sk); |
1795 | 1817 | ||
1796 | if (pfk->dump.dump != NULL) | 1818 | mutex_lock(&pfk->dump_lock); |
1819 | if (pfk->dump.dump != NULL) { | ||
1820 | mutex_unlock(&pfk->dump_lock); | ||
1797 | return -EBUSY; | 1821 | return -EBUSY; |
1822 | } | ||
1798 | 1823 | ||
1799 | proto = pfkey_satype2proto(hdr->sadb_msg_satype); | 1824 | proto = pfkey_satype2proto(hdr->sadb_msg_satype); |
1800 | if (proto == 0) | 1825 | if (proto == 0) { |
1826 | mutex_unlock(&pfk->dump_lock); | ||
1801 | return -EINVAL; | 1827 | return -EINVAL; |
1828 | } | ||
1802 | 1829 | ||
1803 | if (ext_hdrs[SADB_X_EXT_FILTER - 1]) { | 1830 | if (ext_hdrs[SADB_X_EXT_FILTER - 1]) { |
1804 | struct sadb_x_filter *xfilter = ext_hdrs[SADB_X_EXT_FILTER - 1]; | 1831 | struct sadb_x_filter *xfilter = ext_hdrs[SADB_X_EXT_FILTER - 1]; |
1805 | 1832 | ||
1806 | filter = kmalloc(sizeof(*filter), GFP_KERNEL); | 1833 | filter = kmalloc(sizeof(*filter), GFP_KERNEL); |
1807 | if (filter == NULL) | 1834 | if (filter == NULL) { |
1835 | mutex_unlock(&pfk->dump_lock); | ||
1808 | return -ENOMEM; | 1836 | return -ENOMEM; |
1837 | } | ||
1809 | 1838 | ||
1810 | memcpy(&filter->saddr, &xfilter->sadb_x_filter_saddr, | 1839 | memcpy(&filter->saddr, &xfilter->sadb_x_filter_saddr, |
1811 | sizeof(xfrm_address_t)); | 1840 | sizeof(xfrm_address_t)); |
@@ -1821,6 +1850,7 @@ static int pfkey_dump(struct sock *sk, struct sk_buff *skb, const struct sadb_ms | |||
1821 | pfk->dump.dump = pfkey_dump_sa; | 1850 | pfk->dump.dump = pfkey_dump_sa; |
1822 | pfk->dump.done = pfkey_dump_sa_done; | 1851 | pfk->dump.done = pfkey_dump_sa_done; |
1823 | xfrm_state_walk_init(&pfk->dump.u.state, proto, filter); | 1852 | xfrm_state_walk_init(&pfk->dump.u.state, proto, filter); |
1853 | mutex_unlock(&pfk->dump_lock); | ||
1824 | 1854 | ||
1825 | return pfkey_do_dump(pfk); | 1855 | return pfkey_do_dump(pfk); |
1826 | } | 1856 | } |
@@ -1913,19 +1943,14 @@ parse_ipsecrequest(struct xfrm_policy *xp, struct sadb_x_ipsecrequest *rq) | |||
1913 | 1943 | ||
1914 | /* addresses present only in tunnel mode */ | 1944 | /* addresses present only in tunnel mode */ |
1915 | if (t->mode == XFRM_MODE_TUNNEL) { | 1945 | if (t->mode == XFRM_MODE_TUNNEL) { |
1916 | u8 *sa = (u8 *) (rq + 1); | 1946 | int err; |
1917 | int family, socklen; | ||
1918 | 1947 | ||
1919 | family = pfkey_sockaddr_extract((struct sockaddr *)sa, | 1948 | err = parse_sockaddr_pair( |
1920 | &t->saddr); | 1949 | (struct sockaddr *)(rq + 1), |
1921 | if (!family) | 1950 | rq->sadb_x_ipsecrequest_len - sizeof(*rq), |
1922 | return -EINVAL; | 1951 | &t->saddr, &t->id.daddr, &t->encap_family); |
1923 | 1952 | if (err) | |
1924 | socklen = pfkey_sockaddr_len(family); | 1953 | return err; |
1925 | if (pfkey_sockaddr_extract((struct sockaddr *)(sa + socklen), | ||
1926 | &t->id.daddr) != family) | ||
1927 | return -EINVAL; | ||
1928 | t->encap_family = family; | ||
1929 | } else | 1954 | } else |
1930 | t->encap_family = xp->family; | 1955 | t->encap_family = xp->family; |
1931 | 1956 | ||
@@ -1945,7 +1970,11 @@ parse_ipsecrequests(struct xfrm_policy *xp, struct sadb_x_policy *pol) | |||
1945 | if (pol->sadb_x_policy_len * 8 < sizeof(struct sadb_x_policy)) | 1970 | if (pol->sadb_x_policy_len * 8 < sizeof(struct sadb_x_policy)) |
1946 | return -EINVAL; | 1971 | return -EINVAL; |
1947 | 1972 | ||
1948 | while (len >= sizeof(struct sadb_x_ipsecrequest)) { | 1973 | while (len >= sizeof(*rq)) { |
1974 | if (len < rq->sadb_x_ipsecrequest_len || | ||
1975 | rq->sadb_x_ipsecrequest_len < sizeof(*rq)) | ||
1976 | return -EINVAL; | ||
1977 | |||
1949 | if ((err = parse_ipsecrequest(xp, rq)) < 0) | 1978 | if ((err = parse_ipsecrequest(xp, rq)) < 0) |
1950 | return err; | 1979 | return err; |
1951 | len -= rq->sadb_x_ipsecrequest_len; | 1980 | len -= rq->sadb_x_ipsecrequest_len; |
@@ -2408,7 +2437,6 @@ out: | |||
2408 | return err; | 2437 | return err; |
2409 | } | 2438 | } |
2410 | 2439 | ||
2411 | #ifdef CONFIG_NET_KEY_MIGRATE | ||
2412 | static int pfkey_sockaddr_pair_size(sa_family_t family) | 2440 | static int pfkey_sockaddr_pair_size(sa_family_t family) |
2413 | { | 2441 | { |
2414 | return PFKEY_ALIGN8(pfkey_sockaddr_len(family) * 2); | 2442 | return PFKEY_ALIGN8(pfkey_sockaddr_len(family) * 2); |
@@ -2420,7 +2448,7 @@ static int parse_sockaddr_pair(struct sockaddr *sa, int ext_len, | |||
2420 | { | 2448 | { |
2421 | int af, socklen; | 2449 | int af, socklen; |
2422 | 2450 | ||
2423 | if (ext_len < pfkey_sockaddr_pair_size(sa->sa_family)) | 2451 | if (ext_len < 2 || ext_len < pfkey_sockaddr_pair_size(sa->sa_family)) |
2424 | return -EINVAL; | 2452 | return -EINVAL; |
2425 | 2453 | ||
2426 | af = pfkey_sockaddr_extract(sa, saddr); | 2454 | af = pfkey_sockaddr_extract(sa, saddr); |
@@ -2436,6 +2464,7 @@ static int parse_sockaddr_pair(struct sockaddr *sa, int ext_len, | |||
2436 | return 0; | 2464 | return 0; |
2437 | } | 2465 | } |
2438 | 2466 | ||
2467 | #ifdef CONFIG_NET_KEY_MIGRATE | ||
2439 | static int ipsecrequests_to_migrate(struct sadb_x_ipsecrequest *rq1, int len, | 2468 | static int ipsecrequests_to_migrate(struct sadb_x_ipsecrequest *rq1, int len, |
2440 | struct xfrm_migrate *m) | 2469 | struct xfrm_migrate *m) |
2441 | { | 2470 | { |
@@ -2443,13 +2472,14 @@ static int ipsecrequests_to_migrate(struct sadb_x_ipsecrequest *rq1, int len, | |||
2443 | struct sadb_x_ipsecrequest *rq2; | 2472 | struct sadb_x_ipsecrequest *rq2; |
2444 | int mode; | 2473 | int mode; |
2445 | 2474 | ||
2446 | if (len <= sizeof(struct sadb_x_ipsecrequest) || | 2475 | if (len < sizeof(*rq1) || |
2447 | len < rq1->sadb_x_ipsecrequest_len) | 2476 | len < rq1->sadb_x_ipsecrequest_len || |
2477 | rq1->sadb_x_ipsecrequest_len < sizeof(*rq1)) | ||
2448 | return -EINVAL; | 2478 | return -EINVAL; |
2449 | 2479 | ||
2450 | /* old endoints */ | 2480 | /* old endoints */ |
2451 | err = parse_sockaddr_pair((struct sockaddr *)(rq1 + 1), | 2481 | err = parse_sockaddr_pair((struct sockaddr *)(rq1 + 1), |
2452 | rq1->sadb_x_ipsecrequest_len, | 2482 | rq1->sadb_x_ipsecrequest_len - sizeof(*rq1), |
2453 | &m->old_saddr, &m->old_daddr, | 2483 | &m->old_saddr, &m->old_daddr, |
2454 | &m->old_family); | 2484 | &m->old_family); |
2455 | if (err) | 2485 | if (err) |
@@ -2458,13 +2488,14 @@ static int ipsecrequests_to_migrate(struct sadb_x_ipsecrequest *rq1, int len, | |||
2458 | rq2 = (struct sadb_x_ipsecrequest *)((u8 *)rq1 + rq1->sadb_x_ipsecrequest_len); | 2488 | rq2 = (struct sadb_x_ipsecrequest *)((u8 *)rq1 + rq1->sadb_x_ipsecrequest_len); |
2459 | len -= rq1->sadb_x_ipsecrequest_len; | 2489 | len -= rq1->sadb_x_ipsecrequest_len; |
2460 | 2490 | ||
2461 | if (len <= sizeof(struct sadb_x_ipsecrequest) || | 2491 | if (len <= sizeof(*rq2) || |
2462 | len < rq2->sadb_x_ipsecrequest_len) | 2492 | len < rq2->sadb_x_ipsecrequest_len || |
2493 | rq2->sadb_x_ipsecrequest_len < sizeof(*rq2)) | ||
2463 | return -EINVAL; | 2494 | return -EINVAL; |
2464 | 2495 | ||
2465 | /* new endpoints */ | 2496 | /* new endpoints */ |
2466 | err = parse_sockaddr_pair((struct sockaddr *)(rq2 + 1), | 2497 | err = parse_sockaddr_pair((struct sockaddr *)(rq2 + 1), |
2467 | rq2->sadb_x_ipsecrequest_len, | 2498 | rq2->sadb_x_ipsecrequest_len - sizeof(*rq2), |
2468 | &m->new_saddr, &m->new_daddr, | 2499 | &m->new_saddr, &m->new_daddr, |
2469 | &m->new_family); | 2500 | &m->new_family); |
2470 | if (err) | 2501 | if (err) |
@@ -2679,14 +2710,18 @@ static int pfkey_spddump(struct sock *sk, struct sk_buff *skb, const struct sadb | |||
2679 | { | 2710 | { |
2680 | struct pfkey_sock *pfk = pfkey_sk(sk); | 2711 | struct pfkey_sock *pfk = pfkey_sk(sk); |
2681 | 2712 | ||
2682 | if (pfk->dump.dump != NULL) | 2713 | mutex_lock(&pfk->dump_lock); |
2714 | if (pfk->dump.dump != NULL) { | ||
2715 | mutex_unlock(&pfk->dump_lock); | ||
2683 | return -EBUSY; | 2716 | return -EBUSY; |
2717 | } | ||
2684 | 2718 | ||
2685 | pfk->dump.msg_version = hdr->sadb_msg_version; | 2719 | pfk->dump.msg_version = hdr->sadb_msg_version; |
2686 | pfk->dump.msg_portid = hdr->sadb_msg_pid; | 2720 | pfk->dump.msg_portid = hdr->sadb_msg_pid; |
2687 | pfk->dump.dump = pfkey_dump_sp; | 2721 | pfk->dump.dump = pfkey_dump_sp; |
2688 | pfk->dump.done = pfkey_dump_sp_done; | 2722 | pfk->dump.done = pfkey_dump_sp_done; |
2689 | xfrm_policy_walk_init(&pfk->dump.u.policy, XFRM_POLICY_TYPE_MAIN); | 2723 | xfrm_policy_walk_init(&pfk->dump.u.policy, XFRM_POLICY_TYPE_MAIN); |
2724 | mutex_unlock(&pfk->dump_lock); | ||
2690 | 2725 | ||
2691 | return pfkey_do_dump(pfk); | 2726 | return pfkey_do_dump(pfk); |
2692 | } | 2727 | } |
diff --git a/net/l2tp/l2tp_core.c b/net/l2tp/l2tp_core.c index 8adab6335ced..e37d9554da7b 100644 --- a/net/l2tp/l2tp_core.c +++ b/net/l2tp/l2tp_core.c | |||
@@ -278,7 +278,57 @@ struct l2tp_session *l2tp_session_find(struct net *net, struct l2tp_tunnel *tunn | |||
278 | } | 278 | } |
279 | EXPORT_SYMBOL_GPL(l2tp_session_find); | 279 | EXPORT_SYMBOL_GPL(l2tp_session_find); |
280 | 280 | ||
281 | struct l2tp_session *l2tp_session_find_nth(struct l2tp_tunnel *tunnel, int nth) | 281 | /* Like l2tp_session_find() but takes a reference on the returned session. |
282 | * Optionally calls session->ref() too if do_ref is true. | ||
283 | */ | ||
284 | struct l2tp_session *l2tp_session_get(struct net *net, | ||
285 | struct l2tp_tunnel *tunnel, | ||
286 | u32 session_id, bool do_ref) | ||
287 | { | ||
288 | struct hlist_head *session_list; | ||
289 | struct l2tp_session *session; | ||
290 | |||
291 | if (!tunnel) { | ||
292 | struct l2tp_net *pn = l2tp_pernet(net); | ||
293 | |||
294 | session_list = l2tp_session_id_hash_2(pn, session_id); | ||
295 | |||
296 | rcu_read_lock_bh(); | ||
297 | hlist_for_each_entry_rcu(session, session_list, global_hlist) { | ||
298 | if (session->session_id == session_id) { | ||
299 | l2tp_session_inc_refcount(session); | ||
300 | if (do_ref && session->ref) | ||
301 | session->ref(session); | ||
302 | rcu_read_unlock_bh(); | ||
303 | |||
304 | return session; | ||
305 | } | ||
306 | } | ||
307 | rcu_read_unlock_bh(); | ||
308 | |||
309 | return NULL; | ||
310 | } | ||
311 | |||
312 | session_list = l2tp_session_id_hash(tunnel, session_id); | ||
313 | read_lock_bh(&tunnel->hlist_lock); | ||
314 | hlist_for_each_entry(session, session_list, hlist) { | ||
315 | if (session->session_id == session_id) { | ||
316 | l2tp_session_inc_refcount(session); | ||
317 | if (do_ref && session->ref) | ||
318 | session->ref(session); | ||
319 | read_unlock_bh(&tunnel->hlist_lock); | ||
320 | |||
321 | return session; | ||
322 | } | ||
323 | } | ||
324 | read_unlock_bh(&tunnel->hlist_lock); | ||
325 | |||
326 | return NULL; | ||
327 | } | ||
328 | EXPORT_SYMBOL_GPL(l2tp_session_get); | ||
329 | |||
330 | struct l2tp_session *l2tp_session_get_nth(struct l2tp_tunnel *tunnel, int nth, | ||
331 | bool do_ref) | ||
282 | { | 332 | { |
283 | int hash; | 333 | int hash; |
284 | struct l2tp_session *session; | 334 | struct l2tp_session *session; |
@@ -288,6 +338,9 @@ struct l2tp_session *l2tp_session_find_nth(struct l2tp_tunnel *tunnel, int nth) | |||
288 | for (hash = 0; hash < L2TP_HASH_SIZE; hash++) { | 338 | for (hash = 0; hash < L2TP_HASH_SIZE; hash++) { |
289 | hlist_for_each_entry(session, &tunnel->session_hlist[hash], hlist) { | 339 | hlist_for_each_entry(session, &tunnel->session_hlist[hash], hlist) { |
290 | if (++count > nth) { | 340 | if (++count > nth) { |
341 | l2tp_session_inc_refcount(session); | ||
342 | if (do_ref && session->ref) | ||
343 | session->ref(session); | ||
291 | read_unlock_bh(&tunnel->hlist_lock); | 344 | read_unlock_bh(&tunnel->hlist_lock); |
292 | return session; | 345 | return session; |
293 | } | 346 | } |
@@ -298,12 +351,13 @@ struct l2tp_session *l2tp_session_find_nth(struct l2tp_tunnel *tunnel, int nth) | |||
298 | 351 | ||
299 | return NULL; | 352 | return NULL; |
300 | } | 353 | } |
301 | EXPORT_SYMBOL_GPL(l2tp_session_find_nth); | 354 | EXPORT_SYMBOL_GPL(l2tp_session_get_nth); |
302 | 355 | ||
303 | /* Lookup a session by interface name. | 356 | /* Lookup a session by interface name. |
304 | * This is very inefficient but is only used by management interfaces. | 357 | * This is very inefficient but is only used by management interfaces. |
305 | */ | 358 | */ |
306 | struct l2tp_session *l2tp_session_find_by_ifname(struct net *net, char *ifname) | 359 | struct l2tp_session *l2tp_session_get_by_ifname(struct net *net, char *ifname, |
360 | bool do_ref) | ||
307 | { | 361 | { |
308 | struct l2tp_net *pn = l2tp_pernet(net); | 362 | struct l2tp_net *pn = l2tp_pernet(net); |
309 | int hash; | 363 | int hash; |
@@ -313,7 +367,11 @@ struct l2tp_session *l2tp_session_find_by_ifname(struct net *net, char *ifname) | |||
313 | for (hash = 0; hash < L2TP_HASH_SIZE_2; hash++) { | 367 | for (hash = 0; hash < L2TP_HASH_SIZE_2; hash++) { |
314 | hlist_for_each_entry_rcu(session, &pn->l2tp_session_hlist[hash], global_hlist) { | 368 | hlist_for_each_entry_rcu(session, &pn->l2tp_session_hlist[hash], global_hlist) { |
315 | if (!strcmp(session->ifname, ifname)) { | 369 | if (!strcmp(session->ifname, ifname)) { |
370 | l2tp_session_inc_refcount(session); | ||
371 | if (do_ref && session->ref) | ||
372 | session->ref(session); | ||
316 | rcu_read_unlock_bh(); | 373 | rcu_read_unlock_bh(); |
374 | |||
317 | return session; | 375 | return session; |
318 | } | 376 | } |
319 | } | 377 | } |
@@ -323,7 +381,49 @@ struct l2tp_session *l2tp_session_find_by_ifname(struct net *net, char *ifname) | |||
323 | 381 | ||
324 | return NULL; | 382 | return NULL; |
325 | } | 383 | } |
326 | EXPORT_SYMBOL_GPL(l2tp_session_find_by_ifname); | 384 | EXPORT_SYMBOL_GPL(l2tp_session_get_by_ifname); |
385 | |||
386 | static int l2tp_session_add_to_tunnel(struct l2tp_tunnel *tunnel, | ||
387 | struct l2tp_session *session) | ||
388 | { | ||
389 | struct l2tp_session *session_walk; | ||
390 | struct hlist_head *g_head; | ||
391 | struct hlist_head *head; | ||
392 | struct l2tp_net *pn; | ||
393 | |||
394 | head = l2tp_session_id_hash(tunnel, session->session_id); | ||
395 | |||
396 | write_lock_bh(&tunnel->hlist_lock); | ||
397 | hlist_for_each_entry(session_walk, head, hlist) | ||
398 | if (session_walk->session_id == session->session_id) | ||
399 | goto exist; | ||
400 | |||
401 | if (tunnel->version == L2TP_HDR_VER_3) { | ||
402 | pn = l2tp_pernet(tunnel->l2tp_net); | ||
403 | g_head = l2tp_session_id_hash_2(l2tp_pernet(tunnel->l2tp_net), | ||
404 | session->session_id); | ||
405 | |||
406 | spin_lock_bh(&pn->l2tp_session_hlist_lock); | ||
407 | hlist_for_each_entry(session_walk, g_head, global_hlist) | ||
408 | if (session_walk->session_id == session->session_id) | ||
409 | goto exist_glob; | ||
410 | |||
411 | hlist_add_head_rcu(&session->global_hlist, g_head); | ||
412 | spin_unlock_bh(&pn->l2tp_session_hlist_lock); | ||
413 | } | ||
414 | |||
415 | hlist_add_head(&session->hlist, head); | ||
416 | write_unlock_bh(&tunnel->hlist_lock); | ||
417 | |||
418 | return 0; | ||
419 | |||
420 | exist_glob: | ||
421 | spin_unlock_bh(&pn->l2tp_session_hlist_lock); | ||
422 | exist: | ||
423 | write_unlock_bh(&tunnel->hlist_lock); | ||
424 | |||
425 | return -EEXIST; | ||
426 | } | ||
327 | 427 | ||
328 | /* Lookup a tunnel by id | 428 | /* Lookup a tunnel by id |
329 | */ | 429 | */ |
@@ -633,6 +733,9 @@ discard: | |||
633 | * a data (not control) frame before coming here. Fields up to the | 733 | * a data (not control) frame before coming here. Fields up to the |
634 | * session-id have already been parsed and ptr points to the data | 734 | * session-id have already been parsed and ptr points to the data |
635 | * after the session-id. | 735 | * after the session-id. |
736 | * | ||
737 | * session->ref() must have been called prior to l2tp_recv_common(). | ||
738 | * session->deref() will be called automatically after skb is processed. | ||
636 | */ | 739 | */ |
637 | void l2tp_recv_common(struct l2tp_session *session, struct sk_buff *skb, | 740 | void l2tp_recv_common(struct l2tp_session *session, struct sk_buff *skb, |
638 | unsigned char *ptr, unsigned char *optr, u16 hdrflags, | 741 | unsigned char *ptr, unsigned char *optr, u16 hdrflags, |
@@ -642,14 +745,6 @@ void l2tp_recv_common(struct l2tp_session *session, struct sk_buff *skb, | |||
642 | int offset; | 745 | int offset; |
643 | u32 ns, nr; | 746 | u32 ns, nr; |
644 | 747 | ||
645 | /* The ref count is increased since we now hold a pointer to | ||
646 | * the session. Take care to decrement the refcnt when exiting | ||
647 | * this function from now on... | ||
648 | */ | ||
649 | l2tp_session_inc_refcount(session); | ||
650 | if (session->ref) | ||
651 | (*session->ref)(session); | ||
652 | |||
653 | /* Parse and check optional cookie */ | 748 | /* Parse and check optional cookie */ |
654 | if (session->peer_cookie_len > 0) { | 749 | if (session->peer_cookie_len > 0) { |
655 | if (memcmp(ptr, &session->peer_cookie[0], session->peer_cookie_len)) { | 750 | if (memcmp(ptr, &session->peer_cookie[0], session->peer_cookie_len)) { |
@@ -802,8 +897,6 @@ void l2tp_recv_common(struct l2tp_session *session, struct sk_buff *skb, | |||
802 | /* Try to dequeue as many skbs from reorder_q as we can. */ | 897 | /* Try to dequeue as many skbs from reorder_q as we can. */ |
803 | l2tp_recv_dequeue(session); | 898 | l2tp_recv_dequeue(session); |
804 | 899 | ||
805 | l2tp_session_dec_refcount(session); | ||
806 | |||
807 | return; | 900 | return; |
808 | 901 | ||
809 | discard: | 902 | discard: |
@@ -812,8 +905,6 @@ discard: | |||
812 | 905 | ||
813 | if (session->deref) | 906 | if (session->deref) |
814 | (*session->deref)(session); | 907 | (*session->deref)(session); |
815 | |||
816 | l2tp_session_dec_refcount(session); | ||
817 | } | 908 | } |
818 | EXPORT_SYMBOL(l2tp_recv_common); | 909 | EXPORT_SYMBOL(l2tp_recv_common); |
819 | 910 | ||
@@ -920,8 +1011,14 @@ static int l2tp_udp_recv_core(struct l2tp_tunnel *tunnel, struct sk_buff *skb, | |||
920 | } | 1011 | } |
921 | 1012 | ||
922 | /* Find the session context */ | 1013 | /* Find the session context */ |
923 | session = l2tp_session_find(tunnel->l2tp_net, tunnel, session_id); | 1014 | session = l2tp_session_get(tunnel->l2tp_net, tunnel, session_id, true); |
924 | if (!session || !session->recv_skb) { | 1015 | if (!session || !session->recv_skb) { |
1016 | if (session) { | ||
1017 | if (session->deref) | ||
1018 | session->deref(session); | ||
1019 | l2tp_session_dec_refcount(session); | ||
1020 | } | ||
1021 | |||
925 | /* Not found? Pass to userspace to deal with */ | 1022 | /* Not found? Pass to userspace to deal with */ |
926 | l2tp_info(tunnel, L2TP_MSG_DATA, | 1023 | l2tp_info(tunnel, L2TP_MSG_DATA, |
927 | "%s: no session found (%u/%u). Passing up.\n", | 1024 | "%s: no session found (%u/%u). Passing up.\n", |
@@ -930,6 +1027,7 @@ static int l2tp_udp_recv_core(struct l2tp_tunnel *tunnel, struct sk_buff *skb, | |||
930 | } | 1027 | } |
931 | 1028 | ||
932 | l2tp_recv_common(session, skb, ptr, optr, hdrflags, length, payload_hook); | 1029 | l2tp_recv_common(session, skb, ptr, optr, hdrflags, length, payload_hook); |
1030 | l2tp_session_dec_refcount(session); | ||
933 | 1031 | ||
934 | return 0; | 1032 | return 0; |
935 | 1033 | ||
@@ -1738,6 +1836,7 @@ EXPORT_SYMBOL_GPL(l2tp_session_set_header_len); | |||
1738 | struct l2tp_session *l2tp_session_create(int priv_size, struct l2tp_tunnel *tunnel, u32 session_id, u32 peer_session_id, struct l2tp_session_cfg *cfg) | 1836 | struct l2tp_session *l2tp_session_create(int priv_size, struct l2tp_tunnel *tunnel, u32 session_id, u32 peer_session_id, struct l2tp_session_cfg *cfg) |
1739 | { | 1837 | { |
1740 | struct l2tp_session *session; | 1838 | struct l2tp_session *session; |
1839 | int err; | ||
1741 | 1840 | ||
1742 | session = kzalloc(sizeof(struct l2tp_session) + priv_size, GFP_KERNEL); | 1841 | session = kzalloc(sizeof(struct l2tp_session) + priv_size, GFP_KERNEL); |
1743 | if (session != NULL) { | 1842 | if (session != NULL) { |
@@ -1793,6 +1892,13 @@ struct l2tp_session *l2tp_session_create(int priv_size, struct l2tp_tunnel *tunn | |||
1793 | 1892 | ||
1794 | l2tp_session_set_header_len(session, tunnel->version); | 1893 | l2tp_session_set_header_len(session, tunnel->version); |
1795 | 1894 | ||
1895 | err = l2tp_session_add_to_tunnel(tunnel, session); | ||
1896 | if (err) { | ||
1897 | kfree(session); | ||
1898 | |||
1899 | return ERR_PTR(err); | ||
1900 | } | ||
1901 | |||
1796 | /* Bump the reference count. The session context is deleted | 1902 | /* Bump the reference count. The session context is deleted |
1797 | * only when this drops to zero. | 1903 | * only when this drops to zero. |
1798 | */ | 1904 | */ |
@@ -1802,28 +1908,14 @@ struct l2tp_session *l2tp_session_create(int priv_size, struct l2tp_tunnel *tunn | |||
1802 | /* Ensure tunnel socket isn't deleted */ | 1908 | /* Ensure tunnel socket isn't deleted */ |
1803 | sock_hold(tunnel->sock); | 1909 | sock_hold(tunnel->sock); |
1804 | 1910 | ||
1805 | /* Add session to the tunnel's hash list */ | ||
1806 | write_lock_bh(&tunnel->hlist_lock); | ||
1807 | hlist_add_head(&session->hlist, | ||
1808 | l2tp_session_id_hash(tunnel, session_id)); | ||
1809 | write_unlock_bh(&tunnel->hlist_lock); | ||
1810 | |||
1811 | /* And to the global session list if L2TPv3 */ | ||
1812 | if (tunnel->version != L2TP_HDR_VER_2) { | ||
1813 | struct l2tp_net *pn = l2tp_pernet(tunnel->l2tp_net); | ||
1814 | |||
1815 | spin_lock_bh(&pn->l2tp_session_hlist_lock); | ||
1816 | hlist_add_head_rcu(&session->global_hlist, | ||
1817 | l2tp_session_id_hash_2(pn, session_id)); | ||
1818 | spin_unlock_bh(&pn->l2tp_session_hlist_lock); | ||
1819 | } | ||
1820 | |||
1821 | /* Ignore management session in session count value */ | 1911 | /* Ignore management session in session count value */ |
1822 | if (session->session_id != 0) | 1912 | if (session->session_id != 0) |
1823 | atomic_inc(&l2tp_session_count); | 1913 | atomic_inc(&l2tp_session_count); |
1914 | |||
1915 | return session; | ||
1824 | } | 1916 | } |
1825 | 1917 | ||
1826 | return session; | 1918 | return ERR_PTR(-ENOMEM); |
1827 | } | 1919 | } |
1828 | EXPORT_SYMBOL_GPL(l2tp_session_create); | 1920 | EXPORT_SYMBOL_GPL(l2tp_session_create); |
1829 | 1921 | ||
diff --git a/net/l2tp/l2tp_core.h b/net/l2tp/l2tp_core.h index aebf281d09ee..8ce7818c7a9d 100644 --- a/net/l2tp/l2tp_core.h +++ b/net/l2tp/l2tp_core.h | |||
@@ -230,11 +230,16 @@ out: | |||
230 | return tunnel; | 230 | return tunnel; |
231 | } | 231 | } |
232 | 232 | ||
233 | struct l2tp_session *l2tp_session_get(struct net *net, | ||
234 | struct l2tp_tunnel *tunnel, | ||
235 | u32 session_id, bool do_ref); | ||
233 | struct l2tp_session *l2tp_session_find(struct net *net, | 236 | struct l2tp_session *l2tp_session_find(struct net *net, |
234 | struct l2tp_tunnel *tunnel, | 237 | struct l2tp_tunnel *tunnel, |
235 | u32 session_id); | 238 | u32 session_id); |
236 | struct l2tp_session *l2tp_session_find_nth(struct l2tp_tunnel *tunnel, int nth); | 239 | struct l2tp_session *l2tp_session_get_nth(struct l2tp_tunnel *tunnel, int nth, |
237 | struct l2tp_session *l2tp_session_find_by_ifname(struct net *net, char *ifname); | 240 | bool do_ref); |
241 | struct l2tp_session *l2tp_session_get_by_ifname(struct net *net, char *ifname, | ||
242 | bool do_ref); | ||
238 | struct l2tp_tunnel *l2tp_tunnel_find(struct net *net, u32 tunnel_id); | 243 | struct l2tp_tunnel *l2tp_tunnel_find(struct net *net, u32 tunnel_id); |
239 | struct l2tp_tunnel *l2tp_tunnel_find_nth(struct net *net, int nth); | 244 | struct l2tp_tunnel *l2tp_tunnel_find_nth(struct net *net, int nth); |
240 | 245 | ||
diff --git a/net/l2tp/l2tp_debugfs.c b/net/l2tp/l2tp_debugfs.c index 2d6760a2ae34..d100aed3d06f 100644 --- a/net/l2tp/l2tp_debugfs.c +++ b/net/l2tp/l2tp_debugfs.c | |||
@@ -53,7 +53,7 @@ static void l2tp_dfs_next_tunnel(struct l2tp_dfs_seq_data *pd) | |||
53 | 53 | ||
54 | static void l2tp_dfs_next_session(struct l2tp_dfs_seq_data *pd) | 54 | static void l2tp_dfs_next_session(struct l2tp_dfs_seq_data *pd) |
55 | { | 55 | { |
56 | pd->session = l2tp_session_find_nth(pd->tunnel, pd->session_idx); | 56 | pd->session = l2tp_session_get_nth(pd->tunnel, pd->session_idx, true); |
57 | pd->session_idx++; | 57 | pd->session_idx++; |
58 | 58 | ||
59 | if (pd->session == NULL) { | 59 | if (pd->session == NULL) { |
@@ -238,10 +238,14 @@ static int l2tp_dfs_seq_show(struct seq_file *m, void *v) | |||
238 | } | 238 | } |
239 | 239 | ||
240 | /* Show the tunnel or session context */ | 240 | /* Show the tunnel or session context */ |
241 | if (pd->session == NULL) | 241 | if (!pd->session) { |
242 | l2tp_dfs_seq_tunnel_show(m, pd->tunnel); | 242 | l2tp_dfs_seq_tunnel_show(m, pd->tunnel); |
243 | else | 243 | } else { |
244 | l2tp_dfs_seq_session_show(m, pd->session); | 244 | l2tp_dfs_seq_session_show(m, pd->session); |
245 | if (pd->session->deref) | ||
246 | pd->session->deref(pd->session); | ||
247 | l2tp_session_dec_refcount(pd->session); | ||
248 | } | ||
245 | 249 | ||
246 | out: | 250 | out: |
247 | return 0; | 251 | return 0; |
diff --git a/net/l2tp/l2tp_eth.c b/net/l2tp/l2tp_eth.c index 8bf18a5f66e0..6fd41d7afe1e 100644 --- a/net/l2tp/l2tp_eth.c +++ b/net/l2tp/l2tp_eth.c | |||
@@ -221,12 +221,6 @@ static int l2tp_eth_create(struct net *net, u32 tunnel_id, u32 session_id, u32 p | |||
221 | goto out; | 221 | goto out; |
222 | } | 222 | } |
223 | 223 | ||
224 | session = l2tp_session_find(net, tunnel, session_id); | ||
225 | if (session) { | ||
226 | rc = -EEXIST; | ||
227 | goto out; | ||
228 | } | ||
229 | |||
230 | if (cfg->ifname) { | 224 | if (cfg->ifname) { |
231 | dev = dev_get_by_name(net, cfg->ifname); | 225 | dev = dev_get_by_name(net, cfg->ifname); |
232 | if (dev) { | 226 | if (dev) { |
@@ -240,8 +234,8 @@ static int l2tp_eth_create(struct net *net, u32 tunnel_id, u32 session_id, u32 p | |||
240 | 234 | ||
241 | session = l2tp_session_create(sizeof(*spriv), tunnel, session_id, | 235 | session = l2tp_session_create(sizeof(*spriv), tunnel, session_id, |
242 | peer_session_id, cfg); | 236 | peer_session_id, cfg); |
243 | if (!session) { | 237 | if (IS_ERR(session)) { |
244 | rc = -ENOMEM; | 238 | rc = PTR_ERR(session); |
245 | goto out; | 239 | goto out; |
246 | } | 240 | } |
247 | 241 | ||
diff --git a/net/l2tp/l2tp_ip.c b/net/l2tp/l2tp_ip.c index d25038cfd64e..4d322c1b7233 100644 --- a/net/l2tp/l2tp_ip.c +++ b/net/l2tp/l2tp_ip.c | |||
@@ -143,19 +143,19 @@ static int l2tp_ip_recv(struct sk_buff *skb) | |||
143 | } | 143 | } |
144 | 144 | ||
145 | /* Ok, this is a data packet. Lookup the session. */ | 145 | /* Ok, this is a data packet. Lookup the session. */ |
146 | session = l2tp_session_find(net, NULL, session_id); | 146 | session = l2tp_session_get(net, NULL, session_id, true); |
147 | if (session == NULL) | 147 | if (!session) |
148 | goto discard; | 148 | goto discard; |
149 | 149 | ||
150 | tunnel = session->tunnel; | 150 | tunnel = session->tunnel; |
151 | if (tunnel == NULL) | 151 | if (!tunnel) |
152 | goto discard; | 152 | goto discard_sess; |
153 | 153 | ||
154 | /* Trace packet contents, if enabled */ | 154 | /* Trace packet contents, if enabled */ |
155 | if (tunnel->debug & L2TP_MSG_DATA) { | 155 | if (tunnel->debug & L2TP_MSG_DATA) { |
156 | length = min(32u, skb->len); | 156 | length = min(32u, skb->len); |
157 | if (!pskb_may_pull(skb, length)) | 157 | if (!pskb_may_pull(skb, length)) |
158 | goto discard; | 158 | goto discard_sess; |
159 | 159 | ||
160 | /* Point to L2TP header */ | 160 | /* Point to L2TP header */ |
161 | optr = ptr = skb->data; | 161 | optr = ptr = skb->data; |
@@ -165,6 +165,7 @@ static int l2tp_ip_recv(struct sk_buff *skb) | |||
165 | } | 165 | } |
166 | 166 | ||
167 | l2tp_recv_common(session, skb, ptr, optr, 0, skb->len, tunnel->recv_payload_hook); | 167 | l2tp_recv_common(session, skb, ptr, optr, 0, skb->len, tunnel->recv_payload_hook); |
168 | l2tp_session_dec_refcount(session); | ||
168 | 169 | ||
169 | return 0; | 170 | return 0; |
170 | 171 | ||
@@ -178,9 +179,10 @@ pass_up: | |||
178 | 179 | ||
179 | tunnel_id = ntohl(*(__be32 *) &skb->data[4]); | 180 | tunnel_id = ntohl(*(__be32 *) &skb->data[4]); |
180 | tunnel = l2tp_tunnel_find(net, tunnel_id); | 181 | tunnel = l2tp_tunnel_find(net, tunnel_id); |
181 | if (tunnel != NULL) | 182 | if (tunnel) { |
182 | sk = tunnel->sock; | 183 | sk = tunnel->sock; |
183 | else { | 184 | sock_hold(sk); |
185 | } else { | ||
184 | struct iphdr *iph = (struct iphdr *) skb_network_header(skb); | 186 | struct iphdr *iph = (struct iphdr *) skb_network_header(skb); |
185 | 187 | ||
186 | read_lock_bh(&l2tp_ip_lock); | 188 | read_lock_bh(&l2tp_ip_lock); |
@@ -202,6 +204,12 @@ pass_up: | |||
202 | 204 | ||
203 | return sk_receive_skb(sk, skb, 1); | 205 | return sk_receive_skb(sk, skb, 1); |
204 | 206 | ||
207 | discard_sess: | ||
208 | if (session->deref) | ||
209 | session->deref(session); | ||
210 | l2tp_session_dec_refcount(session); | ||
211 | goto discard; | ||
212 | |||
205 | discard_put: | 213 | discard_put: |
206 | sock_put(sk); | 214 | sock_put(sk); |
207 | 215 | ||
diff --git a/net/l2tp/l2tp_ip6.c b/net/l2tp/l2tp_ip6.c index a4abcbc4c09a..88b397c30d86 100644 --- a/net/l2tp/l2tp_ip6.c +++ b/net/l2tp/l2tp_ip6.c | |||
@@ -156,19 +156,19 @@ static int l2tp_ip6_recv(struct sk_buff *skb) | |||
156 | } | 156 | } |
157 | 157 | ||
158 | /* Ok, this is a data packet. Lookup the session. */ | 158 | /* Ok, this is a data packet. Lookup the session. */ |
159 | session = l2tp_session_find(net, NULL, session_id); | 159 | session = l2tp_session_get(net, NULL, session_id, true); |
160 | if (session == NULL) | 160 | if (!session) |
161 | goto discard; | 161 | goto discard; |
162 | 162 | ||
163 | tunnel = session->tunnel; | 163 | tunnel = session->tunnel; |
164 | if (tunnel == NULL) | 164 | if (!tunnel) |
165 | goto discard; | 165 | goto discard_sess; |
166 | 166 | ||
167 | /* Trace packet contents, if enabled */ | 167 | /* Trace packet contents, if enabled */ |
168 | if (tunnel->debug & L2TP_MSG_DATA) { | 168 | if (tunnel->debug & L2TP_MSG_DATA) { |
169 | length = min(32u, skb->len); | 169 | length = min(32u, skb->len); |
170 | if (!pskb_may_pull(skb, length)) | 170 | if (!pskb_may_pull(skb, length)) |
171 | goto discard; | 171 | goto discard_sess; |
172 | 172 | ||
173 | /* Point to L2TP header */ | 173 | /* Point to L2TP header */ |
174 | optr = ptr = skb->data; | 174 | optr = ptr = skb->data; |
@@ -179,6 +179,8 @@ static int l2tp_ip6_recv(struct sk_buff *skb) | |||
179 | 179 | ||
180 | l2tp_recv_common(session, skb, ptr, optr, 0, skb->len, | 180 | l2tp_recv_common(session, skb, ptr, optr, 0, skb->len, |
181 | tunnel->recv_payload_hook); | 181 | tunnel->recv_payload_hook); |
182 | l2tp_session_dec_refcount(session); | ||
183 | |||
182 | return 0; | 184 | return 0; |
183 | 185 | ||
184 | pass_up: | 186 | pass_up: |
@@ -191,9 +193,10 @@ pass_up: | |||
191 | 193 | ||
192 | tunnel_id = ntohl(*(__be32 *) &skb->data[4]); | 194 | tunnel_id = ntohl(*(__be32 *) &skb->data[4]); |
193 | tunnel = l2tp_tunnel_find(net, tunnel_id); | 195 | tunnel = l2tp_tunnel_find(net, tunnel_id); |
194 | if (tunnel != NULL) | 196 | if (tunnel) { |
195 | sk = tunnel->sock; | 197 | sk = tunnel->sock; |
196 | else { | 198 | sock_hold(sk); |
199 | } else { | ||
197 | struct ipv6hdr *iph = ipv6_hdr(skb); | 200 | struct ipv6hdr *iph = ipv6_hdr(skb); |
198 | 201 | ||
199 | read_lock_bh(&l2tp_ip6_lock); | 202 | read_lock_bh(&l2tp_ip6_lock); |
@@ -215,6 +218,12 @@ pass_up: | |||
215 | 218 | ||
216 | return sk_receive_skb(sk, skb, 1); | 219 | return sk_receive_skb(sk, skb, 1); |
217 | 220 | ||
221 | discard_sess: | ||
222 | if (session->deref) | ||
223 | session->deref(session); | ||
224 | l2tp_session_dec_refcount(session); | ||
225 | goto discard; | ||
226 | |||
218 | discard_put: | 227 | discard_put: |
219 | sock_put(sk); | 228 | sock_put(sk); |
220 | 229 | ||
diff --git a/net/l2tp/l2tp_netlink.c b/net/l2tp/l2tp_netlink.c index 3620fba31786..7e3e669baac4 100644 --- a/net/l2tp/l2tp_netlink.c +++ b/net/l2tp/l2tp_netlink.c | |||
@@ -48,7 +48,8 @@ static int l2tp_nl_session_send(struct sk_buff *skb, u32 portid, u32 seq, | |||
48 | /* Accessed under genl lock */ | 48 | /* Accessed under genl lock */ |
49 | static const struct l2tp_nl_cmd_ops *l2tp_nl_cmd_ops[__L2TP_PWTYPE_MAX]; | 49 | static const struct l2tp_nl_cmd_ops *l2tp_nl_cmd_ops[__L2TP_PWTYPE_MAX]; |
50 | 50 | ||
51 | static struct l2tp_session *l2tp_nl_session_find(struct genl_info *info) | 51 | static struct l2tp_session *l2tp_nl_session_get(struct genl_info *info, |
52 | bool do_ref) | ||
52 | { | 53 | { |
53 | u32 tunnel_id; | 54 | u32 tunnel_id; |
54 | u32 session_id; | 55 | u32 session_id; |
@@ -59,14 +60,15 @@ static struct l2tp_session *l2tp_nl_session_find(struct genl_info *info) | |||
59 | 60 | ||
60 | if (info->attrs[L2TP_ATTR_IFNAME]) { | 61 | if (info->attrs[L2TP_ATTR_IFNAME]) { |
61 | ifname = nla_data(info->attrs[L2TP_ATTR_IFNAME]); | 62 | ifname = nla_data(info->attrs[L2TP_ATTR_IFNAME]); |
62 | session = l2tp_session_find_by_ifname(net, ifname); | 63 | session = l2tp_session_get_by_ifname(net, ifname, do_ref); |
63 | } else if ((info->attrs[L2TP_ATTR_SESSION_ID]) && | 64 | } else if ((info->attrs[L2TP_ATTR_SESSION_ID]) && |
64 | (info->attrs[L2TP_ATTR_CONN_ID])) { | 65 | (info->attrs[L2TP_ATTR_CONN_ID])) { |
65 | tunnel_id = nla_get_u32(info->attrs[L2TP_ATTR_CONN_ID]); | 66 | tunnel_id = nla_get_u32(info->attrs[L2TP_ATTR_CONN_ID]); |
66 | session_id = nla_get_u32(info->attrs[L2TP_ATTR_SESSION_ID]); | 67 | session_id = nla_get_u32(info->attrs[L2TP_ATTR_SESSION_ID]); |
67 | tunnel = l2tp_tunnel_find(net, tunnel_id); | 68 | tunnel = l2tp_tunnel_find(net, tunnel_id); |
68 | if (tunnel) | 69 | if (tunnel) |
69 | session = l2tp_session_find(net, tunnel, session_id); | 70 | session = l2tp_session_get(net, tunnel, session_id, |
71 | do_ref); | ||
70 | } | 72 | } |
71 | 73 | ||
72 | return session; | 74 | return session; |
@@ -642,10 +644,12 @@ static int l2tp_nl_cmd_session_create(struct sk_buff *skb, struct genl_info *inf | |||
642 | session_id, peer_session_id, &cfg); | 644 | session_id, peer_session_id, &cfg); |
643 | 645 | ||
644 | if (ret >= 0) { | 646 | if (ret >= 0) { |
645 | session = l2tp_session_find(net, tunnel, session_id); | 647 | session = l2tp_session_get(net, tunnel, session_id, false); |
646 | if (session) | 648 | if (session) { |
647 | ret = l2tp_session_notify(&l2tp_nl_family, info, session, | 649 | ret = l2tp_session_notify(&l2tp_nl_family, info, session, |
648 | L2TP_CMD_SESSION_CREATE); | 650 | L2TP_CMD_SESSION_CREATE); |
651 | l2tp_session_dec_refcount(session); | ||
652 | } | ||
649 | } | 653 | } |
650 | 654 | ||
651 | out: | 655 | out: |
@@ -658,7 +662,7 @@ static int l2tp_nl_cmd_session_delete(struct sk_buff *skb, struct genl_info *inf | |||
658 | struct l2tp_session *session; | 662 | struct l2tp_session *session; |
659 | u16 pw_type; | 663 | u16 pw_type; |
660 | 664 | ||
661 | session = l2tp_nl_session_find(info); | 665 | session = l2tp_nl_session_get(info, true); |
662 | if (session == NULL) { | 666 | if (session == NULL) { |
663 | ret = -ENODEV; | 667 | ret = -ENODEV; |
664 | goto out; | 668 | goto out; |
@@ -672,6 +676,10 @@ static int l2tp_nl_cmd_session_delete(struct sk_buff *skb, struct genl_info *inf | |||
672 | if (l2tp_nl_cmd_ops[pw_type] && l2tp_nl_cmd_ops[pw_type]->session_delete) | 676 | if (l2tp_nl_cmd_ops[pw_type] && l2tp_nl_cmd_ops[pw_type]->session_delete) |
673 | ret = (*l2tp_nl_cmd_ops[pw_type]->session_delete)(session); | 677 | ret = (*l2tp_nl_cmd_ops[pw_type]->session_delete)(session); |
674 | 678 | ||
679 | if (session->deref) | ||
680 | session->deref(session); | ||
681 | l2tp_session_dec_refcount(session); | ||
682 | |||
675 | out: | 683 | out: |
676 | return ret; | 684 | return ret; |
677 | } | 685 | } |
@@ -681,7 +689,7 @@ static int l2tp_nl_cmd_session_modify(struct sk_buff *skb, struct genl_info *inf | |||
681 | int ret = 0; | 689 | int ret = 0; |
682 | struct l2tp_session *session; | 690 | struct l2tp_session *session; |
683 | 691 | ||
684 | session = l2tp_nl_session_find(info); | 692 | session = l2tp_nl_session_get(info, false); |
685 | if (session == NULL) { | 693 | if (session == NULL) { |
686 | ret = -ENODEV; | 694 | ret = -ENODEV; |
687 | goto out; | 695 | goto out; |
@@ -716,6 +724,8 @@ static int l2tp_nl_cmd_session_modify(struct sk_buff *skb, struct genl_info *inf | |||
716 | ret = l2tp_session_notify(&l2tp_nl_family, info, | 724 | ret = l2tp_session_notify(&l2tp_nl_family, info, |
717 | session, L2TP_CMD_SESSION_MODIFY); | 725 | session, L2TP_CMD_SESSION_MODIFY); |
718 | 726 | ||
727 | l2tp_session_dec_refcount(session); | ||
728 | |||
719 | out: | 729 | out: |
720 | return ret; | 730 | return ret; |
721 | } | 731 | } |
@@ -811,29 +821,34 @@ static int l2tp_nl_cmd_session_get(struct sk_buff *skb, struct genl_info *info) | |||
811 | struct sk_buff *msg; | 821 | struct sk_buff *msg; |
812 | int ret; | 822 | int ret; |
813 | 823 | ||
814 | session = l2tp_nl_session_find(info); | 824 | session = l2tp_nl_session_get(info, false); |
815 | if (session == NULL) { | 825 | if (session == NULL) { |
816 | ret = -ENODEV; | 826 | ret = -ENODEV; |
817 | goto out; | 827 | goto err; |
818 | } | 828 | } |
819 | 829 | ||
820 | msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); | 830 | msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); |
821 | if (!msg) { | 831 | if (!msg) { |
822 | ret = -ENOMEM; | 832 | ret = -ENOMEM; |
823 | goto out; | 833 | goto err_ref; |
824 | } | 834 | } |
825 | 835 | ||
826 | ret = l2tp_nl_session_send(msg, info->snd_portid, info->snd_seq, | 836 | ret = l2tp_nl_session_send(msg, info->snd_portid, info->snd_seq, |
827 | 0, session, L2TP_CMD_SESSION_GET); | 837 | 0, session, L2TP_CMD_SESSION_GET); |
828 | if (ret < 0) | 838 | if (ret < 0) |
829 | goto err_out; | 839 | goto err_ref_msg; |
830 | 840 | ||
831 | return genlmsg_unicast(genl_info_net(info), msg, info->snd_portid); | 841 | ret = genlmsg_unicast(genl_info_net(info), msg, info->snd_portid); |
832 | 842 | ||
833 | err_out: | 843 | l2tp_session_dec_refcount(session); |
834 | nlmsg_free(msg); | ||
835 | 844 | ||
836 | out: | 845 | return ret; |
846 | |||
847 | err_ref_msg: | ||
848 | nlmsg_free(msg); | ||
849 | err_ref: | ||
850 | l2tp_session_dec_refcount(session); | ||
851 | err: | ||
837 | return ret; | 852 | return ret; |
838 | } | 853 | } |
839 | 854 | ||
@@ -852,7 +867,7 @@ static int l2tp_nl_cmd_session_dump(struct sk_buff *skb, struct netlink_callback | |||
852 | goto out; | 867 | goto out; |
853 | } | 868 | } |
854 | 869 | ||
855 | session = l2tp_session_find_nth(tunnel, si); | 870 | session = l2tp_session_get_nth(tunnel, si, false); |
856 | if (session == NULL) { | 871 | if (session == NULL) { |
857 | ti++; | 872 | ti++; |
858 | tunnel = NULL; | 873 | tunnel = NULL; |
@@ -862,8 +877,11 @@ static int l2tp_nl_cmd_session_dump(struct sk_buff *skb, struct netlink_callback | |||
862 | 877 | ||
863 | if (l2tp_nl_session_send(skb, NETLINK_CB(cb->skb).portid, | 878 | if (l2tp_nl_session_send(skb, NETLINK_CB(cb->skb).portid, |
864 | cb->nlh->nlmsg_seq, NLM_F_MULTI, | 879 | cb->nlh->nlmsg_seq, NLM_F_MULTI, |
865 | session, L2TP_CMD_SESSION_GET) < 0) | 880 | session, L2TP_CMD_SESSION_GET) < 0) { |
881 | l2tp_session_dec_refcount(session); | ||
866 | break; | 882 | break; |
883 | } | ||
884 | l2tp_session_dec_refcount(session); | ||
867 | 885 | ||
868 | si++; | 886 | si++; |
869 | } | 887 | } |
diff --git a/net/l2tp/l2tp_ppp.c b/net/l2tp/l2tp_ppp.c index 36cc56fd0418..32ea0f3d868c 100644 --- a/net/l2tp/l2tp_ppp.c +++ b/net/l2tp/l2tp_ppp.c | |||
@@ -450,6 +450,10 @@ static void pppol2tp_session_close(struct l2tp_session *session) | |||
450 | static void pppol2tp_session_destruct(struct sock *sk) | 450 | static void pppol2tp_session_destruct(struct sock *sk) |
451 | { | 451 | { |
452 | struct l2tp_session *session = sk->sk_user_data; | 452 | struct l2tp_session *session = sk->sk_user_data; |
453 | |||
454 | skb_queue_purge(&sk->sk_receive_queue); | ||
455 | skb_queue_purge(&sk->sk_write_queue); | ||
456 | |||
453 | if (session) { | 457 | if (session) { |
454 | sk->sk_user_data = NULL; | 458 | sk->sk_user_data = NULL; |
455 | BUG_ON(session->magic != L2TP_SESSION_MAGIC); | 459 | BUG_ON(session->magic != L2TP_SESSION_MAGIC); |
@@ -488,9 +492,6 @@ static int pppol2tp_release(struct socket *sock) | |||
488 | l2tp_session_queue_purge(session); | 492 | l2tp_session_queue_purge(session); |
489 | sock_put(sk); | 493 | sock_put(sk); |
490 | } | 494 | } |
491 | skb_queue_purge(&sk->sk_receive_queue); | ||
492 | skb_queue_purge(&sk->sk_write_queue); | ||
493 | |||
494 | release_sock(sk); | 495 | release_sock(sk); |
495 | 496 | ||
496 | /* This will delete the session context via | 497 | /* This will delete the session context via |
@@ -582,6 +583,7 @@ static int pppol2tp_connect(struct socket *sock, struct sockaddr *uservaddr, | |||
582 | int error = 0; | 583 | int error = 0; |
583 | u32 tunnel_id, peer_tunnel_id; | 584 | u32 tunnel_id, peer_tunnel_id; |
584 | u32 session_id, peer_session_id; | 585 | u32 session_id, peer_session_id; |
586 | bool drop_refcnt = false; | ||
585 | int ver = 2; | 587 | int ver = 2; |
586 | int fd; | 588 | int fd; |
587 | 589 | ||
@@ -683,36 +685,36 @@ static int pppol2tp_connect(struct socket *sock, struct sockaddr *uservaddr, | |||
683 | if (tunnel->peer_tunnel_id == 0) | 685 | if (tunnel->peer_tunnel_id == 0) |
684 | tunnel->peer_tunnel_id = peer_tunnel_id; | 686 | tunnel->peer_tunnel_id = peer_tunnel_id; |
685 | 687 | ||
686 | /* Create session if it doesn't already exist. We handle the | 688 | session = l2tp_session_get(sock_net(sk), tunnel, session_id, false); |
687 | * case where a session was previously created by the netlink | 689 | if (session) { |
688 | * interface by checking that the session doesn't already have | 690 | drop_refcnt = true; |
689 | * a socket and its tunnel socket are what we expect. If any | 691 | ps = l2tp_session_priv(session); |
690 | * of those checks fail, return EEXIST to the caller. | 692 | |
691 | */ | 693 | /* Using a pre-existing session is fine as long as it hasn't |
692 | session = l2tp_session_find(sock_net(sk), tunnel, session_id); | 694 | * been connected yet. |
693 | if (session == NULL) { | ||
694 | /* Default MTU must allow space for UDP/L2TP/PPP | ||
695 | * headers. | ||
696 | */ | 695 | */ |
697 | cfg.mtu = cfg.mru = 1500 - PPPOL2TP_HEADER_OVERHEAD; | 696 | if (ps->sock) { |
697 | error = -EEXIST; | ||
698 | goto end; | ||
699 | } | ||
698 | 700 | ||
699 | /* Allocate and initialize a new session context. */ | 701 | /* consistency checks */ |
700 | session = l2tp_session_create(sizeof(struct pppol2tp_session), | 702 | if (ps->tunnel_sock != tunnel->sock) { |
701 | tunnel, session_id, | 703 | error = -EEXIST; |
702 | peer_session_id, &cfg); | ||
703 | if (session == NULL) { | ||
704 | error = -ENOMEM; | ||
705 | goto end; | 704 | goto end; |
706 | } | 705 | } |
707 | } else { | 706 | } else { |
708 | ps = l2tp_session_priv(session); | 707 | /* Default MTU must allow space for UDP/L2TP/PPP headers */ |
709 | error = -EEXIST; | 708 | cfg.mtu = 1500 - PPPOL2TP_HEADER_OVERHEAD; |
710 | if (ps->sock != NULL) | 709 | cfg.mru = cfg.mtu; |
711 | goto end; | ||
712 | 710 | ||
713 | /* consistency checks */ | 711 | session = l2tp_session_create(sizeof(struct pppol2tp_session), |
714 | if (ps->tunnel_sock != tunnel->sock) | 712 | tunnel, session_id, |
713 | peer_session_id, &cfg); | ||
714 | if (IS_ERR(session)) { | ||
715 | error = PTR_ERR(session); | ||
715 | goto end; | 716 | goto end; |
717 | } | ||
716 | } | 718 | } |
717 | 719 | ||
718 | /* Associate session with its PPPoL2TP socket */ | 720 | /* Associate session with its PPPoL2TP socket */ |
@@ -777,6 +779,8 @@ out_no_ppp: | |||
777 | session->name); | 779 | session->name); |
778 | 780 | ||
779 | end: | 781 | end: |
782 | if (drop_refcnt) | ||
783 | l2tp_session_dec_refcount(session); | ||
780 | release_sock(sk); | 784 | release_sock(sk); |
781 | 785 | ||
782 | return error; | 786 | return error; |
@@ -804,12 +808,6 @@ static int pppol2tp_session_create(struct net *net, u32 tunnel_id, u32 session_i | |||
804 | if (tunnel->sock == NULL) | 808 | if (tunnel->sock == NULL) |
805 | goto out; | 809 | goto out; |
806 | 810 | ||
807 | /* Check that this session doesn't already exist */ | ||
808 | error = -EEXIST; | ||
809 | session = l2tp_session_find(net, tunnel, session_id); | ||
810 | if (session != NULL) | ||
811 | goto out; | ||
812 | |||
813 | /* Default MTU values. */ | 811 | /* Default MTU values. */ |
814 | if (cfg->mtu == 0) | 812 | if (cfg->mtu == 0) |
815 | cfg->mtu = 1500 - PPPOL2TP_HEADER_OVERHEAD; | 813 | cfg->mtu = 1500 - PPPOL2TP_HEADER_OVERHEAD; |
@@ -817,12 +815,13 @@ static int pppol2tp_session_create(struct net *net, u32 tunnel_id, u32 session_i | |||
817 | cfg->mru = cfg->mtu; | 815 | cfg->mru = cfg->mtu; |
818 | 816 | ||
819 | /* Allocate and initialize a new session context. */ | 817 | /* Allocate and initialize a new session context. */ |
820 | error = -ENOMEM; | ||
821 | session = l2tp_session_create(sizeof(struct pppol2tp_session), | 818 | session = l2tp_session_create(sizeof(struct pppol2tp_session), |
822 | tunnel, session_id, | 819 | tunnel, session_id, |
823 | peer_session_id, cfg); | 820 | peer_session_id, cfg); |
824 | if (session == NULL) | 821 | if (IS_ERR(session)) { |
822 | error = PTR_ERR(session); | ||
825 | goto out; | 823 | goto out; |
824 | } | ||
826 | 825 | ||
827 | ps = l2tp_session_priv(session); | 826 | ps = l2tp_session_priv(session); |
828 | ps->tunnel_sock = tunnel->sock; | 827 | ps->tunnel_sock = tunnel->sock; |
@@ -1140,11 +1139,18 @@ static int pppol2tp_tunnel_ioctl(struct l2tp_tunnel *tunnel, | |||
1140 | if (stats.session_id != 0) { | 1139 | if (stats.session_id != 0) { |
1141 | /* resend to session ioctl handler */ | 1140 | /* resend to session ioctl handler */ |
1142 | struct l2tp_session *session = | 1141 | struct l2tp_session *session = |
1143 | l2tp_session_find(sock_net(sk), tunnel, stats.session_id); | 1142 | l2tp_session_get(sock_net(sk), tunnel, |
1144 | if (session != NULL) | 1143 | stats.session_id, true); |
1145 | err = pppol2tp_session_ioctl(session, cmd, arg); | 1144 | |
1146 | else | 1145 | if (session) { |
1146 | err = pppol2tp_session_ioctl(session, cmd, | ||
1147 | arg); | ||
1148 | if (session->deref) | ||
1149 | session->deref(session); | ||
1150 | l2tp_session_dec_refcount(session); | ||
1151 | } else { | ||
1147 | err = -EBADR; | 1152 | err = -EBADR; |
1153 | } | ||
1148 | break; | 1154 | break; |
1149 | } | 1155 | } |
1150 | #ifdef CONFIG_XFRM | 1156 | #ifdef CONFIG_XFRM |
@@ -1377,8 +1383,6 @@ static int pppol2tp_setsockopt(struct socket *sock, int level, int optname, | |||
1377 | } else | 1383 | } else |
1378 | err = pppol2tp_session_setsockopt(sk, session, optname, val); | 1384 | err = pppol2tp_session_setsockopt(sk, session, optname, val); |
1379 | 1385 | ||
1380 | err = 0; | ||
1381 | |||
1382 | end_put_sess: | 1386 | end_put_sess: |
1383 | sock_put(sk); | 1387 | sock_put(sk); |
1384 | end: | 1388 | end: |
@@ -1501,8 +1505,13 @@ static int pppol2tp_getsockopt(struct socket *sock, int level, int optname, | |||
1501 | 1505 | ||
1502 | err = pppol2tp_tunnel_getsockopt(sk, tunnel, optname, &val); | 1506 | err = pppol2tp_tunnel_getsockopt(sk, tunnel, optname, &val); |
1503 | sock_put(ps->tunnel_sock); | 1507 | sock_put(ps->tunnel_sock); |
1504 | } else | 1508 | if (err) |
1509 | goto end_put_sess; | ||
1510 | } else { | ||
1505 | err = pppol2tp_session_getsockopt(sk, session, optname, &val); | 1511 | err = pppol2tp_session_getsockopt(sk, session, optname, &val); |
1512 | if (err) | ||
1513 | goto end_put_sess; | ||
1514 | } | ||
1506 | 1515 | ||
1507 | err = -EFAULT; | 1516 | err = -EFAULT; |
1508 | if (put_user(len, optlen)) | 1517 | if (put_user(len, optlen)) |
@@ -1554,7 +1563,7 @@ static void pppol2tp_next_tunnel(struct net *net, struct pppol2tp_seq_data *pd) | |||
1554 | 1563 | ||
1555 | static void pppol2tp_next_session(struct net *net, struct pppol2tp_seq_data *pd) | 1564 | static void pppol2tp_next_session(struct net *net, struct pppol2tp_seq_data *pd) |
1556 | { | 1565 | { |
1557 | pd->session = l2tp_session_find_nth(pd->tunnel, pd->session_idx); | 1566 | pd->session = l2tp_session_get_nth(pd->tunnel, pd->session_idx, true); |
1558 | pd->session_idx++; | 1567 | pd->session_idx++; |
1559 | 1568 | ||
1560 | if (pd->session == NULL) { | 1569 | if (pd->session == NULL) { |
@@ -1681,10 +1690,14 @@ static int pppol2tp_seq_show(struct seq_file *m, void *v) | |||
1681 | 1690 | ||
1682 | /* Show the tunnel or session context. | 1691 | /* Show the tunnel or session context. |
1683 | */ | 1692 | */ |
1684 | if (pd->session == NULL) | 1693 | if (!pd->session) { |
1685 | pppol2tp_seq_tunnel_show(m, pd->tunnel); | 1694 | pppol2tp_seq_tunnel_show(m, pd->tunnel); |
1686 | else | 1695 | } else { |
1687 | pppol2tp_seq_session_show(m, pd->session); | 1696 | pppol2tp_seq_session_show(m, pd->session); |
1697 | if (pd->session->deref) | ||
1698 | pd->session->deref(pd->session); | ||
1699 | l2tp_session_dec_refcount(pd->session); | ||
1700 | } | ||
1688 | 1701 | ||
1689 | out: | 1702 | out: |
1690 | return 0; | 1703 | return 0; |
@@ -1843,4 +1856,4 @@ MODULE_DESCRIPTION("PPP over L2TP over UDP"); | |||
1843 | MODULE_LICENSE("GPL"); | 1856 | MODULE_LICENSE("GPL"); |
1844 | MODULE_VERSION(PPPOL2TP_DRV_VERSION); | 1857 | MODULE_VERSION(PPPOL2TP_DRV_VERSION); |
1845 | MODULE_ALIAS_NET_PF_PROTO(PF_PPPOX, PX_PROTO_OL2TP); | 1858 | MODULE_ALIAS_NET_PF_PROTO(PF_PPPOX, PX_PROTO_OL2TP); |
1846 | MODULE_ALIAS_L2TP_PWTYPE(11); | 1859 | MODULE_ALIAS_L2TP_PWTYPE(7); |
diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c index 40813dd3301c..5bb0c5012819 100644 --- a/net/mac80211/iface.c +++ b/net/mac80211/iface.c | |||
@@ -718,7 +718,8 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up) | |||
718 | ieee80211_recalc_ps(local); | 718 | ieee80211_recalc_ps(local); |
719 | 719 | ||
720 | if (sdata->vif.type == NL80211_IFTYPE_MONITOR || | 720 | if (sdata->vif.type == NL80211_IFTYPE_MONITOR || |
721 | sdata->vif.type == NL80211_IFTYPE_AP_VLAN) { | 721 | sdata->vif.type == NL80211_IFTYPE_AP_VLAN || |
722 | local->ops->wake_tx_queue) { | ||
722 | /* XXX: for AP_VLAN, actually track AP queues */ | 723 | /* XXX: for AP_VLAN, actually track AP queues */ |
723 | netif_tx_start_all_queues(dev); | 724 | netif_tx_start_all_queues(dev); |
724 | } else if (dev) { | 725 | } else if (dev) { |
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c index e48724a6725e..4d7543d1a62c 100644 --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c | |||
@@ -208,6 +208,51 @@ ieee80211_rx_radiotap_hdrlen(struct ieee80211_local *local, | |||
208 | return len; | 208 | return len; |
209 | } | 209 | } |
210 | 210 | ||
211 | static void ieee80211_handle_mu_mimo_mon(struct ieee80211_sub_if_data *sdata, | ||
212 | struct sk_buff *skb, | ||
213 | int rtap_vendor_space) | ||
214 | { | ||
215 | struct { | ||
216 | struct ieee80211_hdr_3addr hdr; | ||
217 | u8 category; | ||
218 | u8 action_code; | ||
219 | } __packed action; | ||
220 | |||
221 | if (!sdata) | ||
222 | return; | ||
223 | |||
224 | BUILD_BUG_ON(sizeof(action) != IEEE80211_MIN_ACTION_SIZE + 1); | ||
225 | |||
226 | if (skb->len < rtap_vendor_space + sizeof(action) + | ||
227 | VHT_MUMIMO_GROUPS_DATA_LEN) | ||
228 | return; | ||
229 | |||
230 | if (!is_valid_ether_addr(sdata->u.mntr.mu_follow_addr)) | ||
231 | return; | ||
232 | |||
233 | skb_copy_bits(skb, rtap_vendor_space, &action, sizeof(action)); | ||
234 | |||
235 | if (!ieee80211_is_action(action.hdr.frame_control)) | ||
236 | return; | ||
237 | |||
238 | if (action.category != WLAN_CATEGORY_VHT) | ||
239 | return; | ||
240 | |||
241 | if (action.action_code != WLAN_VHT_ACTION_GROUPID_MGMT) | ||
242 | return; | ||
243 | |||
244 | if (!ether_addr_equal(action.hdr.addr1, sdata->u.mntr.mu_follow_addr)) | ||
245 | return; | ||
246 | |||
247 | skb = skb_copy(skb, GFP_ATOMIC); | ||
248 | if (!skb) | ||
249 | return; | ||
250 | |||
251 | skb->pkt_type = IEEE80211_SDATA_QUEUE_TYPE_FRAME; | ||
252 | skb_queue_tail(&sdata->skb_queue, skb); | ||
253 | ieee80211_queue_work(&sdata->local->hw, &sdata->work); | ||
254 | } | ||
255 | |||
211 | /* | 256 | /* |
212 | * ieee80211_add_rx_radiotap_header - add radiotap header | 257 | * ieee80211_add_rx_radiotap_header - add radiotap header |
213 | * | 258 | * |
@@ -515,7 +560,6 @@ ieee80211_rx_monitor(struct ieee80211_local *local, struct sk_buff *origskb, | |||
515 | struct net_device *prev_dev = NULL; | 560 | struct net_device *prev_dev = NULL; |
516 | int present_fcs_len = 0; | 561 | int present_fcs_len = 0; |
517 | unsigned int rtap_vendor_space = 0; | 562 | unsigned int rtap_vendor_space = 0; |
518 | struct ieee80211_mgmt *mgmt; | ||
519 | struct ieee80211_sub_if_data *monitor_sdata = | 563 | struct ieee80211_sub_if_data *monitor_sdata = |
520 | rcu_dereference(local->monitor_sdata); | 564 | rcu_dereference(local->monitor_sdata); |
521 | 565 | ||
@@ -553,6 +597,8 @@ ieee80211_rx_monitor(struct ieee80211_local *local, struct sk_buff *origskb, | |||
553 | return remove_monitor_info(local, origskb, rtap_vendor_space); | 597 | return remove_monitor_info(local, origskb, rtap_vendor_space); |
554 | } | 598 | } |
555 | 599 | ||
600 | ieee80211_handle_mu_mimo_mon(monitor_sdata, origskb, rtap_vendor_space); | ||
601 | |||
556 | /* room for the radiotap header based on driver features */ | 602 | /* room for the radiotap header based on driver features */ |
557 | rt_hdrlen = ieee80211_rx_radiotap_hdrlen(local, status, origskb); | 603 | rt_hdrlen = ieee80211_rx_radiotap_hdrlen(local, status, origskb); |
558 | needed_headroom = rt_hdrlen - rtap_vendor_space; | 604 | needed_headroom = rt_hdrlen - rtap_vendor_space; |
@@ -618,23 +664,6 @@ ieee80211_rx_monitor(struct ieee80211_local *local, struct sk_buff *origskb, | |||
618 | ieee80211_rx_stats(sdata->dev, skb->len); | 664 | ieee80211_rx_stats(sdata->dev, skb->len); |
619 | } | 665 | } |
620 | 666 | ||
621 | mgmt = (void *)skb->data; | ||
622 | if (monitor_sdata && | ||
623 | skb->len >= IEEE80211_MIN_ACTION_SIZE + 1 + VHT_MUMIMO_GROUPS_DATA_LEN && | ||
624 | ieee80211_is_action(mgmt->frame_control) && | ||
625 | mgmt->u.action.category == WLAN_CATEGORY_VHT && | ||
626 | mgmt->u.action.u.vht_group_notif.action_code == WLAN_VHT_ACTION_GROUPID_MGMT && | ||
627 | is_valid_ether_addr(monitor_sdata->u.mntr.mu_follow_addr) && | ||
628 | ether_addr_equal(mgmt->da, monitor_sdata->u.mntr.mu_follow_addr)) { | ||
629 | struct sk_buff *mu_skb = skb_copy(skb, GFP_ATOMIC); | ||
630 | |||
631 | if (mu_skb) { | ||
632 | mu_skb->pkt_type = IEEE80211_SDATA_QUEUE_TYPE_FRAME; | ||
633 | skb_queue_tail(&monitor_sdata->skb_queue, mu_skb); | ||
634 | ieee80211_queue_work(&local->hw, &monitor_sdata->work); | ||
635 | } | ||
636 | } | ||
637 | |||
638 | if (prev_dev) { | 667 | if (prev_dev) { |
639 | skb->dev = prev_dev; | 668 | skb->dev = prev_dev; |
640 | netif_receive_skb(skb); | 669 | netif_receive_skb(skb); |
@@ -3610,6 +3639,27 @@ static bool ieee80211_accept_frame(struct ieee80211_rx_data *rx) | |||
3610 | !ether_addr_equal(bssid, hdr->addr1)) | 3639 | !ether_addr_equal(bssid, hdr->addr1)) |
3611 | return false; | 3640 | return false; |
3612 | } | 3641 | } |
3642 | |||
3643 | /* | ||
3644 | * 802.11-2016 Table 9-26 says that for data frames, A1 must be | ||
3645 | * the BSSID - we've checked that already but may have accepted | ||
3646 | * the wildcard (ff:ff:ff:ff:ff:ff). | ||
3647 | * | ||
3648 | * It also says: | ||
3649 | * The BSSID of the Data frame is determined as follows: | ||
3650 | * a) If the STA is contained within an AP or is associated | ||
3651 | * with an AP, the BSSID is the address currently in use | ||
3652 | * by the STA contained in the AP. | ||
3653 | * | ||
3654 | * So we should not accept data frames with an address that's | ||
3655 | * multicast. | ||
3656 | * | ||
3657 | * Accepting it also opens a security problem because stations | ||
3658 | * could encrypt it with the GTK and inject traffic that way. | ||
3659 | */ | ||
3660 | if (ieee80211_is_data(hdr->frame_control) && multicast) | ||
3661 | return false; | ||
3662 | |||
3613 | return true; | 3663 | return true; |
3614 | case NL80211_IFTYPE_WDS: | 3664 | case NL80211_IFTYPE_WDS: |
3615 | if (bssid || !ieee80211_is_data(hdr->frame_control)) | 3665 | if (bssid || !ieee80211_is_data(hdr->frame_control)) |
diff --git a/net/netfilter/nf_conntrack_ecache.c b/net/netfilter/nf_conntrack_ecache.c index da9df2d56e66..22fc32143e9c 100644 --- a/net/netfilter/nf_conntrack_ecache.c +++ b/net/netfilter/nf_conntrack_ecache.c | |||
@@ -290,6 +290,7 @@ void nf_conntrack_unregister_notifier(struct net *net, | |||
290 | BUG_ON(notify != new); | 290 | BUG_ON(notify != new); |
291 | RCU_INIT_POINTER(net->ct.nf_conntrack_event_cb, NULL); | 291 | RCU_INIT_POINTER(net->ct.nf_conntrack_event_cb, NULL); |
292 | mutex_unlock(&nf_ct_ecache_mutex); | 292 | mutex_unlock(&nf_ct_ecache_mutex); |
293 | /* synchronize_rcu() is called from ctnetlink_exit. */ | ||
293 | } | 294 | } |
294 | EXPORT_SYMBOL_GPL(nf_conntrack_unregister_notifier); | 295 | EXPORT_SYMBOL_GPL(nf_conntrack_unregister_notifier); |
295 | 296 | ||
@@ -326,6 +327,7 @@ void nf_ct_expect_unregister_notifier(struct net *net, | |||
326 | BUG_ON(notify != new); | 327 | BUG_ON(notify != new); |
327 | RCU_INIT_POINTER(net->ct.nf_expect_event_cb, NULL); | 328 | RCU_INIT_POINTER(net->ct.nf_expect_event_cb, NULL); |
328 | mutex_unlock(&nf_ct_ecache_mutex); | 329 | mutex_unlock(&nf_ct_ecache_mutex); |
330 | /* synchronize_rcu() is called from ctnetlink_exit. */ | ||
329 | } | 331 | } |
330 | EXPORT_SYMBOL_GPL(nf_ct_expect_unregister_notifier); | 332 | EXPORT_SYMBOL_GPL(nf_ct_expect_unregister_notifier); |
331 | 333 | ||
diff --git a/net/netfilter/nf_conntrack_expect.c b/net/netfilter/nf_conntrack_expect.c index 4b2e1fb28bb4..d80073037856 100644 --- a/net/netfilter/nf_conntrack_expect.c +++ b/net/netfilter/nf_conntrack_expect.c | |||
@@ -57,7 +57,7 @@ void nf_ct_unlink_expect_report(struct nf_conntrack_expect *exp, | |||
57 | hlist_del_rcu(&exp->hnode); | 57 | hlist_del_rcu(&exp->hnode); |
58 | net->ct.expect_count--; | 58 | net->ct.expect_count--; |
59 | 59 | ||
60 | hlist_del(&exp->lnode); | 60 | hlist_del_rcu(&exp->lnode); |
61 | master_help->expecting[exp->class]--; | 61 | master_help->expecting[exp->class]--; |
62 | 62 | ||
63 | nf_ct_expect_event_report(IPEXP_DESTROY, exp, portid, report); | 63 | nf_ct_expect_event_report(IPEXP_DESTROY, exp, portid, report); |
@@ -363,7 +363,7 @@ static void nf_ct_expect_insert(struct nf_conntrack_expect *exp) | |||
363 | /* two references : one for hash insert, one for the timer */ | 363 | /* two references : one for hash insert, one for the timer */ |
364 | atomic_add(2, &exp->use); | 364 | atomic_add(2, &exp->use); |
365 | 365 | ||
366 | hlist_add_head(&exp->lnode, &master_help->expectations); | 366 | hlist_add_head_rcu(&exp->lnode, &master_help->expectations); |
367 | master_help->expecting[exp->class]++; | 367 | master_help->expecting[exp->class]++; |
368 | 368 | ||
369 | hlist_add_head_rcu(&exp->hnode, &nf_ct_expect_hash[h]); | 369 | hlist_add_head_rcu(&exp->hnode, &nf_ct_expect_hash[h]); |
diff --git a/net/netfilter/nf_conntrack_extend.c b/net/netfilter/nf_conntrack_extend.c index 02bcf00c2492..008299b7f78f 100644 --- a/net/netfilter/nf_conntrack_extend.c +++ b/net/netfilter/nf_conntrack_extend.c | |||
@@ -53,7 +53,11 @@ nf_ct_ext_create(struct nf_ct_ext **ext, enum nf_ct_ext_id id, | |||
53 | 53 | ||
54 | rcu_read_lock(); | 54 | rcu_read_lock(); |
55 | t = rcu_dereference(nf_ct_ext_types[id]); | 55 | t = rcu_dereference(nf_ct_ext_types[id]); |
56 | BUG_ON(t == NULL); | 56 | if (!t) { |
57 | rcu_read_unlock(); | ||
58 | return NULL; | ||
59 | } | ||
60 | |||
57 | off = ALIGN(sizeof(struct nf_ct_ext), t->align); | 61 | off = ALIGN(sizeof(struct nf_ct_ext), t->align); |
58 | len = off + t->len + var_alloc_len; | 62 | len = off + t->len + var_alloc_len; |
59 | alloc_size = t->alloc_size + var_alloc_len; | 63 | alloc_size = t->alloc_size + var_alloc_len; |
@@ -88,7 +92,10 @@ void *__nf_ct_ext_add_length(struct nf_conn *ct, enum nf_ct_ext_id id, | |||
88 | 92 | ||
89 | rcu_read_lock(); | 93 | rcu_read_lock(); |
90 | t = rcu_dereference(nf_ct_ext_types[id]); | 94 | t = rcu_dereference(nf_ct_ext_types[id]); |
91 | BUG_ON(t == NULL); | 95 | if (!t) { |
96 | rcu_read_unlock(); | ||
97 | return NULL; | ||
98 | } | ||
92 | 99 | ||
93 | newoff = ALIGN(old->len, t->align); | 100 | newoff = ALIGN(old->len, t->align); |
94 | newlen = newoff + t->len + var_alloc_len; | 101 | newlen = newoff + t->len + var_alloc_len; |
@@ -175,6 +182,6 @@ void nf_ct_extend_unregister(struct nf_ct_ext_type *type) | |||
175 | RCU_INIT_POINTER(nf_ct_ext_types[type->id], NULL); | 182 | RCU_INIT_POINTER(nf_ct_ext_types[type->id], NULL); |
176 | update_alloc_size(type); | 183 | update_alloc_size(type); |
177 | mutex_unlock(&nf_ct_ext_type_mutex); | 184 | mutex_unlock(&nf_ct_ext_type_mutex); |
178 | rcu_barrier(); /* Wait for completion of call_rcu()'s */ | 185 | synchronize_rcu(); |
179 | } | 186 | } |
180 | EXPORT_SYMBOL_GPL(nf_ct_extend_unregister); | 187 | EXPORT_SYMBOL_GPL(nf_ct_extend_unregister); |
diff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c index 6dc44d9b4190..4eeb3418366a 100644 --- a/net/netfilter/nf_conntrack_helper.c +++ b/net/netfilter/nf_conntrack_helper.c | |||
@@ -158,16 +158,25 @@ nf_conntrack_helper_try_module_get(const char *name, u16 l3num, u8 protonum) | |||
158 | { | 158 | { |
159 | struct nf_conntrack_helper *h; | 159 | struct nf_conntrack_helper *h; |
160 | 160 | ||
161 | rcu_read_lock(); | ||
162 | |||
161 | h = __nf_conntrack_helper_find(name, l3num, protonum); | 163 | h = __nf_conntrack_helper_find(name, l3num, protonum); |
162 | #ifdef CONFIG_MODULES | 164 | #ifdef CONFIG_MODULES |
163 | if (h == NULL) { | 165 | if (h == NULL) { |
164 | if (request_module("nfct-helper-%s", name) == 0) | 166 | rcu_read_unlock(); |
167 | if (request_module("nfct-helper-%s", name) == 0) { | ||
168 | rcu_read_lock(); | ||
165 | h = __nf_conntrack_helper_find(name, l3num, protonum); | 169 | h = __nf_conntrack_helper_find(name, l3num, protonum); |
170 | } else { | ||
171 | return h; | ||
172 | } | ||
166 | } | 173 | } |
167 | #endif | 174 | #endif |
168 | if (h != NULL && !try_module_get(h->me)) | 175 | if (h != NULL && !try_module_get(h->me)) |
169 | h = NULL; | 176 | h = NULL; |
170 | 177 | ||
178 | rcu_read_unlock(); | ||
179 | |||
171 | return h; | 180 | return h; |
172 | } | 181 | } |
173 | EXPORT_SYMBOL_GPL(nf_conntrack_helper_try_module_get); | 182 | EXPORT_SYMBOL_GPL(nf_conntrack_helper_try_module_get); |
@@ -311,38 +320,36 @@ void nf_ct_helper_expectfn_unregister(struct nf_ct_helper_expectfn *n) | |||
311 | } | 320 | } |
312 | EXPORT_SYMBOL_GPL(nf_ct_helper_expectfn_unregister); | 321 | EXPORT_SYMBOL_GPL(nf_ct_helper_expectfn_unregister); |
313 | 322 | ||
323 | /* Caller should hold the rcu lock */ | ||
314 | struct nf_ct_helper_expectfn * | 324 | struct nf_ct_helper_expectfn * |
315 | nf_ct_helper_expectfn_find_by_name(const char *name) | 325 | nf_ct_helper_expectfn_find_by_name(const char *name) |
316 | { | 326 | { |
317 | struct nf_ct_helper_expectfn *cur; | 327 | struct nf_ct_helper_expectfn *cur; |
318 | bool found = false; | 328 | bool found = false; |
319 | 329 | ||
320 | rcu_read_lock(); | ||
321 | list_for_each_entry_rcu(cur, &nf_ct_helper_expectfn_list, head) { | 330 | list_for_each_entry_rcu(cur, &nf_ct_helper_expectfn_list, head) { |
322 | if (!strcmp(cur->name, name)) { | 331 | if (!strcmp(cur->name, name)) { |
323 | found = true; | 332 | found = true; |
324 | break; | 333 | break; |
325 | } | 334 | } |
326 | } | 335 | } |
327 | rcu_read_unlock(); | ||
328 | return found ? cur : NULL; | 336 | return found ? cur : NULL; |
329 | } | 337 | } |
330 | EXPORT_SYMBOL_GPL(nf_ct_helper_expectfn_find_by_name); | 338 | EXPORT_SYMBOL_GPL(nf_ct_helper_expectfn_find_by_name); |
331 | 339 | ||
340 | /* Caller should hold the rcu lock */ | ||
332 | struct nf_ct_helper_expectfn * | 341 | struct nf_ct_helper_expectfn * |
333 | nf_ct_helper_expectfn_find_by_symbol(const void *symbol) | 342 | nf_ct_helper_expectfn_find_by_symbol(const void *symbol) |
334 | { | 343 | { |
335 | struct nf_ct_helper_expectfn *cur; | 344 | struct nf_ct_helper_expectfn *cur; |
336 | bool found = false; | 345 | bool found = false; |
337 | 346 | ||
338 | rcu_read_lock(); | ||
339 | list_for_each_entry_rcu(cur, &nf_ct_helper_expectfn_list, head) { | 347 | list_for_each_entry_rcu(cur, &nf_ct_helper_expectfn_list, head) { |
340 | if (cur->expectfn == symbol) { | 348 | if (cur->expectfn == symbol) { |
341 | found = true; | 349 | found = true; |
342 | break; | 350 | break; |
343 | } | 351 | } |
344 | } | 352 | } |
345 | rcu_read_unlock(); | ||
346 | return found ? cur : NULL; | 353 | return found ? cur : NULL; |
347 | } | 354 | } |
348 | EXPORT_SYMBOL_GPL(nf_ct_helper_expectfn_find_by_symbol); | 355 | EXPORT_SYMBOL_GPL(nf_ct_helper_expectfn_find_by_symbol); |
diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c index 6806b5e73567..dc7dfd68fafe 100644 --- a/net/netfilter/nf_conntrack_netlink.c +++ b/net/netfilter/nf_conntrack_netlink.c | |||
@@ -1488,11 +1488,16 @@ static int ctnetlink_change_helper(struct nf_conn *ct, | |||
1488 | * treat the second attempt as a no-op instead of returning | 1488 | * treat the second attempt as a no-op instead of returning |
1489 | * an error. | 1489 | * an error. |
1490 | */ | 1490 | */ |
1491 | if (help && help->helper && | 1491 | err = -EBUSY; |
1492 | !strcmp(help->helper->name, helpname)) | 1492 | if (help) { |
1493 | return 0; | 1493 | rcu_read_lock(); |
1494 | else | 1494 | helper = rcu_dereference(help->helper); |
1495 | return -EBUSY; | 1495 | if (helper && !strcmp(helper->name, helpname)) |
1496 | err = 0; | ||
1497 | rcu_read_unlock(); | ||
1498 | } | ||
1499 | |||
1500 | return err; | ||
1496 | } | 1501 | } |
1497 | 1502 | ||
1498 | if (!strcmp(helpname, "")) { | 1503 | if (!strcmp(helpname, "")) { |
@@ -1929,9 +1934,9 @@ static int ctnetlink_new_conntrack(struct net *net, struct sock *ctnl, | |||
1929 | 1934 | ||
1930 | err = 0; | 1935 | err = 0; |
1931 | if (test_bit(IPS_EXPECTED_BIT, &ct->status)) | 1936 | if (test_bit(IPS_EXPECTED_BIT, &ct->status)) |
1932 | events = IPCT_RELATED; | 1937 | events = 1 << IPCT_RELATED; |
1933 | else | 1938 | else |
1934 | events = IPCT_NEW; | 1939 | events = 1 << IPCT_NEW; |
1935 | 1940 | ||
1936 | if (cda[CTA_LABELS] && | 1941 | if (cda[CTA_LABELS] && |
1937 | ctnetlink_attach_labels(ct, cda) == 0) | 1942 | ctnetlink_attach_labels(ct, cda) == 0) |
@@ -2675,8 +2680,8 @@ ctnetlink_exp_dump_table(struct sk_buff *skb, struct netlink_callback *cb) | |||
2675 | last = (struct nf_conntrack_expect *)cb->args[1]; | 2680 | last = (struct nf_conntrack_expect *)cb->args[1]; |
2676 | for (; cb->args[0] < nf_ct_expect_hsize; cb->args[0]++) { | 2681 | for (; cb->args[0] < nf_ct_expect_hsize; cb->args[0]++) { |
2677 | restart: | 2682 | restart: |
2678 | hlist_for_each_entry(exp, &nf_ct_expect_hash[cb->args[0]], | 2683 | hlist_for_each_entry_rcu(exp, &nf_ct_expect_hash[cb->args[0]], |
2679 | hnode) { | 2684 | hnode) { |
2680 | if (l3proto && exp->tuple.src.l3num != l3proto) | 2685 | if (l3proto && exp->tuple.src.l3num != l3proto) |
2681 | continue; | 2686 | continue; |
2682 | 2687 | ||
@@ -2727,7 +2732,7 @@ ctnetlink_exp_ct_dump_table(struct sk_buff *skb, struct netlink_callback *cb) | |||
2727 | rcu_read_lock(); | 2732 | rcu_read_lock(); |
2728 | last = (struct nf_conntrack_expect *)cb->args[1]; | 2733 | last = (struct nf_conntrack_expect *)cb->args[1]; |
2729 | restart: | 2734 | restart: |
2730 | hlist_for_each_entry(exp, &help->expectations, lnode) { | 2735 | hlist_for_each_entry_rcu(exp, &help->expectations, lnode) { |
2731 | if (l3proto && exp->tuple.src.l3num != l3proto) | 2736 | if (l3proto && exp->tuple.src.l3num != l3proto) |
2732 | continue; | 2737 | continue; |
2733 | if (cb->args[1]) { | 2738 | if (cb->args[1]) { |
@@ -2789,6 +2794,12 @@ static int ctnetlink_dump_exp_ct(struct net *net, struct sock *ctnl, | |||
2789 | return -ENOENT; | 2794 | return -ENOENT; |
2790 | 2795 | ||
2791 | ct = nf_ct_tuplehash_to_ctrack(h); | 2796 | ct = nf_ct_tuplehash_to_ctrack(h); |
2797 | /* No expectation linked to this connection tracking. */ | ||
2798 | if (!nfct_help(ct)) { | ||
2799 | nf_ct_put(ct); | ||
2800 | return 0; | ||
2801 | } | ||
2802 | |||
2792 | c.data = ct; | 2803 | c.data = ct; |
2793 | 2804 | ||
2794 | err = netlink_dump_start(ctnl, skb, nlh, &c); | 2805 | err = netlink_dump_start(ctnl, skb, nlh, &c); |
@@ -3133,23 +3144,27 @@ ctnetlink_create_expect(struct net *net, | |||
3133 | return -ENOENT; | 3144 | return -ENOENT; |
3134 | ct = nf_ct_tuplehash_to_ctrack(h); | 3145 | ct = nf_ct_tuplehash_to_ctrack(h); |
3135 | 3146 | ||
3147 | rcu_read_lock(); | ||
3136 | if (cda[CTA_EXPECT_HELP_NAME]) { | 3148 | if (cda[CTA_EXPECT_HELP_NAME]) { |
3137 | const char *helpname = nla_data(cda[CTA_EXPECT_HELP_NAME]); | 3149 | const char *helpname = nla_data(cda[CTA_EXPECT_HELP_NAME]); |
3138 | 3150 | ||
3139 | helper = __nf_conntrack_helper_find(helpname, u3, | 3151 | helper = __nf_conntrack_helper_find(helpname, u3, |
3140 | nf_ct_protonum(ct)); | 3152 | nf_ct_protonum(ct)); |
3141 | if (helper == NULL) { | 3153 | if (helper == NULL) { |
3154 | rcu_read_unlock(); | ||
3142 | #ifdef CONFIG_MODULES | 3155 | #ifdef CONFIG_MODULES |
3143 | if (request_module("nfct-helper-%s", helpname) < 0) { | 3156 | if (request_module("nfct-helper-%s", helpname) < 0) { |
3144 | err = -EOPNOTSUPP; | 3157 | err = -EOPNOTSUPP; |
3145 | goto err_ct; | 3158 | goto err_ct; |
3146 | } | 3159 | } |
3160 | rcu_read_lock(); | ||
3147 | helper = __nf_conntrack_helper_find(helpname, u3, | 3161 | helper = __nf_conntrack_helper_find(helpname, u3, |
3148 | nf_ct_protonum(ct)); | 3162 | nf_ct_protonum(ct)); |
3149 | if (helper) { | 3163 | if (helper) { |
3150 | err = -EAGAIN; | 3164 | err = -EAGAIN; |
3151 | goto err_ct; | 3165 | goto err_rcu; |
3152 | } | 3166 | } |
3167 | rcu_read_unlock(); | ||
3153 | #endif | 3168 | #endif |
3154 | err = -EOPNOTSUPP; | 3169 | err = -EOPNOTSUPP; |
3155 | goto err_ct; | 3170 | goto err_ct; |
@@ -3159,11 +3174,13 @@ ctnetlink_create_expect(struct net *net, | |||
3159 | exp = ctnetlink_alloc_expect(cda, ct, helper, &tuple, &mask); | 3174 | exp = ctnetlink_alloc_expect(cda, ct, helper, &tuple, &mask); |
3160 | if (IS_ERR(exp)) { | 3175 | if (IS_ERR(exp)) { |
3161 | err = PTR_ERR(exp); | 3176 | err = PTR_ERR(exp); |
3162 | goto err_ct; | 3177 | goto err_rcu; |
3163 | } | 3178 | } |
3164 | 3179 | ||
3165 | err = nf_ct_expect_related_report(exp, portid, report); | 3180 | err = nf_ct_expect_related_report(exp, portid, report); |
3166 | nf_ct_expect_put(exp); | 3181 | nf_ct_expect_put(exp); |
3182 | err_rcu: | ||
3183 | rcu_read_unlock(); | ||
3167 | err_ct: | 3184 | err_ct: |
3168 | nf_ct_put(ct); | 3185 | nf_ct_put(ct); |
3169 | return err; | 3186 | return err; |
@@ -3442,6 +3459,7 @@ static void __exit ctnetlink_exit(void) | |||
3442 | #ifdef CONFIG_NETFILTER_NETLINK_GLUE_CT | 3459 | #ifdef CONFIG_NETFILTER_NETLINK_GLUE_CT |
3443 | RCU_INIT_POINTER(nfnl_ct_hook, NULL); | 3460 | RCU_INIT_POINTER(nfnl_ct_hook, NULL); |
3444 | #endif | 3461 | #endif |
3462 | synchronize_rcu(); | ||
3445 | } | 3463 | } |
3446 | 3464 | ||
3447 | module_init(ctnetlink_init); | 3465 | module_init(ctnetlink_init); |
diff --git a/net/netfilter/nf_nat_core.c b/net/netfilter/nf_nat_core.c index 94b14c5a8b17..82802e4a6640 100644 --- a/net/netfilter/nf_nat_core.c +++ b/net/netfilter/nf_nat_core.c | |||
@@ -903,6 +903,8 @@ static void __exit nf_nat_cleanup(void) | |||
903 | #ifdef CONFIG_XFRM | 903 | #ifdef CONFIG_XFRM |
904 | RCU_INIT_POINTER(nf_nat_decode_session_hook, NULL); | 904 | RCU_INIT_POINTER(nf_nat_decode_session_hook, NULL); |
905 | #endif | 905 | #endif |
906 | synchronize_rcu(); | ||
907 | |||
906 | for (i = 0; i < NFPROTO_NUMPROTO; i++) | 908 | for (i = 0; i < NFPROTO_NUMPROTO; i++) |
907 | kfree(nf_nat_l4protos[i]); | 909 | kfree(nf_nat_l4protos[i]); |
908 | 910 | ||
diff --git a/net/netfilter/nf_nat_redirect.c b/net/netfilter/nf_nat_redirect.c index d43869879fcf..86067560a318 100644 --- a/net/netfilter/nf_nat_redirect.c +++ b/net/netfilter/nf_nat_redirect.c | |||
@@ -101,11 +101,13 @@ nf_nat_redirect_ipv6(struct sk_buff *skb, const struct nf_nat_range *range, | |||
101 | rcu_read_lock(); | 101 | rcu_read_lock(); |
102 | idev = __in6_dev_get(skb->dev); | 102 | idev = __in6_dev_get(skb->dev); |
103 | if (idev != NULL) { | 103 | if (idev != NULL) { |
104 | read_lock_bh(&idev->lock); | ||
104 | list_for_each_entry(ifa, &idev->addr_list, if_list) { | 105 | list_for_each_entry(ifa, &idev->addr_list, if_list) { |
105 | newdst = ifa->addr; | 106 | newdst = ifa->addr; |
106 | addr = true; | 107 | addr = true; |
107 | break; | 108 | break; |
108 | } | 109 | } |
110 | read_unlock_bh(&idev->lock); | ||
109 | } | 111 | } |
110 | rcu_read_unlock(); | 112 | rcu_read_unlock(); |
111 | 113 | ||
diff --git a/net/netfilter/nfnetlink_cthelper.c b/net/netfilter/nfnetlink_cthelper.c index de8782345c86..d45558178da5 100644 --- a/net/netfilter/nfnetlink_cthelper.c +++ b/net/netfilter/nfnetlink_cthelper.c | |||
@@ -32,6 +32,13 @@ MODULE_LICENSE("GPL"); | |||
32 | MODULE_AUTHOR("Pablo Neira Ayuso <pablo@netfilter.org>"); | 32 | MODULE_AUTHOR("Pablo Neira Ayuso <pablo@netfilter.org>"); |
33 | MODULE_DESCRIPTION("nfnl_cthelper: User-space connection tracking helpers"); | 33 | MODULE_DESCRIPTION("nfnl_cthelper: User-space connection tracking helpers"); |
34 | 34 | ||
35 | struct nfnl_cthelper { | ||
36 | struct list_head list; | ||
37 | struct nf_conntrack_helper helper; | ||
38 | }; | ||
39 | |||
40 | static LIST_HEAD(nfnl_cthelper_list); | ||
41 | |||
35 | static int | 42 | static int |
36 | nfnl_userspace_cthelper(struct sk_buff *skb, unsigned int protoff, | 43 | nfnl_userspace_cthelper(struct sk_buff *skb, unsigned int protoff, |
37 | struct nf_conn *ct, enum ip_conntrack_info ctinfo) | 44 | struct nf_conn *ct, enum ip_conntrack_info ctinfo) |
@@ -161,6 +168,7 @@ nfnl_cthelper_parse_expect_policy(struct nf_conntrack_helper *helper, | |||
161 | int i, ret; | 168 | int i, ret; |
162 | struct nf_conntrack_expect_policy *expect_policy; | 169 | struct nf_conntrack_expect_policy *expect_policy; |
163 | struct nlattr *tb[NFCTH_POLICY_SET_MAX+1]; | 170 | struct nlattr *tb[NFCTH_POLICY_SET_MAX+1]; |
171 | unsigned int class_max; | ||
164 | 172 | ||
165 | ret = nla_parse_nested(tb, NFCTH_POLICY_SET_MAX, attr, | 173 | ret = nla_parse_nested(tb, NFCTH_POLICY_SET_MAX, attr, |
166 | nfnl_cthelper_expect_policy_set); | 174 | nfnl_cthelper_expect_policy_set); |
@@ -170,19 +178,18 @@ nfnl_cthelper_parse_expect_policy(struct nf_conntrack_helper *helper, | |||
170 | if (!tb[NFCTH_POLICY_SET_NUM]) | 178 | if (!tb[NFCTH_POLICY_SET_NUM]) |
171 | return -EINVAL; | 179 | return -EINVAL; |
172 | 180 | ||
173 | helper->expect_class_max = | 181 | class_max = ntohl(nla_get_be32(tb[NFCTH_POLICY_SET_NUM])); |
174 | ntohl(nla_get_be32(tb[NFCTH_POLICY_SET_NUM])); | 182 | if (class_max == 0) |
175 | 183 | return -EINVAL; | |
176 | if (helper->expect_class_max != 0 && | 184 | if (class_max > NF_CT_MAX_EXPECT_CLASSES) |
177 | helper->expect_class_max > NF_CT_MAX_EXPECT_CLASSES) | ||
178 | return -EOVERFLOW; | 185 | return -EOVERFLOW; |
179 | 186 | ||
180 | expect_policy = kzalloc(sizeof(struct nf_conntrack_expect_policy) * | 187 | expect_policy = kzalloc(sizeof(struct nf_conntrack_expect_policy) * |
181 | helper->expect_class_max, GFP_KERNEL); | 188 | class_max, GFP_KERNEL); |
182 | if (expect_policy == NULL) | 189 | if (expect_policy == NULL) |
183 | return -ENOMEM; | 190 | return -ENOMEM; |
184 | 191 | ||
185 | for (i=0; i<helper->expect_class_max; i++) { | 192 | for (i = 0; i < class_max; i++) { |
186 | if (!tb[NFCTH_POLICY_SET+i]) | 193 | if (!tb[NFCTH_POLICY_SET+i]) |
187 | goto err; | 194 | goto err; |
188 | 195 | ||
@@ -191,6 +198,8 @@ nfnl_cthelper_parse_expect_policy(struct nf_conntrack_helper *helper, | |||
191 | if (ret < 0) | 198 | if (ret < 0) |
192 | goto err; | 199 | goto err; |
193 | } | 200 | } |
201 | |||
202 | helper->expect_class_max = class_max - 1; | ||
194 | helper->expect_policy = expect_policy; | 203 | helper->expect_policy = expect_policy; |
195 | return 0; | 204 | return 0; |
196 | err: | 205 | err: |
@@ -203,18 +212,20 @@ nfnl_cthelper_create(const struct nlattr * const tb[], | |||
203 | struct nf_conntrack_tuple *tuple) | 212 | struct nf_conntrack_tuple *tuple) |
204 | { | 213 | { |
205 | struct nf_conntrack_helper *helper; | 214 | struct nf_conntrack_helper *helper; |
215 | struct nfnl_cthelper *nfcth; | ||
206 | int ret; | 216 | int ret; |
207 | 217 | ||
208 | if (!tb[NFCTH_TUPLE] || !tb[NFCTH_POLICY] || !tb[NFCTH_PRIV_DATA_LEN]) | 218 | if (!tb[NFCTH_TUPLE] || !tb[NFCTH_POLICY] || !tb[NFCTH_PRIV_DATA_LEN]) |
209 | return -EINVAL; | 219 | return -EINVAL; |
210 | 220 | ||
211 | helper = kzalloc(sizeof(struct nf_conntrack_helper), GFP_KERNEL); | 221 | nfcth = kzalloc(sizeof(*nfcth), GFP_KERNEL); |
212 | if (helper == NULL) | 222 | if (nfcth == NULL) |
213 | return -ENOMEM; | 223 | return -ENOMEM; |
224 | helper = &nfcth->helper; | ||
214 | 225 | ||
215 | ret = nfnl_cthelper_parse_expect_policy(helper, tb[NFCTH_POLICY]); | 226 | ret = nfnl_cthelper_parse_expect_policy(helper, tb[NFCTH_POLICY]); |
216 | if (ret < 0) | 227 | if (ret < 0) |
217 | goto err; | 228 | goto err1; |
218 | 229 | ||
219 | strncpy(helper->name, nla_data(tb[NFCTH_NAME]), NF_CT_HELPER_NAME_LEN); | 230 | strncpy(helper->name, nla_data(tb[NFCTH_NAME]), NF_CT_HELPER_NAME_LEN); |
220 | helper->data_len = ntohl(nla_get_be32(tb[NFCTH_PRIV_DATA_LEN])); | 231 | helper->data_len = ntohl(nla_get_be32(tb[NFCTH_PRIV_DATA_LEN])); |
@@ -245,15 +256,101 @@ nfnl_cthelper_create(const struct nlattr * const tb[], | |||
245 | 256 | ||
246 | ret = nf_conntrack_helper_register(helper); | 257 | ret = nf_conntrack_helper_register(helper); |
247 | if (ret < 0) | 258 | if (ret < 0) |
248 | goto err; | 259 | goto err2; |
249 | 260 | ||
261 | list_add_tail(&nfcth->list, &nfnl_cthelper_list); | ||
250 | return 0; | 262 | return 0; |
251 | err: | 263 | err2: |
252 | kfree(helper); | 264 | kfree(helper->expect_policy); |
265 | err1: | ||
266 | kfree(nfcth); | ||
253 | return ret; | 267 | return ret; |
254 | } | 268 | } |
255 | 269 | ||
256 | static int | 270 | static int |
271 | nfnl_cthelper_update_policy_one(const struct nf_conntrack_expect_policy *policy, | ||
272 | struct nf_conntrack_expect_policy *new_policy, | ||
273 | const struct nlattr *attr) | ||
274 | { | ||
275 | struct nlattr *tb[NFCTH_POLICY_MAX + 1]; | ||
276 | int err; | ||
277 | |||
278 | err = nla_parse_nested(tb, NFCTH_POLICY_MAX, attr, | ||
279 | nfnl_cthelper_expect_pol); | ||
280 | if (err < 0) | ||
281 | return err; | ||
282 | |||
283 | if (!tb[NFCTH_POLICY_NAME] || | ||
284 | !tb[NFCTH_POLICY_EXPECT_MAX] || | ||
285 | !tb[NFCTH_POLICY_EXPECT_TIMEOUT]) | ||
286 | return -EINVAL; | ||
287 | |||
288 | if (nla_strcmp(tb[NFCTH_POLICY_NAME], policy->name)) | ||
289 | return -EBUSY; | ||
290 | |||
291 | new_policy->max_expected = | ||
292 | ntohl(nla_get_be32(tb[NFCTH_POLICY_EXPECT_MAX])); | ||
293 | new_policy->timeout = | ||
294 | ntohl(nla_get_be32(tb[NFCTH_POLICY_EXPECT_TIMEOUT])); | ||
295 | |||
296 | return 0; | ||
297 | } | ||
298 | |||
299 | static int nfnl_cthelper_update_policy_all(struct nlattr *tb[], | ||
300 | struct nf_conntrack_helper *helper) | ||
301 | { | ||
302 | struct nf_conntrack_expect_policy new_policy[helper->expect_class_max + 1]; | ||
303 | struct nf_conntrack_expect_policy *policy; | ||
304 | int i, err; | ||
305 | |||
306 | /* Check first that all policy attributes are well-formed, so we don't | ||
307 | * leave things in inconsistent state on errors. | ||
308 | */ | ||
309 | for (i = 0; i < helper->expect_class_max + 1; i++) { | ||
310 | |||
311 | if (!tb[NFCTH_POLICY_SET + i]) | ||
312 | return -EINVAL; | ||
313 | |||
314 | err = nfnl_cthelper_update_policy_one(&helper->expect_policy[i], | ||
315 | &new_policy[i], | ||
316 | tb[NFCTH_POLICY_SET + i]); | ||
317 | if (err < 0) | ||
318 | return err; | ||
319 | } | ||
320 | /* Now we can safely update them. */ | ||
321 | for (i = 0; i < helper->expect_class_max + 1; i++) { | ||
322 | policy = (struct nf_conntrack_expect_policy *) | ||
323 | &helper->expect_policy[i]; | ||
324 | policy->max_expected = new_policy->max_expected; | ||
325 | policy->timeout = new_policy->timeout; | ||
326 | } | ||
327 | |||
328 | return 0; | ||
329 | } | ||
330 | |||
331 | static int nfnl_cthelper_update_policy(struct nf_conntrack_helper *helper, | ||
332 | const struct nlattr *attr) | ||
333 | { | ||
334 | struct nlattr *tb[NFCTH_POLICY_SET_MAX + 1]; | ||
335 | unsigned int class_max; | ||
336 | int err; | ||
337 | |||
338 | err = nla_parse_nested(tb, NFCTH_POLICY_SET_MAX, attr, | ||
339 | nfnl_cthelper_expect_policy_set); | ||
340 | if (err < 0) | ||
341 | return err; | ||
342 | |||
343 | if (!tb[NFCTH_POLICY_SET_NUM]) | ||
344 | return -EINVAL; | ||
345 | |||
346 | class_max = ntohl(nla_get_be32(tb[NFCTH_POLICY_SET_NUM])); | ||
347 | if (helper->expect_class_max + 1 != class_max) | ||
348 | return -EBUSY; | ||
349 | |||
350 | return nfnl_cthelper_update_policy_all(tb, helper); | ||
351 | } | ||
352 | |||
353 | static int | ||
257 | nfnl_cthelper_update(const struct nlattr * const tb[], | 354 | nfnl_cthelper_update(const struct nlattr * const tb[], |
258 | struct nf_conntrack_helper *helper) | 355 | struct nf_conntrack_helper *helper) |
259 | { | 356 | { |
@@ -263,8 +360,7 @@ nfnl_cthelper_update(const struct nlattr * const tb[], | |||
263 | return -EBUSY; | 360 | return -EBUSY; |
264 | 361 | ||
265 | if (tb[NFCTH_POLICY]) { | 362 | if (tb[NFCTH_POLICY]) { |
266 | ret = nfnl_cthelper_parse_expect_policy(helper, | 363 | ret = nfnl_cthelper_update_policy(helper, tb[NFCTH_POLICY]); |
267 | tb[NFCTH_POLICY]); | ||
268 | if (ret < 0) | 364 | if (ret < 0) |
269 | return ret; | 365 | return ret; |
270 | } | 366 | } |
@@ -293,7 +389,8 @@ static int nfnl_cthelper_new(struct net *net, struct sock *nfnl, | |||
293 | const char *helper_name; | 389 | const char *helper_name; |
294 | struct nf_conntrack_helper *cur, *helper = NULL; | 390 | struct nf_conntrack_helper *cur, *helper = NULL; |
295 | struct nf_conntrack_tuple tuple; | 391 | struct nf_conntrack_tuple tuple; |
296 | int ret = 0, i; | 392 | struct nfnl_cthelper *nlcth; |
393 | int ret = 0; | ||
297 | 394 | ||
298 | if (!tb[NFCTH_NAME] || !tb[NFCTH_TUPLE]) | 395 | if (!tb[NFCTH_NAME] || !tb[NFCTH_TUPLE]) |
299 | return -EINVAL; | 396 | return -EINVAL; |
@@ -304,31 +401,22 @@ static int nfnl_cthelper_new(struct net *net, struct sock *nfnl, | |||
304 | if (ret < 0) | 401 | if (ret < 0) |
305 | return ret; | 402 | return ret; |
306 | 403 | ||
307 | rcu_read_lock(); | 404 | list_for_each_entry(nlcth, &nfnl_cthelper_list, list) { |
308 | for (i = 0; i < nf_ct_helper_hsize && !helper; i++) { | 405 | cur = &nlcth->helper; |
309 | hlist_for_each_entry_rcu(cur, &nf_ct_helper_hash[i], hnode) { | ||
310 | 406 | ||
311 | /* skip non-userspace conntrack helpers. */ | 407 | if (strncmp(cur->name, helper_name, NF_CT_HELPER_NAME_LEN)) |
312 | if (!(cur->flags & NF_CT_HELPER_F_USERSPACE)) | 408 | continue; |
313 | continue; | ||
314 | 409 | ||
315 | if (strncmp(cur->name, helper_name, | 410 | if ((tuple.src.l3num != cur->tuple.src.l3num || |
316 | NF_CT_HELPER_NAME_LEN) != 0) | 411 | tuple.dst.protonum != cur->tuple.dst.protonum)) |
317 | continue; | 412 | continue; |
318 | 413 | ||
319 | if ((tuple.src.l3num != cur->tuple.src.l3num || | 414 | if (nlh->nlmsg_flags & NLM_F_EXCL) |
320 | tuple.dst.protonum != cur->tuple.dst.protonum)) | 415 | return -EEXIST; |
321 | continue; | ||
322 | 416 | ||
323 | if (nlh->nlmsg_flags & NLM_F_EXCL) { | 417 | helper = cur; |
324 | ret = -EEXIST; | 418 | break; |
325 | goto err; | ||
326 | } | ||
327 | helper = cur; | ||
328 | break; | ||
329 | } | ||
330 | } | 419 | } |
331 | rcu_read_unlock(); | ||
332 | 420 | ||
333 | if (helper == NULL) | 421 | if (helper == NULL) |
334 | ret = nfnl_cthelper_create(tb, &tuple); | 422 | ret = nfnl_cthelper_create(tb, &tuple); |
@@ -336,9 +424,6 @@ static int nfnl_cthelper_new(struct net *net, struct sock *nfnl, | |||
336 | ret = nfnl_cthelper_update(tb, helper); | 424 | ret = nfnl_cthelper_update(tb, helper); |
337 | 425 | ||
338 | return ret; | 426 | return ret; |
339 | err: | ||
340 | rcu_read_unlock(); | ||
341 | return ret; | ||
342 | } | 427 | } |
343 | 428 | ||
344 | static int | 429 | static int |
@@ -377,10 +462,10 @@ nfnl_cthelper_dump_policy(struct sk_buff *skb, | |||
377 | goto nla_put_failure; | 462 | goto nla_put_failure; |
378 | 463 | ||
379 | if (nla_put_be32(skb, NFCTH_POLICY_SET_NUM, | 464 | if (nla_put_be32(skb, NFCTH_POLICY_SET_NUM, |
380 | htonl(helper->expect_class_max))) | 465 | htonl(helper->expect_class_max + 1))) |
381 | goto nla_put_failure; | 466 | goto nla_put_failure; |
382 | 467 | ||
383 | for (i=0; i<helper->expect_class_max; i++) { | 468 | for (i = 0; i < helper->expect_class_max + 1; i++) { |
384 | nest_parms2 = nla_nest_start(skb, | 469 | nest_parms2 = nla_nest_start(skb, |
385 | (NFCTH_POLICY_SET+i) | NLA_F_NESTED); | 470 | (NFCTH_POLICY_SET+i) | NLA_F_NESTED); |
386 | if (nest_parms2 == NULL) | 471 | if (nest_parms2 == NULL) |
@@ -502,11 +587,12 @@ static int nfnl_cthelper_get(struct net *net, struct sock *nfnl, | |||
502 | struct sk_buff *skb, const struct nlmsghdr *nlh, | 587 | struct sk_buff *skb, const struct nlmsghdr *nlh, |
503 | const struct nlattr * const tb[]) | 588 | const struct nlattr * const tb[]) |
504 | { | 589 | { |
505 | int ret = -ENOENT, i; | 590 | int ret = -ENOENT; |
506 | struct nf_conntrack_helper *cur; | 591 | struct nf_conntrack_helper *cur; |
507 | struct sk_buff *skb2; | 592 | struct sk_buff *skb2; |
508 | char *helper_name = NULL; | 593 | char *helper_name = NULL; |
509 | struct nf_conntrack_tuple tuple; | 594 | struct nf_conntrack_tuple tuple; |
595 | struct nfnl_cthelper *nlcth; | ||
510 | bool tuple_set = false; | 596 | bool tuple_set = false; |
511 | 597 | ||
512 | if (nlh->nlmsg_flags & NLM_F_DUMP) { | 598 | if (nlh->nlmsg_flags & NLM_F_DUMP) { |
@@ -527,45 +613,39 @@ static int nfnl_cthelper_get(struct net *net, struct sock *nfnl, | |||
527 | tuple_set = true; | 613 | tuple_set = true; |
528 | } | 614 | } |
529 | 615 | ||
530 | for (i = 0; i < nf_ct_helper_hsize; i++) { | 616 | list_for_each_entry(nlcth, &nfnl_cthelper_list, list) { |
531 | hlist_for_each_entry_rcu(cur, &nf_ct_helper_hash[i], hnode) { | 617 | cur = &nlcth->helper; |
618 | if (helper_name && | ||
619 | strncmp(cur->name, helper_name, NF_CT_HELPER_NAME_LEN)) | ||
620 | continue; | ||
532 | 621 | ||
533 | /* skip non-userspace conntrack helpers. */ | 622 | if (tuple_set && |
534 | if (!(cur->flags & NF_CT_HELPER_F_USERSPACE)) | 623 | (tuple.src.l3num != cur->tuple.src.l3num || |
535 | continue; | 624 | tuple.dst.protonum != cur->tuple.dst.protonum)) |
625 | continue; | ||
536 | 626 | ||
537 | if (helper_name && strncmp(cur->name, helper_name, | 627 | skb2 = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); |
538 | NF_CT_HELPER_NAME_LEN) != 0) { | 628 | if (skb2 == NULL) { |
539 | continue; | 629 | ret = -ENOMEM; |
540 | } | 630 | break; |
541 | if (tuple_set && | 631 | } |
542 | (tuple.src.l3num != cur->tuple.src.l3num || | ||
543 | tuple.dst.protonum != cur->tuple.dst.protonum)) | ||
544 | continue; | ||
545 | |||
546 | skb2 = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); | ||
547 | if (skb2 == NULL) { | ||
548 | ret = -ENOMEM; | ||
549 | break; | ||
550 | } | ||
551 | 632 | ||
552 | ret = nfnl_cthelper_fill_info(skb2, NETLINK_CB(skb).portid, | 633 | ret = nfnl_cthelper_fill_info(skb2, NETLINK_CB(skb).portid, |
553 | nlh->nlmsg_seq, | 634 | nlh->nlmsg_seq, |
554 | NFNL_MSG_TYPE(nlh->nlmsg_type), | 635 | NFNL_MSG_TYPE(nlh->nlmsg_type), |
555 | NFNL_MSG_CTHELPER_NEW, cur); | 636 | NFNL_MSG_CTHELPER_NEW, cur); |
556 | if (ret <= 0) { | 637 | if (ret <= 0) { |
557 | kfree_skb(skb2); | 638 | kfree_skb(skb2); |
558 | break; | 639 | break; |
559 | } | 640 | } |
560 | 641 | ||
561 | ret = netlink_unicast(nfnl, skb2, NETLINK_CB(skb).portid, | 642 | ret = netlink_unicast(nfnl, skb2, NETLINK_CB(skb).portid, |
562 | MSG_DONTWAIT); | 643 | MSG_DONTWAIT); |
563 | if (ret > 0) | 644 | if (ret > 0) |
564 | ret = 0; | 645 | ret = 0; |
565 | 646 | ||
566 | /* this avoids a loop in nfnetlink. */ | 647 | /* this avoids a loop in nfnetlink. */ |
567 | return ret == -EAGAIN ? -ENOBUFS : ret; | 648 | return ret == -EAGAIN ? -ENOBUFS : ret; |
568 | } | ||
569 | } | 649 | } |
570 | return ret; | 650 | return ret; |
571 | } | 651 | } |
@@ -576,10 +656,10 @@ static int nfnl_cthelper_del(struct net *net, struct sock *nfnl, | |||
576 | { | 656 | { |
577 | char *helper_name = NULL; | 657 | char *helper_name = NULL; |
578 | struct nf_conntrack_helper *cur; | 658 | struct nf_conntrack_helper *cur; |
579 | struct hlist_node *tmp; | ||
580 | struct nf_conntrack_tuple tuple; | 659 | struct nf_conntrack_tuple tuple; |
581 | bool tuple_set = false, found = false; | 660 | bool tuple_set = false, found = false; |
582 | int i, j = 0, ret; | 661 | struct nfnl_cthelper *nlcth, *n; |
662 | int j = 0, ret; | ||
583 | 663 | ||
584 | if (tb[NFCTH_NAME]) | 664 | if (tb[NFCTH_NAME]) |
585 | helper_name = nla_data(tb[NFCTH_NAME]); | 665 | helper_name = nla_data(tb[NFCTH_NAME]); |
@@ -592,28 +672,27 @@ static int nfnl_cthelper_del(struct net *net, struct sock *nfnl, | |||
592 | tuple_set = true; | 672 | tuple_set = true; |
593 | } | 673 | } |
594 | 674 | ||
595 | for (i = 0; i < nf_ct_helper_hsize; i++) { | 675 | list_for_each_entry_safe(nlcth, n, &nfnl_cthelper_list, list) { |
596 | hlist_for_each_entry_safe(cur, tmp, &nf_ct_helper_hash[i], | 676 | cur = &nlcth->helper; |
597 | hnode) { | 677 | j++; |
598 | /* skip non-userspace conntrack helpers. */ | ||
599 | if (!(cur->flags & NF_CT_HELPER_F_USERSPACE)) | ||
600 | continue; | ||
601 | 678 | ||
602 | j++; | 679 | if (helper_name && |
680 | strncmp(cur->name, helper_name, NF_CT_HELPER_NAME_LEN)) | ||
681 | continue; | ||
603 | 682 | ||
604 | if (helper_name && strncmp(cur->name, helper_name, | 683 | if (tuple_set && |
605 | NF_CT_HELPER_NAME_LEN) != 0) { | 684 | (tuple.src.l3num != cur->tuple.src.l3num || |
606 | continue; | 685 | tuple.dst.protonum != cur->tuple.dst.protonum)) |
607 | } | 686 | continue; |
608 | if (tuple_set && | ||
609 | (tuple.src.l3num != cur->tuple.src.l3num || | ||
610 | tuple.dst.protonum != cur->tuple.dst.protonum)) | ||
611 | continue; | ||
612 | 687 | ||
613 | found = true; | 688 | found = true; |
614 | nf_conntrack_helper_unregister(cur); | 689 | nf_conntrack_helper_unregister(cur); |
615 | } | 690 | kfree(cur->expect_policy); |
691 | |||
692 | list_del(&nlcth->list); | ||
693 | kfree(nlcth); | ||
616 | } | 694 | } |
695 | |||
617 | /* Make sure we return success if we flush and there is no helpers */ | 696 | /* Make sure we return success if we flush and there is no helpers */ |
618 | return (found || j == 0) ? 0 : -ENOENT; | 697 | return (found || j == 0) ? 0 : -ENOENT; |
619 | } | 698 | } |
@@ -662,20 +741,16 @@ err_out: | |||
662 | static void __exit nfnl_cthelper_exit(void) | 741 | static void __exit nfnl_cthelper_exit(void) |
663 | { | 742 | { |
664 | struct nf_conntrack_helper *cur; | 743 | struct nf_conntrack_helper *cur; |
665 | struct hlist_node *tmp; | 744 | struct nfnl_cthelper *nlcth, *n; |
666 | int i; | ||
667 | 745 | ||
668 | nfnetlink_subsys_unregister(&nfnl_cthelper_subsys); | 746 | nfnetlink_subsys_unregister(&nfnl_cthelper_subsys); |
669 | 747 | ||
670 | for (i=0; i<nf_ct_helper_hsize; i++) { | 748 | list_for_each_entry_safe(nlcth, n, &nfnl_cthelper_list, list) { |
671 | hlist_for_each_entry_safe(cur, tmp, &nf_ct_helper_hash[i], | 749 | cur = &nlcth->helper; |
672 | hnode) { | ||
673 | /* skip non-userspace conntrack helpers. */ | ||
674 | if (!(cur->flags & NF_CT_HELPER_F_USERSPACE)) | ||
675 | continue; | ||
676 | 750 | ||
677 | nf_conntrack_helper_unregister(cur); | 751 | nf_conntrack_helper_unregister(cur); |
678 | } | 752 | kfree(cur->expect_policy); |
753 | kfree(nlcth); | ||
679 | } | 754 | } |
680 | } | 755 | } |
681 | 756 | ||
diff --git a/net/netfilter/nfnetlink_cttimeout.c b/net/netfilter/nfnetlink_cttimeout.c index 139e0867e56e..47d6656c9119 100644 --- a/net/netfilter/nfnetlink_cttimeout.c +++ b/net/netfilter/nfnetlink_cttimeout.c | |||
@@ -646,8 +646,8 @@ static void __exit cttimeout_exit(void) | |||
646 | #ifdef CONFIG_NF_CONNTRACK_TIMEOUT | 646 | #ifdef CONFIG_NF_CONNTRACK_TIMEOUT |
647 | RCU_INIT_POINTER(nf_ct_timeout_find_get_hook, NULL); | 647 | RCU_INIT_POINTER(nf_ct_timeout_find_get_hook, NULL); |
648 | RCU_INIT_POINTER(nf_ct_timeout_put_hook, NULL); | 648 | RCU_INIT_POINTER(nf_ct_timeout_put_hook, NULL); |
649 | synchronize_rcu(); | ||
649 | #endif /* CONFIG_NF_CONNTRACK_TIMEOUT */ | 650 | #endif /* CONFIG_NF_CONNTRACK_TIMEOUT */ |
650 | rcu_barrier(); | ||
651 | } | 651 | } |
652 | 652 | ||
653 | module_init(cttimeout_init); | 653 | module_init(cttimeout_init); |
diff --git a/net/netfilter/nfnetlink_queue.c b/net/netfilter/nfnetlink_queue.c index 3ee0b8a000a4..933509ebf3d3 100644 --- a/net/netfilter/nfnetlink_queue.c +++ b/net/netfilter/nfnetlink_queue.c | |||
@@ -443,7 +443,7 @@ nfqnl_build_packet_message(struct net *net, struct nfqnl_instance *queue, | |||
443 | skb = alloc_skb(size, GFP_ATOMIC); | 443 | skb = alloc_skb(size, GFP_ATOMIC); |
444 | if (!skb) { | 444 | if (!skb) { |
445 | skb_tx_error(entskb); | 445 | skb_tx_error(entskb); |
446 | return NULL; | 446 | goto nlmsg_failure; |
447 | } | 447 | } |
448 | 448 | ||
449 | nlh = nlmsg_put(skb, 0, 0, | 449 | nlh = nlmsg_put(skb, 0, 0, |
@@ -452,7 +452,7 @@ nfqnl_build_packet_message(struct net *net, struct nfqnl_instance *queue, | |||
452 | if (!nlh) { | 452 | if (!nlh) { |
453 | skb_tx_error(entskb); | 453 | skb_tx_error(entskb); |
454 | kfree_skb(skb); | 454 | kfree_skb(skb); |
455 | return NULL; | 455 | goto nlmsg_failure; |
456 | } | 456 | } |
457 | nfmsg = nlmsg_data(nlh); | 457 | nfmsg = nlmsg_data(nlh); |
458 | nfmsg->nfgen_family = entry->state.pf; | 458 | nfmsg->nfgen_family = entry->state.pf; |
@@ -598,12 +598,17 @@ nfqnl_build_packet_message(struct net *net, struct nfqnl_instance *queue, | |||
598 | } | 598 | } |
599 | 599 | ||
600 | nlh->nlmsg_len = skb->len; | 600 | nlh->nlmsg_len = skb->len; |
601 | if (seclen) | ||
602 | security_release_secctx(secdata, seclen); | ||
601 | return skb; | 603 | return skb; |
602 | 604 | ||
603 | nla_put_failure: | 605 | nla_put_failure: |
604 | skb_tx_error(entskb); | 606 | skb_tx_error(entskb); |
605 | kfree_skb(skb); | 607 | kfree_skb(skb); |
606 | net_err_ratelimited("nf_queue: error creating packet message\n"); | 608 | net_err_ratelimited("nf_queue: error creating packet message\n"); |
609 | nlmsg_failure: | ||
610 | if (seclen) | ||
611 | security_release_secctx(secdata, seclen); | ||
607 | return NULL; | 612 | return NULL; |
608 | } | 613 | } |
609 | 614 | ||
diff --git a/net/netfilter/nft_hash.c b/net/netfilter/nft_hash.c index eb2721af898d..c4dad1254ead 100644 --- a/net/netfilter/nft_hash.c +++ b/net/netfilter/nft_hash.c | |||
@@ -21,6 +21,7 @@ struct nft_hash { | |||
21 | enum nft_registers sreg:8; | 21 | enum nft_registers sreg:8; |
22 | enum nft_registers dreg:8; | 22 | enum nft_registers dreg:8; |
23 | u8 len; | 23 | u8 len; |
24 | bool autogen_seed:1; | ||
24 | u32 modulus; | 25 | u32 modulus; |
25 | u32 seed; | 26 | u32 seed; |
26 | u32 offset; | 27 | u32 offset; |
@@ -82,10 +83,12 @@ static int nft_hash_init(const struct nft_ctx *ctx, | |||
82 | if (priv->offset + priv->modulus - 1 < priv->offset) | 83 | if (priv->offset + priv->modulus - 1 < priv->offset) |
83 | return -EOVERFLOW; | 84 | return -EOVERFLOW; |
84 | 85 | ||
85 | if (tb[NFTA_HASH_SEED]) | 86 | if (tb[NFTA_HASH_SEED]) { |
86 | priv->seed = ntohl(nla_get_be32(tb[NFTA_HASH_SEED])); | 87 | priv->seed = ntohl(nla_get_be32(tb[NFTA_HASH_SEED])); |
87 | else | 88 | } else { |
89 | priv->autogen_seed = true; | ||
88 | get_random_bytes(&priv->seed, sizeof(priv->seed)); | 90 | get_random_bytes(&priv->seed, sizeof(priv->seed)); |
91 | } | ||
89 | 92 | ||
90 | return nft_validate_register_load(priv->sreg, len) && | 93 | return nft_validate_register_load(priv->sreg, len) && |
91 | nft_validate_register_store(ctx, priv->dreg, NULL, | 94 | nft_validate_register_store(ctx, priv->dreg, NULL, |
@@ -105,7 +108,8 @@ static int nft_hash_dump(struct sk_buff *skb, | |||
105 | goto nla_put_failure; | 108 | goto nla_put_failure; |
106 | if (nla_put_be32(skb, NFTA_HASH_MODULUS, htonl(priv->modulus))) | 109 | if (nla_put_be32(skb, NFTA_HASH_MODULUS, htonl(priv->modulus))) |
107 | goto nla_put_failure; | 110 | goto nla_put_failure; |
108 | if (nla_put_be32(skb, NFTA_HASH_SEED, htonl(priv->seed))) | 111 | if (!priv->autogen_seed && |
112 | nla_put_be32(skb, NFTA_HASH_SEED, htonl(priv->seed))) | ||
109 | goto nla_put_failure; | 113 | goto nla_put_failure; |
110 | if (priv->offset != 0) | 114 | if (priv->offset != 0) |
111 | if (nla_put_be32(skb, NFTA_HASH_OFFSET, htonl(priv->offset))) | 115 | if (nla_put_be32(skb, NFTA_HASH_OFFSET, htonl(priv->offset))) |
diff --git a/net/netfilter/xt_TCPMSS.c b/net/netfilter/xt_TCPMSS.c index 27241a767f17..c64aca611ac5 100644 --- a/net/netfilter/xt_TCPMSS.c +++ b/net/netfilter/xt_TCPMSS.c | |||
@@ -104,7 +104,7 @@ tcpmss_mangle_packet(struct sk_buff *skb, | |||
104 | tcph = (struct tcphdr *)(skb_network_header(skb) + tcphoff); | 104 | tcph = (struct tcphdr *)(skb_network_header(skb) + tcphoff); |
105 | tcp_hdrlen = tcph->doff * 4; | 105 | tcp_hdrlen = tcph->doff * 4; |
106 | 106 | ||
107 | if (len < tcp_hdrlen) | 107 | if (len < tcp_hdrlen || tcp_hdrlen < sizeof(struct tcphdr)) |
108 | return -1; | 108 | return -1; |
109 | 109 | ||
110 | if (info->mss == XT_TCPMSS_CLAMP_PMTU) { | 110 | if (info->mss == XT_TCPMSS_CLAMP_PMTU) { |
@@ -152,6 +152,10 @@ tcpmss_mangle_packet(struct sk_buff *skb, | |||
152 | if (len > tcp_hdrlen) | 152 | if (len > tcp_hdrlen) |
153 | return 0; | 153 | return 0; |
154 | 154 | ||
155 | /* tcph->doff has 4 bits, do not wrap it to 0 */ | ||
156 | if (tcp_hdrlen >= 15 * 4) | ||
157 | return 0; | ||
158 | |||
155 | /* | 159 | /* |
156 | * MSS Option not found ?! add it.. | 160 | * MSS Option not found ?! add it.. |
157 | */ | 161 | */ |
diff --git a/net/netfilter/xt_TPROXY.c b/net/netfilter/xt_TPROXY.c index 80cb7babeb64..df7f1df00330 100644 --- a/net/netfilter/xt_TPROXY.c +++ b/net/netfilter/xt_TPROXY.c | |||
@@ -393,7 +393,8 @@ tproxy_laddr6(struct sk_buff *skb, const struct in6_addr *user_laddr, | |||
393 | 393 | ||
394 | rcu_read_lock(); | 394 | rcu_read_lock(); |
395 | indev = __in6_dev_get(skb->dev); | 395 | indev = __in6_dev_get(skb->dev); |
396 | if (indev) | 396 | if (indev) { |
397 | read_lock_bh(&indev->lock); | ||
397 | list_for_each_entry(ifa, &indev->addr_list, if_list) { | 398 | list_for_each_entry(ifa, &indev->addr_list, if_list) { |
398 | if (ifa->flags & (IFA_F_TENTATIVE | IFA_F_DEPRECATED)) | 399 | if (ifa->flags & (IFA_F_TENTATIVE | IFA_F_DEPRECATED)) |
399 | continue; | 400 | continue; |
@@ -401,6 +402,8 @@ tproxy_laddr6(struct sk_buff *skb, const struct in6_addr *user_laddr, | |||
401 | laddr = &ifa->addr; | 402 | laddr = &ifa->addr; |
402 | break; | 403 | break; |
403 | } | 404 | } |
405 | read_unlock_bh(&indev->lock); | ||
406 | } | ||
404 | rcu_read_unlock(); | 407 | rcu_read_unlock(); |
405 | 408 | ||
406 | return laddr ? laddr : daddr; | 409 | return laddr ? laddr : daddr; |
diff --git a/net/openvswitch/conntrack.c b/net/openvswitch/conntrack.c index e0a87776a010..7b2c2fce408a 100644 --- a/net/openvswitch/conntrack.c +++ b/net/openvswitch/conntrack.c | |||
@@ -643,8 +643,8 @@ static bool skb_nfct_cached(struct net *net, | |||
643 | */ | 643 | */ |
644 | if (nf_ct_is_confirmed(ct)) | 644 | if (nf_ct_is_confirmed(ct)) |
645 | nf_ct_delete(ct, 0, 0); | 645 | nf_ct_delete(ct, 0, 0); |
646 | else | 646 | |
647 | nf_conntrack_put(&ct->ct_general); | 647 | nf_conntrack_put(&ct->ct_general); |
648 | nf_ct_set(skb, NULL, 0); | 648 | nf_ct_set(skb, NULL, 0); |
649 | return false; | 649 | return false; |
650 | } | 650 | } |
diff --git a/net/openvswitch/flow.c b/net/openvswitch/flow.c index 9d4bb8eb63f2..3f76cb765e5b 100644 --- a/net/openvswitch/flow.c +++ b/net/openvswitch/flow.c | |||
@@ -527,7 +527,7 @@ static int key_extract(struct sk_buff *skb, struct sw_flow_key *key) | |||
527 | 527 | ||
528 | /* Link layer. */ | 528 | /* Link layer. */ |
529 | clear_vlan(key); | 529 | clear_vlan(key); |
530 | if (key->mac_proto == MAC_PROTO_NONE) { | 530 | if (ovs_key_mac_proto(key) == MAC_PROTO_NONE) { |
531 | if (unlikely(eth_type_vlan(skb->protocol))) | 531 | if (unlikely(eth_type_vlan(skb->protocol))) |
532 | return -EINVAL; | 532 | return -EINVAL; |
533 | 533 | ||
@@ -745,7 +745,13 @@ static int key_extract(struct sk_buff *skb, struct sw_flow_key *key) | |||
745 | 745 | ||
746 | int ovs_flow_key_update(struct sk_buff *skb, struct sw_flow_key *key) | 746 | int ovs_flow_key_update(struct sk_buff *skb, struct sw_flow_key *key) |
747 | { | 747 | { |
748 | return key_extract(skb, key); | 748 | int res; |
749 | |||
750 | res = key_extract(skb, key); | ||
751 | if (!res) | ||
752 | key->mac_proto &= ~SW_FLOW_KEY_INVALID; | ||
753 | |||
754 | return res; | ||
749 | } | 755 | } |
750 | 756 | ||
751 | static int key_extract_mac_proto(struct sk_buff *skb) | 757 | static int key_extract_mac_proto(struct sk_buff *skb) |
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index a0dbe7ca8f72..8489beff5c25 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c | |||
@@ -3665,6 +3665,8 @@ packet_setsockopt(struct socket *sock, int level, int optname, char __user *optv | |||
3665 | return -EBUSY; | 3665 | return -EBUSY; |
3666 | if (copy_from_user(&val, optval, sizeof(val))) | 3666 | if (copy_from_user(&val, optval, sizeof(val))) |
3667 | return -EFAULT; | 3667 | return -EFAULT; |
3668 | if (val > INT_MAX) | ||
3669 | return -EINVAL; | ||
3668 | po->tp_reserve = val; | 3670 | po->tp_reserve = val; |
3669 | return 0; | 3671 | return 0; |
3670 | } | 3672 | } |
@@ -4193,8 +4195,8 @@ static int packet_set_ring(struct sock *sk, union tpacket_req_u *req_u, | |||
4193 | if (unlikely(!PAGE_ALIGNED(req->tp_block_size))) | 4195 | if (unlikely(!PAGE_ALIGNED(req->tp_block_size))) |
4194 | goto out; | 4196 | goto out; |
4195 | if (po->tp_version >= TPACKET_V3 && | 4197 | if (po->tp_version >= TPACKET_V3 && |
4196 | (int)(req->tp_block_size - | 4198 | req->tp_block_size <= |
4197 | BLK_PLUS_PRIV(req_u->req3.tp_sizeof_priv)) <= 0) | 4199 | BLK_PLUS_PRIV((u64)req_u->req3.tp_sizeof_priv)) |
4198 | goto out; | 4200 | goto out; |
4199 | if (unlikely(req->tp_frame_size < po->tp_hdrlen + | 4201 | if (unlikely(req->tp_frame_size < po->tp_hdrlen + |
4200 | po->tp_reserve)) | 4202 | po->tp_reserve)) |
@@ -4205,6 +4207,8 @@ static int packet_set_ring(struct sock *sk, union tpacket_req_u *req_u, | |||
4205 | rb->frames_per_block = req->tp_block_size / req->tp_frame_size; | 4207 | rb->frames_per_block = req->tp_block_size / req->tp_frame_size; |
4206 | if (unlikely(rb->frames_per_block == 0)) | 4208 | if (unlikely(rb->frames_per_block == 0)) |
4207 | goto out; | 4209 | goto out; |
4210 | if (unlikely(req->tp_block_size > UINT_MAX / req->tp_block_nr)) | ||
4211 | goto out; | ||
4208 | if (unlikely((rb->frames_per_block * req->tp_block_nr) != | 4212 | if (unlikely((rb->frames_per_block * req->tp_block_nr) != |
4209 | req->tp_frame_nr)) | 4213 | req->tp_frame_nr)) |
4210 | goto out; | 4214 | goto out; |
diff --git a/net/qrtr/qrtr.c b/net/qrtr/qrtr.c index ae5ac175b2be..9da7368b0140 100644 --- a/net/qrtr/qrtr.c +++ b/net/qrtr/qrtr.c | |||
@@ -658,7 +658,9 @@ static int qrtr_sendmsg(struct socket *sock, struct msghdr *msg, size_t len) | |||
658 | } | 658 | } |
659 | 659 | ||
660 | if (plen != len) { | 660 | if (plen != len) { |
661 | skb_pad(skb, plen - len); | 661 | rc = skb_pad(skb, plen - len); |
662 | if (rc) | ||
663 | goto out_node; | ||
662 | skb_put(skb, plen - len); | 664 | skb_put(skb, plen - len); |
663 | } | 665 | } |
664 | 666 | ||
diff --git a/net/sched/act_api.c b/net/sched/act_api.c index b70aa57319ea..e05b924618a0 100644 --- a/net/sched/act_api.c +++ b/net/sched/act_api.c | |||
@@ -529,20 +529,20 @@ errout: | |||
529 | return err; | 529 | return err; |
530 | } | 530 | } |
531 | 531 | ||
532 | static int nla_memdup_cookie(struct tc_action *a, struct nlattr **tb) | 532 | static struct tc_cookie *nla_memdup_cookie(struct nlattr **tb) |
533 | { | 533 | { |
534 | a->act_cookie = kzalloc(sizeof(*a->act_cookie), GFP_KERNEL); | 534 | struct tc_cookie *c = kzalloc(sizeof(*c), GFP_KERNEL); |
535 | if (!a->act_cookie) | 535 | if (!c) |
536 | return -ENOMEM; | 536 | return NULL; |
537 | 537 | ||
538 | a->act_cookie->data = nla_memdup(tb[TCA_ACT_COOKIE], GFP_KERNEL); | 538 | c->data = nla_memdup(tb[TCA_ACT_COOKIE], GFP_KERNEL); |
539 | if (!a->act_cookie->data) { | 539 | if (!c->data) { |
540 | kfree(a->act_cookie); | 540 | kfree(c); |
541 | return -ENOMEM; | 541 | return NULL; |
542 | } | 542 | } |
543 | a->act_cookie->len = nla_len(tb[TCA_ACT_COOKIE]); | 543 | c->len = nla_len(tb[TCA_ACT_COOKIE]); |
544 | 544 | ||
545 | return 0; | 545 | return c; |
546 | } | 546 | } |
547 | 547 | ||
548 | struct tc_action *tcf_action_init_1(struct net *net, struct nlattr *nla, | 548 | struct tc_action *tcf_action_init_1(struct net *net, struct nlattr *nla, |
@@ -551,6 +551,7 @@ struct tc_action *tcf_action_init_1(struct net *net, struct nlattr *nla, | |||
551 | { | 551 | { |
552 | struct tc_action *a; | 552 | struct tc_action *a; |
553 | struct tc_action_ops *a_o; | 553 | struct tc_action_ops *a_o; |
554 | struct tc_cookie *cookie = NULL; | ||
554 | char act_name[IFNAMSIZ]; | 555 | char act_name[IFNAMSIZ]; |
555 | struct nlattr *tb[TCA_ACT_MAX + 1]; | 556 | struct nlattr *tb[TCA_ACT_MAX + 1]; |
556 | struct nlattr *kind; | 557 | struct nlattr *kind; |
@@ -566,6 +567,18 @@ struct tc_action *tcf_action_init_1(struct net *net, struct nlattr *nla, | |||
566 | goto err_out; | 567 | goto err_out; |
567 | if (nla_strlcpy(act_name, kind, IFNAMSIZ) >= IFNAMSIZ) | 568 | if (nla_strlcpy(act_name, kind, IFNAMSIZ) >= IFNAMSIZ) |
568 | goto err_out; | 569 | goto err_out; |
570 | if (tb[TCA_ACT_COOKIE]) { | ||
571 | int cklen = nla_len(tb[TCA_ACT_COOKIE]); | ||
572 | |||
573 | if (cklen > TC_COOKIE_MAX_SIZE) | ||
574 | goto err_out; | ||
575 | |||
576 | cookie = nla_memdup_cookie(tb); | ||
577 | if (!cookie) { | ||
578 | err = -ENOMEM; | ||
579 | goto err_out; | ||
580 | } | ||
581 | } | ||
569 | } else { | 582 | } else { |
570 | err = -EINVAL; | 583 | err = -EINVAL; |
571 | if (strlcpy(act_name, name, IFNAMSIZ) >= IFNAMSIZ) | 584 | if (strlcpy(act_name, name, IFNAMSIZ) >= IFNAMSIZ) |
@@ -604,20 +617,12 @@ struct tc_action *tcf_action_init_1(struct net *net, struct nlattr *nla, | |||
604 | if (err < 0) | 617 | if (err < 0) |
605 | goto err_mod; | 618 | goto err_mod; |
606 | 619 | ||
607 | if (tb[TCA_ACT_COOKIE]) { | 620 | if (name == NULL && tb[TCA_ACT_COOKIE]) { |
608 | int cklen = nla_len(tb[TCA_ACT_COOKIE]); | 621 | if (a->act_cookie) { |
609 | 622 | kfree(a->act_cookie->data); | |
610 | if (cklen > TC_COOKIE_MAX_SIZE) { | 623 | kfree(a->act_cookie); |
611 | err = -EINVAL; | ||
612 | tcf_hash_release(a, bind); | ||
613 | goto err_mod; | ||
614 | } | ||
615 | |||
616 | if (nla_memdup_cookie(a, tb) < 0) { | ||
617 | err = -ENOMEM; | ||
618 | tcf_hash_release(a, bind); | ||
619 | goto err_mod; | ||
620 | } | 624 | } |
625 | a->act_cookie = cookie; | ||
621 | } | 626 | } |
622 | 627 | ||
623 | /* module count goes up only when brand new policy is created | 628 | /* module count goes up only when brand new policy is created |
@@ -632,6 +637,10 @@ struct tc_action *tcf_action_init_1(struct net *net, struct nlattr *nla, | |||
632 | err_mod: | 637 | err_mod: |
633 | module_put(a_o->owner); | 638 | module_put(a_o->owner); |
634 | err_out: | 639 | err_out: |
640 | if (cookie) { | ||
641 | kfree(cookie->data); | ||
642 | kfree(cookie); | ||
643 | } | ||
635 | return ERR_PTR(err); | 644 | return ERR_PTR(err); |
636 | } | 645 | } |
637 | 646 | ||
diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c index b052b27a984e..1a2f9e964330 100644 --- a/net/sched/sch_generic.c +++ b/net/sched/sch_generic.c | |||
@@ -794,7 +794,7 @@ static void attach_default_qdiscs(struct net_device *dev) | |||
794 | } | 794 | } |
795 | } | 795 | } |
796 | #ifdef CONFIG_NET_SCHED | 796 | #ifdef CONFIG_NET_SCHED |
797 | if (dev->qdisc) | 797 | if (dev->qdisc != &noop_qdisc) |
798 | qdisc_hash_add(dev->qdisc); | 798 | qdisc_hash_add(dev->qdisc); |
799 | #endif | 799 | #endif |
800 | } | 800 | } |
diff --git a/net/sctp/associola.c b/net/sctp/associola.c index 0439a1a68367..a9708da28eb5 100644 --- a/net/sctp/associola.c +++ b/net/sctp/associola.c | |||
@@ -246,6 +246,9 @@ static struct sctp_association *sctp_association_init(struct sctp_association *a | |||
246 | if (!sctp_ulpq_init(&asoc->ulpq, asoc)) | 246 | if (!sctp_ulpq_init(&asoc->ulpq, asoc)) |
247 | goto fail_init; | 247 | goto fail_init; |
248 | 248 | ||
249 | if (sctp_stream_new(asoc, gfp)) | ||
250 | goto fail_init; | ||
251 | |||
249 | /* Assume that peer would support both address types unless we are | 252 | /* Assume that peer would support both address types unless we are |
250 | * told otherwise. | 253 | * told otherwise. |
251 | */ | 254 | */ |
@@ -264,7 +267,7 @@ static struct sctp_association *sctp_association_init(struct sctp_association *a | |||
264 | /* AUTH related initializations */ | 267 | /* AUTH related initializations */ |
265 | INIT_LIST_HEAD(&asoc->endpoint_shared_keys); | 268 | INIT_LIST_HEAD(&asoc->endpoint_shared_keys); |
266 | if (sctp_auth_asoc_copy_shkeys(ep, asoc, gfp)) | 269 | if (sctp_auth_asoc_copy_shkeys(ep, asoc, gfp)) |
267 | goto fail_init; | 270 | goto stream_free; |
268 | 271 | ||
269 | asoc->active_key_id = ep->active_key_id; | 272 | asoc->active_key_id = ep->active_key_id; |
270 | asoc->prsctp_enable = ep->prsctp_enable; | 273 | asoc->prsctp_enable = ep->prsctp_enable; |
@@ -287,6 +290,8 @@ static struct sctp_association *sctp_association_init(struct sctp_association *a | |||
287 | 290 | ||
288 | return asoc; | 291 | return asoc; |
289 | 292 | ||
293 | stream_free: | ||
294 | sctp_stream_free(asoc->stream); | ||
290 | fail_init: | 295 | fail_init: |
291 | sock_put(asoc->base.sk); | 296 | sock_put(asoc->base.sk); |
292 | sctp_endpoint_put(asoc->ep); | 297 | sctp_endpoint_put(asoc->ep); |
@@ -1407,7 +1412,7 @@ sctp_assoc_choose_alter_transport(struct sctp_association *asoc, | |||
1407 | /* Update the association's pmtu and frag_point by going through all the | 1412 | /* Update the association's pmtu and frag_point by going through all the |
1408 | * transports. This routine is called when a transport's PMTU has changed. | 1413 | * transports. This routine is called when a transport's PMTU has changed. |
1409 | */ | 1414 | */ |
1410 | void sctp_assoc_sync_pmtu(struct sock *sk, struct sctp_association *asoc) | 1415 | void sctp_assoc_sync_pmtu(struct sctp_association *asoc) |
1411 | { | 1416 | { |
1412 | struct sctp_transport *t; | 1417 | struct sctp_transport *t; |
1413 | __u32 pmtu = 0; | 1418 | __u32 pmtu = 0; |
@@ -1419,8 +1424,8 @@ void sctp_assoc_sync_pmtu(struct sock *sk, struct sctp_association *asoc) | |||
1419 | list_for_each_entry(t, &asoc->peer.transport_addr_list, | 1424 | list_for_each_entry(t, &asoc->peer.transport_addr_list, |
1420 | transports) { | 1425 | transports) { |
1421 | if (t->pmtu_pending && t->dst) { | 1426 | if (t->pmtu_pending && t->dst) { |
1422 | sctp_transport_update_pmtu(sk, t, | 1427 | sctp_transport_update_pmtu( |
1423 | SCTP_TRUNC4(dst_mtu(t->dst))); | 1428 | t, SCTP_TRUNC4(dst_mtu(t->dst))); |
1424 | t->pmtu_pending = 0; | 1429 | t->pmtu_pending = 0; |
1425 | } | 1430 | } |
1426 | if (!pmtu || (t->pathmtu < pmtu)) | 1431 | if (!pmtu || (t->pathmtu < pmtu)) |
diff --git a/net/sctp/input.c b/net/sctp/input.c index 2a28ab20487f..0e06a278d2a9 100644 --- a/net/sctp/input.c +++ b/net/sctp/input.c | |||
@@ -401,10 +401,10 @@ void sctp_icmp_frag_needed(struct sock *sk, struct sctp_association *asoc, | |||
401 | 401 | ||
402 | if (t->param_flags & SPP_PMTUD_ENABLE) { | 402 | if (t->param_flags & SPP_PMTUD_ENABLE) { |
403 | /* Update transports view of the MTU */ | 403 | /* Update transports view of the MTU */ |
404 | sctp_transport_update_pmtu(sk, t, pmtu); | 404 | sctp_transport_update_pmtu(t, pmtu); |
405 | 405 | ||
406 | /* Update association pmtu. */ | 406 | /* Update association pmtu. */ |
407 | sctp_assoc_sync_pmtu(sk, asoc); | 407 | sctp_assoc_sync_pmtu(asoc); |
408 | } | 408 | } |
409 | 409 | ||
410 | /* Retransmit with the new pmtu setting. | 410 | /* Retransmit with the new pmtu setting. |
diff --git a/net/sctp/output.c b/net/sctp/output.c index 1224421036b3..1409a875ad8e 100644 --- a/net/sctp/output.c +++ b/net/sctp/output.c | |||
@@ -86,43 +86,53 @@ void sctp_packet_config(struct sctp_packet *packet, __u32 vtag, | |||
86 | { | 86 | { |
87 | struct sctp_transport *tp = packet->transport; | 87 | struct sctp_transport *tp = packet->transport; |
88 | struct sctp_association *asoc = tp->asoc; | 88 | struct sctp_association *asoc = tp->asoc; |
89 | struct sock *sk; | ||
89 | 90 | ||
90 | pr_debug("%s: packet:%p vtag:0x%x\n", __func__, packet, vtag); | 91 | pr_debug("%s: packet:%p vtag:0x%x\n", __func__, packet, vtag); |
91 | |||
92 | packet->vtag = vtag; | 92 | packet->vtag = vtag; |
93 | 93 | ||
94 | if (asoc && tp->dst) { | 94 | /* do the following jobs only once for a flush schedule */ |
95 | struct sock *sk = asoc->base.sk; | 95 | if (!sctp_packet_empty(packet)) |
96 | 96 | return; | |
97 | rcu_read_lock(); | ||
98 | if (__sk_dst_get(sk) != tp->dst) { | ||
99 | dst_hold(tp->dst); | ||
100 | sk_setup_caps(sk, tp->dst); | ||
101 | } | ||
102 | |||
103 | if (sk_can_gso(sk)) { | ||
104 | struct net_device *dev = tp->dst->dev; | ||
105 | 97 | ||
106 | packet->max_size = dev->gso_max_size; | 98 | /* set packet max_size with pathmtu */ |
107 | } else { | 99 | packet->max_size = tp->pathmtu; |
108 | packet->max_size = asoc->pathmtu; | 100 | if (!asoc) |
109 | } | 101 | return; |
110 | rcu_read_unlock(); | ||
111 | 102 | ||
112 | } else { | 103 | /* update dst or transport pathmtu if in need */ |
113 | packet->max_size = tp->pathmtu; | 104 | sk = asoc->base.sk; |
105 | if (!sctp_transport_dst_check(tp)) { | ||
106 | sctp_transport_route(tp, NULL, sctp_sk(sk)); | ||
107 | if (asoc->param_flags & SPP_PMTUD_ENABLE) | ||
108 | sctp_assoc_sync_pmtu(asoc); | ||
109 | } else if (!sctp_transport_pmtu_check(tp)) { | ||
110 | if (asoc->param_flags & SPP_PMTUD_ENABLE) | ||
111 | sctp_assoc_sync_pmtu(asoc); | ||
114 | } | 112 | } |
115 | 113 | ||
116 | if (ecn_capable && sctp_packet_empty(packet)) { | 114 | /* If there a is a prepend chunk stick it on the list before |
117 | struct sctp_chunk *chunk; | 115 | * any other chunks get appended. |
116 | */ | ||
117 | if (ecn_capable) { | ||
118 | struct sctp_chunk *chunk = sctp_get_ecne_prepend(asoc); | ||
118 | 119 | ||
119 | /* If there a is a prepend chunk stick it on the list before | ||
120 | * any other chunks get appended. | ||
121 | */ | ||
122 | chunk = sctp_get_ecne_prepend(asoc); | ||
123 | if (chunk) | 120 | if (chunk) |
124 | sctp_packet_append_chunk(packet, chunk); | 121 | sctp_packet_append_chunk(packet, chunk); |
125 | } | 122 | } |
123 | |||
124 | if (!tp->dst) | ||
125 | return; | ||
126 | |||
127 | /* set packet max_size with gso_max_size if gso is enabled*/ | ||
128 | rcu_read_lock(); | ||
129 | if (__sk_dst_get(sk) != tp->dst) { | ||
130 | dst_hold(tp->dst); | ||
131 | sk_setup_caps(sk, tp->dst); | ||
132 | } | ||
133 | packet->max_size = sk_can_gso(sk) ? tp->dst->dev->gso_max_size | ||
134 | : asoc->pathmtu; | ||
135 | rcu_read_unlock(); | ||
126 | } | 136 | } |
127 | 137 | ||
128 | /* Initialize the packet structure. */ | 138 | /* Initialize the packet structure. */ |
@@ -582,12 +592,7 @@ int sctp_packet_transmit(struct sctp_packet *packet, gfp_t gfp) | |||
582 | sh->vtag = htonl(packet->vtag); | 592 | sh->vtag = htonl(packet->vtag); |
583 | sh->checksum = 0; | 593 | sh->checksum = 0; |
584 | 594 | ||
585 | /* update dst if in need */ | 595 | /* drop packet if no dst */ |
586 | if (!sctp_transport_dst_check(tp)) { | ||
587 | sctp_transport_route(tp, NULL, sctp_sk(sk)); | ||
588 | if (asoc && asoc->param_flags & SPP_PMTUD_ENABLE) | ||
589 | sctp_assoc_sync_pmtu(sk, asoc); | ||
590 | } | ||
591 | dst = dst_clone(tp->dst); | 596 | dst = dst_clone(tp->dst); |
592 | if (!dst) { | 597 | if (!dst) { |
593 | IP_INC_STATS(sock_net(sk), IPSTATS_MIB_OUTNOROUTES); | 598 | IP_INC_STATS(sock_net(sk), IPSTATS_MIB_OUTNOROUTES); |
@@ -704,7 +709,7 @@ static sctp_xmit_t sctp_packet_can_append_data(struct sctp_packet *packet, | |||
704 | */ | 709 | */ |
705 | 710 | ||
706 | if ((sctp_sk(asoc->base.sk)->nodelay || inflight == 0) && | 711 | if ((sctp_sk(asoc->base.sk)->nodelay || inflight == 0) && |
707 | !chunk->msg->force_delay) | 712 | !asoc->force_delay) |
708 | /* Nothing unacked */ | 713 | /* Nothing unacked */ |
709 | return SCTP_XMIT_OK; | 714 | return SCTP_XMIT_OK; |
710 | 715 | ||
diff --git a/net/sctp/outqueue.c b/net/sctp/outqueue.c index 025ccff67072..8081476ed313 100644 --- a/net/sctp/outqueue.c +++ b/net/sctp/outqueue.c | |||
@@ -1026,8 +1026,7 @@ static void sctp_outq_flush(struct sctp_outq *q, int rtx_timeout, gfp_t gfp) | |||
1026 | /* RFC 2960 6.5 Every DATA chunk MUST carry a valid | 1026 | /* RFC 2960 6.5 Every DATA chunk MUST carry a valid |
1027 | * stream identifier. | 1027 | * stream identifier. |
1028 | */ | 1028 | */ |
1029 | if (chunk->sinfo.sinfo_stream >= | 1029 | if (chunk->sinfo.sinfo_stream >= asoc->stream->outcnt) { |
1030 | asoc->c.sinit_num_ostreams) { | ||
1031 | 1030 | ||
1032 | /* Mark as failed send. */ | 1031 | /* Mark as failed send. */ |
1033 | sctp_chunk_fail(chunk, SCTP_ERROR_INV_STRM); | 1032 | sctp_chunk_fail(chunk, SCTP_ERROR_INV_STRM); |
diff --git a/net/sctp/proc.c b/net/sctp/proc.c index 206377fe91ec..a0b29d43627f 100644 --- a/net/sctp/proc.c +++ b/net/sctp/proc.c | |||
@@ -361,8 +361,8 @@ static int sctp_assocs_seq_show(struct seq_file *seq, void *v) | |||
361 | sctp_seq_dump_remote_addrs(seq, assoc); | 361 | sctp_seq_dump_remote_addrs(seq, assoc); |
362 | seq_printf(seq, "\t%8lu %5d %5d %4d %4d %4d %8d " | 362 | seq_printf(seq, "\t%8lu %5d %5d %4d %4d %4d %8d " |
363 | "%8d %8d %8d %8d", | 363 | "%8d %8d %8d %8d", |
364 | assoc->hbinterval, assoc->c.sinit_max_instreams, | 364 | assoc->hbinterval, assoc->stream->incnt, |
365 | assoc->c.sinit_num_ostreams, assoc->max_retrans, | 365 | assoc->stream->outcnt, assoc->max_retrans, |
366 | assoc->init_retries, assoc->shutdown_retries, | 366 | assoc->init_retries, assoc->shutdown_retries, |
367 | assoc->rtx_data_chunks, | 367 | assoc->rtx_data_chunks, |
368 | atomic_read(&sk->sk_wmem_alloc), | 368 | atomic_read(&sk->sk_wmem_alloc), |
diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c index 969a30c7bb54..118faff6a332 100644 --- a/net/sctp/sm_make_chunk.c +++ b/net/sctp/sm_make_chunk.c | |||
@@ -2460,15 +2460,10 @@ int sctp_process_init(struct sctp_association *asoc, struct sctp_chunk *chunk, | |||
2460 | * association. | 2460 | * association. |
2461 | */ | 2461 | */ |
2462 | if (!asoc->temp) { | 2462 | if (!asoc->temp) { |
2463 | int error; | 2463 | if (sctp_stream_init(asoc, gfp)) |
2464 | |||
2465 | asoc->stream = sctp_stream_new(asoc->c.sinit_max_instreams, | ||
2466 | asoc->c.sinit_num_ostreams, gfp); | ||
2467 | if (!asoc->stream) | ||
2468 | goto clean_up; | 2464 | goto clean_up; |
2469 | 2465 | ||
2470 | error = sctp_assoc_set_id(asoc, gfp); | 2466 | if (sctp_assoc_set_id(asoc, gfp)) |
2471 | if (error) | ||
2472 | goto clean_up; | 2467 | goto clean_up; |
2473 | } | 2468 | } |
2474 | 2469 | ||
diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c index e03bb1aab4d0..24c6ccce7539 100644 --- a/net/sctp/sm_statefuns.c +++ b/net/sctp/sm_statefuns.c | |||
@@ -3946,7 +3946,7 @@ sctp_disposition_t sctp_sf_eat_fwd_tsn(struct net *net, | |||
3946 | 3946 | ||
3947 | /* Silently discard the chunk if stream-id is not valid */ | 3947 | /* Silently discard the chunk if stream-id is not valid */ |
3948 | sctp_walk_fwdtsn(skip, chunk) { | 3948 | sctp_walk_fwdtsn(skip, chunk) { |
3949 | if (ntohs(skip->stream) >= asoc->c.sinit_max_instreams) | 3949 | if (ntohs(skip->stream) >= asoc->stream->incnt) |
3950 | goto discard_noforce; | 3950 | goto discard_noforce; |
3951 | } | 3951 | } |
3952 | 3952 | ||
@@ -4017,7 +4017,7 @@ sctp_disposition_t sctp_sf_eat_fwd_tsn_fast( | |||
4017 | 4017 | ||
4018 | /* Silently discard the chunk if stream-id is not valid */ | 4018 | /* Silently discard the chunk if stream-id is not valid */ |
4019 | sctp_walk_fwdtsn(skip, chunk) { | 4019 | sctp_walk_fwdtsn(skip, chunk) { |
4020 | if (ntohs(skip->stream) >= asoc->c.sinit_max_instreams) | 4020 | if (ntohs(skip->stream) >= asoc->stream->incnt) |
4021 | goto gen_shutdown; | 4021 | goto gen_shutdown; |
4022 | } | 4022 | } |
4023 | 4023 | ||
@@ -6353,7 +6353,7 @@ static int sctp_eat_data(const struct sctp_association *asoc, | |||
6353 | * and discard the DATA chunk. | 6353 | * and discard the DATA chunk. |
6354 | */ | 6354 | */ |
6355 | sid = ntohs(data_hdr->stream); | 6355 | sid = ntohs(data_hdr->stream); |
6356 | if (sid >= asoc->c.sinit_max_instreams) { | 6356 | if (sid >= asoc->stream->incnt) { |
6357 | /* Mark tsn as received even though we drop it */ | 6357 | /* Mark tsn as received even though we drop it */ |
6358 | sctp_add_cmd_sf(commands, SCTP_CMD_REPORT_TSN, SCTP_U32(tsn)); | 6358 | sctp_add_cmd_sf(commands, SCTP_CMD_REPORT_TSN, SCTP_U32(tsn)); |
6359 | 6359 | ||
diff --git a/net/sctp/socket.c b/net/sctp/socket.c index 0f378ea2ae38..d9d4c92e06b3 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c | |||
@@ -1907,7 +1907,7 @@ static int sctp_sendmsg(struct sock *sk, struct msghdr *msg, size_t msg_len) | |||
1907 | } | 1907 | } |
1908 | 1908 | ||
1909 | if (asoc->pmtu_pending) | 1909 | if (asoc->pmtu_pending) |
1910 | sctp_assoc_pending_pmtu(sk, asoc); | 1910 | sctp_assoc_pending_pmtu(asoc); |
1911 | 1911 | ||
1912 | /* If fragmentation is disabled and the message length exceeds the | 1912 | /* If fragmentation is disabled and the message length exceeds the |
1913 | * association fragmentation point, return EMSGSIZE. The I-D | 1913 | * association fragmentation point, return EMSGSIZE. The I-D |
@@ -1920,7 +1920,7 @@ static int sctp_sendmsg(struct sock *sk, struct msghdr *msg, size_t msg_len) | |||
1920 | } | 1920 | } |
1921 | 1921 | ||
1922 | /* Check for invalid stream. */ | 1922 | /* Check for invalid stream. */ |
1923 | if (sinfo->sinfo_stream >= asoc->c.sinit_num_ostreams) { | 1923 | if (sinfo->sinfo_stream >= asoc->stream->outcnt) { |
1924 | err = -EINVAL; | 1924 | err = -EINVAL; |
1925 | goto out_free; | 1925 | goto out_free; |
1926 | } | 1926 | } |
@@ -1965,7 +1965,7 @@ static int sctp_sendmsg(struct sock *sk, struct msghdr *msg, size_t msg_len) | |||
1965 | err = PTR_ERR(datamsg); | 1965 | err = PTR_ERR(datamsg); |
1966 | goto out_free; | 1966 | goto out_free; |
1967 | } | 1967 | } |
1968 | datamsg->force_delay = !!(msg->msg_flags & MSG_MORE); | 1968 | asoc->force_delay = !!(msg->msg_flags & MSG_MORE); |
1969 | 1969 | ||
1970 | /* Now send the (possibly) fragmented message. */ | 1970 | /* Now send the (possibly) fragmented message. */ |
1971 | list_for_each_entry(chunk, &datamsg->chunks, frag_list) { | 1971 | list_for_each_entry(chunk, &datamsg->chunks, frag_list) { |
@@ -2435,7 +2435,7 @@ static int sctp_apply_peer_addr_params(struct sctp_paddrparams *params, | |||
2435 | if ((params->spp_flags & SPP_PMTUD_DISABLE) && params->spp_pathmtu) { | 2435 | if ((params->spp_flags & SPP_PMTUD_DISABLE) && params->spp_pathmtu) { |
2436 | if (trans) { | 2436 | if (trans) { |
2437 | trans->pathmtu = params->spp_pathmtu; | 2437 | trans->pathmtu = params->spp_pathmtu; |
2438 | sctp_assoc_sync_pmtu(sctp_opt2sk(sp), asoc); | 2438 | sctp_assoc_sync_pmtu(asoc); |
2439 | } else if (asoc) { | 2439 | } else if (asoc) { |
2440 | asoc->pathmtu = params->spp_pathmtu; | 2440 | asoc->pathmtu = params->spp_pathmtu; |
2441 | } else { | 2441 | } else { |
@@ -2451,7 +2451,7 @@ static int sctp_apply_peer_addr_params(struct sctp_paddrparams *params, | |||
2451 | (trans->param_flags & ~SPP_PMTUD) | pmtud_change; | 2451 | (trans->param_flags & ~SPP_PMTUD) | pmtud_change; |
2452 | if (update) { | 2452 | if (update) { |
2453 | sctp_transport_pmtu(trans, sctp_opt2sk(sp)); | 2453 | sctp_transport_pmtu(trans, sctp_opt2sk(sp)); |
2454 | sctp_assoc_sync_pmtu(sctp_opt2sk(sp), asoc); | 2454 | sctp_assoc_sync_pmtu(asoc); |
2455 | } | 2455 | } |
2456 | } else if (asoc) { | 2456 | } else if (asoc) { |
2457 | asoc->param_flags = | 2457 | asoc->param_flags = |
@@ -4461,8 +4461,8 @@ int sctp_get_sctp_info(struct sock *sk, struct sctp_association *asoc, | |||
4461 | info->sctpi_rwnd = asoc->a_rwnd; | 4461 | info->sctpi_rwnd = asoc->a_rwnd; |
4462 | info->sctpi_unackdata = asoc->unack_data; | 4462 | info->sctpi_unackdata = asoc->unack_data; |
4463 | info->sctpi_penddata = sctp_tsnmap_pending(&asoc->peer.tsn_map); | 4463 | info->sctpi_penddata = sctp_tsnmap_pending(&asoc->peer.tsn_map); |
4464 | info->sctpi_instrms = asoc->c.sinit_max_instreams; | 4464 | info->sctpi_instrms = asoc->stream->incnt; |
4465 | info->sctpi_outstrms = asoc->c.sinit_num_ostreams; | 4465 | info->sctpi_outstrms = asoc->stream->outcnt; |
4466 | list_for_each(pos, &asoc->base.inqueue.in_chunk_list) | 4466 | list_for_each(pos, &asoc->base.inqueue.in_chunk_list) |
4467 | info->sctpi_inqueue++; | 4467 | info->sctpi_inqueue++; |
4468 | list_for_each(pos, &asoc->outqueue.out_chunk_list) | 4468 | list_for_each(pos, &asoc->outqueue.out_chunk_list) |
@@ -4691,8 +4691,8 @@ static int sctp_getsockopt_sctp_status(struct sock *sk, int len, | |||
4691 | status.sstat_unackdata = asoc->unack_data; | 4691 | status.sstat_unackdata = asoc->unack_data; |
4692 | 4692 | ||
4693 | status.sstat_penddata = sctp_tsnmap_pending(&asoc->peer.tsn_map); | 4693 | status.sstat_penddata = sctp_tsnmap_pending(&asoc->peer.tsn_map); |
4694 | status.sstat_instrms = asoc->c.sinit_max_instreams; | 4694 | status.sstat_instrms = asoc->stream->incnt; |
4695 | status.sstat_outstrms = asoc->c.sinit_num_ostreams; | 4695 | status.sstat_outstrms = asoc->stream->outcnt; |
4696 | status.sstat_fragmentation_point = asoc->frag_point; | 4696 | status.sstat_fragmentation_point = asoc->frag_point; |
4697 | status.sstat_primary.spinfo_assoc_id = sctp_assoc2id(transport->asoc); | 4697 | status.sstat_primary.spinfo_assoc_id = sctp_assoc2id(transport->asoc); |
4698 | memcpy(&status.sstat_primary.spinfo_address, &transport->ipaddr, | 4698 | memcpy(&status.sstat_primary.spinfo_address, &transport->ipaddr, |
@@ -7034,6 +7034,9 @@ int sctp_inet_listen(struct socket *sock, int backlog) | |||
7034 | if (sock->state != SS_UNCONNECTED) | 7034 | if (sock->state != SS_UNCONNECTED) |
7035 | goto out; | 7035 | goto out; |
7036 | 7036 | ||
7037 | if (!sctp_sstate(sk, LISTENING) && !sctp_sstate(sk, CLOSED)) | ||
7038 | goto out; | ||
7039 | |||
7037 | /* If backlog is zero, disable listening. */ | 7040 | /* If backlog is zero, disable listening. */ |
7038 | if (!backlog) { | 7041 | if (!backlog) { |
7039 | if (sctp_sstate(sk, CLOSED)) | 7042 | if (sctp_sstate(sk, CLOSED)) |
diff --git a/net/sctp/stream.c b/net/sctp/stream.c index 1c6cc04fa3a4..bbed997e1c5f 100644 --- a/net/sctp/stream.c +++ b/net/sctp/stream.c | |||
@@ -35,33 +35,60 @@ | |||
35 | #include <net/sctp/sctp.h> | 35 | #include <net/sctp/sctp.h> |
36 | #include <net/sctp/sm.h> | 36 | #include <net/sctp/sm.h> |
37 | 37 | ||
38 | struct sctp_stream *sctp_stream_new(__u16 incnt, __u16 outcnt, gfp_t gfp) | 38 | int sctp_stream_new(struct sctp_association *asoc, gfp_t gfp) |
39 | { | 39 | { |
40 | struct sctp_stream *stream; | 40 | struct sctp_stream *stream; |
41 | int i; | 41 | int i; |
42 | 42 | ||
43 | stream = kzalloc(sizeof(*stream), gfp); | 43 | stream = kzalloc(sizeof(*stream), gfp); |
44 | if (!stream) | 44 | if (!stream) |
45 | return NULL; | 45 | return -ENOMEM; |
46 | 46 | ||
47 | stream->outcnt = outcnt; | 47 | stream->outcnt = asoc->c.sinit_num_ostreams; |
48 | stream->out = kcalloc(stream->outcnt, sizeof(*stream->out), gfp); | 48 | stream->out = kcalloc(stream->outcnt, sizeof(*stream->out), gfp); |
49 | if (!stream->out) { | 49 | if (!stream->out) { |
50 | kfree(stream); | 50 | kfree(stream); |
51 | return NULL; | 51 | return -ENOMEM; |
52 | } | 52 | } |
53 | for (i = 0; i < stream->outcnt; i++) | 53 | for (i = 0; i < stream->outcnt; i++) |
54 | stream->out[i].state = SCTP_STREAM_OPEN; | 54 | stream->out[i].state = SCTP_STREAM_OPEN; |
55 | 55 | ||
56 | stream->incnt = incnt; | 56 | asoc->stream = stream; |
57 | |||
58 | return 0; | ||
59 | } | ||
60 | |||
61 | int sctp_stream_init(struct sctp_association *asoc, gfp_t gfp) | ||
62 | { | ||
63 | struct sctp_stream *stream = asoc->stream; | ||
64 | int i; | ||
65 | |||
66 | /* Initial stream->out size may be very big, so free it and alloc | ||
67 | * a new one with new outcnt to save memory. | ||
68 | */ | ||
69 | kfree(stream->out); | ||
70 | stream->outcnt = asoc->c.sinit_num_ostreams; | ||
71 | stream->out = kcalloc(stream->outcnt, sizeof(*stream->out), gfp); | ||
72 | if (!stream->out) | ||
73 | goto nomem; | ||
74 | |||
75 | for (i = 0; i < stream->outcnt; i++) | ||
76 | stream->out[i].state = SCTP_STREAM_OPEN; | ||
77 | |||
78 | stream->incnt = asoc->c.sinit_max_instreams; | ||
57 | stream->in = kcalloc(stream->incnt, sizeof(*stream->in), gfp); | 79 | stream->in = kcalloc(stream->incnt, sizeof(*stream->in), gfp); |
58 | if (!stream->in) { | 80 | if (!stream->in) { |
59 | kfree(stream->out); | 81 | kfree(stream->out); |
60 | kfree(stream); | 82 | goto nomem; |
61 | return NULL; | ||
62 | } | 83 | } |
63 | 84 | ||
64 | return stream; | 85 | return 0; |
86 | |||
87 | nomem: | ||
88 | asoc->stream = NULL; | ||
89 | kfree(stream); | ||
90 | |||
91 | return -ENOMEM; | ||
65 | } | 92 | } |
66 | 93 | ||
67 | void sctp_stream_free(struct sctp_stream *stream) | 94 | void sctp_stream_free(struct sctp_stream *stream) |
diff --git a/net/sctp/transport.c b/net/sctp/transport.c index 3379668af368..721eeebfcd8a 100644 --- a/net/sctp/transport.c +++ b/net/sctp/transport.c | |||
@@ -251,14 +251,13 @@ void sctp_transport_pmtu(struct sctp_transport *transport, struct sock *sk) | |||
251 | transport->pathmtu = SCTP_DEFAULT_MAXSEGMENT; | 251 | transport->pathmtu = SCTP_DEFAULT_MAXSEGMENT; |
252 | } | 252 | } |
253 | 253 | ||
254 | void sctp_transport_update_pmtu(struct sock *sk, struct sctp_transport *t, u32 pmtu) | 254 | void sctp_transport_update_pmtu(struct sctp_transport *t, u32 pmtu) |
255 | { | 255 | { |
256 | struct dst_entry *dst; | 256 | struct dst_entry *dst = sctp_transport_dst_check(t); |
257 | 257 | ||
258 | if (unlikely(pmtu < SCTP_DEFAULT_MINSEGMENT)) { | 258 | if (unlikely(pmtu < SCTP_DEFAULT_MINSEGMENT)) { |
259 | pr_warn("%s: Reported pmtu %d too low, using default minimum of %d\n", | 259 | pr_warn("%s: Reported pmtu %d too low, using default minimum of %d\n", |
260 | __func__, pmtu, | 260 | __func__, pmtu, SCTP_DEFAULT_MINSEGMENT); |
261 | SCTP_DEFAULT_MINSEGMENT); | ||
262 | /* Use default minimum segment size and disable | 261 | /* Use default minimum segment size and disable |
263 | * pmtu discovery on this transport. | 262 | * pmtu discovery on this transport. |
264 | */ | 263 | */ |
@@ -267,17 +266,13 @@ void sctp_transport_update_pmtu(struct sock *sk, struct sctp_transport *t, u32 p | |||
267 | t->pathmtu = pmtu; | 266 | t->pathmtu = pmtu; |
268 | } | 267 | } |
269 | 268 | ||
270 | dst = sctp_transport_dst_check(t); | ||
271 | if (!dst) | ||
272 | t->af_specific->get_dst(t, &t->saddr, &t->fl, sk); | ||
273 | |||
274 | if (dst) { | 269 | if (dst) { |
275 | dst->ops->update_pmtu(dst, sk, NULL, pmtu); | 270 | dst->ops->update_pmtu(dst, t->asoc->base.sk, NULL, pmtu); |
276 | |||
277 | dst = sctp_transport_dst_check(t); | 271 | dst = sctp_transport_dst_check(t); |
278 | if (!dst) | ||
279 | t->af_specific->get_dst(t, &t->saddr, &t->fl, sk); | ||
280 | } | 272 | } |
273 | |||
274 | if (!dst) | ||
275 | t->af_specific->get_dst(t, &t->saddr, &t->fl, t->asoc->base.sk); | ||
281 | } | 276 | } |
282 | 277 | ||
283 | /* Caches the dst entry and source address for a transport's destination | 278 | /* Caches the dst entry and source address for a transport's destination |
diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c index 8931e33b6541..2b720fa35c4f 100644 --- a/net/sunrpc/svcsock.c +++ b/net/sunrpc/svcsock.c | |||
@@ -1635,6 +1635,7 @@ static struct svc_xprt *svc_bc_create_socket(struct svc_serv *serv, | |||
1635 | 1635 | ||
1636 | xprt = &svsk->sk_xprt; | 1636 | xprt = &svsk->sk_xprt; |
1637 | svc_xprt_init(net, &svc_tcp_bc_class, xprt, serv); | 1637 | svc_xprt_init(net, &svc_tcp_bc_class, xprt, serv); |
1638 | set_bit(XPT_CONG_CTRL, &svsk->sk_xprt.xpt_flags); | ||
1638 | 1639 | ||
1639 | serv->sv_bc_xprt = xprt; | 1640 | serv->sv_bc_xprt = xprt; |
1640 | 1641 | ||
diff --git a/net/sunrpc/xprtrdma/svc_rdma_transport.c b/net/sunrpc/xprtrdma/svc_rdma_transport.c index c13a5c35ce14..fc8f14c7bfec 100644 --- a/net/sunrpc/xprtrdma/svc_rdma_transport.c +++ b/net/sunrpc/xprtrdma/svc_rdma_transport.c | |||
@@ -127,6 +127,7 @@ static struct svc_xprt *svc_rdma_bc_create(struct svc_serv *serv, | |||
127 | xprt = &cma_xprt->sc_xprt; | 127 | xprt = &cma_xprt->sc_xprt; |
128 | 128 | ||
129 | svc_xprt_init(net, &svc_rdma_bc_class, xprt, serv); | 129 | svc_xprt_init(net, &svc_rdma_bc_class, xprt, serv); |
130 | set_bit(XPT_CONG_CTRL, &xprt->xpt_flags); | ||
130 | serv->sv_bc_xprt = xprt; | 131 | serv->sv_bc_xprt = xprt; |
131 | 132 | ||
132 | dprintk("svcrdma: %s(%p)\n", __func__, xprt); | 133 | dprintk("svcrdma: %s(%p)\n", __func__, xprt); |
diff --git a/net/wireless/sysfs.c b/net/wireless/sysfs.c index 16b6b5988be9..570a2b67ca10 100644 --- a/net/wireless/sysfs.c +++ b/net/wireless/sysfs.c | |||
@@ -132,12 +132,10 @@ static int wiphy_resume(struct device *dev) | |||
132 | /* Age scan results with time spent in suspend */ | 132 | /* Age scan results with time spent in suspend */ |
133 | cfg80211_bss_age(rdev, get_seconds() - rdev->suspend_at); | 133 | cfg80211_bss_age(rdev, get_seconds() - rdev->suspend_at); |
134 | 134 | ||
135 | if (rdev->ops->resume) { | 135 | rtnl_lock(); |
136 | rtnl_lock(); | 136 | if (rdev->wiphy.registered && rdev->ops->resume) |
137 | if (rdev->wiphy.registered) | 137 | ret = rdev_resume(rdev); |
138 | ret = rdev_resume(rdev); | 138 | rtnl_unlock(); |
139 | rtnl_unlock(); | ||
140 | } | ||
141 | 139 | ||
142 | return ret; | 140 | return ret; |
143 | } | 141 | } |
diff --git a/samples/statx/test-statx.c b/samples/statx/test-statx.c index 8571d766331d..d4d77b09412c 100644 --- a/samples/statx/test-statx.c +++ b/samples/statx/test-statx.c | |||
@@ -141,8 +141,8 @@ static void dump_statx(struct statx *stx) | |||
141 | if (stx->stx_mask & STATX_BTIME) | 141 | if (stx->stx_mask & STATX_BTIME) |
142 | print_time(" Birth: ", &stx->stx_btime); | 142 | print_time(" Birth: ", &stx->stx_btime); |
143 | 143 | ||
144 | if (stx->stx_attributes) { | 144 | if (stx->stx_attributes_mask) { |
145 | unsigned char bits; | 145 | unsigned char bits, mbits; |
146 | int loop, byte; | 146 | int loop, byte; |
147 | 147 | ||
148 | static char attr_representation[64 + 1] = | 148 | static char attr_representation[64 + 1] = |
@@ -160,14 +160,18 @@ static void dump_statx(struct statx *stx) | |||
160 | printf("Attributes: %016llx (", stx->stx_attributes); | 160 | printf("Attributes: %016llx (", stx->stx_attributes); |
161 | for (byte = 64 - 8; byte >= 0; byte -= 8) { | 161 | for (byte = 64 - 8; byte >= 0; byte -= 8) { |
162 | bits = stx->stx_attributes >> byte; | 162 | bits = stx->stx_attributes >> byte; |
163 | mbits = stx->stx_attributes_mask >> byte; | ||
163 | for (loop = 7; loop >= 0; loop--) { | 164 | for (loop = 7; loop >= 0; loop--) { |
164 | int bit = byte + loop; | 165 | int bit = byte + loop; |
165 | 166 | ||
166 | if (bits & 0x80) | 167 | if (!(mbits & 0x80)) |
168 | putchar('.'); /* Not supported */ | ||
169 | else if (bits & 0x80) | ||
167 | putchar(attr_representation[63 - bit]); | 170 | putchar(attr_representation[63 - bit]); |
168 | else | 171 | else |
169 | putchar('-'); | 172 | putchar('-'); /* Not set */ |
170 | bits <<= 1; | 173 | bits <<= 1; |
174 | mbits <<= 1; | ||
171 | } | 175 | } |
172 | if (byte) | 176 | if (byte) |
173 | putchar(' '); | 177 | putchar(' '); |
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index d6ca649cb0e9..afe3fd3af1e4 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include | |||
@@ -148,6 +148,10 @@ cc-fullversion = $(shell $(CONFIG_SHELL) \ | |||
148 | # Usage: EXTRA_CFLAGS += $(call cc-ifversion, -lt, 0402, -O1) | 148 | # Usage: EXTRA_CFLAGS += $(call cc-ifversion, -lt, 0402, -O1) |
149 | cc-ifversion = $(shell [ $(cc-version) $(1) $(2) ] && echo $(3) || echo $(4)) | 149 | cc-ifversion = $(shell [ $(cc-version) $(1) $(2) ] && echo $(3) || echo $(4)) |
150 | 150 | ||
151 | # cc-if-fullversion | ||
152 | # Usage: EXTRA_CFLAGS += $(call cc-if-fullversion, -lt, 040502, -O1) | ||
153 | cc-if-fullversion = $(shell [ $(cc-fullversion) $(1) $(2) ] && echo $(3) || echo $(4)) | ||
154 | |||
151 | # cc-ldoption | 155 | # cc-ldoption |
152 | # Usage: ldflags += $(call cc-ldoption, -Wl$(comma)--hash-style=both) | 156 | # Usage: ldflags += $(call cc-ldoption, -Wl$(comma)--hash-style=both) |
153 | cc-ldoption = $(call try-run,\ | 157 | cc-ldoption = $(call try-run,\ |
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 0a07f9014944..7234e61e7ce3 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib | |||
@@ -155,7 +155,7 @@ else | |||
155 | # $(call addtree,-I$(obj)) locates .h files in srctree, from generated .c files | 155 | # $(call addtree,-I$(obj)) locates .h files in srctree, from generated .c files |
156 | # and locates generated .h files | 156 | # and locates generated .h files |
157 | # FIXME: Replace both with specific CFLAGS* statements in the makefiles | 157 | # FIXME: Replace both with specific CFLAGS* statements in the makefiles |
158 | __c_flags = $(if $(obj),-I$(srctree)/$(src) -I$(obj)) \ | 158 | __c_flags = $(if $(obj),$(call addtree,-I$(src)) -I$(obj)) \ |
159 | $(call flags,_c_flags) | 159 | $(call flags,_c_flags) |
160 | __a_flags = $(call flags,_a_flags) | 160 | __a_flags = $(call flags,_a_flags) |
161 | __cpp_flags = $(call flags,_cpp_flags) | 161 | __cpp_flags = $(call flags,_cpp_flags) |
diff --git a/scripts/kconfig/gconf.c b/scripts/kconfig/gconf.c index 26d208b435a0..cfddddb9c9d7 100644 --- a/scripts/kconfig/gconf.c +++ b/scripts/kconfig/gconf.c | |||
@@ -914,7 +914,7 @@ on_treeview2_button_press_event(GtkWidget * widget, | |||
914 | current = menu; | 914 | current = menu; |
915 | display_tree_part(); | 915 | display_tree_part(); |
916 | gtk_widget_set_sensitive(back_btn, TRUE); | 916 | gtk_widget_set_sensitive(back_btn, TRUE); |
917 | } else if ((col == COL_OPTION)) { | 917 | } else if (col == COL_OPTION) { |
918 | toggle_sym_value(menu); | 918 | toggle_sym_value(menu); |
919 | gtk_tree_view_expand_row(view, path, TRUE); | 919 | gtk_tree_view_expand_row(view, path, TRUE); |
920 | } | 920 | } |
diff --git a/security/keys/gc.c b/security/keys/gc.c index addf060399e0..9cb4fe4478a1 100644 --- a/security/keys/gc.c +++ b/security/keys/gc.c | |||
@@ -46,7 +46,7 @@ static unsigned long key_gc_flags; | |||
46 | * immediately unlinked. | 46 | * immediately unlinked. |
47 | */ | 47 | */ |
48 | struct key_type key_type_dead = { | 48 | struct key_type key_type_dead = { |
49 | .name = "dead", | 49 | .name = ".dead", |
50 | }; | 50 | }; |
51 | 51 | ||
52 | /* | 52 | /* |
diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c index 52c34532c785..4ad3212adebe 100644 --- a/security/keys/keyctl.c +++ b/security/keys/keyctl.c | |||
@@ -273,7 +273,8 @@ error: | |||
273 | * Create and join an anonymous session keyring or join a named session | 273 | * Create and join an anonymous session keyring or join a named session |
274 | * keyring, creating it if necessary. A named session keyring must have Search | 274 | * keyring, creating it if necessary. A named session keyring must have Search |
275 | * permission for it to be joined. Session keyrings without this permit will | 275 | * permission for it to be joined. Session keyrings without this permit will |
276 | * be skipped over. | 276 | * be skipped over. It is not permitted for userspace to create or join |
277 | * keyrings whose name begin with a dot. | ||
277 | * | 278 | * |
278 | * If successful, the ID of the joined session keyring will be returned. | 279 | * If successful, the ID of the joined session keyring will be returned. |
279 | */ | 280 | */ |
@@ -290,12 +291,16 @@ long keyctl_join_session_keyring(const char __user *_name) | |||
290 | ret = PTR_ERR(name); | 291 | ret = PTR_ERR(name); |
291 | goto error; | 292 | goto error; |
292 | } | 293 | } |
294 | |||
295 | ret = -EPERM; | ||
296 | if (name[0] == '.') | ||
297 | goto error_name; | ||
293 | } | 298 | } |
294 | 299 | ||
295 | /* join the session */ | 300 | /* join the session */ |
296 | ret = join_session_keyring(name); | 301 | ret = join_session_keyring(name); |
302 | error_name: | ||
297 | kfree(name); | 303 | kfree(name); |
298 | |||
299 | error: | 304 | error: |
300 | return ret; | 305 | return ret; |
301 | } | 306 | } |
@@ -1253,8 +1258,8 @@ error: | |||
1253 | * Read or set the default keyring in which request_key() will cache keys and | 1258 | * Read or set the default keyring in which request_key() will cache keys and |
1254 | * return the old setting. | 1259 | * return the old setting. |
1255 | * | 1260 | * |
1256 | * If a process keyring is specified then this will be created if it doesn't | 1261 | * If a thread or process keyring is specified then it will be created if it |
1257 | * yet exist. The old setting will be returned if successful. | 1262 | * doesn't yet exist. The old setting will be returned if successful. |
1258 | */ | 1263 | */ |
1259 | long keyctl_set_reqkey_keyring(int reqkey_defl) | 1264 | long keyctl_set_reqkey_keyring(int reqkey_defl) |
1260 | { | 1265 | { |
@@ -1279,11 +1284,8 @@ long keyctl_set_reqkey_keyring(int reqkey_defl) | |||
1279 | 1284 | ||
1280 | case KEY_REQKEY_DEFL_PROCESS_KEYRING: | 1285 | case KEY_REQKEY_DEFL_PROCESS_KEYRING: |
1281 | ret = install_process_keyring_to_cred(new); | 1286 | ret = install_process_keyring_to_cred(new); |
1282 | if (ret < 0) { | 1287 | if (ret < 0) |
1283 | if (ret != -EEXIST) | 1288 | goto error; |
1284 | goto error; | ||
1285 | ret = 0; | ||
1286 | } | ||
1287 | goto set; | 1289 | goto set; |
1288 | 1290 | ||
1289 | case KEY_REQKEY_DEFL_DEFAULT: | 1291 | case KEY_REQKEY_DEFL_DEFAULT: |
diff --git a/security/keys/process_keys.c b/security/keys/process_keys.c index b6fdd22205b1..9139b18fc863 100644 --- a/security/keys/process_keys.c +++ b/security/keys/process_keys.c | |||
@@ -128,13 +128,18 @@ error: | |||
128 | } | 128 | } |
129 | 129 | ||
130 | /* | 130 | /* |
131 | * Install a fresh thread keyring directly to new credentials. This keyring is | 131 | * Install a thread keyring to the given credentials struct if it didn't have |
132 | * allowed to overrun the quota. | 132 | * one already. This is allowed to overrun the quota. |
133 | * | ||
134 | * Return: 0 if a thread keyring is now present; -errno on failure. | ||
133 | */ | 135 | */ |
134 | int install_thread_keyring_to_cred(struct cred *new) | 136 | int install_thread_keyring_to_cred(struct cred *new) |
135 | { | 137 | { |
136 | struct key *keyring; | 138 | struct key *keyring; |
137 | 139 | ||
140 | if (new->thread_keyring) | ||
141 | return 0; | ||
142 | |||
138 | keyring = keyring_alloc("_tid", new->uid, new->gid, new, | 143 | keyring = keyring_alloc("_tid", new->uid, new->gid, new, |
139 | KEY_POS_ALL | KEY_USR_VIEW, | 144 | KEY_POS_ALL | KEY_USR_VIEW, |
140 | KEY_ALLOC_QUOTA_OVERRUN, | 145 | KEY_ALLOC_QUOTA_OVERRUN, |
@@ -147,7 +152,9 @@ int install_thread_keyring_to_cred(struct cred *new) | |||
147 | } | 152 | } |
148 | 153 | ||
149 | /* | 154 | /* |
150 | * Install a fresh thread keyring, discarding the old one. | 155 | * Install a thread keyring to the current task if it didn't have one already. |
156 | * | ||
157 | * Return: 0 if a thread keyring is now present; -errno on failure. | ||
151 | */ | 158 | */ |
152 | static int install_thread_keyring(void) | 159 | static int install_thread_keyring(void) |
153 | { | 160 | { |
@@ -158,8 +165,6 @@ static int install_thread_keyring(void) | |||
158 | if (!new) | 165 | if (!new) |
159 | return -ENOMEM; | 166 | return -ENOMEM; |
160 | 167 | ||
161 | BUG_ON(new->thread_keyring); | ||
162 | |||
163 | ret = install_thread_keyring_to_cred(new); | 168 | ret = install_thread_keyring_to_cred(new); |
164 | if (ret < 0) { | 169 | if (ret < 0) { |
165 | abort_creds(new); | 170 | abort_creds(new); |
@@ -170,17 +175,17 @@ static int install_thread_keyring(void) | |||
170 | } | 175 | } |
171 | 176 | ||
172 | /* | 177 | /* |
173 | * Install a process keyring directly to a credentials struct. | 178 | * Install a process keyring to the given credentials struct if it didn't have |
179 | * one already. This is allowed to overrun the quota. | ||
174 | * | 180 | * |
175 | * Returns -EEXIST if there was already a process keyring, 0 if one installed, | 181 | * Return: 0 if a process keyring is now present; -errno on failure. |
176 | * and other value on any other error | ||
177 | */ | 182 | */ |
178 | int install_process_keyring_to_cred(struct cred *new) | 183 | int install_process_keyring_to_cred(struct cred *new) |
179 | { | 184 | { |
180 | struct key *keyring; | 185 | struct key *keyring; |
181 | 186 | ||
182 | if (new->process_keyring) | 187 | if (new->process_keyring) |
183 | return -EEXIST; | 188 | return 0; |
184 | 189 | ||
185 | keyring = keyring_alloc("_pid", new->uid, new->gid, new, | 190 | keyring = keyring_alloc("_pid", new->uid, new->gid, new, |
186 | KEY_POS_ALL | KEY_USR_VIEW, | 191 | KEY_POS_ALL | KEY_USR_VIEW, |
@@ -194,11 +199,9 @@ int install_process_keyring_to_cred(struct cred *new) | |||
194 | } | 199 | } |
195 | 200 | ||
196 | /* | 201 | /* |
197 | * Make sure a process keyring is installed for the current process. The | 202 | * Install a process keyring to the current task if it didn't have one already. |
198 | * existing process keyring is not replaced. | ||
199 | * | 203 | * |
200 | * Returns 0 if there is a process keyring by the end of this function, some | 204 | * Return: 0 if a process keyring is now present; -errno on failure. |
201 | * error otherwise. | ||
202 | */ | 205 | */ |
203 | static int install_process_keyring(void) | 206 | static int install_process_keyring(void) |
204 | { | 207 | { |
@@ -212,14 +215,18 @@ static int install_process_keyring(void) | |||
212 | ret = install_process_keyring_to_cred(new); | 215 | ret = install_process_keyring_to_cred(new); |
213 | if (ret < 0) { | 216 | if (ret < 0) { |
214 | abort_creds(new); | 217 | abort_creds(new); |
215 | return ret != -EEXIST ? ret : 0; | 218 | return ret; |
216 | } | 219 | } |
217 | 220 | ||
218 | return commit_creds(new); | 221 | return commit_creds(new); |
219 | } | 222 | } |
220 | 223 | ||
221 | /* | 224 | /* |
222 | * Install a session keyring directly to a credentials struct. | 225 | * Install the given keyring as the session keyring of the given credentials |
226 | * struct, replacing the existing one if any. If the given keyring is NULL, | ||
227 | * then install a new anonymous session keyring. | ||
228 | * | ||
229 | * Return: 0 on success; -errno on failure. | ||
223 | */ | 230 | */ |
224 | int install_session_keyring_to_cred(struct cred *cred, struct key *keyring) | 231 | int install_session_keyring_to_cred(struct cred *cred, struct key *keyring) |
225 | { | 232 | { |
@@ -254,8 +261,11 @@ int install_session_keyring_to_cred(struct cred *cred, struct key *keyring) | |||
254 | } | 261 | } |
255 | 262 | ||
256 | /* | 263 | /* |
257 | * Install a session keyring, discarding the old one. If a keyring is not | 264 | * Install the given keyring as the session keyring of the current task, |
258 | * supplied, an empty one is invented. | 265 | * replacing the existing one if any. If the given keyring is NULL, then |
266 | * install a new anonymous session keyring. | ||
267 | * | ||
268 | * Return: 0 on success; -errno on failure. | ||
259 | */ | 269 | */ |
260 | static int install_session_keyring(struct key *keyring) | 270 | static int install_session_keyring(struct key *keyring) |
261 | { | 271 | { |
diff --git a/sound/core/seq/seq_fifo.c b/sound/core/seq/seq_fifo.c index 33980d1c8037..01c4cfe30c9f 100644 --- a/sound/core/seq/seq_fifo.c +++ b/sound/core/seq/seq_fifo.c | |||
@@ -267,6 +267,10 @@ int snd_seq_fifo_resize(struct snd_seq_fifo *f, int poolsize) | |||
267 | /* NOTE: overflow flag is not cleared */ | 267 | /* NOTE: overflow flag is not cleared */ |
268 | spin_unlock_irqrestore(&f->lock, flags); | 268 | spin_unlock_irqrestore(&f->lock, flags); |
269 | 269 | ||
270 | /* close the old pool and wait until all users are gone */ | ||
271 | snd_seq_pool_mark_closing(oldpool); | ||
272 | snd_use_lock_sync(&f->use_lock); | ||
273 | |||
270 | /* release cells in old pool */ | 274 | /* release cells in old pool */ |
271 | for (cell = oldhead; cell; cell = next) { | 275 | for (cell = oldhead; cell; cell = next) { |
272 | next = cell->next; | 276 | next = cell->next; |
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 7f989898cbd9..299835d1fbaa 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c | |||
@@ -4858,6 +4858,7 @@ enum { | |||
4858 | ALC292_FIXUP_DISABLE_AAMIX, | 4858 | ALC292_FIXUP_DISABLE_AAMIX, |
4859 | ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK, | 4859 | ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK, |
4860 | ALC298_FIXUP_DELL1_MIC_NO_PRESENCE, | 4860 | ALC298_FIXUP_DELL1_MIC_NO_PRESENCE, |
4861 | ALC298_FIXUP_DELL_AIO_MIC_NO_PRESENCE, | ||
4861 | ALC275_FIXUP_DELL_XPS, | 4862 | ALC275_FIXUP_DELL_XPS, |
4862 | ALC256_FIXUP_DELL_XPS_13_HEADPHONE_NOISE, | 4863 | ALC256_FIXUP_DELL_XPS_13_HEADPHONE_NOISE, |
4863 | ALC293_FIXUP_LENOVO_SPK_NOISE, | 4864 | ALC293_FIXUP_LENOVO_SPK_NOISE, |
@@ -5470,6 +5471,15 @@ static const struct hda_fixup alc269_fixups[] = { | |||
5470 | .chained = true, | 5471 | .chained = true, |
5471 | .chain_id = ALC269_FIXUP_HEADSET_MODE | 5472 | .chain_id = ALC269_FIXUP_HEADSET_MODE |
5472 | }, | 5473 | }, |
5474 | [ALC298_FIXUP_DELL_AIO_MIC_NO_PRESENCE] = { | ||
5475 | .type = HDA_FIXUP_PINS, | ||
5476 | .v.pins = (const struct hda_pintbl[]) { | ||
5477 | { 0x18, 0x01a1913c }, /* use as headset mic, without its own jack detect */ | ||
5478 | { } | ||
5479 | }, | ||
5480 | .chained = true, | ||
5481 | .chain_id = ALC269_FIXUP_HEADSET_MODE | ||
5482 | }, | ||
5473 | [ALC275_FIXUP_DELL_XPS] = { | 5483 | [ALC275_FIXUP_DELL_XPS] = { |
5474 | .type = HDA_FIXUP_VERBS, | 5484 | .type = HDA_FIXUP_VERBS, |
5475 | .v.verbs = (const struct hda_verb[]) { | 5485 | .v.verbs = (const struct hda_verb[]) { |
@@ -5542,7 +5552,7 @@ static const struct hda_fixup alc269_fixups[] = { | |||
5542 | .type = HDA_FIXUP_FUNC, | 5552 | .type = HDA_FIXUP_FUNC, |
5543 | .v.func = alc298_fixup_speaker_volume, | 5553 | .v.func = alc298_fixup_speaker_volume, |
5544 | .chained = true, | 5554 | .chained = true, |
5545 | .chain_id = ALC298_FIXUP_DELL1_MIC_NO_PRESENCE, | 5555 | .chain_id = ALC298_FIXUP_DELL_AIO_MIC_NO_PRESENCE, |
5546 | }, | 5556 | }, |
5547 | [ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER] = { | 5557 | [ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER] = { |
5548 | .type = HDA_FIXUP_PINS, | 5558 | .type = HDA_FIXUP_PINS, |
diff --git a/sound/soc/atmel/atmel-classd.c b/sound/soc/atmel/atmel-classd.c index 89ac5f5a93eb..7ae46c2647d4 100644 --- a/sound/soc/atmel/atmel-classd.c +++ b/sound/soc/atmel/atmel-classd.c | |||
@@ -349,7 +349,7 @@ static int atmel_classd_codec_dai_digital_mute(struct snd_soc_dai *codec_dai, | |||
349 | } | 349 | } |
350 | 350 | ||
351 | #define CLASSD_ACLK_RATE_11M2896_MPY_8 (112896 * 100 * 8) | 351 | #define CLASSD_ACLK_RATE_11M2896_MPY_8 (112896 * 100 * 8) |
352 | #define CLASSD_ACLK_RATE_12M288_MPY_8 (12228 * 1000 * 8) | 352 | #define CLASSD_ACLK_RATE_12M288_MPY_8 (12288 * 1000 * 8) |
353 | 353 | ||
354 | static struct { | 354 | static struct { |
355 | int rate; | 355 | int rate; |
diff --git a/sound/soc/codecs/hdac_hdmi.c b/sound/soc/codecs/hdac_hdmi.c index 78fca8acd3ec..fd272a40485b 100644 --- a/sound/soc/codecs/hdac_hdmi.c +++ b/sound/soc/codecs/hdac_hdmi.c | |||
@@ -1534,21 +1534,20 @@ static void hdac_hdmi_eld_notify_cb(void *aptr, int port, int pipe) | |||
1534 | pin->mst_capable = false; | 1534 | pin->mst_capable = false; |
1535 | /* if not MST, default is port[0] */ | 1535 | /* if not MST, default is port[0] */ |
1536 | hport = &pin->ports[0]; | 1536 | hport = &pin->ports[0]; |
1537 | goto out; | ||
1538 | } else { | 1537 | } else { |
1539 | for (i = 0; i < pin->num_ports; i++) { | 1538 | for (i = 0; i < pin->num_ports; i++) { |
1540 | pin->mst_capable = true; | 1539 | pin->mst_capable = true; |
1541 | if (pin->ports[i].id == pipe) { | 1540 | if (pin->ports[i].id == pipe) { |
1542 | hport = &pin->ports[i]; | 1541 | hport = &pin->ports[i]; |
1543 | goto out; | 1542 | break; |
1544 | } | 1543 | } |
1545 | } | 1544 | } |
1546 | } | 1545 | } |
1546 | |||
1547 | if (hport) | ||
1548 | hdac_hdmi_present_sense(pin, hport); | ||
1547 | } | 1549 | } |
1548 | 1550 | ||
1549 | out: | ||
1550 | if (pin && hport) | ||
1551 | hdac_hdmi_present_sense(pin, hport); | ||
1552 | } | 1551 | } |
1553 | 1552 | ||
1554 | static struct i915_audio_component_audio_ops aops = { | 1553 | static struct i915_audio_component_audio_ops aops = { |
@@ -1998,7 +1997,7 @@ static int hdac_hdmi_dev_remove(struct hdac_ext_device *edev) | |||
1998 | struct hdac_hdmi_pin *pin, *pin_next; | 1997 | struct hdac_hdmi_pin *pin, *pin_next; |
1999 | struct hdac_hdmi_cvt *cvt, *cvt_next; | 1998 | struct hdac_hdmi_cvt *cvt, *cvt_next; |
2000 | struct hdac_hdmi_pcm *pcm, *pcm_next; | 1999 | struct hdac_hdmi_pcm *pcm, *pcm_next; |
2001 | struct hdac_hdmi_port *port; | 2000 | struct hdac_hdmi_port *port, *port_next; |
2002 | int i; | 2001 | int i; |
2003 | 2002 | ||
2004 | snd_soc_unregister_codec(&edev->hdac.dev); | 2003 | snd_soc_unregister_codec(&edev->hdac.dev); |
@@ -2008,8 +2007,9 @@ static int hdac_hdmi_dev_remove(struct hdac_ext_device *edev) | |||
2008 | if (list_empty(&pcm->port_list)) | 2007 | if (list_empty(&pcm->port_list)) |
2009 | continue; | 2008 | continue; |
2010 | 2009 | ||
2011 | list_for_each_entry(port, &pcm->port_list, head) | 2010 | list_for_each_entry_safe(port, port_next, |
2012 | port = NULL; | 2011 | &pcm->port_list, head) |
2012 | list_del(&port->head); | ||
2013 | 2013 | ||
2014 | list_del(&pcm->head); | 2014 | list_del(&pcm->head); |
2015 | kfree(pcm); | 2015 | kfree(pcm); |
diff --git a/sound/soc/codecs/rt5665.c b/sound/soc/codecs/rt5665.c index 324461e985b3..476135ec5726 100644 --- a/sound/soc/codecs/rt5665.c +++ b/sound/soc/codecs/rt5665.c | |||
@@ -1241,7 +1241,7 @@ static irqreturn_t rt5665_irq(int irq, void *data) | |||
1241 | static void rt5665_jd_check_handler(struct work_struct *work) | 1241 | static void rt5665_jd_check_handler(struct work_struct *work) |
1242 | { | 1242 | { |
1243 | struct rt5665_priv *rt5665 = container_of(work, struct rt5665_priv, | 1243 | struct rt5665_priv *rt5665 = container_of(work, struct rt5665_priv, |
1244 | calibrate_work.work); | 1244 | jd_check_work.work); |
1245 | 1245 | ||
1246 | if (snd_soc_read(rt5665->codec, RT5665_AJD1_CTRL) & 0x0010) { | 1246 | if (snd_soc_read(rt5665->codec, RT5665_AJD1_CTRL) & 0x0010) { |
1247 | /* jack out */ | 1247 | /* jack out */ |
@@ -2252,7 +2252,7 @@ static const char * const rt5665_if2_1_adc_in_src[] = { | |||
2252 | 2252 | ||
2253 | static const SOC_ENUM_SINGLE_DECL( | 2253 | static const SOC_ENUM_SINGLE_DECL( |
2254 | rt5665_if2_1_adc_in_enum, RT5665_DIG_INF2_DATA, | 2254 | rt5665_if2_1_adc_in_enum, RT5665_DIG_INF2_DATA, |
2255 | RT5665_IF3_ADC_IN_SFT, rt5665_if2_1_adc_in_src); | 2255 | RT5665_IF2_1_ADC_IN_SFT, rt5665_if2_1_adc_in_src); |
2256 | 2256 | ||
2257 | static const struct snd_kcontrol_new rt5665_if2_1_adc_in_mux = | 2257 | static const struct snd_kcontrol_new rt5665_if2_1_adc_in_mux = |
2258 | SOC_DAPM_ENUM("IF2_1 ADC IN Source", rt5665_if2_1_adc_in_enum); | 2258 | SOC_DAPM_ENUM("IF2_1 ADC IN Source", rt5665_if2_1_adc_in_enum); |
@@ -3178,6 +3178,9 @@ static const struct snd_soc_dapm_route rt5665_dapm_routes[] = { | |||
3178 | {"DAC Mono Right Filter", NULL, "DAC Mono R ASRC", is_using_asrc}, | 3178 | {"DAC Mono Right Filter", NULL, "DAC Mono R ASRC", is_using_asrc}, |
3179 | {"DAC Stereo1 Filter", NULL, "DAC STO1 ASRC", is_using_asrc}, | 3179 | {"DAC Stereo1 Filter", NULL, "DAC STO1 ASRC", is_using_asrc}, |
3180 | {"DAC Stereo2 Filter", NULL, "DAC STO2 ASRC", is_using_asrc}, | 3180 | {"DAC Stereo2 Filter", NULL, "DAC STO2 ASRC", is_using_asrc}, |
3181 | {"I2S1 ASRC", NULL, "CLKDET"}, | ||
3182 | {"I2S2 ASRC", NULL, "CLKDET"}, | ||
3183 | {"I2S3 ASRC", NULL, "CLKDET"}, | ||
3181 | 3184 | ||
3182 | /*Vref*/ | 3185 | /*Vref*/ |
3183 | {"Mic Det Power", NULL, "Vref2"}, | 3186 | {"Mic Det Power", NULL, "Vref2"}, |
@@ -3912,6 +3915,7 @@ static const struct snd_soc_dapm_route rt5665_dapm_routes[] = { | |||
3912 | {"Mono MIX", "MONOVOL Switch", "MONOVOL"}, | 3915 | {"Mono MIX", "MONOVOL Switch", "MONOVOL"}, |
3913 | {"Mono Amp", NULL, "Mono MIX"}, | 3916 | {"Mono Amp", NULL, "Mono MIX"}, |
3914 | {"Mono Amp", NULL, "Vref2"}, | 3917 | {"Mono Amp", NULL, "Vref2"}, |
3918 | {"Mono Amp", NULL, "Vref3"}, | ||
3915 | {"Mono Amp", NULL, "CLKDET SYS"}, | 3919 | {"Mono Amp", NULL, "CLKDET SYS"}, |
3916 | {"Mono Amp", NULL, "CLKDET MONO"}, | 3920 | {"Mono Amp", NULL, "CLKDET MONO"}, |
3917 | {"Mono Playback", "Switch", "Mono Amp"}, | 3921 | {"Mono Playback", "Switch", "Mono Amp"}, |
@@ -4798,7 +4802,7 @@ static int rt5665_i2c_probe(struct i2c_client *i2c, | |||
4798 | /* Enhance performance*/ | 4802 | /* Enhance performance*/ |
4799 | regmap_update_bits(rt5665->regmap, RT5665_PWR_ANLG_1, | 4803 | regmap_update_bits(rt5665->regmap, RT5665_PWR_ANLG_1, |
4800 | RT5665_HP_DRIVER_MASK | RT5665_LDO1_DVO_MASK, | 4804 | RT5665_HP_DRIVER_MASK | RT5665_LDO1_DVO_MASK, |
4801 | RT5665_HP_DRIVER_5X | RT5665_LDO1_DVO_09); | 4805 | RT5665_HP_DRIVER_5X | RT5665_LDO1_DVO_12); |
4802 | 4806 | ||
4803 | INIT_DELAYED_WORK(&rt5665->jack_detect_work, | 4807 | INIT_DELAYED_WORK(&rt5665->jack_detect_work, |
4804 | rt5665_jack_detect_handler); | 4808 | rt5665_jack_detect_handler); |
diff --git a/sound/soc/codecs/rt5665.h b/sound/soc/codecs/rt5665.h index 12f7080a0d3c..a30f5e6d0628 100644 --- a/sound/soc/codecs/rt5665.h +++ b/sound/soc/codecs/rt5665.h | |||
@@ -1106,7 +1106,7 @@ | |||
1106 | #define RT5665_HP_DRIVER_MASK (0x3 << 2) | 1106 | #define RT5665_HP_DRIVER_MASK (0x3 << 2) |
1107 | #define RT5665_HP_DRIVER_1X (0x0 << 2) | 1107 | #define RT5665_HP_DRIVER_1X (0x0 << 2) |
1108 | #define RT5665_HP_DRIVER_3X (0x1 << 2) | 1108 | #define RT5665_HP_DRIVER_3X (0x1 << 2) |
1109 | #define RT5665_HP_DRIVER_5X (0x2 << 2) | 1109 | #define RT5665_HP_DRIVER_5X (0x3 << 2) |
1110 | #define RT5665_LDO1_DVO_MASK (0x3) | 1110 | #define RT5665_LDO1_DVO_MASK (0x3) |
1111 | #define RT5665_LDO1_DVO_09 (0x0) | 1111 | #define RT5665_LDO1_DVO_09 (0x0) |
1112 | #define RT5665_LDO1_DVO_10 (0x1) | 1112 | #define RT5665_LDO1_DVO_10 (0x1) |
diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c index d151224ffcca..bbdb72f73df1 100644 --- a/sound/soc/codecs/wm_adsp.c +++ b/sound/soc/codecs/wm_adsp.c | |||
@@ -899,7 +899,10 @@ static int wm_coeff_put(struct snd_kcontrol *kctl, | |||
899 | 899 | ||
900 | mutex_lock(&ctl->dsp->pwr_lock); | 900 | mutex_lock(&ctl->dsp->pwr_lock); |
901 | 901 | ||
902 | memcpy(ctl->cache, p, ctl->len); | 902 | if (ctl->flags & WMFW_CTL_FLAG_VOLATILE) |
903 | ret = -EPERM; | ||
904 | else | ||
905 | memcpy(ctl->cache, p, ctl->len); | ||
903 | 906 | ||
904 | ctl->set = 1; | 907 | ctl->set = 1; |
905 | if (ctl->enabled && ctl->dsp->running) | 908 | if (ctl->enabled && ctl->dsp->running) |
@@ -926,6 +929,8 @@ static int wm_coeff_tlv_put(struct snd_kcontrol *kctl, | |||
926 | ctl->set = 1; | 929 | ctl->set = 1; |
927 | if (ctl->enabled && ctl->dsp->running) | 930 | if (ctl->enabled && ctl->dsp->running) |
928 | ret = wm_coeff_write_control(ctl, ctl->cache, size); | 931 | ret = wm_coeff_write_control(ctl, ctl->cache, size); |
932 | else if (ctl->flags & WMFW_CTL_FLAG_VOLATILE) | ||
933 | ret = -EPERM; | ||
929 | } | 934 | } |
930 | 935 | ||
931 | mutex_unlock(&ctl->dsp->pwr_lock); | 936 | mutex_unlock(&ctl->dsp->pwr_lock); |
@@ -947,7 +952,7 @@ static int wm_coeff_put_acked(struct snd_kcontrol *kctl, | |||
947 | 952 | ||
948 | mutex_lock(&ctl->dsp->pwr_lock); | 953 | mutex_lock(&ctl->dsp->pwr_lock); |
949 | 954 | ||
950 | if (ctl->enabled) | 955 | if (ctl->enabled && ctl->dsp->running) |
951 | ret = wm_coeff_write_acked_control(ctl, val); | 956 | ret = wm_coeff_write_acked_control(ctl, val); |
952 | else | 957 | else |
953 | ret = -EPERM; | 958 | ret = -EPERM; |
diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c index 4924575d2e95..343b291fc372 100644 --- a/sound/soc/generic/simple-card-utils.c +++ b/sound/soc/generic/simple-card-utils.c | |||
@@ -115,6 +115,7 @@ int asoc_simple_card_parse_clk(struct device *dev, | |||
115 | clk = devm_get_clk_from_child(dev, node, NULL); | 115 | clk = devm_get_clk_from_child(dev, node, NULL); |
116 | if (!IS_ERR(clk)) { | 116 | if (!IS_ERR(clk)) { |
117 | simple_dai->sysclk = clk_get_rate(clk); | 117 | simple_dai->sysclk = clk_get_rate(clk); |
118 | simple_dai->clk = clk; | ||
118 | } else if (!of_property_read_u32(node, "system-clock-frequency", &val)) { | 119 | } else if (!of_property_read_u32(node, "system-clock-frequency", &val)) { |
119 | simple_dai->sysclk = val; | 120 | simple_dai->sysclk = val; |
120 | } else { | 121 | } else { |
diff --git a/sound/soc/intel/skylake/skl-topology.c b/sound/soc/intel/skylake/skl-topology.c index ed58b5b3555a..2dbfb1b24ef4 100644 --- a/sound/soc/intel/skylake/skl-topology.c +++ b/sound/soc/intel/skylake/skl-topology.c | |||
@@ -512,7 +512,7 @@ static int skl_tplg_set_module_init_data(struct snd_soc_dapm_widget *w) | |||
512 | if (bc->set_params != SKL_PARAM_INIT) | 512 | if (bc->set_params != SKL_PARAM_INIT) |
513 | continue; | 513 | continue; |
514 | 514 | ||
515 | mconfig->formats_config.caps = (u32 *)&bc->params; | 515 | mconfig->formats_config.caps = (u32 *)bc->params; |
516 | mconfig->formats_config.caps_size = bc->size; | 516 | mconfig->formats_config.caps_size = bc->size; |
517 | 517 | ||
518 | break; | 518 | break; |
diff --git a/sound/soc/mediatek/Kconfig b/sound/soc/mediatek/Kconfig index 05cf809cf9e1..d7013bde6f45 100644 --- a/sound/soc/mediatek/Kconfig +++ b/sound/soc/mediatek/Kconfig | |||
@@ -13,7 +13,7 @@ config SND_SOC_MT2701 | |||
13 | 13 | ||
14 | config SND_SOC_MT2701_CS42448 | 14 | config SND_SOC_MT2701_CS42448 |
15 | tristate "ASoc Audio driver for MT2701 with CS42448 codec" | 15 | tristate "ASoc Audio driver for MT2701 with CS42448 codec" |
16 | depends on SND_SOC_MT2701 | 16 | depends on SND_SOC_MT2701 && I2C |
17 | select SND_SOC_CS42XX8_I2C | 17 | select SND_SOC_CS42XX8_I2C |
18 | select SND_SOC_BT_SCO | 18 | select SND_SOC_BT_SCO |
19 | help | 19 | help |
diff --git a/sound/soc/sh/rcar/cmd.c b/sound/soc/sh/rcar/cmd.c index abb5eaac854a..7d92a24b7cfa 100644 --- a/sound/soc/sh/rcar/cmd.c +++ b/sound/soc/sh/rcar/cmd.c | |||
@@ -31,23 +31,24 @@ static int rsnd_cmd_init(struct rsnd_mod *mod, | |||
31 | struct rsnd_mod *mix = rsnd_io_to_mod_mix(io); | 31 | struct rsnd_mod *mix = rsnd_io_to_mod_mix(io); |
32 | struct device *dev = rsnd_priv_to_dev(priv); | 32 | struct device *dev = rsnd_priv_to_dev(priv); |
33 | u32 data; | 33 | u32 data; |
34 | u32 path[] = { | ||
35 | [1] = 1 << 0, | ||
36 | [5] = 1 << 8, | ||
37 | [6] = 1 << 12, | ||
38 | [9] = 1 << 15, | ||
39 | }; | ||
34 | 40 | ||
35 | if (!mix && !dvc) | 41 | if (!mix && !dvc) |
36 | return 0; | 42 | return 0; |
37 | 43 | ||
44 | if (ARRAY_SIZE(path) < rsnd_mod_id(mod) + 1) | ||
45 | return -ENXIO; | ||
46 | |||
38 | if (mix) { | 47 | if (mix) { |
39 | struct rsnd_dai *rdai; | 48 | struct rsnd_dai *rdai; |
40 | struct rsnd_mod *src; | 49 | struct rsnd_mod *src; |
41 | struct rsnd_dai_stream *tio; | 50 | struct rsnd_dai_stream *tio; |
42 | int i; | 51 | int i; |
43 | u32 path[] = { | ||
44 | [0] = 0, | ||
45 | [1] = 1 << 0, | ||
46 | [2] = 0, | ||
47 | [3] = 0, | ||
48 | [4] = 0, | ||
49 | [5] = 1 << 8 | ||
50 | }; | ||
51 | 52 | ||
52 | /* | 53 | /* |
53 | * it is assuming that integrater is well understanding about | 54 | * it is assuming that integrater is well understanding about |
@@ -70,16 +71,19 @@ static int rsnd_cmd_init(struct rsnd_mod *mod, | |||
70 | } else { | 71 | } else { |
71 | struct rsnd_mod *src = rsnd_io_to_mod_src(io); | 72 | struct rsnd_mod *src = rsnd_io_to_mod_src(io); |
72 | 73 | ||
73 | u32 path[] = { | 74 | u8 cmd_case[] = { |
74 | [0] = 0x30000, | 75 | [0] = 0x3, |
75 | [1] = 0x30001, | 76 | [1] = 0x3, |
76 | [2] = 0x40000, | 77 | [2] = 0x4, |
77 | [3] = 0x10000, | 78 | [3] = 0x1, |
78 | [4] = 0x20000, | 79 | [4] = 0x2, |
79 | [5] = 0x40100 | 80 | [5] = 0x4, |
81 | [6] = 0x1, | ||
82 | [9] = 0x2, | ||
80 | }; | 83 | }; |
81 | 84 | ||
82 | data = path[rsnd_mod_id(src)]; | 85 | data = path[rsnd_mod_id(src)] | |
86 | cmd_case[rsnd_mod_id(src)] << 16; | ||
83 | } | 87 | } |
84 | 88 | ||
85 | dev_dbg(dev, "ctu/mix path = 0x%08x", data); | 89 | dev_dbg(dev, "ctu/mix path = 0x%08x", data); |
diff --git a/sound/soc/sh/rcar/dma.c b/sound/soc/sh/rcar/dma.c index 1f405c833867..241cb3b08a07 100644 --- a/sound/soc/sh/rcar/dma.c +++ b/sound/soc/sh/rcar/dma.c | |||
@@ -454,6 +454,20 @@ static u32 rsnd_dmapp_read(struct rsnd_dma *dma, u32 reg) | |||
454 | return ioread32(rsnd_dmapp_addr(dmac, dma, reg)); | 454 | return ioread32(rsnd_dmapp_addr(dmac, dma, reg)); |
455 | } | 455 | } |
456 | 456 | ||
457 | static void rsnd_dmapp_bset(struct rsnd_dma *dma, u32 data, u32 mask, u32 reg) | ||
458 | { | ||
459 | struct rsnd_mod *mod = rsnd_mod_get(dma); | ||
460 | struct rsnd_priv *priv = rsnd_mod_to_priv(mod); | ||
461 | struct rsnd_dma_ctrl *dmac = rsnd_priv_to_dmac(priv); | ||
462 | void __iomem *addr = rsnd_dmapp_addr(dmac, dma, reg); | ||
463 | u32 val = ioread32(addr); | ||
464 | |||
465 | val &= ~mask; | ||
466 | val |= (data & mask); | ||
467 | |||
468 | iowrite32(val, addr); | ||
469 | } | ||
470 | |||
457 | static int rsnd_dmapp_stop(struct rsnd_mod *mod, | 471 | static int rsnd_dmapp_stop(struct rsnd_mod *mod, |
458 | struct rsnd_dai_stream *io, | 472 | struct rsnd_dai_stream *io, |
459 | struct rsnd_priv *priv) | 473 | struct rsnd_priv *priv) |
@@ -461,10 +475,10 @@ static int rsnd_dmapp_stop(struct rsnd_mod *mod, | |||
461 | struct rsnd_dma *dma = rsnd_mod_to_dma(mod); | 475 | struct rsnd_dma *dma = rsnd_mod_to_dma(mod); |
462 | int i; | 476 | int i; |
463 | 477 | ||
464 | rsnd_dmapp_write(dma, 0, PDMACHCR); | 478 | rsnd_dmapp_bset(dma, 0, PDMACHCR_DE, PDMACHCR); |
465 | 479 | ||
466 | for (i = 0; i < 1024; i++) { | 480 | for (i = 0; i < 1024; i++) { |
467 | if (0 == rsnd_dmapp_read(dma, PDMACHCR)) | 481 | if (0 == (rsnd_dmapp_read(dma, PDMACHCR) & PDMACHCR_DE)) |
468 | return 0; | 482 | return 0; |
469 | udelay(1); | 483 | udelay(1); |
470 | } | 484 | } |
diff --git a/sound/soc/sh/rcar/ssiu.c b/sound/soc/sh/rcar/ssiu.c index 4e817c8a18c0..14fafdaf1395 100644 --- a/sound/soc/sh/rcar/ssiu.c +++ b/sound/soc/sh/rcar/ssiu.c | |||
@@ -64,7 +64,11 @@ static int rsnd_ssiu_init(struct rsnd_mod *mod, | |||
64 | mask1 = (1 << 4) | (1 << 20); /* mask sync bit */ | 64 | mask1 = (1 << 4) | (1 << 20); /* mask sync bit */ |
65 | mask2 = (1 << 4); /* mask sync bit */ | 65 | mask2 = (1 << 4); /* mask sync bit */ |
66 | val1 = val2 = 0; | 66 | val1 = val2 = 0; |
67 | if (rsnd_ssi_is_pin_sharing(io)) { | 67 | if (id == 8) { |
68 | /* | ||
69 | * SSI8 pin is sharing with SSI7, nothing to do. | ||
70 | */ | ||
71 | } else if (rsnd_ssi_is_pin_sharing(io)) { | ||
68 | int shift = -1; | 72 | int shift = -1; |
69 | 73 | ||
70 | switch (id) { | 74 | switch (id) { |
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 6dca408faae3..2722bb0c5573 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c | |||
@@ -3326,7 +3326,10 @@ static int snd_soc_platform_drv_pcm_new(struct snd_soc_pcm_runtime *rtd) | |||
3326 | { | 3326 | { |
3327 | struct snd_soc_platform *platform = rtd->platform; | 3327 | struct snd_soc_platform *platform = rtd->platform; |
3328 | 3328 | ||
3329 | return platform->driver->pcm_new(rtd); | 3329 | if (platform->driver->pcm_new) |
3330 | return platform->driver->pcm_new(rtd); | ||
3331 | else | ||
3332 | return 0; | ||
3330 | } | 3333 | } |
3331 | 3334 | ||
3332 | static void snd_soc_platform_drv_pcm_free(struct snd_pcm *pcm) | 3335 | static void snd_soc_platform_drv_pcm_free(struct snd_pcm *pcm) |
@@ -3334,7 +3337,8 @@ static void snd_soc_platform_drv_pcm_free(struct snd_pcm *pcm) | |||
3334 | struct snd_soc_pcm_runtime *rtd = pcm->private_data; | 3337 | struct snd_soc_pcm_runtime *rtd = pcm->private_data; |
3335 | struct snd_soc_platform *platform = rtd->platform; | 3338 | struct snd_soc_platform *platform = rtd->platform; |
3336 | 3339 | ||
3337 | platform->driver->pcm_free(pcm); | 3340 | if (platform->driver->pcm_free) |
3341 | platform->driver->pcm_free(pcm); | ||
3338 | } | 3342 | } |
3339 | 3343 | ||
3340 | /** | 3344 | /** |
diff --git a/sound/soc/sti/uniperif_reader.c b/sound/soc/sti/uniperif_reader.c index 5992c6ab3833..93a8df6ed880 100644 --- a/sound/soc/sti/uniperif_reader.c +++ b/sound/soc/sti/uniperif_reader.c | |||
@@ -349,6 +349,8 @@ static int uni_reader_startup(struct snd_pcm_substream *substream, | |||
349 | struct uniperif *reader = priv->dai_data.uni; | 349 | struct uniperif *reader = priv->dai_data.uni; |
350 | int ret; | 350 | int ret; |
351 | 351 | ||
352 | reader->substream = substream; | ||
353 | |||
352 | if (!UNIPERIF_TYPE_IS_TDM(reader)) | 354 | if (!UNIPERIF_TYPE_IS_TDM(reader)) |
353 | return 0; | 355 | return 0; |
354 | 356 | ||
@@ -378,6 +380,7 @@ static void uni_reader_shutdown(struct snd_pcm_substream *substream, | |||
378 | /* Stop the reader */ | 380 | /* Stop the reader */ |
379 | uni_reader_stop(reader); | 381 | uni_reader_stop(reader); |
380 | } | 382 | } |
383 | reader->substream = NULL; | ||
381 | } | 384 | } |
382 | 385 | ||
383 | static const struct snd_soc_dai_ops uni_reader_dai_ops = { | 386 | static const struct snd_soc_dai_ops uni_reader_dai_ops = { |
diff --git a/sound/soc/sunxi/sun8i-codec.c b/sound/soc/sunxi/sun8i-codec.c index b92bdc8361af..7527ba29a5a0 100644 --- a/sound/soc/sunxi/sun8i-codec.c +++ b/sound/soc/sunxi/sun8i-codec.c | |||
@@ -259,25 +259,20 @@ static int sun8i_codec_hw_params(struct snd_pcm_substream *substream, | |||
259 | return 0; | 259 | return 0; |
260 | } | 260 | } |
261 | 261 | ||
262 | static const struct snd_kcontrol_new sun8i_output_left_mixer_controls[] = { | 262 | static const struct snd_kcontrol_new sun8i_dac_mixer_controls[] = { |
263 | SOC_DAPM_SINGLE("LSlot 0", SUN8I_DAC_MXR_SRC, | 263 | SOC_DAPM_DOUBLE("AIF1 Slot 0 Digital DAC Playback Switch", |
264 | SUN8I_DAC_MXR_SRC_DACL_MXR_SRC_AIF1DA0L, 1, 0), | 264 | SUN8I_DAC_MXR_SRC, |
265 | SOC_DAPM_SINGLE("LSlot 1", SUN8I_DAC_MXR_SRC, | 265 | SUN8I_DAC_MXR_SRC_DACL_MXR_SRC_AIF1DA0L, |
266 | SUN8I_DAC_MXR_SRC_DACL_MXR_SRC_AIF1DA1L, 1, 0), | ||
267 | SOC_DAPM_SINGLE("DACL", SUN8I_DAC_MXR_SRC, | ||
268 | SUN8I_DAC_MXR_SRC_DACL_MXR_SRC_AIF2DACL, 1, 0), | ||
269 | SOC_DAPM_SINGLE("ADCL", SUN8I_DAC_MXR_SRC, | ||
270 | SUN8I_DAC_MXR_SRC_DACL_MXR_SRC_ADCL, 1, 0), | ||
271 | }; | ||
272 | |||
273 | static const struct snd_kcontrol_new sun8i_output_right_mixer_controls[] = { | ||
274 | SOC_DAPM_SINGLE("RSlot 0", SUN8I_DAC_MXR_SRC, | ||
275 | SUN8I_DAC_MXR_SRC_DACR_MXR_SRC_AIF1DA0R, 1, 0), | 266 | SUN8I_DAC_MXR_SRC_DACR_MXR_SRC_AIF1DA0R, 1, 0), |
276 | SOC_DAPM_SINGLE("RSlot 1", SUN8I_DAC_MXR_SRC, | 267 | SOC_DAPM_DOUBLE("AIF1 Slot 1 Digital DAC Playback Switch", |
268 | SUN8I_DAC_MXR_SRC, | ||
269 | SUN8I_DAC_MXR_SRC_DACL_MXR_SRC_AIF1DA1L, | ||
277 | SUN8I_DAC_MXR_SRC_DACR_MXR_SRC_AIF1DA1R, 1, 0), | 270 | SUN8I_DAC_MXR_SRC_DACR_MXR_SRC_AIF1DA1R, 1, 0), |
278 | SOC_DAPM_SINGLE("DACR", SUN8I_DAC_MXR_SRC, | 271 | SOC_DAPM_DOUBLE("AIF2 Digital DAC Playback Switch", SUN8I_DAC_MXR_SRC, |
272 | SUN8I_DAC_MXR_SRC_DACL_MXR_SRC_AIF2DACL, | ||
279 | SUN8I_DAC_MXR_SRC_DACR_MXR_SRC_AIF2DACR, 1, 0), | 273 | SUN8I_DAC_MXR_SRC_DACR_MXR_SRC_AIF2DACR, 1, 0), |
280 | SOC_DAPM_SINGLE("ADCR", SUN8I_DAC_MXR_SRC, | 274 | SOC_DAPM_DOUBLE("ADC Digital DAC Playback Switch", SUN8I_DAC_MXR_SRC, |
275 | SUN8I_DAC_MXR_SRC_DACL_MXR_SRC_ADCL, | ||
281 | SUN8I_DAC_MXR_SRC_DACR_MXR_SRC_ADCR, 1, 0), | 276 | SUN8I_DAC_MXR_SRC_DACR_MXR_SRC_ADCR, 1, 0), |
282 | }; | 277 | }; |
283 | 278 | ||
@@ -286,19 +281,21 @@ static const struct snd_soc_dapm_widget sun8i_codec_dapm_widgets[] = { | |||
286 | SND_SOC_DAPM_SUPPLY("DAC", SUN8I_DAC_DIG_CTRL, SUN8I_DAC_DIG_CTRL_ENDA, | 281 | SND_SOC_DAPM_SUPPLY("DAC", SUN8I_DAC_DIG_CTRL, SUN8I_DAC_DIG_CTRL_ENDA, |
287 | 0, NULL, 0), | 282 | 0, NULL, 0), |
288 | 283 | ||
289 | /* Analog DAC */ | 284 | /* Analog DAC AIF */ |
290 | SND_SOC_DAPM_DAC("Digital Left DAC", "Playback", SUN8I_AIF1_DACDAT_CTRL, | 285 | SND_SOC_DAPM_AIF_IN("AIF1 Slot 0 Left", "Playback", 0, |
291 | SUN8I_AIF1_DACDAT_CTRL_AIF1_DA0L_ENA, 0), | 286 | SUN8I_AIF1_DACDAT_CTRL, |
292 | SND_SOC_DAPM_DAC("Digital Right DAC", "Playback", SUN8I_AIF1_DACDAT_CTRL, | 287 | SUN8I_AIF1_DACDAT_CTRL_AIF1_DA0L_ENA, 0), |
293 | SUN8I_AIF1_DACDAT_CTRL_AIF1_DA0R_ENA, 0), | 288 | SND_SOC_DAPM_AIF_IN("AIF1 Slot 0 Right", "Playback", 0, |
289 | SUN8I_AIF1_DACDAT_CTRL, | ||
290 | SUN8I_AIF1_DACDAT_CTRL_AIF1_DA0R_ENA, 0), | ||
294 | 291 | ||
295 | /* DAC Mixers */ | 292 | /* DAC Mixers */ |
296 | SND_SOC_DAPM_MIXER("Left DAC Mixer", SND_SOC_NOPM, 0, 0, | 293 | SND_SOC_DAPM_MIXER("Left Digital DAC Mixer", SND_SOC_NOPM, 0, 0, |
297 | sun8i_output_left_mixer_controls, | 294 | sun8i_dac_mixer_controls, |
298 | ARRAY_SIZE(sun8i_output_left_mixer_controls)), | 295 | ARRAY_SIZE(sun8i_dac_mixer_controls)), |
299 | SND_SOC_DAPM_MIXER("Right DAC Mixer", SND_SOC_NOPM, 0, 0, | 296 | SND_SOC_DAPM_MIXER("Right Digital DAC Mixer", SND_SOC_NOPM, 0, 0, |
300 | sun8i_output_right_mixer_controls, | 297 | sun8i_dac_mixer_controls, |
301 | ARRAY_SIZE(sun8i_output_right_mixer_controls)), | 298 | ARRAY_SIZE(sun8i_dac_mixer_controls)), |
302 | 299 | ||
303 | /* Clocks */ | 300 | /* Clocks */ |
304 | SND_SOC_DAPM_SUPPLY("MODCLK AFI1", SUN8I_MOD_CLK_ENA, | 301 | SND_SOC_DAPM_SUPPLY("MODCLK AFI1", SUN8I_MOD_CLK_ENA, |
@@ -321,8 +318,6 @@ static const struct snd_soc_dapm_widget sun8i_codec_dapm_widgets[] = { | |||
321 | SUN8I_MOD_RST_CTL_AIF1, 0, NULL, 0), | 318 | SUN8I_MOD_RST_CTL_AIF1, 0, NULL, 0), |
322 | SND_SOC_DAPM_SUPPLY("RST DAC", SUN8I_MOD_RST_CTL, | 319 | SND_SOC_DAPM_SUPPLY("RST DAC", SUN8I_MOD_RST_CTL, |
323 | SUN8I_MOD_RST_CTL_DAC, 0, NULL, 0), | 320 | SUN8I_MOD_RST_CTL_DAC, 0, NULL, 0), |
324 | |||
325 | SND_SOC_DAPM_OUTPUT("HP"), | ||
326 | }; | 321 | }; |
327 | 322 | ||
328 | static const struct snd_soc_dapm_route sun8i_codec_dapm_routes[] = { | 323 | static const struct snd_soc_dapm_route sun8i_codec_dapm_routes[] = { |
@@ -338,16 +333,14 @@ static const struct snd_soc_dapm_route sun8i_codec_dapm_routes[] = { | |||
338 | { "DAC", NULL, "MODCLK DAC" }, | 333 | { "DAC", NULL, "MODCLK DAC" }, |
339 | 334 | ||
340 | /* DAC Routes */ | 335 | /* DAC Routes */ |
341 | { "Digital Left DAC", NULL, "DAC" }, | 336 | { "AIF1 Slot 0 Right", NULL, "DAC" }, |
342 | { "Digital Right DAC", NULL, "DAC" }, | 337 | { "AIF1 Slot 0 Left", NULL, "DAC" }, |
343 | 338 | ||
344 | /* DAC Mixer Routes */ | 339 | /* DAC Mixer Routes */ |
345 | { "Left DAC Mixer", "LSlot 0", "Digital Left DAC"}, | 340 | { "Left Digital DAC Mixer", "AIF1 Slot 0 Digital DAC Playback Switch", |
346 | { "Right DAC Mixer", "RSlot 0", "Digital Right DAC"}, | 341 | "AIF1 Slot 0 Left"}, |
347 | 342 | { "Right Digital DAC Mixer", "AIF1 Slot 0 Digital DAC Playback Switch", | |
348 | /* End of route : HP out */ | 343 | "AIF1 Slot 0 Right"}, |
349 | { "HP", NULL, "Left DAC Mixer" }, | ||
350 | { "HP", NULL, "Right DAC Mixer" }, | ||
351 | }; | 344 | }; |
352 | 345 | ||
353 | static struct snd_soc_dai_ops sun8i_codec_dai_ops = { | 346 | static struct snd_soc_dai_ops sun8i_codec_dai_ops = { |
diff --git a/tools/include/linux/filter.h b/tools/include/linux/filter.h index 122153b16ea4..390d7c9685fd 100644 --- a/tools/include/linux/filter.h +++ b/tools/include/linux/filter.h | |||
@@ -168,6 +168,16 @@ | |||
168 | .off = OFF, \ | 168 | .off = OFF, \ |
169 | .imm = 0 }) | 169 | .imm = 0 }) |
170 | 170 | ||
171 | /* Atomic memory add, *(uint *)(dst_reg + off16) += src_reg */ | ||
172 | |||
173 | #define BPF_STX_XADD(SIZE, DST, SRC, OFF) \ | ||
174 | ((struct bpf_insn) { \ | ||
175 | .code = BPF_STX | BPF_SIZE(SIZE) | BPF_XADD, \ | ||
176 | .dst_reg = DST, \ | ||
177 | .src_reg = SRC, \ | ||
178 | .off = OFF, \ | ||
179 | .imm = 0 }) | ||
180 | |||
171 | /* Memory store, *(uint *) (dst_reg + off16) = imm32 */ | 181 | /* Memory store, *(uint *) (dst_reg + off16) = imm32 */ |
172 | 182 | ||
173 | #define BPF_ST_MEM(SIZE, DST, OFF, IMM) \ | 183 | #define BPF_ST_MEM(SIZE, DST, OFF, IMM) \ |
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 273f21fa32b5..7aa57225cbf7 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c | |||
@@ -130,6 +130,12 @@ static struct arch architectures[] = { | |||
130 | .name = "powerpc", | 130 | .name = "powerpc", |
131 | .init = powerpc__annotate_init, | 131 | .init = powerpc__annotate_init, |
132 | }, | 132 | }, |
133 | { | ||
134 | .name = "s390", | ||
135 | .objdump = { | ||
136 | .comment_char = '#', | ||
137 | }, | ||
138 | }, | ||
133 | }; | 139 | }; |
134 | 140 | ||
135 | static void ins__delete(struct ins_operands *ops) | 141 | static void ins__delete(struct ins_operands *ops) |
diff --git a/tools/power/cpupower/utils/helpers/cpuid.c b/tools/power/cpupower/utils/helpers/cpuid.c index 93b0aa74ca03..39c2c7d067bb 100644 --- a/tools/power/cpupower/utils/helpers/cpuid.c +++ b/tools/power/cpupower/utils/helpers/cpuid.c | |||
@@ -156,6 +156,7 @@ out: | |||
156 | */ | 156 | */ |
157 | case 0x2C: /* Westmere EP - Gulftown */ | 157 | case 0x2C: /* Westmere EP - Gulftown */ |
158 | cpu_info->caps |= CPUPOWER_CAP_HAS_TURBO_RATIO; | 158 | cpu_info->caps |= CPUPOWER_CAP_HAS_TURBO_RATIO; |
159 | break; | ||
159 | case 0x2A: /* SNB */ | 160 | case 0x2A: /* SNB */ |
160 | case 0x2D: /* SNB Xeon */ | 161 | case 0x2D: /* SNB Xeon */ |
161 | case 0x3A: /* IVB */ | 162 | case 0x3A: /* IVB */ |
diff --git a/tools/power/x86/turbostat/turbostat.8 b/tools/power/x86/turbostat/turbostat.8 index fedca3285326..ccf2a69365cc 100644 --- a/tools/power/x86/turbostat/turbostat.8 +++ b/tools/power/x86/turbostat/turbostat.8 | |||
@@ -100,6 +100,8 @@ The system configuration dump (if --quiet is not used) is followed by statistics | |||
100 | \fBCPU%c1, CPU%c3, CPU%c6, CPU%c7\fP show the percentage residency in hardware core idle states. These numbers are from hardware residency counters. | 100 | \fBCPU%c1, CPU%c3, CPU%c6, CPU%c7\fP show the percentage residency in hardware core idle states. These numbers are from hardware residency counters. |
101 | \fBCoreTmp\fP Degrees Celsius reported by the per-core Digital Thermal Sensor. | 101 | \fBCoreTmp\fP Degrees Celsius reported by the per-core Digital Thermal Sensor. |
102 | \fBPkgTtmp\fP Degrees Celsius reported by the per-package Package Thermal Monitor. | 102 | \fBPkgTtmp\fP Degrees Celsius reported by the per-package Package Thermal Monitor. |
103 | \fBGFX%rc6\fP The percentage of time the GPU is in the "render C6" state, rc6, during the measurement interval. From /sys/class/drm/card0/power/rc6_residency_ms. | ||
104 | \fBGFXMHz\fP Instantaneous snapshot of what sysfs presents at the end of the measurement interval. From /sys/class/graphics/fb0/device/drm/card0/gt_cur_freq_mhz. | ||
103 | \fBPkg%pc2, Pkg%pc3, Pkg%pc6, Pkg%pc7\fP percentage residency in hardware package idle states. These numbers are from hardware residency counters. | 105 | \fBPkg%pc2, Pkg%pc3, Pkg%pc6, Pkg%pc7\fP percentage residency in hardware package idle states. These numbers are from hardware residency counters. |
104 | \fBPkgWatt\fP Watts consumed by the whole package. | 106 | \fBPkgWatt\fP Watts consumed by the whole package. |
105 | \fBCorWatt\fP Watts consumed by the core part of the package. | 107 | \fBCorWatt\fP Watts consumed by the core part of the package. |
diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c index 828dccd3f01e..b11294730771 100644 --- a/tools/power/x86/turbostat/turbostat.c +++ b/tools/power/x86/turbostat/turbostat.c | |||
@@ -1142,7 +1142,7 @@ delta_thread(struct thread_data *new, struct thread_data *old, | |||
1142 | * it is possible for mperf's non-halted cycles + idle states | 1142 | * it is possible for mperf's non-halted cycles + idle states |
1143 | * to exceed TSC's all cycles: show c1 = 0% in that case. | 1143 | * to exceed TSC's all cycles: show c1 = 0% in that case. |
1144 | */ | 1144 | */ |
1145 | if ((old->mperf + core_delta->c3 + core_delta->c6 + core_delta->c7) > old->tsc) | 1145 | if ((old->mperf + core_delta->c3 + core_delta->c6 + core_delta->c7) > (old->tsc * tsc_tweak)) |
1146 | old->c1 = 0; | 1146 | old->c1 = 0; |
1147 | else { | 1147 | else { |
1148 | /* normal case, derive c1 */ | 1148 | /* normal case, derive c1 */ |
@@ -2485,8 +2485,10 @@ int snapshot_gfx_mhz(void) | |||
2485 | 2485 | ||
2486 | if (fp == NULL) | 2486 | if (fp == NULL) |
2487 | fp = fopen_or_die("/sys/class/graphics/fb0/device/drm/card0/gt_cur_freq_mhz", "r"); | 2487 | fp = fopen_or_die("/sys/class/graphics/fb0/device/drm/card0/gt_cur_freq_mhz", "r"); |
2488 | else | 2488 | else { |
2489 | rewind(fp); | 2489 | rewind(fp); |
2490 | fflush(fp); | ||
2491 | } | ||
2490 | 2492 | ||
2491 | retval = fscanf(fp, "%d", &gfx_cur_mhz); | 2493 | retval = fscanf(fp, "%d", &gfx_cur_mhz); |
2492 | if (retval != 1) | 2494 | if (retval != 1) |
@@ -3111,7 +3113,7 @@ int print_hwp(struct thread_data *t, struct core_data *c, struct pkg_data *p) | |||
3111 | return 0; | 3113 | return 0; |
3112 | 3114 | ||
3113 | fprintf(outf, "cpu%d: MSR_HWP_CAPABILITIES: 0x%08llx " | 3115 | fprintf(outf, "cpu%d: MSR_HWP_CAPABILITIES: 0x%08llx " |
3114 | "(high 0x%x guar 0x%x eff 0x%x low 0x%x)\n", | 3116 | "(high %d guar %d eff %d low %d)\n", |
3115 | cpu, msr, | 3117 | cpu, msr, |
3116 | (unsigned int)HWP_HIGHEST_PERF(msr), | 3118 | (unsigned int)HWP_HIGHEST_PERF(msr), |
3117 | (unsigned int)HWP_GUARANTEED_PERF(msr), | 3119 | (unsigned int)HWP_GUARANTEED_PERF(msr), |
@@ -3122,7 +3124,7 @@ int print_hwp(struct thread_data *t, struct core_data *c, struct pkg_data *p) | |||
3122 | return 0; | 3124 | return 0; |
3123 | 3125 | ||
3124 | fprintf(outf, "cpu%d: MSR_HWP_REQUEST: 0x%08llx " | 3126 | fprintf(outf, "cpu%d: MSR_HWP_REQUEST: 0x%08llx " |
3125 | "(min 0x%x max 0x%x des 0x%x epp 0x%x window 0x%x pkg 0x%x)\n", | 3127 | "(min %d max %d des %d epp 0x%x window 0x%x pkg 0x%x)\n", |
3126 | cpu, msr, | 3128 | cpu, msr, |
3127 | (unsigned int)(((msr) >> 0) & 0xff), | 3129 | (unsigned int)(((msr) >> 0) & 0xff), |
3128 | (unsigned int)(((msr) >> 8) & 0xff), | 3130 | (unsigned int)(((msr) >> 8) & 0xff), |
@@ -3136,7 +3138,7 @@ int print_hwp(struct thread_data *t, struct core_data *c, struct pkg_data *p) | |||
3136 | return 0; | 3138 | return 0; |
3137 | 3139 | ||
3138 | fprintf(outf, "cpu%d: MSR_HWP_REQUEST_PKG: 0x%08llx " | 3140 | fprintf(outf, "cpu%d: MSR_HWP_REQUEST_PKG: 0x%08llx " |
3139 | "(min 0x%x max 0x%x des 0x%x epp 0x%x window 0x%x)\n", | 3141 | "(min %d max %d des %d epp 0x%x window 0x%x)\n", |
3140 | cpu, msr, | 3142 | cpu, msr, |
3141 | (unsigned int)(((msr) >> 0) & 0xff), | 3143 | (unsigned int)(((msr) >> 0) & 0xff), |
3142 | (unsigned int)(((msr) >> 8) & 0xff), | 3144 | (unsigned int)(((msr) >> 8) & 0xff), |
@@ -3353,17 +3355,19 @@ void rapl_probe(unsigned int family, unsigned int model) | |||
3353 | case INTEL_FAM6_SKYLAKE_DESKTOP: /* SKL */ | 3355 | case INTEL_FAM6_SKYLAKE_DESKTOP: /* SKL */ |
3354 | case INTEL_FAM6_KABYLAKE_MOBILE: /* KBL */ | 3356 | case INTEL_FAM6_KABYLAKE_MOBILE: /* KBL */ |
3355 | case INTEL_FAM6_KABYLAKE_DESKTOP: /* KBL */ | 3357 | case INTEL_FAM6_KABYLAKE_DESKTOP: /* KBL */ |
3356 | do_rapl = RAPL_PKG | RAPL_DRAM | RAPL_DRAM_PERF_STATUS | RAPL_PKG_PERF_STATUS | RAPL_PKG_POWER_INFO; | 3358 | do_rapl = RAPL_PKG | RAPL_CORES | RAPL_CORE_POLICY | RAPL_DRAM | RAPL_DRAM_PERF_STATUS | RAPL_PKG_PERF_STATUS | RAPL_GFX | RAPL_PKG_POWER_INFO; |
3357 | BIC_PRESENT(BIC_PKG__); | 3359 | BIC_PRESENT(BIC_PKG__); |
3358 | BIC_PRESENT(BIC_RAM__); | 3360 | BIC_PRESENT(BIC_RAM__); |
3359 | if (rapl_joules) { | 3361 | if (rapl_joules) { |
3360 | BIC_PRESENT(BIC_Pkg_J); | 3362 | BIC_PRESENT(BIC_Pkg_J); |
3361 | BIC_PRESENT(BIC_Cor_J); | 3363 | BIC_PRESENT(BIC_Cor_J); |
3362 | BIC_PRESENT(BIC_RAM_J); | 3364 | BIC_PRESENT(BIC_RAM_J); |
3365 | BIC_PRESENT(BIC_GFX_J); | ||
3363 | } else { | 3366 | } else { |
3364 | BIC_PRESENT(BIC_PkgWatt); | 3367 | BIC_PRESENT(BIC_PkgWatt); |
3365 | BIC_PRESENT(BIC_CorWatt); | 3368 | BIC_PRESENT(BIC_CorWatt); |
3366 | BIC_PRESENT(BIC_RAMWatt); | 3369 | BIC_PRESENT(BIC_RAMWatt); |
3370 | BIC_PRESENT(BIC_GFXWatt); | ||
3367 | } | 3371 | } |
3368 | break; | 3372 | break; |
3369 | case INTEL_FAM6_HASWELL_X: /* HSX */ | 3373 | case INTEL_FAM6_HASWELL_X: /* HSX */ |
@@ -3478,7 +3482,7 @@ void perf_limit_reasons_probe(unsigned int family, unsigned int model) | |||
3478 | int print_thermal(struct thread_data *t, struct core_data *c, struct pkg_data *p) | 3482 | int print_thermal(struct thread_data *t, struct core_data *c, struct pkg_data *p) |
3479 | { | 3483 | { |
3480 | unsigned long long msr; | 3484 | unsigned long long msr; |
3481 | unsigned int dts; | 3485 | unsigned int dts, dts2; |
3482 | int cpu; | 3486 | int cpu; |
3483 | 3487 | ||
3484 | if (!(do_dts || do_ptm)) | 3488 | if (!(do_dts || do_ptm)) |
@@ -3503,7 +3507,6 @@ int print_thermal(struct thread_data *t, struct core_data *c, struct pkg_data *p | |||
3503 | fprintf(outf, "cpu%d: MSR_IA32_PACKAGE_THERM_STATUS: 0x%08llx (%d C)\n", | 3507 | fprintf(outf, "cpu%d: MSR_IA32_PACKAGE_THERM_STATUS: 0x%08llx (%d C)\n", |
3504 | cpu, msr, tcc_activation_temp - dts); | 3508 | cpu, msr, tcc_activation_temp - dts); |
3505 | 3509 | ||
3506 | #ifdef THERM_DEBUG | ||
3507 | if (get_msr(cpu, MSR_IA32_PACKAGE_THERM_INTERRUPT, &msr)) | 3510 | if (get_msr(cpu, MSR_IA32_PACKAGE_THERM_INTERRUPT, &msr)) |
3508 | return 0; | 3511 | return 0; |
3509 | 3512 | ||
@@ -3511,11 +3514,10 @@ int print_thermal(struct thread_data *t, struct core_data *c, struct pkg_data *p | |||
3511 | dts2 = (msr >> 8) & 0x7F; | 3514 | dts2 = (msr >> 8) & 0x7F; |
3512 | fprintf(outf, "cpu%d: MSR_IA32_PACKAGE_THERM_INTERRUPT: 0x%08llx (%d C, %d C)\n", | 3515 | fprintf(outf, "cpu%d: MSR_IA32_PACKAGE_THERM_INTERRUPT: 0x%08llx (%d C, %d C)\n", |
3513 | cpu, msr, tcc_activation_temp - dts, tcc_activation_temp - dts2); | 3516 | cpu, msr, tcc_activation_temp - dts, tcc_activation_temp - dts2); |
3514 | #endif | ||
3515 | } | 3517 | } |
3516 | 3518 | ||
3517 | 3519 | ||
3518 | if (do_dts) { | 3520 | if (do_dts && debug) { |
3519 | unsigned int resolution; | 3521 | unsigned int resolution; |
3520 | 3522 | ||
3521 | if (get_msr(cpu, MSR_IA32_THERM_STATUS, &msr)) | 3523 | if (get_msr(cpu, MSR_IA32_THERM_STATUS, &msr)) |
@@ -3526,7 +3528,6 @@ int print_thermal(struct thread_data *t, struct core_data *c, struct pkg_data *p | |||
3526 | fprintf(outf, "cpu%d: MSR_IA32_THERM_STATUS: 0x%08llx (%d C +/- %d)\n", | 3528 | fprintf(outf, "cpu%d: MSR_IA32_THERM_STATUS: 0x%08llx (%d C +/- %d)\n", |
3527 | cpu, msr, tcc_activation_temp - dts, resolution); | 3529 | cpu, msr, tcc_activation_temp - dts, resolution); |
3528 | 3530 | ||
3529 | #ifdef THERM_DEBUG | ||
3530 | if (get_msr(cpu, MSR_IA32_THERM_INTERRUPT, &msr)) | 3531 | if (get_msr(cpu, MSR_IA32_THERM_INTERRUPT, &msr)) |
3531 | return 0; | 3532 | return 0; |
3532 | 3533 | ||
@@ -3534,7 +3535,6 @@ int print_thermal(struct thread_data *t, struct core_data *c, struct pkg_data *p | |||
3534 | dts2 = (msr >> 8) & 0x7F; | 3535 | dts2 = (msr >> 8) & 0x7F; |
3535 | fprintf(outf, "cpu%d: MSR_IA32_THERM_INTERRUPT: 0x%08llx (%d C, %d C)\n", | 3536 | fprintf(outf, "cpu%d: MSR_IA32_THERM_INTERRUPT: 0x%08llx (%d C, %d C)\n", |
3536 | cpu, msr, tcc_activation_temp - dts, tcc_activation_temp - dts2); | 3537 | cpu, msr, tcc_activation_temp - dts, tcc_activation_temp - dts2); |
3537 | #endif | ||
3538 | } | 3538 | } |
3539 | 3539 | ||
3540 | return 0; | 3540 | return 0; |
@@ -4578,7 +4578,7 @@ int get_and_dump_counters(void) | |||
4578 | } | 4578 | } |
4579 | 4579 | ||
4580 | void print_version() { | 4580 | void print_version() { |
4581 | fprintf(outf, "turbostat version 17.02.24" | 4581 | fprintf(outf, "turbostat version 17.04.12" |
4582 | " - Len Brown <lenb@kernel.org>\n"); | 4582 | " - Len Brown <lenb@kernel.org>\n"); |
4583 | } | 4583 | } |
4584 | 4584 | ||
diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile index 6a1ad58cb66f..9af09e8099c0 100644 --- a/tools/testing/selftests/bpf/Makefile +++ b/tools/testing/selftests/bpf/Makefile | |||
@@ -1,7 +1,14 @@ | |||
1 | LIBDIR := ../../../lib | 1 | LIBDIR := ../../../lib |
2 | BPFDIR := $(LIBDIR)/bpf | 2 | BPFDIR := $(LIBDIR)/bpf |
3 | APIDIR := ../../../include/uapi | ||
4 | GENDIR := ../../../../include/generated | ||
5 | GENHDR := $(GENDIR)/autoconf.h | ||
3 | 6 | ||
4 | CFLAGS += -Wall -O2 -I../../../include/uapi -I$(LIBDIR) | 7 | ifneq ($(wildcard $(GENHDR)),) |
8 | GENFLAGS := -DHAVE_GENHDR | ||
9 | endif | ||
10 | |||
11 | CFLAGS += -Wall -O2 -I$(APIDIR) -I$(LIBDIR) -I$(GENDIR) $(GENFLAGS) | ||
5 | LDLIBS += -lcap | 12 | LDLIBS += -lcap |
6 | 13 | ||
7 | TEST_GEN_PROGS = test_verifier test_tag test_maps test_lru_map test_lpm_map | 14 | TEST_GEN_PROGS = test_verifier test_tag test_maps test_lru_map test_lpm_map |
diff --git a/tools/testing/selftests/bpf/test_maps.c b/tools/testing/selftests/bpf/test_maps.c index a0aa2009b0e0..20f1871874df 100644 --- a/tools/testing/selftests/bpf/test_maps.c +++ b/tools/testing/selftests/bpf/test_maps.c | |||
@@ -282,7 +282,7 @@ static void test_arraymap_percpu(int task, void *data) | |||
282 | { | 282 | { |
283 | unsigned int nr_cpus = bpf_num_possible_cpus(); | 283 | unsigned int nr_cpus = bpf_num_possible_cpus(); |
284 | int key, next_key, fd, i; | 284 | int key, next_key, fd, i; |
285 | long values[nr_cpus]; | 285 | long long values[nr_cpus]; |
286 | 286 | ||
287 | fd = bpf_create_map(BPF_MAP_TYPE_PERCPU_ARRAY, sizeof(key), | 287 | fd = bpf_create_map(BPF_MAP_TYPE_PERCPU_ARRAY, sizeof(key), |
288 | sizeof(values[0]), 2, 0); | 288 | sizeof(values[0]), 2, 0); |
@@ -340,7 +340,7 @@ static void test_arraymap_percpu_many_keys(void) | |||
340 | * allocator more than anything else | 340 | * allocator more than anything else |
341 | */ | 341 | */ |
342 | unsigned int nr_keys = 2000; | 342 | unsigned int nr_keys = 2000; |
343 | long values[nr_cpus]; | 343 | long long values[nr_cpus]; |
344 | int key, fd, i; | 344 | int key, fd, i; |
345 | 345 | ||
346 | fd = bpf_create_map(BPF_MAP_TYPE_PERCPU_ARRAY, sizeof(key), | 346 | fd = bpf_create_map(BPF_MAP_TYPE_PERCPU_ARRAY, sizeof(key), |
diff --git a/tools/testing/selftests/bpf/test_verifier.c b/tools/testing/selftests/bpf/test_verifier.c index d1555e4240c0..c848e90b6421 100644 --- a/tools/testing/selftests/bpf/test_verifier.c +++ b/tools/testing/selftests/bpf/test_verifier.c | |||
@@ -30,6 +30,14 @@ | |||
30 | 30 | ||
31 | #include <bpf/bpf.h> | 31 | #include <bpf/bpf.h> |
32 | 32 | ||
33 | #ifdef HAVE_GENHDR | ||
34 | # include "autoconf.h" | ||
35 | #else | ||
36 | # if defined(__i386) || defined(__x86_64) || defined(__s390x__) || defined(__aarch64__) | ||
37 | # define CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS 1 | ||
38 | # endif | ||
39 | #endif | ||
40 | |||
33 | #include "../../../include/linux/filter.h" | 41 | #include "../../../include/linux/filter.h" |
34 | 42 | ||
35 | #ifndef ARRAY_SIZE | 43 | #ifndef ARRAY_SIZE |
@@ -39,6 +47,8 @@ | |||
39 | #define MAX_INSNS 512 | 47 | #define MAX_INSNS 512 |
40 | #define MAX_FIXUPS 8 | 48 | #define MAX_FIXUPS 8 |
41 | 49 | ||
50 | #define F_NEEDS_EFFICIENT_UNALIGNED_ACCESS (1 << 0) | ||
51 | |||
42 | struct bpf_test { | 52 | struct bpf_test { |
43 | const char *descr; | 53 | const char *descr; |
44 | struct bpf_insn insns[MAX_INSNS]; | 54 | struct bpf_insn insns[MAX_INSNS]; |
@@ -53,6 +63,7 @@ struct bpf_test { | |||
53 | REJECT | 63 | REJECT |
54 | } result, result_unpriv; | 64 | } result, result_unpriv; |
55 | enum bpf_prog_type prog_type; | 65 | enum bpf_prog_type prog_type; |
66 | uint8_t flags; | ||
56 | }; | 67 | }; |
57 | 68 | ||
58 | /* Note we want this to be 64 bit aligned so that the end of our array is | 69 | /* Note we want this to be 64 bit aligned so that the end of our array is |
@@ -2432,6 +2443,30 @@ static struct bpf_test tests[] = { | |||
2432 | .prog_type = BPF_PROG_TYPE_SCHED_CLS, | 2443 | .prog_type = BPF_PROG_TYPE_SCHED_CLS, |
2433 | }, | 2444 | }, |
2434 | { | 2445 | { |
2446 | "direct packet access: test15 (spill with xadd)", | ||
2447 | .insns = { | ||
2448 | BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1, | ||
2449 | offsetof(struct __sk_buff, data)), | ||
2450 | BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_1, | ||
2451 | offsetof(struct __sk_buff, data_end)), | ||
2452 | BPF_MOV64_REG(BPF_REG_0, BPF_REG_2), | ||
2453 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_0, 8), | ||
2454 | BPF_JMP_REG(BPF_JGT, BPF_REG_0, BPF_REG_3, 8), | ||
2455 | BPF_MOV64_IMM(BPF_REG_5, 4096), | ||
2456 | BPF_MOV64_REG(BPF_REG_4, BPF_REG_10), | ||
2457 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_4, -8), | ||
2458 | BPF_STX_MEM(BPF_DW, BPF_REG_4, BPF_REG_2, 0), | ||
2459 | BPF_STX_XADD(BPF_DW, BPF_REG_4, BPF_REG_5, 0), | ||
2460 | BPF_LDX_MEM(BPF_DW, BPF_REG_2, BPF_REG_4, 0), | ||
2461 | BPF_STX_MEM(BPF_W, BPF_REG_2, BPF_REG_5, 0), | ||
2462 | BPF_MOV64_IMM(BPF_REG_0, 0), | ||
2463 | BPF_EXIT_INSN(), | ||
2464 | }, | ||
2465 | .errstr = "R2 invalid mem access 'inv'", | ||
2466 | .result = REJECT, | ||
2467 | .prog_type = BPF_PROG_TYPE_SCHED_CLS, | ||
2468 | }, | ||
2469 | { | ||
2435 | "helper access to packet: test1, valid packet_ptr range", | 2470 | "helper access to packet: test1, valid packet_ptr range", |
2436 | .insns = { | 2471 | .insns = { |
2437 | BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1, | 2472 | BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1, |
@@ -2934,6 +2969,7 @@ static struct bpf_test tests[] = { | |||
2934 | .errstr_unpriv = "R0 pointer arithmetic prohibited", | 2969 | .errstr_unpriv = "R0 pointer arithmetic prohibited", |
2935 | .result_unpriv = REJECT, | 2970 | .result_unpriv = REJECT, |
2936 | .result = ACCEPT, | 2971 | .result = ACCEPT, |
2972 | .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS, | ||
2937 | }, | 2973 | }, |
2938 | { | 2974 | { |
2939 | "valid map access into an array with a variable", | 2975 | "valid map access into an array with a variable", |
@@ -2957,6 +2993,7 @@ static struct bpf_test tests[] = { | |||
2957 | .errstr_unpriv = "R0 pointer arithmetic prohibited", | 2993 | .errstr_unpriv = "R0 pointer arithmetic prohibited", |
2958 | .result_unpriv = REJECT, | 2994 | .result_unpriv = REJECT, |
2959 | .result = ACCEPT, | 2995 | .result = ACCEPT, |
2996 | .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS, | ||
2960 | }, | 2997 | }, |
2961 | { | 2998 | { |
2962 | "valid map access into an array with a signed variable", | 2999 | "valid map access into an array with a signed variable", |
@@ -2984,6 +3021,7 @@ static struct bpf_test tests[] = { | |||
2984 | .errstr_unpriv = "R0 pointer arithmetic prohibited", | 3021 | .errstr_unpriv = "R0 pointer arithmetic prohibited", |
2985 | .result_unpriv = REJECT, | 3022 | .result_unpriv = REJECT, |
2986 | .result = ACCEPT, | 3023 | .result = ACCEPT, |
3024 | .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS, | ||
2987 | }, | 3025 | }, |
2988 | { | 3026 | { |
2989 | "invalid map access into an array with a constant", | 3027 | "invalid map access into an array with a constant", |
@@ -3025,6 +3063,7 @@ static struct bpf_test tests[] = { | |||
3025 | .errstr = "R0 min value is outside of the array range", | 3063 | .errstr = "R0 min value is outside of the array range", |
3026 | .result_unpriv = REJECT, | 3064 | .result_unpriv = REJECT, |
3027 | .result = REJECT, | 3065 | .result = REJECT, |
3066 | .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS, | ||
3028 | }, | 3067 | }, |
3029 | { | 3068 | { |
3030 | "invalid map access into an array with a variable", | 3069 | "invalid map access into an array with a variable", |
@@ -3048,6 +3087,7 @@ static struct bpf_test tests[] = { | |||
3048 | .errstr = "R0 min value is negative, either use unsigned index or do a if (index >=0) check.", | 3087 | .errstr = "R0 min value is negative, either use unsigned index or do a if (index >=0) check.", |
3049 | .result_unpriv = REJECT, | 3088 | .result_unpriv = REJECT, |
3050 | .result = REJECT, | 3089 | .result = REJECT, |
3090 | .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS, | ||
3051 | }, | 3091 | }, |
3052 | { | 3092 | { |
3053 | "invalid map access into an array with no floor check", | 3093 | "invalid map access into an array with no floor check", |
@@ -3074,6 +3114,7 @@ static struct bpf_test tests[] = { | |||
3074 | .errstr = "R0 min value is negative, either use unsigned index or do a if (index >=0) check.", | 3114 | .errstr = "R0 min value is negative, either use unsigned index or do a if (index >=0) check.", |
3075 | .result_unpriv = REJECT, | 3115 | .result_unpriv = REJECT, |
3076 | .result = REJECT, | 3116 | .result = REJECT, |
3117 | .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS, | ||
3077 | }, | 3118 | }, |
3078 | { | 3119 | { |
3079 | "invalid map access into an array with a invalid max check", | 3120 | "invalid map access into an array with a invalid max check", |
@@ -3100,6 +3141,7 @@ static struct bpf_test tests[] = { | |||
3100 | .errstr = "invalid access to map value, value_size=48 off=44 size=8", | 3141 | .errstr = "invalid access to map value, value_size=48 off=44 size=8", |
3101 | .result_unpriv = REJECT, | 3142 | .result_unpriv = REJECT, |
3102 | .result = REJECT, | 3143 | .result = REJECT, |
3144 | .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS, | ||
3103 | }, | 3145 | }, |
3104 | { | 3146 | { |
3105 | "invalid map access into an array with a invalid max check", | 3147 | "invalid map access into an array with a invalid max check", |
@@ -3129,6 +3171,7 @@ static struct bpf_test tests[] = { | |||
3129 | .errstr = "R0 min value is negative, either use unsigned index or do a if (index >=0) check.", | 3171 | .errstr = "R0 min value is negative, either use unsigned index or do a if (index >=0) check.", |
3130 | .result_unpriv = REJECT, | 3172 | .result_unpriv = REJECT, |
3131 | .result = REJECT, | 3173 | .result = REJECT, |
3174 | .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS, | ||
3132 | }, | 3175 | }, |
3133 | { | 3176 | { |
3134 | "multiple registers share map_lookup_elem result", | 3177 | "multiple registers share map_lookup_elem result", |
@@ -3252,6 +3295,7 @@ static struct bpf_test tests[] = { | |||
3252 | .result = REJECT, | 3295 | .result = REJECT, |
3253 | .errstr_unpriv = "R0 pointer arithmetic prohibited", | 3296 | .errstr_unpriv = "R0 pointer arithmetic prohibited", |
3254 | .result_unpriv = REJECT, | 3297 | .result_unpriv = REJECT, |
3298 | .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS, | ||
3255 | }, | 3299 | }, |
3256 | { | 3300 | { |
3257 | "constant register |= constant should keep constant type", | 3301 | "constant register |= constant should keep constant type", |
@@ -3418,6 +3462,26 @@ static struct bpf_test tests[] = { | |||
3418 | .prog_type = BPF_PROG_TYPE_LWT_XMIT, | 3462 | .prog_type = BPF_PROG_TYPE_LWT_XMIT, |
3419 | }, | 3463 | }, |
3420 | { | 3464 | { |
3465 | "overlapping checks for direct packet access", | ||
3466 | .insns = { | ||
3467 | BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1, | ||
3468 | offsetof(struct __sk_buff, data)), | ||
3469 | BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_1, | ||
3470 | offsetof(struct __sk_buff, data_end)), | ||
3471 | BPF_MOV64_REG(BPF_REG_0, BPF_REG_2), | ||
3472 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_0, 8), | ||
3473 | BPF_JMP_REG(BPF_JGT, BPF_REG_0, BPF_REG_3, 4), | ||
3474 | BPF_MOV64_REG(BPF_REG_1, BPF_REG_2), | ||
3475 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, 6), | ||
3476 | BPF_JMP_REG(BPF_JGT, BPF_REG_1, BPF_REG_3, 1), | ||
3477 | BPF_LDX_MEM(BPF_H, BPF_REG_0, BPF_REG_2, 6), | ||
3478 | BPF_MOV64_IMM(BPF_REG_0, 0), | ||
3479 | BPF_EXIT_INSN(), | ||
3480 | }, | ||
3481 | .result = ACCEPT, | ||
3482 | .prog_type = BPF_PROG_TYPE_LWT_XMIT, | ||
3483 | }, | ||
3484 | { | ||
3421 | "invalid access of tc_classid for LWT_IN", | 3485 | "invalid access of tc_classid for LWT_IN", |
3422 | .insns = { | 3486 | .insns = { |
3423 | BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1, | 3487 | BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1, |
@@ -3961,7 +4025,208 @@ static struct bpf_test tests[] = { | |||
3961 | .result_unpriv = REJECT, | 4025 | .result_unpriv = REJECT, |
3962 | }, | 4026 | }, |
3963 | { | 4027 | { |
3964 | "map element value (adjusted) is preserved across register spilling", | 4028 | "map element value or null is marked on register spilling", |
4029 | .insns = { | ||
4030 | BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), | ||
4031 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), | ||
4032 | BPF_ST_MEM(BPF_DW, BPF_REG_2, 0, 0), | ||
4033 | BPF_LD_MAP_FD(BPF_REG_1, 0), | ||
4034 | BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem), | ||
4035 | BPF_MOV64_REG(BPF_REG_1, BPF_REG_10), | ||
4036 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, -152), | ||
4037 | BPF_STX_MEM(BPF_DW, BPF_REG_1, BPF_REG_0, 0), | ||
4038 | BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 2), | ||
4039 | BPF_LDX_MEM(BPF_DW, BPF_REG_3, BPF_REG_1, 0), | ||
4040 | BPF_ST_MEM(BPF_DW, BPF_REG_3, 0, 42), | ||
4041 | BPF_EXIT_INSN(), | ||
4042 | }, | ||
4043 | .fixup_map2 = { 3 }, | ||
4044 | .errstr_unpriv = "R0 leaks addr", | ||
4045 | .result = ACCEPT, | ||
4046 | .result_unpriv = REJECT, | ||
4047 | }, | ||
4048 | { | ||
4049 | "map element value store of cleared call register", | ||
4050 | .insns = { | ||
4051 | BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), | ||
4052 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), | ||
4053 | BPF_ST_MEM(BPF_DW, BPF_REG_2, 0, 0), | ||
4054 | BPF_LD_MAP_FD(BPF_REG_1, 0), | ||
4055 | BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem), | ||
4056 | BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 1), | ||
4057 | BPF_STX_MEM(BPF_DW, BPF_REG_0, BPF_REG_1, 0), | ||
4058 | BPF_EXIT_INSN(), | ||
4059 | }, | ||
4060 | .fixup_map2 = { 3 }, | ||
4061 | .errstr_unpriv = "R1 !read_ok", | ||
4062 | .errstr = "R1 !read_ok", | ||
4063 | .result = REJECT, | ||
4064 | .result_unpriv = REJECT, | ||
4065 | }, | ||
4066 | { | ||
4067 | "map element value with unaligned store", | ||
4068 | .insns = { | ||
4069 | BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), | ||
4070 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), | ||
4071 | BPF_ST_MEM(BPF_DW, BPF_REG_2, 0, 0), | ||
4072 | BPF_LD_MAP_FD(BPF_REG_1, 0), | ||
4073 | BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem), | ||
4074 | BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 17), | ||
4075 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_0, 3), | ||
4076 | BPF_ST_MEM(BPF_DW, BPF_REG_0, 0, 42), | ||
4077 | BPF_ST_MEM(BPF_DW, BPF_REG_0, 2, 43), | ||
4078 | BPF_ST_MEM(BPF_DW, BPF_REG_0, -2, 44), | ||
4079 | BPF_MOV64_REG(BPF_REG_8, BPF_REG_0), | ||
4080 | BPF_ST_MEM(BPF_DW, BPF_REG_8, 0, 32), | ||
4081 | BPF_ST_MEM(BPF_DW, BPF_REG_8, 2, 33), | ||
4082 | BPF_ST_MEM(BPF_DW, BPF_REG_8, -2, 34), | ||
4083 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_8, 5), | ||
4084 | BPF_ST_MEM(BPF_DW, BPF_REG_8, 0, 22), | ||
4085 | BPF_ST_MEM(BPF_DW, BPF_REG_8, 4, 23), | ||
4086 | BPF_ST_MEM(BPF_DW, BPF_REG_8, -7, 24), | ||
4087 | BPF_MOV64_REG(BPF_REG_7, BPF_REG_8), | ||
4088 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_7, 3), | ||
4089 | BPF_ST_MEM(BPF_DW, BPF_REG_7, 0, 22), | ||
4090 | BPF_ST_MEM(BPF_DW, BPF_REG_7, 4, 23), | ||
4091 | BPF_ST_MEM(BPF_DW, BPF_REG_7, -4, 24), | ||
4092 | BPF_EXIT_INSN(), | ||
4093 | }, | ||
4094 | .fixup_map2 = { 3 }, | ||
4095 | .errstr_unpriv = "R0 pointer arithmetic prohibited", | ||
4096 | .result = ACCEPT, | ||
4097 | .result_unpriv = REJECT, | ||
4098 | .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS, | ||
4099 | }, | ||
4100 | { | ||
4101 | "map element value with unaligned load", | ||
4102 | .insns = { | ||
4103 | BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), | ||
4104 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), | ||
4105 | BPF_ST_MEM(BPF_DW, BPF_REG_2, 0, 0), | ||
4106 | BPF_LD_MAP_FD(BPF_REG_1, 0), | ||
4107 | BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem), | ||
4108 | BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 11), | ||
4109 | BPF_LDX_MEM(BPF_W, BPF_REG_1, BPF_REG_0, 0), | ||
4110 | BPF_JMP_IMM(BPF_JGE, BPF_REG_1, MAX_ENTRIES, 9), | ||
4111 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_0, 3), | ||
4112 | BPF_LDX_MEM(BPF_DW, BPF_REG_7, BPF_REG_0, 0), | ||
4113 | BPF_LDX_MEM(BPF_DW, BPF_REG_7, BPF_REG_0, 2), | ||
4114 | BPF_MOV64_REG(BPF_REG_8, BPF_REG_0), | ||
4115 | BPF_LDX_MEM(BPF_DW, BPF_REG_7, BPF_REG_8, 0), | ||
4116 | BPF_LDX_MEM(BPF_DW, BPF_REG_7, BPF_REG_8, 2), | ||
4117 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_0, 5), | ||
4118 | BPF_LDX_MEM(BPF_DW, BPF_REG_7, BPF_REG_0, 0), | ||
4119 | BPF_LDX_MEM(BPF_DW, BPF_REG_7, BPF_REG_0, 4), | ||
4120 | BPF_EXIT_INSN(), | ||
4121 | }, | ||
4122 | .fixup_map2 = { 3 }, | ||
4123 | .errstr_unpriv = "R0 pointer arithmetic prohibited", | ||
4124 | .result = ACCEPT, | ||
4125 | .result_unpriv = REJECT, | ||
4126 | .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS, | ||
4127 | }, | ||
4128 | { | ||
4129 | "map element value illegal alu op, 1", | ||
4130 | .insns = { | ||
4131 | BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), | ||
4132 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), | ||
4133 | BPF_ST_MEM(BPF_DW, BPF_REG_2, 0, 0), | ||
4134 | BPF_LD_MAP_FD(BPF_REG_1, 0), | ||
4135 | BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem), | ||
4136 | BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 2), | ||
4137 | BPF_ALU64_IMM(BPF_AND, BPF_REG_0, 8), | ||
4138 | BPF_ST_MEM(BPF_DW, BPF_REG_0, 0, 22), | ||
4139 | BPF_EXIT_INSN(), | ||
4140 | }, | ||
4141 | .fixup_map2 = { 3 }, | ||
4142 | .errstr_unpriv = "R0 pointer arithmetic prohibited", | ||
4143 | .errstr = "invalid mem access 'inv'", | ||
4144 | .result = REJECT, | ||
4145 | .result_unpriv = REJECT, | ||
4146 | }, | ||
4147 | { | ||
4148 | "map element value illegal alu op, 2", | ||
4149 | .insns = { | ||
4150 | BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), | ||
4151 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), | ||
4152 | BPF_ST_MEM(BPF_DW, BPF_REG_2, 0, 0), | ||
4153 | BPF_LD_MAP_FD(BPF_REG_1, 0), | ||
4154 | BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem), | ||
4155 | BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 2), | ||
4156 | BPF_ALU32_IMM(BPF_ADD, BPF_REG_0, 0), | ||
4157 | BPF_ST_MEM(BPF_DW, BPF_REG_0, 0, 22), | ||
4158 | BPF_EXIT_INSN(), | ||
4159 | }, | ||
4160 | .fixup_map2 = { 3 }, | ||
4161 | .errstr_unpriv = "R0 pointer arithmetic prohibited", | ||
4162 | .errstr = "invalid mem access 'inv'", | ||
4163 | .result = REJECT, | ||
4164 | .result_unpriv = REJECT, | ||
4165 | }, | ||
4166 | { | ||
4167 | "map element value illegal alu op, 3", | ||
4168 | .insns = { | ||
4169 | BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), | ||
4170 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), | ||
4171 | BPF_ST_MEM(BPF_DW, BPF_REG_2, 0, 0), | ||
4172 | BPF_LD_MAP_FD(BPF_REG_1, 0), | ||
4173 | BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem), | ||
4174 | BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 2), | ||
4175 | BPF_ALU64_IMM(BPF_DIV, BPF_REG_0, 42), | ||
4176 | BPF_ST_MEM(BPF_DW, BPF_REG_0, 0, 22), | ||
4177 | BPF_EXIT_INSN(), | ||
4178 | }, | ||
4179 | .fixup_map2 = { 3 }, | ||
4180 | .errstr_unpriv = "R0 pointer arithmetic prohibited", | ||
4181 | .errstr = "invalid mem access 'inv'", | ||
4182 | .result = REJECT, | ||
4183 | .result_unpriv = REJECT, | ||
4184 | }, | ||
4185 | { | ||
4186 | "map element value illegal alu op, 4", | ||
4187 | .insns = { | ||
4188 | BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), | ||
4189 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), | ||
4190 | BPF_ST_MEM(BPF_DW, BPF_REG_2, 0, 0), | ||
4191 | BPF_LD_MAP_FD(BPF_REG_1, 0), | ||
4192 | BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem), | ||
4193 | BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 2), | ||
4194 | BPF_ENDIAN(BPF_FROM_BE, BPF_REG_0, 64), | ||
4195 | BPF_ST_MEM(BPF_DW, BPF_REG_0, 0, 22), | ||
4196 | BPF_EXIT_INSN(), | ||
4197 | }, | ||
4198 | .fixup_map2 = { 3 }, | ||
4199 | .errstr_unpriv = "R0 pointer arithmetic prohibited", | ||
4200 | .errstr = "invalid mem access 'inv'", | ||
4201 | .result = REJECT, | ||
4202 | .result_unpriv = REJECT, | ||
4203 | }, | ||
4204 | { | ||
4205 | "map element value illegal alu op, 5", | ||
4206 | .insns = { | ||
4207 | BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), | ||
4208 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), | ||
4209 | BPF_ST_MEM(BPF_DW, BPF_REG_2, 0, 0), | ||
4210 | BPF_LD_MAP_FD(BPF_REG_1, 0), | ||
4211 | BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem), | ||
4212 | BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 7), | ||
4213 | BPF_MOV64_IMM(BPF_REG_3, 4096), | ||
4214 | BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), | ||
4215 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), | ||
4216 | BPF_STX_MEM(BPF_DW, BPF_REG_2, BPF_REG_0, 0), | ||
4217 | BPF_STX_XADD(BPF_DW, BPF_REG_2, BPF_REG_3, 0), | ||
4218 | BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_2, 0), | ||
4219 | BPF_ST_MEM(BPF_DW, BPF_REG_0, 0, 22), | ||
4220 | BPF_EXIT_INSN(), | ||
4221 | }, | ||
4222 | .fixup_map2 = { 3 }, | ||
4223 | .errstr_unpriv = "R0 invalid mem access 'inv'", | ||
4224 | .errstr = "R0 invalid mem access 'inv'", | ||
4225 | .result = REJECT, | ||
4226 | .result_unpriv = REJECT, | ||
4227 | }, | ||
4228 | { | ||
4229 | "map element value is preserved across register spilling", | ||
3965 | .insns = { | 4230 | .insns = { |
3966 | BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), | 4231 | BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), |
3967 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), | 4232 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), |
@@ -3983,6 +4248,7 @@ static struct bpf_test tests[] = { | |||
3983 | .errstr_unpriv = "R0 pointer arithmetic prohibited", | 4248 | .errstr_unpriv = "R0 pointer arithmetic prohibited", |
3984 | .result = ACCEPT, | 4249 | .result = ACCEPT, |
3985 | .result_unpriv = REJECT, | 4250 | .result_unpriv = REJECT, |
4251 | .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS, | ||
3986 | }, | 4252 | }, |
3987 | { | 4253 | { |
3988 | "helper access to variable memory: stack, bitwise AND + JMP, correct bounds", | 4254 | "helper access to variable memory: stack, bitwise AND + JMP, correct bounds", |
@@ -4421,6 +4687,7 @@ static struct bpf_test tests[] = { | |||
4421 | .errstr = "R0 min value is negative, either use unsigned index or do a if (index >=0) check.", | 4687 | .errstr = "R0 min value is negative, either use unsigned index or do a if (index >=0) check.", |
4422 | .result = REJECT, | 4688 | .result = REJECT, |
4423 | .result_unpriv = REJECT, | 4689 | .result_unpriv = REJECT, |
4690 | .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS, | ||
4424 | }, | 4691 | }, |
4425 | { | 4692 | { |
4426 | "invalid range check", | 4693 | "invalid range check", |
@@ -4452,6 +4719,7 @@ static struct bpf_test tests[] = { | |||
4452 | .errstr = "R0 min value is negative, either use unsigned index or do a if (index >=0) check.", | 4719 | .errstr = "R0 min value is negative, either use unsigned index or do a if (index >=0) check.", |
4453 | .result = REJECT, | 4720 | .result = REJECT, |
4454 | .result_unpriv = REJECT, | 4721 | .result_unpriv = REJECT, |
4722 | .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS, | ||
4455 | } | 4723 | } |
4456 | }; | 4724 | }; |
4457 | 4725 | ||
@@ -4530,11 +4798,11 @@ static void do_test_fixup(struct bpf_test *test, struct bpf_insn *prog, | |||
4530 | static void do_test_single(struct bpf_test *test, bool unpriv, | 4798 | static void do_test_single(struct bpf_test *test, bool unpriv, |
4531 | int *passes, int *errors) | 4799 | int *passes, int *errors) |
4532 | { | 4800 | { |
4801 | int fd_prog, expected_ret, reject_from_alignment; | ||
4533 | struct bpf_insn *prog = test->insns; | 4802 | struct bpf_insn *prog = test->insns; |
4534 | int prog_len = probe_filter_length(prog); | 4803 | int prog_len = probe_filter_length(prog); |
4535 | int prog_type = test->prog_type; | 4804 | int prog_type = test->prog_type; |
4536 | int fd_f1 = -1, fd_f2 = -1, fd_f3 = -1; | 4805 | int fd_f1 = -1, fd_f2 = -1, fd_f3 = -1; |
4537 | int fd_prog, expected_ret; | ||
4538 | const char *expected_err; | 4806 | const char *expected_err; |
4539 | 4807 | ||
4540 | do_test_fixup(test, prog, &fd_f1, &fd_f2, &fd_f3); | 4808 | do_test_fixup(test, prog, &fd_f1, &fd_f2, &fd_f3); |
@@ -4547,8 +4815,19 @@ static void do_test_single(struct bpf_test *test, bool unpriv, | |||
4547 | test->result_unpriv : test->result; | 4815 | test->result_unpriv : test->result; |
4548 | expected_err = unpriv && test->errstr_unpriv ? | 4816 | expected_err = unpriv && test->errstr_unpriv ? |
4549 | test->errstr_unpriv : test->errstr; | 4817 | test->errstr_unpriv : test->errstr; |
4818 | |||
4819 | reject_from_alignment = fd_prog < 0 && | ||
4820 | (test->flags & F_NEEDS_EFFICIENT_UNALIGNED_ACCESS) && | ||
4821 | strstr(bpf_vlog, "Unknown alignment."); | ||
4822 | #ifdef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS | ||
4823 | if (reject_from_alignment) { | ||
4824 | printf("FAIL\nFailed due to alignment despite having efficient unaligned access: '%s'!\n", | ||
4825 | strerror(errno)); | ||
4826 | goto fail_log; | ||
4827 | } | ||
4828 | #endif | ||
4550 | if (expected_ret == ACCEPT) { | 4829 | if (expected_ret == ACCEPT) { |
4551 | if (fd_prog < 0) { | 4830 | if (fd_prog < 0 && !reject_from_alignment) { |
4552 | printf("FAIL\nFailed to load prog '%s'!\n", | 4831 | printf("FAIL\nFailed to load prog '%s'!\n", |
4553 | strerror(errno)); | 4832 | strerror(errno)); |
4554 | goto fail_log; | 4833 | goto fail_log; |
@@ -4558,14 +4837,15 @@ static void do_test_single(struct bpf_test *test, bool unpriv, | |||
4558 | printf("FAIL\nUnexpected success to load!\n"); | 4837 | printf("FAIL\nUnexpected success to load!\n"); |
4559 | goto fail_log; | 4838 | goto fail_log; |
4560 | } | 4839 | } |
4561 | if (!strstr(bpf_vlog, expected_err)) { | 4840 | if (!strstr(bpf_vlog, expected_err) && !reject_from_alignment) { |
4562 | printf("FAIL\nUnexpected error message!\n"); | 4841 | printf("FAIL\nUnexpected error message!\n"); |
4563 | goto fail_log; | 4842 | goto fail_log; |
4564 | } | 4843 | } |
4565 | } | 4844 | } |
4566 | 4845 | ||
4567 | (*passes)++; | 4846 | (*passes)++; |
4568 | printf("OK\n"); | 4847 | printf("OK%s\n", reject_from_alignment ? |
4848 | " (NOTE: reject due to unknown alignment)" : ""); | ||
4569 | close_fds: | 4849 | close_fds: |
4570 | close(fd_prog); | 4850 | close(fd_prog); |
4571 | close(fd_f1); | 4851 | close(fd_f1); |
diff --git a/tools/testing/selftests/ftrace/test.d/ftrace/func-filter-pid.tc b/tools/testing/selftests/ftrace/test.d/ftrace/func-filter-pid.tc new file mode 100644 index 000000000000..bab5ff7c607e --- /dev/null +++ b/tools/testing/selftests/ftrace/test.d/ftrace/func-filter-pid.tc | |||
@@ -0,0 +1,117 @@ | |||
1 | #!/bin/sh | ||
2 | # description: ftrace - function pid filters | ||
3 | |||
4 | # Make sure that function pid matching filter works. | ||
5 | # Also test it on an instance directory | ||
6 | |||
7 | if ! grep -q function available_tracers; then | ||
8 | echo "no function tracer configured" | ||
9 | exit_unsupported | ||
10 | fi | ||
11 | |||
12 | if [ ! -f set_ftrace_pid ]; then | ||
13 | echo "set_ftrace_pid not found? Is function tracer not set?" | ||
14 | exit_unsupported | ||
15 | fi | ||
16 | |||
17 | if [ ! -f set_ftrace_filter ]; then | ||
18 | echo "set_ftrace_filter not found? Is function tracer not set?" | ||
19 | exit_unsupported | ||
20 | fi | ||
21 | |||
22 | do_function_fork=1 | ||
23 | |||
24 | if [ ! -f options/function-fork ]; then | ||
25 | do_function_fork=0 | ||
26 | echo "no option for function-fork found. Option will not be tested." | ||
27 | fi | ||
28 | |||
29 | read PID _ < /proc/self/stat | ||
30 | |||
31 | if [ $do_function_fork -eq 1 ]; then | ||
32 | # default value of function-fork option | ||
33 | orig_value=`grep function-fork trace_options` | ||
34 | fi | ||
35 | |||
36 | do_reset() { | ||
37 | reset_tracer | ||
38 | clear_trace | ||
39 | enable_tracing | ||
40 | echo > set_ftrace_filter | ||
41 | echo > set_ftrace_pid | ||
42 | |||
43 | if [ $do_function_fork -eq 0 ]; then | ||
44 | return | ||
45 | fi | ||
46 | |||
47 | echo $orig_value > trace_options | ||
48 | } | ||
49 | |||
50 | fail() { # msg | ||
51 | do_reset | ||
52 | echo $1 | ||
53 | exit $FAIL | ||
54 | } | ||
55 | |||
56 | yield() { | ||
57 | ping localhost -c 1 || sleep .001 || usleep 1 || sleep 1 | ||
58 | } | ||
59 | |||
60 | do_test() { | ||
61 | disable_tracing | ||
62 | |||
63 | echo do_execve* > set_ftrace_filter | ||
64 | echo *do_fork >> set_ftrace_filter | ||
65 | |||
66 | echo $PID > set_ftrace_pid | ||
67 | echo function > current_tracer | ||
68 | |||
69 | if [ $do_function_fork -eq 1 ]; then | ||
70 | # don't allow children to be traced | ||
71 | echo nofunction-fork > trace_options | ||
72 | fi | ||
73 | |||
74 | enable_tracing | ||
75 | yield | ||
76 | |||
77 | count_pid=`cat trace | grep -v ^# | grep $PID | wc -l` | ||
78 | count_other=`cat trace | grep -v ^# | grep -v $PID | wc -l` | ||
79 | |||
80 | # count_other should be 0 | ||
81 | if [ $count_pid -eq 0 -o $count_other -ne 0 ]; then | ||
82 | fail "PID filtering not working?" | ||
83 | fi | ||
84 | |||
85 | disable_tracing | ||
86 | clear_trace | ||
87 | |||
88 | if [ $do_function_fork -eq 0 ]; then | ||
89 | return | ||
90 | fi | ||
91 | |||
92 | # allow children to be traced | ||
93 | echo function-fork > trace_options | ||
94 | |||
95 | enable_tracing | ||
96 | yield | ||
97 | |||
98 | count_pid=`cat trace | grep -v ^# | grep $PID | wc -l` | ||
99 | count_other=`cat trace | grep -v ^# | grep -v $PID | wc -l` | ||
100 | |||
101 | # count_other should NOT be 0 | ||
102 | if [ $count_pid -eq 0 -o $count_other -eq 0 ]; then | ||
103 | fail "PID filtering not following fork?" | ||
104 | fi | ||
105 | } | ||
106 | |||
107 | do_test | ||
108 | |||
109 | mkdir instances/foo | ||
110 | cd instances/foo | ||
111 | do_test | ||
112 | cd ../../ | ||
113 | rmdir instances/foo | ||
114 | |||
115 | do_reset | ||
116 | |||
117 | exit 0 | ||
diff --git a/tools/testing/selftests/net/psock_fanout.c b/tools/testing/selftests/net/psock_fanout.c index 412459369686..e62bb354820c 100644 --- a/tools/testing/selftests/net/psock_fanout.c +++ b/tools/testing/selftests/net/psock_fanout.c | |||
@@ -75,7 +75,7 @@ static int sock_fanout_open(uint16_t typeflags, int num_packets) | |||
75 | { | 75 | { |
76 | int fd, val; | 76 | int fd, val; |
77 | 77 | ||
78 | fd = socket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_IP)); | 78 | fd = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_IP)); |
79 | if (fd < 0) { | 79 | if (fd < 0) { |
80 | perror("socket packet"); | 80 | perror("socket packet"); |
81 | exit(1); | 81 | exit(1); |
@@ -95,6 +95,24 @@ static int sock_fanout_open(uint16_t typeflags, int num_packets) | |||
95 | return fd; | 95 | return fd; |
96 | } | 96 | } |
97 | 97 | ||
98 | static void sock_fanout_set_cbpf(int fd) | ||
99 | { | ||
100 | struct sock_filter bpf_filter[] = { | ||
101 | BPF_STMT(BPF_LD+BPF_B+BPF_ABS, 80), /* ldb [80] */ | ||
102 | BPF_STMT(BPF_RET+BPF_A, 0), /* ret A */ | ||
103 | }; | ||
104 | struct sock_fprog bpf_prog; | ||
105 | |||
106 | bpf_prog.filter = bpf_filter; | ||
107 | bpf_prog.len = sizeof(bpf_filter) / sizeof(struct sock_filter); | ||
108 | |||
109 | if (setsockopt(fd, SOL_PACKET, PACKET_FANOUT_DATA, &bpf_prog, | ||
110 | sizeof(bpf_prog))) { | ||
111 | perror("fanout data cbpf"); | ||
112 | exit(1); | ||
113 | } | ||
114 | } | ||
115 | |||
98 | static void sock_fanout_set_ebpf(int fd) | 116 | static void sock_fanout_set_ebpf(int fd) |
99 | { | 117 | { |
100 | const int len_off = __builtin_offsetof(struct __sk_buff, len); | 118 | const int len_off = __builtin_offsetof(struct __sk_buff, len); |
@@ -270,7 +288,7 @@ static int test_datapath(uint16_t typeflags, int port_off, | |||
270 | exit(1); | 288 | exit(1); |
271 | } | 289 | } |
272 | if (type == PACKET_FANOUT_CBPF) | 290 | if (type == PACKET_FANOUT_CBPF) |
273 | sock_setfilter(fds[0], SOL_PACKET, PACKET_FANOUT_DATA); | 291 | sock_fanout_set_cbpf(fds[0]); |
274 | else if (type == PACKET_FANOUT_EBPF) | 292 | else if (type == PACKET_FANOUT_EBPF) |
275 | sock_fanout_set_ebpf(fds[0]); | 293 | sock_fanout_set_ebpf(fds[0]); |
276 | 294 | ||
diff --git a/tools/testing/selftests/net/psock_lib.h b/tools/testing/selftests/net/psock_lib.h index a77da88bf946..7d990d6c861b 100644 --- a/tools/testing/selftests/net/psock_lib.h +++ b/tools/testing/selftests/net/psock_lib.h | |||
@@ -38,7 +38,7 @@ | |||
38 | # define __maybe_unused __attribute__ ((__unused__)) | 38 | # define __maybe_unused __attribute__ ((__unused__)) |
39 | #endif | 39 | #endif |
40 | 40 | ||
41 | static __maybe_unused void sock_setfilter(int fd, int lvl, int optnum) | 41 | static __maybe_unused void pair_udp_setfilter(int fd) |
42 | { | 42 | { |
43 | /* the filter below checks for all of the following conditions that | 43 | /* the filter below checks for all of the following conditions that |
44 | * are based on the contents of create_payload() | 44 | * are based on the contents of create_payload() |
@@ -76,23 +76,16 @@ static __maybe_unused void sock_setfilter(int fd, int lvl, int optnum) | |||
76 | }; | 76 | }; |
77 | struct sock_fprog bpf_prog; | 77 | struct sock_fprog bpf_prog; |
78 | 78 | ||
79 | if (lvl == SOL_PACKET && optnum == PACKET_FANOUT_DATA) | ||
80 | bpf_filter[5].code = 0x16; /* RET A */ | ||
81 | |||
82 | bpf_prog.filter = bpf_filter; | 79 | bpf_prog.filter = bpf_filter; |
83 | bpf_prog.len = sizeof(bpf_filter) / sizeof(struct sock_filter); | 80 | bpf_prog.len = sizeof(bpf_filter) / sizeof(struct sock_filter); |
84 | if (setsockopt(fd, lvl, optnum, &bpf_prog, | 81 | |
82 | if (setsockopt(fd, SOL_SOCKET, SO_ATTACH_FILTER, &bpf_prog, | ||
85 | sizeof(bpf_prog))) { | 83 | sizeof(bpf_prog))) { |
86 | perror("setsockopt SO_ATTACH_FILTER"); | 84 | perror("setsockopt SO_ATTACH_FILTER"); |
87 | exit(1); | 85 | exit(1); |
88 | } | 86 | } |
89 | } | 87 | } |
90 | 88 | ||
91 | static __maybe_unused void pair_udp_setfilter(int fd) | ||
92 | { | ||
93 | sock_setfilter(fd, SOL_SOCKET, SO_ATTACH_FILTER); | ||
94 | } | ||
95 | |||
96 | static __maybe_unused void pair_udp_open(int fds[], uint16_t port) | 89 | static __maybe_unused void pair_udp_open(int fds[], uint16_t port) |
97 | { | 90 | { |
98 | struct sockaddr_in saddr, daddr; | 91 | struct sockaddr_in saddr, daddr; |
diff --git a/tools/testing/selftests/powerpc/Makefile b/tools/testing/selftests/powerpc/Makefile index 1c5d0575802e..bf13fc2297aa 100644 --- a/tools/testing/selftests/powerpc/Makefile +++ b/tools/testing/selftests/powerpc/Makefile | |||
@@ -34,34 +34,34 @@ endif | |||
34 | all: $(SUB_DIRS) | 34 | all: $(SUB_DIRS) |
35 | 35 | ||
36 | $(SUB_DIRS): | 36 | $(SUB_DIRS): |
37 | BUILD_TARGET=$$OUTPUT/$@; mkdir -p $$BUILD_TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -k -C $@ all | 37 | BUILD_TARGET=$(OUTPUT)/$@; mkdir -p $$BUILD_TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -k -C $@ all |
38 | 38 | ||
39 | include ../lib.mk | 39 | include ../lib.mk |
40 | 40 | ||
41 | override define RUN_TESTS | 41 | override define RUN_TESTS |
42 | @for TARGET in $(SUB_DIRS); do \ | 42 | @for TARGET in $(SUB_DIRS); do \ |
43 | BUILD_TARGET=$$OUTPUT/$$TARGET; \ | 43 | BUILD_TARGET=$(OUTPUT)/$$TARGET; \ |
44 | $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET run_tests;\ | 44 | $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET run_tests;\ |
45 | done; | 45 | done; |
46 | endef | 46 | endef |
47 | 47 | ||
48 | override define INSTALL_RULE | 48 | override define INSTALL_RULE |
49 | @for TARGET in $(SUB_DIRS); do \ | 49 | @for TARGET in $(SUB_DIRS); do \ |
50 | BUILD_TARGET=$$OUTPUT/$$TARGET; \ | 50 | BUILD_TARGET=$(OUTPUT)/$$TARGET; \ |
51 | $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET install;\ | 51 | $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET install;\ |
52 | done; | 52 | done; |
53 | endef | 53 | endef |
54 | 54 | ||
55 | override define EMIT_TESTS | 55 | override define EMIT_TESTS |
56 | @for TARGET in $(SUB_DIRS); do \ | 56 | @for TARGET in $(SUB_DIRS); do \ |
57 | BUILD_TARGET=$$OUTPUT/$$TARGET; \ | 57 | BUILD_TARGET=$(OUTPUT)/$$TARGET; \ |
58 | $(MAKE) OUTPUT=$$BUILD_TARGET -s -C $$TARGET emit_tests;\ | 58 | $(MAKE) OUTPUT=$$BUILD_TARGET -s -C $$TARGET emit_tests;\ |
59 | done; | 59 | done; |
60 | endef | 60 | endef |
61 | 61 | ||
62 | clean: | 62 | clean: |
63 | @for TARGET in $(SUB_DIRS); do \ | 63 | @for TARGET in $(SUB_DIRS); do \ |
64 | BUILD_TARGET=$$OUTPUT/$$TARGET; \ | 64 | BUILD_TARGET=$(OUTPUT)/$$TARGET; \ |
65 | $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET clean; \ | 65 | $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET clean; \ |
66 | done; | 66 | done; |
67 | rm -f tags | 67 | rm -f tags |
diff --git a/virt/kvm/arm/vgic/vgic-init.c b/virt/kvm/arm/vgic/vgic-init.c index 276139a24e6f..702f8108608d 100644 --- a/virt/kvm/arm/vgic/vgic-init.c +++ b/virt/kvm/arm/vgic/vgic-init.c | |||
@@ -392,6 +392,25 @@ static irqreturn_t vgic_maintenance_handler(int irq, void *data) | |||
392 | } | 392 | } |
393 | 393 | ||
394 | /** | 394 | /** |
395 | * kvm_vgic_init_cpu_hardware - initialize the GIC VE hardware | ||
396 | * | ||
397 | * For a specific CPU, initialize the GIC VE hardware. | ||
398 | */ | ||
399 | void kvm_vgic_init_cpu_hardware(void) | ||
400 | { | ||
401 | BUG_ON(preemptible()); | ||
402 | |||
403 | /* | ||
404 | * We want to make sure the list registers start out clear so that we | ||
405 | * only have the program the used registers. | ||
406 | */ | ||
407 | if (kvm_vgic_global_state.type == VGIC_V2) | ||
408 | vgic_v2_init_lrs(); | ||
409 | else | ||
410 | kvm_call_hyp(__vgic_v3_init_lrs); | ||
411 | } | ||
412 | |||
413 | /** | ||
395 | * kvm_vgic_hyp_init: populates the kvm_vgic_global_state variable | 414 | * kvm_vgic_hyp_init: populates the kvm_vgic_global_state variable |
396 | * according to the host GIC model. Accordingly calls either | 415 | * according to the host GIC model. Accordingly calls either |
397 | * vgic_v2/v3_probe which registers the KVM_DEVICE that can be | 416 | * vgic_v2/v3_probe which registers the KVM_DEVICE that can be |
diff --git a/virt/kvm/arm/vgic/vgic-mmio-v2.c b/virt/kvm/arm/vgic/vgic-mmio-v2.c index a3ad7ff95c9b..0a4283ed9aa7 100644 --- a/virt/kvm/arm/vgic/vgic-mmio-v2.c +++ b/virt/kvm/arm/vgic/vgic-mmio-v2.c | |||
@@ -229,7 +229,15 @@ static unsigned long vgic_mmio_read_vcpuif(struct kvm_vcpu *vcpu, | |||
229 | val = vmcr.ctlr; | 229 | val = vmcr.ctlr; |
230 | break; | 230 | break; |
231 | case GIC_CPU_PRIMASK: | 231 | case GIC_CPU_PRIMASK: |
232 | val = vmcr.pmr; | 232 | /* |
233 | * Our KVM_DEV_TYPE_ARM_VGIC_V2 device ABI exports the | ||
234 | * the PMR field as GICH_VMCR.VMPriMask rather than | ||
235 | * GICC_PMR.Priority, so we expose the upper five bits of | ||
236 | * priority mask to userspace using the lower bits in the | ||
237 | * unsigned long. | ||
238 | */ | ||
239 | val = (vmcr.pmr & GICV_PMR_PRIORITY_MASK) >> | ||
240 | GICV_PMR_PRIORITY_SHIFT; | ||
233 | break; | 241 | break; |
234 | case GIC_CPU_BINPOINT: | 242 | case GIC_CPU_BINPOINT: |
235 | val = vmcr.bpr; | 243 | val = vmcr.bpr; |
@@ -262,7 +270,15 @@ static void vgic_mmio_write_vcpuif(struct kvm_vcpu *vcpu, | |||
262 | vmcr.ctlr = val; | 270 | vmcr.ctlr = val; |
263 | break; | 271 | break; |
264 | case GIC_CPU_PRIMASK: | 272 | case GIC_CPU_PRIMASK: |
265 | vmcr.pmr = val; | 273 | /* |
274 | * Our KVM_DEV_TYPE_ARM_VGIC_V2 device ABI exports the | ||
275 | * the PMR field as GICH_VMCR.VMPriMask rather than | ||
276 | * GICC_PMR.Priority, so we expose the upper five bits of | ||
277 | * priority mask to userspace using the lower bits in the | ||
278 | * unsigned long. | ||
279 | */ | ||
280 | vmcr.pmr = (val << GICV_PMR_PRIORITY_SHIFT) & | ||
281 | GICV_PMR_PRIORITY_MASK; | ||
266 | break; | 282 | break; |
267 | case GIC_CPU_BINPOINT: | 283 | case GIC_CPU_BINPOINT: |
268 | vmcr.bpr = val; | 284 | vmcr.bpr = val; |
diff --git a/virt/kvm/arm/vgic/vgic-v2.c b/virt/kvm/arm/vgic/vgic-v2.c index b834ecdf3225..b637d9c7afe3 100644 --- a/virt/kvm/arm/vgic/vgic-v2.c +++ b/virt/kvm/arm/vgic/vgic-v2.c | |||
@@ -36,6 +36,21 @@ static unsigned long *u64_to_bitmask(u64 *val) | |||
36 | return (unsigned long *)val; | 36 | return (unsigned long *)val; |
37 | } | 37 | } |
38 | 38 | ||
39 | static inline void vgic_v2_write_lr(int lr, u32 val) | ||
40 | { | ||
41 | void __iomem *base = kvm_vgic_global_state.vctrl_base; | ||
42 | |||
43 | writel_relaxed(val, base + GICH_LR0 + (lr * 4)); | ||
44 | } | ||
45 | |||
46 | void vgic_v2_init_lrs(void) | ||
47 | { | ||
48 | int i; | ||
49 | |||
50 | for (i = 0; i < kvm_vgic_global_state.nr_lr; i++) | ||
51 | vgic_v2_write_lr(i, 0); | ||
52 | } | ||
53 | |||
39 | void vgic_v2_process_maintenance(struct kvm_vcpu *vcpu) | 54 | void vgic_v2_process_maintenance(struct kvm_vcpu *vcpu) |
40 | { | 55 | { |
41 | struct vgic_v2_cpu_if *cpuif = &vcpu->arch.vgic_cpu.vgic_v2; | 56 | struct vgic_v2_cpu_if *cpuif = &vcpu->arch.vgic_cpu.vgic_v2; |
@@ -191,8 +206,8 @@ void vgic_v2_set_vmcr(struct kvm_vcpu *vcpu, struct vgic_vmcr *vmcrp) | |||
191 | GICH_VMCR_ALIAS_BINPOINT_MASK; | 206 | GICH_VMCR_ALIAS_BINPOINT_MASK; |
192 | vmcr |= (vmcrp->bpr << GICH_VMCR_BINPOINT_SHIFT) & | 207 | vmcr |= (vmcrp->bpr << GICH_VMCR_BINPOINT_SHIFT) & |
193 | GICH_VMCR_BINPOINT_MASK; | 208 | GICH_VMCR_BINPOINT_MASK; |
194 | vmcr |= (vmcrp->pmr << GICH_VMCR_PRIMASK_SHIFT) & | 209 | vmcr |= ((vmcrp->pmr >> GICV_PMR_PRIORITY_SHIFT) << |
195 | GICH_VMCR_PRIMASK_MASK; | 210 | GICH_VMCR_PRIMASK_SHIFT) & GICH_VMCR_PRIMASK_MASK; |
196 | 211 | ||
197 | vcpu->arch.vgic_cpu.vgic_v2.vgic_vmcr = vmcr; | 212 | vcpu->arch.vgic_cpu.vgic_v2.vgic_vmcr = vmcr; |
198 | } | 213 | } |
@@ -207,8 +222,8 @@ void vgic_v2_get_vmcr(struct kvm_vcpu *vcpu, struct vgic_vmcr *vmcrp) | |||
207 | GICH_VMCR_ALIAS_BINPOINT_SHIFT; | 222 | GICH_VMCR_ALIAS_BINPOINT_SHIFT; |
208 | vmcrp->bpr = (vmcr & GICH_VMCR_BINPOINT_MASK) >> | 223 | vmcrp->bpr = (vmcr & GICH_VMCR_BINPOINT_MASK) >> |
209 | GICH_VMCR_BINPOINT_SHIFT; | 224 | GICH_VMCR_BINPOINT_SHIFT; |
210 | vmcrp->pmr = (vmcr & GICH_VMCR_PRIMASK_MASK) >> | 225 | vmcrp->pmr = ((vmcr & GICH_VMCR_PRIMASK_MASK) >> |
211 | GICH_VMCR_PRIMASK_SHIFT; | 226 | GICH_VMCR_PRIMASK_SHIFT) << GICV_PMR_PRIORITY_SHIFT; |
212 | } | 227 | } |
213 | 228 | ||
214 | void vgic_v2_enable(struct kvm_vcpu *vcpu) | 229 | void vgic_v2_enable(struct kvm_vcpu *vcpu) |
diff --git a/virt/kvm/arm/vgic/vgic.h b/virt/kvm/arm/vgic/vgic.h index db28f7cadab2..6cf557e9f718 100644 --- a/virt/kvm/arm/vgic/vgic.h +++ b/virt/kvm/arm/vgic/vgic.h | |||
@@ -81,11 +81,18 @@ static inline bool irq_is_pending(struct vgic_irq *irq) | |||
81 | return irq->pending_latch || irq->line_level; | 81 | return irq->pending_latch || irq->line_level; |
82 | } | 82 | } |
83 | 83 | ||
84 | /* | ||
85 | * This struct provides an intermediate representation of the fields contained | ||
86 | * in the GICH_VMCR and ICH_VMCR registers, such that code exporting the GIC | ||
87 | * state to userspace can generate either GICv2 or GICv3 CPU interface | ||
88 | * registers regardless of the hardware backed GIC used. | ||
89 | */ | ||
84 | struct vgic_vmcr { | 90 | struct vgic_vmcr { |
85 | u32 ctlr; | 91 | u32 ctlr; |
86 | u32 abpr; | 92 | u32 abpr; |
87 | u32 bpr; | 93 | u32 bpr; |
88 | u32 pmr; | 94 | u32 pmr; /* Priority mask field in the GICC_PMR and |
95 | * ICC_PMR_EL1 priority field format */ | ||
89 | /* Below member variable are valid only for GICv3 */ | 96 | /* Below member variable are valid only for GICv3 */ |
90 | u32 grpen0; | 97 | u32 grpen0; |
91 | u32 grpen1; | 98 | u32 grpen1; |
@@ -130,6 +137,8 @@ int vgic_v2_map_resources(struct kvm *kvm); | |||
130 | int vgic_register_dist_iodev(struct kvm *kvm, gpa_t dist_base_address, | 137 | int vgic_register_dist_iodev(struct kvm *kvm, gpa_t dist_base_address, |
131 | enum vgic_type); | 138 | enum vgic_type); |
132 | 139 | ||
140 | void vgic_v2_init_lrs(void); | ||
141 | |||
133 | static inline void vgic_get_irq_kref(struct vgic_irq *irq) | 142 | static inline void vgic_get_irq_kref(struct vgic_irq *irq) |
134 | { | 143 | { |
135 | if (irq->intid < VGIC_MIN_LPI) | 144 | if (irq->intid < VGIC_MIN_LPI) |