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

Merge tag 'v3.10-rc2' into asoc-ux500

Linux 3.10-rc2

+3976 -2876
Documentation/devicetree/bindings/drm/exynos/hdmi.txt Documentation/devicetree/bindings/video/exynos_hdmi.txt
Documentation/devicetree/bindings/drm/exynos/hdmiddc.txt Documentation/devicetree/bindings/video/exynos_hdmiddc.txt
Documentation/devicetree/bindings/drm/exynos/hdmiphy.txt Documentation/devicetree/bindings/video/exynos_hdmiphy.txt
Documentation/devicetree/bindings/drm/exynos/mixer.txt Documentation/devicetree/bindings/video/exynos_mixer.txt
+5 -3
Documentation/devicetree/usage-model.txt
··· 191 191 }; 192 192 193 193 The bootargs property contains the kernel arguments, and the initrd-* 194 - properties define the address and size of an initrd blob. The 195 - chosen node may also optionally contain an arbitrary number of 196 - additional properties for platform-specific configuration data. 194 + properties define the address and size of an initrd blob. Note that 195 + initrd-end is the first address after the initrd image, so this doesn't 196 + match the usual semantic of struct resource. The chosen node may also 197 + optionally contain an arbitrary number of additional properties for 198 + platform-specific configuration data. 197 199 198 200 During early boot, the architecture setup code calls of_scan_flat_dt() 199 201 several times with different helper callbacks to parse device tree
+21
Documentation/kernel-parameters.txt
··· 3005 3005 Force threading of all interrupt handlers except those 3006 3006 marked explicitly IRQF_NO_THREAD. 3007 3007 3008 + tmem [KNL,XEN] 3009 + Enable the Transcendent memory driver if built-in. 3010 + 3011 + tmem.cleancache=0|1 [KNL, XEN] 3012 + Default is on (1). Disable the usage of the cleancache 3013 + API to send anonymous pages to the hypervisor. 3014 + 3015 + tmem.frontswap=0|1 [KNL, XEN] 3016 + Default is on (1). Disable the usage of the frontswap 3017 + API to send swap pages to the hypervisor. If disabled 3018 + the selfballooning and selfshrinking are force disabled. 3019 + 3020 + tmem.selfballooning=0|1 [KNL, XEN] 3021 + Default is on (1). Disable the driving of swap pages 3022 + to the hypervisor. 3023 + 3024 + tmem.selfshrinking=0|1 [KNL, XEN] 3025 + Default is on (1). Partial swapoff that immediately 3026 + transfers pages from Xen hypervisor back to the 3027 + kernel based on different criteria. 3028 + 3008 3029 topology= [S390] 3009 3030 Format: {off | on} 3010 3031 Specify if the kernel should make use of the cpu
+202
Documentation/kernel-per-CPU-kthreads.txt
··· 1 + REDUCING OS JITTER DUE TO PER-CPU KTHREADS 2 + 3 + This document lists per-CPU kthreads in the Linux kernel and presents 4 + options to control their OS jitter. Note that non-per-CPU kthreads are 5 + not listed here. To reduce OS jitter from non-per-CPU kthreads, bind 6 + them to a "housekeeping" CPU dedicated to such work. 7 + 8 + 9 + REFERENCES 10 + 11 + o Documentation/IRQ-affinity.txt: Binding interrupts to sets of CPUs. 12 + 13 + o Documentation/cgroups: Using cgroups to bind tasks to sets of CPUs. 14 + 15 + o man taskset: Using the taskset command to bind tasks to sets 16 + of CPUs. 17 + 18 + o man sched_setaffinity: Using the sched_setaffinity() system 19 + call to bind tasks to sets of CPUs. 20 + 21 + o /sys/devices/system/cpu/cpuN/online: Control CPU N's hotplug state, 22 + writing "0" to offline and "1" to online. 23 + 24 + o In order to locate kernel-generated OS jitter on CPU N: 25 + 26 + cd /sys/kernel/debug/tracing 27 + echo 1 > max_graph_depth # Increase the "1" for more detail 28 + echo function_graph > current_tracer 29 + # run workload 30 + cat per_cpu/cpuN/trace 31 + 32 + 33 + KTHREADS 34 + 35 + Name: ehca_comp/%u 36 + Purpose: Periodically process Infiniband-related work. 37 + To reduce its OS jitter, do any of the following: 38 + 1. Don't use eHCA Infiniband hardware, instead choosing hardware 39 + that does not require per-CPU kthreads. This will prevent these 40 + kthreads from being created in the first place. (This will 41 + work for most people, as this hardware, though important, is 42 + relatively old and is produced in relatively low unit volumes.) 43 + 2. Do all eHCA-Infiniband-related work on other CPUs, including 44 + interrupts. 45 + 3. Rework the eHCA driver so that its per-CPU kthreads are 46 + provisioned only on selected CPUs. 47 + 48 + 49 + Name: irq/%d-%s 50 + Purpose: Handle threaded interrupts. 51 + To reduce its OS jitter, do the following: 52 + 1. Use irq affinity to force the irq threads to execute on 53 + some other CPU. 54 + 55 + Name: kcmtpd_ctr_%d 56 + Purpose: Handle Bluetooth work. 57 + To reduce its OS jitter, do one of the following: 58 + 1. Don't use Bluetooth, in which case these kthreads won't be 59 + created in the first place. 60 + 2. Use irq affinity to force Bluetooth-related interrupts to 61 + occur on some other CPU and furthermore initiate all 62 + Bluetooth activity on some other CPU. 63 + 64 + Name: ksoftirqd/%u 65 + Purpose: Execute softirq handlers when threaded or when under heavy load. 66 + To reduce its OS jitter, each softirq vector must be handled 67 + separately as follows: 68 + TIMER_SOFTIRQ: Do all of the following: 69 + 1. To the extent possible, keep the CPU out of the kernel when it 70 + is non-idle, for example, by avoiding system calls and by forcing 71 + both kernel threads and interrupts to execute elsewhere. 72 + 2. Build with CONFIG_HOTPLUG_CPU=y. After boot completes, force 73 + the CPU offline, then bring it back online. This forces 74 + recurring timers to migrate elsewhere. If you are concerned 75 + with multiple CPUs, force them all offline before bringing the 76 + first one back online. Once you have onlined the CPUs in question, 77 + do not offline any other CPUs, because doing so could force the 78 + timer back onto one of the CPUs in question. 79 + NET_TX_SOFTIRQ and NET_RX_SOFTIRQ: Do all of the following: 80 + 1. Force networking interrupts onto other CPUs. 81 + 2. Initiate any network I/O on other CPUs. 82 + 3. Once your application has started, prevent CPU-hotplug operations 83 + from being initiated from tasks that might run on the CPU to 84 + be de-jittered. (It is OK to force this CPU offline and then 85 + bring it back online before you start your application.) 86 + BLOCK_SOFTIRQ: Do all of the following: 87 + 1. Force block-device interrupts onto some other CPU. 88 + 2. Initiate any block I/O on other CPUs. 89 + 3. Once your application has started, prevent CPU-hotplug operations 90 + from being initiated from tasks that might run on the CPU to 91 + be de-jittered. (It is OK to force this CPU offline and then 92 + bring it back online before you start your application.) 93 + BLOCK_IOPOLL_SOFTIRQ: Do all of the following: 94 + 1. Force block-device interrupts onto some other CPU. 95 + 2. Initiate any block I/O and block-I/O polling on other CPUs. 96 + 3. Once your application has started, prevent CPU-hotplug operations 97 + from being initiated from tasks that might run on the CPU to 98 + be de-jittered. (It is OK to force this CPU offline and then 99 + bring it back online before you start your application.) 100 + TASKLET_SOFTIRQ: Do one or more of the following: 101 + 1. Avoid use of drivers that use tasklets. (Such drivers will contain 102 + calls to things like tasklet_schedule().) 103 + 2. Convert all drivers that you must use from tasklets to workqueues. 104 + 3. Force interrupts for drivers using tasklets onto other CPUs, 105 + and also do I/O involving these drivers on other CPUs. 106 + SCHED_SOFTIRQ: Do all of the following: 107 + 1. Avoid sending scheduler IPIs to the CPU to be de-jittered, 108 + for example, ensure that at most one runnable kthread is present 109 + on that CPU. If a thread that expects to run on the de-jittered 110 + CPU awakens, the scheduler will send an IPI that can result in 111 + a subsequent SCHED_SOFTIRQ. 112 + 2. Build with CONFIG_RCU_NOCB_CPU=y, CONFIG_RCU_NOCB_CPU_ALL=y, 113 + CONFIG_NO_HZ_FULL=y, and, in addition, ensure that the CPU 114 + to be de-jittered is marked as an adaptive-ticks CPU using the 115 + "nohz_full=" boot parameter. This reduces the number of 116 + scheduler-clock interrupts that the de-jittered CPU receives, 117 + minimizing its chances of being selected to do the load balancing 118 + work that runs in SCHED_SOFTIRQ context. 119 + 3. To the extent possible, keep the CPU out of the kernel when it 120 + is non-idle, for example, by avoiding system calls and by 121 + forcing both kernel threads and interrupts to execute elsewhere. 122 + This further reduces the number of scheduler-clock interrupts 123 + received by the de-jittered CPU. 124 + HRTIMER_SOFTIRQ: Do all of the following: 125 + 1. To the extent possible, keep the CPU out of the kernel when it 126 + is non-idle. For example, avoid system calls and force both 127 + kernel threads and interrupts to execute elsewhere. 128 + 2. Build with CONFIG_HOTPLUG_CPU=y. Once boot completes, force the 129 + CPU offline, then bring it back online. This forces recurring 130 + timers to migrate elsewhere. If you are concerned with multiple 131 + CPUs, force them all offline before bringing the first one 132 + back online. Once you have onlined the CPUs in question, do not 133 + offline any other CPUs, because doing so could force the timer 134 + back onto one of the CPUs in question. 135 + RCU_SOFTIRQ: Do at least one of the following: 136 + 1. Offload callbacks and keep the CPU in either dyntick-idle or 137 + adaptive-ticks state by doing all of the following: 138 + a. Build with CONFIG_RCU_NOCB_CPU=y, CONFIG_RCU_NOCB_CPU_ALL=y, 139 + CONFIG_NO_HZ_FULL=y, and, in addition ensure that the CPU 140 + to be de-jittered is marked as an adaptive-ticks CPU using 141 + the "nohz_full=" boot parameter. Bind the rcuo kthreads 142 + to housekeeping CPUs, which can tolerate OS jitter. 143 + b. To the extent possible, keep the CPU out of the kernel 144 + when it is non-idle, for example, by avoiding system 145 + calls and by forcing both kernel threads and interrupts 146 + to execute elsewhere. 147 + 2. Enable RCU to do its processing remotely via dyntick-idle by 148 + doing all of the following: 149 + a. Build with CONFIG_NO_HZ=y and CONFIG_RCU_FAST_NO_HZ=y. 150 + b. Ensure that the CPU goes idle frequently, allowing other 151 + CPUs to detect that it has passed through an RCU quiescent 152 + state. If the kernel is built with CONFIG_NO_HZ_FULL=y, 153 + userspace execution also allows other CPUs to detect that 154 + the CPU in question has passed through a quiescent state. 155 + c. To the extent possible, keep the CPU out of the kernel 156 + when it is non-idle, for example, by avoiding system 157 + calls and by forcing both kernel threads and interrupts 158 + to execute elsewhere. 159 + 160 + Name: rcuc/%u 161 + Purpose: Execute RCU callbacks in CONFIG_RCU_BOOST=y kernels. 162 + To reduce its OS jitter, do at least one of the following: 163 + 1. Build the kernel with CONFIG_PREEMPT=n. This prevents these 164 + kthreads from being created in the first place, and also obviates 165 + the need for RCU priority boosting. This approach is feasible 166 + for workloads that do not require high degrees of responsiveness. 167 + 2. Build the kernel with CONFIG_RCU_BOOST=n. This prevents these 168 + kthreads from being created in the first place. This approach 169 + is feasible only if your workload never requires RCU priority 170 + boosting, for example, if you ensure frequent idle time on all 171 + CPUs that might execute within the kernel. 172 + 3. Build with CONFIG_RCU_NOCB_CPU=y and CONFIG_RCU_NOCB_CPU_ALL=y, 173 + which offloads all RCU callbacks to kthreads that can be moved 174 + off of CPUs susceptible to OS jitter. This approach prevents the 175 + rcuc/%u kthreads from having any work to do, so that they are 176 + never awakened. 177 + 4. Ensure that the CPU never enters the kernel, and, in particular, 178 + avoid initiating any CPU hotplug operations on this CPU. This is 179 + another way of preventing any callbacks from being queued on the 180 + CPU, again preventing the rcuc/%u kthreads from having any work 181 + to do. 182 + 183 + Name: rcuob/%d, rcuop/%d, and rcuos/%d 184 + Purpose: Offload RCU callbacks from the corresponding CPU. 185 + To reduce its OS jitter, do at least one of the following: 186 + 1. Use affinity, cgroups, or other mechanism to force these kthreads 187 + to execute on some other CPU. 188 + 2. Build with CONFIG_RCU_NOCB_CPUS=n, which will prevent these 189 + kthreads from being created in the first place. However, please 190 + note that this will not eliminate OS jitter, but will instead 191 + shift it to RCU_SOFTIRQ. 192 + 193 + Name: watchdog/%u 194 + Purpose: Detect software lockups on each CPU. 195 + To reduce its OS jitter, do at least one of the following: 196 + 1. Build with CONFIG_LOCKUP_DETECTOR=n, which will prevent these 197 + kthreads from being created in the first place. 198 + 2. Echo a zero to /proc/sys/kernel/watchdog to disable the 199 + watchdog timer. 200 + 3. Echo a large number of /proc/sys/kernel/watchdog_thresh in 201 + order to reduce the frequency of OS jitter due to the watchdog 202 + timer down to a level that is acceptable for your workload.
+8 -7
Documentation/power/devices.txt
··· 268 268 System Power Management Phases 269 269 ------------------------------ 270 270 Suspending or resuming the system is done in several phases. Different phases 271 - are used for standby or memory sleep states ("suspend-to-RAM") and the 271 + are used for freeze, standby, and memory sleep states ("suspend-to-RAM") and the 272 272 hibernation state ("suspend-to-disk"). Each phase involves executing callbacks 273 273 for every device before the next phase begins. Not all busses or classes 274 274 support all these callbacks and not all drivers use all the callbacks. The ··· 309 309 310 310 Entering System Suspend 311 311 ----------------------- 312 - When the system goes into the standby or memory sleep state, the phases are: 312 + When the system goes into the freeze, standby or memory sleep state, 313 + the phases are: 313 314 314 315 prepare, suspend, suspend_late, suspend_noirq. 315 316 ··· 369 368 370 369 Leaving System Suspend 371 370 ---------------------- 372 - When resuming from standby or memory sleep, the phases are: 371 + When resuming from freeze, standby or memory sleep, the phases are: 373 372 374 373 resume_noirq, resume_early, resume, complete. 375 374 ··· 434 433 435 434 Entering Hibernation 436 435 -------------------- 437 - Hibernating the system is more complicated than putting it into the standby or 438 - memory sleep state, because it involves creating and saving a system image. 436 + Hibernating the system is more complicated than putting it into the other 437 + sleep states, because it involves creating and saving a system image. 439 438 Therefore there are more phases for hibernation, with a different set of 440 439 callbacks. These phases always run after tasks have been frozen and memory has 441 440 been freed. ··· 486 485 487 486 At this point the system image is saved, and the devices then need to be 488 487 prepared for the upcoming system shutdown. This is much like suspending them 489 - before putting the system into the standby or memory sleep state, and the phases 490 - are similar. 488 + before putting the system into the freeze, standby or memory sleep state, 489 + and the phases are similar. 491 490 492 491 9. The prepare phase is discussed above. 493 492
+2 -2
Documentation/power/interface.txt
··· 7 7 is mounted at /sys). 8 8 9 9 /sys/power/state controls system power state. Reading from this file 10 - returns what states are supported, which is hard-coded to 'standby' 11 - (Power-On Suspend), 'mem' (Suspend-to-RAM), and 'disk' 10 + returns what states are supported, which is hard-coded to 'freeze', 11 + 'standby' (Power-On Suspend), 'mem' (Suspend-to-RAM), and 'disk' 12 12 (Suspend-to-Disk). 13 13 14 14 Writing to this file one of those strings causes the system to
+4 -2
Documentation/power/notifiers.txt
··· 15 15 The subsystems or drivers having such needs can register suspend notifiers that 16 16 will be called upon the following events by the PM core: 17 17 18 - PM_HIBERNATION_PREPARE The system is going to hibernate or suspend, tasks will 19 - be frozen immediately. 18 + PM_HIBERNATION_PREPARE The system is going to hibernate, tasks will be frozen 19 + immediately. This is different from PM_SUSPEND_PREPARE 20 + below because here we do additional work between notifiers 21 + and drivers freezing. 20 22 21 23 PM_POST_HIBERNATION The system memory state has been restored from a 22 24 hibernation image or an error occurred during
+17 -13
Documentation/power/states.txt
··· 2 2 System Power Management States 3 3 4 4 5 - The kernel supports three power management states generically, though 6 - each is dependent on platform support code to implement the low-level 7 - details for each state. This file describes each state, what they are 5 + The kernel supports four power management states generically, though 6 + one is generic and the other three are dependent on platform support 7 + code to implement the low-level details for each state. 8 + This file describes each state, what they are 8 9 commonly called, what ACPI state they map to, and what string to write 9 10 to /sys/power/state to enter that state 11 + 12 + state: Freeze / Low-Power Idle 13 + ACPI state: S0 14 + String: "freeze" 15 + 16 + This state is a generic, pure software, light-weight, low-power state. 17 + It allows more energy to be saved relative to idle by freezing user 18 + space and putting all I/O devices into low-power states (possibly 19 + lower-power than available at run time), such that the processors can 20 + spend more time in their idle states. 21 + This state can be used for platforms without Standby/Suspend-to-RAM 22 + support, or it can be used in addition to Suspend-to-RAM (memory sleep) 23 + to provide reduced resume latency. 10 24 11 25 12 26 State: Standby / Power-On Suspend ··· 35 21 We try to put devices in a low-power state equivalent to D1, which 36 22 also offers low power savings, but low resume latency. Not all devices 37 23 support D1, and those that don't are left on. 38 - 39 - A transition from Standby to the On state should take about 1-2 40 - seconds. 41 24 42 25 43 26 State: Suspend-to-RAM ··· 52 41 53 42 For at least ACPI, STR requires some minimal boot-strapping code to 54 43 resume the system from STR. This may be true on other platforms. 55 - 56 - A transition from Suspend-to-RAM to the On state should take about 57 - 3-5 seconds. 58 44 59 45 60 46 State: Suspend-to-disk ··· 82 74 down offers greater savings, and allows this mechanism to work on any 83 75 system. However, entering a real low-power state allows the user to 84 76 trigger wake up events (e.g. pressing a key or opening a laptop lid). 85 - 86 - A transition from Suspend-to-Disk to the On state should take about 30 87 - seconds, though it's typically a bit more with the current 88 - implementation.
+15 -1
MAINTAINERS
··· 4976 4976 F: Documentation/hwmon/lm90 4977 4977 F: drivers/hwmon/lm90.c 4978 4978 4979 + LM95234 HARDWARE MONITOR DRIVER 4980 + M: Guenter Roeck <linux@roeck-us.net> 4981 + L: lm-sensors@lm-sensors.org 4982 + S: Maintained 4983 + F: Documentation/hwmon/lm95234 4984 + F: drivers/hwmon/lm95234.c 4985 + 4979 4986 LME2510 MEDIA DRIVER 4980 4987 M: Malcolm Priestley <tvboxspy@gmail.com> 4981 4988 L: linux-media@vger.kernel.org ··· 7861 7854 L: target-devel@vger.kernel.org 7862 7855 L: http://groups.google.com/group/linux-iscsi-target-dev 7863 7856 W: http://www.linux-iscsi.org 7864 - T: git git://git.kernel.org/pub/scm/linux/kernel/git/nab/lio-core.git master 7857 + T: git git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending.git master 7865 7858 S: Supported 7866 7859 F: drivers/target/ 7867 7860 F: include/target/ ··· 8188 8181 F: drivers/mmc/host/sh_mobile_sdhi.c 8189 8182 F: include/linux/mmc/tmio.h 8190 8183 F: include/linux/mmc/sh_mobile_sdhi.h 8184 + 8185 + TMP401 HARDWARE MONITOR DRIVER 8186 + M: Guenter Roeck <linux@roeck-us.net> 8187 + L: lm-sensors@lm-sensors.org 8188 + S: Maintained 8189 + F: Documentation/hwmon/tmp401 8190 + F: drivers/hwmon/tmp401.c 8191 8191 8192 8192 TMPFS (SHMEM FILESYSTEM) 8193 8193 M: Hugh Dickins <hughd@google.com>
+1 -1
Makefile
··· 1 1 VERSION = 3 2 2 PATCHLEVEL = 10 3 3 SUBLEVEL = 0 4 - EXTRAVERSION = -rc1 4 + EXTRAVERSION = -rc2 5 5 NAME = Unicycling Gorilla 6 6 7 7 # *DOCUMENTATION*
+3
arch/Kconfig
··· 213 213 config GENERIC_SMP_IDLE_THREAD 214 214 bool 215 215 216 + config GENERIC_IDLE_POLL_SETUP 217 + bool 218 + 216 219 # Select if arch init_task initializer is different to init/init_task.c 217 220 config ARCH_INIT_TASK 218 221 bool
+2 -1
arch/arm/Kconfig
··· 38 38 select HAVE_GENERIC_HARDIRQS 39 39 select HAVE_HW_BREAKPOINT if (PERF_EVENTS && (CPU_V6 || CPU_V6K || CPU_V7)) 40 40 select HAVE_IDE if PCI || ISA || PCMCIA 41 + select HAVE_IRQ_TIME_ACCOUNTING 41 42 select HAVE_KERNEL_GZIP 42 43 select HAVE_KERNEL_LZMA 43 44 select HAVE_KERNEL_LZO ··· 489 488 config ARCH_DOVE 490 489 bool "Marvell Dove" 491 490 select ARCH_REQUIRE_GPIOLIB 492 - select CPU_V7 491 + select CPU_PJ4 493 492 select GENERIC_CLOCKEVENTS 494 493 select MIGHT_HAVE_PCI 495 494 select PINCTRL
+1 -1
arch/arm/Makefile
··· 309 309 echo ' Image - Uncompressed kernel image (arch/$(ARCH)/boot/Image)' 310 310 echo '* xipImage - XIP kernel image, if configured (arch/$(ARCH)/boot/xipImage)' 311 311 echo ' uImage - U-Boot wrapped zImage' 312 - echo ' bootpImage - Combined zImage and initial RAM disk' 312 + echo ' bootpImage - Combined zImage and initial RAM disk' 313 313 echo ' (supply initrd image via make variable INITRD=<path>)' 314 314 echo '* dtbs - Build device tree blobs for enabled boards' 315 315 echo ' install - Install uncompressed kernel'
-3
arch/arm/common/mcpm_platsmp.c
··· 15 15 #include <linux/smp.h> 16 16 #include <linux/spinlock.h> 17 17 18 - #include <linux/irqchip/arm-gic.h> 19 - 20 18 #include <asm/mcpm.h> 21 19 #include <asm/smp.h> 22 20 #include <asm/smp_plat.h> ··· 47 49 static void __cpuinit mcpm_secondary_init(unsigned int cpu) 48 50 { 49 51 mcpm_cpu_powered_up(); 50 - gic_secondary_init(0); 51 52 } 52 53 53 54 #ifdef CONFIG_HOTPLUG_CPU
+4 -4
arch/arm/include/asm/cmpxchg.h
··· 233 233 ((__typeof__(*(ptr)))atomic64_cmpxchg(container_of((ptr), \ 234 234 atomic64_t, \ 235 235 counter), \ 236 - (unsigned long)(o), \ 237 - (unsigned long)(n))) 236 + (unsigned long long)(o), \ 237 + (unsigned long long)(n))) 238 238 239 239 #define cmpxchg64_local(ptr, o, n) \ 240 240 ((__typeof__(*(ptr)))local64_cmpxchg(container_of((ptr), \ 241 241 local64_t, \ 242 242 a), \ 243 - (unsigned long)(o), \ 244 - (unsigned long)(n))) 243 + (unsigned long long)(o), \ 244 + (unsigned long long)(n))) 245 245 246 246 #endif /* __LINUX_ARM_ARCH__ >= 6 */ 247 247
-5
arch/arm/mach-tegra/tegra2_emc.c
··· 307 307 } 308 308 309 309 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 310 - if (!res) { 311 - dev_err(&pdev->dev, "missing register base\n"); 312 - return -ENOMEM; 313 - } 314 - 315 310 emc_regbase = devm_ioremap_resource(&pdev->dev, res); 316 311 if (IS_ERR(emc_regbase)) 317 312 return PTR_ERR(emc_regbase);
-5
arch/arm/plat-samsung/adc.c
··· 381 381 } 382 382 383 383 regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); 384 - if (!regs) { 385 - dev_err(dev, "failed to find registers\n"); 386 - return -ENXIO; 387 - } 388 - 389 384 adc->regs = devm_ioremap_resource(dev, regs); 390 385 if (IS_ERR(adc->regs)) 391 386 return PTR_ERR(adc->regs);
+14 -19
arch/arm/xen/enlighten.c
··· 152 152 } 153 153 EXPORT_SYMBOL_GPL(xen_unmap_domain_mfn_range); 154 154 155 - static int __init xen_secondary_init(unsigned int cpu) 155 + static void __init xen_percpu_init(void *unused) 156 156 { 157 157 struct vcpu_register_vcpu_info info; 158 158 struct vcpu_info *vcpup; 159 159 int err; 160 + int cpu = get_cpu(); 160 161 161 162 pr_info("Xen: initializing cpu%d\n", cpu); 162 163 vcpup = per_cpu_ptr(xen_vcpu_info, cpu); ··· 166 165 info.offset = offset_in_page(vcpup); 167 166 168 167 err = HYPERVISOR_vcpu_op(VCPUOP_register_vcpu_info, cpu, &info); 169 - if (err) { 170 - pr_debug("register_vcpu_info failed: err=%d\n", err); 171 - } else { 172 - /* This cpu is using the registered vcpu info, even if 173 - later ones fail to. */ 174 - per_cpu(xen_vcpu, cpu) = vcpup; 175 - } 176 - return 0; 168 + BUG_ON(err); 169 + per_cpu(xen_vcpu, cpu) = vcpup; 170 + 171 + enable_percpu_irq(xen_events_irq, 0); 177 172 } 178 173 179 174 static void xen_restart(char str, const char *cmd) ··· 205 208 const char *version = NULL; 206 209 const char *xen_prefix = "xen,xen-"; 207 210 struct resource res; 208 - int i; 209 211 210 212 node = of_find_compatible_node(NULL, NULL, "xen,xen"); 211 213 if (!node) { ··· 261 265 sizeof(struct vcpu_info)); 262 266 if (xen_vcpu_info == NULL) 263 267 return -ENOMEM; 264 - for_each_online_cpu(i) 265 - xen_secondary_init(i); 266 268 267 269 gnttab_init(); 268 270 if (!xen_initial_domain()) 269 271 xenbus_probe(NULL); 270 272 273 + return 0; 274 + } 275 + core_initcall(xen_guest_init); 276 + 277 + static int __init xen_pm_init(void) 278 + { 271 279 pm_power_off = xen_power_off; 272 280 arm_pm_restart = xen_restart; 273 281 274 282 return 0; 275 283 } 276 - core_initcall(xen_guest_init); 284 + subsys_initcall(xen_pm_init); 277 285 278 286 static irqreturn_t xen_arm_callback(int irq, void *arg) 279 287 { 280 288 xen_hvm_evtchn_do_upcall(); 281 289 return IRQ_HANDLED; 282 - } 283 - 284 - static __init void xen_percpu_enable_events(void *unused) 285 - { 286 - enable_percpu_irq(xen_events_irq, 0); 287 290 } 288 291 289 292 static int __init xen_init_events(void) ··· 298 303 return -EINVAL; 299 304 } 300 305 301 - on_each_cpu(xen_percpu_enable_events, NULL, 0); 306 + on_each_cpu(xen_percpu_init, NULL, 0); 302 307 303 308 return 0; 304 309 }
-2
arch/arm64/Kconfig
··· 122 122 123 123 menu "Kernel Features" 124 124 125 - source "kernel/time/Kconfig" 126 - 127 125 config ARM64_64K_PAGES 128 126 bool "Enable 64KB pages support" 129 127 help
+1 -1
arch/arm64/include/asm/assembler.h
··· 82 82 83 83 .macro enable_dbg_if_not_stepping, tmp 84 84 mrs \tmp, mdscr_el1 85 - tbnz \tmp, #1, 9990f 85 + tbnz \tmp, #0, 9990f 86 86 enable_dbg 87 87 9990: 88 88 .endm
-2
arch/arm64/kernel/debug-monitors.c
··· 136 136 */ 137 137 static void clear_os_lock(void *unused) 138 138 { 139 - asm volatile("msr mdscr_el1, %0" : : "r" (0)); 140 - isb(); 141 139 asm volatile("msr oslar_el1, %0" : : "r" (0)); 142 140 isb(); 143 141 }
+3 -2
arch/arm64/kernel/early_printk.c
··· 95 95 } 96 96 } 97 97 98 - static struct console early_console = { 98 + static struct console early_console_dev = { 99 99 .name = "earlycon", 100 100 .write = early_write, 101 101 .flags = CON_PRINTBUFFER | CON_BOOT, ··· 145 145 early_base = early_io_map(paddr, EARLYCON_IOBASE); 146 146 147 147 printch = match->printch; 148 - register_console(&early_console); 148 + early_console = &early_console_dev; 149 + register_console(&early_console_dev); 149 150 150 151 return 0; 151 152 }
+3 -9
arch/arm64/kernel/setup.c
··· 282 282 #endif 283 283 } 284 284 285 - static int __init arm64_of_clk_init(void) 285 + static int __init arm64_device_init(void) 286 286 { 287 287 of_clk_init(NULL); 288 + of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); 288 289 return 0; 289 290 } 290 - arch_initcall(arm64_of_clk_init); 291 + arch_initcall(arm64_device_init); 291 292 292 293 static DEFINE_PER_CPU(struct cpu, cpu_data); 293 294 ··· 305 304 return 0; 306 305 } 307 306 subsys_initcall(topology_init); 308 - 309 - static int __init arm64_device_probe(void) 310 - { 311 - of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); 312 - return 0; 313 - } 314 - device_initcall(arm64_device_probe); 315 307 316 308 static const char *hwcap_str[] = { 317 309 "fp",
+1 -1
arch/arm64/mm/cache.S
··· 52 52 add x2, x2, #4 // add 4 (line length offset) 53 53 mov x4, #0x3ff 54 54 and x4, x4, x1, lsr #3 // find maximum number on the way size 55 - clz x5, x4 // find bit position of way size increment 55 + clz w5, w4 // find bit position of way size increment 56 56 mov x7, #0x7fff 57 57 and x7, x7, x1, lsr #13 // extract max number of the index size 58 58 loop2:
+1 -2
arch/arm64/mm/proc.S
··· 119 119 120 120 mov x0, #3 << 20 121 121 msr cpacr_el1, x0 // Enable FP/ASIMD 122 - mov x0, #1 123 - msr oslar_el1, x0 // Set the debug OS lock 122 + msr mdscr_el1, xzr // Reset mdscr_el1 124 123 tlbi vmalle1is // invalidate I + D TLBs 125 124 /* 126 125 * Memory region attributes for LPAE:
+1 -1
arch/mips/include/asm/io.h
··· 118 118 */ 119 119 static inline unsigned long virt_to_phys(volatile const void *address) 120 120 { 121 - return (unsigned long)address - PAGE_OFFSET + PHYS_OFFSET; 121 + return __pa(address); 122 122 } 123 123 124 124 /*
+1 -1
arch/mips/include/asm/kvm_host.h
··· 336 336 #define VPN2_MASK 0xffffe000 337 337 #define TLB_IS_GLOBAL(x) (((x).tlb_lo0 & MIPS3_PG_G) && ((x).tlb_lo1 & MIPS3_PG_G)) 338 338 #define TLB_VPN2(x) ((x).tlb_hi & VPN2_MASK) 339 - #define TLB_ASID(x) (ASID_MASK((x).tlb_hi)) 339 + #define TLB_ASID(x) ((x).tlb_hi & ASID_MASK) 340 340 #define TLB_IS_VALID(x, va) (((va) & (1 << PAGE_SHIFT)) ? ((x).tlb_lo1 & MIPS3_PG_V) : ((x).tlb_lo0 & MIPS3_PG_V)) 341 341 342 342 struct kvm_mips_tlb {
+35 -58
arch/mips/include/asm/mmu_context.h
··· 67 67 TLBMISS_HANDLER_SETUP_PGD(swapper_pg_dir) 68 68 #endif 69 69 #endif /* CONFIG_MIPS_PGD_C0_CONTEXT*/ 70 + #if defined(CONFIG_CPU_R3000) || defined(CONFIG_CPU_TX39XX) 70 71 71 - #define ASID_INC(asid) \ 72 - ({ \ 73 - unsigned long __asid = asid; \ 74 - __asm__("1:\taddiu\t%0,1\t\t\t\t# patched\n\t" \ 75 - ".section\t__asid_inc,\"a\"\n\t" \ 76 - ".word\t1b\n\t" \ 77 - ".previous" \ 78 - :"=r" (__asid) \ 79 - :"0" (__asid)); \ 80 - __asid; \ 81 - }) 82 - #define ASID_MASK(asid) \ 83 - ({ \ 84 - unsigned long __asid = asid; \ 85 - __asm__("1:\tandi\t%0,%1,0xfc0\t\t\t# patched\n\t" \ 86 - ".section\t__asid_mask,\"a\"\n\t" \ 87 - ".word\t1b\n\t" \ 88 - ".previous" \ 89 - :"=r" (__asid) \ 90 - :"r" (__asid)); \ 91 - __asid; \ 92 - }) 93 - #define ASID_VERSION_MASK \ 94 - ({ \ 95 - unsigned long __asid; \ 96 - __asm__("1:\taddiu\t%0,$0,0xff00\t\t\t\t# patched\n\t" \ 97 - ".section\t__asid_version_mask,\"a\"\n\t" \ 98 - ".word\t1b\n\t" \ 99 - ".previous" \ 100 - :"=r" (__asid)); \ 101 - __asid; \ 102 - }) 103 - #define ASID_FIRST_VERSION \ 104 - ({ \ 105 - unsigned long __asid = asid; \ 106 - __asm__("1:\tli\t%0,0x100\t\t\t\t# patched\n\t" \ 107 - ".section\t__asid_first_version,\"a\"\n\t" \ 108 - ".word\t1b\n\t" \ 109 - ".previous" \ 110 - :"=r" (__asid)); \ 111 - __asid; \ 112 - }) 72 + #define ASID_INC 0x40 73 + #define ASID_MASK 0xfc0 113 74 114 - #define ASID_FIRST_VERSION_R3000 0x1000 115 - #define ASID_FIRST_VERSION_R4000 0x100 116 - #define ASID_FIRST_VERSION_R8000 0x1000 117 - #define ASID_FIRST_VERSION_RM9000 0x1000 75 + #elif defined(CONFIG_CPU_R8000) 118 76 119 - #ifdef CONFIG_MIPS_MT_SMTC 120 - #define SMTC_HW_ASID_MASK 0xff 121 - extern unsigned int smtc_asid_mask; 77 + #define ASID_INC 0x10 78 + #define ASID_MASK 0xff0 79 + 80 + #elif defined(CONFIG_MIPS_MT_SMTC) 81 + 82 + #define ASID_INC 0x1 83 + extern unsigned long smtc_asid_mask; 84 + #define ASID_MASK (smtc_asid_mask) 85 + #define HW_ASID_MASK 0xff 86 + /* End SMTC/34K debug hack */ 87 + #else /* FIXME: not correct for R6000 */ 88 + 89 + #define ASID_INC 0x1 90 + #define ASID_MASK 0xff 91 + 122 92 #endif 123 93 124 94 #define cpu_context(cpu, mm) ((mm)->context.asid[cpu]) 125 - #define cpu_asid(cpu, mm) ASID_MASK(cpu_context((cpu), (mm))) 95 + #define cpu_asid(cpu, mm) (cpu_context((cpu), (mm)) & ASID_MASK) 126 96 #define asid_cache(cpu) (cpu_data[cpu].asid_cache) 127 97 128 98 static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk) 129 99 { 130 100 } 101 + 102 + /* 103 + * All unused by hardware upper bits will be considered 104 + * as a software asid extension. 105 + */ 106 + #define ASID_VERSION_MASK ((unsigned long)~(ASID_MASK|(ASID_MASK-1))) 107 + #define ASID_FIRST_VERSION ((unsigned long)(~ASID_VERSION_MASK) + 1) 131 108 132 109 #ifndef CONFIG_MIPS_MT_SMTC 133 110 /* Normal, classic MIPS get_new_mmu_context */ ··· 114 137 extern void kvm_local_flush_tlb_all(void); 115 138 unsigned long asid = asid_cache(cpu); 116 139 117 - if (!ASID_MASK((asid = ASID_INC(asid)))) { 140 + if (! ((asid += ASID_INC) & ASID_MASK) ) { 118 141 if (cpu_has_vtag_icache) 119 142 flush_icache_all(); 120 143 #ifdef CONFIG_VIRTUALIZATION ··· 177 200 * free up the ASID value for use and flush any old 178 201 * instances of it from the TLB. 179 202 */ 180 - oldasid = ASID_MASK(read_c0_entryhi()); 203 + oldasid = (read_c0_entryhi() & ASID_MASK); 181 204 if(smtc_live_asid[mytlb][oldasid]) { 182 205 smtc_live_asid[mytlb][oldasid] &= ~(0x1 << cpu); 183 206 if(smtc_live_asid[mytlb][oldasid] == 0) ··· 188 211 * having ASID_MASK smaller than the hardware maximum, 189 212 * make sure no "soft" bits become "hard"... 190 213 */ 191 - write_c0_entryhi((read_c0_entryhi() & ~SMTC_HW_ASID_MASK) | 214 + write_c0_entryhi((read_c0_entryhi() & ~HW_ASID_MASK) | 192 215 cpu_asid(cpu, next)); 193 216 ehb(); /* Make sure it propagates to TCStatus */ 194 217 evpe(mtflags); ··· 241 264 #ifdef CONFIG_MIPS_MT_SMTC 242 265 /* See comments for similar code above */ 243 266 mtflags = dvpe(); 244 - oldasid = ASID_MASK(read_c0_entryhi()); 267 + oldasid = read_c0_entryhi() & ASID_MASK; 245 268 if(smtc_live_asid[mytlb][oldasid]) { 246 269 smtc_live_asid[mytlb][oldasid] &= ~(0x1 << cpu); 247 270 if(smtc_live_asid[mytlb][oldasid] == 0) 248 271 smtc_flush_tlb_asid(oldasid); 249 272 } 250 273 /* See comments for similar code above */ 251 - write_c0_entryhi((read_c0_entryhi() & ~SMTC_HW_ASID_MASK) | 252 - cpu_asid(cpu, next)); 274 + write_c0_entryhi((read_c0_entryhi() & ~HW_ASID_MASK) | 275 + cpu_asid(cpu, next)); 253 276 ehb(); /* Make sure it propagates to TCStatus */ 254 277 evpe(mtflags); 255 278 #else ··· 286 309 #ifdef CONFIG_MIPS_MT_SMTC 287 310 /* See comments for similar code above */ 288 311 prevvpe = dvpe(); 289 - oldasid = ASID_MASK(read_c0_entryhi()); 312 + oldasid = (read_c0_entryhi() & ASID_MASK); 290 313 if (smtc_live_asid[mytlb][oldasid]) { 291 314 smtc_live_asid[mytlb][oldasid] &= ~(0x1 << cpu); 292 315 if(smtc_live_asid[mytlb][oldasid] == 0) 293 316 smtc_flush_tlb_asid(oldasid); 294 317 } 295 318 /* See comments for similar code above */ 296 - write_c0_entryhi((read_c0_entryhi() & ~SMTC_HW_ASID_MASK) 319 + write_c0_entryhi((read_c0_entryhi() & ~HW_ASID_MASK) 297 320 | cpu_asid(cpu, mm)); 298 321 ehb(); /* Make sure it propagates to TCStatus */ 299 322 evpe(prevvpe);
+1 -1
arch/mips/include/asm/page.h
··· 46 46 #endif /* CONFIG_MIPS_HUGE_TLB_SUPPORT */ 47 47 48 48 #include <linux/pfn.h> 49 - #include <asm/io.h> 50 49 51 50 extern void build_clear_page(void); 52 51 extern void build_copy_page(void); ··· 150 151 ((unsigned long)(x) - PAGE_OFFSET + PHYS_OFFSET) 151 152 #endif 152 153 #define __va(x) ((void *)((unsigned long)(x) + PAGE_OFFSET - PHYS_OFFSET)) 154 + #include <asm/io.h> 153 155 154 156 /* 155 157 * RELOC_HIDE was originally added by 6007b903dfe5f1d13e0c711ac2894bdd4a61b1ad
+1
arch/mips/kernel/crash_dump.c
··· 2 2 #include <linux/bootmem.h> 3 3 #include <linux/crash_dump.h> 4 4 #include <asm/uaccess.h> 5 + #include <linux/slab.h> 5 6 6 7 static int __init parse_savemaxmem(char *p) 7 8 {
+1 -1
arch/mips/kernel/genex.S
··· 493 493 .set noreorder 494 494 /* check if TLB contains a entry for EPC */ 495 495 MFC0 k1, CP0_ENTRYHI 496 - andi k1, 0xff /* ASID_MASK patched at run-time!! */ 496 + andi k1, 0xff /* ASID_MASK */ 497 497 MFC0 k0, CP0_EPC 498 498 PTR_SRL k0, _PAGE_SHIFT + 1 499 499 PTR_SLL k0, _PAGE_SHIFT + 1
+37 -5
arch/mips/kernel/process.c
··· 224 224 int pc_offset; 225 225 }; 226 226 227 + #define J_TARGET(pc,target) \ 228 + (((unsigned long)(pc) & 0xf0000000) | ((target) << 2)) 229 + 227 230 static inline int is_ra_save_ins(union mips_instruction *ip) 228 231 { 229 232 #ifdef CONFIG_CPU_MICROMIPS ··· 267 264 #endif 268 265 } 269 266 270 - static inline int is_jal_jalr_jr_ins(union mips_instruction *ip) 267 + static inline int is_jump_ins(union mips_instruction *ip) 271 268 { 272 269 #ifdef CONFIG_CPU_MICROMIPS 273 270 /* ··· 291 288 return 0; 292 289 return (((ip->u_format.uimmediate >> 6) & mm_jalr_op) == mm_jalr_op); 293 290 #else 291 + if (ip->j_format.opcode == j_op) 292 + return 1; 294 293 if (ip->j_format.opcode == jal_op) 295 294 return 1; 296 295 if (ip->r_format.opcode != spec_op) ··· 355 350 356 351 for (i = 0; i < max_insns; i++, ip++) { 357 352 358 - if (is_jal_jalr_jr_ins(ip)) 353 + if (is_jump_ins(ip)) 359 354 break; 360 355 if (!info->frame_size) { 361 356 if (is_sp_move_ins(ip)) ··· 398 393 399 394 static struct mips_frame_info schedule_mfi __read_mostly; 400 395 396 + #ifdef CONFIG_KALLSYMS 397 + static unsigned long get___schedule_addr(void) 398 + { 399 + return kallsyms_lookup_name("__schedule"); 400 + } 401 + #else 402 + static unsigned long get___schedule_addr(void) 403 + { 404 + union mips_instruction *ip = (void *)schedule; 405 + int max_insns = 8; 406 + int i; 407 + 408 + for (i = 0; i < max_insns; i++, ip++) { 409 + if (ip->j_format.opcode == j_op) 410 + return J_TARGET(ip, ip->j_format.target); 411 + } 412 + return 0; 413 + } 414 + #endif 415 + 401 416 static int __init frame_info_init(void) 402 417 { 403 418 unsigned long size = 0; 404 419 #ifdef CONFIG_KALLSYMS 405 420 unsigned long ofs; 406 - 407 - kallsyms_lookup_size_offset((unsigned long)schedule, &size, &ofs); 408 421 #endif 409 - schedule_mfi.func = schedule; 422 + unsigned long addr; 423 + 424 + addr = get___schedule_addr(); 425 + if (!addr) 426 + addr = (unsigned long)schedule; 427 + 428 + #ifdef CONFIG_KALLSYMS 429 + kallsyms_lookup_size_offset(addr, &size, &ofs); 430 + #endif 431 + schedule_mfi.func = (void *)addr; 410 432 schedule_mfi.func_size = size; 411 433 412 434 get_frame_info(&schedule_mfi);
+5 -5
arch/mips/kernel/smtc.c
··· 111 111 static int ipibuffers; 112 112 static int nostlb; 113 113 static int asidmask; 114 - unsigned int smtc_asid_mask = 0xff; 114 + unsigned long smtc_asid_mask = 0xff; 115 115 116 116 static int __init vpe0tcs(char *str) 117 117 { ··· 1395 1395 asid = asid_cache(cpu); 1396 1396 1397 1397 do { 1398 - if (!ASID_MASK(ASID_INC(asid))) { 1398 + if (!((asid += ASID_INC) & ASID_MASK) ) { 1399 1399 if (cpu_has_vtag_icache) 1400 1400 flush_icache_all(); 1401 1401 /* Traverse all online CPUs (hack requires contiguous range) */ ··· 1414 1414 mips_ihb(); 1415 1415 } 1416 1416 tcstat = read_tc_c0_tcstatus(); 1417 - smtc_live_asid[tlb][ASID_MASK(tcstat)] |= (asiduse)(0x1 << i); 1417 + smtc_live_asid[tlb][(tcstat & ASID_MASK)] |= (asiduse)(0x1 << i); 1418 1418 if (!prevhalt) 1419 1419 write_tc_c0_tchalt(0); 1420 1420 } ··· 1423 1423 asid = ASID_FIRST_VERSION; 1424 1424 local_flush_tlb_all(); /* start new asid cycle */ 1425 1425 } 1426 - } while (smtc_live_asid[tlb][ASID_MASK(asid)]); 1426 + } while (smtc_live_asid[tlb][(asid & ASID_MASK)]); 1427 1427 1428 1428 /* 1429 1429 * SMTC shares the TLB within VPEs and possibly across all VPEs. ··· 1461 1461 tlb_read(); 1462 1462 ehb(); 1463 1463 ehi = read_c0_entryhi(); 1464 - if (ASID_MASK(ehi) == asid) { 1464 + if ((ehi & ASID_MASK) == asid) { 1465 1465 /* 1466 1466 * Invalidate only entries with specified ASID, 1467 1467 * makiing sure all entries differ.
+2 -4
arch/mips/kernel/traps.c
··· 1656 1656 unsigned int cpu = smp_processor_id(); 1657 1657 unsigned int status_set = ST0_CU0; 1658 1658 unsigned int hwrena = cpu_hwrena_impl_bits; 1659 - unsigned long asid = 0; 1660 1659 #ifdef CONFIG_MIPS_MT_SMTC 1661 1660 int secondaryTC = 0; 1662 1661 int bootTC = (cpu == 0); ··· 1739 1740 } 1740 1741 #endif /* CONFIG_MIPS_MT_SMTC */ 1741 1742 1742 - asid = ASID_FIRST_VERSION; 1743 - cpu_data[cpu].asid_cache = asid; 1744 - TLBMISS_HANDLER_SETUP(); 1743 + if (!cpu_data[cpu].asid_cache) 1744 + cpu_data[cpu].asid_cache = ASID_FIRST_VERSION; 1745 1745 1746 1746 atomic_inc(&init_mm.mm_count); 1747 1747 current->active_mm = &init_mm;
+16 -13
arch/mips/kvm/kvm_mips_emul.c
··· 525 525 printk("MTCz, cop0->reg[EBASE]: %#lx\n", 526 526 kvm_read_c0_guest_ebase(cop0)); 527 527 } else if (rd == MIPS_CP0_TLB_HI && sel == 0) { 528 - uint32_t nasid = ASID_MASK(vcpu->arch.gprs[rt]); 528 + uint32_t nasid = 529 + vcpu->arch.gprs[rt] & ASID_MASK; 529 530 if ((KSEGX(vcpu->arch.gprs[rt]) != CKSEG0) 530 531 && 531 - (ASID_MASK(kvm_read_c0_guest_entryhi(cop0)) 532 - != nasid)) { 532 + ((kvm_read_c0_guest_entryhi(cop0) & 533 + ASID_MASK) != nasid)) { 533 534 534 535 kvm_debug 535 536 ("MTCz, change ASID from %#lx to %#lx\n", 536 - ASID_MASK(kvm_read_c0_guest_entryhi(cop0)), 537 - ASID_MASK(vcpu->arch.gprs[rt])); 537 + kvm_read_c0_guest_entryhi(cop0) & 538 + ASID_MASK, 539 + vcpu->arch.gprs[rt] & ASID_MASK); 538 540 539 541 /* Blow away the shadow host TLBs */ 540 542 kvm_mips_flush_host_tlb(1); ··· 988 986 * resulting handler will do the right thing 989 987 */ 990 988 index = kvm_mips_guest_tlb_lookup(vcpu, (va & VPN2_MASK) | 991 - ASID_MASK(kvm_read_c0_guest_entryhi(cop0))); 989 + (kvm_read_c0_guest_entryhi 990 + (cop0) & ASID_MASK)); 992 991 993 992 if (index < 0) { 994 993 vcpu->arch.host_cp0_entryhi = (va & VPN2_MASK); ··· 1154 1151 struct kvm_vcpu_arch *arch = &vcpu->arch; 1155 1152 enum emulation_result er = EMULATE_DONE; 1156 1153 unsigned long entryhi = (vcpu->arch. host_cp0_badvaddr & VPN2_MASK) | 1157 - ASID_MASK(kvm_read_c0_guest_entryhi(cop0)); 1154 + (kvm_read_c0_guest_entryhi(cop0) & ASID_MASK); 1158 1155 1159 1156 if ((kvm_read_c0_guest_status(cop0) & ST0_EXL) == 0) { 1160 1157 /* save old pc */ ··· 1201 1198 enum emulation_result er = EMULATE_DONE; 1202 1199 unsigned long entryhi = 1203 1200 (vcpu->arch.host_cp0_badvaddr & VPN2_MASK) | 1204 - ASID_MASK(kvm_read_c0_guest_entryhi(cop0)); 1201 + (kvm_read_c0_guest_entryhi(cop0) & ASID_MASK); 1205 1202 1206 1203 if ((kvm_read_c0_guest_status(cop0) & ST0_EXL) == 0) { 1207 1204 /* save old pc */ ··· 1246 1243 struct kvm_vcpu_arch *arch = &vcpu->arch; 1247 1244 enum emulation_result er = EMULATE_DONE; 1248 1245 unsigned long entryhi = (vcpu->arch.host_cp0_badvaddr & VPN2_MASK) | 1249 - ASID_MASK(kvm_read_c0_guest_entryhi(cop0)); 1246 + (kvm_read_c0_guest_entryhi(cop0) & ASID_MASK); 1250 1247 1251 1248 if ((kvm_read_c0_guest_status(cop0) & ST0_EXL) == 0) { 1252 1249 /* save old pc */ ··· 1290 1287 struct kvm_vcpu_arch *arch = &vcpu->arch; 1291 1288 enum emulation_result er = EMULATE_DONE; 1292 1289 unsigned long entryhi = (vcpu->arch.host_cp0_badvaddr & VPN2_MASK) | 1293 - ASID_MASK(kvm_read_c0_guest_entryhi(cop0)); 1290 + (kvm_read_c0_guest_entryhi(cop0) & ASID_MASK); 1294 1291 1295 1292 if ((kvm_read_c0_guest_status(cop0) & ST0_EXL) == 0) { 1296 1293 /* save old pc */ ··· 1359 1356 { 1360 1357 struct mips_coproc *cop0 = vcpu->arch.cop0; 1361 1358 unsigned long entryhi = (vcpu->arch.host_cp0_badvaddr & VPN2_MASK) | 1362 - ASID_MASK(kvm_read_c0_guest_entryhi(cop0)); 1359 + (kvm_read_c0_guest_entryhi(cop0) & ASID_MASK); 1363 1360 struct kvm_vcpu_arch *arch = &vcpu->arch; 1364 1361 enum emulation_result er = EMULATE_DONE; 1365 1362 ··· 1786 1783 */ 1787 1784 index = kvm_mips_guest_tlb_lookup(vcpu, 1788 1785 (va & VPN2_MASK) | 1789 - ASID_MASK(kvm_read_c0_guest_entryhi 1790 - (vcpu->arch.cop0))); 1786 + (kvm_read_c0_guest_entryhi 1787 + (vcpu->arch.cop0) & ASID_MASK)); 1791 1788 if (index < 0) { 1792 1789 if (exccode == T_TLB_LD_MISS) { 1793 1790 er = kvm_mips_emulate_tlbmiss_ld(cause, opc, run, vcpu);
+15 -11
arch/mips/kvm/kvm_tlb.c
··· 51 51 52 52 uint32_t kvm_mips_get_kernel_asid(struct kvm_vcpu *vcpu) 53 53 { 54 - return ASID_MASK(vcpu->arch.guest_kernel_asid[smp_processor_id()]); 54 + return vcpu->arch.guest_kernel_asid[smp_processor_id()] & ASID_MASK; 55 55 } 56 56 57 57 58 58 uint32_t kvm_mips_get_user_asid(struct kvm_vcpu *vcpu) 59 59 { 60 - return ASID_MASK(vcpu->arch.guest_user_asid[smp_processor_id()]); 60 + return vcpu->arch.guest_user_asid[smp_processor_id()] & ASID_MASK; 61 61 } 62 62 63 63 inline uint32_t kvm_mips_get_commpage_asid (struct kvm_vcpu *vcpu) ··· 84 84 old_pagemask = read_c0_pagemask(); 85 85 86 86 printk("HOST TLBs:\n"); 87 - printk("ASID: %#lx\n", ASID_MASK(read_c0_entryhi())); 87 + printk("ASID: %#lx\n", read_c0_entryhi() & ASID_MASK); 88 88 89 89 for (i = 0; i < current_cpu_data.tlbsize; i++) { 90 90 write_c0_index(i); ··· 428 428 429 429 for (i = 0; i < KVM_MIPS_GUEST_TLB_SIZE; i++) { 430 430 if (((TLB_VPN2(tlb[i]) & ~tlb[i].tlb_mask) == ((entryhi & VPN2_MASK) & ~tlb[i].tlb_mask)) && 431 - (TLB_IS_GLOBAL(tlb[i]) || (TLB_ASID(tlb[i]) == ASID_MASK(entryhi)))) { 431 + (TLB_IS_GLOBAL(tlb[i]) || (TLB_ASID(tlb[i]) == (entryhi & ASID_MASK)))) { 432 432 index = i; 433 433 break; 434 434 } ··· 626 626 { 627 627 unsigned long asid = asid_cache(cpu); 628 628 629 - if (!(ASID_MASK(ASID_INC(asid)))) { 629 + if (!((asid += ASID_INC) & ASID_MASK)) { 630 630 if (cpu_has_vtag_icache) { 631 631 flush_icache_all(); 632 632 } ··· 804 804 if (!newasid) { 805 805 /* If we preempted while the guest was executing, then reload the pre-empted ASID */ 806 806 if (current->flags & PF_VCPU) { 807 - write_c0_entryhi(ASID_MASK(vcpu->arch.preempt_entryhi)); 807 + write_c0_entryhi(vcpu->arch. 808 + preempt_entryhi & ASID_MASK); 808 809 ehb(); 809 810 } 810 811 } else { ··· 817 816 */ 818 817 if (current->flags & PF_VCPU) { 819 818 if (KVM_GUEST_KERNEL_MODE(vcpu)) 820 - write_c0_entryhi(ASID_MASK(vcpu->arch. 821 - guest_kernel_asid[cpu])); 819 + write_c0_entryhi(vcpu->arch. 820 + guest_kernel_asid[cpu] & 821 + ASID_MASK); 822 822 else 823 - write_c0_entryhi(ASID_MASK(vcpu->arch. 824 - guest_user_asid[cpu])); 823 + write_c0_entryhi(vcpu->arch. 824 + guest_user_asid[cpu] & 825 + ASID_MASK); 825 826 ehb(); 826 827 } 827 828 } ··· 882 879 kvm_mips_guest_tlb_lookup(vcpu, 883 880 ((unsigned long) opc & VPN2_MASK) 884 881 | 885 - ASID_MASK(kvm_read_c0_guest_entryhi(cop0))); 882 + (kvm_read_c0_guest_entryhi 883 + (cop0) & ASID_MASK)); 886 884 if (index < 0) { 887 885 kvm_err 888 886 ("%s: get_user_failed for %p, vcpu: %p, ASID: %#lx\n",
+2 -4
arch/mips/lantiq/xway/gptu.c
··· 144 144 } 145 145 146 146 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 147 - if (!res) { 148 - dev_err(&pdev->dev, "Failed to get resource\n"); 149 - return -ENOMEM; 150 - } 151 147 152 148 /* remap gptu register range */ 153 149 gptu_membase = devm_ioremap_resource(&pdev->dev, res); ··· 165 169 if (((gptu_r32(GPTU_ID) >> 8) & 0xff) != GPTU_MAGIC) { 166 170 dev_err(&pdev->dev, "Failed to find magic\n"); 167 171 gptu_hwexit(); 172 + clk_disable(clk); 173 + clk_put(clk); 168 174 return -ENAVAIL; 169 175 } 170 176
+2 -3
arch/mips/lib/dump_tlb.c
··· 11 11 #include <asm/page.h> 12 12 #include <asm/pgtable.h> 13 13 #include <asm/tlbdebug.h> 14 - #include <asm/mmu_context.h> 15 14 16 15 static inline const char *msk2str(unsigned int mask) 17 16 { ··· 55 56 s_pagemask = read_c0_pagemask(); 56 57 s_entryhi = read_c0_entryhi(); 57 58 s_index = read_c0_index(); 58 - asid = ASID_MASK(s_entryhi); 59 + asid = s_entryhi & 0xff; 59 60 60 61 for (i = first; i <= last; i++) { 61 62 write_c0_index(i); ··· 85 86 86 87 printk("va=%0*lx asid=%02lx\n", 87 88 width, (entryhi & ~0x1fffUL), 88 - ASID_MASK(entryhi)); 89 + entryhi & 0xff); 89 90 printk("\t[pa=%0*llx c=%d d=%d v=%d g=%d] ", 90 91 width, 91 92 (entrylo0 << 6) & PAGE_MASK, c0,
+3 -4
arch/mips/lib/r3k_dump_tlb.c
··· 9 9 #include <linux/mm.h> 10 10 11 11 #include <asm/mipsregs.h> 12 - #include <asm/mmu_context.h> 13 12 #include <asm/page.h> 14 13 #include <asm/pgtable.h> 15 14 #include <asm/tlbdebug.h> ··· 21 22 unsigned int asid; 22 23 unsigned long entryhi, entrylo0; 23 24 24 - asid = ASID_MASK(read_c0_entryhi()); 25 + asid = read_c0_entryhi() & 0xfc0; 25 26 26 27 for (i = first; i <= last; i++) { 27 28 write_c0_index(i<<8); ··· 35 36 36 37 /* Unused entries have a virtual address of KSEG0. */ 37 38 if ((entryhi & 0xffffe000) != 0x80000000 38 - && (ASID_MASK(entryhi) == asid)) { 39 + && (entryhi & 0xfc0) == asid) { 39 40 /* 40 41 * Only print entries in use 41 42 */ ··· 44 45 printk("va=%08lx asid=%08lx" 45 46 " [pa=%06lx n=%d d=%d v=%d g=%d]", 46 47 (entryhi & 0xffffe000), 47 - ASID_MASK(entryhi), 48 + entryhi & 0xfc0, 48 49 entrylo0 & PAGE_MASK, 49 50 (entrylo0 & (1 << 11)) ? 1 : 0, 50 51 (entrylo0 & (1 << 10)) ? 1 : 0,
+10 -10
arch/mips/mm/tlb-r3k.c
··· 51 51 #endif 52 52 53 53 local_irq_save(flags); 54 - old_ctx = ASID_MASK(read_c0_entryhi()); 54 + old_ctx = read_c0_entryhi() & ASID_MASK; 55 55 write_c0_entrylo0(0); 56 56 entry = r3k_have_wired_reg ? read_c0_wired() : 8; 57 57 for (; entry < current_cpu_data.tlbsize; entry++) { ··· 87 87 88 88 #ifdef DEBUG_TLB 89 89 printk("[tlbrange<%lu,0x%08lx,0x%08lx>]", 90 - ASID_MASK(cpu_context(cpu, mm)), start, end); 90 + cpu_context(cpu, mm) & ASID_MASK, start, end); 91 91 #endif 92 92 local_irq_save(flags); 93 93 size = (end - start + (PAGE_SIZE - 1)) >> PAGE_SHIFT; 94 94 if (size <= current_cpu_data.tlbsize) { 95 - int oldpid = ASID_MASK(read_c0_entryhi()); 96 - int newpid = ASID_MASK(cpu_context(cpu, mm)); 95 + int oldpid = read_c0_entryhi() & ASID_MASK; 96 + int newpid = cpu_context(cpu, mm) & ASID_MASK; 97 97 98 98 start &= PAGE_MASK; 99 99 end += PAGE_SIZE - 1; ··· 166 166 #ifdef DEBUG_TLB 167 167 printk("[tlbpage<%lu,0x%08lx>]", cpu_context(cpu, vma->vm_mm), page); 168 168 #endif 169 - newpid = ASID_MASK(cpu_context(cpu, vma->vm_mm)); 169 + newpid = cpu_context(cpu, vma->vm_mm) & ASID_MASK; 170 170 page &= PAGE_MASK; 171 171 local_irq_save(flags); 172 - oldpid = ASID_MASK(read_c0_entryhi()); 172 + oldpid = read_c0_entryhi() & ASID_MASK; 173 173 write_c0_entryhi(page | newpid); 174 174 BARRIER; 175 175 tlb_probe(); ··· 197 197 if (current->active_mm != vma->vm_mm) 198 198 return; 199 199 200 - pid = ASID_MASK(read_c0_entryhi()); 200 + pid = read_c0_entryhi() & ASID_MASK; 201 201 202 202 #ifdef DEBUG_TLB 203 - if ((pid != ASID_MASK(cpu_context(cpu, vma->vm_mm))) || (cpu_context(cpu, vma->vm_mm) == 0)) { 203 + if ((pid != (cpu_context(cpu, vma->vm_mm) & ASID_MASK)) || (cpu_context(cpu, vma->vm_mm) == 0)) { 204 204 printk("update_mmu_cache: Wheee, bogus tlbpid mmpid=%lu tlbpid=%d\n", 205 205 (cpu_context(cpu, vma->vm_mm)), pid); 206 206 } ··· 241 241 242 242 local_irq_save(flags); 243 243 /* Save old context and create impossible VPN2 value */ 244 - old_ctx = ASID_MASK(read_c0_entryhi()); 244 + old_ctx = read_c0_entryhi() & ASID_MASK; 245 245 old_pagemask = read_c0_pagemask(); 246 246 w = read_c0_wired(); 247 247 write_c0_wired(w + 1); ··· 264 264 #endif 265 265 266 266 local_irq_save(flags); 267 - old_ctx = ASID_MASK(read_c0_entryhi()); 267 + old_ctx = read_c0_entryhi() & ASID_MASK; 268 268 write_c0_entrylo0(entrylo0); 269 269 write_c0_entryhi(entryhi); 270 270 write_c0_index(wired);
+1 -1
arch/mips/mm/tlb-r4k.c
··· 287 287 288 288 ENTER_CRITICAL(flags); 289 289 290 - pid = ASID_MASK(read_c0_entryhi()); 290 + pid = read_c0_entryhi() & ASID_MASK; 291 291 address &= (PAGE_MASK << 1); 292 292 write_c0_entryhi(address | pid); 293 293 pgdp = pgd_offset(vma->vm_mm, address);
+1 -1
arch/mips/mm/tlb-r8k.c
··· 195 195 if (current->active_mm != vma->vm_mm) 196 196 return; 197 197 198 - pid = ASID_MASK(read_c0_entryhi()); 198 + pid = read_c0_entryhi() & ASID_MASK; 199 199 200 200 local_irq_save(flags); 201 201 address &= PAGE_MASK;
-79
arch/mips/mm/tlbex.c
··· 29 29 #include <linux/init.h> 30 30 #include <linux/cache.h> 31 31 32 - #include <asm/mmu_context.h> 33 32 #include <asm/cacheflush.h> 34 33 #include <asm/pgtable.h> 35 34 #include <asm/war.h> ··· 304 305 #ifdef CONFIG_64BIT 305 306 static int check_for_high_segbits __cpuinitdata; 306 307 #endif 307 - 308 - static void __cpuinit insn_fixup(unsigned int **start, unsigned int **stop, 309 - unsigned int i_const) 310 - { 311 - unsigned int **p; 312 - 313 - for (p = start; p < stop; p++) { 314 - #ifndef CONFIG_CPU_MICROMIPS 315 - unsigned int *ip; 316 - 317 - ip = *p; 318 - *ip = (*ip & 0xffff0000) | i_const; 319 - #else 320 - unsigned short *ip; 321 - 322 - ip = ((unsigned short *)((unsigned int)*p - 1)); 323 - if ((*ip & 0xf000) == 0x4000) { 324 - *ip &= 0xfff1; 325 - *ip |= (i_const << 1); 326 - } else if ((*ip & 0xf000) == 0x6000) { 327 - *ip &= 0xfff1; 328 - *ip |= ((i_const >> 2) << 1); 329 - } else { 330 - ip++; 331 - *ip = i_const; 332 - } 333 - #endif 334 - local_flush_icache_range((unsigned long)ip, 335 - (unsigned long)ip + sizeof(*ip)); 336 - } 337 - } 338 - 339 - #define asid_insn_fixup(section, const) \ 340 - do { \ 341 - extern unsigned int *__start_ ## section; \ 342 - extern unsigned int *__stop_ ## section; \ 343 - insn_fixup(&__start_ ## section, &__stop_ ## section, const); \ 344 - } while(0) 345 - 346 - /* 347 - * Caller is assumed to flush the caches before the first context switch. 348 - */ 349 - static void __cpuinit setup_asid(unsigned int inc, unsigned int mask, 350 - unsigned int version_mask, 351 - unsigned int first_version) 352 - { 353 - extern asmlinkage void handle_ri_rdhwr_vivt(void); 354 - unsigned long *vivt_exc; 355 - 356 - #ifdef CONFIG_CPU_MICROMIPS 357 - /* 358 - * Worst case optimised microMIPS addiu instructions support 359 - * only a 3-bit immediate value. 360 - */ 361 - if(inc > 7) 362 - panic("Invalid ASID increment value!"); 363 - #endif 364 - asid_insn_fixup(__asid_inc, inc); 365 - asid_insn_fixup(__asid_mask, mask); 366 - asid_insn_fixup(__asid_version_mask, version_mask); 367 - asid_insn_fixup(__asid_first_version, first_version); 368 - 369 - /* Patch up the 'handle_ri_rdhwr_vivt' handler. */ 370 - vivt_exc = (unsigned long *) &handle_ri_rdhwr_vivt; 371 - #ifdef CONFIG_CPU_MICROMIPS 372 - vivt_exc = (unsigned long *)((unsigned long) vivt_exc - 1); 373 - #endif 374 - vivt_exc++; 375 - *vivt_exc = (*vivt_exc & ~mask) | mask; 376 - 377 - current_cpu_data.asid_cache = first_version; 378 - } 379 308 380 309 static int check_for_high_segbits __cpuinitdata; 381 310 ··· 2183 2256 case CPU_TX3922: 2184 2257 case CPU_TX3927: 2185 2258 #ifndef CONFIG_MIPS_PGD_C0_CONTEXT 2186 - setup_asid(0x40, 0xfc0, 0xf000, ASID_FIRST_VERSION_R3000); 2187 2259 if (cpu_has_local_ebase) 2188 2260 build_r3000_tlb_refill_handler(); 2189 2261 if (!run_once) { ··· 2208 2282 break; 2209 2283 2210 2284 default: 2211 - #ifndef CONFIG_MIPS_MT_SMTC 2212 - setup_asid(0x1, 0xff, 0xff00, ASID_FIRST_VERSION_R4000); 2213 - #else 2214 - setup_asid(0x1, smtc_asid_mask, 0xff00, ASID_FIRST_VERSION_R4000); 2215 - #endif 2216 2285 if (!run_once) { 2217 2286 scratch_reg = allocate_kscratch(); 2218 2287 #ifdef CONFIG_MIPS_PGD_C0_CONTEXT
+1 -1
arch/mips/pmcs-msp71xx/msp_prom.c
··· 83 83 return 0; /* foo */ 84 84 } 85 85 86 - static inline int str2eaddr(unsigned char *ea, unsigned char *str) 86 + int str2eaddr(unsigned char *ea, unsigned char *str) 87 87 { 88 88 int index = 0; 89 89 unsigned char num = 0;
+10
arch/mips/ralink/dts/rt3050.dtsi
··· 55 55 reg-shift = <2>; 56 56 }; 57 57 }; 58 + 59 + usb@101c0000 { 60 + compatible = "ralink,rt3050-usb", "snps,dwc2"; 61 + reg = <0x101c0000 40000>; 62 + 63 + interrupt-parent = <&intc>; 64 + interrupts = <18>; 65 + 66 + status = "disabled"; 67 + }; 58 68 };
+4
arch/mips/ralink/dts/rt3052_eval.dts
··· 43 43 reg = <0x50000 0x7b0000>; 44 44 }; 45 45 }; 46 + 47 + usb@101c0000 { 48 + status = "ok"; 49 + }; 46 50 };
+1 -1
arch/parisc/Kconfig
··· 245 245 246 246 config IRQSTACKS 247 247 bool "Use separate kernel stacks when processing interrupts" 248 - default n 248 + default y 249 249 help 250 250 If you say Y here the kernel will use separate kernel stacks 251 251 for handling hard and soft interrupts. This can help avoid
+9 -12
arch/parisc/Makefile
··· 23 23 CHECKFLAGS += -D__hppa__=1 24 24 LIBGCC = $(shell $(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name) 25 25 26 - MACHINE := $(shell uname -m) 27 - NATIVE := $(if $(filter parisc%,$(MACHINE)),1,0) 28 - 29 26 ifdef CONFIG_64BIT 30 27 UTS_MACHINE := parisc64 31 28 CHECKFLAGS += -D__LP64__=1 -m64 32 - WIDTH := 64 29 + CC_ARCHES = hppa64 33 30 else # 32-bit 34 - WIDTH := 31 + CC_ARCHES = hppa hppa2.0 hppa1.1 35 32 endif 36 33 37 - # attempt to help out folks who are cross-compiling 38 - ifeq ($(NATIVE),1) 39 - CROSS_COMPILE := hppa$(WIDTH)-linux- 40 - else 41 - ifeq ($(CROSS_COMPILE),) 42 - CROSS_COMPILE := hppa$(WIDTH)-linux-gnu- 43 - endif 34 + ifneq ($(SUBARCH),$(UTS_MACHINE)) 35 + ifeq ($(CROSS_COMPILE),) 36 + CC_SUFFIXES = linux linux-gnu unknown-linux-gnu 37 + CROSS_COMPILE := $(call cc-cross-prefix, \ 38 + $(foreach a,$(CC_ARCHES), \ 39 + $(foreach s,$(CC_SUFFIXES),$(a)-$(s)-))) 40 + endif 44 41 endif 45 42 46 43 OBJCOPY_FLAGS =-O binary -R .note -R .comment -S
+9
arch/parisc/include/asm/hardirq.h
··· 11 11 #include <linux/threads.h> 12 12 #include <linux/irq.h> 13 13 14 + #ifdef CONFIG_IRQSTACKS 15 + #define __ARCH_HAS_DO_SOFTIRQ 16 + #endif 17 + 14 18 typedef struct { 15 19 unsigned int __softirq_pending; 16 20 #ifdef CONFIG_DEBUG_STACKOVERFLOW 17 21 unsigned int kernel_stack_usage; 22 + #ifdef CONFIG_IRQSTACKS 23 + unsigned int irq_stack_usage; 24 + unsigned int irq_stack_counter; 25 + #endif 18 26 #endif 19 27 #ifdef CONFIG_SMP 20 28 unsigned int irq_resched_count; ··· 36 28 #define __ARCH_IRQ_STAT 37 29 #define __IRQ_STAT(cpu, member) (irq_stat[cpu].member) 38 30 #define inc_irq_stat(member) this_cpu_inc(irq_stat.member) 31 + #define __inc_irq_stat(member) __this_cpu_inc(irq_stat.member) 39 32 #define local_softirq_pending() this_cpu_read(irq_stat.__softirq_pending) 40 33 41 34 #define __ARCH_SET_SOFTIRQ_PENDING
+3
arch/parisc/include/asm/processor.h
··· 63 63 */ 64 64 #ifdef __KERNEL__ 65 65 66 + #include <linux/spinlock_types.h> 67 + 66 68 #define IRQ_STACK_SIZE (4096 << 2) /* 16k irq stack size */ 67 69 68 70 union irq_stack_union { 69 71 unsigned long stack[IRQ_STACK_SIZE/sizeof(unsigned long)]; 72 + raw_spinlock_t lock; 70 73 }; 71 74 72 75 DECLARE_PER_CPU(union irq_stack_union, irq_stack_union);
+83 -72
arch/parisc/kernel/entry.S
··· 452 452 L2_ptep \pgd,\pte,\index,\va,\fault 453 453 .endm 454 454 455 + /* Acquire pa_dbit_lock lock. */ 456 + .macro dbit_lock spc,tmp,tmp1 457 + #ifdef CONFIG_SMP 458 + cmpib,COND(=),n 0,\spc,2f 459 + load32 PA(pa_dbit_lock),\tmp 460 + 1: LDCW 0(\tmp),\tmp1 461 + cmpib,COND(=) 0,\tmp1,1b 462 + nop 463 + 2: 464 + #endif 465 + .endm 466 + 467 + /* Release pa_dbit_lock lock without reloading lock address. */ 468 + .macro dbit_unlock0 spc,tmp 469 + #ifdef CONFIG_SMP 470 + or,COND(=) %r0,\spc,%r0 471 + stw \spc,0(\tmp) 472 + #endif 473 + .endm 474 + 475 + /* Release pa_dbit_lock lock. */ 476 + .macro dbit_unlock1 spc,tmp 477 + #ifdef CONFIG_SMP 478 + load32 PA(pa_dbit_lock),\tmp 479 + dbit_unlock0 \spc,\tmp 480 + #endif 481 + .endm 482 + 455 483 /* Set the _PAGE_ACCESSED bit of the PTE. Be clever and 456 484 * don't needlessly dirty the cache line if it was already set */ 457 - .macro update_ptep ptep,pte,tmp,tmp1 485 + .macro update_ptep spc,ptep,pte,tmp,tmp1 486 + #ifdef CONFIG_SMP 487 + or,COND(=) %r0,\spc,%r0 488 + LDREG 0(\ptep),\pte 489 + #endif 458 490 ldi _PAGE_ACCESSED,\tmp1 459 491 or \tmp1,\pte,\tmp 460 492 and,COND(<>) \tmp1,\pte,%r0 ··· 495 463 496 464 /* Set the dirty bit (and accessed bit). No need to be 497 465 * clever, this is only used from the dirty fault */ 498 - .macro update_dirty ptep,pte,tmp 466 + .macro update_dirty spc,ptep,pte,tmp 467 + #ifdef CONFIG_SMP 468 + or,COND(=) %r0,\spc,%r0 469 + LDREG 0(\ptep),\pte 470 + #endif 499 471 ldi _PAGE_ACCESSED|_PAGE_DIRTY,\tmp 500 472 or \tmp,\pte,\pte 501 473 STREG \pte,0(\ptep) ··· 1147 1111 1148 1112 L3_ptep ptp,pte,t0,va,dtlb_check_alias_20w 1149 1113 1150 - update_ptep ptp,pte,t0,t1 1114 + dbit_lock spc,t0,t1 1115 + update_ptep spc,ptp,pte,t0,t1 1151 1116 1152 1117 make_insert_tlb spc,pte,prot 1153 1118 1154 1119 idtlbt pte,prot 1120 + dbit_unlock1 spc,t0 1155 1121 1156 1122 rfir 1157 1123 nop ··· 1173 1135 1174 1136 L3_ptep ptp,pte,t0,va,nadtlb_check_alias_20w 1175 1137 1176 - update_ptep ptp,pte,t0,t1 1138 + dbit_lock spc,t0,t1 1139 + update_ptep spc,ptp,pte,t0,t1 1177 1140 1178 1141 make_insert_tlb spc,pte,prot 1179 1142 1180 1143 idtlbt pte,prot 1144 + dbit_unlock1 spc,t0 1181 1145 1182 1146 rfir 1183 1147 nop ··· 1201 1161 1202 1162 L2_ptep ptp,pte,t0,va,dtlb_check_alias_11 1203 1163 1204 - update_ptep ptp,pte,t0,t1 1164 + dbit_lock spc,t0,t1 1165 + update_ptep spc,ptp,pte,t0,t1 1205 1166 1206 1167 make_insert_tlb_11 spc,pte,prot 1207 1168 ··· 1213 1172 idtlbp prot,(%sr1,va) 1214 1173 1215 1174 mtsp t0, %sr1 /* Restore sr1 */ 1175 + dbit_unlock1 spc,t0 1216 1176 1217 1177 rfir 1218 1178 nop ··· 1234 1192 1235 1193 L2_ptep ptp,pte,t0,va,nadtlb_check_alias_11 1236 1194 1237 - update_ptep ptp,pte,t0,t1 1195 + dbit_lock spc,t0,t1 1196 + update_ptep spc,ptp,pte,t0,t1 1238 1197 1239 1198 make_insert_tlb_11 spc,pte,prot 1240 1199 ··· 1247 1204 idtlbp prot,(%sr1,va) 1248 1205 1249 1206 mtsp t0, %sr1 /* Restore sr1 */ 1207 + dbit_unlock1 spc,t0 1250 1208 1251 1209 rfir 1252 1210 nop ··· 1268 1224 1269 1225 L2_ptep ptp,pte,t0,va,dtlb_check_alias_20 1270 1226 1271 - update_ptep ptp,pte,t0,t1 1227 + dbit_lock spc,t0,t1 1228 + update_ptep spc,ptp,pte,t0,t1 1272 1229 1273 1230 make_insert_tlb spc,pte,prot 1274 1231 1275 1232 f_extend pte,t0 1276 1233 1277 1234 idtlbt pte,prot 1235 + dbit_unlock1 spc,t0 1278 1236 1279 1237 rfir 1280 1238 nop ··· 1296 1250 1297 1251 L2_ptep ptp,pte,t0,va,nadtlb_check_alias_20 1298 1252 1299 - update_ptep ptp,pte,t0,t1 1253 + dbit_lock spc,t0,t1 1254 + update_ptep spc,ptp,pte,t0,t1 1300 1255 1301 1256 make_insert_tlb spc,pte,prot 1302 1257 1303 1258 f_extend pte,t0 1304 1259 1305 1260 idtlbt pte,prot 1261 + dbit_unlock1 spc,t0 1306 1262 1307 1263 rfir 1308 1264 nop ··· 1405 1357 1406 1358 L3_ptep ptp,pte,t0,va,itlb_fault 1407 1359 1408 - update_ptep ptp,pte,t0,t1 1360 + dbit_lock spc,t0,t1 1361 + update_ptep spc,ptp,pte,t0,t1 1409 1362 1410 1363 make_insert_tlb spc,pte,prot 1411 1364 1412 1365 iitlbt pte,prot 1366 + dbit_unlock1 spc,t0 1413 1367 1414 1368 rfir 1415 1369 nop ··· 1429 1379 1430 1380 L3_ptep ptp,pte,t0,va,naitlb_check_alias_20w 1431 1381 1432 - update_ptep ptp,pte,t0,t1 1382 + dbit_lock spc,t0,t1 1383 + update_ptep spc,ptp,pte,t0,t1 1433 1384 1434 1385 make_insert_tlb spc,pte,prot 1435 1386 1436 1387 iitlbt pte,prot 1388 + dbit_unlock1 spc,t0 1437 1389 1438 1390 rfir 1439 1391 nop ··· 1457 1405 1458 1406 L2_ptep ptp,pte,t0,va,itlb_fault 1459 1407 1460 - update_ptep ptp,pte,t0,t1 1408 + dbit_lock spc,t0,t1 1409 + update_ptep spc,ptp,pte,t0,t1 1461 1410 1462 1411 make_insert_tlb_11 spc,pte,prot 1463 1412 ··· 1469 1416 iitlbp prot,(%sr1,va) 1470 1417 1471 1418 mtsp t0, %sr1 /* Restore sr1 */ 1419 + dbit_unlock1 spc,t0 1472 1420 1473 1421 rfir 1474 1422 nop ··· 1481 1427 1482 1428 L2_ptep ptp,pte,t0,va,naitlb_check_alias_11 1483 1429 1484 - update_ptep ptp,pte,t0,t1 1430 + dbit_lock spc,t0,t1 1431 + update_ptep spc,ptp,pte,t0,t1 1485 1432 1486 1433 make_insert_tlb_11 spc,pte,prot 1487 1434 ··· 1493 1438 iitlbp prot,(%sr1,va) 1494 1439 1495 1440 mtsp t0, %sr1 /* Restore sr1 */ 1441 + dbit_unlock1 spc,t0 1496 1442 1497 1443 rfir 1498 1444 nop ··· 1515 1459 1516 1460 L2_ptep ptp,pte,t0,va,itlb_fault 1517 1461 1518 - update_ptep ptp,pte,t0,t1 1462 + dbit_lock spc,t0,t1 1463 + update_ptep spc,ptp,pte,t0,t1 1519 1464 1520 1465 make_insert_tlb spc,pte,prot 1521 1466 1522 1467 f_extend pte,t0 1523 1468 1524 1469 iitlbt pte,prot 1470 + dbit_unlock1 spc,t0 1525 1471 1526 1472 rfir 1527 1473 nop ··· 1535 1477 1536 1478 L2_ptep ptp,pte,t0,va,naitlb_check_alias_20 1537 1479 1538 - update_ptep ptp,pte,t0,t1 1480 + dbit_lock spc,t0,t1 1481 + update_ptep spc,ptp,pte,t0,t1 1539 1482 1540 1483 make_insert_tlb spc,pte,prot 1541 1484 1542 1485 f_extend pte,t0 1543 1486 1544 1487 iitlbt pte,prot 1488 + dbit_unlock1 spc,t0 1545 1489 1546 1490 rfir 1547 1491 nop ··· 1567 1507 1568 1508 L3_ptep ptp,pte,t0,va,dbit_fault 1569 1509 1570 - #ifdef CONFIG_SMP 1571 - cmpib,COND(=),n 0,spc,dbit_nolock_20w 1572 - load32 PA(pa_dbit_lock),t0 1573 - 1574 - dbit_spin_20w: 1575 - LDCW 0(t0),t1 1576 - cmpib,COND(=) 0,t1,dbit_spin_20w 1577 - nop 1578 - 1579 - dbit_nolock_20w: 1580 - #endif 1581 - update_dirty ptp,pte,t1 1510 + dbit_lock spc,t0,t1 1511 + update_dirty spc,ptp,pte,t1 1582 1512 1583 1513 make_insert_tlb spc,pte,prot 1584 1514 1585 1515 idtlbt pte,prot 1586 - #ifdef CONFIG_SMP 1587 - cmpib,COND(=),n 0,spc,dbit_nounlock_20w 1588 - ldi 1,t1 1589 - stw t1,0(t0) 1590 - 1591 - dbit_nounlock_20w: 1592 - #endif 1516 + dbit_unlock0 spc,t0 1593 1517 1594 1518 rfir 1595 1519 nop ··· 1587 1543 1588 1544 L2_ptep ptp,pte,t0,va,dbit_fault 1589 1545 1590 - #ifdef CONFIG_SMP 1591 - cmpib,COND(=),n 0,spc,dbit_nolock_11 1592 - load32 PA(pa_dbit_lock),t0 1593 - 1594 - dbit_spin_11: 1595 - LDCW 0(t0),t1 1596 - cmpib,= 0,t1,dbit_spin_11 1597 - nop 1598 - 1599 - dbit_nolock_11: 1600 - #endif 1601 - update_dirty ptp,pte,t1 1546 + dbit_lock spc,t0,t1 1547 + update_dirty spc,ptp,pte,t1 1602 1548 1603 1549 make_insert_tlb_11 spc,pte,prot 1604 1550 ··· 1599 1565 idtlbp prot,(%sr1,va) 1600 1566 1601 1567 mtsp t1, %sr1 /* Restore sr1 */ 1602 - #ifdef CONFIG_SMP 1603 - cmpib,COND(=),n 0,spc,dbit_nounlock_11 1604 - ldi 1,t1 1605 - stw t1,0(t0) 1606 - 1607 - dbit_nounlock_11: 1608 - #endif 1568 + dbit_unlock0 spc,t0 1609 1569 1610 1570 rfir 1611 1571 nop ··· 1611 1583 1612 1584 L2_ptep ptp,pte,t0,va,dbit_fault 1613 1585 1614 - #ifdef CONFIG_SMP 1615 - cmpib,COND(=),n 0,spc,dbit_nolock_20 1616 - load32 PA(pa_dbit_lock),t0 1617 - 1618 - dbit_spin_20: 1619 - LDCW 0(t0),t1 1620 - cmpib,= 0,t1,dbit_spin_20 1621 - nop 1622 - 1623 - dbit_nolock_20: 1624 - #endif 1625 - update_dirty ptp,pte,t1 1586 + dbit_lock spc,t0,t1 1587 + update_dirty spc,ptp,pte,t1 1626 1588 1627 1589 make_insert_tlb spc,pte,prot 1628 1590 1629 1591 f_extend pte,t1 1630 1592 1631 1593 idtlbt pte,prot 1632 - 1633 - #ifdef CONFIG_SMP 1634 - cmpib,COND(=),n 0,spc,dbit_nounlock_20 1635 - ldi 1,t1 1636 - stw t1,0(t0) 1637 - 1638 - dbit_nounlock_20: 1639 - #endif 1594 + dbit_unlock0 spc,t0 1640 1595 1641 1596 rfir 1642 1597 nop
+87 -14
arch/parisc/kernel/irq.c
··· 166 166 seq_printf(p, "%*s: ", prec, "STK"); 167 167 for_each_online_cpu(j) 168 168 seq_printf(p, "%10u ", irq_stats(j)->kernel_stack_usage); 169 - seq_printf(p, " Kernel stack usage\n"); 169 + seq_puts(p, " Kernel stack usage\n"); 170 + # ifdef CONFIG_IRQSTACKS 171 + seq_printf(p, "%*s: ", prec, "IST"); 172 + for_each_online_cpu(j) 173 + seq_printf(p, "%10u ", irq_stats(j)->irq_stack_usage); 174 + seq_puts(p, " Interrupt stack usage\n"); 175 + seq_printf(p, "%*s: ", prec, "ISC"); 176 + for_each_online_cpu(j) 177 + seq_printf(p, "%10u ", irq_stats(j)->irq_stack_counter); 178 + seq_puts(p, " Interrupt stack usage counter\n"); 179 + # endif 170 180 #endif 171 181 #ifdef CONFIG_SMP 172 182 seq_printf(p, "%*s: ", prec, "RES"); 173 183 for_each_online_cpu(j) 174 184 seq_printf(p, "%10u ", irq_stats(j)->irq_resched_count); 175 - seq_printf(p, " Rescheduling interrupts\n"); 185 + seq_puts(p, " Rescheduling interrupts\n"); 176 186 seq_printf(p, "%*s: ", prec, "CAL"); 177 187 for_each_online_cpu(j) 178 188 seq_printf(p, "%10u ", irq_stats(j)->irq_call_count); 179 - seq_printf(p, " Function call interrupts\n"); 189 + seq_puts(p, " Function call interrupts\n"); 180 190 #endif 181 191 seq_printf(p, "%*s: ", prec, "TLB"); 182 192 for_each_online_cpu(j) 183 193 seq_printf(p, "%10u ", irq_stats(j)->irq_tlb_count); 184 - seq_printf(p, " TLB shootdowns\n"); 194 + seq_puts(p, " TLB shootdowns\n"); 185 195 return 0; 186 196 } 187 197 ··· 388 378 unsigned long sp = regs->gr[30]; 389 379 unsigned long stack_usage; 390 380 unsigned int *last_usage; 381 + int cpu = smp_processor_id(); 391 382 392 383 /* if sr7 != 0, we interrupted a userspace process which we do not want 393 384 * to check for stack overflow. We will only check the kernel stack. */ ··· 397 386 398 387 /* calculate kernel stack usage */ 399 388 stack_usage = sp - stack_start; 400 - last_usage = &per_cpu(irq_stat.kernel_stack_usage, smp_processor_id()); 389 + #ifdef CONFIG_IRQSTACKS 390 + if (likely(stack_usage <= THREAD_SIZE)) 391 + goto check_kernel_stack; /* found kernel stack */ 392 + 393 + /* check irq stack usage */ 394 + stack_start = (unsigned long) &per_cpu(irq_stack_union, cpu).stack; 395 + stack_usage = sp - stack_start; 396 + 397 + last_usage = &per_cpu(irq_stat.irq_stack_usage, cpu); 398 + if (unlikely(stack_usage > *last_usage)) 399 + *last_usage = stack_usage; 400 + 401 + if (likely(stack_usage < (IRQ_STACK_SIZE - STACK_MARGIN))) 402 + return; 403 + 404 + pr_emerg("stackcheck: %s will most likely overflow irq stack " 405 + "(sp:%lx, stk bottom-top:%lx-%lx)\n", 406 + current->comm, sp, stack_start, stack_start + IRQ_STACK_SIZE); 407 + goto panic_check; 408 + 409 + check_kernel_stack: 410 + #endif 411 + 412 + /* check kernel stack usage */ 413 + last_usage = &per_cpu(irq_stat.kernel_stack_usage, cpu); 401 414 402 415 if (unlikely(stack_usage > *last_usage)) 403 416 *last_usage = stack_usage; ··· 433 398 "(sp:%lx, stk bottom-top:%lx-%lx)\n", 434 399 current->comm, sp, stack_start, stack_start + THREAD_SIZE); 435 400 401 + #ifdef CONFIG_IRQSTACKS 402 + panic_check: 403 + #endif 436 404 if (sysctl_panic_on_stackoverflow) 437 405 panic("low stack detected by irq handler - check messages\n"); 438 406 #endif 439 407 } 440 408 441 409 #ifdef CONFIG_IRQSTACKS 442 - DEFINE_PER_CPU(union irq_stack_union, irq_stack_union); 410 + DEFINE_PER_CPU(union irq_stack_union, irq_stack_union) = { 411 + .lock = __RAW_SPIN_LOCK_UNLOCKED((irq_stack_union).lock) 412 + }; 443 413 444 414 static void execute_on_irq_stack(void *func, unsigned long param1) 445 415 { 446 - unsigned long *irq_stack_start; 416 + union irq_stack_union *union_ptr; 447 417 unsigned long irq_stack; 448 - int cpu = smp_processor_id(); 418 + raw_spinlock_t *irq_stack_in_use; 449 419 450 - irq_stack_start = &per_cpu(irq_stack_union, cpu).stack[0]; 451 - irq_stack = (unsigned long) irq_stack_start; 452 - irq_stack = ALIGN(irq_stack, 16); /* align for stack frame usage */ 420 + union_ptr = &per_cpu(irq_stack_union, smp_processor_id()); 421 + irq_stack = (unsigned long) &union_ptr->stack; 422 + irq_stack = ALIGN(irq_stack + sizeof(irq_stack_union.lock), 423 + 64); /* align for stack frame usage */ 453 424 454 - BUG_ON(*irq_stack_start); /* report bug if we were called recursive. */ 455 - *irq_stack_start = 1; 425 + /* We may be called recursive. If we are already using the irq stack, 426 + * just continue to use it. Use spinlocks to serialize 427 + * the irq stack usage. 428 + */ 429 + irq_stack_in_use = &union_ptr->lock; 430 + if (!raw_spin_trylock(irq_stack_in_use)) { 431 + void (*direct_call)(unsigned long p1) = func; 432 + 433 + /* We are using the IRQ stack already. 434 + * Do direct call on current stack. */ 435 + direct_call(param1); 436 + return; 437 + } 456 438 457 439 /* This is where we switch to the IRQ stack. */ 458 440 call_on_stack(param1, func, irq_stack); 459 441 460 - *irq_stack_start = 0; 442 + __inc_irq_stat(irq_stack_counter); 443 + 444 + /* free up irq stack usage. */ 445 + do_raw_spin_unlock(irq_stack_in_use); 446 + } 447 + 448 + asmlinkage void do_softirq(void) 449 + { 450 + __u32 pending; 451 + unsigned long flags; 452 + 453 + if (in_interrupt()) 454 + return; 455 + 456 + local_irq_save(flags); 457 + 458 + pending = local_softirq_pending(); 459 + 460 + if (pending) 461 + execute_on_irq_stack(__do_softirq, 0); 462 + 463 + local_irq_restore(flags); 461 464 } 462 465 #endif /* CONFIG_IRQSTACKS */ 463 466
+2 -2
arch/parisc/mm/init.c
··· 1069 1069 { 1070 1070 int do_recycle; 1071 1071 1072 - inc_irq_stat(irq_tlb_count); 1072 + __inc_irq_stat(irq_tlb_count); 1073 1073 do_recycle = 0; 1074 1074 spin_lock(&sid_lock); 1075 1075 if (dirty_space_ids > RECYCLE_THRESHOLD) { ··· 1090 1090 #else 1091 1091 void flush_tlb_all(void) 1092 1092 { 1093 - inc_irq_stat(irq_tlb_count); 1093 + __inc_irq_stat(irq_tlb_count); 1094 1094 spin_lock(&sid_lock); 1095 1095 flush_tlb_all_local(NULL); 1096 1096 recycle_sids();
+23
arch/powerpc/Kconfig.debug
··· 262 262 Select this to enable early debugging for the PowerNV platform 263 263 using an "hvsi" console 264 264 265 + config PPC_EARLY_DEBUG_MEMCONS 266 + bool "In memory console" 267 + help 268 + Select this to enable early debugging using an in memory console. 269 + This console provides input and output buffers stored within the 270 + kernel BSS and should be safe to select on any system. A debugger 271 + can then be used to read kernel output or send input to the console. 265 272 endchoice 273 + 274 + config PPC_MEMCONS_OUTPUT_SIZE 275 + int "In memory console output buffer size" 276 + depends on PPC_EARLY_DEBUG_MEMCONS 277 + default 4096 278 + help 279 + Selects the size of the output buffer (in bytes) of the in memory 280 + console. 281 + 282 + config PPC_MEMCONS_INPUT_SIZE 283 + int "In memory console input buffer size" 284 + depends on PPC_EARLY_DEBUG_MEMCONS 285 + default 128 286 + help 287 + Selects the size of the input buffer (in bytes) of the in memory 288 + console. 266 289 267 290 config PPC_EARLY_DEBUG_OPAL 268 291 def_bool y
+10
arch/powerpc/include/asm/context_tracking.h
··· 1 + #ifndef _ASM_POWERPC_CONTEXT_TRACKING_H 2 + #define _ASM_POWERPC_CONTEXT_TRACKING_H 3 + 4 + #ifdef CONFIG_CONTEXT_TRACKING 5 + #define SCHEDULE_USER bl .schedule_user 6 + #else 7 + #define SCHEDULE_USER bl .schedule 8 + #endif 9 + 10 + #endif
+3 -1
arch/powerpc/include/asm/firmware.h
··· 52 52 #define FW_FEATURE_BEST_ENERGY ASM_CONST(0x0000000080000000) 53 53 #define FW_FEATURE_TYPE1_AFFINITY ASM_CONST(0x0000000100000000) 54 54 #define FW_FEATURE_PRRN ASM_CONST(0x0000000200000000) 55 + #define FW_FEATURE_OPALv3 ASM_CONST(0x0000000400000000) 55 56 56 57 #ifndef __ASSEMBLY__ 57 58 ··· 70 69 FW_FEATURE_SET_MODE | FW_FEATURE_BEST_ENERGY | 71 70 FW_FEATURE_TYPE1_AFFINITY | FW_FEATURE_PRRN, 72 71 FW_FEATURE_PSERIES_ALWAYS = 0, 73 - FW_FEATURE_POWERNV_POSSIBLE = FW_FEATURE_OPAL | FW_FEATURE_OPALv2, 72 + FW_FEATURE_POWERNV_POSSIBLE = FW_FEATURE_OPAL | FW_FEATURE_OPALv2 | 73 + FW_FEATURE_OPALv3, 74 74 FW_FEATURE_POWERNV_ALWAYS = 0, 75 75 FW_FEATURE_PS3_POSSIBLE = FW_FEATURE_LPAR | FW_FEATURE_PS3_LV1, 76 76 FW_FEATURE_PS3_ALWAYS = FW_FEATURE_LPAR | FW_FEATURE_PS3_LV1,
+3 -2
arch/powerpc/include/asm/hw_irq.h
··· 96 96 #endif 97 97 98 98 #define hard_irq_disable() do { \ 99 + u8 _was_enabled = get_paca()->soft_enabled; \ 99 100 __hard_irq_disable(); \ 100 - if (local_paca->soft_enabled) \ 101 - trace_hardirqs_off(); \ 102 101 get_paca()->soft_enabled = 0; \ 103 102 get_paca()->irq_happened |= PACA_IRQ_HARD_DIS; \ 103 + if (_was_enabled) \ 104 + trace_hardirqs_off(); \ 104 105 } while(0) 105 106 106 107 static inline bool lazy_irq_pending(void)
+4 -1
arch/powerpc/include/asm/opal.h
··· 243 243 244 244 enum OpalThreadStatus { 245 245 OPAL_THREAD_INACTIVE = 0x0, 246 - OPAL_THREAD_STARTED = 0x1 246 + OPAL_THREAD_STARTED = 0x1, 247 + OPAL_THREAD_UNAVAILABLE = 0x2 /* opal-v3 */ 247 248 }; 248 249 249 250 enum OpalPciBusCompare { ··· 563 562 extern void opal_nvram_init(void); 564 563 565 564 extern int opal_machine_check(struct pt_regs *regs); 565 + 566 + extern void opal_shutdown(void); 566 567 567 568 #endif /* __ASSEMBLY__ */ 568 569
+1 -1
arch/powerpc/include/asm/pgalloc-64.h
··· 186 186 187 187 static inline pgtable_t pmd_pgtable(pmd_t pmd) 188 188 { 189 - return (pgtable_t)(pmd_val(pmd) & -sizeof(pte_t)*PTRS_PER_PTE); 189 + return (pgtable_t)(pmd_val(pmd) & ~PMD_MASKED_BITS); 190 190 } 191 191 192 192 static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
+1 -1
arch/powerpc/include/asm/pte-hash64-64k.h
··· 47 47 * generic accessors and iterators here 48 48 */ 49 49 #define __real_pte(e,p) ((real_pte_t) { \ 50 - (e), ((e) & _PAGE_COMBO) ? \ 50 + (e), (pte_val(e) & _PAGE_COMBO) ? \ 51 51 (pte_val(*((p) + PTRS_PER_PTE))) : 0 }) 52 52 #define __rpte_to_hidx(r,index) ((pte_val((r).pte) & _PAGE_COMBO) ? \ 53 53 (((r).hidx >> ((index)<<2)) & 0xf) : ((pte_val((r).pte) >> 12) & 0xf))
+2
arch/powerpc/include/asm/rtas.h
··· 264 264 extern void rtas_initialize(void); 265 265 extern int rtas_suspend_cpu(struct rtas_suspend_me_data *data); 266 266 extern int rtas_suspend_last_cpu(struct rtas_suspend_me_data *data); 267 + extern int rtas_online_cpus_mask(cpumask_var_t cpus); 268 + extern int rtas_offline_cpus_mask(cpumask_var_t cpus); 267 269 extern int rtas_ibm_suspend_me(struct rtas_args *); 268 270 269 271 struct rtc_time;
+5 -2
arch/powerpc/include/asm/thread_info.h
··· 97 97 #define TIF_PERFMON_CTXSW 6 /* perfmon needs ctxsw calls */ 98 98 #define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */ 99 99 #define TIF_SINGLESTEP 8 /* singlestepping active */ 100 - #define TIF_MEMDIE 9 /* is terminating due to OOM killer */ 100 + #define TIF_NOHZ 9 /* in adaptive nohz mode */ 101 101 #define TIF_SECCOMP 10 /* secure computing */ 102 102 #define TIF_RESTOREALL 11 /* Restore all regs (implies NOERROR) */ 103 103 #define TIF_NOERROR 12 /* Force successful syscall return */ ··· 106 106 #define TIF_SYSCALL_TRACEPOINT 15 /* syscall tracepoint instrumentation */ 107 107 #define TIF_EMULATE_STACK_STORE 16 /* Is an instruction emulation 108 108 for stack store? */ 109 + #define TIF_MEMDIE 17 /* is terminating due to OOM killer */ 109 110 110 111 /* as above, but as bit values */ 111 112 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) ··· 125 124 #define _TIF_UPROBE (1<<TIF_UPROBE) 126 125 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT) 127 126 #define _TIF_EMULATE_STACK_STORE (1<<TIF_EMULATE_STACK_STORE) 127 + #define _TIF_NOHZ (1<<TIF_NOHZ) 128 128 #define _TIF_SYSCALL_T_OR_A (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \ 129 - _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT) 129 + _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT | \ 130 + _TIF_NOHZ) 130 131 131 132 #define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \ 132 133 _TIF_NOTIFY_RESUME | _TIF_UPROBE)
+1
arch/powerpc/include/asm/udbg.h
··· 52 52 extern void __init udbg_init_cpm(void); 53 53 extern void __init udbg_init_usbgecko(void); 54 54 extern void __init udbg_init_wsp(void); 55 + extern void __init udbg_init_memcons(void); 55 56 extern void __init udbg_init_ehv_bc(void); 56 57 extern void __init udbg_init_ps3gelic(void); 57 58 extern void __init udbg_init_debug_opal_raw(void);
-2
arch/powerpc/kernel/entry_32.S
··· 439 439 ret_from_kernel_thread: 440 440 REST_NVGPRS(r1) 441 441 bl schedule_tail 442 - li r3,0 443 - stw r3,0(r1) 444 442 mtlr r14 445 443 mr r3,r15 446 444 PPC440EP_ERR42
+2 -3
arch/powerpc/kernel/entry_64.S
··· 33 33 #include <asm/irqflags.h> 34 34 #include <asm/ftrace.h> 35 35 #include <asm/hw_irq.h> 36 + #include <asm/context_tracking.h> 36 37 37 38 /* 38 39 * System calls. ··· 377 376 _GLOBAL(ret_from_kernel_thread) 378 377 bl .schedule_tail 379 378 REST_NVGPRS(r1) 380 - li r3,0 381 - std r3,0(r1) 382 379 ld r14, 0(r14) 383 380 mtlr r14 384 381 mr r3,r15 ··· 633 634 andi. r0,r4,_TIF_NEED_RESCHED 634 635 beq 1f 635 636 bl .restore_interrupts 636 - bl .schedule 637 + SCHEDULE_USER 637 638 b .ret_from_except_lite 638 639 639 640 1: bl .save_nvgprs
+4 -4
arch/powerpc/kernel/exceptions-64e.S
··· 489 489 */ 490 490 491 491 mfspr r14,SPRN_DBSR /* check single-step/branch taken */ 492 - andis. r15,r14,DBSR_IC@h 492 + andis. r15,r14,(DBSR_IC|DBSR_BT)@h 493 493 beq+ 1f 494 494 495 495 LOAD_REG_IMMEDIATE(r14,interrupt_base_book3e) ··· 500 500 bge+ cr1,1f 501 501 502 502 /* here it looks like we got an inappropriate debug exception. */ 503 - lis r14,DBSR_IC@h /* clear the IC event */ 503 + lis r14,(DBSR_IC|DBSR_BT)@h /* clear the event */ 504 504 rlwinm r11,r11,0,~MSR_DE /* clear DE in the CSRR1 value */ 505 505 mtspr SPRN_DBSR,r14 506 506 mtspr SPRN_CSRR1,r11 ··· 555 555 */ 556 556 557 557 mfspr r14,SPRN_DBSR /* check single-step/branch taken */ 558 - andis. r15,r14,DBSR_IC@h 558 + andis. r15,r14,(DBSR_IC|DBSR_BT)@h 559 559 beq+ 1f 560 560 561 561 LOAD_REG_IMMEDIATE(r14,interrupt_base_book3e) ··· 566 566 bge+ cr1,1f 567 567 568 568 /* here it looks like we got an inappropriate debug exception. */ 569 - lis r14,DBSR_IC@h /* clear the IC event */ 569 + lis r14,(DBSR_IC|DBSR_BT)@h /* clear the event */ 570 570 rlwinm r11,r11,0,~MSR_DE /* clear DE in the DSRR1 value */ 571 571 mtspr SPRN_DBSR,r14 572 572 mtspr SPRN_DSRR1,r11
+4
arch/powerpc/kernel/machine_kexec_64.c
··· 17 17 #include <linux/errno.h> 18 18 #include <linux/kernel.h> 19 19 #include <linux/cpu.h> 20 + #include <linux/hardirq.h> 20 21 21 22 #include <asm/page.h> 22 23 #include <asm/current.h> ··· 336 335 pr_debug("kexec: Starting switchover sequence.\n"); 337 336 338 337 /* switch to a staticly allocated stack. Based on irq stack code. 338 + * We setup preempt_count to avoid using VMX in memcpy. 339 339 * XXX: the task struct will likely be invalid once we do the copy! 340 340 */ 341 341 kexec_stack.thread_info.task = current_thread_info()->task; 342 342 kexec_stack.thread_info.flags = 0; 343 + kexec_stack.thread_info.preempt_count = HARDIRQ_OFFSET; 344 + kexec_stack.thread_info.cpu = current_thread_info()->cpu; 343 345 344 346 /* We need a static PACA, too; copy this CPU's PACA over and switch to 345 347 * it. Also poison per_cpu_offset to catch anyone using non-static
+11
arch/powerpc/kernel/misc_32.S
··· 657 657 li r3,2 658 658 blr 659 659 660 + _GLOBAL(__bswapdi2) 661 + rotlwi r9,r4,8 662 + rotlwi r10,r3,8 663 + rlwimi r9,r4,24,0,7 664 + rlwimi r10,r3,24,0,7 665 + rlwimi r9,r4,24,16,23 666 + rlwimi r10,r3,24,16,23 667 + mr r3,r9 668 + mr r4,r10 669 + blr 670 + 660 671 _GLOBAL(abs) 661 672 srawi r4,r3,31 662 673 xor r3,r3,r4
+11
arch/powerpc/kernel/misc_64.S
··· 234 234 isync 235 235 blr 236 236 237 + _GLOBAL(__bswapdi2) 238 + srdi r8,r3,32 239 + rlwinm r7,r3,8,0xffffffff 240 + rlwimi r7,r3,24,0,7 241 + rlwinm r9,r8,8,0xffffffff 242 + rlwimi r7,r3,24,16,23 243 + rlwimi r9,r8,24,0,7 244 + rlwimi r9,r8,24,16,23 245 + sldi r7,r7,32 246 + or r3,r7,r9 247 + blr 237 248 238 249 #if defined(CONFIG_PPC_PMAC) || defined(CONFIG_PPC_MAPLE) 239 250 /*
+2 -3
arch/powerpc/kernel/pci-common.c
··· 359 359 enum pci_mmap_state mmap_state, 360 360 int write_combine) 361 361 { 362 - unsigned long prot = pgprot_val(protection); 363 362 364 363 /* Write combine is always 0 on non-memory space mappings. On 365 364 * memory space, if the user didn't pass 1, we check for a ··· 375 376 376 377 /* XXX would be nice to have a way to ask for write-through */ 377 378 if (write_combine) 378 - return pgprot_noncached_wc(prot); 379 + return pgprot_noncached_wc(protection); 379 380 else 380 - return pgprot_noncached(prot); 381 + return pgprot_noncached(protection); 381 382 } 382 383 383 384 /*
+2 -1
arch/powerpc/kernel/ppc_ksyms.c
··· 143 143 int __ucmpdi2(unsigned long long, unsigned long long); 144 144 EXPORT_SYMBOL(__ucmpdi2); 145 145 #endif 146 - 146 + long long __bswapdi2(long long); 147 + EXPORT_SYMBOL(__bswapdi2); 147 148 EXPORT_SYMBOL(memcpy); 148 149 EXPORT_SYMBOL(memset); 149 150 EXPORT_SYMBOL(memmove);
+8
arch/powerpc/kernel/process.c
··· 339 339 340 340 static void prime_debug_regs(struct thread_struct *thread) 341 341 { 342 + /* 343 + * We could have inherited MSR_DE from userspace, since 344 + * it doesn't get cleared on exception entry. Make sure 345 + * MSR_DE is clear before we enable any debug events. 346 + */ 347 + mtmsr(mfmsr() & ~MSR_DE); 348 + 342 349 mtspr(SPRN_IAC1, thread->iac1); 343 350 mtspr(SPRN_IAC2, thread->iac2); 344 351 #if CONFIG_PPC_ADV_DEBUG_IACS > 2 ··· 978 971 * do some house keeping and then return from the fork or clone 979 972 * system call, using the stack frame created above. 980 973 */ 974 + ((unsigned long *)sp)[0] = 0; 981 975 sp -= sizeof(struct pt_regs); 982 976 kregs = (struct pt_regs *) sp; 983 977 sp -= STACK_FRAME_OVERHEAD;
+5
arch/powerpc/kernel/ptrace.c
··· 32 32 #include <trace/syscall.h> 33 33 #include <linux/hw_breakpoint.h> 34 34 #include <linux/perf_event.h> 35 + #include <linux/context_tracking.h> 35 36 36 37 #include <asm/uaccess.h> 37 38 #include <asm/page.h> ··· 1789 1788 { 1790 1789 long ret = 0; 1791 1790 1791 + user_exit(); 1792 + 1792 1793 secure_computing_strict(regs->gpr[0]); 1793 1794 1794 1795 if (test_thread_flag(TIF_SYSCALL_TRACE) && ··· 1835 1832 step = test_thread_flag(TIF_SINGLESTEP); 1836 1833 if (step || test_thread_flag(TIF_SYSCALL_TRACE)) 1837 1834 tracehook_report_syscall_exit(regs, step); 1835 + 1836 + user_enter(); 1838 1837 }
+113
arch/powerpc/kernel/rtas.c
··· 19 19 #include <linux/init.h> 20 20 #include <linux/capability.h> 21 21 #include <linux/delay.h> 22 + #include <linux/cpu.h> 22 23 #include <linux/smp.h> 23 24 #include <linux/completion.h> 24 25 #include <linux/cpumask.h> ··· 808 807 __rtas_suspend_cpu((struct rtas_suspend_me_data *)info, 1); 809 808 } 810 809 810 + enum rtas_cpu_state { 811 + DOWN, 812 + UP, 813 + }; 814 + 815 + #ifndef CONFIG_SMP 816 + static int rtas_cpu_state_change_mask(enum rtas_cpu_state state, 817 + cpumask_var_t cpus) 818 + { 819 + if (!cpumask_empty(cpus)) { 820 + cpumask_clear(cpus); 821 + return -EINVAL; 822 + } else 823 + return 0; 824 + } 825 + #else 826 + /* On return cpumask will be altered to indicate CPUs changed. 827 + * CPUs with states changed will be set in the mask, 828 + * CPUs with status unchanged will be unset in the mask. */ 829 + static int rtas_cpu_state_change_mask(enum rtas_cpu_state state, 830 + cpumask_var_t cpus) 831 + { 832 + int cpu; 833 + int cpuret = 0; 834 + int ret = 0; 835 + 836 + if (cpumask_empty(cpus)) 837 + return 0; 838 + 839 + for_each_cpu(cpu, cpus) { 840 + switch (state) { 841 + case DOWN: 842 + cpuret = cpu_down(cpu); 843 + break; 844 + case UP: 845 + cpuret = cpu_up(cpu); 846 + break; 847 + } 848 + if (cpuret) { 849 + pr_debug("%s: cpu_%s for cpu#%d returned %d.\n", 850 + __func__, 851 + ((state == UP) ? "up" : "down"), 852 + cpu, cpuret); 853 + if (!ret) 854 + ret = cpuret; 855 + if (state == UP) { 856 + /* clear bits for unchanged cpus, return */ 857 + cpumask_shift_right(cpus, cpus, cpu); 858 + cpumask_shift_left(cpus, cpus, cpu); 859 + break; 860 + } else { 861 + /* clear bit for unchanged cpu, continue */ 862 + cpumask_clear_cpu(cpu, cpus); 863 + } 864 + } 865 + } 866 + 867 + return ret; 868 + } 869 + #endif 870 + 871 + int rtas_online_cpus_mask(cpumask_var_t cpus) 872 + { 873 + int ret; 874 + 875 + ret = rtas_cpu_state_change_mask(UP, cpus); 876 + 877 + if (ret) { 878 + cpumask_var_t tmp_mask; 879 + 880 + if (!alloc_cpumask_var(&tmp_mask, GFP_TEMPORARY)) 881 + return ret; 882 + 883 + /* Use tmp_mask to preserve cpus mask from first failure */ 884 + cpumask_copy(tmp_mask, cpus); 885 + rtas_offline_cpus_mask(tmp_mask); 886 + free_cpumask_var(tmp_mask); 887 + } 888 + 889 + return ret; 890 + } 891 + EXPORT_SYMBOL(rtas_online_cpus_mask); 892 + 893 + int rtas_offline_cpus_mask(cpumask_var_t cpus) 894 + { 895 + return rtas_cpu_state_change_mask(DOWN, cpus); 896 + } 897 + EXPORT_SYMBOL(rtas_offline_cpus_mask); 898 + 811 899 int rtas_ibm_suspend_me(struct rtas_args *args) 812 900 { 813 901 long state; ··· 904 814 unsigned long retbuf[PLPAR_HCALL_BUFSIZE]; 905 815 struct rtas_suspend_me_data data; 906 816 DECLARE_COMPLETION_ONSTACK(done); 817 + cpumask_var_t offline_mask; 818 + int cpuret; 907 819 908 820 if (!rtas_service_present("ibm,suspend-me")) 909 821 return -ENOSYS; ··· 929 837 return 0; 930 838 } 931 839 840 + if (!alloc_cpumask_var(&offline_mask, GFP_TEMPORARY)) 841 + return -ENOMEM; 842 + 932 843 atomic_set(&data.working, 0); 933 844 atomic_set(&data.done, 0); 934 845 atomic_set(&data.error, 0); 935 846 data.token = rtas_token("ibm,suspend-me"); 936 847 data.complete = &done; 848 + 849 + /* All present CPUs must be online */ 850 + cpumask_andnot(offline_mask, cpu_present_mask, cpu_online_mask); 851 + cpuret = rtas_online_cpus_mask(offline_mask); 852 + if (cpuret) { 853 + pr_err("%s: Could not bring present CPUs online.\n", __func__); 854 + atomic_set(&data.error, cpuret); 855 + goto out; 856 + } 857 + 937 858 stop_topology_update(); 938 859 939 860 /* Call function on all CPUs. One of us will make the ··· 962 857 963 858 start_topology_update(); 964 859 860 + /* Take down CPUs not online prior to suspend */ 861 + cpuret = rtas_offline_cpus_mask(offline_mask); 862 + if (cpuret) 863 + pr_warn("%s: Could not restore CPUs to offline state.\n", 864 + __func__); 865 + 866 + out: 867 + free_cpumask_var(offline_mask); 965 868 return atomic_read(&data.error); 966 869 } 967 870 #else /* CONFIG_PPC_PSERIES */
+6 -4
arch/powerpc/kernel/rtas_flash.c
··· 89 89 90 90 /* Array sizes */ 91 91 #define VALIDATE_BUF_SIZE 4096 92 + #define VALIDATE_MSG_LEN 256 92 93 #define RTAS_MSG_MAXLEN 64 93 94 94 95 /* Quirk - RTAS requires 4k list length and block size */ ··· 467 466 } 468 467 469 468 static int get_validate_flash_msg(struct rtas_validate_flash_t *args_buf, 470 - char *msg) 469 + char *msg, int msglen) 471 470 { 472 471 int n; 473 472 ··· 475 474 n = sprintf(msg, "%d\n", args_buf->update_results); 476 475 if ((args_buf->update_results >= VALIDATE_CUR_UNKNOWN) || 477 476 (args_buf->update_results == VALIDATE_TMP_UPDATE)) 478 - n += sprintf(msg + n, "%s\n", args_buf->buf); 477 + n += snprintf(msg + n, msglen - n, "%s\n", 478 + args_buf->buf); 479 479 } else { 480 480 n = sprintf(msg, "%d\n", args_buf->status); 481 481 } ··· 488 486 { 489 487 struct rtas_validate_flash_t *const args_buf = 490 488 &rtas_validate_flash_data; 491 - char msg[RTAS_MSG_MAXLEN]; 489 + char msg[VALIDATE_MSG_LEN]; 492 490 int msglen; 493 491 494 492 mutex_lock(&rtas_validate_flash_mutex); 495 - msglen = get_validate_flash_msg(args_buf, msg); 493 + msglen = get_validate_flash_msg(args_buf, msg, VALIDATE_MSG_LEN); 496 494 mutex_unlock(&rtas_validate_flash_mutex); 497 495 498 496 return simple_read_from_buffer(buf, count, ppos, msg, msglen);
+6 -1
arch/powerpc/kernel/signal.c
··· 13 13 #include <linux/signal.h> 14 14 #include <linux/uprobes.h> 15 15 #include <linux/key.h> 16 + #include <linux/context_tracking.h> 16 17 #include <asm/hw_breakpoint.h> 17 18 #include <asm/uaccess.h> 18 19 #include <asm/unistd.h> ··· 25 24 * through debug.exception-trace sysctl. 26 25 */ 27 26 28 - int show_unhandled_signals = 0; 27 + int show_unhandled_signals = 1; 29 28 30 29 /* 31 30 * Allocate space for the signal frame ··· 160 159 161 160 void do_notify_resume(struct pt_regs *regs, unsigned long thread_info_flags) 162 161 { 162 + user_exit(); 163 + 163 164 if (thread_info_flags & _TIF_UPROBE) 164 165 uprobe_notify_resume(regs); 165 166 ··· 172 169 clear_thread_flag(TIF_NOTIFY_RESUME); 173 170 tracehook_notify_resume(regs); 174 171 } 172 + 173 + user_enter(); 175 174 }
+58 -22
arch/powerpc/kernel/traps.c
··· 35 35 #include <linux/kdebug.h> 36 36 #include <linux/debugfs.h> 37 37 #include <linux/ratelimit.h> 38 + #include <linux/context_tracking.h> 38 39 39 40 #include <asm/emulated_ops.h> 40 41 #include <asm/pgtable.h> ··· 668 667 669 668 void machine_check_exception(struct pt_regs *regs) 670 669 { 670 + enum ctx_state prev_state = exception_enter(); 671 671 int recover = 0; 672 672 673 673 __get_cpu_var(irq_stat).mce_exceptions++; ··· 685 683 recover = cur_cpu_spec->machine_check(regs); 686 684 687 685 if (recover > 0) 688 - return; 686 + goto bail; 689 687 690 688 #if defined(CONFIG_8xx) && defined(CONFIG_PCI) 691 689 /* the qspan pci read routines can cause machine checks -- Cort ··· 695 693 * -- BenH 696 694 */ 697 695 bad_page_fault(regs, regs->dar, SIGBUS); 698 - return; 696 + goto bail; 699 697 #endif 700 698 701 699 if (debugger_fault_handler(regs)) 702 - return; 700 + goto bail; 703 701 704 702 if (check_io_access(regs)) 705 - return; 703 + goto bail; 706 704 707 705 die("Machine check", regs, SIGBUS); 708 706 709 707 /* Must die if the interrupt is not recoverable */ 710 708 if (!(regs->msr & MSR_RI)) 711 709 panic("Unrecoverable Machine check"); 710 + 711 + bail: 712 + exception_exit(prev_state); 712 713 } 713 714 714 715 void SMIException(struct pt_regs *regs) ··· 721 716 722 717 void unknown_exception(struct pt_regs *regs) 723 718 { 719 + enum ctx_state prev_state = exception_enter(); 720 + 724 721 printk("Bad trap at PC: %lx, SR: %lx, vector=%lx\n", 725 722 regs->nip, regs->msr, regs->trap); 726 723 727 724 _exception(SIGTRAP, regs, 0, 0); 725 + 726 + exception_exit(prev_state); 728 727 } 729 728 730 729 void instruction_breakpoint_exception(struct pt_regs *regs) 731 730 { 731 + enum ctx_state prev_state = exception_enter(); 732 + 732 733 if (notify_die(DIE_IABR_MATCH, "iabr_match", regs, 5, 733 734 5, SIGTRAP) == NOTIFY_STOP) 734 - return; 735 + goto bail; 735 736 if (debugger_iabr_match(regs)) 736 - return; 737 + goto bail; 737 738 _exception(SIGTRAP, regs, TRAP_BRKPT, regs->nip); 739 + 740 + bail: 741 + exception_exit(prev_state); 738 742 } 739 743 740 744 void RunModeException(struct pt_regs *regs) ··· 753 739 754 740 void __kprobes single_step_exception(struct pt_regs *regs) 755 741 { 742 + enum ctx_state prev_state = exception_enter(); 743 + 756 744 clear_single_step(regs); 757 745 758 746 if (notify_die(DIE_SSTEP, "single_step", regs, 5, 759 747 5, SIGTRAP) == NOTIFY_STOP) 760 - return; 748 + goto bail; 761 749 if (debugger_sstep(regs)) 762 - return; 750 + goto bail; 763 751 764 752 _exception(SIGTRAP, regs, TRAP_TRACE, regs->nip); 753 + 754 + bail: 755 + exception_exit(prev_state); 765 756 } 766 757 767 758 /* ··· 1024 1005 1025 1006 void __kprobes program_check_exception(struct pt_regs *regs) 1026 1007 { 1008 + enum ctx_state prev_state = exception_enter(); 1027 1009 unsigned int reason = get_reason(regs); 1028 1010 extern int do_mathemu(struct pt_regs *regs); 1029 1011 ··· 1034 1014 if (reason & REASON_FP) { 1035 1015 /* IEEE FP exception */ 1036 1016 parse_fpe(regs); 1037 - return; 1017 + goto bail; 1038 1018 } 1039 1019 if (reason & REASON_TRAP) { 1040 1020 /* Debugger is first in line to stop recursive faults in 1041 1021 * rcu_lock, notify_die, or atomic_notifier_call_chain */ 1042 1022 if (debugger_bpt(regs)) 1043 - return; 1023 + goto bail; 1044 1024 1045 1025 /* trap exception */ 1046 1026 if (notify_die(DIE_BPT, "breakpoint", regs, 5, 5, SIGTRAP) 1047 1027 == NOTIFY_STOP) 1048 - return; 1028 + goto bail; 1049 1029 1050 1030 if (!(regs->msr & MSR_PR) && /* not user-mode */ 1051 1031 report_bug(regs->nip, regs) == BUG_TRAP_TYPE_WARN) { 1052 1032 regs->nip += 4; 1053 - return; 1033 + goto bail; 1054 1034 } 1055 1035 _exception(SIGTRAP, regs, TRAP_BRKPT, regs->nip); 1056 - return; 1036 + goto bail; 1057 1037 } 1058 1038 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM 1059 1039 if (reason & REASON_TM) { ··· 1069 1049 if (!user_mode(regs) && 1070 1050 report_bug(regs->nip, regs) == BUG_TRAP_TYPE_WARN) { 1071 1051 regs->nip += 4; 1072 - return; 1052 + goto bail; 1073 1053 } 1074 1054 /* If usermode caused this, it's done something illegal and 1075 1055 * gets a SIGILL slap on the wrist. We call it an illegal ··· 1079 1059 */ 1080 1060 if (user_mode(regs)) { 1081 1061 _exception(SIGILL, regs, ILL_ILLOPN, regs->nip); 1082 - return; 1062 + goto bail; 1083 1063 } else { 1084 1064 printk(KERN_EMERG "Unexpected TM Bad Thing exception " 1085 1065 "at %lx (msr 0x%x)\n", regs->nip, reason); ··· 1103 1083 switch (do_mathemu(regs)) { 1104 1084 case 0: 1105 1085 emulate_single_step(regs); 1106 - return; 1086 + goto bail; 1107 1087 case 1: { 1108 1088 int code = 0; 1109 1089 code = __parse_fpscr(current->thread.fpscr.val); 1110 1090 _exception(SIGFPE, regs, code, regs->nip); 1111 - return; 1091 + goto bail; 1112 1092 } 1113 1093 case -EFAULT: 1114 1094 _exception(SIGSEGV, regs, SEGV_MAPERR, regs->nip); 1115 - return; 1095 + goto bail; 1116 1096 } 1117 1097 /* fall through on any other errors */ 1118 1098 #endif /* CONFIG_MATH_EMULATION */ ··· 1123 1103 case 0: 1124 1104 regs->nip += 4; 1125 1105 emulate_single_step(regs); 1126 - return; 1106 + goto bail; 1127 1107 case -EFAULT: 1128 1108 _exception(SIGSEGV, regs, SEGV_MAPERR, regs->nip); 1129 - return; 1109 + goto bail; 1130 1110 } 1131 1111 } 1132 1112 ··· 1134 1114 _exception(SIGILL, regs, ILL_PRVOPC, regs->nip); 1135 1115 else 1136 1116 _exception(SIGILL, regs, ILL_ILLOPC, regs->nip); 1117 + 1118 + bail: 1119 + exception_exit(prev_state); 1137 1120 } 1138 1121 1139 1122 void alignment_exception(struct pt_regs *regs) 1140 1123 { 1124 + enum ctx_state prev_state = exception_enter(); 1141 1125 int sig, code, fixed = 0; 1142 1126 1143 1127 /* We restore the interrupt state now */ ··· 1155 1131 if (fixed == 1) { 1156 1132 regs->nip += 4; /* skip over emulated instruction */ 1157 1133 emulate_single_step(regs); 1158 - return; 1134 + goto bail; 1159 1135 } 1160 1136 1161 1137 /* Operand address was bad */ ··· 1170 1146 _exception(sig, regs, code, regs->dar); 1171 1147 else 1172 1148 bad_page_fault(regs, regs->dar, sig); 1149 + 1150 + bail: 1151 + exception_exit(prev_state); 1173 1152 } 1174 1153 1175 1154 void StackOverflow(struct pt_regs *regs) ··· 1201 1174 1202 1175 void kernel_fp_unavailable_exception(struct pt_regs *regs) 1203 1176 { 1177 + enum ctx_state prev_state = exception_enter(); 1178 + 1204 1179 printk(KERN_EMERG "Unrecoverable FP Unavailable Exception " 1205 1180 "%lx at %lx\n", regs->trap, regs->nip); 1206 1181 die("Unrecoverable FP Unavailable Exception", regs, SIGABRT); 1182 + 1183 + exception_exit(prev_state); 1207 1184 } 1208 1185 1209 1186 void altivec_unavailable_exception(struct pt_regs *regs) 1210 1187 { 1188 + enum ctx_state prev_state = exception_enter(); 1189 + 1211 1190 if (user_mode(regs)) { 1212 1191 /* A user program has executed an altivec instruction, 1213 1192 but this kernel doesn't support altivec. */ 1214 1193 _exception(SIGILL, regs, ILL_ILLOPC, regs->nip); 1215 - return; 1194 + goto bail; 1216 1195 } 1217 1196 1218 1197 printk(KERN_EMERG "Unrecoverable VMX/Altivec Unavailable Exception " 1219 1198 "%lx at %lx\n", regs->trap, regs->nip); 1220 1199 die("Unrecoverable VMX/Altivec Unavailable Exception", regs, SIGABRT); 1200 + 1201 + bail: 1202 + exception_exit(prev_state); 1221 1203 } 1222 1204 1223 1205 void vsx_unavailable_exception(struct pt_regs *regs)
+3
arch/powerpc/kernel/udbg.c
··· 64 64 udbg_init_usbgecko(); 65 65 #elif defined(CONFIG_PPC_EARLY_DEBUG_WSP) 66 66 udbg_init_wsp(); 67 + #elif defined(CONFIG_PPC_EARLY_DEBUG_MEMCONS) 68 + /* In memory console */ 69 + udbg_init_memcons(); 67 70 #elif defined(CONFIG_PPC_EARLY_DEBUG_EHV_BC) 68 71 udbg_init_ehv_bc(); 69 72 #elif defined(CONFIG_PPC_EARLY_DEBUG_PS3GELIC)
+27 -14
arch/powerpc/mm/fault.c
··· 32 32 #include <linux/perf_event.h> 33 33 #include <linux/magic.h> 34 34 #include <linux/ratelimit.h> 35 + #include <linux/context_tracking.h> 35 36 36 37 #include <asm/firmware.h> 37 38 #include <asm/page.h> ··· 197 196 int __kprobes do_page_fault(struct pt_regs *regs, unsigned long address, 198 197 unsigned long error_code) 199 198 { 199 + enum ctx_state prev_state = exception_enter(); 200 200 struct vm_area_struct * vma; 201 201 struct mm_struct *mm = current->mm; 202 202 unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE; ··· 206 204 int trap = TRAP(regs); 207 205 int is_exec = trap == 0x400; 208 206 int fault; 207 + int rc = 0; 209 208 210 209 #if !(defined(CONFIG_4xx) || defined(CONFIG_BOOKE)) 211 210 /* ··· 233 230 * look at it 234 231 */ 235 232 if (error_code & ICSWX_DSI_UCT) { 236 - int rc = acop_handle_fault(regs, address, error_code); 233 + rc = acop_handle_fault(regs, address, error_code); 237 234 if (rc) 238 - return rc; 235 + goto bail; 239 236 } 240 237 #endif /* CONFIG_PPC_ICSWX */ 241 238 242 239 if (notify_page_fault(regs)) 243 - return 0; 240 + goto bail; 244 241 245 242 if (unlikely(debugger_fault_handler(regs))) 246 - return 0; 243 + goto bail; 247 244 248 245 /* On a kernel SLB miss we can only check for a valid exception entry */ 249 - if (!user_mode(regs) && (address >= TASK_SIZE)) 250 - return SIGSEGV; 246 + if (!user_mode(regs) && (address >= TASK_SIZE)) { 247 + rc = SIGSEGV; 248 + goto bail; 249 + } 251 250 252 251 #if !(defined(CONFIG_4xx) || defined(CONFIG_BOOKE) || \ 253 252 defined(CONFIG_PPC_BOOK3S_64)) 254 253 if (error_code & DSISR_DABRMATCH) { 255 254 /* breakpoint match */ 256 255 do_break(regs, address, error_code); 257 - return 0; 256 + goto bail; 258 257 } 259 258 #endif 260 259 ··· 265 260 local_irq_enable(); 266 261 267 262 if (in_atomic() || mm == NULL) { 268 - if (!user_mode(regs)) 269 - return SIGSEGV; 263 + if (!user_mode(regs)) { 264 + rc = SIGSEGV; 265 + goto bail; 266 + } 270 267 /* in_atomic() in user mode is really bad, 271 268 as is current->mm == NULL. */ 272 269 printk(KERN_EMERG "Page fault in user mode with " ··· 424 417 */ 425 418 fault = handle_mm_fault(mm, vma, address, flags); 426 419 if (unlikely(fault & (VM_FAULT_RETRY|VM_FAULT_ERROR))) { 427 - int rc = mm_fault_error(regs, address, fault); 420 + rc = mm_fault_error(regs, address, fault); 428 421 if (rc >= MM_FAULT_RETURN) 429 - return rc; 422 + goto bail; 423 + else 424 + rc = 0; 430 425 } 431 426 432 427 /* ··· 463 454 } 464 455 465 456 up_read(&mm->mmap_sem); 466 - return 0; 457 + goto bail; 467 458 468 459 bad_area: 469 460 up_read(&mm->mmap_sem); ··· 472 463 /* User mode accesses cause a SIGSEGV */ 473 464 if (user_mode(regs)) { 474 465 _exception(SIGSEGV, regs, code, address); 475 - return 0; 466 + goto bail; 476 467 } 477 468 478 469 if (is_exec && (error_code & DSISR_PROTFAULT)) ··· 480 471 " page (%lx) - exploit attempt? (uid: %d)\n", 481 472 address, from_kuid(&init_user_ns, current_uid())); 482 473 483 - return SIGSEGV; 474 + rc = SIGSEGV; 475 + 476 + bail: 477 + exception_exit(prev_state); 478 + return rc; 484 479 485 480 } 486 481
+27 -9
arch/powerpc/mm/hash_utils_64.c
··· 33 33 #include <linux/init.h> 34 34 #include <linux/signal.h> 35 35 #include <linux/memblock.h> 36 + #include <linux/context_tracking.h> 36 37 37 38 #include <asm/processor.h> 38 39 #include <asm/pgtable.h> ··· 955 954 */ 956 955 int hash_page(unsigned long ea, unsigned long access, unsigned long trap) 957 956 { 957 + enum ctx_state prev_state = exception_enter(); 958 958 pgd_t *pgdir; 959 959 unsigned long vsid; 960 960 struct mm_struct *mm; ··· 975 973 mm = current->mm; 976 974 if (! mm) { 977 975 DBG_LOW(" user region with no mm !\n"); 978 - return 1; 976 + rc = 1; 977 + goto bail; 979 978 } 980 979 psize = get_slice_psize(mm, ea); 981 980 ssize = user_segment_size(ea); ··· 995 992 /* Not a valid range 996 993 * Send the problem up to do_page_fault 997 994 */ 998 - return 1; 995 + rc = 1; 996 + goto bail; 999 997 } 1000 998 DBG_LOW(" mm=%p, mm->pgdir=%p, vsid=%016lx\n", mm, mm->pgd, vsid); 1001 999 1002 1000 /* Bad address. */ 1003 1001 if (!vsid) { 1004 1002 DBG_LOW("Bad address!\n"); 1005 - return 1; 1003 + rc = 1; 1004 + goto bail; 1006 1005 } 1007 1006 /* Get pgdir */ 1008 1007 pgdir = mm->pgd; 1009 - if (pgdir == NULL) 1010 - return 1; 1008 + if (pgdir == NULL) { 1009 + rc = 1; 1010 + goto bail; 1011 + } 1011 1012 1012 1013 /* Check CPU locality */ 1013 1014 tmp = cpumask_of(smp_processor_id()); ··· 1034 1027 ptep = find_linux_pte_or_hugepte(pgdir, ea, &hugeshift); 1035 1028 if (ptep == NULL || !pte_present(*ptep)) { 1036 1029 DBG_LOW(" no PTE !\n"); 1037 - return 1; 1030 + rc = 1; 1031 + goto bail; 1038 1032 } 1039 1033 1040 1034 /* Add _PAGE_PRESENT to the required access perm */ ··· 1046 1038 */ 1047 1039 if (access & ~pte_val(*ptep)) { 1048 1040 DBG_LOW(" no access !\n"); 1049 - return 1; 1041 + rc = 1; 1042 + goto bail; 1050 1043 } 1051 1044 1052 1045 #ifdef CONFIG_HUGETLB_PAGE 1053 - if (hugeshift) 1054 - return __hash_page_huge(ea, access, vsid, ptep, trap, local, 1046 + if (hugeshift) { 1047 + rc = __hash_page_huge(ea, access, vsid, ptep, trap, local, 1055 1048 ssize, hugeshift, psize); 1049 + goto bail; 1050 + } 1056 1051 #endif /* CONFIG_HUGETLB_PAGE */ 1057 1052 1058 1053 #ifndef CONFIG_PPC_64K_PAGES ··· 1135 1124 pte_val(*(ptep + PTRS_PER_PTE))); 1136 1125 #endif 1137 1126 DBG_LOW(" -> rc=%d\n", rc); 1127 + 1128 + bail: 1129 + exception_exit(prev_state); 1138 1130 return rc; 1139 1131 } 1140 1132 EXPORT_SYMBOL_GPL(hash_page); ··· 1273 1259 */ 1274 1260 void low_hash_fault(struct pt_regs *regs, unsigned long address, int rc) 1275 1261 { 1262 + enum ctx_state prev_state = exception_enter(); 1263 + 1276 1264 if (user_mode(regs)) { 1277 1265 #ifdef CONFIG_PPC_SUBPAGE_PROT 1278 1266 if (rc == -2) ··· 1284 1268 _exception(SIGBUS, regs, BUS_ADRERR, address); 1285 1269 } else 1286 1270 bad_page_fault(regs, address, SIGBUS); 1271 + 1272 + exception_exit(prev_state); 1287 1273 } 1288 1274 1289 1275 long hpte_insert_repeating(unsigned long hash, unsigned long vpn,
+2 -1
arch/powerpc/mm/init_64.c
··· 215 215 unsigned long phys) 216 216 { 217 217 int mapped = htab_bolt_mapping(start, start + page_size, phys, 218 - PAGE_KERNEL, mmu_vmemmap_psize, 218 + pgprot_val(PAGE_KERNEL), 219 + mmu_vmemmap_psize, 219 220 mmu_kernel_ssize); 220 221 BUG_ON(mapped < 0); 221 222 }
+159 -121
arch/powerpc/perf/core-book3s.c
··· 13 13 #include <linux/perf_event.h> 14 14 #include <linux/percpu.h> 15 15 #include <linux/hardirq.h> 16 + #include <linux/uaccess.h> 16 17 #include <asm/reg.h> 17 18 #include <asm/pmc.h> 18 19 #include <asm/machdep.h> 19 20 #include <asm/firmware.h> 20 21 #include <asm/ptrace.h> 22 + #include <asm/code-patching.h> 21 23 22 24 #define BHRB_MAX_ENTRIES 32 23 25 #define BHRB_TARGET 0x0000000000000002 ··· 102 100 return 1; 103 101 } 104 102 103 + static inline void power_pmu_bhrb_enable(struct perf_event *event) {} 104 + static inline void power_pmu_bhrb_disable(struct perf_event *event) {} 105 + void power_pmu_flush_branch_stack(void) {} 106 + static inline void power_pmu_bhrb_read(struct cpu_hw_events *cpuhw) {} 105 107 #endif /* CONFIG_PPC32 */ 106 108 107 109 static bool regs_use_siar(struct pt_regs *regs) ··· 312 306 return mmcra & POWER7P_MMCRA_SIAR_VALID; 313 307 314 308 return 1; 309 + } 310 + 311 + 312 + /* Reset all possible BHRB entries */ 313 + static void power_pmu_bhrb_reset(void) 314 + { 315 + asm volatile(PPC_CLRBHRB); 316 + } 317 + 318 + static void power_pmu_bhrb_enable(struct perf_event *event) 319 + { 320 + struct cpu_hw_events *cpuhw = &__get_cpu_var(cpu_hw_events); 321 + 322 + if (!ppmu->bhrb_nr) 323 + return; 324 + 325 + /* Clear BHRB if we changed task context to avoid data leaks */ 326 + if (event->ctx->task && cpuhw->bhrb_context != event->ctx) { 327 + power_pmu_bhrb_reset(); 328 + cpuhw->bhrb_context = event->ctx; 329 + } 330 + cpuhw->bhrb_users++; 331 + } 332 + 333 + static void power_pmu_bhrb_disable(struct perf_event *event) 334 + { 335 + struct cpu_hw_events *cpuhw = &__get_cpu_var(cpu_hw_events); 336 + 337 + if (!ppmu->bhrb_nr) 338 + return; 339 + 340 + cpuhw->bhrb_users--; 341 + WARN_ON_ONCE(cpuhw->bhrb_users < 0); 342 + 343 + if (!cpuhw->disabled && !cpuhw->bhrb_users) { 344 + /* BHRB cannot be turned off when other 345 + * events are active on the PMU. 346 + */ 347 + 348 + /* avoid stale pointer */ 349 + cpuhw->bhrb_context = NULL; 350 + } 351 + } 352 + 353 + /* Called from ctxsw to prevent one process's branch entries to 354 + * mingle with the other process's entries during context switch. 355 + */ 356 + void power_pmu_flush_branch_stack(void) 357 + { 358 + if (ppmu->bhrb_nr) 359 + power_pmu_bhrb_reset(); 360 + } 361 + /* Calculate the to address for a branch */ 362 + static __u64 power_pmu_bhrb_to(u64 addr) 363 + { 364 + unsigned int instr; 365 + int ret; 366 + __u64 target; 367 + 368 + if (is_kernel_addr(addr)) 369 + return branch_target((unsigned int *)addr); 370 + 371 + /* Userspace: need copy instruction here then translate it */ 372 + pagefault_disable(); 373 + ret = __get_user_inatomic(instr, (unsigned int __user *)addr); 374 + if (ret) { 375 + pagefault_enable(); 376 + return 0; 377 + } 378 + pagefault_enable(); 379 + 380 + target = branch_target(&instr); 381 + if ((!target) || (instr & BRANCH_ABSOLUTE)) 382 + return target; 383 + 384 + /* Translate relative branch target from kernel to user address */ 385 + return target - (unsigned long)&instr + addr; 386 + } 387 + 388 + /* Processing BHRB entries */ 389 + void power_pmu_bhrb_read(struct cpu_hw_events *cpuhw) 390 + { 391 + u64 val; 392 + u64 addr; 393 + int r_index, u_index, pred; 394 + 395 + r_index = 0; 396 + u_index = 0; 397 + while (r_index < ppmu->bhrb_nr) { 398 + /* Assembly read function */ 399 + val = read_bhrb(r_index++); 400 + if (!val) 401 + /* Terminal marker: End of valid BHRB entries */ 402 + break; 403 + else { 404 + addr = val & BHRB_EA; 405 + pred = val & BHRB_PREDICTION; 406 + 407 + if (!addr) 408 + /* invalid entry */ 409 + continue; 410 + 411 + /* Branches are read most recent first (ie. mfbhrb 0 is 412 + * the most recent branch). 413 + * There are two types of valid entries: 414 + * 1) a target entry which is the to address of a 415 + * computed goto like a blr,bctr,btar. The next 416 + * entry read from the bhrb will be branch 417 + * corresponding to this target (ie. the actual 418 + * blr/bctr/btar instruction). 419 + * 2) a from address which is an actual branch. If a 420 + * target entry proceeds this, then this is the 421 + * matching branch for that target. If this is not 422 + * following a target entry, then this is a branch 423 + * where the target is given as an immediate field 424 + * in the instruction (ie. an i or b form branch). 425 + * In this case we need to read the instruction from 426 + * memory to determine the target/to address. 427 + */ 428 + 429 + if (val & BHRB_TARGET) { 430 + /* Target branches use two entries 431 + * (ie. computed gotos/XL form) 432 + */ 433 + cpuhw->bhrb_entries[u_index].to = addr; 434 + cpuhw->bhrb_entries[u_index].mispred = pred; 435 + cpuhw->bhrb_entries[u_index].predicted = ~pred; 436 + 437 + /* Get from address in next entry */ 438 + val = read_bhrb(r_index++); 439 + addr = val & BHRB_EA; 440 + if (val & BHRB_TARGET) { 441 + /* Shouldn't have two targets in a 442 + row.. Reset index and try again */ 443 + r_index--; 444 + addr = 0; 445 + } 446 + cpuhw->bhrb_entries[u_index].from = addr; 447 + } else { 448 + /* Branches to immediate field 449 + (ie I or B form) */ 450 + cpuhw->bhrb_entries[u_index].from = addr; 451 + cpuhw->bhrb_entries[u_index].to = 452 + power_pmu_bhrb_to(addr); 453 + cpuhw->bhrb_entries[u_index].mispred = pred; 454 + cpuhw->bhrb_entries[u_index].predicted = ~pred; 455 + } 456 + u_index++; 457 + 458 + } 459 + } 460 + cpuhw->bhrb_stack.nr = u_index; 461 + return; 315 462 } 316 463 317 464 #endif /* CONFIG_PPC64 */ ··· 1063 904 return n; 1064 905 } 1065 906 1066 - /* Reset all possible BHRB entries */ 1067 - static void power_pmu_bhrb_reset(void) 1068 - { 1069 - asm volatile(PPC_CLRBHRB); 1070 - } 1071 - 1072 - void power_pmu_bhrb_enable(struct perf_event *event) 1073 - { 1074 - struct cpu_hw_events *cpuhw = &__get_cpu_var(cpu_hw_events); 1075 - 1076 - if (!ppmu->bhrb_nr) 1077 - return; 1078 - 1079 - /* Clear BHRB if we changed task context to avoid data leaks */ 1080 - if (event->ctx->task && cpuhw->bhrb_context != event->ctx) { 1081 - power_pmu_bhrb_reset(); 1082 - cpuhw->bhrb_context = event->ctx; 1083 - } 1084 - cpuhw->bhrb_users++; 1085 - } 1086 - 1087 - void power_pmu_bhrb_disable(struct perf_event *event) 1088 - { 1089 - struct cpu_hw_events *cpuhw = &__get_cpu_var(cpu_hw_events); 1090 - 1091 - if (!ppmu->bhrb_nr) 1092 - return; 1093 - 1094 - cpuhw->bhrb_users--; 1095 - WARN_ON_ONCE(cpuhw->bhrb_users < 0); 1096 - 1097 - if (!cpuhw->disabled && !cpuhw->bhrb_users) { 1098 - /* BHRB cannot be turned off when other 1099 - * events are active on the PMU. 1100 - */ 1101 - 1102 - /* avoid stale pointer */ 1103 - cpuhw->bhrb_context = NULL; 1104 - } 1105 - } 1106 - 1107 907 /* 1108 908 * Add a event to the PMU. 1109 909 * If all events are not already frozen, then we disable and ··· 1296 1178 cpuhw->group_flag &= ~PERF_EVENT_TXN; 1297 1179 perf_pmu_enable(pmu); 1298 1180 return 0; 1299 - } 1300 - 1301 - /* Called from ctxsw to prevent one process's branch entries to 1302 - * mingle with the other process's entries during context switch. 1303 - */ 1304 - void power_pmu_flush_branch_stack(void) 1305 - { 1306 - if (ppmu->bhrb_nr) 1307 - power_pmu_bhrb_reset(); 1308 1181 } 1309 1182 1310 1183 /* ··· 1566 1457 .event_idx = power_pmu_event_idx, 1567 1458 .flush_branch_stack = power_pmu_flush_branch_stack, 1568 1459 }; 1569 - 1570 - /* Processing BHRB entries */ 1571 - void power_pmu_bhrb_read(struct cpu_hw_events *cpuhw) 1572 - { 1573 - u64 val; 1574 - u64 addr; 1575 - int r_index, u_index, target, pred; 1576 - 1577 - r_index = 0; 1578 - u_index = 0; 1579 - while (r_index < ppmu->bhrb_nr) { 1580 - /* Assembly read function */ 1581 - val = read_bhrb(r_index); 1582 - 1583 - /* Terminal marker: End of valid BHRB entries */ 1584 - if (val == 0) { 1585 - break; 1586 - } else { 1587 - /* BHRB field break up */ 1588 - addr = val & BHRB_EA; 1589 - pred = val & BHRB_PREDICTION; 1590 - target = val & BHRB_TARGET; 1591 - 1592 - /* Probable Missed entry: Not applicable for POWER8 */ 1593 - if ((addr == 0) && (target == 0) && (pred == 1)) { 1594 - r_index++; 1595 - continue; 1596 - } 1597 - 1598 - /* Real Missed entry: Power8 based missed entry */ 1599 - if ((addr == 0) && (target == 1) && (pred == 1)) { 1600 - r_index++; 1601 - continue; 1602 - } 1603 - 1604 - /* Reserved condition: Not a valid entry */ 1605 - if ((addr == 0) && (target == 1) && (pred == 0)) { 1606 - r_index++; 1607 - continue; 1608 - } 1609 - 1610 - /* Is a target address */ 1611 - if (val & BHRB_TARGET) { 1612 - /* First address cannot be a target address */ 1613 - if (r_index == 0) { 1614 - r_index++; 1615 - continue; 1616 - } 1617 - 1618 - /* Update target address for the previous entry */ 1619 - cpuhw->bhrb_entries[u_index - 1].to = addr; 1620 - cpuhw->bhrb_entries[u_index - 1].mispred = pred; 1621 - cpuhw->bhrb_entries[u_index - 1].predicted = ~pred; 1622 - 1623 - /* Dont increment u_index */ 1624 - r_index++; 1625 - } else { 1626 - /* Update address, flags for current entry */ 1627 - cpuhw->bhrb_entries[u_index].from = addr; 1628 - cpuhw->bhrb_entries[u_index].mispred = pred; 1629 - cpuhw->bhrb_entries[u_index].predicted = ~pred; 1630 - 1631 - /* Successfully popullated one entry */ 1632 - u_index++; 1633 - r_index++; 1634 - } 1635 - } 1636 - } 1637 - cpuhw->bhrb_stack.nr = u_index; 1638 - return; 1639 - } 1640 1460 1641 1461 /* 1642 1462 * A counter has overflowed; update its count and record
+1 -1
arch/powerpc/platforms/Kconfig
··· 128 128 129 129 config RTAS_PROC 130 130 bool "Proc interface to RTAS" 131 - depends on PPC_RTAS 131 + depends on PPC_RTAS && PROC_FS 132 132 default y 133 133 134 134 config RTAS_FLASH
+29 -1
arch/powerpc/platforms/powernv/opal.c
··· 15 15 #include <linux/of.h> 16 16 #include <linux/of_platform.h> 17 17 #include <linux/interrupt.h> 18 + #include <linux/slab.h> 18 19 #include <asm/opal.h> 19 20 #include <asm/firmware.h> 20 21 ··· 29 28 static struct device_node *opal_node; 30 29 static DEFINE_SPINLOCK(opal_write_lock); 31 30 extern u64 opal_mc_secondary_handler[]; 31 + static unsigned int *opal_irqs; 32 + static unsigned int opal_irq_count; 32 33 33 34 int __init early_init_dt_scan_opal(unsigned long node, 34 35 const char *uname, int depth, void *data) ··· 56 53 opal.entry, entryp, entrysz); 57 54 58 55 powerpc_firmware_features |= FW_FEATURE_OPAL; 59 - if (of_flat_dt_is_compatible(node, "ibm,opal-v2")) { 56 + if (of_flat_dt_is_compatible(node, "ibm,opal-v3")) { 57 + powerpc_firmware_features |= FW_FEATURE_OPALv2; 58 + powerpc_firmware_features |= FW_FEATURE_OPALv3; 59 + printk("OPAL V3 detected !\n"); 60 + } else if (of_flat_dt_is_compatible(node, "ibm,opal-v2")) { 60 61 powerpc_firmware_features |= FW_FEATURE_OPALv2; 61 62 printk("OPAL V2 detected !\n"); 62 63 } else { ··· 151 144 rc == OPAL_BUSY_EVENT || rc == OPAL_SUCCESS)) { 152 145 len = total_len; 153 146 rc = opal_console_write(vtermno, &len, data); 147 + 148 + /* Closed or other error drop */ 149 + if (rc != OPAL_SUCCESS && rc != OPAL_BUSY && 150 + rc != OPAL_BUSY_EVENT) { 151 + written = total_len; 152 + break; 153 + } 154 154 if (rc == OPAL_SUCCESS) { 155 155 total_len -= len; 156 156 data += len; ··· 330 316 irqs = of_get_property(opal_node, "opal-interrupts", &irqlen); 331 317 pr_debug("opal: Found %d interrupts reserved for OPAL\n", 332 318 irqs ? (irqlen / 4) : 0); 319 + opal_irq_count = irqlen / 4; 320 + opal_irqs = kzalloc(opal_irq_count * sizeof(unsigned int), GFP_KERNEL); 333 321 for (i = 0; irqs && i < (irqlen / 4); i++, irqs++) { 334 322 unsigned int hwirq = be32_to_cpup(irqs); 335 323 unsigned int irq = irq_create_mapping(NULL, hwirq); ··· 343 327 if (rc) 344 328 pr_warning("opal: Error %d requesting irq %d" 345 329 " (0x%x)\n", rc, irq, hwirq); 330 + opal_irqs[i] = irq; 346 331 } 347 332 return 0; 348 333 } 349 334 subsys_initcall(opal_init); 335 + 336 + void opal_shutdown(void) 337 + { 338 + unsigned int i; 339 + 340 + for (i = 0; i < opal_irq_count; i++) { 341 + if (opal_irqs[i]) 342 + free_irq(opal_irqs[i], 0); 343 + opal_irqs[i] = 0; 344 + } 345 + }
+9
arch/powerpc/platforms/powernv/pci-ioda.c
··· 1048 1048 return phb->ioda.pe_rmap[(bus->number << 8) | devfn]; 1049 1049 } 1050 1050 1051 + static void pnv_pci_ioda_shutdown(struct pnv_phb *phb) 1052 + { 1053 + opal_pci_reset(phb->opal_id, OPAL_PCI_IODA_TABLE_RESET, 1054 + OPAL_ASSERT_RESET); 1055 + } 1056 + 1051 1057 void __init pnv_pci_init_ioda_phb(struct device_node *np, int ioda_type) 1052 1058 { 1053 1059 struct pci_controller *hose; ··· 1183 1177 1184 1178 /* Setup TCEs */ 1185 1179 phb->dma_dev_setup = pnv_pci_ioda_dma_dev_setup; 1180 + 1181 + /* Setup shutdown function for kexec */ 1182 + phb->shutdown = pnv_pci_ioda_shutdown; 1186 1183 1187 1184 /* Setup MSI support */ 1188 1185 pnv_pci_init_ioda_msis(phb);
+12
arch/powerpc/platforms/powernv/pci.c
··· 450 450 pnv_pci_dma_fallback_setup(hose, pdev); 451 451 } 452 452 453 + void pnv_pci_shutdown(void) 454 + { 455 + struct pci_controller *hose; 456 + 457 + list_for_each_entry(hose, &hose_list, list_node) { 458 + struct pnv_phb *phb = hose->private_data; 459 + 460 + if (phb && phb->shutdown) 461 + phb->shutdown(phb); 462 + } 463 + } 464 + 453 465 /* Fixup wrong class code in p7ioc and p8 root complex */ 454 466 static void pnv_p7ioc_rc_quirk(struct pci_dev *dev) 455 467 {
+2
arch/powerpc/platforms/powernv/pci.h
··· 86 86 void (*dma_dev_setup)(struct pnv_phb *phb, struct pci_dev *pdev); 87 87 void (*fixup_phb)(struct pci_controller *hose); 88 88 u32 (*bdfn_to_pe)(struct pnv_phb *phb, struct pci_bus *bus, u32 devfn); 89 + void (*shutdown)(struct pnv_phb *phb); 89 90 90 91 union { 91 92 struct { ··· 159 158 extern void pnv_pci_init_ioda2_phb(struct device_node *np); 160 159 extern void pnv_pci_ioda_tce_invalidate(struct iommu_table *tbl, 161 160 u64 *startp, u64 *endp); 161 + 162 162 #endif /* __POWERNV_PCI_H */
+2
arch/powerpc/platforms/powernv/powernv.h
··· 9 9 10 10 #ifdef CONFIG_PCI 11 11 extern void pnv_pci_init(void); 12 + extern void pnv_pci_shutdown(void); 12 13 #else 13 14 static inline void pnv_pci_init(void) { } 15 + static inline void pnv_pci_shutdown(void) { } 14 16 #endif 15 17 16 18 #endif /* _POWERNV_H */
+15 -1
arch/powerpc/platforms/powernv/setup.c
··· 78 78 if (root) 79 79 model = of_get_property(root, "model", NULL); 80 80 seq_printf(m, "machine\t\t: PowerNV %s\n", model); 81 - if (firmware_has_feature(FW_FEATURE_OPALv2)) 81 + if (firmware_has_feature(FW_FEATURE_OPALv3)) 82 + seq_printf(m, "firmware\t: OPAL v3\n"); 83 + else if (firmware_has_feature(FW_FEATURE_OPALv2)) 82 84 seq_printf(m, "firmware\t: OPAL v2\n"); 83 85 else if (firmware_has_feature(FW_FEATURE_OPAL)) 84 86 seq_printf(m, "firmware\t: OPAL v1\n"); ··· 126 124 127 125 static void pnv_progress(char *s, unsigned short hex) 128 126 { 127 + } 128 + 129 + static void pnv_shutdown(void) 130 + { 131 + /* Let the PCI code clear up IODA tables */ 132 + pnv_pci_shutdown(); 133 + 134 + /* And unregister all OPAL interrupts so they don't fire 135 + * up while we kexec 136 + */ 137 + opal_shutdown(); 129 138 } 130 139 131 140 #ifdef CONFIG_KEXEC ··· 200 187 .init_IRQ = pnv_init_IRQ, 201 188 .show_cpuinfo = pnv_show_cpuinfo, 202 189 .progress = pnv_progress, 190 + .machine_shutdown = pnv_shutdown, 203 191 .power_save = power7_idle, 204 192 .calibrate_decr = generic_calibrate_decr, 205 193 #ifdef CONFIG_KEXEC
+56 -6
arch/powerpc/platforms/powernv/smp.c
··· 71 71 72 72 BUG_ON(nr < 0 || nr >= NR_CPUS); 73 73 74 - /* On OPAL v2 the CPU are still spinning inside OPAL itself, 75 - * get them back now 74 + /* 75 + * If we already started or OPALv2 is not supported, we just 76 + * kick the CPU via the PACA 76 77 */ 77 - if (!paca[nr].cpu_start && firmware_has_feature(FW_FEATURE_OPALv2)) { 78 - pr_devel("OPAL: Starting CPU %d (HW 0x%x)...\n", nr, pcpu); 79 - rc = opal_start_cpu(pcpu, start_here); 78 + if (paca[nr].cpu_start || !firmware_has_feature(FW_FEATURE_OPALv2)) 79 + goto kick; 80 + 81 + /* 82 + * At this point, the CPU can either be spinning on the way in 83 + * from kexec or be inside OPAL waiting to be started for the 84 + * first time. OPAL v3 allows us to query OPAL to know if it 85 + * has the CPUs, so we do that 86 + */ 87 + if (firmware_has_feature(FW_FEATURE_OPALv3)) { 88 + uint8_t status; 89 + 90 + rc = opal_query_cpu_status(pcpu, &status); 80 91 if (rc != OPAL_SUCCESS) { 81 - pr_warn("OPAL Error %ld starting CPU %d\n", 92 + pr_warn("OPAL Error %ld querying CPU %d state\n", 82 93 rc, nr); 83 94 return -ENODEV; 84 95 } 96 + 97 + /* 98 + * Already started, just kick it, probably coming from 99 + * kexec and spinning 100 + */ 101 + if (status == OPAL_THREAD_STARTED) 102 + goto kick; 103 + 104 + /* 105 + * Available/inactive, let's kick it 106 + */ 107 + if (status == OPAL_THREAD_INACTIVE) { 108 + pr_devel("OPAL: Starting CPU %d (HW 0x%x)...\n", 109 + nr, pcpu); 110 + rc = opal_start_cpu(pcpu, start_here); 111 + if (rc != OPAL_SUCCESS) { 112 + pr_warn("OPAL Error %ld starting CPU %d\n", 113 + rc, nr); 114 + return -ENODEV; 115 + } 116 + } else { 117 + /* 118 + * An unavailable CPU (or any other unknown status) 119 + * shouldn't be started. It should also 120 + * not be in the possible map but currently it can 121 + * happen 122 + */ 123 + pr_devel("OPAL: CPU %d (HW 0x%x) is unavailable" 124 + " (status %d)...\n", nr, pcpu, status); 125 + return -ENODEV; 126 + } 127 + } else { 128 + /* 129 + * On OPAL v2, we just kick it and hope for the best, 130 + * we must not test the error from opal_start_cpu() or 131 + * we would fail to get CPUs from kexec. 132 + */ 133 + opal_start_cpu(pcpu, start_here); 85 134 } 135 + kick: 86 136 return smp_generic_kick_cpu(nr); 87 137 } 88 138
+1
arch/powerpc/platforms/pseries/Kconfig
··· 18 18 select PPC_PCI_CHOICE if EXPERT 19 19 select ZLIB_DEFLATE 20 20 select PPC_DOORBELL 21 + select HAVE_CONTEXT_TRACKING 21 22 default y 22 23 23 24 config PPC_SPLPAR
+22
arch/powerpc/platforms/pseries/suspend.c
··· 16 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 17 */ 18 18 19 + #include <linux/cpu.h> 19 20 #include <linux/delay.h> 20 21 #include <linux/suspend.h> 21 22 #include <linux/stat.h> ··· 127 126 struct device_attribute *attr, 128 127 const char *buf, size_t count) 129 128 { 129 + cpumask_var_t offline_mask; 130 130 int rc; 131 131 132 132 if (!capable(CAP_SYS_ADMIN)) 133 133 return -EPERM; 134 + 135 + if (!alloc_cpumask_var(&offline_mask, GFP_TEMPORARY)) 136 + return -ENOMEM; 134 137 135 138 stream_id = simple_strtoul(buf, NULL, 16); 136 139 ··· 145 140 } while (rc == -EAGAIN); 146 141 147 142 if (!rc) { 143 + /* All present CPUs must be online */ 144 + cpumask_andnot(offline_mask, cpu_present_mask, 145 + cpu_online_mask); 146 + rc = rtas_online_cpus_mask(offline_mask); 147 + if (rc) { 148 + pr_err("%s: Could not bring present CPUs online.\n", 149 + __func__); 150 + goto out; 151 + } 152 + 148 153 stop_topology_update(); 149 154 rc = pm_suspend(PM_SUSPEND_MEM); 150 155 start_topology_update(); 156 + 157 + /* Take down CPUs not online prior to suspend */ 158 + if (!rtas_offline_cpus_mask(offline_mask)) 159 + pr_warn("%s: Could not restore CPUs to offline " 160 + "state.\n", __func__); 151 161 } 152 162 153 163 stream_id = 0; 154 164 155 165 if (!rc) 156 166 rc = count; 167 + out: 168 + free_cpumask_var(offline_mask); 157 169 return rc; 158 170 } 159 171
+1 -1
arch/powerpc/platforms/wsp/ics.c
··· 361 361 xive = xive_set_server(xive, get_irq_server(ics, hw_irq)); 362 362 wsp_ics_set_xive(ics, hw_irq, xive); 363 363 364 - return 0; 364 + return IRQ_SET_MASK_OK; 365 365 } 366 366 367 367 static struct irq_chip wsp_irq_chip = {
+2
arch/powerpc/sysdev/Makefile
··· 64 64 65 65 obj-$(CONFIG_PPC_SCOM) += scom.o 66 66 67 + obj-$(CONFIG_PPC_EARLY_DEBUG_MEMCONS) += udbg_memcons.o 68 + 67 69 subdir-ccflags-$(CONFIG_PPC_WERROR) := -Werror 68 70 69 71 obj-$(CONFIG_PPC_XICS) += xics/
+1 -1
arch/powerpc/sysdev/ehv_pic.c
··· 81 81 ev_int_set_config(src, config, prio, cpuid); 82 82 spin_unlock_irqrestore(&ehv_pic_lock, flags); 83 83 84 - return 0; 84 + return IRQ_SET_MASK_OK; 85 85 } 86 86 87 87 static unsigned int ehv_pic_type_to_vecpri(unsigned int type)
+1 -1
arch/powerpc/sysdev/mpic.c
··· 836 836 mpic_physmask(mask)); 837 837 } 838 838 839 - return 0; 839 + return IRQ_SET_MASK_OK; 840 840 } 841 841 842 842 static unsigned int mpic_type_to_vecpri(struct mpic *mpic, unsigned int type)
+105
arch/powerpc/sysdev/udbg_memcons.c
··· 1 + /* 2 + * A udbg backend which logs messages and reads input from in memory 3 + * buffers. 4 + * 5 + * The console output can be read from memcons_output which is a 6 + * circular buffer whose next write position is stored in memcons.output_pos. 7 + * 8 + * Input may be passed by writing into the memcons_input buffer when it is 9 + * empty. The input buffer is empty when both input_pos == input_start and 10 + * *input_start == '\0'. 11 + * 12 + * Copyright (C) 2003-2005 Anton Blanchard and Milton Miller, IBM Corp 13 + * Copyright (C) 2013 Alistair Popple, IBM Corp 14 + * 15 + * This program is free software; you can redistribute it and/or 16 + * modify it under the terms of the GNU General Public License 17 + * as published by the Free Software Foundation; either version 18 + * 2 of the License, or (at your option) any later version. 19 + */ 20 + 21 + #include <linux/init.h> 22 + #include <linux/kernel.h> 23 + #include <asm/barrier.h> 24 + #include <asm/page.h> 25 + #include <asm/processor.h> 26 + #include <asm/udbg.h> 27 + 28 + struct memcons { 29 + char *output_start; 30 + char *output_pos; 31 + char *output_end; 32 + char *input_start; 33 + char *input_pos; 34 + char *input_end; 35 + }; 36 + 37 + static char memcons_output[CONFIG_PPC_MEMCONS_OUTPUT_SIZE]; 38 + static char memcons_input[CONFIG_PPC_MEMCONS_INPUT_SIZE]; 39 + 40 + struct memcons memcons = { 41 + .output_start = memcons_output, 42 + .output_pos = memcons_output, 43 + .output_end = &memcons_output[CONFIG_PPC_MEMCONS_OUTPUT_SIZE], 44 + .input_start = memcons_input, 45 + .input_pos = memcons_input, 46 + .input_end = &memcons_input[CONFIG_PPC_MEMCONS_INPUT_SIZE], 47 + }; 48 + 49 + void memcons_putc(char c) 50 + { 51 + char *new_output_pos; 52 + 53 + *memcons.output_pos = c; 54 + wmb(); 55 + new_output_pos = memcons.output_pos + 1; 56 + if (new_output_pos >= memcons.output_end) 57 + new_output_pos = memcons.output_start; 58 + 59 + memcons.output_pos = new_output_pos; 60 + } 61 + 62 + int memcons_getc_poll(void) 63 + { 64 + char c; 65 + char *new_input_pos; 66 + 67 + if (*memcons.input_pos) { 68 + c = *memcons.input_pos; 69 + 70 + new_input_pos = memcons.input_pos + 1; 71 + if (new_input_pos >= memcons.input_end) 72 + new_input_pos = memcons.input_start; 73 + else if (*new_input_pos == '\0') 74 + new_input_pos = memcons.input_start; 75 + 76 + *memcons.input_pos = '\0'; 77 + wmb(); 78 + memcons.input_pos = new_input_pos; 79 + return c; 80 + } 81 + 82 + return -1; 83 + } 84 + 85 + int memcons_getc(void) 86 + { 87 + int c; 88 + 89 + while (1) { 90 + c = memcons_getc_poll(); 91 + if (c == -1) 92 + cpu_relax(); 93 + else 94 + break; 95 + } 96 + 97 + return c; 98 + } 99 + 100 + void udbg_init_memcons(void) 101 + { 102 + udbg_putc = memcons_putc; 103 + udbg_getc = memcons_getc; 104 + udbg_getc_poll = memcons_getc_poll; 105 + }
+1 -1
arch/powerpc/sysdev/xics/ics-opal.c
··· 148 148 __func__, d->irq, hw_irq, server, rc); 149 149 return -1; 150 150 } 151 - return 0; 151 + return IRQ_SET_MASK_OK; 152 152 } 153 153 154 154 static struct irq_chip ics_opal_irq_chip = {
-1
arch/x86/Kconfig
··· 108 108 select GENERIC_CLOCKEVENTS_BROADCAST if X86_64 || (X86_32 && X86_LOCAL_APIC) 109 109 select GENERIC_TIME_VSYSCALL if X86_64 110 110 select KTIME_SCALAR if X86_32 111 - select ALWAYS_USE_PERSISTENT_CLOCK 112 111 select GENERIC_STRNCPY_FROM_USER 113 112 select GENERIC_STRNLEN_USER 114 113 select HAVE_CONTEXT_TRACKING if X86_64
+1 -1
arch/x86/kernel/head64.c
··· 34 34 extern pgd_t early_level4_pgt[PTRS_PER_PGD]; 35 35 extern pmd_t early_dynamic_pgts[EARLY_DYNAMIC_PAGE_TABLES][PTRS_PER_PMD]; 36 36 static unsigned int __initdata next_early_pgt = 2; 37 - pmdval_t __initdata early_pmd_flags = __PAGE_KERNEL_LARGE & ~(_PAGE_GLOBAL | _PAGE_NX); 37 + pmdval_t early_pmd_flags = __PAGE_KERNEL_LARGE & ~(_PAGE_GLOBAL | _PAGE_NX); 38 38 39 39 /* Wipe all early page tables except for the kernel symbol map */ 40 40 static void __init reset_early_page_tables(void)
+3 -2
arch/x86/kernel/microcode_intel_early.c
··· 487 487 #endif 488 488 489 489 #if defined(CONFIG_MICROCODE_INTEL_EARLY) && defined(CONFIG_HOTPLUG_CPU) 490 + static DEFINE_MUTEX(x86_cpu_microcode_mutex); 490 491 /* 491 492 * Save this mc into mc_saved_data. So it will be loaded early when a CPU is 492 493 * hot added or resumes. ··· 508 507 * Hold hotplug lock so mc_saved_data is not accessed by a CPU in 509 508 * hotplug. 510 509 */ 511 - cpu_hotplug_driver_lock(); 510 + mutex_lock(&x86_cpu_microcode_mutex); 512 511 513 512 mc_saved_count_init = mc_saved_data.mc_saved_count; 514 513 mc_saved_count = mc_saved_data.mc_saved_count; ··· 545 544 } 546 545 547 546 out: 548 - cpu_hotplug_driver_unlock(); 547 + mutex_unlock(&x86_cpu_microcode_mutex); 549 548 550 549 return ret; 551 550 }
+2 -3
arch/x86/kernel/process.c
··· 312 312 { 313 313 if (cpuidle_idle_call()) 314 314 x86_idle(); 315 + else 316 + local_irq_enable(); 315 317 } 316 318 317 319 /* ··· 370 368 */ 371 369 static void amd_e400_idle(void) 372 370 { 373 - if (need_resched()) 374 - return; 375 - 376 371 if (!amd_e400_c1e_detected) { 377 372 u32 lo, hi; 378 373
+18 -1
arch/x86/mm/init.c
··· 359 359 } 360 360 361 361 /* 362 - * would have hole in the middle or ends, and only ram parts will be mapped. 362 + * We need to iterate through the E820 memory map and create direct mappings 363 + * for only E820_RAM and E820_KERN_RESERVED regions. We cannot simply 364 + * create direct mappings for all pfns from [0 to max_low_pfn) and 365 + * [4GB to max_pfn) because of possible memory holes in high addresses 366 + * that cannot be marked as UC by fixed/variable range MTRRs. 367 + * Depending on the alignment of E820 ranges, this may possibly result 368 + * in using smaller size (i.e. 4K instead of 2M or 1G) page tables. 369 + * 370 + * init_mem_mapping() calls init_range_memory_mapping() with big range. 371 + * That range would have hole in the middle or ends, and only ram parts 372 + * will be mapped in init_range_memory_mapping(). 363 373 */ 364 374 static unsigned long __init init_range_memory_mapping( 365 375 unsigned long r_start, ··· 429 419 max_pfn_mapped = 0; /* will get exact value next */ 430 420 min_pfn_mapped = real_end >> PAGE_SHIFT; 431 421 last_start = start = real_end; 422 + 423 + /* 424 + * We start from the top (end of memory) and go to the bottom. 425 + * The memblock_find_in_range() gets us a block of RAM from the 426 + * end of RAM in [min_pfn_mapped, max_pfn_mapped) used as new pages 427 + * for page table. 428 + */ 432 429 while (last_start > ISA_END_ADDRESS) { 433 430 if (last_start > step_size) { 434 431 start = round_down(last_start - 1, step_size);
+33
drivers/acpi/ac.c
··· 28 28 #include <linux/slab.h> 29 29 #include <linux/init.h> 30 30 #include <linux/types.h> 31 + #include <linux/dmi.h> 32 + #include <linux/delay.h> 31 33 #ifdef CONFIG_ACPI_PROCFS_POWER 32 34 #include <linux/proc_fs.h> 33 35 #include <linux/seq_file.h> ··· 75 73 static int acpi_ac_resume(struct device *dev); 76 74 #endif 77 75 static SIMPLE_DEV_PM_OPS(acpi_ac_pm, NULL, acpi_ac_resume); 76 + 77 + static int ac_sleep_before_get_state_ms; 78 78 79 79 static struct acpi_driver acpi_ac_driver = { 80 80 .name = "ac", ··· 256 252 case ACPI_AC_NOTIFY_STATUS: 257 253 case ACPI_NOTIFY_BUS_CHECK: 258 254 case ACPI_NOTIFY_DEVICE_CHECK: 255 + /* 256 + * A buggy BIOS may notify AC first and then sleep for 257 + * a specific time before doing actual operations in the 258 + * EC event handler (_Qxx). This will cause the AC state 259 + * reported by the ACPI event to be incorrect, so wait for a 260 + * specific time for the EC event handler to make progress. 261 + */ 262 + if (ac_sleep_before_get_state_ms > 0) 263 + msleep(ac_sleep_before_get_state_ms); 264 + 259 265 acpi_ac_get_state(ac); 260 266 acpi_bus_generate_proc_event(device, event, (u32) ac->state); 261 267 acpi_bus_generate_netlink_event(device->pnp.device_class, ··· 277 263 278 264 return; 279 265 } 266 + 267 + static int thinkpad_e530_quirk(const struct dmi_system_id *d) 268 + { 269 + ac_sleep_before_get_state_ms = 1000; 270 + return 0; 271 + } 272 + 273 + static struct dmi_system_id ac_dmi_table[] = { 274 + { 275 + .callback = thinkpad_e530_quirk, 276 + .ident = "thinkpad e530", 277 + .matches = { 278 + DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), 279 + DMI_MATCH(DMI_PRODUCT_NAME, "32597CG"), 280 + }, 281 + }, 282 + {}, 283 + }; 280 284 281 285 static int acpi_ac_add(struct acpi_device *device) 282 286 { ··· 344 312 kfree(ac); 345 313 } 346 314 315 + dmi_check_system(ac_dmi_table); 347 316 return result; 348 317 } 349 318
+1 -3
drivers/acpi/ec.c
··· 223 223 static int ec_poll(struct acpi_ec *ec) 224 224 { 225 225 unsigned long flags; 226 - int repeat = 2; /* number of command restarts */ 226 + int repeat = 5; /* number of command restarts */ 227 227 while (repeat--) { 228 228 unsigned long delay = jiffies + 229 229 msecs_to_jiffies(ec_delay); ··· 241 241 } 242 242 advance_transaction(ec, acpi_ec_read_status(ec)); 243 243 } while (time_before(jiffies, delay)); 244 - if (acpi_ec_read_status(ec) & ACPI_EC_FLAG_IBF) 245 - break; 246 244 pr_debug(PREFIX "controller reset, restart transaction\n"); 247 245 spin_lock_irqsave(&ec->lock, flags); 248 246 start_transaction(ec);
+4 -4
drivers/acpi/processor_driver.c
··· 95 95 }; 96 96 MODULE_DEVICE_TABLE(acpi, processor_device_ids); 97 97 98 - static SIMPLE_DEV_PM_OPS(acpi_processor_pm, 99 - acpi_processor_suspend, acpi_processor_resume); 100 - 101 98 static struct acpi_driver acpi_processor_driver = { 102 99 .name = "processor", 103 100 .class = ACPI_PROCESSOR_CLASS, ··· 104 107 .remove = acpi_processor_remove, 105 108 .notify = acpi_processor_notify, 106 109 }, 107 - .drv.pm = &acpi_processor_pm, 108 110 }; 109 111 110 112 #define INSTALL_NOTIFY_HANDLER 1 ··· 930 934 if (result < 0) 931 935 return result; 932 936 937 + acpi_processor_syscore_init(); 938 + 933 939 acpi_processor_install_hotplug_notify(); 934 940 935 941 acpi_thermal_cpufreq_init(); ··· 953 955 acpi_thermal_cpufreq_exit(); 954 956 955 957 acpi_processor_uninstall_hotplug_notify(); 958 + 959 + acpi_processor_syscore_exit(); 956 960 957 961 acpi_bus_unregister_driver(&acpi_processor_driver); 958 962
+19 -10
drivers/acpi/processor_idle.c
··· 34 34 #include <linux/sched.h> /* need_resched() */ 35 35 #include <linux/clockchips.h> 36 36 #include <linux/cpuidle.h> 37 + #include <linux/syscore_ops.h> 37 38 38 39 /* 39 40 * Include the apic definitions for x86 to have the APIC timer related defines ··· 211 210 212 211 #endif 213 212 213 + #ifdef CONFIG_PM_SLEEP 214 214 static u32 saved_bm_rld; 215 215 216 - static void acpi_idle_bm_rld_save(void) 216 + int acpi_processor_suspend(void) 217 217 { 218 218 acpi_read_bit_register(ACPI_BITREG_BUS_MASTER_RLD, &saved_bm_rld); 219 + return 0; 219 220 } 220 - static void acpi_idle_bm_rld_restore(void) 221 + 222 + void acpi_processor_resume(void) 221 223 { 222 224 u32 resumed_bm_rld; 223 225 224 226 acpi_read_bit_register(ACPI_BITREG_BUS_MASTER_RLD, &resumed_bm_rld); 227 + if (resumed_bm_rld == saved_bm_rld) 228 + return; 225 229 226 - if (resumed_bm_rld != saved_bm_rld) 227 - acpi_write_bit_register(ACPI_BITREG_BUS_MASTER_RLD, saved_bm_rld); 230 + acpi_write_bit_register(ACPI_BITREG_BUS_MASTER_RLD, saved_bm_rld); 228 231 } 229 232 230 - int acpi_processor_suspend(struct device *dev) 233 + static struct syscore_ops acpi_processor_syscore_ops = { 234 + .suspend = acpi_processor_suspend, 235 + .resume = acpi_processor_resume, 236 + }; 237 + 238 + void acpi_processor_syscore_init(void) 231 239 { 232 - acpi_idle_bm_rld_save(); 233 - return 0; 240 + register_syscore_ops(&acpi_processor_syscore_ops); 234 241 } 235 242 236 - int acpi_processor_resume(struct device *dev) 243 + void acpi_processor_syscore_exit(void) 237 244 { 238 - acpi_idle_bm_rld_restore(); 239 - return 0; 245 + unregister_syscore_ops(&acpi_processor_syscore_ops); 240 246 } 247 + #endif /* CONFIG_PM_SLEEP */ 241 248 242 249 #if defined(CONFIG_X86) 243 250 static void tsc_check_state(int state)
+2 -1
drivers/acpi/scan.c
··· 1785 1785 acpi_set_pnp_ids(handle, &pnp, type); 1786 1786 1787 1787 if (!pnp.type.hardware_id) 1788 - return; 1788 + goto out; 1789 1789 1790 1790 /* 1791 1791 * This relies on the fact that acpi_install_notify_handler() will not ··· 1800 1800 } 1801 1801 } 1802 1802 1803 + out: 1803 1804 acpi_free_pnp_ids(&pnp); 1804 1805 } 1805 1806
+8
drivers/acpi/video.c
··· 456 456 DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion dm4 Notebook PC"), 457 457 }, 458 458 }, 459 + { 460 + .callback = video_ignore_initial_backlight, 461 + .ident = "HP 1000 Notebook PC", 462 + .matches = { 463 + DMI_MATCH(DMI_BOARD_VENDOR, "Hewlett-Packard"), 464 + DMI_MATCH(DMI_PRODUCT_NAME, "HP 1000 Notebook PC"), 465 + }, 466 + }, 459 467 {} 460 468 }; 461 469
-5
drivers/ata/pata_ep93xx.c
··· 933 933 } 934 934 935 935 mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 936 - if (!mem_res) { 937 - err = -ENXIO; 938 - goto err_rel_gpio; 939 - } 940 - 941 936 ide_base = devm_ioremap_resource(&pdev->dev, mem_res); 942 937 if (IS_ERR(ide_base)) { 943 938 err = PTR_ERR(ide_base);
+6 -6
drivers/base/power/common.c
··· 61 61 int dev_pm_put_subsys_data(struct device *dev) 62 62 { 63 63 struct pm_subsys_data *psd; 64 - int ret = 0; 64 + int ret = 1; 65 65 66 66 spin_lock_irq(&dev->power.lock); 67 67 68 68 psd = dev_to_psd(dev); 69 - if (!psd) { 70 - ret = -EINVAL; 69 + if (!psd) 71 70 goto out; 72 - } 73 71 74 72 if (--psd->refcount == 0) { 75 73 dev->power.subsys_data = NULL; 76 - kfree(psd); 77 - ret = 1; 74 + } else { 75 + psd = NULL; 76 + ret = 0; 78 77 } 79 78 80 79 out: 81 80 spin_unlock_irq(&dev->power.lock); 81 + kfree(psd); 82 82 83 83 return ret; 84 84 }
+554 -391
drivers/block/rbd.c
··· 55 55 #define SECTOR_SHIFT 9 56 56 #define SECTOR_SIZE (1ULL << SECTOR_SHIFT) 57 57 58 + /* 59 + * Increment the given counter and return its updated value. 60 + * If the counter is already 0 it will not be incremented. 61 + * If the counter is already at its maximum value returns 62 + * -EINVAL without updating it. 63 + */ 64 + static int atomic_inc_return_safe(atomic_t *v) 65 + { 66 + unsigned int counter; 67 + 68 + counter = (unsigned int)__atomic_add_unless(v, 1, 0); 69 + if (counter <= (unsigned int)INT_MAX) 70 + return (int)counter; 71 + 72 + atomic_dec(v); 73 + 74 + return -EINVAL; 75 + } 76 + 77 + /* Decrement the counter. Return the resulting value, or -EINVAL */ 78 + static int atomic_dec_return_safe(atomic_t *v) 79 + { 80 + int counter; 81 + 82 + counter = atomic_dec_return(v); 83 + if (counter >= 0) 84 + return counter; 85 + 86 + atomic_inc(v); 87 + 88 + return -EINVAL; 89 + } 90 + 58 91 #define RBD_DRV_NAME "rbd" 59 92 #define RBD_DRV_NAME_LONG "rbd (rados block device)" 60 93 ··· 133 100 * block device image metadata (in-memory version) 134 101 */ 135 102 struct rbd_image_header { 136 - /* These four fields never change for a given rbd image */ 103 + /* These six fields never change for a given rbd image */ 137 104 char *object_prefix; 138 - u64 features; 139 105 __u8 obj_order; 140 106 __u8 crypt_type; 141 107 __u8 comp_type; 108 + u64 stripe_unit; 109 + u64 stripe_count; 110 + u64 features; /* Might be changeable someday? */ 142 111 143 112 /* The remaining fields need to be updated occasionally */ 144 113 u64 image_size; 145 114 struct ceph_snap_context *snapc; 146 - char *snap_names; 147 - u64 *snap_sizes; 148 - 149 - u64 stripe_unit; 150 - u64 stripe_count; 115 + char *snap_names; /* format 1 only */ 116 + u64 *snap_sizes; /* format 1 only */ 151 117 }; 152 118 153 119 /* ··· 257 225 }; 258 226 }; 259 227 struct page **copyup_pages; 228 + u32 copyup_page_count; 260 229 261 230 struct ceph_osd_request *osd_req; 262 231 ··· 290 257 struct rbd_obj_request *obj_request; /* obj req initiator */ 291 258 }; 292 259 struct page **copyup_pages; 260 + u32 copyup_page_count; 293 261 spinlock_t completion_lock;/* protects next_completion */ 294 262 u32 next_completion; 295 263 rbd_img_callback_t callback; ··· 345 311 346 312 struct rbd_spec *parent_spec; 347 313 u64 parent_overlap; 314 + atomic_t parent_ref; 348 315 struct rbd_device *parent; 349 316 350 317 /* protects updating the header */ ··· 394 359 size_t count); 395 360 static ssize_t rbd_remove(struct bus_type *bus, const char *buf, 396 361 size_t count); 397 - static int rbd_dev_image_probe(struct rbd_device *rbd_dev); 362 + static int rbd_dev_image_probe(struct rbd_device *rbd_dev, bool mapping); 363 + static void rbd_spec_put(struct rbd_spec *spec); 398 364 399 365 static struct bus_attribute rbd_bus_attrs[] = { 400 366 __ATTR(add, S_IWUSR, NULL, rbd_add), ··· 462 426 static void rbd_dev_remove_parent(struct rbd_device *rbd_dev); 463 427 464 428 static int rbd_dev_refresh(struct rbd_device *rbd_dev); 465 - static int rbd_dev_v2_refresh(struct rbd_device *rbd_dev); 429 + static int rbd_dev_v2_header_onetime(struct rbd_device *rbd_dev); 430 + static int rbd_dev_v2_header_info(struct rbd_device *rbd_dev); 466 431 static const char *rbd_dev_v2_snap_name(struct rbd_device *rbd_dev, 467 432 u64 snap_id); 468 433 static int _rbd_dev_v2_snap_size(struct rbd_device *rbd_dev, u64 snap_id, ··· 763 726 } 764 727 765 728 /* 766 - * Create a new header structure, translate header format from the on-disk 767 - * header. 729 + * Fill an rbd image header with information from the given format 1 730 + * on-disk header. 768 731 */ 769 - static int rbd_header_from_disk(struct rbd_image_header *header, 732 + static int rbd_header_from_disk(struct rbd_device *rbd_dev, 770 733 struct rbd_image_header_ondisk *ondisk) 771 734 { 735 + struct rbd_image_header *header = &rbd_dev->header; 736 + bool first_time = header->object_prefix == NULL; 737 + struct ceph_snap_context *snapc; 738 + char *object_prefix = NULL; 739 + char *snap_names = NULL; 740 + u64 *snap_sizes = NULL; 772 741 u32 snap_count; 773 - size_t len; 774 742 size_t size; 743 + int ret = -ENOMEM; 775 744 u32 i; 776 745 777 - memset(header, 0, sizeof (*header)); 746 + /* Allocate this now to avoid having to handle failure below */ 747 + 748 + if (first_time) { 749 + size_t len; 750 + 751 + len = strnlen(ondisk->object_prefix, 752 + sizeof (ondisk->object_prefix)); 753 + object_prefix = kmalloc(len + 1, GFP_KERNEL); 754 + if (!object_prefix) 755 + return -ENOMEM; 756 + memcpy(object_prefix, ondisk->object_prefix, len); 757 + object_prefix[len] = '\0'; 758 + } 759 + 760 + /* Allocate the snapshot context and fill it in */ 778 761 779 762 snap_count = le32_to_cpu(ondisk->snap_count); 780 - 781 - len = strnlen(ondisk->object_prefix, sizeof (ondisk->object_prefix)); 782 - header->object_prefix = kmalloc(len + 1, GFP_KERNEL); 783 - if (!header->object_prefix) 784 - return -ENOMEM; 785 - memcpy(header->object_prefix, ondisk->object_prefix, len); 786 - header->object_prefix[len] = '\0'; 787 - 763 + snapc = ceph_create_snap_context(snap_count, GFP_KERNEL); 764 + if (!snapc) 765 + goto out_err; 766 + snapc->seq = le64_to_cpu(ondisk->snap_seq); 788 767 if (snap_count) { 768 + struct rbd_image_snap_ondisk *snaps; 789 769 u64 snap_names_len = le64_to_cpu(ondisk->snap_names_len); 790 770 791 - /* Save a copy of the snapshot names */ 771 + /* We'll keep a copy of the snapshot names... */ 792 772 793 - if (snap_names_len > (u64) SIZE_MAX) 794 - return -EIO; 795 - header->snap_names = kmalloc(snap_names_len, GFP_KERNEL); 796 - if (!header->snap_names) 773 + if (snap_names_len > (u64)SIZE_MAX) 774 + goto out_2big; 775 + snap_names = kmalloc(snap_names_len, GFP_KERNEL); 776 + if (!snap_names) 797 777 goto out_err; 778 + 779 + /* ...as well as the array of their sizes. */ 780 + 781 + size = snap_count * sizeof (*header->snap_sizes); 782 + snap_sizes = kmalloc(size, GFP_KERNEL); 783 + if (!snap_sizes) 784 + goto out_err; 785 + 798 786 /* 799 - * Note that rbd_dev_v1_header_read() guarantees 800 - * the ondisk buffer we're working with has 787 + * Copy the names, and fill in each snapshot's id 788 + * and size. 789 + * 790 + * Note that rbd_dev_v1_header_info() guarantees the 791 + * ondisk buffer we're working with has 801 792 * snap_names_len bytes beyond the end of the 802 793 * snapshot id array, this memcpy() is safe. 803 794 */ 804 - memcpy(header->snap_names, &ondisk->snaps[snap_count], 805 - snap_names_len); 806 - 807 - /* Record each snapshot's size */ 808 - 809 - size = snap_count * sizeof (*header->snap_sizes); 810 - header->snap_sizes = kmalloc(size, GFP_KERNEL); 811 - if (!header->snap_sizes) 812 - goto out_err; 813 - for (i = 0; i < snap_count; i++) 814 - header->snap_sizes[i] = 815 - le64_to_cpu(ondisk->snaps[i].image_size); 816 - } else { 817 - header->snap_names = NULL; 818 - header->snap_sizes = NULL; 795 + memcpy(snap_names, &ondisk->snaps[snap_count], snap_names_len); 796 + snaps = ondisk->snaps; 797 + for (i = 0; i < snap_count; i++) { 798 + snapc->snaps[i] = le64_to_cpu(snaps[i].id); 799 + snap_sizes[i] = le64_to_cpu(snaps[i].image_size); 800 + } 819 801 } 820 802 821 - header->features = 0; /* No features support in v1 images */ 822 - header->obj_order = ondisk->options.order; 823 - header->crypt_type = ondisk->options.crypt_type; 824 - header->comp_type = ondisk->options.comp_type; 803 + /* We won't fail any more, fill in the header */ 825 804 826 - /* Allocate and fill in the snapshot context */ 805 + down_write(&rbd_dev->header_rwsem); 806 + if (first_time) { 807 + header->object_prefix = object_prefix; 808 + header->obj_order = ondisk->options.order; 809 + header->crypt_type = ondisk->options.crypt_type; 810 + header->comp_type = ondisk->options.comp_type; 811 + /* The rest aren't used for format 1 images */ 812 + header->stripe_unit = 0; 813 + header->stripe_count = 0; 814 + header->features = 0; 815 + } else { 816 + ceph_put_snap_context(header->snapc); 817 + kfree(header->snap_names); 818 + kfree(header->snap_sizes); 819 + } 820 + 821 + /* The remaining fields always get updated (when we refresh) */ 827 822 828 823 header->image_size = le64_to_cpu(ondisk->image_size); 824 + header->snapc = snapc; 825 + header->snap_names = snap_names; 826 + header->snap_sizes = snap_sizes; 829 827 830 - header->snapc = ceph_create_snap_context(snap_count, GFP_KERNEL); 831 - if (!header->snapc) 832 - goto out_err; 833 - header->snapc->seq = le64_to_cpu(ondisk->snap_seq); 834 - for (i = 0; i < snap_count; i++) 835 - header->snapc->snaps[i] = le64_to_cpu(ondisk->snaps[i].id); 828 + /* Make sure mapping size is consistent with header info */ 829 + 830 + if (rbd_dev->spec->snap_id == CEPH_NOSNAP || first_time) 831 + if (rbd_dev->mapping.size != header->image_size) 832 + rbd_dev->mapping.size = header->image_size; 833 + 834 + up_write(&rbd_dev->header_rwsem); 836 835 837 836 return 0; 838 - 837 + out_2big: 838 + ret = -EIO; 839 839 out_err: 840 - kfree(header->snap_sizes); 841 - header->snap_sizes = NULL; 842 - kfree(header->snap_names); 843 - header->snap_names = NULL; 844 - kfree(header->object_prefix); 845 - header->object_prefix = NULL; 840 + kfree(snap_sizes); 841 + kfree(snap_names); 842 + ceph_put_snap_context(snapc); 843 + kfree(object_prefix); 846 844 847 - return -ENOMEM; 845 + return ret; 848 846 } 849 847 850 848 static const char *_rbd_dev_v1_snap_name(struct rbd_device *rbd_dev, u32 which) ··· 1006 934 1007 935 static int rbd_dev_mapping_set(struct rbd_device *rbd_dev) 1008 936 { 1009 - const char *snap_name = rbd_dev->spec->snap_name; 1010 - u64 snap_id; 937 + u64 snap_id = rbd_dev->spec->snap_id; 1011 938 u64 size = 0; 1012 939 u64 features = 0; 1013 940 int ret; 1014 - 1015 - if (strcmp(snap_name, RBD_SNAP_HEAD_NAME)) { 1016 - snap_id = rbd_snap_id_by_name(rbd_dev, snap_name); 1017 - if (snap_id == CEPH_NOSNAP) 1018 - return -ENOENT; 1019 - } else { 1020 - snap_id = CEPH_NOSNAP; 1021 - } 1022 941 1023 942 ret = rbd_snap_size(rbd_dev, snap_id, &size); 1024 943 if (ret) ··· 1021 958 rbd_dev->mapping.size = size; 1022 959 rbd_dev->mapping.features = features; 1023 960 1024 - /* If we are mapping a snapshot it must be marked read-only */ 1025 - 1026 - if (snap_id != CEPH_NOSNAP) 1027 - rbd_dev->mapping.read_only = true; 1028 - 1029 961 return 0; 1030 962 } 1031 963 ··· 1028 970 { 1029 971 rbd_dev->mapping.size = 0; 1030 972 rbd_dev->mapping.features = 0; 1031 - rbd_dev->mapping.read_only = true; 1032 - } 1033 - 1034 - static void rbd_dev_clear_mapping(struct rbd_device *rbd_dev) 1035 - { 1036 - rbd_dev->mapping.size = 0; 1037 - rbd_dev->mapping.features = 0; 1038 - rbd_dev->mapping.read_only = true; 1039 973 } 1040 974 1041 975 static const char *rbd_segment_name(struct rbd_device *rbd_dev, u64 offset) ··· 1392 1342 kref_put(&obj_request->kref, rbd_obj_request_destroy); 1393 1343 } 1394 1344 1395 - static void rbd_img_request_get(struct rbd_img_request *img_request) 1396 - { 1397 - dout("%s: img %p (was %d)\n", __func__, img_request, 1398 - atomic_read(&img_request->kref.refcount)); 1399 - kref_get(&img_request->kref); 1400 - } 1401 - 1345 + static bool img_request_child_test(struct rbd_img_request *img_request); 1346 + static void rbd_parent_request_destroy(struct kref *kref); 1402 1347 static void rbd_img_request_destroy(struct kref *kref); 1403 1348 static void rbd_img_request_put(struct rbd_img_request *img_request) 1404 1349 { 1405 1350 rbd_assert(img_request != NULL); 1406 1351 dout("%s: img %p (was %d)\n", __func__, img_request, 1407 1352 atomic_read(&img_request->kref.refcount)); 1408 - kref_put(&img_request->kref, rbd_img_request_destroy); 1353 + if (img_request_child_test(img_request)) 1354 + kref_put(&img_request->kref, rbd_parent_request_destroy); 1355 + else 1356 + kref_put(&img_request->kref, rbd_img_request_destroy); 1409 1357 } 1410 1358 1411 1359 static inline void rbd_img_obj_request_add(struct rbd_img_request *img_request, ··· 1520 1472 smp_mb(); 1521 1473 } 1522 1474 1475 + static void img_request_child_clear(struct rbd_img_request *img_request) 1476 + { 1477 + clear_bit(IMG_REQ_CHILD, &img_request->flags); 1478 + smp_mb(); 1479 + } 1480 + 1523 1481 static bool img_request_child_test(struct rbd_img_request *img_request) 1524 1482 { 1525 1483 smp_mb(); ··· 1535 1481 static void img_request_layered_set(struct rbd_img_request *img_request) 1536 1482 { 1537 1483 set_bit(IMG_REQ_LAYERED, &img_request->flags); 1484 + smp_mb(); 1485 + } 1486 + 1487 + static void img_request_layered_clear(struct rbd_img_request *img_request) 1488 + { 1489 + clear_bit(IMG_REQ_LAYERED, &img_request->flags); 1538 1490 smp_mb(); 1539 1491 } 1540 1492 ··· 1887 1827 kmem_cache_free(rbd_obj_request_cache, obj_request); 1888 1828 } 1889 1829 1830 + /* It's OK to call this for a device with no parent */ 1831 + 1832 + static void rbd_spec_put(struct rbd_spec *spec); 1833 + static void rbd_dev_unparent(struct rbd_device *rbd_dev) 1834 + { 1835 + rbd_dev_remove_parent(rbd_dev); 1836 + rbd_spec_put(rbd_dev->parent_spec); 1837 + rbd_dev->parent_spec = NULL; 1838 + rbd_dev->parent_overlap = 0; 1839 + } 1840 + 1841 + /* 1842 + * Parent image reference counting is used to determine when an 1843 + * image's parent fields can be safely torn down--after there are no 1844 + * more in-flight requests to the parent image. When the last 1845 + * reference is dropped, cleaning them up is safe. 1846 + */ 1847 + static void rbd_dev_parent_put(struct rbd_device *rbd_dev) 1848 + { 1849 + int counter; 1850 + 1851 + if (!rbd_dev->parent_spec) 1852 + return; 1853 + 1854 + counter = atomic_dec_return_safe(&rbd_dev->parent_ref); 1855 + if (counter > 0) 1856 + return; 1857 + 1858 + /* Last reference; clean up parent data structures */ 1859 + 1860 + if (!counter) 1861 + rbd_dev_unparent(rbd_dev); 1862 + else 1863 + rbd_warn(rbd_dev, "parent reference underflow\n"); 1864 + } 1865 + 1866 + /* 1867 + * If an image has a non-zero parent overlap, get a reference to its 1868 + * parent. 1869 + * 1870 + * We must get the reference before checking for the overlap to 1871 + * coordinate properly with zeroing the parent overlap in 1872 + * rbd_dev_v2_parent_info() when an image gets flattened. We 1873 + * drop it again if there is no overlap. 1874 + * 1875 + * Returns true if the rbd device has a parent with a non-zero 1876 + * overlap and a reference for it was successfully taken, or 1877 + * false otherwise. 1878 + */ 1879 + static bool rbd_dev_parent_get(struct rbd_device *rbd_dev) 1880 + { 1881 + int counter; 1882 + 1883 + if (!rbd_dev->parent_spec) 1884 + return false; 1885 + 1886 + counter = atomic_inc_return_safe(&rbd_dev->parent_ref); 1887 + if (counter > 0 && rbd_dev->parent_overlap) 1888 + return true; 1889 + 1890 + /* Image was flattened, but parent is not yet torn down */ 1891 + 1892 + if (counter < 0) 1893 + rbd_warn(rbd_dev, "parent reference overflow\n"); 1894 + 1895 + return false; 1896 + } 1897 + 1890 1898 /* 1891 1899 * Caller is responsible for filling in the list of object requests 1892 1900 * that comprises the image request, and the Linux request pointer ··· 1963 1835 static struct rbd_img_request *rbd_img_request_create( 1964 1836 struct rbd_device *rbd_dev, 1965 1837 u64 offset, u64 length, 1966 - bool write_request, 1967 - bool child_request) 1838 + bool write_request) 1968 1839 { 1969 1840 struct rbd_img_request *img_request; 1970 1841 ··· 1988 1861 } else { 1989 1862 img_request->snap_id = rbd_dev->spec->snap_id; 1990 1863 } 1991 - if (child_request) 1992 - img_request_child_set(img_request); 1993 - if (rbd_dev->parent_spec) 1864 + if (rbd_dev_parent_get(rbd_dev)) 1994 1865 img_request_layered_set(img_request); 1995 1866 spin_lock_init(&img_request->completion_lock); 1996 1867 img_request->next_completion = 0; ··· 1997 1872 img_request->obj_request_count = 0; 1998 1873 INIT_LIST_HEAD(&img_request->obj_requests); 1999 1874 kref_init(&img_request->kref); 2000 - 2001 - rbd_img_request_get(img_request); /* Avoid a warning */ 2002 - rbd_img_request_put(img_request); /* TEMPORARY */ 2003 1875 2004 1876 dout("%s: rbd_dev %p %s %llu/%llu -> img %p\n", __func__, rbd_dev, 2005 1877 write_request ? "write" : "read", offset, length, ··· 2019 1897 rbd_img_obj_request_del(img_request, obj_request); 2020 1898 rbd_assert(img_request->obj_request_count == 0); 2021 1899 1900 + if (img_request_layered_test(img_request)) { 1901 + img_request_layered_clear(img_request); 1902 + rbd_dev_parent_put(img_request->rbd_dev); 1903 + } 1904 + 2022 1905 if (img_request_write_test(img_request)) 2023 1906 ceph_put_snap_context(img_request->snapc); 2024 1907 2025 - if (img_request_child_test(img_request)) 2026 - rbd_obj_request_put(img_request->obj_request); 2027 - 2028 1908 kmem_cache_free(rbd_img_request_cache, img_request); 1909 + } 1910 + 1911 + static struct rbd_img_request *rbd_parent_request_create( 1912 + struct rbd_obj_request *obj_request, 1913 + u64 img_offset, u64 length) 1914 + { 1915 + struct rbd_img_request *parent_request; 1916 + struct rbd_device *rbd_dev; 1917 + 1918 + rbd_assert(obj_request->img_request); 1919 + rbd_dev = obj_request->img_request->rbd_dev; 1920 + 1921 + parent_request = rbd_img_request_create(rbd_dev->parent, 1922 + img_offset, length, false); 1923 + if (!parent_request) 1924 + return NULL; 1925 + 1926 + img_request_child_set(parent_request); 1927 + rbd_obj_request_get(obj_request); 1928 + parent_request->obj_request = obj_request; 1929 + 1930 + return parent_request; 1931 + } 1932 + 1933 + static void rbd_parent_request_destroy(struct kref *kref) 1934 + { 1935 + struct rbd_img_request *parent_request; 1936 + struct rbd_obj_request *orig_request; 1937 + 1938 + parent_request = container_of(kref, struct rbd_img_request, kref); 1939 + orig_request = parent_request->obj_request; 1940 + 1941 + parent_request->obj_request = NULL; 1942 + rbd_obj_request_put(orig_request); 1943 + img_request_child_clear(parent_request); 1944 + 1945 + rbd_img_request_destroy(kref); 2029 1946 } 2030 1947 2031 1948 static bool rbd_img_obj_end_request(struct rbd_obj_request *obj_request) ··· 2275 2114 { 2276 2115 struct rbd_img_request *img_request; 2277 2116 struct rbd_device *rbd_dev; 2278 - u64 length; 2117 + struct page **pages; 2279 2118 u32 page_count; 2280 2119 2281 2120 rbd_assert(obj_request->type == OBJ_REQUEST_BIO); ··· 2285 2124 2286 2125 rbd_dev = img_request->rbd_dev; 2287 2126 rbd_assert(rbd_dev); 2288 - length = (u64)1 << rbd_dev->header.obj_order; 2289 - page_count = (u32)calc_pages_for(0, length); 2290 2127 2291 - rbd_assert(obj_request->copyup_pages); 2292 - ceph_release_page_vector(obj_request->copyup_pages, page_count); 2128 + pages = obj_request->copyup_pages; 2129 + rbd_assert(pages != NULL); 2293 2130 obj_request->copyup_pages = NULL; 2131 + page_count = obj_request->copyup_page_count; 2132 + rbd_assert(page_count); 2133 + obj_request->copyup_page_count = 0; 2134 + ceph_release_page_vector(pages, page_count); 2294 2135 2295 2136 /* 2296 2137 * We want the transfer count to reflect the size of the ··· 2316 2153 struct ceph_osd_client *osdc; 2317 2154 struct rbd_device *rbd_dev; 2318 2155 struct page **pages; 2319 - int result; 2320 - u64 obj_size; 2321 - u64 xferred; 2156 + u32 page_count; 2157 + int img_result; 2158 + u64 parent_length; 2159 + u64 offset; 2160 + u64 length; 2322 2161 2323 2162 rbd_assert(img_request_child_test(img_request)); 2324 2163 ··· 2329 2164 pages = img_request->copyup_pages; 2330 2165 rbd_assert(pages != NULL); 2331 2166 img_request->copyup_pages = NULL; 2167 + page_count = img_request->copyup_page_count; 2168 + rbd_assert(page_count); 2169 + img_request->copyup_page_count = 0; 2332 2170 2333 2171 orig_request = img_request->obj_request; 2334 2172 rbd_assert(orig_request != NULL); 2335 - rbd_assert(orig_request->type == OBJ_REQUEST_BIO); 2336 - result = img_request->result; 2337 - obj_size = img_request->length; 2338 - xferred = img_request->xferred; 2339 - 2340 - rbd_dev = img_request->rbd_dev; 2341 - rbd_assert(rbd_dev); 2342 - rbd_assert(obj_size == (u64)1 << rbd_dev->header.obj_order); 2343 - 2173 + rbd_assert(obj_request_type_valid(orig_request->type)); 2174 + img_result = img_request->result; 2175 + parent_length = img_request->length; 2176 + rbd_assert(parent_length == img_request->xferred); 2344 2177 rbd_img_request_put(img_request); 2345 2178 2346 - if (result) 2179 + rbd_assert(orig_request->img_request); 2180 + rbd_dev = orig_request->img_request->rbd_dev; 2181 + rbd_assert(rbd_dev); 2182 + 2183 + /* 2184 + * If the overlap has become 0 (most likely because the 2185 + * image has been flattened) we need to free the pages 2186 + * and re-submit the original write request. 2187 + */ 2188 + if (!rbd_dev->parent_overlap) { 2189 + struct ceph_osd_client *osdc; 2190 + 2191 + ceph_release_page_vector(pages, page_count); 2192 + osdc = &rbd_dev->rbd_client->client->osdc; 2193 + img_result = rbd_obj_request_submit(osdc, orig_request); 2194 + if (!img_result) 2195 + return; 2196 + } 2197 + 2198 + if (img_result) 2347 2199 goto out_err; 2348 2200 2349 - /* Allocate the new copyup osd request for the original request */ 2350 - 2351 - result = -ENOMEM; 2352 - rbd_assert(!orig_request->osd_req); 2201 + /* 2202 + * The original osd request is of no use to use any more. 2203 + * We need a new one that can hold the two ops in a copyup 2204 + * request. Allocate the new copyup osd request for the 2205 + * original request, and release the old one. 2206 + */ 2207 + img_result = -ENOMEM; 2353 2208 osd_req = rbd_osd_req_create_copyup(orig_request); 2354 2209 if (!osd_req) 2355 2210 goto out_err; 2211 + rbd_osd_req_destroy(orig_request->osd_req); 2356 2212 orig_request->osd_req = osd_req; 2357 2213 orig_request->copyup_pages = pages; 2214 + orig_request->copyup_page_count = page_count; 2358 2215 2359 2216 /* Initialize the copyup op */ 2360 2217 2361 2218 osd_req_op_cls_init(osd_req, 0, CEPH_OSD_OP_CALL, "rbd", "copyup"); 2362 - osd_req_op_cls_request_data_pages(osd_req, 0, pages, obj_size, 0, 2219 + osd_req_op_cls_request_data_pages(osd_req, 0, pages, parent_length, 0, 2363 2220 false, false); 2364 2221 2365 2222 /* Then the original write request op */ 2366 2223 2224 + offset = orig_request->offset; 2225 + length = orig_request->length; 2367 2226 osd_req_op_extent_init(osd_req, 1, CEPH_OSD_OP_WRITE, 2368 - orig_request->offset, 2369 - orig_request->length, 0, 0); 2370 - osd_req_op_extent_osd_data_bio(osd_req, 1, orig_request->bio_list, 2371 - orig_request->length); 2227 + offset, length, 0, 0); 2228 + if (orig_request->type == OBJ_REQUEST_BIO) 2229 + osd_req_op_extent_osd_data_bio(osd_req, 1, 2230 + orig_request->bio_list, length); 2231 + else 2232 + osd_req_op_extent_osd_data_pages(osd_req, 1, 2233 + orig_request->pages, length, 2234 + offset & ~PAGE_MASK, false, false); 2372 2235 2373 2236 rbd_osd_req_format_write(orig_request); 2374 2237 ··· 2404 2211 2405 2212 orig_request->callback = rbd_img_obj_copyup_callback; 2406 2213 osdc = &rbd_dev->rbd_client->client->osdc; 2407 - result = rbd_obj_request_submit(osdc, orig_request); 2408 - if (!result) 2214 + img_result = rbd_obj_request_submit(osdc, orig_request); 2215 + if (!img_result) 2409 2216 return; 2410 2217 out_err: 2411 2218 /* Record the error code and complete the request */ 2412 2219 2413 - orig_request->result = result; 2220 + orig_request->result = img_result; 2414 2221 orig_request->xferred = 0; 2415 2222 obj_request_done_set(orig_request); 2416 2223 rbd_obj_request_complete(orig_request); ··· 2442 2249 int result; 2443 2250 2444 2251 rbd_assert(obj_request_img_data_test(obj_request)); 2445 - rbd_assert(obj_request->type == OBJ_REQUEST_BIO); 2252 + rbd_assert(obj_request_type_valid(obj_request->type)); 2446 2253 2447 2254 img_request = obj_request->img_request; 2448 2255 rbd_assert(img_request != NULL); 2449 2256 rbd_dev = img_request->rbd_dev; 2450 2257 rbd_assert(rbd_dev->parent != NULL); 2451 - 2452 - /* 2453 - * First things first. The original osd request is of no 2454 - * use to use any more, we'll need a new one that can hold 2455 - * the two ops in a copyup request. We'll get that later, 2456 - * but for now we can release the old one. 2457 - */ 2458 - rbd_osd_req_destroy(obj_request->osd_req); 2459 - obj_request->osd_req = NULL; 2460 2258 2461 2259 /* 2462 2260 * Determine the byte range covered by the object in the ··· 2479 2295 } 2480 2296 2481 2297 result = -ENOMEM; 2482 - parent_request = rbd_img_request_create(rbd_dev->parent, 2483 - img_offset, length, 2484 - false, true); 2298 + parent_request = rbd_parent_request_create(obj_request, 2299 + img_offset, length); 2485 2300 if (!parent_request) 2486 2301 goto out_err; 2487 - rbd_obj_request_get(obj_request); 2488 - parent_request->obj_request = obj_request; 2489 2302 2490 2303 result = rbd_img_request_fill(parent_request, OBJ_REQUEST_PAGES, pages); 2491 2304 if (result) 2492 2305 goto out_err; 2493 2306 parent_request->copyup_pages = pages; 2307 + parent_request->copyup_page_count = page_count; 2494 2308 2495 2309 parent_request->callback = rbd_img_obj_parent_read_full_callback; 2496 2310 result = rbd_img_request_submit(parent_request); ··· 2496 2314 return 0; 2497 2315 2498 2316 parent_request->copyup_pages = NULL; 2317 + parent_request->copyup_page_count = 0; 2499 2318 parent_request->obj_request = NULL; 2500 2319 rbd_obj_request_put(obj_request); 2501 2320 out_err: ··· 2514 2331 static void rbd_img_obj_exists_callback(struct rbd_obj_request *obj_request) 2515 2332 { 2516 2333 struct rbd_obj_request *orig_request; 2334 + struct rbd_device *rbd_dev; 2517 2335 int result; 2518 2336 2519 2337 rbd_assert(!obj_request_img_data_test(obj_request)); ··· 2537 2353 obj_request->xferred, obj_request->length); 2538 2354 rbd_obj_request_put(obj_request); 2539 2355 2540 - rbd_assert(orig_request); 2541 - rbd_assert(orig_request->img_request); 2356 + /* 2357 + * If the overlap has become 0 (most likely because the 2358 + * image has been flattened) we need to free the pages 2359 + * and re-submit the original write request. 2360 + */ 2361 + rbd_dev = orig_request->img_request->rbd_dev; 2362 + if (!rbd_dev->parent_overlap) { 2363 + struct ceph_osd_client *osdc; 2364 + 2365 + rbd_obj_request_put(orig_request); 2366 + osdc = &rbd_dev->rbd_client->client->osdc; 2367 + result = rbd_obj_request_submit(osdc, orig_request); 2368 + if (!result) 2369 + return; 2370 + } 2542 2371 2543 2372 /* 2544 2373 * Our only purpose here is to determine whether the object ··· 2709 2512 struct rbd_obj_request *obj_request; 2710 2513 struct rbd_device *rbd_dev; 2711 2514 u64 obj_end; 2515 + u64 img_xferred; 2516 + int img_result; 2712 2517 2713 2518 rbd_assert(img_request_child_test(img_request)); 2714 2519 2520 + /* First get what we need from the image request and release it */ 2521 + 2715 2522 obj_request = img_request->obj_request; 2523 + img_xferred = img_request->xferred; 2524 + img_result = img_request->result; 2525 + rbd_img_request_put(img_request); 2526 + 2527 + /* 2528 + * If the overlap has become 0 (most likely because the 2529 + * image has been flattened) we need to re-submit the 2530 + * original request. 2531 + */ 2716 2532 rbd_assert(obj_request); 2717 2533 rbd_assert(obj_request->img_request); 2534 + rbd_dev = obj_request->img_request->rbd_dev; 2535 + if (!rbd_dev->parent_overlap) { 2536 + struct ceph_osd_client *osdc; 2718 2537 2719 - obj_request->result = img_request->result; 2538 + osdc = &rbd_dev->rbd_client->client->osdc; 2539 + img_result = rbd_obj_request_submit(osdc, obj_request); 2540 + if (!img_result) 2541 + return; 2542 + } 2543 + 2544 + obj_request->result = img_result; 2720 2545 if (obj_request->result) 2721 2546 goto out; 2722 2547 ··· 2751 2532 */ 2752 2533 rbd_assert(obj_request->img_offset < U64_MAX - obj_request->length); 2753 2534 obj_end = obj_request->img_offset + obj_request->length; 2754 - rbd_dev = obj_request->img_request->rbd_dev; 2755 2535 if (obj_end > rbd_dev->parent_overlap) { 2756 2536 u64 xferred = 0; 2757 2537 ··· 2758 2540 xferred = rbd_dev->parent_overlap - 2759 2541 obj_request->img_offset; 2760 2542 2761 - obj_request->xferred = min(img_request->xferred, xferred); 2543 + obj_request->xferred = min(img_xferred, xferred); 2762 2544 } else { 2763 - obj_request->xferred = img_request->xferred; 2545 + obj_request->xferred = img_xferred; 2764 2546 } 2765 2547 out: 2766 - rbd_img_request_put(img_request); 2767 2548 rbd_img_obj_request_read_callback(obj_request); 2768 2549 rbd_obj_request_complete(obj_request); 2769 2550 } 2770 2551 2771 2552 static void rbd_img_parent_read(struct rbd_obj_request *obj_request) 2772 2553 { 2773 - struct rbd_device *rbd_dev; 2774 2554 struct rbd_img_request *img_request; 2775 2555 int result; 2776 2556 2777 2557 rbd_assert(obj_request_img_data_test(obj_request)); 2778 2558 rbd_assert(obj_request->img_request != NULL); 2779 2559 rbd_assert(obj_request->result == (s32) -ENOENT); 2780 - rbd_assert(obj_request->type == OBJ_REQUEST_BIO); 2560 + rbd_assert(obj_request_type_valid(obj_request->type)); 2781 2561 2782 - rbd_dev = obj_request->img_request->rbd_dev; 2783 - rbd_assert(rbd_dev->parent != NULL); 2784 2562 /* rbd_read_finish(obj_request, obj_request->length); */ 2785 - img_request = rbd_img_request_create(rbd_dev->parent, 2563 + img_request = rbd_parent_request_create(obj_request, 2786 2564 obj_request->img_offset, 2787 - obj_request->length, 2788 - false, true); 2565 + obj_request->length); 2789 2566 result = -ENOMEM; 2790 2567 if (!img_request) 2791 2568 goto out_err; 2792 2569 2793 - rbd_obj_request_get(obj_request); 2794 - img_request->obj_request = obj_request; 2795 - 2796 - result = rbd_img_request_fill(img_request, OBJ_REQUEST_BIO, 2797 - obj_request->bio_list); 2570 + if (obj_request->type == OBJ_REQUEST_BIO) 2571 + result = rbd_img_request_fill(img_request, OBJ_REQUEST_BIO, 2572 + obj_request->bio_list); 2573 + else 2574 + result = rbd_img_request_fill(img_request, OBJ_REQUEST_PAGES, 2575 + obj_request->pages); 2798 2576 if (result) 2799 2577 goto out_err; 2800 2578 ··· 2840 2626 static void rbd_watch_cb(u64 ver, u64 notify_id, u8 opcode, void *data) 2841 2627 { 2842 2628 struct rbd_device *rbd_dev = (struct rbd_device *)data; 2629 + int ret; 2843 2630 2844 2631 if (!rbd_dev) 2845 2632 return; ··· 2848 2633 dout("%s: \"%s\" notify_id %llu opcode %u\n", __func__, 2849 2634 rbd_dev->header_name, (unsigned long long)notify_id, 2850 2635 (unsigned int)opcode); 2851 - (void)rbd_dev_refresh(rbd_dev); 2636 + ret = rbd_dev_refresh(rbd_dev); 2637 + if (ret) 2638 + rbd_warn(rbd_dev, ": header refresh error (%d)\n", ret); 2852 2639 2853 2640 rbd_obj_notify_ack(rbd_dev, notify_id); 2854 2641 } ··· 2859 2642 * Request sync osd watch/unwatch. The value of "start" determines 2860 2643 * whether a watch request is being initiated or torn down. 2861 2644 */ 2862 - static int rbd_dev_header_watch_sync(struct rbd_device *rbd_dev, int start) 2645 + static int rbd_dev_header_watch_sync(struct rbd_device *rbd_dev, bool start) 2863 2646 { 2864 2647 struct ceph_osd_client *osdc = &rbd_dev->rbd_client->client->osdc; 2865 2648 struct rbd_obj_request *obj_request; ··· 2893 2676 rbd_dev->watch_request->osd_req); 2894 2677 2895 2678 osd_req_op_watch_init(obj_request->osd_req, 0, CEPH_OSD_OP_WATCH, 2896 - rbd_dev->watch_event->cookie, 0, start); 2679 + rbd_dev->watch_event->cookie, 0, start ? 1 : 0); 2897 2680 rbd_osd_req_format_write(obj_request); 2898 2681 2899 2682 ret = rbd_obj_request_submit(osdc, obj_request); ··· 3086 2869 goto end_request; /* Shouldn't happen */ 3087 2870 } 3088 2871 2872 + result = -EIO; 2873 + if (offset + length > rbd_dev->mapping.size) { 2874 + rbd_warn(rbd_dev, "beyond EOD (%llu~%llu > %llu)\n", 2875 + offset, length, rbd_dev->mapping.size); 2876 + goto end_request; 2877 + } 2878 + 3089 2879 result = -ENOMEM; 3090 2880 img_request = rbd_img_request_create(rbd_dev, offset, length, 3091 - write_request, false); 2881 + write_request); 3092 2882 if (!img_request) 3093 2883 goto end_request; 3094 2884 ··· 3246 3022 } 3247 3023 3248 3024 /* 3249 - * Read the complete header for the given rbd device. 3250 - * 3251 - * Returns a pointer to a dynamically-allocated buffer containing 3252 - * the complete and validated header. Caller can pass the address 3253 - * of a variable that will be filled in with the version of the 3254 - * header object at the time it was read. 3255 - * 3256 - * Returns a pointer-coded errno if a failure occurs. 3025 + * Read the complete header for the given rbd device. On successful 3026 + * return, the rbd_dev->header field will contain up-to-date 3027 + * information about the image. 3257 3028 */ 3258 - static struct rbd_image_header_ondisk * 3259 - rbd_dev_v1_header_read(struct rbd_device *rbd_dev) 3029 + static int rbd_dev_v1_header_info(struct rbd_device *rbd_dev) 3260 3030 { 3261 3031 struct rbd_image_header_ondisk *ondisk = NULL; 3262 3032 u32 snap_count = 0; ··· 3275 3057 size += names_size; 3276 3058 ondisk = kmalloc(size, GFP_KERNEL); 3277 3059 if (!ondisk) 3278 - return ERR_PTR(-ENOMEM); 3060 + return -ENOMEM; 3279 3061 3280 3062 ret = rbd_obj_read_sync(rbd_dev, rbd_dev->header_name, 3281 3063 0, size, ondisk); 3282 3064 if (ret < 0) 3283 - goto out_err; 3065 + goto out; 3284 3066 if ((size_t)ret < size) { 3285 3067 ret = -ENXIO; 3286 3068 rbd_warn(rbd_dev, "short header read (want %zd got %d)", 3287 3069 size, ret); 3288 - goto out_err; 3070 + goto out; 3289 3071 } 3290 3072 if (!rbd_dev_ondisk_valid(ondisk)) { 3291 3073 ret = -ENXIO; 3292 3074 rbd_warn(rbd_dev, "invalid header"); 3293 - goto out_err; 3075 + goto out; 3294 3076 } 3295 3077 3296 3078 names_size = le64_to_cpu(ondisk->snap_names_len); ··· 3298 3080 snap_count = le32_to_cpu(ondisk->snap_count); 3299 3081 } while (snap_count != want_count); 3300 3082 3301 - return ondisk; 3302 - 3303 - out_err: 3083 + ret = rbd_header_from_disk(rbd_dev, ondisk); 3084 + out: 3304 3085 kfree(ondisk); 3305 - 3306 - return ERR_PTR(ret); 3307 - } 3308 - 3309 - /* 3310 - * reload the ondisk the header 3311 - */ 3312 - static int rbd_read_header(struct rbd_device *rbd_dev, 3313 - struct rbd_image_header *header) 3314 - { 3315 - struct rbd_image_header_ondisk *ondisk; 3316 - int ret; 3317 - 3318 - ondisk = rbd_dev_v1_header_read(rbd_dev); 3319 - if (IS_ERR(ondisk)) 3320 - return PTR_ERR(ondisk); 3321 - ret = rbd_header_from_disk(header, ondisk); 3322 - kfree(ondisk); 3323 - 3324 - return ret; 3325 - } 3326 - 3327 - static void rbd_update_mapping_size(struct rbd_device *rbd_dev) 3328 - { 3329 - if (rbd_dev->spec->snap_id != CEPH_NOSNAP) 3330 - return; 3331 - 3332 - if (rbd_dev->mapping.size != rbd_dev->header.image_size) { 3333 - sector_t size; 3334 - 3335 - rbd_dev->mapping.size = rbd_dev->header.image_size; 3336 - size = (sector_t)rbd_dev->mapping.size / SECTOR_SIZE; 3337 - dout("setting size to %llu sectors", (unsigned long long)size); 3338 - set_capacity(rbd_dev->disk, size); 3339 - } 3340 - } 3341 - 3342 - /* 3343 - * only read the first part of the ondisk header, without the snaps info 3344 - */ 3345 - static int rbd_dev_v1_refresh(struct rbd_device *rbd_dev) 3346 - { 3347 - int ret; 3348 - struct rbd_image_header h; 3349 - 3350 - ret = rbd_read_header(rbd_dev, &h); 3351 - if (ret < 0) 3352 - return ret; 3353 - 3354 - down_write(&rbd_dev->header_rwsem); 3355 - 3356 - /* Update image size, and check for resize of mapped image */ 3357 - rbd_dev->header.image_size = h.image_size; 3358 - rbd_update_mapping_size(rbd_dev); 3359 - 3360 - /* rbd_dev->header.object_prefix shouldn't change */ 3361 - kfree(rbd_dev->header.snap_sizes); 3362 - kfree(rbd_dev->header.snap_names); 3363 - /* osd requests may still refer to snapc */ 3364 - ceph_put_snap_context(rbd_dev->header.snapc); 3365 - 3366 - rbd_dev->header.image_size = h.image_size; 3367 - rbd_dev->header.snapc = h.snapc; 3368 - rbd_dev->header.snap_names = h.snap_names; 3369 - rbd_dev->header.snap_sizes = h.snap_sizes; 3370 - /* Free the extra copy of the object prefix */ 3371 - if (strcmp(rbd_dev->header.object_prefix, h.object_prefix)) 3372 - rbd_warn(rbd_dev, "object prefix changed (ignoring)"); 3373 - kfree(h.object_prefix); 3374 - 3375 - up_write(&rbd_dev->header_rwsem); 3376 3086 3377 3087 return ret; 3378 3088 } ··· 3326 3180 3327 3181 static int rbd_dev_refresh(struct rbd_device *rbd_dev) 3328 3182 { 3329 - u64 image_size; 3183 + u64 mapping_size; 3330 3184 int ret; 3331 3185 3332 3186 rbd_assert(rbd_image_format_valid(rbd_dev->image_format)); 3333 - image_size = rbd_dev->header.image_size; 3187 + mapping_size = rbd_dev->mapping.size; 3334 3188 mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING); 3335 3189 if (rbd_dev->image_format == 1) 3336 - ret = rbd_dev_v1_refresh(rbd_dev); 3190 + ret = rbd_dev_v1_header_info(rbd_dev); 3337 3191 else 3338 - ret = rbd_dev_v2_refresh(rbd_dev); 3192 + ret = rbd_dev_v2_header_info(rbd_dev); 3339 3193 3340 3194 /* If it's a mapped snapshot, validate its EXISTS flag */ 3341 3195 3342 3196 rbd_exists_validate(rbd_dev); 3343 3197 mutex_unlock(&ctl_mutex); 3344 - if (ret) 3345 - rbd_warn(rbd_dev, "got notification but failed to " 3346 - " update snaps: %d\n", ret); 3347 - if (image_size != rbd_dev->header.image_size) 3198 + if (mapping_size != rbd_dev->mapping.size) { 3199 + sector_t size; 3200 + 3201 + size = (sector_t)rbd_dev->mapping.size / SECTOR_SIZE; 3202 + dout("setting size to %llu sectors", (unsigned long long)size); 3203 + set_capacity(rbd_dev->disk, size); 3348 3204 revalidate_disk(rbd_dev->disk); 3205 + } 3349 3206 3350 3207 return ret; 3351 3208 } ··· 3552 3403 int ret; 3553 3404 3554 3405 ret = rbd_dev_refresh(rbd_dev); 3406 + if (ret) 3407 + rbd_warn(rbd_dev, ": manual header refresh error (%d)\n", ret); 3555 3408 3556 3409 return ret < 0 ? ret : size; 3557 3410 } ··· 3652 3501 3653 3502 spin_lock_init(&rbd_dev->lock); 3654 3503 rbd_dev->flags = 0; 3504 + atomic_set(&rbd_dev->parent_ref, 0); 3655 3505 INIT_LIST_HEAD(&rbd_dev->node); 3656 3506 init_rwsem(&rbd_dev->header_rwsem); 3657 3507 ··· 3802 3650 __le64 snapid; 3803 3651 void *p; 3804 3652 void *end; 3653 + u64 pool_id; 3805 3654 char *image_id; 3806 3655 u64 overlap; 3807 3656 int ret; ··· 3833 3680 p = reply_buf; 3834 3681 end = reply_buf + ret; 3835 3682 ret = -ERANGE; 3836 - ceph_decode_64_safe(&p, end, parent_spec->pool_id, out_err); 3837 - if (parent_spec->pool_id == CEPH_NOPOOL) 3683 + ceph_decode_64_safe(&p, end, pool_id, out_err); 3684 + if (pool_id == CEPH_NOPOOL) { 3685 + /* 3686 + * Either the parent never existed, or we have 3687 + * record of it but the image got flattened so it no 3688 + * longer has a parent. When the parent of a 3689 + * layered image disappears we immediately set the 3690 + * overlap to 0. The effect of this is that all new 3691 + * requests will be treated as if the image had no 3692 + * parent. 3693 + */ 3694 + if (rbd_dev->parent_overlap) { 3695 + rbd_dev->parent_overlap = 0; 3696 + smp_mb(); 3697 + rbd_dev_parent_put(rbd_dev); 3698 + pr_info("%s: clone image has been flattened\n", 3699 + rbd_dev->disk->disk_name); 3700 + } 3701 + 3838 3702 goto out; /* No parent? No problem. */ 3703 + } 3839 3704 3840 3705 /* The ceph file layout needs to fit pool id in 32 bits */ 3841 3706 3842 3707 ret = -EIO; 3843 - if (parent_spec->pool_id > (u64)U32_MAX) { 3708 + if (pool_id > (u64)U32_MAX) { 3844 3709 rbd_warn(NULL, "parent pool id too large (%llu > %u)\n", 3845 - (unsigned long long)parent_spec->pool_id, U32_MAX); 3710 + (unsigned long long)pool_id, U32_MAX); 3846 3711 goto out_err; 3847 3712 } 3713 + parent_spec->pool_id = pool_id; 3848 3714 3849 3715 image_id = ceph_extract_encoded_string(&p, end, NULL, GFP_KERNEL); 3850 3716 if (IS_ERR(image_id)) { ··· 3874 3702 ceph_decode_64_safe(&p, end, parent_spec->snap_id, out_err); 3875 3703 ceph_decode_64_safe(&p, end, overlap, out_err); 3876 3704 3877 - rbd_dev->parent_overlap = overlap; 3878 - rbd_dev->parent_spec = parent_spec; 3879 - parent_spec = NULL; /* rbd_dev now owns this */ 3705 + if (overlap) { 3706 + rbd_spec_put(rbd_dev->parent_spec); 3707 + rbd_dev->parent_spec = parent_spec; 3708 + parent_spec = NULL; /* rbd_dev now owns this */ 3709 + rbd_dev->parent_overlap = overlap; 3710 + } else { 3711 + rbd_warn(rbd_dev, "ignoring parent of clone with overlap 0\n"); 3712 + } 3880 3713 out: 3881 3714 ret = 0; 3882 3715 out_err: ··· 4179 4002 for (i = 0; i < snap_count; i++) 4180 4003 snapc->snaps[i] = ceph_decode_64(&p); 4181 4004 4005 + ceph_put_snap_context(rbd_dev->header.snapc); 4182 4006 rbd_dev->header.snapc = snapc; 4183 4007 4184 4008 dout(" snap context seq = %llu, snap_count = %u\n", ··· 4231 4053 return snap_name; 4232 4054 } 4233 4055 4234 - static int rbd_dev_v2_refresh(struct rbd_device *rbd_dev) 4056 + static int rbd_dev_v2_header_info(struct rbd_device *rbd_dev) 4235 4057 { 4058 + bool first_time = rbd_dev->header.object_prefix == NULL; 4236 4059 int ret; 4237 4060 4238 4061 down_write(&rbd_dev->header_rwsem); 4239 4062 4063 + if (first_time) { 4064 + ret = rbd_dev_v2_header_onetime(rbd_dev); 4065 + if (ret) 4066 + goto out; 4067 + } 4068 + 4069 + /* 4070 + * If the image supports layering, get the parent info. We 4071 + * need to probe the first time regardless. Thereafter we 4072 + * only need to if there's a parent, to see if it has 4073 + * disappeared due to the mapped image getting flattened. 4074 + */ 4075 + if (rbd_dev->header.features & RBD_FEATURE_LAYERING && 4076 + (first_time || rbd_dev->parent_spec)) { 4077 + bool warn; 4078 + 4079 + ret = rbd_dev_v2_parent_info(rbd_dev); 4080 + if (ret) 4081 + goto out; 4082 + 4083 + /* 4084 + * Print a warning if this is the initial probe and 4085 + * the image has a parent. Don't print it if the 4086 + * image now being probed is itself a parent. We 4087 + * can tell at this point because we won't know its 4088 + * pool name yet (just its pool id). 4089 + */ 4090 + warn = rbd_dev->parent_spec && rbd_dev->spec->pool_name; 4091 + if (first_time && warn) 4092 + rbd_warn(rbd_dev, "WARNING: kernel layering " 4093 + "is EXPERIMENTAL!"); 4094 + } 4095 + 4240 4096 ret = rbd_dev_v2_image_size(rbd_dev); 4241 4097 if (ret) 4242 4098 goto out; 4243 - rbd_update_mapping_size(rbd_dev); 4099 + 4100 + if (rbd_dev->spec->snap_id == CEPH_NOSNAP) 4101 + if (rbd_dev->mapping.size != rbd_dev->header.image_size) 4102 + rbd_dev->mapping.size = rbd_dev->header.image_size; 4244 4103 4245 4104 ret = rbd_dev_v2_snap_context(rbd_dev); 4246 4105 dout("rbd_dev_v2_snap_context returned %d\n", ret); 4247 - if (ret) 4248 - goto out; 4249 4106 out: 4250 4107 up_write(&rbd_dev->header_rwsem); 4251 4108 ··· 4703 4490 { 4704 4491 struct rbd_image_header *header; 4705 4492 4706 - rbd_dev_remove_parent(rbd_dev); 4707 - rbd_spec_put(rbd_dev->parent_spec); 4708 - rbd_dev->parent_spec = NULL; 4709 - rbd_dev->parent_overlap = 0; 4493 + /* Drop parent reference unless it's already been done (or none) */ 4494 + 4495 + if (rbd_dev->parent_overlap) 4496 + rbd_dev_parent_put(rbd_dev); 4710 4497 4711 4498 /* Free dynamic fields from the header, then zero it out */ 4712 4499 ··· 4718 4505 memset(header, 0, sizeof (*header)); 4719 4506 } 4720 4507 4721 - static int rbd_dev_v1_probe(struct rbd_device *rbd_dev) 4508 + static int rbd_dev_v2_header_onetime(struct rbd_device *rbd_dev) 4722 4509 { 4723 4510 int ret; 4724 - 4725 - /* Populate rbd image metadata */ 4726 - 4727 - ret = rbd_read_header(rbd_dev, &rbd_dev->header); 4728 - if (ret < 0) 4729 - goto out_err; 4730 - 4731 - /* Version 1 images have no parent (no layering) */ 4732 - 4733 - rbd_dev->parent_spec = NULL; 4734 - rbd_dev->parent_overlap = 0; 4735 - 4736 - dout("discovered version 1 image, header name is %s\n", 4737 - rbd_dev->header_name); 4738 - 4739 - return 0; 4740 - 4741 - out_err: 4742 - kfree(rbd_dev->header_name); 4743 - rbd_dev->header_name = NULL; 4744 - kfree(rbd_dev->spec->image_id); 4745 - rbd_dev->spec->image_id = NULL; 4746 - 4747 - return ret; 4748 - } 4749 - 4750 - static int rbd_dev_v2_probe(struct rbd_device *rbd_dev) 4751 - { 4752 - int ret; 4753 - 4754 - ret = rbd_dev_v2_image_size(rbd_dev); 4755 - if (ret) 4756 - goto out_err; 4757 - 4758 - /* Get the object prefix (a.k.a. block_name) for the image */ 4759 4511 4760 4512 ret = rbd_dev_v2_object_prefix(rbd_dev); 4761 4513 if (ret) 4762 4514 goto out_err; 4763 4515 4764 - /* Get the and check features for the image */ 4765 - 4516 + /* 4517 + * Get the and check features for the image. Currently the 4518 + * features are assumed to never change. 4519 + */ 4766 4520 ret = rbd_dev_v2_features(rbd_dev); 4767 4521 if (ret) 4768 4522 goto out_err; 4769 - 4770 - /* If the image supports layering, get the parent info */ 4771 - 4772 - if (rbd_dev->header.features & RBD_FEATURE_LAYERING) { 4773 - ret = rbd_dev_v2_parent_info(rbd_dev); 4774 - if (ret) 4775 - goto out_err; 4776 - 4777 - /* 4778 - * Don't print a warning for parent images. We can 4779 - * tell this point because we won't know its pool 4780 - * name yet (just its pool id). 4781 - */ 4782 - if (rbd_dev->spec->pool_name) 4783 - rbd_warn(rbd_dev, "WARNING: kernel layering " 4784 - "is EXPERIMENTAL!"); 4785 - } 4786 4523 4787 4524 /* If the image supports fancy striping, get its parameters */ 4788 4525 ··· 4741 4578 if (ret < 0) 4742 4579 goto out_err; 4743 4580 } 4744 - 4745 - /* crypto and compression type aren't (yet) supported for v2 images */ 4746 - 4747 - rbd_dev->header.crypt_type = 0; 4748 - rbd_dev->header.comp_type = 0; 4749 - 4750 - /* Get the snapshot context, plus the header version */ 4751 - 4752 - ret = rbd_dev_v2_snap_context(rbd_dev); 4753 - if (ret) 4754 - goto out_err; 4755 - 4756 - dout("discovered version 2 image, header name is %s\n", 4757 - rbd_dev->header_name); 4581 + /* No support for crypto and compression type format 2 images */ 4758 4582 4759 4583 return 0; 4760 4584 out_err: 4761 - rbd_dev->parent_overlap = 0; 4762 - rbd_spec_put(rbd_dev->parent_spec); 4763 - rbd_dev->parent_spec = NULL; 4764 - kfree(rbd_dev->header_name); 4765 - rbd_dev->header_name = NULL; 4585 + rbd_dev->header.features = 0; 4766 4586 kfree(rbd_dev->header.object_prefix); 4767 4587 rbd_dev->header.object_prefix = NULL; 4768 4588 ··· 4774 4628 if (!parent) 4775 4629 goto out_err; 4776 4630 4777 - ret = rbd_dev_image_probe(parent); 4631 + ret = rbd_dev_image_probe(parent, false); 4778 4632 if (ret < 0) 4779 4633 goto out_err; 4780 4634 rbd_dev->parent = parent; 4635 + atomic_set(&rbd_dev->parent_ref, 1); 4781 4636 4782 4637 return 0; 4783 4638 out_err: 4784 4639 if (parent) { 4785 - rbd_spec_put(rbd_dev->parent_spec); 4640 + rbd_dev_unparent(rbd_dev); 4786 4641 kfree(rbd_dev->header_name); 4787 4642 rbd_dev_destroy(parent); 4788 4643 } else { ··· 4797 4650 static int rbd_dev_device_setup(struct rbd_device *rbd_dev) 4798 4651 { 4799 4652 int ret; 4800 - 4801 - ret = rbd_dev_mapping_set(rbd_dev); 4802 - if (ret) 4803 - return ret; 4804 4653 4805 4654 /* generate unique id: find highest unique id, add one */ 4806 4655 rbd_dev_id_get(rbd_dev); ··· 4819 4676 if (ret) 4820 4677 goto err_out_blkdev; 4821 4678 4822 - ret = rbd_bus_add_dev(rbd_dev); 4679 + ret = rbd_dev_mapping_set(rbd_dev); 4823 4680 if (ret) 4824 4681 goto err_out_disk; 4682 + set_capacity(rbd_dev->disk, rbd_dev->mapping.size / SECTOR_SIZE); 4683 + 4684 + ret = rbd_bus_add_dev(rbd_dev); 4685 + if (ret) 4686 + goto err_out_mapping; 4825 4687 4826 4688 /* Everything's ready. Announce the disk to the world. */ 4827 4689 4828 - set_capacity(rbd_dev->disk, rbd_dev->mapping.size / SECTOR_SIZE); 4829 4690 set_bit(RBD_DEV_FLAG_EXISTS, &rbd_dev->flags); 4830 4691 add_disk(rbd_dev->disk); 4831 4692 ··· 4838 4691 4839 4692 return ret; 4840 4693 4694 + err_out_mapping: 4695 + rbd_dev_mapping_clear(rbd_dev); 4841 4696 err_out_disk: 4842 4697 rbd_free_disk(rbd_dev); 4843 4698 err_out_blkdev: ··· 4880 4731 4881 4732 static void rbd_dev_image_release(struct rbd_device *rbd_dev) 4882 4733 { 4883 - int ret; 4884 - 4885 4734 rbd_dev_unprobe(rbd_dev); 4886 - ret = rbd_dev_header_watch_sync(rbd_dev, 0); 4887 - if (ret) 4888 - rbd_warn(rbd_dev, "failed to cancel watch event (%d)\n", ret); 4889 4735 kfree(rbd_dev->header_name); 4890 4736 rbd_dev->header_name = NULL; 4891 4737 rbd_dev->image_format = 0; ··· 4892 4748 4893 4749 /* 4894 4750 * Probe for the existence of the header object for the given rbd 4895 - * device. For format 2 images this includes determining the image 4896 - * id. 4751 + * device. If this image is the one being mapped (i.e., not a 4752 + * parent), initiate a watch on its header object before using that 4753 + * object to get detailed information about the rbd image. 4897 4754 */ 4898 - static int rbd_dev_image_probe(struct rbd_device *rbd_dev) 4755 + static int rbd_dev_image_probe(struct rbd_device *rbd_dev, bool mapping) 4899 4756 { 4900 4757 int ret; 4901 4758 int tmp; ··· 4916 4771 if (ret) 4917 4772 goto err_out_format; 4918 4773 4919 - ret = rbd_dev_header_watch_sync(rbd_dev, 1); 4920 - if (ret) 4921 - goto out_header_name; 4774 + if (mapping) { 4775 + ret = rbd_dev_header_watch_sync(rbd_dev, true); 4776 + if (ret) 4777 + goto out_header_name; 4778 + } 4922 4779 4923 4780 if (rbd_dev->image_format == 1) 4924 - ret = rbd_dev_v1_probe(rbd_dev); 4781 + ret = rbd_dev_v1_header_info(rbd_dev); 4925 4782 else 4926 - ret = rbd_dev_v2_probe(rbd_dev); 4783 + ret = rbd_dev_v2_header_info(rbd_dev); 4927 4784 if (ret) 4928 4785 goto err_out_watch; 4929 4786 ··· 4934 4787 goto err_out_probe; 4935 4788 4936 4789 ret = rbd_dev_probe_parent(rbd_dev); 4937 - if (!ret) 4938 - return 0; 4790 + if (ret) 4791 + goto err_out_probe; 4939 4792 4793 + dout("discovered format %u image, header name is %s\n", 4794 + rbd_dev->image_format, rbd_dev->header_name); 4795 + 4796 + return 0; 4940 4797 err_out_probe: 4941 4798 rbd_dev_unprobe(rbd_dev); 4942 4799 err_out_watch: 4943 - tmp = rbd_dev_header_watch_sync(rbd_dev, 0); 4944 - if (tmp) 4945 - rbd_warn(rbd_dev, "unable to tear down watch request\n"); 4800 + if (mapping) { 4801 + tmp = rbd_dev_header_watch_sync(rbd_dev, false); 4802 + if (tmp) 4803 + rbd_warn(rbd_dev, "unable to tear down " 4804 + "watch request (%d)\n", tmp); 4805 + } 4946 4806 out_header_name: 4947 4807 kfree(rbd_dev->header_name); 4948 4808 rbd_dev->header_name = NULL; ··· 4973 4819 struct rbd_spec *spec = NULL; 4974 4820 struct rbd_client *rbdc; 4975 4821 struct ceph_osd_client *osdc; 4822 + bool read_only; 4976 4823 int rc = -ENOMEM; 4977 4824 4978 4825 if (!try_module_get(THIS_MODULE)) ··· 4983 4828 rc = rbd_add_parse_args(buf, &ceph_opts, &rbd_opts, &spec); 4984 4829 if (rc < 0) 4985 4830 goto err_out_module; 4831 + read_only = rbd_opts->read_only; 4832 + kfree(rbd_opts); 4833 + rbd_opts = NULL; /* done with this */ 4986 4834 4987 4835 rbdc = rbd_get_client(ceph_opts); 4988 4836 if (IS_ERR(rbdc)) { ··· 5016 4858 rbdc = NULL; /* rbd_dev now owns this */ 5017 4859 spec = NULL; /* rbd_dev now owns this */ 5018 4860 5019 - rbd_dev->mapping.read_only = rbd_opts->read_only; 5020 - kfree(rbd_opts); 5021 - rbd_opts = NULL; /* done with this */ 5022 - 5023 - rc = rbd_dev_image_probe(rbd_dev); 4861 + rc = rbd_dev_image_probe(rbd_dev, true); 5024 4862 if (rc < 0) 5025 4863 goto err_out_rbd_dev; 4864 + 4865 + /* If we are mapping a snapshot it must be marked read-only */ 4866 + 4867 + if (rbd_dev->spec->snap_id != CEPH_NOSNAP) 4868 + read_only = true; 4869 + rbd_dev->mapping.read_only = read_only; 5026 4870 5027 4871 rc = rbd_dev_device_setup(rbd_dev); 5028 4872 if (!rc) ··· 5071 4911 5072 4912 rbd_free_disk(rbd_dev); 5073 4913 clear_bit(RBD_DEV_FLAG_EXISTS, &rbd_dev->flags); 5074 - rbd_dev_clear_mapping(rbd_dev); 4914 + rbd_dev_mapping_clear(rbd_dev); 5075 4915 unregister_blkdev(rbd_dev->major, rbd_dev->name); 5076 4916 rbd_dev->major = 0; 5077 4917 rbd_dev_id_put(rbd_dev); ··· 5138 4978 spin_unlock_irq(&rbd_dev->lock); 5139 4979 if (ret < 0) 5140 4980 goto done; 5141 - ret = count; 5142 4981 rbd_bus_del_dev(rbd_dev); 4982 + ret = rbd_dev_header_watch_sync(rbd_dev, false); 4983 + if (ret) 4984 + rbd_warn(rbd_dev, "failed to cancel watch event (%d)\n", ret); 5143 4985 rbd_dev_image_release(rbd_dev); 5144 4986 module_put(THIS_MODULE); 4987 + ret = count; 5145 4988 done: 5146 4989 mutex_unlock(&ctl_mutex); 5147 4990
-6
drivers/char/hw_random/mxc-rnga.c
··· 167 167 clk_prepare_enable(mxc_rng->clk); 168 168 169 169 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 170 - if (!res) { 171 - err = -ENOENT; 172 - goto err_region; 173 - } 174 - 175 170 mxc_rng->mem = devm_ioremap_resource(&pdev->dev, res); 176 171 if (IS_ERR(mxc_rng->mem)) { 177 172 err = PTR_ERR(mxc_rng->mem); ··· 184 189 return 0; 185 190 186 191 err_ioremap: 187 - err_region: 188 192 clk_disable_unprepare(mxc_rng->clk); 189 193 190 194 out:
-5
drivers/char/hw_random/omap-rng.c
··· 119 119 dev_set_drvdata(&pdev->dev, priv); 120 120 121 121 priv->mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 122 - if (!priv->mem_res) { 123 - ret = -ENOENT; 124 - goto err_ioremap; 125 - } 126 - 127 122 priv->base = devm_ioremap_resource(&pdev->dev, priv->mem_res); 128 123 if (IS_ERR(priv->base)) { 129 124 ret = PTR_ERR(priv->base);
+2 -2
drivers/char/ipmi/ipmi_bt_sm.c
··· 95 95 enum bt_states state; 96 96 unsigned char seq; /* BT sequence number */ 97 97 struct si_sm_io *io; 98 - unsigned char write_data[IPMI_MAX_MSG_LENGTH]; 98 + unsigned char write_data[IPMI_MAX_MSG_LENGTH + 2]; /* +2 for memcpy */ 99 99 int write_count; 100 - unsigned char read_data[IPMI_MAX_MSG_LENGTH]; 100 + unsigned char read_data[IPMI_MAX_MSG_LENGTH + 2]; /* +2 for memcpy */ 101 101 int read_count; 102 102 int truncated; 103 103 long timeout; /* microseconds countdown */
+13 -1
drivers/char/ipmi/ipmi_devintf.c
··· 837 837 return ipmi_ioctl(filep, cmd, arg); 838 838 } 839 839 } 840 + 841 + static long unlocked_compat_ipmi_ioctl(struct file *filep, unsigned int cmd, 842 + unsigned long arg) 843 + { 844 + int ret; 845 + 846 + mutex_lock(&ipmi_mutex); 847 + ret = compat_ipmi_ioctl(filep, cmd, arg); 848 + mutex_unlock(&ipmi_mutex); 849 + 850 + return ret; 851 + } 840 852 #endif 841 853 842 854 static const struct file_operations ipmi_fops = { 843 855 .owner = THIS_MODULE, 844 856 .unlocked_ioctl = ipmi_unlocked_ioctl, 845 857 #ifdef CONFIG_COMPAT 846 - .compat_ioctl = compat_ipmi_ioctl, 858 + .compat_ioctl = unlocked_compat_ipmi_ioctl, 847 859 #endif 848 860 .open = ipmi_open, 849 861 .release = ipmi_release,
+1 -2
drivers/char/ipmi/ipmi_msghandler.c
··· 2037 2037 entry = kmalloc(sizeof(*entry), GFP_KERNEL); 2038 2038 if (!entry) 2039 2039 return -ENOMEM; 2040 - entry->name = kmalloc(strlen(name)+1, GFP_KERNEL); 2040 + entry->name = kstrdup(name, GFP_KERNEL); 2041 2041 if (!entry->name) { 2042 2042 kfree(entry); 2043 2043 return -ENOMEM; 2044 2044 } 2045 - strcpy(entry->name, name); 2046 2045 2047 2046 file = proc_create_data(name, 0, smi->proc_dir, proc_ops, data); 2048 2047 if (!file) {
+10 -6
drivers/char/ipmi/ipmi_si_intf.c
··· 663 663 /* We got the flags from the SMI, now handle them. */ 664 664 smi_info->handlers->get_result(smi_info->si_sm, msg, 4); 665 665 if (msg[2] != 0) { 666 - dev_warn(smi_info->dev, "Could not enable interrupts" 667 - ", failed get, using polled mode.\n"); 666 + dev_warn(smi_info->dev, 667 + "Couldn't get irq info: %x.\n", msg[2]); 668 + dev_warn(smi_info->dev, 669 + "Maybe ok, but ipmi might run very slowly.\n"); 668 670 smi_info->si_state = SI_NORMAL; 669 671 } else { 670 672 msg[0] = (IPMI_NETFN_APP_REQUEST << 2); ··· 687 685 688 686 /* We got the flags from the SMI, now handle them. */ 689 687 smi_info->handlers->get_result(smi_info->si_sm, msg, 4); 690 - if (msg[2] != 0) 691 - dev_warn(smi_info->dev, "Could not enable interrupts" 692 - ", failed set, using polled mode.\n"); 693 - else 688 + if (msg[2] != 0) { 689 + dev_warn(smi_info->dev, 690 + "Couldn't set irq info: %x.\n", msg[2]); 691 + dev_warn(smi_info->dev, 692 + "Maybe ok, but ipmi might run very slowly.\n"); 693 + } else 694 694 smi_info->interrupt_disabled = 0; 695 695 smi_info->si_state = SI_NORMAL; 696 696 break;
+1 -1
drivers/cpufreq/Kconfig
··· 47 47 48 48 choice 49 49 prompt "Default CPUFreq governor" 50 - default CPU_FREQ_DEFAULT_GOV_USERSPACE if CPU_FREQ_SA1100 || CPU_FREQ_SA1110 50 + default CPU_FREQ_DEFAULT_GOV_USERSPACE if ARM_SA1100_CPUFREQ || ARM_SA1110_CPUFREQ 51 51 default CPU_FREQ_DEFAULT_GOV_PERFORMANCE 52 52 help 53 53 This option sets which CPUFreq governor shall be loaded at
+8 -7
drivers/cpufreq/Kconfig.arm
··· 3 3 # 4 4 5 5 config ARM_BIG_LITTLE_CPUFREQ 6 - tristate 7 - depends on ARM_CPU_TOPOLOGY 6 + tristate "Generic ARM big LITTLE CPUfreq driver" 7 + depends on ARM_CPU_TOPOLOGY && PM_OPP && HAVE_CLK 8 + help 9 + This enables the Generic CPUfreq driver for ARM big.LITTLE platforms. 8 10 9 11 config ARM_DT_BL_CPUFREQ 10 - tristate "Generic ARM big LITTLE CPUfreq driver probed via DT" 11 - select ARM_BIG_LITTLE_CPUFREQ 12 - depends on OF && HAVE_CLK 12 + tristate "Generic probing via DT for ARM big LITTLE CPUfreq driver" 13 + depends on ARM_BIG_LITTLE_CPUFREQ && OF 13 14 help 14 - This enables the Generic CPUfreq driver for ARM big.LITTLE platform. 15 - This gets frequency tables from DT. 15 + This enables probing via DT for Generic CPUfreq driver for ARM 16 + big.LITTLE platform. This gets frequency tables from DT. 16 17 17 18 config ARM_EXYNOS_CPUFREQ 18 19 bool "SAMSUNG EXYNOS SoCs"
+1 -6
drivers/cpufreq/arm_big_little.c
··· 40 40 static struct cpufreq_frequency_table *freq_table[MAX_CLUSTERS]; 41 41 static atomic_t cluster_usage[MAX_CLUSTERS] = {ATOMIC_INIT(0), ATOMIC_INIT(0)}; 42 42 43 - static int cpu_to_cluster(int cpu) 44 - { 45 - return topology_physical_package_id(cpu); 46 - } 47 - 48 43 static unsigned int bL_cpufreq_get(unsigned int cpu) 49 44 { 50 45 u32 cur_cluster = cpu_to_cluster(cpu); ··· 187 192 188 193 cpumask_copy(policy->cpus, topology_core_cpumask(policy->cpu)); 189 194 190 - dev_info(cpu_dev, "CPU %d initialized\n", policy->cpu); 195 + dev_info(cpu_dev, "%s: CPU %d initialized\n", __func__, policy->cpu); 191 196 return 0; 192 197 } 193 198
+5
drivers/cpufreq/arm_big_little.h
··· 34 34 int (*init_opp_table)(struct device *cpu_dev); 35 35 }; 36 36 37 + static inline int cpu_to_cluster(int cpu) 38 + { 39 + return topology_physical_package_id(cpu); 40 + } 41 + 37 42 int bL_cpufreq_register(struct cpufreq_arm_bL_ops *ops); 38 43 void bL_cpufreq_unregister(struct cpufreq_arm_bL_ops *ops); 39 44
+5 -4
drivers/cpufreq/arm_big_little_dt.c
··· 66 66 67 67 parent = of_find_node_by_path("/cpus"); 68 68 if (!parent) { 69 - pr_err("failed to find OF /cpus\n"); 70 - return -ENOENT; 69 + pr_info("Failed to find OF /cpus. Use CPUFREQ_ETERNAL transition latency\n"); 70 + return CPUFREQ_ETERNAL; 71 71 } 72 72 73 73 for_each_child_of_node(parent, np) { ··· 78 78 of_node_put(np); 79 79 of_node_put(parent); 80 80 81 - return 0; 81 + return transition_latency; 82 82 } 83 83 84 - return -ENODEV; 84 + pr_info("clock-latency isn't found, use CPUFREQ_ETERNAL transition latency\n"); 85 + return CPUFREQ_ETERNAL; 85 86 } 86 87 87 88 static struct cpufreq_arm_bL_ops dt_bL_ops = {
+20 -7
drivers/cpufreq/cpufreq-cpu0.c
··· 189 189 190 190 if (!np) { 191 191 pr_err("failed to find cpu0 node\n"); 192 - return -ENOENT; 192 + ret = -ENOENT; 193 + goto out_put_parent; 193 194 } 194 195 195 196 cpu_dev = &pdev->dev; 196 197 cpu_dev->of_node = np; 198 + 199 + cpu_reg = devm_regulator_get(cpu_dev, "cpu0"); 200 + if (IS_ERR(cpu_reg)) { 201 + /* 202 + * If cpu0 regulator supply node is present, but regulator is 203 + * not yet registered, we should try defering probe. 204 + */ 205 + if (PTR_ERR(cpu_reg) == -EPROBE_DEFER) { 206 + dev_err(cpu_dev, "cpu0 regulator not ready, retry\n"); 207 + ret = -EPROBE_DEFER; 208 + goto out_put_node; 209 + } 210 + pr_warn("failed to get cpu0 regulator: %ld\n", 211 + PTR_ERR(cpu_reg)); 212 + cpu_reg = NULL; 213 + } 197 214 198 215 cpu_clk = devm_clk_get(cpu_dev, NULL); 199 216 if (IS_ERR(cpu_clk)) { 200 217 ret = PTR_ERR(cpu_clk); 201 218 pr_err("failed to get cpu0 clock: %d\n", ret); 202 219 goto out_put_node; 203 - } 204 - 205 - cpu_reg = devm_regulator_get(cpu_dev, "cpu0"); 206 - if (IS_ERR(cpu_reg)) { 207 - pr_warn("failed to get cpu0 regulator\n"); 208 - cpu_reg = NULL; 209 220 } 210 221 211 222 ret = of_init_opp_table(cpu_dev); ··· 275 264 opp_free_cpufreq_table(cpu_dev, &freq_table); 276 265 out_put_node: 277 266 of_node_put(np); 267 + out_put_parent: 268 + of_node_put(parent); 278 269 return ret; 279 270 } 280 271
+4 -6
drivers/cpufreq/cpufreq.c
··· 1075 1075 __func__, cpu_dev->id, cpu); 1076 1076 } 1077 1077 1078 + if ((cpus == 1) && (cpufreq_driver->target)) 1079 + __cpufreq_governor(data, CPUFREQ_GOV_POLICY_EXIT); 1080 + 1078 1081 pr_debug("%s: removing link, cpu: %d\n", __func__, cpu); 1079 1082 cpufreq_cpu_put(data); 1080 1083 1081 1084 /* If cpu is last user of policy, free policy */ 1082 1085 if (cpus == 1) { 1083 - if (cpufreq_driver->target) 1084 - __cpufreq_governor(data, CPUFREQ_GOV_POLICY_EXIT); 1085 - 1086 1086 lock_policy_rwsem_read(cpu); 1087 1087 kobj = &data->kobj; 1088 1088 cmp = &data->kobj_unregister; ··· 1832 1832 if (dev) { 1833 1833 switch (action) { 1834 1834 case CPU_ONLINE: 1835 - case CPU_ONLINE_FROZEN: 1836 1835 cpufreq_add_dev(dev, NULL); 1837 1836 break; 1838 1837 case CPU_DOWN_PREPARE: 1839 - case CPU_DOWN_PREPARE_FROZEN: 1838 + case CPU_UP_CANCELED_FROZEN: 1840 1839 __cpufreq_remove_dev(dev, NULL); 1841 1840 break; 1842 1841 case CPU_DOWN_FAILED: 1843 - case CPU_DOWN_FAILED_FROZEN: 1844 1842 cpufreq_add_dev(dev, NULL); 1845 1843 break; 1846 1844 }
+7 -4
drivers/cpufreq/cpufreq_governor.c
··· 255 255 if (have_governor_per_policy()) { 256 256 WARN_ON(dbs_data); 257 257 } else if (dbs_data) { 258 + dbs_data->usage_count++; 258 259 policy->governor_data = dbs_data; 259 260 return 0; 260 261 } ··· 267 266 } 268 267 269 268 dbs_data->cdata = cdata; 269 + dbs_data->usage_count = 1; 270 270 rc = cdata->init(dbs_data); 271 271 if (rc) { 272 272 pr_err("%s: POLICY_INIT: init() failed\n", __func__); ··· 296 294 set_sampling_rate(dbs_data, max(dbs_data->min_sampling_rate, 297 295 latency * LATENCY_MULTIPLIER)); 298 296 299 - if (dbs_data->cdata->governor == GOV_CONSERVATIVE) { 297 + if ((cdata->governor == GOV_CONSERVATIVE) && 298 + (!policy->governor->initialized)) { 300 299 struct cs_ops *cs_ops = dbs_data->cdata->gov_ops; 301 300 302 301 cpufreq_register_notifier(cs_ops->notifier_block, ··· 309 306 310 307 return 0; 311 308 case CPUFREQ_GOV_POLICY_EXIT: 312 - if ((policy->governor->initialized == 1) || 313 - have_governor_per_policy()) { 309 + if (!--dbs_data->usage_count) { 314 310 sysfs_remove_group(get_governor_parent_kobj(policy), 315 311 get_sysfs_attr(dbs_data)); 316 312 317 - if (dbs_data->cdata->governor == GOV_CONSERVATIVE) { 313 + if ((dbs_data->cdata->governor == GOV_CONSERVATIVE) && 314 + (policy->governor->initialized == 1)) { 318 315 struct cs_ops *cs_ops = dbs_data->cdata->gov_ops; 319 316 320 317 cpufreq_unregister_notifier(cs_ops->notifier_block,
+1
drivers/cpufreq/cpufreq_governor.h
··· 211 211 struct dbs_data { 212 212 struct common_dbs_data *cdata; 213 213 unsigned int min_sampling_rate; 214 + int usage_count; 214 215 void *tuners; 215 216 216 217 /* dbs_mutex protects dbs_enable in governor start/stop */
-1
drivers/cpufreq/cpufreq_ondemand.c
··· 547 547 tuners->io_is_busy = should_io_be_busy(); 548 548 549 549 dbs_data->tuners = tuners; 550 - pr_info("%s: tuners %p\n", __func__, tuners); 551 550 mutex_init(&dbs_data->mutex); 552 551 return 0; 553 552 }
+4 -3
drivers/cpufreq/cpufreq_stats.c
··· 349 349 350 350 switch (action) { 351 351 case CPU_ONLINE: 352 - case CPU_ONLINE_FROZEN: 353 352 cpufreq_update_policy(cpu); 354 353 break; 355 354 case CPU_DOWN_PREPARE: 356 - case CPU_DOWN_PREPARE_FROZEN: 357 355 cpufreq_stats_free_sysfs(cpu); 358 356 break; 359 357 case CPU_DEAD: 360 - case CPU_DEAD_FROZEN: 358 + cpufreq_stats_free_table(cpu); 359 + break; 360 + case CPU_UP_CANCELED_FROZEN: 361 + cpufreq_stats_free_sysfs(cpu); 361 362 cpufreq_stats_free_table(cpu); 362 363 break; 363 364 }
+20 -100
drivers/cpufreq/intel_pstate.c
··· 48 48 } 49 49 50 50 struct sample { 51 - ktime_t start_time; 52 - ktime_t end_time; 53 51 int core_pct_busy; 54 - int pstate_pct_busy; 55 - u64 duration_us; 56 - u64 idletime_us; 57 52 u64 aperf; 58 53 u64 mperf; 59 54 int freq; ··· 81 86 struct pstate_adjust_policy *pstate_policy; 82 87 struct pstate_data pstate; 83 88 struct _pid pid; 84 - struct _pid idle_pid; 85 89 86 90 int min_pstate_count; 87 - int idle_mode; 88 91 89 - ktime_t prev_sample; 90 - u64 prev_idle_time_us; 91 92 u64 prev_aperf; 92 93 u64 prev_mperf; 93 94 int sample_ptr; ··· 115 124 int min_perf_pct; 116 125 int32_t max_perf; 117 126 int32_t min_perf; 127 + int max_policy_pct; 128 + int max_sysfs_pct; 118 129 }; 119 130 120 131 static struct perf_limits limits = { ··· 125 132 .max_perf = int_tofp(1), 126 133 .min_perf_pct = 0, 127 134 .min_perf = 0, 135 + .max_policy_pct = 100, 136 + .max_sysfs_pct = 100, 128 137 }; 129 138 130 139 static inline void pid_reset(struct _pid *pid, int setpoint, int busy, ··· 193 198 pid_reset(&cpu->pid, 194 199 cpu->pstate_policy->setpoint, 195 200 100, 196 - cpu->pstate_policy->deadband, 197 - 0); 198 - } 199 - 200 - static inline void intel_pstate_idle_pid_reset(struct cpudata *cpu) 201 - { 202 - pid_p_gain_set(&cpu->idle_pid, cpu->pstate_policy->p_gain_pct); 203 - pid_d_gain_set(&cpu->idle_pid, cpu->pstate_policy->d_gain_pct); 204 - pid_i_gain_set(&cpu->idle_pid, cpu->pstate_policy->i_gain_pct); 205 - 206 - pid_reset(&cpu->idle_pid, 207 - 75, 208 - 50, 209 201 cpu->pstate_policy->deadband, 210 202 0); 211 203 } ··· 284 302 if (ret != 1) 285 303 return -EINVAL; 286 304 287 - limits.max_perf_pct = clamp_t(int, input, 0 , 100); 305 + limits.max_sysfs_pct = clamp_t(int, input, 0 , 100); 306 + limits.max_perf_pct = min(limits.max_policy_pct, limits.max_sysfs_pct); 288 307 limits.max_perf = div_fp(int_tofp(limits.max_perf_pct), int_tofp(100)); 289 308 return count; 290 309 } ··· 391 408 if (pstate == cpu->pstate.current_pstate) 392 409 return; 393 410 394 - #ifndef MODULE 395 411 trace_cpu_frequency(pstate * 100000, cpu->cpu); 396 - #endif 412 + 397 413 cpu->pstate.current_pstate = pstate; 398 414 wrmsrl(MSR_IA32_PERF_CTL, pstate << 8); 399 415 ··· 432 450 struct sample *sample) 433 451 { 434 452 u64 core_pct; 435 - sample->pstate_pct_busy = 100 - div64_u64( 436 - sample->idletime_us * 100, 437 - sample->duration_us); 438 453 core_pct = div64_u64(sample->aperf * 100, sample->mperf); 439 454 sample->freq = cpu->pstate.max_pstate * core_pct * 1000; 440 455 441 - sample->core_pct_busy = div_s64((sample->pstate_pct_busy * core_pct), 442 - 100); 456 + sample->core_pct_busy = core_pct; 443 457 } 444 458 445 459 static inline void intel_pstate_sample(struct cpudata *cpu) 446 460 { 447 - ktime_t now; 448 - u64 idle_time_us; 449 461 u64 aperf, mperf; 450 - 451 - now = ktime_get(); 452 - idle_time_us = get_cpu_idle_time_us(cpu->cpu, NULL); 453 462 454 463 rdmsrl(MSR_IA32_APERF, aperf); 455 464 rdmsrl(MSR_IA32_MPERF, mperf); 456 - /* for the first sample, don't actually record a sample, just 457 - * set the baseline */ 458 - if (cpu->prev_idle_time_us > 0) { 459 - cpu->sample_ptr = (cpu->sample_ptr + 1) % SAMPLE_COUNT; 460 - cpu->samples[cpu->sample_ptr].start_time = cpu->prev_sample; 461 - cpu->samples[cpu->sample_ptr].end_time = now; 462 - cpu->samples[cpu->sample_ptr].duration_us = 463 - ktime_us_delta(now, cpu->prev_sample); 464 - cpu->samples[cpu->sample_ptr].idletime_us = 465 - idle_time_us - cpu->prev_idle_time_us; 465 + cpu->sample_ptr = (cpu->sample_ptr + 1) % SAMPLE_COUNT; 466 + cpu->samples[cpu->sample_ptr].aperf = aperf; 467 + cpu->samples[cpu->sample_ptr].mperf = mperf; 468 + cpu->samples[cpu->sample_ptr].aperf -= cpu->prev_aperf; 469 + cpu->samples[cpu->sample_ptr].mperf -= cpu->prev_mperf; 466 470 467 - cpu->samples[cpu->sample_ptr].aperf = aperf; 468 - cpu->samples[cpu->sample_ptr].mperf = mperf; 469 - cpu->samples[cpu->sample_ptr].aperf -= cpu->prev_aperf; 470 - cpu->samples[cpu->sample_ptr].mperf -= cpu->prev_mperf; 471 + intel_pstate_calc_busy(cpu, &cpu->samples[cpu->sample_ptr]); 471 472 472 - intel_pstate_calc_busy(cpu, &cpu->samples[cpu->sample_ptr]); 473 - } 474 - 475 - cpu->prev_sample = now; 476 - cpu->prev_idle_time_us = idle_time_us; 477 473 cpu->prev_aperf = aperf; 478 474 cpu->prev_mperf = mperf; 479 475 } ··· 463 503 sample_time = cpu->pstate_policy->sample_rate_ms; 464 504 delay = msecs_to_jiffies(sample_time); 465 505 mod_timer_pinned(&cpu->timer, jiffies + delay); 466 - } 467 - 468 - static inline void intel_pstate_idle_mode(struct cpudata *cpu) 469 - { 470 - cpu->idle_mode = 1; 471 - } 472 - 473 - static inline void intel_pstate_normal_mode(struct cpudata *cpu) 474 - { 475 - cpu->idle_mode = 0; 476 506 } 477 507 478 508 static inline int intel_pstate_get_scaled_busy(struct cpudata *cpu) ··· 497 547 intel_pstate_pstate_decrease(cpu, steps); 498 548 } 499 549 500 - static inline void intel_pstate_adjust_idle_pstate(struct cpudata *cpu) 501 - { 502 - int busy_scaled; 503 - struct _pid *pid; 504 - int ctl = 0; 505 - int steps; 506 - 507 - pid = &cpu->idle_pid; 508 - 509 - busy_scaled = intel_pstate_get_scaled_busy(cpu); 510 - 511 - ctl = pid_calc(pid, 100 - busy_scaled); 512 - 513 - steps = abs(ctl); 514 - if (ctl < 0) 515 - intel_pstate_pstate_decrease(cpu, steps); 516 - else 517 - intel_pstate_pstate_increase(cpu, steps); 518 - 519 - if (cpu->pstate.current_pstate == cpu->pstate.min_pstate) 520 - intel_pstate_normal_mode(cpu); 521 - } 522 - 523 550 static void intel_pstate_timer_func(unsigned long __data) 524 551 { 525 552 struct cpudata *cpu = (struct cpudata *) __data; 526 553 527 554 intel_pstate_sample(cpu); 555 + intel_pstate_adjust_busy_pstate(cpu); 528 556 529 - if (!cpu->idle_mode) 530 - intel_pstate_adjust_busy_pstate(cpu); 531 - else 532 - intel_pstate_adjust_idle_pstate(cpu); 533 - 534 - #if defined(XPERF_FIX) 535 557 if (cpu->pstate.current_pstate == cpu->pstate.min_pstate) { 536 558 cpu->min_pstate_count++; 537 559 if (!(cpu->min_pstate_count % 5)) { 538 560 intel_pstate_set_pstate(cpu, cpu->pstate.max_pstate); 539 - intel_pstate_idle_mode(cpu); 540 561 } 541 562 } else 542 563 cpu->min_pstate_count = 0; 543 - #endif 564 + 544 565 intel_pstate_set_sample_time(cpu); 545 566 } 546 567 ··· 552 631 (unsigned long)cpu; 553 632 cpu->timer.expires = jiffies + HZ/100; 554 633 intel_pstate_busy_pid_reset(cpu); 555 - intel_pstate_idle_pid_reset(cpu); 556 634 intel_pstate_sample(cpu); 557 635 intel_pstate_set_pstate(cpu, cpu->pstate.max_pstate); 558 636 ··· 595 675 limits.min_perf_pct = clamp_t(int, limits.min_perf_pct, 0 , 100); 596 676 limits.min_perf = div_fp(int_tofp(limits.min_perf_pct), int_tofp(100)); 597 677 598 - limits.max_perf_pct = policy->max * 100 / policy->cpuinfo.max_freq; 599 - limits.max_perf_pct = clamp_t(int, limits.max_perf_pct, 0 , 100); 678 + limits.max_policy_pct = policy->max * 100 / policy->cpuinfo.max_freq; 679 + limits.max_policy_pct = clamp_t(int, limits.max_policy_pct, 0 , 100); 680 + limits.max_perf_pct = min(limits.max_policy_pct, limits.max_sysfs_pct); 600 681 limits.max_perf = div_fp(int_tofp(limits.max_perf_pct), int_tofp(100)); 601 682 602 683 return 0; ··· 709 788 710 789 pr_info("Intel P-state driver initializing.\n"); 711 790 712 - all_cpu_data = vmalloc(sizeof(void *) * num_possible_cpus()); 791 + all_cpu_data = vzalloc(sizeof(void *) * num_possible_cpus()); 713 792 if (!all_cpu_data) 714 793 return -ENOMEM; 715 - memset(all_cpu_data, 0, sizeof(void *) * num_possible_cpus()); 716 794 717 795 rc = cpufreq_register_driver(&intel_pstate_driver); 718 796 if (rc)
-4
drivers/cpufreq/kirkwood-cpufreq.c
··· 171 171 priv.dev = &pdev->dev; 172 172 173 173 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 174 - if (!res) { 175 - dev_err(&pdev->dev, "Cannot get memory resource\n"); 176 - return -ENODEV; 177 - } 178 174 priv.base = devm_ioremap_resource(&pdev->dev, res); 179 175 if (IS_ERR(priv.base)) 180 176 return PTR_ERR(priv.base);
-5
drivers/dma/tegra20-apb-dma.c
··· 1273 1273 platform_set_drvdata(pdev, tdma); 1274 1274 1275 1275 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1276 - if (!res) { 1277 - dev_err(&pdev->dev, "No mem resource for DMA\n"); 1278 - return -EINVAL; 1279 - } 1280 - 1281 1276 tdma->base_addr = devm_ioremap_resource(&pdev->dev, res); 1282 1277 if (IS_ERR(tdma->base_addr)) 1283 1278 return PTR_ERR(tdma->base_addr);
-5
drivers/gpio/gpio-mvebu.c
··· 619 619 * per-CPU registers */ 620 620 if (soc_variant == MVEBU_GPIO_SOC_VARIANT_ARMADAXP) { 621 621 res = platform_get_resource(pdev, IORESOURCE_MEM, 1); 622 - if (!res) { 623 - dev_err(&pdev->dev, "Cannot get memory resource\n"); 624 - return -ENODEV; 625 - } 626 - 627 622 mvchip->percpu_membase = devm_ioremap_resource(&pdev->dev, 628 623 res); 629 624 if (IS_ERR(mvchip->percpu_membase))
-5
drivers/gpio/gpio-tegra.c
··· 463 463 } 464 464 465 465 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 466 - if (!res) { 467 - dev_err(&pdev->dev, "Missing MEM resource\n"); 468 - return -ENODEV; 469 - } 470 - 471 466 regs = devm_ioremap_resource(&pdev->dev, res); 472 467 if (IS_ERR(regs)) 473 468 return PTR_ERR(regs);
+5
drivers/gpu/drm/drm_crtc.c
··· 78 78 { 79 79 struct drm_crtc *crtc; 80 80 81 + /* Locking is currently fubar in the panic handler. */ 82 + if (oops_in_progress) 83 + return; 84 + 81 85 list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) 82 86 WARN_ON(!mutex_is_locked(&crtc->mutex)); 83 87 ··· 250 246 else 251 247 return "unknown"; 252 248 } 249 + EXPORT_SYMBOL(drm_get_connector_status_name); 253 250 254 251 /** 255 252 * drm_mode_object_get - allocate a new modeset identifier
+19 -8
drivers/gpu/drm/drm_crtc_helper.c
··· 121 121 connector->helper_private; 122 122 int count = 0; 123 123 int mode_flags = 0; 124 + bool verbose_prune = true; 124 125 125 126 DRM_DEBUG_KMS("[CONNECTOR:%d:%s]\n", connector->base.id, 126 127 drm_get_connector_name(connector)); ··· 150 149 DRM_DEBUG_KMS("[CONNECTOR:%d:%s] disconnected\n", 151 150 connector->base.id, drm_get_connector_name(connector)); 152 151 drm_mode_connector_update_edid_property(connector, NULL); 152 + verbose_prune = false; 153 153 goto prune; 154 154 } 155 155 ··· 184 182 } 185 183 186 184 prune: 187 - drm_mode_prune_invalid(dev, &connector->modes, true); 185 + drm_mode_prune_invalid(dev, &connector->modes, verbose_prune); 188 186 189 187 if (list_empty(&connector->modes)) 190 188 return 0; ··· 1007 1005 continue; 1008 1006 1009 1007 connector->status = connector->funcs->detect(connector, false); 1010 - DRM_DEBUG_KMS("[CONNECTOR:%d:%s] status updated from %d to %d\n", 1011 - connector->base.id, 1012 - drm_get_connector_name(connector), 1013 - old_status, connector->status); 1014 - if (old_status != connector->status) 1008 + if (old_status != connector->status) { 1009 + const char *old, *new; 1010 + 1011 + old = drm_get_connector_status_name(old_status); 1012 + new = drm_get_connector_status_name(connector->status); 1013 + 1014 + DRM_DEBUG_KMS("[CONNECTOR:%d:%s] " 1015 + "status updated from %s to %s\n", 1016 + connector->base.id, 1017 + drm_get_connector_name(connector), 1018 + old, new); 1019 + 1015 1020 changed = true; 1021 + } 1016 1022 } 1017 1023 1018 1024 mutex_unlock(&dev->mode_config.mutex); ··· 1093 1083 old_status = connector->status; 1094 1084 1095 1085 connector->status = connector->funcs->detect(connector, false); 1096 - DRM_DEBUG_KMS("[CONNECTOR:%d:%s] status updated from %d to %d\n", 1086 + DRM_DEBUG_KMS("[CONNECTOR:%d:%s] status updated from %s to %s\n", 1097 1087 connector->base.id, 1098 1088 drm_get_connector_name(connector), 1099 - old_status, connector->status); 1089 + drm_get_connector_status_name(old_status), 1090 + drm_get_connector_status_name(connector->status)); 1100 1091 if (old_status != connector->status) 1101 1092 changed = true; 1102 1093 }
+13 -7
drivers/gpu/drm/drm_drv.c
··· 57 57 struct drm_file *file_priv); 58 58 59 59 #define DRM_IOCTL_DEF(ioctl, _func, _flags) \ 60 - [DRM_IOCTL_NR(ioctl)] = {.cmd = ioctl, .func = _func, .flags = _flags, .cmd_drv = 0} 60 + [DRM_IOCTL_NR(ioctl)] = {.cmd = ioctl, .func = _func, .flags = _flags, .cmd_drv = 0, .name = #ioctl} 61 61 62 62 /** Ioctl table */ 63 63 static const struct drm_ioctl_desc drm_ioctls[] = { ··· 375 375 { 376 376 struct drm_file *file_priv = filp->private_data; 377 377 struct drm_device *dev; 378 - const struct drm_ioctl_desc *ioctl; 378 + const struct drm_ioctl_desc *ioctl = NULL; 379 379 drm_ioctl_t *func; 380 380 unsigned int nr = DRM_IOCTL_NR(cmd); 381 381 int retcode = -EINVAL; ··· 391 391 atomic_inc(&dev->ioctl_count); 392 392 atomic_inc(&dev->counts[_DRM_STAT_IOCTLS]); 393 393 ++file_priv->ioctl_count; 394 - 395 - DRM_DEBUG("pid=%d, cmd=0x%02x, nr=0x%02x, dev 0x%lx, auth=%d\n", 396 - task_pid_nr(current), cmd, nr, 397 - (long)old_encode_dev(file_priv->minor->device), 398 - file_priv->authenticated); 399 394 400 395 if ((nr >= DRM_CORE_IOCTL_COUNT) && 401 396 ((nr < DRM_COMMAND_BASE) || (nr >= DRM_COMMAND_END))) ··· 411 416 usize = asize = _IOC_SIZE(cmd); 412 417 } else 413 418 goto err_i1; 419 + 420 + DRM_DEBUG("pid=%d, dev=0x%lx, auth=%d, %s\n", 421 + task_pid_nr(current), 422 + (long)old_encode_dev(file_priv->minor->device), 423 + file_priv->authenticated, ioctl->name); 414 424 415 425 /* Do not trust userspace, use our own definition */ 416 426 func = ioctl->func; ··· 471 471 } 472 472 473 473 err_i1: 474 + if (!ioctl) 475 + DRM_DEBUG("invalid iotcl: pid=%d, dev=0x%lx, auth=%d, cmd=0x%02x, nr=0x%02x\n", 476 + task_pid_nr(current), 477 + (long)old_encode_dev(file_priv->minor->device), 478 + file_priv->authenticated, cmd, nr); 479 + 474 480 if (kdata != stack_kdata) 475 481 kfree(kdata); 476 482 atomic_dec(&dev->ioctl_count);
+1 -5
drivers/gpu/drm/drm_encoder_slave.c
··· 54 54 struct i2c_adapter *adap, 55 55 const struct i2c_board_info *info) 56 56 { 57 - char modalias[sizeof(I2C_MODULE_PREFIX) 58 - + I2C_NAME_SIZE]; 59 57 struct module *module = NULL; 60 58 struct i2c_client *client; 61 59 struct drm_i2c_encoder_driver *encoder_drv; 62 60 int err = 0; 63 61 64 - snprintf(modalias, sizeof(modalias), 65 - "%s%s", I2C_MODULE_PREFIX, info->type); 66 - request_module(modalias); 62 + request_module("%s%s", I2C_MODULE_PREFIX, info->type); 67 63 68 64 client = i2c_new_device(adap, info); 69 65 if (!client) {
+18 -16
drivers/gpu/drm/drm_mm.c
··· 755 755 EXPORT_SYMBOL(drm_mm_debug_table); 756 756 757 757 #if defined(CONFIG_DEBUG_FS) 758 + static unsigned long drm_mm_dump_hole(struct seq_file *m, struct drm_mm_node *entry) 759 + { 760 + unsigned long hole_start, hole_end, hole_size; 761 + 762 + if (entry->hole_follows) { 763 + hole_start = drm_mm_hole_node_start(entry); 764 + hole_end = drm_mm_hole_node_end(entry); 765 + hole_size = hole_end - hole_start; 766 + seq_printf(m, "0x%08lx-0x%08lx: 0x%08lx: free\n", 767 + hole_start, hole_end, hole_size); 768 + return hole_size; 769 + } 770 + 771 + return 0; 772 + } 773 + 758 774 int drm_mm_dump_table(struct seq_file *m, struct drm_mm *mm) 759 775 { 760 776 struct drm_mm_node *entry; 761 777 unsigned long total_used = 0, total_free = 0, total = 0; 762 - unsigned long hole_start, hole_end, hole_size; 763 778 764 - hole_start = drm_mm_hole_node_start(&mm->head_node); 765 - hole_end = drm_mm_hole_node_end(&mm->head_node); 766 - hole_size = hole_end - hole_start; 767 - if (hole_size) 768 - seq_printf(m, "0x%08lx-0x%08lx: 0x%08lx: free\n", 769 - hole_start, hole_end, hole_size); 770 - total_free += hole_size; 779 + total_free += drm_mm_dump_hole(m, &mm->head_node); 771 780 772 781 drm_mm_for_each_node(entry, mm) { 773 782 seq_printf(m, "0x%08lx-0x%08lx: 0x%08lx: used\n", 774 783 entry->start, entry->start + entry->size, 775 784 entry->size); 776 785 total_used += entry->size; 777 - if (entry->hole_follows) { 778 - hole_start = drm_mm_hole_node_start(entry); 779 - hole_end = drm_mm_hole_node_end(entry); 780 - hole_size = hole_end - hole_start; 781 - seq_printf(m, "0x%08lx-0x%08lx: 0x%08lx: free\n", 782 - hole_start, hole_end, hole_size); 783 - total_free += hole_size; 784 - } 786 + total_free += drm_mm_dump_hole(m, entry); 785 787 } 786 788 total = total_free + total_used; 787 789
+1
drivers/gpu/drm/drm_modes.c
··· 1143 1143 was_digit = false; 1144 1144 } else 1145 1145 goto done; 1146 + break; 1146 1147 case '0' ... '9': 1147 1148 was_digit = true; 1148 1149 break;
-5
drivers/gpu/drm/exynos/exynos_hdmi.c
··· 2005 2005 } 2006 2006 2007 2007 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 2008 - if (!res) { 2009 - DRM_ERROR("failed to find registers\n"); 2010 - return -ENOENT; 2011 - } 2012 - 2013 2008 hdata->regs = devm_ioremap_resource(&pdev->dev, res); 2014 2009 if (IS_ERR(hdata->regs)) 2015 2010 return PTR_ERR(hdata->regs);
+3 -5
drivers/gpu/drm/i915/i915_gem.c
··· 1045 1045 if (timeout) { 1046 1046 struct timespec sleep_time = timespec_sub(now, before); 1047 1047 *timeout = timespec_sub(*timeout, sleep_time); 1048 + if (!timespec_valid(timeout)) /* i.e. negative time remains */ 1049 + set_normalized_timespec(timeout, 0, 0); 1048 1050 } 1049 1051 1050 1052 switch (end) { ··· 1055 1053 case -ERESTARTSYS: /* Signal */ 1056 1054 return (int)end; 1057 1055 case 0: /* Timeout */ 1058 - if (timeout) 1059 - set_normalized_timespec(timeout, 0, 0); 1060 1056 return -ETIME; 1061 1057 default: /* Completed */ 1062 1058 WARN_ON(end < 0); /* We're not aware of other errors */ ··· 2377 2377 mutex_unlock(&dev->struct_mutex); 2378 2378 2379 2379 ret = __wait_seqno(ring, seqno, reset_counter, true, timeout); 2380 - if (timeout) { 2381 - WARN_ON(!timespec_valid(timeout)); 2380 + if (timeout) 2382 2381 args->timeout_ns = timespec_to_ns(timeout); 2383 - } 2384 2382 return ret; 2385 2383 2386 2384 out:
+1 -14
drivers/gpu/drm/i915/i915_gem_gtt.c
··· 709 709 return snb_gmch_ctl << 25; /* 32 MB units */ 710 710 } 711 711 712 - static inline size_t gen7_get_stolen_size(u16 snb_gmch_ctl) 713 - { 714 - static const int stolen_decoder[] = { 715 - 0, 0, 0, 0, 0, 32, 48, 64, 128, 256, 96, 160, 224, 352}; 716 - snb_gmch_ctl >>= IVB_GMCH_GMS_SHIFT; 717 - snb_gmch_ctl &= IVB_GMCH_GMS_MASK; 718 - return stolen_decoder[snb_gmch_ctl] << 20; 719 - } 720 - 721 712 static int gen6_gmch_probe(struct drm_device *dev, 722 713 size_t *gtt_total, 723 714 size_t *stolen, ··· 738 747 pci_read_config_word(dev->pdev, SNB_GMCH_CTRL, &snb_gmch_ctl); 739 748 gtt_size = gen6_get_total_gtt_size(snb_gmch_ctl); 740 749 741 - if (IS_GEN7(dev) && !IS_VALLEYVIEW(dev)) 742 - *stolen = gen7_get_stolen_size(snb_gmch_ctl); 743 - else 744 - *stolen = gen6_get_stolen_size(snb_gmch_ctl); 745 - 750 + *stolen = gen6_get_stolen_size(snb_gmch_ctl); 746 751 *gtt_total = (gtt_size / sizeof(gen6_gtt_pte_t)) << PAGE_SHIFT; 747 752 748 753 /* For Modern GENs the PTEs and register space are split in the BAR */
-2
drivers/gpu/drm/i915/i915_reg.h
··· 46 46 #define SNB_GMCH_GGMS_MASK 0x3 47 47 #define SNB_GMCH_GMS_SHIFT 3 /* Graphics Mode Select */ 48 48 #define SNB_GMCH_GMS_MASK 0x1f 49 - #define IVB_GMCH_GMS_SHIFT 4 50 - #define IVB_GMCH_GMS_MASK 0xf 51 49 52 50 53 51 /* PCI config space */
+5
drivers/gpu/drm/i915/intel_ddi.c
··· 1265 1265 intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_ON); 1266 1266 intel_dp_start_link_train(intel_dp); 1267 1267 intel_dp_complete_link_train(intel_dp); 1268 + if (port != PORT_A) 1269 + intel_dp_stop_link_train(intel_dp); 1268 1270 } 1269 1271 } 1270 1272 ··· 1327 1325 intel_dig_port->port_reversal | DDI_BUF_CTL_ENABLE); 1328 1326 } else if (type == INTEL_OUTPUT_EDP) { 1329 1327 struct intel_dp *intel_dp = enc_to_intel_dp(encoder); 1328 + 1329 + if (port == PORT_A) 1330 + intel_dp_stop_link_train(intel_dp); 1330 1331 1331 1332 ironlake_edp_backlight_on(intel_dp); 1332 1333 }
+48 -29
drivers/gpu/drm/i915/intel_dp.c
··· 702 702 /* Walk through all bpp values. Luckily they're all nicely spaced with 2 703 703 * bpc in between. */ 704 704 bpp = min_t(int, 8*3, pipe_config->pipe_bpp); 705 + if (is_edp(intel_dp) && dev_priv->edp.bpp) 706 + bpp = min_t(int, bpp, dev_priv->edp.bpp); 707 + 705 708 for (; bpp >= 6*3; bpp -= 2*3) { 706 709 mode_rate = intel_dp_link_required(target_clock, bpp); 707 710 ··· 742 739 intel_dp->link_bw = bws[clock]; 743 740 intel_dp->lane_count = lane_count; 744 741 adjusted_mode->clock = drm_dp_bw_code_to_link_rate(intel_dp->link_bw); 742 + pipe_config->pipe_bpp = bpp; 745 743 pipe_config->pixel_target_clock = target_clock; 746 744 747 745 DRM_DEBUG_KMS("DP link bw %02x lane count %d clock %d bpp %d\n", ··· 754 750 intel_link_compute_m_n(bpp, lane_count, 755 751 target_clock, adjusted_mode->clock, 756 752 &pipe_config->dp_m_n); 757 - 758 - /* 759 - * XXX: We have a strange regression where using the vbt edp bpp value 760 - * for the link bw computation results in black screens, the panel only 761 - * works when we do the computation at the usual 24bpp (but still 762 - * requires us to use 18bpp). Until that's fully debugged, stay 763 - * bug-for-bug compatible with the old code. 764 - */ 765 - if (is_edp(intel_dp) && dev_priv->edp.bpp) { 766 - DRM_DEBUG_KMS("clamping display bpc (was %d) to eDP (%d)\n", 767 - bpp, dev_priv->edp.bpp); 768 - bpp = min_t(int, bpp, dev_priv->edp.bpp); 769 - } 770 - pipe_config->pipe_bpp = bpp; 771 753 772 754 return true; 773 755 } ··· 1379 1389 ironlake_edp_panel_on(intel_dp); 1380 1390 ironlake_edp_panel_vdd_off(intel_dp, true); 1381 1391 intel_dp_complete_link_train(intel_dp); 1392 + intel_dp_stop_link_train(intel_dp); 1382 1393 ironlake_edp_backlight_on(intel_dp); 1383 1394 } 1384 1395 ··· 1702 1711 struct drm_i915_private *dev_priv = dev->dev_private; 1703 1712 enum port port = intel_dig_port->port; 1704 1713 int ret; 1705 - uint32_t temp; 1706 1714 1707 1715 if (HAS_DDI(dev)) { 1708 - temp = I915_READ(DP_TP_CTL(port)); 1716 + uint32_t temp = I915_READ(DP_TP_CTL(port)); 1709 1717 1710 1718 if (dp_train_pat & DP_LINK_SCRAMBLING_DISABLE) 1711 1719 temp |= DP_TP_CTL_SCRAMBLE_DISABLE; ··· 1714 1724 temp &= ~DP_TP_CTL_LINK_TRAIN_MASK; 1715 1725 switch (dp_train_pat & DP_TRAINING_PATTERN_MASK) { 1716 1726 case DP_TRAINING_PATTERN_DISABLE: 1717 - 1718 - if (port != PORT_A) { 1719 - temp |= DP_TP_CTL_LINK_TRAIN_IDLE; 1720 - I915_WRITE(DP_TP_CTL(port), temp); 1721 - 1722 - if (wait_for((I915_READ(DP_TP_STATUS(port)) & 1723 - DP_TP_STATUS_IDLE_DONE), 1)) 1724 - DRM_ERROR("Timed out waiting for DP idle patterns\n"); 1725 - 1726 - temp &= ~DP_TP_CTL_LINK_TRAIN_MASK; 1727 - } 1728 - 1729 1727 temp |= DP_TP_CTL_LINK_TRAIN_NORMAL; 1730 1728 1731 1729 break; ··· 1787 1809 } 1788 1810 1789 1811 return true; 1812 + } 1813 + 1814 + static void intel_dp_set_idle_link_train(struct intel_dp *intel_dp) 1815 + { 1816 + struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp); 1817 + struct drm_device *dev = intel_dig_port->base.base.dev; 1818 + struct drm_i915_private *dev_priv = dev->dev_private; 1819 + enum port port = intel_dig_port->port; 1820 + uint32_t val; 1821 + 1822 + if (!HAS_DDI(dev)) 1823 + return; 1824 + 1825 + val = I915_READ(DP_TP_CTL(port)); 1826 + val &= ~DP_TP_CTL_LINK_TRAIN_MASK; 1827 + val |= DP_TP_CTL_LINK_TRAIN_IDLE; 1828 + I915_WRITE(DP_TP_CTL(port), val); 1829 + 1830 + /* 1831 + * On PORT_A we can have only eDP in SST mode. There the only reason 1832 + * we need to set idle transmission mode is to work around a HW issue 1833 + * where we enable the pipe while not in idle link-training mode. 1834 + * In this case there is requirement to wait for a minimum number of 1835 + * idle patterns to be sent. 1836 + */ 1837 + if (port == PORT_A) 1838 + return; 1839 + 1840 + if (wait_for((I915_READ(DP_TP_STATUS(port)) & DP_TP_STATUS_IDLE_DONE), 1841 + 1)) 1842 + DRM_ERROR("Timed out waiting for DP idle patterns\n"); 1790 1843 } 1791 1844 1792 1845 /* Enable corresponding port and start training pattern 1 */ ··· 1962 1953 ++tries; 1963 1954 } 1964 1955 1956 + intel_dp_set_idle_link_train(intel_dp); 1957 + 1958 + intel_dp->DP = DP; 1959 + 1965 1960 if (channel_eq) 1966 1961 DRM_DEBUG_KMS("Channel EQ done. DP Training successful\n"); 1967 1962 1968 - intel_dp_set_link_train(intel_dp, DP, DP_TRAINING_PATTERN_DISABLE); 1963 + } 1964 + 1965 + void intel_dp_stop_link_train(struct intel_dp *intel_dp) 1966 + { 1967 + intel_dp_set_link_train(intel_dp, intel_dp->DP, 1968 + DP_TRAINING_PATTERN_DISABLE); 1969 1969 } 1970 1970 1971 1971 static void ··· 2182 2164 drm_get_encoder_name(&intel_encoder->base)); 2183 2165 intel_dp_start_link_train(intel_dp); 2184 2166 intel_dp_complete_link_train(intel_dp); 2167 + intel_dp_stop_link_train(intel_dp); 2185 2168 } 2186 2169 } 2187 2170
+1
drivers/gpu/drm/i915/intel_drv.h
··· 499 499 extern void intel_dp_init_link_config(struct intel_dp *intel_dp); 500 500 extern void intel_dp_start_link_train(struct intel_dp *intel_dp); 501 501 extern void intel_dp_complete_link_train(struct intel_dp *intel_dp); 502 + extern void intel_dp_stop_link_train(struct intel_dp *intel_dp); 502 503 extern void intel_dp_sink_dpms(struct intel_dp *intel_dp, int mode); 503 504 extern void intel_dp_encoder_destroy(struct drm_encoder *encoder); 504 505 extern void intel_dp_check_link_status(struct intel_dp *intel_dp);
+14 -2
drivers/gpu/drm/i915/intel_fb.c
··· 262 262 void intel_fbdev_set_suspend(struct drm_device *dev, int state) 263 263 { 264 264 drm_i915_private_t *dev_priv = dev->dev_private; 265 - if (!dev_priv->fbdev) 265 + struct intel_fbdev *ifbdev = dev_priv->fbdev; 266 + struct fb_info *info; 267 + 268 + if (!ifbdev) 266 269 return; 267 270 268 - fb_set_suspend(dev_priv->fbdev->helper.fbdev, state); 271 + info = ifbdev->helper.fbdev; 272 + 273 + /* On resume from hibernation: If the object is shmemfs backed, it has 274 + * been restored from swap. If the object is stolen however, it will be 275 + * full of whatever garbage was left in there. 276 + */ 277 + if (!state && ifbdev->ifb.obj->stolen) 278 + memset_io(info->screen_base, 0, info->screen_size); 279 + 280 + fb_set_suspend(info, state); 269 281 } 270 282 271 283 MODULE_LICENSE("GPL and additional rights");
+22 -22
drivers/gpu/drm/i915/intel_pm.c
··· 1301 1301 1302 1302 vlv_update_drain_latency(dev); 1303 1303 1304 - if (g4x_compute_wm0(dev, 0, 1304 + if (g4x_compute_wm0(dev, PIPE_A, 1305 1305 &valleyview_wm_info, latency_ns, 1306 1306 &valleyview_cursor_wm_info, latency_ns, 1307 1307 &planea_wm, &cursora_wm)) 1308 - enabled |= 1; 1308 + enabled |= 1 << PIPE_A; 1309 1309 1310 - if (g4x_compute_wm0(dev, 1, 1310 + if (g4x_compute_wm0(dev, PIPE_B, 1311 1311 &valleyview_wm_info, latency_ns, 1312 1312 &valleyview_cursor_wm_info, latency_ns, 1313 1313 &planeb_wm, &cursorb_wm)) 1314 - enabled |= 2; 1314 + enabled |= 1 << PIPE_B; 1315 1315 1316 1316 if (single_plane_enabled(enabled) && 1317 1317 g4x_compute_srwm(dev, ffs(enabled) - 1, ··· 1357 1357 int plane_sr, cursor_sr; 1358 1358 unsigned int enabled = 0; 1359 1359 1360 - if (g4x_compute_wm0(dev, 0, 1360 + if (g4x_compute_wm0(dev, PIPE_A, 1361 1361 &g4x_wm_info, latency_ns, 1362 1362 &g4x_cursor_wm_info, latency_ns, 1363 1363 &planea_wm, &cursora_wm)) 1364 - enabled |= 1; 1364 + enabled |= 1 << PIPE_A; 1365 1365 1366 - if (g4x_compute_wm0(dev, 1, 1366 + if (g4x_compute_wm0(dev, PIPE_B, 1367 1367 &g4x_wm_info, latency_ns, 1368 1368 &g4x_cursor_wm_info, latency_ns, 1369 1369 &planeb_wm, &cursorb_wm)) 1370 - enabled |= 2; 1370 + enabled |= 1 << PIPE_B; 1371 1371 1372 1372 if (single_plane_enabled(enabled) && 1373 1373 g4x_compute_srwm(dev, ffs(enabled) - 1, ··· 1716 1716 unsigned int enabled; 1717 1717 1718 1718 enabled = 0; 1719 - if (g4x_compute_wm0(dev, 0, 1719 + if (g4x_compute_wm0(dev, PIPE_A, 1720 1720 &ironlake_display_wm_info, 1721 1721 ILK_LP0_PLANE_LATENCY, 1722 1722 &ironlake_cursor_wm_info, ··· 1727 1727 DRM_DEBUG_KMS("FIFO watermarks For pipe A -" 1728 1728 " plane %d, " "cursor: %d\n", 1729 1729 plane_wm, cursor_wm); 1730 - enabled |= 1; 1730 + enabled |= 1 << PIPE_A; 1731 1731 } 1732 1732 1733 - if (g4x_compute_wm0(dev, 1, 1733 + if (g4x_compute_wm0(dev, PIPE_B, 1734 1734 &ironlake_display_wm_info, 1735 1735 ILK_LP0_PLANE_LATENCY, 1736 1736 &ironlake_cursor_wm_info, ··· 1741 1741 DRM_DEBUG_KMS("FIFO watermarks For pipe B -" 1742 1742 " plane %d, cursor: %d\n", 1743 1743 plane_wm, cursor_wm); 1744 - enabled |= 2; 1744 + enabled |= 1 << PIPE_B; 1745 1745 } 1746 1746 1747 1747 /* ··· 1801 1801 unsigned int enabled; 1802 1802 1803 1803 enabled = 0; 1804 - if (g4x_compute_wm0(dev, 0, 1804 + if (g4x_compute_wm0(dev, PIPE_A, 1805 1805 &sandybridge_display_wm_info, latency, 1806 1806 &sandybridge_cursor_wm_info, latency, 1807 1807 &plane_wm, &cursor_wm)) { ··· 1812 1812 DRM_DEBUG_KMS("FIFO watermarks For pipe A -" 1813 1813 " plane %d, " "cursor: %d\n", 1814 1814 plane_wm, cursor_wm); 1815 - enabled |= 1; 1815 + enabled |= 1 << PIPE_A; 1816 1816 } 1817 1817 1818 - if (g4x_compute_wm0(dev, 1, 1818 + if (g4x_compute_wm0(dev, PIPE_B, 1819 1819 &sandybridge_display_wm_info, latency, 1820 1820 &sandybridge_cursor_wm_info, latency, 1821 1821 &plane_wm, &cursor_wm)) { ··· 1826 1826 DRM_DEBUG_KMS("FIFO watermarks For pipe B -" 1827 1827 " plane %d, cursor: %d\n", 1828 1828 plane_wm, cursor_wm); 1829 - enabled |= 2; 1829 + enabled |= 1 << PIPE_B; 1830 1830 } 1831 1831 1832 1832 /* ··· 1904 1904 unsigned int enabled; 1905 1905 1906 1906 enabled = 0; 1907 - if (g4x_compute_wm0(dev, 0, 1907 + if (g4x_compute_wm0(dev, PIPE_A, 1908 1908 &sandybridge_display_wm_info, latency, 1909 1909 &sandybridge_cursor_wm_info, latency, 1910 1910 &plane_wm, &cursor_wm)) { ··· 1915 1915 DRM_DEBUG_KMS("FIFO watermarks For pipe A -" 1916 1916 " plane %d, " "cursor: %d\n", 1917 1917 plane_wm, cursor_wm); 1918 - enabled |= 1; 1918 + enabled |= 1 << PIPE_A; 1919 1919 } 1920 1920 1921 - if (g4x_compute_wm0(dev, 1, 1921 + if (g4x_compute_wm0(dev, PIPE_B, 1922 1922 &sandybridge_display_wm_info, latency, 1923 1923 &sandybridge_cursor_wm_info, latency, 1924 1924 &plane_wm, &cursor_wm)) { ··· 1929 1929 DRM_DEBUG_KMS("FIFO watermarks For pipe B -" 1930 1930 " plane %d, cursor: %d\n", 1931 1931 plane_wm, cursor_wm); 1932 - enabled |= 2; 1932 + enabled |= 1 << PIPE_B; 1933 1933 } 1934 1934 1935 - if (g4x_compute_wm0(dev, 2, 1935 + if (g4x_compute_wm0(dev, PIPE_C, 1936 1936 &sandybridge_display_wm_info, latency, 1937 1937 &sandybridge_cursor_wm_info, latency, 1938 1938 &plane_wm, &cursor_wm)) { ··· 1943 1943 DRM_DEBUG_KMS("FIFO watermarks For pipe C -" 1944 1944 " plane %d, cursor: %d\n", 1945 1945 plane_wm, cursor_wm); 1946 - enabled |= 3; 1946 + enabled |= 1 << PIPE_C; 1947 1947 } 1948 1948 1949 1949 /*
+52 -38
drivers/gpu/drm/mgag200/mgag200_mode.c
··· 46 46 47 47 static inline void mga_wait_vsync(struct mga_device *mdev) 48 48 { 49 - unsigned int count = 0; 49 + unsigned long timeout = jiffies + HZ/10; 50 50 unsigned int status = 0; 51 51 52 52 do { 53 53 status = RREG32(MGAREG_Status); 54 - count++; 55 - } while ((status & 0x08) && (count < 250000)); 56 - count = 0; 54 + } while ((status & 0x08) && time_before(jiffies, timeout)); 55 + timeout = jiffies + HZ/10; 57 56 status = 0; 58 57 do { 59 58 status = RREG32(MGAREG_Status); 60 - count++; 61 - } while (!(status & 0x08) && (count < 250000)); 59 + } while (!(status & 0x08) && time_before(jiffies, timeout)); 62 60 } 63 61 64 62 static inline void mga_wait_busy(struct mga_device *mdev) 65 63 { 66 - unsigned int count = 0; 64 + unsigned long timeout = jiffies + HZ; 67 65 unsigned int status = 0; 68 66 do { 69 67 status = RREG8(MGAREG_Status + 2); 70 - count++; 71 - } while ((status & 0x01) && (count < 500000)); 68 + } while ((status & 0x01) && time_before(jiffies, timeout)); 72 69 } 73 70 74 71 /* ··· 186 189 WREG8(DAC_INDEX, MGA1064_PIX_CLK_CTL); 187 190 tmp = RREG8(DAC_DATA); 188 191 tmp |= MGA1064_PIX_CLK_CTL_CLK_DIS; 189 - WREG_DAC(MGA1064_PIX_CLK_CTL_CLK_DIS, tmp); 192 + WREG8(DAC_DATA, tmp); 190 193 191 194 WREG8(DAC_INDEX, MGA1064_REMHEADCTL); 192 195 tmp = RREG8(DAC_DATA); 193 196 tmp |= MGA1064_REMHEADCTL_CLKDIS; 194 - WREG_DAC(MGA1064_REMHEADCTL, tmp); 197 + WREG8(DAC_DATA, tmp); 195 198 196 199 /* select PLL Set C */ 197 200 tmp = RREG8(MGAREG_MEM_MISC_READ); ··· 201 204 WREG8(DAC_INDEX, MGA1064_PIX_CLK_CTL); 202 205 tmp = RREG8(DAC_DATA); 203 206 tmp |= MGA1064_PIX_CLK_CTL_CLK_POW_DOWN | 0x80; 204 - WREG_DAC(MGA1064_PIX_CLK_CTL, tmp); 207 + WREG8(DAC_DATA, tmp); 205 208 206 209 udelay(500); 207 210 ··· 209 212 WREG8(DAC_INDEX, MGA1064_VREF_CTL); 210 213 tmp = RREG8(DAC_DATA); 211 214 tmp &= ~0x04; 212 - WREG_DAC(MGA1064_VREF_CTL, tmp); 215 + WREG8(DAC_DATA, tmp); 213 216 214 217 udelay(50); 215 218 ··· 233 236 tmp = RREG8(DAC_DATA); 234 237 tmp &= ~MGA1064_PIX_CLK_CTL_SEL_MSK; 235 238 tmp |= MGA1064_PIX_CLK_CTL_SEL_PLL; 236 - WREG_DAC(MGA1064_PIX_CLK_CTL, tmp); 239 + WREG8(DAC_DATA, tmp); 237 240 238 241 WREG8(DAC_INDEX, MGA1064_REMHEADCTL); 239 242 tmp = RREG8(DAC_DATA); 240 243 tmp &= ~MGA1064_REMHEADCTL_CLKSL_MSK; 241 244 tmp |= MGA1064_REMHEADCTL_CLKSL_PLL; 242 - WREG_DAC(MGA1064_REMHEADCTL, tmp); 245 + WREG8(DAC_DATA, tmp); 243 246 244 247 /* reset dotclock rate bit */ 245 248 WREG8(MGAREG_SEQ_INDEX, 1); ··· 250 253 WREG8(DAC_INDEX, MGA1064_PIX_CLK_CTL); 251 254 tmp = RREG8(DAC_DATA); 252 255 tmp &= ~MGA1064_PIX_CLK_CTL_CLK_DIS; 253 - WREG_DAC(MGA1064_PIX_CLK_CTL, tmp); 256 + WREG8(DAC_DATA, tmp); 254 257 255 258 vcount = RREG8(MGAREG_VCOUNT); 256 259 ··· 315 318 WREG8(DAC_INDEX, MGA1064_PIX_CLK_CTL); 316 319 tmp = RREG8(DAC_DATA); 317 320 tmp |= MGA1064_PIX_CLK_CTL_CLK_DIS; 318 - WREG_DAC(MGA1064_PIX_CLK_CTL_CLK_DIS, tmp); 321 + WREG8(DAC_DATA, tmp); 319 322 320 323 tmp = RREG8(MGAREG_MEM_MISC_READ); 321 324 tmp |= 0x3 << 2; ··· 323 326 324 327 WREG8(DAC_INDEX, MGA1064_PIX_PLL_STAT); 325 328 tmp = RREG8(DAC_DATA); 326 - WREG_DAC(MGA1064_PIX_PLL_STAT, tmp & ~0x40); 329 + WREG8(DAC_DATA, tmp & ~0x40); 327 330 328 331 WREG8(DAC_INDEX, MGA1064_PIX_CLK_CTL); 329 332 tmp = RREG8(DAC_DATA); 330 333 tmp |= MGA1064_PIX_CLK_CTL_CLK_POW_DOWN; 331 - WREG_DAC(MGA1064_PIX_CLK_CTL, tmp); 334 + WREG8(DAC_DATA, tmp); 332 335 333 336 WREG_DAC(MGA1064_EV_PIX_PLLC_M, m); 334 337 WREG_DAC(MGA1064_EV_PIX_PLLC_N, n); ··· 339 342 WREG8(DAC_INDEX, MGA1064_PIX_CLK_CTL); 340 343 tmp = RREG8(DAC_DATA); 341 344 tmp &= ~MGA1064_PIX_CLK_CTL_CLK_POW_DOWN; 342 - WREG_DAC(MGA1064_PIX_CLK_CTL, tmp); 345 + WREG8(DAC_DATA, tmp); 343 346 344 347 udelay(500); 345 348 ··· 347 350 tmp = RREG8(DAC_DATA); 348 351 tmp &= ~MGA1064_PIX_CLK_CTL_SEL_MSK; 349 352 tmp |= MGA1064_PIX_CLK_CTL_SEL_PLL; 350 - WREG_DAC(MGA1064_PIX_CLK_CTL, tmp); 353 + WREG8(DAC_DATA, tmp); 351 354 352 355 WREG8(DAC_INDEX, MGA1064_PIX_PLL_STAT); 353 356 tmp = RREG8(DAC_DATA); 354 - WREG_DAC(MGA1064_PIX_PLL_STAT, tmp | 0x40); 357 + WREG8(DAC_DATA, tmp | 0x40); 355 358 356 359 tmp = RREG8(MGAREG_MEM_MISC_READ); 357 360 tmp |= (0x3 << 2); ··· 360 363 WREG8(DAC_INDEX, MGA1064_PIX_CLK_CTL); 361 364 tmp = RREG8(DAC_DATA); 362 365 tmp &= ~MGA1064_PIX_CLK_CTL_CLK_DIS; 363 - WREG_DAC(MGA1064_PIX_CLK_CTL, tmp); 366 + WREG8(DAC_DATA, tmp); 364 367 365 368 return 0; 366 369 } ··· 413 416 WREG8(DAC_INDEX, MGA1064_PIX_CLK_CTL); 414 417 tmp = RREG8(DAC_DATA); 415 418 tmp |= MGA1064_PIX_CLK_CTL_CLK_DIS; 416 - WREG_DAC(MGA1064_PIX_CLK_CTL_CLK_DIS, tmp); 419 + WREG8(DAC_DATA, tmp); 417 420 418 421 tmp = RREG8(MGAREG_MEM_MISC_READ); 419 422 tmp |= 0x3 << 2; ··· 422 425 WREG8(DAC_INDEX, MGA1064_PIX_CLK_CTL); 423 426 tmp = RREG8(DAC_DATA); 424 427 tmp |= MGA1064_PIX_CLK_CTL_CLK_POW_DOWN; 425 - WREG_DAC(MGA1064_PIX_CLK_CTL, tmp); 428 + WREG8(DAC_DATA, tmp); 426 429 427 430 udelay(500); 428 431 ··· 436 439 tmp = RREG8(DAC_DATA); 437 440 tmp &= ~MGA1064_PIX_CLK_CTL_SEL_MSK; 438 441 tmp |= MGA1064_PIX_CLK_CTL_SEL_PLL; 439 - WREG_DAC(MGA1064_PIX_CLK_CTL, tmp); 442 + WREG8(DAC_DATA, tmp); 440 443 441 444 WREG8(DAC_INDEX, MGA1064_PIX_CLK_CTL); 442 445 tmp = RREG8(DAC_DATA); 443 446 tmp &= ~MGA1064_PIX_CLK_CTL_CLK_DIS; 444 447 tmp &= ~MGA1064_PIX_CLK_CTL_CLK_POW_DOWN; 445 - WREG_DAC(MGA1064_PIX_CLK_CTL, tmp); 448 + WREG8(DAC_DATA, tmp); 446 449 447 450 vcount = RREG8(MGAREG_VCOUNT); 448 451 ··· 512 515 WREG8(DAC_INDEX, MGA1064_PIX_CLK_CTL); 513 516 tmp = RREG8(DAC_DATA); 514 517 tmp |= MGA1064_PIX_CLK_CTL_CLK_DIS; 515 - WREG_DAC(MGA1064_PIX_CLK_CTL_CLK_DIS, tmp); 518 + WREG8(DAC_DATA, tmp); 516 519 517 520 WREG8(DAC_INDEX, MGA1064_REMHEADCTL); 518 521 tmp = RREG8(DAC_DATA); 519 522 tmp |= MGA1064_REMHEADCTL_CLKDIS; 520 - WREG_DAC(MGA1064_REMHEADCTL, tmp); 523 + WREG8(DAC_DATA, tmp); 521 524 522 525 tmp = RREG8(MGAREG_MEM_MISC_READ); 523 526 tmp |= (0x3<<2) | 0xc0; ··· 527 530 tmp = RREG8(DAC_DATA); 528 531 tmp &= ~MGA1064_PIX_CLK_CTL_CLK_DIS; 529 532 tmp |= MGA1064_PIX_CLK_CTL_CLK_POW_DOWN; 530 - WREG_DAC(MGA1064_PIX_CLK_CTL, tmp); 533 + WREG8(DAC_DATA, tmp); 531 534 532 535 udelay(500); 533 536 ··· 654 657 WREG_DAC(MGA1064_GEN_IO_DATA, tmp); 655 658 } 656 659 657 - 660 + /* 661 + This is how the framebuffer base address is stored in g200 cards: 662 + * Assume @offset is the gpu_addr variable of the framebuffer object 663 + * Then addr is the number of _pixels_ (not bytes) from the start of 664 + VRAM to the first pixel we want to display. (divided by 2 for 32bit 665 + framebuffers) 666 + * addr is stored in the CRTCEXT0, CRTCC and CRTCD registers 667 + addr<20> -> CRTCEXT0<6> 668 + addr<19-16> -> CRTCEXT0<3-0> 669 + addr<15-8> -> CRTCC<7-0> 670 + addr<7-0> -> CRTCD<7-0> 671 + CRTCEXT0 has to be programmed last to trigger an update and make the 672 + new addr variable take effect. 673 + */ 658 674 void mga_set_start_address(struct drm_crtc *crtc, unsigned offset) 659 675 { 660 676 struct mga_device *mdev = crtc->dev->dev_private; 661 677 u32 addr; 662 678 int count; 679 + u8 crtcext0; 663 680 664 681 while (RREG8(0x1fda) & 0x08); 665 682 while (!(RREG8(0x1fda) & 0x08)); ··· 681 670 count = RREG8(MGAREG_VCOUNT) + 2; 682 671 while (RREG8(MGAREG_VCOUNT) < count); 683 672 684 - addr = offset >> 2; 673 + WREG8(MGAREG_CRTCEXT_INDEX, 0); 674 + crtcext0 = RREG8(MGAREG_CRTCEXT_DATA); 675 + crtcext0 &= 0xB0; 676 + addr = offset / 8; 677 + /* Can't store addresses any higher than that... 678 + but we also don't have more than 16MB of memory, so it should be fine. */ 679 + WARN_ON(addr > 0x1fffff); 680 + crtcext0 |= (!!(addr & (1<<20)))<<6; 685 681 WREG_CRT(0x0d, (u8)(addr & 0xff)); 686 682 WREG_CRT(0x0c, (u8)(addr >> 8) & 0xff); 687 - WREG_CRT(0xaf, (u8)(addr >> 16) & 0xf); 683 + WREG_ECRT(0x0, ((u8)(addr >> 16) & 0xf) | crtcext0); 688 684 } 689 685 690 686 ··· 847 829 848 830 849 831 for (i = 0; i < sizeof(dacvalue); i++) { 850 - if ((i <= 0x03) || 851 - (i == 0x07) || 852 - (i == 0x0b) || 853 - (i == 0x0f) || 854 - ((i >= 0x13) && (i <= 0x17)) || 832 + if ((i <= 0x17) || 855 833 (i == 0x1b) || 856 834 (i == 0x1c) || 857 835 ((i >= 0x1f) && (i <= 0x29)) ||
+19 -10
drivers/gpu/drm/qxl/qxl_cmd.c
··· 277 277 return 0; 278 278 } 279 279 280 - static int wait_for_io_cmd_user(struct qxl_device *qdev, uint8_t val, long port) 280 + static int wait_for_io_cmd_user(struct qxl_device *qdev, uint8_t val, long port, bool intr) 281 281 { 282 282 int irq_num; 283 283 long addr = qdev->io_base + port; ··· 285 285 286 286 mutex_lock(&qdev->async_io_mutex); 287 287 irq_num = atomic_read(&qdev->irq_received_io_cmd); 288 - 289 - 290 288 if (qdev->last_sent_io_cmd > irq_num) { 291 - ret = wait_event_interruptible(qdev->io_cmd_event, 292 - atomic_read(&qdev->irq_received_io_cmd) > irq_num); 293 - if (ret) 289 + if (intr) 290 + ret = wait_event_interruptible_timeout(qdev->io_cmd_event, 291 + atomic_read(&qdev->irq_received_io_cmd) > irq_num, 5*HZ); 292 + else 293 + ret = wait_event_timeout(qdev->io_cmd_event, 294 + atomic_read(&qdev->irq_received_io_cmd) > irq_num, 5*HZ); 295 + /* 0 is timeout, just bail the "hw" has gone away */ 296 + if (ret <= 0) 294 297 goto out; 295 298 irq_num = atomic_read(&qdev->irq_received_io_cmd); 296 299 } 297 300 outb(val, addr); 298 301 qdev->last_sent_io_cmd = irq_num + 1; 299 - ret = wait_event_interruptible(qdev->io_cmd_event, 300 - atomic_read(&qdev->irq_received_io_cmd) > irq_num); 302 + if (intr) 303 + ret = wait_event_interruptible_timeout(qdev->io_cmd_event, 304 + atomic_read(&qdev->irq_received_io_cmd) > irq_num, 5*HZ); 305 + else 306 + ret = wait_event_timeout(qdev->io_cmd_event, 307 + atomic_read(&qdev->irq_received_io_cmd) > irq_num, 5*HZ); 301 308 out: 309 + if (ret > 0) 310 + ret = 0; 302 311 mutex_unlock(&qdev->async_io_mutex); 303 312 return ret; 304 313 } ··· 317 308 int ret; 318 309 319 310 restart: 320 - ret = wait_for_io_cmd_user(qdev, val, port); 311 + ret = wait_for_io_cmd_user(qdev, val, port, false); 321 312 if (ret == -ERESTARTSYS) 322 313 goto restart; 323 314 } ··· 349 340 mutex_lock(&qdev->update_area_mutex); 350 341 qdev->ram_header->update_area = *area; 351 342 qdev->ram_header->update_surface = surface_id; 352 - ret = wait_for_io_cmd_user(qdev, 0, QXL_IO_UPDATE_AREA_ASYNC); 343 + ret = wait_for_io_cmd_user(qdev, 0, QXL_IO_UPDATE_AREA_ASYNC, true); 353 344 mutex_unlock(&qdev->update_area_mutex); 354 345 return ret; 355 346 }
+4 -13
drivers/gpu/drm/qxl/qxl_display.c
··· 428 428 int inc = 1; 429 429 430 430 qobj = gem_to_qxl_bo(qxl_fb->obj); 431 - if (qxl_fb != qdev->active_user_framebuffer) { 432 - DRM_INFO("%s: qxl_fb 0x%p != qdev->active_user_framebuffer 0x%p\n", 433 - __func__, qxl_fb, qdev->active_user_framebuffer); 434 - } 431 + /* if we aren't primary surface ignore this */ 432 + if (!qobj->is_primary) 433 + return 0; 434 + 435 435 if (!num_clips) { 436 436 num_clips = 1; 437 437 clips = &norect; ··· 604 604 mode->hdisplay, 605 605 mode->vdisplay); 606 606 } 607 - qdev->mode_set = true; 608 607 return 0; 609 608 } 610 609 ··· 892 893 { 893 894 struct drm_gem_object *obj; 894 895 struct qxl_framebuffer *qxl_fb; 895 - struct qxl_device *qdev = dev->dev_private; 896 896 int ret; 897 897 898 898 obj = drm_gem_object_lookup(dev, file_priv, mode_cmd->handles[0]); ··· 906 908 drm_gem_object_unreference_unlocked(obj); 907 909 return NULL; 908 910 } 909 - 910 - if (qdev->active_user_framebuffer) { 911 - DRM_INFO("%s: active_user_framebuffer %p -> %p\n", 912 - __func__, 913 - qdev->active_user_framebuffer, qxl_fb); 914 - } 915 - qdev->active_user_framebuffer = qxl_fb; 916 911 917 912 return &qxl_fb->base; 918 913 }
-7
drivers/gpu/drm/qxl/qxl_drv.h
··· 255 255 struct qxl_gem gem; 256 256 struct qxl_mode_info mode_info; 257 257 258 - /* 259 - * last created framebuffer with fb_create 260 - * only used by debugfs dumbppm 261 - */ 262 - struct qxl_framebuffer *active_user_framebuffer; 263 - 264 258 struct fb_info *fbdev_info; 265 259 struct qxl_framebuffer *fbdev_qfb; 266 260 void *ram_physical; ··· 264 270 struct qxl_ring *cursor_ring; 265 271 266 272 struct qxl_ram_header *ram_header; 267 - bool mode_set; 268 273 269 274 bool primary_created; 270 275
+1
drivers/gpu/drm/qxl/qxl_ioctl.c
··· 294 294 goto out; 295 295 296 296 if (!qobj->pin_count) { 297 + qxl_ttm_placement_from_domain(qobj, qobj->type); 297 298 ret = ttm_bo_validate(&qobj->tbo, &qobj->placement, 298 299 true, false); 299 300 if (unlikely(ret))
+1 -1
drivers/gpu/drm/radeon/r300_cmdbuf.c
··· 75 75 OUT_RING(CP_PACKET0(R300_RE_CLIPRECT_TL_0, nr * 2 - 1)); 76 76 77 77 for (i = 0; i < nr; ++i) { 78 - if (DRM_COPY_FROM_USER_UNCHECKED 78 + if (DRM_COPY_FROM_USER 79 79 (&box, &cmdbuf->boxes[n + i], sizeof(box))) { 80 80 DRM_ERROR("copy cliprect faulted\n"); 81 81 return -EFAULT;
+11 -1
drivers/gpu/drm/radeon/radeon_drv.c
··· 147 147 #endif 148 148 149 149 int radeon_no_wb; 150 - int radeon_modeset = 1; 150 + int radeon_modeset = -1; 151 151 int radeon_dynclks = -1; 152 152 int radeon_r4xx_atom = 0; 153 153 int radeon_agpmode = 0; ··· 456 456 457 457 static int __init radeon_init(void) 458 458 { 459 + #ifdef CONFIG_VGA_CONSOLE 460 + if (vgacon_text_force() && radeon_modeset == -1) { 461 + DRM_INFO("VGACON disable radeon kernel modesetting.\n"); 462 + radeon_modeset = 0; 463 + } 464 + #endif 465 + /* set to modesetting by default if not nomodeset */ 466 + if (radeon_modeset == -1) 467 + radeon_modeset = 1; 468 + 459 469 if (radeon_modeset == 1) { 460 470 DRM_INFO("radeon kernel modesetting enabled.\n"); 461 471 driver = &kms_driver;
-5
drivers/gpu/host1x/drm/dc.c
··· 1128 1128 return err; 1129 1129 1130 1130 regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1131 - if (!regs) { 1132 - dev_err(&pdev->dev, "failed to get registers\n"); 1133 - return -ENXIO; 1134 - } 1135 - 1136 1131 dc->regs = devm_ioremap_resource(&pdev->dev, regs); 1137 1132 if (IS_ERR(dc->regs)) 1138 1133 return PTR_ERR(dc->regs);
+10 -6
drivers/hwmon/abituguru.c
··· 1414 1414 pr_info("found Abit uGuru\n"); 1415 1415 1416 1416 /* Register sysfs hooks */ 1417 - for (i = 0; i < sysfs_attr_i; i++) 1418 - if (device_create_file(&pdev->dev, 1419 - &data->sysfs_attr[i].dev_attr)) 1417 + for (i = 0; i < sysfs_attr_i; i++) { 1418 + res = device_create_file(&pdev->dev, 1419 + &data->sysfs_attr[i].dev_attr); 1420 + if (res) 1420 1421 goto abituguru_probe_error; 1421 - for (i = 0; i < ARRAY_SIZE(abituguru_sysfs_attr); i++) 1422 - if (device_create_file(&pdev->dev, 1423 - &abituguru_sysfs_attr[i].dev_attr)) 1422 + } 1423 + for (i = 0; i < ARRAY_SIZE(abituguru_sysfs_attr); i++) { 1424 + res = device_create_file(&pdev->dev, 1425 + &abituguru_sysfs_attr[i].dev_attr); 1426 + if (res) 1424 1427 goto abituguru_probe_error; 1428 + } 1425 1429 1426 1430 data->hwmon_dev = hwmon_device_register(&pdev->dev); 1427 1431 if (!IS_ERR(data->hwmon_dev))
+5 -3
drivers/hwmon/iio_hwmon.c
··· 84 84 return PTR_ERR(channels); 85 85 86 86 st = devm_kzalloc(dev, sizeof(*st), GFP_KERNEL); 87 - if (st == NULL) 88 - return -ENOMEM; 87 + if (st == NULL) { 88 + ret = -ENOMEM; 89 + goto error_release_channels; 90 + } 89 91 90 92 st->channels = channels; 91 93 ··· 161 159 error_remove_group: 162 160 sysfs_remove_group(&dev->kobj, &st->attr_group); 163 161 error_release_channels: 164 - iio_channel_release_all(st->channels); 162 + iio_channel_release_all(channels); 165 163 return ret; 166 164 } 167 165
+4 -2
drivers/hwmon/nct6775.c
··· 3705 3705 data->have_temp |= 1 << i; 3706 3706 data->have_temp_fixed |= 1 << i; 3707 3707 data->reg_temp[0][i] = reg_temp_alternate[i]; 3708 - data->reg_temp[1][i] = reg_temp_over[i]; 3709 - data->reg_temp[2][i] = reg_temp_hyst[i]; 3708 + if (i < num_reg_temp) { 3709 + data->reg_temp[1][i] = reg_temp_over[i]; 3710 + data->reg_temp[2][i] = reg_temp_hyst[i]; 3711 + } 3710 3712 data->temp_src[i] = i + 1; 3711 3713 continue; 3712 3714 }
+1 -1
drivers/hwmon/tmp401.c
··· 240 240 mutex_lock(&data->update_lock); 241 241 242 242 next_update = data->last_updated + 243 - msecs_to_jiffies(data->update_interval) + 1; 243 + msecs_to_jiffies(data->update_interval); 244 244 if (time_after(jiffies, next_update) || !data->valid) { 245 245 if (data->kind != tmp432) { 246 246 /*
-5
drivers/i2c/busses/i2c-s3c2410.c
··· 1082 1082 /* map the registers */ 1083 1083 1084 1084 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1085 - if (res == NULL) { 1086 - dev_err(&pdev->dev, "cannot find IO resource\n"); 1087 - return -ENOENT; 1088 - } 1089 - 1090 1085 i2c->regs = devm_ioremap_resource(&pdev->dev, res); 1091 1086 1092 1087 if (IS_ERR(i2c->regs))
-6
drivers/i2c/busses/i2c-sirf.c
··· 303 303 adap->class = I2C_CLASS_HWMON; 304 304 305 305 mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 306 - if (mem_res == NULL) { 307 - dev_err(&pdev->dev, "Unable to get MEM resource\n"); 308 - err = -EINVAL; 309 - goto out; 310 - } 311 - 312 306 siic->base = devm_ioremap_resource(&pdev->dev, mem_res); 313 307 if (IS_ERR(siic->base)) { 314 308 err = PTR_ERR(siic->base);
-5
drivers/i2c/busses/i2c-tegra.c
··· 714 714 int ret = 0; 715 715 716 716 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 717 - if (!res) { 718 - dev_err(&pdev->dev, "no mem resource\n"); 719 - return -EINVAL; 720 - } 721 - 722 717 base = devm_ioremap_resource(&pdev->dev, res); 723 718 if (IS_ERR(base)) 724 719 return PTR_ERR(base);
+1
drivers/lguest/page_tables.c
··· 1002 1002 kill_guest(&lg->cpus[0], 1003 1003 "Cannot populate switcher mapping"); 1004 1004 } 1005 + lg->pgdirs[pgdir].last_host_cpu = -1; 1005 1006 } 1006 1007 } 1007 1008
+2 -2
drivers/md/dm-thin.c
··· 2188 2188 2189 2189 *need_commit = false; 2190 2190 2191 - metadata_dev_size = get_metadata_dev_size(pool->md_dev); 2191 + metadata_dev_size = get_metadata_dev_size_in_blocks(pool->md_dev); 2192 2192 2193 2193 r = dm_pool_get_metadata_dev_size(pool->pmd, &sb_metadata_dev_size); 2194 2194 if (r) { ··· 2197 2197 } 2198 2198 2199 2199 if (metadata_dev_size < sb_metadata_dev_size) { 2200 - DMERR("metadata device (%llu sectors) too small: expected %llu", 2200 + DMERR("metadata device (%llu blocks) too small: expected %llu", 2201 2201 metadata_dev_size, sb_metadata_dev_size); 2202 2202 return -EINVAL; 2203 2203
-6
drivers/memory/emif.c
··· 1560 1560 platform_set_drvdata(pdev, emif); 1561 1561 1562 1562 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1563 - if (!res) { 1564 - dev_err(emif->dev, "%s: error getting memory resource\n", 1565 - __func__); 1566 - goto error; 1567 - } 1568 - 1569 1563 emif->base = devm_ioremap_resource(emif->dev, res); 1570 1564 if (IS_ERR(emif->base)) 1571 1565 goto error;
-5
drivers/mfd/intel_msic.c
··· 414 414 * the clients via intel_msic_irq_read(). 415 415 */ 416 416 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 417 - if (!res) { 418 - dev_err(&pdev->dev, "failed to get SRAM iomem resource\n"); 419 - return -ENODEV; 420 - } 421 - 422 417 msic->irq_base = devm_ioremap_resource(&pdev->dev, res); 423 418 if (IS_ERR(msic->irq_base)) 424 419 return PTR_ERR(msic->irq_base);
-5
drivers/misc/atmel-ssc.c
··· 154 154 ssc->pdata = (struct atmel_ssc_platform_data *)plat_dat; 155 155 156 156 regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); 157 - if (!regs) { 158 - dev_dbg(&pdev->dev, "no mmio resource defined\n"); 159 - return -ENXIO; 160 - } 161 - 162 157 ssc->regs = devm_ioremap_resource(&pdev->dev, regs); 163 158 if (IS_ERR(ssc->regs)) 164 159 return PTR_ERR(ssc->regs);
+7 -2
drivers/mmc/host/mmci.c
··· 1130 1130 struct variant_data *variant = host->variant; 1131 1131 u32 pwr = 0; 1132 1132 unsigned long flags; 1133 + int ret; 1133 1134 1134 1135 pm_runtime_get_sync(mmc_dev(mmc)); 1135 1136 ··· 1162 1161 break; 1163 1162 case MMC_POWER_ON: 1164 1163 if (!IS_ERR(mmc->supply.vqmmc) && 1165 - !regulator_is_enabled(mmc->supply.vqmmc)) 1166 - regulator_enable(mmc->supply.vqmmc); 1164 + !regulator_is_enabled(mmc->supply.vqmmc)) { 1165 + ret = regulator_enable(mmc->supply.vqmmc); 1166 + if (ret < 0) 1167 + dev_err(mmc_dev(mmc), 1168 + "failed to enable vqmmc regulator\n"); 1169 + } 1167 1170 1168 1171 pwr |= MCI_PWR_ON; 1169 1172 break;
-5
drivers/mtd/nand/lpc32xx_mlc.c
··· 672 672 } 673 673 674 674 rc = platform_get_resource(pdev, IORESOURCE_MEM, 0); 675 - if (rc == NULL) { 676 - dev_err(&pdev->dev, "No memory resource found for device!\r\n"); 677 - return -ENXIO; 678 - } 679 - 680 675 host->io_base = devm_ioremap_resource(&pdev->dev, rc); 681 676 if (IS_ERR(host->io_base)) 682 677 return PTR_ERR(host->io_base);
+1 -1
drivers/net/caif/Kconfig
··· 43 43 44 44 config CAIF_VIRTIO 45 45 tristate "CAIF virtio transport driver" 46 - depends on CAIF 46 + depends on CAIF && HAS_DMA 47 47 select VHOST_RING 48 48 select VIRTIO 49 49 select GENERIC_ALLOCATOR
+13 -12
drivers/net/ethernet/3com/3c59x.c
··· 632 632 pm_state_valid:1, /* pci_dev->saved_config_space has sane contents */ 633 633 open:1, 634 634 medialock:1, 635 - must_free_region:1, /* Flag: if zero, Cardbus owns the I/O region */ 636 635 large_frames:1, /* accept large frames */ 637 636 handling_irq:1; /* private in_irq indicator */ 638 637 /* {get|set}_wol operations are already serialized by rtnl. ··· 1011 1012 if (rc < 0) 1012 1013 goto out; 1013 1014 1015 + rc = pci_request_regions(pdev, DRV_NAME); 1016 + if (rc < 0) { 1017 + pci_disable_device(pdev); 1018 + goto out; 1019 + } 1020 + 1014 1021 unit = vortex_cards_found; 1015 1022 1016 1023 if (global_use_mmio < 0 && (unit >= MAX_UNITS || use_mmio[unit] < 0)) { ··· 1032 1027 if (!ioaddr) /* If mapping fails, fall-back to BAR 0... */ 1033 1028 ioaddr = pci_iomap(pdev, 0, 0); 1034 1029 if (!ioaddr) { 1030 + pci_release_regions(pdev); 1035 1031 pci_disable_device(pdev); 1036 1032 rc = -ENOMEM; 1037 1033 goto out; ··· 1042 1036 ent->driver_data, unit); 1043 1037 if (rc < 0) { 1044 1038 pci_iounmap(pdev, ioaddr); 1039 + pci_release_regions(pdev); 1045 1040 pci_disable_device(pdev); 1046 1041 goto out; 1047 1042 } ··· 1185 1178 1186 1179 /* PCI-only startup logic */ 1187 1180 if (pdev) { 1188 - /* EISA resources already marked, so only PCI needs to do this here */ 1189 - /* Ignore return value, because Cardbus drivers already allocate for us */ 1190 - if (request_region(dev->base_addr, vci->io_size, print_name) != NULL) 1191 - vp->must_free_region = 1; 1192 - 1193 1181 /* enable bus-mastering if necessary */ 1194 1182 if (vci->flags & PCI_USES_MASTER) 1195 1183 pci_set_master(pdev); ··· 1222 1220 &vp->rx_ring_dma); 1223 1221 retval = -ENOMEM; 1224 1222 if (!vp->rx_ring) 1225 - goto free_region; 1223 + goto free_device; 1226 1224 1227 1225 vp->tx_ring = (struct boom_tx_desc *)(vp->rx_ring + RX_RING_SIZE); 1228 1226 vp->tx_ring_dma = vp->rx_ring_dma + sizeof(struct boom_rx_desc) * RX_RING_SIZE; ··· 1486 1484 + sizeof(struct boom_tx_desc) * TX_RING_SIZE, 1487 1485 vp->rx_ring, 1488 1486 vp->rx_ring_dma); 1489 - free_region: 1490 - if (vp->must_free_region) 1491 - release_region(dev->base_addr, vci->io_size); 1487 + free_device: 1492 1488 free_netdev(dev); 1493 1489 pr_err(PFX "vortex_probe1 fails. Returns %d\n", retval); 1494 1490 out: ··· 3254 3254 + sizeof(struct boom_tx_desc) * TX_RING_SIZE, 3255 3255 vp->rx_ring, 3256 3256 vp->rx_ring_dma); 3257 - if (vp->must_free_region) 3258 - release_region(dev->base_addr, vp->io_size); 3257 + 3258 + pci_release_regions(pdev); 3259 + 3259 3260 free_netdev(dev); 3260 3261 } 3261 3262
+3 -2
drivers/net/ethernet/brocade/bna/bnad.c
··· 3236 3236 3237 3237 sprintf(bnad->wq_name, "%s_wq_%d", BNAD_NAME, bnad->id); 3238 3238 bnad->work_q = create_singlethread_workqueue(bnad->wq_name); 3239 - 3240 - if (!bnad->work_q) 3239 + if (!bnad->work_q) { 3240 + iounmap(bnad->bar0); 3241 3241 return -ENOMEM; 3242 + } 3242 3243 3243 3244 return 0; 3244 3245 }
+2 -1
drivers/net/ethernet/cadence/Kconfig
··· 22 22 23 23 config ARM_AT91_ETHER 24 24 tristate "AT91RM9200 Ethernet support" 25 - depends on GENERIC_HARDIRQS 25 + depends on GENERIC_HARDIRQS && HAS_DMA 26 26 select NET_CORE 27 27 select MACB 28 28 ---help--- ··· 31 31 32 32 config MACB 33 33 tristate "Cadence MACB/GEM support" 34 + depends on HAS_DMA 34 35 select PHYLIB 35 36 ---help--- 36 37 The Cadence MACB ethernet interface is found on many Atmel AT32 and
+1 -1
drivers/net/ethernet/calxeda/Kconfig
··· 1 1 config NET_CALXEDA_XGMAC 2 2 tristate "Calxeda 1G/10G XGMAC Ethernet driver" 3 - depends on HAS_IOMEM 3 + depends on HAS_IOMEM && HAS_DMA 4 4 select CRC32 5 5 help 6 6 This is the driver for the XGMAC Ethernet IP block found on Calxeda
+13 -7
drivers/net/ethernet/freescale/fec_main.c
··· 87 87 #define FEC_QUIRK_HAS_GBIT (1 << 3) 88 88 /* Controller has extend desc buffer */ 89 89 #define FEC_QUIRK_HAS_BUFDESC_EX (1 << 4) 90 + /* Controller has hardware checksum support */ 91 + #define FEC_QUIRK_HAS_CSUM (1 << 5) 90 92 91 93 static struct platform_device_id fec_devtype[] = { 92 94 { ··· 107 105 }, { 108 106 .name = "imx6q-fec", 109 107 .driver_data = FEC_QUIRK_ENET_MAC | FEC_QUIRK_HAS_GBIT | 110 - FEC_QUIRK_HAS_BUFDESC_EX, 108 + FEC_QUIRK_HAS_BUFDESC_EX | FEC_QUIRK_HAS_CSUM, 111 109 }, { 112 110 .name = "mvf-fec", 113 111 .driver_data = FEC_QUIRK_ENET_MAC, ··· 1746 1744 static int fec_enet_init(struct net_device *ndev) 1747 1745 { 1748 1746 struct fec_enet_private *fep = netdev_priv(ndev); 1747 + const struct platform_device_id *id_entry = 1748 + platform_get_device_id(fep->pdev); 1749 1749 struct bufdesc *cbd_base; 1750 1750 1751 1751 /* Allocate memory for buffer descriptors. */ ··· 1779 1775 writel(FEC_RX_DISABLED_IMASK, fep->hwp + FEC_IMASK); 1780 1776 netif_napi_add(ndev, &fep->napi, fec_enet_rx_napi, FEC_NAPI_WEIGHT); 1781 1777 1782 - /* enable hw accelerator */ 1783 - ndev->features |= (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM 1784 - | NETIF_F_RXCSUM); 1785 - ndev->hw_features |= (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM 1786 - | NETIF_F_RXCSUM); 1787 - fep->csum_flags |= FLAG_RX_CSUM_ENABLED; 1778 + if (id_entry->driver_data & FEC_QUIRK_HAS_CSUM) { 1779 + /* enable hw accelerator */ 1780 + ndev->features |= (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM 1781 + | NETIF_F_RXCSUM); 1782 + ndev->hw_features |= (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM 1783 + | NETIF_F_RXCSUM); 1784 + fep->csum_flags |= FLAG_RX_CSUM_ENABLED; 1785 + } 1788 1786 1789 1787 fec_restart(ndev, 0); 1790 1788
+28 -8
drivers/net/ethernet/ibm/emac/core.c
··· 359 359 } 360 360 361 361 #ifdef CONFIG_PPC_DCR_NATIVE 362 - /* Enable internal clock source */ 363 - if (emac_has_feature(dev, EMAC_FTR_460EX_PHY_CLK_FIX)) 364 - dcri_clrset(SDR0, SDR0_ETH_CFG, 365 - 0, SDR0_ETH_CFG_ECS << dev->cell_index); 362 + /* 363 + * PPC460EX/GT Embedded Processor Advanced User's Manual 364 + * section 28.10.1 Mode Register 0 (EMACx_MR0) states: 365 + * Note: The PHY must provide a TX Clk in order to perform a soft reset 366 + * of the EMAC. If none is present, select the internal clock 367 + * (SDR0_ETH_CFG[EMACx_PHY_CLK] = 1). 368 + * After a soft reset, select the external clock. 369 + */ 370 + if (emac_has_feature(dev, EMAC_FTR_460EX_PHY_CLK_FIX)) { 371 + if (dev->phy_address == 0xffffffff && 372 + dev->phy_map == 0xffffffff) { 373 + /* No PHY: select internal loop clock before reset */ 374 + dcri_clrset(SDR0, SDR0_ETH_CFG, 375 + 0, SDR0_ETH_CFG_ECS << dev->cell_index); 376 + } else { 377 + /* PHY present: select external clock before reset */ 378 + dcri_clrset(SDR0, SDR0_ETH_CFG, 379 + SDR0_ETH_CFG_ECS << dev->cell_index, 0); 380 + } 381 + } 366 382 #endif 367 383 368 384 out_be32(&p->mr0, EMAC_MR0_SRST); ··· 386 370 --n; 387 371 388 372 #ifdef CONFIG_PPC_DCR_NATIVE 389 - /* Enable external clock source */ 390 - if (emac_has_feature(dev, EMAC_FTR_460EX_PHY_CLK_FIX)) 391 - dcri_clrset(SDR0, SDR0_ETH_CFG, 392 - SDR0_ETH_CFG_ECS << dev->cell_index, 0); 373 + if (emac_has_feature(dev, EMAC_FTR_460EX_PHY_CLK_FIX)) { 374 + if (dev->phy_address == 0xffffffff && 375 + dev->phy_map == 0xffffffff) { 376 + /* No PHY: restore external clock source after reset */ 377 + dcri_clrset(SDR0, SDR0_ETH_CFG, 378 + SDR0_ETH_CFG_ECS << dev->cell_index, 0); 379 + } 380 + } 393 381 #endif 394 382 395 383 if (n) {
+1 -1
drivers/net/ethernet/mellanox/mlx4/en_resources.c
··· 60 60 context->pri_path.sched_queue = 0x83 | (priv->port - 1) << 6; 61 61 if (user_prio >= 0) { 62 62 context->pri_path.sched_queue |= user_prio << 3; 63 - context->pri_path.feup = 1 << 6; 63 + context->pri_path.feup = MLX4_FEUP_FORCE_ETH_UP; 64 64 } 65 65 context->pri_path.counter_index = 0xff; 66 66 context->cqn_send = cpu_to_be32(cqn);
+3 -1
drivers/net/ethernet/mellanox/mlx4/fw.c
··· 131 131 [2] = "RSS XOR Hash Function support", 132 132 [3] = "Device manage flow steering support", 133 133 [4] = "Automatic MAC reassignment support", 134 - [5] = "Time stamping support" 134 + [5] = "Time stamping support", 135 + [6] = "VST (control vlan insertion/stripping) support", 136 + [7] = "FSM (MAC anti-spoofing) support" 135 137 }; 136 138 int i; 137 139
+17 -12
drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
··· 372 372 if (MLX4_QP_ST_RC == qp_type) 373 373 return -EINVAL; 374 374 375 + /* force strip vlan by clear vsd */ 376 + qpc->param3 &= ~cpu_to_be32(MLX4_STRIP_VLAN); 377 + if (0 != vp_oper->state.default_vlan) { 378 + qpc->pri_path.vlan_control = 379 + MLX4_VLAN_CTRL_ETH_TX_BLOCK_TAGGED | 380 + MLX4_VLAN_CTRL_ETH_RX_BLOCK_PRIO_TAGGED | 381 + MLX4_VLAN_CTRL_ETH_RX_BLOCK_UNTAGGED; 382 + } else { /* priority tagged */ 383 + qpc->pri_path.vlan_control = 384 + MLX4_VLAN_CTRL_ETH_TX_BLOCK_TAGGED | 385 + MLX4_VLAN_CTRL_ETH_RX_BLOCK_TAGGED; 386 + } 387 + 388 + qpc->pri_path.fvl_rx |= MLX4_FVL_RX_FORCE_ETH_VLAN; 375 389 qpc->pri_path.vlan_index = vp_oper->vlan_idx; 376 - qpc->pri_path.fl = (1 << 6) | (1 << 2); /* set cv bit and hide_cqe_vlan bit*/ 377 - qpc->pri_path.feup |= 1 << 3; /* set fvl bit */ 390 + qpc->pri_path.fl |= MLX4_FL_CV | MLX4_FL_ETH_HIDE_CQE_VLAN; 391 + qpc->pri_path.feup |= MLX4_FEUP_FORCE_ETH_UP | MLX4_FVL_FORCE_ETH_VLAN; 378 392 qpc->pri_path.sched_queue &= 0xC7; 379 393 qpc->pri_path.sched_queue |= (vp_oper->state.default_qos) << 3; 380 - mlx4_dbg(dev, "qp %d port %d Q 0x%x set vlan to %d vidx %d feup %x fl %x\n", 381 - be32_to_cpu(qpc->local_qpn) & 0xffffff, port, 382 - (int)(qpc->pri_path.sched_queue), vp_oper->state.default_vlan, 383 - vp_oper->vlan_idx, (int)(qpc->pri_path.feup), 384 - (int)(qpc->pri_path.fl)); 385 394 } 386 395 if (vp_oper->state.spoofchk) { 387 - qpc->pri_path.feup |= 1 << 5; /* set fsm bit */; 396 + qpc->pri_path.feup |= MLX4_FSM_FORCE_ETH_SRC_MAC; 388 397 qpc->pri_path.grh_mylmc = (0x80 & qpc->pri_path.grh_mylmc) + vp_oper->mac_idx; 389 - mlx4_dbg(dev, "spoof qp %d port %d feup 0x%x, myLmc 0x%x mindx %d\n", 390 - be32_to_cpu(qpc->local_qpn) & 0xffffff, port, 391 - (int)qpc->pri_path.feup, (int)qpc->pri_path.grh_mylmc, 392 - vp_oper->mac_idx); 393 398 } 394 399 return 0; 395 400 }
+2
drivers/net/ethernet/qlogic/qlcnic/qlcnic.h
··· 429 429 430 430 u16 port_type; 431 431 u16 board_type; 432 + u16 supported_type; 432 433 433 434 u16 link_speed; 434 435 u16 link_duplex; ··· 1515 1514 void qlcnic_remove_diag_entries(struct qlcnic_adapter *adapter); 1516 1515 void qlcnic_82xx_add_sysfs(struct qlcnic_adapter *adapter); 1517 1516 void qlcnic_82xx_remove_sysfs(struct qlcnic_adapter *adapter); 1517 + int qlcnic_82xx_get_settings(struct qlcnic_adapter *, struct ethtool_cmd *); 1518 1518 1519 1519 int qlcnicvf_config_bridged_mode(struct qlcnic_adapter *, u32); 1520 1520 int qlcnicvf_config_led(struct qlcnic_adapter *, u32, u32);
+83 -12
drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c
··· 696 696 return 1; 697 697 } 698 698 699 - u32 qlcnic_83xx_mbx_poll(struct qlcnic_adapter *adapter) 699 + u32 qlcnic_83xx_mbx_poll(struct qlcnic_adapter *adapter, u32 *wait_time) 700 700 { 701 701 u32 data; 702 - unsigned long wait_time = 0; 703 702 struct qlcnic_hardware_context *ahw = adapter->ahw; 704 703 /* wait for mailbox completion */ 705 704 do { 706 705 data = QLCRDX(ahw, QLCNIC_FW_MBX_CTRL); 707 - if (++wait_time > QLCNIC_MBX_TIMEOUT) { 706 + if (++(*wait_time) > QLCNIC_MBX_TIMEOUT) { 708 707 data = QLCNIC_RCODE_TIMEOUT; 709 708 break; 710 709 } ··· 719 720 u16 opcode; 720 721 u8 mbx_err_code; 721 722 unsigned long flags; 722 - u32 rsp, mbx_val, fw_data, rsp_num, mbx_cmd; 723 723 struct qlcnic_hardware_context *ahw = adapter->ahw; 724 + u32 rsp, mbx_val, fw_data, rsp_num, mbx_cmd, wait_time = 0; 724 725 725 726 opcode = LSW(cmd->req.arg[0]); 726 727 if (!test_bit(QLC_83XX_MBX_READY, &adapter->ahw->idc.status)) { ··· 753 754 /* Signal FW about the impending command */ 754 755 QLCWRX(ahw, QLCNIC_HOST_MBX_CTRL, QLCNIC_SET_OWNER); 755 756 poll: 756 - rsp = qlcnic_83xx_mbx_poll(adapter); 757 + rsp = qlcnic_83xx_mbx_poll(adapter, &wait_time); 757 758 if (rsp != QLCNIC_RCODE_TIMEOUT) { 758 759 /* Get the FW response data */ 759 760 fw_data = readl(QLCNIC_MBX_FW(ahw, 0)); 760 761 if (fw_data & QLCNIC_MBX_ASYNC_EVENT) { 761 762 __qlcnic_83xx_process_aen(adapter); 762 - mbx_val = QLCRDX(ahw, QLCNIC_HOST_MBX_CTRL); 763 - if (mbx_val) 764 - goto poll; 763 + goto poll; 765 764 } 766 765 mbx_err_code = QLCNIC_MBX_STATUS(fw_data); 767 766 rsp_num = QLCNIC_MBX_NUM_REGS(fw_data); ··· 1273 1276 return err; 1274 1277 } 1275 1278 1276 - static int qlcnic_83xx_diag_alloc_res(struct net_device *netdev, int test) 1279 + static int qlcnic_83xx_diag_alloc_res(struct net_device *netdev, int test, 1280 + int num_sds_ring) 1277 1281 { 1278 1282 struct qlcnic_adapter *adapter = netdev_priv(netdev); 1279 1283 struct qlcnic_host_sds_ring *sds_ring; 1280 1284 struct qlcnic_host_rds_ring *rds_ring; 1285 + u16 adapter_state = adapter->is_up; 1281 1286 u8 ring; 1282 1287 int ret; 1283 1288 ··· 1303 1304 ret = qlcnic_fw_create_ctx(adapter); 1304 1305 if (ret) { 1305 1306 qlcnic_detach(adapter); 1307 + if (adapter_state == QLCNIC_ADAPTER_UP_MAGIC) { 1308 + adapter->max_sds_rings = num_sds_ring; 1309 + qlcnic_attach(adapter); 1310 + } 1306 1311 netif_device_attach(netdev); 1307 1312 return ret; 1308 1313 } ··· 1599 1596 if (test_and_set_bit(__QLCNIC_RESETTING, &adapter->state)) 1600 1597 return -EBUSY; 1601 1598 1602 - ret = qlcnic_83xx_diag_alloc_res(netdev, QLCNIC_LOOPBACK_TEST); 1599 + ret = qlcnic_83xx_diag_alloc_res(netdev, QLCNIC_LOOPBACK_TEST, 1600 + max_sds_rings); 1603 1601 if (ret) 1604 1602 goto fail_diag_alloc; 1605 1603 ··· 2834 2830 break; 2835 2831 } 2836 2832 config = cmd.rsp.arg[3]; 2833 + if (QLC_83XX_SFP_PRESENT(config)) { 2834 + switch (ahw->module_type) { 2835 + case LINKEVENT_MODULE_OPTICAL_UNKNOWN: 2836 + case LINKEVENT_MODULE_OPTICAL_SRLR: 2837 + case LINKEVENT_MODULE_OPTICAL_LRM: 2838 + case LINKEVENT_MODULE_OPTICAL_SFP_1G: 2839 + ahw->supported_type = PORT_FIBRE; 2840 + break; 2841 + case LINKEVENT_MODULE_TWINAX_UNSUPPORTED_CABLE: 2842 + case LINKEVENT_MODULE_TWINAX_UNSUPPORTED_CABLELEN: 2843 + case LINKEVENT_MODULE_TWINAX: 2844 + ahw->supported_type = PORT_TP; 2845 + break; 2846 + default: 2847 + ahw->supported_type = PORT_OTHER; 2848 + } 2849 + } 2837 2850 if (config & 1) 2838 2851 err = 1; 2839 2852 } ··· 2859 2838 return config; 2860 2839 } 2861 2840 2862 - int qlcnic_83xx_get_settings(struct qlcnic_adapter *adapter) 2841 + int qlcnic_83xx_get_settings(struct qlcnic_adapter *adapter, 2842 + struct ethtool_cmd *ecmd) 2863 2843 { 2864 2844 u32 config = 0; 2865 2845 int status = 0; ··· 2873 2851 ahw->module_type = QLC_83XX_SFP_MODULE_TYPE(config); 2874 2852 /* hard code until there is a way to get it from flash */ 2875 2853 ahw->board_type = QLCNIC_BRDTYPE_83XX_10G; 2854 + 2855 + if (netif_running(adapter->netdev) && ahw->has_link_events) { 2856 + ethtool_cmd_speed_set(ecmd, ahw->link_speed); 2857 + ecmd->duplex = ahw->link_duplex; 2858 + ecmd->autoneg = ahw->link_autoneg; 2859 + } else { 2860 + ethtool_cmd_speed_set(ecmd, SPEED_UNKNOWN); 2861 + ecmd->duplex = DUPLEX_UNKNOWN; 2862 + ecmd->autoneg = AUTONEG_DISABLE; 2863 + } 2864 + 2865 + if (ahw->port_type == QLCNIC_XGBE) { 2866 + ecmd->supported = SUPPORTED_1000baseT_Full; 2867 + ecmd->advertising = ADVERTISED_1000baseT_Full; 2868 + } else { 2869 + ecmd->supported = (SUPPORTED_10baseT_Half | 2870 + SUPPORTED_10baseT_Full | 2871 + SUPPORTED_100baseT_Half | 2872 + SUPPORTED_100baseT_Full | 2873 + SUPPORTED_1000baseT_Half | 2874 + SUPPORTED_1000baseT_Full); 2875 + ecmd->advertising = (ADVERTISED_100baseT_Half | 2876 + ADVERTISED_100baseT_Full | 2877 + ADVERTISED_1000baseT_Half | 2878 + ADVERTISED_1000baseT_Full); 2879 + } 2880 + 2881 + switch (ahw->supported_type) { 2882 + case PORT_FIBRE: 2883 + ecmd->supported |= SUPPORTED_FIBRE; 2884 + ecmd->advertising |= ADVERTISED_FIBRE; 2885 + ecmd->port = PORT_FIBRE; 2886 + ecmd->transceiver = XCVR_EXTERNAL; 2887 + break; 2888 + case PORT_TP: 2889 + ecmd->supported |= SUPPORTED_TP; 2890 + ecmd->advertising |= ADVERTISED_TP; 2891 + ecmd->port = PORT_TP; 2892 + ecmd->transceiver = XCVR_INTERNAL; 2893 + break; 2894 + default: 2895 + ecmd->supported |= SUPPORTED_FIBRE; 2896 + ecmd->advertising |= ADVERTISED_FIBRE; 2897 + ecmd->port = PORT_OTHER; 2898 + ecmd->transceiver = XCVR_EXTERNAL; 2899 + break; 2900 + } 2901 + ecmd->phy_address = ahw->physical_port; 2876 2902 return status; 2877 2903 } 2878 2904 ··· 3116 3046 if (test_and_set_bit(__QLCNIC_RESETTING, &adapter->state)) 3117 3047 return -EIO; 3118 3048 3119 - ret = qlcnic_83xx_diag_alloc_res(netdev, QLCNIC_INTERRUPT_TEST); 3049 + ret = qlcnic_83xx_diag_alloc_res(netdev, QLCNIC_INTERRUPT_TEST, 3050 + max_sds_rings); 3120 3051 if (ret) 3121 3052 goto fail_diag_irq; 3122 3053
+2 -2
drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.h
··· 603 603 604 604 void qlcnic_83xx_get_minidump_template(struct qlcnic_adapter *); 605 605 void qlcnic_83xx_get_stats(struct qlcnic_adapter *adapter, u64 *data); 606 - int qlcnic_83xx_get_settings(struct qlcnic_adapter *); 606 + int qlcnic_83xx_get_settings(struct qlcnic_adapter *, struct ethtool_cmd *); 607 607 int qlcnic_83xx_set_settings(struct qlcnic_adapter *, struct ethtool_cmd *); 608 608 void qlcnic_83xx_get_pauseparam(struct qlcnic_adapter *, 609 609 struct ethtool_pauseparam *); ··· 620 620 int qlcnic_83xx_enable_flash_write(struct qlcnic_adapter *); 621 621 int qlcnic_83xx_disable_flash_write(struct qlcnic_adapter *); 622 622 u32 qlcnic_83xx_mac_rcode(struct qlcnic_adapter *); 623 - u32 qlcnic_83xx_mbx_poll(struct qlcnic_adapter *); 623 + u32 qlcnic_83xx_mbx_poll(struct qlcnic_adapter *, u32 *); 624 624 void qlcnic_83xx_enable_mbx_poll(struct qlcnic_adapter *); 625 625 void qlcnic_83xx_disable_mbx_poll(struct qlcnic_adapter *); 626 626 #endif
+13 -9
drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
··· 435 435 } 436 436 done: 437 437 netif_device_attach(netdev); 438 - if (netif_running(netdev)) { 439 - netif_carrier_on(netdev); 440 - netif_wake_queue(netdev); 441 - } 442 438 } 443 439 444 440 static int qlcnic_83xx_idc_enter_failed_state(struct qlcnic_adapter *adapter, ··· 638 642 639 643 static void qlcnic_83xx_idc_update_idc_params(struct qlcnic_adapter *adapter) 640 644 { 645 + struct qlcnic_hardware_context *ahw = adapter->ahw; 646 + 641 647 qlcnic_83xx_idc_update_drv_presence_reg(adapter, 1, 1); 642 - clear_bit(__QLCNIC_RESETTING, &adapter->state); 643 648 set_bit(QLC_83XX_MBX_READY, &adapter->ahw->idc.status); 644 649 qlcnic_83xx_idc_update_audit_reg(adapter, 0, 1); 645 650 set_bit(QLC_83XX_MODULE_LOADED, &adapter->ahw->idc.status); 646 - adapter->ahw->idc.quiesce_req = 0; 647 - adapter->ahw->idc.delay = QLC_83XX_IDC_FW_POLL_DELAY; 648 - adapter->ahw->idc.err_code = 0; 649 - adapter->ahw->idc.collect_dump = 0; 651 + 652 + ahw->idc.quiesce_req = 0; 653 + ahw->idc.delay = QLC_83XX_IDC_FW_POLL_DELAY; 654 + ahw->idc.err_code = 0; 655 + ahw->idc.collect_dump = 0; 656 + ahw->reset_context = 0; 657 + adapter->tx_timeo_cnt = 0; 658 + 659 + clear_bit(__QLCNIC_RESETTING, &adapter->state); 650 660 } 651 661 652 662 /** ··· 853 851 /* Check for soft reset request */ 854 852 if (ahw->reset_context && 855 853 !(val & QLC_83XX_IDC_DISABLE_FW_RESET_RECOVERY)) { 854 + adapter->ahw->reset_context = 0; 856 855 qlcnic_83xx_idc_tx_soft_reset(adapter); 857 856 return ret; 858 857 } ··· 917 914 static int qlcnic_83xx_idc_failed_state(struct qlcnic_adapter *adapter) 918 915 { 919 916 dev_err(&adapter->pdev->dev, "%s: please restart!!\n", __func__); 917 + clear_bit(__QLCNIC_RESETTING, &adapter->state); 920 918 adapter->ahw->idc.err_code = -EIO; 921 919 922 920 return 0;
+27 -27
drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c
··· 131 131 "ctx_lro_pkt_cnt", 132 132 "ctx_ip_csum_error", 133 133 "ctx_rx_pkts_wo_ctx", 134 - "ctx_rx_pkts_dropped_wo_sts", 134 + "ctx_rx_pkts_drop_wo_sds_on_card", 135 + "ctx_rx_pkts_drop_wo_sds_on_host", 135 136 "ctx_rx_osized_pkts", 136 137 "ctx_rx_pkts_dropped_wo_rds", 137 138 "ctx_rx_unexpected_mcast_pkts", 138 139 "ctx_invalid_mac_address", 139 - "ctx_rx_rds_ring_prim_attemoted", 140 + "ctx_rx_rds_ring_prim_attempted", 140 141 "ctx_rx_rds_ring_prim_success", 141 142 "ctx_num_lro_flows_added", 142 143 "ctx_num_lro_flows_removed", ··· 252 251 qlcnic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd) 253 252 { 254 253 struct qlcnic_adapter *adapter = netdev_priv(dev); 254 + 255 + if (qlcnic_82xx_check(adapter)) 256 + return qlcnic_82xx_get_settings(adapter, ecmd); 257 + else if (qlcnic_83xx_check(adapter)) 258 + return qlcnic_83xx_get_settings(adapter, ecmd); 259 + 260 + return -EIO; 261 + } 262 + 263 + int qlcnic_82xx_get_settings(struct qlcnic_adapter *adapter, 264 + struct ethtool_cmd *ecmd) 265 + { 255 266 struct qlcnic_hardware_context *ahw = adapter->ahw; 256 267 u32 speed, reg; 257 268 int check_sfp_module = 0; ··· 289 276 290 277 } else if (adapter->ahw->port_type == QLCNIC_XGBE) { 291 278 u32 val = 0; 292 - if (qlcnic_83xx_check(adapter)) 293 - qlcnic_83xx_get_settings(adapter); 294 - else 295 - val = QLCRD32(adapter, QLCNIC_PORT_MODE_ADDR); 279 + val = QLCRD32(adapter, QLCNIC_PORT_MODE_ADDR); 296 280 297 281 if (val == QLCNIC_PORT_MODE_802_3_AP) { 298 282 ecmd->supported = SUPPORTED_1000baseT_Full; ··· 299 289 ecmd->advertising = ADVERTISED_10000baseT_Full; 300 290 } 301 291 302 - if (netif_running(dev) && adapter->ahw->has_link_events) { 303 - if (qlcnic_82xx_check(adapter)) { 304 - reg = QLCRD32(adapter, 305 - P3P_LINK_SPEED_REG(pcifn)); 306 - speed = P3P_LINK_SPEED_VAL(pcifn, reg); 307 - ahw->link_speed = speed * P3P_LINK_SPEED_MHZ; 308 - } 309 - ethtool_cmd_speed_set(ecmd, adapter->ahw->link_speed); 310 - ecmd->autoneg = adapter->ahw->link_autoneg; 311 - ecmd->duplex = adapter->ahw->link_duplex; 292 + if (netif_running(adapter->netdev) && ahw->has_link_events) { 293 + reg = QLCRD32(adapter, P3P_LINK_SPEED_REG(pcifn)); 294 + speed = P3P_LINK_SPEED_VAL(pcifn, reg); 295 + ahw->link_speed = speed * P3P_LINK_SPEED_MHZ; 296 + ethtool_cmd_speed_set(ecmd, ahw->link_speed); 297 + ecmd->autoneg = ahw->link_autoneg; 298 + ecmd->duplex = ahw->link_duplex; 312 299 goto skip; 313 300 } 314 301 ··· 347 340 case QLCNIC_BRDTYPE_P3P_10G_SFP_QT: 348 341 ecmd->advertising |= ADVERTISED_TP; 349 342 ecmd->supported |= SUPPORTED_TP; 350 - check_sfp_module = netif_running(dev) && 351 - adapter->ahw->has_link_events; 343 + check_sfp_module = netif_running(adapter->netdev) && 344 + ahw->has_link_events; 352 345 case QLCNIC_BRDTYPE_P3P_10G_XFP: 353 346 ecmd->supported |= SUPPORTED_FIBRE; 354 347 ecmd->advertising |= ADVERTISED_FIBRE; ··· 362 355 ecmd->advertising |= 363 356 (ADVERTISED_FIBRE | ADVERTISED_TP); 364 357 ecmd->port = PORT_FIBRE; 365 - check_sfp_module = netif_running(dev) && 366 - adapter->ahw->has_link_events; 358 + check_sfp_module = netif_running(adapter->netdev) && 359 + ahw->has_link_events; 367 360 } else { 368 361 ecmd->autoneg = AUTONEG_ENABLE; 369 362 ecmd->supported |= (SUPPORTED_TP | SUPPORTED_Autoneg); ··· 371 364 (ADVERTISED_TP | ADVERTISED_Autoneg); 372 365 ecmd->port = PORT_TP; 373 366 } 374 - break; 375 - case QLCNIC_BRDTYPE_83XX_10G: 376 - ecmd->autoneg = AUTONEG_DISABLE; 377 - ecmd->supported |= (SUPPORTED_FIBRE | SUPPORTED_TP); 378 - ecmd->advertising |= (ADVERTISED_FIBRE | ADVERTISED_TP); 379 - ecmd->port = PORT_FIBRE; 380 - check_sfp_module = netif_running(dev) && ahw->has_link_events; 381 367 break; 382 368 default: 383 369 dev_err(&adapter->pdev->dev, "Unsupported board model %d\n",
+1 -1
drivers/net/ethernet/qlogic/qlcnic/qlcnic_hw.h
··· 134 134 135 135 #define QLCNIC_SET_OWNER 1 136 136 #define QLCNIC_CLR_OWNER 0 137 - #define QLCNIC_MBX_TIMEOUT 10000 137 + #define QLCNIC_MBX_TIMEOUT 5000 138 138 139 139 #define QLCNIC_MBX_RSP_OK 1 140 140 #define QLCNIC_MBX_PORT_RSP_OK 0x1a
+36 -10
drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
··· 37 37 "Mac Filter (0=learning is disabled, 1=Driver learning is enabled, 2=FDB learning is enabled)"); 38 38 39 39 int qlcnic_use_msi = 1; 40 - MODULE_PARM_DESC(use_msi, "MSI interrupt (0=disabled, 1=enabled"); 40 + MODULE_PARM_DESC(use_msi, "MSI interrupt (0=disabled, 1=enabled)"); 41 41 module_param_named(use_msi, qlcnic_use_msi, int, 0444); 42 42 43 43 int qlcnic_use_msi_x = 1; 44 - MODULE_PARM_DESC(use_msi_x, "MSI-X interrupt (0=disabled, 1=enabled"); 44 + MODULE_PARM_DESC(use_msi_x, "MSI-X interrupt (0=disabled, 1=enabled)"); 45 45 module_param_named(use_msi_x, qlcnic_use_msi_x, int, 0444); 46 46 47 47 int qlcnic_auto_fw_reset = 1; 48 - MODULE_PARM_DESC(auto_fw_reset, "Auto firmware reset (0=disabled, 1=enabled"); 48 + MODULE_PARM_DESC(auto_fw_reset, "Auto firmware reset (0=disabled, 1=enabled)"); 49 49 module_param_named(auto_fw_reset, qlcnic_auto_fw_reset, int, 0644); 50 50 51 51 int qlcnic_load_fw_file; 52 - MODULE_PARM_DESC(load_fw_file, "Load firmware from (0=flash, 1=file"); 52 + MODULE_PARM_DESC(load_fw_file, "Load firmware from (0=flash, 1=file)"); 53 53 module_param_named(load_fw_file, qlcnic_load_fw_file, int, 0444); 54 54 55 55 int qlcnic_config_npars; 56 56 module_param(qlcnic_config_npars, int, 0444); 57 - MODULE_PARM_DESC(qlcnic_config_npars, "Configure NPARs (0=disabled, 1=enabled"); 57 + MODULE_PARM_DESC(qlcnic_config_npars, "Configure NPARs (0=disabled, 1=enabled)"); 58 58 59 59 static int qlcnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent); 60 60 static void qlcnic_remove(struct pci_dev *pdev); ··· 308 308 return 0; 309 309 } 310 310 311 + static void qlcnic_delete_adapter_mac(struct qlcnic_adapter *adapter) 312 + { 313 + struct qlcnic_mac_list_s *cur; 314 + struct list_head *head; 315 + 316 + list_for_each(head, &adapter->mac_list) { 317 + cur = list_entry(head, struct qlcnic_mac_list_s, list); 318 + if (!memcmp(adapter->mac_addr, cur->mac_addr, ETH_ALEN)) { 319 + qlcnic_sre_macaddr_change(adapter, cur->mac_addr, 320 + 0, QLCNIC_MAC_DEL); 321 + list_del(&cur->list); 322 + kfree(cur); 323 + return; 324 + } 325 + } 326 + } 327 + 311 328 static int qlcnic_set_mac(struct net_device *netdev, void *p) 312 329 { 313 330 struct qlcnic_adapter *adapter = netdev_priv(netdev); ··· 339 322 if (!is_valid_ether_addr(addr->sa_data)) 340 323 return -EINVAL; 341 324 325 + if (!memcmp(adapter->mac_addr, addr->sa_data, ETH_ALEN)) 326 + return 0; 327 + 342 328 if (test_bit(__QLCNIC_DEV_UP, &adapter->state)) { 343 329 netif_device_detach(netdev); 344 330 qlcnic_napi_disable(adapter); 345 331 } 346 332 333 + qlcnic_delete_adapter_mac(adapter); 347 334 memcpy(adapter->mac_addr, addr->sa_data, netdev->addr_len); 348 335 memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len); 349 336 qlcnic_set_multi(adapter->netdev); ··· 2502 2481 if (test_bit(__QLCNIC_RESETTING, &adapter->state)) 2503 2482 return; 2504 2483 2505 - dev_err(&netdev->dev, "transmit timeout, resetting.\n"); 2506 - 2507 - if (++adapter->tx_timeo_cnt >= QLCNIC_MAX_TX_TIMEOUTS) 2508 - adapter->need_fw_reset = 1; 2509 - else 2484 + if (++adapter->tx_timeo_cnt >= QLCNIC_MAX_TX_TIMEOUTS) { 2485 + netdev_info(netdev, "Tx timeout, reset the adapter.\n"); 2486 + if (qlcnic_82xx_check(adapter)) 2487 + adapter->need_fw_reset = 1; 2488 + else if (qlcnic_83xx_check(adapter)) 2489 + qlcnic_83xx_idc_request_reset(adapter, 2490 + QLCNIC_FORCE_FW_DUMP_KEY); 2491 + } else { 2492 + netdev_info(netdev, "Tx timeout, reset adapter context.\n"); 2510 2493 adapter->ahw->reset_context = 1; 2494 + } 2511 2495 } 2512 2496 2513 2497 static struct net_device_stats *qlcnic_get_stats(struct net_device *netdev)
+3 -5
drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c
··· 280 280 static int qlcnic_sriov_post_bc_msg(struct qlcnic_adapter *adapter, u32 *hdr, 281 281 u32 *pay, u8 pci_func, u8 size) 282 282 { 283 + u32 rsp, mbx_val, fw_data, rsp_num, mbx_cmd, val, wait_time = 0; 283 284 struct qlcnic_hardware_context *ahw = adapter->ahw; 284 285 unsigned long flags; 285 - u32 rsp, mbx_val, fw_data, rsp_num, mbx_cmd, val; 286 286 u16 opcode; 287 287 u8 mbx_err_code; 288 288 int i, j; ··· 330 330 * assume something is wrong. 331 331 */ 332 332 poll: 333 - rsp = qlcnic_83xx_mbx_poll(adapter); 333 + rsp = qlcnic_83xx_mbx_poll(adapter, &wait_time); 334 334 if (rsp != QLCNIC_RCODE_TIMEOUT) { 335 335 /* Get the FW response data */ 336 336 fw_data = readl(QLCNIC_MBX_FW(ahw, 0)); 337 337 if (fw_data & QLCNIC_MBX_ASYNC_EVENT) { 338 338 __qlcnic_83xx_process_aen(adapter); 339 - mbx_val = QLCRDX(ahw, QLCNIC_HOST_MBX_CTRL); 340 - if (mbx_val) 341 - goto poll; 339 + goto poll; 342 340 } 343 341 mbx_err_code = QLCNIC_MBX_STATUS(fw_data); 344 342 rsp_num = QLCNIC_MBX_NUM_REGS(fw_data);
-3
drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_pf.c
··· 1133 1133 if ((cmd->req.arg[1] >> 16) != vf->rx_ctx_id) 1134 1134 return -EINVAL; 1135 1135 1136 - if (!(cmd->req.arg[1] & BIT_8)) 1137 - return -EINVAL; 1138 - 1139 1136 return 0; 1140 1137 } 1141 1138
+7
drivers/net/ethernet/qlogic/qlge/qlge_main.c
··· 1106 1106 if (pci_dma_mapping_error(qdev->pdev, map)) { 1107 1107 __free_pages(rx_ring->pg_chunk.page, 1108 1108 qdev->lbq_buf_order); 1109 + rx_ring->pg_chunk.page = NULL; 1109 1110 netif_err(qdev, drv, qdev->ndev, 1110 1111 "PCI mapping failed.\n"); 1111 1112 return -ENOMEM; ··· 2777 2776 if (++curr_idx == rx_ring->lbq_len) 2778 2777 curr_idx = 0; 2779 2778 2779 + } 2780 + if (rx_ring->pg_chunk.page) { 2781 + pci_unmap_page(qdev->pdev, rx_ring->pg_chunk.map, 2782 + ql_lbq_block_size(qdev), PCI_DMA_FROMDEVICE); 2783 + put_page(rx_ring->pg_chunk.page); 2784 + rx_ring->pg_chunk.page = NULL; 2780 2785 } 2781 2786 } 2782 2787
-5
drivers/net/ethernet/renesas/sh_eth.c
··· 2745 2745 if (mdp->cd->tsu) { 2746 2746 struct resource *rtsu; 2747 2747 rtsu = platform_get_resource(pdev, IORESOURCE_MEM, 1); 2748 - if (!rtsu) { 2749 - dev_err(&pdev->dev, "Not found TSU resource\n"); 2750 - ret = -ENODEV; 2751 - goto out_release; 2752 - } 2753 2748 mdp->tsu_addr = devm_ioremap_resource(&pdev->dev, rtsu); 2754 2749 if (IS_ERR(mdp->tsu_addr)) { 2755 2750 ret = PTR_ERR(mdp->tsu_addr);
+1 -1
drivers/net/ethernet/stmicro/stmmac/Kconfig
··· 1 1 config STMMAC_ETH 2 2 tristate "STMicroelectronics 10/100/1000 Ethernet driver" 3 - depends on HAS_IOMEM 3 + depends on HAS_IOMEM && HAS_DMA 4 4 select NET_CORE 5 5 select MII 6 6 select PHYLIB
+4 -3
drivers/net/macvlan.c
··· 229 229 } 230 230 231 231 if (port->passthru) 232 - vlan = list_first_entry(&port->vlans, struct macvlan_dev, list); 232 + vlan = list_first_or_null_rcu(&port->vlans, 233 + struct macvlan_dev, list); 233 234 else 234 235 vlan = macvlan_hash_lookup(port, eth->h_dest); 235 236 if (vlan == NULL) ··· 815 814 if (err < 0) 816 815 goto upper_dev_unlink; 817 816 818 - list_add_tail(&vlan->list, &port->vlans); 817 + list_add_tail_rcu(&vlan->list, &port->vlans); 819 818 netif_stacked_transfer_operstate(lowerdev, dev); 820 819 821 820 return 0; ··· 843 842 { 844 843 struct macvlan_dev *vlan = netdev_priv(dev); 845 844 846 - list_del(&vlan->list); 845 + list_del_rcu(&vlan->list); 847 846 unregister_netdevice_queue(dev, head); 848 847 netdev_upper_dev_unlink(vlan->lowerdev, dev); 849 848 }
+2
drivers/net/ntb_netdev.c
··· 375 375 if (dev == NULL) 376 376 return; 377 377 378 + list_del(&dev->list); 379 + 378 380 ndev = dev->ndev; 379 381 380 382 unregister_netdev(ndev);
+1 -1
drivers/net/virtio_net.c
··· 28 28 #include <linux/slab.h> 29 29 #include <linux/cpu.h> 30 30 31 - static int napi_weight = 128; 31 + static int napi_weight = NAPI_POLL_WEIGHT; 32 32 module_param(napi_weight, int, 0444); 33 33 34 34 static bool csum = true, gso = true;
+5
drivers/net/wireless/ath/ath5k/base.c
··· 2369 2369 int i; 2370 2370 bool needreset = false; 2371 2371 2372 + if (!test_bit(ATH_STAT_STARTED, ah->status)) 2373 + return; 2374 + 2372 2375 mutex_lock(&ah->lock); 2373 2376 2374 2377 for (i = 0; i < ARRAY_SIZE(ah->txqs); i++) { ··· 2679 2676 mmiowb(); 2680 2677 mutex_unlock(&ah->lock); 2681 2678 2679 + set_bit(ATH_STAT_STARTED, ah->status); 2682 2680 ieee80211_queue_delayed_work(ah->hw, &ah->tx_complete_work, 2683 2681 msecs_to_jiffies(ATH5K_TX_COMPLETE_POLL_INT)); 2684 2682 ··· 2741 2737 2742 2738 ath5k_stop_tasklets(ah); 2743 2739 2740 + clear_bit(ATH_STAT_STARTED, ah->status); 2744 2741 cancel_delayed_work_sync(&ah->tx_complete_work); 2745 2742 2746 2743 if (!ath5k_modparam_no_hw_rfkill_switch)
+1 -1
drivers/net/wireless/ath/ath9k/Kconfig
··· 17 17 18 18 config ATH9K 19 19 tristate "Atheros 802.11n wireless cards support" 20 - depends on MAC80211 20 + depends on MAC80211 && HAS_DMA 21 21 select ATH9K_HW 22 22 select MAC80211_LEDS 23 23 select LEDS_CLASS
+70 -68
drivers/net/wireless/ath/ath9k/ar9565_1p0_initvals.h
··· 233 233 {0x00009d10, 0x01834061}, 234 234 {0x00009d14, 0x00c00400}, 235 235 {0x00009d18, 0x00000000}, 236 - {0x00009e08, 0x0078230c}, 237 - {0x00009e24, 0x990bb515}, 238 - {0x00009e28, 0x126f0000}, 236 + {0x00009e08, 0x0038230c}, 237 + {0x00009e24, 0x9907b515}, 238 + {0x00009e28, 0x126f0600}, 239 239 {0x00009e30, 0x06336f77}, 240 240 {0x00009e34, 0x6af6532f}, 241 241 {0x00009e38, 0x0cc80c00}, ··· 337 337 338 338 static const u32 ar9565_1p0_baseband_postamble[][5] = { 339 339 /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */ 340 - {0x00009810, 0xd00a8005, 0xd00a8005, 0xd00a8005, 0xd00a800d}, 340 + {0x00009810, 0xd00a8005, 0xd00a8005, 0xd00a8005, 0xd00a8009}, 341 341 {0x00009820, 0x206a022e, 0x206a022e, 0x206a012e, 0x206a01ae}, 342 342 {0x00009824, 0x5ac640d0, 0x5ac640d0, 0x5ac640d0, 0x63c640da}, 343 343 {0x00009828, 0x06903081, 0x06903081, 0x06903881, 0x09143c81}, ··· 345 345 {0x00009830, 0x0000059c, 0x0000059c, 0x0000059c, 0x0000059c}, 346 346 {0x00009c00, 0x000000c4, 0x000000c4, 0x000000c4, 0x000000c4}, 347 347 {0x00009e00, 0x0372111a, 0x0372111a, 0x037216a0, 0x037216a0}, 348 - {0x00009e04, 0x00802020, 0x00802020, 0x00802020, 0x00802020}, 349 - {0x00009e0c, 0x6c4000e2, 0x6d4000e2, 0x6d4000e2, 0x6c4000d8}, 350 - {0x00009e10, 0x7ec88d2e, 0x7ec88d2e, 0x7ec84d2e, 0x7ec86d2e}, 348 + {0x00009e04, 0x00802020, 0x00802020, 0x00142020, 0x00142020}, 349 + {0x00009e0c, 0x6c4000e2, 0x6d4000e2, 0x6d4000e2, 0x6c4000e2}, 350 + {0x00009e10, 0x7ec88d2e, 0x7ec88d2e, 0x7ec84d2e, 0x7ec84d2e}, 351 351 {0x00009e14, 0x37b95d5e, 0x37b9605e, 0x3379605e, 0x33795d5e}, 352 352 {0x00009e18, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, 353 353 {0x00009e1c, 0x0001cf9c, 0x0001cf9c, 0x00021f9c, 0x00021f9c}, ··· 450 450 451 451 static const u32 ar9565_1p0_Common_rx_gain_table[][2] = { 452 452 /* Addr allmodes */ 453 + {0x00004050, 0x00300300}, 454 + {0x0000406c, 0x00100000}, 453 455 {0x0000a000, 0x00010000}, 454 456 {0x0000a004, 0x00030002}, 455 457 {0x0000a008, 0x00050004}, ··· 500 498 {0x0000a0b4, 0x00000000}, 501 499 {0x0000a0b8, 0x00000000}, 502 500 {0x0000a0bc, 0x00000000}, 503 - {0x0000a0c0, 0x001f0000}, 504 - {0x0000a0c4, 0x01000101}, 505 - {0x0000a0c8, 0x011e011f}, 506 - {0x0000a0cc, 0x011c011d}, 507 - {0x0000a0d0, 0x02030204}, 508 - {0x0000a0d4, 0x02010202}, 509 - {0x0000a0d8, 0x021f0200}, 510 - {0x0000a0dc, 0x0302021e}, 511 - {0x0000a0e0, 0x03000301}, 512 - {0x0000a0e4, 0x031e031f}, 513 - {0x0000a0e8, 0x0402031d}, 514 - {0x0000a0ec, 0x04000401}, 515 - {0x0000a0f0, 0x041e041f}, 516 - {0x0000a0f4, 0x0502041d}, 517 - {0x0000a0f8, 0x05000501}, 518 - {0x0000a0fc, 0x051e051f}, 519 - {0x0000a100, 0x06010602}, 520 - {0x0000a104, 0x061f0600}, 521 - {0x0000a108, 0x061d061e}, 522 - {0x0000a10c, 0x07020703}, 523 - {0x0000a110, 0x07000701}, 501 + {0x0000a0c0, 0x00bf00a0}, 502 + {0x0000a0c4, 0x11a011a1}, 503 + {0x0000a0c8, 0x11be11bf}, 504 + {0x0000a0cc, 0x11bc11bd}, 505 + {0x0000a0d0, 0x22632264}, 506 + {0x0000a0d4, 0x22612262}, 507 + {0x0000a0d8, 0x227f2260}, 508 + {0x0000a0dc, 0x4322227e}, 509 + {0x0000a0e0, 0x43204321}, 510 + {0x0000a0e4, 0x433e433f}, 511 + {0x0000a0e8, 0x4462433d}, 512 + {0x0000a0ec, 0x44604461}, 513 + {0x0000a0f0, 0x447e447f}, 514 + {0x0000a0f4, 0x5582447d}, 515 + {0x0000a0f8, 0x55805581}, 516 + {0x0000a0fc, 0x559e559f}, 517 + {0x0000a100, 0x66816682}, 518 + {0x0000a104, 0x669f6680}, 519 + {0x0000a108, 0x669d669e}, 520 + {0x0000a10c, 0x77627763}, 521 + {0x0000a110, 0x77607761}, 524 522 {0x0000a114, 0x00000000}, 525 523 {0x0000a118, 0x00000000}, 526 524 {0x0000a11c, 0x00000000}, ··· 532 530 {0x0000a134, 0x00000000}, 533 531 {0x0000a138, 0x00000000}, 534 532 {0x0000a13c, 0x00000000}, 535 - {0x0000a140, 0x001f0000}, 536 - {0x0000a144, 0x01000101}, 537 - {0x0000a148, 0x011e011f}, 538 - {0x0000a14c, 0x011c011d}, 539 - {0x0000a150, 0x02030204}, 540 - {0x0000a154, 0x02010202}, 541 - {0x0000a158, 0x021f0200}, 542 - {0x0000a15c, 0x0302021e}, 543 - {0x0000a160, 0x03000301}, 544 - {0x0000a164, 0x031e031f}, 545 - {0x0000a168, 0x0402031d}, 546 - {0x0000a16c, 0x04000401}, 547 - {0x0000a170, 0x041e041f}, 548 - {0x0000a174, 0x0502041d}, 549 - {0x0000a178, 0x05000501}, 550 - {0x0000a17c, 0x051e051f}, 551 - {0x0000a180, 0x06010602}, 552 - {0x0000a184, 0x061f0600}, 553 - {0x0000a188, 0x061d061e}, 554 - {0x0000a18c, 0x07020703}, 555 - {0x0000a190, 0x07000701}, 533 + {0x0000a140, 0x00bf00a0}, 534 + {0x0000a144, 0x11a011a1}, 535 + {0x0000a148, 0x11be11bf}, 536 + {0x0000a14c, 0x11bc11bd}, 537 + {0x0000a150, 0x22632264}, 538 + {0x0000a154, 0x22612262}, 539 + {0x0000a158, 0x227f2260}, 540 + {0x0000a15c, 0x4322227e}, 541 + {0x0000a160, 0x43204321}, 542 + {0x0000a164, 0x433e433f}, 543 + {0x0000a168, 0x4462433d}, 544 + {0x0000a16c, 0x44604461}, 545 + {0x0000a170, 0x447e447f}, 546 + {0x0000a174, 0x5582447d}, 547 + {0x0000a178, 0x55805581}, 548 + {0x0000a17c, 0x559e559f}, 549 + {0x0000a180, 0x66816682}, 550 + {0x0000a184, 0x669f6680}, 551 + {0x0000a188, 0x669d669e}, 552 + {0x0000a18c, 0x77e677e7}, 553 + {0x0000a190, 0x77e477e5}, 556 554 {0x0000a194, 0x00000000}, 557 555 {0x0000a198, 0x00000000}, 558 556 {0x0000a19c, 0x00000000}, ··· 772 770 773 771 static const u32 ar9565_1p0_pciephy_clkreq_disable_L1[][2] = { 774 772 /* Addr allmodes */ 775 - {0x00018c00, 0x18213ede}, 773 + {0x00018c00, 0x18212ede}, 776 774 {0x00018c04, 0x000801d8}, 777 775 {0x00018c08, 0x0003780c}, 778 776 }; ··· 891 889 {0x0000a180, 0x66816682}, 892 890 {0x0000a184, 0x669f6680}, 893 891 {0x0000a188, 0x669d669e}, 894 - {0x0000a18c, 0x77627763}, 895 - {0x0000a190, 0x77607761}, 892 + {0x0000a18c, 0x77e677e7}, 893 + {0x0000a190, 0x77e477e5}, 896 894 {0x0000a194, 0x00000000}, 897 895 {0x0000a198, 0x00000000}, 898 896 {0x0000a19c, 0x00000000}, ··· 1116 1114 {0x0000a2e0, 0xffecec00, 0xffecec00, 0xfd339c84, 0xfd339c84}, 1117 1115 {0x0000a2e4, 0xfc0f0000, 0xfc0f0000, 0xfec3e000, 0xfec3e000}, 1118 1116 {0x0000a2e8, 0xfc100000, 0xfc100000, 0xfffc0000, 0xfffc0000}, 1119 - {0x0000a410, 0x000050d9, 0x000050d9, 0x000050d9, 0x000050d9}, 1117 + {0x0000a410, 0x000050d9, 0x000050d9, 0x000050df, 0x000050df}, 1120 1118 {0x0000a500, 0x00002220, 0x00002220, 0x00000000, 0x00000000}, 1121 1119 {0x0000a504, 0x06002223, 0x06002223, 0x04000002, 0x04000002}, 1122 1120 {0x0000a508, 0x0b022220, 0x0b022220, 0x08000004, 0x08000004}, ··· 1142 1140 {0x0000a558, 0x69027f56, 0x69027f56, 0x53001ce5, 0x53001ce5}, 1143 1141 {0x0000a55c, 0x6d029f56, 0x6d029f56, 0x57001ce9, 0x57001ce9}, 1144 1142 {0x0000a560, 0x73049f56, 0x73049f56, 0x5b001ceb, 0x5b001ceb}, 1145 - {0x0000a564, 0x7804ff56, 0x7804ff56, 0x5d001eec, 0x5d001eec}, 1146 - {0x0000a568, 0x7804ff56, 0x7804ff56, 0x5d001eec, 0x5d001eec}, 1147 - {0x0000a56c, 0x7804ff56, 0x7804ff56, 0x5d001eec, 0x5d001eec}, 1148 - {0x0000a570, 0x7804ff56, 0x7804ff56, 0x5d001eec, 0x5d001eec}, 1149 - {0x0000a574, 0x7804ff56, 0x7804ff56, 0x5d001eec, 0x5d001eec}, 1150 - {0x0000a578, 0x7804ff56, 0x7804ff56, 0x5d001eec, 0x5d001eec}, 1151 - {0x0000a57c, 0x7804ff56, 0x7804ff56, 0x5d001eec, 0x5d001eec}, 1143 + {0x0000a564, 0x7804ff56, 0x7804ff56, 0x60001cf0, 0x60001cf0}, 1144 + {0x0000a568, 0x7804ff56, 0x7804ff56, 0x61001cf1, 0x61001cf1}, 1145 + {0x0000a56c, 0x7804ff56, 0x7804ff56, 0x62001cf2, 0x62001cf2}, 1146 + {0x0000a570, 0x7804ff56, 0x7804ff56, 0x63001cf3, 0x63001cf3}, 1147 + {0x0000a574, 0x7804ff56, 0x7804ff56, 0x64001cf4, 0x64001cf4}, 1148 + {0x0000a578, 0x7804ff56, 0x7804ff56, 0x66001ff6, 0x66001ff6}, 1149 + {0x0000a57c, 0x7804ff56, 0x7804ff56, 0x66001ff6, 0x66001ff6}, 1152 1150 {0x0000a600, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, 1153 1151 {0x0000a604, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, 1154 1152 {0x0000a608, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, ··· 1176 1174 {0x0000a2e0, 0xffecec00, 0xffecec00, 0xfd339c84, 0xfd339c84}, 1177 1175 {0x0000a2e4, 0xfc0f0000, 0xfc0f0000, 0xfec3e000, 0xfec3e000}, 1178 1176 {0x0000a2e8, 0xfc100000, 0xfc100000, 0xfffc0000, 0xfffc0000}, 1179 - {0x0000a410, 0x000050d9, 0x000050d9, 0x000050d9, 0x000050d9}, 1177 + {0x0000a410, 0x000050d9, 0x000050d9, 0x000050df, 0x000050df}, 1180 1178 {0x0000a500, 0x00002220, 0x00002220, 0x00000000, 0x00000000}, 1181 1179 {0x0000a504, 0x06002223, 0x06002223, 0x04000002, 0x04000002}, 1182 1180 {0x0000a508, 0x0a022220, 0x0a022220, 0x08000004, 0x08000004}, ··· 1202 1200 {0x0000a558, 0x66027f56, 0x66027f56, 0x4c001ce5, 0x4c001ce5}, 1203 1201 {0x0000a55c, 0x6a029f56, 0x6a029f56, 0x50001ce9, 0x50001ce9}, 1204 1202 {0x0000a560, 0x70049f56, 0x70049f56, 0x54001ceb, 0x54001ceb}, 1205 - {0x0000a564, 0x7504ff56, 0x7504ff56, 0x56001eec, 0x56001eec}, 1206 - {0x0000a568, 0x7504ff56, 0x7504ff56, 0x56001eec, 0x56001eec}, 1207 - {0x0000a56c, 0x7504ff56, 0x7504ff56, 0x56001eec, 0x56001eec}, 1208 - {0x0000a570, 0x7504ff56, 0x7504ff56, 0x56001eec, 0x56001eec}, 1209 - {0x0000a574, 0x7504ff56, 0x7504ff56, 0x56001eec, 0x56001eec}, 1210 - {0x0000a578, 0x7504ff56, 0x7504ff56, 0x56001eec, 0x56001eec}, 1211 - {0x0000a57c, 0x7504ff56, 0x7504ff56, 0x56001eec, 0x56001eec}, 1203 + {0x0000a564, 0x7504ff56, 0x7504ff56, 0x59001cf0, 0x59001cf0}, 1204 + {0x0000a568, 0x7504ff56, 0x7504ff56, 0x5a001cf1, 0x5a001cf1}, 1205 + {0x0000a56c, 0x7504ff56, 0x7504ff56, 0x5b001cf2, 0x5b001cf2}, 1206 + {0x0000a570, 0x7504ff56, 0x7504ff56, 0x5c001cf3, 0x5c001cf3}, 1207 + {0x0000a574, 0x7504ff56, 0x7504ff56, 0x5d001cf4, 0x5d001cf4}, 1208 + {0x0000a578, 0x7504ff56, 0x7504ff56, 0x5f001ff6, 0x5f001ff6}, 1209 + {0x0000a57c, 0x7504ff56, 0x7504ff56, 0x5f001ff6, 0x5f001ff6}, 1212 1210 {0x0000a600, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, 1213 1211 {0x0000a604, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, 1214 1212 {0x0000a608, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
+7 -3
drivers/net/wireless/ath/ath9k/main.c
··· 227 227 if (!test_bit(SC_OP_BEACONS, &sc->sc_flags)) 228 228 goto work; 229 229 230 - ath9k_set_beacon(sc); 231 - 232 230 if (ah->opmode == NL80211_IFTYPE_STATION && 233 231 test_bit(SC_OP_PRIM_STA_VIF, &sc->sc_flags)) { 234 232 spin_lock_irqsave(&sc->sc_pm_lock, flags); 235 233 sc->ps_flags |= PS_BEACON_SYNC | PS_WAIT_FOR_BEACON; 236 234 spin_unlock_irqrestore(&sc->sc_pm_lock, flags); 235 + } else { 236 + ath9k_set_beacon(sc); 237 237 } 238 238 work: 239 239 ath_restart_work(sc); ··· 1332 1332 struct ath_common *common = ath9k_hw_common(sc->sc_ah); 1333 1333 struct ath_node *an = (struct ath_node *) sta->drv_priv; 1334 1334 struct ieee80211_key_conf ps_key = { }; 1335 + int key; 1335 1336 1336 1337 ath_node_attach(sc, sta, vif); 1337 1338 ··· 1340 1339 vif->type != NL80211_IFTYPE_AP_VLAN) 1341 1340 return 0; 1342 1341 1343 - an->ps_key = ath_key_config(common, vif, sta, &ps_key); 1342 + key = ath_key_config(common, vif, sta, &ps_key); 1343 + if (key > 0) 1344 + an->ps_key = key; 1344 1345 1345 1346 return 0; 1346 1347 } ··· 1359 1356 return; 1360 1357 1361 1358 ath_key_delete(common, &ps_key); 1359 + an->ps_key = 0; 1362 1360 } 1363 1361 1364 1362 static int ath9k_sta_remove(struct ieee80211_hw *hw,
+19
drivers/net/wireless/b43/dma.c
··· 1728 1728 sync_descbuffer_for_device(ring, dmaaddr, ring->rx_buffersize); 1729 1729 } 1730 1730 1731 + void b43_dma_handle_rx_overflow(struct b43_dmaring *ring) 1732 + { 1733 + int current_slot, previous_slot; 1734 + 1735 + B43_WARN_ON(ring->tx); 1736 + 1737 + /* Device has filled all buffers, drop all packets and let TCP 1738 + * decrease speed. 1739 + * Decrement RX index by one will let the device to see all slots 1740 + * as free again 1741 + */ 1742 + /* 1743 + *TODO: How to increase rx_drop in mac80211? 1744 + */ 1745 + current_slot = ring->ops->get_current_rxslot(ring); 1746 + previous_slot = prev_slot(ring, current_slot); 1747 + ring->ops->set_current_rxslot(ring, previous_slot); 1748 + } 1749 + 1731 1750 void b43_dma_rx(struct b43_dmaring *ring) 1732 1751 { 1733 1752 const struct b43_dma_ops *ops = ring->ops;
+3 -1
drivers/net/wireless/b43/dma.h
··· 9 9 /* DMA-Interrupt reasons. */ 10 10 #define B43_DMAIRQ_FATALMASK ((1 << 10) | (1 << 11) | (1 << 12) \ 11 11 | (1 << 14) | (1 << 15)) 12 - #define B43_DMAIRQ_NONFATALMASK (1 << 13) 12 + #define B43_DMAIRQ_RDESC_UFLOW (1 << 13) 13 13 #define B43_DMAIRQ_RX_DONE (1 << 16) 14 14 15 15 /*** 32-bit DMA Engine. ***/ ··· 294 294 struct sk_buff *skb); 295 295 void b43_dma_handle_txstatus(struct b43_wldev *dev, 296 296 const struct b43_txstatus *status); 297 + 298 + void b43_dma_handle_rx_overflow(struct b43_dmaring *ring); 297 299 298 300 void b43_dma_rx(struct b43_dmaring *ring); 299 301
+18 -25
drivers/net/wireless/b43/main.c
··· 1902 1902 } 1903 1903 } 1904 1904 1905 - if (unlikely(merged_dma_reason & (B43_DMAIRQ_FATALMASK | 1906 - B43_DMAIRQ_NONFATALMASK))) { 1907 - if (merged_dma_reason & B43_DMAIRQ_FATALMASK) { 1908 - b43err(dev->wl, "Fatal DMA error: " 1909 - "0x%08X, 0x%08X, 0x%08X, " 1910 - "0x%08X, 0x%08X, 0x%08X\n", 1911 - dma_reason[0], dma_reason[1], 1912 - dma_reason[2], dma_reason[3], 1913 - dma_reason[4], dma_reason[5]); 1914 - b43err(dev->wl, "This device does not support DMA " 1905 + if (unlikely(merged_dma_reason & (B43_DMAIRQ_FATALMASK))) { 1906 + b43err(dev->wl, 1907 + "Fatal DMA error: 0x%08X, 0x%08X, 0x%08X, 0x%08X, 0x%08X, 0x%08X\n", 1908 + dma_reason[0], dma_reason[1], 1909 + dma_reason[2], dma_reason[3], 1910 + dma_reason[4], dma_reason[5]); 1911 + b43err(dev->wl, "This device does not support DMA " 1915 1912 "on your system. It will now be switched to PIO.\n"); 1916 - /* Fall back to PIO transfers if we get fatal DMA errors! */ 1917 - dev->use_pio = true; 1918 - b43_controller_restart(dev, "DMA error"); 1919 - return; 1920 - } 1921 - if (merged_dma_reason & B43_DMAIRQ_NONFATALMASK) { 1922 - b43err(dev->wl, "DMA error: " 1923 - "0x%08X, 0x%08X, 0x%08X, " 1924 - "0x%08X, 0x%08X, 0x%08X\n", 1925 - dma_reason[0], dma_reason[1], 1926 - dma_reason[2], dma_reason[3], 1927 - dma_reason[4], dma_reason[5]); 1928 - } 1913 + /* Fall back to PIO transfers if we get fatal DMA errors! */ 1914 + dev->use_pio = true; 1915 + b43_controller_restart(dev, "DMA error"); 1916 + return; 1929 1917 } 1930 1918 1931 1919 if (unlikely(reason & B43_IRQ_UCODE_DEBUG)) ··· 1932 1944 handle_irq_noise(dev); 1933 1945 1934 1946 /* Check the DMA reason registers for received data. */ 1947 + if (dma_reason[0] & B43_DMAIRQ_RDESC_UFLOW) { 1948 + if (B43_DEBUG) 1949 + b43warn(dev->wl, "RX descriptor underrun\n"); 1950 + b43_dma_handle_rx_overflow(dev->dma.rx_ring); 1951 + } 1935 1952 if (dma_reason[0] & B43_DMAIRQ_RX_DONE) { 1936 1953 if (b43_using_pio_transfers(dev)) 1937 1954 b43_pio_rx(dev->pio.rx_queue); ··· 1994 2001 return IRQ_NONE; 1995 2002 1996 2003 dev->dma_reason[0] = b43_read32(dev, B43_MMIO_DMA0_REASON) 1997 - & 0x0001DC00; 2004 + & 0x0001FC00; 1998 2005 dev->dma_reason[1] = b43_read32(dev, B43_MMIO_DMA1_REASON) 1999 2006 & 0x0000DC00; 2000 2007 dev->dma_reason[2] = b43_read32(dev, B43_MMIO_DMA2_REASON) ··· 3123 3130 b43_write32(dev, 0x018C, 0x02000000); 3124 3131 } 3125 3132 b43_write32(dev, B43_MMIO_GEN_IRQ_REASON, 0x00004000); 3126 - b43_write32(dev, B43_MMIO_DMA0_IRQ_MASK, 0x0001DC00); 3133 + b43_write32(dev, B43_MMIO_DMA0_IRQ_MASK, 0x0001FC00); 3127 3134 b43_write32(dev, B43_MMIO_DMA1_IRQ_MASK, 0x0000DC00); 3128 3135 b43_write32(dev, B43_MMIO_DMA2_IRQ_MASK, 0x0000DC00); 3129 3136 b43_write32(dev, B43_MMIO_DMA3_IRQ_MASK, 0x0001DC00);
+1 -2
drivers/net/wireless/iwlegacy/4965-mac.c
··· 5741 5741 hw->flags = 5742 5742 IEEE80211_HW_SIGNAL_DBM | IEEE80211_HW_AMPDU_AGGREGATION | 5743 5743 IEEE80211_HW_NEED_DTIM_BEFORE_ASSOC | IEEE80211_HW_SPECTRUM_MGMT | 5744 - IEEE80211_HW_REPORTS_TX_ACK_STATUS | IEEE80211_HW_SUPPORTS_PS | 5745 - IEEE80211_HW_SUPPORTS_DYNAMIC_PS; 5744 + IEEE80211_HW_SUPPORTS_PS | IEEE80211_HW_SUPPORTS_DYNAMIC_PS; 5746 5745 if (il->cfg->sku & IL_SKU_N) 5747 5746 hw->flags |= 5748 5747 IEEE80211_HW_SUPPORTS_DYNAMIC_SMPS |
-3
drivers/net/wireless/mwifiex/cfg80211.c
··· 2234 2234 if (wdev->netdev->reg_state == NETREG_REGISTERED) 2235 2235 unregister_netdevice(wdev->netdev); 2236 2236 2237 - if (wdev->netdev->reg_state == NETREG_UNREGISTERED) 2238 - free_netdev(wdev->netdev); 2239 - 2240 2237 /* Clear the priv in adapter */ 2241 2238 priv->netdev = NULL; 2242 2239
+1
drivers/net/wireless/mwifiex/cmdevt.c
··· 1191 1191 adapter->if_ops.wakeup(adapter); 1192 1192 adapter->hs_activated = false; 1193 1193 adapter->is_hs_configured = false; 1194 + adapter->is_suspended = false; 1194 1195 mwifiex_hs_activated_event(mwifiex_get_priv(adapter, 1195 1196 MWIFIEX_BSS_ROLE_ANY), 1196 1197 false);
+1
drivers/net/wireless/mwifiex/main.c
··· 655 655 struct net_device *dev) 656 656 { 657 657 dev->netdev_ops = &mwifiex_netdev_ops; 658 + dev->destructor = free_netdev; 658 659 /* Initialize private structure */ 659 660 priv->current_key_index = 0; 660 661 priv->media_connected = false;
+6 -15
drivers/net/wireless/mwifiex/sta_ioctl.c
··· 96 96 } else { 97 97 /* Multicast */ 98 98 priv->curr_pkt_filter &= ~HostCmd_ACT_MAC_PROMISCUOUS_ENABLE; 99 - if (mcast_list->mode == MWIFIEX_MULTICAST_MODE) { 99 + if (mcast_list->mode == MWIFIEX_ALL_MULTI_MODE) { 100 100 dev_dbg(priv->adapter->dev, 101 101 "info: Enabling All Multicast!\n"); 102 102 priv->curr_pkt_filter |= ··· 108 108 dev_dbg(priv->adapter->dev, 109 109 "info: Set multicast list=%d\n", 110 110 mcast_list->num_multicast_addr); 111 - /* Set multicast addresses to firmware */ 112 - if (old_pkt_filter == priv->curr_pkt_filter) { 113 - /* Send request to firmware */ 114 - ret = mwifiex_send_cmd_async(priv, 115 - HostCmd_CMD_MAC_MULTICAST_ADR, 116 - HostCmd_ACT_GEN_SET, 0, 117 - mcast_list); 118 - } else { 119 - /* Send request to firmware */ 120 - ret = mwifiex_send_cmd_async(priv, 121 - HostCmd_CMD_MAC_MULTICAST_ADR, 122 - HostCmd_ACT_GEN_SET, 0, 123 - mcast_list); 124 - } 111 + /* Send multicast addresses to firmware */ 112 + ret = mwifiex_send_cmd_async(priv, 113 + HostCmd_CMD_MAC_MULTICAST_ADR, 114 + HostCmd_ACT_GEN_SET, 0, 115 + mcast_list); 125 116 } 126 117 } 127 118 }
+5 -5
drivers/ntb/ntb_hw.c
··· 345 345 */ 346 346 void __iomem *ntb_get_mw_vbase(struct ntb_device *ndev, unsigned int mw) 347 347 { 348 - if (mw > NTB_NUM_MW) 348 + if (mw >= NTB_NUM_MW) 349 349 return NULL; 350 350 351 351 return ndev->mw[mw].vbase; ··· 362 362 */ 363 363 resource_size_t ntb_get_mw_size(struct ntb_device *ndev, unsigned int mw) 364 364 { 365 - if (mw > NTB_NUM_MW) 365 + if (mw >= NTB_NUM_MW) 366 366 return 0; 367 367 368 368 return ndev->mw[mw].bar_sz; ··· 380 380 */ 381 381 void ntb_set_mw_addr(struct ntb_device *ndev, unsigned int mw, u64 addr) 382 382 { 383 - if (mw > NTB_NUM_MW) 383 + if (mw >= NTB_NUM_MW) 384 384 return; 385 385 386 386 dev_dbg(&ndev->pdev->dev, "Writing addr %Lx to BAR %d\n", addr, ··· 1027 1027 ndev->mw[i].vbase = 1028 1028 ioremap_wc(pci_resource_start(pdev, MW_TO_BAR(i)), 1029 1029 ndev->mw[i].bar_sz); 1030 - dev_info(&pdev->dev, "MW %d size %d\n", i, 1031 - (u32) pci_resource_len(pdev, MW_TO_BAR(i))); 1030 + dev_info(&pdev->dev, "MW %d size %llu\n", i, 1031 + pci_resource_len(pdev, MW_TO_BAR(i))); 1032 1032 if (!ndev->mw[i].vbase) { 1033 1033 dev_warn(&pdev->dev, "Cannot remap BAR %d\n", 1034 1034 MW_TO_BAR(i));
+116 -63
drivers/ntb/ntb_transport.c
··· 58 58 #include <linux/ntb.h> 59 59 #include "ntb_hw.h" 60 60 61 - #define NTB_TRANSPORT_VERSION 2 61 + #define NTB_TRANSPORT_VERSION 3 62 62 63 63 static unsigned int transport_mtu = 0x401E; 64 64 module_param(transport_mtu, uint, 0644); ··· 173 173 174 174 enum { 175 175 VERSION = 0, 176 - MW0_SZ, 177 - MW1_SZ, 178 - NUM_QPS, 179 176 QP_LINKS, 177 + NUM_QPS, 178 + NUM_MWS, 179 + MW0_SZ_HIGH, 180 + MW0_SZ_LOW, 181 + MW1_SZ_HIGH, 182 + MW1_SZ_LOW, 180 183 MAX_SPAD, 181 184 }; 182 185 ··· 300 297 { 301 298 struct ntb_transport_client_dev *client_dev; 302 299 struct ntb_transport *nt; 303 - int rc; 300 + int rc, i = 0; 304 301 305 302 if (list_empty(&ntb_transport_list)) 306 303 return -ENODEV; ··· 318 315 dev = &client_dev->dev; 319 316 320 317 /* setup and register client devices */ 321 - dev_set_name(dev, "%s", device_name); 318 + dev_set_name(dev, "%s%d", device_name, i); 322 319 dev->bus = &ntb_bus_type; 323 320 dev->release = ntb_client_release; 324 321 dev->parent = &ntb_query_pdev(nt->ndev)->dev; ··· 330 327 } 331 328 332 329 list_add_tail(&client_dev->entry, &nt->client_devs); 330 + i++; 333 331 } 334 332 335 333 return 0; ··· 490 486 (qp_num / NTB_NUM_MW * rx_size); 491 487 rx_size -= sizeof(struct ntb_rx_info); 492 488 493 - qp->rx_buff = qp->remote_rx_info + sizeof(struct ntb_rx_info); 494 - qp->rx_max_frame = min(transport_mtu, rx_size); 489 + qp->rx_buff = qp->remote_rx_info + 1; 490 + /* Due to housekeeping, there must be atleast 2 buffs */ 491 + qp->rx_max_frame = min(transport_mtu, rx_size / 2); 495 492 qp->rx_max_entry = rx_size / qp->rx_max_frame; 496 493 qp->rx_index = 0; 497 494 498 - qp->remote_rx_info->entry = qp->rx_max_entry; 495 + qp->remote_rx_info->entry = qp->rx_max_entry - 1; 499 496 500 497 /* setup the hdr offsets with 0's */ 501 498 for (i = 0; i < qp->rx_max_entry; i++) { ··· 507 502 508 503 qp->rx_pkts = 0; 509 504 qp->tx_pkts = 0; 505 + qp->tx_index = 0; 506 + } 507 + 508 + static void ntb_free_mw(struct ntb_transport *nt, int num_mw) 509 + { 510 + struct ntb_transport_mw *mw = &nt->mw[num_mw]; 511 + struct pci_dev *pdev = ntb_query_pdev(nt->ndev); 512 + 513 + if (!mw->virt_addr) 514 + return; 515 + 516 + dma_free_coherent(&pdev->dev, mw->size, mw->virt_addr, mw->dma_addr); 517 + mw->virt_addr = NULL; 510 518 } 511 519 512 520 static int ntb_set_mw(struct ntb_transport *nt, int num_mw, unsigned int size) ··· 527 509 struct ntb_transport_mw *mw = &nt->mw[num_mw]; 528 510 struct pci_dev *pdev = ntb_query_pdev(nt->ndev); 529 511 512 + /* No need to re-setup */ 513 + if (mw->size == ALIGN(size, 4096)) 514 + return 0; 515 + 516 + if (mw->size != 0) 517 + ntb_free_mw(nt, num_mw); 518 + 530 519 /* Alloc memory for receiving data. Must be 4k aligned */ 531 520 mw->size = ALIGN(size, 4096); 532 521 533 522 mw->virt_addr = dma_alloc_coherent(&pdev->dev, mw->size, &mw->dma_addr, 534 523 GFP_KERNEL); 535 524 if (!mw->virt_addr) { 525 + mw->size = 0; 536 526 dev_err(&pdev->dev, "Unable to allocate MW buffer of size %d\n", 537 527 (int) mw->size); 538 528 return -ENOMEM; ··· 630 604 u32 val; 631 605 int rc, i; 632 606 633 - /* send the local info */ 634 - rc = ntb_write_remote_spad(ndev, VERSION, NTB_TRANSPORT_VERSION); 635 - if (rc) { 636 - dev_err(&pdev->dev, "Error writing %x to remote spad %d\n", 637 - 0, VERSION); 638 - goto out; 607 + /* send the local info, in the opposite order of the way we read it */ 608 + for (i = 0; i < NTB_NUM_MW; i++) { 609 + rc = ntb_write_remote_spad(ndev, MW0_SZ_HIGH + (i * 2), 610 + ntb_get_mw_size(ndev, i) >> 32); 611 + if (rc) { 612 + dev_err(&pdev->dev, "Error writing %u to remote spad %d\n", 613 + (u32)(ntb_get_mw_size(ndev, i) >> 32), 614 + MW0_SZ_HIGH + (i * 2)); 615 + goto out; 616 + } 617 + 618 + rc = ntb_write_remote_spad(ndev, MW0_SZ_LOW + (i * 2), 619 + (u32) ntb_get_mw_size(ndev, i)); 620 + if (rc) { 621 + dev_err(&pdev->dev, "Error writing %u to remote spad %d\n", 622 + (u32) ntb_get_mw_size(ndev, i), 623 + MW0_SZ_LOW + (i * 2)); 624 + goto out; 625 + } 639 626 } 640 627 641 - rc = ntb_write_remote_spad(ndev, MW0_SZ, ntb_get_mw_size(ndev, 0)); 628 + rc = ntb_write_remote_spad(ndev, NUM_MWS, NTB_NUM_MW); 642 629 if (rc) { 643 630 dev_err(&pdev->dev, "Error writing %x to remote spad %d\n", 644 - (u32) ntb_get_mw_size(ndev, 0), MW0_SZ); 645 - goto out; 646 - } 647 - 648 - rc = ntb_write_remote_spad(ndev, MW1_SZ, ntb_get_mw_size(ndev, 1)); 649 - if (rc) { 650 - dev_err(&pdev->dev, "Error writing %x to remote spad %d\n", 651 - (u32) ntb_get_mw_size(ndev, 1), MW1_SZ); 631 + NTB_NUM_MW, NUM_MWS); 652 632 goto out; 653 633 } 654 634 ··· 665 633 goto out; 666 634 } 667 635 668 - rc = ntb_read_local_spad(nt->ndev, QP_LINKS, &val); 669 - if (rc) { 670 - dev_err(&pdev->dev, "Error reading spad %d\n", QP_LINKS); 671 - goto out; 672 - } 673 - 674 - rc = ntb_write_remote_spad(ndev, QP_LINKS, val); 636 + rc = ntb_write_remote_spad(ndev, VERSION, NTB_TRANSPORT_VERSION); 675 637 if (rc) { 676 638 dev_err(&pdev->dev, "Error writing %x to remote spad %d\n", 677 - val, QP_LINKS); 639 + NTB_TRANSPORT_VERSION, VERSION); 678 640 goto out; 679 641 } 680 642 ··· 693 667 goto out; 694 668 dev_dbg(&pdev->dev, "Remote max number of qps = %d\n", val); 695 669 696 - rc = ntb_read_remote_spad(ndev, MW0_SZ, &val); 670 + rc = ntb_read_remote_spad(ndev, NUM_MWS, &val); 697 671 if (rc) { 698 - dev_err(&pdev->dev, "Error reading remote spad %d\n", MW0_SZ); 672 + dev_err(&pdev->dev, "Error reading remote spad %d\n", NUM_MWS); 699 673 goto out; 700 674 } 701 675 702 - if (!val) 676 + if (val != NTB_NUM_MW) 703 677 goto out; 704 - dev_dbg(&pdev->dev, "Remote MW0 size = %d\n", val); 678 + dev_dbg(&pdev->dev, "Remote number of mws = %d\n", val); 705 679 706 - rc = ntb_set_mw(nt, 0, val); 707 - if (rc) 708 - goto out; 680 + for (i = 0; i < NTB_NUM_MW; i++) { 681 + u64 val64; 709 682 710 - rc = ntb_read_remote_spad(ndev, MW1_SZ, &val); 711 - if (rc) { 712 - dev_err(&pdev->dev, "Error reading remote spad %d\n", MW1_SZ); 713 - goto out; 683 + rc = ntb_read_remote_spad(ndev, MW0_SZ_HIGH + (i * 2), &val); 684 + if (rc) { 685 + dev_err(&pdev->dev, "Error reading remote spad %d\n", 686 + MW0_SZ_HIGH + (i * 2)); 687 + goto out1; 688 + } 689 + 690 + val64 = (u64) val << 32; 691 + 692 + rc = ntb_read_remote_spad(ndev, MW0_SZ_LOW + (i * 2), &val); 693 + if (rc) { 694 + dev_err(&pdev->dev, "Error reading remote spad %d\n", 695 + MW0_SZ_LOW + (i * 2)); 696 + goto out1; 697 + } 698 + 699 + val64 |= val; 700 + 701 + dev_dbg(&pdev->dev, "Remote MW%d size = %llu\n", i, val64); 702 + 703 + rc = ntb_set_mw(nt, i, val64); 704 + if (rc) 705 + goto out1; 714 706 } 715 - 716 - if (!val) 717 - goto out; 718 - dev_dbg(&pdev->dev, "Remote MW1 size = %d\n", val); 719 - 720 - rc = ntb_set_mw(nt, 1, val); 721 - if (rc) 722 - goto out; 723 707 724 708 nt->transport_link = NTB_LINK_UP; 725 709 ··· 744 708 745 709 return; 746 710 711 + out1: 712 + for (i = 0; i < NTB_NUM_MW; i++) 713 + ntb_free_mw(nt, i); 747 714 out: 748 715 if (ntb_hw_link_status(ndev)) 749 716 schedule_delayed_work(&nt->link_work, ··· 819 780 (qp_num / NTB_NUM_MW * tx_size); 820 781 tx_size -= sizeof(struct ntb_rx_info); 821 782 822 - qp->tx_mw = qp->rx_info + sizeof(struct ntb_rx_info); 823 - qp->tx_max_frame = min(transport_mtu, tx_size); 783 + qp->tx_mw = qp->rx_info + 1; 784 + /* Due to housekeeping, there must be atleast 2 buffs */ 785 + qp->tx_max_frame = min(transport_mtu, tx_size / 2); 824 786 qp->tx_max_entry = tx_size / qp->tx_max_frame; 825 - qp->tx_index = 0; 826 787 827 788 if (nt->debugfs_dir) { 828 789 char debugfs_name[4]; ··· 936 897 pdev = ntb_query_pdev(nt->ndev); 937 898 938 899 for (i = 0; i < NTB_NUM_MW; i++) 939 - if (nt->mw[i].virt_addr) 940 - dma_free_coherent(&pdev->dev, nt->mw[i].size, 941 - nt->mw[i].virt_addr, 942 - nt->mw[i].dma_addr); 900 + ntb_free_mw(nt, i); 943 901 944 902 kfree(nt->qps); 945 903 ntb_unregister_transport(nt->ndev); ··· 1035 999 static void ntb_transport_rx(unsigned long data) 1036 1000 { 1037 1001 struct ntb_transport_qp *qp = (struct ntb_transport_qp *)data; 1038 - int rc; 1002 + int rc, i; 1039 1003 1040 - do { 1004 + /* Limit the number of packets processed in a single interrupt to 1005 + * provide fairness to others 1006 + */ 1007 + for (i = 0; i < qp->rx_max_entry; i++) { 1041 1008 rc = ntb_process_rxc(qp); 1042 - } while (!rc); 1009 + if (rc) 1010 + break; 1011 + } 1043 1012 } 1044 1013 1045 1014 static void ntb_transport_rxc_db(void *data, int db_num) ··· 1251 1210 */ 1252 1211 void ntb_transport_free_queue(struct ntb_transport_qp *qp) 1253 1212 { 1254 - struct pci_dev *pdev = ntb_query_pdev(qp->ndev); 1213 + struct pci_dev *pdev; 1255 1214 struct ntb_queue_entry *entry; 1256 1215 1257 1216 if (!qp) 1258 1217 return; 1218 + 1219 + pdev = ntb_query_pdev(qp->ndev); 1259 1220 1260 1221 cancel_delayed_work_sync(&qp->link_work); 1261 1222 ··· 1414 1371 */ 1415 1372 void ntb_transport_link_down(struct ntb_transport_qp *qp) 1416 1373 { 1417 - struct pci_dev *pdev = ntb_query_pdev(qp->ndev); 1374 + struct pci_dev *pdev; 1418 1375 int rc, val; 1419 1376 1420 1377 if (!qp) 1421 1378 return; 1422 1379 1380 + pdev = ntb_query_pdev(qp->ndev); 1423 1381 qp->client_ready = NTB_LINK_DOWN; 1424 1382 1425 1383 rc = ntb_read_local_spad(qp->ndev, QP_LINKS, &val); ··· 1452 1408 */ 1453 1409 bool ntb_transport_link_query(struct ntb_transport_qp *qp) 1454 1410 { 1411 + if (!qp) 1412 + return false; 1413 + 1455 1414 return qp->qp_link == NTB_LINK_UP; 1456 1415 } 1457 1416 EXPORT_SYMBOL_GPL(ntb_transport_link_query); ··· 1469 1422 */ 1470 1423 unsigned char ntb_transport_qp_num(struct ntb_transport_qp *qp) 1471 1424 { 1425 + if (!qp) 1426 + return 0; 1427 + 1472 1428 return qp->qp_num; 1473 1429 } 1474 1430 EXPORT_SYMBOL_GPL(ntb_transport_qp_num); ··· 1486 1436 */ 1487 1437 unsigned int ntb_transport_max_size(struct ntb_transport_qp *qp) 1488 1438 { 1439 + if (!qp) 1440 + return 0; 1441 + 1489 1442 return qp->tx_max_frame - sizeof(struct ntb_payload_header); 1490 1443 } 1491 1444 EXPORT_SYMBOL_GPL(ntb_transport_max_size);
+2 -2
drivers/of/base.c
··· 1208 1208 out_args->args_count = count; 1209 1209 for (i = 0; i < count; i++) 1210 1210 out_args->args[i] = be32_to_cpup(list++); 1211 + } else { 1212 + of_node_put(node); 1211 1213 } 1212 1214 1213 1215 /* Found it! return success */ 1214 - if (node) 1215 - of_node_put(node); 1216 1216 return 0; 1217 1217 } 1218 1218
+14 -16
drivers/pinctrl/pinctrl-abx500.c
··· 851 851 852 852 if (abx500_pdata) 853 853 pdata = abx500_pdata->gpio; 854 - if (!pdata) { 855 - if (np) { 856 - const struct of_device_id *match; 857 854 858 - match = of_match_device(abx500_gpio_match, &pdev->dev); 859 - if (!match) 860 - return -ENODEV; 861 - id = (unsigned long)match->data; 862 - } else { 863 - dev_err(&pdev->dev, "gpio dt and platform data missing\n"); 864 - return -ENODEV; 865 - } 855 + if (!(pdata || np)) { 856 + dev_err(&pdev->dev, "gpio dt and platform data missing\n"); 857 + return -ENODEV; 866 858 } 867 - 868 - if (platid) 869 - id = platid->driver_data; 870 859 871 860 pct = devm_kzalloc(&pdev->dev, sizeof(struct abx500_pinctrl), 872 861 GFP_KERNEL); ··· 870 881 pct->chip = abx500gpio_chip; 871 882 pct->chip.dev = &pdev->dev; 872 883 pct->chip.base = (np) ? -1 : pdata->gpio_base; 884 + 885 + if (platid) 886 + id = platid->driver_data; 887 + else if (np) { 888 + const struct of_device_id *match; 889 + 890 + match = of_match_device(abx500_gpio_match, &pdev->dev); 891 + if (match) 892 + id = (unsigned long)match->data; 893 + } 873 894 874 895 /* initialize the lock */ 875 896 mutex_init(&pct->lock); ··· 899 900 abx500_pinctrl_ab8505_init(&pct->soc); 900 901 break; 901 902 default: 902 - dev_err(&pdev->dev, "Unsupported pinctrl sub driver (%d)\n", 903 - (int) platid->driver_data); 903 + dev_err(&pdev->dev, "Unsupported pinctrl sub driver (%d)\n", id); 904 904 mutex_destroy(&pct->lock); 905 905 return -EINVAL; 906 906 }
-5
drivers/pinctrl/pinctrl-coh901.c
··· 713 713 gpio->dev = &pdev->dev; 714 714 715 715 memres = platform_get_resource(pdev, IORESOURCE_MEM, 0); 716 - if (!memres) { 717 - dev_err(gpio->dev, "could not get GPIO memory resource\n"); 718 - return -ENODEV; 719 - } 720 - 721 716 gpio->base = devm_ioremap_resource(&pdev->dev, memres); 722 717 if (IS_ERR(gpio->base)) 723 718 return PTR_ERR(gpio->base);
-5
drivers/pinctrl/pinctrl-exynos5440.c
··· 1000 1000 } 1001 1001 1002 1002 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1003 - if (!res) { 1004 - dev_err(dev, "cannot find IO resource\n"); 1005 - return -ENOENT; 1006 - } 1007 - 1008 1003 priv->reg_base = devm_ioremap_resource(&pdev->dev, res); 1009 1004 if (IS_ERR(priv->reg_base)) 1010 1005 return PTR_ERR(priv->reg_base);
+2 -1
drivers/pinctrl/pinctrl-lantiq.c
··· 52 52 int i; 53 53 54 54 for (i = 0; i < num_maps; i++) 55 - if (map[i].type == PIN_MAP_TYPE_CONFIGS_PIN) 55 + if (map[i].type == PIN_MAP_TYPE_CONFIGS_PIN || 56 + map[i].type == PIN_MAP_TYPE_CONFIGS_GROUP) 56 57 kfree(map[i].data.configs.configs); 57 58 kfree(map); 58 59 }
-5
drivers/pinctrl/pinctrl-samsung.c
··· 932 932 drvdata->dev = dev; 933 933 934 934 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 935 - if (!res) { 936 - dev_err(dev, "cannot find IO resource\n"); 937 - return -ENOENT; 938 - } 939 - 940 935 drvdata->virt_base = devm_ioremap_resource(&pdev->dev, res); 941 936 if (IS_ERR(drvdata->virt_base)) 942 937 return PTR_ERR(drvdata->virt_base);
+2 -1
drivers/pinctrl/pinctrl-single.c
··· 1166 1166 (*map)->data.mux.function = np->name; 1167 1167 1168 1168 if (pcs->is_pinconf) { 1169 - if (pcs_parse_pinconf(pcs, np, function, map)) 1169 + res = pcs_parse_pinconf(pcs, np, function, map); 1170 + if (res) 1170 1171 goto free_pingroups; 1171 1172 *num_maps = 2; 1172 1173 } else {
-4
drivers/pinctrl/pinctrl-xway.c
··· 716 716 717 717 /* get and remap our register range */ 718 718 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 719 - if (!res) { 720 - dev_err(&pdev->dev, "Failed to get resource\n"); 721 - return -ENOENT; 722 - } 723 719 xway_info.membase[0] = devm_ioremap_resource(&pdev->dev, res); 724 720 if (IS_ERR(xway_info.membase[0])) 725 721 return PTR_ERR(xway_info.membase[0]);
+1 -1
drivers/pinctrl/vt8500/pinctrl-wm8750.c
··· 53 53 #define WMT_PIN_EXTGPIO6 WMT_PIN(0, 6) 54 54 #define WMT_PIN_EXTGPIO7 WMT_PIN(0, 7) 55 55 #define WMT_PIN_WAKEUP0 WMT_PIN(0, 16) 56 - #define WMT_PIN_WAKEUP1 WMT_PIN(0, 16) 56 + #define WMT_PIN_WAKEUP1 WMT_PIN(0, 17) 57 57 #define WMT_PIN_SD0CD WMT_PIN(0, 28) 58 58 #define WMT_PIN_VDOUT0 WMT_PIN(1, 0) 59 59 #define WMT_PIN_VDOUT1 WMT_PIN(1, 1)
-5
drivers/pwm/pwm-imx.c
··· 265 265 imx->chip.npwm = 1; 266 266 267 267 r = platform_get_resource(pdev, IORESOURCE_MEM, 0); 268 - if (r == NULL) { 269 - dev_err(&pdev->dev, "no memory resource defined\n"); 270 - return -ENODEV; 271 - } 272 - 273 268 imx->mmio_base = devm_ioremap_resource(&pdev->dev, r); 274 269 if (IS_ERR(imx->mmio_base)) 275 270 return PTR_ERR(imx->mmio_base);
-5
drivers/pwm/pwm-puv3.c
··· 117 117 return PTR_ERR(puv3->clk); 118 118 119 119 r = platform_get_resource(pdev, IORESOURCE_MEM, 0); 120 - if (r == NULL) { 121 - dev_err(&pdev->dev, "no memory resource defined\n"); 122 - return -ENODEV; 123 - } 124 - 125 120 puv3->base = devm_ioremap_resource(&pdev->dev, r); 126 121 if (IS_ERR(puv3->base)) 127 122 return PTR_ERR(puv3->base);
-5
drivers/pwm/pwm-pxa.c
··· 147 147 pwm->chip.npwm = (id->driver_data & HAS_SECONDARY_PWM) ? 2 : 1; 148 148 149 149 r = platform_get_resource(pdev, IORESOURCE_MEM, 0); 150 - if (r == NULL) { 151 - dev_err(&pdev->dev, "no memory resource defined\n"); 152 - return -ENODEV; 153 - } 154 - 155 150 pwm->mmio_base = devm_ioremap_resource(&pdev->dev, r); 156 151 if (IS_ERR(pwm->mmio_base)) 157 152 return PTR_ERR(pwm->mmio_base);
-5
drivers/pwm/pwm-tegra.c
··· 181 181 pwm->dev = &pdev->dev; 182 182 183 183 r = platform_get_resource(pdev, IORESOURCE_MEM, 0); 184 - if (!r) { 185 - dev_err(&pdev->dev, "no memory resources defined\n"); 186 - return -ENODEV; 187 - } 188 - 189 184 pwm->mmio_base = devm_ioremap_resource(&pdev->dev, r); 190 185 if (IS_ERR(pwm->mmio_base)) 191 186 return PTR_ERR(pwm->mmio_base);
-5
drivers/pwm/pwm-tiecap.c
··· 240 240 pc->chip.npwm = 1; 241 241 242 242 r = platform_get_resource(pdev, IORESOURCE_MEM, 0); 243 - if (!r) { 244 - dev_err(&pdev->dev, "no memory resource defined\n"); 245 - return -ENODEV; 246 - } 247 - 248 243 pc->mmio_base = devm_ioremap_resource(&pdev->dev, r); 249 244 if (IS_ERR(pc->mmio_base)) 250 245 return PTR_ERR(pc->mmio_base);
-5
drivers/pwm/pwm-tiehrpwm.c
··· 471 471 pc->chip.npwm = NUM_PWM_CHANNEL; 472 472 473 473 r = platform_get_resource(pdev, IORESOURCE_MEM, 0); 474 - if (!r) { 475 - dev_err(&pdev->dev, "no memory resource defined\n"); 476 - return -ENODEV; 477 - } 478 - 479 474 pc->mmio_base = devm_ioremap_resource(&pdev->dev, r); 480 475 if (IS_ERR(pc->mmio_base)) 481 476 return PTR_ERR(pc->mmio_base);
-5
drivers/pwm/pwm-tipwmss.c
··· 70 70 mutex_init(&info->pwmss_lock); 71 71 72 72 r = platform_get_resource(pdev, IORESOURCE_MEM, 0); 73 - if (!r) { 74 - dev_err(&pdev->dev, "no memory resource defined\n"); 75 - return -ENODEV; 76 - } 77 - 78 73 info->mmio_base = devm_ioremap_resource(&pdev->dev, r); 79 74 if (IS_ERR(info->mmio_base)) 80 75 return PTR_ERR(info->mmio_base);
-5
drivers/pwm/pwm-vt8500.c
··· 230 230 } 231 231 232 232 r = platform_get_resource(pdev, IORESOURCE_MEM, 0); 233 - if (r == NULL) { 234 - dev_err(&pdev->dev, "no memory resource defined\n"); 235 - return -ENODEV; 236 - } 237 - 238 233 chip->base = devm_ioremap_resource(&pdev->dev, r); 239 234 if (IS_ERR(chip->base)) 240 235 return PTR_ERR(chip->base);
-2
drivers/rtc/Kconfig
··· 20 20 config RTC_HCTOSYS 21 21 bool "Set system time from RTC on startup and resume" 22 22 default y 23 - depends on !ALWAYS_USE_PERSISTENT_CLOCK 24 23 help 25 24 If you say yes here, the system time (wall clock) will be set using 26 25 the value read from a specified RTC device. This is useful to avoid ··· 28 29 config RTC_SYSTOHC 29 30 bool "Set the RTC time based on NTP synchronization" 30 31 default y 31 - depends on !ALWAYS_USE_PERSISTENT_CLOCK 32 32 help 33 33 If you say yes here, the system time (wall clock) will be stored 34 34 in the RTC specified by RTC_HCTOSYS_DEVICE approximately every 11
-5
drivers/rtc/rtc-nuc900.c
··· 234 234 return -ENOMEM; 235 235 } 236 236 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 237 - if (!res) { 238 - dev_err(&pdev->dev, "platform_get_resource failed\n"); 239 - return -ENXIO; 240 - } 241 - 242 237 nuc900_rtc->rtc_reg = devm_ioremap_resource(&pdev->dev, res); 243 238 if (IS_ERR(nuc900_rtc->rtc_reg)) 244 239 return PTR_ERR(nuc900_rtc->rtc_reg);
-5
drivers/rtc/rtc-omap.c
··· 347 347 } 348 348 349 349 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 350 - if (!res) { 351 - pr_debug("%s: RTC resource data missing\n", pdev->name); 352 - return -ENOENT; 353 - } 354 - 355 350 rtc_base = devm_ioremap_resource(&pdev->dev, res); 356 351 if (IS_ERR(rtc_base)) 357 352 return PTR_ERR(rtc_base);
-5
drivers/rtc/rtc-s3c.c
··· 477 477 /* get the memory region */ 478 478 479 479 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 480 - if (res == NULL) { 481 - dev_err(&pdev->dev, "failed to get memory region resource\n"); 482 - return -ENOENT; 483 - } 484 - 485 480 s3c_rtc_base = devm_ioremap_resource(&pdev->dev, res); 486 481 if (IS_ERR(s3c_rtc_base)) 487 482 return PTR_ERR(s3c_rtc_base);
-6
drivers/rtc/rtc-tegra.c
··· 322 322 return -ENOMEM; 323 323 324 324 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 325 - if (!res) { 326 - dev_err(&pdev->dev, 327 - "Unable to allocate resources for device.\n"); 328 - return -EBUSY; 329 - } 330 - 331 325 info->rtc_base = devm_ioremap_resource(&pdev->dev, res); 332 326 if (IS_ERR(info->rtc_base)) 333 327 return PTR_ERR(info->rtc_base);
+40 -11
drivers/spi/spi-atmel.c
··· 526 526 } 527 527 528 528 if (xfer->tx_buf) 529 - spi_writel(as, TDR, *(u8 *)(xfer->tx_buf)); 529 + if (xfer->bits_per_word > 8) 530 + spi_writel(as, TDR, *(u16 *)(xfer->tx_buf)); 531 + else 532 + spi_writel(as, TDR, *(u8 *)(xfer->tx_buf)); 530 533 else 531 534 spi_writel(as, TDR, 0); 532 535 533 536 dev_dbg(master->dev.parent, 534 - " start pio xfer %p: len %u tx %p rx %p\n", 535 - xfer, xfer->len, xfer->tx_buf, xfer->rx_buf); 537 + " start pio xfer %p: len %u tx %p rx %p bitpw %d\n", 538 + xfer, xfer->len, xfer->tx_buf, xfer->rx_buf, 539 + xfer->bits_per_word); 536 540 537 541 /* Enable relevant interrupts */ 538 542 spi_writel(as, IER, SPI_BIT(RDRF) | SPI_BIT(OVRES)); ··· 954 950 { 955 951 u8 *txp; 956 952 u8 *rxp; 953 + u16 *txp16; 954 + u16 *rxp16; 957 955 unsigned long xfer_pos = xfer->len - as->current_remaining_bytes; 958 956 959 957 if (xfer->rx_buf) { 960 - rxp = ((u8 *)xfer->rx_buf) + xfer_pos; 961 - *rxp = spi_readl(as, RDR); 958 + if (xfer->bits_per_word > 8) { 959 + rxp16 = (u16 *)(((u8 *)xfer->rx_buf) + xfer_pos); 960 + *rxp16 = spi_readl(as, RDR); 961 + } else { 962 + rxp = ((u8 *)xfer->rx_buf) + xfer_pos; 963 + *rxp = spi_readl(as, RDR); 964 + } 962 965 } else { 963 966 spi_readl(as, RDR); 964 967 } 965 - 966 - as->current_remaining_bytes--; 968 + if (xfer->bits_per_word > 8) { 969 + as->current_remaining_bytes -= 2; 970 + if (as->current_remaining_bytes < 0) 971 + as->current_remaining_bytes = 0; 972 + } else { 973 + as->current_remaining_bytes--; 974 + } 967 975 968 976 if (as->current_remaining_bytes) { 969 977 if (xfer->tx_buf) { 970 - txp = ((u8 *)xfer->tx_buf) + xfer_pos + 1; 971 - spi_writel(as, TDR, *txp); 978 + if (xfer->bits_per_word > 8) { 979 + txp16 = (u16 *)(((u8 *)xfer->tx_buf) 980 + + xfer_pos + 2); 981 + spi_writel(as, TDR, *txp16); 982 + } else { 983 + txp = ((u8 *)xfer->tx_buf) + xfer_pos + 1; 984 + spi_writel(as, TDR, *txp); 985 + } 972 986 } else { 973 987 spi_writel(as, TDR, 0); 974 988 } ··· 1400 1378 } 1401 1379 } 1402 1380 1381 + if (xfer->bits_per_word > 8) { 1382 + if (xfer->len % 2) { 1383 + dev_dbg(&spi->dev, "buffer len should be 16 bits aligned\n"); 1384 + return -EINVAL; 1385 + } 1386 + } 1387 + 1403 1388 /* FIXME implement these protocol options!! */ 1404 - if (xfer->speed_hz) { 1405 - dev_dbg(&spi->dev, "no protocol options yet\n"); 1389 + if (xfer->speed_hz < spi->max_speed_hz) { 1390 + dev_dbg(&spi->dev, "can't change speed in transfer\n"); 1406 1391 return -ENOPROTOOPT; 1407 1392 } 1408 1393
+1 -1
drivers/spi/spi-davinci.c
··· 784 784 }, 785 785 { }, 786 786 }; 787 - MODULE_DEVICE_TABLE(of, davini_spi_of_match); 787 + MODULE_DEVICE_TABLE(of, davinci_spi_of_match); 788 788 789 789 /** 790 790 * spi_davinci_get_pdata - Get platform data from DTS binding
-5
drivers/spi/spi-tegra20-sflash.c
··· 489 489 tegra_sflash_parse_dt(tsd); 490 490 491 491 r = platform_get_resource(pdev, IORESOURCE_MEM, 0); 492 - if (!r) { 493 - dev_err(&pdev->dev, "No IO memory resource\n"); 494 - ret = -ENODEV; 495 - goto exit_free_master; 496 - } 497 492 tsd->base = devm_ioremap_resource(&pdev->dev, r); 498 493 if (IS_ERR(tsd->base)) { 499 494 ret = PTR_ERR(tsd->base);
+6 -3
drivers/spi/spi.c
··· 334 334 spi->dev.parent = &master->dev; 335 335 spi->dev.bus = &spi_bus_type; 336 336 spi->dev.release = spidev_release; 337 - spi->cs_gpio = -EINVAL; 337 + spi->cs_gpio = -ENOENT; 338 338 device_initialize(&spi->dev); 339 339 return spi; 340 340 } ··· 1067 1067 nb = of_gpio_named_count(np, "cs-gpios"); 1068 1068 master->num_chipselect = max(nb, (int)master->num_chipselect); 1069 1069 1070 - if (nb < 1) 1070 + /* Return error only for an incorrectly formed cs-gpios property */ 1071 + if (nb == 0 || nb == -ENOENT) 1071 1072 return 0; 1073 + else if (nb < 0) 1074 + return nb; 1072 1075 1073 1076 cs = devm_kzalloc(&master->dev, 1074 1077 sizeof(int) * master->num_chipselect, ··· 1082 1079 return -ENOMEM; 1083 1080 1084 1081 for (i = 0; i < master->num_chipselect; i++) 1085 - cs[i] = -EINVAL; 1082 + cs[i] = -ENOENT; 1086 1083 1087 1084 for (i = 0; i < nb; i++) 1088 1085 cs[i] = of_get_named_gpio(np, "cs-gpios", i);
-5
drivers/staging/dwc2/platform.c
··· 102 102 } 103 103 104 104 res = platform_get_resource(dev, IORESOURCE_MEM, 0); 105 - if (!res) { 106 - dev_err(&dev->dev, "missing memory base resource\n"); 107 - return -EINVAL; 108 - } 109 - 110 105 hsotg->regs = devm_ioremap_resource(&dev->dev, res); 111 106 if (IS_ERR(hsotg->regs)) 112 107 return PTR_ERR(hsotg->regs);
-5
drivers/staging/nvec/nvec.c
··· 800 800 } 801 801 802 802 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 803 - if (!res) { 804 - dev_err(&pdev->dev, "no mem resource?\n"); 805 - return -ENODEV; 806 - } 807 - 808 803 base = devm_ioremap_resource(&pdev->dev, res); 809 804 if (IS_ERR(base)) 810 805 return PTR_ERR(base);
+26 -37
drivers/target/iscsi/iscsi_target.c
··· 1250 1250 1251 1251 static void iscsit_do_crypto_hash_buf( 1252 1252 struct hash_desc *hash, 1253 - unsigned char *buf, 1253 + const void *buf, 1254 1254 u32 payload_length, 1255 1255 u32 padding, 1256 1256 u8 *pad_bytes, ··· 2524 2524 if (conn->conn_ops->HeaderDigest) { 2525 2525 u32 *header_digest = (u32 *)&cmd->pdu[ISCSI_HDR_LEN]; 2526 2526 2527 - iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, 2528 - (unsigned char *)hdr, ISCSI_HDR_LEN, 2529 - 0, NULL, (u8 *)header_digest); 2527 + iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, hdr, 2528 + ISCSI_HDR_LEN, 0, NULL, (u8 *)header_digest); 2530 2529 2531 2530 cmd->tx_size += ISCSI_CRC_LEN; 2532 2531 pr_debug("Attaching CRC32C HeaderDigest to" ··· 2661 2662 if (conn->conn_ops->HeaderDigest) { 2662 2663 u32 *header_digest = (u32 *)&cmd->pdu[ISCSI_HDR_LEN]; 2663 2664 2664 - iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, 2665 - (unsigned char *)cmd->pdu, ISCSI_HDR_LEN, 2666 - 0, NULL, (u8 *)header_digest); 2665 + iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, cmd->pdu, 2666 + ISCSI_HDR_LEN, 0, NULL, (u8 *)header_digest); 2667 2667 2668 2668 iov[0].iov_len += ISCSI_CRC_LEN; 2669 2669 tx_size += ISCSI_CRC_LEN; ··· 2839 2841 if (conn->conn_ops->HeaderDigest) { 2840 2842 u32 *header_digest = (u32 *)&cmd->pdu[ISCSI_HDR_LEN]; 2841 2843 2842 - iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, 2843 - (unsigned char *)&cmd->pdu[0], ISCSI_HDR_LEN, 2844 - 0, NULL, (u8 *)header_digest); 2844 + iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, &cmd->pdu[0], 2845 + ISCSI_HDR_LEN, 0, NULL, (u8 *)header_digest); 2845 2846 2846 2847 iov[0].iov_len += ISCSI_CRC_LEN; 2847 2848 tx_size += ISCSI_CRC_LEN; ··· 2897 2900 if (conn->conn_ops->HeaderDigest) { 2898 2901 u32 *header_digest = (u32 *)&cmd->pdu[ISCSI_HDR_LEN]; 2899 2902 2900 - iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, 2901 - (unsigned char *)hdr, ISCSI_HDR_LEN, 2902 - 0, NULL, (u8 *)header_digest); 2903 + iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, hdr, 2904 + ISCSI_HDR_LEN, 0, NULL, (u8 *)header_digest); 2903 2905 2904 2906 tx_size += ISCSI_CRC_LEN; 2905 2907 pr_debug("Attaching CRC32C HeaderDigest to" ··· 2945 2949 if (conn->conn_ops->HeaderDigest) { 2946 2950 u32 *header_digest = (u32 *)&cmd->pdu[ISCSI_HDR_LEN]; 2947 2951 2948 - iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, 2949 - (unsigned char *)hdr, ISCSI_HDR_LEN, 2950 - 0, NULL, (u8 *)header_digest); 2952 + iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, hdr, 2953 + ISCSI_HDR_LEN, 0, NULL, (u8 *)header_digest); 2951 2954 2952 2955 iov[0].iov_len += ISCSI_CRC_LEN; 2953 2956 tx_size += ISCSI_CRC_LEN; ··· 3035 3040 if (conn->conn_ops->HeaderDigest) { 3036 3041 u32 *header_digest = (u32 *)&cmd->pdu[ISCSI_HDR_LEN]; 3037 3042 3038 - iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, 3039 - (unsigned char *)hdr, ISCSI_HDR_LEN, 3040 - 0, NULL, (u8 *)header_digest); 3043 + iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, hdr, 3044 + ISCSI_HDR_LEN, 0, NULL, (u8 *)header_digest); 3041 3045 3042 3046 cmd->iov_misc[0].iov_len += ISCSI_CRC_LEN; 3043 3047 tx_size += ISCSI_CRC_LEN; ··· 3250 3256 if (conn->conn_ops->HeaderDigest) { 3251 3257 u32 *header_digest = (u32 *)&cmd->pdu[ISCSI_HDR_LEN]; 3252 3258 3253 - iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, 3254 - (unsigned char *)cmd->pdu, ISCSI_HDR_LEN, 3255 - 0, NULL, (u8 *)header_digest); 3259 + iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, cmd->pdu, 3260 + ISCSI_HDR_LEN, 0, NULL, (u8 *)header_digest); 3256 3261 3257 3262 iov[0].iov_len += ISCSI_CRC_LEN; 3258 3263 tx_size += ISCSI_CRC_LEN; ··· 3322 3329 if (conn->conn_ops->HeaderDigest) { 3323 3330 u32 *header_digest = (u32 *)&cmd->pdu[ISCSI_HDR_LEN]; 3324 3331 3325 - iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, 3326 - (unsigned char *)hdr, ISCSI_HDR_LEN, 3327 - 0, NULL, (u8 *)header_digest); 3332 + iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, hdr, 3333 + ISCSI_HDR_LEN, 0, NULL, (u8 *)header_digest); 3328 3334 3329 3335 cmd->iov_misc[0].iov_len += ISCSI_CRC_LEN; 3330 3336 tx_size += ISCSI_CRC_LEN; ··· 3496 3504 if (conn->conn_ops->HeaderDigest) { 3497 3505 u32 *header_digest = (u32 *)&cmd->pdu[ISCSI_HDR_LEN]; 3498 3506 3499 - iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, 3500 - (unsigned char *)hdr, ISCSI_HDR_LEN, 3501 - 0, NULL, (u8 *)header_digest); 3507 + iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, hdr, 3508 + ISCSI_HDR_LEN, 0, NULL, (u8 *)header_digest); 3502 3509 3503 3510 iov[0].iov_len += ISCSI_CRC_LEN; 3504 3511 tx_size += ISCSI_CRC_LEN; ··· 3548 3557 struct iscsi_cmd *cmd, 3549 3558 struct iscsi_conn *conn) 3550 3559 { 3551 - u32 iov_count = 0, tx_size = 0; 3552 - struct iscsi_reject *hdr; 3560 + struct iscsi_reject *hdr = (struct iscsi_reject *)&cmd->pdu[0]; 3553 3561 struct kvec *iov; 3562 + u32 iov_count = 0, tx_size; 3554 3563 3555 - iscsit_build_reject(cmd, conn, (struct iscsi_reject *)&cmd->pdu[0]); 3564 + iscsit_build_reject(cmd, conn, hdr); 3556 3565 3557 3566 iov = &cmd->iov_misc[0]; 3558 3567 iov[iov_count].iov_base = cmd->pdu; ··· 3565 3574 if (conn->conn_ops->HeaderDigest) { 3566 3575 u32 *header_digest = (u32 *)&cmd->pdu[ISCSI_HDR_LEN]; 3567 3576 3568 - iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, 3569 - (unsigned char *)hdr, ISCSI_HDR_LEN, 3570 - 0, NULL, (u8 *)header_digest); 3577 + iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, hdr, 3578 + ISCSI_HDR_LEN, 0, NULL, (u8 *)header_digest); 3571 3579 3572 3580 iov[0].iov_len += ISCSI_CRC_LEN; 3573 3581 tx_size += ISCSI_CRC_LEN; ··· 3575 3585 } 3576 3586 3577 3587 if (conn->conn_ops->DataDigest) { 3578 - iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, 3579 - (unsigned char *)cmd->buf_ptr, ISCSI_HDR_LEN, 3580 - 0, NULL, (u8 *)&cmd->data_crc); 3588 + iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, cmd->buf_ptr, 3589 + ISCSI_HDR_LEN, 0, NULL, (u8 *)&cmd->data_crc); 3581 3590 3582 3591 iov[iov_count].iov_base = &cmd->data_crc; 3583 3592 iov[iov_count++].iov_len = ISCSI_CRC_LEN;
+4 -3
drivers/target/iscsi/iscsi_target_erl1.c
··· 823 823 /* 824 824 * CmdSN is greater than the tail of the list. 825 825 */ 826 - if (ooo_tail->cmdsn < ooo_cmdsn->cmdsn) 826 + if (iscsi_sna_lt(ooo_tail->cmdsn, ooo_cmdsn->cmdsn)) 827 827 list_add_tail(&ooo_cmdsn->ooo_list, 828 828 &sess->sess_ooo_cmdsn_list); 829 829 else { ··· 833 833 */ 834 834 list_for_each_entry(ooo_tmp, &sess->sess_ooo_cmdsn_list, 835 835 ooo_list) { 836 - if (ooo_tmp->cmdsn < ooo_cmdsn->cmdsn) 836 + if (iscsi_sna_lt(ooo_tmp->cmdsn, ooo_cmdsn->cmdsn)) 837 837 continue; 838 838 839 + /* Insert before this entry */ 839 840 list_add(&ooo_cmdsn->ooo_list, 840 - &ooo_tmp->ooo_list); 841 + ooo_tmp->ooo_list.prev); 841 842 break; 842 843 } 843 844 }
+4 -4
drivers/target/iscsi/iscsi_target_parameters.c
··· 436 436 /* 437 437 * Extra parameters for ISER from RFC-5046 438 438 */ 439 - param = iscsi_set_default_param(pl, RDMAEXTENTIONS, INITIAL_RDMAEXTENTIONS, 439 + param = iscsi_set_default_param(pl, RDMAEXTENSIONS, INITIAL_RDMAEXTENSIONS, 440 440 PHASE_OPERATIONAL, SCOPE_SESSION_WIDE, SENDER_BOTH, 441 441 TYPERANGE_BOOL_AND, USE_LEADING_ONLY); 442 442 if (!param) ··· 529 529 SET_PSTATE_NEGOTIATE(param); 530 530 } else if (!strcmp(param->name, OFMARKINT)) { 531 531 SET_PSTATE_NEGOTIATE(param); 532 - } else if (!strcmp(param->name, RDMAEXTENTIONS)) { 532 + } else if (!strcmp(param->name, RDMAEXTENSIONS)) { 533 533 if (iser == true) 534 534 SET_PSTATE_NEGOTIATE(param); 535 535 } else if (!strcmp(param->name, INITIATORRECVDATASEGMENTLENGTH)) { ··· 580 580 param->state &= ~PSTATE_NEGOTIATE; 581 581 else if (!strcmp(param->name, OFMARKINT)) 582 582 param->state &= ~PSTATE_NEGOTIATE; 583 - else if (!strcmp(param->name, RDMAEXTENTIONS)) 583 + else if (!strcmp(param->name, RDMAEXTENSIONS)) 584 584 param->state &= ~PSTATE_NEGOTIATE; 585 585 else if (!strcmp(param->name, INITIATORRECVDATASEGMENTLENGTH)) 586 586 param->state &= ~PSTATE_NEGOTIATE; ··· 1977 1977 ops->SessionType = !strcmp(param->value, DISCOVERY); 1978 1978 pr_debug("SessionType: %s\n", 1979 1979 param->value); 1980 - } else if (!strcmp(param->name, RDMAEXTENTIONS)) { 1980 + } else if (!strcmp(param->name, RDMAEXTENSIONS)) { 1981 1981 ops->RDMAExtensions = !strcmp(param->value, YES); 1982 1982 pr_debug("RDMAExtensions: %s\n", 1983 1983 param->value);
+2 -2
drivers/target/iscsi/iscsi_target_parameters.h
··· 91 91 /* 92 92 * Parameter names of iSCSI Extentions for RDMA (iSER). See RFC-5046 93 93 */ 94 - #define RDMAEXTENTIONS "RDMAExtensions" 94 + #define RDMAEXTENSIONS "RDMAExtensions" 95 95 #define INITIATORRECVDATASEGMENTLENGTH "InitiatorRecvDataSegmentLength" 96 96 #define TARGETRECVDATASEGMENTLENGTH "TargetRecvDataSegmentLength" 97 97 ··· 142 142 /* 143 143 * Initial values for iSER parameters following RFC-5046 Section 6 144 144 */ 145 - #define INITIAL_RDMAEXTENTIONS NO 145 + #define INITIAL_RDMAEXTENSIONS NO 146 146 #define INITIAL_INITIATORRECVDATASEGMENTLENGTH "262144" 147 147 #define INITIAL_TARGETRECVDATASEGMENTLENGTH "8192" 148 148
+9 -2
drivers/target/target_core_configfs.c
··· 1584 1584 .store = target_core_store_dev_udev_path, 1585 1585 }; 1586 1586 1587 + static ssize_t target_core_show_dev_enable(void *p, char *page) 1588 + { 1589 + struct se_device *dev = p; 1590 + 1591 + return snprintf(page, PAGE_SIZE, "%d\n", !!(dev->dev_flags & DF_CONFIGURED)); 1592 + } 1593 + 1587 1594 static ssize_t target_core_store_dev_enable( 1588 1595 void *p, 1589 1596 const char *page, ··· 1616 1609 static struct target_core_configfs_attribute target_core_attr_dev_enable = { 1617 1610 .attr = { .ca_owner = THIS_MODULE, 1618 1611 .ca_name = "enable", 1619 - .ca_mode = S_IWUSR }, 1620 - .show = NULL, 1612 + .ca_mode = S_IRUGO | S_IWUSR }, 1613 + .show = target_core_show_dev_enable, 1621 1614 .store = target_core_store_dev_enable, 1622 1615 }; 1623 1616
-14
drivers/target/target_core_device.c
··· 68 68 struct se_dev_entry *deve = se_cmd->se_deve; 69 69 70 70 deve->total_cmds++; 71 - deve->total_bytes += se_cmd->data_length; 72 71 73 72 if ((se_cmd->data_direction == DMA_TO_DEVICE) && 74 73 (deve->lun_flags & TRANSPORT_LUNFLAGS_READ_ONLY)) { ··· 83 84 deve->write_bytes += se_cmd->data_length; 84 85 else if (se_cmd->data_direction == DMA_FROM_DEVICE) 85 86 deve->read_bytes += se_cmd->data_length; 86 - 87 - deve->deve_cmds++; 88 87 89 88 se_lun = deve->se_lun; 90 89 se_cmd->se_lun = deve->se_lun; ··· 270 273 nacl->device_list = NULL; 271 274 272 275 return 0; 273 - } 274 - 275 - void core_dec_lacl_count(struct se_node_acl *se_nacl, struct se_cmd *se_cmd) 276 - { 277 - struct se_dev_entry *deve; 278 - unsigned long flags; 279 - 280 - spin_lock_irqsave(&se_nacl->device_list_lock, flags); 281 - deve = se_nacl->device_list[se_cmd->orig_fe_lun]; 282 - deve->deve_cmds--; 283 - spin_unlock_irqrestore(&se_nacl->device_list_lock, flags); 284 276 } 285 277 286 278 void core_update_device_list_access(
+2 -7
drivers/target/target_core_file.c
··· 153 153 struct request_queue *q = bdev_get_queue(inode->i_bdev); 154 154 unsigned long long dev_size; 155 155 156 - dev->dev_attrib.hw_block_size = 157 - bdev_logical_block_size(inode->i_bdev); 158 - dev->dev_attrib.hw_max_sectors = queue_max_hw_sectors(q); 159 - 160 156 /* 161 157 * Determine the number of bytes from i_size_read() minus 162 158 * one (1) logical sector from underlying struct block_device ··· 199 203 goto fail; 200 204 } 201 205 202 - dev->dev_attrib.hw_block_size = FD_BLOCKSIZE; 203 - dev->dev_attrib.hw_max_sectors = FD_MAX_SECTORS; 204 - 205 206 /* 206 207 * Limit UNMAP emulation to 8k Number of LBAs (NoLB) 207 208 */ ··· 219 226 220 227 fd_dev->fd_block_size = dev->dev_attrib.hw_block_size; 221 228 229 + dev->dev_attrib.hw_block_size = FD_BLOCKSIZE; 230 + dev->dev_attrib.hw_max_sectors = FD_MAX_SECTORS; 222 231 dev->dev_attrib.hw_queue_depth = FD_MAX_DEVICE_QUEUE_DEPTH; 223 232 224 233 if (fd_dev->fbd_flags & FDBD_HAS_BUFFERED_IO_WCE) {
+2
drivers/target/target_core_iblock.c
··· 615 615 rw = WRITE_FUA; 616 616 else if (!(q->flush_flags & REQ_FLUSH)) 617 617 rw = WRITE_FUA; 618 + else 619 + rw = WRITE; 618 620 } else { 619 621 rw = WRITE; 620 622 }
-1
drivers/target/target_core_internal.h
··· 8 8 struct se_dev_entry *core_get_se_deve_from_rtpi(struct se_node_acl *, u16); 9 9 int core_free_device_list_for_node(struct se_node_acl *, 10 10 struct se_portal_group *); 11 - void core_dec_lacl_count(struct se_node_acl *, struct se_cmd *); 12 11 void core_update_device_list_access(u32, u32, struct se_node_acl *); 13 12 int core_enable_device_list_for_node(struct se_lun *, struct se_lun_acl *, 14 13 u32, u32, struct se_node_acl *, struct se_portal_group *);
+18 -3
drivers/target/target_core_rd.c
··· 291 291 u32 src_len; 292 292 u64 tmp; 293 293 294 + if (dev->rd_flags & RDF_NULLIO) { 295 + target_complete_cmd(cmd, SAM_STAT_GOOD); 296 + return 0; 297 + } 298 + 294 299 tmp = cmd->t_task_lba * se_dev->dev_attrib.block_size; 295 300 rd_offset = do_div(tmp, PAGE_SIZE); 296 301 rd_page = tmp; ··· 378 373 } 379 374 380 375 enum { 381 - Opt_rd_pages, Opt_err 376 + Opt_rd_pages, Opt_rd_nullio, Opt_err 382 377 }; 383 378 384 379 static match_table_t tokens = { 385 380 {Opt_rd_pages, "rd_pages=%d"}, 381 + {Opt_rd_nullio, "rd_nullio=%d"}, 386 382 {Opt_err, NULL} 387 383 }; 388 384 ··· 414 408 " Count: %u\n", rd_dev->rd_page_count); 415 409 rd_dev->rd_flags |= RDF_HAS_PAGE_COUNT; 416 410 break; 411 + case Opt_rd_nullio: 412 + match_int(args, &arg); 413 + if (arg != 1) 414 + break; 415 + 416 + pr_debug("RAMDISK: Setting NULLIO flag: %d\n", arg); 417 + rd_dev->rd_flags |= RDF_NULLIO; 418 + break; 417 419 default: 418 420 break; 419 421 } ··· 438 424 ssize_t bl = sprintf(b, "TCM RamDisk ID: %u RamDisk Makeup: rd_mcp\n", 439 425 rd_dev->rd_dev_id); 440 426 bl += sprintf(b + bl, " PAGES/PAGE_SIZE: %u*%lu" 441 - " SG_table_count: %u\n", rd_dev->rd_page_count, 442 - PAGE_SIZE, rd_dev->sg_table_count); 427 + " SG_table_count: %u nullio: %d\n", rd_dev->rd_page_count, 428 + PAGE_SIZE, rd_dev->sg_table_count, 429 + !!(rd_dev->rd_flags & RDF_NULLIO)); 443 430 return bl; 444 431 } 445 432
+1
drivers/target/target_core_rd.h
··· 22 22 } ____cacheline_aligned; 23 23 24 24 #define RDF_HAS_PAGE_COUNT 0x01 25 + #define RDF_NULLIO 0x02 25 26 26 27 struct rd_dev { 27 28 struct se_device dev;
+5 -8
drivers/target/target_core_transport.c
··· 2163 2163 if (wait_for_tasks) 2164 2164 transport_wait_for_tasks(cmd); 2165 2165 2166 - core_dec_lacl_count(cmd->se_sess->se_node_acl, cmd); 2167 - 2168 2166 if (cmd->se_lun) 2169 2167 transport_lun_remove_cmd(cmd); 2170 2168 ··· 2211 2213 { 2212 2214 struct se_cmd *se_cmd = container_of(kref, struct se_cmd, cmd_kref); 2213 2215 struct se_session *se_sess = se_cmd->se_sess; 2214 - unsigned long flags; 2215 2216 2216 - spin_lock_irqsave(&se_sess->sess_cmd_lock, flags); 2217 2217 if (list_empty(&se_cmd->se_cmd_list)) { 2218 - spin_unlock_irqrestore(&se_sess->sess_cmd_lock, flags); 2218 + spin_unlock(&se_sess->sess_cmd_lock); 2219 2219 se_cmd->se_tfo->release_cmd(se_cmd); 2220 2220 return; 2221 2221 } 2222 2222 if (se_sess->sess_tearing_down && se_cmd->cmd_wait_set) { 2223 - spin_unlock_irqrestore(&se_sess->sess_cmd_lock, flags); 2223 + spin_unlock(&se_sess->sess_cmd_lock); 2224 2224 complete(&se_cmd->cmd_wait_comp); 2225 2225 return; 2226 2226 } 2227 2227 list_del(&se_cmd->se_cmd_list); 2228 - spin_unlock_irqrestore(&se_sess->sess_cmd_lock, flags); 2228 + spin_unlock(&se_sess->sess_cmd_lock); 2229 2229 2230 2230 se_cmd->se_tfo->release_cmd(se_cmd); 2231 2231 } ··· 2234 2238 */ 2235 2239 int target_put_sess_cmd(struct se_session *se_sess, struct se_cmd *se_cmd) 2236 2240 { 2237 - return kref_put(&se_cmd->cmd_kref, target_release_cmd_kref); 2241 + return kref_put_spinlock_irqsave(&se_cmd->cmd_kref, target_release_cmd_kref, 2242 + &se_sess->sess_cmd_lock); 2238 2243 } 2239 2244 EXPORT_SYMBOL(target_put_sess_cmd); 2240 2245
-10
drivers/thermal/armada_thermal.c
··· 169 169 return -ENOMEM; 170 170 171 171 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 172 - if (!res) { 173 - dev_err(&pdev->dev, "Failed to get platform resource\n"); 174 - return -ENODEV; 175 - } 176 - 177 172 priv->sensor = devm_ioremap_resource(&pdev->dev, res); 178 173 if (IS_ERR(priv->sensor)) 179 174 return PTR_ERR(priv->sensor); 180 175 181 176 res = platform_get_resource(pdev, IORESOURCE_MEM, 1); 182 - if (!res) { 183 - dev_err(&pdev->dev, "Failed to get platform resource\n"); 184 - return -ENODEV; 185 - } 186 - 187 177 priv->control = devm_ioremap_resource(&pdev->dev, res); 188 178 if (IS_ERR(priv->control)) 189 179 return PTR_ERR(priv->control);
-4
drivers/thermal/dove_thermal.c
··· 149 149 return PTR_ERR(priv->sensor); 150 150 151 151 res = platform_get_resource(pdev, IORESOURCE_MEM, 1); 152 - if (!res) { 153 - dev_err(&pdev->dev, "Failed to get platform resource\n"); 154 - return -ENODEV; 155 - } 156 152 priv->control = devm_ioremap_resource(&pdev->dev, res); 157 153 if (IS_ERR(priv->control)) 158 154 return PTR_ERR(priv->control);
-5
drivers/thermal/exynos_thermal.c
··· 925 925 INIT_WORK(&data->irq_work, exynos_tmu_work); 926 926 927 927 data->mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 928 - if (!data->mem) { 929 - dev_err(&pdev->dev, "Failed to get platform resource\n"); 930 - return -ENOENT; 931 - } 932 - 933 928 data->base = devm_ioremap_resource(&pdev->dev, data->mem); 934 929 if (IS_ERR(data->base)) 935 930 return PTR_ERR(data->base);
-5
drivers/usb/chipidea/core.c
··· 370 370 } 371 371 372 372 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 373 - if (!res) { 374 - dev_err(dev, "missing resource\n"); 375 - return -ENODEV; 376 - } 377 - 378 373 base = devm_ioremap_resource(dev, res); 379 374 if (IS_ERR(base)) 380 375 return PTR_ERR(base);
-10
drivers/usb/gadget/bcm63xx_udc.c
··· 2334 2334 } 2335 2335 2336 2336 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 2337 - if (!res) { 2338 - dev_err(dev, "error finding USBD resource\n"); 2339 - return -ENXIO; 2340 - } 2341 - 2342 2337 udc->usbd_regs = devm_ioremap_resource(dev, res); 2343 2338 if (IS_ERR(udc->usbd_regs)) 2344 2339 return PTR_ERR(udc->usbd_regs); 2345 2340 2346 2341 res = platform_get_resource(pdev, IORESOURCE_MEM, 1); 2347 - if (!res) { 2348 - dev_err(dev, "error finding IUDMA resource\n"); 2349 - return -ENXIO; 2350 - } 2351 - 2352 2342 udc->iudma_regs = devm_ioremap_resource(dev, res); 2353 2343 if (IS_ERR(udc->iudma_regs)) 2354 2344 return PTR_ERR(udc->iudma_regs);
-6
drivers/usb/host/ohci-nxp.c
··· 300 300 } 301 301 302 302 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 303 - if (!res) { 304 - dev_err(&pdev->dev, "Failed to get MEM resource\n"); 305 - ret = -ENOMEM; 306 - goto out8; 307 - } 308 - 309 303 hcd->regs = devm_ioremap_resource(&pdev->dev, res); 310 304 if (IS_ERR(hcd->regs)) { 311 305 ret = PTR_ERR(hcd->regs);
-5
drivers/usb/phy/phy-mv-u3d-usb.c
··· 278 278 } 279 279 280 280 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 281 - if (!res) { 282 - dev_err(dev, "missing mem resource\n"); 283 - return -ENODEV; 284 - } 285 - 286 281 phy_base = devm_ioremap_resource(dev, res); 287 282 if (IS_ERR(phy_base)) 288 283 return PTR_ERR(phy_base);
-5
drivers/usb/phy/phy-mxs-usb.c
··· 130 130 int ret; 131 131 132 132 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 133 - if (!res) { 134 - dev_err(&pdev->dev, "can't get device resources\n"); 135 - return -ENOENT; 136 - } 137 - 138 133 base = devm_ioremap_resource(&pdev->dev, res); 139 134 if (IS_ERR(base)) 140 135 return PTR_ERR(base);
-5
drivers/usb/phy/phy-samsung-usb2.c
··· 363 363 int ret; 364 364 365 365 phy_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 366 - if (!phy_mem) { 367 - dev_err(dev, "%s: missing mem resource\n", __func__); 368 - return -ENODEV; 369 - } 370 - 371 366 phy_base = devm_ioremap_resource(dev, phy_mem); 372 367 if (IS_ERR(phy_base)) 373 368 return PTR_ERR(phy_base);
-5
drivers/usb/phy/phy-samsung-usb3.c
··· 239 239 int ret; 240 240 241 241 phy_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 242 - if (!phy_mem) { 243 - dev_err(dev, "%s: missing mem resource\n", __func__); 244 - return -ENODEV; 245 - } 246 - 247 242 phy_base = devm_ioremap_resource(dev, phy_mem); 248 243 if (IS_ERR(phy_base)) 249 244 return PTR_ERR(phy_base);
+3
drivers/vhost/vringh.c
··· 3 3 * 4 4 * Since these may be in userspace, we use (inline) accessors. 5 5 */ 6 + #include <linux/module.h> 6 7 #include <linux/vringh.h> 7 8 #include <linux/virtio_ring.h> 8 9 #include <linux/kernel.h> ··· 1006 1005 return __vringh_need_notify(vrh, getu16_kern); 1007 1006 } 1008 1007 EXPORT_SYMBOL(vringh_need_notify_kern); 1008 + 1009 + MODULE_LICENSE("GPL");
-4
drivers/video/omap2/dss/hdmi.c
··· 1065 1065 mutex_init(&hdmi.ip_data.lock); 1066 1066 1067 1067 res = platform_get_resource(hdmi.pdev, IORESOURCE_MEM, 0); 1068 - if (!res) { 1069 - DSSERR("can't get IORESOURCE_MEM HDMI\n"); 1070 - return -EINVAL; 1071 - } 1072 1068 1073 1069 /* Base address taken from platform */ 1074 1070 hdmi.ip_data.base_wp = devm_ioremap_resource(&pdev->dev, res);
-5
drivers/video/omap2/vrfb.c
··· 353 353 /* first resource is the register res, the rest are vrfb contexts */ 354 354 355 355 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 356 - if (!mem) { 357 - dev_err(&pdev->dev, "can't get vrfb base address\n"); 358 - return -EINVAL; 359 - } 360 - 361 356 vrfb_base = devm_ioremap_resource(&pdev->dev, mem); 362 357 if (IS_ERR(vrfb_base)) 363 358 return PTR_ERR(vrfb_base);
-5
drivers/w1/masters/omap_hdq.c
··· 555 555 platform_set_drvdata(pdev, hdq_data); 556 556 557 557 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 558 - if (!res) { 559 - dev_dbg(&pdev->dev, "unable to get resource\n"); 560 - return -ENXIO; 561 - } 562 - 563 558 hdq_data->hdq_base = devm_ioremap_resource(dev, res); 564 559 if (IS_ERR(hdq_data->hdq_base)) 565 560 return PTR_ERR(hdq_data->hdq_base);
-5
drivers/watchdog/ath79_wdt.c
··· 248 248 return -EBUSY; 249 249 250 250 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 251 - if (!res) { 252 - dev_err(&pdev->dev, "no memory resource found\n"); 253 - return -EINVAL; 254 - } 255 - 256 251 wdt_base = devm_ioremap_resource(&pdev->dev, res); 257 252 if (IS_ERR(wdt_base)) 258 253 return PTR_ERR(wdt_base);
-5
drivers/watchdog/davinci_wdt.c
··· 217 217 dev_info(dev, "heartbeat %d sec\n", heartbeat); 218 218 219 219 wdt_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 220 - if (wdt_mem == NULL) { 221 - dev_err(dev, "failed to get memory region resource\n"); 222 - return -ENOENT; 223 - } 224 - 225 220 wdt_base = devm_ioremap_resource(dev, wdt_mem); 226 221 if (IS_ERR(wdt_base)) 227 222 return PTR_ERR(wdt_base);
-5
drivers/watchdog/imx2_wdt.c
··· 257 257 struct resource *res; 258 258 259 259 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 260 - if (!res) { 261 - dev_err(&pdev->dev, "can't get device resources\n"); 262 - return -ENODEV; 263 - } 264 - 265 260 imx2_wdt.base = devm_ioremap_resource(&pdev->dev, res); 266 261 if (IS_ERR(imx2_wdt.base)) 267 262 return PTR_ERR(imx2_wdt.base);
+3 -4
drivers/xen/Kconfig
··· 19 19 by the current usage of anonymous memory ("committed AS") and 20 20 controlled by various sysfs-settable parameters. Configuring 21 21 FRONTSWAP is highly recommended; if it is not configured, self- 22 - ballooning is disabled by default but can be enabled with the 23 - 'selfballooning' kernel boot parameter. If FRONTSWAP is configured, 22 + ballooning is disabled by default. If FRONTSWAP is configured, 24 23 frontswap-selfshrinking is enabled by default but can be disabled 25 - with the 'noselfshrink' kernel boot parameter; and self-ballooning 26 - is enabled by default but can be disabled with the 'noselfballooning' 24 + with the 'tmem.selfshrink=0' kernel boot parameter; and self-ballooning 25 + is enabled by default but can be disabled with the 'tmem.selfballooning=0' 27 26 kernel boot parameter. Note that systems without a sufficiently 28 27 large swap device should not enable self-ballooning. 29 28
+2 -1
drivers/xen/balloon.c
··· 407 407 nr_pages = ARRAY_SIZE(frame_list); 408 408 409 409 for (i = 0; i < nr_pages; i++) { 410 - if ((page = alloc_page(gfp)) == NULL) { 410 + page = alloc_page(gfp); 411 + if (page == NULL) { 411 412 nr_pages = i; 412 413 state = BP_EAGAIN; 413 414 break;
+1 -1
drivers/xen/privcmd.c
··· 504 504 struct page **pages = vma->vm_private_data; 505 505 int numpgs = (vma->vm_end - vma->vm_start) >> PAGE_SHIFT; 506 506 507 - if (!xen_feature(XENFEAT_auto_translated_physmap || !numpgs || !pages)) 507 + if (!xen_feature(XENFEAT_auto_translated_physmap) || !numpgs || !pages) 508 508 return; 509 509 510 510 xen_unmap_domain_mfn_range(vma, numpgs, pages);
+39 -48
drivers/xen/tmem.c
··· 11 11 #include <linux/init.h> 12 12 #include <linux/pagemap.h> 13 13 #include <linux/cleancache.h> 14 - 15 - /* temporary ifdef until include/linux/frontswap.h is upstream */ 16 - #ifdef CONFIG_FRONTSWAP 17 14 #include <linux/frontswap.h> 18 - #endif 19 15 20 16 #include <xen/xen.h> 21 17 #include <xen/interface/xen.h> ··· 19 23 #include <asm/xen/page.h> 20 24 #include <asm/xen/hypervisor.h> 21 25 #include <xen/tmem.h> 26 + 27 + #ifndef CONFIG_XEN_TMEM_MODULE 28 + bool __read_mostly tmem_enabled = false; 29 + 30 + static int __init enable_tmem(char *s) 31 + { 32 + tmem_enabled = true; 33 + return 1; 34 + } 35 + __setup("tmem", enable_tmem); 36 + #endif 37 + 38 + #ifdef CONFIG_CLEANCACHE 39 + static bool cleancache __read_mostly = true; 40 + module_param(cleancache, bool, S_IRUGO); 41 + static bool selfballooning __read_mostly = true; 42 + module_param(selfballooning, bool, S_IRUGO); 43 + #endif /* CONFIG_CLEANCACHE */ 44 + 45 + #ifdef CONFIG_FRONTSWAP 46 + static bool frontswap __read_mostly = true; 47 + module_param(frontswap, bool, S_IRUGO); 48 + #endif /* CONFIG_FRONTSWAP */ 49 + 50 + #ifdef CONFIG_XEN_SELFBALLOONING 51 + static bool selfshrinking __read_mostly = true; 52 + module_param(selfshrinking, bool, S_IRUGO); 53 + #endif /* CONFIG_XEN_SELFBALLOONING */ 22 54 23 55 #define TMEM_CONTROL 0 24 56 #define TMEM_NEW_POOL 1 ··· 153 129 return xen_tmem_op(TMEM_FLUSH_OBJECT, pool_id, oid, 0, 0, 0, 0, 0); 154 130 } 155 131 156 - #ifndef CONFIG_XEN_TMEM_MODULE 157 - bool __read_mostly tmem_enabled = false; 158 - 159 - static int __init enable_tmem(char *s) 160 - { 161 - tmem_enabled = true; 162 - return 1; 163 - } 164 - __setup("tmem", enable_tmem); 165 - #endif 166 132 167 133 #ifdef CONFIG_CLEANCACHE 168 134 static int xen_tmem_destroy_pool(u32 pool_id) ··· 243 229 shared_uuid.uuid_hi = *(u64 *)(&uuid[8]); 244 230 return xen_tmem_new_pool(shared_uuid, TMEM_POOL_SHARED, pagesize); 245 231 } 246 - 247 - static bool disable_cleancache __read_mostly; 248 - static bool disable_selfballooning __read_mostly; 249 - #ifdef CONFIG_XEN_TMEM_MODULE 250 - module_param(disable_cleancache, bool, S_IRUGO); 251 - module_param(disable_selfballooning, bool, S_IRUGO); 252 - #else 253 - static int __init no_cleancache(char *s) 254 - { 255 - disable_cleancache = true; 256 - return 1; 257 - } 258 - __setup("nocleancache", no_cleancache); 259 - #endif 260 232 261 233 static struct cleancache_ops tmem_cleancache_ops = { 262 234 .put_page = tmem_cleancache_put_page, ··· 361 361 xen_tmem_new_pool(private, TMEM_POOL_PERSIST, PAGE_SIZE); 362 362 } 363 363 364 - static bool disable_frontswap __read_mostly; 365 - static bool disable_frontswap_selfshrinking __read_mostly; 366 - #ifdef CONFIG_XEN_TMEM_MODULE 367 - module_param(disable_frontswap, bool, S_IRUGO); 368 - module_param(disable_frontswap_selfshrinking, bool, S_IRUGO); 369 - #else 370 - static int __init no_frontswap(char *s) 371 - { 372 - disable_frontswap = true; 373 - return 1; 374 - } 375 - __setup("nofrontswap", no_frontswap); 376 - #endif 377 - 378 364 static struct frontswap_ops tmem_frontswap_ops = { 379 365 .store = tmem_frontswap_store, 380 366 .load = tmem_frontswap_load, ··· 368 382 .invalidate_area = tmem_frontswap_flush_area, 369 383 .init = tmem_frontswap_init 370 384 }; 371 - #else /* CONFIG_FRONTSWAP */ 372 - #define disable_frontswap_selfshrinking 1 373 385 #endif 374 386 375 387 static int xen_tmem_init(void) ··· 375 391 if (!xen_domain()) 376 392 return 0; 377 393 #ifdef CONFIG_FRONTSWAP 378 - if (tmem_enabled && !disable_frontswap) { 394 + if (tmem_enabled && frontswap) { 379 395 char *s = ""; 380 396 struct frontswap_ops *old_ops = 381 397 frontswap_register_ops(&tmem_frontswap_ops); ··· 392 408 #endif 393 409 #ifdef CONFIG_CLEANCACHE 394 410 BUG_ON(sizeof(struct cleancache_filekey) != sizeof(struct tmem_oid)); 395 - if (tmem_enabled && !disable_cleancache) { 411 + if (tmem_enabled && cleancache) { 396 412 char *s = ""; 397 413 struct cleancache_ops *old_ops = 398 414 cleancache_register_ops(&tmem_cleancache_ops); ··· 403 419 } 404 420 #endif 405 421 #ifdef CONFIG_XEN_SELFBALLOONING 406 - xen_selfballoon_init(!disable_selfballooning, 407 - !disable_frontswap_selfshrinking); 422 + /* 423 + * There is no point of driving pages to the swap system if they 424 + * aren't going anywhere in tmem universe. 425 + */ 426 + if (!frontswap) { 427 + selfshrinking = false; 428 + selfballooning = false; 429 + } 430 + xen_selfballoon_init(selfballooning, selfshrinking); 408 431 #endif 409 432 return 0; 410 433 }
+6 -41
drivers/xen/xen-selfballoon.c
··· 53 53 * System configuration note: Selfballooning should not be enabled on 54 54 * systems without a sufficiently large swap device configured; for best 55 55 * results, it is recommended that total swap be increased by the size 56 - * of the guest memory. Also, while technically not required to be 57 - * configured, it is highly recommended that frontswap also be configured 58 - * and enabled when selfballooning is running. So, selfballooning 59 - * is disabled by default if frontswap is not configured and can only 60 - * be enabled with the "selfballooning" kernel boot option; similarly 61 - * selfballooning is enabled by default if frontswap is configured and 62 - * can be disabled with the "noselfballooning" kernel boot option. Finally, 63 - * when frontswap is configured, frontswap-selfshrinking can be disabled 64 - * with the "noselfshrink" kernel boot option. 56 + * of the guest memory. Note, that selfballooning should be disabled by default 57 + * if frontswap is not configured. Similarly selfballooning should be enabled 58 + * by default if frontswap is configured and can be disabled with the 59 + * "tmem.selfballooning=0" kernel boot option. Finally, when frontswap is 60 + * configured, frontswap-selfshrinking can be disabled with the 61 + * "tmem.selfshrink=0" kernel boot option. 65 62 * 66 63 * Selfballooning is disallowed in domain0 and force-disabled. 67 64 * ··· 117 120 /* Enable/disable with sysfs. */ 118 121 static bool frontswap_selfshrinking __read_mostly; 119 122 120 - /* Enable/disable with kernel boot option. */ 121 - static bool use_frontswap_selfshrink = true; 122 - 123 123 /* 124 124 * The default values for the following parameters were deemed reasonable 125 125 * by experimentation, may be workload-dependent, and can all be ··· 170 176 frontswap_shrink(tgt_frontswap_pages); 171 177 } 172 178 173 - static int __init xen_nofrontswap_selfshrink_setup(char *s) 174 - { 175 - use_frontswap_selfshrink = false; 176 - return 1; 177 - } 178 - 179 - __setup("noselfshrink", xen_nofrontswap_selfshrink_setup); 180 - 181 - /* Disable with kernel boot option. */ 182 - static bool use_selfballooning = true; 183 - 184 - static int __init xen_noselfballooning_setup(char *s) 185 - { 186 - use_selfballooning = false; 187 - return 1; 188 - } 189 - 190 - __setup("noselfballooning", xen_noselfballooning_setup); 191 - #else /* !CONFIG_FRONTSWAP */ 192 - /* Enable with kernel boot option. */ 193 - static bool use_selfballooning; 194 - 195 - static int __init xen_selfballooning_setup(char *s) 196 - { 197 - use_selfballooning = true; 198 - return 1; 199 - } 200 - 201 - __setup("selfballooning", xen_selfballooning_setup); 202 179 #endif /* CONFIG_FRONTSWAP */ 203 180 204 181 #define MB2PAGES(mb) ((mb) << (20 - PAGE_SHIFT))
+10 -11
drivers/xen/xenbus/xenbus_dev_backend.c
··· 70 70 return err; 71 71 } 72 72 73 - static long xenbus_backend_ioctl(struct file *file, unsigned int cmd, unsigned long data) 73 + static long xenbus_backend_ioctl(struct file *file, unsigned int cmd, 74 + unsigned long data) 74 75 { 75 76 if (!capable(CAP_SYS_ADMIN)) 76 77 return -EPERM; 77 78 78 79 switch (cmd) { 79 - case IOCTL_XENBUS_BACKEND_EVTCHN: 80 - if (xen_store_evtchn > 0) 81 - return xen_store_evtchn; 82 - return -ENODEV; 83 - 84 - case IOCTL_XENBUS_BACKEND_SETUP: 85 - return xenbus_alloc(data); 86 - 87 - default: 88 - return -ENOTTY; 80 + case IOCTL_XENBUS_BACKEND_EVTCHN: 81 + if (xen_store_evtchn > 0) 82 + return xen_store_evtchn; 83 + return -ENODEV; 84 + case IOCTL_XENBUS_BACKEND_SETUP: 85 + return xenbus_alloc(data); 86 + default: 87 + return -ENOTTY; 89 88 } 90 89 } 91 90
+2 -1
fs/btrfs/backref.c
··· 918 918 ref->parent, bsz, 0); 919 919 if (!eb || !extent_buffer_uptodate(eb)) { 920 920 free_extent_buffer(eb); 921 - return -EIO; 921 + ret = -EIO; 922 + goto out; 922 923 } 923 924 ret = find_extent_in_eb(eb, bytenr, 924 925 *extent_item_pos, &eie);
+1 -1
fs/btrfs/check-integrity.c
··· 1700 1700 unsigned int j; 1701 1701 DECLARE_COMPLETION_ONSTACK(complete); 1702 1702 1703 - bio = bio_alloc(GFP_NOFS, num_pages - i); 1703 + bio = btrfs_io_bio_alloc(GFP_NOFS, num_pages - i); 1704 1704 if (!bio) { 1705 1705 printk(KERN_INFO 1706 1706 "btrfsic: bio_alloc() for %u pages failed!\n",
+3 -1
fs/btrfs/ctree.c
··· 951 951 BUG_ON(ret); /* -ENOMEM */ 952 952 } 953 953 if (new_flags != 0) { 954 + int level = btrfs_header_level(buf); 955 + 954 956 ret = btrfs_set_disk_extent_flags(trans, root, 955 957 buf->start, 956 958 buf->len, 957 - new_flags, 0); 959 + new_flags, level, 0); 958 960 if (ret) 959 961 return ret; 960 962 }
+4 -4
fs/btrfs/ctree.h
··· 88 88 /* holds checksums of all the data extents */ 89 89 #define BTRFS_CSUM_TREE_OBJECTID 7ULL 90 90 91 - /* for storing balance parameters in the root tree */ 92 - #define BTRFS_BALANCE_OBJECTID -4ULL 93 - 94 91 /* holds quota configuration and tracking */ 95 92 #define BTRFS_QUOTA_TREE_OBJECTID 8ULL 93 + 94 + /* for storing balance parameters in the root tree */ 95 + #define BTRFS_BALANCE_OBJECTID -4ULL 96 96 97 97 /* orhpan objectid for tracking unlinked/truncated files */ 98 98 #define BTRFS_ORPHAN_OBJECTID -5ULL ··· 3075 3075 int btrfs_set_disk_extent_flags(struct btrfs_trans_handle *trans, 3076 3076 struct btrfs_root *root, 3077 3077 u64 bytenr, u64 num_bytes, u64 flags, 3078 - int is_data); 3078 + int level, int is_data); 3079 3079 int btrfs_free_extent(struct btrfs_trans_handle *trans, 3080 3080 struct btrfs_root *root, 3081 3081 u64 bytenr, u64 num_bytes, u64 parent, u64 root_objectid,
+1
fs/btrfs/delayed-ref.h
··· 60 60 struct btrfs_delayed_extent_op { 61 61 struct btrfs_disk_key key; 62 62 u64 flags_to_set; 63 + int level; 63 64 unsigned int update_key:1; 64 65 unsigned int update_flags:1; 65 66 unsigned int is_data:1;
+5
fs/btrfs/dev-replace.c
··· 313 313 struct btrfs_device *tgt_device = NULL; 314 314 struct btrfs_device *src_device = NULL; 315 315 316 + if (btrfs_fs_incompat(fs_info, RAID56)) { 317 + pr_warn("btrfs: dev_replace cannot yet handle RAID5/RAID6\n"); 318 + return -EINVAL; 319 + } 320 + 316 321 switch (args->start.cont_reading_from_srcdev_mode) { 317 322 case BTRFS_IOCTL_DEV_REPLACE_CONT_READING_FROM_SRCDEV_MODE_ALWAYS: 318 323 case BTRFS_IOCTL_DEV_REPLACE_CONT_READING_FROM_SRCDEV_MODE_AVOID:
+30 -22
fs/btrfs/disk-io.c
··· 152 152 { .id = BTRFS_DEV_TREE_OBJECTID, .name_stem = "dev" }, 153 153 { .id = BTRFS_FS_TREE_OBJECTID, .name_stem = "fs" }, 154 154 { .id = BTRFS_CSUM_TREE_OBJECTID, .name_stem = "csum" }, 155 - { .id = BTRFS_ORPHAN_OBJECTID, .name_stem = "orphan" }, 155 + { .id = BTRFS_QUOTA_TREE_OBJECTID, .name_stem = "quota" }, 156 156 { .id = BTRFS_TREE_LOG_OBJECTID, .name_stem = "log" }, 157 157 { .id = BTRFS_TREE_RELOC_OBJECTID, .name_stem = "treloc" }, 158 158 { .id = BTRFS_DATA_RELOC_TREE_OBJECTID, .name_stem = "dreloc" }, ··· 1513 1513 } 1514 1514 1515 1515 root->commit_root = btrfs_root_node(root); 1516 - BUG_ON(!root->node); /* -ENOMEM */ 1517 1516 out: 1518 1517 if (location->objectid != BTRFS_TREE_LOG_OBJECTID) { 1519 1518 root->ref_cows = 1; ··· 1987 1988 { 1988 1989 free_extent_buffer(info->tree_root->node); 1989 1990 free_extent_buffer(info->tree_root->commit_root); 1990 - free_extent_buffer(info->dev_root->node); 1991 - free_extent_buffer(info->dev_root->commit_root); 1992 - free_extent_buffer(info->extent_root->node); 1993 - free_extent_buffer(info->extent_root->commit_root); 1994 - free_extent_buffer(info->csum_root->node); 1995 - free_extent_buffer(info->csum_root->commit_root); 1991 + info->tree_root->node = NULL; 1992 + info->tree_root->commit_root = NULL; 1993 + 1994 + if (info->dev_root) { 1995 + free_extent_buffer(info->dev_root->node); 1996 + free_extent_buffer(info->dev_root->commit_root); 1997 + info->dev_root->node = NULL; 1998 + info->dev_root->commit_root = NULL; 1999 + } 2000 + if (info->extent_root) { 2001 + free_extent_buffer(info->extent_root->node); 2002 + free_extent_buffer(info->extent_root->commit_root); 2003 + info->extent_root->node = NULL; 2004 + info->extent_root->commit_root = NULL; 2005 + } 2006 + if (info->csum_root) { 2007 + free_extent_buffer(info->csum_root->node); 2008 + free_extent_buffer(info->csum_root->commit_root); 2009 + info->csum_root->node = NULL; 2010 + info->csum_root->commit_root = NULL; 2011 + } 1996 2012 if (info->quota_root) { 1997 2013 free_extent_buffer(info->quota_root->node); 1998 2014 free_extent_buffer(info->quota_root->commit_root); 1999 - } 2000 - 2001 - info->tree_root->node = NULL; 2002 - info->tree_root->commit_root = NULL; 2003 - info->dev_root->node = NULL; 2004 - info->dev_root->commit_root = NULL; 2005 - info->extent_root->node = NULL; 2006 - info->extent_root->commit_root = NULL; 2007 - info->csum_root->node = NULL; 2008 - info->csum_root->commit_root = NULL; 2009 - if (info->quota_root) { 2010 2015 info->quota_root->node = NULL; 2011 2016 info->quota_root->commit_root = NULL; 2012 2017 } 2013 - 2014 2018 if (chunk_root) { 2015 2019 free_extent_buffer(info->chunk_root->node); 2016 2020 free_extent_buffer(info->chunk_root->commit_root); ··· 3130 3128 * caller 3131 3129 */ 3132 3130 device->flush_bio = NULL; 3133 - bio = bio_alloc(GFP_NOFS, 0); 3131 + bio = btrfs_io_bio_alloc(GFP_NOFS, 0); 3134 3132 if (!bio) 3135 3133 return -ENOMEM; 3136 3134 ··· 3661 3659 ordered_operations); 3662 3660 3663 3661 list_del_init(&btrfs_inode->ordered_operations); 3662 + spin_unlock(&root->fs_info->ordered_extent_lock); 3664 3663 3665 3664 btrfs_invalidate_inodes(btrfs_inode->root); 3665 + 3666 + spin_lock(&root->fs_info->ordered_extent_lock); 3666 3667 } 3667 3668 3668 3669 spin_unlock(&root->fs_info->ordered_extent_lock); ··· 3787 3782 list_del_init(&btrfs_inode->delalloc_inodes); 3788 3783 clear_bit(BTRFS_INODE_IN_DELALLOC_LIST, 3789 3784 &btrfs_inode->runtime_flags); 3785 + spin_unlock(&root->fs_info->delalloc_lock); 3790 3786 3791 3787 btrfs_invalidate_inodes(btrfs_inode->root); 3788 + 3789 + spin_lock(&root->fs_info->delalloc_lock); 3792 3790 } 3793 3791 3794 3792 spin_unlock(&root->fs_info->delalloc_lock); ··· 3816 3808 while (start <= end) { 3817 3809 eb = btrfs_find_tree_block(root, start, 3818 3810 root->leafsize); 3819 - start += eb->len; 3811 + start += root->leafsize; 3820 3812 if (!eb) 3821 3813 continue; 3822 3814 wait_on_extent_buffer_writeback(eb);
+51 -45
fs/btrfs/extent-tree.c
··· 2070 2070 u32 item_size; 2071 2071 int ret; 2072 2072 int err = 0; 2073 - int metadata = (node->type == BTRFS_TREE_BLOCK_REF_KEY || 2074 - node->type == BTRFS_SHARED_BLOCK_REF_KEY); 2073 + int metadata = !extent_op->is_data; 2075 2074 2076 2075 if (trans->aborted) 2077 2076 return 0; ··· 2085 2086 key.objectid = node->bytenr; 2086 2087 2087 2088 if (metadata) { 2088 - struct btrfs_delayed_tree_ref *tree_ref; 2089 - 2090 - tree_ref = btrfs_delayed_node_to_tree_ref(node); 2091 2089 key.type = BTRFS_METADATA_ITEM_KEY; 2092 - key.offset = tree_ref->level; 2090 + key.offset = extent_op->level; 2093 2091 } else { 2094 2092 key.type = BTRFS_EXTENT_ITEM_KEY; 2095 2093 key.offset = node->num_bytes; ··· 2715 2719 int btrfs_set_disk_extent_flags(struct btrfs_trans_handle *trans, 2716 2720 struct btrfs_root *root, 2717 2721 u64 bytenr, u64 num_bytes, u64 flags, 2718 - int is_data) 2722 + int level, int is_data) 2719 2723 { 2720 2724 struct btrfs_delayed_extent_op *extent_op; 2721 2725 int ret; ··· 2728 2732 extent_op->update_flags = 1; 2729 2733 extent_op->update_key = 0; 2730 2734 extent_op->is_data = is_data ? 1 : 0; 2735 + extent_op->level = level; 2731 2736 2732 2737 ret = btrfs_add_delayed_extent_op(root->fs_info, trans, bytenr, 2733 2738 num_bytes, extent_op); ··· 3106 3109 WARN_ON(ret); 3107 3110 3108 3111 if (i_size_read(inode) > 0) { 3112 + ret = btrfs_check_trunc_cache_free_space(root, 3113 + &root->fs_info->global_block_rsv); 3114 + if (ret) 3115 + goto out_put; 3116 + 3109 3117 ret = btrfs_truncate_free_space_cache(root, trans, path, 3110 3118 inode); 3111 3119 if (ret) ··· 4564 4562 fs_info->csum_root->block_rsv = &fs_info->global_block_rsv; 4565 4563 fs_info->dev_root->block_rsv = &fs_info->global_block_rsv; 4566 4564 fs_info->tree_root->block_rsv = &fs_info->global_block_rsv; 4565 + if (fs_info->quota_root) 4566 + fs_info->quota_root->block_rsv = &fs_info->global_block_rsv; 4567 4567 fs_info->chunk_root->block_rsv = &fs_info->chunk_block_rsv; 4568 4568 4569 4569 update_global_block_rsv(fs_info); ··· 6655 6651 struct btrfs_block_rsv *block_rsv; 6656 6652 struct btrfs_block_rsv *global_rsv = &root->fs_info->global_block_rsv; 6657 6653 int ret; 6654 + bool global_updated = false; 6658 6655 6659 6656 block_rsv = get_block_rsv(trans, root); 6660 6657 6661 - if (block_rsv->size == 0) { 6662 - ret = reserve_metadata_bytes(root, block_rsv, blocksize, 6663 - BTRFS_RESERVE_NO_FLUSH); 6664 - /* 6665 - * If we couldn't reserve metadata bytes try and use some from 6666 - * the global reserve. 6667 - */ 6668 - if (ret && block_rsv != global_rsv) { 6669 - ret = block_rsv_use_bytes(global_rsv, blocksize); 6670 - if (!ret) 6671 - return global_rsv; 6672 - return ERR_PTR(ret); 6673 - } else if (ret) { 6674 - return ERR_PTR(ret); 6675 - } 6676 - return block_rsv; 6677 - } 6678 - 6658 + if (unlikely(block_rsv->size == 0)) 6659 + goto try_reserve; 6660 + again: 6679 6661 ret = block_rsv_use_bytes(block_rsv, blocksize); 6680 6662 if (!ret) 6681 6663 return block_rsv; 6682 - if (ret && !block_rsv->failfast) { 6683 - if (btrfs_test_opt(root, ENOSPC_DEBUG)) { 6684 - static DEFINE_RATELIMIT_STATE(_rs, 6685 - DEFAULT_RATELIMIT_INTERVAL * 10, 6686 - /*DEFAULT_RATELIMIT_BURST*/ 1); 6687 - if (__ratelimit(&_rs)) 6688 - WARN(1, KERN_DEBUG 6689 - "btrfs: block rsv returned %d\n", ret); 6690 - } 6691 - ret = reserve_metadata_bytes(root, block_rsv, blocksize, 6692 - BTRFS_RESERVE_NO_FLUSH); 6693 - if (!ret) { 6694 - return block_rsv; 6695 - } else if (ret && block_rsv != global_rsv) { 6696 - ret = block_rsv_use_bytes(global_rsv, blocksize); 6697 - if (!ret) 6698 - return global_rsv; 6699 - } 6664 + 6665 + if (block_rsv->failfast) 6666 + return ERR_PTR(ret); 6667 + 6668 + if (block_rsv->type == BTRFS_BLOCK_RSV_GLOBAL && !global_updated) { 6669 + global_updated = true; 6670 + update_global_block_rsv(root->fs_info); 6671 + goto again; 6700 6672 } 6701 6673 6702 - return ERR_PTR(-ENOSPC); 6674 + if (btrfs_test_opt(root, ENOSPC_DEBUG)) { 6675 + static DEFINE_RATELIMIT_STATE(_rs, 6676 + DEFAULT_RATELIMIT_INTERVAL * 10, 6677 + /*DEFAULT_RATELIMIT_BURST*/ 1); 6678 + if (__ratelimit(&_rs)) 6679 + WARN(1, KERN_DEBUG 6680 + "btrfs: block rsv returned %d\n", ret); 6681 + } 6682 + try_reserve: 6683 + ret = reserve_metadata_bytes(root, block_rsv, blocksize, 6684 + BTRFS_RESERVE_NO_FLUSH); 6685 + if (!ret) 6686 + return block_rsv; 6687 + /* 6688 + * If we couldn't reserve metadata bytes try and use some from 6689 + * the global reserve if its space type is the same as the global 6690 + * reservation. 6691 + */ 6692 + if (block_rsv->type != BTRFS_BLOCK_RSV_GLOBAL && 6693 + block_rsv->space_info == global_rsv->space_info) { 6694 + ret = block_rsv_use_bytes(global_rsv, blocksize); 6695 + if (!ret) 6696 + return global_rsv; 6697 + } 6698 + return ERR_PTR(ret); 6703 6699 } 6704 6700 6705 6701 static void unuse_block_rsv(struct btrfs_fs_info *fs_info, ··· 6767 6763 extent_op->update_key = 1; 6768 6764 extent_op->update_flags = 1; 6769 6765 extent_op->is_data = 0; 6766 + extent_op->level = level; 6770 6767 6771 6768 ret = btrfs_add_delayed_tree_ref(root->fs_info, trans, 6772 6769 ins.objectid, ··· 6939 6934 ret = btrfs_dec_ref(trans, root, eb, 0, wc->for_reloc); 6940 6935 BUG_ON(ret); /* -ENOMEM */ 6941 6936 ret = btrfs_set_disk_extent_flags(trans, root, eb->start, 6942 - eb->len, flag, 0); 6937 + eb->len, flag, 6938 + btrfs_header_level(eb), 0); 6943 6939 BUG_ON(ret); /* -ENOMEM */ 6944 6940 wc->flags[level] |= flag; 6945 6941 }
+73 -65
fs/btrfs/extent_io.c
··· 23 23 24 24 static struct kmem_cache *extent_state_cache; 25 25 static struct kmem_cache *extent_buffer_cache; 26 + static struct bio_set *btrfs_bioset; 26 27 27 28 #ifdef CONFIG_BTRFS_DEBUG 28 29 static LIST_HEAD(buffers); ··· 126 125 SLAB_RECLAIM_ACCOUNT | SLAB_MEM_SPREAD, NULL); 127 126 if (!extent_buffer_cache) 128 127 goto free_state_cache; 128 + 129 + btrfs_bioset = bioset_create(BIO_POOL_SIZE, 130 + offsetof(struct btrfs_io_bio, bio)); 131 + if (!btrfs_bioset) 132 + goto free_buffer_cache; 129 133 return 0; 134 + 135 + free_buffer_cache: 136 + kmem_cache_destroy(extent_buffer_cache); 137 + extent_buffer_cache = NULL; 130 138 131 139 free_state_cache: 132 140 kmem_cache_destroy(extent_state_cache); 141 + extent_state_cache = NULL; 133 142 return -ENOMEM; 134 143 } 135 144 ··· 156 145 kmem_cache_destroy(extent_state_cache); 157 146 if (extent_buffer_cache) 158 147 kmem_cache_destroy(extent_buffer_cache); 148 + if (btrfs_bioset) 149 + bioset_free(btrfs_bioset); 159 150 } 160 151 161 152 void extent_io_tree_init(struct extent_io_tree *tree, ··· 1961 1948 } 1962 1949 1963 1950 /* 1964 - * helper function to unlock a page if all the extents in the tree 1965 - * for that page are unlocked 1966 - */ 1967 - static void check_page_locked(struct extent_io_tree *tree, struct page *page) 1968 - { 1969 - u64 start = page_offset(page); 1970 - u64 end = start + PAGE_CACHE_SIZE - 1; 1971 - if (!test_range_bit(tree, start, end, EXTENT_LOCKED, 0, NULL)) 1972 - unlock_page(page); 1973 - } 1974 - 1975 - /* 1976 - * helper function to end page writeback if all the extents 1977 - * in the tree for that page are done with writeback 1978 - */ 1979 - static void check_page_writeback(struct extent_io_tree *tree, 1980 - struct page *page) 1981 - { 1982 - end_page_writeback(page); 1983 - } 1984 - 1985 - /* 1986 1951 * When IO fails, either with EIO or csum verification fails, we 1987 1952 * try other mirrors that might have a good copy of the data. This 1988 1953 * io_failure_record is used to record state as we go through all the ··· 2037 2046 if (btrfs_is_parity_mirror(map_tree, logical, length, mirror_num)) 2038 2047 return 0; 2039 2048 2040 - bio = bio_alloc(GFP_NOFS, 1); 2049 + bio = btrfs_io_bio_alloc(GFP_NOFS, 1); 2041 2050 if (!bio) 2042 2051 return -EIO; 2043 2052 bio->bi_private = &compl; ··· 2327 2336 return -EIO; 2328 2337 } 2329 2338 2330 - bio = bio_alloc(GFP_NOFS, 1); 2339 + bio = btrfs_io_bio_alloc(GFP_NOFS, 1); 2331 2340 if (!bio) { 2332 2341 free_io_failure(inode, failrec, 0); 2333 2342 return -EIO; ··· 2389 2398 struct extent_io_tree *tree; 2390 2399 u64 start; 2391 2400 u64 end; 2392 - int whole_page; 2393 2401 2394 2402 do { 2395 2403 struct page *page = bvec->bv_page; 2396 2404 tree = &BTRFS_I(page->mapping->host)->io_tree; 2397 2405 2398 - start = page_offset(page) + bvec->bv_offset; 2399 - end = start + bvec->bv_len - 1; 2406 + /* We always issue full-page reads, but if some block 2407 + * in a page fails to read, blk_update_request() will 2408 + * advance bv_offset and adjust bv_len to compensate. 2409 + * Print a warning for nonzero offsets, and an error 2410 + * if they don't add up to a full page. */ 2411 + if (bvec->bv_offset || bvec->bv_len != PAGE_CACHE_SIZE) 2412 + printk("%s page write in btrfs with offset %u and length %u\n", 2413 + bvec->bv_offset + bvec->bv_len != PAGE_CACHE_SIZE 2414 + ? KERN_ERR "partial" : KERN_INFO "incomplete", 2415 + bvec->bv_offset, bvec->bv_len); 2400 2416 2401 - if (bvec->bv_offset == 0 && bvec->bv_len == PAGE_CACHE_SIZE) 2402 - whole_page = 1; 2403 - else 2404 - whole_page = 0; 2417 + start = page_offset(page); 2418 + end = start + bvec->bv_offset + bvec->bv_len - 1; 2405 2419 2406 2420 if (--bvec >= bio->bi_io_vec) 2407 2421 prefetchw(&bvec->bv_page->flags); ··· 2414 2418 if (end_extent_writepage(page, err, start, end)) 2415 2419 continue; 2416 2420 2417 - if (whole_page) 2418 - end_page_writeback(page); 2419 - else 2420 - check_page_writeback(tree, page); 2421 + end_page_writeback(page); 2421 2422 } while (bvec >= bio->bi_io_vec); 2422 2423 2423 2424 bio_put(bio); ··· 2439 2446 struct extent_io_tree *tree; 2440 2447 u64 start; 2441 2448 u64 end; 2442 - int whole_page; 2443 2449 int mirror; 2444 2450 int ret; 2445 2451 ··· 2449 2457 struct page *page = bvec->bv_page; 2450 2458 struct extent_state *cached = NULL; 2451 2459 struct extent_state *state; 2460 + struct btrfs_io_bio *io_bio = btrfs_io_bio(bio); 2452 2461 2453 2462 pr_debug("end_bio_extent_readpage: bi_sector=%llu, err=%d, " 2454 - "mirror=%ld\n", (u64)bio->bi_sector, err, 2455 - (long int)bio->bi_bdev); 2463 + "mirror=%lu\n", (u64)bio->bi_sector, err, 2464 + io_bio->mirror_num); 2456 2465 tree = &BTRFS_I(page->mapping->host)->io_tree; 2457 2466 2458 - start = page_offset(page) + bvec->bv_offset; 2459 - end = start + bvec->bv_len - 1; 2467 + /* We always issue full-page reads, but if some block 2468 + * in a page fails to read, blk_update_request() will 2469 + * advance bv_offset and adjust bv_len to compensate. 2470 + * Print a warning for nonzero offsets, and an error 2471 + * if they don't add up to a full page. */ 2472 + if (bvec->bv_offset || bvec->bv_len != PAGE_CACHE_SIZE) 2473 + printk("%s page read in btrfs with offset %u and length %u\n", 2474 + bvec->bv_offset + bvec->bv_len != PAGE_CACHE_SIZE 2475 + ? KERN_ERR "partial" : KERN_INFO "incomplete", 2476 + bvec->bv_offset, bvec->bv_len); 2460 2477 2461 - if (bvec->bv_offset == 0 && bvec->bv_len == PAGE_CACHE_SIZE) 2462 - whole_page = 1; 2463 - else 2464 - whole_page = 0; 2478 + start = page_offset(page); 2479 + end = start + bvec->bv_offset + bvec->bv_len - 1; 2465 2480 2466 2481 if (++bvec <= bvec_end) 2467 2482 prefetchw(&bvec->bv_page->flags); ··· 2484 2485 } 2485 2486 spin_unlock(&tree->lock); 2486 2487 2487 - mirror = (int)(unsigned long)bio->bi_bdev; 2488 + mirror = io_bio->mirror_num; 2488 2489 if (uptodate && tree->ops && tree->ops->readpage_end_io_hook) { 2489 2490 ret = tree->ops->readpage_end_io_hook(page, start, end, 2490 2491 state, mirror); ··· 2527 2528 } 2528 2529 unlock_extent_cached(tree, start, end, &cached, GFP_ATOMIC); 2529 2530 2530 - if (whole_page) { 2531 - if (uptodate) { 2532 - SetPageUptodate(page); 2533 - } else { 2534 - ClearPageUptodate(page); 2535 - SetPageError(page); 2536 - } 2537 - unlock_page(page); 2531 + if (uptodate) { 2532 + SetPageUptodate(page); 2538 2533 } else { 2539 - if (uptodate) { 2540 - check_page_uptodate(tree, page); 2541 - } else { 2542 - ClearPageUptodate(page); 2543 - SetPageError(page); 2544 - } 2545 - check_page_locked(tree, page); 2534 + ClearPageUptodate(page); 2535 + SetPageError(page); 2546 2536 } 2537 + unlock_page(page); 2547 2538 } while (bvec <= bvec_end); 2548 2539 2549 2540 bio_put(bio); 2550 2541 } 2551 2542 2543 + /* 2544 + * this allocates from the btrfs_bioset. We're returning a bio right now 2545 + * but you can call btrfs_io_bio for the appropriate container_of magic 2546 + */ 2552 2547 struct bio * 2553 2548 btrfs_bio_alloc(struct block_device *bdev, u64 first_sector, int nr_vecs, 2554 2549 gfp_t gfp_flags) 2555 2550 { 2556 2551 struct bio *bio; 2557 2552 2558 - bio = bio_alloc(gfp_flags, nr_vecs); 2553 + bio = bio_alloc_bioset(gfp_flags, nr_vecs, btrfs_bioset); 2559 2554 2560 2555 if (bio == NULL && (current->flags & PF_MEMALLOC)) { 2561 - while (!bio && (nr_vecs /= 2)) 2562 - bio = bio_alloc(gfp_flags, nr_vecs); 2556 + while (!bio && (nr_vecs /= 2)) { 2557 + bio = bio_alloc_bioset(gfp_flags, 2558 + nr_vecs, btrfs_bioset); 2559 + } 2563 2560 } 2564 2561 2565 2562 if (bio) { ··· 2565 2570 } 2566 2571 return bio; 2567 2572 } 2573 + 2574 + struct bio *btrfs_bio_clone(struct bio *bio, gfp_t gfp_mask) 2575 + { 2576 + return bio_clone_bioset(bio, gfp_mask, btrfs_bioset); 2577 + } 2578 + 2579 + 2580 + /* this also allocates from the btrfs_bioset */ 2581 + struct bio *btrfs_io_bio_alloc(gfp_t gfp_mask, unsigned int nr_iovecs) 2582 + { 2583 + return bio_alloc_bioset(gfp_mask, nr_iovecs, btrfs_bioset); 2584 + } 2585 + 2568 2586 2569 2587 static int __must_check submit_one_bio(int rw, struct bio *bio, 2570 2588 int mirror_num, unsigned long bio_flags) ··· 3996 3988 last_for_get_extent = isize; 3997 3989 } 3998 3990 3999 - lock_extent_bits(&BTRFS_I(inode)->io_tree, start, start + len, 0, 3991 + lock_extent_bits(&BTRFS_I(inode)->io_tree, start, start + len - 1, 0, 4000 3992 &cached_state); 4001 3993 4002 3994 em = get_extent_skip_holes(inode, start, last_for_get_extent, ··· 4083 4075 out_free: 4084 4076 free_extent_map(em); 4085 4077 out: 4086 - unlock_extent_cached(&BTRFS_I(inode)->io_tree, start, start + len, 4078 + unlock_extent_cached(&BTRFS_I(inode)->io_tree, start, start + len - 1, 4087 4079 &cached_state, GFP_NOFS); 4088 4080 return ret; 4089 4081 }
+2
fs/btrfs/extent_io.h
··· 336 336 struct bio * 337 337 btrfs_bio_alloc(struct block_device *bdev, u64 first_sector, int nr_vecs, 338 338 gfp_t gfp_flags); 339 + struct bio *btrfs_io_bio_alloc(gfp_t gfp_mask, unsigned int nr_iovecs); 340 + struct bio *btrfs_bio_clone(struct bio *bio, gfp_t gfp_mask); 339 341 340 342 struct btrfs_fs_info; 341 343
+20 -23
fs/btrfs/free-space-cache.c
··· 197 197 block_group->key.objectid); 198 198 } 199 199 200 - int btrfs_truncate_free_space_cache(struct btrfs_root *root, 201 - struct btrfs_trans_handle *trans, 202 - struct btrfs_path *path, 203 - struct inode *inode) 200 + int btrfs_check_trunc_cache_free_space(struct btrfs_root *root, 201 + struct btrfs_block_rsv *rsv) 204 202 { 205 - struct btrfs_block_rsv *rsv; 206 203 u64 needed_bytes; 207 - loff_t oldsize; 208 - int ret = 0; 209 - 210 - rsv = trans->block_rsv; 211 - trans->block_rsv = &root->fs_info->global_block_rsv; 204 + int ret; 212 205 213 206 /* 1 for slack space, 1 for updating the inode */ 214 207 needed_bytes = btrfs_calc_trunc_metadata_size(root, 1) + 215 208 btrfs_calc_trans_metadata_size(root, 1); 216 209 217 - spin_lock(&trans->block_rsv->lock); 218 - if (trans->block_rsv->reserved < needed_bytes) { 219 - spin_unlock(&trans->block_rsv->lock); 220 - trans->block_rsv = rsv; 221 - return -ENOSPC; 222 - } 223 - spin_unlock(&trans->block_rsv->lock); 210 + spin_lock(&rsv->lock); 211 + if (rsv->reserved < needed_bytes) 212 + ret = -ENOSPC; 213 + else 214 + ret = 0; 215 + spin_unlock(&rsv->lock); 216 + return 0; 217 + } 218 + 219 + int btrfs_truncate_free_space_cache(struct btrfs_root *root, 220 + struct btrfs_trans_handle *trans, 221 + struct btrfs_path *path, 222 + struct inode *inode) 223 + { 224 + loff_t oldsize; 225 + int ret = 0; 224 226 225 227 oldsize = i_size_read(inode); 226 228 btrfs_i_size_write(inode, 0); ··· 234 232 */ 235 233 ret = btrfs_truncate_inode_items(trans, root, inode, 236 234 0, BTRFS_EXTENT_DATA_KEY); 237 - 238 235 if (ret) { 239 - trans->block_rsv = rsv; 240 236 btrfs_abort_transaction(trans, root, ret); 241 237 return ret; 242 238 } ··· 242 242 ret = btrfs_update_inode(trans, root, inode); 243 243 if (ret) 244 244 btrfs_abort_transaction(trans, root, ret); 245 - trans->block_rsv = rsv; 246 245 247 246 return ret; 248 247 } ··· 919 920 920 921 /* Make sure we can fit our crcs into the first page */ 921 922 if (io_ctl.check_crcs && 922 - (io_ctl.num_pages * sizeof(u32)) >= PAGE_CACHE_SIZE) { 923 - WARN_ON(1); 923 + (io_ctl.num_pages * sizeof(u32)) >= PAGE_CACHE_SIZE) 924 924 goto out_nospc; 925 - } 926 925 927 926 io_ctl_set_generation(&io_ctl, trans->transid); 928 927
+2
fs/btrfs/free-space-cache.h
··· 54 54 struct btrfs_block_group_cache *block_group, 55 55 struct btrfs_path *path); 56 56 57 + int btrfs_check_trunc_cache_free_space(struct btrfs_root *root, 58 + struct btrfs_block_rsv *rsv); 57 59 int btrfs_truncate_free_space_cache(struct btrfs_root *root, 58 60 struct btrfs_trans_handle *trans, 59 61 struct btrfs_path *path,
+5 -3
fs/btrfs/inode-map.c
··· 429 429 num_bytes = trans->bytes_reserved; 430 430 /* 431 431 * 1 item for inode item insertion if need 432 - * 3 items for inode item update (in the worst case) 432 + * 4 items for inode item update (in the worst case) 433 + * 1 items for slack space if we need do truncation 433 434 * 1 item for free space object 434 435 * 3 items for pre-allocation 435 436 */ 436 - trans->bytes_reserved = btrfs_calc_trans_metadata_size(root, 8); 437 + trans->bytes_reserved = btrfs_calc_trans_metadata_size(root, 10); 437 438 ret = btrfs_block_rsv_add(root, trans->block_rsv, 438 439 trans->bytes_reserved, 439 440 BTRFS_RESERVE_NO_FLUSH); ··· 469 468 if (i_size_read(inode) > 0) { 470 469 ret = btrfs_truncate_free_space_cache(root, trans, path, inode); 471 470 if (ret) { 472 - btrfs_abort_transaction(trans, root, ret); 471 + if (ret != -ENOSPC) 472 + btrfs_abort_transaction(trans, root, ret); 473 473 goto out_put; 474 474 } 475 475 }
+54 -29
fs/btrfs/inode.c
··· 715 715 async_extent->ram_size - 1, 0); 716 716 717 717 em = alloc_extent_map(); 718 - if (!em) 718 + if (!em) { 719 + ret = -ENOMEM; 719 720 goto out_free_reserve; 721 + } 720 722 em->start = async_extent->start; 721 723 em->len = async_extent->ram_size; 722 724 em->orig_start = em->start; ··· 925 923 } 926 924 927 925 em = alloc_extent_map(); 928 - if (!em) 926 + if (!em) { 927 + ret = -ENOMEM; 929 928 goto out_reserve; 929 + } 930 930 em->start = start; 931 931 em->orig_start = em->start; 932 932 ram_size = ins.offset; ··· 4728 4724 btrfs_end_transaction(trans, root); 4729 4725 btrfs_btree_balance_dirty(root); 4730 4726 no_delete: 4727 + btrfs_remove_delayed_node(inode); 4731 4728 clear_inode(inode); 4732 4729 return; 4733 4730 } ··· 4844 4839 struct rb_node **p; 4845 4840 struct rb_node *parent; 4846 4841 u64 ino = btrfs_ino(inode); 4847 - again: 4848 - p = &root->inode_tree.rb_node; 4849 - parent = NULL; 4850 4842 4851 4843 if (inode_unhashed(inode)) 4852 4844 return; 4853 - 4845 + again: 4846 + parent = NULL; 4854 4847 spin_lock(&root->inode_lock); 4848 + p = &root->inode_tree.rb_node; 4855 4849 while (*p) { 4856 4850 parent = *p; 4857 4851 entry = rb_entry(parent, struct btrfs_inode, rb_node); ··· 6932 6928 /* IO errors */ 6933 6929 int errors; 6934 6930 6931 + /* orig_bio is our btrfs_io_bio */ 6935 6932 struct bio *orig_bio; 6933 + 6934 + /* dio_bio came from fs/direct-io.c */ 6935 + struct bio *dio_bio; 6936 6936 }; 6937 6937 6938 6938 static void btrfs_endio_direct_read(struct bio *bio, int err) ··· 6946 6938 struct bio_vec *bvec = bio->bi_io_vec; 6947 6939 struct inode *inode = dip->inode; 6948 6940 struct btrfs_root *root = BTRFS_I(inode)->root; 6941 + struct bio *dio_bio; 6949 6942 u64 start; 6950 6943 6951 6944 start = dip->logical_offset; ··· 6986 6977 6987 6978 unlock_extent(&BTRFS_I(inode)->io_tree, dip->logical_offset, 6988 6979 dip->logical_offset + dip->bytes - 1); 6989 - bio->bi_private = dip->private; 6980 + dio_bio = dip->dio_bio; 6990 6981 6991 6982 kfree(dip); 6992 6983 6993 6984 /* If we had a csum failure make sure to clear the uptodate flag */ 6994 6985 if (err) 6995 - clear_bit(BIO_UPTODATE, &bio->bi_flags); 6996 - dio_end_io(bio, err); 6986 + clear_bit(BIO_UPTODATE, &dio_bio->bi_flags); 6987 + dio_end_io(dio_bio, err); 6988 + bio_put(bio); 6997 6989 } 6998 6990 6999 6991 static void btrfs_endio_direct_write(struct bio *bio, int err) ··· 7005 6995 struct btrfs_ordered_extent *ordered = NULL; 7006 6996 u64 ordered_offset = dip->logical_offset; 7007 6997 u64 ordered_bytes = dip->bytes; 6998 + struct bio *dio_bio; 7008 6999 int ret; 7009 7000 7010 7001 if (err) ··· 7033 7022 goto again; 7034 7023 } 7035 7024 out_done: 7036 - bio->bi_private = dip->private; 7025 + dio_bio = dip->dio_bio; 7037 7026 7038 7027 kfree(dip); 7039 7028 7040 7029 /* If we had an error make sure to clear the uptodate flag */ 7041 7030 if (err) 7042 - clear_bit(BIO_UPTODATE, &bio->bi_flags); 7043 - dio_end_io(bio, err); 7031 + clear_bit(BIO_UPTODATE, &dio_bio->bi_flags); 7032 + dio_end_io(dio_bio, err); 7033 + bio_put(bio); 7044 7034 } 7045 7035 7046 7036 static int __btrfs_submit_bio_start_direct_io(struct inode *inode, int rw, ··· 7077 7065 if (!atomic_dec_and_test(&dip->pending_bios)) 7078 7066 goto out; 7079 7067 7080 - if (dip->errors) 7068 + if (dip->errors) { 7081 7069 bio_io_error(dip->orig_bio); 7082 - else { 7083 - set_bit(BIO_UPTODATE, &dip->orig_bio->bi_flags); 7070 + } else { 7071 + set_bit(BIO_UPTODATE, &dip->dio_bio->bi_flags); 7084 7072 bio_endio(dip->orig_bio, 0); 7085 7073 } 7086 7074 out: ··· 7255 7243 return 0; 7256 7244 } 7257 7245 7258 - static void btrfs_submit_direct(int rw, struct bio *bio, struct inode *inode, 7259 - loff_t file_offset) 7246 + static void btrfs_submit_direct(int rw, struct bio *dio_bio, 7247 + struct inode *inode, loff_t file_offset) 7260 7248 { 7261 7249 struct btrfs_root *root = BTRFS_I(inode)->root; 7262 7250 struct btrfs_dio_private *dip; 7263 - struct bio_vec *bvec = bio->bi_io_vec; 7251 + struct bio_vec *bvec = dio_bio->bi_io_vec; 7252 + struct bio *io_bio; 7264 7253 int skip_sum; 7265 7254 int write = rw & REQ_WRITE; 7266 7255 int ret = 0; 7267 7256 7268 7257 skip_sum = BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM; 7269 7258 7270 - dip = kmalloc(sizeof(*dip), GFP_NOFS); 7271 - if (!dip) { 7259 + io_bio = btrfs_bio_clone(dio_bio, GFP_NOFS); 7260 + 7261 + if (!io_bio) { 7272 7262 ret = -ENOMEM; 7273 7263 goto free_ordered; 7274 7264 } 7275 7265 7276 - dip->private = bio->bi_private; 7266 + dip = kmalloc(sizeof(*dip), GFP_NOFS); 7267 + if (!dip) { 7268 + ret = -ENOMEM; 7269 + goto free_io_bio; 7270 + } 7271 + 7272 + dip->private = dio_bio->bi_private; 7273 + io_bio->bi_private = dio_bio->bi_private; 7277 7274 dip->inode = inode; 7278 7275 dip->logical_offset = file_offset; 7279 7276 ··· 7290 7269 do { 7291 7270 dip->bytes += bvec->bv_len; 7292 7271 bvec++; 7293 - } while (bvec <= (bio->bi_io_vec + bio->bi_vcnt - 1)); 7272 + } while (bvec <= (dio_bio->bi_io_vec + dio_bio->bi_vcnt - 1)); 7294 7273 7295 - dip->disk_bytenr = (u64)bio->bi_sector << 9; 7296 - bio->bi_private = dip; 7274 + dip->disk_bytenr = (u64)dio_bio->bi_sector << 9; 7275 + io_bio->bi_private = dip; 7297 7276 dip->errors = 0; 7298 - dip->orig_bio = bio; 7277 + dip->orig_bio = io_bio; 7278 + dip->dio_bio = dio_bio; 7299 7279 atomic_set(&dip->pending_bios, 0); 7300 7280 7301 7281 if (write) 7302 - bio->bi_end_io = btrfs_endio_direct_write; 7282 + io_bio->bi_end_io = btrfs_endio_direct_write; 7303 7283 else 7304 - bio->bi_end_io = btrfs_endio_direct_read; 7284 + io_bio->bi_end_io = btrfs_endio_direct_read; 7305 7285 7306 7286 ret = btrfs_submit_direct_hook(rw, dip, skip_sum); 7307 7287 if (!ret) 7308 7288 return; 7289 + 7290 + free_io_bio: 7291 + bio_put(io_bio); 7292 + 7309 7293 free_ordered: 7310 7294 /* 7311 7295 * If this is a write, we need to clean up the reserved space and kill ··· 7326 7300 btrfs_put_ordered_extent(ordered); 7327 7301 btrfs_put_ordered_extent(ordered); 7328 7302 } 7329 - bio_endio(bio, ret); 7303 + bio_endio(dio_bio, ret); 7330 7304 } 7331 7305 7332 7306 static ssize_t check_direct_IO(struct btrfs_root *root, int rw, struct kiocb *iocb, ··· 8005 7979 inode_tree_del(inode); 8006 7980 btrfs_drop_extent_cache(inode, 0, (u64)-1, 0); 8007 7981 free: 8008 - btrfs_remove_delayed_node(inode); 8009 7982 call_rcu(&inode->i_rcu, btrfs_i_callback); 8010 7983 } 8011 7984
+5 -5
fs/btrfs/ioctl.c
··· 1801 1801 item_off = btrfs_item_ptr_offset(leaf, i); 1802 1802 item_len = btrfs_item_size_nr(leaf, i); 1803 1803 1804 - if (item_len > BTRFS_SEARCH_ARGS_BUFSIZE) 1804 + btrfs_item_key_to_cpu(leaf, key, i); 1805 + if (!key_in_sk(key, sk)) 1806 + continue; 1807 + 1808 + if (sizeof(sh) + item_len > BTRFS_SEARCH_ARGS_BUFSIZE) 1805 1809 item_len = 0; 1806 1810 1807 1811 if (sizeof(sh) + item_len + *sk_offset > ··· 1813 1809 ret = 1; 1814 1810 goto overflow; 1815 1811 } 1816 - 1817 - btrfs_item_key_to_cpu(leaf, key, i); 1818 - if (!key_in_sk(key, sk)) 1819 - continue; 1820 1812 1821 1813 sh.objectid = key->objectid; 1822 1814 sh.offset = key->offset;
+1 -1
fs/btrfs/raid56.c
··· 1050 1050 } 1051 1051 1052 1052 /* put a new bio on the list */ 1053 - bio = bio_alloc(GFP_NOFS, bio_max_len >> PAGE_SHIFT?:1); 1053 + bio = btrfs_io_bio_alloc(GFP_NOFS, bio_max_len >> PAGE_SHIFT?:1); 1054 1054 if (!bio) 1055 1055 return -ENOMEM; 1056 1056
+6 -1
fs/btrfs/relocation.c
··· 1773 1773 if (!eb || !extent_buffer_uptodate(eb)) { 1774 1774 ret = (!eb) ? -ENOMEM : -EIO; 1775 1775 free_extent_buffer(eb); 1776 - return ret; 1776 + break; 1777 1777 } 1778 1778 btrfs_tree_lock(eb); 1779 1779 if (cow) { ··· 3350 3350 } 3351 3351 3352 3352 truncate: 3353 + ret = btrfs_check_trunc_cache_free_space(root, 3354 + &fs_info->global_block_rsv); 3355 + if (ret) 3356 + goto out; 3357 + 3353 3358 path = btrfs_alloc_path(); 3354 3359 if (!path) { 3355 3360 ret = -ENOMEM;
+5 -5
fs/btrfs/scrub.c
··· 1296 1296 } 1297 1297 1298 1298 WARN_ON(!page->page); 1299 - bio = bio_alloc(GFP_NOFS, 1); 1299 + bio = btrfs_io_bio_alloc(GFP_NOFS, 1); 1300 1300 if (!bio) { 1301 1301 page->io_error = 1; 1302 1302 sblock->no_io_error_seen = 0; ··· 1431 1431 return -EIO; 1432 1432 } 1433 1433 1434 - bio = bio_alloc(GFP_NOFS, 1); 1434 + bio = btrfs_io_bio_alloc(GFP_NOFS, 1); 1435 1435 if (!bio) 1436 1436 return -EIO; 1437 1437 bio->bi_bdev = page_bad->dev->bdev; ··· 1522 1522 sbio->dev = wr_ctx->tgtdev; 1523 1523 bio = sbio->bio; 1524 1524 if (!bio) { 1525 - bio = bio_alloc(GFP_NOFS, wr_ctx->pages_per_wr_bio); 1525 + bio = btrfs_io_bio_alloc(GFP_NOFS, wr_ctx->pages_per_wr_bio); 1526 1526 if (!bio) { 1527 1527 mutex_unlock(&wr_ctx->wr_lock); 1528 1528 return -ENOMEM; ··· 1930 1930 sbio->dev = spage->dev; 1931 1931 bio = sbio->bio; 1932 1932 if (!bio) { 1933 - bio = bio_alloc(GFP_NOFS, sctx->pages_per_rd_bio); 1933 + bio = btrfs_io_bio_alloc(GFP_NOFS, sctx->pages_per_rd_bio); 1934 1934 if (!bio) 1935 1935 return -ENOMEM; 1936 1936 sbio->bio = bio; ··· 3307 3307 "btrfs: scrub write_page_nocow(bdev == NULL) is unexpected!\n"); 3308 3308 return -EIO; 3309 3309 } 3310 - bio = bio_alloc(GFP_NOFS, 1); 3310 + bio = btrfs_io_bio_alloc(GFP_NOFS, 1); 3311 3311 if (!bio) { 3312 3312 spin_lock(&sctx->stat_lock); 3313 3313 sctx->stat.malloc_errors++;
+1
fs/btrfs/super.c
··· 1263 1263 1264 1264 btrfs_dev_replace_suspend_for_unmount(fs_info); 1265 1265 btrfs_scrub_cancel(fs_info); 1266 + btrfs_pause_balance(fs_info); 1266 1267 1267 1268 ret = btrfs_commit_super(root); 1268 1269 if (ret)
+12 -42
fs/btrfs/volumes.c
··· 3120 3120 allowed = BTRFS_AVAIL_ALLOC_BIT_SINGLE; 3121 3121 if (num_devices == 1) 3122 3122 allowed |= BTRFS_BLOCK_GROUP_DUP; 3123 - else if (num_devices < 4) 3123 + else if (num_devices > 1) 3124 3124 allowed |= (BTRFS_BLOCK_GROUP_RAID0 | BTRFS_BLOCK_GROUP_RAID1); 3125 - else 3126 - allowed |= (BTRFS_BLOCK_GROUP_RAID0 | BTRFS_BLOCK_GROUP_RAID1 | 3127 - BTRFS_BLOCK_GROUP_RAID10 | 3128 - BTRFS_BLOCK_GROUP_RAID5 | 3129 - BTRFS_BLOCK_GROUP_RAID6); 3130 - 3125 + if (num_devices > 2) 3126 + allowed |= BTRFS_BLOCK_GROUP_RAID5; 3127 + if (num_devices > 3) 3128 + allowed |= (BTRFS_BLOCK_GROUP_RAID10 | 3129 + BTRFS_BLOCK_GROUP_RAID6); 3131 3130 if ((bctl->data.flags & BTRFS_BALANCE_ARGS_CONVERT) && 3132 3131 (!alloc_profile_is_valid(bctl->data.target, 1) || 3133 3132 (bctl->data.target & ~allowed))) { ··· 5018 5019 return 0; 5019 5020 } 5020 5021 5021 - static void *merge_stripe_index_into_bio_private(void *bi_private, 5022 - unsigned int stripe_index) 5023 - { 5024 - /* 5025 - * with single, dup, RAID0, RAID1 and RAID10, stripe_index is 5026 - * at most 1. 5027 - * The alternative solution (instead of stealing bits from the 5028 - * pointer) would be to allocate an intermediate structure 5029 - * that contains the old private pointer plus the stripe_index. 5030 - */ 5031 - BUG_ON((((uintptr_t)bi_private) & 3) != 0); 5032 - BUG_ON(stripe_index > 3); 5033 - return (void *)(((uintptr_t)bi_private) | stripe_index); 5034 - } 5035 - 5036 - static struct btrfs_bio *extract_bbio_from_bio_private(void *bi_private) 5037 - { 5038 - return (struct btrfs_bio *)(((uintptr_t)bi_private) & ~((uintptr_t)3)); 5039 - } 5040 - 5041 - static unsigned int extract_stripe_index_from_bio_private(void *bi_private) 5042 - { 5043 - return (unsigned int)((uintptr_t)bi_private) & 3; 5044 - } 5045 - 5046 5022 static void btrfs_end_bio(struct bio *bio, int err) 5047 5023 { 5048 - struct btrfs_bio *bbio = extract_bbio_from_bio_private(bio->bi_private); 5024 + struct btrfs_bio *bbio = bio->bi_private; 5049 5025 int is_orig_bio = 0; 5050 5026 5051 5027 if (err) { 5052 5028 atomic_inc(&bbio->error); 5053 5029 if (err == -EIO || err == -EREMOTEIO) { 5054 5030 unsigned int stripe_index = 5055 - extract_stripe_index_from_bio_private( 5056 - bio->bi_private); 5031 + btrfs_io_bio(bio)->stripe_index; 5057 5032 struct btrfs_device *dev; 5058 5033 5059 5034 BUG_ON(stripe_index >= bbio->num_stripes); ··· 5057 5084 } 5058 5085 bio->bi_private = bbio->private; 5059 5086 bio->bi_end_io = bbio->end_io; 5060 - bio->bi_bdev = (struct block_device *) 5061 - (unsigned long)bbio->mirror_num; 5087 + btrfs_io_bio(bio)->mirror_num = bbio->mirror_num; 5062 5088 /* only send an error to the higher layers if it is 5063 5089 * beyond the tolerance of the btrfs bio 5064 5090 */ ··· 5183 5211 struct btrfs_device *dev = bbio->stripes[dev_nr].dev; 5184 5212 5185 5213 bio->bi_private = bbio; 5186 - bio->bi_private = merge_stripe_index_into_bio_private( 5187 - bio->bi_private, (unsigned int)dev_nr); 5214 + btrfs_io_bio(bio)->stripe_index = dev_nr; 5188 5215 bio->bi_end_io = btrfs_end_bio; 5189 5216 bio->bi_sector = physical >> 9; 5190 5217 #ifdef DEBUG ··· 5244 5273 if (atomic_dec_and_test(&bbio->stripes_pending)) { 5245 5274 bio->bi_private = bbio->private; 5246 5275 bio->bi_end_io = bbio->end_io; 5247 - bio->bi_bdev = (struct block_device *) 5248 - (unsigned long)bbio->mirror_num; 5276 + btrfs_io_bio(bio)->mirror_num = bbio->mirror_num; 5249 5277 bio->bi_sector = logical >> 9; 5250 5278 kfree(bbio); 5251 5279 bio_endio(bio, -EIO); ··· 5322 5352 } 5323 5353 5324 5354 if (dev_nr < total_devs - 1) { 5325 - bio = bio_clone(first_bio, GFP_NOFS); 5355 + bio = btrfs_bio_clone(first_bio, GFP_NOFS); 5326 5356 BUG_ON(!bio); /* -ENOMEM */ 5327 5357 } else { 5328 5358 bio = first_bio;
+20
fs/btrfs/volumes.h
··· 152 152 int rotating; 153 153 }; 154 154 155 + /* 156 + * we need the mirror number and stripe index to be passed around 157 + * the call chain while we are processing end_io (especially errors). 158 + * Really, what we need is a btrfs_bio structure that has this info 159 + * and is properly sized with its stripe array, but we're not there 160 + * quite yet. We have our own btrfs bioset, and all of the bios 161 + * we allocate are actually btrfs_io_bios. We'll cram as much of 162 + * struct btrfs_bio as we can into this over time. 163 + */ 164 + struct btrfs_io_bio { 165 + unsigned long mirror_num; 166 + unsigned long stripe_index; 167 + struct bio bio; 168 + }; 169 + 170 + static inline struct btrfs_io_bio *btrfs_io_bio(struct bio *bio) 171 + { 172 + return container_of(bio, struct btrfs_io_bio, bio); 173 + } 174 + 155 175 struct btrfs_bio_stripe { 156 176 struct btrfs_device *dev; 157 177 u64 physical;
+2 -6
fs/ext4/ext4.h
··· 209 209 ssize_t size; /* size of the extent */ 210 210 struct kiocb *iocb; /* iocb struct for AIO */ 211 211 int result; /* error value for AIO */ 212 - atomic_t count; /* reference counter */ 213 212 } ext4_io_end_t; 214 213 215 214 struct ext4_io_submit { ··· 2650 2651 2651 2652 /* page-io.c */ 2652 2653 extern int __init ext4_init_pageio(void); 2654 + extern void ext4_add_complete_io(ext4_io_end_t *io_end); 2653 2655 extern void ext4_exit_pageio(void); 2654 2656 extern void ext4_ioend_shutdown(struct inode *); 2657 + extern void ext4_free_io_end(ext4_io_end_t *io); 2655 2658 extern ext4_io_end_t *ext4_init_io_end(struct inode *inode, gfp_t flags); 2656 - extern ext4_io_end_t *ext4_get_io_end(ext4_io_end_t *io_end); 2657 - extern int ext4_put_io_end(ext4_io_end_t *io_end); 2658 - extern void ext4_put_io_end_defer(ext4_io_end_t *io_end); 2659 - extern void ext4_io_submit_init(struct ext4_io_submit *io, 2660 - struct writeback_control *wbc); 2661 2659 extern void ext4_end_io_work(struct work_struct *work); 2662 2660 extern void ext4_io_submit(struct ext4_io_submit *io); 2663 2661 extern int ext4_bio_write_page(struct ext4_io_submit *io,
+5 -4
fs/ext4/extents.c
··· 3642 3642 { 3643 3643 struct extent_status es; 3644 3644 3645 - ext4_es_find_delayed_extent(inode, lblk_start, &es); 3645 + ext4_es_find_delayed_extent_range(inode, lblk_start, lblk_end, &es); 3646 3646 if (es.es_len == 0) 3647 3647 return 0; /* there is no delay extent in this tree */ 3648 3648 else if (es.es_lblk <= lblk_start && ··· 4608 4608 struct extent_status es; 4609 4609 ext4_lblk_t block, next_del; 4610 4610 4611 - ext4_es_find_delayed_extent(inode, newes->es_lblk, &es); 4612 - 4613 4611 if (newes->es_pblk == 0) { 4612 + ext4_es_find_delayed_extent_range(inode, newes->es_lblk, 4613 + newes->es_lblk + newes->es_len - 1, &es); 4614 + 4614 4615 /* 4615 4616 * No extent in extent-tree contains block @newes->es_pblk, 4616 4617 * then the block may stay in 1)a hole or 2)delayed-extent. ··· 4631 4630 } 4632 4631 4633 4632 block = newes->es_lblk + newes->es_len; 4634 - ext4_es_find_delayed_extent(inode, block, &es); 4633 + ext4_es_find_delayed_extent_range(inode, block, EXT_MAX_BLOCKS, &es); 4635 4634 if (es.es_len == 0) 4636 4635 next_del = EXT_MAX_BLOCKS; 4637 4636 else
+12 -5
fs/ext4/extents_status.c
··· 232 232 } 233 233 234 234 /* 235 - * ext4_es_find_delayed_extent: find the 1st delayed extent covering @es->lblk 236 - * if it exists, otherwise, the next extent after @es->lblk. 235 + * ext4_es_find_delayed_extent_range: find the 1st delayed extent covering 236 + * @es->lblk if it exists, otherwise, the next extent after @es->lblk. 237 237 * 238 238 * @inode: the inode which owns delayed extents 239 239 * @lblk: the offset where we start to search 240 + * @end: the offset where we stop to search 240 241 * @es: delayed extent that we found 241 242 */ 242 - void ext4_es_find_delayed_extent(struct inode *inode, ext4_lblk_t lblk, 243 + void ext4_es_find_delayed_extent_range(struct inode *inode, 244 + ext4_lblk_t lblk, ext4_lblk_t end, 243 245 struct extent_status *es) 244 246 { 245 247 struct ext4_es_tree *tree = NULL; ··· 249 247 struct rb_node *node; 250 248 251 249 BUG_ON(es == NULL); 252 - trace_ext4_es_find_delayed_extent_enter(inode, lblk); 250 + BUG_ON(end < lblk); 251 + trace_ext4_es_find_delayed_extent_range_enter(inode, lblk); 253 252 254 253 read_lock(&EXT4_I(inode)->i_es_lock); 255 254 tree = &EXT4_I(inode)->i_es_tree; ··· 273 270 if (es1 && !ext4_es_is_delayed(es1)) { 274 271 while ((node = rb_next(&es1->rb_node)) != NULL) { 275 272 es1 = rb_entry(node, struct extent_status, rb_node); 273 + if (es1->es_lblk > end) { 274 + es1 = NULL; 275 + break; 276 + } 276 277 if (ext4_es_is_delayed(es1)) 277 278 break; 278 279 } ··· 292 285 read_unlock(&EXT4_I(inode)->i_es_lock); 293 286 294 287 ext4_es_lru_add(inode); 295 - trace_ext4_es_find_delayed_extent_exit(inode, es); 288 + trace_ext4_es_find_delayed_extent_range_exit(inode, es); 296 289 } 297 290 298 291 static struct extent_status *
+2 -1
fs/ext4/extents_status.h
··· 62 62 unsigned long long status); 63 63 extern int ext4_es_remove_extent(struct inode *inode, ext4_lblk_t lblk, 64 64 ext4_lblk_t len); 65 - extern void ext4_es_find_delayed_extent(struct inode *inode, ext4_lblk_t lblk, 65 + extern void ext4_es_find_delayed_extent_range(struct inode *inode, 66 + ext4_lblk_t lblk, ext4_lblk_t end, 66 67 struct extent_status *es); 67 68 extern int ext4_es_lookup_extent(struct inode *inode, ext4_lblk_t lblk, 68 69 struct extent_status *es);
+2 -2
fs/ext4/file.c
··· 465 465 * If there is a delay extent at this offset, 466 466 * it will be as a data. 467 467 */ 468 - ext4_es_find_delayed_extent(inode, last, &es); 468 + ext4_es_find_delayed_extent_range(inode, last, last, &es); 469 469 if (es.es_len != 0 && in_range(last, es.es_lblk, es.es_len)) { 470 470 if (last != start) 471 471 dataoff = last << blkbits; ··· 548 548 * If there is a delay extent at this offset, 549 549 * we will skip this extent. 550 550 */ 551 - ext4_es_find_delayed_extent(inode, last, &es); 551 + ext4_es_find_delayed_extent_range(inode, last, last, &es); 552 552 if (es.es_len != 0 && in_range(last, es.es_lblk, es.es_len)) { 553 553 last = es.es_lblk + es.es_len; 554 554 holeoff = last << blkbits;
+39 -48
fs/ext4/inode.c
··· 1488 1488 struct ext4_io_submit io_submit; 1489 1489 1490 1490 BUG_ON(mpd->next_page <= mpd->first_page); 1491 - ext4_io_submit_init(&io_submit, mpd->wbc); 1492 - io_submit.io_end = ext4_init_io_end(inode, GFP_NOFS); 1493 - if (!io_submit.io_end) 1494 - return -ENOMEM; 1491 + memset(&io_submit, 0, sizeof(io_submit)); 1495 1492 /* 1496 1493 * We need to start from the first_page to the next_page - 1 1497 1494 * to make sure we also write the mapped dirty buffer_heads. ··· 1576 1579 pagevec_release(&pvec); 1577 1580 } 1578 1581 ext4_io_submit(&io_submit); 1579 - /* Drop io_end reference we got from init */ 1580 - ext4_put_io_end_defer(io_submit.io_end); 1581 1582 return ret; 1582 1583 } 1583 1584 ··· 2234 2239 */ 2235 2240 return __ext4_journalled_writepage(page, len); 2236 2241 2237 - ext4_io_submit_init(&io_submit, wbc); 2238 - io_submit.io_end = ext4_init_io_end(inode, GFP_NOFS); 2239 - if (!io_submit.io_end) { 2240 - redirty_page_for_writepage(wbc, page); 2241 - return -ENOMEM; 2242 - } 2242 + memset(&io_submit, 0, sizeof(io_submit)); 2243 2243 ret = ext4_bio_write_page(&io_submit, page, len, wbc); 2244 2244 ext4_io_submit(&io_submit); 2245 - /* Drop io_end reference we got from init */ 2246 - ext4_put_io_end_defer(io_submit.io_end); 2247 2245 return ret; 2248 2246 } 2249 2247 ··· 3067 3079 struct inode *inode = file_inode(iocb->ki_filp); 3068 3080 ext4_io_end_t *io_end = iocb->private; 3069 3081 3070 - /* if not async direct IO just return */ 3071 - if (!io_end) { 3072 - inode_dio_done(inode); 3073 - if (is_async) 3074 - aio_complete(iocb, ret, 0); 3075 - return; 3076 - } 3082 + /* if not async direct IO or dio with 0 bytes write, just return */ 3083 + if (!io_end || !size) 3084 + goto out; 3077 3085 3078 3086 ext_debug("ext4_end_io_dio(): io_end 0x%p " 3079 3087 "for inode %lu, iocb 0x%p, offset %llu, size %zd\n", ··· 3077 3093 size); 3078 3094 3079 3095 iocb->private = NULL; 3096 + 3097 + /* if not aio dio with unwritten extents, just free io and return */ 3098 + if (!(io_end->flag & EXT4_IO_END_UNWRITTEN)) { 3099 + ext4_free_io_end(io_end); 3100 + out: 3101 + inode_dio_done(inode); 3102 + if (is_async) 3103 + aio_complete(iocb, ret, 0); 3104 + return; 3105 + } 3106 + 3080 3107 io_end->offset = offset; 3081 3108 io_end->size = size; 3082 3109 if (is_async) { 3083 3110 io_end->iocb = iocb; 3084 3111 io_end->result = ret; 3085 3112 } 3086 - ext4_put_io_end_defer(io_end); 3113 + 3114 + ext4_add_complete_io(io_end); 3087 3115 } 3088 3116 3089 3117 /* ··· 3129 3133 get_block_t *get_block_func = NULL; 3130 3134 int dio_flags = 0; 3131 3135 loff_t final_size = offset + count; 3132 - ext4_io_end_t *io_end = NULL; 3133 3136 3134 3137 /* Use the old path for reads and writes beyond i_size. */ 3135 3138 if (rw != WRITE || final_size > inode->i_size) ··· 3167 3172 iocb->private = NULL; 3168 3173 ext4_inode_aio_set(inode, NULL); 3169 3174 if (!is_sync_kiocb(iocb)) { 3170 - io_end = ext4_init_io_end(inode, GFP_NOFS); 3175 + ext4_io_end_t *io_end = ext4_init_io_end(inode, GFP_NOFS); 3171 3176 if (!io_end) { 3172 3177 ret = -ENOMEM; 3173 3178 goto retake_lock; 3174 3179 } 3175 3180 io_end->flag |= EXT4_IO_END_DIRECT; 3176 - /* 3177 - * Grab reference for DIO. Will be dropped in ext4_end_io_dio() 3178 - */ 3179 - iocb->private = ext4_get_io_end(io_end); 3181 + iocb->private = io_end; 3180 3182 /* 3181 3183 * we save the io structure for current async direct 3182 3184 * IO, so that later ext4_map_blocks() could flag the ··· 3197 3205 NULL, 3198 3206 dio_flags); 3199 3207 3200 - /* 3201 - * Put our reference to io_end. This can free the io_end structure e.g. 3202 - * in sync IO case or in case of error. It can even perform extent 3203 - * conversion if all bios we submitted finished before we got here. 3204 - * Note that in that case iocb->private can be already set to NULL 3205 - * here. 3206 - */ 3207 - if (io_end) { 3208 + if (iocb->private) 3208 3209 ext4_inode_aio_set(inode, NULL); 3209 - ext4_put_io_end(io_end); 3210 - /* 3211 - * In case of error or no write ext4_end_io_dio() was not 3212 - * called so we have to put iocb's reference. 3213 - */ 3214 - if (ret <= 0 && ret != -EIOCBQUEUED) { 3215 - WARN_ON(iocb->private != io_end); 3216 - ext4_put_io_end(io_end); 3217 - iocb->private = NULL; 3218 - } 3219 - } 3220 - if (ret > 0 && !overwrite && ext4_test_inode_state(inode, 3210 + /* 3211 + * The io_end structure takes a reference to the inode, that 3212 + * structure needs to be destroyed and the reference to the 3213 + * inode need to be dropped, when IO is complete, even with 0 3214 + * byte write, or failed. 3215 + * 3216 + * In the successful AIO DIO case, the io_end structure will 3217 + * be destroyed and the reference to the inode will be dropped 3218 + * after the end_io call back function is called. 3219 + * 3220 + * In the case there is 0 byte write, or error case, since VFS 3221 + * direct IO won't invoke the end_io call back function, we 3222 + * need to free the end_io structure here. 3223 + */ 3224 + if (ret != -EIOCBQUEUED && ret <= 0 && iocb->private) { 3225 + ext4_free_io_end(iocb->private); 3226 + iocb->private = NULL; 3227 + } else if (ret > 0 && !overwrite && ext4_test_inode_state(inode, 3221 3228 EXT4_STATE_DIO_UNWRITTEN)) { 3222 3229 int err; 3223 3230 /*
+5 -1
fs/ext4/mballoc.c
··· 2105 2105 group = ac->ac_g_ex.fe_group; 2106 2106 2107 2107 for (i = 0; i < ngroups; group++, i++) { 2108 - if (group == ngroups) 2108 + /* 2109 + * Artificially restricted ngroups for non-extent 2110 + * files makes group > ngroups possible on first loop. 2111 + */ 2112 + if (group >= ngroups) 2109 2113 group = 0; 2110 2114 2111 2115 /* This now checks without needing the buddy page */
+45 -76
fs/ext4/page-io.c
··· 62 62 cancel_work_sync(&EXT4_I(inode)->i_unwritten_work); 63 63 } 64 64 65 - static void ext4_release_io_end(ext4_io_end_t *io_end) 65 + void ext4_free_io_end(ext4_io_end_t *io) 66 66 { 67 - BUG_ON(!list_empty(&io_end->list)); 68 - BUG_ON(io_end->flag & EXT4_IO_END_UNWRITTEN); 67 + BUG_ON(!io); 68 + BUG_ON(!list_empty(&io->list)); 69 + BUG_ON(io->flag & EXT4_IO_END_UNWRITTEN); 69 70 70 - if (atomic_dec_and_test(&EXT4_I(io_end->inode)->i_ioend_count)) 71 - wake_up_all(ext4_ioend_wq(io_end->inode)); 72 - if (io_end->flag & EXT4_IO_END_DIRECT) 73 - inode_dio_done(io_end->inode); 74 - if (io_end->iocb) 75 - aio_complete(io_end->iocb, io_end->result, 0); 76 - kmem_cache_free(io_end_cachep, io_end); 77 - } 78 - 79 - static void ext4_clear_io_unwritten_flag(ext4_io_end_t *io_end) 80 - { 81 - struct inode *inode = io_end->inode; 82 - 83 - io_end->flag &= ~EXT4_IO_END_UNWRITTEN; 84 - /* Wake up anyone waiting on unwritten extent conversion */ 85 - if (atomic_dec_and_test(&EXT4_I(inode)->i_unwritten)) 86 - wake_up_all(ext4_ioend_wq(inode)); 71 + if (atomic_dec_and_test(&EXT4_I(io->inode)->i_ioend_count)) 72 + wake_up_all(ext4_ioend_wq(io->inode)); 73 + kmem_cache_free(io_end_cachep, io); 87 74 } 88 75 89 76 /* check a range of space and convert unwritten extents to written. */ ··· 93 106 "(inode %lu, offset %llu, size %zd, error %d)", 94 107 inode->i_ino, offset, size, ret); 95 108 } 96 - ext4_clear_io_unwritten_flag(io); 97 - ext4_release_io_end(io); 109 + /* Wake up anyone waiting on unwritten extent conversion */ 110 + if (atomic_dec_and_test(&EXT4_I(inode)->i_unwritten)) 111 + wake_up_all(ext4_ioend_wq(inode)); 112 + if (io->flag & EXT4_IO_END_DIRECT) 113 + inode_dio_done(inode); 114 + if (io->iocb) 115 + aio_complete(io->iocb, io->result, 0); 98 116 return ret; 99 117 } 100 118 ··· 130 138 } 131 139 132 140 /* Add the io_end to per-inode completed end_io list. */ 133 - static void ext4_add_complete_io(ext4_io_end_t *io_end) 141 + void ext4_add_complete_io(ext4_io_end_t *io_end) 134 142 { 135 143 struct ext4_inode_info *ei = EXT4_I(io_end->inode); 136 144 struct workqueue_struct *wq; ··· 167 175 err = ext4_end_io(io); 168 176 if (unlikely(!ret && err)) 169 177 ret = err; 178 + io->flag &= ~EXT4_IO_END_UNWRITTEN; 179 + ext4_free_io_end(io); 170 180 } 171 181 return ret; 172 182 } ··· 200 206 atomic_inc(&EXT4_I(inode)->i_ioend_count); 201 207 io->inode = inode; 202 208 INIT_LIST_HEAD(&io->list); 203 - atomic_set(&io->count, 1); 204 209 } 205 210 return io; 206 - } 207 - 208 - void ext4_put_io_end_defer(ext4_io_end_t *io_end) 209 - { 210 - if (atomic_dec_and_test(&io_end->count)) { 211 - if (!(io_end->flag & EXT4_IO_END_UNWRITTEN) || !io_end->size) { 212 - ext4_release_io_end(io_end); 213 - return; 214 - } 215 - ext4_add_complete_io(io_end); 216 - } 217 - } 218 - 219 - int ext4_put_io_end(ext4_io_end_t *io_end) 220 - { 221 - int err = 0; 222 - 223 - if (atomic_dec_and_test(&io_end->count)) { 224 - if (io_end->flag & EXT4_IO_END_UNWRITTEN) { 225 - err = ext4_convert_unwritten_extents(io_end->inode, 226 - io_end->offset, io_end->size); 227 - ext4_clear_io_unwritten_flag(io_end); 228 - } 229 - ext4_release_io_end(io_end); 230 - } 231 - return err; 232 - } 233 - 234 - ext4_io_end_t *ext4_get_io_end(ext4_io_end_t *io_end) 235 - { 236 - atomic_inc(&io_end->count); 237 - return io_end; 238 211 } 239 212 240 213 /* ··· 286 325 bi_sector >> (inode->i_blkbits - 9)); 287 326 } 288 327 289 - ext4_put_io_end_defer(io_end); 328 + if (!(io_end->flag & EXT4_IO_END_UNWRITTEN)) { 329 + ext4_free_io_end(io_end); 330 + return; 331 + } 332 + 333 + ext4_add_complete_io(io_end); 290 334 } 291 335 292 336 void ext4_io_submit(struct ext4_io_submit *io) ··· 305 339 bio_put(io->io_bio); 306 340 } 307 341 io->io_bio = NULL; 308 - } 309 - 310 - void ext4_io_submit_init(struct ext4_io_submit *io, 311 - struct writeback_control *wbc) 312 - { 313 - io->io_op = (wbc->sync_mode == WB_SYNC_ALL ? WRITE_SYNC : WRITE); 314 - io->io_bio = NULL; 342 + io->io_op = 0; 315 343 io->io_end = NULL; 316 344 } 317 345 318 - static int io_submit_init_bio(struct ext4_io_submit *io, 319 - struct buffer_head *bh) 346 + static int io_submit_init(struct ext4_io_submit *io, 347 + struct inode *inode, 348 + struct writeback_control *wbc, 349 + struct buffer_head *bh) 320 350 { 351 + ext4_io_end_t *io_end; 352 + struct page *page = bh->b_page; 321 353 int nvecs = bio_get_nr_vecs(bh->b_bdev); 322 354 struct bio *bio; 323 355 356 + io_end = ext4_init_io_end(inode, GFP_NOFS); 357 + if (!io_end) 358 + return -ENOMEM; 324 359 bio = bio_alloc(GFP_NOIO, min(nvecs, BIO_MAX_PAGES)); 325 360 bio->bi_sector = bh->b_blocknr * (bh->b_size >> 9); 326 361 bio->bi_bdev = bh->b_bdev; 362 + bio->bi_private = io->io_end = io_end; 327 363 bio->bi_end_io = ext4_end_bio; 328 - bio->bi_private = ext4_get_io_end(io->io_end); 329 - if (!io->io_end->size) 330 - io->io_end->offset = (bh->b_page->index << PAGE_CACHE_SHIFT) 331 - + bh_offset(bh); 364 + 365 + io_end->offset = (page->index << PAGE_CACHE_SHIFT) + bh_offset(bh); 366 + 332 367 io->io_bio = bio; 368 + io->io_op = (wbc->sync_mode == WB_SYNC_ALL ? WRITE_SYNC : WRITE); 333 369 io->io_next_block = bh->b_blocknr; 334 370 return 0; 335 371 } 336 372 337 373 static int io_submit_add_bh(struct ext4_io_submit *io, 338 374 struct inode *inode, 375 + struct writeback_control *wbc, 339 376 struct buffer_head *bh) 340 377 { 341 378 ext4_io_end_t *io_end; ··· 349 380 ext4_io_submit(io); 350 381 } 351 382 if (io->io_bio == NULL) { 352 - ret = io_submit_init_bio(io, bh); 383 + ret = io_submit_init(io, inode, wbc, bh); 353 384 if (ret) 354 385 return ret; 355 386 } 356 - ret = bio_add_page(io->io_bio, bh->b_page, bh->b_size, bh_offset(bh)); 357 - if (ret != bh->b_size) 358 - goto submit_and_retry; 359 387 io_end = io->io_end; 360 388 if (test_clear_buffer_uninit(bh)) 361 389 ext4_set_io_unwritten_flag(inode, io_end); 362 - io_end->size += bh->b_size; 390 + io->io_end->size += bh->b_size; 363 391 io->io_next_block++; 392 + ret = bio_add_page(io->io_bio, bh->b_page, bh->b_size, bh_offset(bh)); 393 + if (ret != bh->b_size) 394 + goto submit_and_retry; 364 395 return 0; 365 396 } 366 397 ··· 432 463 do { 433 464 if (!buffer_async_write(bh)) 434 465 continue; 435 - ret = io_submit_add_bh(io, inode, bh); 466 + ret = io_submit_add_bh(io, inode, wbc, bh); 436 467 if (ret) { 437 468 /* 438 469 * We only get here on ENOMEM. Not much else
+1 -1
include/acpi/acpiosxf.h
··· 77 77 /* 78 78 * OSL Initialization and shutdown primitives 79 79 */ 80 - acpi_status __initdata acpi_os_initialize(void); 80 + acpi_status __init acpi_os_initialize(void); 81 81 82 82 acpi_status acpi_os_terminate(void); 83 83
+8 -2
include/acpi/processor.h
··· 329 329 int acpi_processor_power_exit(struct acpi_processor *pr); 330 330 int acpi_processor_cst_has_changed(struct acpi_processor *pr); 331 331 int acpi_processor_hotplug(struct acpi_processor *pr); 332 - int acpi_processor_suspend(struct device *dev); 333 - int acpi_processor_resume(struct device *dev); 334 332 extern struct cpuidle_driver acpi_idle_driver; 333 + 334 + #ifdef CONFIG_PM_SLEEP 335 + void acpi_processor_syscore_init(void); 336 + void acpi_processor_syscore_exit(void); 337 + #else 338 + static inline void acpi_processor_syscore_init(void) {} 339 + static inline void acpi_processor_syscore_exit(void) {} 340 + #endif 335 341 336 342 /* in processor_thermal.c */ 337 343 int acpi_processor_get_limit_info(struct acpi_processor *pr);
+2 -1
include/drm/drmP.h
··· 316 316 int flags; 317 317 drm_ioctl_t *func; 318 318 unsigned int cmd_drv; 319 + const char *name; 319 320 }; 320 321 321 322 /** ··· 325 324 */ 326 325 327 326 #define DRM_IOCTL_DEF_DRV(ioctl, _func, _flags) \ 328 - [DRM_IOCTL_NR(DRM_##ioctl)] = {.cmd = DRM_##ioctl, .func = _func, .flags = _flags, .cmd_drv = DRM_IOCTL_##ioctl} 327 + [DRM_IOCTL_NR(DRM_##ioctl)] = {.cmd = DRM_##ioctl, .func = _func, .flags = _flags, .cmd_drv = DRM_IOCTL_##ioctl, .name = #ioctl} 329 328 330 329 struct drm_magic_entry { 331 330 struct list_head head;
+8 -7
include/drm/drm_fb_helper.h
··· 50 50 51 51 /** 52 52 * struct drm_fb_helper_funcs - driver callbacks for the fbdev emulation library 53 - * @gamma_set: - Set the given gamma lut register on the given crtc. 54 - * @gamma_get: - Read the given gamma lut register on the given crtc, used to 55 - * save the current lut when force-restoring the fbdev for e.g. 56 - * kdbg. 57 - * @fb_probe: - Driver callback to allocate and initialize the fbdev info 58 - * structure. Futhermore it also needs to allocate the drm 59 - * framebuffer used to back the fbdev. 53 + * @gamma_set: Set the given gamma lut register on the given crtc. 54 + * @gamma_get: Read the given gamma lut register on the given crtc, used to 55 + * save the current lut when force-restoring the fbdev for e.g. 56 + * kdbg. 57 + * @fb_probe: Driver callback to allocate and initialize the fbdev info 58 + * structure. Futhermore it also needs to allocate the drm 59 + * framebuffer used to back the fbdev. 60 + * @initial_config: Setup an initial fbdev display configuration 60 61 * 61 62 * Driver callbacks used by the fbdev emulation helper library. 62 63 */
-9
include/drm/drm_os_linux.h
··· 87 87 /** Other copying of data from kernel space */ 88 88 #define DRM_COPY_TO_USER(arg1, arg2, arg3) \ 89 89 copy_to_user(arg1, arg2, arg3) 90 - /* Macros for copyfrom user, but checking readability only once */ 91 - #define DRM_VERIFYAREA_READ( uaddr, size ) \ 92 - (access_ok( VERIFY_READ, uaddr, size ) ? 0 : -EFAULT) 93 - #define DRM_COPY_FROM_USER_UNCHECKED(arg1, arg2, arg3) \ 94 - __copy_from_user(arg1, arg2, arg3) 95 - #define DRM_COPY_TO_USER_UNCHECKED(arg1, arg2, arg3) \ 96 - __copy_to_user(arg1, arg2, arg3) 97 - #define DRM_GET_USER_UNCHECKED(val, uaddr) \ 98 - __get_user(val, uaddr) 99 90 100 91 #define DRM_HZ HZ 101 92
+6 -2
include/linux/journal-head.h
··· 30 30 31 31 /* 32 32 * Journalling list for this buffer [jbd_lock_bh_state()] 33 + * NOTE: We *cannot* combine this with b_modified into a bitfield 34 + * as gcc would then (which the C standard allows but which is 35 + * very unuseful) make 64-bit accesses to the bitfield and clobber 36 + * b_jcount if its update races with bitfield modification. 33 37 */ 34 - unsigned b_jlist:4; 38 + unsigned b_jlist; 35 39 36 40 /* 37 41 * This flag signals the buffer has been modified by 38 42 * the currently running transaction 39 43 * [jbd_lock_bh_state()] 40 44 */ 41 - unsigned b_modified:1; 45 + unsigned b_modified; 42 46 43 47 /* 44 48 * Copy of the buffer data frozen for writing to the log.
+33
include/linux/kref.h
··· 19 19 #include <linux/atomic.h> 20 20 #include <linux/kernel.h> 21 21 #include <linux/mutex.h> 22 + #include <linux/spinlock.h> 22 23 23 24 struct kref { 24 25 atomic_t refcount; ··· 97 96 static inline int kref_put(struct kref *kref, void (*release)(struct kref *kref)) 98 97 { 99 98 return kref_sub(kref, 1, release); 99 + } 100 + 101 + /** 102 + * kref_put_spinlock_irqsave - decrement refcount for object. 103 + * @kref: object. 104 + * @release: pointer to the function that will clean up the object when the 105 + * last reference to the object is released. 106 + * This pointer is required, and it is not acceptable to pass kfree 107 + * in as this function. 108 + * @lock: lock to take in release case 109 + * 110 + * Behaves identical to kref_put with one exception. If the reference count 111 + * drops to zero, the lock will be taken atomically wrt dropping the reference 112 + * count. The release function has to call spin_unlock() without _irqrestore. 113 + */ 114 + static inline int kref_put_spinlock_irqsave(struct kref *kref, 115 + void (*release)(struct kref *kref), 116 + spinlock_t *lock) 117 + { 118 + unsigned long flags; 119 + 120 + WARN_ON(release == NULL); 121 + if (atomic_add_unless(&kref->refcount, -1, 1)) 122 + return 0; 123 + spin_lock_irqsave(lock, flags); 124 + if (atomic_dec_and_test(&kref->refcount)) { 125 + release(kref); 126 + local_irq_restore(flags); 127 + return 1; 128 + } 129 + spin_unlock_irqrestore(lock, flags); 130 + return 0; 100 131 } 101 132 102 133 static inline int kref_put_mutex(struct kref *kref,
+27 -2
include/linux/mlx4/qp.h
··· 126 126 127 127 struct mlx4_qp_path { 128 128 u8 fl; 129 - u8 reserved1[1]; 129 + u8 vlan_control; 130 130 u8 disable_pkey_check; 131 131 u8 pkey_index; 132 132 u8 counter_index; ··· 141 141 u8 sched_queue; 142 142 u8 vlan_index; 143 143 u8 feup; 144 - u8 reserved3; 144 + u8 fvl_rx; 145 145 u8 reserved4[2]; 146 146 u8 dmac[6]; 147 + }; 148 + 149 + enum { /* fl */ 150 + MLX4_FL_CV = 1 << 6, 151 + MLX4_FL_ETH_HIDE_CQE_VLAN = 1 << 2 152 + }; 153 + enum { /* vlan_control */ 154 + MLX4_VLAN_CTRL_ETH_TX_BLOCK_TAGGED = 1 << 6, 155 + MLX4_VLAN_CTRL_ETH_RX_BLOCK_TAGGED = 1 << 2, 156 + MLX4_VLAN_CTRL_ETH_RX_BLOCK_PRIO_TAGGED = 1 << 1, /* 802.1p priority tag */ 157 + MLX4_VLAN_CTRL_ETH_RX_BLOCK_UNTAGGED = 1 << 0 158 + }; 159 + 160 + enum { /* feup */ 161 + MLX4_FEUP_FORCE_ETH_UP = 1 << 6, /* force Eth UP */ 162 + MLX4_FSM_FORCE_ETH_SRC_MAC = 1 << 5, /* force Source MAC */ 163 + MLX4_FVL_FORCE_ETH_VLAN = 1 << 3 /* force Eth vlan */ 164 + }; 165 + 166 + enum { /* fvl_rx */ 167 + MLX4_FVL_RX_FORCE_ETH_VLAN = 1 << 0 /* enforce Eth rx vlan */ 147 168 }; 148 169 149 170 struct mlx4_qp_context { ··· 204 183 u8 mtt_base_addr_h; 205 184 __be32 mtt_base_addr_l; 206 185 u32 reserved5[10]; 186 + }; 187 + 188 + enum { /* param3 */ 189 + MLX4_STRIP_VLAN = 1 << 30 207 190 }; 208 191 209 192 /* Which firmware version adds support for NEC (NoErrorCompletion) bit */
+3 -2
include/linux/of_platform.h
··· 11 11 * 12 12 */ 13 13 14 - #ifdef CONFIG_OF_DEVICE 15 14 #include <linux/device.h> 16 15 #include <linux/mod_devicetable.h> 16 + 17 + #ifdef CONFIG_OF_DEVICE 17 18 #include <linux/pm.h> 18 19 #include <linux/of_device.h> 19 20 #include <linux/platform_device.h> ··· 101 100 102 101 #if !defined(CONFIG_OF_ADDRESS) 103 102 struct of_dev_auxdata; 104 - struct device; 103 + struct device_node; 105 104 static inline int of_platform_populate(struct device_node *root, 106 105 const struct of_device_id *matches, 107 106 const struct of_dev_auxdata *lookup,
+6 -6
include/linux/pinctrl/pinconf-generic.h
··· 37 37 * if it is 0, pull-down is disabled. 38 38 * @PIN_CONFIG_DRIVE_PUSH_PULL: the pin will be driven actively high and 39 39 * low, this is the most typical case and is typically achieved with two 40 - * active transistors on the output. Sending this config will enabale 40 + * active transistors on the output. Setting this config will enable 41 41 * push-pull mode, the argument is ignored. 42 42 * @PIN_CONFIG_DRIVE_OPEN_DRAIN: the pin will be driven with open drain (open 43 43 * collector) which means it is usually wired with other output ports 44 - * which are then pulled up with an external resistor. Sending this 45 - * config will enabale open drain mode, the argument is ignored. 44 + * which are then pulled up with an external resistor. Setting this 45 + * config will enable open drain mode, the argument is ignored. 46 46 * @PIN_CONFIG_DRIVE_OPEN_SOURCE: the pin will be driven with open source 47 - * (open emitter). Sending this config will enabale open drain mode, the 47 + * (open emitter). Setting this config will enable open drain mode, the 48 48 * argument is ignored. 49 - * @PIN_CONFIG_DRIVE_STRENGTH: the pin will output the current passed as 50 - * argument. The argument is in mA. 49 + * @PIN_CONFIG_DRIVE_STRENGTH: the pin will sink or source at most the current 50 + * passed as argument. The argument is in mA. 51 51 * @PIN_CONFIG_INPUT_SCHMITT_ENABLE: control schmitt-trigger mode on the pin. 52 52 * If the argument != 0, schmitt-trigger mode is enabled. If it's 0, 53 53 * schmitt-trigger mode is disabled.
+2 -2
include/linux/spi/spi.h
··· 57 57 * @modalias: Name of the driver to use with this device, or an alias 58 58 * for that name. This appears in the sysfs "modalias" attribute 59 59 * for driver coldplugging, and in uevents used for hotplugging 60 - * @cs_gpio: gpio number of the chipselect line (optional, -EINVAL when 60 + * @cs_gpio: gpio number of the chipselect line (optional, -ENOENT when 61 61 * when not using a GPIO line) 62 62 * 63 63 * A @spi_device is used to interchange data between an SPI slave ··· 266 266 * queue so the subsystem notifies the driver that it may relax the 267 267 * hardware by issuing this call 268 268 * @cs_gpios: Array of GPIOs to use as chip select lines; one per CS 269 - * number. Any individual value may be -EINVAL for CS lines that 269 + * number. Any individual value may be -ENOENT for CS lines that 270 270 * are not GPIOs (driven by the SPI controller itself). 271 271 * 272 272 * Each SPI master controller can communicate with one or more @spi_device
-4
include/linux/time.h
··· 117 117 118 118 extern bool persistent_clock_exist; 119 119 120 - #ifdef ALWAYS_USE_PERSISTENT_CLOCK 121 - #define has_persistent_clock() true 122 - #else 123 120 static inline bool has_persistent_clock(void) 124 121 { 125 122 return persistent_clock_exist; 126 123 } 127 - #endif 128 124 129 125 extern void read_persistent_clock(struct timespec *ts); 130 126 extern void read_boot_clock(struct timespec *ts);
+12
include/net/sock.h
··· 866 866 struct raw_hashinfo; 867 867 struct module; 868 868 869 + /* 870 + * caches using SLAB_DESTROY_BY_RCU should let .next pointer from nulls nodes 871 + * un-modified. Special care is taken when initializing object to zero. 872 + */ 873 + static inline void sk_prot_clear_nulls(struct sock *sk, int size) 874 + { 875 + if (offsetof(struct sock, sk_node.next) != 0) 876 + memset(sk, 0, offsetof(struct sock, sk_node.next)); 877 + memset(&sk->sk_node.pprev, 0, 878 + size - offsetof(struct sock, sk_node.pprev)); 879 + } 880 + 869 881 /* Networking protocol blocks we attach to sockets. 870 882 * socket layer -> transport layer interface 871 883 * transport -> network interface is defined by struct inet_proto
-5
include/target/target_core_base.h
··· 463 463 #define CMD_T_ABORTED (1 << 0) 464 464 #define CMD_T_ACTIVE (1 << 1) 465 465 #define CMD_T_COMPLETE (1 << 2) 466 - #define CMD_T_QUEUED (1 << 3) 467 466 #define CMD_T_SENT (1 << 4) 468 467 #define CMD_T_STOP (1 << 5) 469 468 #define CMD_T_FAILED (1 << 6) ··· 571 572 bool def_pr_registered; 572 573 /* See transport_lunflags_table */ 573 574 u32 lun_flags; 574 - u32 deve_cmds; 575 575 u32 mapped_lun; 576 - u32 average_bytes; 577 - u32 last_byte_count; 578 576 u32 total_cmds; 579 - u32 total_bytes; 580 577 u64 pr_res_key; 581 578 u64 creation_time; 582 579 u32 attach_count;
+2 -2
include/trace/events/ext4.h
··· 2139 2139 __entry->lblk, __entry->len) 2140 2140 ); 2141 2141 2142 - TRACE_EVENT(ext4_es_find_delayed_extent_enter, 2142 + TRACE_EVENT(ext4_es_find_delayed_extent_range_enter, 2143 2143 TP_PROTO(struct inode *inode, ext4_lblk_t lblk), 2144 2144 2145 2145 TP_ARGS(inode, lblk), ··· 2161 2161 (unsigned long) __entry->ino, __entry->lblk) 2162 2162 ); 2163 2163 2164 - TRACE_EVENT(ext4_es_find_delayed_extent_exit, 2164 + TRACE_EVENT(ext4_es_find_delayed_extent_range_exit, 2165 2165 TP_PROTO(struct inode *inode, struct extent_status *es), 2166 2166 2167 2167 TP_ARGS(inode, es),
+2
kernel/cpu/idle.c
··· 40 40 41 41 static inline int cpu_idle_poll(void) 42 42 { 43 + rcu_idle_enter(); 43 44 trace_cpu_idle_rcuidle(0, smp_processor_id()); 44 45 local_irq_enable(); 45 46 while (!need_resched()) 46 47 cpu_relax(); 47 48 trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, smp_processor_id()); 49 + rcu_idle_exit(); 48 50 return 1; 49 51 } 50 52
+89 -151
kernel/events/core.c
··· 4394 4394 perf_output_end(&handle); 4395 4395 } 4396 4396 4397 + typedef int (perf_event_aux_match_cb)(struct perf_event *event, void *data); 4398 + typedef void (perf_event_aux_output_cb)(struct perf_event *event, void *data); 4399 + 4400 + static void 4401 + perf_event_aux_ctx(struct perf_event_context *ctx, 4402 + perf_event_aux_match_cb match, 4403 + perf_event_aux_output_cb output, 4404 + void *data) 4405 + { 4406 + struct perf_event *event; 4407 + 4408 + list_for_each_entry_rcu(event, &ctx->event_list, event_entry) { 4409 + if (event->state < PERF_EVENT_STATE_INACTIVE) 4410 + continue; 4411 + if (!event_filter_match(event)) 4412 + continue; 4413 + if (match(event, data)) 4414 + output(event, data); 4415 + } 4416 + } 4417 + 4418 + static void 4419 + perf_event_aux(perf_event_aux_match_cb match, 4420 + perf_event_aux_output_cb output, 4421 + void *data, 4422 + struct perf_event_context *task_ctx) 4423 + { 4424 + struct perf_cpu_context *cpuctx; 4425 + struct perf_event_context *ctx; 4426 + struct pmu *pmu; 4427 + int ctxn; 4428 + 4429 + rcu_read_lock(); 4430 + list_for_each_entry_rcu(pmu, &pmus, entry) { 4431 + cpuctx = get_cpu_ptr(pmu->pmu_cpu_context); 4432 + if (cpuctx->unique_pmu != pmu) 4433 + goto next; 4434 + perf_event_aux_ctx(&cpuctx->ctx, match, output, data); 4435 + if (task_ctx) 4436 + goto next; 4437 + ctxn = pmu->task_ctx_nr; 4438 + if (ctxn < 0) 4439 + goto next; 4440 + ctx = rcu_dereference(current->perf_event_ctxp[ctxn]); 4441 + if (ctx) 4442 + perf_event_aux_ctx(ctx, match, output, data); 4443 + next: 4444 + put_cpu_ptr(pmu->pmu_cpu_context); 4445 + } 4446 + 4447 + if (task_ctx) { 4448 + preempt_disable(); 4449 + perf_event_aux_ctx(task_ctx, match, output, data); 4450 + preempt_enable(); 4451 + } 4452 + rcu_read_unlock(); 4453 + } 4454 + 4397 4455 /* 4398 4456 * task tracking -- fork/exit 4399 4457 * ··· 4474 4416 }; 4475 4417 4476 4418 static void perf_event_task_output(struct perf_event *event, 4477 - struct perf_task_event *task_event) 4419 + void *data) 4478 4420 { 4421 + struct perf_task_event *task_event = data; 4479 4422 struct perf_output_handle handle; 4480 4423 struct perf_sample_data sample; 4481 4424 struct task_struct *task = task_event->task; ··· 4504 4445 task_event->event_id.header.size = size; 4505 4446 } 4506 4447 4507 - static int perf_event_task_match(struct perf_event *event) 4448 + static int perf_event_task_match(struct perf_event *event, 4449 + void *data __maybe_unused) 4508 4450 { 4509 - if (event->state < PERF_EVENT_STATE_INACTIVE) 4510 - return 0; 4511 - 4512 - if (!event_filter_match(event)) 4513 - return 0; 4514 - 4515 - if (event->attr.comm || event->attr.mmap || 4516 - event->attr.mmap_data || event->attr.task) 4517 - return 1; 4518 - 4519 - return 0; 4520 - } 4521 - 4522 - static void perf_event_task_ctx(struct perf_event_context *ctx, 4523 - struct perf_task_event *task_event) 4524 - { 4525 - struct perf_event *event; 4526 - 4527 - list_for_each_entry_rcu(event, &ctx->event_list, event_entry) { 4528 - if (perf_event_task_match(event)) 4529 - perf_event_task_output(event, task_event); 4530 - } 4531 - } 4532 - 4533 - static void perf_event_task_event(struct perf_task_event *task_event) 4534 - { 4535 - struct perf_cpu_context *cpuctx; 4536 - struct perf_event_context *ctx; 4537 - struct pmu *pmu; 4538 - int ctxn; 4539 - 4540 - rcu_read_lock(); 4541 - list_for_each_entry_rcu(pmu, &pmus, entry) { 4542 - cpuctx = get_cpu_ptr(pmu->pmu_cpu_context); 4543 - if (cpuctx->unique_pmu != pmu) 4544 - goto next; 4545 - perf_event_task_ctx(&cpuctx->ctx, task_event); 4546 - 4547 - ctx = task_event->task_ctx; 4548 - if (!ctx) { 4549 - ctxn = pmu->task_ctx_nr; 4550 - if (ctxn < 0) 4551 - goto next; 4552 - ctx = rcu_dereference(current->perf_event_ctxp[ctxn]); 4553 - if (ctx) 4554 - perf_event_task_ctx(ctx, task_event); 4555 - } 4556 - next: 4557 - put_cpu_ptr(pmu->pmu_cpu_context); 4558 - } 4559 - if (task_event->task_ctx) 4560 - perf_event_task_ctx(task_event->task_ctx, task_event); 4561 - 4562 - rcu_read_unlock(); 4451 + return event->attr.comm || event->attr.mmap || 4452 + event->attr.mmap_data || event->attr.task; 4563 4453 } 4564 4454 4565 4455 static void perf_event_task(struct task_struct *task, ··· 4539 4531 }, 4540 4532 }; 4541 4533 4542 - perf_event_task_event(&task_event); 4534 + perf_event_aux(perf_event_task_match, 4535 + perf_event_task_output, 4536 + &task_event, 4537 + task_ctx); 4543 4538 } 4544 4539 4545 4540 void perf_event_fork(struct task_struct *task) ··· 4568 4557 }; 4569 4558 4570 4559 static void perf_event_comm_output(struct perf_event *event, 4571 - struct perf_comm_event *comm_event) 4560 + void *data) 4572 4561 { 4562 + struct perf_comm_event *comm_event = data; 4573 4563 struct perf_output_handle handle; 4574 4564 struct perf_sample_data sample; 4575 4565 int size = comm_event->event_id.header.size; ··· 4597 4585 comm_event->event_id.header.size = size; 4598 4586 } 4599 4587 4600 - static int perf_event_comm_match(struct perf_event *event) 4588 + static int perf_event_comm_match(struct perf_event *event, 4589 + void *data __maybe_unused) 4601 4590 { 4602 - if (event->state < PERF_EVENT_STATE_INACTIVE) 4603 - return 0; 4604 - 4605 - if (!event_filter_match(event)) 4606 - return 0; 4607 - 4608 - if (event->attr.comm) 4609 - return 1; 4610 - 4611 - return 0; 4612 - } 4613 - 4614 - static void perf_event_comm_ctx(struct perf_event_context *ctx, 4615 - struct perf_comm_event *comm_event) 4616 - { 4617 - struct perf_event *event; 4618 - 4619 - list_for_each_entry_rcu(event, &ctx->event_list, event_entry) { 4620 - if (perf_event_comm_match(event)) 4621 - perf_event_comm_output(event, comm_event); 4622 - } 4591 + return event->attr.comm; 4623 4592 } 4624 4593 4625 4594 static void perf_event_comm_event(struct perf_comm_event *comm_event) 4626 4595 { 4627 - struct perf_cpu_context *cpuctx; 4628 - struct perf_event_context *ctx; 4629 4596 char comm[TASK_COMM_LEN]; 4630 4597 unsigned int size; 4631 - struct pmu *pmu; 4632 - int ctxn; 4633 4598 4634 4599 memset(comm, 0, sizeof(comm)); 4635 4600 strlcpy(comm, comm_event->task->comm, sizeof(comm)); ··· 4616 4627 comm_event->comm_size = size; 4617 4628 4618 4629 comm_event->event_id.header.size = sizeof(comm_event->event_id) + size; 4619 - rcu_read_lock(); 4620 - list_for_each_entry_rcu(pmu, &pmus, entry) { 4621 - cpuctx = get_cpu_ptr(pmu->pmu_cpu_context); 4622 - if (cpuctx->unique_pmu != pmu) 4623 - goto next; 4624 - perf_event_comm_ctx(&cpuctx->ctx, comm_event); 4625 4630 4626 - ctxn = pmu->task_ctx_nr; 4627 - if (ctxn < 0) 4628 - goto next; 4629 - 4630 - ctx = rcu_dereference(current->perf_event_ctxp[ctxn]); 4631 - if (ctx) 4632 - perf_event_comm_ctx(ctx, comm_event); 4633 - next: 4634 - put_cpu_ptr(pmu->pmu_cpu_context); 4635 - } 4636 - rcu_read_unlock(); 4631 + perf_event_aux(perf_event_comm_match, 4632 + perf_event_comm_output, 4633 + comm_event, 4634 + NULL); 4637 4635 } 4638 4636 4639 4637 void perf_event_comm(struct task_struct *task) ··· 4682 4706 }; 4683 4707 4684 4708 static void perf_event_mmap_output(struct perf_event *event, 4685 - struct perf_mmap_event *mmap_event) 4709 + void *data) 4686 4710 { 4711 + struct perf_mmap_event *mmap_event = data; 4687 4712 struct perf_output_handle handle; 4688 4713 struct perf_sample_data sample; 4689 4714 int size = mmap_event->event_id.header.size; ··· 4711 4734 } 4712 4735 4713 4736 static int perf_event_mmap_match(struct perf_event *event, 4714 - struct perf_mmap_event *mmap_event, 4715 - int executable) 4737 + void *data) 4716 4738 { 4717 - if (event->state < PERF_EVENT_STATE_INACTIVE) 4718 - return 0; 4739 + struct perf_mmap_event *mmap_event = data; 4740 + struct vm_area_struct *vma = mmap_event->vma; 4741 + int executable = vma->vm_flags & VM_EXEC; 4719 4742 4720 - if (!event_filter_match(event)) 4721 - return 0; 4722 - 4723 - if ((!executable && event->attr.mmap_data) || 4724 - (executable && event->attr.mmap)) 4725 - return 1; 4726 - 4727 - return 0; 4728 - } 4729 - 4730 - static void perf_event_mmap_ctx(struct perf_event_context *ctx, 4731 - struct perf_mmap_event *mmap_event, 4732 - int executable) 4733 - { 4734 - struct perf_event *event; 4735 - 4736 - list_for_each_entry_rcu(event, &ctx->event_list, event_entry) { 4737 - if (perf_event_mmap_match(event, mmap_event, executable)) 4738 - perf_event_mmap_output(event, mmap_event); 4739 - } 4743 + return (!executable && event->attr.mmap_data) || 4744 + (executable && event->attr.mmap); 4740 4745 } 4741 4746 4742 4747 static void perf_event_mmap_event(struct perf_mmap_event *mmap_event) 4743 4748 { 4744 - struct perf_cpu_context *cpuctx; 4745 - struct perf_event_context *ctx; 4746 4749 struct vm_area_struct *vma = mmap_event->vma; 4747 4750 struct file *file = vma->vm_file; 4748 4751 unsigned int size; 4749 4752 char tmp[16]; 4750 4753 char *buf = NULL; 4751 4754 const char *name; 4752 - struct pmu *pmu; 4753 - int ctxn; 4754 4755 4755 4756 memset(tmp, 0, sizeof(tmp)); 4756 4757 ··· 4784 4829 4785 4830 mmap_event->event_id.header.size = sizeof(mmap_event->event_id) + size; 4786 4831 4787 - rcu_read_lock(); 4788 - list_for_each_entry_rcu(pmu, &pmus, entry) { 4789 - cpuctx = get_cpu_ptr(pmu->pmu_cpu_context); 4790 - if (cpuctx->unique_pmu != pmu) 4791 - goto next; 4792 - perf_event_mmap_ctx(&cpuctx->ctx, mmap_event, 4793 - vma->vm_flags & VM_EXEC); 4794 - 4795 - ctxn = pmu->task_ctx_nr; 4796 - if (ctxn < 0) 4797 - goto next; 4798 - 4799 - ctx = rcu_dereference(current->perf_event_ctxp[ctxn]); 4800 - if (ctx) { 4801 - perf_event_mmap_ctx(ctx, mmap_event, 4802 - vma->vm_flags & VM_EXEC); 4803 - } 4804 - next: 4805 - put_cpu_ptr(pmu->pmu_cpu_context); 4806 - } 4807 - rcu_read_unlock(); 4832 + perf_event_aux(perf_event_mmap_match, 4833 + perf_event_mmap_output, 4834 + mmap_event, 4835 + NULL); 4808 4836 4809 4837 kfree(buf); 4810 4838 }
+5
kernel/kmod.c
··· 569 569 int retval = 0; 570 570 571 571 helper_lock(); 572 + if (!sub_info->path) { 573 + retval = -EINVAL; 574 + goto out; 575 + } 576 + 572 577 if (sub_info->path[0] == '\0') 573 578 goto out; 574 579
+4 -17
kernel/module.c
··· 2431 2431 kmemleak_scan_area(mod, sizeof(struct module), GFP_KERNEL); 2432 2432 2433 2433 for (i = 1; i < info->hdr->e_shnum; i++) { 2434 - const char *name = info->secstrings + info->sechdrs[i].sh_name; 2435 - if (!(info->sechdrs[i].sh_flags & SHF_ALLOC)) 2436 - continue; 2437 - if (!strstarts(name, ".data") && !strstarts(name, ".bss")) 2434 + /* Scan all writable sections that's not executable */ 2435 + if (!(info->sechdrs[i].sh_flags & SHF_ALLOC) || 2436 + !(info->sechdrs[i].sh_flags & SHF_WRITE) || 2437 + (info->sechdrs[i].sh_flags & SHF_EXECINSTR)) 2438 2438 continue; 2439 2439 2440 2440 kmemleak_scan_area((void *)info->sechdrs[i].sh_addr, ··· 2769 2769 mod->trace_events = section_objs(info, "_ftrace_events", 2770 2770 sizeof(*mod->trace_events), 2771 2771 &mod->num_trace_events); 2772 - /* 2773 - * This section contains pointers to allocated objects in the trace 2774 - * code and not scanning it leads to false positives. 2775 - */ 2776 - kmemleak_scan_area(mod->trace_events, sizeof(*mod->trace_events) * 2777 - mod->num_trace_events, GFP_KERNEL); 2778 2772 #endif 2779 2773 #ifdef CONFIG_TRACING 2780 2774 mod->trace_bprintk_fmt_start = section_objs(info, "__trace_printk_fmt", 2781 2775 sizeof(*mod->trace_bprintk_fmt_start), 2782 2776 &mod->num_trace_bprintk_fmt); 2783 - /* 2784 - * This section contains pointers to allocated objects in the trace 2785 - * code and not scanning it leads to false positives. 2786 - */ 2787 - kmemleak_scan_area(mod->trace_bprintk_fmt_start, 2788 - sizeof(*mod->trace_bprintk_fmt_start) * 2789 - mod->num_trace_bprintk_fmt, GFP_KERNEL); 2790 2777 #endif 2791 2778 #ifdef CONFIG_FTRACE_MCOUNT_RECORD 2792 2779 /* sechdrs[0].sh_size is always zero */
+2 -2
kernel/rcutree_plugin.h
··· 88 88 #ifdef CONFIG_RCU_NOCB_CPU 89 89 #ifndef CONFIG_RCU_NOCB_CPU_NONE 90 90 if (!have_rcu_nocb_mask) { 91 - alloc_bootmem_cpumask_var(&rcu_nocb_mask); 91 + zalloc_cpumask_var(&rcu_nocb_mask, GFP_KERNEL); 92 92 have_rcu_nocb_mask = true; 93 93 } 94 94 #ifdef CONFIG_RCU_NOCB_CPU_ZERO ··· 1667 1667 rdtp->last_accelerate = jiffies; 1668 1668 1669 1669 /* Request timer delay depending on laziness, and round. */ 1670 - if (rdtp->all_lazy) { 1670 + if (!rdtp->all_lazy) { 1671 1671 *dj = round_up(rcu_idle_gp_delay + jiffies, 1672 1672 rcu_idle_gp_delay) - jiffies; 1673 1673 } else {
-5
kernel/time/Kconfig
··· 12 12 config ARCH_CLOCKSOURCE_DATA 13 13 bool 14 14 15 - # Platforms has a persistent clock 16 - config ALWAYS_USE_PERSISTENT_CLOCK 17 - bool 18 - default n 19 - 20 15 # Timekeeping vsyscall support 21 16 config GENERIC_TIME_VSYSCALL 22 17 bool
+5 -5
kernel/time/tick-broadcast.c
··· 786 786 787 787 void __init tick_broadcast_init(void) 788 788 { 789 - alloc_cpumask_var(&tick_broadcast_mask, GFP_NOWAIT); 790 - alloc_cpumask_var(&tmpmask, GFP_NOWAIT); 789 + zalloc_cpumask_var(&tick_broadcast_mask, GFP_NOWAIT); 790 + zalloc_cpumask_var(&tmpmask, GFP_NOWAIT); 791 791 #ifdef CONFIG_TICK_ONESHOT 792 - alloc_cpumask_var(&tick_broadcast_oneshot_mask, GFP_NOWAIT); 793 - alloc_cpumask_var(&tick_broadcast_pending_mask, GFP_NOWAIT); 794 - alloc_cpumask_var(&tick_broadcast_force_mask, GFP_NOWAIT); 792 + zalloc_cpumask_var(&tick_broadcast_oneshot_mask, GFP_NOWAIT); 793 + zalloc_cpumask_var(&tick_broadcast_pending_mask, GFP_NOWAIT); 794 + zalloc_cpumask_var(&tick_broadcast_force_mask, GFP_NOWAIT); 795 795 #endif 796 796 }
+2 -1
kernel/time/tick-sched.c
··· 717 717 if (unlikely(!cpu_online(cpu))) { 718 718 if (cpu == tick_do_timer_cpu) 719 719 tick_do_timer_cpu = TICK_DO_TIMER_NONE; 720 + return false; 720 721 } 721 722 722 723 if (unlikely(ts->nohz_mode == NOHZ_MODE_INACTIVE)) ··· 1169 1168 hrtimer_cancel(&ts->sched_timer); 1170 1169 # endif 1171 1170 1172 - ts->nohz_mode = NOHZ_MODE_INACTIVE; 1171 + memset(ts, 0, sizeof(*ts)); 1173 1172 } 1174 1173 #endif 1175 1174
+1 -1
kernel/timer.c
··· 1539 1539 boot_done = 1; 1540 1540 base = &boot_tvec_bases; 1541 1541 } 1542 + spin_lock_init(&base->lock); 1542 1543 tvec_base_done[cpu] = 1; 1543 1544 } else { 1544 1545 base = per_cpu(tvec_bases, cpu); 1545 1546 } 1546 1547 1547 - spin_lock_init(&base->lock); 1548 1548 1549 1549 for (j = 0; j < TVN_SIZE; j++) { 1550 1550 INIT_LIST_HEAD(base->tv5.vec + j);
+4
kernel/trace/trace_events_filter.c
··· 750 750 751 751 static void __free_preds(struct event_filter *filter) 752 752 { 753 + int i; 754 + 753 755 if (filter->preds) { 756 + for (i = 0; i < filter->n_preds; i++) 757 + kfree(filter->preds[i].ops); 754 758 kfree(filter->preds); 755 759 filter->preds = NULL; 756 760 }
+40 -13
kernel/trace/trace_kprobe.c
··· 35 35 const char *symbol; /* symbol name */ 36 36 struct ftrace_event_class class; 37 37 struct ftrace_event_call call; 38 - struct ftrace_event_file **files; 38 + struct ftrace_event_file * __rcu *files; 39 39 ssize_t size; /* trace entry size */ 40 40 unsigned int nr_args; 41 41 struct probe_arg args[]; ··· 185 185 186 186 static int trace_probe_nr_files(struct trace_probe *tp) 187 187 { 188 - struct ftrace_event_file **file = tp->files; 188 + struct ftrace_event_file **file; 189 189 int ret = 0; 190 190 191 + /* 192 + * Since all tp->files updater is protected by probe_enable_lock, 193 + * we don't need to lock an rcu_read_lock. 194 + */ 195 + file = rcu_dereference_raw(tp->files); 191 196 if (file) 192 197 while (*(file++)) 193 198 ret++; ··· 214 209 mutex_lock(&probe_enable_lock); 215 210 216 211 if (file) { 217 - struct ftrace_event_file **new, **old = tp->files; 212 + struct ftrace_event_file **new, **old; 218 213 int n = trace_probe_nr_files(tp); 219 214 215 + old = rcu_dereference_raw(tp->files); 220 216 /* 1 is for new one and 1 is for stopper */ 221 217 new = kzalloc((n + 2) * sizeof(struct ftrace_event_file *), 222 218 GFP_KERNEL); ··· 257 251 static int 258 252 trace_probe_file_index(struct trace_probe *tp, struct ftrace_event_file *file) 259 253 { 254 + struct ftrace_event_file **files; 260 255 int i; 261 256 262 - if (tp->files) { 263 - for (i = 0; tp->files[i]; i++) 264 - if (tp->files[i] == file) 257 + /* 258 + * Since all tp->files updater is protected by probe_enable_lock, 259 + * we don't need to lock an rcu_read_lock. 260 + */ 261 + files = rcu_dereference_raw(tp->files); 262 + if (files) { 263 + for (i = 0; files[i]; i++) 264 + if (files[i] == file) 265 265 return i; 266 266 } 267 267 ··· 286 274 mutex_lock(&probe_enable_lock); 287 275 288 276 if (file) { 289 - struct ftrace_event_file **new, **old = tp->files; 277 + struct ftrace_event_file **new, **old; 290 278 int n = trace_probe_nr_files(tp); 291 279 int i, j; 292 280 281 + old = rcu_dereference_raw(tp->files); 293 282 if (n == 0 || trace_probe_file_index(tp, file) < 0) { 294 283 ret = -EINVAL; 295 284 goto out_unlock; ··· 885 872 static __kprobes void 886 873 kprobe_trace_func(struct trace_probe *tp, struct pt_regs *regs) 887 874 { 888 - struct ftrace_event_file **file = tp->files; 875 + /* 876 + * Note: preempt is already disabled around the kprobe handler. 877 + * However, we still need an smp_read_barrier_depends() corresponding 878 + * to smp_wmb() in rcu_assign_pointer() to access the pointer. 879 + */ 880 + struct ftrace_event_file **file = rcu_dereference_raw(tp->files); 889 881 890 - /* Note: preempt is already disabled around the kprobe handler */ 882 + if (unlikely(!file)) 883 + return; 884 + 891 885 while (*file) { 892 886 __kprobe_trace_func(tp, regs, *file); 893 887 file++; ··· 945 925 kretprobe_trace_func(struct trace_probe *tp, struct kretprobe_instance *ri, 946 926 struct pt_regs *regs) 947 927 { 948 - struct ftrace_event_file **file = tp->files; 928 + /* 929 + * Note: preempt is already disabled around the kprobe handler. 930 + * However, we still need an smp_read_barrier_depends() corresponding 931 + * to smp_wmb() in rcu_assign_pointer() to access the pointer. 932 + */ 933 + struct ftrace_event_file **file = rcu_dereference_raw(tp->files); 949 934 950 - /* Note: preempt is already disabled around the kprobe handler */ 935 + if (unlikely(!file)) 936 + return; 937 + 951 938 while (*file) { 952 939 __kretprobe_trace_func(tp, ri, regs, *file); 953 940 file++; ··· 962 935 } 963 936 964 937 /* Event entry printers */ 965 - enum print_line_t 938 + static enum print_line_t 966 939 print_kprobe_event(struct trace_iterator *iter, int flags, 967 940 struct trace_event *event) 968 941 { ··· 998 971 return TRACE_TYPE_PARTIAL_LINE; 999 972 } 1000 973 1001 - enum print_line_t 974 + static enum print_line_t 1002 975 print_kretprobe_event(struct trace_iterator *iter, int flags, 1003 976 struct trace_event *event) 1004 977 {
+15 -4
kernel/workqueue.c
··· 296 296 static struct workqueue_attrs *unbound_std_wq_attrs[NR_STD_WORKER_POOLS]; 297 297 298 298 struct workqueue_struct *system_wq __read_mostly; 299 - EXPORT_SYMBOL_GPL(system_wq); 299 + EXPORT_SYMBOL(system_wq); 300 300 struct workqueue_struct *system_highpri_wq __read_mostly; 301 301 EXPORT_SYMBOL_GPL(system_highpri_wq); 302 302 struct workqueue_struct *system_long_wq __read_mostly; ··· 1411 1411 local_irq_restore(flags); 1412 1412 return ret; 1413 1413 } 1414 - EXPORT_SYMBOL_GPL(queue_work_on); 1414 + EXPORT_SYMBOL(queue_work_on); 1415 1415 1416 1416 void delayed_work_timer_fn(unsigned long __data) 1417 1417 { ··· 1485 1485 local_irq_restore(flags); 1486 1486 return ret; 1487 1487 } 1488 - EXPORT_SYMBOL_GPL(queue_delayed_work_on); 1488 + EXPORT_SYMBOL(queue_delayed_work_on); 1489 1489 1490 1490 /** 1491 1491 * mod_delayed_work_on - modify delay of or queue a delayed work on specific CPU ··· 2059 2059 if (unlikely(!mutex_trylock(&pool->manager_mutex))) { 2060 2060 spin_unlock_irq(&pool->lock); 2061 2061 mutex_lock(&pool->manager_mutex); 2062 + spin_lock_irq(&pool->lock); 2062 2063 ret = true; 2063 2064 } 2064 2065 ··· 4312 4311 * no synchronization around this function and the test result is 4313 4312 * unreliable and only useful as advisory hints or for debugging. 4314 4313 * 4314 + * If @cpu is WORK_CPU_UNBOUND, the test is performed on the local CPU. 4315 + * Note that both per-cpu and unbound workqueues may be associated with 4316 + * multiple pool_workqueues which have separate congested states. A 4317 + * workqueue being congested on one CPU doesn't mean the workqueue is also 4318 + * contested on other CPUs / NUMA nodes. 4319 + * 4315 4320 * RETURNS: 4316 4321 * %true if congested, %false otherwise. 4317 4322 */ ··· 4327 4320 bool ret; 4328 4321 4329 4322 rcu_read_lock_sched(); 4323 + 4324 + if (cpu == WORK_CPU_UNBOUND) 4325 + cpu = smp_processor_id(); 4330 4326 4331 4327 if (!(wq->flags & WQ_UNBOUND)) 4332 4328 pwq = per_cpu_ptr(wq->cpu_pwqs, cpu); ··· 4905 4895 BUG_ON(!tbl); 4906 4896 4907 4897 for_each_node(node) 4908 - BUG_ON(!alloc_cpumask_var_node(&tbl[node], GFP_KERNEL, node)); 4898 + BUG_ON(!alloc_cpumask_var_node(&tbl[node], GFP_KERNEL, 4899 + node_online(node) ? node : NUMA_NO_NODE)); 4909 4900 4910 4901 for_each_possible_cpu(cpu) { 4911 4902 node = cpu_to_node(cpu);
+13
net/batman-adv/distributed-arp-table.c
··· 837 837 838 838 dat_entry = batadv_dat_entry_hash_find(bat_priv, ip_dst); 839 839 if (dat_entry) { 840 + /* If the ARP request is destined for a local client the local 841 + * client will answer itself. DAT would only generate a 842 + * duplicate packet. 843 + * 844 + * Moreover, if the soft-interface is enslaved into a bridge, an 845 + * additional DAT answer may trigger kernel warnings about 846 + * a packet coming from the wrong port. 847 + */ 848 + if (batadv_is_my_client(bat_priv, dat_entry->mac_addr)) { 849 + ret = true; 850 + goto out; 851 + } 852 + 840 853 skb_new = arp_create(ARPOP_REPLY, ETH_P_ARP, ip_src, 841 854 bat_priv->soft_iface, ip_dst, hw_src, 842 855 dat_entry->mac_addr, hw_src);
+14 -6
net/batman-adv/main.c
··· 163 163 batadv_vis_quit(bat_priv); 164 164 165 165 batadv_gw_node_purge(bat_priv); 166 - batadv_originator_free(bat_priv); 167 166 batadv_nc_free(bat_priv); 168 - 169 - batadv_tt_free(bat_priv); 170 - 167 + batadv_dat_free(bat_priv); 171 168 batadv_bla_free(bat_priv); 172 169 173 - batadv_dat_free(bat_priv); 170 + /* Free the TT and the originator tables only after having terminated 171 + * all the other depending components which may use these structures for 172 + * their purposes. 173 + */ 174 + batadv_tt_free(bat_priv); 175 + 176 + /* Since the originator table clean up routine is accessing the TT 177 + * tables as well, it has to be invoked after the TT tables have been 178 + * freed and marked as empty. This ensures that no cleanup RCU callbacks 179 + * accessing the TT data are scheduled for later execution. 180 + */ 181 + batadv_originator_free(bat_priv); 174 182 175 183 free_percpu(bat_priv->bat_counters); 176 184 ··· 483 475 char *algo_name = (char *)val; 484 476 size_t name_len = strlen(algo_name); 485 477 486 - if (algo_name[name_len - 1] == '\n') 478 + if (name_len > 0 && algo_name[name_len - 1] == '\n') 487 479 algo_name[name_len - 1] = '\0'; 488 480 489 481 bat_algo_ops = batadv_algo_get(algo_name);
+6 -2
net/batman-adv/network-coding.c
··· 1514 1514 struct ethhdr *ethhdr, ethhdr_tmp; 1515 1515 uint8_t *orig_dest, ttl, ttvn; 1516 1516 unsigned int coding_len; 1517 + int err; 1517 1518 1518 1519 /* Save headers temporarily */ 1519 1520 memcpy(&coded_packet_tmp, skb->data, sizeof(coded_packet_tmp)); ··· 1569 1568 coding_len); 1570 1569 1571 1570 /* Resize decoded skb if decoded with larger packet */ 1572 - if (nc_packet->skb->len > coding_len + h_size) 1573 - pskb_trim_rcsum(skb, coding_len + h_size); 1571 + if (nc_packet->skb->len > coding_len + h_size) { 1572 + err = pskb_trim_rcsum(skb, coding_len + h_size); 1573 + if (err) 1574 + return NULL; 1575 + } 1574 1576 1575 1577 /* Create decoded unicast packet */ 1576 1578 unicast_packet = (struct batadv_unicast_packet *)skb->data;
+4 -1
net/ceph/osd_client.c
··· 1204 1204 mutex_lock(&osdc->request_mutex); 1205 1205 if (req->r_linger) { 1206 1206 __unregister_linger_request(osdc, req); 1207 + req->r_linger = 0; 1207 1208 ceph_osdc_put_request(req); 1208 1209 } 1209 1210 mutex_unlock(&osdc->request_mutex); ··· 2121 2120 down_read(&osdc->map_sem); 2122 2121 mutex_lock(&osdc->request_mutex); 2123 2122 __register_request(osdc, req); 2124 - WARN_ON(req->r_sent); 2123 + req->r_sent = 0; 2124 + req->r_got_reply = 0; 2125 + req->r_completed = 0; 2125 2126 rc = __map_request(osdc, req, 0); 2126 2127 if (rc < 0) { 2127 2128 if (nofail) {
-12
net/core/sock.c
··· 1217 1217 #endif 1218 1218 } 1219 1219 1220 - /* 1221 - * caches using SLAB_DESTROY_BY_RCU should let .next pointer from nulls nodes 1222 - * un-modified. Special care is taken when initializing object to zero. 1223 - */ 1224 - static inline void sk_prot_clear_nulls(struct sock *sk, int size) 1225 - { 1226 - if (offsetof(struct sock, sk_node.next) != 0) 1227 - memset(sk, 0, offsetof(struct sock, sk_node.next)); 1228 - memset(&sk->sk_node.pprev, 0, 1229 - size - offsetof(struct sock, sk_node.pprev)); 1230 - } 1231 - 1232 1220 void sk_prot_clear_portaddr_nulls(struct sock *sk, int size) 1233 1221 { 1234 1222 unsigned long nulls1, nulls2;
+1 -1
net/ipv4/ip_output.c
··· 84 84 EXPORT_SYMBOL(sysctl_ip_default_ttl); 85 85 86 86 /* Generate a checksum for an outgoing IP datagram. */ 87 - __inline__ void ip_send_check(struct iphdr *iph) 87 + void ip_send_check(struct iphdr *iph) 88 88 { 89 89 iph->check = 0; 90 90 iph->check = ip_fast_csum((unsigned char *)iph, iph->ihl);
+2
net/ipv6/ip6_gre.c
··· 1081 1081 } 1082 1082 if (t == NULL) 1083 1083 t = netdev_priv(dev); 1084 + memset(&p, 0, sizeof(p)); 1084 1085 ip6gre_tnl_parm_to_user(&p, &t->parms); 1085 1086 if (copy_to_user(ifr->ifr_ifru.ifru_data, &p, sizeof(p))) 1086 1087 err = -EFAULT; ··· 1129 1128 if (t) { 1130 1129 err = 0; 1131 1130 1131 + memset(&p, 0, sizeof(p)); 1132 1132 ip6gre_tnl_parm_to_user(&p, &t->parms); 1133 1133 if (copy_to_user(ifr->ifr_ifru.ifru_data, &p, sizeof(p))) 1134 1134 err = -EFAULT;
+12
net/ipv6/tcp_ipv6.c
··· 1890 1890 } 1891 1891 #endif 1892 1892 1893 + static void tcp_v6_clear_sk(struct sock *sk, int size) 1894 + { 1895 + struct inet_sock *inet = inet_sk(sk); 1896 + 1897 + /* we do not want to clear pinet6 field, because of RCU lookups */ 1898 + sk_prot_clear_nulls(sk, offsetof(struct inet_sock, pinet6)); 1899 + 1900 + size -= offsetof(struct inet_sock, pinet6) + sizeof(inet->pinet6); 1901 + memset(&inet->pinet6 + 1, 0, size); 1902 + } 1903 + 1893 1904 struct proto tcpv6_prot = { 1894 1905 .name = "TCPv6", 1895 1906 .owner = THIS_MODULE, ··· 1944 1933 #ifdef CONFIG_MEMCG_KMEM 1945 1934 .proto_cgroup = tcp_proto_cgroup, 1946 1935 #endif 1936 + .clear_sk = tcp_v6_clear_sk, 1947 1937 }; 1948 1938 1949 1939 static const struct inet6_protocol tcpv6_protocol = {
+12 -1
net/ipv6/udp.c
··· 1432 1432 } 1433 1433 #endif /* CONFIG_PROC_FS */ 1434 1434 1435 + void udp_v6_clear_sk(struct sock *sk, int size) 1436 + { 1437 + struct inet_sock *inet = inet_sk(sk); 1438 + 1439 + /* we do not want to clear pinet6 field, because of RCU lookups */ 1440 + sk_prot_clear_portaddr_nulls(sk, offsetof(struct inet_sock, pinet6)); 1441 + 1442 + size -= offsetof(struct inet_sock, pinet6) + sizeof(inet->pinet6); 1443 + memset(&inet->pinet6 + 1, 0, size); 1444 + } 1445 + 1435 1446 /* ------------------------------------------------------------------------ */ 1436 1447 1437 1448 struct proto udpv6_prot = { ··· 1473 1462 .compat_setsockopt = compat_udpv6_setsockopt, 1474 1463 .compat_getsockopt = compat_udpv6_getsockopt, 1475 1464 #endif 1476 - .clear_sk = sk_prot_clear_portaddr_nulls, 1465 + .clear_sk = udp_v6_clear_sk, 1477 1466 }; 1478 1467 1479 1468 static struct inet_protosw udpv6_protosw = {
+2
net/ipv6/udp_impl.h
··· 31 31 extern int udpv6_queue_rcv_skb(struct sock * sk, struct sk_buff *skb); 32 32 extern void udpv6_destroy_sock(struct sock *sk); 33 33 34 + extern void udp_v6_clear_sk(struct sock *sk, int size); 35 + 34 36 #ifdef CONFIG_PROC_FS 35 37 extern int udp6_seq_show(struct seq_file *seq, void *v); 36 38 #endif
+1 -1
net/ipv6/udplite.c
··· 56 56 .compat_setsockopt = compat_udpv6_setsockopt, 57 57 .compat_getsockopt = compat_udpv6_getsockopt, 58 58 #endif 59 - .clear_sk = sk_prot_clear_portaddr_nulls, 59 + .clear_sk = udp_v6_clear_sk, 60 60 }; 61 61 62 62 static struct inet_protosw udplite6_protosw = {
+3 -1
net/ipv6/xfrm6_policy.c
··· 103 103 dev_hold(dev); 104 104 105 105 xdst->u.rt6.rt6i_idev = in6_dev_get(dev); 106 - if (!xdst->u.rt6.rt6i_idev) 106 + if (!xdst->u.rt6.rt6i_idev) { 107 + dev_put(dev); 107 108 return -ENODEV; 109 + } 108 110 109 111 rt6_transfer_peer(&xdst->u.rt6, rt); 110 112
+1 -1
scripts/package/Makefile
··· 63 63 mv -f $(objtree)/.tmp_version $(objtree)/.version 64 64 65 65 $(RPM) $(RPMOPTS) --define "_builddir $(objtree)" --target \ 66 - $(UTS_MACHINE) -bb $< 66 + $(UTS_MACHINE) -bb $(objtree)/binkernel.spec 67 67 rm binkernel.spec 68 68 69 69 # Deb target
+8
sound/aoa/fabrics/layout.c
··· 113 113 MODULE_ALIAS("aoa-device-id-14"); 114 114 MODULE_ALIAS("aoa-device-id-22"); 115 115 MODULE_ALIAS("aoa-device-id-35"); 116 + MODULE_ALIAS("aoa-device-id-44"); 116 117 117 118 /* onyx with all but microphone connected */ 118 119 static struct codec_connection onyx_connections_nomic[] = { ··· 360 359 .codecs[0] = { 361 360 .name = "tas", 362 361 .connections = tas_connections_nolineout, 362 + }, 363 + }, 364 + /* PowerBook6,5 */ 365 + { .device_id = 44, 366 + .codecs[0] = { 367 + .name = "tas", 368 + .connections = tas_connections_all, 363 369 }, 364 370 }, 365 371 /* PowerBook6,7 */
+2 -1
sound/aoa/soundbus/i2sbus/core.c
··· 200 200 * We probably cannot handle all device-id machines, 201 201 * so restrict to those we do handle for now. 202 202 */ 203 - if (id && (*id == 22 || *id == 14 || *id == 35)) { 203 + if (id && (*id == 22 || *id == 14 || *id == 35 || 204 + *id == 44)) { 204 205 snprintf(dev->sound.modalias, 32, 205 206 "aoa-device-id-%d", *id); 206 207 ok = 1;
+1 -1
sound/oss/Kconfig
··· 250 250 menuconfig SOUND_OSS 251 251 tristate "OSS sound modules" 252 252 depends on ISA_DMA_API && VIRT_TO_BUS 253 - depends on !ISA_DMA_SUPPORT_BROKEN 253 + depends on !GENERIC_ISA_DMA_SUPPORT_BROKEN 254 254 help 255 255 OSS is the Open Sound System suite of sound card drivers. They make 256 256 sound programming easier since they provide a common API. Say Y or
+7 -2
sound/pci/hda/hda_generic.c
··· 606 606 return false; 607 607 } 608 608 609 + /* check whether the NID is referred by any active paths */ 610 + #define is_active_nid_for_any(codec, nid) \ 611 + is_active_nid(codec, nid, HDA_OUTPUT, 0) 612 + 609 613 /* get the default amp value for the target state */ 610 614 static int get_amp_val_to_activate(struct hda_codec *codec, hda_nid_t nid, 611 615 int dir, unsigned int caps, bool enable) ··· 763 759 764 760 for (i = 0; i < path->depth; i++) { 765 761 hda_nid_t nid = path->path[i]; 766 - if (!snd_hda_check_power_state(codec, nid, AC_PWRST_D3)) { 762 + if (!snd_hda_check_power_state(codec, nid, AC_PWRST_D3) && 763 + !is_active_nid_for_any(codec, nid)) { 767 764 snd_hda_codec_write(codec, nid, 0, 768 765 AC_VERB_SET_POWER_STATE, 769 766 AC_PWRST_D3); ··· 4162 4157 return power_state; 4163 4158 if (get_wcaps_type(get_wcaps(codec, nid)) >= AC_WID_POWER) 4164 4159 return power_state; 4165 - if (is_active_nid(codec, nid, HDA_OUTPUT, 0)) 4160 + if (is_active_nid_for_any(codec, nid)) 4166 4161 return power_state; 4167 4162 return AC_PWRST_D3; 4168 4163 }
+1
sound/pci/hda/patch_realtek.c
··· 3482 3482 SND_PCI_QUIRK(0x1028, 0x05c9, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), 3483 3483 SND_PCI_QUIRK(0x1028, 0x05ca, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE), 3484 3484 SND_PCI_QUIRK(0x1028, 0x05cb, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE), 3485 + SND_PCI_QUIRK(0x1028, 0x05de, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE), 3485 3486 SND_PCI_QUIRK(0x1028, 0x05e9, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), 3486 3487 SND_PCI_QUIRK(0x1028, 0x05ea, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), 3487 3488 SND_PCI_QUIRK(0x1028, 0x05eb, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
+18 -18
sound/soc/codecs/ab8500-codec.h
··· 355 355 356 356 /* AB8500_ADSLOTSELX */ 357 357 #define AB8500_ADSLOTSELX_AD_OUT1_TO_SLOT_ODD 0x00 358 - #define AB8500_ADSLOTSELX_AD_OUT2_TO_SLOT_ODD 0x01 359 - #define AB8500_ADSLOTSELX_AD_OUT3_TO_SLOT_ODD 0x02 360 - #define AB8500_ADSLOTSELX_AD_OUT4_TO_SLOT_ODD 0x03 361 - #define AB8500_ADSLOTSELX_AD_OUT5_TO_SLOT_ODD 0x04 362 - #define AB8500_ADSLOTSELX_AD_OUT6_TO_SLOT_ODD 0x05 363 - #define AB8500_ADSLOTSELX_AD_OUT7_TO_SLOT_ODD 0x06 364 - #define AB8500_ADSLOTSELX_AD_OUT8_TO_SLOT_ODD 0x07 365 - #define AB8500_ADSLOTSELX_ZEROES_TO_SLOT_ODD 0x08 366 - #define AB8500_ADSLOTSELX_TRISTATE_TO_SLOT_ODD 0x0F 358 + #define AB8500_ADSLOTSELX_AD_OUT2_TO_SLOT_ODD 0x10 359 + #define AB8500_ADSLOTSELX_AD_OUT3_TO_SLOT_ODD 0x20 360 + #define AB8500_ADSLOTSELX_AD_OUT4_TO_SLOT_ODD 0x30 361 + #define AB8500_ADSLOTSELX_AD_OUT5_TO_SLOT_ODD 0x40 362 + #define AB8500_ADSLOTSELX_AD_OUT6_TO_SLOT_ODD 0x50 363 + #define AB8500_ADSLOTSELX_AD_OUT7_TO_SLOT_ODD 0x60 364 + #define AB8500_ADSLOTSELX_AD_OUT8_TO_SLOT_ODD 0x70 365 + #define AB8500_ADSLOTSELX_ZEROES_TO_SLOT_ODD 0x80 366 + #define AB8500_ADSLOTSELX_TRISTATE_TO_SLOT_ODD 0xF0 367 367 #define AB8500_ADSLOTSELX_AD_OUT1_TO_SLOT_EVEN 0x00 368 - #define AB8500_ADSLOTSELX_AD_OUT2_TO_SLOT_EVEN 0x10 369 - #define AB8500_ADSLOTSELX_AD_OUT3_TO_SLOT_EVEN 0x20 370 - #define AB8500_ADSLOTSELX_AD_OUT4_TO_SLOT_EVEN 0x30 371 - #define AB8500_ADSLOTSELX_AD_OUT5_TO_SLOT_EVEN 0x40 372 - #define AB8500_ADSLOTSELX_AD_OUT6_TO_SLOT_EVEN 0x50 373 - #define AB8500_ADSLOTSELX_AD_OUT7_TO_SLOT_EVEN 0x60 374 - #define AB8500_ADSLOTSELX_AD_OUT8_TO_SLOT_EVEN 0x70 375 - #define AB8500_ADSLOTSELX_ZEROES_TO_SLOT_EVEN 0x80 376 - #define AB8500_ADSLOTSELX_TRISTATE_TO_SLOT_EVEN 0xF0 368 + #define AB8500_ADSLOTSELX_AD_OUT2_TO_SLOT_EVEN 0x01 369 + #define AB8500_ADSLOTSELX_AD_OUT3_TO_SLOT_EVEN 0x02 370 + #define AB8500_ADSLOTSELX_AD_OUT4_TO_SLOT_EVEN 0x03 371 + #define AB8500_ADSLOTSELX_AD_OUT5_TO_SLOT_EVEN 0x04 372 + #define AB8500_ADSLOTSELX_AD_OUT6_TO_SLOT_EVEN 0x05 373 + #define AB8500_ADSLOTSELX_AD_OUT7_TO_SLOT_EVEN 0x06 374 + #define AB8500_ADSLOTSELX_AD_OUT8_TO_SLOT_EVEN 0x07 375 + #define AB8500_ADSLOTSELX_ZEROES_TO_SLOT_EVEN 0x08 376 + #define AB8500_ADSLOTSELX_TRISTATE_TO_SLOT_EVEN 0x0F 377 377 #define AB8500_ADSLOTSELX_EVEN_SHIFT 0 378 378 #define AB8500_ADSLOTSELX_ODD_SHIFT 4 379 379
+4 -4
sound/soc/codecs/da7213.c
··· 1488 1488 DA7213_DMIC_DATA_SEL_SHIFT); 1489 1489 break; 1490 1490 } 1491 - switch (pdata->dmic_data_sel) { 1491 + switch (pdata->dmic_samplephase) { 1492 1492 case DA7213_DMIC_SAMPLE_ON_CLKEDGE: 1493 1493 case DA7213_DMIC_SAMPLE_BETWEEN_CLKEDGE: 1494 - dmic_cfg |= (pdata->dmic_data_sel << 1494 + dmic_cfg |= (pdata->dmic_samplephase << 1495 1495 DA7213_DMIC_SAMPLEPHASE_SHIFT); 1496 1496 break; 1497 1497 } 1498 - switch (pdata->dmic_data_sel) { 1498 + switch (pdata->dmic_clk_rate) { 1499 1499 case DA7213_DMIC_CLK_3_0MHZ: 1500 1500 case DA7213_DMIC_CLK_1_5MHZ: 1501 - dmic_cfg |= (pdata->dmic_data_sel << 1501 + dmic_cfg |= (pdata->dmic_clk_rate << 1502 1502 DA7213_DMIC_CLK_RATE_SHIFT); 1503 1503 break; 1504 1504 }
+1
sound/soc/codecs/wm0010.c
··· 667 667 /* On wm0010 only the CLKCTRL1 value is used */ 668 668 pll_rec.clkctrl1 = wm0010->pll_clkctrl1; 669 669 670 + ret = -ENOMEM; 670 671 len = pll_rec.length + 8; 671 672 out = kzalloc(len, GFP_KERNEL); 672 673 if (!out) {
-6
sound/soc/fsl/imx-ssi.c
··· 540 540 clk_prepare_enable(ssi->clk); 541 541 542 542 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 543 - if (!res) { 544 - ret = -ENODEV; 545 - goto failed_get_resource; 546 - } 547 - 548 543 ssi->base = devm_ioremap_resource(&pdev->dev, res); 549 544 if (IS_ERR(ssi->base)) { 550 545 ret = PTR_ERR(ssi->base); ··· 628 633 snd_soc_unregister_component(&pdev->dev); 629 634 failed_register: 630 635 release_mem_region(res->start, resource_size(res)); 631 - failed_get_resource: 632 636 clk_disable_unprepare(ssi->clk); 633 637 failed_clk: 634 638
-5
sound/soc/kirkwood/kirkwood-i2s.c
··· 471 471 dev_set_drvdata(&pdev->dev, priv); 472 472 473 473 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 474 - if (!mem) { 475 - dev_err(&pdev->dev, "platform_get_resource failed\n"); 476 - return -ENXIO; 477 - } 478 - 479 474 priv->io = devm_ioremap_resource(&pdev->dev, mem); 480 475 if (IS_ERR(priv->io)) 481 476 return PTR_ERR(priv->io);
+11 -11
sound/usb/proc.c
··· 116 116 } 117 117 118 118 static void proc_dump_ep_status(struct snd_usb_substream *subs, 119 - struct snd_usb_endpoint *ep, 119 + struct snd_usb_endpoint *data_ep, 120 + struct snd_usb_endpoint *sync_ep, 120 121 struct snd_info_buffer *buffer) 121 122 { 122 - if (!ep) 123 + if (!data_ep) 123 124 return; 124 - snd_iprintf(buffer, " Packet Size = %d\n", ep->curpacksize); 125 + snd_iprintf(buffer, " Packet Size = %d\n", data_ep->curpacksize); 125 126 snd_iprintf(buffer, " Momentary freq = %u Hz (%#x.%04x)\n", 126 127 subs->speed == USB_SPEED_FULL 127 - ? get_full_speed_hz(ep->freqm) 128 - : get_high_speed_hz(ep->freqm), 129 - ep->freqm >> 16, ep->freqm & 0xffff); 130 - if (ep->freqshift != INT_MIN) { 131 - int res = 16 - ep->freqshift; 128 + ? get_full_speed_hz(data_ep->freqm) 129 + : get_high_speed_hz(data_ep->freqm), 130 + data_ep->freqm >> 16, data_ep->freqm & 0xffff); 131 + if (sync_ep && data_ep->freqshift != INT_MIN) { 132 + int res = 16 - data_ep->freqshift; 132 133 snd_iprintf(buffer, " Feedback Format = %d.%d\n", 133 - (ep->syncmaxsize > 3 ? 32 : 24) - res, res); 134 + (sync_ep->syncmaxsize > 3 ? 32 : 24) - res, res); 134 135 } 135 136 } 136 137 ··· 141 140 snd_iprintf(buffer, " Status: Running\n"); 142 141 snd_iprintf(buffer, " Interface = %d\n", subs->interface); 143 142 snd_iprintf(buffer, " Altset = %d\n", subs->altset_idx); 144 - proc_dump_ep_status(subs, subs->data_endpoint, buffer); 145 - proc_dump_ep_status(subs, subs->sync_endpoint, buffer); 143 + proc_dump_ep_status(subs, subs->data_endpoint, subs->sync_endpoint, buffer); 146 144 } else { 147 145 snd_iprintf(buffer, " Status: Stop\n"); 148 146 }