We want these fixes in here as well.
Unified · Split
| @@ -0,0 +1,72 @@ | ||
| 1 | +Null block device driver | |
| 2 | +================================================================================ | |
| 3 | + | |
| 4 | +I. Overview | |
| 5 | + | |
| 6 | +The null block device (/dev/nullb*) is used for benchmarking the various | |
| 7 | +block-layer implementations. It emulates a block device of X gigabytes in size. | |
| 8 | +The following instances are possible: | |
| 9 | + | |
| 10 | + Single-queue block-layer | |
| 11 | + - Request-based. | |
| 12 | + - Single submission queue per device. | |
| 13 | + - Implements IO scheduling algorithms (CFQ, Deadline, noop). | |
| 14 | + Multi-queue block-layer | |
| 15 | + - Request-based. | |
| 16 | + - Configurable submission queues per device. | |
| 17 | + No block-layer (Known as bio-based) | |
| 18 | + - Bio-based. IO requests are submitted directly to the device driver. | |
| 19 | + - Directly accepts bio data structure and returns them. | |
| 20 | + | |
| 21 | +All of them have a completion queue for each core in the system. | |
| 22 | + | |
| 23 | +II. Module parameters applicable for all instances: | |
| 24 | + | |
| 25 | +queue_mode=[0-2]: Default: 2-Multi-queue | |
| 26 | + Selects which block-layer the module should instantiate with. | |
| 27 | + | |
| 28 | + 0: Bio-based. | |
| 29 | + 1: Single-queue. | |
| 30 | + 2: Multi-queue. | |
| 31 | + | |
| 32 | +home_node=[0--nr_nodes]: Default: NUMA_NO_NODE | |
| 33 | + Selects what CPU node the data structures are allocated from. | |
| 34 | + | |
| 35 | +gb=[Size in GB]: Default: 250GB | |
| 36 | + The size of the device reported to the system. | |
| 37 | + | |
| 38 | +bs=[Block size (in bytes)]: Default: 512 bytes | |
| 39 | + The block size reported to the system. | |
| 40 | + | |
| 41 | +nr_devices=[Number of devices]: Default: 2 | |
| 42 | + Number of block devices instantiated. They are instantiated as /dev/nullb0, | |
| 43 | + etc. | |
| 44 | + | |
| 45 | +irq_mode=[0-2]: Default: 1-Soft-irq | |
| 46 | + The completion mode used for completing IOs to the block-layer. | |
| 47 | + | |
| 48 | + 0: None. | |
| 49 | + 1: Soft-irq. Uses IPI to complete IOs across CPU nodes. Simulates the overhead | |
| 50 | + when IOs are issued from another CPU node than the home the device is | |
| 51 | + connected to. | |
| 52 | + 2: Timer: Waits a specific period (completion_nsec) for each IO before | |
| 53 | + completion. | |
| 54 | + | |
| 55 | +completion_nsec=[ns]: Default: 10.000ns | |
| 56 | + Combined with irq_mode=2 (timer). The time each completion event must wait. | |
| 57 | + | |
| 58 | +submit_queues=[0..nr_cpus]: | |
| 59 | + The number of submission queues attached to the device driver. If unset, it | |
| 60 | + defaults to 1 on single-queue and bio-based instances. For multi-queue, | |
| 61 | + it is ignored when use_per_node_hctx module parameter is 1. | |
| 62 | + | |
| 63 | +hw_queue_depth=[0..qdepth]: Default: 64 | |
| 64 | + The hardware queue depth of the device. | |
| 65 | + | |
| 66 | +III: Multi-queue specific parameters | |
| 67 | + | |
| 68 | +use_per_node_hctx=[0/1]: Default: 0 | |
| 69 | + 0: The number of submit queues are set to the value of the submit_queues | |
| 70 | + parameter. | |
| 71 | + 1: The multi-queue block layer is instantiated with a hardware dispatch | |
| 72 | + queue for each CPU node in the system. | |
| @@ -1529,6 +1529,8 @@ bytes respectively. Such letter suffixes can also be entirely omitted. · 1528 unmodified lines | ||
| 1529 | 1529 | |
| 1530 | 1530 | * atapi_dmadir: Enable ATAPI DMADIR bridge support |
| 1531 | 1531 | |
| 1532 | + * disable: Disable this device. | |
| 1533 | + | |
| 1532 | 1534 | If there are multiple matching configurations changing |
| 1533 | 1535 | the same attribute, the last one is used. |
| 1534 | 1536 | |
| @@ -0,0 +1,240 @@ | ||
| 1 | + ============================== | |
| 2 | + KERNEL MODULE SIGNING FACILITY | |
| 3 | + ============================== | |
| 4 | + | |
| 5 | +CONTENTS | |
| 6 | + | |
| 7 | + - Overview. | |
| 8 | + - Configuring module signing. | |
| 9 | + - Generating signing keys. | |
| 10 | + - Public keys in the kernel. | |
| 11 | + - Manually signing modules. | |
| 12 | + - Signed modules and stripping. | |
| 13 | + - Loading signed modules. | |
| 14 | + - Non-valid signatures and unsigned modules. | |
| 15 | + - Administering/protecting the private key. | |
| 16 | + | |
| 17 | + | |
| 18 | +======== | |
| 19 | +OVERVIEW | |
| 20 | +======== | |
| 21 | + | |
| 22 | +The kernel module signing facility cryptographically signs modules during | |
| 23 | +installation and then checks the signature upon loading the module. This | |
| 24 | +allows increased kernel security by disallowing the loading of unsigned modules | |
| 25 | +or modules signed with an invalid key. Module signing increases security by | |
| 26 | +making it harder to load a malicious module into the kernel. The module | |
| 27 | +signature checking is done by the kernel so that it is not necessary to have | |
| 28 | +trusted userspace bits. | |
| 29 | + | |
| 30 | +This facility uses X.509 ITU-T standard certificates to encode the public keys | |
| 31 | +involved. The signatures are not themselves encoded in any industrial standard | |
| 32 | +type. The facility currently only supports the RSA public key encryption | |
| 33 | +standard (though it is pluggable and permits others to be used). The possible | |
| 34 | +hash algorithms that can be used are SHA-1, SHA-224, SHA-256, SHA-384, and | |
| 35 | +SHA-512 (the algorithm is selected by data in the signature). | |
| 36 | + | |
| 37 | + | |
| 38 | +========================== | |
| 39 | +CONFIGURING MODULE SIGNING | |
| 40 | +========================== | |
| 41 | + | |
| 42 | +The module signing facility is enabled by going to the "Enable Loadable Module | |
| 43 | +Support" section of the kernel configuration and turning on | |
| 44 | + | |
| 45 | + CONFIG_MODULE_SIG "Module signature verification" | |
| 46 | + | |
| 47 | +This has a number of options available: | |
| 48 | + | |
| 49 | + (1) "Require modules to be validly signed" (CONFIG_MODULE_SIG_FORCE) | |
| 50 | + | |
| 51 | + This specifies how the kernel should deal with a module that has a | |
| 52 | + signature for which the key is not known or a module that is unsigned. | |
| 53 | + | |
| 54 | + If this is off (ie. "permissive"), then modules for which the key is not | |
| 55 | + available and modules that are unsigned are permitted, but the kernel will | |
| 56 | + be marked as being tainted. | |
| 57 | + | |
| 58 | + If this is on (ie. "restrictive"), only modules that have a valid | |
| 59 | + signature that can be verified by a public key in the kernel's possession | |
| 60 | + will be loaded. All other modules will generate an error. | |
| 61 | + | |
| 62 | + Irrespective of the setting here, if the module has a signature block that | |
| 63 | + cannot be parsed, it will be rejected out of hand. | |
| 64 | + | |
| 65 | + | |
| 66 | + (2) "Automatically sign all modules" (CONFIG_MODULE_SIG_ALL) | |
| 67 | + | |
| 68 | + If this is on then modules will be automatically signed during the | |
| 69 | + modules_install phase of a build. If this is off, then the modules must | |
| 70 | + be signed manually using: | |
| 71 | + | |
| 72 | + scripts/sign-file | |
| 73 | + | |
| 74 | + | |
| 75 | + (3) "Which hash algorithm should modules be signed with?" | |
| 76 | + | |
| 77 | + This presents a choice of which hash algorithm the installation phase will | |
| 78 | + sign the modules with: | |
| 79 | + | |
| 80 | + CONFIG_SIG_SHA1 "Sign modules with SHA-1" | |
| 81 | + CONFIG_SIG_SHA224 "Sign modules with SHA-224" | |
| 82 | + CONFIG_SIG_SHA256 "Sign modules with SHA-256" | |
| 83 | + CONFIG_SIG_SHA384 "Sign modules with SHA-384" | |
| 84 | + CONFIG_SIG_SHA512 "Sign modules with SHA-512" | |
| 85 | + | |
| 86 | + The algorithm selected here will also be built into the kernel (rather | |
| 87 | + than being a module) so that modules signed with that algorithm can have | |
| 88 | + their signatures checked without causing a dependency loop. | |
| 89 | + | |
| 90 | + | |
| 91 | +======================= | |
| 92 | +GENERATING SIGNING KEYS | |
| 93 | +======================= | |
| 94 | + | |
| 95 | +Cryptographic keypairs are required to generate and check signatures. A | |
| 96 | +private key is used to generate a signature and the corresponding public key is | |
| 97 | +used to check it. The private key is only needed during the build, after which | |
| 98 | +it can be deleted or stored securely. The public key gets built into the | |
| 99 | +kernel so that it can be used to check the signatures as the modules are | |
| 100 | +loaded. | |
| 101 | + | |
| 102 | +Under normal conditions, the kernel build will automatically generate a new | |
| 103 | +keypair using openssl if one does not exist in the files: | |
| 104 | + | |
| 105 | + signing_key.priv | |
| 106 | + signing_key.x509 | |
| 107 | + | |
| 108 | +during the building of vmlinux (the public part of the key needs to be built | |
| 109 | +into vmlinux) using parameters in the: | |
| 110 | + | |
| 111 | + x509.genkey | |
| 112 | + | |
| 113 | +file (which is also generated if it does not already exist). | |
| 114 | + | |
| 115 | +It is strongly recommended that you provide your own x509.genkey file. | |
| 116 | + | |
| 117 | +Most notably, in the x509.genkey file, the req_distinguished_name section | |
| 118 | +should be altered from the default: | |
| 119 | + | |
| 120 | + [ req_distinguished_name ] | |
| 121 | + O = Magrathea | |
| 122 | + CN = Glacier signing key | |
| 123 | + emailAddress = slartibartfast@magrathea.h2g2 | |
| 124 | + | |
| 125 | +The generated RSA key size can also be set with: | |
| 126 | + | |
| 127 | + [ req ] | |
| 128 | + default_bits = 4096 | |
| 129 | + | |
| 130 | + | |
| 131 | +It is also possible to manually generate the key private/public files using the | |
| 132 | +x509.genkey key generation configuration file in the root node of the Linux | |
| 133 | +kernel sources tree and the openssl command. The following is an example to | |
| 134 | +generate the public/private key files: | |
| 135 | + | |
| 136 | + openssl req -new -nodes -utf8 -sha256 -days 36500 -batch -x509 \ | |
| 137 | + -config x509.genkey -outform DER -out signing_key.x509 \ | |
| 138 | + -keyout signing_key.priv | |
| 139 | + | |
| 140 | + | |
| 141 | +========================= | |
| 142 | +PUBLIC KEYS IN THE KERNEL | |
| 143 | +========================= | |
| 144 | + | |
| 145 | +The kernel contains a ring of public keys that can be viewed by root. They're | |
| 146 | +in a keyring called ".system_keyring" that can be seen by: | |
| 147 | + | |
| 148 | + [root@deneb ~]# cat /proc/keys | |
| 149 | + ... | |
| 150 | + 223c7853 I------ 1 perm 1f030000 0 0 keyring .system_keyring: 1 | |
| 151 | + 302d2d52 I------ 1 perm 1f010000 0 0 asymmetri Fedora kernel signing key: d69a84e6bce3d216b979e9505b3e3ef9a7118079: X509.RSA a7118079 [] | |
| 152 | + ... | |
| 153 | + | |
| 154 | +Beyond the public key generated specifically for module signing, any file | |
| 155 | +placed in the kernel source root directory or the kernel build root directory | |
| 156 | +whose name is suffixed with ".x509" will be assumed to be an X.509 public key | |
| 157 | +and will be added to the keyring. | |
| 158 | + | |
| 159 | +Further, the architecture code may take public keys from a hardware store and | |
| 160 | +add those in also (e.g. from the UEFI key database). | |
| 161 | + | |
| 162 | +Finally, it is possible to add additional public keys by doing: | |
| 163 | + | |
| 164 | + keyctl padd asymmetric "" [.system_keyring-ID] <[key-file] | |
| 165 | + | |
| 166 | +e.g.: | |
| 167 | + | |
| 168 | + keyctl padd asymmetric "" 0x223c7853 <my_public_key.x509 | |
| 169 | + | |
| 170 | +Note, however, that the kernel will only permit keys to be added to | |
| 171 | +.system_keyring _if_ the new key's X.509 wrapper is validly signed by a key | |
| 172 | +that is already resident in the .system_keyring at the time the key was added. | |
| 173 | + | |
| 174 | + | |
| 175 | +========================= | |
| 176 | +MANUALLY SIGNING MODULES | |
| 177 | +========================= | |
| 178 | + | |
| 179 | +To manually sign a module, use the scripts/sign-file tool available in | |
| 180 | +the Linux kernel source tree. The script requires 4 arguments: | |
| 181 | + | |
| 182 | + 1. The hash algorithm (e.g., sha256) | |
| 183 | + 2. The private key filename | |
| 184 | + 3. The public key filename | |
| 185 | + 4. The kernel module to be signed | |
| 186 | + | |
| 187 | +The following is an example to sign a kernel module: | |
| 188 | + | |
| 189 | + scripts/sign-file sha512 kernel-signkey.priv \ | |
| 190 | + kernel-signkey.x509 module.ko | |
| 191 | + | |
| 192 | +The hash algorithm used does not have to match the one configured, but if it | |
| 193 | +doesn't, you should make sure that hash algorithm is either built into the | |
| 194 | +kernel or can be loaded without requiring itself. | |
| 195 | + | |
| 196 | + | |
| 197 | +============================ | |
| 198 | +SIGNED MODULES AND STRIPPING | |
| 199 | +============================ | |
| 200 | + | |
| 201 | +A signed module has a digital signature simply appended at the end. The string | |
| 202 | +"~Module signature appended~." at the end of the module's file confirms that a | |
| 203 | +signature is present but it does not confirm that the signature is valid! | |
| 204 | + | |
| 205 | +Signed modules are BRITTLE as the signature is outside of the defined ELF | |
| 206 | +container. Thus they MAY NOT be stripped once the signature is computed and | |
| 207 | +attached. Note the entire module is the signed payload, including any and all | |
| 208 | +debug information present at the time of signing. | |
| 209 | + | |
| 210 | + | |
| 211 | +====================== | |
| 212 | +LOADING SIGNED MODULES | |
| 213 | +====================== | |
| 214 | + | |
| 215 | +Modules are loaded with insmod, modprobe, init_module() or finit_module(), | |
| 216 | +exactly as for unsigned modules as no processing is done in userspace. The | |
| 217 | +signature checking is all done within the kernel. | |
| 218 | + | |
| 219 | + | |
| 220 | +========================================= | |
| 221 | +NON-VALID SIGNATURES AND UNSIGNED MODULES | |
| 222 | +========================================= | |
| 223 | + | |
| 224 | +If CONFIG_MODULE_SIG_FORCE is enabled or enforcemodulesig=1 is supplied on | |
| 225 | +the kernel command line, the kernel will only load validly signed modules | |
| 226 | +for which it has a public key. Otherwise, it will also load modules that are | |
| 227 | +unsigned. Any module for which the kernel has a key, but which proves to have | |
| 228 | +a signature mismatch will not be permitted to load. | |
| 229 | + | |
| 230 | +Any module that has an unparseable signature will be rejected. | |
| 231 | + | |
| 232 | + | |
| 233 | +========================================= | |
| 234 | +ADMINISTERING/PROTECTING THE PRIVATE KEY | |
| 235 | +========================================= | |
| 236 | + | |
| 237 | +Since the private key is used to sign modules, viruses and malware could use | |
| 238 | +the private key to sign modules and compromise the operating system. The | |
| 239 | +private key must be either destroyed or moved to a secure location and not kept | |
| 240 | +in the root node of the kernel source tree. | |
| @@ -16,8 +16,12 @@ ip_default_ttl - INTEGER · 15 unmodified lines | ||
| 16 | 16 | Default: 64 (as recommended by RFC1700) |
| 17 | 17 | |
| 18 | 18 | ip_no_pmtu_disc - BOOLEAN |
| 19 | − Disable Path MTU Discovery. | |
| 20 | − default FALSE | |
| 19 | + Disable Path MTU Discovery. If enabled and a | |
| 20 | + fragmentation-required ICMP is received, the PMTU to this | |
| 21 | + destination will be set to min_pmtu (see below). You will need | |
| 22 | + to raise min_pmtu to the smallest interface MTU on your system | |
| 23 | + manually if you want to avoid locally generated fragments. | |
| 24 | + Default: FALSE | |
| 21 | 25 | |
| 22 | 26 | min_pmtu - INTEGER |
| 23 | 27 | default 552 - minimum discovered Path MTU |
| @@ -1008,6 +1008,8 @@ M: Santosh Shilimkar <santosh.shilimkar@ti.com> · 1007 unmodified lines | ||
| 1008 | 1008 | L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) |
| 1009 | 1009 | S: Maintained |
| 1010 | 1010 | F: arch/arm/mach-keystone/ |
| 1011 | +F: drivers/clk/keystone/ | |
| 1012 | +T: git git://git.kernel.org/pub/scm/linux/kernel/git/ssantosh/linux-keystone.git | |
| 1011 | 1013 | |
| 1012 | 1014 | ARM/LOGICPD PXA270 MACHINE SUPPORT |
| 1013 | 1015 | M: Lennert Buytenhek <kernel@wantstofly.org> |
| @@ -3761,9 +3763,11 @@ F: include/uapi/linux/gigaset_dev.h · 2747 unmodified lines | ||
| 3761 | 3763 | |
| 3762 | 3764 | GPIO SUBSYSTEM |
| 3763 | 3765 | M: Linus Walleij <linus.walleij@linaro.org> |
| 3764 | −S: Maintained | |
| 3766 | +M: Alexandre Courbot <gnurou@gmail.com> | |
| 3765 | 3767 | L: linux-gpio@vger.kernel.org |
| 3766 | −F: Documentation/gpio.txt | |
| 3768 | +T: git git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio.git | |
| 3769 | +S: Maintained | |
| 3770 | +F: Documentation/gpio/ | |
| 3767 | 3771 | F: drivers/gpio/ |
| 3768 | 3772 | F: include/linux/gpio* |
| 3769 | 3773 | F: include/asm-generic/gpio.h |
| @@ -3831,6 +3835,12 @@ T: git git://linuxtv.org/media_tree.git · 61 unmodified lines | ||
| 3831 | 3835 | S: Maintained |
| 3832 | 3836 | F: drivers/media/usb/gspca/ |
| 3833 | 3837 | |
| 3838 | +GUID PARTITION TABLE (GPT) | |
| 3839 | +M: Davidlohr Bueso <davidlohr@hp.com> | |
| 3840 | +L: linux-efi@vger.kernel.org | |
| 3841 | +S: Maintained | |
| 3842 | +F: block/partitions/efi.* | |
| 3843 | + | |
| 3834 | 3844 | STK1160 USB VIDEO CAPTURE DRIVER |
| 3835 | 3845 | M: Ezequiel Garcia <elezegarcia@gmail.com> |
| 3836 | 3846 | L: linux-media@vger.kernel.org |
| @@ -5911,12 +5921,21 @@ M: Steffen Klassert <steffen.klassert@secunet.com> · 2074 unmodified lines | ||
| 5911 | 5921 | M: Herbert Xu <herbert@gondor.apana.org.au> |
| 5912 | 5922 | M: "David S. Miller" <davem@davemloft.net> |
| 5913 | 5923 | L: netdev@vger.kernel.org |
| 5914 | −T: git git://git.kernel.org/pub/scm/linux/kernel/git/davem/net.git | |
| 5924 | +T: git git://git.kernel.org/pub/scm/linux/kernel/git/klassert/ipsec.git | |
| 5925 | +T: git git://git.kernel.org/pub/scm/linux/kernel/git/klassert/ipsec-next.git | |
| 5915 | 5926 | S: Maintained |
| 5916 | 5927 | F: net/xfrm/ |
| 5917 | 5928 | F: net/key/ |
| 5918 | 5929 | F: net/ipv4/xfrm* |
| 5930 | +F: net/ipv4/esp4.c | |
| 5931 | +F: net/ipv4/ah4.c | |
| 5932 | +F: net/ipv4/ipcomp.c | |
| 5933 | +F: net/ipv4/ip_vti.c | |
| 5919 | 5934 | F: net/ipv6/xfrm* |
| 5935 | +F: net/ipv6/esp6.c | |
| 5936 | +F: net/ipv6/ah6.c | |
| 5937 | +F: net/ipv6/ipcomp6.c | |
| 5938 | +F: net/ipv6/ip6_vti.c | |
| 5920 | 5939 | F: include/uapi/linux/xfrm.h |
| 5921 | 5940 | F: include/net/xfrm.h |
| 5922 | 5941 | |
| @@ -9571,7 +9590,7 @@ F: drivers/xen/*swiotlb* · 3648 unmodified lines | ||
| 9571 | 9590 | |
| 9572 | 9591 | XFS FILESYSTEM |
| 9573 | 9592 | P: Silicon Graphics Inc |
| 9574 | −M: Dave Chinner <dchinner@fromorbit.com> | |
| 9593 | +M: Dave Chinner <david@fromorbit.com> | |
| 9575 | 9594 | M: Ben Myers <bpm@sgi.com> |
| 9576 | 9595 | M: xfs@oss.sgi.com |
| 9577 | 9596 | L: xfs@oss.sgi.com |
| @@ -1,7 +1,7 @@ | ||
| 1 | 1 | VERSION = 3 |
| 2 | 2 | PATCHLEVEL = 13 |
| 3 | 3 | SUBLEVEL = 0 |
| 4 | −EXTRAVERSION = -rc4 | |
| 4 | +EXTRAVERSION = -rc6 | |
| 5 | 5 | NAME = One Giant Leap for Frogkind |
| 6 | 6 | |
| 7 | 7 | # *DOCUMENTATION* |
| @@ -732,19 +732,15 @@ export mod_strip_cmd · 724 unmodified lines | ||
| 732 | 732 | # Select initial ramdisk compression format, default is gzip(1). |
| 733 | 733 | # This shall be used by the dracut(8) tool while creating an initramfs image. |
| 734 | 734 | # |
| 735 | −INITRD_COMPRESS=gzip | |
| 736 | −ifeq ($(CONFIG_RD_BZIP2), y) | |
| 737 | − INITRD_COMPRESS=bzip2 | |
| 738 | −else ifeq ($(CONFIG_RD_LZMA), y) | |
| 739 | − INITRD_COMPRESS=lzma | |
| 740 | −else ifeq ($(CONFIG_RD_XZ), y) | |
| 741 | − INITRD_COMPRESS=xz | |
| 742 | −else ifeq ($(CONFIG_RD_LZO), y) | |
| 743 | − INITRD_COMPRESS=lzo | |
| 744 | −else ifeq ($(CONFIG_RD_LZ4), y) | |
| 745 | − INITRD_COMPRESS=lz4 | |
| 746 | −endif | |
| 747 | −export INITRD_COMPRESS | |
| 735 | +INITRD_COMPRESS-y := gzip | |
| 736 | +INITRD_COMPRESS-$(CONFIG_RD_BZIP2) := bzip2 | |
| 737 | +INITRD_COMPRESS-$(CONFIG_RD_LZMA) := lzma | |
| 738 | +INITRD_COMPRESS-$(CONFIG_RD_XZ) := xz | |
| 739 | +INITRD_COMPRESS-$(CONFIG_RD_LZO) := lzo | |
| 740 | +INITRD_COMPRESS-$(CONFIG_RD_LZ4) := lz4 | |
| 741 | +# do not export INITRD_COMPRESS, since we didn't actually | |
| 742 | +# choose a sane default compression above. | |
| 743 | +# export INITRD_COMPRESS := $(INITRD_COMPRESS-y) | |
| 748 | 744 | |
| 749 | 745 | ifdef CONFIG_MODULE_SIG_ALL |
| 750 | 746 | MODSECKEY = ./signing_key.priv |
| @@ -8,7 +8,11 @@ · 7 unmodified lines | ||
| 8 | 8 | |
| 9 | 9 | /******** no-legacy-syscalls-ABI *******/ |
| 10 | 10 | |
| 11 | −#ifndef _UAPI_ASM_ARC_UNISTD_H | |
| 11 | +/* | |
| 12 | + * Non-typical guard macro to enable inclusion twice in ARCH sys.c | |
| 13 | + * That is how the Generic syscall wrapper generator works | |
| 14 | + */ | |
| 15 | +#if !defined(_UAPI_ASM_ARC_UNISTD_H) || defined(__SYSCALL) | |
| 12 | 16 | #define _UAPI_ASM_ARC_UNISTD_H |
| 13 | 17 | |
| 14 | 18 | #define __ARCH_WANT_SYS_EXECVE |
| @@ -36,4 +40,6 @@ __SYSCALL(__NR_arc_gettls, sys_arc_gettls) · 21 unmodified lines | ||
| 36 | 40 | #define __NR_sysfs (__NR_arch_specific_syscall + 3) |
| 37 | 41 | __SYSCALL(__NR_sysfs, sys_sysfs) |
| 38 | 42 | |
| 43 | +#undef __SYSCALL | |
| 44 | + | |
| 39 | 45 | #endif |
| @@ -87,9 +87,9 @@ · 86 unmodified lines | ||
| 87 | 87 | interrupts = <1 9 0xf04>; |
| 88 | 88 | }; |
| 89 | 89 | |
| 90 | − gpio0: gpio@ffc40000 { | |
| 90 | + gpio0: gpio@e6050000 { | |
| 91 | 91 | compatible = "renesas,gpio-r8a7790", "renesas,gpio-rcar"; |
| 92 | − reg = <0 0xffc40000 0 0x2c>; | |
| 92 | + reg = <0 0xe6050000 0 0x50>; | |
| 93 | 93 | interrupt-parent = <&gic>; |
| 94 | 94 | interrupts = <0 4 0x4>; |
| 95 | 95 | #gpio-cells = <2>; |
| @@ -99,9 +99,9 @@ · 3 unmodified lines | ||
| 99 | 99 | interrupt-controller; |
| 100 | 100 | }; |
| 101 | 101 | |
| 102 | − gpio1: gpio@ffc41000 { | |
| 102 | + gpio1: gpio@e6051000 { | |
| 103 | 103 | compatible = "renesas,gpio-r8a7790", "renesas,gpio-rcar"; |
| 104 | − reg = <0 0xffc41000 0 0x2c>; | |
| 104 | + reg = <0 0xe6051000 0 0x50>; | |
| 105 | 105 | interrupt-parent = <&gic>; |
| 106 | 106 | interrupts = <0 5 0x4>; |
| 107 | 107 | #gpio-cells = <2>; |
| @@ -111,9 +111,9 @@ · 3 unmodified lines | ||
| 111 | 111 | interrupt-controller; |
| 112 | 112 | }; |
| 113 | 113 | |
| 114 | − gpio2: gpio@ffc42000 { | |
| 114 | + gpio2: gpio@e6052000 { | |
| 115 | 115 | compatible = "renesas,gpio-r8a7790", "renesas,gpio-rcar"; |
| 116 | − reg = <0 0xffc42000 0 0x2c>; | |
| 116 | + reg = <0 0xe6052000 0 0x50>; | |
| 117 | 117 | interrupt-parent = <&gic>; |
| 118 | 118 | interrupts = <0 6 0x4>; |
| 119 | 119 | #gpio-cells = <2>; |
| @@ -123,9 +123,9 @@ · 3 unmodified lines | ||
| 123 | 123 | interrupt-controller; |
| 124 | 124 | }; |
| 125 | 125 | |
| 126 | − gpio3: gpio@ffc43000 { | |
| 126 | + gpio3: gpio@e6053000 { | |
| 127 | 127 | compatible = "renesas,gpio-r8a7790", "renesas,gpio-rcar"; |
| 128 | − reg = <0 0xffc43000 0 0x2c>; | |
| 128 | + reg = <0 0xe6053000 0 0x50>; | |
| 129 | 129 | interrupt-parent = <&gic>; |
| 130 | 130 | interrupts = <0 7 0x4>; |
| 131 | 131 | #gpio-cells = <2>; |
| @@ -135,9 +135,9 @@ · 3 unmodified lines | ||
| 135 | 135 | interrupt-controller; |
| 136 | 136 | }; |
| 137 | 137 | |
| 138 | − gpio4: gpio@ffc44000 { | |
| 138 | + gpio4: gpio@e6054000 { | |
| 139 | 139 | compatible = "renesas,gpio-r8a7790", "renesas,gpio-rcar"; |
| 140 | − reg = <0 0xffc44000 0 0x2c>; | |
| 140 | + reg = <0 0xe6054000 0 0x50>; | |
| 141 | 141 | interrupt-parent = <&gic>; |
| 142 | 142 | interrupts = <0 8 0x4>; |
| 143 | 143 | #gpio-cells = <2>; |
| @@ -147,9 +147,9 @@ · 3 unmodified lines | ||
| 147 | 147 | interrupt-controller; |
| 148 | 148 | }; |
| 149 | 149 | |
| 150 | − gpio5: gpio@ffc45000 { | |
| 150 | + gpio5: gpio@e6055000 { | |
| 151 | 151 | compatible = "renesas,gpio-r8a7790", "renesas,gpio-rcar"; |
| 152 | − reg = <0 0xffc45000 0 0x2c>; | |
| 152 | + reg = <0 0xe6055000 0 0x50>; | |
| 153 | 153 | interrupt-parent = <&gic>; |
| 154 | 154 | interrupts = <0 9 0x4>; |
| 155 | 155 | #gpio-cells = <2>; |
| @@ -241,7 +241,7 @@ · 85 unmodified lines | ||
| 241 | 241 | |
| 242 | 242 | sdhi0: sdhi@ee100000 { |
| 243 | 243 | compatible = "renesas,sdhi-r8a7790"; |
| 244 | − reg = <0 0xee100000 0 0x100>; | |
| 244 | + reg = <0 0xee100000 0 0x200>; | |
| 245 | 245 | interrupt-parent = <&gic>; |
| 246 | 246 | interrupts = <0 165 4>; |
| 247 | 247 | cap-sd-highspeed; |
| @@ -250,7 +250,7 @@ · 2 unmodified lines | ||
| 250 | 250 | |
| 251 | 251 | sdhi1: sdhi@ee120000 { |
| 252 | 252 | compatible = "renesas,sdhi-r8a7790"; |
| 253 | − reg = <0 0xee120000 0 0x100>; | |
| 253 | + reg = <0 0xee120000 0 0x200>; | |
| 254 | 254 | interrupt-parent = <&gic>; |
| 255 | 255 | interrupts = <0 166 4>; |
| 256 | 256 | cap-sd-highspeed; |
| @@ -242,12 +242,18 @@ static void __init ldp_display_init(void) · 241 unmodified lines | ||
| 242 | 242 | |
| 243 | 243 | static int ldp_twl_gpio_setup(struct device *dev, unsigned gpio, unsigned ngpio) |
| 244 | 244 | { |
| 245 | + int res; | |
| 246 | + | |
| 245 | 247 | /* LCD enable GPIO */ |
| 246 | 248 | ldp_lcd_pdata.enable_gpio = gpio + 7; |
| 247 | 249 | |
| 248 | 250 | /* Backlight enable GPIO */ |
| 249 | 251 | ldp_lcd_pdata.backlight_gpio = gpio + 15; |
| 250 | 252 | |
| 253 | + res = platform_device_register(&ldp_lcd_device); | |
| 254 | + if (res) | |
| 255 | + pr_err("Unable to register LCD: %d\n", res); | |
| 256 | + | |
| 251 | 257 | return 0; |
| 252 | 258 | } |
| 253 | 259 | |
| @@ -346,7 +352,6 @@ static struct omap2_hsmmc_info mmc[] __initdata = { · 92 unmodified lines | ||
| 346 | 352 | |
| 347 | 353 | static struct platform_device *ldp_devices[] __initdata = { |
| 348 | 354 | &ldp_gpio_keys_device, |
| 349 | − &ldp_lcd_device, | |
| 350 | 355 | }; |
| 351 | 356 | |
| 352 | 357 | #ifdef CONFIG_OMAP_MUX |
| @@ -101,13 +101,51 @@ static const struct omap_dss_hwmod_data omap4_dss_hwmod_data[] __initconst = { · 100 unmodified lines | ||
| 101 | 101 | { "dss_hdmi", "omapdss_hdmi", -1 }, |
| 102 | 102 | }; |
| 103 | 103 | |
| 104 | +static int omap4_dsi_mux_pads(int dsi_id, unsigned lanes) | |
| 105 | +{ | |
| 106 | + u32 enable_mask, enable_shift; | |
| 107 | + u32 pipd_mask, pipd_shift; | |
| 108 | + u32 reg; | |
| 109 | + | |
| 110 | + if (dsi_id == 0) { | |
| 111 | + enable_mask = OMAP4_DSI1_LANEENABLE_MASK; | |
| 112 | + enable_shift = OMAP4_DSI1_LANEENABLE_SHIFT; | |
| 113 | + pipd_mask = OMAP4_DSI1_PIPD_MASK; | |
| 114 | + pipd_shift = OMAP4_DSI1_PIPD_SHIFT; | |
| 115 | + } else if (dsi_id == 1) { | |
| 116 | + enable_mask = OMAP4_DSI2_LANEENABLE_MASK; | |
| 117 | + enable_shift = OMAP4_DSI2_LANEENABLE_SHIFT; | |
| 118 | + pipd_mask = OMAP4_DSI2_PIPD_MASK; | |
| 119 | + pipd_shift = OMAP4_DSI2_PIPD_SHIFT; | |
| 120 | + } else { | |
| 121 | + return -ENODEV; | |
| 122 | + } | |
| 123 | + | |
| 124 | + reg = omap4_ctrl_pad_readl(OMAP4_CTRL_MODULE_PAD_CORE_CONTROL_DSIPHY); | |
| 125 | + | |
| 126 | + reg &= ~enable_mask; | |
| 127 | + reg &= ~pipd_mask; | |
| 128 | + | |
| 129 | + reg |= (lanes << enable_shift) & enable_mask; | |
| 130 | + reg |= (lanes << pipd_shift) & pipd_mask; | |
| 131 | + | |
| 132 | + omap4_ctrl_pad_writel(reg, OMAP4_CTRL_MODULE_PAD_CORE_CONTROL_DSIPHY); | |
| 133 | + | |
| 134 | + return 0; | |
| 135 | +} | |
| 136 | + | |
| 104 | 137 | static int omap_dsi_enable_pads(int dsi_id, unsigned lane_mask) |
| 105 | 138 | { |
| 139 | + if (cpu_is_omap44xx()) | |
| 140 | + return omap4_dsi_mux_pads(dsi_id, lane_mask); | |
| 141 | + | |
| 106 | 142 | return 0; |
| 107 | 143 | } |
| 108 | 144 | |
| 109 | 145 | static void omap_dsi_disable_pads(int dsi_id, unsigned lane_mask) |
| 110 | 146 | { |
| 147 | + if (cpu_is_omap44xx()) | |
| 148 | + omap4_dsi_mux_pads(dsi_id, 0); | |
| 111 | 149 | } |
| 112 | 150 | |
| 113 | 151 | static int omap_dss_set_min_bus_tput(struct device *dev, unsigned long tput) |
| @@ -796,7 +796,7 @@ struct omap_hwmod omap2xxx_counter_32k_hwmod = { · 795 unmodified lines | ||
| 796 | 796 | |
| 797 | 797 | /* gpmc */ |
| 798 | 798 | static struct omap_hwmod_irq_info omap2xxx_gpmc_irqs[] = { |
| 799 | − { .irq = 20 }, | |
| 799 | + { .irq = 20 + OMAP_INTC_START, }, | |
| 800 | 800 | { .irq = -1 } |
| 801 | 801 | }; |
| 802 | 802 | |
| @@ -841,7 +841,7 @@ static struct omap_hwmod_class omap2_rng_hwmod_class = { · 38 unmodified lines | ||
| 841 | 841 | }; |
| 842 | 842 | |
| 843 | 843 | static struct omap_hwmod_irq_info omap2_rng_mpu_irqs[] = { |
| 844 | − { .irq = 52 }, | |
| 844 | + { .irq = 52 + OMAP_INTC_START, }, | |
| 845 | 845 | { .irq = -1 } |
| 846 | 846 | }; |
| 847 | 847 | |
| @@ -2165,7 +2165,7 @@ static struct omap_hwmod_class omap3xxx_gpmc_hwmod_class = { · 2164 unmodified lines | ||
| 2165 | 2165 | }; |
| 2166 | 2166 | |
| 2167 | 2167 | static struct omap_hwmod_irq_info omap3xxx_gpmc_irqs[] = { |
| 2168 | − { .irq = 20 }, | |
| 2168 | + { .irq = 20 + OMAP_INTC_START, }, | |
| 2169 | 2169 | { .irq = -1 } |
| 2170 | 2170 | }; |
| 2171 | 2171 | |
| @@ -2999,7 +2999,7 @@ static struct omap_mmu_dev_attr mmu_isp_dev_attr = { · 827 unmodified lines | ||
| 2999 | 2999 | |
| 3000 | 3000 | static struct omap_hwmod omap3xxx_mmu_isp_hwmod; |
| 3001 | 3001 | static struct omap_hwmod_irq_info omap3xxx_mmu_isp_irqs[] = { |
| 3002 | − { .irq = 24 }, | |
| 3002 | + { .irq = 24 + OMAP_INTC_START, }, | |
| 3003 | 3003 | { .irq = -1 } |
| 3004 | 3004 | }; |
| 3005 | 3005 | |
| @@ -3041,7 +3041,7 @@ static struct omap_mmu_dev_attr mmu_iva_dev_attr = { · 35 unmodified lines | ||
| 3041 | 3041 | |
| 3042 | 3042 | static struct omap_hwmod omap3xxx_mmu_iva_hwmod; |
| 3043 | 3043 | static struct omap_hwmod_irq_info omap3xxx_mmu_iva_irqs[] = { |
| 3044 | − { .irq = 28 }, | |
| 3044 | + { .irq = 28 + OMAP_INTC_START, }, | |
| 3045 | 3045 | { .irq = -1 } |
| 3046 | 3046 | }; |
| 3047 | 3047 | |
| @@ -1637,7 +1637,7 @@ static struct omap_hwmod dra7xx_uart1_hwmod = { · 1636 unmodified lines | ||
| 1637 | 1637 | .class = &dra7xx_uart_hwmod_class, |
| 1638 | 1638 | .clkdm_name = "l4per_clkdm", |
| 1639 | 1639 | .main_clk = "uart1_gfclk_mux", |
| 1640 | − .flags = HWMOD_SWSUP_SIDLE_ACT, | |
| 1640 | + .flags = HWMOD_SWSUP_SIDLE_ACT | DEBUG_OMAP2UART1_FLAGS, | |
| 1641 | 1641 | .prcm = { |
| 1642 | 1642 | .omap4 = { |
| 1643 | 1643 | .clkctrl_offs = DRA7XX_CM_L4PER_UART1_CLKCTRL_OFFSET, |
| @@ -10,6 +10,8 @@ · 9 unmodified lines | ||
| 10 | 10 | * published by the Free Software Foundation. |
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | +#include <mach/irqs.h> | |
| 14 | + | |
| 13 | 15 | #define LUBBOCK_ETH_PHYS PXA_CS3_PHYS |
| 14 | 16 | |
| 15 | 17 | #define LUBBOCK_FPGA_PHYS PXA_CS2_PHYS |
| @@ -8,8 +8,6 @@ · 7 unmodified lines | ||
| 8 | 8 | * published by the Free Software Foundation. |
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | −#include <linux/clk-provider.h> | |
| 12 | −#include <linux/irqchip.h> | |
| 13 | 11 | #include <linux/of_platform.h> |
| 14 | 12 | |
| 15 | 13 | #include <asm/mach/arch.h> |
| @@ -48,15 +46,9 @@ static void __init s3c64xx_dt_map_io(void) · 32 unmodified lines | ||
| 48 | 46 | panic("SoC is not S3C64xx!"); |
| 49 | 47 | } |
| 50 | 48 | |
| 51 | −static void __init s3c64xx_dt_init_irq(void) | |
| 52 | −{ | |
| 53 | − of_clk_init(NULL); | |
| 54 | − samsung_wdt_reset_of_init(); | |
| 55 | − irqchip_init(); | |
| 56 | −}; | |
| 57 | − | |
| 58 | 49 | static void __init s3c64xx_dt_init_machine(void) |
| 59 | 50 | { |
| 51 | + samsung_wdt_reset_of_init(); | |
| 60 | 52 | of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); |
| 61 | 53 | } |
| 62 | 54 | |
| @@ -79,7 +71,6 @@ DT_MACHINE_START(S3C6400_DT, "Samsung S3C64xx (Flattened Device Tree)") · 16 unmodified lines | ||
| 79 | 71 | /* Maintainer: Tomasz Figa <tomasz.figa@gmail.com> */ |
| 80 | 72 | .dt_compat = s3c64xx_dt_compat, |
| 81 | 73 | .map_io = s3c64xx_dt_map_io, |
| 82 | − .init_irq = s3c64xx_dt_init_irq, | |
| 83 | 74 | .init_machine = s3c64xx_dt_init_machine, |
| 84 | 75 | .restart = s3c64xx_dt_restart, |
| 85 | 76 | MACHINE_END |
| @@ -614,6 +614,11 @@ static struct regulator_consumer_supply fixed3v3_power_consumers[] = { · 613 unmodified lines | ||
| 614 | 614 | REGULATOR_SUPPLY("vqmmc", "sh_mmcif"), |
| 615 | 615 | }; |
| 616 | 616 | |
| 617 | +/* Fixed 3.3V regulator used by LCD backlight */ | |
| 618 | +static struct regulator_consumer_supply fixed5v0_power_consumers[] = { | |
| 619 | + REGULATOR_SUPPLY("power", "pwm-backlight.0"), | |
| 620 | +}; | |
| 621 | + | |
| 617 | 622 | /* Fixed 3.3V regulator to be used by SDHI0 */ |
| 618 | 623 | static struct regulator_consumer_supply vcc_sdhi0_consumers[] = { |
| 619 | 624 | REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.0"), |
| @@ -1196,6 +1201,8 @@ static void __init eva_init(void) · 576 unmodified lines | ||
| 1196 | 1201 | |
| 1197 | 1202 | regulator_register_always_on(0, "fixed-3.3V", fixed3v3_power_consumers, |
| 1198 | 1203 | ARRAY_SIZE(fixed3v3_power_consumers), 3300000); |
| 1204 | + regulator_register_always_on(3, "fixed-5.0V", fixed5v0_power_consumers, | |
| 1205 | + ARRAY_SIZE(fixed5v0_power_consumers), 5000000); | |
| 1199 | 1206 | |
| 1200 | 1207 | pinctrl_register_mappings(eva_pinctrl_map, ARRAY_SIZE(eva_pinctrl_map)); |
| 1201 | 1208 | pwm_add_table(pwm_lookup, ARRAY_SIZE(pwm_lookup)); |
| @@ -679,7 +679,7 @@ static void __init bockw_init(void) · 678 unmodified lines | ||
| 679 | 679 | .id = i, |
| 680 | 680 | .data = &rsnd_card_info[i], |
| 681 | 681 | .size_data = sizeof(struct asoc_simple_card_info), |
| 682 | − .dma_mask = ~0, | |
| 682 | + .dma_mask = DMA_BIT_MASK(32), | |
| 683 | 683 | }; |
| 684 | 684 | |
| 685 | 685 | platform_device_register_full(&cardinfo); |
| @@ -245,7 +245,9 @@ static void __init lager_init(void) · 244 unmodified lines | ||
| 245 | 245 | { |
| 246 | 246 | lager_add_standard_devices(); |
| 247 | 247 | |
| 248 | − phy_register_fixup_for_id("r8a7790-ether-ff:01", lager_ksz8041_fixup); | |
| 248 | + if (IS_ENABLED(CONFIG_PHYLIB)) | |
| 249 | + phy_register_fixup_for_id("r8a7790-ether-ff:01", | |
| 250 | + lager_ksz8041_fixup); | |
| 249 | 251 | } |
| 250 | 252 | |
| 251 | 253 | static const char * const lager_boards_compat_dt[] __initconst = { |
| @@ -96,7 +96,7 @@ static int remap_pte_fn(pte_t *ptep, pgtable_t token, unsigned long addr, · 95 unmodified lines | ||
| 96 | 96 | struct remap_data *info = data; |
| 97 | 97 | struct page *page = info->pages[info->index++]; |
| 98 | 98 | unsigned long pfn = page_to_pfn(page); |
| 99 | − pte_t pte = pfn_pte(pfn, info->prot); | |
| 99 | + pte_t pte = pte_mkspecial(pfn_pte(pfn, info->prot)); | |
| 100 | 100 | |
| 101 | 101 | if (map_foreign_page(pfn, info->fgmfn, info->domid)) |
| 102 | 102 | return -EFAULT; |
| @@ -224,10 +224,10 @@ static int __init xen_guest_init(void) · 121 unmodified lines | ||
| 224 | 224 | } |
| 225 | 225 | if (of_address_to_resource(node, GRANT_TABLE_PHYSADDR, &res)) |
| 226 | 226 | return 0; |
| 227 | − xen_hvm_resume_frames = res.start >> PAGE_SHIFT; | |
| 227 | + xen_hvm_resume_frames = res.start; | |
| 228 | 228 | xen_events_irq = irq_of_parse_and_map(node, 0); |
| 229 | 229 | pr_info("Xen %s support found, events_irq=%d gnttab_frame_pfn=%lx\n", |
| 230 | − version, xen_events_irq, xen_hvm_resume_frames); | |
| 230 | + version, xen_events_irq, (xen_hvm_resume_frames >> PAGE_SHIFT)); | |
| 231 | 231 | xen_domain_type = XEN_HVM_DOMAIN; |
| 232 | 232 | |
| 233 | 233 | xen_setup_features(); |
| @@ -23,25 +23,21 @@ static inline void xen_dma_map_page(struct device *hwdev, struct page *page, · 22 unmodified lines | ||
| 23 | 23 | unsigned long offset, size_t size, enum dma_data_direction dir, |
| 24 | 24 | struct dma_attrs *attrs) |
| 25 | 25 | { |
| 26 | − __generic_dma_ops(hwdev)->map_page(hwdev, page, offset, size, dir, attrs); | |
| 27 | 26 | } |
| 28 | 27 | |
| 29 | 28 | static inline void xen_dma_unmap_page(struct device *hwdev, dma_addr_t handle, |
| 30 | 29 | size_t size, enum dma_data_direction dir, |
| 31 | 30 | struct dma_attrs *attrs) |
| 32 | 31 | { |
| 33 | − __generic_dma_ops(hwdev)->unmap_page(hwdev, handle, size, dir, attrs); | |
| 34 | 32 | } |
| 35 | 33 | |
| 36 | 34 | static inline void xen_dma_sync_single_for_cpu(struct device *hwdev, |
| 37 | 35 | dma_addr_t handle, size_t size, enum dma_data_direction dir) |
| 38 | 36 | { |
| 39 | − __generic_dma_ops(hwdev)->sync_single_for_cpu(hwdev, handle, size, dir); | |
| 40 | 37 | } |
| 41 | 38 | |
| 42 | 39 | static inline void xen_dma_sync_single_for_device(struct device *hwdev, |
| 43 | 40 | dma_addr_t handle, size_t size, enum dma_data_direction dir) |
| 44 | 41 | { |
| 45 | − __generic_dma_ops(hwdev)->sync_single_for_device(hwdev, handle, size, dir); | |
| 46 | 42 | } |
| 47 | 43 | #endif /* _ASM_ARM64_XEN_PAGE_COHERENT_H */ |
| @@ -214,31 +214,29 @@ static int ptrace_hbp_fill_attr_ctrl(unsigned int note_type, · 213 unmodified lines | ||
| 214 | 214 | { |
| 215 | 215 | int err, len, type, disabled = !ctrl.enabled; |
| 216 | 216 | |
| 217 | − if (disabled) { | |
| 218 | − len = 0; | |
| 219 | − type = HW_BREAKPOINT_EMPTY; | |
| 220 | − } else { | |
| 221 | − err = arch_bp_generic_fields(ctrl, &len, &type); | |
| 222 | − if (err) | |
| 223 | − return err; | |
| 224 | − | |
| 225 | − switch (note_type) { | |
| 226 | − case NT_ARM_HW_BREAK: | |
| 227 | − if ((type & HW_BREAKPOINT_X) != type) | |
| 228 | − return -EINVAL; | |
| 229 | − break; | |
| 230 | − case NT_ARM_HW_WATCH: | |
| 231 | − if ((type & HW_BREAKPOINT_RW) != type) | |
| 232 | − return -EINVAL; | |
| 233 | − break; | |
| 234 | − default: | |
| 217 | + attr->disabled = disabled; | |
| 218 | + if (disabled) | |
| 219 | + return 0; | |
| 220 | + | |
| 221 | + err = arch_bp_generic_fields(ctrl, &len, &type); | |
| 222 | + if (err) | |
| 223 | + return err; | |
| 224 | + | |
| 225 | + switch (note_type) { | |
| 226 | + case NT_ARM_HW_BREAK: | |
| 227 | + if ((type & HW_BREAKPOINT_X) != type) | |
| 235 | 228 | return -EINVAL; |
| 236 | − } | |
| 229 | + break; | |
| 230 | + case NT_ARM_HW_WATCH: | |
| 231 | + if ((type & HW_BREAKPOINT_RW) != type) | |
| 232 | + return -EINVAL; | |
| 233 | + break; | |
| 234 | + default: | |
| 235 | + return -EINVAL; | |
| 237 | 236 | } |
| 238 | 237 | |
| 239 | 238 | attr->bp_len = len; |
| 240 | 239 | attr->bp_type = type; |
| 241 | − attr->disabled = disabled; | |
| 242 | 240 | |
| 243 | 241 | return 0; |
| 244 | 242 | } |
| @@ -192,6 +192,10 @@ extern void kvmppc_load_up_vsx(void); · 191 unmodified lines | ||
| 192 | 192 | extern u32 kvmppc_alignment_dsisr(struct kvm_vcpu *vcpu, unsigned int inst); |
| 193 | 193 | extern ulong kvmppc_alignment_dar(struct kvm_vcpu *vcpu, unsigned int inst); |
| 194 | 194 | extern int kvmppc_h_pr(struct kvm_vcpu *vcpu, unsigned long cmd); |
| 195 | +extern void kvmppc_copy_to_svcpu(struct kvmppc_book3s_shadow_vcpu *svcpu, | |
| 196 | + struct kvm_vcpu *vcpu); | |
| 197 | +extern void kvmppc_copy_from_svcpu(struct kvm_vcpu *vcpu, | |
| 198 | + struct kvmppc_book3s_shadow_vcpu *svcpu); | |
| 195 | 199 | |
| 196 | 200 | static inline struct kvmppc_vcpu_book3s *to_book3s(struct kvm_vcpu *vcpu) |
| 197 | 201 | { |
| @@ -79,6 +79,7 @@ struct kvmppc_host_state { · 78 unmodified lines | ||
| 79 | 79 | ulong vmhandler; |
| 80 | 80 | ulong scratch0; |
| 81 | 81 | ulong scratch1; |
| 82 | + ulong scratch2; | |
| 82 | 83 | u8 in_guest; |
| 83 | 84 | u8 restore_hid5; |
| 84 | 85 | u8 napping; |
| @@ -106,6 +107,7 @@ struct kvmppc_host_state { · 21 unmodified lines | ||
| 106 | 107 | }; |
| 107 | 108 | |
| 108 | 109 | struct kvmppc_book3s_shadow_vcpu { |
| 110 | + bool in_use; | |
| 109 | 111 | ulong gpr[14]; |
| 110 | 112 | u32 cr; |
| 111 | 113 | u32 xer; |
| @@ -720,13 +720,13 @@ int64_t opal_pci_next_error(uint64_t phb_id, uint64_t *first_frozen_pe, · 719 unmodified lines | ||
| 720 | 720 | int64_t opal_pci_poll(uint64_t phb_id); |
| 721 | 721 | int64_t opal_return_cpu(void); |
| 722 | 722 | |
| 723 | −int64_t opal_xscom_read(uint32_t gcid, uint32_t pcb_addr, uint64_t *val); | |
| 723 | +int64_t opal_xscom_read(uint32_t gcid, uint32_t pcb_addr, __be64 *val); | |
| 724 | 724 | int64_t opal_xscom_write(uint32_t gcid, uint32_t pcb_addr, uint64_t val); |
| 725 | 725 | |
| 726 | 726 | int64_t opal_lpc_write(uint32_t chip_id, enum OpalLPCAddressType addr_type, |
| 727 | 727 | uint32_t addr, uint32_t data, uint32_t sz); |
| 728 | 728 | int64_t opal_lpc_read(uint32_t chip_id, enum OpalLPCAddressType addr_type, |
| 729 | − uint32_t addr, uint32_t *data, uint32_t sz); | |
| 729 | + uint32_t addr, __be32 *data, uint32_t sz); | |
| 730 | 730 | int64_t opal_validate_flash(uint64_t buffer, uint32_t *size, uint32_t *result); |
| 731 | 731 | int64_t opal_manage_flash(uint8_t op); |
| 732 | 732 | int64_t opal_update_flash(uint64_t blk_list); |
| @@ -35,7 +35,7 @@ extern void giveup_vsx(struct task_struct *); · 34 unmodified lines | ||
| 35 | 35 | extern void enable_kernel_spe(void); |
| 36 | 36 | extern void giveup_spe(struct task_struct *); |
| 37 | 37 | extern void load_up_spe(struct task_struct *); |
| 38 | −extern void switch_booke_debug_regs(struct thread_struct *new_thread); | |
| 38 | +extern void switch_booke_debug_regs(struct debug_reg *new_debug); | |
| 39 | 39 | |
| 40 | 40 | #ifndef CONFIG_SMP |
| 41 | 41 | extern void discard_lazy_cpu_state(void); |
| @@ -576,6 +576,7 @@ int main(void) · 575 unmodified lines | ||
| 576 | 576 | HSTATE_FIELD(HSTATE_VMHANDLER, vmhandler); |
| 577 | 577 | HSTATE_FIELD(HSTATE_SCRATCH0, scratch0); |
| 578 | 578 | HSTATE_FIELD(HSTATE_SCRATCH1, scratch1); |
| 579 | + HSTATE_FIELD(HSTATE_SCRATCH2, scratch2); | |
| 579 | 580 | HSTATE_FIELD(HSTATE_IN_GUEST, in_guest); |
| 580 | 581 | HSTATE_FIELD(HSTATE_RESTORE_HID5, restore_hid5); |
| 581 | 582 | HSTATE_FIELD(HSTATE_NAPPING, napping); |
| @@ -124,15 +124,15 @@ ssize_t copy_oldmem_page(unsigned long pfn, char *buf, · 123 unmodified lines | ||
| 124 | 124 | void crash_free_reserved_phys_range(unsigned long begin, unsigned long end) |
| 125 | 125 | { |
| 126 | 126 | unsigned long addr; |
| 127 | − const u32 *basep, *sizep; | |
| 127 | + const __be32 *basep, *sizep; | |
| 128 | 128 | unsigned int rtas_start = 0, rtas_end = 0; |
| 129 | 129 | |
| 130 | 130 | basep = of_get_property(rtas.dev, "linux,rtas-base", NULL); |
| 131 | 131 | sizep = of_get_property(rtas.dev, "rtas-size", NULL); |
| 132 | 132 | |
| 133 | 133 | if (basep && sizep) { |
| 134 | − rtas_start = *basep; | |
| 135 | − rtas_end = *basep + *sizep; | |
| 134 | + rtas_start = be32_to_cpup(basep); | |
| 135 | + rtas_end = rtas_start + be32_to_cpup(sizep); | |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | for (addr = begin; addr < end; addr += PAGE_SIZE) { |
| @@ -339,7 +339,7 @@ static void set_debug_reg_defaults(struct thread_struct *thread) · 338 unmodified lines | ||
| 339 | 339 | #endif |
| 340 | 340 | } |
| 341 | 341 | |
| 342 | −static void prime_debug_regs(struct thread_struct *thread) | |
| 342 | +static void prime_debug_regs(struct debug_reg *debug) | |
| 343 | 343 | { |
| 344 | 344 | /* |
| 345 | 345 | * We could have inherited MSR_DE from userspace, since |
| @@ -348,22 +348,22 @@ static void prime_debug_regs(struct thread_struct *thread) · 2 unmodified lines | ||
| 348 | 348 | */ |
| 349 | 349 | mtmsr(mfmsr() & ~MSR_DE); |
| 350 | 350 | |
| 351 | − mtspr(SPRN_IAC1, thread->debug.iac1); | |
| 352 | − mtspr(SPRN_IAC2, thread->debug.iac2); | |
| 351 | + mtspr(SPRN_IAC1, debug->iac1); | |
| 352 | + mtspr(SPRN_IAC2, debug->iac2); | |
| 353 | 353 | #if CONFIG_PPC_ADV_DEBUG_IACS > 2 |
| 354 | − mtspr(SPRN_IAC3, thread->debug.iac3); | |
| 355 | − mtspr(SPRN_IAC4, thread->debug.iac4); | |
| 354 | + mtspr(SPRN_IAC3, debug->iac3); | |
| 355 | + mtspr(SPRN_IAC4, debug->iac4); | |
| 356 | 356 | #endif |
| 357 | − mtspr(SPRN_DAC1, thread->debug.dac1); | |
| 358 | − mtspr(SPRN_DAC2, thread->debug.dac2); | |
| 357 | + mtspr(SPRN_DAC1, debug->dac1); | |
| 358 | + mtspr(SPRN_DAC2, debug->dac2); | |
| 359 | 359 | #if CONFIG_PPC_ADV_DEBUG_DVCS > 0 |
| 360 | − mtspr(SPRN_DVC1, thread->debug.dvc1); | |
| 361 | − mtspr(SPRN_DVC2, thread->debug.dvc2); | |
| 360 | + mtspr(SPRN_DVC1, debug->dvc1); | |
| 361 | + mtspr(SPRN_DVC2, debug->dvc2); | |
| 362 | 362 | #endif |
| 363 | − mtspr(SPRN_DBCR0, thread->debug.dbcr0); | |
| 364 | − mtspr(SPRN_DBCR1, thread->debug.dbcr1); | |
| 363 | + mtspr(SPRN_DBCR0, debug->dbcr0); | |
| 364 | + mtspr(SPRN_DBCR1, debug->dbcr1); | |
| 365 | 365 | #ifdef CONFIG_BOOKE |
| 366 | − mtspr(SPRN_DBCR2, thread->debug.dbcr2); | |
| 366 | + mtspr(SPRN_DBCR2, debug->dbcr2); | |
| 367 | 367 | #endif |
| 368 | 368 | } |
| 369 | 369 | /* |
| @@ -371,11 +371,11 @@ static void prime_debug_regs(struct thread_struct *thread) · 1 unmodified line | ||
| 371 | 371 | * debug registers, set the debug registers from the values |
| 372 | 372 | * stored in the new thread. |
| 373 | 373 | */ |
| 374 | −void switch_booke_debug_regs(struct thread_struct *new_thread) | |
| 374 | +void switch_booke_debug_regs(struct debug_reg *new_debug) | |
| 375 | 375 | { |
| 376 | 376 | if ((current->thread.debug.dbcr0 & DBCR0_IDM) |
| 377 | − || (new_thread->debug.dbcr0 & DBCR0_IDM)) | |
| 378 | − prime_debug_regs(new_thread); | |
| 377 | + || (new_debug->dbcr0 & DBCR0_IDM)) | |
| 378 | + prime_debug_regs(new_debug); | |
| 379 | 379 | } |
| 380 | 380 | EXPORT_SYMBOL_GPL(switch_booke_debug_regs); |
| 381 | 381 | #else /* !CONFIG_PPC_ADV_DEBUG_REGS */ |
| @@ -683,7 +683,7 @@ struct task_struct *__switch_to(struct task_struct *prev, · 301 unmodified lines | ||
| 683 | 683 | #endif /* CONFIG_SMP */ |
| 684 | 684 | |
| 685 | 685 | #ifdef CONFIG_PPC_ADV_DEBUG_REGS |
| 686 | − switch_booke_debug_regs(&new->thread); | |
| 686 | + switch_booke_debug_regs(&new->thread.debug); | |
| 687 | 687 | #else |
| 688 | 688 | /* |
| 689 | 689 | * For PPC_BOOK3S_64, we use the hw-breakpoint interfaces that would |
| @@ -1555,7 +1555,7 @@ long arch_ptrace(struct task_struct *child, long request, · 1554 unmodified lines | ||
| 1555 | 1555 | |
| 1556 | 1556 | flush_fp_to_thread(child); |
| 1557 | 1557 | if (fpidx < (PT_FPSCR - PT_FPR0)) |
| 1558 | − memcpy(&tmp, &child->thread.fp_state.fpr, | |
| 1558 | + memcpy(&tmp, &child->thread.TS_FPR(fpidx), | |
| 1559 | 1559 | sizeof(long)); |
| 1560 | 1560 | else |
| 1561 | 1561 | tmp = child->thread.fp_state.fpscr; |
| @@ -1588,7 +1588,7 @@ long arch_ptrace(struct task_struct *child, long request, · 26 unmodified lines | ||
| 1588 | 1588 | |
| 1589 | 1589 | flush_fp_to_thread(child); |
| 1590 | 1590 | if (fpidx < (PT_FPSCR - PT_FPR0)) |
| 1591 | − memcpy(&child->thread.fp_state.fpr, &data, | |
| 1591 | + memcpy(&child->thread.TS_FPR(fpidx), &data, | |
| 1592 | 1592 | sizeof(long)); |
| 1593 | 1593 | else |
| 1594 | 1594 | child->thread.fp_state.fpscr = data; |
| @@ -479,7 +479,7 @@ void __init smp_setup_cpu_maps(void) · 478 unmodified lines | ||
| 479 | 479 | if (machine_is(pseries) && firmware_has_feature(FW_FEATURE_LPAR) && |
| 480 | 480 | (dn = of_find_node_by_path("/rtas"))) { |
| 481 | 481 | int num_addr_cell, num_size_cell, maxcpus; |
| 482 | − const unsigned int *ireg; | |
| 482 | + const __be32 *ireg; | |
| 483 | 483 | |
| 484 | 484 | num_addr_cell = of_n_addr_cells(dn); |
| 485 | 485 | num_size_cell = of_n_size_cells(dn); |
| @@ -489,7 +489,7 @@ void __init smp_setup_cpu_maps(void) · 3 unmodified lines | ||
| 489 | 489 | if (!ireg) |
| 490 | 490 | goto out; |
| 491 | 491 | |
| 492 | − maxcpus = ireg[num_addr_cell + num_size_cell]; | |
| 492 | + maxcpus = be32_to_cpup(ireg + num_addr_cell + num_size_cell); | |
| 493 | 493 | |
| 494 | 494 | /* Double maxcpus for processors which have SMT capability */ |
| 495 | 495 | if (cpu_has_feature(CPU_FTR_SMT)) |
| @@ -580,7 +580,7 @@ int __cpu_up(unsigned int cpu, struct task_struct *tidle) · 579 unmodified lines | ||
| 580 | 580 | int cpu_to_core_id(int cpu) |
| 581 | 581 | { |
| 582 | 582 | struct device_node *np; |
| 583 | − const int *reg; | |
| 583 | + const __be32 *reg; | |
| 584 | 584 | int id = -1; |
| 585 | 585 | |
| 586 | 586 | np = of_get_cpu_node(cpu, NULL); |
| @@ -591,7 +591,7 @@ int cpu_to_core_id(int cpu) · 4 unmodified lines | ||
| 591 | 591 | if (!reg) |
| 592 | 592 | goto out; |
| 593 | 593 | |
| 594 | − id = *reg; | |
| 594 | + id = be32_to_cpup(reg); | |
| 595 | 595 | out: |
| 596 | 596 | of_node_put(np); |
| 597 | 597 | return id; |
| @@ -469,11 +469,14 @@ static int kvmppc_mmu_book3s_64_hv_xlate(struct kvm_vcpu *vcpu, gva_t eaddr, · 468 unmodified lines | ||
| 469 | 469 | slb_v = vcpu->kvm->arch.vrma_slb_v; |
| 470 | 470 | } |
| 471 | 471 | |
| 472 | + preempt_disable(); | |
| 472 | 473 | /* Find the HPTE in the hash table */ |
| 473 | 474 | index = kvmppc_hv_find_lock_hpte(kvm, eaddr, slb_v, |
| 474 | 475 | HPTE_V_VALID | HPTE_V_ABSENT); |
| 475 | − if (index < 0) | |
| 476 | + if (index < 0) { | |
| 477 | + preempt_enable(); | |
| 476 | 478 | return -ENOENT; |
| 479 | + } | |
| 477 | 480 | hptep = (unsigned long *)(kvm->arch.hpt_virt + (index << 4)); |
| 478 | 481 | v = hptep[0] & ~HPTE_V_HVLOCK; |
| 479 | 482 | gr = kvm->arch.revmap[index].guest_rpte; |
| @@ -481,6 +484,7 @@ static int kvmppc_mmu_book3s_64_hv_xlate(struct kvm_vcpu *vcpu, gva_t eaddr, · 1 unmodified line | ||
| 481 | 484 | /* Unlock the HPTE */ |
| 482 | 485 | asm volatile("lwsync" : : : "memory"); |
| 483 | 486 | hptep[0] = v; |
| 487 | + preempt_enable(); | |
| 484 | 488 | |
| 485 | 489 | gpte->eaddr = eaddr; |
| 486 | 490 | gpte->vpage = ((v & HPTE_V_AVPN) << 4) | ((eaddr >> 12) & 0xfff); |
| @@ -665,6 +669,7 @@ int kvmppc_book3s_hv_page_fault(struct kvm_run *run, struct kvm_vcpu *vcpu, · 178 unmodified lines | ||
| 665 | 669 | return -EFAULT; |
| 666 | 670 | } else { |
| 667 | 671 | page = pages[0]; |
| 672 | + pfn = page_to_pfn(page); | |
| 668 | 673 | if (PageHuge(page)) { |
| 669 | 674 | page = compound_head(page); |
| 670 | 675 | pte_size <<= compound_order(page); |
| @@ -689,7 +694,6 @@ int kvmppc_book3s_hv_page_fault(struct kvm_run *run, struct kvm_vcpu *vcpu, · 18 unmodified lines | ||
| 689 | 694 | } |
| 690 | 695 | rcu_read_unlock_sched(); |
| 691 | 696 | } |
| 692 | − pfn = page_to_pfn(page); | |
| 693 | 697 | } |
| 694 | 698 | |
| 695 | 699 | ret = -EFAULT; |
| @@ -707,8 +711,14 @@ int kvmppc_book3s_hv_page_fault(struct kvm_run *run, struct kvm_vcpu *vcpu, · 11 unmodified lines | ||
| 707 | 711 | r = (r & ~(HPTE_R_W|HPTE_R_I|HPTE_R_G)) | HPTE_R_M; |
| 708 | 712 | } |
| 709 | 713 | |
| 710 | − /* Set the HPTE to point to pfn */ | |
| 711 | − r = (r & ~(HPTE_R_PP0 - pte_size)) | (pfn << PAGE_SHIFT); | |
| 714 | + /* | |
| 715 | + * Set the HPTE to point to pfn. | |
| 716 | + * Since the pfn is at PAGE_SIZE granularity, make sure we | |
| 717 | + * don't mask out lower-order bits if psize < PAGE_SIZE. | |
| 718 | + */ | |
| 719 | + if (psize < PAGE_SIZE) | |
| 720 | + psize = PAGE_SIZE; | |
| 721 | + r = (r & ~(HPTE_R_PP0 - psize)) | ((pfn << PAGE_SHIFT) & ~(psize - 1)); | |
| 712 | 722 | if (hpte_is_writable(r) && !write_ok) |
| 713 | 723 | r = hpte_make_readonly(r); |
| 714 | 724 | ret = RESUME_GUEST; |
| @@ -131,8 +131,9 @@ static void kvmppc_fast_vcpu_kick_hv(struct kvm_vcpu *vcpu) · 130 unmodified lines | ||
| 131 | 131 | static void kvmppc_core_vcpu_load_hv(struct kvm_vcpu *vcpu, int cpu) |
| 132 | 132 | { |
| 133 | 133 | struct kvmppc_vcore *vc = vcpu->arch.vcore; |
| 134 | + unsigned long flags; | |
| 134 | 135 | |
| 135 | − spin_lock(&vcpu->arch.tbacct_lock); | |
| 136 | + spin_lock_irqsave(&vcpu->arch.tbacct_lock, flags); | |
| 136 | 137 | if (vc->runner == vcpu && vc->vcore_state != VCORE_INACTIVE && |
| 137 | 138 | vc->preempt_tb != TB_NIL) { |
| 138 | 139 | vc->stolen_tb += mftb() - vc->preempt_tb; |
| @@ -143,19 +144,20 @@ static void kvmppc_core_vcpu_load_hv(struct kvm_vcpu *vcpu, int cpu) · 4 unmodified lines | ||
| 143 | 144 | vcpu->arch.busy_stolen += mftb() - vcpu->arch.busy_preempt; |
| 144 | 145 | vcpu->arch.busy_preempt = TB_NIL; |
| 145 | 146 | } |
| 146 | − spin_unlock(&vcpu->arch.tbacct_lock); | |
| 147 | + spin_unlock_irqrestore(&vcpu->arch.tbacct_lock, flags); | |
| 147 | 148 | } |
| 148 | 149 | |
| 149 | 150 | static void kvmppc_core_vcpu_put_hv(struct kvm_vcpu *vcpu) |
| 150 | 151 | { |
| 151 | 152 | struct kvmppc_vcore *vc = vcpu->arch.vcore; |
| 153 | + unsigned long flags; | |
| 152 | 154 | |
| 153 | − spin_lock(&vcpu->arch.tbacct_lock); | |
| 155 | + spin_lock_irqsave(&vcpu->arch.tbacct_lock, flags); | |
| 154 | 156 | if (vc->runner == vcpu && vc->vcore_state != VCORE_INACTIVE) |
| 155 | 157 | vc->preempt_tb = mftb(); |
| 156 | 158 | if (vcpu->arch.state == KVMPPC_VCPU_BUSY_IN_HOST) |
| 157 | 159 | vcpu->arch.busy_preempt = mftb(); |
| 158 | − spin_unlock(&vcpu->arch.tbacct_lock); | |
| 160 | + spin_unlock_irqrestore(&vcpu->arch.tbacct_lock, flags); | |
| 159 | 161 | } |
| 160 | 162 | |
| 161 | 163 | static void kvmppc_set_msr_hv(struct kvm_vcpu *vcpu, u64 msr) |
| @@ -486,11 +488,11 @@ static u64 vcore_stolen_time(struct kvmppc_vcore *vc, u64 now) · 324 unmodified lines | ||
| 486 | 488 | */ |
| 487 | 489 | if (vc->vcore_state != VCORE_INACTIVE && |
| 488 | 490 | vc->runner->arch.run_task != current) { |
| 489 | − spin_lock(&vc->runner->arch.tbacct_lock); | |
| 491 | + spin_lock_irq(&vc->runner->arch.tbacct_lock); | |
| 490 | 492 | p = vc->stolen_tb; |
| 491 | 493 | if (vc->preempt_tb != TB_NIL) |
| 492 | 494 | p += now - vc->preempt_tb; |
| 493 | − spin_unlock(&vc->runner->arch.tbacct_lock); | |
| 495 | + spin_unlock_irq(&vc->runner->arch.tbacct_lock); | |
| 494 | 496 | } else { |
| 495 | 497 | p = vc->stolen_tb; |
| 496 | 498 | } |
| @@ -512,10 +514,10 @@ static void kvmppc_create_dtl_entry(struct kvm_vcpu *vcpu, · 15 unmodified lines | ||
| 512 | 514 | core_stolen = vcore_stolen_time(vc, now); |
| 513 | 515 | stolen = core_stolen - vcpu->arch.stolen_logged; |
| 514 | 516 | vcpu->arch.stolen_logged = core_stolen; |
| 515 | − spin_lock(&vcpu->arch.tbacct_lock); | |
| 517 | + spin_lock_irq(&vcpu->arch.tbacct_lock); | |
| 516 | 518 | stolen += vcpu->arch.busy_stolen; |
| 517 | 519 | vcpu->arch.busy_stolen = 0; |
| 518 | − spin_unlock(&vcpu->arch.tbacct_lock); | |
| 520 | + spin_unlock_irq(&vcpu->arch.tbacct_lock); | |
| 519 | 521 | if (!dt || !vpa) |
| 520 | 522 | return; |
| 521 | 523 | memset(dt, 0, sizeof(struct dtl_entry)); |
| @@ -589,7 +591,9 @@ int kvmppc_pseries_do_hcall(struct kvm_vcpu *vcpu) · 67 unmodified lines | ||
| 589 | 591 | if (list_empty(&vcpu->kvm->arch.rtas_tokens)) |
| 590 | 592 | return RESUME_HOST; |
| 591 | 593 | |
| 594 | + idx = srcu_read_lock(&vcpu->kvm->srcu); | |
| 592 | 595 | rc = kvmppc_rtas_hcall(vcpu); |
| 596 | + srcu_read_unlock(&vcpu->kvm->srcu, idx); | |
| 593 | 597 | |
| 594 | 598 | if (rc == -ENOENT) |
| 595 | 599 | return RESUME_HOST; |
| @@ -1115,13 +1119,13 @@ static void kvmppc_remove_runnable(struct kvmppc_vcore *vc, · 519 unmodified lines | ||
| 1115 | 1119 | |
| 1116 | 1120 | if (vcpu->arch.state != KVMPPC_VCPU_RUNNABLE) |
| 1117 | 1121 | return; |
| 1118 | − spin_lock(&vcpu->arch.tbacct_lock); | |
| 1122 | + spin_lock_irq(&vcpu->arch.tbacct_lock); | |
| 1119 | 1123 | now = mftb(); |
| 1120 | 1124 | vcpu->arch.busy_stolen += vcore_stolen_time(vc, now) - |
| 1121 | 1125 | vcpu->arch.stolen_logged; |
| 1122 | 1126 | vcpu->arch.busy_preempt = now; |
| 1123 | 1127 | vcpu->arch.state = KVMPPC_VCPU_BUSY_IN_HOST; |
| 1124 | − spin_unlock(&vcpu->arch.tbacct_lock); | |
| 1128 | + spin_unlock_irq(&vcpu->arch.tbacct_lock); | |
| 1125 | 1129 | --vc->n_runnable; |
| 1126 | 1130 | list_del(&vcpu->arch.run_list); |
| 1127 | 1131 | } |
| @@ -225,6 +225,7 @@ long kvmppc_do_h_enter(struct kvm *kvm, unsigned long flags, · 224 unmodified lines | ||
| 225 | 225 | is_io = pa & (HPTE_R_I | HPTE_R_W); |
| 226 | 226 | pte_size = PAGE_SIZE << (pa & KVMPPC_PAGE_ORDER_MASK); |
| 227 | 227 | pa &= PAGE_MASK; |
| 228 | + pa |= gpa & ~PAGE_MASK; | |
| 228 | 229 | } else { |
| 229 | 230 | /* Translate to host virtual address */ |
| 230 | 231 | hva = __gfn_to_hva_memslot(memslot, gfn); |
| @@ -238,13 +239,13 @@ long kvmppc_do_h_enter(struct kvm *kvm, unsigned long flags, · 7 unmodified lines | ||
| 238 | 239 | ptel = hpte_make_readonly(ptel); |
| 239 | 240 | is_io = hpte_cache_bits(pte_val(pte)); |
| 240 | 241 | pa = pte_pfn(pte) << PAGE_SHIFT; |
| 242 | + pa |= hva & (pte_size - 1); | |
| 243 | + pa |= gpa & ~PAGE_MASK; | |
| 241 | 244 | } |
| 242 | 245 | } |
| 243 | 246 | |
| 244 | 247 | if (pte_size < psize) |
| 245 | 248 | return H_PARAMETER; |
| 246 | − if (pa && pte_size > psize) | |
| 247 | − pa |= gpa & (pte_size - 1); | |
| 248 | 249 | |
| 249 | 250 | ptel &= ~(HPTE_R_PP0 - psize); |
| 250 | 251 | ptel |= pa; |
| @@ -749,6 +750,10 @@ static int slb_base_page_shift[4] = { · 498 unmodified lines | ||
| 749 | 750 | 20, /* 1M, unsupported */ |
| 750 | 751 | }; |
| 751 | 752 | |
| 753 | +/* When called from virtmode, this func should be protected by | |
| 754 | + * preempt_disable(), otherwise, the holding of HPTE_V_HVLOCK | |
| 755 | + * can trigger deadlock issue. | |
| 756 | + */ | |
| 752 | 757 | long kvmppc_hv_find_lock_hpte(struct kvm *kvm, gva_t eaddr, unsigned long slb_v, |
| 753 | 758 | unsigned long valid) |
| 754 | 759 | { |
| @@ -153,7 +153,6 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_206) · 152 unmodified lines | ||
| 153 | 153 | |
| 154 | 154 | 13: b machine_check_fwnmi |
| 155 | 155 | |
| 156 | − | |
| 157 | 156 | /* |
| 158 | 157 | * We come in here when wakened from nap mode on a secondary hw thread. |
| 159 | 158 | * Relocation is off and most register values are lost. |
| @@ -224,6 +223,11 @@ kvm_start_guest: · 64 unmodified lines | ||
| 224 | 223 | /* Clear our vcpu pointer so we don't come back in early */ |
| 225 | 224 | li r0, 0 |
| 226 | 225 | std r0, HSTATE_KVM_VCPU(r13) |
| 226 | + /* | |
| 227 | + * Make sure we clear HSTATE_KVM_VCPU(r13) before incrementing | |
| 228 | + * the nap_count, because once the increment to nap_count is | |
| 229 | + * visible we could be given another vcpu. | |
| 230 | + */ | |
| 227 | 231 | lwsync |
| 228 | 232 | /* Clear any pending IPI - we're an offline thread */ |
| 229 | 233 | ld r5, HSTATE_XICS_PHYS(r13) |
| @@ -241,7 +245,6 @@ kvm_start_guest: · 11 unmodified lines | ||
| 241 | 245 | /* increment the nap count and then go to nap mode */ |
| 242 | 246 | ld r4, HSTATE_KVM_VCORE(r13) |
| 243 | 247 | addi r4, r4, VCORE_NAP_COUNT |
| 244 | − lwsync /* make previous updates visible */ | |
| 245 | 248 | 51: lwarx r3, 0, r4 |
| 246 | 249 | addi r3, r3, 1 |
| 247 | 250 | stwcx. r3, 0, r4 |
| @@ -751,15 +754,14 @@ kvmppc_interrupt_hv: · 503 unmodified lines | ||
| 751 | 754 | * guest CR, R12 saved in shadow VCPU SCRATCH1/0 |
| 752 | 755 | * guest R13 saved in SPRN_SCRATCH0 |
| 753 | 756 | */ |
| 754 | − /* abuse host_r2 as third scratch area; we get r2 from PACATOC(r13) */ | |
| 755 | − std r9, HSTATE_HOST_R2(r13) | |
| 757 | + std r9, HSTATE_SCRATCH2(r13) | |
| 756 | 758 | |
| 757 | 759 | lbz r9, HSTATE_IN_GUEST(r13) |
| 758 | 760 | cmpwi r9, KVM_GUEST_MODE_HOST_HV |
| 759 | 761 | beq kvmppc_bad_host_intr |
| 760 | 762 | #ifdef CONFIG_KVM_BOOK3S_PR_POSSIBLE |
| 761 | 763 | cmpwi r9, KVM_GUEST_MODE_GUEST |
| 762 | − ld r9, HSTATE_HOST_R2(r13) | |
| 764 | + ld r9, HSTATE_SCRATCH2(r13) | |
| 763 | 765 | beq kvmppc_interrupt_pr |
| 764 | 766 | #endif |
| 765 | 767 | /* We're now back in the host but in guest MMU context */ |
| @@ -779,7 +781,7 @@ kvmppc_interrupt_hv: · 13 unmodified lines | ||
| 779 | 781 | std r6, VCPU_GPR(R6)(r9) |
| 780 | 782 | std r7, VCPU_GPR(R7)(r9) |
| 781 | 783 | std r8, VCPU_GPR(R8)(r9) |
| 782 | − ld r0, HSTATE_HOST_R2(r13) | |
| 784 | + ld r0, HSTATE_SCRATCH2(r13) | |
| 783 | 785 | std r0, VCPU_GPR(R9)(r9) |
| 784 | 786 | std r10, VCPU_GPR(R10)(r9) |
| 785 | 787 | std r11, VCPU_GPR(R11)(r9) |
| @@ -990,14 +992,13 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_201) · 204 unmodified lines | ||
| 990 | 992 | */ |
| 991 | 993 | /* Increment the threads-exiting-guest count in the 0xff00 |
| 992 | 994 | bits of vcore->entry_exit_count */ |
| 993 | − lwsync | |
| 994 | 995 | ld r5,HSTATE_KVM_VCORE(r13) |
| 995 | 996 | addi r6,r5,VCORE_ENTRY_EXIT |
| 996 | 997 | 41: lwarx r3,0,r6 |
| 997 | 998 | addi r0,r3,0x100 |
| 998 | 999 | stwcx. r0,0,r6 |
| 999 | 1000 | bne 41b |
| 1000 | − lwsync | |
| 1001 | + isync /* order stwcx. vs. reading napping_threads */ | |
| 1001 | 1002 | |
| 1002 | 1003 | /* |
| 1003 | 1004 | * At this point we have an interrupt that we have to pass |
| @@ -1030,6 +1031,8 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_201) · 26 unmodified lines | ||
| 1030 | 1031 | sld r0,r0,r4 |
| 1031 | 1032 | andc. r3,r3,r0 /* no sense IPI'ing ourselves */ |
| 1032 | 1033 | beq 43f |
| 1034 | + /* Order entry/exit update vs. IPIs */ | |
| 1035 | + sync | |
| 1033 | 1036 | mulli r4,r4,PACA_SIZE /* get paca for thread 0 */ |
| 1034 | 1037 | subf r6,r4,r13 |
| 1035 | 1038 | 42: andi. r0,r3,1 |
| @@ -1638,10 +1641,10 @@ END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_206) · 602 unmodified lines | ||
| 1638 | 1641 | bge kvm_cede_exit |
| 1639 | 1642 | stwcx. r4,0,r6 |
| 1640 | 1643 | bne 31b |
| 1644 | + /* order napping_threads update vs testing entry_exit_count */ | |
| 1645 | + isync | |
| 1641 | 1646 | li r0,1 |
| 1642 | 1647 | stb r0,HSTATE_NAPPING(r13) |
| 1643 | − /* order napping_threads update vs testing entry_exit_count */ | |
| 1644 | − lwsync | |
| 1645 | 1648 | mr r4,r3 |
| 1646 | 1649 | lwz r7,VCORE_ENTRY_EXIT(r5) |
| 1647 | 1650 | cmpwi r7,0x100 |
| @@ -129,29 +129,32 @@ kvm_start_lightweight: · 128 unmodified lines | ||
| 129 | 129 | * R12 = exit handler id |
| 130 | 130 | * R13 = PACA |
| 131 | 131 | * SVCPU.* = guest * |
| 132 | + * MSR.EE = 1 | |
| 132 | 133 | * |
| 133 | 134 | */ |
| 134 | 135 | |
| 136 | + PPC_LL r3, GPR4(r1) /* vcpu pointer */ | |
| 137 | + | |
| 138 | + /* | |
| 139 | + * kvmppc_copy_from_svcpu can clobber volatile registers, save | |
| 140 | + * the exit handler id to the vcpu and restore it from there later. | |
| 141 | + */ | |
| 142 | + stw r12, VCPU_TRAP(r3) | |
| 143 | + | |
| 135 | 144 | /* Transfer reg values from shadow vcpu back to vcpu struct */ |
| 136 | 145 | /* On 64-bit, interrupts are still off at this point */ |
| 137 | − PPC_LL r3, GPR4(r1) /* vcpu pointer */ | |
| 146 | + | |
| 138 | 147 | GET_SHADOW_VCPU(r4) |
| 139 | 148 | bl FUNC(kvmppc_copy_from_svcpu) |
| 140 | 149 | nop |
| 141 | 150 | |
| 142 | 151 | #ifdef CONFIG_PPC_BOOK3S_64 |
| 143 | − /* Re-enable interrupts */ | |
| 144 | − ld r3, HSTATE_HOST_MSR(r13) | |
| 145 | − ori r3, r3, MSR_EE | |
| 146 | − MTMSR_EERI(r3) | |
| 147 | − | |
| 148 | 152 | /* |
| 149 | 153 | * Reload kernel SPRG3 value. |
| 150 | 154 | * No need to save guest value as usermode can't modify SPRG3. |
| 151 | 155 | */ |
| 152 | 156 | ld r3, PACA_SPRG3(r13) |
| 153 | 157 | mtspr SPRN_SPRG3, r3 |
| 154 | − | |
| 155 | 158 | #endif /* CONFIG_PPC_BOOK3S_64 */ |
| 156 | 159 | |
| 157 | 160 | /* R7 = vcpu */ |
| @@ -177,7 +180,7 @@ kvm_start_lightweight: · 19 unmodified lines | ||
| 177 | 180 | PPC_STL r31, VCPU_GPR(R31)(r7) |
| 178 | 181 | |
| 179 | 182 | /* Pass the exit number as 3rd argument to kvmppc_handle_exit */ |
| 180 | − mr r5, r12 | |
| 183 | + lwz r5, VCPU_TRAP(r7) | |
| 181 | 184 | |
| 182 | 185 | /* Restore r3 (kvm_run) and r4 (vcpu) */ |
| 183 | 186 | REST_2GPRS(3, r1) |
| @@ -66,6 +66,7 @@ static void kvmppc_core_vcpu_load_pr(struct kvm_vcpu *vcpu, int cpu) · 65 unmodified lines | ||
| 66 | 66 | struct kvmppc_book3s_shadow_vcpu *svcpu = svcpu_get(vcpu); |
| 67 | 67 | memcpy(svcpu->slb, to_book3s(vcpu)->slb_shadow, sizeof(svcpu->slb)); |
| 68 | 68 | svcpu->slb_max = to_book3s(vcpu)->slb_shadow_max; |
| 69 | + svcpu->in_use = 0; | |
| 69 | 70 | svcpu_put(svcpu); |
| 70 | 71 | #endif |
| 71 | 72 | vcpu->cpu = smp_processor_id(); |
| @@ -78,6 +79,9 @@ static void kvmppc_core_vcpu_put_pr(struct kvm_vcpu *vcpu) · 6 unmodified lines | ||
| 78 | 79 | { |
| 79 | 80 | #ifdef CONFIG_PPC_BOOK3S_64 |
| 80 | 81 | struct kvmppc_book3s_shadow_vcpu *svcpu = svcpu_get(vcpu); |
| 82 | + if (svcpu->in_use) { | |
| 83 | + kvmppc_copy_from_svcpu(vcpu, svcpu); | |
| 84 | + } | |
| 81 | 85 | memcpy(to_book3s(vcpu)->slb_shadow, svcpu->slb, sizeof(svcpu->slb)); |
| 82 | 86 | to_book3s(vcpu)->slb_shadow_max = svcpu->slb_max; |
| 83 | 87 | svcpu_put(svcpu); |
| @@ -110,12 +114,26 @@ void kvmppc_copy_to_svcpu(struct kvmppc_book3s_shadow_vcpu *svcpu, · 26 unmodified lines | ||
| 110 | 114 | svcpu->ctr = vcpu->arch.ctr; |
| 111 | 115 | svcpu->lr = vcpu->arch.lr; |
| 112 | 116 | svcpu->pc = vcpu->arch.pc; |
| 117 | + svcpu->in_use = true; | |
| 113 | 118 | } |
| 114 | 119 | |
| 115 | 120 | /* Copy data touched by real-mode code from shadow vcpu back to vcpu */ |
| 116 | 121 | void kvmppc_copy_from_svcpu(struct kvm_vcpu *vcpu, |
| 117 | 122 | struct kvmppc_book3s_shadow_vcpu *svcpu) |
| 118 | 123 | { |
| 124 | + /* | |
| 125 | + * vcpu_put would just call us again because in_use hasn't | |
| 126 | + * been updated yet. | |
| 127 | + */ | |
| 128 | + preempt_disable(); | |
| 129 | + | |
| 130 | + /* | |
| 131 | + * Maybe we were already preempted and synced the svcpu from | |
| 132 | + * our preempt notifiers. Don't bother touching this svcpu then. | |
| 133 | + */ | |
| 134 | + if (!svcpu->in_use) | |
| 135 | + goto out; | |
| 136 | + | |
| 119 | 137 | vcpu->arch.gpr[0] = svcpu->gpr[0]; |
| 120 | 138 | vcpu->arch.gpr[1] = svcpu->gpr[1]; |
| 121 | 139 | vcpu->arch.gpr[2] = svcpu->gpr[2]; |
| @@ -139,6 +157,10 @@ void kvmppc_copy_from_svcpu(struct kvm_vcpu *vcpu, · 17 unmodified lines | ||
| 139 | 157 | vcpu->arch.fault_dar = svcpu->fault_dar; |
| 140 | 158 | vcpu->arch.fault_dsisr = svcpu->fault_dsisr; |
| 141 | 159 | vcpu->arch.last_inst = svcpu->last_inst; |
| 160 | + svcpu->in_use = false; | |
| 161 | + | |
| 162 | +out: | |
| 163 | + preempt_enable(); | |
| 142 | 164 | } |
| 143 | 165 | |
| 144 | 166 | static int kvmppc_core_check_requests_pr(struct kvm_vcpu *vcpu) |
| @@ -153,15 +153,11 @@ _GLOBAL(kvmppc_entry_trampoline) · 152 unmodified lines | ||
| 153 | 153 | |
| 154 | 154 | li r6, MSR_IR | MSR_DR |
| 155 | 155 | andc r6, r5, r6 /* Clear DR and IR in MSR value */ |
| 156 | −#ifdef CONFIG_PPC_BOOK3S_32 | |
| 157 | 156 | /* |
| 158 | 157 | * Set EE in HOST_MSR so that it's enabled when we get into our |
| 159 | − * C exit handler function. On 64-bit we delay enabling | |
| 160 | − * interrupts until we have finished transferring stuff | |
| 161 | − * to or from the PACA. | |
| 158 | + * C exit handler function. | |
| 162 | 159 | */ |
| 163 | 160 | ori r5, r5, MSR_EE |
| 164 | −#endif | |
| 165 | 161 | mtsrr0 r7 |
| 166 | 162 | mtsrr1 r6 |
| 167 | 163 | RFI |
| @@ -681,7 +681,7 @@ int kvmppc_core_check_requests(struct kvm_vcpu *vcpu) · 680 unmodified lines | ||
| 681 | 681 | int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu) |
| 682 | 682 | { |
| 683 | 683 | int ret, s; |
| 684 | − struct thread_struct thread; | |
| 684 | + struct debug_reg debug; | |
| 685 | 685 | #ifdef CONFIG_PPC_FPU |
| 686 | 686 | struct thread_fp_state fp; |
| 687 | 687 | int fpexc_mode; |
| @@ -723,9 +723,9 @@ int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu) · 35 unmodified lines | ||
| 723 | 723 | #endif |
| 724 | 724 | |
| 725 | 725 | /* Switch to guest debug context */ |
| 726 | − thread.debug = vcpu->arch.shadow_dbg_reg; | |
| 727 | − switch_booke_debug_regs(&thread); | |
| 728 | − thread.debug = current->thread.debug; | |
| 726 | + debug = vcpu->arch.shadow_dbg_reg; | |
| 727 | + switch_booke_debug_regs(&debug); | |
| 728 | + debug = current->thread.debug; | |
| 729 | 729 | current->thread.debug = vcpu->arch.shadow_dbg_reg; |
| 730 | 730 | |
| 731 | 731 | kvmppc_fix_ee_before_entry(); |
| @@ -736,8 +736,8 @@ int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu) · 4 unmodified lines | ||
| 736 | 736 | We also get here with interrupts enabled. */ |
| 737 | 737 | |
| 738 | 738 | /* Switch back to user space debug context */ |
| 739 | − switch_booke_debug_regs(&thread); | |
| 740 | − current->thread.debug = thread.debug; | |
| 739 | + switch_booke_debug_regs(&debug); | |
| 740 | + current->thread.debug = debug; | |
| 741 | 741 | |
| 742 | 742 | #ifdef CONFIG_PPC_FPU |
| 743 | 743 | kvmppc_save_guest_fp(vcpu); |
| @@ -24,25 +24,25 @@ static int opal_lpc_chip_id = -1; · 23 unmodified lines | ||
| 24 | 24 | static u8 opal_lpc_inb(unsigned long port) |
| 25 | 25 | { |
| 26 | 26 | int64_t rc; |
| 27 | − uint32_t data; | |
| 27 | + __be32 data; | |
| 28 | 28 | |
| 29 | 29 | if (opal_lpc_chip_id < 0 || port > 0xffff) |
| 30 | 30 | return 0xff; |
| 31 | 31 | rc = opal_lpc_read(opal_lpc_chip_id, OPAL_LPC_IO, port, &data, 1); |
| 32 | − return rc ? 0xff : data; | |
| 32 | + return rc ? 0xff : be32_to_cpu(data); | |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | static __le16 __opal_lpc_inw(unsigned long port) |
| 36 | 36 | { |
| 37 | 37 | int64_t rc; |
| 38 | − uint32_t data; | |
| 38 | + __be32 data; | |
| 39 | 39 | |
| 40 | 40 | if (opal_lpc_chip_id < 0 || port > 0xfffe) |
| 41 | 41 | return 0xffff; |
| 42 | 42 | if (port & 1) |
| 43 | 43 | return (__le16)opal_lpc_inb(port) << 8 | opal_lpc_inb(port + 1); |
| 44 | 44 | rc = opal_lpc_read(opal_lpc_chip_id, OPAL_LPC_IO, port, &data, 2); |
| 45 | − return rc ? 0xffff : data; | |
| 45 | + return rc ? 0xffff : be32_to_cpu(data); | |
| 46 | 46 | } |
| 47 | 47 | static u16 opal_lpc_inw(unsigned long port) |
| 48 | 48 | { |
| @@ -52,7 +52,7 @@ static u16 opal_lpc_inw(unsigned long port) · 3 unmodified lines | ||
| 52 | 52 | static __le32 __opal_lpc_inl(unsigned long port) |
| 53 | 53 | { |
| 54 | 54 | int64_t rc; |
| 55 | − uint32_t data; | |
| 55 | + __be32 data; | |
| 56 | 56 | |
| 57 | 57 | if (opal_lpc_chip_id < 0 || port > 0xfffc) |
| 58 | 58 | return 0xffffffff; |
| @@ -62,7 +62,7 @@ static __le32 __opal_lpc_inl(unsigned long port) · 3 unmodified lines | ||
| 62 | 62 | (__le32)opal_lpc_inb(port + 2) << 8 | |
| 63 | 63 | opal_lpc_inb(port + 3); |
| 64 | 64 | rc = opal_lpc_read(opal_lpc_chip_id, OPAL_LPC_IO, port, &data, 4); |
| 65 | − return rc ? 0xffffffff : data; | |
| 65 | + return rc ? 0xffffffff : be32_to_cpu(data); | |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | static u32 opal_lpc_inl(unsigned long port) |
| @@ -96,9 +96,11 @@ static int opal_scom_read(scom_map_t map, u64 reg, u64 *value) · 95 unmodified lines | ||
| 96 | 96 | { |
| 97 | 97 | struct opal_scom_map *m = map; |
| 98 | 98 | int64_t rc; |
| 99 | + __be64 v; | |
| 99 | 100 | |
| 100 | 101 | reg = opal_scom_unmangle(reg); |
| 101 | − rc = opal_xscom_read(m->chip, m->addr + reg, (uint64_t *)__pa(value)); | |
| 102 | + rc = opal_xscom_read(m->chip, m->addr + reg, (__be64 *)__pa(&v)); | |
| 103 | + *value = be64_to_cpu(v); | |
| 102 | 104 | return opal_xscom_err_xlate(rc); |
| 103 | 105 | } |
| 104 | 106 | |
| @@ -157,7 +157,7 @@ static void parse_ppp_data(struct seq_file *m) · 156 unmodified lines | ||
| 157 | 157 | { |
| 158 | 158 | struct hvcall_ppp_data ppp_data; |
| 159 | 159 | struct device_node *root; |
| 160 | − const int *perf_level; | |
| 160 | + const __be32 *perf_level; | |
| 161 | 161 | int rc; |
| 162 | 162 | |
| 163 | 163 | rc = h_get_ppp(&ppp_data); |
| @@ -201,7 +201,7 @@ static void parse_ppp_data(struct seq_file *m) · 37 unmodified lines | ||
| 201 | 201 | perf_level = of_get_property(root, |
| 202 | 202 | "ibm,partition-performance-parameters-level", |
| 203 | 203 | NULL); |
| 204 | − if (perf_level && (*perf_level >= 1)) { | |
| 204 | + if (perf_level && (be32_to_cpup(perf_level) >= 1)) { | |
| 205 | 205 | seq_printf(m, |
| 206 | 206 | "physical_procs_allocated_to_virtualization=%d\n", |
| 207 | 207 | ppp_data.phys_platform_procs); |
| @@ -435,7 +435,7 @@ static int pseries_lparcfg_data(struct seq_file *m, void *v) · 227 unmodified lines | ||
| 435 | 435 | int partition_potential_processors; |
| 436 | 436 | int partition_active_processors; |
| 437 | 437 | struct device_node *rtas_node; |
| 438 | − const int *lrdrp = NULL; | |
| 438 | + const __be32 *lrdrp = NULL; | |
| 439 | 439 | |
| 440 | 440 | rtas_node = of_find_node_by_path("/rtas"); |
| 441 | 441 | if (rtas_node) |
| @@ -444,7 +444,7 @@ static int pseries_lparcfg_data(struct seq_file *m, void *v) · 2 unmodified lines | ||
| 444 | 444 | if (lrdrp == NULL) { |
| 445 | 445 | partition_potential_processors = vdso_data->processorCount; |
| 446 | 446 | } else { |
| 447 | − partition_potential_processors = *(lrdrp + 4); | |
| 447 | + partition_potential_processors = be32_to_cpup(lrdrp + 4); | |
| 448 | 448 | } |
| 449 | 449 | of_node_put(rtas_node); |
| 450 | 450 | |
| @@ -654,7 +654,7 @@ static int lparcfg_data(struct seq_file *m, void *v) · 203 unmodified lines | ||
| 654 | 654 | const char *model = ""; |
| 655 | 655 | const char *system_id = ""; |
| 656 | 656 | const char *tmp; |
| 657 | − const unsigned int *lp_index_ptr; | |
| 657 | + const __be32 *lp_index_ptr; | |
| 658 | 658 | unsigned int lp_index = 0; |
| 659 | 659 | |
| 660 | 660 | seq_printf(m, "%s %s\n", MODULE_NAME, MODULE_VERS); |
| @@ -670,7 +670,7 @@ static int lparcfg_data(struct seq_file *m, void *v) · 9 unmodified lines | ||
| 670 | 670 | lp_index_ptr = of_get_property(rootdn, "ibm,partition-no", |
| 671 | 671 | NULL); |
| 672 | 672 | if (lp_index_ptr) |
| 673 | − lp_index = *lp_index_ptr; | |
| 673 | + lp_index = be32_to_cpup(lp_index_ptr); | |
| 674 | 674 | of_node_put(rootdn); |
| 675 | 675 | } |
| 676 | 676 | seq_printf(m, "serial_number=%s\n", system_id); |
| @@ -130,7 +130,8 @@ static int check_req(struct pci_dev *pdev, int nvec, char *prop_name) · 129 unmodified lines | ||
| 130 | 130 | { |
| 131 | 131 | struct device_node *dn; |
| 132 | 132 | struct pci_dn *pdn; |
| 133 | − const u32 *req_msi; | |
| 133 | + const __be32 *p; | |
| 134 | + u32 req_msi; | |
| 134 | 135 | |
| 135 | 136 | pdn = pci_get_pdn(pdev); |
| 136 | 137 | if (!pdn) |
| @@ -138,19 +139,20 @@ static int check_req(struct pci_dev *pdev, int nvec, char *prop_name) · 1 unmodified line | ||
| 138 | 139 | |
| 139 | 140 | dn = pdn->node; |
| 140 | 141 | |
| 141 | − req_msi = of_get_property(dn, prop_name, NULL); | |
| 142 | − if (!req_msi) { | |
| 142 | + p = of_get_property(dn, prop_name, NULL); | |
| 143 | + if (!p) { | |
| 143 | 144 | pr_debug("rtas_msi: No %s on %s\n", prop_name, dn->full_name); |
| 144 | 145 | return -ENOENT; |
| 145 | 146 | } |
| 146 | 147 | |
| 147 | − if (*req_msi < nvec) { | |
| 148 | + req_msi = be32_to_cpup(p); | |
| 149 | + if (req_msi < nvec) { | |
| 148 | 150 | pr_debug("rtas_msi: %s requests < %d MSIs\n", prop_name, nvec); |
| 149 | 151 | |
| 150 | − if (*req_msi == 0) /* Be paranoid */ | |
| 152 | + if (req_msi == 0) /* Be paranoid */ | |
| 151 | 153 | return -ENOSPC; |
| 152 | 154 | |
| 153 | − return *req_msi; | |
| 155 | + return req_msi; | |
| 154 | 156 | } |
| 155 | 157 | |
| 156 | 158 | return 0; |
| @@ -171,7 +173,7 @@ static int check_req_msix(struct pci_dev *pdev, int nvec) · 14 unmodified lines | ||
| 171 | 173 | static struct device_node *find_pe_total_msi(struct pci_dev *dev, int *total) |
| 172 | 174 | { |
| 173 | 175 | struct device_node *dn; |
| 174 | − const u32 *p; | |
| 176 | + const __be32 *p; | |
| 175 | 177 | |
| 176 | 178 | dn = of_node_get(pci_device_to_OF_node(dev)); |
| 177 | 179 | while (dn) { |
| @@ -179,7 +181,7 @@ static struct device_node *find_pe_total_msi(struct pci_dev *dev, int *total) · 1 unmodified line | ||
| 179 | 181 | if (p) { |
| 180 | 182 | pr_debug("rtas_msi: found prop on dn %s\n", |
| 181 | 183 | dn->full_name); |
| 182 | − *total = *p; | |
| 184 | + *total = be32_to_cpup(p); | |
| 183 | 185 | return dn; |
| 184 | 186 | } |
| 185 | 187 | |
| @@ -232,13 +234,13 @@ struct msi_counts { · 46 unmodified lines | ||
| 232 | 234 | static void *count_non_bridge_devices(struct device_node *dn, void *data) |
| 233 | 235 | { |
| 234 | 236 | struct msi_counts *counts = data; |
| 235 | − const u32 *p; | |
| 237 | + const __be32 *p; | |
| 236 | 238 | u32 class; |
| 237 | 239 | |
| 238 | 240 | pr_debug("rtas_msi: counting %s\n", dn->full_name); |
| 239 | 241 | |
| 240 | 242 | p = of_get_property(dn, "class-code", NULL); |
| 241 | − class = p ? *p : 0; | |
| 243 | + class = p ? be32_to_cpup(p) : 0; | |
| 242 | 244 | |
| 243 | 245 | if ((class >> 8) != PCI_CLASS_BRIDGE_PCI) |
| 244 | 246 | counts->num_devices++; |
| @@ -249,7 +251,7 @@ static void *count_non_bridge_devices(struct device_node *dn, void *data) · 4 unmodified lines | ||
| 249 | 251 | static void *count_spare_msis(struct device_node *dn, void *data) |
| 250 | 252 | { |
| 251 | 253 | struct msi_counts *counts = data; |
| 252 | − const u32 *p; | |
| 254 | + const __be32 *p; | |
| 253 | 255 | int req; |
| 254 | 256 | |
| 255 | 257 | if (dn == counts->requestor) |
| @@ -260,11 +262,11 @@ static void *count_spare_msis(struct device_node *dn, void *data) · 4 unmodified lines | ||
| 260 | 262 | req = 0; |
| 261 | 263 | p = of_get_property(dn, "ibm,req#msi", NULL); |
| 262 | 264 | if (p) |
| 263 | − req = *p; | |
| 265 | + req = be32_to_cpup(p); | |
| 264 | 266 | |
| 265 | 267 | p = of_get_property(dn, "ibm,req#msi-x", NULL); |
| 266 | 268 | if (p) |
| 267 | − req = max(req, (int)*p); | |
| 269 | + req = max(req, (int)be32_to_cpup(p)); | |
| 268 | 270 | } |
| 269 | 271 | |
| 270 | 272 | if (req < counts->quota) |
| @@ -43,8 +43,8 @@ static char nvram_buf[NVRW_CNT]; /* assume this is in the first 4GB */ · 42 unmodified lines | ||
| 43 | 43 | static DEFINE_SPINLOCK(nvram_lock); |
| 44 | 44 | |
| 45 | 45 | struct err_log_info { |
| 46 | − int error_type; | |
| 47 | − unsigned int seq_num; | |
| 46 | + __be32 error_type; | |
| 47 | + __be32 seq_num; | |
| 48 | 48 | }; |
| 49 | 49 | |
| 50 | 50 | struct nvram_os_partition { |
| @@ -79,9 +79,9 @@ static const char *pseries_nvram_os_partitions[] = { · 28 unmodified lines | ||
| 79 | 79 | }; |
| 80 | 80 | |
| 81 | 81 | struct oops_log_info { |
| 82 | − u16 version; | |
| 83 | − u16 report_length; | |
| 84 | − u64 timestamp; | |
| 82 | + __be16 version; | |
| 83 | + __be16 report_length; | |
| 84 | + __be64 timestamp; | |
| 85 | 85 | } __attribute__((packed)); |
| 86 | 86 | |
| 87 | 87 | static void oops_to_nvram(struct kmsg_dumper *dumper, |
| @@ -291,8 +291,8 @@ int nvram_write_os_partition(struct nvram_os_partition *part, char * buff, · 203 unmodified lines | ||
| 291 | 291 | length = part->size; |
| 292 | 292 | } |
| 293 | 293 | |
| 294 | − info.error_type = err_type; | |
| 295 | − info.seq_num = error_log_cnt; | |
| 294 | + info.error_type = cpu_to_be32(err_type); | |
| 295 | + info.seq_num = cpu_to_be32(error_log_cnt); | |
| 296 | 296 | |
| 297 | 297 | tmp_index = part->index; |
| 298 | 298 | |
| @@ -364,8 +364,8 @@ int nvram_read_partition(struct nvram_os_partition *part, char *buff, · 65 unmodified lines | ||
| 364 | 364 | } |
| 365 | 365 | |
| 366 | 366 | if (part->os_partition) { |
| 367 | − *error_log_cnt = info.seq_num; | |
| 368 | − *err_type = info.error_type; | |
| 367 | + *error_log_cnt = be32_to_cpu(info.seq_num); | |
| 368 | + *err_type = be32_to_cpu(info.error_type); | |
| 369 | 369 | } |
| 370 | 370 | |
| 371 | 371 | return 0; |
| @@ -529,9 +529,9 @@ static int zip_oops(size_t text_len) · 157 unmodified lines | ||
| 529 | 529 | pr_err("nvram: logging uncompressed oops/panic report\n"); |
| 530 | 530 | return -1; |
| 531 | 531 | } |
| 532 | − oops_hdr->version = OOPS_HDR_VERSION; | |
| 533 | − oops_hdr->report_length = (u16) zipped_len; | |
| 534 | − oops_hdr->timestamp = get_seconds(); | |
| 532 | + oops_hdr->version = cpu_to_be16(OOPS_HDR_VERSION); | |
| 533 | + oops_hdr->report_length = cpu_to_be16(zipped_len); | |
| 534 | + oops_hdr->timestamp = cpu_to_be64(get_seconds()); | |
| 535 | 535 | return 0; |
| 536 | 536 | } |
| 537 | 537 | |
| @@ -574,9 +574,9 @@ static int nvram_pstore_write(enum pstore_type_id type, · 36 unmodified lines | ||
| 574 | 574 | clobbering_unread_rtas_event()) |
| 575 | 575 | return -1; |
| 576 | 576 | |
| 577 | − oops_hdr->version = OOPS_HDR_VERSION; | |
| 578 | − oops_hdr->report_length = (u16) size; | |
| 579 | − oops_hdr->timestamp = get_seconds(); | |
| 577 | + oops_hdr->version = cpu_to_be16(OOPS_HDR_VERSION); | |
| 578 | + oops_hdr->report_length = cpu_to_be16(size); | |
| 579 | + oops_hdr->timestamp = cpu_to_be64(get_seconds()); | |
| 580 | 580 | |
| 581 | 581 | if (compressed) |
| 582 | 582 | err_type = ERR_TYPE_KERNEL_PANIC_GZ; |
| @@ -670,16 +670,16 @@ static ssize_t nvram_pstore_read(u64 *id, enum pstore_type_id *type, · 87 unmodified lines | ||
| 670 | 670 | size_t length, hdr_size; |
| 671 | 671 | |
| 672 | 672 | oops_hdr = (struct oops_log_info *)buff; |
| 673 | − if (oops_hdr->version < OOPS_HDR_VERSION) { | |
| 673 | + if (be16_to_cpu(oops_hdr->version) < OOPS_HDR_VERSION) { | |
| 674 | 674 | /* Old format oops header had 2-byte record size */ |
| 675 | 675 | hdr_size = sizeof(u16); |
| 676 | − length = oops_hdr->version; | |
| 676 | + length = be16_to_cpu(oops_hdr->version); | |
| 677 | 677 | time->tv_sec = 0; |
| 678 | 678 | time->tv_nsec = 0; |
| 679 | 679 | } else { |
| 680 | 680 | hdr_size = sizeof(*oops_hdr); |
| 681 | − length = oops_hdr->report_length; | |
| 682 | − time->tv_sec = oops_hdr->timestamp; | |
| 681 | + length = be16_to_cpu(oops_hdr->report_length); | |
| 682 | + time->tv_sec = be64_to_cpu(oops_hdr->timestamp); | |
| 683 | 683 | time->tv_nsec = 0; |
| 684 | 684 | } |
| 685 | 685 | *buf = kmalloc(length, GFP_KERNEL); |
| @@ -889,13 +889,13 @@ static void oops_to_nvram(struct kmsg_dumper *dumper, · 203 unmodified lines | ||
| 889 | 889 | kmsg_dump_get_buffer(dumper, false, |
| 890 | 890 | oops_data, oops_data_sz, &text_len); |
| 891 | 891 | err_type = ERR_TYPE_KERNEL_PANIC; |
| 892 | − oops_hdr->version = OOPS_HDR_VERSION; | |
| 893 | − oops_hdr->report_length = (u16) text_len; | |
| 894 | − oops_hdr->timestamp = get_seconds(); | |
| 892 | + oops_hdr->version = cpu_to_be16(OOPS_HDR_VERSION); | |
| 893 | + oops_hdr->report_length = cpu_to_be16(text_len); | |
| 894 | + oops_hdr->timestamp = cpu_to_be64(get_seconds()); | |
| 895 | 895 | } |
| 896 | 896 | |
| 897 | 897 | (void) nvram_write_os_partition(&oops_log_partition, oops_buf, |
| 898 | − (int) (sizeof(*oops_hdr) + oops_hdr->report_length), err_type, | |
| 898 | + (int) (sizeof(*oops_hdr) + text_len), err_type, | |
| 899 | 899 | ++oops_count); |
| 900 | 900 | |
| 901 | 901 | spin_unlock_irqrestore(&lock, flags); |
| @@ -113,7 +113,7 @@ int pseries_root_bridge_prepare(struct pci_host_bridge *bridge) · 112 unmodified lines | ||
| 113 | 113 | { |
| 114 | 114 | struct device_node *dn, *pdn; |
| 115 | 115 | struct pci_bus *bus; |
| 116 | − const uint32_t *pcie_link_speed_stats; | |
| 116 | + const __be32 *pcie_link_speed_stats; | |
| 117 | 117 | |
| 118 | 118 | bus = bridge->bus; |
| 119 | 119 | |
| @@ -122,7 +122,7 @@ int pseries_root_bridge_prepare(struct pci_host_bridge *bridge) · 2 unmodified lines | ||
| 122 | 122 | return 0; |
| 123 | 123 | |
| 124 | 124 | for (pdn = dn; pdn != NULL; pdn = of_get_next_parent(pdn)) { |
| 125 | − pcie_link_speed_stats = (const uint32_t *) of_get_property(pdn, | |
| 125 | + pcie_link_speed_stats = of_get_property(pdn, | |
| 126 | 126 | "ibm,pcie-link-speed-stats", NULL); |
| 127 | 127 | if (pcie_link_speed_stats) |
| 128 | 128 | break; |
| @@ -135,7 +135,7 @@ int pseries_root_bridge_prepare(struct pci_host_bridge *bridge) · 6 unmodified lines | ||
| 135 | 135 | return 0; |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | − switch (pcie_link_speed_stats[0]) { | |
| 138 | + switch (be32_to_cpup(pcie_link_speed_stats)) { | |
| 139 | 139 | case 0x01: |
| 140 | 140 | bus->max_bus_speed = PCIE_SPEED_2_5GT; |
| 141 | 141 | break; |
| @@ -147,7 +147,7 @@ int pseries_root_bridge_prepare(struct pci_host_bridge *bridge) · 5 unmodified lines | ||
| 147 | 147 | break; |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | − switch (pcie_link_speed_stats[1]) { | |
| 150 | + switch (be32_to_cpup(pcie_link_speed_stats)) { | |
| 151 | 151 | case 0x01: |
| 152 | 152 | bus->cur_bus_speed = PCIE_SPEED_2_5GT; |
| 153 | 153 | break; |
| @@ -6,7 +6,7 @@ lib-y = delay.o memmove.o memchr.o \ · 5 unmodified lines | ||
| 6 | 6 | checksum.o strlen.o div64.o div64-generic.o |
| 7 | 7 | |
| 8 | 8 | # Extracted from libgcc |
| 9 | −lib-y += movmem.o ashldi3.o ashrdi3.o lshrdi3.o \ | |
| 9 | +obj-y += movmem.o ashldi3.o ashrdi3.o lshrdi3.o \ | |
| 10 | 10 | ashlsi3.o ashrsi3.o ashiftrt.o lshrsi3.o \ |
| 11 | 11 | udiv_qrnnd.o |
| 12 | 12 | |
| @@ -619,7 +619,7 @@ static inline unsigned long pte_present(pte_t pte) · 618 unmodified lines | ||
| 619 | 619 | } |
| 620 | 620 | |
| 621 | 621 | #define pte_accessible pte_accessible |
| 622 | −static inline unsigned long pte_accessible(pte_t a) | |
| 622 | +static inline unsigned long pte_accessible(struct mm_struct *mm, pte_t a) | |
| 623 | 623 | { |
| 624 | 624 | return pte_val(a) & _PAGE_VALID; |
| 625 | 625 | } |
| @@ -847,7 +847,7 @@ static inline void __set_pte_at(struct mm_struct *mm, unsigned long addr, · 221 unmodified lines | ||
| 847 | 847 | * SUN4V NOTE: _PAGE_VALID is the same value in both the SUN4U |
| 848 | 848 | * and SUN4V pte layout, so this inline test is fine. |
| 849 | 849 | */ |
| 850 | − if (likely(mm != &init_mm) && pte_accessible(orig)) | |
| 850 | + if (likely(mm != &init_mm) && pte_accessible(mm, orig)) | |
| 851 | 851 | tlb_batch_add(mm, addr, ptep, orig, fullmm); |
| 852 | 852 | } |
| 853 | 853 | |
| @@ -26,6 +26,7 @@ config X86 · 25 unmodified lines | ||
| 26 | 26 | select HAVE_AOUT if X86_32 |
| 27 | 27 | select HAVE_UNSTABLE_SCHED_CLOCK |
| 28 | 28 | select ARCH_SUPPORTS_NUMA_BALANCING |
| 29 | + select ARCH_SUPPORTS_INT128 if X86_64 | |
| 29 | 30 | select ARCH_WANTS_PROT_NUMA_PROT_NONE |
| 30 | 31 | select HAVE_IDE |
| 31 | 32 | select HAVE_OPROFILE |
| @@ -452,9 +452,16 @@ static inline int pte_present(pte_t a) · 451 unmodified lines | ||
| 452 | 452 | } |
| 453 | 453 | |
| 454 | 454 | #define pte_accessible pte_accessible |
| 455 | −static inline int pte_accessible(pte_t a) | |
| 455 | +static inline bool pte_accessible(struct mm_struct *mm, pte_t a) | |
| 456 | 456 | { |
| 457 | − return pte_flags(a) & _PAGE_PRESENT; | |
| 457 | + if (pte_flags(a) & _PAGE_PRESENT) | |
| 458 | + return true; | |
| 459 | + | |
| 460 | + if ((pte_flags(a) & (_PAGE_PROTNONE | _PAGE_NUMA)) && | |
| 461 | + mm_tlb_flush_pending(mm)) | |
| 462 | + return true; | |
| 463 | + | |
| 464 | + return false; | |
| 458 | 465 | } |
| 459 | 466 | |
| 460 | 467 | static inline int pte_hidden(pte_t pte) |
| @@ -7,6 +7,12 @@ · 6 unmodified lines | ||
| 7 | 7 | |
| 8 | 8 | DECLARE_PER_CPU(int, __preempt_count); |
| 9 | 9 | |
| 10 | +/* | |
| 11 | + * We use the PREEMPT_NEED_RESCHED bit as an inverted NEED_RESCHED such | |
| 12 | + * that a decrement hitting 0 means we can and should reschedule. | |
| 13 | + */ | |
| 14 | +#define PREEMPT_ENABLED (0 + PREEMPT_NEED_RESCHED) | |
| 15 | + | |
| 10 | 16 | /* |
| 11 | 17 | * We mask the PREEMPT_NEED_RESCHED bit so as not to confuse all current users |
| 12 | 18 | * that think a non-zero value indicates we cannot preempt. |
| @@ -74,6 +80,11 @@ static __always_inline void __preempt_count_sub(int val) · 61 unmodified lines | ||
| 74 | 80 | __this_cpu_add_4(__preempt_count, -val); |
| 75 | 81 | } |
| 76 | 82 | |
| 83 | +/* | |
| 84 | + * Because we keep PREEMPT_NEED_RESCHED set when we do _not_ need to reschedule | |
| 85 | + * a decrement which hits zero means we have no preempt_count and should | |
| 86 | + * reschedule. | |
| 87 | + */ | |
| 77 | 88 | static __always_inline bool __preempt_count_dec_and_test(void) |
| 78 | 89 | { |
| 79 | 90 | GEN_UNARY_RMWcc("decl", __preempt_count, __percpu_arg(0), "e"); |
| @@ -387,7 +387,8 @@ static void init_intel(struct cpuinfo_x86 *c) · 386 unmodified lines | ||
| 387 | 387 | set_cpu_cap(c, X86_FEATURE_PEBS); |
| 388 | 388 | } |
| 389 | 389 | |
| 390 | − if (c->x86 == 6 && c->x86_model == 29 && cpu_has_clflush) | |
| 390 | + if (c->x86 == 6 && cpu_has_clflush && | |
| 391 | + (c->x86_model == 29 || c->x86_model == 46 || c->x86_model == 47)) | |
| 391 | 392 | set_cpu_cap(c, X86_FEATURE_CLFLUSH_MONITOR); |
| 392 | 393 | |
| 393 | 394 | #ifdef CONFIG_X86_64 |
| @@ -262,11 +262,20 @@ struct cpu_hw_events { · 261 unmodified lines | ||
| 262 | 262 | __EVENT_CONSTRAINT(c, n, INTEL_ARCH_EVENT_MASK, \ |
| 263 | 263 | HWEIGHT(n), 0, PERF_X86_EVENT_PEBS_ST_HSW) |
| 264 | 264 | |
| 265 | −#define EVENT_CONSTRAINT_END \ | |
| 266 | − EVENT_CONSTRAINT(0, 0, 0) | |
| 265 | +/* | |
| 266 | + * We define the end marker as having a weight of -1 | |
| 267 | + * to enable blacklisting of events using a counter bitmask | |
| 268 | + * of zero and thus a weight of zero. | |
| 269 | + * The end marker has a weight that cannot possibly be | |
| 270 | + * obtained from counting the bits in the bitmask. | |
| 271 | + */ | |
| 272 | +#define EVENT_CONSTRAINT_END { .weight = -1 } | |
| 267 | 273 | |
| 274 | +/* | |
| 275 | + * Check for end marker with weight == -1 | |
| 276 | + */ | |
| 268 | 277 | #define for_each_event_constraint(e, c) \ |
| 269 | − for ((e) = (c); (e)->weight; (e)++) | |
| 278 | + for ((e) = (c); (e)->weight != -1; (e)++) | |
| 270 | 279 | |
| 271 | 280 | /* |
| 272 | 281 | * Extra registers for specific events. |
| @@ -83,6 +83,12 @@ static noinline int gup_pte_range(pmd_t pmd, unsigned long addr, · 82 unmodified lines | ||
| 83 | 83 | pte_t pte = gup_get_pte(ptep); |
| 84 | 84 | struct page *page; |
| 85 | 85 | |
| 86 | + /* Similar to the PMD case, NUMA hinting must take slow path */ | |
| 87 | + if (pte_numa(pte)) { | |
| 88 | + pte_unmap(ptep); | |
| 89 | + return 0; | |
| 90 | + } | |
| 91 | + | |
| 86 | 92 | if ((pte_flags(pte) & (mask | _PAGE_SPECIAL)) != mask) { |
| 87 | 93 | pte_unmap(ptep); |
| 88 | 94 | return 0; |
| @@ -167,6 +173,13 @@ static int gup_pmd_range(pud_t pud, unsigned long addr, unsigned long end, · 78 unmodified lines | ||
| 167 | 173 | if (pmd_none(pmd) || pmd_trans_splitting(pmd)) |
| 168 | 174 | return 0; |
| 169 | 175 | if (unlikely(pmd_large(pmd))) { |
| 176 | + /* | |
| 177 | + * NUMA hinting faults need to be handled in the GUP | |
| 178 | + * slowpath for accounting purposes and so that they | |
| 179 | + * can be serialised against THP migration. | |
| 180 | + */ | |
| 181 | + if (pmd_numa(pmd)) | |
| 182 | + return 0; | |
| 170 | 183 | if (!gup_huge_pmd(pmd, addr, next, write, pages, nr)) |
| 171 | 184 | return 0; |
| 172 | 185 | } else { |
| @@ -335,9 +335,22 @@ static struct kobj_type blk_mq_hw_ktype = { · 334 unmodified lines | ||
| 335 | 335 | void blk_mq_unregister_disk(struct gendisk *disk) |
| 336 | 336 | { |
| 337 | 337 | struct request_queue *q = disk->queue; |
| 338 | + struct blk_mq_hw_ctx *hctx; | |
| 339 | + struct blk_mq_ctx *ctx; | |
| 340 | + int i, j; | |
| 341 | + | |
| 342 | + queue_for_each_hw_ctx(q, hctx, i) { | |
| 343 | + hctx_for_each_ctx(hctx, ctx, j) { | |
| 344 | + kobject_del(&ctx->kobj); | |
| 345 | + kobject_put(&ctx->kobj); | |
| 346 | + } | |
| 347 | + kobject_del(&hctx->kobj); | |
| 348 | + kobject_put(&hctx->kobj); | |
| 349 | + } | |
| 338 | 350 | |
| 339 | 351 | kobject_uevent(&q->mq_kobj, KOBJ_REMOVE); |
| 340 | 352 | kobject_del(&q->mq_kobj); |
| 353 | + kobject_put(&q->mq_kobj); | |
| 341 | 354 | |
| 342 | 355 | kobject_put(&disk_to_dev(disk)->kobj); |
| 343 | 356 | } |
| @@ -348,7 +348,6 @@ source "drivers/acpi/apei/Kconfig" · 347 unmodified lines | ||
| 348 | 348 | config ACPI_EXTLOG |
| 349 | 349 | tristate "Extended Error Log support" |
| 350 | 350 | depends on X86_MCE && X86_LOCAL_APIC |
| 351 | − select EFI | |
| 352 | 351 | select UEFI_CPER |
| 353 | 352 | default n |
| 354 | 353 | help |
| @@ -162,6 +162,7 @@ static const struct acpi_device_id acpi_lpss_device_ids[] = { · 161 unmodified lines | ||
| 162 | 162 | { "80860F14", (unsigned long)&byt_sdio_dev_desc }, |
| 163 | 163 | { "80860F41", (unsigned long)&byt_i2c_dev_desc }, |
| 164 | 164 | { "INT33B2", }, |
| 165 | + { "INT33FC", }, | |
| 165 | 166 | |
| 166 | 167 | { "INT3430", (unsigned long)&lpt_dev_desc }, |
| 167 | 168 | { "INT3431", (unsigned long)&lpt_dev_desc }, |
| @@ -2,7 +2,6 @@ config ACPI_APEI · 1 unmodified line | ||
| 2 | 2 | bool "ACPI Platform Error Interface (APEI)" |
| 3 | 3 | select MISC_FILESYSTEMS |
| 4 | 4 | select PSTORE |
| 5 | − select EFI | |
| 6 | 5 | select UEFI_CPER |
| 7 | 6 | depends on X86 |
| 8 | 7 | help |
| @@ -942,6 +942,7 @@ static int erst_clearer(enum pstore_type_id type, u64 id, int count, · 941 unmodified lines | ||
| 942 | 942 | static struct pstore_info erst_info = { |
| 943 | 943 | .owner = THIS_MODULE, |
| 944 | 944 | .name = "erst", |
| 945 | + .flags = PSTORE_FLAGS_FRAGILE, | |
| 945 | 946 | .open = erst_open_pstore, |
| 946 | 947 | .close = erst_close_pstore, |
| 947 | 948 | .read = erst_reader, |
| @@ -1238,15 +1238,6 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) · 1237 unmodified lines | ||
| 1238 | 1238 | if (rc) |
| 1239 | 1239 | return rc; |
| 1240 | 1240 | |
| 1241 | − /* AHCI controllers often implement SFF compatible interface. | |
| 1242 | − * Grab all PCI BARs just in case. | |
| 1243 | − */ | |
| 1244 | − rc = pcim_iomap_regions_request_all(pdev, 1 << ahci_pci_bar, DRV_NAME); | |
| 1245 | − if (rc == -EBUSY) | |
| 1246 | − pcim_pin_device(pdev); | |
| 1247 | − if (rc) | |
| 1248 | − return rc; | |
| 1249 | − | |
| 1250 | 1241 | if (pdev->vendor == PCI_VENDOR_ID_INTEL && |
| 1251 | 1242 | (pdev->device == 0x2652 || pdev->device == 0x2653)) { |
| 1252 | 1243 | u8 map; |
| @@ -1263,6 +1254,15 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) · 10 unmodified lines | ||
| 1263 | 1254 | } |
| 1264 | 1255 | } |
| 1265 | 1256 | |
| 1257 | + /* AHCI controllers often implement SFF compatible interface. | |
| 1258 | + * Grab all PCI BARs just in case. | |
| 1259 | + */ | |
| 1260 | + rc = pcim_iomap_regions_request_all(pdev, 1 << ahci_pci_bar, DRV_NAME); | |
| 1261 | + if (rc == -EBUSY) | |
| 1262 | + pcim_pin_device(pdev); | |
| 1263 | + if (rc) | |
| 1264 | + return rc; | |
| 1265 | + | |
| 1266 | 1266 | hpriv = devm_kzalloc(dev, sizeof(*hpriv), GFP_KERNEL); |
| 1267 | 1267 | if (!hpriv) |
| 1268 | 1268 | return -ENOMEM; |
| @@ -113,7 +113,7 @@ static int imx6q_sata_init(struct device *dev, void __iomem *mmio) · 112 unmodified lines | ||
| 113 | 113 | /* |
| 114 | 114 | * set PHY Paremeters, two steps to configure the GPR13, |
| 115 | 115 | * one write for rest of parameters, mask of first write |
| 116 | − * is 0x07fffffd, and the other one write for setting | |
| 116 | + * is 0x07ffffff, and the other one write for setting | |
| 117 | 117 | * the mpll_clk_en. |
| 118 | 118 | */ |
| 119 | 119 | regmap_update_bits(imxpriv->gpr, 0x34, IMX6Q_GPR13_SATA_RX_EQ_VAL_MASK |
| @@ -124,6 +124,7 @@ static int imx6q_sata_init(struct device *dev, void __iomem *mmio) · 4 unmodified lines | ||
| 124 | 124 | | IMX6Q_GPR13_SATA_TX_ATTEN_MASK |
| 125 | 125 | | IMX6Q_GPR13_SATA_TX_BOOST_MASK |
| 126 | 126 | | IMX6Q_GPR13_SATA_TX_LVL_MASK |
| 127 | + | IMX6Q_GPR13_SATA_MPLL_CLK_EN | |
| 127 | 128 | | IMX6Q_GPR13_SATA_TX_EDGE_RATE |
| 128 | 129 | , IMX6Q_GPR13_SATA_RX_EQ_VAL_3_0_DB |
| 129 | 130 | | IMX6Q_GPR13_SATA_RX_LOS_LVL_SATA2M |
| @@ -2149,9 +2149,16 @@ static int ata_dev_config_ncq(struct ata_device *dev, · 2148 unmodified lines | ||
| 2149 | 2149 | "failed to get NCQ Send/Recv Log Emask 0x%x\n", |
| 2150 | 2150 | err_mask); |
| 2151 | 2151 | } else { |
| 2152 | + u8 *cmds = dev->ncq_send_recv_cmds; | |
| 2153 | + | |
| 2152 | 2154 | dev->flags |= ATA_DFLAG_NCQ_SEND_RECV; |
| 2153 | − memcpy(dev->ncq_send_recv_cmds, ap->sector_buf, | |
| 2154 | − ATA_LOG_NCQ_SEND_RECV_SIZE); | |
| 2155 | + memcpy(cmds, ap->sector_buf, ATA_LOG_NCQ_SEND_RECV_SIZE); | |
| 2156 | + | |
| 2157 | + if (dev->horkage & ATA_HORKAGE_NO_NCQ_TRIM) { | |
| 2158 | + ata_dev_dbg(dev, "disabling queued TRIM support\n"); | |
| 2159 | + cmds[ATA_LOG_NCQ_SEND_RECV_DSM_OFFSET] &= | |
| 2160 | + ~ATA_LOG_NCQ_SEND_RECV_DSM_TRIM; | |
| 2161 | + } | |
| 2155 | 2162 | } |
| 2156 | 2163 | } |
| 2157 | 2164 | |
| @@ -4156,6 +4163,9 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = { · 1998 unmodified lines | ||
| 4156 | 4163 | { "ST3320[68]13AS", "SD1[5-9]", ATA_HORKAGE_NONCQ | |
| 4157 | 4164 | ATA_HORKAGE_FIRMWARE_WARN }, |
| 4158 | 4165 | |
| 4166 | + /* Seagate Momentus SpinPoint M8 seem to have FPMDA_AA issues */ | |
| 4167 | + { "ST1000LM024 HN-M101MBB", "2AR10001", ATA_HORKAGE_BROKEN_FPDMA_AA }, | |
| 4168 | + | |
| 4159 | 4169 | /* Blacklist entries taken from Silicon Image 3124/3132 |
| 4160 | 4170 | Windows driver .inf file - also several Linux problem reports */ |
| 4161 | 4171 | { "HTS541060G9SA00", "MB3OC60D", ATA_HORKAGE_NONCQ, }, |
| @@ -4202,6 +4212,10 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = { · 40 unmodified lines | ||
| 4202 | 4212 | { "PIONEER DVD-RW DVR-212D", NULL, ATA_HORKAGE_NOSETXFER }, |
| 4203 | 4213 | { "PIONEER DVD-RW DVR-216D", NULL, ATA_HORKAGE_NOSETXFER }, |
| 4204 | 4214 | |
| 4215 | + /* devices that don't properly handle queued TRIM commands */ | |
| 4216 | + { "Micron_M500*", NULL, ATA_HORKAGE_NO_NCQ_TRIM, }, | |
| 4217 | + { "Crucial_CT???M500SSD1", NULL, ATA_HORKAGE_NO_NCQ_TRIM, }, | |
| 4218 | + | |
| 4205 | 4219 | /* End Marker */ |
| 4206 | 4220 | { } |
| 4207 | 4221 | }; |
| @@ -6519,6 +6533,7 @@ static int __init ata_parse_force_one(char **cur, · 2311 unmodified lines | ||
| 6519 | 6533 | { "norst", .lflags = ATA_LFLAG_NO_HRST | ATA_LFLAG_NO_SRST }, |
| 6520 | 6534 | { "rstonce", .lflags = ATA_LFLAG_RST_ONCE }, |
| 6521 | 6535 | { "atapi_dmadir", .horkage_on = ATA_HORKAGE_ATAPI_DMADIR }, |
| 6536 | + { "disable", .horkage_on = ATA_HORKAGE_DISABLE }, | |
| 6522 | 6537 | }; |
| 6523 | 6538 | char *start = *cur, *p = *cur; |
| 6524 | 6539 | char *id, *val, *endp; |
| @@ -3872,6 +3872,27 @@ void ata_scsi_hotplug(struct work_struct *work) · 3871 unmodified lines | ||
| 3872 | 3872 | return; |
| 3873 | 3873 | } |
| 3874 | 3874 | |
| 3875 | + /* | |
| 3876 | + * XXX - UGLY HACK | |
| 3877 | + * | |
| 3878 | + * The block layer suspend/resume path is fundamentally broken due | |
| 3879 | + * to freezable kthreads and workqueue and may deadlock if a block | |
| 3880 | + * device gets removed while resume is in progress. I don't know | |
| 3881 | + * what the solution is short of removing freezable kthreads and | |
| 3882 | + * workqueues altogether. | |
| 3883 | + * | |
| 3884 | + * The following is an ugly hack to avoid kicking off device | |
| 3885 | + * removal while freezer is active. This is a joke but does avoid | |
| 3886 | + * this particular deadlock scenario. | |
| 3887 | + * | |
| 3888 | + * https://bugzilla.kernel.org/show_bug.cgi?id=62801 | |
| 3889 | + * http://marc.info/?l=linux-kernel&m=138695698516487 | |
| 3890 | + */ | |
| 3891 | +#ifdef CONFIG_FREEZER | |
| 3892 | + while (pm_freezing) | |
| 3893 | + msleep(10); | |
| 3894 | +#endif | |
| 3895 | + | |
| 3875 | 3896 | DPRINTK("ENTER\n"); |
| 3876 | 3897 | mutex_lock(&ap->scsi_scan_mutex); |
| 3877 | 3898 | |
| @@ -1,4 +1,5 @@ | ||
| 1 | 1 | #include <linux/module.h> |
| 2 | + | |
| 2 | 3 | #include <linux/moduleparam.h> |
| 3 | 4 | #include <linux/sched.h> |
| 4 | 5 | #include <linux/fs.h> |
| @@ -65,7 +66,7 @@ enum { · 60 unmodified lines | ||
| 65 | 66 | NULL_Q_MQ = 2, |
| 66 | 67 | }; |
| 67 | 68 | |
| 68 | −static int submit_queues = 1; | |
| 69 | +static int submit_queues; | |
| 69 | 70 | module_param(submit_queues, int, S_IRUGO); |
| 70 | 71 | MODULE_PARM_DESC(submit_queues, "Number of submission queues"); |
| 71 | 72 | |
| @@ -101,9 +102,9 @@ static int hw_queue_depth = 64; · 29 unmodified lines | ||
| 101 | 102 | module_param(hw_queue_depth, int, S_IRUGO); |
| 102 | 103 | MODULE_PARM_DESC(hw_queue_depth, "Queue depth for each hardware queue. Default: 64"); |
| 103 | 104 | |
| 104 | −static bool use_per_node_hctx = true; | |
| 105 | +static bool use_per_node_hctx = false; | |
| 105 | 106 | module_param(use_per_node_hctx, bool, S_IRUGO); |
| 106 | −MODULE_PARM_DESC(use_per_node_hctx, "Use per-node allocation for hardware context queues. Default: true"); | |
| 107 | +MODULE_PARM_DESC(use_per_node_hctx, "Use per-node allocation for hardware context queues. Default: false"); | |
| 107 | 108 | |
| 108 | 109 | static void put_tag(struct nullb_queue *nq, unsigned int tag) |
| 109 | 110 | { |
| @@ -346,8 +347,37 @@ static int null_queue_rq(struct blk_mq_hw_ctx *hctx, struct request *rq) · 236 unmodified lines | ||
| 346 | 347 | |
| 347 | 348 | static struct blk_mq_hw_ctx *null_alloc_hctx(struct blk_mq_reg *reg, unsigned int hctx_index) |
| 348 | 349 | { |
| 349 | − return kzalloc_node(sizeof(struct blk_mq_hw_ctx), GFP_KERNEL, | |
| 350 | − hctx_index); | |
| 350 | + int b_size = DIV_ROUND_UP(reg->nr_hw_queues, nr_online_nodes); | |
| 351 | + int tip = (reg->nr_hw_queues % nr_online_nodes); | |
| 352 | + int node = 0, i, n; | |
| 353 | + | |
| 354 | + /* | |
| 355 | + * Split submit queues evenly wrt to the number of nodes. If uneven, | |
| 356 | + * fill the first buckets with one extra, until the rest is filled with | |
| 357 | + * no extra. | |
| 358 | + */ | |
| 359 | + for (i = 0, n = 1; i < hctx_index; i++, n++) { | |
| 360 | + if (n % b_size == 0) { | |
| 361 | + n = 0; | |
| 362 | + node++; | |
| 363 | + | |
| 364 | + tip--; | |
| 365 | + if (!tip) | |
| 366 | + b_size = reg->nr_hw_queues / nr_online_nodes; | |
| 367 | + } | |
| 368 | + } | |
| 369 | + | |
| 370 | + /* | |
| 371 | + * A node might not be online, therefore map the relative node id to the | |
| 372 | + * real node id. | |
| 373 | + */ | |
| 374 | + for_each_online_node(n) { | |
| 375 | + if (!node) | |
| 376 | + break; | |
| 377 | + node--; | |
| 378 | + } | |
| 379 | + | |
| 380 | + return kzalloc_node(sizeof(struct blk_mq_hw_ctx), GFP_KERNEL, n); | |
| 351 | 381 | } |
| 352 | 382 | |
| 353 | 383 | static void null_free_hctx(struct blk_mq_hw_ctx *hctx, unsigned int hctx_index) |
| @@ -355,16 +385,24 @@ static void null_free_hctx(struct blk_mq_hw_ctx *hctx, unsigned int hctx_index) · 1 unmodified line | ||
| 355 | 385 | kfree(hctx); |
| 356 | 386 | } |
| 357 | 387 | |
| 388 | +static void null_init_queue(struct nullb *nullb, struct nullb_queue *nq) | |
| 389 | +{ | |
| 390 | + BUG_ON(!nullb); | |
| 391 | + BUG_ON(!nq); | |
| 392 | + | |
| 393 | + init_waitqueue_head(&nq->wait); | |
| 394 | + nq->queue_depth = nullb->queue_depth; | |
| 395 | +} | |
| 396 | + | |
| 358 | 397 | static int null_init_hctx(struct blk_mq_hw_ctx *hctx, void *data, |
| 359 | 398 | unsigned int index) |
| 360 | 399 | { |
| 361 | 400 | struct nullb *nullb = data; |
| 362 | 401 | struct nullb_queue *nq = &nullb->queues[index]; |
| 363 | 402 | |
| 364 | − init_waitqueue_head(&nq->wait); | |
| 365 | − nq->queue_depth = nullb->queue_depth; | |
| 366 | − nullb->nr_queues++; | |
| 367 | 403 | hctx->driver_data = nq; |
| 404 | + null_init_queue(nullb, nq); | |
| 405 | + nullb->nr_queues++; | |
| 368 | 406 | |
| 369 | 407 | return 0; |
| 370 | 408 | } |
| @@ -417,13 +455,13 @@ static int setup_commands(struct nullb_queue *nq) · 46 unmodified lines | ||
| 417 | 455 | |
| 418 | 456 | nq->cmds = kzalloc(nq->queue_depth * sizeof(*cmd), GFP_KERNEL); |
| 419 | 457 | if (!nq->cmds) |
| 420 | − return 1; | |
| 458 | + return -ENOMEM; | |
| 421 | 459 | |
| 422 | 460 | tag_size = ALIGN(nq->queue_depth, BITS_PER_LONG) / BITS_PER_LONG; |
| 423 | 461 | nq->tag_map = kzalloc(tag_size * sizeof(unsigned long), GFP_KERNEL); |
| 424 | 462 | if (!nq->tag_map) { |
| 425 | 463 | kfree(nq->cmds); |
| 426 | − return 1; | |
| 464 | + return -ENOMEM; | |
| 427 | 465 | } |
| 428 | 466 | |
| 429 | 467 | for (i = 0; i < nq->queue_depth; i++) { |
| @@ -454,33 +492,37 @@ static void cleanup_queues(struct nullb *nullb) · 24 unmodified lines | ||
| 454 | 492 | |
| 455 | 493 | static int setup_queues(struct nullb *nullb) |
| 456 | 494 | { |
| 457 | − struct nullb_queue *nq; | |
| 458 | − int i; | |
| 459 | − | |
| 460 | − nullb->queues = kzalloc(submit_queues * sizeof(*nq), GFP_KERNEL); | |
| 495 | + nullb->queues = kzalloc(submit_queues * sizeof(struct nullb_queue), | |
| 496 | + GFP_KERNEL); | |
| 461 | 497 | if (!nullb->queues) |
| 462 | − return 1; | |
| 498 | + return -ENOMEM; | |
| 463 | 499 | |
| 464 | 500 | nullb->nr_queues = 0; |
| 465 | 501 | nullb->queue_depth = hw_queue_depth; |
| 466 | 502 | |
| 467 | − if (queue_mode == NULL_Q_MQ) | |
| 468 | − return 0; | |
| 503 | + return 0; | |
| 504 | +} | |
| 505 | + | |
| 506 | +static int init_driver_queues(struct nullb *nullb) | |
| 507 | +{ | |
| 508 | + struct nullb_queue *nq; | |
| 509 | + int i, ret = 0; | |
| 469 | 510 | |
| 470 | 511 | for (i = 0; i < submit_queues; i++) { |
| 471 | 512 | nq = &nullb->queues[i]; |
| 472 | − init_waitqueue_head(&nq->wait); | |
| 473 | − nq->queue_depth = hw_queue_depth; | |
| 474 | − if (setup_commands(nq)) | |
| 475 | − break; | |
| 513 | + | |
| 514 | + null_init_queue(nullb, nq); | |
| 515 | + | |
| 516 | + ret = setup_commands(nq); | |
| 517 | + if (ret) | |
| 518 | + goto err_queue; | |
| 476 | 519 | nullb->nr_queues++; |
| 477 | 520 | } |
| 478 | 521 | |
| 479 | − if (i == submit_queues) | |
| 480 | − return 0; | |
| 481 | − | |
| 522 | + return 0; | |
| 523 | +err_queue: | |
| 482 | 524 | cleanup_queues(nullb); |
| 483 | − return 1; | |
| 525 | + return ret; | |
| 484 | 526 | } |
| 485 | 527 | |
| 486 | 528 | static int null_add_dev(void) |
| @@ -518,11 +560,13 @@ static int null_add_dev(void) · 31 unmodified lines | ||
| 518 | 560 | } else if (queue_mode == NULL_Q_BIO) { |
| 519 | 561 | nullb->q = blk_alloc_queue_node(GFP_KERNEL, home_node); |
| 520 | 562 | blk_queue_make_request(nullb->q, null_queue_bio); |
| 563 | + init_driver_queues(nullb); | |
| 521 | 564 | } else { |
| 522 | 565 | nullb->q = blk_init_queue_node(null_request_fn, &nullb->lock, home_node); |
| 523 | 566 | blk_queue_prep_rq(nullb->q, null_rq_prep_fn); |
| 524 | 567 | if (nullb->q) |
| 525 | 568 | blk_queue_softirq_done(nullb->q, null_softirq_done_fn); |
| 569 | + init_driver_queues(nullb); | |
| 526 | 570 | } |
| 527 | 571 | |
| 528 | 572 | if (!nullb->q) |
| @@ -579,7 +623,13 @@ static int __init null_init(void) · 50 unmodified lines | ||
| 579 | 623 | } |
| 580 | 624 | #endif |
| 581 | 625 | |
| 582 | − if (submit_queues > nr_cpu_ids) | |
| 626 | + if (queue_mode == NULL_Q_MQ && use_per_node_hctx) { | |
| 627 | + if (submit_queues < nr_online_nodes) { | |
| 628 | + pr_warn("null_blk: submit_queues param is set to %u.", | |
| 629 | + nr_online_nodes); | |
| 630 | + submit_queues = nr_online_nodes; | |
| 631 | + } | |
| 632 | + } else if (submit_queues > nr_cpu_ids) | |
| 583 | 633 | submit_queues = nr_cpu_ids; |
| 584 | 634 | else if (!submit_queues) |
| 585 | 635 | submit_queues = 1; |
| @@ -5269,7 +5269,7 @@ const char *skd_skdev_state_to_str(enum skd_drvr_state state) · 5268 unmodified lines | ||
| 5269 | 5269 | } |
| 5270 | 5270 | } |
| 5271 | 5271 | |
| 5272 | −const char *skd_skmsg_state_to_str(enum skd_fit_msg_state state) | |
| 5272 | +static const char *skd_skmsg_state_to_str(enum skd_fit_msg_state state) | |
| 5273 | 5273 | { |
| 5274 | 5274 | switch (state) { |
| 5275 | 5275 | case SKD_MSG_STATE_IDLE: |
| @@ -5281,7 +5281,7 @@ const char *skd_skmsg_state_to_str(enum skd_fit_msg_state state) · 5 unmodified lines | ||
| 5281 | 5281 | } |
| 5282 | 5282 | } |
| 5283 | 5283 | |
| 5284 | −const char *skd_skreq_state_to_str(enum skd_req_state state) | |
| 5284 | +static const char *skd_skreq_state_to_str(enum skd_req_state state) | |
| 5285 | 5285 | { |
| 5286 | 5286 | switch (state) { |
| 5287 | 5287 | case SKD_REQ_STATE_IDLE: |
| @@ -60,7 +60,7 @@ static int s2mps11_clk_prepare(struct clk_hw *hw) · 59 unmodified lines | ||
| 60 | 60 | struct s2mps11_clk *s2mps11 = to_s2mps11_clk(hw); |
| 61 | 61 | int ret; |
| 62 | 62 | |
| 63 | − ret = regmap_update_bits(s2mps11->iodev->regmap, | |
| 63 | + ret = regmap_update_bits(s2mps11->iodev->regmap_pmic, | |
| 64 | 64 | S2MPS11_REG_RTC_CTRL, |
| 65 | 65 | s2mps11->mask, s2mps11->mask); |
| 66 | 66 | if (!ret) |
| @@ -74,7 +74,7 @@ static void s2mps11_clk_unprepare(struct clk_hw *hw) · 7 unmodified lines | ||
| 74 | 74 | struct s2mps11_clk *s2mps11 = to_s2mps11_clk(hw); |
| 75 | 75 | int ret; |
| 76 | 76 | |
| 77 | − ret = regmap_update_bits(s2mps11->iodev->regmap, S2MPS11_REG_RTC_CTRL, | |
| 77 | + ret = regmap_update_bits(s2mps11->iodev->regmap_pmic, S2MPS11_REG_RTC_CTRL, | |
| 78 | 78 | s2mps11->mask, ~s2mps11->mask); |
| 79 | 79 | |
| 80 | 80 | if (!ret) |
| @@ -174,7 +174,7 @@ static int s2mps11_clk_probe(struct platform_device *pdev) · 93 unmodified lines | ||
| 174 | 174 | s2mps11_clk->hw.init = &s2mps11_clks_init[i]; |
| 175 | 175 | s2mps11_clk->mask = 1 << i; |
| 176 | 176 | |
| 177 | − ret = regmap_read(s2mps11_clk->iodev->regmap, | |
| 177 | + ret = regmap_read(s2mps11_clk->iodev->regmap_pmic, | |
| 178 | 178 | S2MPS11_REG_RTC_CTRL, &val); |
| 179 | 179 | if (ret < 0) |
| 180 | 180 | goto err_reg; |
| @@ -75,6 +75,7 @@ config CLKSRC_DBX500_PRCMU_SCHED_CLOCK · 74 unmodified lines | ||
| 75 | 75 | config CLKSRC_EFM32 |
| 76 | 76 | bool "Clocksource for Energy Micro's EFM32 SoCs" if !ARCH_EFM32 |
| 77 | 77 | depends on OF && ARM && (ARCH_EFM32 || COMPILE_TEST) |
| 78 | + select CLKSRC_MMIO | |
| 78 | 79 | default ARCH_EFM32 |
| 79 | 80 | help |
| 80 | 81 | Support to use the timers of EFM32 SoCs as clock source and clock |
| @@ -35,6 +35,5 @@ void __init clocksource_of_init(void) · 34 unmodified lines | ||
| 35 | 35 | |
| 36 | 36 | init_func = match->data; |
| 37 | 37 | init_func(np); |
| 38 | − of_node_put(np); | |
| 39 | 38 | } |
| 40 | 39 | } |
| @@ -108,12 +108,11 @@ static void __init add_clocksource(struct device_node *source_timer) · 107 unmodified lines | ||
| 108 | 108 | |
| 109 | 109 | static u64 read_sched_clock(void) |
| 110 | 110 | { |
| 111 | − return __raw_readl(sched_io_base); | |
| 111 | + return ~__raw_readl(sched_io_base); | |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | static const struct of_device_id sptimer_ids[] __initconst = { |
| 115 | 115 | { .compatible = "picochip,pc3x2-rtc" }, |
| 116 | − { .compatible = "snps,dw-apb-timer-sp" }, | |
| 117 | 116 | { /* Sentinel */ }, |
| 118 | 117 | }; |
| 119 | 118 | |
| @@ -151,4 +150,6 @@ static void __init dw_apb_timer_init(struct device_node *timer) · 31 unmodified lines | ||
| 151 | 150 | num_called++; |
| 152 | 151 | } |
| 153 | 152 | CLOCKSOURCE_OF_DECLARE(pc3x2_timer, "picochip,pc3x2-timer", dw_apb_timer_init); |
| 154 | −CLOCKSOURCE_OF_DECLARE(apb_timer, "snps,dw-apb-timer-osc", dw_apb_timer_init); | |
| 153 | +CLOCKSOURCE_OF_DECLARE(apb_timer_osc, "snps,dw-apb-timer-osc", dw_apb_timer_init); | |
| 154 | +CLOCKSOURCE_OF_DECLARE(apb_timer_sp, "snps,dw-apb-timer-sp", dw_apb_timer_init); | |
| 155 | +CLOCKSOURCE_OF_DECLARE(apb_timer, "snps,dw-apb-timer", dw_apb_timer_init); | |
| @@ -179,6 +179,9 @@ static void __init sun4i_timer_init(struct device_node *node) · 178 unmodified lines | ||
| 179 | 179 | writel(TIMER_CTL_CLK_SRC(TIMER_CTL_CLK_SRC_OSC24M), |
| 180 | 180 | timer_base + TIMER_CTL_REG(0)); |
| 181 | 181 | |
| 182 | + /* Make sure timer is stopped before playing with interrupts */ | |
| 183 | + sun4i_clkevt_time_stop(0); | |
| 184 | + | |
| 182 | 185 | ret = setup_irq(irq, &sun4i_timer_irq); |
| 183 | 186 | if (ret) |
| 184 | 187 | pr_warn("failed to setup irq %d\n", irq); |
| @@ -255,11 +255,6 @@ static void __init armada_370_xp_timer_common_init(struct device_node *np) · 254 unmodified lines | ||
| 255 | 255 | |
| 256 | 256 | ticks_per_jiffy = (timer_clk + HZ / 2) / HZ; |
| 257 | 257 | |
| 258 | − /* | |
| 259 | − * Set scale and timer for sched_clock. | |
| 260 | − */ | |
| 261 | − sched_clock_register(armada_370_xp_read_sched_clock, 32, timer_clk); | |
| 262 | − | |
| 263 | 258 | /* |
| 264 | 259 | * Setup free-running clocksource timer (interrupts |
| 265 | 260 | * disabled). |
| @@ -270,6 +265,11 @@ static void __init armada_370_xp_timer_common_init(struct device_node *np) · 4 unmodified lines | ||
| 270 | 265 | timer_ctrl_clrset(0, TIMER0_EN | TIMER0_RELOAD_EN | |
| 271 | 266 | TIMER0_DIV(TIMER_DIVIDER_SHIFT)); |
| 272 | 267 | |
| 268 | + /* | |
| 269 | + * Set scale and timer for sched_clock. | |
| 270 | + */ | |
| 271 | + sched_clock_register(armada_370_xp_read_sched_clock, 32, timer_clk); | |
| 272 | + | |
| 273 | 273 | clocksource_mmio_init(timer_base + TIMER0_VAL_OFF, |
| 274 | 274 | "armada_370_xp_clocksource", |
| 275 | 275 | timer_clk, 300, 32, clocksource_mmio_readl_down); |
| @@ -828,6 +828,12 @@ static void cpufreq_init_policy(struct cpufreq_policy *policy) · 827 unmodified lines | ||
| 828 | 828 | int ret = 0; |
| 829 | 829 | |
| 830 | 830 | memcpy(&new_policy, policy, sizeof(*policy)); |
| 831 | + | |
| 832 | + /* Use the default policy if its valid. */ | |
| 833 | + if (cpufreq_driver->setpolicy) | |
| 834 | + cpufreq_parse_governor(policy->governor->name, | |
| 835 | + &new_policy.policy, NULL); | |
| 836 | + | |
| 831 | 837 | /* assure that the starting sequence is run in cpufreq_set_policy */ |
| 832 | 838 | policy->governor = NULL; |
| 833 | 839 | |
| @@ -845,8 +851,7 @@ static void cpufreq_init_policy(struct cpufreq_policy *policy) · 11 unmodified lines | ||
| 845 | 851 | |
| 846 | 852 | #ifdef CONFIG_HOTPLUG_CPU |
| 847 | 853 | static int cpufreq_add_policy_cpu(struct cpufreq_policy *policy, |
| 848 | − unsigned int cpu, struct device *dev, | |
| 849 | − bool frozen) | |
| 854 | + unsigned int cpu, struct device *dev) | |
| 850 | 855 | { |
| 851 | 856 | int ret = 0; |
| 852 | 857 | unsigned long flags; |
| @@ -877,11 +882,7 @@ static int cpufreq_add_policy_cpu(struct cpufreq_policy *policy, · 24 unmodified lines | ||
| 877 | 882 | } |
| 878 | 883 | } |
| 879 | 884 | |
| 880 | − /* Don't touch sysfs links during light-weight init */ | |
| 881 | − if (!frozen) | |
| 882 | − ret = sysfs_create_link(&dev->kobj, &policy->kobj, "cpufreq"); | |
| 883 | − | |
| 884 | − return ret; | |
| 885 | + return sysfs_create_link(&dev->kobj, &policy->kobj, "cpufreq"); | |
| 885 | 886 | } |
| 886 | 887 | #endif |
| 887 | 888 | |
| @@ -926,6 +927,27 @@ err_free_policy: · 38 unmodified lines | ||
| 926 | 927 | return NULL; |
| 927 | 928 | } |
| 928 | 929 | |
| 930 | +static void cpufreq_policy_put_kobj(struct cpufreq_policy *policy) | |
| 931 | +{ | |
| 932 | + struct kobject *kobj; | |
| 933 | + struct completion *cmp; | |
| 934 | + | |
| 935 | + down_read(&policy->rwsem); | |
| 936 | + kobj = &policy->kobj; | |
| 937 | + cmp = &policy->kobj_unregister; | |
| 938 | + up_read(&policy->rwsem); | |
| 939 | + kobject_put(kobj); | |
| 940 | + | |
| 941 | + /* | |
| 942 | + * We need to make sure that the underlying kobj is | |
| 943 | + * actually not referenced anymore by anybody before we | |
| 944 | + * proceed with unloading. | |
| 945 | + */ | |
| 946 | + pr_debug("waiting for dropping of refcount\n"); | |
| 947 | + wait_for_completion(cmp); | |
| 948 | + pr_debug("wait complete\n"); | |
| 949 | +} | |
| 950 | + | |
| 929 | 951 | static void cpufreq_policy_free(struct cpufreq_policy *policy) |
| 930 | 952 | { |
| 931 | 953 | free_cpumask_var(policy->related_cpus); |
| @@ -986,7 +1008,7 @@ static int __cpufreq_add_dev(struct device *dev, struct subsys_interface *sif, · 54 unmodified lines | ||
| 986 | 1008 | list_for_each_entry(tpolicy, &cpufreq_policy_list, policy_list) { |
| 987 | 1009 | if (cpumask_test_cpu(cpu, tpolicy->related_cpus)) { |
| 988 | 1010 | read_unlock_irqrestore(&cpufreq_driver_lock, flags); |
| 989 | − ret = cpufreq_add_policy_cpu(tpolicy, cpu, dev, frozen); | |
| 1011 | + ret = cpufreq_add_policy_cpu(tpolicy, cpu, dev); | |
| 990 | 1012 | up_read(&cpufreq_rwsem); |
| 991 | 1013 | return ret; |
| 992 | 1014 | } |
| @@ -1096,7 +1118,10 @@ err_get_freq: · 103 unmodified lines | ||
| 1096 | 1118 | if (cpufreq_driver->exit) |
| 1097 | 1119 | cpufreq_driver->exit(policy); |
| 1098 | 1120 | err_set_policy_cpu: |
| 1121 | + if (frozen) | |
| 1122 | + cpufreq_policy_put_kobj(policy); | |
| 1099 | 1123 | cpufreq_policy_free(policy); |
| 1124 | + | |
| 1100 | 1125 | nomem_out: |
| 1101 | 1126 | up_read(&cpufreq_rwsem); |
| 1102 | 1127 | |
| @@ -1118,7 +1143,7 @@ static int cpufreq_add_dev(struct device *dev, struct subsys_interface *sif) · 15 unmodified lines | ||
| 1118 | 1143 | } |
| 1119 | 1144 | |
| 1120 | 1145 | static int cpufreq_nominate_new_policy_cpu(struct cpufreq_policy *policy, |
| 1121 | − unsigned int old_cpu, bool frozen) | |
| 1146 | + unsigned int old_cpu) | |
| 1122 | 1147 | { |
| 1123 | 1148 | struct device *cpu_dev; |
| 1124 | 1149 | int ret; |
| @@ -1126,10 +1151,6 @@ static int cpufreq_nominate_new_policy_cpu(struct cpufreq_policy *policy, · 1 unmodified line | ||
| 1126 | 1151 | /* first sibling now owns the new sysfs dir */ |
| 1127 | 1152 | cpu_dev = get_cpu_device(cpumask_any_but(policy->cpus, old_cpu)); |
| 1128 | 1153 | |
| 1129 | − /* Don't touch sysfs files during light-weight tear-down */ | |
| 1130 | − if (frozen) | |
| 1131 | − return cpu_dev->id; | |
| 1132 | − | |
| 1133 | 1154 | sysfs_remove_link(&cpu_dev->kobj, "cpufreq"); |
| 1134 | 1155 | ret = kobject_move(&policy->kobj, &cpu_dev->kobj); |
| 1135 | 1156 | if (ret) { |
| @@ -1196,7 +1217,7 @@ static int __cpufreq_remove_dev_prepare(struct device *dev, · 60 unmodified lines | ||
| 1196 | 1217 | if (!frozen) |
| 1197 | 1218 | sysfs_remove_link(&dev->kobj, "cpufreq"); |
| 1198 | 1219 | } else if (cpus > 1) { |
| 1199 | − new_cpu = cpufreq_nominate_new_policy_cpu(policy, cpu, frozen); | |
| 1220 | + new_cpu = cpufreq_nominate_new_policy_cpu(policy, cpu); | |
| 1200 | 1221 | if (new_cpu >= 0) { |
| 1201 | 1222 | update_policy_cpu(policy, new_cpu); |
| 1202 | 1223 | |
| @@ -1218,8 +1239,6 @@ static int __cpufreq_remove_dev_finish(struct device *dev, · 15 unmodified lines | ||
| 1218 | 1239 | int ret; |
| 1219 | 1240 | unsigned long flags; |
| 1220 | 1241 | struct cpufreq_policy *policy; |
| 1221 | − struct kobject *kobj; | |
| 1222 | − struct completion *cmp; | |
| 1223 | 1242 | |
| 1224 | 1243 | read_lock_irqsave(&cpufreq_driver_lock, flags); |
| 1225 | 1244 | policy = per_cpu(cpufreq_cpu_data, cpu); |
| @@ -1249,22 +1268,8 @@ static int __cpufreq_remove_dev_finish(struct device *dev, · 23 unmodified lines | ||
| 1249 | 1268 | } |
| 1250 | 1269 | } |
| 1251 | 1270 | |
| 1252 | − if (!frozen) { | |
| 1253 | − down_read(&policy->rwsem); | |
| 1254 | − kobj = &policy->kobj; | |
| 1255 | − cmp = &policy->kobj_unregister; | |
| 1256 | − up_read(&policy->rwsem); | |
| 1257 | − kobject_put(kobj); | |
| 1258 | − | |
| 1259 | − /* | |
| 1260 | − * We need to make sure that the underlying kobj is | |
| 1261 | − * actually not referenced anymore by anybody before we | |
| 1262 | − * proceed with unloading. | |
| 1263 | − */ | |
| 1264 | − pr_debug("waiting for dropping of refcount\n"); | |
| 1265 | − wait_for_completion(cmp); | |
| 1266 | − pr_debug("wait complete\n"); | |
| 1267 | − } | |
| 1271 | + if (!frozen) | |
| 1272 | + cpufreq_policy_put_kobj(policy); | |
| 1268 | 1273 | |
| 1269 | 1274 | /* |
| 1270 | 1275 | * Perform the ->exit() even during light-weight tear-down, |
| @@ -62,6 +62,7 @@ config INTEL_IOATDMA · 61 unmodified lines | ||
| 62 | 62 | tristate "Intel I/OAT DMA support" |
| 63 | 63 | depends on PCI && X86 |
| 64 | 64 | select DMA_ENGINE |
| 65 | + select DMA_ENGINE_RAID | |
| 65 | 66 | select DCA |
| 66 | 67 | help |
| 67 | 68 | Enable support for the Intel(R) I/OAT DMA engine present |
| @@ -112,6 +113,7 @@ config MV_XOR · 44 unmodified lines | ||
| 112 | 113 | bool "Marvell XOR engine support" |
| 113 | 114 | depends on PLAT_ORION |
| 114 | 115 | select DMA_ENGINE |
| 116 | + select DMA_ENGINE_RAID | |
| 115 | 117 | select ASYNC_TX_ENABLE_CHANNEL_SWITCH |
| 116 | 118 | ---help--- |
| 117 | 119 | Enable support for the Marvell XOR engine. |
| @@ -187,6 +189,7 @@ config AMCC_PPC440SPE_ADMA · 69 unmodified lines | ||
| 187 | 189 | tristate "AMCC PPC440SPe ADMA support" |
| 188 | 190 | depends on 440SPe || 440SP |
| 189 | 191 | select DMA_ENGINE |
| 192 | + select DMA_ENGINE_RAID | |
| 190 | 193 | select ARCH_HAS_ASYNC_TX_FIND_CHANNEL |
| 191 | 194 | select ASYNC_TX_ENABLE_CHANNEL_SWITCH |
| 192 | 195 | help |
| @@ -352,6 +355,7 @@ config NET_DMA · 159 unmodified lines | ||
| 352 | 355 | bool "Network: TCP receive copy offload" |
| 353 | 356 | depends on DMA_ENGINE && NET |
| 354 | 357 | default (INTEL_IOATDMA || FSL_DMA) |
| 358 | + depends on BROKEN | |
| 355 | 359 | help |
| 356 | 360 | This enables the use of DMA engines in the network stack to |
| 357 | 361 | offload receive copy-to-user operations, freeing CPU cycles. |
| @@ -377,4 +381,7 @@ config DMATEST · 19 unmodified lines | ||
| 377 | 381 | Simple DMA test client. Say N unless you're debugging a |
| 378 | 382 | DMA Device driver. |
| 379 | 383 | |
| 384 | +config DMA_ENGINE_RAID | |
| 385 | + bool | |
| 386 | + | |
| 380 | 387 | endif |
| @@ -347,10 +347,6 @@ static struct device *chan2dev(struct dma_chan *chan) · 346 unmodified lines | ||
| 347 | 347 | { |
| 348 | 348 | return &chan->dev->device; |
| 349 | 349 | } |
| 350 | −static struct device *chan2parent(struct dma_chan *chan) | |
| 351 | −{ | |
| 352 | − return chan->dev->device.parent; | |
| 353 | −} | |
| 354 | 350 | |
| 355 | 351 | #if defined(VERBOSE_DEBUG) |
| 356 | 352 | static void vdbg_dump_regs(struct at_dma_chan *atchan) |
| @@ -912,7 +912,7 @@ struct dmaengine_unmap_pool { · 911 unmodified lines | ||
| 912 | 912 | #define __UNMAP_POOL(x) { .size = x, .name = "dmaengine-unmap-" __stringify(x) } |
| 913 | 913 | static struct dmaengine_unmap_pool unmap_pool[] = { |
| 914 | 914 | __UNMAP_POOL(2), |
| 915 | − #if IS_ENABLED(CONFIG_ASYNC_TX_DMA) | |
| 915 | + #if IS_ENABLED(CONFIG_DMA_ENGINE_RAID) | |
| 916 | 916 | __UNMAP_POOL(16), |
| 917 | 917 | __UNMAP_POOL(128), |
| 918 | 918 | __UNMAP_POOL(256), |
| @@ -1054,7 +1054,7 @@ dma_async_memcpy_pg_to_pg(struct dma_chan *chan, struct page *dest_pg, · 135 unmodified lines | ||
| 1054 | 1054 | dma_cookie_t cookie; |
| 1055 | 1055 | unsigned long flags; |
| 1056 | 1056 | |
| 1057 | − unmap = dmaengine_get_unmap_data(dev->dev, 2, GFP_NOIO); | |
| 1057 | + unmap = dmaengine_get_unmap_data(dev->dev, 2, GFP_NOWAIT); | |
| 1058 | 1058 | if (!unmap) |
| 1059 | 1059 | return -ENOMEM; |
| 1060 | 1060 | |
| @@ -539,9 +539,9 @@ static int dmatest_func(void *data) · 538 unmodified lines | ||
| 539 | 539 | |
| 540 | 540 | um->len = params->buf_size; |
| 541 | 541 | for (i = 0; i < src_cnt; i++) { |
| 542 | − unsigned long buf = (unsigned long) thread->srcs[i]; | |
| 542 | + void *buf = thread->srcs[i]; | |
| 543 | 543 | struct page *pg = virt_to_page(buf); |
| 544 | − unsigned pg_off = buf & ~PAGE_MASK; | |
| 544 | + unsigned pg_off = (unsigned long) buf & ~PAGE_MASK; | |
| 545 | 545 | |
| 546 | 546 | um->addr[i] = dma_map_page(dev->dev, pg, pg_off, |
| 547 | 547 | um->len, DMA_TO_DEVICE); |
| @@ -559,9 +559,9 @@ static int dmatest_func(void *data) · 11 unmodified lines | ||
| 559 | 559 | /* map with DMA_BIDIRECTIONAL to force writeback/invalidate */ |
| 560 | 560 | dsts = &um->addr[src_cnt]; |
| 561 | 561 | for (i = 0; i < dst_cnt; i++) { |
| 562 | − unsigned long buf = (unsigned long) thread->dsts[i]; | |
| 562 | + void *buf = thread->dsts[i]; | |
| 563 | 563 | struct page *pg = virt_to_page(buf); |
| 564 | − unsigned pg_off = buf & ~PAGE_MASK; | |
| 564 | + unsigned pg_off = (unsigned long) buf & ~PAGE_MASK; | |
| 565 | 565 | |
| 566 | 566 | dsts[i] = dma_map_page(dev->dev, pg, pg_off, um->len, |
| 567 | 567 | DMA_BIDIRECTIONAL); |
| @@ -86,11 +86,6 @@ static void set_desc_cnt(struct fsldma_chan *chan, · 85 unmodified lines | ||
| 86 | 86 | hw->count = CPU_TO_DMA(chan, count, 32); |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | −static u32 get_desc_cnt(struct fsldma_chan *chan, struct fsl_desc_sw *desc) | |
| 90 | −{ | |
| 91 | − return DMA_TO_CPU(chan, desc->hw.count, 32); | |
| 92 | −} | |
| 93 | − | |
| 94 | 89 | static void set_desc_src(struct fsldma_chan *chan, |
| 95 | 90 | struct fsl_dma_ld_hw *hw, dma_addr_t src) |
| 96 | 91 | { |
| @@ -101,16 +96,6 @@ static void set_desc_src(struct fsldma_chan *chan, · 4 unmodified lines | ||
| 101 | 96 | hw->src_addr = CPU_TO_DMA(chan, snoop_bits | src, 64); |
| 102 | 97 | } |
| 103 | 98 | |
| 104 | −static dma_addr_t get_desc_src(struct fsldma_chan *chan, | |
| 105 | − struct fsl_desc_sw *desc) | |
| 106 | −{ | |
| 107 | − u64 snoop_bits; | |
| 108 | − | |
| 109 | − snoop_bits = ((chan->feature & FSL_DMA_IP_MASK) == FSL_DMA_IP_85XX) | |
| 110 | − ? ((u64)FSL_DMA_SATR_SREADTYPE_SNOOP_READ << 32) : 0; | |
| 111 | − return DMA_TO_CPU(chan, desc->hw.src_addr, 64) & ~snoop_bits; | |
| 112 | −} | |
| 113 | − | |
| 114 | 99 | static void set_desc_dst(struct fsldma_chan *chan, |
| 115 | 100 | struct fsl_dma_ld_hw *hw, dma_addr_t dst) |
| 116 | 101 | { |
| @@ -121,16 +106,6 @@ static void set_desc_dst(struct fsldma_chan *chan, · 4 unmodified lines | ||
| 121 | 106 | hw->dst_addr = CPU_TO_DMA(chan, snoop_bits | dst, 64); |
| 122 | 107 | } |
| 123 | 108 | |
| 124 | −static dma_addr_t get_desc_dst(struct fsldma_chan *chan, | |
| 125 | − struct fsl_desc_sw *desc) | |
| 126 | −{ | |
| 127 | − u64 snoop_bits; | |
| 128 | − | |
| 129 | − snoop_bits = ((chan->feature & FSL_DMA_IP_MASK) == FSL_DMA_IP_85XX) | |
| 130 | − ? ((u64)FSL_DMA_DATR_DWRITETYPE_SNOOP_WRITE << 32) : 0; | |
| 131 | − return DMA_TO_CPU(chan, desc->hw.dst_addr, 64) & ~snoop_bits; | |
| 132 | −} | |
| 133 | − | |
| 134 | 109 | static void set_desc_next(struct fsldma_chan *chan, |
| 135 | 110 | struct fsl_dma_ld_hw *hw, dma_addr_t next) |
| 136 | 111 | { |
| @@ -408,7 +383,7 @@ static dma_cookie_t fsl_dma_tx_submit(struct dma_async_tx_descriptor *tx) · 271 unmodified lines | ||
| 408 | 383 | struct fsl_desc_sw *desc = tx_to_fsl_desc(tx); |
| 409 | 384 | struct fsl_desc_sw *child; |
| 410 | 385 | unsigned long flags; |
| 411 | − dma_cookie_t cookie; | |
| 386 | + dma_cookie_t cookie = -EINVAL; | |
| 412 | 387 | |
| 413 | 388 | spin_lock_irqsave(&chan->desc_lock, flags); |
| 414 | 389 | |
| @@ -854,10 +829,6 @@ static void fsldma_cleanup_descriptor(struct fsldma_chan *chan, · 439 unmodified lines | ||
| 854 | 829 | struct fsl_desc_sw *desc) |
| 855 | 830 | { |
| 856 | 831 | struct dma_async_tx_descriptor *txd = &desc->async_tx; |
| 857 | − struct device *dev = chan->common.device->dev; | |
| 858 | − dma_addr_t src = get_desc_src(chan, desc); | |
| 859 | − dma_addr_t dst = get_desc_dst(chan, desc); | |
| 860 | − u32 len = get_desc_cnt(chan, desc); | |
| 861 | 832 | |
| 862 | 833 | /* Run the link descriptor callback function */ |
| 863 | 834 | if (txd->callback) { |
| @@ -54,12 +54,6 @@ static void mv_desc_init(struct mv_xor_desc_slot *desc, unsigned long flags) · 53 unmodified lines | ||
| 54 | 54 | hw_desc->desc_command = (1 << 31); |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | −static u32 mv_desc_get_dest_addr(struct mv_xor_desc_slot *desc) | |
| 58 | −{ | |
| 59 | − struct mv_xor_desc *hw_desc = desc->hw_desc; | |
| 60 | − return hw_desc->phy_dest_addr; | |
| 61 | −} | |
| 62 | − | |
| 63 | 57 | static void mv_desc_set_byte_count(struct mv_xor_desc_slot *desc, |
| 64 | 58 | u32 byte_count) |
| 65 | 59 | { |
| @@ -787,7 +781,6 @@ static void mv_xor_issue_pending(struct dma_chan *chan) · 721 unmodified lines | ||
| 787 | 781 | /* |
| 788 | 782 | * Perform a transaction to verify the HW works. |
| 789 | 783 | */ |
| 790 | −#define MV_XOR_TEST_SIZE 2000 | |
| 791 | 784 | |
| 792 | 785 | static int mv_xor_memcpy_self_test(struct mv_xor_chan *mv_chan) |
| 793 | 786 | { |
| @@ -797,20 +790,21 @@ static int mv_xor_memcpy_self_test(struct mv_xor_chan *mv_chan) · 3 unmodified lines | ||
| 797 | 790 | struct dma_chan *dma_chan; |
| 798 | 791 | dma_cookie_t cookie; |
| 799 | 792 | struct dma_async_tx_descriptor *tx; |
| 793 | + struct dmaengine_unmap_data *unmap; | |
| 800 | 794 | int err = 0; |
| 801 | 795 | |
| 802 | − src = kmalloc(sizeof(u8) * MV_XOR_TEST_SIZE, GFP_KERNEL); | |
| 796 | + src = kmalloc(sizeof(u8) * PAGE_SIZE, GFP_KERNEL); | |
| 803 | 797 | if (!src) |
| 804 | 798 | return -ENOMEM; |
| 805 | 799 | |
| 806 | − dest = kzalloc(sizeof(u8) * MV_XOR_TEST_SIZE, GFP_KERNEL); | |
| 800 | + dest = kzalloc(sizeof(u8) * PAGE_SIZE, GFP_KERNEL); | |
| 807 | 801 | if (!dest) { |
| 808 | 802 | kfree(src); |
| 809 | 803 | return -ENOMEM; |
| 810 | 804 | } |
| 811 | 805 | |
| 812 | 806 | /* Fill in src buffer */ |
| 813 | − for (i = 0; i < MV_XOR_TEST_SIZE; i++) | |
| 807 | + for (i = 0; i < PAGE_SIZE; i++) | |
| 814 | 808 | ((u8 *) src)[i] = (u8)i; |
| 815 | 809 | |
| 816 | 810 | dma_chan = &mv_chan->dmachan; |
| @@ -819,14 +813,26 @@ static int mv_xor_memcpy_self_test(struct mv_xor_chan *mv_chan) · 2 unmodified lines | ||
| 819 | 813 | goto out; |
| 820 | 814 | } |
| 821 | 815 | |
| 822 | − dest_dma = dma_map_single(dma_chan->device->dev, dest, | |
| 823 | − MV_XOR_TEST_SIZE, DMA_FROM_DEVICE); | |
| 816 | + unmap = dmaengine_get_unmap_data(dma_chan->device->dev, 2, GFP_KERNEL); | |
| 817 | + if (!unmap) { | |
| 818 | + err = -ENOMEM; | |
| 819 | + goto free_resources; | |
| 820 | + } | |
| 821 | + | |
| 822 | + src_dma = dma_map_page(dma_chan->device->dev, virt_to_page(src), 0, | |
| 823 | + PAGE_SIZE, DMA_TO_DEVICE); | |
| 824 | + unmap->to_cnt = 1; | |
| 825 | + unmap->addr[0] = src_dma; | |
| 824 | 826 | |
| 825 | − src_dma = dma_map_single(dma_chan->device->dev, src, | |
| 826 | − MV_XOR_TEST_SIZE, DMA_TO_DEVICE); | |
| 827 | + dest_dma = dma_map_page(dma_chan->device->dev, virt_to_page(dest), 0, | |
| 828 | + PAGE_SIZE, DMA_FROM_DEVICE); | |
| 829 | + unmap->from_cnt = 1; | |
| 830 | + unmap->addr[1] = dest_dma; | |
| 831 | + | |
| 832 | + unmap->len = PAGE_SIZE; | |
| 827 | 833 | |
| 828 | 834 | tx = mv_xor_prep_dma_memcpy(dma_chan, dest_dma, src_dma, |
| 829 | − MV_XOR_TEST_SIZE, 0); | |
| 835 | + PAGE_SIZE, 0); | |
| 830 | 836 | cookie = mv_xor_tx_submit(tx); |
| 831 | 837 | mv_xor_issue_pending(dma_chan); |
| 832 | 838 | async_tx_ack(tx); |
| @@ -841,8 +847,8 @@ static int mv_xor_memcpy_self_test(struct mv_xor_chan *mv_chan) · 8 unmodified lines | ||
| 841 | 847 | } |
| 842 | 848 | |
| 843 | 849 | dma_sync_single_for_cpu(dma_chan->device->dev, dest_dma, |
| 844 | − MV_XOR_TEST_SIZE, DMA_FROM_DEVICE); | |
| 845 | − if (memcmp(src, dest, MV_XOR_TEST_SIZE)) { | |
| 850 | + PAGE_SIZE, DMA_FROM_DEVICE); | |
| 851 | + if (memcmp(src, dest, PAGE_SIZE)) { | |
| 846 | 852 | dev_err(dma_chan->device->dev, |
| 847 | 853 | "Self-test copy failed compare, disabling\n"); |
| 848 | 854 | err = -ENODEV; |
| @@ -850,6 +856,7 @@ static int mv_xor_memcpy_self_test(struct mv_xor_chan *mv_chan) · 1 unmodified line | ||
| 850 | 856 | } |
| 851 | 857 | |
| 852 | 858 | free_resources: |
| 859 | + dmaengine_unmap_put(unmap); | |
| 853 | 860 | mv_xor_free_chan_resources(dma_chan); |
| 854 | 861 | out: |
| 855 | 862 | kfree(src); |
| @@ -867,13 +874,15 @@ mv_xor_xor_self_test(struct mv_xor_chan *mv_chan) · 11 unmodified lines | ||
| 867 | 874 | dma_addr_t dma_srcs[MV_XOR_NUM_SRC_TEST]; |
| 868 | 875 | dma_addr_t dest_dma; |
| 869 | 876 | struct dma_async_tx_descriptor *tx; |
| 877 | + struct dmaengine_unmap_data *unmap; | |
| 870 | 878 | struct dma_chan *dma_chan; |
| 871 | 879 | dma_cookie_t cookie; |
| 872 | 880 | u8 cmp_byte = 0; |
| 873 | 881 | u32 cmp_word; |
| 874 | 882 | int err = 0; |
| 883 | + int src_count = MV_XOR_NUM_SRC_TEST; | |
| 875 | 884 | |
| 876 | − for (src_idx = 0; src_idx < MV_XOR_NUM_SRC_TEST; src_idx++) { | |
| 885 | + for (src_idx = 0; src_idx < src_count; src_idx++) { | |
| 877 | 886 | xor_srcs[src_idx] = alloc_page(GFP_KERNEL); |
| 878 | 887 | if (!xor_srcs[src_idx]) { |
| 879 | 888 | while (src_idx--) |
| @@ -890,13 +899,13 @@ mv_xor_xor_self_test(struct mv_xor_chan *mv_chan) · 10 unmodified lines | ||
| 890 | 899 | } |
| 891 | 900 | |
| 892 | 901 | /* Fill in src buffers */ |
| 893 | − for (src_idx = 0; src_idx < MV_XOR_NUM_SRC_TEST; src_idx++) { | |
| 902 | + for (src_idx = 0; src_idx < src_count; src_idx++) { | |
| 894 | 903 | u8 *ptr = page_address(xor_srcs[src_idx]); |
| 895 | 904 | for (i = 0; i < PAGE_SIZE; i++) |
| 896 | 905 | ptr[i] = (1 << src_idx); |
| 897 | 906 | } |
| 898 | 907 | |
| 899 | − for (src_idx = 0; src_idx < MV_XOR_NUM_SRC_TEST; src_idx++) | |
| 908 | + for (src_idx = 0; src_idx < src_count; src_idx++) | |
| 900 | 909 | cmp_byte ^= (u8) (1 << src_idx); |
| 901 | 910 | |
| 902 | 911 | cmp_word = (cmp_byte << 24) | (cmp_byte << 16) | |
| @@ -910,16 +919,29 @@ mv_xor_xor_self_test(struct mv_xor_chan *mv_chan) · 7 unmodified lines | ||
| 910 | 919 | goto out; |
| 911 | 920 | } |
| 912 | 921 | |
| 922 | + unmap = dmaengine_get_unmap_data(dma_chan->device->dev, src_count + 1, | |
| 923 | + GFP_KERNEL); | |
| 924 | + if (!unmap) { | |
| 925 | + err = -ENOMEM; | |
| 926 | + goto free_resources; | |
| 927 | + } | |
| 928 | + | |
| 913 | 929 | /* test xor */ |
| 914 | − dest_dma = dma_map_page(dma_chan->device->dev, dest, 0, PAGE_SIZE, | |
| 915 | − DMA_FROM_DEVICE); | |
| 930 | + for (i = 0; i < src_count; i++) { | |
| 931 | + unmap->addr[i] = dma_map_page(dma_chan->device->dev, xor_srcs[i], | |
| 932 | + 0, PAGE_SIZE, DMA_TO_DEVICE); | |
| 933 | + dma_srcs[i] = unmap->addr[i]; | |
| 934 | + unmap->to_cnt++; | |
| 935 | + } | |
| 916 | 936 | |
| 917 | − for (i = 0; i < MV_XOR_NUM_SRC_TEST; i++) | |
| 918 | − dma_srcs[i] = dma_map_page(dma_chan->device->dev, xor_srcs[i], | |
| 919 | − 0, PAGE_SIZE, DMA_TO_DEVICE); | |
| 937 | + unmap->addr[src_count] = dma_map_page(dma_chan->device->dev, dest, 0, PAGE_SIZE, | |
| 938 | + DMA_FROM_DEVICE); | |
| 939 | + dest_dma = unmap->addr[src_count]; | |
| 940 | + unmap->from_cnt = 1; | |
| 941 | + unmap->len = PAGE_SIZE; | |
| 920 | 942 | |
| 921 | 943 | tx = mv_xor_prep_dma_xor(dma_chan, dest_dma, dma_srcs, |
| 922 | − MV_XOR_NUM_SRC_TEST, PAGE_SIZE, 0); | |
| 944 | + src_count, PAGE_SIZE, 0); | |
| 923 | 945 | |
| 924 | 946 | cookie = mv_xor_tx_submit(tx); |
| 925 | 947 | mv_xor_issue_pending(dma_chan); |
| @@ -948,9 +970,10 @@ mv_xor_xor_self_test(struct mv_xor_chan *mv_chan) · 22 unmodified lines | ||
| 948 | 970 | } |
| 949 | 971 | |
| 950 | 972 | free_resources: |
| 973 | + dmaengine_unmap_put(unmap); | |
| 951 | 974 | mv_xor_free_chan_resources(dma_chan); |
| 952 | 975 | out: |
| 953 | − src_idx = MV_XOR_NUM_SRC_TEST; | |
| 976 | + src_idx = src_count; | |
| 954 | 977 | while (src_idx--) |
| 955 | 978 | __free_page(xor_srcs[src_idx]); |
| 956 | 979 | __free_page(dest); |
| @@ -1176,6 +1199,7 @@ static int mv_xor_probe(struct platform_device *pdev) · 219 unmodified lines | ||
| 1176 | 1199 | int i = 0; |
| 1177 | 1200 | |
| 1178 | 1201 | for_each_child_of_node(pdev->dev.of_node, np) { |
| 1202 | + struct mv_xor_chan *chan; | |
| 1179 | 1203 | dma_cap_mask_t cap_mask; |
| 1180 | 1204 | int irq; |
| 1181 | 1205 | |
| @@ -1193,21 +1217,21 @@ static int mv_xor_probe(struct platform_device *pdev) · 11 unmodified lines | ||
| 1193 | 1217 | goto err_channel_add; |
| 1194 | 1218 | } |
| 1195 | 1219 | |
| 1196 | − xordev->channels[i] = | |
| 1197 | − mv_xor_channel_add(xordev, pdev, i, | |
| 1198 | − cap_mask, irq); | |
| 1199 | − if (IS_ERR(xordev->channels[i])) { | |
| 1200 | − ret = PTR_ERR(xordev->channels[i]); | |
| 1201 | − xordev->channels[i] = NULL; | |
| 1220 | + chan = mv_xor_channel_add(xordev, pdev, i, | |
| 1221 | + cap_mask, irq); | |
| 1222 | + if (IS_ERR(chan)) { | |
| 1223 | + ret = PTR_ERR(chan); | |
| 1202 | 1224 | irq_dispose_mapping(irq); |
| 1203 | 1225 | goto err_channel_add; |
| 1204 | 1226 | } |
| 1205 | 1227 | |
| 1228 | + xordev->channels[i] = chan; | |
| 1206 | 1229 | i++; |
| 1207 | 1230 | } |
| 1208 | 1231 | } else if (pdata && pdata->channels) { |
| 1209 | 1232 | for (i = 0; i < MV_XOR_MAX_CHANNELS; i++) { |
| 1210 | 1233 | struct mv_xor_channel_data *cd; |
| 1234 | + struct mv_xor_chan *chan; | |
| 1211 | 1235 | int irq; |
| 1212 | 1236 | |
| 1213 | 1237 | cd = &pdata->channels[i]; |
| @@ -1222,13 +1246,14 @@ static int mv_xor_probe(struct platform_device *pdev) · 8 unmodified lines | ||
| 1222 | 1246 | goto err_channel_add; |
| 1223 | 1247 | } |
| 1224 | 1248 | |
| 1225 | − xordev->channels[i] = | |
| 1226 | − mv_xor_channel_add(xordev, pdev, i, | |
| 1227 | − cd->cap_mask, irq); | |
| 1228 | − if (IS_ERR(xordev->channels[i])) { | |
| 1229 | − ret = PTR_ERR(xordev->channels[i]); | |
| 1249 | + chan = mv_xor_channel_add(xordev, pdev, i, | |
| 1250 | + cd->cap_mask, irq); | |
| 1251 | + if (IS_ERR(chan)) { | |
| 1252 | + ret = PTR_ERR(chan); | |
| 1230 | 1253 | goto err_channel_add; |
| 1231 | 1254 | } |
| 1255 | + | |
| 1256 | + xordev->channels[i] = chan; | |
| 1232 | 1257 | } |
| 1233 | 1258 | } |
| 1234 | 1259 | |
| @@ -2492,12 +2492,9 @@ static dma_cookie_t pl330_tx_submit(struct dma_async_tx_descriptor *tx) · 2491 unmodified lines | ||
| 2492 | 2492 | |
| 2493 | 2493 | static inline void _init_desc(struct dma_pl330_desc *desc) |
| 2494 | 2494 | { |
| 2495 | − desc->pchan = NULL; | |
| 2496 | 2495 | desc->req.x = &desc->px; |
| 2497 | 2496 | desc->req.token = desc; |
| 2498 | 2497 | desc->rqcfg.swap = SWAP_NO; |
| 2499 | − desc->rqcfg.privileged = 0; | |
| 2500 | − desc->rqcfg.insnaccess = 0; | |
| 2501 | 2498 | desc->rqcfg.scctl = SCCTRL0; |
| 2502 | 2499 | desc->rqcfg.dcctl = DCCTRL0; |
| 2503 | 2500 | desc->req.cfg = &desc->rqcfg; |
| @@ -2517,7 +2514,7 @@ static int add_desc(struct dma_pl330_dmac *pdmac, gfp_t flg, int count) · 13 unmodified lines | ||
| 2517 | 2514 | if (!pdmac) |
| 2518 | 2515 | return 0; |
| 2519 | 2516 | |
| 2520 | − desc = kmalloc(count * sizeof(*desc), flg); | |
| 2517 | + desc = kcalloc(count, sizeof(*desc), flg); | |
| 2521 | 2518 | if (!desc) |
| 2522 | 2519 | return 0; |
| 2523 | 2520 | |
| @@ -532,29 +532,6 @@ static void ppc440spe_desc_init_memcpy(struct ppc440spe_adma_desc_slot *desc, · 531 unmodified lines | ||
| 532 | 532 | hw_desc->opc = DMA_CDB_OPC_MV_SG1_SG2; |
| 533 | 533 | } |
| 534 | 534 | |
| 535 | −/** | |
| 536 | − * ppc440spe_desc_init_memset - initialize the descriptor for MEMSET operation | |
| 537 | − */ | |
| 538 | −static void ppc440spe_desc_init_memset(struct ppc440spe_adma_desc_slot *desc, | |
| 539 | − int value, unsigned long flags) | |
| 540 | −{ | |
| 541 | − struct dma_cdb *hw_desc = desc->hw_desc; | |
| 542 | − | |
| 543 | − memset(desc->hw_desc, 0, sizeof(struct dma_cdb)); | |
| 544 | − desc->hw_next = NULL; | |
| 545 | − desc->src_cnt = 1; | |
| 546 | − desc->dst_cnt = 1; | |
| 547 | − | |
| 548 | − if (flags & DMA_PREP_INTERRUPT) | |
| 549 | − set_bit(PPC440SPE_DESC_INT, &desc->flags); | |
| 550 | − else | |
| 551 | − clear_bit(PPC440SPE_DESC_INT, &desc->flags); | |
| 552 | − | |
| 553 | − hw_desc->sg1u = hw_desc->sg1l = cpu_to_le32((u32)value); | |
| 554 | − hw_desc->sg3u = hw_desc->sg3l = cpu_to_le32((u32)value); | |
| 555 | − hw_desc->opc = DMA_CDB_OPC_DFILL128; | |
| 556 | −} | |
| 557 | − | |
| 558 | 535 | /** |
| 559 | 536 | * ppc440spe_desc_set_src_addr - set source address into the descriptor |
| 560 | 537 | */ |
| @@ -1504,8 +1481,6 @@ static dma_cookie_t ppc440spe_adma_run_tx_complete_actions( · 943 unmodified lines | ||
| 1504 | 1481 | struct ppc440spe_adma_chan *chan, |
| 1505 | 1482 | dma_cookie_t cookie) |
| 1506 | 1483 | { |
| 1507 | − int i; | |
| 1508 | − | |
| 1509 | 1484 | BUG_ON(desc->async_tx.cookie < 0); |
| 1510 | 1485 | if (desc->async_tx.cookie > 0) { |
| 1511 | 1486 | cookie = desc->async_tx.cookie; |
| @@ -3898,7 +3873,7 @@ static void ppc440spe_adma_init_capabilities(struct ppc440spe_adma_device *adev) · 2386 unmodified lines | ||
| 3898 | 3873 | ppc440spe_adma_prep_dma_interrupt; |
| 3899 | 3874 | } |
| 3900 | 3875 | pr_info("%s: AMCC(R) PPC440SP(E) ADMA Engine: " |
| 3901 | − "( %s%s%s%s%s%s%s)\n", | |
| 3876 | + "( %s%s%s%s%s%s)\n", | |
| 3902 | 3877 | dev_name(adev->dev), |
| 3903 | 3878 | dma_has_cap(DMA_PQ, adev->common.cap_mask) ? "pq " : "", |
| 3904 | 3879 | dma_has_cap(DMA_PQ_VAL, adev->common.cap_mask) ? "pq_val " : "", |
| @@ -406,7 +406,6 @@ txx9dmac_descriptor_complete(struct txx9dmac_chan *dc, · 405 unmodified lines | ||
| 406 | 406 | dma_async_tx_callback callback; |
| 407 | 407 | void *param; |
| 408 | 408 | struct dma_async_tx_descriptor *txd = &desc->txd; |
| 409 | − struct txx9dmac_slave *ds = dc->chan.private; | |
| 410 | 409 | |
| 411 | 410 | dev_vdbg(chan2dev(&dc->chan), "descriptor %u %p complete\n", |
| 412 | 411 | txd->cookie, desc); |
| @@ -1623,7 +1623,6 @@ static struct scsi_host_template scsi_driver_template = { · 1622 unmodified lines | ||
| 1623 | 1623 | .cmd_per_lun = 1, |
| 1624 | 1624 | .can_queue = 1, |
| 1625 | 1625 | .sdev_attrs = sbp2_scsi_sysfs_attrs, |
| 1626 | − .no_write_same = 1, | |
| 1627 | 1626 | }; |
| 1628 | 1627 | |
| 1629 | 1628 | MODULE_AUTHOR("Kristian Hoegsberg <krh@bitplanet.net>"); |
| @@ -14,3 +14,4 @@ obj-$(CONFIG_FIRMWARE_MEMMAP) += memmap.o · 13 unmodified lines | ||
| 14 | 14 | |
| 15 | 15 | obj-$(CONFIG_GOOGLE_FIRMWARE) += google/ |
| 16 | 16 | obj-$(CONFIG_EFI) += efi/ |
| 17 | +obj-$(CONFIG_UEFI_CPER) += efi/ | |
| @@ -36,7 +36,7 @@ config EFI_VARS_PSTORE_DEFAULT_DISABLE · 35 unmodified lines | ||
| 36 | 36 | backend for pstore by default. This setting can be overridden |
| 37 | 37 | using the efivars module's pstore_disable parameter. |
| 38 | 38 | |
| 39 | −config UEFI_CPER | |
| 40 | − def_bool n | |
| 41 | − | |
| 42 | 39 | endmenu |
| 40 | + | |
| 41 | +config UEFI_CPER | |
| 42 | + bool | |
| @@ -1,7 +1,7 @@ | ||
| 1 | 1 | # |
| 2 | 2 | # Makefile for linux kernel |
| 3 | 3 | # |
| 4 | −obj-y += efi.o vars.o | |
| 4 | +obj-$(CONFIG_EFI) += efi.o vars.o | |
| 5 | 5 | obj-$(CONFIG_EFI_VARS) += efivars.o |
| 6 | 6 | obj-$(CONFIG_EFI_VARS_PSTORE) += efi-pstore.o |
| 7 | 7 | obj-$(CONFIG_UEFI_CPER) += cper.o |
| @@ -356,6 +356,7 @@ static int efi_pstore_erase(enum pstore_type_id type, u64 id, int count, · 355 unmodified lines | ||
| 356 | 356 | static struct pstore_info efi_pstore_info = { |
| 357 | 357 | .owner = THIS_MODULE, |
| 358 | 358 | .name = "efi", |
| 359 | + .flags = PSTORE_FLAGS_FRAGILE, | |
| 359 | 360 | .open = efi_pstore_open, |
| 360 | 361 | .close = efi_pstore_close, |
| 361 | 362 | .read = efi_pstore_read, |
| @@ -252,7 +252,7 @@ static void msm_gpio_irq_mask(struct irq_data *d) · 251 unmodified lines | ||
| 252 | 252 | |
| 253 | 253 | spin_lock_irqsave(&tlmm_lock, irq_flags); |
| 254 | 254 | writel(TARGET_PROC_NONE, GPIO_INTR_CFG_SU(gpio)); |
| 255 | − clear_gpio_bits(INTR_RAW_STATUS_EN | INTR_ENABLE, GPIO_INTR_CFG(gpio)); | |
| 255 | + clear_gpio_bits(BIT(INTR_RAW_STATUS_EN) | BIT(INTR_ENABLE), GPIO_INTR_CFG(gpio)); | |
| 256 | 256 | __clear_bit(gpio, msm_gpio.enabled_irqs); |
| 257 | 257 | spin_unlock_irqrestore(&tlmm_lock, irq_flags); |
| 258 | 258 | } |
| @@ -264,7 +264,7 @@ static void msm_gpio_irq_unmask(struct irq_data *d) · 5 unmodified lines | ||
| 264 | 264 | |
| 265 | 265 | spin_lock_irqsave(&tlmm_lock, irq_flags); |
| 266 | 266 | __set_bit(gpio, msm_gpio.enabled_irqs); |
| 267 | − set_gpio_bits(INTR_RAW_STATUS_EN | INTR_ENABLE, GPIO_INTR_CFG(gpio)); | |
| 267 | + set_gpio_bits(BIT(INTR_RAW_STATUS_EN) | BIT(INTR_ENABLE), GPIO_INTR_CFG(gpio)); | |
| 268 | 268 | writel(TARGET_PROC_SCORPION, GPIO_INTR_CFG_SU(gpio)); |
| 269 | 269 | spin_unlock_irqrestore(&tlmm_lock, irq_flags); |
| 270 | 270 | } |
| @@ -169,7 +169,8 @@ static irqreturn_t gpio_rcar_irq_handler(int irq, void *dev_id) · 168 unmodified lines | ||
| 169 | 169 | u32 pending; |
| 170 | 170 | unsigned int offset, irqs_handled = 0; |
| 171 | 171 | |
| 172 | − while ((pending = gpio_rcar_read(p, INTDT))) { | |
| 172 | + while ((pending = gpio_rcar_read(p, INTDT) & | |
| 173 | + gpio_rcar_read(p, INTMSK))) { | |
| 173 | 174 | offset = __ffs(pending); |
| 174 | 175 | gpio_rcar_write(p, INTCLR, BIT(offset)); |
| 175 | 176 | generic_handle_irq(irq_find_mapping(p->irq_domain, offset)); |
| @@ -300,7 +300,7 @@ static int twl_direction_in(struct gpio_chip *chip, unsigned offset) · 299 unmodified lines | ||
| 300 | 300 | if (offset < TWL4030_GPIO_MAX) |
| 301 | 301 | ret = twl4030_set_gpio_direction(offset, 1); |
| 302 | 302 | else |
| 303 | − ret = -EINVAL; | |
| 303 | + ret = -EINVAL; /* LED outputs can't be set as input */ | |
| 304 | 304 | |
| 305 | 305 | if (!ret) |
| 306 | 306 | priv->direction &= ~BIT(offset); |
| @@ -354,11 +354,20 @@ static void twl_set(struct gpio_chip *chip, unsigned offset, int value) · 47 unmodified lines | ||
| 354 | 354 | static int twl_direction_out(struct gpio_chip *chip, unsigned offset, int value) |
| 355 | 355 | { |
| 356 | 356 | struct gpio_twl4030_priv *priv = to_gpio_twl4030(chip); |
| 357 | − int ret = -EINVAL; | |
| 357 | + int ret = 0; | |
| 358 | 358 | |
| 359 | 359 | mutex_lock(&priv->mutex); |
| 360 | − if (offset < TWL4030_GPIO_MAX) | |
| 360 | + if (offset < TWL4030_GPIO_MAX) { | |
| 361 | 361 | ret = twl4030_set_gpio_direction(offset, 0); |
| 362 | + if (ret) { | |
| 363 | + mutex_unlock(&priv->mutex); | |
| 364 | + return ret; | |
| 365 | + } | |
| 366 | + } | |
| 367 | + | |
| 368 | + /* | |
| 369 | + * LED gpios i.e. offset >= TWL4030_GPIO_MAX are always output | |
| 370 | + */ | |
| 362 | 371 | |
| 363 | 372 | priv->direction |= BIT(offset); |
| 364 | 373 | mutex_unlock(&priv->mutex); |
| @@ -103,6 +103,7 @@ void armada_drm_queue_unref_work(struct drm_device *, · 102 unmodified lines | ||
| 103 | 103 | extern const struct drm_mode_config_funcs armada_drm_mode_config_funcs; |
| 104 | 104 | |
| 105 | 105 | int armada_fbdev_init(struct drm_device *); |
| 106 | +void armada_fbdev_lastclose(struct drm_device *); | |
| 106 | 107 | void armada_fbdev_fini(struct drm_device *); |
| 107 | 108 | |
| 108 | 109 | int armada_overlay_plane_create(struct drm_device *, unsigned long); |
| @@ -321,6 +321,11 @@ static struct drm_ioctl_desc armada_ioctls[] = { · 320 unmodified lines | ||
| 321 | 321 | DRM_UNLOCKED), |
| 322 | 322 | }; |
| 323 | 323 | |
| 324 | +static void armada_drm_lastclose(struct drm_device *dev) | |
| 325 | +{ | |
| 326 | + armada_fbdev_lastclose(dev); | |
| 327 | +} | |
| 328 | + | |
| 324 | 329 | static const struct file_operations armada_drm_fops = { |
| 325 | 330 | .owner = THIS_MODULE, |
| 326 | 331 | .llseek = no_llseek, |
| @@ -337,7 +342,7 @@ static struct drm_driver armada_drm_driver = { · 10 unmodified lines | ||
| 337 | 342 | .open = NULL, |
| 338 | 343 | .preclose = NULL, |
| 339 | 344 | .postclose = NULL, |
| 340 | − .lastclose = NULL, | |
| 345 | + .lastclose = armada_drm_lastclose, | |
| 341 | 346 | .unload = armada_drm_unload, |
| 342 | 347 | .get_vblank_counter = drm_vblank_count, |
| 343 | 348 | .enable_vblank = armada_drm_enable_vblank, |
| @@ -105,9 +105,9 @@ static int armada_fb_create(struct drm_fb_helper *fbh, · 104 unmodified lines | ||
| 105 | 105 | drm_fb_helper_fill_fix(info, dfb->fb.pitches[0], dfb->fb.depth); |
| 106 | 106 | drm_fb_helper_fill_var(info, fbh, sizes->fb_width, sizes->fb_height); |
| 107 | 107 | |
| 108 | − DRM_DEBUG_KMS("allocated %dx%d %dbpp fb: 0x%08x\n", | |
| 109 | − dfb->fb.width, dfb->fb.height, | |
| 110 | − dfb->fb.bits_per_pixel, obj->phys_addr); | |
| 108 | + DRM_DEBUG_KMS("allocated %dx%d %dbpp fb: 0x%08llx\n", | |
| 109 | + dfb->fb.width, dfb->fb.height, dfb->fb.bits_per_pixel, | |
| 110 | + (unsigned long long)obj->phys_addr); | |
| 111 | 111 | |
| 112 | 112 | return 0; |
| 113 | 113 | |
| @@ -177,6 +177,16 @@ int armada_fbdev_init(struct drm_device *dev) · 63 unmodified lines | ||
| 177 | 177 | return ret; |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | +void armada_fbdev_lastclose(struct drm_device *dev) | |
| 181 | +{ | |
| 182 | + struct armada_private *priv = dev->dev_private; | |
| 183 | + | |
| 184 | + drm_modeset_lock_all(dev); | |
| 185 | + if (priv->fbdev) | |
| 186 | + drm_fb_helper_restore_fbdev_mode(priv->fbdev); | |
| 187 | + drm_modeset_unlock_all(dev); | |
| 188 | +} | |
| 189 | + | |
| 180 | 190 | void armada_fbdev_fini(struct drm_device *dev) |
| 181 | 191 | { |
| 182 | 192 | struct armada_private *priv = dev->dev_private; |
| @@ -192,11 +202,11 @@ void armada_fbdev_fini(struct drm_device *dev) · 9 unmodified lines | ||
| 192 | 202 | framebuffer_release(info); |
| 193 | 203 | } |
| 194 | 204 | |
| 205 | + drm_fb_helper_fini(fbh); | |
| 206 | + | |
| 195 | 207 | if (fbh->fb) |
| 196 | 208 | fbh->fb->funcs->destroy(fbh->fb); |
| 197 | 209 | |
| 198 | − drm_fb_helper_fini(fbh); | |
| 199 | − | |
| 200 | 210 | priv->fbdev = NULL; |
| 201 | 211 | } |
| 202 | 212 | } |
| @@ -172,8 +172,9 @@ armada_gem_linear_back(struct drm_device *dev, struct armada_gem_object *obj) · 171 unmodified lines | ||
| 172 | 172 | obj->dev_addr = obj->linear->start; |
| 173 | 173 | } |
| 174 | 174 | |
| 175 | − DRM_DEBUG_DRIVER("obj %p phys %#x dev %#x\n", | |
| 176 | − obj, obj->phys_addr, obj->dev_addr); | |
| 175 | + DRM_DEBUG_DRIVER("obj %p phys %#llx dev %#llx\n", obj, | |
| 176 | + (unsigned long long)obj->phys_addr, | |
| 177 | + (unsigned long long)obj->dev_addr); | |
| 177 | 178 | |
| 178 | 179 | return 0; |
| 179 | 180 | } |
| @@ -557,7 +558,6 @@ armada_gem_prime_import(struct drm_device *dev, struct dma_buf *buf) · 377 unmodified lines | ||
| 557 | 558 | * refcount on the gem object itself. |
| 558 | 559 | */ |
| 559 | 560 | drm_gem_object_reference(obj); |
| 560 | − dma_buf_put(buf); | |
| 561 | 561 | return obj; |
| 562 | 562 | } |
| 563 | 563 | } |
| @@ -573,6 +573,7 @@ armada_gem_prime_import(struct drm_device *dev, struct dma_buf *buf) · 9 unmodified lines | ||
| 573 | 573 | } |
| 574 | 574 | |
| 575 | 575 | dobj->obj.import_attach = attach; |
| 576 | + get_dma_buf(buf); | |
| 576 | 577 | |
| 577 | 578 | /* |
| 578 | 579 | * Don't call dma_buf_map_attachment() here - it maps the |
| @@ -68,6 +68,8 @@ · 67 unmodified lines | ||
| 68 | 68 | #define EDID_QUIRK_DETAILED_SYNC_PP (1 << 6) |
| 69 | 69 | /* Force reduced-blanking timings for detailed modes */ |
| 70 | 70 | #define EDID_QUIRK_FORCE_REDUCED_BLANKING (1 << 7) |
| 71 | +/* Force 8bpc */ | |
| 72 | +#define EDID_QUIRK_FORCE_8BPC (1 << 8) | |
| 71 | 73 | |
| 72 | 74 | struct detailed_mode_closure { |
| 73 | 75 | struct drm_connector *connector; |
| @@ -128,6 +130,9 @@ static struct edid_quirk { · 54 unmodified lines | ||
| 128 | 130 | |
| 129 | 131 | /* Medion MD 30217 PG */ |
| 130 | 132 | { "MED", 0x7b8, EDID_QUIRK_PREFER_LARGE_75 }, |
| 133 | + | |
| 134 | + /* Panel in Samsung NP700G7A-S01PL notebook reports 6bpc */ | |
| 135 | + { "SEC", 0xd033, EDID_QUIRK_FORCE_8BPC }, | |
| 131 | 136 | }; |
| 132 | 137 | |
| 133 | 138 | /* |
| @@ -3435,6 +3440,9 @@ int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid) · 3301 unmodified lines | ||
| 3435 | 3440 | |
| 3436 | 3441 | drm_add_display_info(edid, &connector->display_info); |
| 3437 | 3442 | |
| 3443 | + if (quirks & EDID_QUIRK_FORCE_8BPC) | |
| 3444 | + connector->display_info.bpc = 8; | |
| 3445 | + | |
| 3438 | 3446 | return num_modes; |
| 3439 | 3447 | } |
| 3440 | 3448 | EXPORT_SYMBOL(drm_add_edid_modes); |
| @@ -566,11 +566,11 @@ err_unload: · 565 unmodified lines | ||
| 566 | 566 | if (dev->driver->unload) |
| 567 | 567 | dev->driver->unload(dev); |
| 568 | 568 | err_primary_node: |
| 569 | − drm_put_minor(dev->primary); | |
| 569 | + drm_unplug_minor(dev->primary); | |
| 570 | 570 | err_render_node: |
| 571 | − drm_put_minor(dev->render); | |
| 571 | + drm_unplug_minor(dev->render); | |
| 572 | 572 | err_control_node: |
| 573 | − drm_put_minor(dev->control); | |
| 573 | + drm_unplug_minor(dev->control); | |
| 574 | 574 | err_agp: |
| 575 | 575 | if (dev->driver->bus->agp_destroy) |
| 576 | 576 | dev->driver->bus->agp_destroy(dev); |
| @@ -83,6 +83,14 @@ void i915_update_dri1_breadcrumb(struct drm_device *dev) · 82 unmodified lines | ||
| 83 | 83 | drm_i915_private_t *dev_priv = dev->dev_private; |
| 84 | 84 | struct drm_i915_master_private *master_priv; |
| 85 | 85 | |
| 86 | + /* | |
| 87 | + * The dri breadcrumb update races against the drm master disappearing. | |
| 88 | + * Instead of trying to fix this (this is by far not the only ums issue) | |
| 89 | + * just don't do the update in kms mode. | |
| 90 | + */ | |
| 91 | + if (drm_core_check_feature(dev, DRIVER_MODESET)) | |
| 92 | + return; | |
| 93 | + | |
| 86 | 94 | if (dev->primary->master) { |
| 87 | 95 | master_priv = dev->primary->master->driver_priv; |
| 88 | 96 | if (master_priv->sarea_priv) |
| @@ -1490,16 +1498,9 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags) · 1401 unmodified lines | ||
| 1490 | 1498 | spin_lock_init(&dev_priv->uncore.lock); |
| 1491 | 1499 | spin_lock_init(&dev_priv->mm.object_stat_lock); |
| 1492 | 1500 | mutex_init(&dev_priv->dpio_lock); |
| 1493 | − mutex_init(&dev_priv->rps.hw_lock); | |
| 1494 | 1501 | mutex_init(&dev_priv->modeset_restore_lock); |
| 1495 | 1502 | |
| 1496 | − mutex_init(&dev_priv->pc8.lock); | |
| 1497 | − dev_priv->pc8.requirements_met = false; | |
| 1498 | − dev_priv->pc8.gpu_idle = false; | |
| 1499 | − dev_priv->pc8.irqs_disabled = false; | |
| 1500 | − dev_priv->pc8.enabled = false; | |
| 1501 | − dev_priv->pc8.disable_count = 2; /* requirements_met + gpu_idle */ | |
| 1502 | − INIT_DELAYED_WORK(&dev_priv->pc8.enable_work, hsw_enable_pc8_work); | |
| 1503 | + intel_pm_setup(dev); | |
| 1503 | 1504 | |
| 1504 | 1505 | intel_display_crc_init(dev); |
| 1505 | 1506 | |
| @@ -1603,7 +1604,6 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags) · 97 unmodified lines | ||
| 1603 | 1604 | } |
| 1604 | 1605 | |
| 1605 | 1606 | intel_irq_init(dev); |
| 1606 | − intel_pm_init(dev); | |
| 1607 | 1607 | intel_uncore_sanitize(dev); |
| 1608 | 1608 | |
| 1609 | 1609 | /* Try to make sure MCHBAR is enabled before poking at it */ |
| @@ -1848,8 +1848,10 @@ void i915_driver_lastclose(struct drm_device * dev) · 238 unmodified lines | ||
| 1848 | 1848 | |
| 1849 | 1849 | void i915_driver_preclose(struct drm_device * dev, struct drm_file *file_priv) |
| 1850 | 1850 | { |
| 1851 | + mutex_lock(&dev->struct_mutex); | |
| 1851 | 1852 | i915_gem_context_close(dev, file_priv); |
| 1852 | 1853 | i915_gem_release(dev, file_priv); |
| 1854 | + mutex_unlock(&dev->struct_mutex); | |
| 1853 | 1855 | } |
| 1854 | 1856 | |
| 1855 | 1857 | void i915_driver_postclose(struct drm_device *dev, struct drm_file *file) |
| @@ -651,6 +651,7 @@ static int __i915_drm_thaw(struct drm_device *dev, bool restore_gtt_mappings) · 650 unmodified lines | ||
| 651 | 651 | intel_modeset_init_hw(dev); |
| 652 | 652 | |
| 653 | 653 | drm_modeset_lock_all(dev); |
| 654 | + drm_mode_config_reset(dev); | |
| 654 | 655 | intel_modeset_setup_hw_state(dev, true); |
| 655 | 656 | drm_modeset_unlock_all(dev); |
| 656 | 657 | |
| @@ -1755,8 +1755,13 @@ struct drm_i915_file_private { · 1754 unmodified lines | ||
| 1755 | 1755 | #define IS_MOBILE(dev) (INTEL_INFO(dev)->is_mobile) |
| 1756 | 1756 | #define IS_HSW_EARLY_SDV(dev) (IS_HASWELL(dev) && \ |
| 1757 | 1757 | ((dev)->pdev->device & 0xFF00) == 0x0C00) |
| 1758 | −#define IS_ULT(dev) (IS_HASWELL(dev) && \ | |
| 1758 | +#define IS_BDW_ULT(dev) (IS_BROADWELL(dev) && \ | |
| 1759 | + (((dev)->pdev->device & 0xf) == 0x2 || \ | |
| 1760 | + ((dev)->pdev->device & 0xf) == 0x6 || \ | |
| 1761 | + ((dev)->pdev->device & 0xf) == 0xe)) | |
| 1762 | +#define IS_HSW_ULT(dev) (IS_HASWELL(dev) && \ | |
| 1759 | 1763 | ((dev)->pdev->device & 0xFF00) == 0x0A00) |
| 1764 | +#define IS_ULT(dev) (IS_HSW_ULT(dev) || IS_BDW_ULT(dev)) | |
| 1760 | 1765 | #define IS_HSW_GT3(dev) (IS_HASWELL(dev) && \ |
| 1761 | 1766 | ((dev)->pdev->device & 0x00F0) == 0x0020) |
| 1762 | 1767 | #define IS_PRELIMINARY_HW(intel_info) ((intel_info)->is_preliminary) |
| @@ -1901,9 +1906,7 @@ void i915_queue_hangcheck(struct drm_device *dev); · 138 unmodified lines | ||
| 1901 | 1906 | void i915_handle_error(struct drm_device *dev, bool wedged); |
| 1902 | 1907 | |
| 1903 | 1908 | extern void intel_irq_init(struct drm_device *dev); |
| 1904 | −extern void intel_pm_init(struct drm_device *dev); | |
| 1905 | 1909 | extern void intel_hpd_init(struct drm_device *dev); |
| 1906 | −extern void intel_pm_init(struct drm_device *dev); | |
| 1907 | 1910 | |
| 1908 | 1911 | extern void intel_uncore_sanitize(struct drm_device *dev); |
| 1909 | 1912 | extern void intel_uncore_early_sanitize(struct drm_device *dev); |
| @@ -2343,15 +2343,24 @@ static void i915_gem_free_request(struct drm_i915_gem_request *request) · 2342 unmodified lines | ||
| 2343 | 2343 | kfree(request); |
| 2344 | 2344 | } |
| 2345 | 2345 | |
| 2346 | −static void i915_gem_reset_ring_lists(struct drm_i915_private *dev_priv, | |
| 2347 | − struct intel_ring_buffer *ring) | |
| 2346 | +static void i915_gem_reset_ring_status(struct drm_i915_private *dev_priv, | |
| 2347 | + struct intel_ring_buffer *ring) | |
| 2348 | 2348 | { |
| 2349 | − u32 completed_seqno; | |
| 2350 | − u32 acthd; | |
| 2349 | + u32 completed_seqno = ring->get_seqno(ring, false); | |
| 2350 | + u32 acthd = intel_ring_get_active_head(ring); | |
| 2351 | + struct drm_i915_gem_request *request; | |
| 2352 | + | |
| 2353 | + list_for_each_entry(request, &ring->request_list, list) { | |
| 2354 | + if (i915_seqno_passed(completed_seqno, request->seqno)) | |
| 2355 | + continue; | |
| 2351 | 2356 | |
| 2352 | − acthd = intel_ring_get_active_head(ring); | |
| 2353 | − completed_seqno = ring->get_seqno(ring, false); | |
| 2357 | + i915_set_reset_status(ring, request, acthd); | |
| 2358 | + } | |
| 2359 | +} | |
| 2354 | 2360 | |
| 2361 | +static void i915_gem_reset_ring_cleanup(struct drm_i915_private *dev_priv, | |
| 2362 | + struct intel_ring_buffer *ring) | |
| 2363 | +{ | |
| 2355 | 2364 | while (!list_empty(&ring->request_list)) { |
| 2356 | 2365 | struct drm_i915_gem_request *request; |
| 2357 | 2366 | |
| @@ -2359,9 +2368,6 @@ static void i915_gem_reset_ring_lists(struct drm_i915_private *dev_priv, · 1 unmodified line | ||
| 2359 | 2368 | struct drm_i915_gem_request, |
| 2360 | 2369 | list); |
| 2361 | 2370 | |
| 2362 | − if (request->seqno > completed_seqno) | |
| 2363 | − i915_set_reset_status(ring, request, acthd); | |
| 2364 | − | |
| 2365 | 2371 | i915_gem_free_request(request); |
| 2366 | 2372 | } |
| 2367 | 2373 | |
| @@ -2403,8 +2409,16 @@ void i915_gem_reset(struct drm_device *dev) · 35 unmodified lines | ||
| 2403 | 2409 | struct intel_ring_buffer *ring; |
| 2404 | 2410 | int i; |
| 2405 | 2411 | |
| 2412 | + /* | |
| 2413 | + * Before we free the objects from the requests, we need to inspect | |
| 2414 | + * them for finding the guilty party. As the requests only borrow | |
| 2415 | + * their reference to the objects, the inspection must be done first. | |
| 2416 | + */ | |
| 2417 | + for_each_ring(ring, dev_priv, i) | |
| 2418 | + i915_gem_reset_ring_status(dev_priv, ring); | |
| 2419 | + | |
| 2406 | 2420 | for_each_ring(ring, dev_priv, i) |
| 2407 | − i915_gem_reset_ring_lists(dev_priv, ring); | |
| 2421 | + i915_gem_reset_ring_cleanup(dev_priv, ring); | |
| 2408 | 2422 | |
| 2409 | 2423 | i915_gem_cleanup_ringbuffer(dev); |
| 2410 | 2424 | |
| @@ -347,10 +347,8 @@ void i915_gem_context_close(struct drm_device *dev, struct drm_file *file) · 346 unmodified lines | ||
| 347 | 347 | { |
| 348 | 348 | struct drm_i915_file_private *file_priv = file->driver_priv; |
| 349 | 349 | |
| 350 | − mutex_lock(&dev->struct_mutex); | |
| 351 | 350 | idr_for_each(&file_priv->context_idr, context_idr_cleanup, NULL); |
| 352 | 351 | idr_destroy(&file_priv->context_idr); |
| 353 | − mutex_unlock(&dev->struct_mutex); | |
| 354 | 352 | } |
| 355 | 353 | |
| 356 | 354 | static struct i915_hw_context * |
| @@ -423,11 +421,21 @@ static int do_switch(struct i915_hw_context *to) · 66 unmodified lines | ||
| 423 | 421 | if (ret) |
| 424 | 422 | return ret; |
| 425 | 423 | |
| 426 | − /* Clear this page out of any CPU caches for coherent swap-in/out. Note | |
| 424 | + /* | |
| 425 | + * Pin can switch back to the default context if we end up calling into | |
| 426 | + * evict_everything - as a last ditch gtt defrag effort that also | |
| 427 | + * switches to the default context. Hence we need to reload from here. | |
| 428 | + */ | |
| 429 | + from = ring->last_context; | |
| 430 | + | |
| 431 | + /* | |
| 432 | + * Clear this page out of any CPU caches for coherent swap-in/out. Note | |
| 427 | 433 | * that thanks to write = false in this call and us not setting any gpu |
| 428 | 434 | * write domains when putting a context object onto the active list |
| 429 | 435 | * (when switching away from it), this won't block. |
| 430 | − * XXX: We need a real interface to do this instead of trickery. */ | |
| 436 | + * | |
| 437 | + * XXX: We need a real interface to do this instead of trickery. | |
| 438 | + */ | |
| 431 | 439 | ret = i915_gem_object_set_to_gtt_domain(to->obj, false); |
| 432 | 440 | if (ret) { |
| 433 | 441 | i915_gem_object_unpin(to->obj); |
| @@ -88,6 +88,7 @@ i915_gem_evict_something(struct drm_device *dev, struct i915_address_space *vm, · 87 unmodified lines | ||
| 88 | 88 | } else |
| 89 | 89 | drm_mm_init_scan(&vm->mm, min_size, alignment, cache_level); |
| 90 | 90 | |
| 91 | +search_again: | |
| 91 | 92 | /* First see if there is a large enough contiguous idle region... */ |
| 92 | 93 | list_for_each_entry(vma, &vm->inactive_list, mm_list) { |
| 93 | 94 | if (mark_free(vma, &unwind_list)) |
| @@ -115,10 +116,17 @@ none: · 21 unmodified lines | ||
| 115 | 116 | list_del_init(&vma->exec_list); |
| 116 | 117 | } |
| 117 | 118 | |
| 118 | − /* We expect the caller to unpin, evict all and try again, or give up. | |
| 119 | − * So calling i915_gem_evict_vm() is unnecessary. | |
| 119 | + /* Can we unpin some objects such as idle hw contents, | |
| 120 | + * or pending flips? | |
| 120 | 121 | */ |
| 121 | − return -ENOSPC; | |
| 122 | + ret = nonblocking ? -ENOSPC : i915_gpu_idle(dev); | |
| 123 | + if (ret) | |
| 124 | + return ret; | |
| 125 | + | |
| 126 | + /* Only idle the GPU and repeat the search once */ | |
| 127 | + i915_gem_retire_requests(dev); | |
| 128 | + nonblocking = true; | |
| 129 | + goto search_again; | |
| 122 | 130 | |
| 123 | 131 | found: |
| 124 | 132 | /* drm_mm doesn't allow any other other operations while |
| @@ -93,7 +93,7 @@ eb_lookup_vmas(struct eb_vmas *eb, · 92 unmodified lines | ||
| 93 | 93 | { |
| 94 | 94 | struct drm_i915_gem_object *obj; |
| 95 | 95 | struct list_head objects; |
| 96 | − int i, ret = 0; | |
| 96 | + int i, ret; | |
| 97 | 97 | |
| 98 | 98 | INIT_LIST_HEAD(&objects); |
| 99 | 99 | spin_lock(&file->table_lock); |
| @@ -106,7 +106,7 @@ eb_lookup_vmas(struct eb_vmas *eb, · 6 unmodified lines | ||
| 106 | 106 | DRM_DEBUG("Invalid object handle %d at index %d\n", |
| 107 | 107 | exec[i].handle, i); |
| 108 | 108 | ret = -ENOENT; |
| 109 | − goto out; | |
| 109 | + goto err; | |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | if (!list_empty(&obj->obj_exec_link)) { |
| @@ -114,7 +114,7 @@ eb_lookup_vmas(struct eb_vmas *eb, · 1 unmodified line | ||
| 114 | 114 | DRM_DEBUG("Object %p [handle %d, index %d] appears more than once in object list\n", |
| 115 | 115 | obj, exec[i].handle, i); |
| 116 | 116 | ret = -EINVAL; |
| 117 | − goto out; | |
| 117 | + goto err; | |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | drm_gem_object_reference(&obj->base); |
| @@ -123,9 +123,13 @@ eb_lookup_vmas(struct eb_vmas *eb, · 2 unmodified lines | ||
| 123 | 123 | spin_unlock(&file->table_lock); |
| 124 | 124 | |
| 125 | 125 | i = 0; |
| 126 | − list_for_each_entry(obj, &objects, obj_exec_link) { | |
| 126 | + while (!list_empty(&objects)) { | |
| 127 | 127 | struct i915_vma *vma; |
| 128 | 128 | |
| 129 | + obj = list_first_entry(&objects, | |
| 130 | + struct drm_i915_gem_object, | |
| 131 | + obj_exec_link); | |
| 132 | + | |
| 129 | 133 | /* |
| 130 | 134 | * NOTE: We can leak any vmas created here when something fails |
| 131 | 135 | * later on. But that's no issue since vma_unbind can deal with |
| @@ -138,10 +142,12 @@ eb_lookup_vmas(struct eb_vmas *eb, · 6 unmodified lines | ||
| 138 | 142 | if (IS_ERR(vma)) { |
| 139 | 143 | DRM_DEBUG("Failed to lookup VMA\n"); |
| 140 | 144 | ret = PTR_ERR(vma); |
| 141 | − goto out; | |
| 145 | + goto err; | |
| 142 | 146 | } |
| 143 | 147 | |
| 148 | + /* Transfer ownership from the objects list to the vmas list. */ | |
| 144 | 149 | list_add_tail(&vma->exec_list, &eb->vmas); |
| 150 | + list_del_init(&obj->obj_exec_link); | |
| 145 | 151 | |
| 146 | 152 | vma->exec_entry = &exec[i]; |
| 147 | 153 | if (eb->and < 0) { |
| @@ -155,16 +161,22 @@ eb_lookup_vmas(struct eb_vmas *eb, · 7 unmodified lines | ||
| 155 | 161 | ++i; |
| 156 | 162 | } |
| 157 | 163 | |
| 164 | + return 0; | |
| 165 | + | |
| 158 | 166 | |
| 159 | −out: | |
| 167 | +err: | |
| 160 | 168 | while (!list_empty(&objects)) { |
| 161 | 169 | obj = list_first_entry(&objects, |
| 162 | 170 | struct drm_i915_gem_object, |
| 163 | 171 | obj_exec_link); |
| 164 | 172 | list_del_init(&obj->obj_exec_link); |
| 165 | − if (ret) | |
| 166 | − drm_gem_object_unreference(&obj->base); | |
| 173 | + drm_gem_object_unreference(&obj->base); | |
| 167 | 174 | } |
| 175 | + /* | |
| 176 | + * Objects already transfered to the vmas list will be unreferenced by | |
| 177 | + * eb_destroy. | |
| 178 | + */ | |
| 179 | + | |
| 168 | 180 | return ret; |
| 169 | 181 | } |
| 170 | 182 | |
| @@ -337,8 +337,8 @@ static void gen8_ppgtt_cleanup(struct i915_address_space *vm) · 336 unmodified lines | ||
| 337 | 337 | kfree(ppgtt->gen8_pt_dma_addr[i]); |
| 338 | 338 | } |
| 339 | 339 | |
| 340 | − __free_pages(ppgtt->gen8_pt_pages, ppgtt->num_pt_pages << PAGE_SHIFT); | |
| 341 | − __free_pages(ppgtt->pd_pages, ppgtt->num_pd_pages << PAGE_SHIFT); | |
| 340 | + __free_pages(ppgtt->gen8_pt_pages, get_order(ppgtt->num_pt_pages << PAGE_SHIFT)); | |
| 341 | + __free_pages(ppgtt->pd_pages, get_order(ppgtt->num_pd_pages << PAGE_SHIFT)); | |
| 342 | 342 | } |
| 343 | 343 | |
| 344 | 344 | /** |
| @@ -1241,6 +1241,11 @@ static inline unsigned int gen8_get_total_gtt_size(u16 bdw_gmch_ctl) · 896 unmodified lines | ||
| 1241 | 1241 | bdw_gmch_ctl &= BDW_GMCH_GGMS_MASK; |
| 1242 | 1242 | if (bdw_gmch_ctl) |
| 1243 | 1243 | bdw_gmch_ctl = 1 << bdw_gmch_ctl; |
| 1244 | + if (bdw_gmch_ctl > 4) { | |
| 1245 | + WARN_ON(!i915_preliminary_hw_support); | |
| 1246 | + return 4<<20; | |
| 1247 | + } | |
| 1248 | + | |
| 1244 | 1249 | return bdw_gmch_ctl << 20; |
| 1245 | 1250 | } |
| 1246 | 1251 | |
| @@ -6303,7 +6303,7 @@ static void assert_can_disable_lcpll(struct drm_i915_private *dev_priv) · 6302 unmodified lines | ||
| 6303 | 6303 | uint32_t val; |
| 6304 | 6304 | |
| 6305 | 6305 | list_for_each_entry(crtc, &dev->mode_config.crtc_list, base.head) |
| 6306 | − WARN(crtc->base.enabled, "CRTC for pipe %c enabled\n", | |
| 6306 | + WARN(crtc->active, "CRTC for pipe %c enabled\n", | |
| 6307 | 6307 | pipe_name(crtc->pipe)); |
| 6308 | 6308 | |
| 6309 | 6309 | WARN(I915_READ(HSW_PWR_WELL_DRIVER), "Power well on\n"); |
| @@ -9135,7 +9135,7 @@ intel_pipe_config_compare(struct drm_device *dev, · 2825 unmodified lines | ||
| 9135 | 9135 | if (IS_G4X(dev) || INTEL_INFO(dev)->gen >= 5) |
| 9136 | 9136 | PIPE_CONF_CHECK_I(pipe_bpp); |
| 9137 | 9137 | |
| 9138 | − if (!IS_HASWELL(dev)) { | |
| 9138 | + if (!HAS_DDI(dev)) { | |
| 9139 | 9139 | PIPE_CONF_CHECK_CLOCK_FUZZY(adjusted_mode.crtc_clock); |
| 9140 | 9140 | PIPE_CONF_CHECK_CLOCK_FUZZY(port_clock); |
| 9141 | 9141 | } |
| @@ -11036,8 +11036,6 @@ void intel_modeset_setup_hw_state(struct drm_device *dev, · 1894 unmodified lines | ||
| 11036 | 11036 | } |
| 11037 | 11037 | |
| 11038 | 11038 | intel_modeset_check_state(dev); |
| 11039 | − | |
| 11040 | − drm_mode_config_reset(dev); | |
| 11041 | 11039 | } |
| 11042 | 11040 | |
| 11043 | 11041 | void intel_modeset_gem_init(struct drm_device *dev) |
| @@ -11046,7 +11044,10 @@ void intel_modeset_gem_init(struct drm_device *dev) · 2 unmodified lines | ||
| 11046 | 11044 | |
| 11047 | 11045 | intel_setup_overlay(dev); |
| 11048 | 11046 | |
| 11047 | + drm_modeset_lock_all(dev); | |
| 11048 | + drm_mode_config_reset(dev); | |
| 11049 | 11049 | intel_modeset_setup_hw_state(dev, false); |
| 11050 | + drm_modeset_unlock_all(dev); | |
| 11050 | 11051 | } |
| 11051 | 11052 | |
| 11052 | 11053 | void intel_modeset_cleanup(struct drm_device *dev) |
| @@ -11125,14 +11126,15 @@ void intel_connector_attach_encoder(struct intel_connector *connector, · 72 unmodified lines | ||
| 11125 | 11126 | int intel_modeset_vga_set_state(struct drm_device *dev, bool state) |
| 11126 | 11127 | { |
| 11127 | 11128 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 11129 | + unsigned reg = INTEL_INFO(dev)->gen >= 6 ? SNB_GMCH_CTRL : INTEL_GMCH_CTRL; | |
| 11128 | 11130 | u16 gmch_ctrl; |
| 11129 | 11131 | |
| 11130 | − pci_read_config_word(dev_priv->bridge_dev, INTEL_GMCH_CTRL, &gmch_ctrl); | |
| 11132 | + pci_read_config_word(dev_priv->bridge_dev, reg, &gmch_ctrl); | |
| 11131 | 11133 | if (state) |
| 11132 | 11134 | gmch_ctrl &= ~INTEL_GMCH_VGA_DISABLE; |
| 11133 | 11135 | else |
| 11134 | 11136 | gmch_ctrl |= INTEL_GMCH_VGA_DISABLE; |
| 11135 | − pci_write_config_word(dev_priv->bridge_dev, INTEL_GMCH_CTRL, gmch_ctrl); | |
| 11137 | + pci_write_config_word(dev_priv->bridge_dev, reg, gmch_ctrl); | |
| 11136 | 11138 | return 0; |
| 11137 | 11139 | } |
| 11138 | 11140 | |
| @@ -821,6 +821,7 @@ void intel_update_sprite_watermarks(struct drm_plane *plane, · 820 unmodified lines | ||
| 821 | 821 | uint32_t sprite_width, int pixel_size, |
| 822 | 822 | bool enabled, bool scaled); |
| 823 | 823 | void intel_init_pm(struct drm_device *dev); |
| 824 | +void intel_pm_setup(struct drm_device *dev); | |
| 824 | 825 | bool intel_fbc_enabled(struct drm_device *dev); |
| 825 | 826 | void intel_update_fbc(struct drm_device *dev); |
| 826 | 827 | void intel_gpu_ips_init(struct drm_i915_private *dev_priv); |
| @@ -451,7 +451,9 @@ static u32 intel_panel_get_backlight(struct drm_device *dev, · 450 unmodified lines | ||
| 451 | 451 | |
| 452 | 452 | spin_lock_irqsave(&dev_priv->backlight.lock, flags); |
| 453 | 453 | |
| 454 | − if (HAS_PCH_SPLIT(dev)) { | |
| 454 | + if (IS_BROADWELL(dev)) { | |
| 455 | + val = I915_READ(BLC_PWM_PCH_CTL2) & BACKLIGHT_DUTY_CYCLE_MASK; | |
| 456 | + } else if (HAS_PCH_SPLIT(dev)) { | |
| 455 | 457 | val = I915_READ(BLC_PWM_CPU_CTL) & BACKLIGHT_DUTY_CYCLE_MASK; |
| 456 | 458 | } else { |
| 457 | 459 | if (IS_VALLEYVIEW(dev)) |
| @@ -479,6 +481,13 @@ static u32 intel_panel_get_backlight(struct drm_device *dev, · 21 unmodified lines | ||
| 479 | 481 | return val; |
| 480 | 482 | } |
| 481 | 483 | |
| 484 | +static void intel_bdw_panel_set_backlight(struct drm_device *dev, u32 level) | |
| 485 | +{ | |
| 486 | + struct drm_i915_private *dev_priv = dev->dev_private; | |
| 487 | + u32 val = I915_READ(BLC_PWM_PCH_CTL2) & ~BACKLIGHT_DUTY_CYCLE_MASK; | |
| 488 | + I915_WRITE(BLC_PWM_PCH_CTL2, val | level); | |
| 489 | +} | |
| 490 | + | |
| 482 | 491 | static void intel_pch_panel_set_backlight(struct drm_device *dev, u32 level) |
| 483 | 492 | { |
| 484 | 493 | struct drm_i915_private *dev_priv = dev->dev_private; |
| @@ -496,7 +505,9 @@ static void intel_panel_actually_set_backlight(struct drm_device *dev, · 11 unmodified lines | ||
| 496 | 505 | DRM_DEBUG_DRIVER("set backlight PWM = %d\n", level); |
| 497 | 506 | level = intel_panel_compute_brightness(dev, pipe, level); |
| 498 | 507 | |
| 499 | − if (HAS_PCH_SPLIT(dev)) | |
| 508 | + if (IS_BROADWELL(dev)) | |
| 509 | + return intel_bdw_panel_set_backlight(dev, level); | |
| 510 | + else if (HAS_PCH_SPLIT(dev)) | |
| 500 | 511 | return intel_pch_panel_set_backlight(dev, level); |
| 501 | 512 | |
| 502 | 513 | if (is_backlight_combination_mode(dev)) { |
| @@ -666,7 +677,16 @@ void intel_panel_enable_backlight(struct intel_connector *connector) · 163 unmodified lines | ||
| 666 | 677 | POSTING_READ(reg); |
| 667 | 678 | I915_WRITE(reg, tmp | BLM_PWM_ENABLE); |
| 668 | 679 | |
| 669 | − if (HAS_PCH_SPLIT(dev) && | |
| 680 | + if (IS_BROADWELL(dev)) { | |
| 681 | + /* | |
| 682 | + * Broadwell requires PCH override to drive the PCH | |
| 683 | + * backlight pin. The above will configure the CPU | |
| 684 | + * backlight pin, which we don't plan to use. | |
| 685 | + */ | |
| 686 | + tmp = I915_READ(BLC_PWM_PCH_CTL1); | |
| 687 | + tmp |= BLM_PCH_OVERRIDE_ENABLE | BLM_PCH_PWM_ENABLE; | |
| 688 | + I915_WRITE(BLC_PWM_PCH_CTL1, tmp); | |
| 689 | + } else if (HAS_PCH_SPLIT(dev) && | |
| 670 | 690 | !(dev_priv->quirks & QUIRK_NO_PCH_PWM_ENABLE)) { |
| 671 | 691 | tmp = I915_READ(BLC_PWM_PCH_CTL1); |
| 672 | 692 | tmp |= BLM_PCH_PWM_ENABLE; |
| @@ -5685,8 +5685,11 @@ static void __intel_set_power_well(struct drm_device *dev, bool enable) · 5684 unmodified lines | ||
| 5685 | 5685 | { |
| 5686 | 5686 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 5687 | 5687 | bool is_enabled, enable_requested; |
| 5688 | + unsigned long irqflags; | |
| 5688 | 5689 | uint32_t tmp; |
| 5689 | 5690 | |
| 5691 | + WARN_ON(dev_priv->pc8.enabled); | |
| 5692 | + | |
| 5690 | 5693 | tmp = I915_READ(HSW_PWR_WELL_DRIVER); |
| 5691 | 5694 | is_enabled = tmp & HSW_PWR_WELL_STATE_ENABLED; |
| 5692 | 5695 | enable_requested = tmp & HSW_PWR_WELL_ENABLE_REQUEST; |
| @@ -5702,9 +5705,24 @@ static void __intel_set_power_well(struct drm_device *dev, bool enable) · 9 unmodified lines | ||
| 5702 | 5705 | HSW_PWR_WELL_STATE_ENABLED), 20)) |
| 5703 | 5706 | DRM_ERROR("Timeout enabling power well\n"); |
| 5704 | 5707 | } |
| 5708 | + | |
| 5709 | + if (IS_BROADWELL(dev)) { | |
| 5710 | + spin_lock_irqsave(&dev_priv->irq_lock, irqflags); | |
| 5711 | + I915_WRITE(GEN8_DE_PIPE_IMR(PIPE_B), | |
| 5712 | + dev_priv->de_irq_mask[PIPE_B]); | |
| 5713 | + I915_WRITE(GEN8_DE_PIPE_IER(PIPE_B), | |
| 5714 | + ~dev_priv->de_irq_mask[PIPE_B] | | |
| 5715 | + GEN8_PIPE_VBLANK); | |
| 5716 | + I915_WRITE(GEN8_DE_PIPE_IMR(PIPE_C), | |
| 5717 | + dev_priv->de_irq_mask[PIPE_C]); | |
| 5718 | + I915_WRITE(GEN8_DE_PIPE_IER(PIPE_C), | |
| 5719 | + ~dev_priv->de_irq_mask[PIPE_C] | | |
| 5720 | + GEN8_PIPE_VBLANK); | |
| 5721 | + POSTING_READ(GEN8_DE_PIPE_IER(PIPE_C)); | |
| 5722 | + spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags); | |
| 5723 | + } | |
| 5705 | 5724 | } else { |
| 5706 | 5725 | if (enable_requested) { |
| 5707 | − unsigned long irqflags; | |
| 5708 | 5726 | enum pipe p; |
| 5709 | 5727 | |
| 5710 | 5728 | I915_WRITE(HSW_PWR_WELL_DRIVER, 0); |
| @@ -5731,16 +5749,24 @@ static void __intel_set_power_well(struct drm_device *dev, bool enable) · 20 unmodified lines | ||
| 5731 | 5749 | static void __intel_power_well_get(struct drm_device *dev, |
| 5732 | 5750 | struct i915_power_well *power_well) |
| 5733 | 5751 | { |
| 5734 | − if (!power_well->count++) | |
| 5752 | + struct drm_i915_private *dev_priv = dev->dev_private; | |
| 5753 | + | |
| 5754 | + if (!power_well->count++) { | |
| 5755 | + hsw_disable_package_c8(dev_priv); | |
| 5735 | 5756 | __intel_set_power_well(dev, true); |
| 5757 | + } | |
| 5736 | 5758 | } |
| 5737 | 5759 | |
| 5738 | 5760 | static void __intel_power_well_put(struct drm_device *dev, |
| 5739 | 5761 | struct i915_power_well *power_well) |
| 5740 | 5762 | { |
| 5763 | + struct drm_i915_private *dev_priv = dev->dev_private; | |
| 5764 | + | |
| 5741 | 5765 | WARN_ON(!power_well->count); |
| 5742 | − if (!--power_well->count && i915_disable_power_well) | |
| 5766 | + if (!--power_well->count && i915_disable_power_well) { | |
| 5743 | 5767 | __intel_set_power_well(dev, false); |
| 5768 | + hsw_enable_package_c8(dev_priv); | |
| 5769 | + } | |
| 5744 | 5770 | } |
| 5745 | 5771 | |
| 5746 | 5772 | void intel_display_power_get(struct drm_device *dev, |
| @@ -6130,10 +6156,19 @@ int vlv_freq_opcode(int ddr_freq, int val) · 383 unmodified lines | ||
| 6130 | 6156 | return val; |
| 6131 | 6157 | } |
| 6132 | 6158 | |
| 6133 | −void intel_pm_init(struct drm_device *dev) | |
| 6159 | +void intel_pm_setup(struct drm_device *dev) | |
| 6134 | 6160 | { |
| 6135 | 6161 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 6136 | 6162 | |
| 6163 | + mutex_init(&dev_priv->rps.hw_lock); | |
| 6164 | + | |
| 6165 | + mutex_init(&dev_priv->pc8.lock); | |
| 6166 | + dev_priv->pc8.requirements_met = false; | |
| 6167 | + dev_priv->pc8.gpu_idle = false; | |
| 6168 | + dev_priv->pc8.irqs_disabled = false; | |
| 6169 | + dev_priv->pc8.enabled = false; | |
| 6170 | + dev_priv->pc8.disable_count = 2; /* requirements_met + gpu_idle */ | |
| 6171 | + INIT_DELAYED_WORK(&dev_priv->pc8.enable_work, hsw_enable_pc8_work); | |
| 6137 | 6172 | INIT_DELAYED_WORK(&dev_priv->rps.delayed_resume_work, |
| 6138 | 6173 | intel_gen6_powersave_work); |
| 6139 | 6174 | } |
| @@ -965,6 +965,7 @@ void intel_ring_setup_status_page(struct intel_ring_buffer *ring) · 964 unmodified lines | ||
| 965 | 965 | } else if (IS_GEN6(ring->dev)) { |
| 966 | 966 | mmio = RING_HWS_PGA_GEN6(ring->mmio_base); |
| 967 | 967 | } else { |
| 968 | + /* XXX: gen8 returns to sanity */ | |
| 968 | 969 | mmio = RING_HWS_PGA(ring->mmio_base); |
| 969 | 970 | } |
| 970 | 971 | |
| @@ -784,6 +784,7 @@ static int gen6_do_reset(struct drm_device *dev) · 783 unmodified lines | ||
| 784 | 784 | int intel_gpu_reset(struct drm_device *dev) |
| 785 | 785 | { |
| 786 | 786 | switch (INTEL_INFO(dev)->gen) { |
| 787 | + case 8: | |
| 787 | 788 | case 7: |
| 788 | 789 | case 6: return gen6_do_reset(dev); |
| 789 | 790 | case 5: return ironlake_do_reset(dev); |
| @@ -858,6 +858,12 @@ static int nouveau_pmops_runtime_suspend(struct device *dev) · 857 unmodified lines | ||
| 858 | 858 | if (nouveau_runtime_pm == 0) |
| 859 | 859 | return -EINVAL; |
| 860 | 860 | |
| 861 | + /* are we optimus enabled? */ | |
| 862 | + if (nouveau_runtime_pm == -1 && !nouveau_is_optimus() && !nouveau_is_v1_dsm()) { | |
| 863 | + DRM_DEBUG_DRIVER("failing to power off - not optimus\n"); | |
| 864 | + return -EINVAL; | |
| 865 | + } | |
| 866 | + | |
| 861 | 867 | nv_debug_level(SILENT); |
| 862 | 868 | drm_kms_helper_poll_disable(drm_dev); |
| 863 | 869 | vga_switcheroo_set_dynamic_switch(pdev, VGA_SWITCHEROO_OFF); |
| @@ -8,5 +8,6 @@ config DRM_QXL · 7 unmodified lines | ||
| 8 | 8 | select DRM_KMS_HELPER |
| 9 | 9 | select DRM_KMS_FB_HELPER |
| 10 | 10 | select DRM_TTM |
| 11 | + select CRC32 | |
| 11 | 12 | help |
| 12 | 13 | QXL virtual GPU for Spice virtualization desktop integration. Do not enable this driver unless your distro ships a corresponding X.org QXL driver that can handle kernel modesetting. |
| @@ -24,7 +24,7 @@ · 23 unmodified lines | ||
| 24 | 24 | */ |
| 25 | 25 | |
| 26 | 26 | |
| 27 | −#include "linux/crc32.h" | |
| 27 | +#include <linux/crc32.h> | |
| 28 | 28 | |
| 29 | 29 | #include "qxl_drv.h" |
| 30 | 30 | #include "qxl_object.h" |
| @@ -1196,7 +1196,9 @@ static int dce4_crtc_do_set_base(struct drm_crtc *crtc, · 1195 unmodified lines | ||
| 1196 | 1196 | } else if ((rdev->family == CHIP_TAHITI) || |
| 1197 | 1197 | (rdev->family == CHIP_PITCAIRN)) |
| 1198 | 1198 | fb_format |= SI_GRPH_PIPE_CONFIG(SI_ADDR_SURF_P8_32x32_8x16); |
| 1199 | − else if (rdev->family == CHIP_VERDE) | |
| 1199 | + else if ((rdev->family == CHIP_VERDE) || | |
| 1200 | + (rdev->family == CHIP_OLAND) || | |
| 1201 | + (rdev->family == CHIP_HAINAN)) /* for completeness. HAINAN has no display hw */ | |
| 1200 | 1202 | fb_format |= SI_GRPH_PIPE_CONFIG(SI_ADDR_SURF_P4_8x16); |
| 1201 | 1203 | |
| 1202 | 1204 | switch (radeon_crtc->crtc_id) { |
| @@ -458,7 +458,7 @@ int cik_copy_dma(struct radeon_device *rdev, · 457 unmodified lines | ||
| 458 | 458 | radeon_ring_write(ring, 0); /* src/dst endian swap */ |
| 459 | 459 | radeon_ring_write(ring, src_offset & 0xffffffff); |
| 460 | 460 | radeon_ring_write(ring, upper_32_bits(src_offset) & 0xffffffff); |
| 461 | − radeon_ring_write(ring, dst_offset & 0xfffffffc); | |
| 461 | + radeon_ring_write(ring, dst_offset & 0xffffffff); | |
| 462 | 462 | radeon_ring_write(ring, upper_32_bits(dst_offset) & 0xffffffff); |
| 463 | 463 | src_offset += cur_size_in_bytes; |
| 464 | 464 | dst_offset += cur_size_in_bytes; |
| @@ -174,7 +174,7 @@ void dce6_afmt_write_speaker_allocation(struct drm_encoder *encoder) · 173 unmodified lines | ||
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | sad_count = drm_edid_to_speaker_allocation(radeon_connector->edid, &sadb); |
| 177 | − if (sad_count < 0) { | |
| 177 | + if (sad_count <= 0) { | |
| 178 | 178 | DRM_ERROR("Couldn't read Speaker Allocation Data Block: %d\n", sad_count); |
| 179 | 179 | return; |
| 180 | 180 | } |
| @@ -235,7 +235,7 @@ void dce6_afmt_write_sad_regs(struct drm_encoder *encoder) · 54 unmodified lines | ||
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | sad_count = drm_edid_to_sad(radeon_connector->edid, &sads); |
| 238 | − if (sad_count < 0) { | |
| 238 | + if (sad_count <= 0) { | |
| 239 | 239 | DRM_ERROR("Couldn't read SADs: %d\n", sad_count); |
| 240 | 240 | return; |
| 241 | 241 | } |
| @@ -308,7 +308,9 @@ int dce6_audio_init(struct radeon_device *rdev) · 66 unmodified lines | ||
| 308 | 308 | rdev->audio.enabled = true; |
| 309 | 309 | |
| 310 | 310 | if (ASIC_IS_DCE8(rdev)) |
| 311 | − rdev->audio.num_pins = 7; | |
| 311 | + rdev->audio.num_pins = 6; | |
| 312 | + else if (ASIC_IS_DCE61(rdev)) | |
| 313 | + rdev->audio.num_pins = 4; | |
| 312 | 314 | else |
| 313 | 315 | rdev->audio.num_pins = 6; |
| 314 | 316 | |
| @@ -118,7 +118,7 @@ static void dce4_afmt_write_speaker_allocation(struct drm_encoder *encoder) · 117 unmodified lines | ||
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | sad_count = drm_edid_to_speaker_allocation(radeon_connector->edid, &sadb); |
| 121 | − if (sad_count < 0) { | |
| 121 | + if (sad_count <= 0) { | |
| 122 | 122 | DRM_ERROR("Couldn't read Speaker Allocation Data Block: %d\n", sad_count); |
| 123 | 123 | return; |
| 124 | 124 | } |
| @@ -173,7 +173,7 @@ static void evergreen_hdmi_write_sad_regs(struct drm_encoder *encoder) · 48 unmodified lines | ||
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | sad_count = drm_edid_to_sad(radeon_connector->edid, &sads); |
| 176 | − if (sad_count < 0) { | |
| 176 | + if (sad_count <= 0) { | |
| 177 | 177 | DRM_ERROR("Couldn't read SADs: %d\n", sad_count); |
| 178 | 178 | return; |
| 179 | 179 | } |
| @@ -895,6 +895,10 @@ static void cayman_gpu_init(struct radeon_device *rdev) · 894 unmodified lines | ||
| 895 | 895 | (rdev->pdev->device == 0x999C)) { |
| 896 | 896 | rdev->config.cayman.max_simds_per_se = 6; |
| 897 | 897 | rdev->config.cayman.max_backends_per_se = 2; |
| 898 | + rdev->config.cayman.max_hw_contexts = 8; | |
| 899 | + rdev->config.cayman.sx_max_export_size = 256; | |
| 900 | + rdev->config.cayman.sx_max_export_pos_size = 64; | |
| 901 | + rdev->config.cayman.sx_max_export_smx_size = 192; | |
| 898 | 902 | } else if ((rdev->pdev->device == 0x9903) || |
| 899 | 903 | (rdev->pdev->device == 0x9904) || |
| 900 | 904 | (rdev->pdev->device == 0x990A) || |
| @@ -905,6 +909,10 @@ static void cayman_gpu_init(struct radeon_device *rdev) · 4 unmodified lines | ||
| 905 | 909 | (rdev->pdev->device == 0x999D)) { |
| 906 | 910 | rdev->config.cayman.max_simds_per_se = 4; |
| 907 | 911 | rdev->config.cayman.max_backends_per_se = 2; |
| 912 | + rdev->config.cayman.max_hw_contexts = 8; | |
| 913 | + rdev->config.cayman.sx_max_export_size = 256; | |
| 914 | + rdev->config.cayman.sx_max_export_pos_size = 64; | |
| 915 | + rdev->config.cayman.sx_max_export_smx_size = 192; | |
| 908 | 916 | } else if ((rdev->pdev->device == 0x9919) || |
| 909 | 917 | (rdev->pdev->device == 0x9990) || |
| 910 | 918 | (rdev->pdev->device == 0x9991) || |
| @@ -915,9 +923,17 @@ static void cayman_gpu_init(struct radeon_device *rdev) · 4 unmodified lines | ||
| 915 | 923 | (rdev->pdev->device == 0x99A0)) { |
| 916 | 924 | rdev->config.cayman.max_simds_per_se = 3; |
| 917 | 925 | rdev->config.cayman.max_backends_per_se = 1; |
| 926 | + rdev->config.cayman.max_hw_contexts = 4; | |
| 927 | + rdev->config.cayman.sx_max_export_size = 128; | |
| 928 | + rdev->config.cayman.sx_max_export_pos_size = 32; | |
| 929 | + rdev->config.cayman.sx_max_export_smx_size = 96; | |
| 918 | 930 | } else { |
| 919 | 931 | rdev->config.cayman.max_simds_per_se = 2; |
| 920 | 932 | rdev->config.cayman.max_backends_per_se = 1; |
| 933 | + rdev->config.cayman.max_hw_contexts = 4; | |
| 934 | + rdev->config.cayman.sx_max_export_size = 128; | |
| 935 | + rdev->config.cayman.sx_max_export_pos_size = 32; | |
| 936 | + rdev->config.cayman.sx_max_export_smx_size = 96; | |
| 921 | 937 | } |
| 922 | 938 | rdev->config.cayman.max_texture_channel_caches = 2; |
| 923 | 939 | rdev->config.cayman.max_gprs = 256; |
| @@ -925,10 +941,6 @@ static void cayman_gpu_init(struct radeon_device *rdev) · 1 unmodified line | ||
| 925 | 941 | rdev->config.cayman.max_gs_threads = 32; |
| 926 | 942 | rdev->config.cayman.max_stack_entries = 512; |
| 927 | 943 | rdev->config.cayman.sx_num_of_sets = 8; |
| 928 | − rdev->config.cayman.sx_max_export_size = 256; | |
| 929 | − rdev->config.cayman.sx_max_export_pos_size = 64; | |
| 930 | − rdev->config.cayman.sx_max_export_smx_size = 192; | |
| 931 | − rdev->config.cayman.max_hw_contexts = 8; | |
| 932 | 944 | rdev->config.cayman.sq_num_cf_insts = 2; |
| 933 | 945 | |
| 934 | 946 | rdev->config.cayman.sc_prim_fifo_size = 0x40; |
| @@ -2021,7 +2021,7 @@ static struct radeon_asic ci_asic = { · 2020 unmodified lines | ||
| 2021 | 2021 | .hdmi_setmode = &evergreen_hdmi_setmode, |
| 2022 | 2022 | }, |
| 2023 | 2023 | .copy = { |
| 2024 | − .blit = NULL, | |
| 2024 | + .blit = &cik_copy_cpdma, | |
| 2025 | 2025 | .blit_ring_index = RADEON_RING_TYPE_GFX_INDEX, |
| 2026 | 2026 | .dma = &cik_copy_dma, |
| 2027 | 2027 | .dma_ring_index = R600_RING_TYPE_DMA_INDEX, |
| @@ -2122,7 +2122,7 @@ static struct radeon_asic kv_asic = { · 94 unmodified lines | ||
| 2122 | 2122 | .hdmi_setmode = &evergreen_hdmi_setmode, |
| 2123 | 2123 | }, |
| 2124 | 2124 | .copy = { |
| 2125 | − .blit = NULL, | |
| 2125 | + .blit = &cik_copy_cpdma, | |
| 2126 | 2126 | .blit_ring_index = RADEON_RING_TYPE_GFX_INDEX, |
| 2127 | 2127 | .dma = &cik_copy_dma, |
| 2128 | 2128 | .dma_ring_index = R600_RING_TYPE_DMA_INDEX, |
| @@ -508,15 +508,6 @@ static const struct file_operations radeon_driver_kms_fops = { · 507 unmodified lines | ||
| 508 | 508 | #endif |
| 509 | 509 | }; |
| 510 | 510 | |
| 511 | − | |
| 512 | −static void | |
| 513 | −radeon_pci_shutdown(struct pci_dev *pdev) | |
| 514 | −{ | |
| 515 | − struct drm_device *dev = pci_get_drvdata(pdev); | |
| 516 | − | |
| 517 | − radeon_driver_unload_kms(dev); | |
| 518 | −} | |
| 519 | − | |
| 520 | 511 | static struct drm_driver kms_driver = { |
| 521 | 512 | .driver_features = |
| 522 | 513 | DRIVER_USE_AGP | |
| @@ -586,7 +577,6 @@ static struct pci_driver radeon_kms_pci_driver = { · 63 unmodified lines | ||
| 586 | 577 | .probe = radeon_pci_probe, |
| 587 | 578 | .remove = radeon_pci_remove, |
| 588 | 579 | .driver.pm = &radeon_pm_ops, |
| 589 | − .shutdown = radeon_pci_shutdown, | |
| 590 | 580 | }; |
| 591 | 581 | |
| 592 | 582 | static int __init radeon_init(void) |
| @@ -162,6 +162,16 @@ static void rs690_mc_init(struct radeon_device *rdev) · 161 unmodified lines | ||
| 162 | 162 | base = RREG32_MC(R_000100_MCCFG_FB_LOCATION); |
| 163 | 163 | base = G_000100_MC_FB_START(base) << 16; |
| 164 | 164 | rdev->mc.igp_sideport_enabled = radeon_atombios_sideport_present(rdev); |
| 165 | + /* Some boards seem to be configured for 128MB of sideport memory, | |
| 166 | + * but really only have 64MB. Just skip the sideport and use | |
| 167 | + * UMA memory. | |
| 168 | + */ | |
| 169 | + if (rdev->mc.igp_sideport_enabled && | |
| 170 | + (rdev->mc.real_vram_size == (384 * 1024 * 1024))) { | |
| 171 | + base += 128 * 1024 * 1024; | |
| 172 | + rdev->mc.real_vram_size -= 128 * 1024 * 1024; | |
| 173 | + rdev->mc.mc_vram_size = rdev->mc.real_vram_size; | |
| 174 | + } | |
| 165 | 175 | |
| 166 | 176 | /* Use K8 direct mapping for fast fb access. */ |
| 167 | 177 | rdev->fastfb_working = false; |
| @@ -2328,6 +2328,12 @@ void rv770_get_engine_memory_ss(struct radeon_device *rdev) · 2327 unmodified lines | ||
| 2328 | 2328 | pi->mclk_ss = radeon_atombios_get_asic_ss_info(rdev, &ss, |
| 2329 | 2329 | ASIC_INTERNAL_MEMORY_SS, 0); |
| 2330 | 2330 | |
| 2331 | + /* disable ss, causes hangs on some cayman boards */ | |
| 2332 | + if (rdev->family == CHIP_CAYMAN) { | |
| 2333 | + pi->sclk_ss = false; | |
| 2334 | + pi->mclk_ss = false; | |
| 2335 | + } | |
| 2336 | + | |
| 2331 | 2337 | if (pi->sclk_ss || pi->mclk_ss) |
| 2332 | 2338 | pi->dynamic_ss = true; |
| 2333 | 2339 | else |
| @@ -353,7 +353,8 @@ int ttm_bo_move_memcpy(struct ttm_buffer_object *bo, · 352 unmodified lines | ||
| 353 | 353 | * Don't move nonexistent data. Clear destination instead. |
| 354 | 354 | */ |
| 355 | 355 | if (old_iomap == NULL && |
| 356 | − (ttm == NULL || ttm->state == tt_unpopulated)) { | |
| 356 | + (ttm == NULL || (ttm->state == tt_unpopulated && | |
| 357 | + !(ttm->page_flags & TTM_PAGE_FLAG_SWAPPED)))) { | |
| 357 | 358 | memset_io(new_iomap, 0, new_mem->num_pages*PAGE_SIZE); |
| 358 | 359 | goto out2; |
| 359 | 360 | } |
| @@ -169,9 +169,9 @@ static int ttm_bo_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf) · 168 unmodified lines | ||
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | page_offset = ((address - vma->vm_start) >> PAGE_SHIFT) + |
| 172 | − drm_vma_node_start(&bo->vma_node) - vma->vm_pgoff; | |
| 173 | − page_last = vma_pages(vma) + | |
| 174 | − drm_vma_node_start(&bo->vma_node) - vma->vm_pgoff; | |
| 172 | + vma->vm_pgoff - drm_vma_node_start(&bo->vma_node); | |
| 173 | + page_last = vma_pages(vma) + vma->vm_pgoff - | |
| 174 | + drm_vma_node_start(&bo->vma_node); | |
| 175 | 175 | |
| 176 | 176 | if (unlikely(page_offset >= bo->num_pages)) { |
| 177 | 177 | retval = VM_FAULT_SIGBUS; |
| @@ -68,6 +68,9 @@ int vmw_getparam_ioctl(struct drm_device *dev, void *data, · 67 unmodified lines | ||
| 68 | 68 | SVGA_FIFO_3D_HWVERSION)); |
| 69 | 69 | break; |
| 70 | 70 | } |
| 71 | + case DRM_VMW_PARAM_MAX_SURF_MEMORY: | |
| 72 | + param->value = dev_priv->memory_size; | |
| 73 | + break; | |
| 71 | 74 | default: |
| 72 | 75 | DRM_ERROR("Illegal vmwgfx get param request: %d\n", |
| 73 | 76 | param->param); |
| @@ -377,6 +377,9 @@ static int intel_idle(struct cpuidle_device *dev, · 376 unmodified lines | ||
| 377 | 377 | |
| 378 | 378 | if (!current_set_polling_and_test()) { |
| 379 | 379 | |
| 380 | + if (this_cpu_has(X86_FEATURE_CLFLUSH_MONITOR)) | |
| 381 | + clflush((void *)¤t_thread_info()->flags); | |
| 382 | + | |
| 380 | 383 | __monitor((void *)¤t_thread_info()->flags, 0, 0); |
| 381 | 384 | smp_mb(); |
| 382 | 385 | if (!need_resched()) |
| @@ -200,7 +200,13 @@ static const struct ad7887_chip_info ad7887_chip_info_tbl[] = { · 199 unmodified lines | ||
| 200 | 200 | .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), |
| 201 | 201 | .address = 1, |
| 202 | 202 | .scan_index = 1, |
| 203 | − .scan_type = IIO_ST('u', 12, 16, 0), | |
| 203 | + .scan_type = { | |
| 204 | + .sign = 'u', | |
| 205 | + .realbits = 12, | |
| 206 | + .storagebits = 16, | |
| 207 | + .shift = 0, | |
| 208 | + .endianness = IIO_BE, | |
| 209 | + }, | |
| 204 | 210 | }, |
| 205 | 211 | .channel[1] = { |
| 206 | 212 | .type = IIO_VOLTAGE, |
| @@ -210,7 +216,13 @@ static const struct ad7887_chip_info ad7887_chip_info_tbl[] = { · 3 unmodified lines | ||
| 210 | 216 | .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), |
| 211 | 217 | .address = 0, |
| 212 | 218 | .scan_index = 0, |
| 213 | − .scan_type = IIO_ST('u', 12, 16, 0), | |
| 219 | + .scan_type = { | |
| 220 | + .sign = 'u', | |
| 221 | + .realbits = 12, | |
| 222 | + .storagebits = 16, | |
| 223 | + .shift = 0, | |
| 224 | + .endianness = IIO_BE, | |
| 225 | + }, | |
| 214 | 226 | }, |
| 215 | 227 | .channel[2] = IIO_CHAN_SOFT_TIMESTAMP(2), |
| 216 | 228 | .int_vref_mv = 2500, |
| @@ -651,7 +651,12 @@ static const struct iio_chan_spec adis16448_channels[] = { · 650 unmodified lines | ||
| 651 | 651 | .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), |
| 652 | 652 | .address = ADIS16448_BARO_OUT, |
| 653 | 653 | .scan_index = ADIS16400_SCAN_BARO, |
| 654 | − .scan_type = IIO_ST('s', 16, 16, 0), | |
| 654 | + .scan_type = { | |
| 655 | + .sign = 's', | |
| 656 | + .realbits = 16, | |
| 657 | + .storagebits = 16, | |
| 658 | + .endianness = IIO_BE, | |
| 659 | + }, | |
| 655 | 660 | }, |
| 656 | 661 | ADIS16400_TEMP_CHAN(ADIS16448_TEMP_OUT, 12), |
| 657 | 662 | IIO_CHAN_SOFT_TIMESTAMP(11) |
| @@ -387,7 +387,7 @@ static int cm36651_read_int_time(struct cm36651_data *cm36651, · 386 unmodified lines | ||
| 387 | 387 | return -EINVAL; |
| 388 | 388 | } |
| 389 | 389 | |
| 390 | − return IIO_VAL_INT_PLUS_MICRO; | |
| 390 | + return IIO_VAL_INT; | |
| 391 | 391 | } |
| 392 | 392 | |
| 393 | 393 | static int cm36651_write_int_time(struct cm36651_data *cm36651, |
| @@ -181,9 +181,16 @@ static void add_ref(struct iw_cm_id *cm_id) · 180 unmodified lines | ||
| 181 | 181 | static void rem_ref(struct iw_cm_id *cm_id) |
| 182 | 182 | { |
| 183 | 183 | struct iwcm_id_private *cm_id_priv; |
| 184 | + int cb_destroy; | |
| 185 | + | |
| 184 | 186 | cm_id_priv = container_of(cm_id, struct iwcm_id_private, id); |
| 185 | − if (iwcm_deref_id(cm_id_priv) && | |
| 186 | − test_bit(IWCM_F_CALLBACK_DESTROY, &cm_id_priv->flags)) { | |
| 187 | + | |
| 188 | + /* | |
| 189 | + * Test bit before deref in case the cm_id gets freed on another | |
| 190 | + * thread. | |
| 191 | + */ | |
| 192 | + cb_destroy = test_bit(IWCM_F_CALLBACK_DESTROY, &cm_id_priv->flags); | |
| 193 | + if (iwcm_deref_id(cm_id_priv) && cb_destroy) { | |
| 187 | 194 | BUG_ON(!list_empty(&cm_id_priv->work_list)); |
| 188 | 195 | free_cm_id(cm_id_priv); |
| 189 | 196 | } |
| @@ -49,12 +49,20 @@ · 48 unmodified lines | ||
| 49 | 49 | |
| 50 | 50 | #define INIT_UDATA(udata, ibuf, obuf, ilen, olen) \ |
| 51 | 51 | do { \ |
| 52 | − (udata)->inbuf = (void __user *) (ibuf); \ | |
| 52 | + (udata)->inbuf = (const void __user *) (ibuf); \ | |
| 53 | 53 | (udata)->outbuf = (void __user *) (obuf); \ |
| 54 | 54 | (udata)->inlen = (ilen); \ |
| 55 | 55 | (udata)->outlen = (olen); \ |
| 56 | 56 | } while (0) |
| 57 | 57 | |
| 58 | +#define INIT_UDATA_BUF_OR_NULL(udata, ibuf, obuf, ilen, olen) \ | |
| 59 | + do { \ | |
| 60 | + (udata)->inbuf = (ilen) ? (const void __user *) (ibuf) : NULL; \ | |
| 61 | + (udata)->outbuf = (olen) ? (void __user *) (obuf) : NULL; \ | |
| 62 | + (udata)->inlen = (ilen); \ | |
| 63 | + (udata)->outlen = (olen); \ | |
| 64 | + } while (0) | |
| 65 | + | |
| 58 | 66 | /* |
| 59 | 67 | * Our lifetime rules for these structs are the following: |
| 60 | 68 | * |
| @@ -2593,6 +2593,9 @@ out_put: · 2592 unmodified lines | ||
| 2593 | 2593 | static int kern_spec_to_ib_spec(struct ib_uverbs_flow_spec *kern_spec, |
| 2594 | 2594 | union ib_flow_spec *ib_spec) |
| 2595 | 2595 | { |
| 2596 | + if (kern_spec->reserved) | |
| 2597 | + return -EINVAL; | |
| 2598 | + | |
| 2596 | 2599 | ib_spec->type = kern_spec->type; |
| 2597 | 2600 | |
| 2598 | 2601 | switch (ib_spec->type) { |
| @@ -2646,6 +2649,9 @@ int ib_uverbs_ex_create_flow(struct ib_uverbs_file *file, · 47 unmodified lines | ||
| 2646 | 2649 | void *ib_spec; |
| 2647 | 2650 | int i; |
| 2648 | 2651 | |
| 2652 | + if (ucore->inlen < sizeof(cmd)) | |
| 2653 | + return -EINVAL; | |
| 2654 | + | |
| 2649 | 2655 | if (ucore->outlen < sizeof(resp)) |
| 2650 | 2656 | return -ENOSPC; |
| 2651 | 2657 | |
| @@ -2671,6 +2677,10 @@ int ib_uverbs_ex_create_flow(struct ib_uverbs_file *file, · 19 unmodified lines | ||
| 2671 | 2677 | (cmd.flow_attr.num_of_specs * sizeof(struct ib_uverbs_flow_spec))) |
| 2672 | 2678 | return -EINVAL; |
| 2673 | 2679 | |
| 2680 | + if (cmd.flow_attr.reserved[0] || | |
| 2681 | + cmd.flow_attr.reserved[1]) | |
| 2682 | + return -EINVAL; | |
| 2683 | + | |
| 2674 | 2684 | if (cmd.flow_attr.num_of_specs) { |
| 2675 | 2685 | kern_flow_attr = kmalloc(sizeof(*kern_flow_attr) + cmd.flow_attr.size, |
| 2676 | 2686 | GFP_KERNEL); |
| @@ -2731,6 +2741,7 @@ int ib_uverbs_ex_create_flow(struct ib_uverbs_file *file, · 54 unmodified lines | ||
| 2731 | 2741 | if (cmd.flow_attr.size || (i != flow_attr->num_of_specs)) { |
| 2732 | 2742 | pr_warn("create flow failed, flow %d: %d bytes left from uverb cmd\n", |
| 2733 | 2743 | i, cmd.flow_attr.size); |
| 2744 | + err = -EINVAL; | |
| 2734 | 2745 | goto err_free; |
| 2735 | 2746 | } |
| 2736 | 2747 | flow_id = ib_create_flow(qp, flow_attr, IB_FLOW_DOMAIN_USER); |
| @@ -2791,10 +2802,16 @@ int ib_uverbs_ex_destroy_flow(struct ib_uverbs_file *file, · 54 unmodified lines | ||
| 2791 | 2802 | struct ib_uobject *uobj; |
| 2792 | 2803 | int ret; |
| 2793 | 2804 | |
| 2805 | + if (ucore->inlen < sizeof(cmd)) | |
| 2806 | + return -EINVAL; | |
| 2807 | + | |
| 2794 | 2808 | ret = ib_copy_from_udata(&cmd, ucore, sizeof(cmd)); |
| 2795 | 2809 | if (ret) |
| 2796 | 2810 | return ret; |
| 2797 | 2811 | |
| 2812 | + if (cmd.comp_mask) | |
| 2813 | + return -EINVAL; | |
| 2814 | + | |
| 2798 | 2815 | uobj = idr_write_uobj(&ib_uverbs_rule_idr, cmd.flow_handle, |
| 2799 | 2816 | file->ucontext); |
| 2800 | 2817 | if (!uobj) |
| @@ -668,25 +668,30 @@ static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf, · 667 unmodified lines | ||
| 668 | 668 | if ((hdr.in_words + ex_hdr.provider_in_words) * 8 != count) |
| 669 | 669 | return -EINVAL; |
| 670 | 670 | |
| 671 | + if (ex_hdr.cmd_hdr_reserved) | |
| 672 | + return -EINVAL; | |
| 673 | + | |
| 671 | 674 | if (ex_hdr.response) { |
| 672 | 675 | if (!hdr.out_words && !ex_hdr.provider_out_words) |
| 673 | 676 | return -EINVAL; |
| 677 | + | |
| 678 | + if (!access_ok(VERIFY_WRITE, | |
| 679 | + (void __user *) (unsigned long) ex_hdr.response, | |
| 680 | + (hdr.out_words + ex_hdr.provider_out_words) * 8)) | |
| 681 | + return -EFAULT; | |
| 674 | 682 | } else { |
| 675 | 683 | if (hdr.out_words || ex_hdr.provider_out_words) |
| 676 | 684 | return -EINVAL; |
| 677 | 685 | } |
| 678 | 686 | |
| 679 | − INIT_UDATA(&ucore, | |
| 680 | − (hdr.in_words) ? buf : 0, | |
| 681 | − (unsigned long)ex_hdr.response, | |
| 682 | − hdr.in_words * 8, | |
| 683 | − hdr.out_words * 8); | |
| 684 | − | |
| 685 | − INIT_UDATA(&uhw, | |
| 686 | − (ex_hdr.provider_in_words) ? buf + ucore.inlen : 0, | |
| 687 | − (ex_hdr.provider_out_words) ? (unsigned long)ex_hdr.response + ucore.outlen : 0, | |
| 688 | − ex_hdr.provider_in_words * 8, | |
| 689 | − ex_hdr.provider_out_words * 8); | |
| 687 | + INIT_UDATA_BUF_OR_NULL(&ucore, buf, (unsigned long) ex_hdr.response, | |
| 688 | + hdr.in_words * 8, hdr.out_words * 8); | |
| 689 | + | |
| 690 | + INIT_UDATA_BUF_OR_NULL(&uhw, | |
| 691 | + buf + ucore.inlen, | |
| 692 | + (unsigned long) ex_hdr.response + ucore.outlen, | |
| 693 | + ex_hdr.provider_in_words * 8, | |
| 694 | + ex_hdr.provider_out_words * 8); | |
| 690 | 695 | |
| 691 | 696 | err = uverbs_ex_cmd_table[command](file, |
| 692 | 697 | &ucore, |
| @@ -173,7 +173,7 @@ static int _c4iw_write_mem_inline(struct c4iw_rdev *rdev, u32 addr, u32 len, · 172 unmodified lines | ||
| 173 | 173 | return ret; |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | −int _c4iw_write_mem_dma(struct c4iw_rdev *rdev, u32 addr, u32 len, void *data) | |
| 176 | +static int _c4iw_write_mem_dma(struct c4iw_rdev *rdev, u32 addr, u32 len, void *data) | |
| 177 | 177 | { |
| 178 | 178 | u32 remain = len; |
| 179 | 179 | u32 dmalen; |
| @@ -207,7 +207,9 @@ isert_free_rx_descriptors(struct isert_conn *isert_conn) · 206 unmodified lines | ||
| 207 | 207 | isert_conn->conn_rx_descs = NULL; |
| 208 | 208 | } |
| 209 | 209 | |
| 210 | +static void isert_cq_tx_work(struct work_struct *); | |
| 210 | 211 | static void isert_cq_tx_callback(struct ib_cq *, void *); |
| 212 | +static void isert_cq_rx_work(struct work_struct *); | |
| 211 | 213 | static void isert_cq_rx_callback(struct ib_cq *, void *); |
| 212 | 214 | |
| 213 | 215 | static int |
| @@ -259,26 +261,36 @@ isert_create_device_ib_res(struct isert_device *device) · 45 unmodified lines | ||
| 259 | 261 | cq_desc[i].device = device; |
| 260 | 262 | cq_desc[i].cq_index = i; |
| 261 | 263 | |
| 264 | + INIT_WORK(&cq_desc[i].cq_rx_work, isert_cq_rx_work); | |
| 262 | 265 | device->dev_rx_cq[i] = ib_create_cq(device->ib_device, |
| 263 | 266 | isert_cq_rx_callback, |
| 264 | 267 | isert_cq_event_callback, |
| 265 | 268 | (void *)&cq_desc[i], |
| 266 | 269 | ISER_MAX_RX_CQ_LEN, i); |
| 267 | − if (IS_ERR(device->dev_rx_cq[i])) | |
| 270 | + if (IS_ERR(device->dev_rx_cq[i])) { | |
| 271 | + ret = PTR_ERR(device->dev_rx_cq[i]); | |
| 272 | + device->dev_rx_cq[i] = NULL; | |
| 268 | 273 | goto out_cq; |
| 274 | + } | |
| 269 | 275 | |
| 276 | + INIT_WORK(&cq_desc[i].cq_tx_work, isert_cq_tx_work); | |
| 270 | 277 | device->dev_tx_cq[i] = ib_create_cq(device->ib_device, |
| 271 | 278 | isert_cq_tx_callback, |
| 272 | 279 | isert_cq_event_callback, |
| 273 | 280 | (void *)&cq_desc[i], |
| 274 | 281 | ISER_MAX_TX_CQ_LEN, i); |
| 275 | − if (IS_ERR(device->dev_tx_cq[i])) | |
| 282 | + if (IS_ERR(device->dev_tx_cq[i])) { | |
| 283 | + ret = PTR_ERR(device->dev_tx_cq[i]); | |
| 284 | + device->dev_tx_cq[i] = NULL; | |
| 276 | 285 | goto out_cq; |
| 286 | + } | |
| 277 | 287 | |
| 278 | − if (ib_req_notify_cq(device->dev_rx_cq[i], IB_CQ_NEXT_COMP)) | |
| 288 | + ret = ib_req_notify_cq(device->dev_rx_cq[i], IB_CQ_NEXT_COMP); | |
| 289 | + if (ret) | |
| 279 | 290 | goto out_cq; |
| 280 | 291 | |
| 281 | − if (ib_req_notify_cq(device->dev_tx_cq[i], IB_CQ_NEXT_COMP)) | |
| 292 | + ret = ib_req_notify_cq(device->dev_tx_cq[i], IB_CQ_NEXT_COMP); | |
| 293 | + if (ret) | |
| 282 | 294 | goto out_cq; |
| 283 | 295 | } |
| 284 | 296 | |
| @@ -1724,7 +1736,6 @@ isert_cq_tx_callback(struct ib_cq *cq, void *context) · 1439 unmodified lines | ||
| 1724 | 1736 | { |
| 1725 | 1737 | struct isert_cq_desc *cq_desc = (struct isert_cq_desc *)context; |
| 1726 | 1738 | |
| 1727 | − INIT_WORK(&cq_desc->cq_tx_work, isert_cq_tx_work); | |
| 1728 | 1739 | queue_work(isert_comp_wq, &cq_desc->cq_tx_work); |
| 1729 | 1740 | } |
| 1730 | 1741 | |
| @@ -1768,7 +1779,6 @@ isert_cq_rx_callback(struct ib_cq *cq, void *context) · 37 unmodified lines | ||
| 1768 | 1779 | { |
| 1769 | 1780 | struct isert_cq_desc *cq_desc = (struct isert_cq_desc *)context; |
| 1770 | 1781 | |
| 1771 | − INIT_WORK(&cq_desc->cq_rx_work, isert_cq_rx_work); | |
| 1772 | 1782 | queue_work(isert_rx_wq, &cq_desc->cq_rx_work); |
| 1773 | 1783 | } |
| 1774 | 1784 | |
| @@ -149,8 +149,9 @@ static void intc_irqpin_read_modify_write(struct intc_irqpin_priv *p, · 148 unmodified lines | ||
| 149 | 149 | static void intc_irqpin_mask_unmask_prio(struct intc_irqpin_priv *p, |
| 150 | 150 | int irq, int do_mask) |
| 151 | 151 | { |
| 152 | − int bitfield_width = 4; /* PRIO assumed to have fixed bitfield width */ | |
| 153 | − int shift = (7 - irq) * bitfield_width; /* PRIO assumed to be 32-bit */ | |
| 152 | + /* The PRIO register is assumed to be 32-bit with fixed 4-bit fields. */ | |
| 153 | + int bitfield_width = 4; | |
| 154 | + int shift = 32 - (irq + 1) * bitfield_width; | |
| 154 | 155 | |
| 155 | 156 | intc_irqpin_read_modify_write(p, INTC_IRQPIN_REG_PRIO, |
| 156 | 157 | shift, bitfield_width, |
| @@ -159,8 +160,9 @@ static void intc_irqpin_mask_unmask_prio(struct intc_irqpin_priv *p, · 2 unmodified lines | ||
| 159 | 160 | |
| 160 | 161 | static int intc_irqpin_set_sense(struct intc_irqpin_priv *p, int irq, int value) |
| 161 | 162 | { |
| 163 | + /* The SENSE register is assumed to be 32-bit. */ | |
| 162 | 164 | int bitfield_width = p->config.sense_bitfield_width; |
| 163 | − int shift = (7 - irq) * bitfield_width; /* SENSE assumed to be 32-bit */ | |
| 165 | + int shift = 32 - (irq + 1) * bitfield_width; | |
| 164 | 166 | |
| 165 | 167 | dev_dbg(&p->pdev->dev, "sense irq = %d, mode = %d\n", irq, value); |
| 166 | 168 | |
| @@ -421,9 +421,11 @@ out: · 420 unmodified lines | ||
| 421 | 421 | |
| 422 | 422 | if (watermark <= WATERMARK_METADATA) { |
| 423 | 423 | SET_GC_MARK(b, GC_MARK_METADATA); |
| 424 | + SET_GC_MOVE(b, 0); | |
| 424 | 425 | b->prio = BTREE_PRIO; |
| 425 | 426 | } else { |
| 426 | 427 | SET_GC_MARK(b, GC_MARK_RECLAIMABLE); |
| 428 | + SET_GC_MOVE(b, 0); | |
| 427 | 429 | b->prio = INITIAL_PRIO; |
| 428 | 430 | } |
| 429 | 431 | |
| @@ -197,7 +197,7 @@ struct bucket { · 196 unmodified lines | ||
| 197 | 197 | uint8_t disk_gen; |
| 198 | 198 | uint8_t last_gc; /* Most out of date gen in the btree */ |
| 199 | 199 | uint8_t gc_gen; |
| 200 | − uint16_t gc_mark; | |
| 200 | + uint16_t gc_mark; /* Bitfield used by GC. See below for field */ | |
| 201 | 201 | }; |
| 202 | 202 | |
| 203 | 203 | /* |
| @@ -209,7 +209,8 @@ BITMASK(GC_MARK, struct bucket, gc_mark, 0, 2); · 5 unmodified lines | ||
| 209 | 209 | #define GC_MARK_RECLAIMABLE 0 |
| 210 | 210 | #define GC_MARK_DIRTY 1 |
| 211 | 211 | #define GC_MARK_METADATA 2 |
| 212 | −BITMASK(GC_SECTORS_USED, struct bucket, gc_mark, 2, 14); | |
| 212 | +BITMASK(GC_SECTORS_USED, struct bucket, gc_mark, 2, 13); | |
| 213 | +BITMASK(GC_MOVE, struct bucket, gc_mark, 15, 1); | |
| 213 | 214 | |
| 214 | 215 | #include "journal.h" |
| 215 | 216 | #include "stats.h" |
| @@ -372,14 +373,14 @@ struct cached_dev { · 156 unmodified lines | ||
| 372 | 373 | unsigned char writeback_percent; |
| 373 | 374 | unsigned writeback_delay; |
| 374 | 375 | |
| 375 | − int writeback_rate_change; | |
| 376 | − int64_t writeback_rate_derivative; | |
| 377 | 376 | uint64_t writeback_rate_target; |
| 377 | + int64_t writeback_rate_proportional; | |
| 378 | + int64_t writeback_rate_derivative; | |
| 379 | + int64_t writeback_rate_change; | |
| 378 | 380 | |
| 379 | 381 | unsigned writeback_rate_update_seconds; |
| 380 | 382 | unsigned writeback_rate_d_term; |
| 381 | 383 | unsigned writeback_rate_p_term_inverse; |
| 382 | − unsigned writeback_rate_d_smooth; | |
| 383 | 384 | }; |
| 384 | 385 | |
| 385 | 386 | enum alloc_watermarks { |
| @@ -445,7 +446,6 @@ struct cache { · 59 unmodified lines | ||
| 445 | 446 | * call prio_write() to keep gens from wrapping. |
| 446 | 447 | */ |
| 447 | 448 | uint8_t need_save_prio; |
| 448 | − unsigned gc_move_threshold; | |
| 449 | 449 | |
| 450 | 450 | /* |
| 451 | 451 | * If nonzero, we know we aren't going to find any buckets to invalidate |
| @@ -1561,6 +1561,28 @@ size_t bch_btree_gc_finish(struct cache_set *c) · 1560 unmodified lines | ||
| 1561 | 1561 | SET_GC_MARK(PTR_BUCKET(c, &c->uuid_bucket, i), |
| 1562 | 1562 | GC_MARK_METADATA); |
| 1563 | 1563 | |
| 1564 | + /* don't reclaim buckets to which writeback keys point */ | |
| 1565 | + rcu_read_lock(); | |
| 1566 | + for (i = 0; i < c->nr_uuids; i++) { | |
| 1567 | + struct bcache_device *d = c->devices[i]; | |
| 1568 | + struct cached_dev *dc; | |
| 1569 | + struct keybuf_key *w, *n; | |
| 1570 | + unsigned j; | |
| 1571 | + | |
| 1572 | + if (!d || UUID_FLASH_ONLY(&c->uuids[i])) | |
| 1573 | + continue; | |
| 1574 | + dc = container_of(d, struct cached_dev, disk); | |
| 1575 | + | |
| 1576 | + spin_lock(&dc->writeback_keys.lock); | |
| 1577 | + rbtree_postorder_for_each_entry_safe(w, n, | |
| 1578 | + &dc->writeback_keys.keys, node) | |
| 1579 | + for (j = 0; j < KEY_PTRS(&w->key); j++) | |
| 1580 | + SET_GC_MARK(PTR_BUCKET(c, &w->key, j), | |
| 1581 | + GC_MARK_DIRTY); | |
| 1582 | + spin_unlock(&dc->writeback_keys.lock); | |
| 1583 | + } | |
| 1584 | + rcu_read_unlock(); | |
| 1585 | + | |
| 1564 | 1586 | for_each_cache(ca, c, i) { |
| 1565 | 1587 | uint64_t *i; |
| 1566 | 1588 | |
| @@ -1817,7 +1839,8 @@ static bool fix_overlapping_extents(struct btree *b, struct bkey *insert, · 250 unmodified lines | ||
| 1817 | 1839 | if (KEY_START(k) > KEY_START(insert) + sectors_found) |
| 1818 | 1840 | goto check_failed; |
| 1819 | 1841 | |
| 1820 | − if (KEY_PTRS(replace_key) != KEY_PTRS(k)) | |
| 1842 | + if (KEY_PTRS(k) != KEY_PTRS(replace_key) || | |
| 1843 | + KEY_DIRTY(k) != KEY_DIRTY(replace_key)) | |
| 1821 | 1844 | goto check_failed; |
| 1822 | 1845 | |
| 1823 | 1846 | /* skip past gen */ |
| @@ -2217,7 +2240,7 @@ struct btree_insert_op { · 393 unmodified lines | ||
| 2217 | 2240 | struct bkey *replace_key; |
| 2218 | 2241 | }; |
| 2219 | 2242 | |
| 2220 | −int btree_insert_fn(struct btree_op *b_op, struct btree *b) | |
| 2243 | +static int btree_insert_fn(struct btree_op *b_op, struct btree *b) | |
| 2221 | 2244 | { |
| 2222 | 2245 | struct btree_insert_op *op = container_of(b_op, |
| 2223 | 2246 | struct btree_insert_op, op); |
| @@ -25,10 +25,9 @@ static bool moving_pred(struct keybuf *buf, struct bkey *k) · 24 unmodified lines | ||
| 25 | 25 | unsigned i; |
| 26 | 26 | |
| 27 | 27 | for (i = 0; i < KEY_PTRS(k); i++) { |
| 28 | − struct cache *ca = PTR_CACHE(c, k, i); | |
| 29 | 28 | struct bucket *g = PTR_BUCKET(c, k, i); |
| 30 | 29 | |
| 31 | − if (GC_SECTORS_USED(g) < ca->gc_move_threshold) | |
| 30 | + if (GC_MOVE(g)) | |
| 32 | 31 | return true; |
| 33 | 32 | } |
| 34 | 33 | |
| @@ -65,11 +64,16 @@ static void write_moving_finish(struct closure *cl) · 30 unmodified lines | ||
| 65 | 64 | |
| 66 | 65 | static void read_moving_endio(struct bio *bio, int error) |
| 67 | 66 | { |
| 67 | + struct bbio *b = container_of(bio, struct bbio, bio); | |
| 68 | 68 | struct moving_io *io = container_of(bio->bi_private, |
| 69 | 69 | struct moving_io, cl); |
| 70 | 70 | |
| 71 | 71 | if (error) |
| 72 | 72 | io->op.error = error; |
| 73 | + else if (!KEY_DIRTY(&b->key) && | |
| 74 | + ptr_stale(io->op.c, &b->key, 0)) { | |
| 75 | + io->op.error = -EINTR; | |
| 76 | + } | |
| 73 | 77 | |
| 74 | 78 | bch_bbio_endio(io->op.c, bio, error, "reading data to move"); |
| 75 | 79 | } |
| @@ -141,6 +145,11 @@ static void read_moving(struct cache_set *c) · 65 unmodified lines | ||
| 141 | 145 | if (!w) |
| 142 | 146 | break; |
| 143 | 147 | |
| 148 | + if (ptr_stale(c, &w->key, 0)) { | |
| 149 | + bch_keybuf_del(&c->moving_gc_keys, w); | |
| 150 | + continue; | |
| 151 | + } | |
| 152 | + | |
| 144 | 153 | io = kzalloc(sizeof(struct moving_io) + sizeof(struct bio_vec) |
| 145 | 154 | * DIV_ROUND_UP(KEY_SIZE(&w->key), PAGE_SECTORS), |
| 146 | 155 | GFP_KERNEL); |
| @@ -184,7 +193,8 @@ static bool bucket_cmp(struct bucket *l, struct bucket *r) · 37 unmodified lines | ||
| 184 | 193 | |
| 185 | 194 | static unsigned bucket_heap_top(struct cache *ca) |
| 186 | 195 | { |
| 187 | − return GC_SECTORS_USED(heap_peek(&ca->heap)); | |
| 196 | + struct bucket *b; | |
| 197 | + return (b = heap_peek(&ca->heap)) ? GC_SECTORS_USED(b) : 0; | |
| 188 | 198 | } |
| 189 | 199 | |
| 190 | 200 | void bch_moving_gc(struct cache_set *c) |
| @@ -226,9 +236,8 @@ void bch_moving_gc(struct cache_set *c) · 35 unmodified lines | ||
| 226 | 236 | sectors_to_move -= GC_SECTORS_USED(b); |
| 227 | 237 | } |
| 228 | 238 | |
| 229 | − ca->gc_move_threshold = bucket_heap_top(ca); | |
| 230 | − | |
| 231 | − pr_debug("threshold %u", ca->gc_move_threshold); | |
| 239 | + while (heap_pop(&ca->heap, b, bucket_cmp)) | |
| 240 | + SET_GC_MOVE(b, 1); | |
| 232 | 241 | } |
| 233 | 242 | |
| 234 | 243 | mutex_unlock(&c->bucket_lock); |
| @@ -1676,7 +1676,7 @@ err: · 1675 unmodified lines | ||
| 1676 | 1676 | static bool can_attach_cache(struct cache *ca, struct cache_set *c) |
| 1677 | 1677 | { |
| 1678 | 1678 | return ca->sb.block_size == c->sb.block_size && |
| 1679 | − ca->sb.bucket_size == c->sb.block_size && | |
| 1679 | + ca->sb.bucket_size == c->sb.bucket_size && | |
| 1680 | 1680 | ca->sb.nr_in_set == c->sb.nr_in_set; |
| 1681 | 1681 | } |
| 1682 | 1682 | |
| @@ -83,7 +83,6 @@ rw_attribute(writeback_rate); · 82 unmodified lines | ||
| 83 | 83 | rw_attribute(writeback_rate_update_seconds); |
| 84 | 84 | rw_attribute(writeback_rate_d_term); |
| 85 | 85 | rw_attribute(writeback_rate_p_term_inverse); |
| 86 | −rw_attribute(writeback_rate_d_smooth); | |
| 87 | 86 | read_attribute(writeback_rate_debug); |
| 88 | 87 | |
| 89 | 88 | read_attribute(stripe_size); |
| @@ -129,31 +128,41 @@ SHOW(__bch_cached_dev) · 39 unmodified lines | ||
| 129 | 128 | var_printf(writeback_running, "%i"); |
| 130 | 129 | var_print(writeback_delay); |
| 131 | 130 | var_print(writeback_percent); |
| 132 | − sysfs_print(writeback_rate, dc->writeback_rate.rate); | |
| 131 | + sysfs_hprint(writeback_rate, dc->writeback_rate.rate << 9); | |
| 133 | 132 | |
| 134 | 133 | var_print(writeback_rate_update_seconds); |
| 135 | 134 | var_print(writeback_rate_d_term); |
| 136 | 135 | var_print(writeback_rate_p_term_inverse); |
| 137 | − var_print(writeback_rate_d_smooth); | |
| 138 | 136 | |
| 139 | 137 | if (attr == &sysfs_writeback_rate_debug) { |
| 138 | + char rate[20]; | |
| 140 | 139 | char dirty[20]; |
| 141 | − char derivative[20]; | |
| 142 | 140 | char target[20]; |
| 143 | − bch_hprint(dirty, | |
| 144 | − bcache_dev_sectors_dirty(&dc->disk) << 9); | |
| 145 | − bch_hprint(derivative, dc->writeback_rate_derivative << 9); | |
| 141 | + char proportional[20]; | |
| 142 | + char derivative[20]; | |
| 143 | + char change[20]; | |
| 144 | + s64 next_io; | |
| 145 | + | |
| 146 | + bch_hprint(rate, dc->writeback_rate.rate << 9); | |
| 147 | + bch_hprint(dirty, bcache_dev_sectors_dirty(&dc->disk) << 9); | |
| 146 | 148 | bch_hprint(target, dc->writeback_rate_target << 9); |
| 149 | + bch_hprint(proportional,dc->writeback_rate_proportional << 9); | |
| 150 | + bch_hprint(derivative, dc->writeback_rate_derivative << 9); | |
| 151 | + bch_hprint(change, dc->writeback_rate_change << 9); | |
| 152 | + | |
| 153 | + next_io = div64_s64(dc->writeback_rate.next - local_clock(), | |
| 154 | + NSEC_PER_MSEC); | |
| 147 | 155 | |
| 148 | 156 | return sprintf(buf, |
| 149 | − "rate:\t\t%u\n" | |
| 150 | − "change:\t\t%i\n" | |
| 157 | + "rate:\t\t%s/sec\n" | |
| 151 | 158 | "dirty:\t\t%s\n" |
| 159 | + "target:\t\t%s\n" | |
| 160 | + "proportional:\t%s\n" | |
| 152 | 161 | "derivative:\t%s\n" |
| 153 | − "target:\t\t%s\n", | |
| 154 | − dc->writeback_rate.rate, | |
| 155 | − dc->writeback_rate_change, | |
| 156 | − dirty, derivative, target); | |
| 162 | + "change:\t\t%s/sec\n" | |
| 163 | + "next io:\t%llims\n", | |
| 164 | + rate, dirty, target, proportional, | |
| 165 | + derivative, change, next_io); | |
| 157 | 166 | } |
| 158 | 167 | |
| 159 | 168 | sysfs_hprint(dirty_data, |
| @@ -189,6 +198,7 @@ STORE(__cached_dev) · 29 unmodified lines | ||
| 189 | 198 | struct kobj_uevent_env *env; |
| 190 | 199 | |
| 191 | 200 | #define d_strtoul(var) sysfs_strtoul(var, dc->var) |
| 201 | +#define d_strtoul_nonzero(var) sysfs_strtoul_clamp(var, dc->var, 1, INT_MAX) | |
| 192 | 202 | #define d_strtoi_h(var) sysfs_hatoi(var, dc->var) |
| 193 | 203 | |
| 194 | 204 | sysfs_strtoul(data_csum, dc->disk.data_csum); |
| @@ -197,16 +207,15 @@ STORE(__cached_dev) · 2 unmodified lines | ||
| 197 | 207 | d_strtoul(writeback_metadata); |
| 198 | 208 | d_strtoul(writeback_running); |
| 199 | 209 | d_strtoul(writeback_delay); |
| 200 | − sysfs_strtoul_clamp(writeback_rate, | |
| 201 | − dc->writeback_rate.rate, 1, 1000000); | |
| 210 | + | |
| 202 | 211 | sysfs_strtoul_clamp(writeback_percent, dc->writeback_percent, 0, 40); |
| 203 | 212 | |
| 204 | − d_strtoul(writeback_rate_update_seconds); | |
| 213 | + sysfs_strtoul_clamp(writeback_rate, | |
| 214 | + dc->writeback_rate.rate, 1, INT_MAX); | |
| 215 | + | |
| 216 | + d_strtoul_nonzero(writeback_rate_update_seconds); | |
| 205 | 217 | d_strtoul(writeback_rate_d_term); |
| 206 | − d_strtoul(writeback_rate_p_term_inverse); | |
| 207 | − sysfs_strtoul_clamp(writeback_rate_p_term_inverse, | |
| 208 | − dc->writeback_rate_p_term_inverse, 1, INT_MAX); | |
| 209 | − d_strtoul(writeback_rate_d_smooth); | |
| 218 | + d_strtoul_nonzero(writeback_rate_p_term_inverse); | |
| 210 | 219 | |
| 211 | 220 | d_strtoi_h(sequential_cutoff); |
| 212 | 221 | d_strtoi_h(readahead); |
| @@ -313,7 +322,6 @@ static struct attribute *bch_cached_dev_files[] = { · 100 unmodified lines | ||
| 313 | 322 | &sysfs_writeback_rate_update_seconds, |
| 314 | 323 | &sysfs_writeback_rate_d_term, |
| 315 | 324 | &sysfs_writeback_rate_p_term_inverse, |
| 316 | − &sysfs_writeback_rate_d_smooth, | |
| 317 | 325 | &sysfs_writeback_rate_debug, |
| 318 | 326 | &sysfs_dirty_data, |
| 319 | 327 | &sysfs_stripe_size, |
| @@ -209,7 +209,13 @@ uint64_t bch_next_delay(struct bch_ratelimit *d, uint64_t done) · 208 unmodified lines | ||
| 209 | 209 | { |
| 210 | 210 | uint64_t now = local_clock(); |
| 211 | 211 | |
| 212 | − d->next += div_u64(done, d->rate); | |
| 212 | + d->next += div_u64(done * NSEC_PER_SEC, d->rate); | |
| 213 | + | |
| 214 | + if (time_before64(now + NSEC_PER_SEC, d->next)) | |
| 215 | + d->next = now + NSEC_PER_SEC; | |
| 216 | + | |
| 217 | + if (time_after64(now - NSEC_PER_SEC * 2, d->next)) | |
| 218 | + d->next = now - NSEC_PER_SEC * 2; | |
| 213 | 219 | |
| 214 | 220 | return time_after64(d->next, now) |
| 215 | 221 | ? div_u64(d->next - now, NSEC_PER_SEC / HZ) |
| @@ -110,7 +110,7 @@ do { \ · 109 unmodified lines | ||
| 110 | 110 | _r; \ |
| 111 | 111 | }) |
| 112 | 112 | |
| 113 | −#define heap_peek(h) ((h)->size ? (h)->data[0] : NULL) | |
| 113 | +#define heap_peek(h) ((h)->used ? (h)->data[0] : NULL) | |
| 114 | 114 | |
| 115 | 115 | #define heap_full(h) ((h)->used == (h)->size) |
| 116 | 116 | |
| @@ -30,38 +30,40 @@ static void __update_writeback_rate(struct cached_dev *dc) · 29 unmodified lines | ||
| 30 | 30 | |
| 31 | 31 | /* PD controller */ |
| 32 | 32 | |
| 33 | − int change = 0; | |
| 34 | − int64_t error; | |
| 35 | 33 | int64_t dirty = bcache_dev_sectors_dirty(&dc->disk); |
| 36 | 34 | int64_t derivative = dirty - dc->disk.sectors_dirty_last; |
| 35 | + int64_t proportional = dirty - target; | |
| 36 | + int64_t change; | |
| 37 | 37 | |
| 38 | 38 | dc->disk.sectors_dirty_last = dirty; |
| 39 | 39 | |
| 40 | − derivative *= dc->writeback_rate_d_term; | |
| 41 | − derivative = clamp(derivative, -dirty, dirty); | |
| 40 | + /* Scale to sectors per second */ | |
| 42 | 41 | |
| 43 | − derivative = ewma_add(dc->disk.sectors_dirty_derivative, derivative, | |
| 44 | − dc->writeback_rate_d_smooth, 0); | |
| 42 | + proportional *= dc->writeback_rate_update_seconds; | |
| 43 | + proportional = div_s64(proportional, dc->writeback_rate_p_term_inverse); | |
| 45 | 44 | |
| 46 | − /* Avoid divide by zero */ | |
| 47 | − if (!target) | |
| 48 | − goto out; | |
| 45 | + derivative = div_s64(derivative, dc->writeback_rate_update_seconds); | |
| 49 | 46 | |
| 50 | − error = div64_s64((dirty + derivative - target) << 8, target); | |
| 47 | + derivative = ewma_add(dc->disk.sectors_dirty_derivative, derivative, | |
| 48 | + (dc->writeback_rate_d_term / | |
| 49 | + dc->writeback_rate_update_seconds) ?: 1, 0); | |
| 50 | + | |
| 51 | + derivative *= dc->writeback_rate_d_term; | |
| 52 | + derivative = div_s64(derivative, dc->writeback_rate_p_term_inverse); | |
| 51 | 53 | |
| 52 | − change = div_s64((dc->writeback_rate.rate * error) >> 8, | |
| 53 | − dc->writeback_rate_p_term_inverse); | |
| 54 | + change = proportional + derivative; | |
| 54 | 55 | |
| 55 | 56 | /* Don't increase writeback rate if the device isn't keeping up */ |
| 56 | 57 | if (change > 0 && |
| 57 | 58 | time_after64(local_clock(), |
| 58 | − dc->writeback_rate.next + 10 * NSEC_PER_MSEC)) | |
| 59 | + dc->writeback_rate.next + NSEC_PER_MSEC)) | |
| 59 | 60 | change = 0; |
| 60 | 61 | |
| 61 | 62 | dc->writeback_rate.rate = |
| 62 | − clamp_t(int64_t, dc->writeback_rate.rate + change, | |
| 63 | + clamp_t(int64_t, (int64_t) dc->writeback_rate.rate + change, | |
| 63 | 64 | 1, NSEC_PER_MSEC); |
| 64 | −out: | |
| 65 | + | |
| 66 | + dc->writeback_rate_proportional = proportional; | |
| 65 | 67 | dc->writeback_rate_derivative = derivative; |
| 66 | 68 | dc->writeback_rate_change = change; |
| 67 | 69 | dc->writeback_rate_target = target; |
| @@ -87,15 +89,11 @@ static void update_writeback_rate(struct work_struct *work) · 19 unmodified lines | ||
| 87 | 89 | |
| 88 | 90 | static unsigned writeback_delay(struct cached_dev *dc, unsigned sectors) |
| 89 | 91 | { |
| 90 | − uint64_t ret; | |
| 91 | − | |
| 92 | 92 | if (test_bit(BCACHE_DEV_DETACHING, &dc->disk.flags) || |
| 93 | 93 | !dc->writeback_percent) |
| 94 | 94 | return 0; |
| 95 | 95 | |
| 96 | − ret = bch_next_delay(&dc->writeback_rate, sectors * 10000000ULL); | |
| 97 | − | |
| 98 | − return min_t(uint64_t, ret, HZ); | |
| 96 | + return bch_next_delay(&dc->writeback_rate, sectors); | |
| 99 | 97 | } |
| 100 | 98 | |
| 101 | 99 | struct dirty_io { |
| @@ -241,7 +239,7 @@ static void read_dirty(struct cached_dev *dc) · 139 unmodified lines | ||
| 241 | 239 | if (KEY_START(&w->key) != dc->last_read || |
| 242 | 240 | jiffies_to_msecs(delay) > 50) |
| 243 | 241 | while (!kthread_should_stop() && delay) |
| 244 | − delay = schedule_timeout_interruptible(delay); | |
| 242 | + delay = schedule_timeout_uninterruptible(delay); | |
| 245 | 243 | |
| 246 | 244 | dc->last_read = KEY_OFFSET(&w->key); |
| 247 | 245 | |
| @@ -438,7 +436,7 @@ static int bch_writeback_thread(void *arg) · 190 unmodified lines | ||
| 438 | 436 | while (delay && |
| 439 | 437 | !kthread_should_stop() && |
| 440 | 438 | !test_bit(BCACHE_DEV_DETACHING, &dc->disk.flags)) |
| 441 | − delay = schedule_timeout_interruptible(delay); | |
| 439 | + delay = schedule_timeout_uninterruptible(delay); | |
| 442 | 440 | } |
| 443 | 441 | } |
| 444 | 442 | |
| @@ -476,6 +474,8 @@ void bch_sectors_dirty_init(struct cached_dev *dc) · 31 unmodified lines | ||
| 476 | 474 | |
| 477 | 475 | bch_btree_map_keys(&op.op, dc->disk.c, &KEY(op.inode, 0, 0), |
| 478 | 476 | sectors_dirty_init_fn, 0); |
| 477 | + | |
| 478 | + dc->disk.sectors_dirty_last = bcache_dev_sectors_dirty(&dc->disk); | |
| 479 | 479 | } |
| 480 | 480 | |
| 481 | 481 | int bch_cached_dev_writeback_init(struct cached_dev *dc) |
| @@ -490,18 +490,15 @@ int bch_cached_dev_writeback_init(struct cached_dev *dc) · 8 unmodified lines | ||
| 490 | 490 | dc->writeback_delay = 30; |
| 491 | 491 | dc->writeback_rate.rate = 1024; |
| 492 | 492 | |
| 493 | − dc->writeback_rate_update_seconds = 30; | |
| 494 | − dc->writeback_rate_d_term = 16; | |
| 495 | − dc->writeback_rate_p_term_inverse = 64; | |
| 496 | − dc->writeback_rate_d_smooth = 8; | |
| 493 | + dc->writeback_rate_update_seconds = 5; | |
| 494 | + dc->writeback_rate_d_term = 30; | |
| 495 | + dc->writeback_rate_p_term_inverse = 6000; | |
| 497 | 496 | |
| 498 | 497 | dc->writeback_thread = kthread_create(bch_writeback_thread, dc, |
| 499 | 498 | "bcache_writeback"); |
| 500 | 499 | if (IS_ERR(dc->writeback_thread)) |
| 501 | 500 | return PTR_ERR(dc->writeback_thread); |
| 502 | 501 | |
| 503 | − set_task_state(dc->writeback_thread, TASK_INTERRUPTIBLE); | |
| 504 | − | |
| 505 | 502 | INIT_DELAYED_WORK(&dc->writeback_rate_update, update_writeback_rate); |
| 506 | 503 | schedule_delayed_work(&dc->writeback_rate_update, |
| 507 | 504 | dc->writeback_rate_update_seconds * HZ); |
| @@ -625,6 +625,7 @@ static int ems_usb_start(struct ems_usb *dev) · 624 unmodified lines | ||
| 625 | 625 | usb_unanchor_urb(urb); |
| 626 | 626 | usb_free_coherent(dev->udev, RX_BUFFER_SIZE, buf, |
| 627 | 627 | urb->transfer_dma); |
| 628 | + usb_free_urb(urb); | |
| 628 | 629 | break; |
| 629 | 630 | } |
| 630 | 631 | |
| @@ -798,8 +799,8 @@ static netdev_tx_t ems_usb_start_xmit(struct sk_buff *skb, struct net_device *ne · 167 unmodified lines | ||
| 798 | 799 | * allowed (MAX_TX_URBS). |
| 799 | 800 | */ |
| 800 | 801 | if (!context) { |
| 801 | − usb_unanchor_urb(urb); | |
| 802 | 802 | usb_free_coherent(dev->udev, size, buf, urb->transfer_dma); |
| 803 | + usb_free_urb(urb); | |
| 803 | 804 | |
| 804 | 805 | netdev_warn(netdev, "couldn't find free context\n"); |
| 805 | 806 | |
| @@ -927,6 +927,9 @@ static int pcan_usb_pro_init(struct peak_usb_device *dev) · 926 unmodified lines | ||
| 927 | 927 | /* set LED in default state (end of init phase) */ |
| 928 | 928 | pcan_usb_pro_set_led(dev, 0, 1); |
| 929 | 929 | |
| 930 | + kfree(bi); | |
| 931 | + kfree(fi); | |
| 932 | + | |
| 930 | 933 | return 0; |
| 931 | 934 | |
| 932 | 935 | err_out: |
| @@ -447,8 +447,9 @@ irqreturn_t qlcnic_83xx_intr(int irq, void *data) · 446 unmodified lines | ||
| 447 | 447 | |
| 448 | 448 | qlcnic_83xx_poll_process_aen(adapter); |
| 449 | 449 | |
| 450 | − if (ahw->diag_test == QLCNIC_INTERRUPT_TEST) { | |
| 451 | − ahw->diag_cnt++; | |
| 450 | + if (ahw->diag_test) { | |
| 451 | + if (ahw->diag_test == QLCNIC_INTERRUPT_TEST) | |
| 452 | + ahw->diag_cnt++; | |
| 452 | 453 | qlcnic_83xx_enable_legacy_msix_mbx_intr(adapter); |
| 453 | 454 | return IRQ_HANDLED; |
| 454 | 455 | } |
| @@ -1345,11 +1346,6 @@ static int qlcnic_83xx_diag_alloc_res(struct net_device *netdev, int test, · 890 unmodified lines | ||
| 1345 | 1346 | } |
| 1346 | 1347 | |
| 1347 | 1348 | if (adapter->ahw->diag_test == QLCNIC_LOOPBACK_TEST) { |
| 1348 | − /* disable and free mailbox interrupt */ | |
| 1349 | − if (!(adapter->flags & QLCNIC_MSIX_ENABLED)) { | |
| 1350 | − qlcnic_83xx_enable_mbx_poll(adapter); | |
| 1351 | − qlcnic_83xx_free_mbx_intr(adapter); | |
| 1352 | − } | |
| 1353 | 1349 | adapter->ahw->loopback_state = 0; |
| 1354 | 1350 | adapter->ahw->hw_ops->setup_link_event(adapter, 1); |
| 1355 | 1351 | } |
| @@ -1363,33 +1359,20 @@ static void qlcnic_83xx_diag_free_res(struct net_device *netdev, · 7 unmodified lines | ||
| 1363 | 1359 | { |
| 1364 | 1360 | struct qlcnic_adapter *adapter = netdev_priv(netdev); |
| 1365 | 1361 | struct qlcnic_host_sds_ring *sds_ring; |
| 1366 | − int ring, err; | |
| 1362 | + int ring; | |
| 1367 | 1363 | |
| 1368 | 1364 | clear_bit(__QLCNIC_DEV_UP, &adapter->state); |
| 1369 | 1365 | if (adapter->ahw->diag_test == QLCNIC_INTERRUPT_TEST) { |
| 1370 | 1366 | for (ring = 0; ring < adapter->drv_sds_rings; ring++) { |
| 1371 | 1367 | sds_ring = &adapter->recv_ctx->sds_rings[ring]; |
| 1372 | − qlcnic_83xx_disable_intr(adapter, sds_ring); | |
| 1373 | − if (!(adapter->flags & QLCNIC_MSIX_ENABLED)) | |
| 1374 | − qlcnic_83xx_enable_mbx_poll(adapter); | |
| 1368 | + if (adapter->flags & QLCNIC_MSIX_ENABLED) | |
| 1369 | + qlcnic_83xx_disable_intr(adapter, sds_ring); | |
| 1375 | 1370 | } |
| 1376 | 1371 | } |
| 1377 | 1372 | |
| 1378 | 1373 | qlcnic_fw_destroy_ctx(adapter); |
| 1379 | 1374 | qlcnic_detach(adapter); |
| 1380 | 1375 | |
| 1381 | − if (adapter->ahw->diag_test == QLCNIC_LOOPBACK_TEST) { | |
| 1382 | − if (!(adapter->flags & QLCNIC_MSIX_ENABLED)) { | |
| 1383 | − err = qlcnic_83xx_setup_mbx_intr(adapter); | |
| 1384 | − qlcnic_83xx_disable_mbx_poll(adapter); | |
| 1385 | − if (err) { | |
| 1386 | − dev_err(&adapter->pdev->dev, | |
| 1387 | − "%s: failed to setup mbx interrupt\n", | |
| 1388 | − __func__); | |
| 1389 | − goto out; | |
| 1390 | − } | |
| 1391 | − } | |
| 1392 | − } | |
| 1393 | 1376 | adapter->ahw->diag_test = 0; |
| 1394 | 1377 | adapter->drv_sds_rings = drv_sds_rings; |
| 1395 | 1378 | |
| @@ -1399,9 +1382,6 @@ static void qlcnic_83xx_diag_free_res(struct net_device *netdev, · 3 unmodified lines | ||
| 1399 | 1382 | if (netif_running(netdev)) |
| 1400 | 1383 | __qlcnic_up(adapter, netdev); |
| 1401 | 1384 | |
| 1402 | − if (adapter->ahw->diag_test == QLCNIC_INTERRUPT_TEST && | |
| 1403 | − !(adapter->flags & QLCNIC_MSIX_ENABLED)) | |
| 1404 | − qlcnic_83xx_disable_mbx_poll(adapter); | |
| 1405 | 1385 | out: |
| 1406 | 1386 | netif_device_attach(netdev); |
| 1407 | 1387 | } |
| @@ -3754,6 +3734,19 @@ static void qlcnic_83xx_decode_mbx_rsp(struct qlcnic_adapter *adapter, · 2346 unmodified lines | ||
| 3754 | 3734 | return; |
| 3755 | 3735 | } |
| 3756 | 3736 | |
| 3737 | +static inline void qlcnic_dump_mailbox_registers(struct qlcnic_adapter *adapter) | |
| 3738 | +{ | |
| 3739 | + struct qlcnic_hardware_context *ahw = adapter->ahw; | |
| 3740 | + u32 offset; | |
| 3741 | + | |
| 3742 | + offset = QLCRDX(ahw, QLCNIC_DEF_INT_MASK); | |
| 3743 | + dev_info(&adapter->pdev->dev, "Mbx interrupt mask=0x%x, Mbx interrupt enable=0x%x, Host mbx control=0x%x, Fw mbx control=0x%x", | |
| 3744 | + readl(ahw->pci_base0 + offset), | |
| 3745 | + QLCRDX(ahw, QLCNIC_MBX_INTR_ENBL), | |
| 3746 | + QLCRDX(ahw, QLCNIC_HOST_MBX_CTRL), | |
| 3747 | + QLCRDX(ahw, QLCNIC_FW_MBX_CTRL)); | |
| 3748 | +} | |
| 3749 | + | |
| 3757 | 3750 | static void qlcnic_83xx_mailbox_worker(struct work_struct *work) |
| 3758 | 3751 | { |
| 3759 | 3752 | struct qlcnic_mailbox *mbx = container_of(work, struct qlcnic_mailbox, |
| @@ -3798,6 +3791,8 @@ static void qlcnic_83xx_mailbox_worker(struct work_struct *work) · 38 unmodified lines | ||
| 3798 | 3791 | __func__, cmd->cmd_op, cmd->type, ahw->pci_func, |
| 3799 | 3792 | ahw->op_mode); |
| 3800 | 3793 | clear_bit(QLC_83XX_MBX_READY, &mbx->status); |
| 3794 | + qlcnic_dump_mailbox_registers(adapter); | |
| 3795 | + qlcnic_83xx_get_mbx_data(adapter, cmd); | |
| 3801 | 3796 | qlcnic_dump_mbx(adapter, cmd); |
| 3802 | 3797 | qlcnic_83xx_idc_request_reset(adapter, |
| 3803 | 3798 | QLCNIC_FORCE_FW_DUMP_KEY); |
| @@ -662,4 +662,5 @@ pci_ers_result_t qlcnic_83xx_io_error_detected(struct pci_dev *, · 661 unmodified lines | ||
| 662 | 662 | pci_channel_state_t); |
| 663 | 663 | pci_ers_result_t qlcnic_83xx_io_slot_reset(struct pci_dev *); |
| 664 | 664 | void qlcnic_83xx_io_resume(struct pci_dev *); |
| 665 | +void qlcnic_83xx_stop_hw(struct qlcnic_adapter *); | |
| 665 | 666 | #endif |
| @@ -740,6 +740,7 @@ static int qlcnic_83xx_idc_unknown_state(struct qlcnic_adapter *adapter) · 739 unmodified lines | ||
| 740 | 740 | adapter->ahw->idc.err_code = -EIO; |
| 741 | 741 | dev_err(&adapter->pdev->dev, |
| 742 | 742 | "%s: Device in unknown state\n", __func__); |
| 743 | + clear_bit(__QLCNIC_RESETTING, &adapter->state); | |
| 743 | 744 | return 0; |
| 744 | 745 | } |
| 745 | 746 | |
| @@ -818,7 +819,6 @@ static int qlcnic_83xx_idc_ready_state(struct qlcnic_adapter *adapter) · 72 unmodified lines | ||
| 818 | 819 | struct qlcnic_hardware_context *ahw = adapter->ahw; |
| 819 | 820 | struct qlcnic_mailbox *mbx = ahw->mailbox; |
| 820 | 821 | int ret = 0; |
| 821 | − u32 owner; | |
| 822 | 822 | u32 val; |
| 823 | 823 | |
| 824 | 824 | /* Perform NIC configuration based ready state entry actions */ |
| @@ -848,9 +848,9 @@ static int qlcnic_83xx_idc_ready_state(struct qlcnic_adapter *adapter) · 23 unmodified lines | ||
| 848 | 848 | set_bit(__QLCNIC_RESETTING, &adapter->state); |
| 849 | 849 | qlcnic_83xx_idc_enter_need_reset_state(adapter, 1); |
| 850 | 850 | } else { |
| 851 | − owner = qlcnic_83xx_idc_find_reset_owner_id(adapter); | |
| 852 | − if (ahw->pci_func == owner) | |
| 853 | − qlcnic_dump_fw(adapter); | |
| 851 | + netdev_info(adapter->netdev, "%s: Auto firmware recovery is disabled\n", | |
| 852 | + __func__); | |
| 853 | + qlcnic_83xx_idc_enter_failed_state(adapter, 1); | |
| 854 | 854 | } |
| 855 | 855 | return -EIO; |
| 856 | 856 | } |
| @@ -948,13 +948,26 @@ static int qlcnic_83xx_idc_need_quiesce_state(struct qlcnic_adapter *adapter) · 91 unmodified lines | ||
| 948 | 948 | return 0; |
| 949 | 949 | } |
| 950 | 950 | |
| 951 | −static int qlcnic_83xx_idc_failed_state(struct qlcnic_adapter *adapter) | |
| 951 | +static void qlcnic_83xx_idc_failed_state(struct qlcnic_adapter *adapter) | |
| 952 | 952 | { |
| 953 | − dev_err(&adapter->pdev->dev, "%s: please restart!!\n", __func__); | |
| 953 | + struct qlcnic_hardware_context *ahw = adapter->ahw; | |
| 954 | + u32 val, owner; | |
| 955 | + | |
| 956 | + val = QLCRDX(adapter->ahw, QLC_83XX_IDC_CTRL); | |
| 957 | + if (val & QLC_83XX_IDC_DISABLE_FW_RESET_RECOVERY) { | |
| 958 | + owner = qlcnic_83xx_idc_find_reset_owner_id(adapter); | |
| 959 | + if (ahw->pci_func == owner) { | |
| 960 | + qlcnic_83xx_stop_hw(adapter); | |
| 961 | + qlcnic_dump_fw(adapter); | |
| 962 | + } | |
| 963 | + } | |
| 964 | + | |
| 965 | + netdev_warn(adapter->netdev, "%s: Reboot will be required to recover the adapter!!\n", | |
| 966 | + __func__); | |
| 954 | 967 | clear_bit(__QLCNIC_RESETTING, &adapter->state); |
| 955 | − adapter->ahw->idc.err_code = -EIO; | |
| 968 | + ahw->idc.err_code = -EIO; | |
| 956 | 969 | |
| 957 | − return 0; | |
| 970 | + return; | |
| 958 | 971 | } |
| 959 | 972 | |
| 960 | 973 | static int qlcnic_83xx_idc_quiesce_state(struct qlcnic_adapter *adapter) |
| @@ -1063,12 +1076,6 @@ void qlcnic_83xx_idc_poll_dev_state(struct work_struct *work) · 102 unmodified lines | ||
| 1063 | 1076 | adapter->ahw->idc.prev_state = adapter->ahw->idc.curr_state; |
| 1064 | 1077 | qlcnic_83xx_periodic_tasks(adapter); |
| 1065 | 1078 | |
| 1066 | − /* Do not reschedule if firmaware is in hanged state and auto | |
| 1067 | − * recovery is disabled | |
| 1068 | − */ | |
| 1069 | − if ((adapter->flags & QLCNIC_FW_HANG) && !qlcnic_auto_fw_reset) | |
| 1070 | − return; | |
| 1071 | − | |
| 1072 | 1079 | /* Re-schedule the function */ |
| 1073 | 1080 | if (test_bit(QLC_83XX_MODULE_LOADED, &adapter->ahw->idc.status)) |
| 1074 | 1081 | qlcnic_schedule_work(adapter, qlcnic_83xx_idc_poll_dev_state, |
| @@ -1219,10 +1226,10 @@ void qlcnic_83xx_idc_request_reset(struct qlcnic_adapter *adapter, u32 key) · 144 unmodified lines | ||
| 1219 | 1226 | } |
| 1220 | 1227 | |
| 1221 | 1228 | val = QLCRDX(adapter->ahw, QLC_83XX_IDC_CTRL); |
| 1222 | − if ((val & QLC_83XX_IDC_DISABLE_FW_RESET_RECOVERY) || | |
| 1223 | − !qlcnic_auto_fw_reset) { | |
| 1224 | − dev_err(&adapter->pdev->dev, | |
| 1225 | − "%s:failed, device in non reset mode\n", __func__); | |
| 1229 | + if (val & QLC_83XX_IDC_DISABLE_FW_RESET_RECOVERY) { | |
| 1230 | + netdev_info(adapter->netdev, "%s: Auto firmware recovery is disabled\n", | |
| 1231 | + __func__); | |
| 1232 | + qlcnic_83xx_idc_enter_failed_state(adapter, 0); | |
| 1226 | 1233 | qlcnic_83xx_unlock_driver(adapter); |
| 1227 | 1234 | return; |
| 1228 | 1235 | } |
| @@ -1254,24 +1261,24 @@ static int qlcnic_83xx_copy_bootloader(struct qlcnic_adapter *adapter) · 25 unmodified lines | ||
| 1254 | 1261 | if (size & 0xF) |
| 1255 | 1262 | size = (size + 16) & ~0xF; |
| 1256 | 1263 | |
| 1257 | − p_cache = kzalloc(size, GFP_KERNEL); | |
| 1264 | + p_cache = vzalloc(size); | |
| 1258 | 1265 | if (p_cache == NULL) |
| 1259 | 1266 | return -ENOMEM; |
| 1260 | 1267 | |
| 1261 | 1268 | ret = qlcnic_83xx_lockless_flash_read32(adapter, src, p_cache, |
| 1262 | 1269 | size / sizeof(u32)); |
| 1263 | 1270 | if (ret) { |
| 1264 | − kfree(p_cache); | |
| 1271 | + vfree(p_cache); | |
| 1265 | 1272 | return ret; |
| 1266 | 1273 | } |
| 1267 | 1274 | /* 16 byte write to MS memory */ |
| 1268 | 1275 | ret = qlcnic_83xx_ms_mem_write128(adapter, dest, (u32 *)p_cache, |
| 1269 | 1276 | size / 16); |
| 1270 | 1277 | if (ret) { |
| 1271 | − kfree(p_cache); | |
| 1278 | + vfree(p_cache); | |
| 1272 | 1279 | return ret; |
| 1273 | 1280 | } |
| 1274 | − kfree(p_cache); | |
| 1281 | + vfree(p_cache); | |
| 1275 | 1282 | |
| 1276 | 1283 | return ret; |
| 1277 | 1284 | } |
| @@ -1939,7 +1946,7 @@ static void qlcnic_83xx_exec_template_cmd(struct qlcnic_adapter *p_dev, · 661 unmodified lines | ||
| 1939 | 1946 | p_dev->ahw->reset.seq_index = index; |
| 1940 | 1947 | } |
| 1941 | 1948 | |
| 1942 | −static void qlcnic_83xx_stop_hw(struct qlcnic_adapter *p_dev) | |
| 1949 | +void qlcnic_83xx_stop_hw(struct qlcnic_adapter *p_dev) | |
| 1943 | 1950 | { |
| 1944 | 1951 | p_dev->ahw->reset.seq_index = 0; |
| 1945 | 1952 | |
| @@ -1994,6 +2001,14 @@ static int qlcnic_83xx_restart_hw(struct qlcnic_adapter *adapter) · 48 unmodified lines | ||
| 1994 | 2001 | val = QLCRDX(adapter->ahw, QLC_83XX_IDC_CTRL); |
| 1995 | 2002 | if (!(val & QLC_83XX_IDC_GRACEFULL_RESET)) |
| 1996 | 2003 | qlcnic_dump_fw(adapter); |
| 2004 | + | |
| 2005 | + if (val & QLC_83XX_IDC_DISABLE_FW_RESET_RECOVERY) { | |
| 2006 | + netdev_info(adapter->netdev, "%s: Auto firmware recovery is disabled\n", | |
| 2007 | + __func__); | |
| 2008 | + qlcnic_83xx_idc_enter_failed_state(adapter, 1); | |
| 2009 | + return err; | |
| 2010 | + } | |
| 2011 | + | |
| 1997 | 2012 | qlcnic_83xx_init_hw(adapter); |
| 1998 | 2013 | |
| 1999 | 2014 | if (qlcnic_83xx_copy_bootloader(adapter)) |
| @@ -2073,8 +2088,8 @@ int qlcnic_83xx_configure_opmode(struct qlcnic_adapter *adapter) · 73 unmodified lines | ||
| 2073 | 2088 | ahw->nic_mode = QLCNIC_DEFAULT_MODE; |
| 2074 | 2089 | adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver; |
| 2075 | 2090 | ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry; |
| 2076 | − adapter->max_sds_rings = ahw->max_rx_ques; | |
| 2077 | − adapter->max_tx_rings = ahw->max_tx_ques; | |
| 2091 | + adapter->max_sds_rings = QLCNIC_MAX_SDS_RINGS; | |
| 2092 | + adapter->max_tx_rings = QLCNIC_MAX_TX_RINGS; | |
| 2078 | 2093 | } else { |
| 2079 | 2094 | return -EIO; |
| 2080 | 2095 | } |
| @@ -667,30 +667,25 @@ qlcnic_set_ringparam(struct net_device *dev, · 666 unmodified lines | ||
| 667 | 667 | static int qlcnic_validate_ring_count(struct qlcnic_adapter *adapter, |
| 668 | 668 | u8 rx_ring, u8 tx_ring) |
| 669 | 669 | { |
| 670 | + if (rx_ring == 0 || tx_ring == 0) | |
| 671 | + return -EINVAL; | |
| 672 | + | |
| 670 | 673 | if (rx_ring != 0) { |
| 671 | 674 | if (rx_ring > adapter->max_sds_rings) { |
| 672 | − netdev_err(adapter->netdev, "Invalid ring count, SDS ring count %d should not be greater than max %d driver sds rings.\n", | |
| 675 | + netdev_err(adapter->netdev, | |
| 676 | + "Invalid ring count, SDS ring count %d should not be greater than max %d driver sds rings.\n", | |
| 673 | 677 | rx_ring, adapter->max_sds_rings); |
| 674 | 678 | return -EINVAL; |
| 675 | 679 | } |
| 676 | 680 | } |
| 677 | 681 | |
| 678 | 682 | if (tx_ring != 0) { |
| 679 | − if (qlcnic_82xx_check(adapter) && | |
| 680 | − (tx_ring > adapter->max_tx_rings)) { | |
| 683 | + if (tx_ring > adapter->max_tx_rings) { | |
| 681 | 684 | netdev_err(adapter->netdev, |
| 682 | 685 | "Invalid ring count, Tx ring count %d should not be greater than max %d driver Tx rings.\n", |
| 683 | 686 | tx_ring, adapter->max_tx_rings); |
| 684 | 687 | return -EINVAL; |
| 685 | 688 | } |
| 686 | − | |
| 687 | − if (qlcnic_83xx_check(adapter) && | |
| 688 | − (tx_ring > QLCNIC_SINGLE_RING)) { | |
| 689 | − netdev_err(adapter->netdev, | |
| 690 | − "Invalid ring count, Tx ring count %d should not be greater than %d driver Tx rings.\n", | |
| 691 | − tx_ring, QLCNIC_SINGLE_RING); | |
| 692 | − return -EINVAL; | |
| 693 | − } | |
| 694 | 689 | } |
| 695 | 690 | |
| 696 | 691 | return 0; |
| @@ -948,6 +943,7 @@ static int qlcnic_irq_test(struct net_device *netdev) · 251 unmodified lines | ||
| 948 | 943 | struct qlcnic_hardware_context *ahw = adapter->ahw; |
| 949 | 944 | struct qlcnic_cmd_args cmd; |
| 950 | 945 | int ret, drv_sds_rings = adapter->drv_sds_rings; |
| 946 | + int drv_tx_rings = adapter->drv_tx_rings; | |
| 951 | 947 | |
| 952 | 948 | if (qlcnic_83xx_check(adapter)) |
| 953 | 949 | return qlcnic_83xx_interrupt_test(netdev); |
| @@ -980,6 +976,7 @@ free_diag_res: · 26 unmodified lines | ||
| 980 | 976 | |
| 981 | 977 | clear_diag_irq: |
| 982 | 978 | adapter->drv_sds_rings = drv_sds_rings; |
| 979 | + adapter->drv_tx_rings = drv_tx_rings; | |
| 983 | 980 | clear_bit(__QLCNIC_RESETTING, &adapter->state); |
| 984 | 981 | |
| 985 | 982 | return ret; |
| @@ -687,17 +687,11 @@ void qlcnic_advert_link_change(struct qlcnic_adapter *adapter, int linkup) · 686 unmodified lines | ||
| 687 | 687 | if (adapter->ahw->linkup && !linkup) { |
| 688 | 688 | netdev_info(netdev, "NIC Link is down\n"); |
| 689 | 689 | adapter->ahw->linkup = 0; |
| 690 | − if (netif_running(netdev)) { | |
| 691 | − netif_carrier_off(netdev); | |
| 692 | − netif_tx_stop_all_queues(netdev); | |
| 693 | − } | |
| 690 | + netif_carrier_off(netdev); | |
| 694 | 691 | } else if (!adapter->ahw->linkup && linkup) { |
| 695 | 692 | netdev_info(netdev, "NIC Link is up\n"); |
| 696 | 693 | adapter->ahw->linkup = 1; |
| 697 | − if (netif_running(netdev)) { | |
| 698 | − netif_carrier_on(netdev); | |
| 699 | − netif_wake_queue(netdev); | |
| 700 | − } | |
| 694 | + netif_carrier_on(netdev); | |
| 701 | 695 | } |
| 702 | 696 | } |
| 703 | 697 | |
| @@ -1178,6 +1178,7 @@ qlcnic_initialize_nic(struct qlcnic_adapter *adapter) · 1177 unmodified lines | ||
| 1178 | 1178 | } else { |
| 1179 | 1179 | adapter->ahw->nic_mode = QLCNIC_DEFAULT_MODE; |
| 1180 | 1180 | adapter->max_tx_rings = QLCNIC_MAX_HW_TX_RINGS; |
| 1181 | + adapter->max_sds_rings = QLCNIC_MAX_SDS_RINGS; | |
| 1181 | 1182 | adapter->flags &= ~QLCNIC_ESWITCH_ENABLED; |
| 1182 | 1183 | } |
| 1183 | 1184 | |
| @@ -1940,7 +1941,6 @@ int qlcnic_diag_alloc_res(struct net_device *netdev, int test) · 756 unmodified lines | ||
| 1940 | 1941 | qlcnic_detach(adapter); |
| 1941 | 1942 | |
| 1942 | 1943 | adapter->drv_sds_rings = QLCNIC_SINGLE_RING; |
| 1943 | − adapter->drv_tx_rings = QLCNIC_SINGLE_RING; | |
| 1944 | 1944 | adapter->ahw->diag_test = test; |
| 1945 | 1945 | adapter->ahw->linkup = 0; |
| 1946 | 1946 | |
| @@ -327,7 +327,6 @@ static int netvsc_change_mtu(struct net_device *ndev, int mtu) · 326 unmodified lines | ||
| 327 | 327 | return -EINVAL; |
| 328 | 328 | |
| 329 | 329 | nvdev->start_remove = true; |
| 330 | − cancel_delayed_work_sync(&ndevctx->dwork); | |
| 331 | 330 | cancel_work_sync(&ndevctx->work); |
| 332 | 331 | netif_tx_disable(ndev); |
| 333 | 332 | rndis_filter_device_remove(hdev); |
| @@ -1197,6 +1197,9 @@ static int checksum_setup_ip(struct xenvif *vif, struct sk_buff *skb, · 1196 unmodified lines | ||
| 1197 | 1197 | |
| 1198 | 1198 | err = -EPROTO; |
| 1199 | 1199 | |
| 1200 | + if (fragment) | |
| 1201 | + goto out; | |
| 1202 | + | |
| 1200 | 1203 | switch (ip_hdr(skb)->protocol) { |
| 1201 | 1204 | case IPPROTO_TCP: |
| 1202 | 1205 | err = maybe_pull_tail(skb, |
| @@ -24,8 +24,8 @@ config PHY_EXYNOS_MIPI_VIDEO · 23 unmodified lines | ||
| 24 | 24 | config OMAP_USB2 |
| 25 | 25 | tristate "OMAP USB2 PHY Driver" |
| 26 | 26 | depends on ARCH_OMAP2PLUS |
| 27 | + depends on USB_PHY | |
| 27 | 28 | select GENERIC_PHY |
| 28 | − select USB_PHY | |
| 29 | 29 | select OMAP_CONTROL_USB |
| 30 | 30 | help |
| 31 | 31 | Enable this to support the transceiver that is part of SOC. This |
| @@ -36,8 +36,8 @@ config OMAP_USB2 · 4 unmodified lines | ||
| 36 | 36 | config TWL4030_USB |
| 37 | 37 | tristate "TWL4030 USB Transceiver Driver" |
| 38 | 38 | depends on TWL4030_CORE && REGULATOR_TWL4030 && USB_MUSB_OMAP2PLUS |
| 39 | + depends on USB_PHY | |
| 39 | 40 | select GENERIC_PHY |
| 40 | − select USB_PHY | |
| 41 | 41 | help |
| 42 | 42 | Enable this to support the USB OTG transceiver on TWL4030 |
| 43 | 43 | family chips (including the TWL5030 and TPS659x0 devices). |
| @@ -437,23 +437,18 @@ struct phy *phy_create(struct device *dev, const struct phy_ops *ops, · 436 unmodified lines | ||
| 437 | 437 | int id; |
| 438 | 438 | struct phy *phy; |
| 439 | 439 | |
| 440 | − if (!dev) { | |
| 441 | − dev_WARN(dev, "no device provided for PHY\n"); | |
| 442 | − ret = -EINVAL; | |
| 443 | − goto err0; | |
| 444 | − } | |
| 440 | + if (WARN_ON(!dev)) | |
| 441 | + return ERR_PTR(-EINVAL); | |
| 445 | 442 | |
| 446 | 443 | phy = kzalloc(sizeof(*phy), GFP_KERNEL); |
| 447 | − if (!phy) { | |
| 448 | − ret = -ENOMEM; | |
| 449 | − goto err0; | |
| 450 | − } | |
| 444 | + if (!phy) | |
| 445 | + return ERR_PTR(-ENOMEM); | |
| 451 | 446 | |
| 452 | 447 | id = ida_simple_get(&phy_ida, 0, 0, GFP_KERNEL); |
| 453 | 448 | if (id < 0) { |
| 454 | 449 | dev_err(dev, "unable to get id\n"); |
| 455 | 450 | ret = id; |
| 456 | − goto err0; | |
| 451 | + goto free_phy; | |
| 457 | 452 | } |
| 458 | 453 | |
| 459 | 454 | device_initialize(&phy->dev); |
| @@ -468,11 +463,11 @@ struct phy *phy_create(struct device *dev, const struct phy_ops *ops, · 8 unmodified lines | ||
| 468 | 463 | |
| 469 | 464 | ret = dev_set_name(&phy->dev, "phy-%s.%d", dev_name(dev), id); |
| 470 | 465 | if (ret) |
| 471 | − goto err1; | |
| 466 | + goto put_dev; | |
| 472 | 467 | |
| 473 | 468 | ret = device_add(&phy->dev); |
| 474 | 469 | if (ret) |
| 475 | − goto err1; | |
| 470 | + goto put_dev; | |
| 476 | 471 | |
| 477 | 472 | if (pm_runtime_enabled(dev)) { |
| 478 | 473 | pm_runtime_enable(&phy->dev); |
| @@ -481,12 +476,11 @@ struct phy *phy_create(struct device *dev, const struct phy_ops *ops, · 2 unmodified lines | ||
| 481 | 476 | |
| 482 | 477 | return phy; |
| 483 | 478 | |
| 484 | −err1: | |
| 485 | − ida_remove(&phy_ida, phy->id); | |
| 479 | +put_dev: | |
| 486 | 480 | put_device(&phy->dev); |
| 481 | + ida_remove(&phy_ida, phy->id); | |
| 482 | +free_phy: | |
| 487 | 483 | kfree(phy); |
| 488 | − | |
| 489 | −err0: | |
| 490 | 484 | return ERR_PTR(ret); |
| 491 | 485 | } |
| 492 | 486 | EXPORT_SYMBOL_GPL(phy_create); |
| @@ -512,6 +512,7 @@ static const struct dev_pm_ops byt_gpio_pm_ops = { · 511 unmodified lines | ||
| 512 | 512 | |
| 513 | 513 | static const struct acpi_device_id byt_gpio_acpi_match[] = { |
| 514 | 514 | { "INT33B2", 0 }, |
| 515 | + { "INT33FC", 0 }, | |
| 515 | 516 | { } |
| 516 | 517 | }; |
| 517 | 518 | MODULE_DEVICE_TABLE(acpi, byt_gpio_acpi_match); |
| @@ -254,7 +254,7 @@ struct sh_pfc_soc_info { · 253 unmodified lines | ||
| 254 | 254 | #define PINMUX_GPIO(_pin) \ |
| 255 | 255 | [GPIO_##_pin] = { \ |
| 256 | 256 | .pin = (u16)-1, \ |
| 257 | − .name = __stringify(name), \ | |
| 257 | + .name = __stringify(GPIO_##_pin), \ | |
| 258 | 258 | .enum_id = _pin##_DATA, \ |
| 259 | 259 | } |
| 260 | 260 | |
| @@ -833,6 +833,11 @@ static int rapl_write_data_raw(struct rapl_domain *rd, · 832 unmodified lines | ||
| 833 | 833 | return 0; |
| 834 | 834 | } |
| 835 | 835 | |
| 836 | +static const struct x86_cpu_id energy_unit_quirk_ids[] = { | |
| 837 | + { X86_VENDOR_INTEL, 6, 0x37},/* VLV */ | |
| 838 | + {} | |
| 839 | +}; | |
| 840 | + | |
| 836 | 841 | static int rapl_check_unit(struct rapl_package *rp, int cpu) |
| 837 | 842 | { |
| 838 | 843 | u64 msr_val; |
| @@ -853,8 +858,11 @@ static int rapl_check_unit(struct rapl_package *rp, int cpu) · 14 unmodified lines | ||
| 853 | 858 | * time unit: 1/time_unit_divisor Seconds |
| 854 | 859 | */ |
| 855 | 860 | value = (msr_val & ENERGY_UNIT_MASK) >> ENERGY_UNIT_OFFSET; |
| 856 | − rp->energy_unit_divisor = 1 << value; | |
| 857 | − | |
| 861 | + /* some CPUs have different way to calculate energy unit */ | |
| 862 | + if (x86_match_cpu(energy_unit_quirk_ids)) | |
| 863 | + rp->energy_unit_divisor = 1000000 / (1 << value); | |
| 864 | + else | |
| 865 | + rp->energy_unit_divisor = 1 << value; | |
| 858 | 866 | |
| 859 | 867 | value = (msr_val & POWER_UNIT_MASK) >> POWER_UNIT_OFFSET; |
| 860 | 868 | rp->power_unit_divisor = 1 << value; |
| @@ -941,6 +949,7 @@ static void package_power_limit_irq_restore(int package_id) · 80 unmodified lines | ||
| 941 | 949 | static const struct x86_cpu_id rapl_ids[] = { |
| 942 | 950 | { X86_VENDOR_INTEL, 6, 0x2a},/* SNB */ |
| 943 | 951 | { X86_VENDOR_INTEL, 6, 0x2d},/* SNB EP */ |
| 952 | + { X86_VENDOR_INTEL, 6, 0x37},/* VLV */ | |
| 944 | 953 | { X86_VENDOR_INTEL, 6, 0x3a},/* IVB */ |
| 945 | 954 | { X86_VENDOR_INTEL, 6, 0x45},/* HSW */ |
| 946 | 955 | /* TODO: Add more CPU IDs after testing */ |
| @@ -438,7 +438,7 @@ common_reg: · 437 unmodified lines | ||
| 438 | 438 | platform_set_drvdata(pdev, s2mps11); |
| 439 | 439 | |
| 440 | 440 | config.dev = &pdev->dev; |
| 441 | − config.regmap = iodev->regmap; | |
| 441 | + config.regmap = iodev->regmap_pmic; | |
| 442 | 442 | config.driver_data = s2mps11; |
| 443 | 443 | for (i = 0; i < S2MPS11_REGULATOR_MAX; i++) { |
| 444 | 444 | if (!reg_np) { |
| @@ -471,7 +471,7 @@ static void qlt_schedule_sess_for_deletion(struct qla_tgt_sess *sess, · 470 unmodified lines | ||
| 471 | 471 | schedule_delayed_work(&tgt->sess_del_work, 0); |
| 472 | 472 | else |
| 473 | 473 | schedule_delayed_work(&tgt->sess_del_work, |
| 474 | − jiffies - sess->expires); | |
| 474 | + sess->expires - jiffies); | |
| 475 | 475 | } |
| 476 | 476 | |
| 477 | 477 | /* ha->hardware_lock supposed to be held on entry */ |
| @@ -550,13 +550,14 @@ static void qlt_del_sess_work_fn(struct delayed_work *work) · 72 unmodified lines | ||
| 550 | 550 | struct scsi_qla_host *vha = tgt->vha; |
| 551 | 551 | struct qla_hw_data *ha = vha->hw; |
| 552 | 552 | struct qla_tgt_sess *sess; |
| 553 | − unsigned long flags; | |
| 553 | + unsigned long flags, elapsed; | |
| 554 | 554 | |
| 555 | 555 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 556 | 556 | while (!list_empty(&tgt->del_sess_list)) { |
| 557 | 557 | sess = list_entry(tgt->del_sess_list.next, typeof(*sess), |
| 558 | 558 | del_list_entry); |
| 559 | − if (time_after_eq(jiffies, sess->expires)) { | |
| 559 | + elapsed = jiffies; | |
| 560 | + if (time_after_eq(elapsed, sess->expires)) { | |
| 560 | 561 | qlt_undelete_sess(sess); |
| 561 | 562 | |
| 562 | 563 | ql_dbg(ql_dbg_tgt_mgt, vha, 0xf004, |
| @@ -566,7 +567,7 @@ static void qlt_del_sess_work_fn(struct delayed_work *work) · 3 unmodified lines | ||
| 566 | 567 | ha->tgt.tgt_ops->put_sess(sess); |
| 567 | 568 | } else { |
| 568 | 569 | schedule_delayed_work(&tgt->sess_del_work, |
| 569 | − jiffies - sess->expires); | |
| 570 | + sess->expires - elapsed); | |
| 570 | 571 | break; |
| 571 | 572 | } |
| 572 | 573 | } |
| @@ -4290,6 +4291,7 @@ int qlt_lport_register(struct qla_tgt_func_tmpl *qla_tgt_ops, u64 wwpn, · 3717 unmodified lines | ||
| 4290 | 4291 | if (rc != 0) { |
| 4291 | 4292 | ha->tgt.tgt_ops = NULL; |
| 4292 | 4293 | ha->tgt.target_lport_ptr = NULL; |
| 4294 | + scsi_host_put(host); | |
| 4293 | 4295 | } |
| 4294 | 4296 | mutex_unlock(&qla_tgt_mutex); |
| 4295 | 4297 | return rc; |
| @@ -446,7 +446,7 @@ int comedi_load_firmware(struct comedi_device *dev, · 445 unmodified lines | ||
| 446 | 446 | release_firmware(fw); |
| 447 | 447 | } |
| 448 | 448 | |
| 449 | − return ret; | |
| 449 | + return ret < 0 ? ret : 0; | |
| 450 | 450 | } |
| 451 | 451 | EXPORT_SYMBOL_GPL(comedi_load_firmware); |
| 452 | 452 | |
| @@ -63,7 +63,8 @@ enum pci_8255_boardid { · 62 unmodified lines | ||
| 63 | 63 | BOARD_ADLINK_PCI7296, |
| 64 | 64 | BOARD_CB_PCIDIO24, |
| 65 | 65 | BOARD_CB_PCIDIO24H, |
| 66 | − BOARD_CB_PCIDIO48H, | |
| 66 | + BOARD_CB_PCIDIO48H_OLD, | |
| 67 | + BOARD_CB_PCIDIO48H_NEW, | |
| 67 | 68 | BOARD_CB_PCIDIO96H, |
| 68 | 69 | BOARD_NI_PCIDIO96, |
| 69 | 70 | BOARD_NI_PCIDIO96B, |
| @@ -106,11 +107,16 @@ static const struct pci_8255_boardinfo pci_8255_boards[] = { · 36 unmodified lines | ||
| 106 | 107 | .dio_badr = 2, |
| 107 | 108 | .n_8255 = 1, |
| 108 | 109 | }, |
| 109 | − [BOARD_CB_PCIDIO48H] = { | |
| 110 | + [BOARD_CB_PCIDIO48H_OLD] = { | |
| 110 | 111 | .name = "cb_pci-dio48h", |
| 111 | 112 | .dio_badr = 1, |
| 112 | 113 | .n_8255 = 2, |
| 113 | 114 | }, |
| 115 | + [BOARD_CB_PCIDIO48H_NEW] = { | |
| 116 | + .name = "cb_pci-dio48h", | |
| 117 | + .dio_badr = 2, | |
| 118 | + .n_8255 = 2, | |
| 119 | + }, | |
| 114 | 120 | [BOARD_CB_PCIDIO96H] = { |
| 115 | 121 | .name = "cb_pci-dio96h", |
| 116 | 122 | .dio_badr = 2, |
| @@ -263,7 +269,10 @@ static DEFINE_PCI_DEVICE_TABLE(pci_8255_pci_table) = { · 146 unmodified lines | ||
| 263 | 269 | { PCI_VDEVICE(ADLINK, 0x7296), BOARD_ADLINK_PCI7296 }, |
| 264 | 270 | { PCI_VDEVICE(CB, 0x0028), BOARD_CB_PCIDIO24 }, |
| 265 | 271 | { PCI_VDEVICE(CB, 0x0014), BOARD_CB_PCIDIO24H }, |
| 266 | − { PCI_VDEVICE(CB, 0x000b), BOARD_CB_PCIDIO48H }, | |
| 272 | + { PCI_DEVICE_SUB(PCI_VENDOR_ID_CB, 0x000b, 0x0000, 0x0000), | |
| 273 | + .driver_data = BOARD_CB_PCIDIO48H_OLD }, | |
| 274 | + { PCI_DEVICE_SUB(PCI_VENDOR_ID_CB, 0x000b, PCI_VENDOR_ID_CB, 0x000b), | |
| 275 | + .driver_data = BOARD_CB_PCIDIO48H_NEW }, | |
| 267 | 276 | { PCI_VDEVICE(CB, 0x0017), BOARD_CB_PCIDIO96H }, |
| 268 | 277 | { PCI_VDEVICE(NI, 0x0160), BOARD_NI_PCIDIO96 }, |
| 269 | 278 | { PCI_VDEVICE(NI, 0x1630), BOARD_NI_PCIDIO96B }, |
| @@ -451,7 +451,12 @@ done: · 450 unmodified lines | ||
| 451 | 451 | .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) | \ |
| 452 | 452 | BIT(IIO_CHAN_INFO_SAMP_FREQ), \ |
| 453 | 453 | .scan_index = idx, \ |
| 454 | − .scan_type = IIO_ST('s', 16, 16, IIO_BE), \ | |
| 454 | + .scan_type = { \ | |
| 455 | + .sign = 's', \ | |
| 456 | + .realbits = 16, \ | |
| 457 | + .storagebits = 16, \ | |
| 458 | + .endianness = IIO_BE, \ | |
| 459 | + }, \ | |
| 455 | 460 | } |
| 456 | 461 | |
| 457 | 462 | static const struct iio_chan_spec hmc5843_channels[] = { |
| @@ -88,8 +88,9 @@ static int imx_drm_driver_unload(struct drm_device *drm) · 87 unmodified lines | ||
| 88 | 88 | |
| 89 | 89 | imx_drm_device_put(); |
| 90 | 90 | |
| 91 | − drm_mode_config_cleanup(imxdrm->drm); | |
| 91 | + drm_vblank_cleanup(imxdrm->drm); | |
| 92 | 92 | drm_kms_helper_poll_fini(imxdrm->drm); |
| 93 | + drm_mode_config_cleanup(imxdrm->drm); | |
| 93 | 94 | |
| 94 | 95 | return 0; |
| 95 | 96 | } |
| @@ -199,8 +200,8 @@ static void imx_drm_driver_preclose(struct drm_device *drm, · 103 unmodified lines | ||
| 199 | 200 | if (!file->is_master) |
| 200 | 201 | return; |
| 201 | 202 | |
| 202 | − for (i = 0; i < 4; i++) | |
| 203 | − imx_drm_disable_vblank(drm , i); | |
| 203 | + for (i = 0; i < MAX_CRTC; i++) | |
| 204 | + imx_drm_disable_vblank(drm, i); | |
| 204 | 205 | } |
| 205 | 206 | |
| 206 | 207 | static const struct file_operations imx_drm_driver_fops = { |
| @@ -376,8 +377,6 @@ static int imx_drm_crtc_register(struct imx_drm_crtc *imx_drm_crtc) · 169 unmodified lines | ||
| 376 | 377 | struct imx_drm_device *imxdrm = __imx_drm_device(); |
| 377 | 378 | int ret; |
| 378 | 379 | |
| 379 | − drm_crtc_init(imxdrm->drm, imx_drm_crtc->crtc, | |
| 380 | − imx_drm_crtc->imx_drm_helper_funcs.crtc_funcs); | |
| 381 | 380 | ret = drm_mode_crtc_set_gamma_size(imx_drm_crtc->crtc, 256); |
| 382 | 381 | if (ret) |
| 383 | 382 | return ret; |
| @@ -385,6 +384,9 @@ static int imx_drm_crtc_register(struct imx_drm_crtc *imx_drm_crtc) · 1 unmodified line | ||
| 385 | 384 | drm_crtc_helper_add(imx_drm_crtc->crtc, |
| 386 | 385 | imx_drm_crtc->imx_drm_helper_funcs.crtc_helper_funcs); |
| 387 | 386 | |
| 387 | + drm_crtc_init(imxdrm->drm, imx_drm_crtc->crtc, | |
| 388 | + imx_drm_crtc->imx_drm_helper_funcs.crtc_funcs); | |
| 389 | + | |
| 388 | 390 | drm_mode_group_reinit(imxdrm->drm); |
| 389 | 391 | |
| 390 | 392 | return 0; |
| @@ -428,11 +430,11 @@ static int imx_drm_driver_load(struct drm_device *drm, unsigned long flags) · 37 unmodified lines | ||
| 428 | 430 | ret = drm_mode_group_init_legacy_group(imxdrm->drm, |
| 429 | 431 | &imxdrm->drm->primary->mode_group); |
| 430 | 432 | if (ret) |
| 431 | − goto err_init; | |
| 433 | + goto err_kms; | |
| 432 | 434 | |
| 433 | 435 | ret = drm_vblank_init(imxdrm->drm, MAX_CRTC); |
| 434 | 436 | if (ret) |
| 435 | − goto err_init; | |
| 437 | + goto err_kms; | |
| 436 | 438 | |
| 437 | 439 | /* |
| 438 | 440 | * with vblank_disable_allowed = true, vblank interrupt will be disabled |
| @@ -441,12 +443,19 @@ static int imx_drm_driver_load(struct drm_device *drm, unsigned long flags) · 2 unmodified lines | ||
| 441 | 443 | */ |
| 442 | 444 | imxdrm->drm->vblank_disable_allowed = true; |
| 443 | 445 | |
| 444 | − if (!imx_drm_device_get()) | |
| 446 | + if (!imx_drm_device_get()) { | |
| 445 | 447 | ret = -EINVAL; |
| 448 | + goto err_vblank; | |
| 449 | + } | |
| 446 | 450 | |
| 447 | − ret = 0; | |
| 451 | + mutex_unlock(&imxdrm->mutex); | |
| 452 | + return 0; | |
| 448 | 453 | |
| 449 | −err_init: | |
| 454 | +err_vblank: | |
| 455 | + drm_vblank_cleanup(drm); | |
| 456 | +err_kms: | |
| 457 | + drm_kms_helper_poll_fini(drm); | |
| 458 | + drm_mode_config_cleanup(drm); | |
| 450 | 459 | mutex_unlock(&imxdrm->mutex); |
| 451 | 460 | |
| 452 | 461 | return ret; |
| @@ -492,6 +501,15 @@ int imx_drm_add_crtc(struct drm_crtc *crtc, · 39 unmodified lines | ||
| 492 | 501 | |
| 493 | 502 | mutex_lock(&imxdrm->mutex); |
| 494 | 503 | |
| 504 | + /* | |
| 505 | + * The vblank arrays are dimensioned by MAX_CRTC - we can't | |
| 506 | + * pass IDs greater than this to those functions. | |
| 507 | + */ | |
| 508 | + if (imxdrm->pipes >= MAX_CRTC) { | |
| 509 | + ret = -EINVAL; | |
| 510 | + goto err_busy; | |
| 511 | + } | |
| 512 | + | |
| 495 | 513 | if (imxdrm->drm->open_count) { |
| 496 | 514 | ret = -EBUSY; |
| 497 | 515 | goto err_busy; |
| @@ -528,6 +546,7 @@ int imx_drm_add_crtc(struct drm_crtc *crtc, · 30 unmodified lines | ||
| 528 | 546 | return 0; |
| 529 | 547 | |
| 530 | 548 | err_register: |
| 549 | + list_del(&imx_drm_crtc->list); | |
| 531 | 550 | kfree(imx_drm_crtc); |
| 532 | 551 | err_alloc: |
| 533 | 552 | err_busy: |
| @@ -114,7 +114,6 @@ struct imx_tve { · 113 unmodified lines | ||
| 114 | 114 | struct drm_encoder encoder; |
| 115 | 115 | struct imx_drm_encoder *imx_drm_encoder; |
| 116 | 116 | struct device *dev; |
| 117 | − spinlock_t enable_lock; /* serializes tve_enable/disable */ | |
| 118 | 117 | spinlock_t lock; /* register lock */ |
| 119 | 118 | bool enabled; |
| 120 | 119 | int mode; |
| @@ -146,10 +145,8 @@ __releases(&tve->lock) · 25 unmodified lines | ||
| 146 | 145 | |
| 147 | 146 | static void tve_enable(struct imx_tve *tve) |
| 148 | 147 | { |
| 149 | − unsigned long flags; | |
| 150 | 148 | int ret; |
| 151 | 149 | |
| 152 | − spin_lock_irqsave(&tve->enable_lock, flags); | |
| 153 | 150 | if (!tve->enabled) { |
| 154 | 151 | tve->enabled = true; |
| 155 | 152 | clk_prepare_enable(tve->clk); |
| @@ -169,23 +166,18 @@ static void tve_enable(struct imx_tve *tve) · 13 unmodified lines | ||
| 169 | 166 | TVE_CD_SM_IEN | |
| 170 | 167 | TVE_CD_LM_IEN | |
| 171 | 168 | TVE_CD_MON_END_IEN); |
| 172 | − | |
| 173 | − spin_unlock_irqrestore(&tve->enable_lock, flags); | |
| 174 | 169 | } |
| 175 | 170 | |
| 176 | 171 | static void tve_disable(struct imx_tve *tve) |
| 177 | 172 | { |
| 178 | − unsigned long flags; | |
| 179 | 173 | int ret; |
| 180 | 174 | |
| 181 | − spin_lock_irqsave(&tve->enable_lock, flags); | |
| 182 | 175 | if (tve->enabled) { |
| 183 | 176 | tve->enabled = false; |
| 184 | 177 | ret = regmap_update_bits(tve->regmap, TVE_COM_CONF_REG, |
| 185 | 178 | TVE_IPU_CLK_EN | TVE_EN, 0); |
| 186 | 179 | clk_disable_unprepare(tve->clk); |
| 187 | 180 | } |
| 188 | − spin_unlock_irqrestore(&tve->enable_lock, flags); | |
| 189 | 181 | } |
| 190 | 182 | |
| 191 | 183 | static int tve_setup_tvout(struct imx_tve *tve) |
| @@ -601,7 +593,6 @@ static int imx_tve_probe(struct platform_device *pdev) · 409 unmodified lines | ||
| 601 | 593 | |
| 602 | 594 | tve->dev = &pdev->dev; |
| 603 | 595 | spin_lock_init(&tve->lock); |
| 604 | − spin_lock_init(&tve->enable_lock); | |
| 605 | 596 | |
| 606 | 597 | ddc_node = of_parse_phandle(np, "ddc", 0); |
| 607 | 598 | if (ddc_node) { |
| @@ -996,35 +996,35 @@ static const struct ipu_platform_reg client_reg[] = { · 995 unmodified lines | ||
| 996 | 996 | }, |
| 997 | 997 | }; |
| 998 | 998 | |
| 999 | +static DEFINE_MUTEX(ipu_client_id_mutex); | |
| 999 | 1000 | static int ipu_client_id; |
| 1000 | 1001 | |
| 1001 | −static int ipu_add_subdevice_pdata(struct device *dev, | |
| 1002 | − const struct ipu_platform_reg *reg) | |
| 1003 | −{ | |
| 1004 | − struct platform_device *pdev; | |
| 1005 | − | |
| 1006 | − pdev = platform_device_register_data(dev, reg->name, ipu_client_id++, | |
| 1007 | − ®->pdata, sizeof(struct ipu_platform_reg)); | |
| 1008 | − | |
| 1009 | − return PTR_ERR_OR_ZERO(pdev); | |
| 1010 | −} | |
| 1011 | − | |
| 1012 | 1002 | static int ipu_add_client_devices(struct ipu_soc *ipu) |
| 1013 | 1003 | { |
| 1014 | − int ret; | |
| 1015 | − int i; | |
| 1004 | + struct device *dev = ipu->dev; | |
| 1005 | + unsigned i; | |
| 1006 | + int id, ret; | |
| 1007 | + | |
| 1008 | + mutex_lock(&ipu_client_id_mutex); | |
| 1009 | + id = ipu_client_id; | |
| 1010 | + ipu_client_id += ARRAY_SIZE(client_reg); | |
| 1011 | + mutex_unlock(&ipu_client_id_mutex); | |
| 1016 | 1012 | |
| 1017 | 1013 | for (i = 0; i < ARRAY_SIZE(client_reg); i++) { |
| 1018 | 1014 | const struct ipu_platform_reg *reg = &client_reg[i]; |
| 1019 | − ret = ipu_add_subdevice_pdata(ipu->dev, reg); | |
| 1020 | − if (ret) | |
| 1015 | + struct platform_device *pdev; | |
| 1016 | + | |
| 1017 | + pdev = platform_device_register_data(dev, reg->name, | |
| 1018 | + id++, ®->pdata, sizeof(reg->pdata)); | |
| 1019 | + | |
| 1020 | + if (IS_ERR(pdev)) | |
| 1021 | 1021 | goto err_register; |
| 1022 | 1022 | } |
| 1023 | 1023 | |
| 1024 | 1024 | return 0; |
| 1025 | 1025 | |
| 1026 | 1026 | err_register: |
| 1027 | − platform_device_unregister_children(to_platform_device(ipu->dev)); | |
| 1027 | + platform_device_unregister_children(to_platform_device(dev)); | |
| 1028 | 1028 | |
| 1029 | 1029 | return ret; |
| 1030 | 1030 | } |
| @@ -465,6 +465,7 @@ int iscsit_del_np(struct iscsi_np *np) · 464 unmodified lines | ||
| 465 | 465 | */ |
| 466 | 466 | send_sig(SIGINT, np->np_thread, 1); |
| 467 | 467 | kthread_stop(np->np_thread); |
| 468 | + np->np_thread = NULL; | |
| 468 | 469 | } |
| 469 | 470 | |
| 470 | 471 | np->np_transport->iscsit_free_np(np); |
| @@ -823,24 +824,22 @@ int iscsit_setup_scsi_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd, · 352 unmodified lines | ||
| 823 | 824 | if (((hdr->flags & ISCSI_FLAG_CMD_READ) || |
| 824 | 825 | (hdr->flags & ISCSI_FLAG_CMD_WRITE)) && !hdr->data_length) { |
| 825 | 826 | /* |
| 826 | − * Vmware ESX v3.0 uses a modified Cisco Initiator (v3.4.2) | |
| 827 | − * that adds support for RESERVE/RELEASE. There is a bug | |
| 828 | − * add with this new functionality that sets R/W bits when | |
| 829 | − * neither CDB carries any READ or WRITE datapayloads. | |
| 827 | + * From RFC-3720 Section 10.3.1: | |
| 828 | + * | |
| 829 | + * "Either or both of R and W MAY be 1 when either the | |
| 830 | + * Expected Data Transfer Length and/or Bidirectional Read | |
| 831 | + * Expected Data Transfer Length are 0" | |
| 832 | + * | |
| 833 | + * For this case, go ahead and clear the unnecssary bits | |
| 834 | + * to avoid any confusion with ->data_direction. | |
| 830 | 835 | */ |
| 831 | − if ((hdr->cdb[0] == 0x16) || (hdr->cdb[0] == 0x17)) { | |
| 832 | − hdr->flags &= ~ISCSI_FLAG_CMD_READ; | |
| 833 | − hdr->flags &= ~ISCSI_FLAG_CMD_WRITE; | |
| 834 | − goto done; | |
| 835 | − } | |
| 836 | + hdr->flags &= ~ISCSI_FLAG_CMD_READ; | |
| 837 | + hdr->flags &= ~ISCSI_FLAG_CMD_WRITE; | |
| 836 | 838 | |
| 837 | − pr_err("ISCSI_FLAG_CMD_READ or ISCSI_FLAG_CMD_WRITE" | |
| 839 | + pr_warn("ISCSI_FLAG_CMD_READ or ISCSI_FLAG_CMD_WRITE" | |
| 838 | 840 | " set when Expected Data Transfer Length is 0 for" |
| 839 | − " CDB: 0x%02x. Bad iSCSI Initiator.\n", hdr->cdb[0]); | |
| 840 | − return iscsit_add_reject_cmd(cmd, | |
| 841 | − ISCSI_REASON_BOOKMARK_INVALID, buf); | |
| 841 | + " CDB: 0x%02x, Fixing up flags\n", hdr->cdb[0]); | |
| 842 | 842 | } |
| 843 | −done: | |
| 844 | 843 | |
| 845 | 844 | if (!(hdr->flags & ISCSI_FLAG_CMD_READ) && |
| 846 | 845 | !(hdr->flags & ISCSI_FLAG_CMD_WRITE) && (hdr->data_length != 0)) { |
| @@ -474,7 +474,8 @@ static ssize_t __iscsi_##prefix##_store_##name( \ · 473 unmodified lines | ||
| 474 | 474 | \ |
| 475 | 475 | if (!capable(CAP_SYS_ADMIN)) \ |
| 476 | 476 | return -EPERM; \ |
| 477 | − \ | |
| 477 | + if (count >= sizeof(auth->name)) \ | |
| 478 | + return -EINVAL; \ | |
| 478 | 479 | snprintf(auth->name, sizeof(auth->name), "%s", page); \ |
| 479 | 480 | if (!strncmp("NULL", auth->name, 4)) \ |
| 480 | 481 | auth->naf_flags &= ~flags; \ |
| @@ -1403,11 +1403,6 @@ old_sess_out: · 1402 unmodified lines | ||
| 1403 | 1403 | |
| 1404 | 1404 | out: |
| 1405 | 1405 | stop = kthread_should_stop(); |
| 1406 | − if (!stop && signal_pending(current)) { | |
| 1407 | − spin_lock_bh(&np->np_thread_lock); | |
| 1408 | − stop = (np->np_thread_state == ISCSI_NP_THREAD_SHUTDOWN); | |
| 1409 | − spin_unlock_bh(&np->np_thread_lock); | |
| 1410 | − } | |
| 1411 | 1406 | /* Wait for another socket.. */ |
| 1412 | 1407 | if (!stop) |
| 1413 | 1408 | return 1; |
| @@ -1415,7 +1410,6 @@ exit: · 1 unmodified line | ||
| 1415 | 1410 | iscsi_stop_login_thread_timer(np); |
| 1416 | 1411 | spin_lock_bh(&np->np_thread_lock); |
| 1417 | 1412 | np->np_thread_state = ISCSI_NP_THREAD_EXIT; |
| 1418 | − np->np_thread = NULL; | |
| 1419 | 1413 | spin_unlock_bh(&np->np_thread_lock); |
| 1420 | 1414 | |
| 1421 | 1415 | return 0; |
| @@ -1106,6 +1106,11 @@ int se_dev_set_block_size(struct se_device *dev, u32 block_size) · 1105 unmodified lines | ||
| 1106 | 1106 | dev->dev_attrib.block_size = block_size; |
| 1107 | 1107 | pr_debug("dev[%p]: SE Device block_size changed to %u\n", |
| 1108 | 1108 | dev, block_size); |
| 1109 | + | |
| 1110 | + if (dev->dev_attrib.max_bytes_per_io) | |
| 1111 | + dev->dev_attrib.hw_max_sectors = | |
| 1112 | + dev->dev_attrib.max_bytes_per_io / block_size; | |
| 1113 | + | |
| 1109 | 1114 | return 0; |
| 1110 | 1115 | } |
| 1111 | 1116 | |
| @@ -66,9 +66,8 @@ static int fd_attach_hba(struct se_hba *hba, u32 host_id) · 65 unmodified lines | ||
| 66 | 66 | pr_debug("CORE_HBA[%d] - TCM FILEIO HBA Driver %s on Generic" |
| 67 | 67 | " Target Core Stack %s\n", hba->hba_id, FD_VERSION, |
| 68 | 68 | TARGET_CORE_MOD_VERSION); |
| 69 | − pr_debug("CORE_HBA[%d] - Attached FILEIO HBA: %u to Generic" | |
| 70 | − " MaxSectors: %u\n", | |
| 71 | − hba->hba_id, fd_host->fd_host_id, FD_MAX_SECTORS); | |
| 69 | + pr_debug("CORE_HBA[%d] - Attached FILEIO HBA: %u to Generic\n", | |
| 70 | + hba->hba_id, fd_host->fd_host_id); | |
| 72 | 71 | |
| 73 | 72 | return 0; |
| 74 | 73 | } |
| @@ -220,7 +219,8 @@ static int fd_configure_device(struct se_device *dev) · 145 unmodified lines | ||
| 220 | 219 | } |
| 221 | 220 | |
| 222 | 221 | dev->dev_attrib.hw_block_size = fd_dev->fd_block_size; |
| 223 | − dev->dev_attrib.hw_max_sectors = FD_MAX_SECTORS; | |
| 222 | + dev->dev_attrib.max_bytes_per_io = FD_MAX_BYTES; | |
| 223 | + dev->dev_attrib.hw_max_sectors = FD_MAX_BYTES / fd_dev->fd_block_size; | |
| 224 | 224 | dev->dev_attrib.hw_queue_depth = FD_MAX_DEVICE_QUEUE_DEPTH; |
| 225 | 225 | |
| 226 | 226 | if (fd_dev->fbd_flags & FDBD_HAS_BUFFERED_IO_WCE) { |
| @@ -7,7 +7,10 @@ · 6 unmodified lines | ||
| 7 | 7 | #define FD_DEVICE_QUEUE_DEPTH 32 |
| 8 | 8 | #define FD_MAX_DEVICE_QUEUE_DEPTH 128 |
| 9 | 9 | #define FD_BLOCKSIZE 512 |
| 10 | −#define FD_MAX_SECTORS 2048 | |
| 10 | +/* | |
| 11 | + * Limited by the number of iovecs (2048) per vfs_[writev,readv] call | |
| 12 | + */ | |
| 13 | +#define FD_MAX_BYTES 8388608 | |
| 11 | 14 | |
| 12 | 15 | #define RRF_EMULATE_CDB 0x01 |
| 13 | 16 | #define RRF_GOT_LBA 0x02 |
| @@ -278,7 +278,6 @@ struct se_node_acl *core_tpg_check_initiator_node_acl( · 277 unmodified lines | ||
| 278 | 278 | snprintf(acl->initiatorname, TRANSPORT_IQN_LEN, "%s", initiatorname); |
| 279 | 279 | acl->se_tpg = tpg; |
| 280 | 280 | acl->acl_index = scsi_get_new_index(SCSI_AUTH_INTR_INDEX); |
| 281 | − spin_lock_init(&acl->stats_lock); | |
| 282 | 281 | acl->dynamic_node_acl = 1; |
| 283 | 282 | |
| 284 | 283 | tpg->se_tpg_tfo->set_default_node_attributes(acl); |
| @@ -406,7 +405,6 @@ struct se_node_acl *core_tpg_add_initiator_node_acl( · 121 unmodified lines | ||
| 406 | 405 | snprintf(acl->initiatorname, TRANSPORT_IQN_LEN, "%s", initiatorname); |
| 407 | 406 | acl->se_tpg = tpg; |
| 408 | 407 | acl->acl_index = scsi_get_new_index(SCSI_AUTH_INTR_INDEX); |
| 409 | − spin_lock_init(&acl->stats_lock); | |
| 410 | 408 | |
| 411 | 409 | tpg->se_tpg_tfo->set_default_node_attributes(acl); |
| 412 | 410 | |
| @@ -658,15 +656,9 @@ static int core_tpg_setup_virtual_lun0(struct se_portal_group *se_tpg) · 245 unmodified lines | ||
| 658 | 656 | spin_lock_init(&lun->lun_sep_lock); |
| 659 | 657 | init_completion(&lun->lun_ref_comp); |
| 660 | 658 | |
| 661 | − ret = percpu_ref_init(&lun->lun_ref, core_tpg_lun_ref_release); | |
| 662 | − if (ret < 0) | |
| 663 | − return ret; | |
| 664 | − | |
| 665 | 659 | ret = core_tpg_post_addlun(se_tpg, lun, lun_access, dev); |
| 666 | − if (ret < 0) { | |
| 667 | − percpu_ref_cancel_init(&lun->lun_ref); | |
| 660 | + if (ret < 0) | |
| 668 | 661 | return ret; |
| 669 | − } | |
| 670 | 662 | |
| 671 | 663 | return 0; |
| 672 | 664 | } |
| @@ -93,6 +93,7 @@ struct n_tty_data { · 92 unmodified lines | ||
| 93 | 93 | size_t canon_head; |
| 94 | 94 | size_t echo_head; |
| 95 | 95 | size_t echo_commit; |
| 96 | + size_t echo_mark; | |
| 96 | 97 | DECLARE_BITMAP(char_map, 256); |
| 97 | 98 | |
| 98 | 99 | /* private to n_tty_receive_overrun (single-threaded) */ |
| @@ -336,6 +337,7 @@ static void reset_buffer_flags(struct n_tty_data *ldata) · 237 unmodified lines | ||
| 336 | 337 | { |
| 337 | 338 | ldata->read_head = ldata->canon_head = ldata->read_tail = 0; |
| 338 | 339 | ldata->echo_head = ldata->echo_tail = ldata->echo_commit = 0; |
| 340 | + ldata->echo_mark = 0; | |
| 339 | 341 | ldata->line_start = 0; |
| 340 | 342 | |
| 341 | 343 | ldata->erasing = 0; |
| @@ -787,6 +789,7 @@ static void commit_echoes(struct tty_struct *tty) · 445 unmodified lines | ||
| 787 | 789 | size_t head; |
| 788 | 790 | |
| 789 | 791 | head = ldata->echo_head; |
| 792 | + ldata->echo_mark = head; | |
| 790 | 793 | old = ldata->echo_commit - ldata->echo_tail; |
| 791 | 794 | |
| 792 | 795 | /* Process committed echoes if the accumulated # of bytes |
| @@ -811,10 +814,11 @@ static void process_echoes(struct tty_struct *tty) · 18 unmodified lines | ||
| 811 | 814 | size_t echoed; |
| 812 | 815 | |
| 813 | 816 | if ((!L_ECHO(tty) && !L_ECHONL(tty)) || |
| 814 | − ldata->echo_commit == ldata->echo_tail) | |
| 817 | + ldata->echo_mark == ldata->echo_tail) | |
| 815 | 818 | return; |
| 816 | 819 | |
| 817 | 820 | mutex_lock(&ldata->output_lock); |
| 821 | + ldata->echo_commit = ldata->echo_mark; | |
| 818 | 822 | echoed = __process_echoes(tty); |
| 819 | 823 | mutex_unlock(&ldata->output_lock); |
| 820 | 824 | |
| @@ -822,6 +826,7 @@ static void process_echoes(struct tty_struct *tty) · 1 unmodified line | ||
| 822 | 826 | tty->ops->flush_chars(tty); |
| 823 | 827 | } |
| 824 | 828 | |
| 829 | +/* NB: echo_mark and echo_head should be equivalent here */ | |
| 825 | 830 | static void flush_echoes(struct tty_struct *tty) |
| 826 | 831 | { |
| 827 | 832 | struct n_tty_data *ldata = tty->disc_data; |
| @@ -96,7 +96,8 @@ static void dw8250_serial_out(struct uart_port *p, int offset, int value) · 95 unmodified lines | ||
| 96 | 96 | if (offset == UART_LCR) { |
| 97 | 97 | int tries = 1000; |
| 98 | 98 | while (tries--) { |
| 99 | − if (value == p->serial_in(p, UART_LCR)) | |
| 99 | + unsigned int lcr = p->serial_in(p, UART_LCR); | |
| 100 | + if ((value & ~UART_LCR_SPAR) == (lcr & ~UART_LCR_SPAR)) | |
| 100 | 101 | return; |
| 101 | 102 | dw8250_force_idle(p); |
| 102 | 103 | writeb(value, p->membase + (UART_LCR << p->regshift)); |
| @@ -132,7 +133,8 @@ static void dw8250_serial_out32(struct uart_port *p, int offset, int value) · 29 unmodified lines | ||
| 132 | 133 | if (offset == UART_LCR) { |
| 133 | 134 | int tries = 1000; |
| 134 | 135 | while (tries--) { |
| 135 | − if (value == p->serial_in(p, UART_LCR)) | |
| 136 | + unsigned int lcr = p->serial_in(p, UART_LCR); | |
| 137 | + if ((value & ~UART_LCR_SPAR) == (lcr & ~UART_LCR_SPAR)) | |
| 136 | 138 | return; |
| 137 | 139 | dw8250_force_idle(p); |
| 138 | 140 | writel(value, p->membase + (UART_LCR << p->regshift)); |
| @@ -455,6 +457,8 @@ MODULE_DEVICE_TABLE(of, dw8250_of_match); · 316 unmodified lines | ||
| 455 | 457 | static const struct acpi_device_id dw8250_acpi_match[] = { |
| 456 | 458 | { "INT33C4", 0 }, |
| 457 | 459 | { "INT33C5", 0 }, |
| 460 | + { "INT3434", 0 }, | |
| 461 | + { "INT3435", 0 }, | |
| 458 | 462 | { "80860F0A", 0 }, |
| 459 | 463 | { }, |
| 460 | 464 | }; |
| @@ -240,6 +240,7 @@ static irqreturn_t xuartps_isr(int irq, void *dev_id) · 239 unmodified lines | ||
| 240 | 240 | continue; |
| 241 | 241 | } |
| 242 | 242 | |
| 243 | +#ifdef SUPPORT_SYSRQ | |
| 243 | 244 | /* |
| 244 | 245 | * uart_handle_sysrq_char() doesn't work if |
| 245 | 246 | * spinlocked, for some reason |
| @@ -253,6 +254,7 @@ static irqreturn_t xuartps_isr(int irq, void *dev_id) · 7 unmodified lines | ||
| 253 | 254 | } |
| 254 | 255 | spin_lock(&port->lock); |
| 255 | 256 | } |
| 257 | +#endif | |
| 256 | 258 | |
| 257 | 259 | port->icount.rx++; |
| 258 | 260 | |
| @@ -86,11 +86,21 @@ static inline long ldsem_atomic_update(long delta, struct ld_semaphore *sem) · 85 unmodified lines | ||
| 86 | 86 | return atomic_long_add_return(delta, (atomic_long_t *)&sem->count); |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | +/* | |
| 90 | + * ldsem_cmpxchg() updates @*old with the last-known sem->count value. | |
| 91 | + * Returns 1 if count was successfully changed; @*old will have @new value. | |
| 92 | + * Returns 0 if count was not changed; @*old will have most recent sem->count | |
| 93 | + */ | |
| 89 | 94 | static inline int ldsem_cmpxchg(long *old, long new, struct ld_semaphore *sem) |
| 90 | 95 | { |
| 91 | − long tmp = *old; | |
| 92 | − *old = atomic_long_cmpxchg(&sem->count, *old, new); | |
| 93 | − return *old == tmp; | |
| 96 | + long tmp = atomic_long_cmpxchg(&sem->count, *old, new); | |
| 97 | + if (tmp == *old) { | |
| 98 | + *old = new; | |
| 99 | + return 1; | |
| 100 | + } else { | |
| 101 | + *old = tmp; | |
| 102 | + return 0; | |
| 103 | + } | |
| 94 | 104 | } |
| 95 | 105 | |
| 96 | 106 | /* |
| @@ -642,6 +642,10 @@ static int ci_hdrc_probe(struct platform_device *pdev) · 641 unmodified lines | ||
| 642 | 642 | : CI_ROLE_GADGET; |
| 643 | 643 | } |
| 644 | 644 | |
| 645 | + /* only update vbus status for peripheral */ | |
| 646 | + if (ci->role == CI_ROLE_GADGET) | |
| 647 | + ci_handle_vbus_change(ci); | |
| 648 | + | |
| 645 | 649 | ret = ci_role_start(ci, ci->role); |
| 646 | 650 | if (ret) { |
| 647 | 651 | dev_err(dev, "can't start %s role\n", ci_role(ci)->name); |
| @@ -88,7 +88,8 @@ static int host_start(struct ci_hdrc *ci) · 87 unmodified lines | ||
| 88 | 88 | return ret; |
| 89 | 89 | |
| 90 | 90 | disable_reg: |
| 91 | − regulator_disable(ci->platdata->reg_vbus); | |
| 91 | + if (ci->platdata->reg_vbus) | |
| 92 | + regulator_disable(ci->platdata->reg_vbus); | |
| 92 | 93 | |
| 93 | 94 | put_hcd: |
| 94 | 95 | usb_put_hcd(hcd); |
| @@ -1795,9 +1795,6 @@ static int udc_start(struct ci_hdrc *ci) · 1794 unmodified lines | ||
| 1795 | 1795 | pm_runtime_no_callbacks(&ci->gadget.dev); |
| 1796 | 1796 | pm_runtime_enable(&ci->gadget.dev); |
| 1797 | 1797 | |
| 1798 | − /* Update ci->vbus_active */ | |
| 1799 | − ci_handle_vbus_change(ci); | |
| 1800 | − | |
| 1801 | 1798 | return retval; |
| 1802 | 1799 | |
| 1803 | 1800 | destroy_eps: |
| @@ -854,13 +854,11 @@ static int wdm_manage_power(struct usb_interface *intf, int on) · 853 unmodified lines | ||
| 854 | 854 | { |
| 855 | 855 | /* need autopm_get/put here to ensure the usbcore sees the new value */ |
| 856 | 856 | int rv = usb_autopm_get_interface(intf); |
| 857 | − if (rv < 0) | |
| 858 | − goto err; | |
| 859 | 857 | |
| 860 | 858 | intf->needs_remote_wakeup = on; |
| 861 | − usb_autopm_put_interface(intf); | |
| 862 | −err: | |
| 863 | − return rv; | |
| 859 | + if (!rv) | |
| 860 | + usb_autopm_put_interface(intf); | |
| 861 | + return 0; | |
| 864 | 862 | } |
| 865 | 863 | |
| 866 | 864 | static int wdm_probe(struct usb_interface *intf, const struct usb_device_id *id) |
| @@ -455,9 +455,6 @@ static int dwc3_probe(struct platform_device *pdev) · 454 unmodified lines | ||
| 455 | 455 | if (IS_ERR(regs)) |
| 456 | 456 | return PTR_ERR(regs); |
| 457 | 457 | |
| 458 | − usb_phy_set_suspend(dwc->usb2_phy, 0); | |
| 459 | − usb_phy_set_suspend(dwc->usb3_phy, 0); | |
| 460 | − | |
| 461 | 458 | spin_lock_init(&dwc->lock); |
| 462 | 459 | platform_set_drvdata(pdev, dwc); |
| 463 | 460 | |
| @@ -488,6 +485,9 @@ static int dwc3_probe(struct platform_device *pdev) · 24 unmodified lines | ||
| 488 | 485 | goto err0; |
| 489 | 486 | } |
| 490 | 487 | |
| 488 | + usb_phy_set_suspend(dwc->usb2_phy, 0); | |
| 489 | + usb_phy_set_suspend(dwc->usb3_phy, 0); | |
| 490 | + | |
| 491 | 491 | ret = dwc3_event_buffers_setup(dwc); |
| 492 | 492 | if (ret) { |
| 493 | 493 | dev_err(dwc->dev, "failed to setup event buffers\n"); |
| @@ -569,6 +569,8 @@ err2: · 75 unmodified lines | ||
| 569 | 569 | dwc3_event_buffers_cleanup(dwc); |
| 570 | 570 | |
| 571 | 571 | err1: |
| 572 | + usb_phy_set_suspend(dwc->usb2_phy, 1); | |
| 573 | + usb_phy_set_suspend(dwc->usb3_phy, 1); | |
| 572 | 574 | dwc3_core_exit(dwc); |
| 573 | 575 | |
| 574 | 576 | err0: |
| @@ -136,23 +136,27 @@ static int usb_hcd_at91_probe(const struct hc_driver *driver, · 135 unmodified lines | ||
| 136 | 136 | struct ohci_hcd *ohci; |
| 137 | 137 | int retval; |
| 138 | 138 | struct usb_hcd *hcd = NULL; |
| 139 | − | |
| 140 | − if (pdev->num_resources != 2) { | |
| 141 | − pr_debug("hcd probe: invalid num_resources"); | |
| 142 | − return -ENODEV; | |
| 139 | + struct device *dev = &pdev->dev; | |
| 140 | + struct resource *res; | |
| 141 | + int irq; | |
| 142 | + | |
| 143 | + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | |
| 144 | + if (!res) { | |
| 145 | + dev_dbg(dev, "hcd probe: missing memory resource\n"); | |
| 146 | + return -ENXIO; | |
| 143 | 147 | } |
| 144 | 148 | |
| 145 | − if ((pdev->resource[0].flags != IORESOURCE_MEM) | |
| 146 | − || (pdev->resource[1].flags != IORESOURCE_IRQ)) { | |
| 147 | − pr_debug("hcd probe: invalid resource type\n"); | |
| 148 | − return -ENODEV; | |
| 149 | + irq = platform_get_irq(pdev, 0); | |
| 150 | + if (irq < 0) { | |
| 151 | + dev_dbg(dev, "hcd probe: missing irq resource\n"); | |
| 152 | + return irq; | |
| 149 | 153 | } |
| 150 | 154 | |
| 151 | 155 | hcd = usb_create_hcd(driver, &pdev->dev, "at91"); |
| 152 | 156 | if (!hcd) |
| 153 | 157 | return -ENOMEM; |
| 154 | − hcd->rsrc_start = pdev->resource[0].start; | |
| 155 | − hcd->rsrc_len = resource_size(&pdev->resource[0]); | |
| 158 | + hcd->rsrc_start = res->start; | |
| 159 | + hcd->rsrc_len = resource_size(res); | |
| 156 | 160 | |
| 157 | 161 | if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { |
| 158 | 162 | pr_debug("request_mem_region failed\n"); |
| @@ -199,7 +203,7 @@ static int usb_hcd_at91_probe(const struct hc_driver *driver, · 40 unmodified lines | ||
| 199 | 203 | ohci->num_ports = board->ports; |
| 200 | 204 | at91_start_hc(pdev); |
| 201 | 205 | |
| 202 | − retval = usb_add_hcd(hcd, pdev->resource[1].start, IRQF_SHARED); | |
| 206 | + retval = usb_add_hcd(hcd, irq, IRQF_SHARED); | |
| 203 | 207 | if (retval == 0) |
| 204 | 208 | return retval; |
| 205 | 209 | |
| @@ -128,7 +128,12 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci) · 127 unmodified lines | ||
| 128 | 128 | * any other sleep) on Haswell machines with LPT and LPT-LP |
| 129 | 129 | * with the new Intel BIOS |
| 130 | 130 | */ |
| 131 | − xhci->quirks |= XHCI_SPURIOUS_WAKEUP; | |
| 131 | + /* Limit the quirk to only known vendors, as this triggers | |
| 132 | + * yet another BIOS bug on some other machines | |
| 133 | + * https://bugzilla.kernel.org/show_bug.cgi?id=66171 | |
| 134 | + */ | |
| 135 | + if (pdev->subsystem_vendor == PCI_VENDOR_ID_HP) | |
| 136 | + xhci->quirks |= XHCI_SPURIOUS_WAKEUP; | |
| 132 | 137 | } |
| 133 | 138 | if (pdev->vendor == PCI_VENDOR_ID_ETRON && |
| 134 | 139 | pdev->device == PCI_DEVICE_ID_ASROCK_P67) { |
| @@ -19,8 +19,9 @@ config AB8500_USB · 18 unmodified lines | ||
| 19 | 19 | in host mode, low speed. |
| 20 | 20 | |
| 21 | 21 | config FSL_USB2_OTG |
| 22 | − bool "Freescale USB OTG Transceiver Driver" | |
| 22 | + tristate "Freescale USB OTG Transceiver Driver" | |
| 23 | 23 | depends on USB_EHCI_FSL && USB_FSL_USB2 && PM_RUNTIME |
| 24 | + depends on USB | |
| 24 | 25 | select USB_OTG |
| 25 | 26 | select USB_PHY |
| 26 | 27 | help |
| @@ -29,6 +30,7 @@ config FSL_USB2_OTG · 2 unmodified lines | ||
| 29 | 30 | config ISP1301_OMAP |
| 30 | 31 | tristate "Philips ISP1301 with OMAP OTG" |
| 31 | 32 | depends on I2C && ARCH_OMAP_OTG |
| 33 | + depends on USB | |
| 32 | 34 | select USB_PHY |
| 33 | 35 | help |
| 34 | 36 | If you say yes here you get support for the Philips ISP1301 |
| @@ -876,7 +876,7 @@ static int utmi_phy_probe(struct tegra_usb_phy *tegra_phy, · 875 unmodified lines | ||
| 876 | 876 | |
| 877 | 877 | tegra_phy->pad_regs = devm_ioremap(&pdev->dev, res->start, |
| 878 | 878 | resource_size(res)); |
| 879 | − if (!tegra_phy->regs) { | |
| 879 | + if (!tegra_phy->pad_regs) { | |
| 880 | 880 | dev_err(&pdev->dev, "Failed to remap UTMI Pad regs\n"); |
| 881 | 881 | return -ENOMEM; |
| 882 | 882 | } |
| @@ -127,7 +127,8 @@ static inline int twl6030_writeb(struct twl6030_usb *twl, u8 module, · 126 unmodified lines | ||
| 127 | 127 | |
| 128 | 128 | static inline u8 twl6030_readb(struct twl6030_usb *twl, u8 module, u8 address) |
| 129 | 129 | { |
| 130 | − u8 data, ret = 0; | |
| 130 | + u8 data; | |
| 131 | + int ret; | |
| 131 | 132 | |
| 132 | 133 | ret = twl_i2c_read_u8(module, &data, address); |
| 133 | 134 | if (ret >= 0) |
| @@ -251,6 +251,7 @@ static void option_instat_callback(struct urb *urb); · 250 unmodified lines | ||
| 251 | 251 | #define ZTE_PRODUCT_MF628 0x0015 |
| 252 | 252 | #define ZTE_PRODUCT_MF626 0x0031 |
| 253 | 253 | #define ZTE_PRODUCT_MC2718 0xffe8 |
| 254 | +#define ZTE_PRODUCT_AC2726 0xfff1 | |
| 254 | 255 | |
| 255 | 256 | #define BENQ_VENDOR_ID 0x04a5 |
| 256 | 257 | #define BENQ_PRODUCT_H10 0x4068 |
| @@ -1453,6 +1454,7 @@ static const struct usb_device_id option_ids[] = { · 1196 unmodified lines | ||
| 1453 | 1454 | { USB_VENDOR_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff, 0x02, 0x01) }, |
| 1454 | 1455 | { USB_VENDOR_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff, 0x02, 0x05) }, |
| 1455 | 1456 | { USB_VENDOR_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff, 0x86, 0x10) }, |
| 1457 | + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_AC2726, 0xff, 0xff, 0xff) }, | |
| 1456 | 1458 | |
| 1457 | 1459 | { USB_DEVICE(BENQ_VENDOR_ID, BENQ_PRODUCT_H10) }, |
| 1458 | 1460 | { USB_DEVICE(DLINK_VENDOR_ID, DLINK_PRODUCT_DWM_652) }, |
| @@ -281,8 +281,7 @@ static const struct usb_device_id id_table[] = { · 280 unmodified lines | ||
| 281 | 281 | { USB_DEVICE(0x19d2, 0xfffd) }, |
| 282 | 282 | { USB_DEVICE(0x19d2, 0xfffc) }, |
| 283 | 283 | { USB_DEVICE(0x19d2, 0xfffb) }, |
| 284 | − /* AC2726, AC8710_V3 */ | |
| 285 | − { USB_DEVICE_AND_INTERFACE_INFO(0x19d2, 0xfff1, 0xff, 0xff, 0xff) }, | |
| 284 | + /* AC8710_V3 */ | |
| 286 | 285 | { USB_DEVICE(0x19d2, 0xfff6) }, |
| 287 | 286 | { USB_DEVICE(0x19d2, 0xfff7) }, |
| 288 | 287 | { USB_DEVICE(0x19d2, 0xfff8) }, |
| @@ -285,7 +285,7 @@ static void update_balloon_size(struct virtio_balloon *vb) · 284 unmodified lines | ||
| 285 | 285 | { |
| 286 | 286 | __le32 actual = cpu_to_le32(vb->num_pages); |
| 287 | 287 | |
| 288 | − virtio_cwrite(vb->vdev, struct virtio_balloon_config, num_pages, | |
| 288 | + virtio_cwrite(vb->vdev, struct virtio_balloon_config, actual, | |
| 289 | 289 | &actual); |
| 290 | 290 | } |
| 291 | 291 | |
| @@ -350,17 +350,19 @@ static enum bp_state increase_reservation(unsigned long nr_pages) · 349 unmodified lines | ||
| 350 | 350 | |
| 351 | 351 | pfn = page_to_pfn(page); |
| 352 | 352 | |
| 353 | − set_phys_to_machine(pfn, frame_list[i]); | |
| 354 | − | |
| 355 | 353 | #ifdef CONFIG_XEN_HAVE_PVMMU |
| 356 | − /* Link back into the page tables if not highmem. */ | |
| 357 | − if (xen_pv_domain() && !PageHighMem(page)) { | |
| 358 | − int ret; | |
| 359 | − ret = HYPERVISOR_update_va_mapping( | |
| 360 | − (unsigned long)__va(pfn << PAGE_SHIFT), | |
| 361 | − mfn_pte(frame_list[i], PAGE_KERNEL), | |
| 362 | − 0); | |
| 363 | − BUG_ON(ret); | |
| 354 | + if (!xen_feature(XENFEAT_auto_translated_physmap)) { | |
| 355 | + set_phys_to_machine(pfn, frame_list[i]); | |
| 356 | + | |
| 357 | + /* Link back into the page tables if not highmem. */ | |
| 358 | + if (!PageHighMem(page)) { | |
| 359 | + int ret; | |
| 360 | + ret = HYPERVISOR_update_va_mapping( | |
| 361 | + (unsigned long)__va(pfn << PAGE_SHIFT), | |
| 362 | + mfn_pte(frame_list[i], PAGE_KERNEL), | |
| 363 | + 0); | |
| 364 | + BUG_ON(ret); | |
| 365 | + } | |
| 364 | 366 | } |
| 365 | 367 | #endif |
| 366 | 368 | |
| @@ -378,7 +380,6 @@ static enum bp_state decrease_reservation(unsigned long nr_pages, gfp_t gfp) · 11 unmodified lines | ||
| 378 | 380 | enum bp_state state = BP_DONE; |
| 379 | 381 | unsigned long pfn, i; |
| 380 | 382 | struct page *page; |
| 381 | − struct page *scratch_page; | |
| 382 | 383 | int ret; |
| 383 | 384 | struct xen_memory_reservation reservation = { |
| 384 | 385 | .address_bits = 0, |
| @@ -411,27 +412,29 @@ static enum bp_state decrease_reservation(unsigned long nr_pages, gfp_t gfp) · 26 unmodified lines | ||
| 411 | 412 | |
| 412 | 413 | scrub_page(page); |
| 413 | 414 | |
| 415 | +#ifdef CONFIG_XEN_HAVE_PVMMU | |
| 414 | 416 | /* |
| 415 | 417 | * Ballooned out frames are effectively replaced with |
| 416 | 418 | * a scratch frame. Ensure direct mappings and the |
| 417 | 419 | * p2m are consistent. |
| 418 | 420 | */ |
| 419 | − scratch_page = get_balloon_scratch_page(); | |
| 420 | −#ifdef CONFIG_XEN_HAVE_PVMMU | |
| 421 | − if (xen_pv_domain() && !PageHighMem(page)) { | |
| 422 | − ret = HYPERVISOR_update_va_mapping( | |
| 423 | − (unsigned long)__va(pfn << PAGE_SHIFT), | |
| 424 | − pfn_pte(page_to_pfn(scratch_page), | |
| 425 | − PAGE_KERNEL_RO), 0); | |
| 426 | − BUG_ON(ret); | |
| 427 | − } | |
| 428 | −#endif | |
| 429 | 421 | if (!xen_feature(XENFEAT_auto_translated_physmap)) { |
| 430 | 422 | unsigned long p; |
| 423 | + struct page *scratch_page = get_balloon_scratch_page(); | |
| 424 | + | |
| 425 | + if (!PageHighMem(page)) { | |
| 426 | + ret = HYPERVISOR_update_va_mapping( | |
| 427 | + (unsigned long)__va(pfn << PAGE_SHIFT), | |
| 428 | + pfn_pte(page_to_pfn(scratch_page), | |
| 429 | + PAGE_KERNEL_RO), 0); | |
| 430 | + BUG_ON(ret); | |
| 431 | + } | |
| 431 | 432 | p = page_to_pfn(scratch_page); |
| 432 | 433 | __set_phys_to_machine(pfn, pfn_to_mfn(p)); |
| 434 | + | |
| 435 | + put_balloon_scratch_page(); | |
| 433 | 436 | } |
| 434 | − put_balloon_scratch_page(); | |
| 437 | +#endif | |
| 435 | 438 | |
| 436 | 439 | balloon_append(pfn_to_page(pfn)); |
| 437 | 440 | } |
| @@ -627,15 +630,17 @@ static int __init balloon_init(void) · 189 unmodified lines | ||
| 627 | 630 | if (!xen_domain()) |
| 628 | 631 | return -ENODEV; |
| 629 | 632 | |
| 630 | − for_each_online_cpu(cpu) | |
| 631 | − { | |
| 632 | − per_cpu(balloon_scratch_page, cpu) = alloc_page(GFP_KERNEL); | |
| 633 | − if (per_cpu(balloon_scratch_page, cpu) == NULL) { | |
| 634 | − pr_warn("Failed to allocate balloon_scratch_page for cpu %d\n", cpu); | |
| 635 | − return -ENOMEM; | |
| 633 | + if (!xen_feature(XENFEAT_auto_translated_physmap)) { | |
| 634 | + for_each_online_cpu(cpu) | |
| 635 | + { | |
| 636 | + per_cpu(balloon_scratch_page, cpu) = alloc_page(GFP_KERNEL); | |
| 637 | + if (per_cpu(balloon_scratch_page, cpu) == NULL) { | |
| 638 | + pr_warn("Failed to allocate balloon_scratch_page for cpu %d\n", cpu); | |
| 639 | + return -ENOMEM; | |
| 640 | + } | |
| 636 | 641 | } |
| 642 | + register_cpu_notifier(&balloon_cpu_notifier); | |
| 637 | 643 | } |
| 638 | − register_cpu_notifier(&balloon_cpu_notifier); | |
| 639 | 644 | |
| 640 | 645 | pr_info("Initialising balloon driver\n"); |
| 641 | 646 | |
| @@ -1176,7 +1176,8 @@ static int gnttab_setup(void) · 1175 unmodified lines | ||
| 1176 | 1176 | gnttab_shared.addr = xen_remap(xen_hvm_resume_frames, |
| 1177 | 1177 | PAGE_SIZE * max_nr_gframes); |
| 1178 | 1178 | if (gnttab_shared.addr == NULL) { |
| 1179 | − pr_warn("Failed to ioremap gnttab share frames!\n"); | |
| 1179 | + pr_warn("Failed to ioremap gnttab share frames (addr=0x%08lx)!\n", | |
| 1180 | + xen_hvm_resume_frames); | |
| 1180 | 1181 | return -ENOMEM; |
| 1181 | 1182 | } |
| 1182 | 1183 | } |
| @@ -533,12 +533,17 @@ static void privcmd_close(struct vm_area_struct *vma) · 532 unmodified lines | ||
| 533 | 533 | { |
| 534 | 534 | struct page **pages = vma->vm_private_data; |
| 535 | 535 | int numpgs = (vma->vm_end - vma->vm_start) >> PAGE_SHIFT; |
| 536 | + int rc; | |
| 536 | 537 | |
| 537 | 538 | if (!xen_feature(XENFEAT_auto_translated_physmap) || !numpgs || !pages) |
| 538 | 539 | return; |
| 539 | 540 | |
| 540 | − xen_unmap_domain_mfn_range(vma, numpgs, pages); | |
| 541 | − free_xenballooned_pages(numpgs, pages); | |
| 541 | + rc = xen_unmap_domain_mfn_range(vma, numpgs, pages); | |
| 542 | + if (rc == 0) | |
| 543 | + free_xenballooned_pages(numpgs, pages); | |
| 544 | + else | |
| 545 | + pr_crit("unable to unmap MFN range: leaking %d pages. rc=%d\n", | |
| 546 | + numpgs, rc); | |
| 542 | 547 | kfree(pages); |
| 543 | 548 | } |
| 544 | 549 | |
| @@ -244,9 +244,14 @@ static void aio_free_ring(struct kioctx *ctx) · 243 unmodified lines | ||
| 244 | 244 | int i; |
| 245 | 245 | |
| 246 | 246 | for (i = 0; i < ctx->nr_pages; i++) { |
| 247 | + struct page *page; | |
| 247 | 248 | pr_debug("pid(%d) [%d] page->count=%d\n", current->pid, i, |
| 248 | 249 | page_count(ctx->ring_pages[i])); |
| 249 | − put_page(ctx->ring_pages[i]); | |
| 250 | + page = ctx->ring_pages[i]; | |
| 251 | + if (!page) | |
| 252 | + continue; | |
| 253 | + ctx->ring_pages[i] = NULL; | |
| 254 | + put_page(page); | |
| 250 | 255 | } |
| 251 | 256 | |
| 252 | 257 | put_aio_ring_file(ctx); |
| @@ -280,18 +285,38 @@ static int aio_migratepage(struct address_space *mapping, struct page *new, · 27 unmodified lines | ||
| 280 | 285 | unsigned long flags; |
| 281 | 286 | int rc; |
| 282 | 287 | |
| 288 | + rc = 0; | |
| 289 | + | |
| 290 | + /* Make sure the old page hasn't already been changed */ | |
| 291 | + spin_lock(&mapping->private_lock); | |
| 292 | + ctx = mapping->private_data; | |
| 293 | + if (ctx) { | |
| 294 | + pgoff_t idx; | |
| 295 | + spin_lock_irqsave(&ctx->completion_lock, flags); | |
| 296 | + idx = old->index; | |
| 297 | + if (idx < (pgoff_t)ctx->nr_pages) { | |
| 298 | + if (ctx->ring_pages[idx] != old) | |
| 299 | + rc = -EAGAIN; | |
| 300 | + } else | |
| 301 | + rc = -EINVAL; | |
| 302 | + spin_unlock_irqrestore(&ctx->completion_lock, flags); | |
| 303 | + } else | |
| 304 | + rc = -EINVAL; | |
| 305 | + spin_unlock(&mapping->private_lock); | |
| 306 | + | |
| 307 | + if (rc != 0) | |
| 308 | + return rc; | |
| 309 | + | |
| 283 | 310 | /* Writeback must be complete */ |
| 284 | 311 | BUG_ON(PageWriteback(old)); |
| 285 | − put_page(old); | |
| 312 | + get_page(new); | |
| 286 | 313 | |
| 287 | − rc = migrate_page_move_mapping(mapping, new, old, NULL, mode); | |
| 314 | + rc = migrate_page_move_mapping(mapping, new, old, NULL, mode, 1); | |
| 288 | 315 | if (rc != MIGRATEPAGE_SUCCESS) { |
| 289 | − get_page(old); | |
| 316 | + put_page(new); | |
| 290 | 317 | return rc; |
| 291 | 318 | } |
| 292 | 319 | |
| 293 | − get_page(new); | |
| 294 | − | |
| 295 | 320 | /* We can potentially race against kioctx teardown here. Use the |
| 296 | 321 | * address_space's private data lock to protect the mapping's |
| 297 | 322 | * private_data. |
| @@ -303,13 +328,24 @@ static int aio_migratepage(struct address_space *mapping, struct page *new, · 5 unmodified lines | ||
| 303 | 328 | spin_lock_irqsave(&ctx->completion_lock, flags); |
| 304 | 329 | migrate_page_copy(new, old); |
| 305 | 330 | idx = old->index; |
| 306 | − if (idx < (pgoff_t)ctx->nr_pages) | |
| 307 | − ctx->ring_pages[idx] = new; | |
| 331 | + if (idx < (pgoff_t)ctx->nr_pages) { | |
| 332 | + /* And only do the move if things haven't changed */ | |
| 333 | + if (ctx->ring_pages[idx] == old) | |
| 334 | + ctx->ring_pages[idx] = new; | |
| 335 | + else | |
| 336 | + rc = -EAGAIN; | |
| 337 | + } else | |
| 338 | + rc = -EINVAL; | |
| 308 | 339 | spin_unlock_irqrestore(&ctx->completion_lock, flags); |
| 309 | 340 | } else |
| 310 | 341 | rc = -EBUSY; |
| 311 | 342 | spin_unlock(&mapping->private_lock); |
| 312 | 343 | |
| 344 | + if (rc == MIGRATEPAGE_SUCCESS) | |
| 345 | + put_page(old); | |
| 346 | + else | |
| 347 | + put_page(new); | |
| 348 | + | |
| 313 | 349 | return rc; |
| 314 | 350 | } |
| 315 | 351 | #endif |
| @@ -326,7 +362,7 @@ static int aio_setup_ring(struct kioctx *ctx) · 10 unmodified lines | ||
| 326 | 362 | struct aio_ring *ring; |
| 327 | 363 | unsigned nr_events = ctx->max_reqs; |
| 328 | 364 | struct mm_struct *mm = current->mm; |
| 329 | − unsigned long size, populate; | |
| 365 | + unsigned long size, unused; | |
| 330 | 366 | int nr_pages; |
| 331 | 367 | int i; |
| 332 | 368 | struct file *file; |
| @@ -347,6 +383,20 @@ static int aio_setup_ring(struct kioctx *ctx) · 14 unmodified lines | ||
| 347 | 383 | return -EAGAIN; |
| 348 | 384 | } |
| 349 | 385 | |
| 386 | + ctx->aio_ring_file = file; | |
| 387 | + nr_events = (PAGE_SIZE * nr_pages - sizeof(struct aio_ring)) | |
| 388 | + / sizeof(struct io_event); | |
| 389 | + | |
| 390 | + ctx->ring_pages = ctx->internal_pages; | |
| 391 | + if (nr_pages > AIO_RING_PAGES) { | |
| 392 | + ctx->ring_pages = kcalloc(nr_pages, sizeof(struct page *), | |
| 393 | + GFP_KERNEL); | |
| 394 | + if (!ctx->ring_pages) { | |
| 395 | + put_aio_ring_file(ctx); | |
| 396 | + return -ENOMEM; | |
| 397 | + } | |
| 398 | + } | |
| 399 | + | |
| 350 | 400 | for (i = 0; i < nr_pages; i++) { |
| 351 | 401 | struct page *page; |
| 352 | 402 | page = find_or_create_page(file->f_inode->i_mapping, |
| @@ -358,19 +408,14 @@ static int aio_setup_ring(struct kioctx *ctx) · 5 unmodified lines | ||
| 358 | 408 | SetPageUptodate(page); |
| 359 | 409 | SetPageDirty(page); |
| 360 | 410 | unlock_page(page); |
| 411 | + | |
| 412 | + ctx->ring_pages[i] = page; | |
| 361 | 413 | } |
| 362 | − ctx->aio_ring_file = file; | |
| 363 | − nr_events = (PAGE_SIZE * nr_pages - sizeof(struct aio_ring)) | |
| 364 | − / sizeof(struct io_event); | |
| 414 | + ctx->nr_pages = i; | |
| 365 | 415 | |
| 366 | − ctx->ring_pages = ctx->internal_pages; | |
| 367 | − if (nr_pages > AIO_RING_PAGES) { | |
| 368 | − ctx->ring_pages = kcalloc(nr_pages, sizeof(struct page *), | |
| 369 | − GFP_KERNEL); | |
| 370 | − if (!ctx->ring_pages) { | |
| 371 | − put_aio_ring_file(ctx); | |
| 372 | − return -ENOMEM; | |
| 373 | − } | |
| 416 | + if (unlikely(i != nr_pages)) { | |
| 417 | + aio_free_ring(ctx); | |
| 418 | + return -EAGAIN; | |
| 374 | 419 | } |
| 375 | 420 | |
| 376 | 421 | ctx->mmap_size = nr_pages * PAGE_SIZE; |
| @@ -379,9 +424,9 @@ static int aio_setup_ring(struct kioctx *ctx) · 2 unmodified lines | ||
| 379 | 424 | down_write(&mm->mmap_sem); |
| 380 | 425 | ctx->mmap_base = do_mmap_pgoff(ctx->aio_ring_file, 0, ctx->mmap_size, |
| 381 | 426 | PROT_READ | PROT_WRITE, |
| 382 | − MAP_SHARED | MAP_POPULATE, 0, &populate); | |
| 427 | + MAP_SHARED, 0, &unused); | |
| 428 | + up_write(&mm->mmap_sem); | |
| 383 | 429 | if (IS_ERR((void *)ctx->mmap_base)) { |
| 384 | − up_write(&mm->mmap_sem); | |
| 385 | 430 | ctx->mmap_size = 0; |
| 386 | 431 | aio_free_ring(ctx); |
| 387 | 432 | return -EAGAIN; |
| @@ -389,27 +434,6 @@ static int aio_setup_ring(struct kioctx *ctx) · 1 unmodified line | ||
| 389 | 434 | |
| 390 | 435 | pr_debug("mmap address: 0x%08lx\n", ctx->mmap_base); |
| 391 | 436 | |
| 392 | − /* We must do this while still holding mmap_sem for write, as we | |
| 393 | − * need to be protected against userspace attempting to mremap() | |
| 394 | − * or munmap() the ring buffer. | |
| 395 | − */ | |
| 396 | − ctx->nr_pages = get_user_pages(current, mm, ctx->mmap_base, nr_pages, | |
| 397 | − 1, 0, ctx->ring_pages, NULL); | |
| 398 | − | |
| 399 | − /* Dropping the reference here is safe as the page cache will hold | |
| 400 | − * onto the pages for us. It is also required so that page migration | |
| 401 | − * can unmap the pages and get the right reference count. | |
| 402 | − */ | |
| 403 | − for (i = 0; i < ctx->nr_pages; i++) | |
| 404 | − put_page(ctx->ring_pages[i]); | |
| 405 | − | |
| 406 | − up_write(&mm->mmap_sem); | |
| 407 | − | |
| 408 | − if (unlikely(ctx->nr_pages != nr_pages)) { | |
| 409 | − aio_free_ring(ctx); | |
| 410 | − return -EAGAIN; | |
| 411 | − } | |
| 412 | − | |
| 413 | 437 | ctx->user_id = ctx->mmap_base; |
| 414 | 438 | ctx->nr_events = nr_events; /* trusted copy */ |
| 415 | 439 | |
| @@ -652,7 +676,8 @@ static struct kioctx *ioctx_alloc(unsigned nr_events) · 236 unmodified lines | ||
| 652 | 676 | aio_nr += ctx->max_reqs; |
| 653 | 677 | spin_unlock(&aio_nr_lock); |
| 654 | 678 | |
| 655 | − percpu_ref_get(&ctx->users); /* io_setup() will drop this ref */ | |
| 679 | + percpu_ref_get(&ctx->users); /* io_setup() will drop this ref */ | |
| 680 | + percpu_ref_get(&ctx->reqs); /* free_ioctx_users() will drop this */ | |
| 656 | 681 | |
| 657 | 682 | err = ioctx_add_table(ctx, mm); |
| 658 | 683 | if (err) |
| @@ -210,9 +210,13 @@ static int readpage_nounlock(struct file *filp, struct page *page) · 209 unmodified lines | ||
| 210 | 210 | if (err < 0) { |
| 211 | 211 | SetPageError(page); |
| 212 | 212 | goto out; |
| 213 | − } else if (err < PAGE_CACHE_SIZE) { | |
| 213 | + } else { | |
| 214 | + if (err < PAGE_CACHE_SIZE) { | |
| 214 | 215 | /* zero fill remainder of page */ |
| 215 | − zero_user_segment(page, err, PAGE_CACHE_SIZE); | |
| 216 | + zero_user_segment(page, err, PAGE_CACHE_SIZE); | |
| 217 | + } else { | |
| 218 | + flush_dcache_page(page); | |
| 219 | + } | |
| 216 | 220 | } |
| 217 | 221 | SetPageUptodate(page); |
| 218 | 222 | |
| @@ -978,7 +978,6 @@ int ceph_fill_trace(struct super_block *sb, struct ceph_mds_request *req, · 977 unmodified lines | ||
| 978 | 978 | struct ceph_mds_reply_inode *ininfo; |
| 979 | 979 | struct ceph_vino vino; |
| 980 | 980 | struct ceph_fs_client *fsc = ceph_sb_to_client(sb); |
| 981 | − int i = 0; | |
| 982 | 981 | int err = 0; |
| 983 | 982 | |
| 984 | 983 | dout("fill_trace %p is_dentry %d is_target %d\n", req, |
| @@ -1039,6 +1038,29 @@ int ceph_fill_trace(struct super_block *sb, struct ceph_mds_request *req, · 54 unmodified lines | ||
| 1039 | 1038 | } |
| 1040 | 1039 | } |
| 1041 | 1040 | |
| 1041 | + if (rinfo->head->is_target) { | |
| 1042 | + vino.ino = le64_to_cpu(rinfo->targeti.in->ino); | |
| 1043 | + vino.snap = le64_to_cpu(rinfo->targeti.in->snapid); | |
| 1044 | + | |
| 1045 | + in = ceph_get_inode(sb, vino); | |
| 1046 | + if (IS_ERR(in)) { | |
| 1047 | + err = PTR_ERR(in); | |
| 1048 | + goto done; | |
| 1049 | + } | |
| 1050 | + req->r_target_inode = in; | |
| 1051 | + | |
| 1052 | + err = fill_inode(in, &rinfo->targeti, NULL, | |
| 1053 | + session, req->r_request_started, | |
| 1054 | + (le32_to_cpu(rinfo->head->result) == 0) ? | |
| 1055 | + req->r_fmode : -1, | |
| 1056 | + &req->r_caps_reservation); | |
| 1057 | + if (err < 0) { | |
| 1058 | + pr_err("fill_inode badness %p %llx.%llx\n", | |
| 1059 | + in, ceph_vinop(in)); | |
| 1060 | + goto done; | |
| 1061 | + } | |
| 1062 | + } | |
| 1063 | + | |
| 1042 | 1064 | /* |
| 1043 | 1065 | * ignore null lease/binding on snapdir ENOENT, or else we |
| 1044 | 1066 | * will have trouble splicing in the virtual snapdir later |
| @@ -1108,7 +1130,6 @@ int ceph_fill_trace(struct super_block *sb, struct ceph_mds_request *req, · 63 unmodified lines | ||
| 1108 | 1130 | ceph_dentry(req->r_old_dentry)->offset); |
| 1109 | 1131 | |
| 1110 | 1132 | dn = req->r_old_dentry; /* use old_dentry */ |
| 1111 | − in = dn->d_inode; | |
| 1112 | 1133 | } |
| 1113 | 1134 | |
| 1114 | 1135 | /* null dentry? */ |
| @@ -1130,44 +1151,28 @@ int ceph_fill_trace(struct super_block *sb, struct ceph_mds_request *req, · 15 unmodified lines | ||
| 1130 | 1151 | } |
| 1131 | 1152 | |
| 1132 | 1153 | /* attach proper inode */ |
| 1133 | − ininfo = rinfo->targeti.in; | |
| 1134 | − vino.ino = le64_to_cpu(ininfo->ino); | |
| 1135 | − vino.snap = le64_to_cpu(ininfo->snapid); | |
| 1136 | − in = dn->d_inode; | |
| 1137 | − if (!in) { | |
| 1138 | − in = ceph_get_inode(sb, vino); | |
| 1139 | − if (IS_ERR(in)) { | |
| 1140 | − pr_err("fill_trace bad get_inode " | |
| 1141 | − "%llx.%llx\n", vino.ino, vino.snap); | |
| 1142 | − err = PTR_ERR(in); | |
| 1143 | − d_drop(dn); | |
| 1144 | − goto done; | |
| 1145 | − } | |
| 1154 | + if (!dn->d_inode) { | |
| 1155 | + ihold(in); | |
| 1146 | 1156 | dn = splice_dentry(dn, in, &have_lease, true); |
| 1147 | 1157 | if (IS_ERR(dn)) { |
| 1148 | 1158 | err = PTR_ERR(dn); |
| 1149 | 1159 | goto done; |
| 1150 | 1160 | } |
| 1151 | 1161 | req->r_dentry = dn; /* may have spliced */ |
| 1152 | − ihold(in); | |
| 1153 | − } else if (ceph_ino(in) == vino.ino && | |
| 1154 | − ceph_snap(in) == vino.snap) { | |
| 1155 | − ihold(in); | |
| 1156 | − } else { | |
| 1162 | + } else if (dn->d_inode && dn->d_inode != in) { | |
| 1157 | 1163 | dout(" %p links to %p %llx.%llx, not %llx.%llx\n", |
| 1158 | − dn, in, ceph_ino(in), ceph_snap(in), | |
| 1159 | − vino.ino, vino.snap); | |
| 1164 | + dn, dn->d_inode, ceph_vinop(dn->d_inode), | |
| 1165 | + ceph_vinop(in)); | |
| 1160 | 1166 | have_lease = false; |
| 1161 | − in = NULL; | |
| 1162 | 1167 | } |
| 1163 | 1168 | |
| 1164 | 1169 | if (have_lease) |
| 1165 | 1170 | update_dentry_lease(dn, rinfo->dlease, session, |
| 1166 | 1171 | req->r_request_started); |
| 1167 | 1172 | dout(" final dn %p\n", dn); |
| 1168 | − i++; | |
| 1169 | − } else if ((req->r_op == CEPH_MDS_OP_LOOKUPSNAP || | |
| 1170 | − req->r_op == CEPH_MDS_OP_MKSNAP) && !req->r_aborted) { | |
| 1173 | + } else if (!req->r_aborted && | |
| 1174 | + (req->r_op == CEPH_MDS_OP_LOOKUPSNAP || | |
| 1175 | + req->r_op == CEPH_MDS_OP_MKSNAP)) { | |
| 1171 | 1176 | struct dentry *dn = req->r_dentry; |
| 1172 | 1177 | |
| 1173 | 1178 | /* fill out a snapdir LOOKUPSNAP dentry */ |
| @@ -1177,52 +1182,15 @@ int ceph_fill_trace(struct super_block *sb, struct ceph_mds_request *req, · 3 unmodified lines | ||
| 1177 | 1182 | ininfo = rinfo->targeti.in; |
| 1178 | 1183 | vino.ino = le64_to_cpu(ininfo->ino); |
| 1179 | 1184 | vino.snap = le64_to_cpu(ininfo->snapid); |
| 1180 | − in = ceph_get_inode(sb, vino); | |
| 1181 | − if (IS_ERR(in)) { | |
| 1182 | − pr_err("fill_inode get_inode badness %llx.%llx\n", | |
| 1183 | − vino.ino, vino.snap); | |
| 1184 | − err = PTR_ERR(in); | |
| 1185 | − d_delete(dn); | |
| 1186 | − goto done; | |
| 1187 | − } | |
| 1188 | 1185 | dout(" linking snapped dir %p to dn %p\n", in, dn); |
| 1186 | + ihold(in); | |
| 1189 | 1187 | dn = splice_dentry(dn, in, NULL, true); |
| 1190 | 1188 | if (IS_ERR(dn)) { |
| 1191 | 1189 | err = PTR_ERR(dn); |
| 1192 | 1190 | goto done; |
| 1193 | 1191 | } |
| 1194 | 1192 | req->r_dentry = dn; /* may have spliced */ |
| 1195 | − ihold(in); | |
| 1196 | − rinfo->head->is_dentry = 1; /* fool notrace handlers */ | |
| 1197 | − } | |
| 1198 | − | |
| 1199 | − if (rinfo->head->is_target) { | |
| 1200 | − vino.ino = le64_to_cpu(rinfo->targeti.in->ino); | |
| 1201 | − vino.snap = le64_to_cpu(rinfo->targeti.in->snapid); | |
| 1202 | − | |
| 1203 | − if (in == NULL || ceph_ino(in) != vino.ino || | |
| 1204 | − ceph_snap(in) != vino.snap) { | |
| 1205 | − in = ceph_get_inode(sb, vino); | |
| 1206 | − if (IS_ERR(in)) { | |
| 1207 | − err = PTR_ERR(in); | |
| 1208 | − goto done; | |
| 1209 | − } | |
| 1210 | − } | |
| 1211 | − req->r_target_inode = in; | |
| 1212 | − | |
| 1213 | − err = fill_inode(in, | |
| 1214 | − &rinfo->targeti, NULL, | |
| 1215 | − session, req->r_request_started, | |
| 1216 | − (le32_to_cpu(rinfo->head->result) == 0) ? | |
| 1217 | − req->r_fmode : -1, | |
| 1218 | − &req->r_caps_reservation); | |
| 1219 | − if (err < 0) { | |
| 1220 | − pr_err("fill_inode badness %p %llx.%llx\n", | |
| 1221 | − in, ceph_vinop(in)); | |
| 1222 | − goto done; | |
| 1223 | − } | |
| 1224 | 1193 | } |
| 1225 | − | |
| 1226 | 1194 | done: |
| 1227 | 1195 | dout("fill_trace done err=%d\n", err); |
| 1228 | 1196 | return err; |
| @@ -1272,7 +1240,7 @@ int ceph_readdir_prepopulate(struct ceph_mds_request *req, · 43 unmodified lines | ||
| 1272 | 1240 | struct qstr dname; |
| 1273 | 1241 | struct dentry *dn; |
| 1274 | 1242 | struct inode *in; |
| 1275 | − int err = 0, i; | |
| 1243 | + int err = 0, ret, i; | |
| 1276 | 1244 | struct inode *snapdir = NULL; |
| 1277 | 1245 | struct ceph_mds_request_head *rhead = req->r_request->front.iov_base; |
| 1278 | 1246 | struct ceph_dentry_info *di; |
| @@ -1305,6 +1273,7 @@ int ceph_readdir_prepopulate(struct ceph_mds_request *req, · 26 unmodified lines | ||
| 1305 | 1273 | ceph_fill_dirfrag(parent->d_inode, rinfo->dir_dir); |
| 1306 | 1274 | } |
| 1307 | 1275 | |
| 1276 | + /* FIXME: release caps/leases if error occurs */ | |
| 1308 | 1277 | for (i = 0; i < rinfo->dir_nr; i++) { |
| 1309 | 1278 | struct ceph_vino vino; |
| 1310 | 1279 | |
| @@ -1329,9 +1298,10 @@ retry_lookup: · 18 unmodified lines | ||
| 1329 | 1298 | err = -ENOMEM; |
| 1330 | 1299 | goto out; |
| 1331 | 1300 | } |
| 1332 | − err = ceph_init_dentry(dn); | |
| 1333 | − if (err < 0) { | |
| 1301 | + ret = ceph_init_dentry(dn); | |
| 1302 | + if (ret < 0) { | |
| 1334 | 1303 | dput(dn); |
| 1304 | + err = ret; | |
| 1335 | 1305 | goto out; |
| 1336 | 1306 | } |
| 1337 | 1307 | } else if (dn->d_inode && |
| @@ -1351,9 +1321,6 @@ retry_lookup: · 13 unmodified lines | ||
| 1351 | 1321 | spin_unlock(&parent->d_lock); |
| 1352 | 1322 | } |
| 1353 | 1323 | |
| 1354 | − di = dn->d_fsdata; | |
| 1355 | − di->offset = ceph_make_fpos(frag, i + r_readdir_offset); | |
| 1356 | − | |
| 1357 | 1324 | /* inode */ |
| 1358 | 1325 | if (dn->d_inode) { |
| 1359 | 1326 | in = dn->d_inode; |
| @@ -1366,26 +1333,39 @@ retry_lookup: · 6 unmodified lines | ||
| 1366 | 1333 | err = PTR_ERR(in); |
| 1367 | 1334 | goto out; |
| 1368 | 1335 | } |
| 1369 | − dn = splice_dentry(dn, in, NULL, false); | |
| 1370 | − if (IS_ERR(dn)) | |
| 1371 | − dn = NULL; | |
| 1372 | 1336 | } |
| 1373 | 1337 | |
| 1374 | 1338 | if (fill_inode(in, &rinfo->dir_in[i], NULL, session, |
| 1375 | 1339 | req->r_request_started, -1, |
| 1376 | 1340 | &req->r_caps_reservation) < 0) { |
| 1377 | 1341 | pr_err("fill_inode badness on %p\n", in); |
| 1342 | + if (!dn->d_inode) | |
| 1343 | + iput(in); | |
| 1344 | + d_drop(dn); | |
| 1378 | 1345 | goto next_item; |
| 1379 | 1346 | } |
| 1380 | − if (dn) | |
| 1381 | − update_dentry_lease(dn, rinfo->dir_dlease[i], | |
| 1382 | − req->r_session, | |
| 1383 | − req->r_request_started); | |
| 1347 | + | |
| 1348 | + if (!dn->d_inode) { | |
| 1349 | + dn = splice_dentry(dn, in, NULL, false); | |
| 1350 | + if (IS_ERR(dn)) { | |
| 1351 | + err = PTR_ERR(dn); | |
| 1352 | + dn = NULL; | |
| 1353 | + goto next_item; | |
| 1354 | + } | |
| 1355 | + } | |
| 1356 | + | |
| 1357 | + di = dn->d_fsdata; | |
| 1358 | + di->offset = ceph_make_fpos(frag, i + r_readdir_offset); | |
| 1359 | + | |
| 1360 | + update_dentry_lease(dn, rinfo->dir_dlease[i], | |
| 1361 | + req->r_session, | |
| 1362 | + req->r_request_started); | |
| 1384 | 1363 | next_item: |
| 1385 | 1364 | if (dn) |
| 1386 | 1365 | dput(dn); |
| 1387 | 1366 | } |
| 1388 | − req->r_did_prepopulate = true; | |
| 1367 | + if (err == 0) | |
| 1368 | + req->r_did_prepopulate = true; | |
| 1389 | 1369 | |
| 1390 | 1370 | out: |
| 1391 | 1371 | if (snapdir) { |
| @@ -1493,6 +1493,7 @@ static ssize_t ext2_quota_write(struct super_block *sb, int type, · 1492 unmodified lines | ||
| 1493 | 1493 | sb->s_blocksize - offset : towrite; |
| 1494 | 1494 | |
| 1495 | 1495 | tmp_bh.b_state = 0; |
| 1496 | + tmp_bh.b_size = sb->s_blocksize; | |
| 1496 | 1497 | err = ext2_get_block(inode, blk, &tmp_bh, 1); |
| 1497 | 1498 | if (err < 0) |
| 1498 | 1499 | goto out; |
| @@ -268,6 +268,16 @@ struct ext4_io_submit { · 267 unmodified lines | ||
| 268 | 268 | /* Translate # of blks to # of clusters */ |
| 269 | 269 | #define EXT4_NUM_B2C(sbi, blks) (((blks) + (sbi)->s_cluster_ratio - 1) >> \ |
| 270 | 270 | (sbi)->s_cluster_bits) |
| 271 | +/* Mask out the low bits to get the starting block of the cluster */ | |
| 272 | +#define EXT4_PBLK_CMASK(s, pblk) ((pblk) & \ | |
| 273 | + ~((ext4_fsblk_t) (s)->s_cluster_ratio - 1)) | |
| 274 | +#define EXT4_LBLK_CMASK(s, lblk) ((lblk) & \ | |
| 275 | + ~((ext4_lblk_t) (s)->s_cluster_ratio - 1)) | |
| 276 | +/* Get the cluster offset */ | |
| 277 | +#define EXT4_PBLK_COFF(s, pblk) ((pblk) & \ | |
| 278 | + ((ext4_fsblk_t) (s)->s_cluster_ratio - 1)) | |
| 279 | +#define EXT4_LBLK_COFF(s, lblk) ((lblk) & \ | |
| 280 | + ((ext4_lblk_t) (s)->s_cluster_ratio - 1)) | |
| 271 | 281 | |
| 272 | 282 | /* |
| 273 | 283 | * Structure of a blocks group descriptor |
| @@ -259,6 +259,15 @@ int __ext4_handle_dirty_metadata(const char *where, unsigned int line, · 258 unmodified lines | ||
| 259 | 259 | if (WARN_ON_ONCE(err)) { |
| 260 | 260 | ext4_journal_abort_handle(where, line, __func__, bh, |
| 261 | 261 | handle, err); |
| 262 | + ext4_error_inode(inode, where, line, | |
| 263 | + bh->b_blocknr, | |
| 264 | + "journal_dirty_metadata failed: " | |
| 265 | + "handle type %u started at line %u, " | |
| 266 | + "credits %u/%u, errcode %d", | |
| 267 | + handle->h_type, | |
| 268 | + handle->h_line_no, | |
| 269 | + handle->h_requested_credits, | |
| 270 | + handle->h_buffer_credits, err); | |
| 262 | 271 | } |
| 263 | 272 | } else { |
| 264 | 273 | if (inode) |
| @@ -360,8 +360,10 @@ static int ext4_valid_extent(struct inode *inode, struct ext4_extent *ext) · 359 unmodified lines | ||
| 360 | 360 | { |
| 361 | 361 | ext4_fsblk_t block = ext4_ext_pblock(ext); |
| 362 | 362 | int len = ext4_ext_get_actual_len(ext); |
| 363 | + ext4_lblk_t lblock = le32_to_cpu(ext->ee_block); | |
| 364 | + ext4_lblk_t last = lblock + len - 1; | |
| 363 | 365 | |
| 364 | − if (len == 0) | |
| 366 | + if (lblock > last) | |
| 365 | 367 | return 0; |
| 366 | 368 | return ext4_data_block_valid(EXT4_SB(inode->i_sb), block, len); |
| 367 | 369 | } |
| @@ -387,11 +389,26 @@ static int ext4_valid_extent_entries(struct inode *inode, · 19 unmodified lines | ||
| 387 | 389 | if (depth == 0) { |
| 388 | 390 | /* leaf entries */ |
| 389 | 391 | struct ext4_extent *ext = EXT_FIRST_EXTENT(eh); |
| 392 | + struct ext4_super_block *es = EXT4_SB(inode->i_sb)->s_es; | |
| 393 | + ext4_fsblk_t pblock = 0; | |
| 394 | + ext4_lblk_t lblock = 0; | |
| 395 | + ext4_lblk_t prev = 0; | |
| 396 | + int len = 0; | |
| 390 | 397 | while (entries) { |
| 391 | 398 | if (!ext4_valid_extent(inode, ext)) |
| 392 | 399 | return 0; |
| 400 | + | |
| 401 | + /* Check for overlapping extents */ | |
| 402 | + lblock = le32_to_cpu(ext->ee_block); | |
| 403 | + len = ext4_ext_get_actual_len(ext); | |
| 404 | + if ((lblock <= prev) && prev) { | |
| 405 | + pblock = ext4_ext_pblock(ext); | |
| 406 | + es->s_last_error_block = cpu_to_le64(pblock); | |
| 407 | + return 0; | |
| 408 | + } | |
| 393 | 409 | ext++; |
| 394 | 410 | entries--; |
| 411 | + prev = lblock + len - 1; | |
| 395 | 412 | } |
| 396 | 413 | } else { |
| 397 | 414 | struct ext4_extent_idx *ext_idx = EXT_FIRST_INDEX(eh); |
| @@ -1834,8 +1851,7 @@ static unsigned int ext4_ext_check_overlap(struct ext4_sb_info *sbi, · 1436 unmodified lines | ||
| 1834 | 1851 | depth = ext_depth(inode); |
| 1835 | 1852 | if (!path[depth].p_ext) |
| 1836 | 1853 | goto out; |
| 1837 | − b2 = le32_to_cpu(path[depth].p_ext->ee_block); | |
| 1838 | − b2 &= ~(sbi->s_cluster_ratio - 1); | |
| 1854 | + b2 = EXT4_LBLK_CMASK(sbi, le32_to_cpu(path[depth].p_ext->ee_block)); | |
| 1839 | 1855 | |
| 1840 | 1856 | /* |
| 1841 | 1857 | * get the next allocated block if the extent in the path |
| @@ -1845,7 +1861,7 @@ static unsigned int ext4_ext_check_overlap(struct ext4_sb_info *sbi, · 3 unmodified lines | ||
| 1845 | 1861 | b2 = ext4_ext_next_allocated_block(path); |
| 1846 | 1862 | if (b2 == EXT_MAX_BLOCKS) |
| 1847 | 1863 | goto out; |
| 1848 | − b2 &= ~(sbi->s_cluster_ratio - 1); | |
| 1864 | + b2 = EXT4_LBLK_CMASK(sbi, b2); | |
| 1849 | 1865 | } |
| 1850 | 1866 | |
| 1851 | 1867 | /* check for wrap through zero on extent logical start block*/ |
| @@ -2504,7 +2520,7 @@ static int ext4_remove_blocks(handle_t *handle, struct inode *inode, · 652 unmodified lines | ||
| 2504 | 2520 | * extent, we have to mark the cluster as used (store negative |
| 2505 | 2521 | * cluster number in partial_cluster). |
| 2506 | 2522 | */ |
| 2507 | − unaligned = pblk & (sbi->s_cluster_ratio - 1); | |
| 2523 | + unaligned = EXT4_PBLK_COFF(sbi, pblk); | |
| 2508 | 2524 | if (unaligned && (ee_len == num) && |
| 2509 | 2525 | (*partial_cluster != -((long long)EXT4_B2C(sbi, pblk)))) |
| 2510 | 2526 | *partial_cluster = EXT4_B2C(sbi, pblk); |
| @@ -2598,7 +2614,7 @@ ext4_ext_rm_leaf(handle_t *handle, struct inode *inode, · 87 unmodified lines | ||
| 2598 | 2614 | * accidentally freeing it later on |
| 2599 | 2615 | */ |
| 2600 | 2616 | pblk = ext4_ext_pblock(ex); |
| 2601 | − if (pblk & (sbi->s_cluster_ratio - 1)) | |
| 2617 | + if (EXT4_PBLK_COFF(sbi, pblk)) | |
| 2602 | 2618 | *partial_cluster = |
| 2603 | 2619 | -((long long)EXT4_B2C(sbi, pblk)); |
| 2604 | 2620 | ex--; |
| @@ -3753,7 +3769,7 @@ int ext4_find_delalloc_cluster(struct inode *inode, ext4_lblk_t lblk) · 1148 unmodified lines | ||
| 3753 | 3769 | { |
| 3754 | 3770 | struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb); |
| 3755 | 3771 | ext4_lblk_t lblk_start, lblk_end; |
| 3756 | − lblk_start = lblk & (~(sbi->s_cluster_ratio - 1)); | |
| 3772 | + lblk_start = EXT4_LBLK_CMASK(sbi, lblk); | |
| 3757 | 3773 | lblk_end = lblk_start + sbi->s_cluster_ratio - 1; |
| 3758 | 3774 | |
| 3759 | 3775 | return ext4_find_delalloc_range(inode, lblk_start, lblk_end); |
| @@ -3812,9 +3828,9 @@ get_reserved_cluster_alloc(struct inode *inode, ext4_lblk_t lblk_start, · 52 unmodified lines | ||
| 3812 | 3828 | trace_ext4_get_reserved_cluster_alloc(inode, lblk_start, num_blks); |
| 3813 | 3829 | |
| 3814 | 3830 | /* Check towards left side */ |
| 3815 | − c_offset = lblk_start & (sbi->s_cluster_ratio - 1); | |
| 3831 | + c_offset = EXT4_LBLK_COFF(sbi, lblk_start); | |
| 3816 | 3832 | if (c_offset) { |
| 3817 | − lblk_from = lblk_start & (~(sbi->s_cluster_ratio - 1)); | |
| 3833 | + lblk_from = EXT4_LBLK_CMASK(sbi, lblk_start); | |
| 3818 | 3834 | lblk_to = lblk_from + c_offset - 1; |
| 3819 | 3835 | |
| 3820 | 3836 | if (ext4_find_delalloc_range(inode, lblk_from, lblk_to)) |
| @@ -3822,7 +3838,7 @@ get_reserved_cluster_alloc(struct inode *inode, ext4_lblk_t lblk_start, · 1 unmodified line | ||
| 3822 | 3838 | } |
| 3823 | 3839 | |
| 3824 | 3840 | /* Now check towards right. */ |
| 3825 | − c_offset = (lblk_start + num_blks) & (sbi->s_cluster_ratio - 1); | |
| 3841 | + c_offset = EXT4_LBLK_COFF(sbi, lblk_start + num_blks); | |
| 3826 | 3842 | if (allocated_clusters && c_offset) { |
| 3827 | 3843 | lblk_from = lblk_start + num_blks; |
| 3828 | 3844 | lblk_to = lblk_from + (sbi->s_cluster_ratio - c_offset) - 1; |
| @@ -4030,7 +4046,7 @@ static int get_implied_cluster_alloc(struct super_block *sb, · 201 unmodified lines | ||
| 4030 | 4046 | struct ext4_ext_path *path) |
| 4031 | 4047 | { |
| 4032 | 4048 | struct ext4_sb_info *sbi = EXT4_SB(sb); |
| 4033 | − ext4_lblk_t c_offset = map->m_lblk & (sbi->s_cluster_ratio-1); | |
| 4049 | + ext4_lblk_t c_offset = EXT4_LBLK_COFF(sbi, map->m_lblk); | |
| 4034 | 4050 | ext4_lblk_t ex_cluster_start, ex_cluster_end; |
| 4035 | 4051 | ext4_lblk_t rr_cluster_start; |
| 4036 | 4052 | ext4_lblk_t ee_block = le32_to_cpu(ex->ee_block); |
| @@ -4048,8 +4064,7 @@ static int get_implied_cluster_alloc(struct super_block *sb, · 11 unmodified lines | ||
| 4048 | 4064 | (rr_cluster_start == ex_cluster_start)) { |
| 4049 | 4065 | if (rr_cluster_start == ex_cluster_end) |
| 4050 | 4066 | ee_start += ee_len - 1; |
| 4051 | − map->m_pblk = (ee_start & ~(sbi->s_cluster_ratio - 1)) + | |
| 4052 | − c_offset; | |
| 4067 | + map->m_pblk = EXT4_PBLK_CMASK(sbi, ee_start) + c_offset; | |
| 4053 | 4068 | map->m_len = min(map->m_len, |
| 4054 | 4069 | (unsigned) sbi->s_cluster_ratio - c_offset); |
| 4055 | 4070 | /* |
| @@ -4203,7 +4218,7 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode, · 147 unmodified lines | ||
| 4203 | 4218 | */ |
| 4204 | 4219 | map->m_flags &= ~EXT4_MAP_FROM_CLUSTER; |
| 4205 | 4220 | newex.ee_block = cpu_to_le32(map->m_lblk); |
| 4206 | − cluster_offset = map->m_lblk & (sbi->s_cluster_ratio-1); | |
| 4221 | + cluster_offset = EXT4_LBLK_CMASK(sbi, map->m_lblk); | |
| 4207 | 4222 | |
| 4208 | 4223 | /* |
| 4209 | 4224 | * If we are doing bigalloc, check to see if the extent returned |
| @@ -4271,7 +4286,7 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode, · 61 unmodified lines | ||
| 4271 | 4286 | * needed so that future calls to get_implied_cluster_alloc() |
| 4272 | 4287 | * work correctly. |
| 4273 | 4288 | */ |
| 4274 | − offset = map->m_lblk & (sbi->s_cluster_ratio - 1); | |
| 4289 | + offset = EXT4_LBLK_COFF(sbi, map->m_lblk); | |
| 4275 | 4290 | ar.len = EXT4_NUM_B2C(sbi, offset+allocated); |
| 4276 | 4291 | ar.goal -= offset; |
| 4277 | 4292 | ar.logical -= offset; |
| @@ -1206,7 +1206,6 @@ static int ext4_journalled_write_end(struct file *file, · 1205 unmodified lines | ||
| 1206 | 1206 | */ |
| 1207 | 1207 | static int ext4_da_reserve_metadata(struct inode *inode, ext4_lblk_t lblock) |
| 1208 | 1208 | { |
| 1209 | − int retries = 0; | |
| 1210 | 1209 | struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb); |
| 1211 | 1210 | struct ext4_inode_info *ei = EXT4_I(inode); |
| 1212 | 1211 | unsigned int md_needed; |
| @@ -1218,7 +1217,6 @@ static int ext4_da_reserve_metadata(struct inode *inode, ext4_lblk_t lblock) · 5 unmodified lines | ||
| 1218 | 1217 | * in order to allocate nrblocks |
| 1219 | 1218 | * worse case is one extent per block |
| 1220 | 1219 | */ |
| 1221 | −repeat: | |
| 1222 | 1220 | spin_lock(&ei->i_block_reservation_lock); |
| 1223 | 1221 | /* |
| 1224 | 1222 | * ext4_calc_metadata_amount() has side effects, which we have |
| @@ -1238,10 +1236,6 @@ repeat: · 13 unmodified lines | ||
| 1238 | 1236 | ei->i_da_metadata_calc_len = save_len; |
| 1239 | 1237 | ei->i_da_metadata_calc_last_lblock = save_last_lblock; |
| 1240 | 1238 | spin_unlock(&ei->i_block_reservation_lock); |
| 1241 | − if (ext4_should_retry_alloc(inode->i_sb, &retries)) { | |
| 1242 | − cond_resched(); | |
| 1243 | − goto repeat; | |
| 1244 | − } | |
| 1245 | 1239 | return -ENOSPC; |
| 1246 | 1240 | } |
| 1247 | 1241 | ei->i_reserved_meta_blocks += md_needed; |
| @@ -1255,7 +1249,6 @@ repeat: · 7 unmodified lines | ||
| 1255 | 1249 | */ |
| 1256 | 1250 | static int ext4_da_reserve_space(struct inode *inode, ext4_lblk_t lblock) |
| 1257 | 1251 | { |
| 1258 | − int retries = 0; | |
| 1259 | 1252 | struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb); |
| 1260 | 1253 | struct ext4_inode_info *ei = EXT4_I(inode); |
| 1261 | 1254 | unsigned int md_needed; |
| @@ -1277,7 +1270,6 @@ static int ext4_da_reserve_space(struct inode *inode, ext4_lblk_t lblock) · 15 unmodified lines | ||
| 1277 | 1270 | * in order to allocate nrblocks |
| 1278 | 1271 | * worse case is one extent per block |
| 1279 | 1272 | */ |
| 1280 | −repeat: | |
| 1281 | 1273 | spin_lock(&ei->i_block_reservation_lock); |
| 1282 | 1274 | /* |
| 1283 | 1275 | * ext4_calc_metadata_amount() has side effects, which we have |
| @@ -1297,10 +1289,6 @@ repeat: · 13 unmodified lines | ||
| 1297 | 1289 | ei->i_da_metadata_calc_len = save_len; |
| 1298 | 1290 | ei->i_da_metadata_calc_last_lblock = save_last_lblock; |
| 1299 | 1291 | spin_unlock(&ei->i_block_reservation_lock); |
| 1300 | − if (ext4_should_retry_alloc(inode->i_sb, &retries)) { | |
| 1301 | − cond_resched(); | |
| 1302 | − goto repeat; | |
| 1303 | − } | |
| 1304 | 1292 | dquot_release_reservation_block(inode, EXT4_C2B(sbi, 1)); |
| 1305 | 1293 | return -ENOSPC; |
| 1306 | 1294 | } |
| @@ -3442,6 +3442,9 @@ static void ext4_mb_pa_callback(struct rcu_head *head) · 3441 unmodified lines | ||
| 3442 | 3442 | { |
| 3443 | 3443 | struct ext4_prealloc_space *pa; |
| 3444 | 3444 | pa = container_of(head, struct ext4_prealloc_space, u.pa_rcu); |
| 3445 | + | |
| 3446 | + BUG_ON(atomic_read(&pa->pa_count)); | |
| 3447 | + BUG_ON(pa->pa_deleted == 0); | |
| 3445 | 3448 | kmem_cache_free(ext4_pspace_cachep, pa); |
| 3446 | 3449 | } |
| 3447 | 3450 | |
| @@ -3455,11 +3458,13 @@ static void ext4_mb_put_pa(struct ext4_allocation_context *ac, · 7 unmodified lines | ||
| 3455 | 3458 | ext4_group_t grp; |
| 3456 | 3459 | ext4_fsblk_t grp_blk; |
| 3457 | 3460 | |
| 3458 | − if (!atomic_dec_and_test(&pa->pa_count) || pa->pa_free != 0) | |
| 3459 | − return; | |
| 3460 | − | |
| 3461 | 3461 | /* in this short window concurrent discard can set pa_deleted */ |
| 3462 | 3462 | spin_lock(&pa->pa_lock); |
| 3463 | + if (!atomic_dec_and_test(&pa->pa_count) || pa->pa_free != 0) { | |
| 3464 | + spin_unlock(&pa->pa_lock); | |
| 3465 | + return; | |
| 3466 | + } | |
| 3467 | + | |
| 3463 | 3468 | if (pa->pa_deleted == 1) { |
| 3464 | 3469 | spin_unlock(&pa->pa_lock); |
| 3465 | 3470 | return; |
| @@ -4121,7 +4126,7 @@ ext4_mb_initialize_context(struct ext4_allocation_context *ac, · 655 unmodified lines | ||
| 4121 | 4126 | ext4_get_group_no_and_offset(sb, goal, &group, &block); |
| 4122 | 4127 | |
| 4123 | 4128 | /* set up allocation goals */ |
| 4124 | − ac->ac_b_ex.fe_logical = ar->logical & ~(sbi->s_cluster_ratio - 1); | |
| 4129 | + ac->ac_b_ex.fe_logical = EXT4_LBLK_CMASK(sbi, ar->logical); | |
| 4125 | 4130 | ac->ac_status = AC_STATUS_CONTINUE; |
| 4126 | 4131 | ac->ac_sb = sb; |
| 4127 | 4132 | ac->ac_inode = ar->inode; |
| @@ -4663,7 +4668,7 @@ void ext4_free_blocks(handle_t *handle, struct inode *inode, · 535 unmodified lines | ||
| 4663 | 4668 | * blocks at the beginning or the end unless we are explicitly |
| 4664 | 4669 | * requested to avoid doing so. |
| 4665 | 4670 | */ |
| 4666 | − overflow = block & (sbi->s_cluster_ratio - 1); | |
| 4671 | + overflow = EXT4_PBLK_COFF(sbi, block); | |
| 4667 | 4672 | if (overflow) { |
| 4668 | 4673 | if (flags & EXT4_FREE_BLOCKS_NOFREE_FIRST_CLUSTER) { |
| 4669 | 4674 | overflow = sbi->s_cluster_ratio - overflow; |
| @@ -4677,7 +4682,7 @@ void ext4_free_blocks(handle_t *handle, struct inode *inode, · 7 unmodified lines | ||
| 4677 | 4682 | count += overflow; |
| 4678 | 4683 | } |
| 4679 | 4684 | } |
| 4680 | − overflow = count & (sbi->s_cluster_ratio - 1); | |
| 4685 | + overflow = EXT4_LBLK_COFF(sbi, count); | |
| 4681 | 4686 | if (overflow) { |
| 4682 | 4687 | if (flags & EXT4_FREE_BLOCKS_NOFREE_LAST_CLUSTER) { |
| 4683 | 4688 | if (count > overflow) |
| @@ -792,7 +792,7 @@ static void ext4_put_super(struct super_block *sb) · 791 unmodified lines | ||
| 792 | 792 | } |
| 793 | 793 | |
| 794 | 794 | ext4_es_unregister_shrinker(sbi); |
| 795 | − del_timer(&sbi->s_err_report); | |
| 795 | + del_timer_sync(&sbi->s_err_report); | |
| 796 | 796 | ext4_release_system_zone(sb); |
| 797 | 797 | ext4_mb_release(sb); |
| 798 | 798 | ext4_ext_release(sb); |
| @@ -3316,10 +3316,18 @@ int ext4_calculate_overhead(struct super_block *sb) · 2517 unmodified lines | ||
| 3316 | 3316 | } |
| 3317 | 3317 | |
| 3318 | 3318 | |
| 3319 | −static ext4_fsblk_t ext4_calculate_resv_clusters(struct ext4_sb_info *sbi) | |
| 3319 | +static ext4_fsblk_t ext4_calculate_resv_clusters(struct super_block *sb) | |
| 3320 | 3320 | { |
| 3321 | 3321 | ext4_fsblk_t resv_clusters; |
| 3322 | 3322 | |
| 3323 | + /* | |
| 3324 | + * There's no need to reserve anything when we aren't using extents. | |
| 3325 | + * The space estimates are exact, there are no unwritten extents, | |
| 3326 | + * hole punching doesn't need new metadata... This is needed especially | |
| 3327 | + * to keep ext2/3 backward compatibility. | |
| 3328 | + */ | |
| 3329 | + if (!EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_EXTENTS)) | |
| 3330 | + return 0; | |
| 3323 | 3331 | /* |
| 3324 | 3332 | * By default we reserve 2% or 4096 clusters, whichever is smaller. |
| 3325 | 3333 | * This should cover the situations where we can not afford to run |
| @@ -3328,7 +3336,8 @@ static ext4_fsblk_t ext4_calculate_resv_clusters(struct ext4_sb_info *sbi) · 2 unmodified lines | ||
| 3328 | 3336 | * allocation would require 1, or 2 blocks, higher numbers are |
| 3329 | 3337 | * very rare. |
| 3330 | 3338 | */ |
| 3331 | − resv_clusters = ext4_blocks_count(sbi->s_es) >> sbi->s_cluster_bits; | |
| 3339 | + resv_clusters = ext4_blocks_count(EXT4_SB(sb)->s_es) >> | |
| 3340 | + EXT4_SB(sb)->s_cluster_bits; | |
| 3332 | 3341 | |
| 3333 | 3342 | do_div(resv_clusters, 50); |
| 3334 | 3343 | resv_clusters = min_t(ext4_fsblk_t, resv_clusters, 4096); |
| @@ -4071,10 +4080,10 @@ no_journal: · 736 unmodified lines | ||
| 4071 | 4080 | "available"); |
| 4072 | 4081 | } |
| 4073 | 4082 | |
| 4074 | − err = ext4_reserve_clusters(sbi, ext4_calculate_resv_clusters(sbi)); | |
| 4083 | + err = ext4_reserve_clusters(sbi, ext4_calculate_resv_clusters(sb)); | |
| 4075 | 4084 | if (err) { |
| 4076 | 4085 | ext4_msg(sb, KERN_ERR, "failed to reserve %llu clusters for " |
| 4077 | − "reserved pool", ext4_calculate_resv_clusters(sbi)); | |
| 4086 | + "reserved pool", ext4_calculate_resv_clusters(sb)); | |
| 4078 | 4087 | goto failed_mount4a; |
| 4079 | 4088 | } |
| 4080 | 4089 | |
| @@ -4184,7 +4193,7 @@ failed_mount_wq: · 103 unmodified lines | ||
| 4184 | 4193 | } |
| 4185 | 4194 | failed_mount3: |
| 4186 | 4195 | ext4_es_unregister_shrinker(sbi); |
| 4187 | − del_timer(&sbi->s_err_report); | |
| 4196 | + del_timer_sync(&sbi->s_err_report); | |
| 4188 | 4197 | if (sbi->s_flex_groups) |
| 4189 | 4198 | ext4_kvfree(sbi->s_flex_groups); |
| 4190 | 4199 | percpu_counter_destroy(&sbi->s_freeclusters_counter); |
| @@ -702,7 +702,7 @@ int jbd2_log_wait_commit(journal_t *journal, tid_t tid) · 701 unmodified lines | ||
| 702 | 702 | read_lock(&journal->j_state_lock); |
| 703 | 703 | #ifdef CONFIG_JBD2_DEBUG |
| 704 | 704 | if (!tid_geq(journal->j_commit_request, tid)) { |
| 705 | − printk(KERN_EMERG | |
| 705 | + printk(KERN_ERR | |
| 706 | 706 | "%s: error: j_commit_request=%d, tid=%d\n", |
| 707 | 707 | __func__, journal->j_commit_request, tid); |
| 708 | 708 | } |
| @@ -718,10 +718,8 @@ int jbd2_log_wait_commit(journal_t *journal, tid_t tid) · 9 unmodified lines | ||
| 718 | 718 | } |
| 719 | 719 | read_unlock(&journal->j_state_lock); |
| 720 | 720 | |
| 721 | − if (unlikely(is_journal_aborted(journal))) { | |
| 722 | − printk(KERN_EMERG "journal commit I/O error\n"); | |
| 721 | + if (unlikely(is_journal_aborted(journal))) | |
| 723 | 722 | err = -EIO; |
| 724 | − } | |
| 725 | 723 | return err; |
| 726 | 724 | } |
| 727 | 725 | |
| @@ -1527,13 +1525,13 @@ static int journal_get_superblock(journal_t *journal) · 799 unmodified lines | ||
| 1527 | 1525 | if (JBD2_HAS_COMPAT_FEATURE(journal, JBD2_FEATURE_COMPAT_CHECKSUM) && |
| 1528 | 1526 | JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_CSUM_V2)) { |
| 1529 | 1527 | /* Can't have checksum v1 and v2 on at the same time! */ |
| 1530 | − printk(KERN_ERR "JBD: Can't enable checksumming v1 and v2 " | |
| 1528 | + printk(KERN_ERR "JBD2: Can't enable checksumming v1 and v2 " | |
| 1531 | 1529 | "at the same time!\n"); |
| 1532 | 1530 | goto out; |
| 1533 | 1531 | } |
| 1534 | 1532 | |
| 1535 | 1533 | if (!jbd2_verify_csum_type(journal, sb)) { |
| 1536 | − printk(KERN_ERR "JBD: Unknown checksum type\n"); | |
| 1534 | + printk(KERN_ERR "JBD2: Unknown checksum type\n"); | |
| 1537 | 1535 | goto out; |
| 1538 | 1536 | } |
| 1539 | 1537 | |
| @@ -1541,7 +1539,7 @@ static int journal_get_superblock(journal_t *journal) · 1 unmodified line | ||
| 1541 | 1539 | if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_CSUM_V2)) { |
| 1542 | 1540 | journal->j_chksum_driver = crypto_alloc_shash("crc32c", 0, 0); |
| 1543 | 1541 | if (IS_ERR(journal->j_chksum_driver)) { |
| 1544 | − printk(KERN_ERR "JBD: Cannot load crc32c driver.\n"); | |
| 1542 | + printk(KERN_ERR "JBD2: Cannot load crc32c driver.\n"); | |
| 1545 | 1543 | err = PTR_ERR(journal->j_chksum_driver); |
| 1546 | 1544 | journal->j_chksum_driver = NULL; |
| 1547 | 1545 | goto out; |
| @@ -1550,7 +1548,7 @@ static int journal_get_superblock(journal_t *journal) · 2 unmodified lines | ||
| 1550 | 1548 | |
| 1551 | 1549 | /* Check superblock checksum */ |
| 1552 | 1550 | if (!jbd2_superblock_csum_verify(journal, sb)) { |
| 1553 | − printk(KERN_ERR "JBD: journal checksum error\n"); | |
| 1551 | + printk(KERN_ERR "JBD2: journal checksum error\n"); | |
| 1554 | 1552 | goto out; |
| 1555 | 1553 | } |
| 1556 | 1554 | |
| @@ -1836,7 +1834,7 @@ int jbd2_journal_set_features (journal_t *journal, unsigned long compat, · 279 unmodified lines | ||
| 1836 | 1834 | journal->j_chksum_driver = crypto_alloc_shash("crc32c", |
| 1837 | 1835 | 0, 0); |
| 1838 | 1836 | if (IS_ERR(journal->j_chksum_driver)) { |
| 1839 | − printk(KERN_ERR "JBD: Cannot load crc32c " | |
| 1837 | + printk(KERN_ERR "JBD2: Cannot load crc32c " | |
| 1840 | 1838 | "driver.\n"); |
| 1841 | 1839 | journal->j_chksum_driver = NULL; |
| 1842 | 1840 | return 0; |
| @@ -2645,7 +2643,7 @@ static void __exit journal_exit(void) · 802 unmodified lines | ||
| 2645 | 2643 | #ifdef CONFIG_JBD2_DEBUG |
| 2646 | 2644 | int n = atomic_read(&nr_journal_heads); |
| 2647 | 2645 | if (n) |
| 2648 | − printk(KERN_EMERG "JBD2: leaked %d journal_heads!\n", n); | |
| 2646 | + printk(KERN_ERR "JBD2: leaked %d journal_heads!\n", n); | |
| 2649 | 2647 | #endif |
| 2650 | 2648 | jbd2_remove_jbd_stats_proc_entry(); |
| 2651 | 2649 | jbd2_journal_destroy_caches(); |
| @@ -594,7 +594,7 @@ static int do_one_pass(journal_t *journal, · 593 unmodified lines | ||
| 594 | 594 | be32_to_cpu(tmp->h_sequence))) { |
| 595 | 595 | brelse(obh); |
| 596 | 596 | success = -EIO; |
| 597 | − printk(KERN_ERR "JBD: Invalid " | |
| 597 | + printk(KERN_ERR "JBD2: Invalid " | |
| 598 | 598 | "checksum recovering " |
| 599 | 599 | "block %llu in log\n", |
| 600 | 600 | blocknr); |
| @@ -932,7 +932,7 @@ repeat: · 931 unmodified lines | ||
| 932 | 932 | jbd2_alloc(jh2bh(jh)->b_size, |
| 933 | 933 | GFP_NOFS); |
| 934 | 934 | if (!frozen_buffer) { |
| 935 | − printk(KERN_EMERG | |
| 935 | + printk(KERN_ERR | |
| 936 | 936 | "%s: OOM for frozen_buffer\n", |
| 937 | 937 | __func__); |
| 938 | 938 | JBUFFER_TRACE(jh, "oom!"); |
| @@ -1166,7 +1166,7 @@ repeat: · 227 unmodified lines | ||
| 1166 | 1166 | if (!jh->b_committed_data) { |
| 1167 | 1167 | committed_data = jbd2_alloc(jh2bh(jh)->b_size, GFP_NOFS); |
| 1168 | 1168 | if (!committed_data) { |
| 1169 | − printk(KERN_EMERG "%s: No memory for committed data\n", | |
| 1169 | + printk(KERN_ERR "%s: No memory for committed data\n", | |
| 1170 | 1170 | __func__); |
| 1171 | 1171 | err = -ENOMEM; |
| 1172 | 1172 | goto out; |
| @@ -1290,7 +1290,10 @@ int jbd2_journal_dirty_metadata(handle_t *handle, struct buffer_head *bh) · 117 unmodified lines | ||
| 1290 | 1290 | * once a transaction -bzzz |
| 1291 | 1291 | */ |
| 1292 | 1292 | jh->b_modified = 1; |
| 1293 | − J_ASSERT_JH(jh, handle->h_buffer_credits > 0); | |
| 1293 | + if (handle->h_buffer_credits <= 0) { | |
| 1294 | + ret = -ENOSPC; | |
| 1295 | + goto out_unlock_bh; | |
| 1296 | + } | |
| 1294 | 1297 | handle->h_buffer_credits--; |
| 1295 | 1298 | } |
| 1296 | 1299 | |
| @@ -1305,7 +1308,7 @@ int jbd2_journal_dirty_metadata(handle_t *handle, struct buffer_head *bh) · 8 unmodified lines | ||
| 1305 | 1308 | JBUFFER_TRACE(jh, "fastpath"); |
| 1306 | 1309 | if (unlikely(jh->b_transaction != |
| 1307 | 1310 | journal->j_running_transaction)) { |
| 1308 | − printk(KERN_EMERG "JBD: %s: " | |
| 1311 | + printk(KERN_ERR "JBD2: %s: " | |
| 1309 | 1312 | "jh->b_transaction (%llu, %p, %u) != " |
| 1310 | 1313 | "journal->j_running_transaction (%p, %u)", |
| 1311 | 1314 | journal->j_devname, |
| @@ -1332,7 +1335,7 @@ int jbd2_journal_dirty_metadata(handle_t *handle, struct buffer_head *bh) · 20 unmodified lines | ||
| 1332 | 1335 | JBUFFER_TRACE(jh, "already on other transaction"); |
| 1333 | 1336 | if (unlikely(jh->b_transaction != |
| 1334 | 1337 | journal->j_committing_transaction)) { |
| 1335 | − printk(KERN_EMERG "JBD: %s: " | |
| 1338 | + printk(KERN_ERR "JBD2: %s: " | |
| 1336 | 1339 | "jh->b_transaction (%llu, %p, %u) != " |
| 1337 | 1340 | "journal->j_committing_transaction (%p, %u)", |
| 1338 | 1341 | journal->j_devname, |
| @@ -1345,7 +1348,7 @@ int jbd2_journal_dirty_metadata(handle_t *handle, struct buffer_head *bh) · 6 unmodified lines | ||
| 1345 | 1348 | ret = -EINVAL; |
| 1346 | 1349 | } |
| 1347 | 1350 | if (unlikely(jh->b_next_transaction != transaction)) { |
| 1348 | − printk(KERN_EMERG "JBD: %s: " | |
| 1351 | + printk(KERN_ERR "JBD2: %s: " | |
| 1349 | 1352 | "jh->b_next_transaction (%llu, %p, %u) != " |
| 1350 | 1353 | "transaction (%p, %u)", |
| 1351 | 1354 | journal->j_devname, |
| @@ -1373,7 +1376,6 @@ out_unlock_bh: · 21 unmodified lines | ||
| 1373 | 1376 | jbd2_journal_put_journal_head(jh); |
| 1374 | 1377 | out: |
| 1375 | 1378 | JBUFFER_TRACE(jh, "exit"); |
| 1376 | − WARN_ON(ret); /* All errors are bugs, so dump the stack */ | |
| 1377 | 1379 | return ret; |
| 1378 | 1380 | } |
| 1379 | 1381 | |
| @@ -443,8 +443,11 @@ int pstore_register(struct pstore_info *psi) · 442 unmodified lines | ||
| 443 | 443 | pstore_get_records(0); |
| 444 | 444 | |
| 445 | 445 | kmsg_dump_register(&pstore_dumper); |
| 446 | − pstore_register_console(); | |
| 447 | − pstore_register_ftrace(); | |
| 446 | + | |
| 447 | + if ((psi->flags & PSTORE_FLAGS_FRAGILE) == 0) { | |
| 448 | + pstore_register_console(); | |
| 449 | + pstore_register_ftrace(); | |
| 450 | + } | |
| 448 | 451 | |
| 449 | 452 | if (pstore_update_ms >= 0) { |
| 450 | 453 | pstore_timer.expires = jiffies + |
| @@ -609,7 +609,7 @@ static int sysfs_open_file(struct inode *inode, struct file *file) · 608 unmodified lines | ||
| 609 | 609 | struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata; |
| 610 | 610 | struct kobject *kobj = attr_sd->s_parent->s_dir.kobj; |
| 611 | 611 | struct sysfs_open_file *of; |
| 612 | − bool has_read, has_write, has_mmap; | |
| 612 | + bool has_read, has_write; | |
| 613 | 613 | int error = -EACCES; |
| 614 | 614 | |
| 615 | 615 | /* need attr_sd for attr and ops, its parent for kobj */ |
| @@ -621,7 +621,6 @@ static int sysfs_open_file(struct inode *inode, struct file *file) · 5 unmodified lines | ||
| 621 | 621 | |
| 622 | 622 | has_read = battr->read || battr->mmap; |
| 623 | 623 | has_write = battr->write || battr->mmap; |
| 624 | − has_mmap = battr->mmap; | |
| 625 | 624 | } else { |
| 626 | 625 | const struct sysfs_ops *ops = sysfs_file_ops(attr_sd); |
| 627 | 626 | |
| @@ -633,7 +632,6 @@ static int sysfs_open_file(struct inode *inode, struct file *file) · 5 unmodified lines | ||
| 633 | 632 | |
| 634 | 633 | has_read = ops->show; |
| 635 | 634 | has_write = ops->store; |
| 636 | − has_mmap = false; | |
| 637 | 635 | } |
| 638 | 636 | |
| 639 | 637 | /* check perms and supported operations */ |
| @@ -661,9 +659,9 @@ static int sysfs_open_file(struct inode *inode, struct file *file) · 21 unmodified lines | ||
| 661 | 659 | * open file has a separate mutex, it's okay as long as those don't |
| 662 | 660 | * happen on the same file. At this point, we can't easily give |
| 663 | 661 | * each file a separate locking class. Let's differentiate on |
| 664 | − * whether the file has mmap or not for now. | |
| 662 | + * whether the file is bin or not for now. | |
| 665 | 663 | */ |
| 666 | − if (has_mmap) | |
| 664 | + if (sysfs_is_bin(attr_sd)) | |
| 667 | 665 | mutex_init(&of->mutex); |
| 668 | 666 | else |
| 669 | 667 | mutex_init(&of->mutex); |
| @@ -1635,7 +1635,7 @@ xfs_bmap_last_extent( · 1634 unmodified lines | ||
| 1635 | 1635 | * blocks at the end of the file which do not start at the previous data block, |
| 1636 | 1636 | * we will try to align the new blocks at stripe unit boundaries. |
| 1637 | 1637 | * |
| 1638 | − * Returns 0 in bma->aeof if the file (fork) is empty as any new write will be | |
| 1638 | + * Returns 1 in bma->aeof if the file (fork) is empty as any new write will be | |
| 1639 | 1639 | * at, or past the EOF. |
| 1640 | 1640 | */ |
| 1641 | 1641 | STATIC int |
| @@ -1650,9 +1650,14 @@ xfs_bmap_isaeof( · 8 unmodified lines | ||
| 1650 | 1650 | bma->aeof = 0; |
| 1651 | 1651 | error = xfs_bmap_last_extent(NULL, bma->ip, whichfork, &rec, |
| 1652 | 1652 | &is_empty); |
| 1653 | − if (error || is_empty) | |
| 1653 | + if (error) | |
| 1654 | 1654 | return error; |
| 1655 | 1655 | |
| 1656 | + if (is_empty) { | |
| 1657 | + bma->aeof = 1; | |
| 1658 | + return 0; | |
| 1659 | + } | |
| 1660 | + | |
| 1656 | 1661 | /* |
| 1657 | 1662 | * Check if we are allocation or past the last extent, or at least into |
| 1658 | 1663 | * the last delayed allocated extent. |
| @@ -3643,10 +3648,19 @@ xfs_bmap_btalloc( · 1984 unmodified lines | ||
| 3643 | 3648 | int isaligned; |
| 3644 | 3649 | int tryagain; |
| 3645 | 3650 | int error; |
| 3651 | + int stripe_align; | |
| 3646 | 3652 | |
| 3647 | 3653 | ASSERT(ap->length); |
| 3648 | 3654 | |
| 3649 | 3655 | mp = ap->ip->i_mount; |
| 3656 | + | |
| 3657 | + /* stripe alignment for allocation is determined by mount parameters */ | |
| 3658 | + stripe_align = 0; | |
| 3659 | + if (mp->m_swidth && (mp->m_flags & XFS_MOUNT_SWALLOC)) | |
| 3660 | + stripe_align = mp->m_swidth; | |
| 3661 | + else if (mp->m_dalign) | |
| 3662 | + stripe_align = mp->m_dalign; | |
| 3663 | + | |
| 3650 | 3664 | align = ap->userdata ? xfs_get_extsz_hint(ap->ip) : 0; |
| 3651 | 3665 | if (unlikely(align)) { |
| 3652 | 3666 | error = xfs_bmap_extsize_align(mp, &ap->got, &ap->prev, |
| @@ -3655,6 +3669,8 @@ xfs_bmap_btalloc( · 2 unmodified lines | ||
| 3655 | 3669 | ASSERT(!error); |
| 3656 | 3670 | ASSERT(ap->length); |
| 3657 | 3671 | } |
| 3672 | + | |
| 3673 | + | |
| 3658 | 3674 | nullfb = *ap->firstblock == NULLFSBLOCK; |
| 3659 | 3675 | fb_agno = nullfb ? NULLAGNUMBER : XFS_FSB_TO_AGNO(mp, *ap->firstblock); |
| 3660 | 3676 | if (nullfb) { |
| @@ -3730,7 +3746,7 @@ xfs_bmap_btalloc( · 69 unmodified lines | ||
| 3730 | 3746 | */ |
| 3731 | 3747 | if (!ap->flist->xbf_low && ap->aeof) { |
| 3732 | 3748 | if (!ap->offset) { |
| 3733 | − args.alignment = mp->m_dalign; | |
| 3749 | + args.alignment = stripe_align; | |
| 3734 | 3750 | atype = args.type; |
| 3735 | 3751 | isaligned = 1; |
| 3736 | 3752 | /* |
| @@ -3755,13 +3771,13 @@ xfs_bmap_btalloc( · 18 unmodified lines | ||
| 3755 | 3771 | * of minlen+alignment+slop doesn't go up |
| 3756 | 3772 | * between the calls. |
| 3757 | 3773 | */ |
| 3758 | − if (blen > mp->m_dalign && blen <= args.maxlen) | |
| 3759 | − nextminlen = blen - mp->m_dalign; | |
| 3774 | + if (blen > stripe_align && blen <= args.maxlen) | |
| 3775 | + nextminlen = blen - stripe_align; | |
| 3760 | 3776 | else |
| 3761 | 3777 | nextminlen = args.minlen; |
| 3762 | − if (nextminlen + mp->m_dalign > args.minlen + 1) | |
| 3778 | + if (nextminlen + stripe_align > args.minlen + 1) | |
| 3763 | 3779 | args.minalignslop = |
| 3764 | − nextminlen + mp->m_dalign - | |
| 3780 | + nextminlen + stripe_align - | |
| 3765 | 3781 | args.minlen - 1; |
| 3766 | 3782 | else |
| 3767 | 3783 | args.minalignslop = 0; |
| @@ -3783,7 +3799,7 @@ xfs_bmap_btalloc( · 15 unmodified lines | ||
| 3783 | 3799 | */ |
| 3784 | 3800 | args.type = atype; |
| 3785 | 3801 | args.fsbno = ap->blkno; |
| 3786 | − args.alignment = mp->m_dalign; | |
| 3802 | + args.alignment = stripe_align; | |
| 3787 | 3803 | args.minlen = nextminlen; |
| 3788 | 3804 | args.minalignslop = 0; |
| 3789 | 3805 | isaligned = 1; |
| @@ -1187,7 +1187,12 @@ xfs_zero_remaining_bytes( · 1186 unmodified lines | ||
| 1187 | 1187 | XFS_BUF_UNWRITE(bp); |
| 1188 | 1188 | XFS_BUF_READ(bp); |
| 1189 | 1189 | XFS_BUF_SET_ADDR(bp, xfs_fsb_to_db(ip, imap.br_startblock)); |
| 1190 | − xfsbdstrat(mp, bp); | |
| 1190 | + | |
| 1191 | + if (XFS_FORCED_SHUTDOWN(mp)) { | |
| 1192 | + error = XFS_ERROR(EIO); | |
| 1193 | + break; | |
| 1194 | + } | |
| 1195 | + xfs_buf_iorequest(bp); | |
| 1191 | 1196 | error = xfs_buf_iowait(bp); |
| 1192 | 1197 | if (error) { |
| 1193 | 1198 | xfs_buf_ioerror_alert(bp, |
| @@ -1200,7 +1205,12 @@ xfs_zero_remaining_bytes( · 6 unmodified lines | ||
| 1200 | 1205 | XFS_BUF_UNDONE(bp); |
| 1201 | 1206 | XFS_BUF_UNREAD(bp); |
| 1202 | 1207 | XFS_BUF_WRITE(bp); |
| 1203 | − xfsbdstrat(mp, bp); | |
| 1208 | + | |
| 1209 | + if (XFS_FORCED_SHUTDOWN(mp)) { | |
| 1210 | + error = XFS_ERROR(EIO); | |
| 1211 | + break; | |
| 1212 | + } | |
| 1213 | + xfs_buf_iorequest(bp); | |
| 1204 | 1214 | error = xfs_buf_iowait(bp); |
| 1205 | 1215 | if (error) { |
| 1206 | 1216 | xfs_buf_ioerror_alert(bp, |
| @@ -698,7 +698,11 @@ xfs_buf_read_uncached( · 697 unmodified lines | ||
| 698 | 698 | bp->b_flags |= XBF_READ; |
| 699 | 699 | bp->b_ops = ops; |
| 700 | 700 | |
| 701 | − xfsbdstrat(target->bt_mount, bp); | |
| 701 | + if (XFS_FORCED_SHUTDOWN(target->bt_mount)) { | |
| 702 | + xfs_buf_relse(bp); | |
| 703 | + return NULL; | |
| 704 | + } | |
| 705 | + xfs_buf_iorequest(bp); | |
| 702 | 706 | xfs_buf_iowait(bp); |
| 703 | 707 | return bp; |
| 704 | 708 | } |
| @@ -1089,7 +1093,7 @@ xfs_bioerror( · 384 unmodified lines | ||
| 1089 | 1093 | * This is meant for userdata errors; metadata bufs come with |
| 1090 | 1094 | * iodone functions attached, so that we can track down errors. |
| 1091 | 1095 | */ |
| 1092 | −STATIC int | |
| 1096 | +int | |
| 1093 | 1097 | xfs_bioerror_relse( |
| 1094 | 1098 | struct xfs_buf *bp) |
| 1095 | 1099 | { |
| @@ -1152,7 +1156,7 @@ xfs_bwrite( · 56 unmodified lines | ||
| 1152 | 1156 | ASSERT(xfs_buf_islocked(bp)); |
| 1153 | 1157 | |
| 1154 | 1158 | bp->b_flags |= XBF_WRITE; |
| 1155 | − bp->b_flags &= ~(XBF_ASYNC | XBF_READ | _XBF_DELWRI_Q); | |
| 1159 | + bp->b_flags &= ~(XBF_ASYNC | XBF_READ | _XBF_DELWRI_Q | XBF_WRITE_FAIL); | |
| 1156 | 1160 | |
| 1157 | 1161 | xfs_bdstrat_cb(bp); |
| 1158 | 1162 | |
| @@ -1164,25 +1168,6 @@ xfs_bwrite( · 5 unmodified lines | ||
| 1164 | 1168 | return error; |
| 1165 | 1169 | } |
| 1166 | 1170 | |
| 1167 | −/* | |
| 1168 | − * Wrapper around bdstrat so that we can stop data from going to disk in case | |
| 1169 | − * we are shutting down the filesystem. Typically user data goes thru this | |
| 1170 | − * path; one of the exceptions is the superblock. | |
| 1171 | − */ | |
| 1172 | −void | |
| 1173 | −xfsbdstrat( | |
| 1174 | − struct xfs_mount *mp, | |
| 1175 | − struct xfs_buf *bp) | |
| 1176 | −{ | |
| 1177 | − if (XFS_FORCED_SHUTDOWN(mp)) { | |
| 1178 | − trace_xfs_bdstrat_shut(bp, _RET_IP_); | |
| 1179 | − xfs_bioerror_relse(bp); | |
| 1180 | − return; | |
| 1181 | − } | |
| 1182 | − | |
| 1183 | − xfs_buf_iorequest(bp); | |
| 1184 | −} | |
| 1185 | − | |
| 1186 | 1171 | STATIC void |
| 1187 | 1172 | _xfs_buf_ioend( |
| 1188 | 1173 | xfs_buf_t *bp, |
| @@ -1516,6 +1501,12 @@ xfs_wait_buftarg( · 327 unmodified lines | ||
| 1516 | 1501 | struct xfs_buf *bp; |
| 1517 | 1502 | bp = list_first_entry(&dispose, struct xfs_buf, b_lru); |
| 1518 | 1503 | list_del_init(&bp->b_lru); |
| 1504 | + if (bp->b_flags & XBF_WRITE_FAIL) { | |
| 1505 | + xfs_alert(btp->bt_mount, | |
| 1506 | +"Corruption Alert: Buffer at block 0x%llx had permanent write failures!\n" | |
| 1507 | +"Please run xfs_repair to determine the extent of the problem.", | |
| 1508 | + (long long)bp->b_bn); | |
| 1509 | + } | |
| 1519 | 1510 | xfs_buf_rele(bp); |
| 1520 | 1511 | } |
| 1521 | 1512 | if (loop++ != 0) |
| @@ -1799,7 +1790,7 @@ __xfs_buf_delwri_submit( · 277 unmodified lines | ||
| 1799 | 1790 | |
| 1800 | 1791 | blk_start_plug(&plug); |
| 1801 | 1792 | list_for_each_entry_safe(bp, n, io_list, b_list) { |
| 1802 | − bp->b_flags &= ~(_XBF_DELWRI_Q | XBF_ASYNC); | |
| 1793 | + bp->b_flags &= ~(_XBF_DELWRI_Q | XBF_ASYNC | XBF_WRITE_FAIL); | |
| 1803 | 1794 | bp->b_flags |= XBF_WRITE; |
| 1804 | 1795 | |
| 1805 | 1796 | if (!wait) { |
| @@ -45,6 +45,7 @@ typedef enum { · 44 unmodified lines | ||
| 45 | 45 | #define XBF_ASYNC (1 << 4) /* initiator will not wait for completion */ |
| 46 | 46 | #define XBF_DONE (1 << 5) /* all pages in the buffer uptodate */ |
| 47 | 47 | #define XBF_STALE (1 << 6) /* buffer has been staled, do not find it */ |
| 48 | +#define XBF_WRITE_FAIL (1 << 24)/* async writes have failed on this buffer */ | |
| 48 | 49 | |
| 49 | 50 | /* I/O hints for the BIO layer */ |
| 50 | 51 | #define XBF_SYNCIO (1 << 10)/* treat this buffer as synchronous I/O */ |
| @@ -70,6 +71,7 @@ typedef unsigned int xfs_buf_flags_t; · 19 unmodified lines | ||
| 70 | 71 | { XBF_ASYNC, "ASYNC" }, \ |
| 71 | 72 | { XBF_DONE, "DONE" }, \ |
| 72 | 73 | { XBF_STALE, "STALE" }, \ |
| 74 | + { XBF_WRITE_FAIL, "WRITE_FAIL" }, \ | |
| 73 | 75 | { XBF_SYNCIO, "SYNCIO" }, \ |
| 74 | 76 | { XBF_FUA, "FUA" }, \ |
| 75 | 77 | { XBF_FLUSH, "FLUSH" }, \ |
| @@ -80,6 +82,7 @@ typedef unsigned int xfs_buf_flags_t; · 4 unmodified lines | ||
| 80 | 82 | { _XBF_DELWRI_Q, "DELWRI_Q" }, \ |
| 81 | 83 | { _XBF_COMPOUND, "COMPOUND" } |
| 82 | 84 | |
| 85 | + | |
| 83 | 86 | /* |
| 84 | 87 | * Internal state flags. |
| 85 | 88 | */ |
| @@ -269,9 +272,6 @@ extern void xfs_buf_unlock(xfs_buf_t *); · 183 unmodified lines | ||
| 269 | 272 | |
| 270 | 273 | /* Buffer Read and Write Routines */ |
| 271 | 274 | extern int xfs_bwrite(struct xfs_buf *bp); |
| 272 | − | |
| 273 | −extern void xfsbdstrat(struct xfs_mount *, struct xfs_buf *); | |
| 274 | − | |
| 275 | 275 | extern void xfs_buf_ioend(xfs_buf_t *, int); |
| 276 | 276 | extern void xfs_buf_ioerror(xfs_buf_t *, int); |
| 277 | 277 | extern void xfs_buf_ioerror_alert(struct xfs_buf *, const char *func); |
| @@ -282,6 +282,8 @@ extern void xfs_buf_iomove(xfs_buf_t *, size_t, size_t, void *, · 4 unmodified lines | ||
| 282 | 282 | #define xfs_buf_zero(bp, off, len) \ |
| 283 | 283 | xfs_buf_iomove((bp), (off), (len), NULL, XBRW_ZERO) |
| 284 | 284 | |
| 285 | +extern int xfs_bioerror_relse(struct xfs_buf *); | |
| 286 | + | |
| 285 | 287 | static inline int xfs_buf_geterror(xfs_buf_t *bp) |
| 286 | 288 | { |
| 287 | 289 | return bp ? bp->b_error : ENOMEM; |
| @@ -301,7 +303,8 @@ extern void xfs_buf_terminate(void); · 13 unmodified lines | ||
| 301 | 303 | |
| 302 | 304 | #define XFS_BUF_ZEROFLAGS(bp) \ |
| 303 | 305 | ((bp)->b_flags &= ~(XBF_READ|XBF_WRITE|XBF_ASYNC| \ |
| 304 | − XBF_SYNCIO|XBF_FUA|XBF_FLUSH)) | |
| 306 | + XBF_SYNCIO|XBF_FUA|XBF_FLUSH| \ | |
| 307 | + XBF_WRITE_FAIL)) | |
| 305 | 308 | |
| 306 | 309 | void xfs_buf_stale(struct xfs_buf *bp); |
| 307 | 310 | #define XFS_BUF_UNSTALE(bp) ((bp)->b_flags &= ~XBF_STALE) |
| @@ -496,6 +496,14 @@ xfs_buf_item_unpin( · 495 unmodified lines | ||
| 496 | 496 | } |
| 497 | 497 | } |
| 498 | 498 | |
| 499 | +/* | |
| 500 | + * Buffer IO error rate limiting. Limit it to no more than 10 messages per 30 | |
| 501 | + * seconds so as to not spam logs too much on repeated detection of the same | |
| 502 | + * buffer being bad.. | |
| 503 | + */ | |
| 504 | + | |
| 505 | +DEFINE_RATELIMIT_STATE(xfs_buf_write_fail_rl_state, 30 * HZ, 10); | |
| 506 | + | |
| 499 | 507 | STATIC uint |
| 500 | 508 | xfs_buf_item_push( |
| 501 | 509 | struct xfs_log_item *lip, |
| @@ -524,6 +532,14 @@ xfs_buf_item_push( · 22 unmodified lines | ||
| 524 | 532 | |
| 525 | 533 | trace_xfs_buf_item_push(bip); |
| 526 | 534 | |
| 535 | + /* has a previous flush failed due to IO errors? */ | |
| 536 | + if ((bp->b_flags & XBF_WRITE_FAIL) && | |
| 537 | + ___ratelimit(&xfs_buf_write_fail_rl_state, "XFS:")) { | |
| 538 | + xfs_warn(bp->b_target->bt_mount, | |
| 539 | +"Detected failing async write on buffer block 0x%llx. Retrying async write.\n", | |
| 540 | + (long long)bp->b_bn); | |
| 541 | + } | |
| 542 | + | |
| 527 | 543 | if (!xfs_buf_delwri_queue(bp, buffer_list)) |
| 528 | 544 | rval = XFS_ITEM_FLUSHING; |
| 529 | 545 | xfs_buf_unlock(bp); |
| @@ -1096,8 +1112,9 @@ xfs_buf_iodone_callbacks( · 566 unmodified lines | ||
| 1096 | 1112 | |
| 1097 | 1113 | xfs_buf_ioerror(bp, 0); /* errno of 0 unsets the flag */ |
| 1098 | 1114 | |
| 1099 | − if (!XFS_BUF_ISSTALE(bp)) { | |
| 1100 | − bp->b_flags |= XBF_WRITE | XBF_ASYNC | XBF_DONE; | |
| 1115 | + if (!(bp->b_flags & (XBF_STALE|XBF_WRITE_FAIL))) { | |
| 1116 | + bp->b_flags |= XBF_WRITE | XBF_ASYNC | | |
| 1117 | + XBF_DONE | XBF_WRITE_FAIL; | |
| 1101 | 1118 | xfs_buf_iorequest(bp); |
| 1102 | 1119 | } else { |
| 1103 | 1120 | xfs_buf_relse(bp); |
| @@ -2067,12 +2067,12 @@ xfs_dir2_node_lookup( · 2066 unmodified lines | ||
| 2067 | 2067 | */ |
| 2068 | 2068 | int /* error */ |
| 2069 | 2069 | xfs_dir2_node_removename( |
| 2070 | − xfs_da_args_t *args) /* operation arguments */ | |
| 2070 | + struct xfs_da_args *args) /* operation arguments */ | |
| 2071 | 2071 | { |
| 2072 | − xfs_da_state_blk_t *blk; /* leaf block */ | |
| 2072 | + struct xfs_da_state_blk *blk; /* leaf block */ | |
| 2073 | 2073 | int error; /* error return value */ |
| 2074 | 2074 | int rval; /* operation return value */ |
| 2075 | − xfs_da_state_t *state; /* btree cursor */ | |
| 2075 | + struct xfs_da_state *state; /* btree cursor */ | |
| 2076 | 2076 | |
| 2077 | 2077 | trace_xfs_dir2_node_removename(args); |
| 2078 | 2078 | |
| @@ -2084,19 +2084,18 @@ xfs_dir2_node_removename( · 5 unmodified lines | ||
| 2084 | 2084 | state->mp = args->dp->i_mount; |
| 2085 | 2085 | state->blocksize = state->mp->m_dirblksize; |
| 2086 | 2086 | state->node_ents = state->mp->m_dir_node_ents; |
| 2087 | − /* | |
| 2088 | − * Look up the entry we're deleting, set up the cursor. | |
| 2089 | − */ | |
| 2087 | + | |
| 2088 | + /* Look up the entry we're deleting, set up the cursor. */ | |
| 2090 | 2089 | error = xfs_da3_node_lookup_int(state, &rval); |
| 2091 | 2090 | if (error) |
| 2092 | − rval = error; | |
| 2093 | − /* | |
| 2094 | − * Didn't find it, upper layer screwed up. | |
| 2095 | − */ | |
| 2091 | + goto out_free; | |
| 2092 | + | |
| 2093 | + /* Didn't find it, upper layer screwed up. */ | |
| 2096 | 2094 | if (rval != EEXIST) { |
| 2097 | − xfs_da_state_free(state); | |
| 2098 | − return rval; | |
| 2095 | + error = rval; | |
| 2096 | + goto out_free; | |
| 2099 | 2097 | } |
| 2098 | + | |
| 2100 | 2099 | blk = &state->path.blk[state->path.active - 1]; |
| 2101 | 2100 | ASSERT(blk->magic == XFS_DIR2_LEAFN_MAGIC); |
| 2102 | 2101 | ASSERT(state->extravalid); |
| @@ -2107,7 +2106,7 @@ xfs_dir2_node_removename( · 4 unmodified lines | ||
| 2107 | 2106 | error = xfs_dir2_leafn_remove(args, blk->bp, blk->index, |
| 2108 | 2107 | &state->extrablk, &rval); |
| 2109 | 2108 | if (error) |
| 2110 | − return error; | |
| 2109 | + goto out_free; | |
| 2111 | 2110 | /* |
| 2112 | 2111 | * Fix the hash values up the btree. |
| 2113 | 2112 | */ |
| @@ -2122,6 +2121,7 @@ xfs_dir2_node_removename( · 8 unmodified lines | ||
| 2122 | 2121 | */ |
| 2123 | 2122 | if (!error) |
| 2124 | 2123 | error = xfs_dir2_node_to_leaf(state); |
| 2124 | +out_free: | |
| 2125 | 2125 | xfs_da_state_free(state); |
| 2126 | 2126 | return error; |
| 2127 | 2127 | } |
| @@ -618,7 +618,8 @@ xfs_setattr_nonsize( · 617 unmodified lines | ||
| 618 | 618 | } |
| 619 | 619 | if (!gid_eq(igid, gid)) { |
| 620 | 620 | if (XFS_IS_QUOTA_RUNNING(mp) && XFS_IS_GQUOTA_ON(mp)) { |
| 621 | − ASSERT(!XFS_IS_PQUOTA_ON(mp)); | |
| 621 | + ASSERT(xfs_sb_version_has_pquotino(&mp->m_sb) || | |
| 622 | + !XFS_IS_PQUOTA_ON(mp)); | |
| 622 | 623 | ASSERT(mask & ATTR_GID); |
| 623 | 624 | ASSERT(gdqp); |
| 624 | 625 | olddquot2 = xfs_qm_vop_chown(tp, ip, |
| @@ -193,7 +193,10 @@ xlog_bread_noalign( · 192 unmodified lines | ||
| 193 | 193 | bp->b_io_length = nbblks; |
| 194 | 194 | bp->b_error = 0; |
| 195 | 195 | |
| 196 | − xfsbdstrat(log->l_mp, bp); | |
| 196 | + if (XFS_FORCED_SHUTDOWN(log->l_mp)) | |
| 197 | + return XFS_ERROR(EIO); | |
| 198 | + | |
| 199 | + xfs_buf_iorequest(bp); | |
| 197 | 200 | error = xfs_buf_iowait(bp); |
| 198 | 201 | if (error) |
| 199 | 202 | xfs_buf_ioerror_alert(bp, __func__); |
| @@ -4397,7 +4400,13 @@ xlog_do_recover( · 4197 unmodified lines | ||
| 4397 | 4400 | XFS_BUF_READ(bp); |
| 4398 | 4401 | XFS_BUF_UNASYNC(bp); |
| 4399 | 4402 | bp->b_ops = &xfs_sb_buf_ops; |
| 4400 | − xfsbdstrat(log->l_mp, bp); | |
| 4403 | + | |
| 4404 | + if (XFS_FORCED_SHUTDOWN(log->l_mp)) { | |
| 4405 | + xfs_buf_relse(bp); | |
| 4406 | + return XFS_ERROR(EIO); | |
| 4407 | + } | |
| 4408 | + | |
| 4409 | + xfs_buf_iorequest(bp); | |
| 4401 | 4410 | error = xfs_buf_iowait(bp); |
| 4402 | 4411 | if (error) { |
| 4403 | 4412 | xfs_buf_ioerror_alert(bp, __func__); |
| @@ -134,8 +134,6 @@ xfs_qm_dqpurge( · 133 unmodified lines | ||
| 134 | 134 | { |
| 135 | 135 | struct xfs_mount *mp = dqp->q_mount; |
| 136 | 136 | struct xfs_quotainfo *qi = mp->m_quotainfo; |
| 137 | − struct xfs_dquot *gdqp = NULL; | |
| 138 | − struct xfs_dquot *pdqp = NULL; | |
| 139 | 137 | |
| 140 | 138 | xfs_dqlock(dqp); |
| 141 | 139 | if ((dqp->dq_flags & XFS_DQ_FREEING) || dqp->q_nrefs != 0) { |
| @@ -143,21 +141,6 @@ xfs_qm_dqpurge( · 1 unmodified line | ||
| 143 | 141 | return EAGAIN; |
| 144 | 142 | } |
| 145 | 143 | |
| 146 | − /* | |
| 147 | − * If this quota has a hint attached, prepare for releasing it now. | |
| 148 | − */ | |
| 149 | − gdqp = dqp->q_gdquot; | |
| 150 | − if (gdqp) { | |
| 151 | − xfs_dqlock(gdqp); | |
| 152 | − dqp->q_gdquot = NULL; | |
| 153 | − } | |
| 154 | − | |
| 155 | − pdqp = dqp->q_pdquot; | |
| 156 | − if (pdqp) { | |
| 157 | − xfs_dqlock(pdqp); | |
| 158 | − dqp->q_pdquot = NULL; | |
| 159 | − } | |
| 160 | − | |
| 161 | 144 | dqp->dq_flags |= XFS_DQ_FREEING; |
| 162 | 145 | |
| 163 | 146 | xfs_dqflock(dqp); |
| @@ -206,11 +189,47 @@ xfs_qm_dqpurge( · 42 unmodified lines | ||
| 206 | 189 | XFS_STATS_DEC(xs_qm_dquot_unused); |
| 207 | 190 | |
| 208 | 191 | xfs_qm_dqdestroy(dqp); |
| 192 | + return 0; | |
| 193 | +} | |
| 194 | + | |
| 195 | +/* | |
| 196 | + * Release the group or project dquot pointers the user dquots maybe carrying | |
| 197 | + * around as a hint, and proceed to purge the user dquot cache if requested. | |
| 198 | +*/ | |
| 199 | +STATIC int | |
| 200 | +xfs_qm_dqpurge_hints( | |
| 201 | + struct xfs_dquot *dqp, | |
| 202 | + void *data) | |
| 203 | +{ | |
| 204 | + struct xfs_dquot *gdqp = NULL; | |
| 205 | + struct xfs_dquot *pdqp = NULL; | |
| 206 | + uint flags = *((uint *)data); | |
| 207 | + | |
| 208 | + xfs_dqlock(dqp); | |
| 209 | + if (dqp->dq_flags & XFS_DQ_FREEING) { | |
| 210 | + xfs_dqunlock(dqp); | |
| 211 | + return EAGAIN; | |
| 212 | + } | |
| 213 | + | |
| 214 | + /* If this quota has a hint attached, prepare for releasing it now */ | |
| 215 | + gdqp = dqp->q_gdquot; | |
| 216 | + if (gdqp) | |
| 217 | + dqp->q_gdquot = NULL; | |
| 218 | + | |
| 219 | + pdqp = dqp->q_pdquot; | |
| 220 | + if (pdqp) | |
| 221 | + dqp->q_pdquot = NULL; | |
| 222 | + | |
| 223 | + xfs_dqunlock(dqp); | |
| 209 | 224 | |
| 210 | 225 | if (gdqp) |
| 211 | − xfs_qm_dqput(gdqp); | |
| 226 | + xfs_qm_dqrele(gdqp); | |
| 212 | 227 | if (pdqp) |
| 213 | − xfs_qm_dqput(pdqp); | |
| 228 | + xfs_qm_dqrele(pdqp); | |
| 229 | + | |
| 230 | + if (flags & XFS_QMOPT_UQUOTA) | |
| 231 | + return xfs_qm_dqpurge(dqp, NULL); | |
| 232 | + | |
| 214 | 233 | return 0; |
| 215 | 234 | } |
| 216 | 235 | |
| @@ -222,8 +241,18 @@ xfs_qm_dqpurge_all( · 5 unmodified lines | ||
| 222 | 241 | struct xfs_mount *mp, |
| 223 | 242 | uint flags) |
| 224 | 243 | { |
| 225 | − if (flags & XFS_QMOPT_UQUOTA) | |
| 226 | − xfs_qm_dquot_walk(mp, XFS_DQ_USER, xfs_qm_dqpurge, NULL); | |
| 244 | + /* | |
| 245 | + * We have to release group/project dquot hint(s) from the user dquot | |
| 246 | + * at first if they are there, otherwise we would run into an infinite | |
| 247 | + * loop while walking through radix tree to purge other type of dquots | |
| 248 | + * since their refcount is not zero if the user dquot refers to them | |
| 249 | + * as hint. | |
| 250 | + * | |
| 251 | + * Call the special xfs_qm_dqpurge_hints() will end up go through the | |
| 252 | + * general xfs_qm_dqpurge() against user dquot cache if requested. | |
| 253 | + */ | |
| 254 | + xfs_qm_dquot_walk(mp, XFS_DQ_USER, xfs_qm_dqpurge_hints, &flags); | |
| 255 | + | |
| 227 | 256 | if (flags & XFS_QMOPT_GQUOTA) |
| 228 | 257 | xfs_qm_dquot_walk(mp, XFS_DQ_GROUP, xfs_qm_dqpurge, NULL); |
| 229 | 258 | if (flags & XFS_QMOPT_PQUOTA) |
| @@ -2082,24 +2111,21 @@ xfs_qm_vop_create_dqattach( · 1852 unmodified lines | ||
| 2082 | 2111 | ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); |
| 2083 | 2112 | ASSERT(XFS_IS_QUOTA_RUNNING(mp)); |
| 2084 | 2113 | |
| 2085 | − if (udqp) { | |
| 2114 | + if (udqp && XFS_IS_UQUOTA_ON(mp)) { | |
| 2086 | 2115 | ASSERT(ip->i_udquot == NULL); |
| 2087 | − ASSERT(XFS_IS_UQUOTA_ON(mp)); | |
| 2088 | 2116 | ASSERT(ip->i_d.di_uid == be32_to_cpu(udqp->q_core.d_id)); |
| 2089 | 2117 | |
| 2090 | 2118 | ip->i_udquot = xfs_qm_dqhold(udqp); |
| 2091 | 2119 | xfs_trans_mod_dquot(tp, udqp, XFS_TRANS_DQ_ICOUNT, 1); |
| 2092 | 2120 | } |
| 2093 | − if (gdqp) { | |
| 2121 | + if (gdqp && XFS_IS_GQUOTA_ON(mp)) { | |
| 2094 | 2122 | ASSERT(ip->i_gdquot == NULL); |
| 2095 | − ASSERT(XFS_IS_GQUOTA_ON(mp)); | |
| 2096 | 2123 | ASSERT(ip->i_d.di_gid == be32_to_cpu(gdqp->q_core.d_id)); |
| 2097 | 2124 | ip->i_gdquot = xfs_qm_dqhold(gdqp); |
| 2098 | 2125 | xfs_trans_mod_dquot(tp, gdqp, XFS_TRANS_DQ_ICOUNT, 1); |
| 2099 | 2126 | } |
| 2100 | − if (pdqp) { | |
| 2127 | + if (pdqp && XFS_IS_PQUOTA_ON(mp)) { | |
| 2101 | 2128 | ASSERT(ip->i_pdquot == NULL); |
| 2102 | − ASSERT(XFS_IS_PQUOTA_ON(mp)); | |
| 2103 | 2129 | ASSERT(xfs_get_projid(ip) == be32_to_cpu(pdqp->q_core.d_id)); |
| 2104 | 2130 | |
| 2105 | 2131 | ip->i_pdquot = xfs_qm_dqhold(pdqp); |
| @@ -314,7 +314,18 @@ xfs_trans_read_buf_map( · 313 unmodified lines | ||
| 314 | 314 | ASSERT(bp->b_iodone == NULL); |
| 315 | 315 | XFS_BUF_READ(bp); |
| 316 | 316 | bp->b_ops = ops; |
| 317 | − xfsbdstrat(tp->t_mountp, bp); | |
| 317 | + | |
| 318 | + /* | |
| 319 | + * XXX(hch): clean up the error handling here to be less | |
| 320 | + * of a mess.. | |
| 321 | + */ | |
| 322 | + if (XFS_FORCED_SHUTDOWN(mp)) { | |
| 323 | + trace_xfs_bdstrat_shut(bp, _RET_IP_); | |
| 324 | + xfs_bioerror_relse(bp); | |
| 325 | + } else { | |
| 326 | + xfs_buf_iorequest(bp); | |
| 327 | + } | |
| 328 | + | |
| 318 | 329 | error = xfs_buf_iowait(bp); |
| 319 | 330 | if (error) { |
| 320 | 331 | xfs_buf_ioerror_alert(bp, __func__); |
| @@ -217,7 +217,7 @@ static inline int pmd_same(pmd_t pmd_a, pmd_t pmd_b) · 216 unmodified lines | ||
| 217 | 217 | #endif |
| 218 | 218 | |
| 219 | 219 | #ifndef pte_accessible |
| 220 | −# define pte_accessible(pte) ((void)(pte),1) | |
| 220 | +# define pte_accessible(mm, pte) ((void)(pte), 1) | |
| 221 | 221 | #endif |
| 222 | 222 | |
| 223 | 223 | #ifndef flush_tlb_fix_spurious_fault |
| @@ -599,11 +599,10 @@ static inline int pmd_none_or_trans_huge_or_clear_bad(pmd_t *pmd) · 375 unmodified lines | ||
| 599 | 599 | #ifdef CONFIG_TRANSPARENT_HUGEPAGE |
| 600 | 600 | barrier(); |
| 601 | 601 | #endif |
| 602 | − if (pmd_none(pmdval)) | |
| 602 | + if (pmd_none(pmdval) || pmd_trans_huge(pmdval)) | |
| 603 | 603 | return 1; |
| 604 | 604 | if (unlikely(pmd_bad(pmdval))) { |
| 605 | − if (!pmd_trans_huge(pmdval)) | |
| 606 | − pmd_clear_bad(pmd); | |
| 605 | + pmd_clear_bad(pmd); | |
| 607 | 606 | return 1; |
| 608 | 607 | } |
| 609 | 608 | return 0; |
| @@ -3,13 +3,11 @@ · 2 unmodified lines | ||
| 3 | 3 | |
| 4 | 4 | #include <linux/thread_info.h> |
| 5 | 5 | |
| 6 | −/* | |
| 7 | − * We mask the PREEMPT_NEED_RESCHED bit so as not to confuse all current users | |
| 8 | − * that think a non-zero value indicates we cannot preempt. | |
| 9 | − */ | |
| 6 | +#define PREEMPT_ENABLED (0) | |
| 7 | + | |
| 10 | 8 | static __always_inline int preempt_count(void) |
| 11 | 9 | { |
| 12 | − return current_thread_info()->preempt_count & ~PREEMPT_NEED_RESCHED; | |
| 10 | + return current_thread_info()->preempt_count; | |
| 13 | 11 | } |
| 14 | 12 | |
| 15 | 13 | static __always_inline int *preempt_count_ptr(void) |
| @@ -17,11 +15,6 @@ static __always_inline int *preempt_count_ptr(void) · 1 unmodified line | ||
| 17 | 15 | return ¤t_thread_info()->preempt_count; |
| 18 | 16 | } |
| 19 | 17 | |
| 20 | −/* | |
| 21 | − * We now loose PREEMPT_NEED_RESCHED and cause an extra reschedule; however the | |
| 22 | − * alternative is loosing a reschedule. Better schedule too often -- also this | |
| 23 | − * should be a very rare operation. | |
| 24 | − */ | |
| 25 | 18 | static __always_inline void preempt_count_set(int pc) |
| 26 | 19 | { |
| 27 | 20 | *preempt_count_ptr() = pc; |
| @@ -41,28 +34,17 @@ static __always_inline void preempt_count_set(int pc) · 13 unmodified lines | ||
| 41 | 34 | task_thread_info(p)->preempt_count = PREEMPT_ENABLED; \ |
| 42 | 35 | } while (0) |
| 43 | 36 | |
| 44 | −/* | |
| 45 | − * We fold the NEED_RESCHED bit into the preempt count such that | |
| 46 | − * preempt_enable() can decrement and test for needing to reschedule with a | |
| 47 | − * single instruction. | |
| 48 | − * | |
| 49 | − * We invert the actual bit, so that when the decrement hits 0 we know we both | |
| 50 | − * need to resched (the bit is cleared) and can resched (no preempt count). | |
| 51 | − */ | |
| 52 | − | |
| 53 | 37 | static __always_inline void set_preempt_need_resched(void) |
| 54 | 38 | { |
| 55 | − *preempt_count_ptr() &= ~PREEMPT_NEED_RESCHED; | |
| 56 | 39 | } |
| 57 | 40 | |
| 58 | 41 | static __always_inline void clear_preempt_need_resched(void) |
| 59 | 42 | { |
| 60 | − *preempt_count_ptr() |= PREEMPT_NEED_RESCHED; | |
| 61 | 43 | } |
| 62 | 44 | |
| 63 | 45 | static __always_inline bool test_preempt_need_resched(void) |
| 64 | 46 | { |
| 65 | − return !(*preempt_count_ptr() & PREEMPT_NEED_RESCHED); | |
| 47 | + return false; | |
| 66 | 48 | } |
| 67 | 49 | |
| 68 | 50 | /* |
| @@ -81,7 +63,12 @@ static __always_inline void __preempt_count_sub(int val) · 12 unmodified lines | ||
| 81 | 63 | |
| 82 | 64 | static __always_inline bool __preempt_count_dec_and_test(void) |
| 83 | 65 | { |
| 84 | − return !--*preempt_count_ptr(); | |
| 66 | + /* | |
| 67 | + * Because of load-store architectures cannot do per-cpu atomic | |
| 68 | + * operations; we cannot use PREEMPT_NEED_RESCHED because it might get | |
| 69 | + * lost. | |
| 70 | + */ | |
| 71 | + return !--*preempt_count_ptr() && tif_need_resched(); | |
| 85 | 72 | } |
| 86 | 73 | |
| 87 | 74 | /* |
| @@ -89,7 +76,7 @@ static __always_inline bool __preempt_count_dec_and_test(void) · 1 unmodified line | ||
| 89 | 76 | */ |
| 90 | 77 | static __always_inline bool should_resched(void) |
| 91 | 78 | { |
| 92 | − return unlikely(!*preempt_count_ptr()); | |
| 79 | + return unlikely(!preempt_count() && tif_need_resched()); | |
| 93 | 80 | } |
| 94 | 81 | |
| 95 | 82 | #ifdef CONFIG_PREEMPT |
| @@ -3,6 +3,6 @@ · 2 unmodified lines | ||
| 3 | 3 | |
| 4 | 4 | #include <uapi/linux/auxvec.h> |
| 5 | 5 | |
| 6 | −#define AT_VECTOR_SIZE_BASE 19 /* NEW_AUX_ENT entries in auxiliary table */ | |
| 6 | +#define AT_VECTOR_SIZE_BASE 20 /* NEW_AUX_ENT entries in auxiliary table */ | |
| 7 | 7 | /* number of "#define AT_.*" above, minus {AT_NULL, AT_IGNORE, AT_NOTELF} */ |
| 8 | 8 | #endif /* _LINUX_AUXVEC_H */ |
| @@ -418,6 +418,7 @@ enum { · 417 unmodified lines | ||
| 418 | 418 | ATA_HORKAGE_DUMP_ID = (1 << 16), /* dump IDENTIFY data */ |
| 419 | 419 | ATA_HORKAGE_MAX_SEC_LBA48 = (1 << 17), /* Set max sects to 65535 */ |
| 420 | 420 | ATA_HORKAGE_ATAPI_DMADIR = (1 << 18), /* device requires dmadir */ |
| 421 | + ATA_HORKAGE_NO_NCQ_TRIM = (1 << 19), /* don't use queued TRIM */ | |
| 421 | 422 | |
| 422 | 423 | /* DMA mask for user DMA control: User visible values; DO NOT |
| 423 | 424 | renumber */ |
| @@ -19,7 +19,7 @@ · 18 unmodified lines | ||
| 19 | 19 | |
| 20 | 20 | #define USE_CMPXCHG_LOCKREF \ |
| 21 | 21 | (IS_ENABLED(CONFIG_ARCH_USE_CMPXCHG_LOCKREF) && \ |
| 22 | − IS_ENABLED(CONFIG_SMP) && !BLOATED_SPINLOCKS) | |
| 22 | + IS_ENABLED(CONFIG_SMP) && SPINLOCK_SIZE <= 4) | |
| 23 | 23 | |
| 24 | 24 | struct lockref { |
| 25 | 25 | union { |
| @@ -133,4 +133,34 @@ __iter_div_u64_rem(u64 dividend, u32 divisor, u64 *remainder) · 132 unmodified lines | ||
| 133 | 133 | return ret; |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | +#if defined(CONFIG_ARCH_SUPPORTS_INT128) && defined(__SIZEOF_INT128__) | |
| 137 | + | |
| 138 | +#ifndef mul_u64_u32_shr | |
| 139 | +static inline u64 mul_u64_u32_shr(u64 a, u32 mul, unsigned int shift) | |
| 140 | +{ | |
| 141 | + return (u64)(((unsigned __int128)a * mul) >> shift); | |
| 142 | +} | |
| 143 | +#endif /* mul_u64_u32_shr */ | |
| 144 | + | |
| 145 | +#else | |
| 146 | + | |
| 147 | +#ifndef mul_u64_u32_shr | |
| 148 | +static inline u64 mul_u64_u32_shr(u64 a, u32 mul, unsigned int shift) | |
| 149 | +{ | |
| 150 | + u32 ah, al; | |
| 151 | + u64 ret; | |
| 152 | + | |
| 153 | + al = a; | |
| 154 | + ah = a >> 32; | |
| 155 | + | |
| 156 | + ret = ((u64)al * mul) >> shift; | |
| 157 | + if (ah) | |
| 158 | + ret += ((u64)ah * mul) << (32 - shift); | |
| 159 | + | |
| 160 | + return ret; | |
| 161 | +} | |
| 162 | +#endif /* mul_u64_u32_shr */ | |
| 163 | + | |
| 164 | +#endif | |
| 165 | + | |
| 136 | 166 | #endif /* _LINUX_MATH64_H */ |
| @@ -55,7 +55,8 @@ extern int migrate_huge_page_move_mapping(struct address_space *mapping, · 54 unmodified lines | ||
| 55 | 55 | struct page *newpage, struct page *page); |
| 56 | 56 | extern int migrate_page_move_mapping(struct address_space *mapping, |
| 57 | 57 | struct page *newpage, struct page *page, |
| 58 | − struct buffer_head *head, enum migrate_mode mode); | |
| 58 | + struct buffer_head *head, enum migrate_mode mode, | |
| 59 | + int extra_count); | |
| 59 | 60 | #else |
| 60 | 61 | |
| 61 | 62 | static inline void putback_lru_pages(struct list_head *l) {} |
| @@ -90,10 +91,19 @@ static inline int migrate_huge_page_move_mapping(struct address_space *mapping, · 28 unmodified lines | ||
| 90 | 91 | #endif /* CONFIG_MIGRATION */ |
| 91 | 92 | |
| 92 | 93 | #ifdef CONFIG_NUMA_BALANCING |
| 94 | +extern bool pmd_trans_migrating(pmd_t pmd); | |
| 95 | +extern void wait_migrate_huge_page(struct anon_vma *anon_vma, pmd_t *pmd); | |
| 93 | 96 | extern int migrate_misplaced_page(struct page *page, |
| 94 | 97 | struct vm_area_struct *vma, int node); |
| 95 | 98 | extern bool migrate_ratelimited(int node); |
| 96 | 99 | #else |
| 100 | +static inline bool pmd_trans_migrating(pmd_t pmd) | |
| 101 | +{ | |
| 102 | + return false; | |
| 103 | +} | |
| 104 | +static inline void wait_migrate_huge_page(struct anon_vma *anon_vma, pmd_t *pmd) | |
| 105 | +{ | |
| 106 | +} | |
| 97 | 107 | static inline int migrate_misplaced_page(struct page *page, |
| 98 | 108 | struct vm_area_struct *vma, int node) |
| 99 | 109 | { |
| @@ -1317,7 +1317,7 @@ static inline pmd_t *pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long a · 1316 unmodified lines | ||
| 1317 | 1317 | #endif /* CONFIG_MMU && !__ARCH_HAS_4LEVEL_HACK */ |
| 1318 | 1318 | |
| 1319 | 1319 | #if USE_SPLIT_PTE_PTLOCKS |
| 1320 | −#if BLOATED_SPINLOCKS | |
| 1320 | +#if ALLOC_SPLIT_PTLOCKS | |
| 1321 | 1321 | extern bool ptlock_alloc(struct page *page); |
| 1322 | 1322 | extern void ptlock_free(struct page *page); |
| 1323 | 1323 | |
| @@ -1325,7 +1325,7 @@ static inline spinlock_t *ptlock_ptr(struct page *page) · 1 unmodified line | ||
| 1325 | 1325 | { |
| 1326 | 1326 | return page->ptl; |
| 1327 | 1327 | } |
| 1328 | −#else /* BLOATED_SPINLOCKS */ | |
| 1328 | +#else /* ALLOC_SPLIT_PTLOCKS */ | |
| 1329 | 1329 | static inline bool ptlock_alloc(struct page *page) |
| 1330 | 1330 | { |
| 1331 | 1331 | return true; |
| @@ -1339,7 +1339,7 @@ static inline spinlock_t *ptlock_ptr(struct page *page) · 7 unmodified lines | ||
| 1339 | 1339 | { |
| 1340 | 1340 | return &page->ptl; |
| 1341 | 1341 | } |
| 1342 | −#endif /* BLOATED_SPINLOCKS */ | |
| 1342 | +#endif /* ALLOC_SPLIT_PTLOCKS */ | |
| 1343 | 1343 | |
| 1344 | 1344 | static inline spinlock_t *pte_lockptr(struct mm_struct *mm, pmd_t *pmd) |
| 1345 | 1345 | { |
| @@ -26,6 +26,7 @@ struct address_space; · 25 unmodified lines | ||
| 26 | 26 | #define USE_SPLIT_PTE_PTLOCKS (NR_CPUS >= CONFIG_SPLIT_PTLOCK_CPUS) |
| 27 | 27 | #define USE_SPLIT_PMD_PTLOCKS (USE_SPLIT_PTE_PTLOCKS && \ |
| 28 | 28 | IS_ENABLED(CONFIG_ARCH_ENABLE_SPLIT_PMD_PTLOCK)) |
| 29 | +#define ALLOC_SPLIT_PTLOCKS (SPINLOCK_SIZE > BITS_PER_LONG/8) | |
| 29 | 30 | |
| 30 | 31 | /* |
| 31 | 32 | * Each physical page in the system has a struct page associated with |
| @@ -155,7 +156,7 @@ struct page { · 123 unmodified lines | ||
| 155 | 156 | * system if PG_buddy is set. |
| 156 | 157 | */ |
| 157 | 158 | #if USE_SPLIT_PTE_PTLOCKS |
| 158 | −#if BLOATED_SPINLOCKS | |
| 159 | +#if ALLOC_SPLIT_PTLOCKS | |
| 159 | 160 | spinlock_t *ptl; |
| 160 | 161 | #else |
| 161 | 162 | spinlock_t ptl; |
| @@ -442,6 +443,14 @@ struct mm_struct { · 280 unmodified lines | ||
| 442 | 443 | |
| 443 | 444 | /* numa_scan_seq prevents two threads setting pte_numa */ |
| 444 | 445 | int numa_scan_seq; |
| 446 | +#endif | |
| 447 | +#if defined(CONFIG_NUMA_BALANCING) || defined(CONFIG_COMPACTION) | |
| 448 | + /* | |
| 449 | + * An operation with batched TLB flushing is going on. Anything that | |
| 450 | + * can move process memory needs to flush the TLB when moving a | |
| 451 | + * PROT_NONE or PROT_NUMA mapped page. | |
| 452 | + */ | |
| 453 | + bool tlb_flush_pending; | |
| 445 | 454 | #endif |
| 446 | 455 | struct uprobes_state uprobes_state; |
| 447 | 456 | }; |
| @@ -459,4 +468,45 @@ static inline cpumask_t *mm_cpumask(struct mm_struct *mm) · 11 unmodified lines | ||
| 459 | 468 | return mm->cpu_vm_mask_var; |
| 460 | 469 | } |
| 461 | 470 | |
| 471 | +#if defined(CONFIG_NUMA_BALANCING) || defined(CONFIG_COMPACTION) | |
| 472 | +/* | |
| 473 | + * Memory barriers to keep this state in sync are graciously provided by | |
| 474 | + * the page table locks, outside of which no page table modifications happen. | |
| 475 | + * The barriers below prevent the compiler from re-ordering the instructions | |
| 476 | + * around the memory barriers that are already present in the code. | |
| 477 | + */ | |
| 478 | +static inline bool mm_tlb_flush_pending(struct mm_struct *mm) | |
| 479 | +{ | |
| 480 | + barrier(); | |
| 481 | + return mm->tlb_flush_pending; | |
| 482 | +} | |
| 483 | +static inline void set_tlb_flush_pending(struct mm_struct *mm) | |
| 484 | +{ | |
| 485 | + mm->tlb_flush_pending = true; | |
| 486 | + | |
| 487 | + /* | |
| 488 | + * Guarantee that the tlb_flush_pending store does not leak into the | |
| 489 | + * critical section updating the page tables | |
| 490 | + */ | |
| 491 | + smp_mb__before_spinlock(); | |
| 492 | +} | |
| 493 | +/* Clearing is done after a TLB flush, which also provides a barrier. */ | |
| 494 | +static inline void clear_tlb_flush_pending(struct mm_struct *mm) | |
| 495 | +{ | |
| 496 | + barrier(); | |
| 497 | + mm->tlb_flush_pending = false; | |
| 498 | +} | |
| 499 | +#else | |
| 500 | +static inline bool mm_tlb_flush_pending(struct mm_struct *mm) | |
| 501 | +{ | |
| 502 | + return false; | |
| 503 | +} | |
| 504 | +static inline void set_tlb_flush_pending(struct mm_struct *mm) | |
| 505 | +{ | |
| 506 | +} | |
| 507 | +static inline void clear_tlb_flush_pending(struct mm_struct *mm) | |
| 508 | +{ | |
| 509 | +} | |
| 510 | +#endif | |
| 511 | + | |
| 462 | 512 | #endif /* _LINUX_MM_TYPES_H */ |
| @@ -69,6 +69,7 @@ · 68 unmodified lines | ||
| 69 | 69 | __PCPU_DUMMY_ATTRS char __pcpu_scope_##name; \ |
| 70 | 70 | extern __PCPU_DUMMY_ATTRS char __pcpu_unique_##name; \ |
| 71 | 71 | __PCPU_DUMMY_ATTRS char __pcpu_unique_##name; \ |
| 72 | + extern __PCPU_ATTRS(sec) __typeof__(type) name; \ | |
| 72 | 73 | __PCPU_ATTRS(sec) PER_CPU_DEF_ATTRIBUTES __weak \ |
| 73 | 74 | __typeof__(type) name |
| 74 | 75 | #else |
| @@ -51,6 +51,7 @@ struct pstore_info { · 50 unmodified lines | ||
| 51 | 51 | char *buf; |
| 52 | 52 | size_t bufsize; |
| 53 | 53 | struct mutex read_mutex; /* serialize open/read/close */ |
| 54 | + int flags; | |
| 54 | 55 | int (*open)(struct pstore_info *psi); |
| 55 | 56 | int (*close)(struct pstore_info *psi); |
| 56 | 57 | ssize_t (*read)(u64 *id, enum pstore_type_id *type, |
| @@ -70,6 +71,8 @@ struct pstore_info { · 13 unmodified lines | ||
| 70 | 71 | void *data; |
| 71 | 72 | }; |
| 72 | 73 | |
| 74 | +#define PSTORE_FLAGS_FRAGILE 1 | |
| 75 | + | |
| 73 | 76 | #ifdef CONFIG_PSTORE |
| 74 | 77 | extern int pstore_register(struct pstore_info *); |
| 75 | 78 | extern bool pstore_cannot_block_path(enum kmsg_dump_reason reason); |
| @@ -43,6 +43,7 @@ extern int unregister_reboot_notifier(struct notifier_block *); · 42 unmodified lines | ||
| 43 | 43 | * Architecture-specific implementations of sys_reboot commands. |
| 44 | 44 | */ |
| 45 | 45 | |
| 46 | +extern void migrate_to_reboot_cpu(void); | |
| 46 | 47 | extern void machine_restart(char *cmd); |
| 47 | 48 | extern void machine_halt(void); |
| 48 | 49 | extern void machine_power_off(void); |
| @@ -440,8 +440,6 @@ struct task_cputime { · 439 unmodified lines | ||
| 440 | 440 | .sum_exec_runtime = 0, \ |
| 441 | 441 | } |
| 442 | 442 | |
| 443 | −#define PREEMPT_ENABLED (PREEMPT_NEED_RESCHED) | |
| 444 | − | |
| 445 | 443 | #ifdef CONFIG_PREEMPT_COUNT |
| 446 | 444 | #define PREEMPT_DISABLED (1 + PREEMPT_ENABLED) |
| 447 | 445 | #else |
| @@ -932,7 +930,8 @@ struct pipe_inode_info; · 484 unmodified lines | ||
| 932 | 930 | struct uts_namespace; |
| 933 | 931 | |
| 934 | 932 | struct load_weight { |
| 935 | − unsigned long weight, inv_weight; | |
| 933 | + unsigned long weight; | |
| 934 | + u32 inv_weight; | |
| 936 | 935 | }; |
| 937 | 936 | |
| 938 | 937 | struct sched_avg { |
| @@ -978,7 +978,7 @@ struct ib_uobject { · 977 unmodified lines | ||
| 978 | 978 | }; |
| 979 | 979 | |
| 980 | 980 | struct ib_udata { |
| 981 | − void __user *inbuf; | |
| 981 | + const void __user *inbuf; | |
| 982 | 982 | void __user *outbuf; |
| 983 | 983 | size_t inlen; |
| 984 | 984 | size_t outlen; |
| @@ -517,10 +517,6 @@ struct se_node_acl { · 516 unmodified lines | ||
| 517 | 517 | u32 acl_index; |
| 518 | 518 | #define MAX_ACL_TAG_SIZE 64 |
| 519 | 519 | char acl_tag[MAX_ACL_TAG_SIZE]; |
| 520 | − u64 num_cmds; | |
| 521 | − u64 read_bytes; | |
| 522 | − u64 write_bytes; | |
| 523 | − spinlock_t stats_lock; | |
| 524 | 520 | /* Used for PR SPEC_I_PT=1 and REGISTER_AND_MOVE */ |
| 525 | 521 | atomic_t acl_pr_ref_count; |
| 526 | 522 | struct se_dev_entry **device_list; |
| @@ -624,6 +620,7 @@ struct se_dev_attrib { · 97 unmodified lines | ||
| 624 | 620 | u32 unmap_granularity; |
| 625 | 621 | u32 unmap_granularity_alignment; |
| 626 | 622 | u32 max_write_same_len; |
| 623 | + u32 max_bytes_per_io; | |
| 627 | 624 | struct se_device *da_dev; |
| 628 | 625 | struct config_group da_group; |
| 629 | 626 | }; |
| @@ -75,6 +75,7 @@ · 74 unmodified lines | ||
| 75 | 75 | #define DRM_VMW_PARAM_FIFO_CAPS 4 |
| 76 | 76 | #define DRM_VMW_PARAM_MAX_FB_SIZE 5 |
| 77 | 77 | #define DRM_VMW_PARAM_FIFO_HW_VERSION 6 |
| 78 | +#define DRM_VMW_PARAM_MAX_SURF_MEMORY 7 | |
| 78 | 79 | |
| 79 | 80 | /** |
| 80 | 81 | * struct drm_vmw_getparam_arg |
| @@ -679,6 +679,7 @@ enum perf_event_type { · 678 unmodified lines | ||
| 679 | 679 | * |
| 680 | 680 | * { u64 weight; } && PERF_SAMPLE_WEIGHT |
| 681 | 681 | * { u64 data_src; } && PERF_SAMPLE_DATA_SRC |
| 682 | + * { u64 transaction; } && PERF_SAMPLE_TRANSACTION | |
| 682 | 683 | * }; |
| 683 | 684 | */ |
| 684 | 685 | PERF_RECORD_SAMPLE = 9, |
| @@ -146,7 +146,7 @@ struct blkif_request_segment_aligned { · 145 unmodified lines | ||
| 146 | 146 | struct blkif_request_rw { |
| 147 | 147 | uint8_t nr_segments; /* number of segments */ |
| 148 | 148 | blkif_vdev_t handle; /* only for read/write requests */ |
| 149 | −#ifdef CONFIG_X86_64 | |
| 149 | +#ifndef CONFIG_X86_32 | |
| 150 | 150 | uint32_t _pad1; /* offsetof(blkif_request,u.rw.id) == 8 */ |
| 151 | 151 | #endif |
| 152 | 152 | uint64_t id; /* private guest value, echoed in resp */ |
| @@ -163,7 +163,7 @@ struct blkif_request_discard { · 10 unmodified lines | ||
| 163 | 163 | uint8_t flag; /* BLKIF_DISCARD_SECURE or zero. */ |
| 164 | 164 | #define BLKIF_DISCARD_SECURE (1<<0) /* ignored if discard-secure=0 */ |
| 165 | 165 | blkif_vdev_t _pad1; /* only for read/write requests */ |
| 166 | −#ifdef CONFIG_X86_64 | |
| 166 | +#ifndef CONFIG_X86_32 | |
| 167 | 167 | uint32_t _pad2; /* offsetof(blkif_req..,u.discard.id)==8*/ |
| 168 | 168 | #endif |
| 169 | 169 | uint64_t id; /* private guest value, echoed in resp */ |
| @@ -175,7 +175,7 @@ struct blkif_request_discard { · 5 unmodified lines | ||
| 175 | 175 | struct blkif_request_other { |
| 176 | 176 | uint8_t _pad1; |
| 177 | 177 | blkif_vdev_t _pad2; /* only for read/write requests */ |
| 178 | −#ifdef CONFIG_X86_64 | |
| 178 | +#ifndef CONFIG_X86_32 | |
| 179 | 179 | uint32_t _pad3; /* offsetof(blkif_req..,u.other.id)==8*/ |
| 180 | 180 | #endif |
| 181 | 181 | uint64_t id; /* private guest value, echoed in resp */ |
| @@ -184,7 +184,7 @@ struct blkif_request_other { · 2 unmodified lines | ||
| 184 | 184 | struct blkif_request_indirect { |
| 185 | 185 | uint8_t indirect_op; |
| 186 | 186 | uint16_t nr_segments; |
| 187 | −#ifdef CONFIG_X86_64 | |
| 187 | +#ifndef CONFIG_X86_32 | |
| 188 | 188 | uint32_t _pad1; /* offsetof(blkif_...,u.indirect.id) == 8 */ |
| 189 | 189 | #endif |
| 190 | 190 | uint64_t id; |
| @@ -192,7 +192,7 @@ struct blkif_request_indirect { · 1 unmodified line | ||
| 192 | 192 | blkif_vdev_t handle; |
| 193 | 193 | uint16_t _pad2; |
| 194 | 194 | grant_ref_t indirect_grefs[BLKIF_MAX_INDIRECT_PAGES_PER_REQUEST]; |
| 195 | −#ifdef CONFIG_X86_64 | |
| 195 | +#ifndef CONFIG_X86_32 | |
| 196 | 196 | uint32_t _pad3; /* make it 64 byte aligned */ |
| 197 | 197 | #else |
| 198 | 198 | uint64_t _pad3; /* make it 64 byte aligned */ |
| @@ -809,6 +809,12 @@ config GENERIC_SCHED_CLOCK · 808 unmodified lines | ||
| 809 | 809 | config ARCH_SUPPORTS_NUMA_BALANCING |
| 810 | 810 | bool |
| 811 | 811 | |
| 812 | +# | |
| 813 | +# For architectures that know their GCC __int128 support is sound | |
| 814 | +# | |
| 815 | +config ARCH_SUPPORTS_INT128 | |
| 816 | + bool | |
| 817 | + | |
| 812 | 818 | # For architectures that (ab)use NUMA to represent different memory regions |
| 813 | 819 | # all cpu-local but of different latencies, such as SuperH. |
| 814 | 820 | # |
| @@ -137,9 +137,10 @@ $(obj)/timeconst.h: $(obj)/hz.bc $(src)/timeconst.bc FORCE · 136 unmodified lines | ||
| 137 | 137 | ############################################################################### |
| 138 | 138 | ifeq ($(CONFIG_SYSTEM_TRUSTED_KEYRING),y) |
| 139 | 139 | X509_CERTIFICATES-y := $(wildcard *.x509) $(wildcard $(srctree)/*.x509) |
| 140 | −X509_CERTIFICATES-$(CONFIG_MODULE_SIG) += signing_key.x509 | |
| 141 | −X509_CERTIFICATES := $(sort $(foreach CERT,$(X509_CERTIFICATES-y), \ | |
| 140 | +X509_CERTIFICATES-$(CONFIG_MODULE_SIG) += $(objtree)/signing_key.x509 | |
| 141 | +X509_CERTIFICATES-raw := $(sort $(foreach CERT,$(X509_CERTIFICATES-y), \ | |
| 142 | 142 | $(or $(realpath $(CERT)),$(CERT)))) |
| 143 | +X509_CERTIFICATES := $(subst $(realpath $(objtree))/,,$(X509_CERTIFICATES-raw)) | |
| 143 | 144 | |
| 144 | 145 | ifeq ($(X509_CERTIFICATES),) |
| 145 | 146 | $(warning *** No X.509 certificates found ***) |
| @@ -164,9 +165,9 @@ $(obj)/x509_certificate_list: $(X509_CERTIFICATES) $(obj)/.x509.list · 18 unmodified lines | ||
| 164 | 165 | targets += $(obj)/.x509.list |
| 165 | 166 | $(obj)/.x509.list: |
| 166 | 167 | @echo $(X509_CERTIFICATES) >$@ |
| 168 | +endif | |
| 167 | 169 | |
| 168 | 170 | clean-files := x509_certificate_list .x509.list |
| 169 | −endif | |
| 170 | 171 | |
| 171 | 172 | ifeq ($(CONFIG_MODULE_SIG),y) |
| 172 | 173 | ############################################################################### |
| @@ -22,6 +22,6 @@ void foo(void) · 21 unmodified lines | ||
| 22 | 22 | #ifdef CONFIG_SMP |
| 23 | 23 | DEFINE(NR_CPUS_BITS, ilog2(CONFIG_NR_CPUS)); |
| 24 | 24 | #endif |
| 25 | − DEFINE(BLOATED_SPINLOCKS, sizeof(spinlock_t) > sizeof(int)); | |
| 25 | + DEFINE(SPINLOCK_SIZE, sizeof(spinlock_t)); | |
| 26 | 26 | /* End of constants */ |
| 27 | 27 | } |
| @@ -890,6 +890,16 @@ static void cgroup_diput(struct dentry *dentry, struct inode *inode) · 889 unmodified lines | ||
| 890 | 890 | struct cgroup *cgrp = dentry->d_fsdata; |
| 891 | 891 | |
| 892 | 892 | BUG_ON(!(cgroup_is_dead(cgrp))); |
| 893 | + | |
| 894 | + /* | |
| 895 | + * XXX: cgrp->id is only used to look up css's. As cgroup | |
| 896 | + * and css's lifetimes will be decoupled, it should be made | |
| 897 | + * per-subsystem and moved to css->id so that lookups are | |
| 898 | + * successful until the target css is released. | |
| 899 | + */ | |
| 900 | + idr_remove(&cgrp->root->cgroup_idr, cgrp->id); | |
| 901 | + cgrp->id = -1; | |
| 902 | + | |
| 893 | 903 | call_rcu(&cgrp->rcu_head, cgroup_free_rcu); |
| 894 | 904 | } else { |
| 895 | 905 | struct cfent *cfe = __d_cfe(dentry); |
| @@ -4268,6 +4278,7 @@ static void css_release(struct percpu_ref *ref) · 3372 unmodified lines | ||
| 4268 | 4278 | struct cgroup_subsys_state *css = |
| 4269 | 4279 | container_of(ref, struct cgroup_subsys_state, refcnt); |
| 4270 | 4280 | |
| 4281 | + rcu_assign_pointer(css->cgroup->subsys[css->ss->subsys_id], NULL); | |
| 4271 | 4282 | call_rcu(&css->rcu_head, css_free_rcu_fn); |
| 4272 | 4283 | } |
| 4273 | 4284 | |
| @@ -4426,14 +4437,6 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry, · 152 unmodified lines | ||
| 4426 | 4437 | list_add_tail_rcu(&cgrp->sibling, &cgrp->parent->children); |
| 4427 | 4438 | root->number_of_cgroups++; |
| 4428 | 4439 | |
| 4429 | − /* each css holds a ref to the cgroup's dentry and the parent css */ | |
| 4430 | − for_each_root_subsys(root, ss) { | |
| 4431 | − struct cgroup_subsys_state *css = css_ar[ss->subsys_id]; | |
| 4432 | − | |
| 4433 | − dget(dentry); | |
| 4434 | − css_get(css->parent); | |
| 4435 | − } | |
| 4436 | − | |
| 4437 | 4440 | /* hold a ref to the parent's dentry */ |
| 4438 | 4441 | dget(parent->dentry); |
| 4439 | 4442 | |
| @@ -4445,6 +4448,13 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry, · 5 unmodified lines | ||
| 4445 | 4448 | if (err) |
| 4446 | 4449 | goto err_destroy; |
| 4447 | 4450 | |
| 4451 | + /* each css holds a ref to the cgroup's dentry and parent css */ | |
| 4452 | + dget(dentry); | |
| 4453 | + css_get(css->parent); | |
| 4454 | + | |
| 4455 | + /* mark it consumed for error path */ | |
| 4456 | + css_ar[ss->subsys_id] = NULL; | |
| 4457 | + | |
| 4448 | 4458 | if (ss->broken_hierarchy && !ss->warned_broken_hierarchy && |
| 4449 | 4459 | parent->parent) { |
| 4450 | 4460 | pr_warning("cgroup: %s (%d) created nested cgroup for controller \"%s\" which has incomplete hierarchy support. Nested cgroups may change behavior in the future.\n", |
| @@ -4491,6 +4501,14 @@ err_free_cgrp: · 40 unmodified lines | ||
| 4491 | 4501 | return err; |
| 4492 | 4502 | |
| 4493 | 4503 | err_destroy: |
| 4504 | + for_each_root_subsys(root, ss) { | |
| 4505 | + struct cgroup_subsys_state *css = css_ar[ss->subsys_id]; | |
| 4506 | + | |
| 4507 | + if (css) { | |
| 4508 | + percpu_ref_cancel_init(&css->refcnt); | |
| 4509 | + ss->css_free(css); | |
| 4510 | + } | |
| 4511 | + } | |
| 4494 | 4512 | cgroup_destroy_locked(cgrp); |
| 4495 | 4513 | mutex_unlock(&cgroup_mutex); |
| 4496 | 4514 | mutex_unlock(&dentry->d_inode->i_mutex); |
| @@ -4652,8 +4670,12 @@ static int cgroup_destroy_locked(struct cgroup *cgrp) · 155 unmodified lines | ||
| 4652 | 4670 | * will be invoked to perform the rest of destruction once the |
| 4653 | 4671 | * percpu refs of all css's are confirmed to be killed. |
| 4654 | 4672 | */ |
| 4655 | − for_each_root_subsys(cgrp->root, ss) | |
| 4656 | − kill_css(cgroup_css(cgrp, ss)); | |
| 4673 | + for_each_root_subsys(cgrp->root, ss) { | |
| 4674 | + struct cgroup_subsys_state *css = cgroup_css(cgrp, ss); | |
| 4675 | + | |
| 4676 | + if (css) | |
| 4677 | + kill_css(css); | |
| 4678 | + } | |
| 4657 | 4679 | |
| 4658 | 4680 | /* |
| 4659 | 4681 | * Mark @cgrp dead. This prevents further task migration and child |
| @@ -4722,14 +4744,6 @@ static void cgroup_destroy_css_killed(struct cgroup *cgrp) · 62 unmodified lines | ||
| 4722 | 4744 | /* delete this cgroup from parent->children */ |
| 4723 | 4745 | list_del_rcu(&cgrp->sibling); |
| 4724 | 4746 | |
| 4725 | − /* | |
| 4726 | − * We should remove the cgroup object from idr before its grace | |
| 4727 | − * period starts, so we won't be looking up a cgroup while the | |
| 4728 | − * cgroup is being freed. | |
| 4729 | − */ | |
| 4730 | − idr_remove(&cgrp->root->cgroup_idr, cgrp->id); | |
| 4731 | − cgrp->id = -1; | |
| 4732 | − | |
| 4733 | 4747 | dput(d); |
| 4734 | 4748 | |
| 4735 | 4749 | set_bit(CGRP_RELEASABLE, &parent->flags); |
| @@ -1396,6 +1396,8 @@ event_sched_out(struct perf_event *event, · 1395 unmodified lines | ||
| 1396 | 1396 | if (event->state != PERF_EVENT_STATE_ACTIVE) |
| 1397 | 1397 | return; |
| 1398 | 1398 | |
| 1399 | + perf_pmu_disable(event->pmu); | |
| 1400 | + | |
| 1399 | 1401 | event->state = PERF_EVENT_STATE_INACTIVE; |
| 1400 | 1402 | if (event->pending_disable) { |
| 1401 | 1403 | event->pending_disable = 0; |
| @@ -1412,6 +1414,8 @@ event_sched_out(struct perf_event *event, · 10 unmodified lines | ||
| 1412 | 1414 | ctx->nr_freq--; |
| 1413 | 1415 | if (event->attr.exclusive || !cpuctx->active_oncpu) |
| 1414 | 1416 | cpuctx->exclusive = 0; |
| 1417 | + | |
| 1418 | + perf_pmu_enable(event->pmu); | |
| 1415 | 1419 | } |
| 1416 | 1420 | |
| 1417 | 1421 | static void |
| @@ -1652,6 +1656,7 @@ event_sched_in(struct perf_event *event, · 234 unmodified lines | ||
| 1652 | 1656 | struct perf_event_context *ctx) |
| 1653 | 1657 | { |
| 1654 | 1658 | u64 tstamp = perf_event_time(event); |
| 1659 | + int ret = 0; | |
| 1655 | 1660 | |
| 1656 | 1661 | if (event->state <= PERF_EVENT_STATE_OFF) |
| 1657 | 1662 | return 0; |
| @@ -1674,10 +1679,13 @@ event_sched_in(struct perf_event *event, · 16 unmodified lines | ||
| 1674 | 1679 | */ |
| 1675 | 1680 | smp_wmb(); |
| 1676 | 1681 | |
| 1682 | + perf_pmu_disable(event->pmu); | |
| 1683 | + | |
| 1677 | 1684 | if (event->pmu->add(event, PERF_EF_START)) { |
| 1678 | 1685 | event->state = PERF_EVENT_STATE_INACTIVE; |
| 1679 | 1686 | event->oncpu = -1; |
| 1680 | − return -EAGAIN; | |
| 1687 | + ret = -EAGAIN; | |
| 1688 | + goto out; | |
| 1681 | 1689 | } |
| 1682 | 1690 | |
| 1683 | 1691 | event->tstamp_running += tstamp - event->tstamp_stopped; |
| @@ -1693,7 +1701,10 @@ event_sched_in(struct perf_event *event, · 9 unmodified lines | ||
| 1693 | 1701 | if (event->attr.exclusive) |
| 1694 | 1702 | cpuctx->exclusive = 1; |
| 1695 | 1703 | |
| 1696 | − return 0; | |
| 1704 | +out: | |
| 1705 | + perf_pmu_enable(event->pmu); | |
| 1706 | + | |
| 1707 | + return ret; | |
| 1697 | 1708 | } |
| 1698 | 1709 | |
| 1699 | 1710 | static int |
| @@ -2743,6 +2754,8 @@ static void perf_adjust_freq_unthr_context(struct perf_event_context *ctx, · 1043 unmodified lines | ||
| 2743 | 2754 | if (!event_filter_match(event)) |
| 2744 | 2755 | continue; |
| 2745 | 2756 | |
| 2757 | + perf_pmu_disable(event->pmu); | |
| 2758 | + | |
| 2746 | 2759 | hwc = &event->hw; |
| 2747 | 2760 | |
| 2748 | 2761 | if (hwc->interrupts == MAX_INTERRUPTS) { |
| @@ -2752,7 +2765,7 @@ static void perf_adjust_freq_unthr_context(struct perf_event_context *ctx, · 3 unmodified lines | ||
| 2752 | 2765 | } |
| 2753 | 2766 | |
| 2754 | 2767 | if (!event->attr.freq || !event->attr.sample_freq) |
| 2755 | − continue; | |
| 2768 | + goto next; | |
| 2756 | 2769 | |
| 2757 | 2770 | /* |
| 2758 | 2771 | * stop the event and update event->count |
| @@ -2774,6 +2787,8 @@ static void perf_adjust_freq_unthr_context(struct perf_event_context *ctx, · 15 unmodified lines | ||
| 2774 | 2787 | perf_adjust_period(event, period, delta, false); |
| 2775 | 2788 | |
| 2776 | 2789 | event->pmu->start(event, delta > 0 ? PERF_EF_RELOAD : 0); |
| 2790 | + next: | |
| 2791 | + perf_pmu_enable(event->pmu); | |
| 2777 | 2792 | } |
| 2778 | 2793 | |
| 2779 | 2794 | perf_pmu_enable(ctx->pmu); |
| @@ -537,6 +537,7 @@ static struct mm_struct *mm_init(struct mm_struct *mm, struct task_struct *p) · 536 unmodified lines | ||
| 537 | 537 | spin_lock_init(&mm->page_table_lock); |
| 538 | 538 | mm_init_aio(mm); |
| 539 | 539 | mm_init_owner(mm, p); |
| 540 | + clear_tlb_flush_pending(mm); | |
| 540 | 541 | |
| 541 | 542 | if (likely(!mm_alloc_pgd(mm))) { |
| 542 | 543 | mm->def_flags = 0; |
| @@ -19,6 +19,12 @@ EXPORT_SYMBOL(system_freezing_cnt); · 18 unmodified lines | ||
| 19 | 19 | bool pm_freezing; |
| 20 | 20 | bool pm_nosig_freezing; |
| 21 | 21 | |
| 22 | +/* | |
| 23 | + * Temporary export for the deadlock workaround in ata_scsi_hotplug(). | |
| 24 | + * Remove once the hack becomes unnecessary. | |
| 25 | + */ | |
| 26 | +EXPORT_SYMBOL_GPL(pm_freezing); | |
| 27 | + | |
| 22 | 28 | /* protects freezing and frozen transitions */ |
| 23 | 29 | static DEFINE_SPINLOCK(freezer_lock); |
| 24 | 30 | |
| @@ -1680,6 +1680,7 @@ int kernel_kexec(void) · 1679 unmodified lines | ||
| 1680 | 1680 | { |
| 1681 | 1681 | kexec_in_progress = true; |
| 1682 | 1682 | kernel_restart_prepare(NULL); |
| 1683 | + migrate_to_reboot_cpu(); | |
| 1683 | 1684 | printk(KERN_EMERG "Starting new kernel\n"); |
| 1684 | 1685 | machine_shutdown(); |
| 1685 | 1686 | } |
| @@ -81,6 +81,7 @@ void pm_vt_switch_unregister(struct device *dev) · 80 unmodified lines | ||
| 81 | 81 | list_for_each_entry(tmp, &pm_vt_switch_list, head) { |
| 82 | 82 | if (tmp->dev == dev) { |
| 83 | 83 | list_del(&tmp->head); |
| 84 | + kfree(tmp); | |
| 84 | 85 | break; |
| 85 | 86 | } |
| 86 | 87 | } |
| @@ -104,7 +104,7 @@ int unregister_reboot_notifier(struct notifier_block *nb) · 103 unmodified lines | ||
| 104 | 104 | } |
| 105 | 105 | EXPORT_SYMBOL(unregister_reboot_notifier); |
| 106 | 106 | |
| 107 | −static void migrate_to_reboot_cpu(void) | |
| 107 | +void migrate_to_reboot_cpu(void) | |
| 108 | 108 | { |
| 109 | 109 | /* The boot cpu is always logical cpu 0 */ |
| 110 | 110 | int cpu = reboot_cpu; |
| @@ -4902,6 +4902,7 @@ DEFINE_PER_CPU(struct sched_domain *, sd_asym); · 4901 unmodified lines | ||
| 4902 | 4902 | static void update_top_cache_domain(int cpu) |
| 4903 | 4903 | { |
| 4904 | 4904 | struct sched_domain *sd; |
| 4905 | + struct sched_domain *busy_sd = NULL; | |
| 4905 | 4906 | int id = cpu; |
| 4906 | 4907 | int size = 1; |
| 4907 | 4908 | |
| @@ -4909,9 +4910,9 @@ static void update_top_cache_domain(int cpu) · 1 unmodified line | ||
| 4909 | 4910 | if (sd) { |
| 4910 | 4911 | id = cpumask_first(sched_domain_span(sd)); |
| 4911 | 4912 | size = cpumask_weight(sched_domain_span(sd)); |
| 4912 | − sd = sd->parent; /* sd_busy */ | |
| 4913 | + busy_sd = sd->parent; /* sd_busy */ | |
| 4913 | 4914 | } |
| 4914 | − rcu_assign_pointer(per_cpu(sd_busy, cpu), sd); | |
| 4915 | + rcu_assign_pointer(per_cpu(sd_busy, cpu), busy_sd); | |
| 4915 | 4916 | |
| 4916 | 4917 | rcu_assign_pointer(per_cpu(sd_llc, cpu), sd); |
| 4917 | 4918 | per_cpu(sd_llc_size, cpu) = size; |
| @@ -5112,6 +5113,7 @@ build_overlap_sched_groups(struct sched_domain *sd, int cpu) · 194 unmodified lines | ||
| 5112 | 5113 | * die on a /0 trap. |
| 5113 | 5114 | */ |
| 5114 | 5115 | sg->sgp->power = SCHED_POWER_SCALE * cpumask_weight(sg_span); |
| 5116 | + sg->sgp->power_orig = sg->sgp->power; | |
| 5115 | 5117 | |
| 5116 | 5118 | /* |
| 5117 | 5119 | * Make sure the first group of this domain contains the |
| @@ -178,59 +178,61 @@ void sched_init_granularity(void) · 177 unmodified lines | ||
| 178 | 178 | update_sysctl(); |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | −#if BITS_PER_LONG == 32 | |
| 182 | −# define WMULT_CONST (~0UL) | |
| 183 | −#else | |
| 184 | −# define WMULT_CONST (1UL << 32) | |
| 185 | −#endif | |
| 186 | − | |
| 181 | +#define WMULT_CONST (~0U) | |
| 187 | 182 | #define WMULT_SHIFT 32 |
| 188 | 183 | |
| 189 | −/* | |
| 190 | − * Shift right and round: | |
| 191 | − */ | |
| 192 | −#define SRR(x, y) (((x) + (1UL << ((y) - 1))) >> (y)) | |
| 184 | +static void __update_inv_weight(struct load_weight *lw) | |
| 185 | +{ | |
| 186 | + unsigned long w; | |
| 187 | + | |
| 188 | + if (likely(lw->inv_weight)) | |
| 189 | + return; | |
| 190 | + | |
| 191 | + w = scale_load_down(lw->weight); | |
| 192 | + | |
| 193 | + if (BITS_PER_LONG > 32 && unlikely(w >= WMULT_CONST)) | |
| 194 | + lw->inv_weight = 1; | |
| 195 | + else if (unlikely(!w)) | |
| 196 | + lw->inv_weight = WMULT_CONST; | |
| 197 | + else | |
| 198 | + lw->inv_weight = WMULT_CONST / w; | |
| 199 | +} | |
| 193 | 200 | |
| 194 | 201 | /* |
| 195 | − * delta *= weight / lw | |
| 202 | + * delta_exec * weight / lw.weight | |
| 203 | + * OR | |
| 204 | + * (delta_exec * (weight * lw->inv_weight)) >> WMULT_SHIFT | |
| 205 | + * | |
| 206 | + * Either weight := NICE_0_LOAD and lw \e prio_to_wmult[], in which case | |
| 207 | + * we're guaranteed shift stays positive because inv_weight is guaranteed to | |
| 208 | + * fit 32 bits, and NICE_0_LOAD gives another 10 bits; therefore shift >= 22. | |
| 209 | + * | |
| 210 | + * Or, weight =< lw.weight (because lw.weight is the runqueue weight), thus | |
| 211 | + * weight/lw.weight <= 1, and therefore our shift will also be positive. | |
| 196 | 212 | */ |
| 197 | −static unsigned long | |
| 198 | −calc_delta_mine(unsigned long delta_exec, unsigned long weight, | |
| 199 | − struct load_weight *lw) | |
| 213 | +static u64 __calc_delta(u64 delta_exec, unsigned long weight, struct load_weight *lw) | |
| 200 | 214 | { |
| 201 | − u64 tmp; | |
| 202 | − | |
| 203 | − /* | |
| 204 | − * weight can be less than 2^SCHED_LOAD_RESOLUTION for task group sched | |
| 205 | − * entities since MIN_SHARES = 2. Treat weight as 1 if less than | |
| 206 | − * 2^SCHED_LOAD_RESOLUTION. | |
| 207 | − */ | |
| 208 | − if (likely(weight > (1UL << SCHED_LOAD_RESOLUTION))) | |
| 209 | − tmp = (u64)delta_exec * scale_load_down(weight); | |
| 210 | − else | |
| 211 | − tmp = (u64)delta_exec; | |
| 215 | + u64 fact = scale_load_down(weight); | |
| 216 | + int shift = WMULT_SHIFT; | |
| 212 | 217 | |
| 213 | − if (!lw->inv_weight) { | |
| 214 | − unsigned long w = scale_load_down(lw->weight); | |
| 218 | + __update_inv_weight(lw); | |
| 215 | 219 | |
| 216 | − if (BITS_PER_LONG > 32 && unlikely(w >= WMULT_CONST)) | |
| 217 | − lw->inv_weight = 1; | |
| 218 | − else if (unlikely(!w)) | |
| 219 | − lw->inv_weight = WMULT_CONST; | |
| 220 | − else | |
| 221 | − lw->inv_weight = WMULT_CONST / w; | |
| 220 | + if (unlikely(fact >> 32)) { | |
| 221 | + while (fact >> 32) { | |
| 222 | + fact >>= 1; | |
| 223 | + shift--; | |
| 224 | + } | |
| 222 | 225 | } |
| 223 | 226 | |
| 224 | − /* | |
| 225 | − * Check whether we'd overflow the 64-bit multiplication: | |
| 226 | − */ | |
| 227 | − if (unlikely(tmp > WMULT_CONST)) | |
| 228 | − tmp = SRR(SRR(tmp, WMULT_SHIFT/2) * lw->inv_weight, | |
| 229 | − WMULT_SHIFT/2); | |
| 230 | − else | |
| 231 | − tmp = SRR(tmp * lw->inv_weight, WMULT_SHIFT); | |
| 227 | + /* hint to use a 32x32->64 mul */ | |
| 228 | + fact = (u64)(u32)fact * lw->inv_weight; | |
| 229 | + | |
| 230 | + while (fact >> 32) { | |
| 231 | + fact >>= 1; | |
| 232 | + shift--; | |
| 233 | + } | |
| 232 | 234 | |
| 233 | − return (unsigned long)min(tmp, (u64)(unsigned long)LONG_MAX); | |
| 235 | + return mul_u64_u32_shr(delta_exec, fact, shift); | |
| 234 | 236 | } |
| 235 | 237 | |
| 236 | 238 | |
| @@ -443,7 +445,7 @@ find_matching_se(struct sched_entity **se, struct sched_entity **pse) · 206 unmodified lines | ||
| 443 | 445 | #endif /* CONFIG_FAIR_GROUP_SCHED */ |
| 444 | 446 | |
| 445 | 447 | static __always_inline |
| 446 | −void account_cfs_rq_runtime(struct cfs_rq *cfs_rq, unsigned long delta_exec); | |
| 448 | +void account_cfs_rq_runtime(struct cfs_rq *cfs_rq, u64 delta_exec); | |
| 447 | 449 | |
| 448 | 450 | /************************************************************** |
| 449 | 451 | * Scheduling class tree data structure manipulation methods: |
| @@ -612,11 +614,10 @@ int sched_proc_update_handler(struct ctl_table *table, int write, · 162 unmodified lines | ||
| 612 | 614 | /* |
| 613 | 615 | * delta /= w |
| 614 | 616 | */ |
| 615 | −static inline unsigned long | |
| 616 | −calc_delta_fair(unsigned long delta, struct sched_entity *se) | |
| 617 | +static inline u64 calc_delta_fair(u64 delta, struct sched_entity *se) | |
| 617 | 618 | { |
| 618 | 619 | if (unlikely(se->load.weight != NICE_0_LOAD)) |
| 619 | − delta = calc_delta_mine(delta, NICE_0_LOAD, &se->load); | |
| 620 | + delta = __calc_delta(delta, NICE_0_LOAD, &se->load); | |
| 620 | 621 | |
| 621 | 622 | return delta; |
| 622 | 623 | } |
| @@ -665,7 +666,7 @@ static u64 sched_slice(struct cfs_rq *cfs_rq, struct sched_entity *se) · 42 unmodified lines | ||
| 665 | 666 | update_load_add(&lw, se->load.weight); |
| 666 | 667 | load = &lw; |
| 667 | 668 | } |
| 668 | − slice = calc_delta_mine(slice, se->load.weight, load); | |
| 669 | + slice = __calc_delta(slice, se->load.weight, load); | |
| 669 | 670 | } |
| 670 | 671 | return slice; |
| 671 | 672 | } |
| @@ -703,47 +704,32 @@ void init_task_runnable_average(struct task_struct *p) · 31 unmodified lines | ||
| 703 | 704 | #endif |
| 704 | 705 | |
| 705 | 706 | /* |
| 706 | − * Update the current task's runtime statistics. Skip current tasks that | |
| 707 | − * are not in our scheduling class. | |
| 707 | + * Update the current task's runtime statistics. | |
| 708 | 708 | */ |
| 709 | −static inline void | |
| 710 | −__update_curr(struct cfs_rq *cfs_rq, struct sched_entity *curr, | |
| 711 | − unsigned long delta_exec) | |
| 712 | −{ | |
| 713 | − unsigned long delta_exec_weighted; | |
| 714 | − | |
| 715 | − schedstat_set(curr->statistics.exec_max, | |
| 716 | − max((u64)delta_exec, curr->statistics.exec_max)); | |
| 717 | − | |
| 718 | − curr->sum_exec_runtime += delta_exec; | |
| 719 | − schedstat_add(cfs_rq, exec_clock, delta_exec); | |
| 720 | − delta_exec_weighted = calc_delta_fair(delta_exec, curr); | |
| 721 | − | |
| 722 | − curr->vruntime += delta_exec_weighted; | |
| 723 | − update_min_vruntime(cfs_rq); | |
| 724 | −} | |
| 725 | − | |
| 726 | 709 | static void update_curr(struct cfs_rq *cfs_rq) |
| 727 | 710 | { |
| 728 | 711 | struct sched_entity *curr = cfs_rq->curr; |
| 729 | 712 | u64 now = rq_clock_task(rq_of(cfs_rq)); |
| 730 | − unsigned long delta_exec; | |
| 713 | + u64 delta_exec; | |
| 731 | 714 | |
| 732 | 715 | if (unlikely(!curr)) |
| 733 | 716 | return; |
| 734 | 717 | |
| 735 | − /* | |
| 736 | − * Get the amount of time the current task was running | |
| 737 | − * since the last time we changed load (this cannot | |
| 738 | − * overflow on 32 bits): | |
| 739 | − */ | |
| 740 | − delta_exec = (unsigned long)(now - curr->exec_start); | |
| 741 | − if (!delta_exec) | |
| 718 | + delta_exec = now - curr->exec_start; | |
| 719 | + if (unlikely((s64)delta_exec <= 0)) | |
| 742 | 720 | return; |
| 743 | 721 | |
| 744 | − __update_curr(cfs_rq, curr, delta_exec); | |
| 745 | 722 | curr->exec_start = now; |
| 746 | 723 | |
| 724 | + schedstat_set(curr->statistics.exec_max, | |
| 725 | + max(delta_exec, curr->statistics.exec_max)); | |
| 726 | + | |
| 727 | + curr->sum_exec_runtime += delta_exec; | |
| 728 | + schedstat_add(cfs_rq, exec_clock, delta_exec); | |
| 729 | + | |
| 730 | + curr->vruntime += calc_delta_fair(delta_exec, curr); | |
| 731 | + update_min_vruntime(cfs_rq); | |
| 732 | + | |
| 747 | 733 | if (entity_is_task(curr)) { |
| 748 | 734 | struct task_struct *curtask = task_of(curr); |
| 749 | 735 | |
| @@ -1752,6 +1738,13 @@ void task_numa_work(struct callback_head *work) · 1002 unmodified lines | ||
| 1752 | 1738 | (vma->vm_file && (vma->vm_flags & (VM_READ|VM_WRITE)) == (VM_READ))) |
| 1753 | 1739 | continue; |
| 1754 | 1740 | |
| 1741 | + /* | |
| 1742 | + * Skip inaccessible VMAs to avoid any confusion between | |
| 1743 | + * PROT_NONE and NUMA hinting ptes | |
| 1744 | + */ | |
| 1745 | + if (!(vma->vm_flags & (VM_READ | VM_EXEC | VM_WRITE))) | |
| 1746 | + continue; | |
| 1747 | + | |
| 1755 | 1748 | do { |
| 1756 | 1749 | start = max(start, vma->vm_start); |
| 1757 | 1750 | end = ALIGN(start + (pages << PAGE_SHIFT), HPAGE_SIZE); |
| @@ -3015,8 +3008,7 @@ static void expire_cfs_rq_runtime(struct cfs_rq *cfs_rq) · 1257 unmodified lines | ||
| 3015 | 3008 | } |
| 3016 | 3009 | } |
| 3017 | 3010 | |
| 3018 | −static void __account_cfs_rq_runtime(struct cfs_rq *cfs_rq, | |
| 3019 | − unsigned long delta_exec) | |
| 3011 | +static void __account_cfs_rq_runtime(struct cfs_rq *cfs_rq, u64 delta_exec) | |
| 3020 | 3012 | { |
| 3021 | 3013 | /* dock delta_exec before expiring quota (as it could span periods) */ |
| 3022 | 3014 | cfs_rq->runtime_remaining -= delta_exec; |
| @@ -3034,7 +3026,7 @@ static void __account_cfs_rq_runtime(struct cfs_rq *cfs_rq, · 11 unmodified lines | ||
| 3034 | 3026 | } |
| 3035 | 3027 | |
| 3036 | 3028 | static __always_inline |
| 3037 | −void account_cfs_rq_runtime(struct cfs_rq *cfs_rq, unsigned long delta_exec) | |
| 3029 | +void account_cfs_rq_runtime(struct cfs_rq *cfs_rq, u64 delta_exec) | |
| 3038 | 3030 | { |
| 3039 | 3031 | if (!cfs_bandwidth_used() || !cfs_rq->runtime_enabled) |
| 3040 | 3032 | return; |
| @@ -3574,8 +3566,7 @@ static inline u64 cfs_rq_clock_task(struct cfs_rq *cfs_rq) · 533 unmodified lines | ||
| 3574 | 3566 | return rq_clock_task(rq_of(cfs_rq)); |
| 3575 | 3567 | } |
| 3576 | 3568 | |
| 3577 | −static void account_cfs_rq_runtime(struct cfs_rq *cfs_rq, | |
| 3578 | − unsigned long delta_exec) {} | |
| 3569 | +static void account_cfs_rq_runtime(struct cfs_rq *cfs_rq, u64 delta_exec) {} | |
| 3579 | 3570 | static void check_cfs_rq_runtime(struct cfs_rq *cfs_rq) {} |
| 3580 | 3571 | static void check_enqueue_throttle(struct cfs_rq *cfs_rq) {} |
| 3581 | 3572 | static __always_inline void return_cfs_rq_runtime(struct cfs_rq *cfs_rq) {} |
| @@ -901,6 +901,13 @@ inc_rt_prio_smp(struct rt_rq *rt_rq, int prio, int prev_prio) · 900 unmodified lines | ||
| 901 | 901 | { |
| 902 | 902 | struct rq *rq = rq_of_rt_rq(rt_rq); |
| 903 | 903 | |
| 904 | +#ifdef CONFIG_RT_GROUP_SCHED | |
| 905 | + /* | |
| 906 | + * Change rq's cpupri only if rt_rq is the top queue. | |
| 907 | + */ | |
| 908 | + if (&rq->rt != rt_rq) | |
| 909 | + return; | |
| 910 | +#endif | |
| 904 | 911 | if (rq->online && prio < prev_prio) |
| 905 | 912 | cpupri_set(&rq->rd->cpupri, rq->cpu, prio); |
| 906 | 913 | } |
| @@ -910,6 +917,13 @@ dec_rt_prio_smp(struct rt_rq *rt_rq, int prio, int prev_prio) · 3 unmodified lines | ||
| 910 | 917 | { |
| 911 | 918 | struct rq *rq = rq_of_rt_rq(rt_rq); |
| 912 | 919 | |
| 920 | +#ifdef CONFIG_RT_GROUP_SCHED | |
| 921 | + /* | |
| 922 | + * Change rq's cpupri only if rt_rq is the top queue. | |
| 923 | + */ | |
| 924 | + if (&rq->rt != rt_rq) | |
| 925 | + return; | |
| 926 | +#endif | |
| 913 | 927 | if (rq->online && rt_rq->highest_prio.curr != prev_prio) |
| 914 | 928 | cpupri_set(&rq->rd->cpupri, rq->cpu, rt_rq->highest_prio.curr); |
| 915 | 929 | } |
| @@ -775,7 +775,7 @@ static int ftrace_profile_init(void) · 774 unmodified lines | ||
| 775 | 775 | int cpu; |
| 776 | 776 | int ret = 0; |
| 777 | 777 | |
| 778 | − for_each_online_cpu(cpu) { | |
| 778 | + for_each_possible_cpu(cpu) { | |
| 779 | 779 | ret = ftrace_profile_init_cpu(cpu); |
| 780 | 780 | if (ret) |
| 781 | 781 | break; |
| @@ -51,9 +51,9 @@ struct user_namespace init_user_ns = { · 50 unmodified lines | ||
| 51 | 51 | .owner = GLOBAL_ROOT_UID, |
| 52 | 52 | .group = GLOBAL_ROOT_GID, |
| 53 | 53 | .proc_inum = PROC_USER_INIT_INO, |
| 54 | −#ifdef CONFIG_KEYS_KERBEROS_CACHE | |
| 55 | − .krb_cache_register_sem = | |
| 56 | − __RWSEM_INITIALIZER(init_user_ns.krb_cache_register_sem), | |
| 54 | +#ifdef CONFIG_PERSISTENT_KEYRINGS | |
| 55 | + .persistent_keyring_register_sem = | |
| 56 | + __RWSEM_INITIALIZER(init_user_ns.persistent_keyring_register_sem), | |
| 57 | 57 | #endif |
| 58 | 58 | }; |
| 59 | 59 | EXPORT_SYMBOL_GPL(init_user_ns); |
| @@ -543,7 +543,7 @@ config ZSWAP · 542 unmodified lines | ||
| 543 | 543 | |
| 544 | 544 | config MEM_SOFT_DIRTY |
| 545 | 545 | bool "Track memory changes" |
| 546 | − depends on CHECKPOINT_RESTORE && HAVE_ARCH_SOFT_DIRTY | |
| 546 | + depends on CHECKPOINT_RESTORE && HAVE_ARCH_SOFT_DIRTY && PROC_FS | |
| 547 | 547 | select PROC_PAGE_MONITOR |
| 548 | 548 | help |
| 549 | 549 | This option enables memory changes tracking by introducing a |
| @@ -134,6 +134,10 @@ static void update_pageblock_skip(struct compact_control *cc, · 133 unmodified lines | ||
| 134 | 134 | bool migrate_scanner) |
| 135 | 135 | { |
| 136 | 136 | struct zone *zone = cc->zone; |
| 137 | + | |
| 138 | + if (cc->ignore_skip_hint) | |
| 139 | + return; | |
| 140 | + | |
| 137 | 141 | if (!page) |
| 138 | 142 | return; |
| 139 | 143 | |
| @@ -882,6 +882,10 @@ int copy_huge_pmd(struct mm_struct *dst_mm, struct mm_struct *src_mm, · 881 unmodified lines | ||
| 882 | 882 | ret = 0; |
| 883 | 883 | goto out_unlock; |
| 884 | 884 | } |
| 885 | + | |
| 886 | + /* mmap_sem prevents this happening but warn if that changes */ | |
| 887 | + WARN_ON(pmd_trans_migrating(pmd)); | |
| 888 | + | |
| 885 | 889 | if (unlikely(pmd_trans_splitting(pmd))) { |
| 886 | 890 | /* split huge page running from under us */ |
| 887 | 891 | spin_unlock(src_ptl); |
| @@ -1243,6 +1247,10 @@ struct page *follow_trans_huge_pmd(struct vm_area_struct *vma, · 355 unmodified lines | ||
| 1243 | 1247 | if ((flags & FOLL_DUMP) && is_huge_zero_pmd(*pmd)) |
| 1244 | 1248 | return ERR_PTR(-EFAULT); |
| 1245 | 1249 | |
| 1250 | + /* Full NUMA hinting faults to serialise migration in fault paths */ | |
| 1251 | + if ((flags & FOLL_NUMA) && pmd_numa(*pmd)) | |
| 1252 | + goto out; | |
| 1253 | + | |
| 1246 | 1254 | page = pmd_page(*pmd); |
| 1247 | 1255 | VM_BUG_ON(!PageHead(page)); |
| 1248 | 1256 | if (flags & FOLL_TOUCH) { |
| @@ -1295,6 +1303,17 @@ int do_huge_pmd_numa_page(struct mm_struct *mm, struct vm_area_struct *vma, · 46 unmodified lines | ||
| 1295 | 1303 | if (unlikely(!pmd_same(pmd, *pmdp))) |
| 1296 | 1304 | goto out_unlock; |
| 1297 | 1305 | |
| 1306 | + /* | |
| 1307 | + * If there are potential migrations, wait for completion and retry | |
| 1308 | + * without disrupting NUMA hinting information. Do not relock and | |
| 1309 | + * check_same as the page may no longer be mapped. | |
| 1310 | + */ | |
| 1311 | + if (unlikely(pmd_trans_migrating(*pmdp))) { | |
| 1312 | + spin_unlock(ptl); | |
| 1313 | + wait_migrate_huge_page(vma->anon_vma, pmdp); | |
| 1314 | + goto out; | |
| 1315 | + } | |
| 1316 | + | |
| 1298 | 1317 | page = pmd_page(pmd); |
| 1299 | 1318 | BUG_ON(is_huge_zero_page(page)); |
| 1300 | 1319 | page_nid = page_to_nid(page); |
| @@ -1323,23 +1342,22 @@ int do_huge_pmd_numa_page(struct mm_struct *mm, struct vm_area_struct *vma, · 22 unmodified lines | ||
| 1323 | 1342 | /* If the page was locked, there are no parallel migrations */ |
| 1324 | 1343 | if (page_locked) |
| 1325 | 1344 | goto clear_pmdnuma; |
| 1345 | + } | |
| 1326 | 1346 | |
| 1327 | − /* | |
| 1328 | − * Otherwise wait for potential migrations and retry. We do | |
| 1329 | − * relock and check_same as the page may no longer be mapped. | |
| 1330 | − * As the fault is being retried, do not account for it. | |
| 1331 | − */ | |
| 1347 | + /* Migration could have started since the pmd_trans_migrating check */ | |
| 1348 | + if (!page_locked) { | |
| 1332 | 1349 | spin_unlock(ptl); |
| 1333 | 1350 | wait_on_page_locked(page); |
| 1334 | 1351 | page_nid = -1; |
| 1335 | 1352 | goto out; |
| 1336 | 1353 | } |
| 1337 | 1354 | |
| 1338 | − /* Page is misplaced, serialise migrations and parallel THP splits */ | |
| 1355 | + /* | |
| 1356 | + * Page is misplaced. Page lock serialises migrations. Acquire anon_vma | |
| 1357 | + * to serialises splits | |
| 1358 | + */ | |
| 1339 | 1359 | get_page(page); |
| 1340 | 1360 | spin_unlock(ptl); |
| 1341 | − if (!page_locked) | |
| 1342 | − lock_page(page); | |
| 1343 | 1361 | anon_vma = page_lock_anon_vma_read(page); |
| 1344 | 1362 | |
| 1345 | 1363 | /* Confirm the PMD did not change while page_table_lock was released */ |
| @@ -1351,6 +1369,13 @@ int do_huge_pmd_numa_page(struct mm_struct *mm, struct vm_area_struct *vma, · 5 unmodified lines | ||
| 1351 | 1369 | goto out_unlock; |
| 1352 | 1370 | } |
| 1353 | 1371 | |
| 1372 | + /* Bail if we fail to protect against THP splits for any reason */ | |
| 1373 | + if (unlikely(!anon_vma)) { | |
| 1374 | + put_page(page); | |
| 1375 | + page_nid = -1; | |
| 1376 | + goto clear_pmdnuma; | |
| 1377 | + } | |
| 1378 | + | |
| 1354 | 1379 | /* |
| 1355 | 1380 | * Migrate the THP to the requested node, returns with page unlocked |
| 1356 | 1381 | * and pmd_numa cleared. |
| @@ -1517,6 +1542,8 @@ int change_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd, · 160 unmodified lines | ||
| 1517 | 1542 | ret = 1; |
| 1518 | 1543 | if (!prot_numa) { |
| 1519 | 1544 | entry = pmdp_get_and_clear(mm, addr, pmd); |
| 1545 | + if (pmd_numa(entry)) | |
| 1546 | + entry = pmd_mknonnuma(entry); | |
| 1520 | 1547 | entry = pmd_modify(entry, newprot); |
| 1521 | 1548 | ret = HPAGE_PMD_NR; |
| 1522 | 1549 | BUG_ON(pmd_write(entry)); |
| @@ -1531,7 +1558,7 @@ int change_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd, · 8 unmodified lines | ||
| 1531 | 1558 | */ |
| 1532 | 1559 | if (!is_huge_zero_page(page) && |
| 1533 | 1560 | !pmd_numa(*pmd)) { |
| 1534 | − entry = pmdp_get_and_clear(mm, addr, pmd); | |
| 1561 | + entry = *pmd; | |
| 1535 | 1562 | entry = pmd_mknuma(entry); |
| 1536 | 1563 | ret = HPAGE_PMD_NR; |
| 1537 | 1564 | } |
| @@ -1505,10 +1505,16 @@ static int soft_offline_huge_page(struct page *page, int flags) · 1504 unmodified lines | ||
| 1505 | 1505 | if (ret > 0) |
| 1506 | 1506 | ret = -EIO; |
| 1507 | 1507 | } else { |
| 1508 | − set_page_hwpoison_huge_page(hpage); | |
| 1509 | − dequeue_hwpoisoned_huge_page(hpage); | |
| 1510 | − atomic_long_add(1 << compound_order(hpage), | |
| 1511 | − &num_poisoned_pages); | |
| 1508 | + /* overcommit hugetlb page will be freed to buddy */ | |
| 1509 | + if (PageHuge(page)) { | |
| 1510 | + set_page_hwpoison_huge_page(hpage); | |
| 1511 | + dequeue_hwpoisoned_huge_page(hpage); | |
| 1512 | + atomic_long_add(1 << compound_order(hpage), | |
| 1513 | + &num_poisoned_pages); | |
| 1514 | + } else { | |
| 1515 | + SetPageHWPoison(page); | |
| 1516 | + atomic_long_inc(&num_poisoned_pages); | |
| 1517 | + } | |
| 1512 | 1518 | } |
| 1513 | 1519 | return ret; |
| 1514 | 1520 | } |
| @@ -4271,7 +4271,7 @@ void copy_user_huge_page(struct page *dst, struct page *src, · 4270 unmodified lines | ||
| 4271 | 4271 | } |
| 4272 | 4272 | #endif /* CONFIG_TRANSPARENT_HUGEPAGE || CONFIG_HUGETLBFS */ |
| 4273 | 4273 | |
| 4274 | −#if USE_SPLIT_PTE_PTLOCKS && BLOATED_SPINLOCKS | |
| 4274 | +#if USE_SPLIT_PTE_PTLOCKS && ALLOC_SPLIT_PTLOCKS | |
| 4275 | 4275 | bool ptlock_alloc(struct page *page) |
| 4276 | 4276 | { |
| 4277 | 4277 | spinlock_t *ptl; |
| @@ -1197,14 +1197,16 @@ static struct page *new_vma_page(struct page *page, unsigned long private, int * · 1196 unmodified lines | ||
| 1197 | 1197 | break; |
| 1198 | 1198 | vma = vma->vm_next; |
| 1199 | 1199 | } |
| 1200 | + | |
| 1201 | + if (PageHuge(page)) { | |
| 1202 | + if (vma) | |
| 1203 | + return alloc_huge_page_noerr(vma, address, 1); | |
| 1204 | + else | |
| 1205 | + return NULL; | |
| 1206 | + } | |
| 1200 | 1207 | /* |
| 1201 | − * queue_pages_range() confirms that @page belongs to some vma, | |
| 1202 | − * so vma shouldn't be NULL. | |
| 1208 | + * if !vma, alloc_page_vma() will use task or system default policy | |
| 1203 | 1209 | */ |
| 1204 | − BUG_ON(!vma); | |
| 1205 | − | |
| 1206 | − if (PageHuge(page)) | |
| 1207 | − return alloc_huge_page_noerr(vma, address, 1); | |
| 1208 | 1210 | return alloc_page_vma(GFP_HIGHUSER_MOVABLE, vma, address); |
| 1209 | 1211 | } |
| 1210 | 1212 | #else |
| @@ -1318,7 +1320,7 @@ static long do_mbind(unsigned long start, unsigned long len, · 107 unmodified lines | ||
| 1318 | 1320 | if (nr_failed && (flags & MPOL_MF_STRICT)) |
| 1319 | 1321 | err = -EIO; |
| 1320 | 1322 | } else |
| 1321 | − putback_lru_pages(&pagelist); | |
| 1323 | + putback_movable_pages(&pagelist); | |
| 1322 | 1324 | |
| 1323 | 1325 | up_write(&mm->mmap_sem); |
| 1324 | 1326 | mpol_out: |
| @@ -36,6 +36,7 @@ · 35 unmodified lines | ||
| 36 | 36 | #include <linux/hugetlb_cgroup.h> |
| 37 | 37 | #include <linux/gfp.h> |
| 38 | 38 | #include <linux/balloon_compaction.h> |
| 39 | +#include <linux/mmu_notifier.h> | |
| 39 | 40 | |
| 40 | 41 | #include <asm/tlbflush.h> |
| 41 | 42 | |
| @@ -316,14 +317,15 @@ static inline bool buffer_migrate_lock_buffers(struct buffer_head *head, · 274 unmodified lines | ||
| 316 | 317 | */ |
| 317 | 318 | int migrate_page_move_mapping(struct address_space *mapping, |
| 318 | 319 | struct page *newpage, struct page *page, |
| 319 | − struct buffer_head *head, enum migrate_mode mode) | |
| 320 | + struct buffer_head *head, enum migrate_mode mode, | |
| 321 | + int extra_count) | |
| 320 | 322 | { |
| 321 | − int expected_count = 0; | |
| 323 | + int expected_count = 1 + extra_count; | |
| 322 | 324 | void **pslot; |
| 323 | 325 | |
| 324 | 326 | if (!mapping) { |
| 325 | 327 | /* Anonymous page without mapping */ |
| 326 | − if (page_count(page) != 1) | |
| 328 | + if (page_count(page) != expected_count) | |
| 327 | 329 | return -EAGAIN; |
| 328 | 330 | return MIGRATEPAGE_SUCCESS; |
| 329 | 331 | } |
| @@ -333,7 +335,7 @@ int migrate_page_move_mapping(struct address_space *mapping, · 3 unmodified lines | ||
| 333 | 335 | pslot = radix_tree_lookup_slot(&mapping->page_tree, |
| 334 | 336 | page_index(page)); |
| 335 | 337 | |
| 336 | − expected_count = 2 + page_has_private(page); | |
| 338 | + expected_count += 1 + page_has_private(page); | |
| 337 | 339 | if (page_count(page) != expected_count || |
| 338 | 340 | radix_tree_deref_slot_protected(pslot, &mapping->tree_lock) != page) { |
| 339 | 341 | spin_unlock_irq(&mapping->tree_lock); |
| @@ -583,7 +585,7 @@ int migrate_page(struct address_space *mapping, · 243 unmodified lines | ||
| 583 | 585 | |
| 584 | 586 | BUG_ON(PageWriteback(page)); /* Writeback must be complete */ |
| 585 | 587 | |
| 586 | − rc = migrate_page_move_mapping(mapping, newpage, page, NULL, mode); | |
| 588 | + rc = migrate_page_move_mapping(mapping, newpage, page, NULL, mode, 0); | |
| 587 | 589 | |
| 588 | 590 | if (rc != MIGRATEPAGE_SUCCESS) |
| 589 | 591 | return rc; |
| @@ -610,7 +612,7 @@ int buffer_migrate_page(struct address_space *mapping, · 20 unmodified lines | ||
| 610 | 612 | |
| 611 | 613 | head = page_buffers(page); |
| 612 | 614 | |
| 613 | − rc = migrate_page_move_mapping(mapping, newpage, page, head, mode); | |
| 615 | + rc = migrate_page_move_mapping(mapping, newpage, page, head, mode, 0); | |
| 614 | 616 | |
| 615 | 617 | if (rc != MIGRATEPAGE_SUCCESS) |
| 616 | 618 | return rc; |
| @@ -1654,6 +1656,18 @@ int numamigrate_isolate_page(pg_data_t *pgdat, struct page *page) · 1037 unmodified lines | ||
| 1654 | 1656 | return 1; |
| 1655 | 1657 | } |
| 1656 | 1658 | |
| 1659 | +bool pmd_trans_migrating(pmd_t pmd) | |
| 1660 | +{ | |
| 1661 | + struct page *page = pmd_page(pmd); | |
| 1662 | + return PageLocked(page); | |
| 1663 | +} | |
| 1664 | + | |
| 1665 | +void wait_migrate_huge_page(struct anon_vma *anon_vma, pmd_t *pmd) | |
| 1666 | +{ | |
| 1667 | + struct page *page = pmd_page(*pmd); | |
| 1668 | + wait_on_page_locked(page); | |
| 1669 | +} | |
| 1670 | + | |
| 1657 | 1671 | /* |
| 1658 | 1672 | * Attempt to migrate a misplaced page to the specified destination |
| 1659 | 1673 | * node. Caller is expected to have an elevated reference count on |
| @@ -1716,12 +1730,14 @@ int migrate_misplaced_transhuge_page(struct mm_struct *mm, · 56 unmodified lines | ||
| 1716 | 1730 | struct page *page, int node) |
| 1717 | 1731 | { |
| 1718 | 1732 | spinlock_t *ptl; |
| 1719 | − unsigned long haddr = address & HPAGE_PMD_MASK; | |
| 1720 | 1733 | pg_data_t *pgdat = NODE_DATA(node); |
| 1721 | 1734 | int isolated = 0; |
| 1722 | 1735 | struct page *new_page = NULL; |
| 1723 | 1736 | struct mem_cgroup *memcg = NULL; |
| 1724 | 1737 | int page_lru = page_is_file_cache(page); |
| 1738 | + unsigned long mmun_start = address & HPAGE_PMD_MASK; | |
| 1739 | + unsigned long mmun_end = mmun_start + HPAGE_PMD_SIZE; | |
| 1740 | + pmd_t orig_entry; | |
| 1725 | 1741 | |
| 1726 | 1742 | /* |
| 1727 | 1743 | * Rate-limit the amount of data that is being migrated to a node. |
| @@ -1744,6 +1760,9 @@ int migrate_misplaced_transhuge_page(struct mm_struct *mm, · 16 unmodified lines | ||
| 1744 | 1760 | goto out_fail; |
| 1745 | 1761 | } |
| 1746 | 1762 | |
| 1763 | + if (mm_tlb_flush_pending(mm)) | |
| 1764 | + flush_tlb_range(vma, mmun_start, mmun_end); | |
| 1765 | + | |
| 1747 | 1766 | /* Prepare a page as a migration target */ |
| 1748 | 1767 | __set_page_locked(new_page); |
| 1749 | 1768 | SetPageSwapBacked(new_page); |
| @@ -1755,9 +1774,12 @@ int migrate_misplaced_transhuge_page(struct mm_struct *mm, · 5 unmodified lines | ||
| 1755 | 1774 | WARN_ON(PageLRU(new_page)); |
| 1756 | 1775 | |
| 1757 | 1776 | /* Recheck the target PMD */ |
| 1777 | + mmu_notifier_invalidate_range_start(mm, mmun_start, mmun_end); | |
| 1758 | 1778 | ptl = pmd_lock(mm, pmd); |
| 1759 | − if (unlikely(!pmd_same(*pmd, entry))) { | |
| 1779 | + if (unlikely(!pmd_same(*pmd, entry) || page_count(page) != 2)) { | |
| 1780 | +fail_putback: | |
| 1760 | 1781 | spin_unlock(ptl); |
| 1782 | + mmu_notifier_invalidate_range_end(mm, mmun_start, mmun_end); | |
| 1761 | 1783 | |
| 1762 | 1784 | /* Reverse changes made by migrate_page_copy() */ |
| 1763 | 1785 | if (TestClearPageActive(new_page)) |
| @@ -1774,7 +1796,8 @@ int migrate_misplaced_transhuge_page(struct mm_struct *mm, · 10 unmodified lines | ||
| 1774 | 1796 | putback_lru_page(page); |
| 1775 | 1797 | mod_zone_page_state(page_zone(page), |
| 1776 | 1798 | NR_ISOLATED_ANON + page_lru, -HPAGE_PMD_NR); |
| 1777 | − goto out_fail; | |
| 1799 | + | |
| 1800 | + goto out_unlock; | |
| 1778 | 1801 | } |
| 1779 | 1802 | |
| 1780 | 1803 | /* |
| @@ -1786,16 +1809,35 @@ int migrate_misplaced_transhuge_page(struct mm_struct *mm, · 5 unmodified lines | ||
| 1786 | 1809 | */ |
| 1787 | 1810 | mem_cgroup_prepare_migration(page, new_page, &memcg); |
| 1788 | 1811 | |
| 1812 | + orig_entry = *pmd; | |
| 1789 | 1813 | entry = mk_pmd(new_page, vma->vm_page_prot); |
| 1790 | − entry = pmd_mknonnuma(entry); | |
| 1791 | − entry = maybe_pmd_mkwrite(pmd_mkdirty(entry), vma); | |
| 1792 | 1814 | entry = pmd_mkhuge(entry); |
| 1815 | + entry = maybe_pmd_mkwrite(pmd_mkdirty(entry), vma); | |
| 1793 | 1816 | |
| 1794 | − pmdp_clear_flush(vma, haddr, pmd); | |
| 1795 | − set_pmd_at(mm, haddr, pmd, entry); | |
| 1796 | − page_add_new_anon_rmap(new_page, vma, haddr); | |
| 1817 | + /* | |
| 1818 | + * Clear the old entry under pagetable lock and establish the new PTE. | |
| 1819 | + * Any parallel GUP will either observe the old page blocking on the | |
| 1820 | + * page lock, block on the page table lock or observe the new page. | |
| 1821 | + * The SetPageUptodate on the new page and page_add_new_anon_rmap | |
| 1822 | + * guarantee the copy is visible before the pagetable update. | |
| 1823 | + */ | |
| 1824 | + flush_cache_range(vma, mmun_start, mmun_end); | |
| 1825 | + page_add_new_anon_rmap(new_page, vma, mmun_start); | |
| 1826 | + pmdp_clear_flush(vma, mmun_start, pmd); | |
| 1827 | + set_pmd_at(mm, mmun_start, pmd, entry); | |
| 1828 | + flush_tlb_range(vma, mmun_start, mmun_end); | |
| 1797 | 1829 | update_mmu_cache_pmd(vma, address, &entry); |
| 1830 | + | |
| 1831 | + if (page_count(page) != 2) { | |
| 1832 | + set_pmd_at(mm, mmun_start, pmd, orig_entry); | |
| 1833 | + flush_tlb_range(vma, mmun_start, mmun_end); | |
| 1834 | + update_mmu_cache_pmd(vma, address, &entry); | |
| 1835 | + page_remove_rmap(new_page); | |
| 1836 | + goto fail_putback; | |
| 1837 | + } | |
| 1838 | + | |
| 1798 | 1839 | page_remove_rmap(page); |
| 1840 | + | |
| 1799 | 1841 | /* |
| 1800 | 1842 | * Finish the charge transaction under the page table lock to |
| 1801 | 1843 | * prevent split_huge_page() from dividing up the charge |
| @@ -1803,6 +1845,7 @@ int migrate_misplaced_transhuge_page(struct mm_struct *mm, · 1 unmodified line | ||
| 1803 | 1845 | */ |
| 1804 | 1846 | mem_cgroup_end_migration(memcg, page, new_page, true); |
| 1805 | 1847 | spin_unlock(ptl); |
| 1848 | + mmu_notifier_invalidate_range_end(mm, mmun_start, mmun_end); | |
| 1806 | 1849 | |
| 1807 | 1850 | unlock_page(new_page); |
| 1808 | 1851 | unlock_page(page); |
| @@ -1820,10 +1863,15 @@ int migrate_misplaced_transhuge_page(struct mm_struct *mm, · 11 unmodified lines | ||
| 1820 | 1863 | out_fail: |
| 1821 | 1864 | count_vm_events(PGMIGRATE_FAIL, HPAGE_PMD_NR); |
| 1822 | 1865 | out_dropref: |
| 1823 | − entry = pmd_mknonnuma(entry); | |
| 1824 | − set_pmd_at(mm, haddr, pmd, entry); | |
| 1825 | − update_mmu_cache_pmd(vma, address, &entry); | |
| 1866 | + ptl = pmd_lock(mm, pmd); | |
| 1867 | + if (pmd_same(*pmd, entry)) { | |
| 1868 | + entry = pmd_mknonnuma(entry); | |
| 1869 | + set_pmd_at(mm, mmun_start, pmd, entry); | |
| 1870 | + update_mmu_cache_pmd(vma, address, &entry); | |
| 1871 | + } | |
| 1872 | + spin_unlock(ptl); | |
| 1826 | 1873 | |
| 1874 | +out_unlock: | |
| 1827 | 1875 | unlock_page(page); |
| 1828 | 1876 | put_page(page); |
| 1829 | 1877 | return 0; |
| @@ -52,17 +52,21 @@ static unsigned long change_pte_range(struct vm_area_struct *vma, pmd_t *pmd, · 51 unmodified lines | ||
| 52 | 52 | pte_t ptent; |
| 53 | 53 | bool updated = false; |
| 54 | 54 | |
| 55 | − ptent = ptep_modify_prot_start(mm, addr, pte); | |
| 56 | 55 | if (!prot_numa) { |
| 56 | + ptent = ptep_modify_prot_start(mm, addr, pte); | |
| 57 | + if (pte_numa(ptent)) | |
| 58 | + ptent = pte_mknonnuma(ptent); | |
| 57 | 59 | ptent = pte_modify(ptent, newprot); |
| 58 | 60 | updated = true; |
| 59 | 61 | } else { |
| 60 | 62 | struct page *page; |
| 61 | 63 | |
| 64 | + ptent = *pte; | |
| 62 | 65 | page = vm_normal_page(vma, addr, oldpte); |
| 63 | 66 | if (page) { |
| 64 | 67 | if (!pte_numa(oldpte)) { |
| 65 | 68 | ptent = pte_mknuma(ptent); |
| 69 | + set_pte_at(mm, addr, pte, ptent); | |
| 66 | 70 | updated = true; |
| 67 | 71 | } |
| 68 | 72 | } |
| @@ -79,7 +83,10 @@ static unsigned long change_pte_range(struct vm_area_struct *vma, pmd_t *pmd, · 10 unmodified lines | ||
| 79 | 83 | |
| 80 | 84 | if (updated) |
| 81 | 85 | pages++; |
| 82 | − ptep_modify_prot_commit(mm, addr, pte, ptent); | |
| 86 | + | |
| 87 | + /* Only !prot_numa always clears the pte */ | |
| 88 | + if (!prot_numa) | |
| 89 | + ptep_modify_prot_commit(mm, addr, pte, ptent); | |
| 83 | 90 | } else if (IS_ENABLED(CONFIG_MIGRATION) && !pte_file(oldpte)) { |
| 84 | 91 | swp_entry_t entry = pte_to_swp_entry(oldpte); |
| 85 | 92 | |
| @@ -181,6 +188,7 @@ static unsigned long change_protection_range(struct vm_area_struct *vma, · 95 unmodified lines | ||
| 181 | 188 | BUG_ON(addr >= end); |
| 182 | 189 | pgd = pgd_offset(mm, addr); |
| 183 | 190 | flush_cache_range(vma, addr, end); |
| 191 | + set_tlb_flush_pending(mm); | |
| 184 | 192 | do { |
| 185 | 193 | next = pgd_addr_end(addr, end); |
| 186 | 194 | if (pgd_none_or_clear_bad(pgd)) |
| @@ -192,6 +200,7 @@ static unsigned long change_protection_range(struct vm_area_struct *vma, · 5 unmodified lines | ||
| 192 | 200 | /* Only flush the TLB if we actually modified any entries: */ |
| 193 | 201 | if (pages) |
| 194 | 202 | flush_tlb_range(vma, start, end); |
| 203 | + clear_tlb_flush_pending(mm); | |
| 195 | 204 | |
| 196 | 205 | return pages; |
| 197 | 206 | } |
| @@ -1816,7 +1816,7 @@ static void zlc_clear_zones_full(struct zonelist *zonelist) · 1815 unmodified lines | ||
| 1816 | 1816 | |
| 1817 | 1817 | static bool zone_local(struct zone *local_zone, struct zone *zone) |
| 1818 | 1818 | { |
| 1819 | − return node_distance(local_zone->node, zone->node) == LOCAL_DISTANCE; | |
| 1819 | + return local_zone->node == zone->node; | |
| 1820 | 1820 | } |
| 1821 | 1821 | |
| 1822 | 1822 | static bool zone_allows_reclaim(struct zone *local_zone, struct zone *zone) |
| @@ -1913,18 +1913,17 @@ zonelist_scan: · 90 unmodified lines | ||
| 1913 | 1913 | * page was allocated in should have no effect on the |
| 1914 | 1914 | * time the page has in memory before being reclaimed. |
| 1915 | 1915 | * |
| 1916 | − * When zone_reclaim_mode is enabled, try to stay in | |
| 1917 | − * local zones in the fastpath. If that fails, the | |
| 1918 | − * slowpath is entered, which will do another pass | |
| 1919 | − * starting with the local zones, but ultimately fall | |
| 1920 | − * back to remote zones that do not partake in the | |
| 1921 | − * fairness round-robin cycle of this zonelist. | |
| 1916 | + * Try to stay in local zones in the fastpath. If | |
| 1917 | + * that fails, the slowpath is entered, which will do | |
| 1918 | + * another pass starting with the local zones, but | |
| 1919 | + * ultimately fall back to remote zones that do not | |
| 1920 | + * partake in the fairness round-robin cycle of this | |
| 1921 | + * zonelist. | |
| 1922 | 1922 | */ |
| 1923 | 1923 | if (alloc_flags & ALLOC_WMARK_LOW) { |
| 1924 | 1924 | if (zone_page_state(zone, NR_ALLOC_BATCH) <= 0) |
| 1925 | 1925 | continue; |
| 1926 | − if (zone_reclaim_mode && | |
| 1927 | − !zone_local(preferred_zone, zone)) | |
| 1926 | + if (!zone_local(preferred_zone, zone)) | |
| 1928 | 1927 | continue; |
| 1929 | 1928 | } |
| 1930 | 1929 | /* |
| @@ -2390,7 +2389,7 @@ static void prepare_slowpath(gfp_t gfp_mask, unsigned int order, · 459 unmodified lines | ||
| 2390 | 2389 | * thrash fairness information for zones that are not |
| 2391 | 2390 | * actually part of this zonelist's round-robin cycle. |
| 2392 | 2391 | */ |
| 2393 | − if (zone_reclaim_mode && !zone_local(preferred_zone, zone)) | |
| 2392 | + if (!zone_local(preferred_zone, zone)) | |
| 2394 | 2393 | continue; |
| 2395 | 2394 | mod_zone_page_state(zone, NR_ALLOC_BATCH, |
| 2396 | 2395 | high_wmark_pages(zone) - |
| @@ -110,9 +110,10 @@ int pmdp_clear_flush_young(struct vm_area_struct *vma, · 109 unmodified lines | ||
| 110 | 110 | pte_t ptep_clear_flush(struct vm_area_struct *vma, unsigned long address, |
| 111 | 111 | pte_t *ptep) |
| 112 | 112 | { |
| 113 | + struct mm_struct *mm = (vma)->vm_mm; | |
| 113 | 114 | pte_t pte; |
| 114 | − pte = ptep_get_and_clear((vma)->vm_mm, address, ptep); | |
| 115 | − if (pte_accessible(pte)) | |
| 115 | + pte = ptep_get_and_clear(mm, address, ptep); | |
| 116 | + if (pte_accessible(mm, pte)) | |
| 116 | 117 | flush_tlb_page(vma, address); |
| 117 | 118 | return pte; |
| 118 | 119 | } |
| @@ -191,6 +192,9 @@ pgtable_t pgtable_trans_huge_withdraw(struct mm_struct *mm, pmd_t *pmdp) · 72 unmodified lines | ||
| 191 | 192 | void pmdp_invalidate(struct vm_area_struct *vma, unsigned long address, |
| 192 | 193 | pmd_t *pmdp) |
| 193 | 194 | { |
| 195 | + pmd_t entry = *pmdp; | |
| 196 | + if (pmd_numa(entry)) | |
| 197 | + entry = pmd_mknonnuma(entry); | |
| 194 | 198 | set_pmd_at(vma->vm_mm, address, pmdp, pmd_mknotpresent(*pmdp)); |
| 195 | 199 | flush_tlb_range(vma, address, address + HPAGE_PMD_SIZE); |
| 196 | 200 | } |
| @@ -600,7 +600,11 @@ pte_t *__page_check_address(struct page *page, struct mm_struct *mm, · 599 unmodified lines | ||
| 600 | 600 | spinlock_t *ptl; |
| 601 | 601 | |
| 602 | 602 | if (unlikely(PageHuge(page))) { |
| 603 | + /* when pud is not present, pte will be NULL */ | |
| 603 | 604 | pte = huge_pte_offset(mm, address); |
| 605 | + if (!pte) | |
| 606 | + return NULL; | |
| 607 | + | |
| 604 | 608 | ptl = huge_pte_lockptr(page_hstate(page), mm, pte); |
| 605 | 609 | goto check; |
| 606 | 610 | } |
| @@ -1161,6 +1161,7 @@ int neigh_update(struct neighbour *neigh, const u8 *lladdr, u8 new, · 1160 unmodified lines | ||
| 1161 | 1161 | neigh->parms->reachable_time : |
| 1162 | 1162 | 0))); |
| 1163 | 1163 | neigh->nud_state = new; |
| 1164 | + notify = 1; | |
| 1164 | 1165 | } |
| 1165 | 1166 | |
| 1166 | 1167 | if (lladdr != neigh->ha) { |
| @@ -423,6 +423,7 @@ static void synproxy_tg4_destroy(const struct xt_tgdtor_param *par) · 422 unmodified lines | ||
| 423 | 423 | static struct xt_target synproxy_tg4_reg __read_mostly = { |
| 424 | 424 | .name = "SYNPROXY", |
| 425 | 425 | .family = NFPROTO_IPV4, |
| 426 | + .hooks = (1 << NF_INET_LOCAL_IN) | (1 << NF_INET_FORWARD), | |
| 426 | 427 | .target = synproxy_tg4, |
| 427 | 428 | .targetsize = sizeof(struct xt_synproxy_info), |
| 428 | 429 | .checkentry = synproxy_tg4_check, |
| @@ -72,7 +72,7 @@ static int nft_reject_dump(struct sk_buff *skb, const struct nft_expr *expr) · 71 unmodified lines | ||
| 72 | 72 | { |
| 73 | 73 | const struct nft_reject *priv = nft_expr_priv(expr); |
| 74 | 74 | |
| 75 | − if (nla_put_be32(skb, NFTA_REJECT_TYPE, priv->type)) | |
| 75 | + if (nla_put_be32(skb, NFTA_REJECT_TYPE, htonl(priv->type))) | |
| 76 | 76 | goto nla_put_failure; |
| 77 | 77 | |
| 78 | 78 | switch (priv->type) { |
| @@ -1600,20 +1600,15 @@ static void flush_stack(struct sock **stack, unsigned int count, · 1599 unmodified lines | ||
| 1600 | 1600 | } |
| 1601 | 1601 | |
| 1602 | 1602 | /* For TCP sockets, sk_rx_dst is protected by socket lock |
| 1603 | − * For UDP, we use sk_dst_lock to guard against concurrent changes. | |
| 1603 | + * For UDP, we use xchg() to guard against concurrent changes. | |
| 1604 | 1604 | */ |
| 1605 | 1605 | static void udp_sk_rx_dst_set(struct sock *sk, struct dst_entry *dst) |
| 1606 | 1606 | { |
| 1607 | 1607 | struct dst_entry *old; |
| 1608 | 1608 | |
| 1609 | − spin_lock(&sk->sk_dst_lock); | |
| 1610 | − old = sk->sk_rx_dst; | |
| 1611 | − if (likely(old != dst)) { | |
| 1612 | − dst_hold(dst); | |
| 1613 | − sk->sk_rx_dst = dst; | |
| 1614 | − dst_release(old); | |
| 1615 | − } | |
| 1616 | − spin_unlock(&sk->sk_dst_lock); | |
| 1609 | + dst_hold(dst); | |
| 1610 | + old = xchg(&sk->sk_rx_dst, dst); | |
| 1611 | + dst_release(old); | |
| 1617 | 1612 | } |
| 1618 | 1613 | |
| 1619 | 1614 | /* |
| @@ -446,6 +446,7 @@ static void synproxy_tg6_destroy(const struct xt_tgdtor_param *par) · 445 unmodified lines | ||
| 446 | 446 | static struct xt_target synproxy_tg6_reg __read_mostly = { |
| 447 | 447 | .name = "SYNPROXY", |
| 448 | 448 | .family = NFPROTO_IPV6, |
| 449 | + .hooks = (1 << NF_INET_LOCAL_IN) | (1 << NF_INET_FORWARD), | |
| 449 | 450 | .target = synproxy_tg6, |
| 450 | 451 | .targetsize = sizeof(struct xt_synproxy_info), |
| 451 | 452 | .checkentry = synproxy_tg6_check, |
| @@ -38,6 +38,7 @@ · 37 unmodified lines | ||
| 38 | 38 | #include <net/sctp/sctp.h> |
| 39 | 39 | #include <net/sctp/sm.h> |
| 40 | 40 | |
| 41 | +MODULE_SOFTDEP("pre: sctp"); | |
| 41 | 42 | MODULE_AUTHOR("Wei Yongjun <yjwei@cn.fujitsu.com>"); |
| 42 | 43 | MODULE_DESCRIPTION("SCTP snooper"); |
| 43 | 44 | MODULE_LICENSE("GPL"); |
| @@ -182,6 +183,20 @@ static struct jprobe sctp_recv_probe = { · 138 unmodified lines | ||
| 182 | 183 | .entry = jsctp_sf_eat_sack, |
| 183 | 184 | }; |
| 184 | 185 | |
| 186 | +static __init int sctp_setup_jprobe(void) | |
| 187 | +{ | |
| 188 | + int ret = register_jprobe(&sctp_recv_probe); | |
| 189 | + | |
| 190 | + if (ret) { | |
| 191 | + if (request_module("sctp")) | |
| 192 | + goto out; | |
| 193 | + ret = register_jprobe(&sctp_recv_probe); | |
| 194 | + } | |
| 195 | + | |
| 196 | +out: | |
| 197 | + return ret; | |
| 198 | +} | |
| 199 | + | |
| 185 | 200 | static __init int sctpprobe_init(void) |
| 186 | 201 | { |
| 187 | 202 | int ret = -ENOMEM; |
| @@ -202,7 +217,7 @@ static __init int sctpprobe_init(void) · 14 unmodified lines | ||
| 202 | 217 | &sctpprobe_fops)) |
| 203 | 218 | goto free_kfifo; |
| 204 | 219 | |
| 205 | − ret = register_jprobe(&sctp_recv_probe); | |
| 220 | + ret = sctp_setup_jprobe(); | |
| 206 | 221 | if (ret) |
| 207 | 222 | goto remove_proc; |
| 208 | 223 | |
| @@ -718,7 +718,9 @@ static int unix_autobind(struct socket *sock) · 717 unmodified lines | ||
| 718 | 718 | int err; |
| 719 | 719 | unsigned int retries = 0; |
| 720 | 720 | |
| 721 | − mutex_lock(&u->readlock); | |
| 721 | + err = mutex_lock_interruptible(&u->readlock); | |
| 722 | + if (err) | |
| 723 | + return err; | |
| 722 | 724 | |
| 723 | 725 | err = 0; |
| 724 | 726 | if (u->addr) |
| @@ -877,7 +879,9 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) · 152 unmodified lines | ||
| 877 | 879 | goto out; |
| 878 | 880 | addr_len = err; |
| 879 | 881 | |
| 880 | − mutex_lock(&u->readlock); | |
| 882 | + err = mutex_lock_interruptible(&u->readlock); | |
| 883 | + if (err) | |
| 884 | + goto out; | |
| 881 | 885 | |
| 882 | 886 | err = -EINVAL; |
| 883 | 887 | if (u->addr) |
| @@ -82,7 +82,9 @@ kallsyms() · 81 unmodified lines | ||
| 82 | 82 | kallsymopt="${kallsymopt} --all-symbols" |
| 83 | 83 | fi |
| 84 | 84 | |
| 85 | − kallsymopt="${kallsymopt} --page-offset=$CONFIG_PAGE_OFFSET" | |
| 85 | + if [ -n "${CONFIG_ARM}" ] && [ -n "${CONFIG_PAGE_OFFSET}" ]; then | |
| 86 | + kallsymopt="${kallsymopt} --page-offset=$CONFIG_PAGE_OFFSET" | |
| 87 | + fi | |
| 86 | 88 | |
| 87 | 89 | local aflags="${KBUILD_AFLAGS} ${KBUILD_AFLAGS_KERNEL} \ |
| 88 | 90 | ${NOSTDINC_FLAGS} ${LINUXINCLUDE} ${KBUILD_CPPFLAGS}" |
| @@ -4334,8 +4334,10 @@ static int selinux_socket_sock_rcv_skb(struct sock *sk, struct sk_buff *skb) · 4333 unmodified lines | ||
| 4334 | 4334 | } |
| 4335 | 4335 | err = avc_has_perm(sk_sid, peer_sid, SECCLASS_PEER, |
| 4336 | 4336 | PEER__RECV, &ad); |
| 4337 | − if (err) | |
| 4337 | + if (err) { | |
| 4338 | 4338 | selinux_netlbl_err(skb, err, 0); |
| 4339 | + return err; | |
| 4340 | + } | |
| 4339 | 4341 | } |
| 4340 | 4342 | |
| 4341 | 4343 | if (secmark_active) { |
| @@ -5586,11 +5588,11 @@ static int selinux_setprocattr(struct task_struct *p, · 1244 unmodified lines | ||
| 5586 | 5588 | /* Check for ptracing, and update the task SID if ok. |
| 5587 | 5589 | Otherwise, leave SID unchanged and fail. */ |
| 5588 | 5590 | ptsid = 0; |
| 5589 | − task_lock(p); | |
| 5591 | + rcu_read_lock(); | |
| 5590 | 5592 | tracer = ptrace_parent(p); |
| 5591 | 5593 | if (tracer) |
| 5592 | 5594 | ptsid = task_sid(tracer); |
| 5593 | − task_unlock(p); | |
| 5595 | + rcu_read_unlock(); | |
| 5594 | 5596 | |
| 5595 | 5597 | if (tracer) { |
| 5596 | 5598 | error = avc_has_perm(ptsid, sid, SECCLASS_PROCESS, |
| @@ -1937,6 +1937,8 @@ static int wait_for_avail(struct snd_pcm_substream *substream, · 1936 unmodified lines | ||
| 1937 | 1937 | case SNDRV_PCM_STATE_DISCONNECTED: |
| 1938 | 1938 | err = -EBADFD; |
| 1939 | 1939 | goto _endloop; |
| 1940 | + case SNDRV_PCM_STATE_PAUSED: | |
| 1941 | + continue; | |
| 1940 | 1942 | } |
| 1941 | 1943 | if (!tout) { |
| 1942 | 1944 | snd_printd("%s write error (DMA or IRQ trouble?)\n", |
| @@ -3433,6 +3433,10 @@ static void check_probe_mask(struct azx *chip, int dev) · 3432 unmodified lines | ||
| 3433 | 3433 | * white/black-list for enable_msi |
| 3434 | 3434 | */ |
| 3435 | 3435 | static struct snd_pci_quirk msi_black_list[] = { |
| 3436 | + SND_PCI_QUIRK(0x103c, 0x2191, "HP", 0), /* AMD Hudson */ | |
| 3437 | + SND_PCI_QUIRK(0x103c, 0x2192, "HP", 0), /* AMD Hudson */ | |
| 3438 | + SND_PCI_QUIRK(0x103c, 0x21f7, "HP", 0), /* AMD Hudson */ | |
| 3439 | + SND_PCI_QUIRK(0x103c, 0x21fa, "HP", 0), /* AMD Hudson */ | |
| 3436 | 3440 | SND_PCI_QUIRK(0x1043, 0x81f2, "ASUS", 0), /* Athlon64 X2 + nvidia */ |
| 3437 | 3441 | SND_PCI_QUIRK(0x1043, 0x81f6, "ASUS", 0), /* nvidia */ |
| 3438 | 3442 | SND_PCI_QUIRK(0x1043, 0x822d, "ASUS", 0), /* Athlon64 X2 + nvidia MCP55 */ |
| @@ -4247,12 +4247,16 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = { · 4246 unmodified lines | ||
| 4247 | 4247 | SND_PCI_QUIRK(0x1028, 0x0606, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), |
| 4248 | 4248 | SND_PCI_QUIRK(0x1028, 0x0608, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), |
| 4249 | 4249 | SND_PCI_QUIRK(0x1028, 0x0609, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), |
| 4250 | + SND_PCI_QUIRK(0x1028, 0x0610, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), | |
| 4250 | 4251 | SND_PCI_QUIRK(0x1028, 0x0613, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), |
| 4251 | 4252 | SND_PCI_QUIRK(0x1028, 0x0614, "Dell Inspiron 3135", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), |
| 4252 | 4253 | SND_PCI_QUIRK(0x1028, 0x0616, "Dell Vostro 5470", ALC290_FIXUP_MONO_SPEAKERS), |
| 4253 | 4254 | SND_PCI_QUIRK(0x1028, 0x061f, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE), |
| 4255 | + SND_PCI_QUIRK(0x1028, 0x0629, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), | |
| 4254 | 4256 | SND_PCI_QUIRK(0x1028, 0x0638, "Dell Inspiron 5439", ALC290_FIXUP_MONO_SPEAKERS), |
| 4257 | + SND_PCI_QUIRK(0x1028, 0x063e, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), | |
| 4255 | 4258 | SND_PCI_QUIRK(0x1028, 0x063f, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE), |
| 4259 | + SND_PCI_QUIRK(0x1028, 0x0640, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE), | |
| 4256 | 4260 | SND_PCI_QUIRK(0x1028, 0x15cc, "Dell X5 Precision", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE), |
| 4257 | 4261 | SND_PCI_QUIRK(0x1028, 0x15cd, "Dell X5 Precision", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE), |
| 4258 | 4262 | SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC2), |
| @@ -648,7 +648,7 @@ static int atmel_ssc_prepare(struct snd_pcm_substream *substream, · 647 unmodified lines | ||
| 648 | 648 | |
| 649 | 649 | dma_params = ssc_p->dma_params[dir]; |
| 650 | 650 | |
| 651 | − ssc_writel(ssc_p->ssc->regs, CR, dma_params->mask->ssc_enable); | |
| 651 | + ssc_writel(ssc_p->ssc->regs, CR, dma_params->mask->ssc_disable); | |
| 652 | 652 | ssc_writel(ssc_p->ssc->regs, IDR, dma_params->mask->ssc_error); |
| 653 | 653 | |
| 654 | 654 | pr_debug("%s enabled SSC_SR=0x%08x\n", |
| @@ -657,6 +657,33 @@ static int atmel_ssc_prepare(struct snd_pcm_substream *substream, · 2 unmodified lines | ||
| 657 | 657 | return 0; |
| 658 | 658 | } |
| 659 | 659 | |
| 660 | +static int atmel_ssc_trigger(struct snd_pcm_substream *substream, | |
| 661 | + int cmd, struct snd_soc_dai *dai) | |
| 662 | +{ | |
| 663 | + struct atmel_ssc_info *ssc_p = &ssc_info[dai->id]; | |
| 664 | + struct atmel_pcm_dma_params *dma_params; | |
| 665 | + int dir; | |
| 666 | + | |
| 667 | + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) | |
| 668 | + dir = 0; | |
| 669 | + else | |
| 670 | + dir = 1; | |
| 671 | + | |
| 672 | + dma_params = ssc_p->dma_params[dir]; | |
| 673 | + | |
| 674 | + switch (cmd) { | |
| 675 | + case SNDRV_PCM_TRIGGER_START: | |
| 676 | + case SNDRV_PCM_TRIGGER_RESUME: | |
| 677 | + case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: | |
| 678 | + ssc_writel(ssc_p->ssc->regs, CR, dma_params->mask->ssc_enable); | |
| 679 | + break; | |
| 680 | + default: | |
| 681 | + ssc_writel(ssc_p->ssc->regs, CR, dma_params->mask->ssc_disable); | |
| 682 | + break; | |
| 683 | + } | |
| 684 | + | |
| 685 | + return 0; | |
| 686 | +} | |
| 660 | 687 | |
| 661 | 688 | #ifdef CONFIG_PM |
| 662 | 689 | static int atmel_ssc_suspend(struct snd_soc_dai *cpu_dai) |
| @@ -731,6 +758,7 @@ static const struct snd_soc_dai_ops atmel_ssc_dai_ops = { · 68 unmodified lines | ||
| 731 | 758 | .startup = atmel_ssc_startup, |
| 732 | 759 | .shutdown = atmel_ssc_shutdown, |
| 733 | 760 | .prepare = atmel_ssc_prepare, |
| 761 | + .trigger = atmel_ssc_trigger, | |
| 734 | 762 | .hw_params = atmel_ssc_hw_params, |
| 735 | 763 | .set_fmt = atmel_ssc_set_dai_fmt, |
| 736 | 764 | .set_clkdiv = atmel_ssc_set_dai_clkdiv, |
| @@ -109,7 +109,7 @@ static int sam9x5_wm8731_driver_probe(struct platform_device *pdev) · 108 unmodified lines | ||
| 109 | 109 | dai->stream_name = "WM8731 PCM"; |
| 110 | 110 | dai->codec_dai_name = "wm8731-hifi"; |
| 111 | 111 | dai->init = sam9x5_wm8731_init; |
| 112 | − dai->dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | |
| 112 | + dai->dai_fmt = SND_SOC_DAIFMT_DSP_A | SND_SOC_DAIFMT_NB_NF | |
| 113 | 113 | | SND_SOC_DAIFMT_CBM_CFM; |
| 114 | 114 | |
| 115 | 115 | ret = snd_soc_of_parse_card_name(card, "atmel,model"); |
| @@ -1012,7 +1012,7 @@ static const struct snd_soc_dapm_route wm5110_dapm_routes[] = { · 1011 unmodified lines | ||
| 1012 | 1012 | { "AEC Loopback", "HPOUT3L", "OUT3L" }, |
| 1013 | 1013 | { "AEC Loopback", "HPOUT3R", "OUT3R" }, |
| 1014 | 1014 | { "HPOUT3L", NULL, "OUT3L" }, |
| 1015 | − { "HPOUT3R", NULL, "OUT3L" }, | |
| 1015 | + { "HPOUT3R", NULL, "OUT3R" }, | |
| 1016 | 1016 | |
| 1017 | 1017 | { "AEC Loopback", "SPKOUTL", "OUT4L" }, |
| 1018 | 1018 | { "SPKOUTLN", NULL, "OUT4L" }, |
| @@ -1444,7 +1444,7 @@ static int wm8904_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) · 1443 unmodified lines | ||
| 1444 | 1444 | |
| 1445 | 1445 | switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { |
| 1446 | 1446 | case SND_SOC_DAIFMT_DSP_B: |
| 1447 | − aif1 |= WM8904_AIF_LRCLK_INV; | |
| 1447 | + aif1 |= 0x3 | WM8904_AIF_LRCLK_INV; | |
| 1448 | 1448 | case SND_SOC_DAIFMT_DSP_A: |
| 1449 | 1449 | aif1 |= 0x3; |
| 1450 | 1450 | break; |
| @@ -2439,7 +2439,20 @@ static void wm8962_configure_bclk(struct snd_soc_codec *codec) · 2438 unmodified lines | ||
| 2439 | 2439 | snd_soc_update_bits(codec, WM8962_CLOCKING_4, |
| 2440 | 2440 | WM8962_SYSCLK_RATE_MASK, clocking4); |
| 2441 | 2441 | |
| 2442 | + /* DSPCLK_DIV can be only generated correctly after enabling SYSCLK. | |
| 2443 | + * So we here provisionally enable it and then disable it afterward | |
| 2444 | + * if current bias_level hasn't reached SND_SOC_BIAS_ON. | |
| 2445 | + */ | |
| 2446 | + if (codec->dapm.bias_level != SND_SOC_BIAS_ON) | |
| 2447 | + snd_soc_update_bits(codec, WM8962_CLOCKING2, | |
| 2448 | + WM8962_SYSCLK_ENA_MASK, WM8962_SYSCLK_ENA); | |
| 2449 | + | |
| 2442 | 2450 | dspclk = snd_soc_read(codec, WM8962_CLOCKING1); |
| 2451 | + | |
| 2452 | + if (codec->dapm.bias_level != SND_SOC_BIAS_ON) | |
| 2453 | + snd_soc_update_bits(codec, WM8962_CLOCKING2, | |
| 2454 | + WM8962_SYSCLK_ENA_MASK, 0); | |
| 2455 | + | |
| 2443 | 2456 | if (dspclk < 0) { |
| 2444 | 2457 | dev_err(codec->dev, "Failed to read DSPCLK: %d\n", dspclk); |
| 2445 | 2458 | return; |
| @@ -1474,13 +1474,17 @@ static int wm_adsp2_ena(struct wm_adsp *dsp) · 1473 unmodified lines | ||
| 1474 | 1474 | return ret; |
| 1475 | 1475 | |
| 1476 | 1476 | /* Wait for the RAM to start, should be near instantaneous */ |
| 1477 | − count = 0; | |
| 1478 | − do { | |
| 1477 | + for (count = 0; count < 10; ++count) { | |
| 1479 | 1478 | ret = regmap_read(dsp->regmap, dsp->base + ADSP2_STATUS1, |
| 1480 | 1479 | &val); |
| 1481 | 1480 | if (ret != 0) |
| 1482 | 1481 | return ret; |
| 1483 | − } while (!(val & ADSP2_RAM_RDY) && ++count < 10); | |
| 1482 | + | |
| 1483 | + if (val & ADSP2_RAM_RDY) | |
| 1484 | + break; | |
| 1485 | + | |
| 1486 | + msleep(1); | |
| 1487 | + } | |
| 1484 | 1488 | |
| 1485 | 1489 | if (!(val & ADSP2_RAM_RDY)) { |
| 1486 | 1490 | adsp_err(dsp, "Failed to start DSP RAM\n"); |
| @@ -130,8 +130,6 @@ static int imx_wm8962_set_bias_level(struct snd_soc_card *card, · 129 unmodified lines | ||
| 130 | 130 | break; |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | − dapm->bias_level = level; | |
| 134 | − | |
| 135 | 133 | return 0; |
| 136 | 134 | } |
| 137 | 135 | |
| @@ -473,17 +473,17 @@ static struct snd_soc_dai_driver kirkwood_i2s_dai_extclk[2] = { · 472 unmodified lines | ||
| 473 | 473 | .playback = { |
| 474 | 474 | .channels_min = 1, |
| 475 | 475 | .channels_max = 2, |
| 476 | − .rates = SNDRV_PCM_RATE_8000_192000 | | |
| 477 | − SNDRV_PCM_RATE_CONTINUOUS | | |
| 478 | − SNDRV_PCM_RATE_KNOT, | |
| 476 | + .rates = SNDRV_PCM_RATE_CONTINUOUS, | |
| 477 | + .rate_min = 5512, | |
| 478 | + .rate_max = 192000, | |
| 479 | 479 | .formats = KIRKWOOD_I2S_FORMATS, |
| 480 | 480 | }, |
| 481 | 481 | .capture = { |
| 482 | 482 | .channels_min = 1, |
| 483 | 483 | .channels_max = 2, |
| 484 | − .rates = SNDRV_PCM_RATE_8000_192000 | | |
| 485 | − SNDRV_PCM_RATE_CONTINUOUS | | |
| 486 | − SNDRV_PCM_RATE_KNOT, | |
| 484 | + .rates = SNDRV_PCM_RATE_CONTINUOUS, | |
| 485 | + .rate_min = 5512, | |
| 486 | + .rate_max = 192000, | |
| 487 | 487 | .formats = KIRKWOOD_I2S_FORMATS, |
| 488 | 488 | }, |
| 489 | 489 | .ops = &kirkwood_i2s_dai_ops, |
| @@ -494,17 +494,17 @@ static struct snd_soc_dai_driver kirkwood_i2s_dai_extclk[2] = { · 4 unmodified lines | ||
| 494 | 494 | .playback = { |
| 495 | 495 | .channels_min = 1, |
| 496 | 496 | .channels_max = 2, |
| 497 | − .rates = SNDRV_PCM_RATE_8000_192000 | | |
| 498 | − SNDRV_PCM_RATE_CONTINUOUS | | |
| 499 | − SNDRV_PCM_RATE_KNOT, | |
| 497 | + .rates = SNDRV_PCM_RATE_CONTINUOUS, | |
| 498 | + .rate_min = 5512, | |
| 499 | + .rate_max = 192000, | |
| 500 | 500 | .formats = KIRKWOOD_SPDIF_FORMATS, |
| 501 | 501 | }, |
| 502 | 502 | .capture = { |
| 503 | 503 | .channels_min = 1, |
| 504 | 504 | .channels_max = 2, |
| 505 | − .rates = SNDRV_PCM_RATE_8000_192000 | | |
| 506 | − SNDRV_PCM_RATE_CONTINUOUS | | |
| 507 | − SNDRV_PCM_RATE_KNOT, | |
| 505 | + .rates = SNDRV_PCM_RATE_CONTINUOUS, | |
| 506 | + .rate_min = 5512, | |
| 507 | + .rate_max = 192000, | |
| 508 | 508 | .formats = KIRKWOOD_SPDIF_FORMATS, |
| 509 | 509 | }, |
| 510 | 510 | .ops = &kirkwood_i2s_dai_ops, |
| @@ -305,6 +305,20 @@ static void dmaengine_pcm_request_chan_of(struct dmaengine_pcm *pcm, · 304 unmodified lines | ||
| 305 | 305 | } |
| 306 | 306 | } |
| 307 | 307 | |
| 308 | +static void dmaengine_pcm_release_chan(struct dmaengine_pcm *pcm) | |
| 309 | +{ | |
| 310 | + unsigned int i; | |
| 311 | + | |
| 312 | + for (i = SNDRV_PCM_STREAM_PLAYBACK; i <= SNDRV_PCM_STREAM_CAPTURE; | |
| 313 | + i++) { | |
| 314 | + if (!pcm->chan[i]) | |
| 315 | + continue; | |
| 316 | + dma_release_channel(pcm->chan[i]); | |
| 317 | + if (pcm->flags & SND_DMAENGINE_PCM_FLAG_HALF_DUPLEX) | |
| 318 | + break; | |
| 319 | + } | |
| 320 | +} | |
| 321 | + | |
| 308 | 322 | /** |
| 309 | 323 | * snd_dmaengine_pcm_register - Register a dmaengine based PCM device |
| 310 | 324 | * @dev: The parent device for the PCM device |
| @@ -315,6 +329,7 @@ int snd_dmaengine_pcm_register(struct device *dev, · 4 unmodified lines | ||
| 315 | 329 | const struct snd_dmaengine_pcm_config *config, unsigned int flags) |
| 316 | 330 | { |
| 317 | 331 | struct dmaengine_pcm *pcm; |
| 332 | + int ret; | |
| 318 | 333 | |
| 319 | 334 | pcm = kzalloc(sizeof(*pcm), GFP_KERNEL); |
| 320 | 335 | if (!pcm) |
| @@ -326,11 +341,20 @@ int snd_dmaengine_pcm_register(struct device *dev, · 5 unmodified lines | ||
| 326 | 341 | dmaengine_pcm_request_chan_of(pcm, dev); |
| 327 | 342 | |
| 328 | 343 | if (flags & SND_DMAENGINE_PCM_FLAG_NO_RESIDUE) |
| 329 | − return snd_soc_add_platform(dev, &pcm->platform, | |
| 344 | + ret = snd_soc_add_platform(dev, &pcm->platform, | |
| 330 | 345 | &dmaengine_no_residue_pcm_platform); |
| 331 | 346 | else |
| 332 | − return snd_soc_add_platform(dev, &pcm->platform, | |
| 347 | + ret = snd_soc_add_platform(dev, &pcm->platform, | |
| 333 | 348 | &dmaengine_pcm_platform); |
| 349 | + if (ret) | |
| 350 | + goto err_free_dma; | |
| 351 | + | |
| 352 | + return 0; | |
| 353 | + | |
| 354 | +err_free_dma: | |
| 355 | + dmaengine_pcm_release_chan(pcm); | |
| 356 | + kfree(pcm); | |
| 357 | + return ret; | |
| 334 | 358 | } |
| 335 | 359 | EXPORT_SYMBOL_GPL(snd_dmaengine_pcm_register); |
| 336 | 360 | |
| @@ -345,7 +369,6 @@ void snd_dmaengine_pcm_unregister(struct device *dev) · 8 unmodified lines | ||
| 345 | 369 | { |
| 346 | 370 | struct snd_soc_platform *platform; |
| 347 | 371 | struct dmaengine_pcm *pcm; |
| 348 | − unsigned int i; | |
| 349 | 372 | |
| 350 | 373 | platform = snd_soc_lookup_platform(dev); |
| 351 | 374 | if (!platform) |
| @@ -353,15 +376,8 @@ void snd_dmaengine_pcm_unregister(struct device *dev) · 1 unmodified line | ||
| 353 | 376 | |
| 354 | 377 | pcm = soc_platform_to_pcm(platform); |
| 355 | 378 | |
| 356 | − for (i = SNDRV_PCM_STREAM_PLAYBACK; i <= SNDRV_PCM_STREAM_CAPTURE; i++) { | |
| 357 | − if (pcm->chan[i]) { | |
| 358 | − dma_release_channel(pcm->chan[i]); | |
| 359 | − if (pcm->flags & SND_DMAENGINE_PCM_FLAG_HALF_DUPLEX) | |
| 360 | − break; | |
| 361 | − } | |
| 362 | − } | |
| 363 | − | |
| 364 | 379 | snd_soc_remove_platform(platform); |
| 380 | + dmaengine_pcm_release_chan(pcm); | |
| 365 | 381 | kfree(pcm); |
| 366 | 382 | } |
| 367 | 383 | EXPORT_SYMBOL_GPL(snd_dmaengine_pcm_unregister); |
| @@ -600,12 +600,13 @@ static int soc_pcm_hw_free(struct snd_pcm_substream *substream) · 599 unmodified lines | ||
| 600 | 600 | struct snd_soc_platform *platform = rtd->platform; |
| 601 | 601 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; |
| 602 | 602 | struct snd_soc_dai *codec_dai = rtd->codec_dai; |
| 603 | − struct snd_soc_codec *codec = rtd->codec; | |
| 603 | + bool playback = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; | |
| 604 | 604 | |
| 605 | 605 | mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass); |
| 606 | 606 | |
| 607 | 607 | /* apply codec digital mute */ |
| 608 | − if (!codec->active) | |
| 608 | + if ((playback && codec_dai->playback_active == 1) || | |
| 609 | + (!playback && codec_dai->capture_active == 1)) | |
| 609 | 610 | snd_soc_dai_digital_mute(codec_dai, 1, substream->stream); |
| 610 | 611 | |
| 611 | 612 | /* free any machine hw params */ |
| @@ -74,7 +74,7 @@ static int tegra20_i2s_set_fmt(struct snd_soc_dai *dai, · 73 unmodified lines | ||
| 74 | 74 | unsigned int fmt) |
| 75 | 75 | { |
| 76 | 76 | struct tegra20_i2s *i2s = snd_soc_dai_get_drvdata(dai); |
| 77 | − unsigned int mask, val; | |
| 77 | + unsigned int mask = 0, val = 0; | |
| 78 | 78 | |
| 79 | 79 | switch (fmt & SND_SOC_DAIFMT_INV_MASK) { |
| 80 | 80 | case SND_SOC_DAIFMT_NB_NF: |
| @@ -83,10 +83,10 @@ static int tegra20_i2s_set_fmt(struct snd_soc_dai *dai, · 2 unmodified lines | ||
| 83 | 83 | return -EINVAL; |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | − mask = TEGRA20_I2S_CTRL_MASTER_ENABLE; | |
| 86 | + mask |= TEGRA20_I2S_CTRL_MASTER_ENABLE; | |
| 87 | 87 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { |
| 88 | 88 | case SND_SOC_DAIFMT_CBS_CFS: |
| 89 | − val = TEGRA20_I2S_CTRL_MASTER_ENABLE; | |
| 89 | + val |= TEGRA20_I2S_CTRL_MASTER_ENABLE; | |
| 90 | 90 | break; |
| 91 | 91 | case SND_SOC_DAIFMT_CBM_CFM: |
| 92 | 92 | break; |
| @@ -67,15 +67,15 @@ static int tegra20_spdif_hw_params(struct snd_pcm_substream *substream, · 66 unmodified lines | ||
| 67 | 67 | { |
| 68 | 68 | struct device *dev = dai->dev; |
| 69 | 69 | struct tegra20_spdif *spdif = snd_soc_dai_get_drvdata(dai); |
| 70 | − unsigned int mask, val; | |
| 70 | + unsigned int mask = 0, val = 0; | |
| 71 | 71 | int ret, spdifclock; |
| 72 | 72 | |
| 73 | − mask = TEGRA20_SPDIF_CTRL_PACK | | |
| 74 | − TEGRA20_SPDIF_CTRL_BIT_MODE_MASK; | |
| 73 | + mask |= TEGRA20_SPDIF_CTRL_PACK | | |
| 74 | + TEGRA20_SPDIF_CTRL_BIT_MODE_MASK; | |
| 75 | 75 | switch (params_format(params)) { |
| 76 | 76 | case SNDRV_PCM_FORMAT_S16_LE: |
| 77 | − val = TEGRA20_SPDIF_CTRL_PACK | | |
| 78 | − TEGRA20_SPDIF_CTRL_BIT_MODE_16BIT; | |
| 77 | + val |= TEGRA20_SPDIF_CTRL_PACK | | |
| 78 | + TEGRA20_SPDIF_CTRL_BIT_MODE_16BIT; | |
| 79 | 79 | break; |
| 80 | 80 | default: |
| 81 | 81 | return -EINVAL; |
| @@ -118,7 +118,7 @@ static int tegra30_i2s_set_fmt(struct snd_soc_dai *dai, · 117 unmodified lines | ||
| 118 | 118 | unsigned int fmt) |
| 119 | 119 | { |
| 120 | 120 | struct tegra30_i2s *i2s = snd_soc_dai_get_drvdata(dai); |
| 121 | − unsigned int mask, val; | |
| 121 | + unsigned int mask = 0, val = 0; | |
| 122 | 122 | |
| 123 | 123 | switch (fmt & SND_SOC_DAIFMT_INV_MASK) { |
| 124 | 124 | case SND_SOC_DAIFMT_NB_NF: |
| @@ -127,10 +127,10 @@ static int tegra30_i2s_set_fmt(struct snd_soc_dai *dai, · 2 unmodified lines | ||
| 127 | 127 | return -EINVAL; |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | − mask = TEGRA30_I2S_CTRL_MASTER_ENABLE; | |
| 130 | + mask |= TEGRA30_I2S_CTRL_MASTER_ENABLE; | |
| 131 | 131 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { |
| 132 | 132 | case SND_SOC_DAIFMT_CBS_CFS: |
| 133 | − val = TEGRA30_I2S_CTRL_MASTER_ENABLE; | |
| 133 | + val |= TEGRA30_I2S_CTRL_MASTER_ENABLE; | |
| 134 | 134 | break; |
| 135 | 135 | case SND_SOC_DAIFMT_CBM_CFM: |
| 136 | 136 | break; |
| @@ -18,9 +18,9 @@ · 17 unmodified lines | ||
| 18 | 18 | #include "helpers/bitmask.h" |
| 19 | 19 | |
| 20 | 20 | static struct option set_opts[] = { |
| 21 | − { .name = "perf-bias", .has_arg = optional_argument, .flag = NULL, .val = 'b'}, | |
| 22 | − { .name = "sched-mc", .has_arg = optional_argument, .flag = NULL, .val = 'm'}, | |
| 23 | − { .name = "sched-smt", .has_arg = optional_argument, .flag = NULL, .val = 's'}, | |
| 21 | + { .name = "perf-bias", .has_arg = required_argument, .flag = NULL, .val = 'b'}, | |
| 22 | + { .name = "sched-mc", .has_arg = required_argument, .flag = NULL, .val = 'm'}, | |
| 23 | + { .name = "sched-smt", .has_arg = required_argument, .flag = NULL, .val = 's'}, | |
| 24 | 24 | { }, |
| 25 | 25 | }; |
| 26 | 26 | |