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

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

All three conflicts were cases of simple overlapping
changes.

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

+5383 -2124
+10 -14
Documentation/PCI/MSI-HOWTO.txt
··· 94 94 min_vecs argument set to this limit, and the PCI core will return -ENOSPC 95 95 if it can't meet the minimum number of vectors. 96 96 97 - The flags argument should normally be set to 0, but can be used to pass the 98 - PCI_IRQ_NOMSI and PCI_IRQ_NOMSIX flag in case a device claims to support 99 - MSI or MSI-X, but the support is broken, or to pass PCI_IRQ_NOLEGACY in 100 - case the device does not support legacy interrupt lines. 101 - 102 - By default this function will spread the interrupts around the available 103 - CPUs, but this feature can be disabled by passing the PCI_IRQ_NOAFFINITY 104 - flag. 97 + The flags argument is used to specify which type of interrupt can be used 98 + by the device and the driver (PCI_IRQ_LEGACY, PCI_IRQ_MSI, PCI_IRQ_MSIX). 99 + A convenient short-hand (PCI_IRQ_ALL_TYPES) is also available to ask for 100 + any possible kind of interrupt. If the PCI_IRQ_AFFINITY flag is set, 101 + pci_alloc_irq_vectors() will spread the interrupts around the available CPUs. 105 102 106 103 To get the Linux IRQ numbers passed to request_irq() and free_irq() and the 107 104 vectors, use the following function: ··· 128 131 capped to the supported limit, so there is no need to query the number of 129 132 vectors supported beforehand: 130 133 131 - nvec = pci_alloc_irq_vectors(pdev, 1, nvec, 0); 134 + nvec = pci_alloc_irq_vectors(pdev, 1, nvec, PCI_IRQ_ALL_TYPES) 132 135 if (nvec < 0) 133 136 goto out_err; 134 137 ··· 137 140 number to pci_alloc_irq_vectors() function as both 'min_vecs' and 138 141 'max_vecs' parameters: 139 142 140 - ret = pci_alloc_irq_vectors(pdev, nvec, nvec, 0); 143 + ret = pci_alloc_irq_vectors(pdev, nvec, nvec, PCI_IRQ_ALL_TYPES); 141 144 if (ret < 0) 142 145 goto out_err; 143 146 ··· 145 148 the single MSI mode for a device. It could be done by passing two 1s as 146 149 'min_vecs' and 'max_vecs': 147 150 148 - ret = pci_alloc_irq_vectors(pdev, 1, 1, 0); 151 + ret = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_ALL_TYPES); 149 152 if (ret < 0) 150 153 goto out_err; 151 154 152 155 Some devices might not support using legacy line interrupts, in which case 153 - the PCI_IRQ_NOLEGACY flag can be used to fail the request if the platform 154 - can't provide MSI or MSI-X interrupts: 156 + the driver can specify that only MSI or MSI-X is acceptable: 155 157 156 - nvec = pci_alloc_irq_vectors(pdev, 1, nvec, PCI_IRQ_NOLEGACY); 158 + nvec = pci_alloc_irq_vectors(pdev, 1, nvec, PCI_IRQ_MSI | PCI_IRQ_MSIX); 157 159 if (nvec < 0) 158 160 goto out_err; 159 161
+1
Documentation/arm64/silicon-errata.txt
··· 53 53 | ARM | Cortex-A57 | #832075 | ARM64_ERRATUM_832075 | 54 54 | ARM | Cortex-A57 | #852523 | N/A | 55 55 | ARM | Cortex-A57 | #834220 | ARM64_ERRATUM_834220 | 56 + | ARM | Cortex-A72 | #853709 | N/A | 56 57 | ARM | MMU-500 | #841119,#826419 | N/A | 57 58 | | | | | 58 59 | Cavium | ThunderX ITS | #22375, #24313 | CAVIUM_ERRATUM_22375 |
+1 -1
Documentation/conf.py
··· 131 131 todo_include_todos = False 132 132 133 133 primary_domain = 'C' 134 - highlight_language = 'C' 134 + highlight_language = 'guess' 135 135 136 136 # -- Options for HTML output ---------------------------------------------- 137 137
-10
Documentation/devicetree/bindings/sound/omap-mcpdm.txt
··· 8 8 - interrupts: Interrupt number for McPDM 9 9 - interrupt-parent: The parent interrupt controller 10 10 - ti,hwmods: Name of the hwmod associated to the McPDM 11 - - clocks: phandle for the pdmclk provider, likely <&twl6040> 12 - - clock-names: Must be "pdmclk" 13 11 14 12 Example: 15 13 ··· 18 20 interrupts = <0 112 0x4>; 19 21 interrupt-parent = <&gic>; 20 22 ti,hwmods = "mcpdm"; 21 - }; 22 - 23 - In board DTS file the pdmclk needs to be added: 24 - 25 - &mcpdm { 26 - clocks = <&twl6040>; 27 - clock-names = "pdmclk"; 28 - status = "okay"; 29 23 };
+5 -5
Documentation/devicetree/bindings/thermal/thermal.txt
··· 62 62 Required properties: 63 63 - #cooling-cells: Used to provide cooling device specific information 64 64 Type: unsigned while referring to it. Must be at least 2, in order 65 - Size: one cell to specify minimum and maximum cooling state used 65 + Size: one cell to specify minimum and maximum cooling state used 66 66 in the reference. The first cell is the minimum 67 67 cooling state requested and the second cell is 68 68 the maximum cooling state requested in the reference. ··· 119 119 Optional property: 120 120 - contribution: The cooling contribution to the thermal zone of the 121 121 Type: unsigned referred cooling device at the referred trip point. 122 - Size: one cell The contribution is a ratio of the sum 122 + Size: one cell The contribution is a ratio of the sum 123 123 of all cooling contributions within a thermal zone. 124 124 125 125 Note: Using the THERMAL_NO_LIMIT (-1UL) constant in the cooling-device phandle ··· 145 145 Size: one cell 146 146 147 147 - thermal-sensors: A list of thermal sensor phandles and sensor specifier 148 - Type: list of used while monitoring the thermal zone. 148 + Type: list of used while monitoring the thermal zone. 149 149 phandles + sensor 150 150 specifier 151 151 ··· 473 473 <&adc>; /* pcb north */ 474 474 475 475 /* hotspot = 100 * bandgap - 120 * adc + 484 */ 476 - coefficients = <100 -120 484>; 476 + coefficients = <100 -120 484>; 477 477 478 478 trips { 479 479 ... ··· 502 502 thermal-sensors = <&adc>; 503 503 504 504 /* hotspot = 1 * adc + 6000 */ 505 - coefficients = <1 6000>; 505 + coefficients = <1 6000>; 506 506 507 507 (d) - Board thermal 508 508
+2 -2
Documentation/hwmon/ftsteutates
··· 19 19 implemented in this driver. 20 20 21 21 Specification of the chip can be found here: 22 - ftp:///pub/Mainboard-OEM-Sales/Services/Software&Tools/Linux_SystemMonitoring&Watchdog&GPIO/BMC-Teutates_Specification_V1.21.pdf 23 - ftp:///pub/Mainboard-OEM-Sales/Services/Software&Tools/Linux_SystemMonitoring&Watchdog&GPIO/Fujitsu_mainboards-1-Sensors_HowTo-en-US.pdf 22 + ftp://ftp.ts.fujitsu.com/pub/Mainboard-OEM-Sales/Services/Software&Tools/Linux_SystemMonitoring&Watchdog&GPIO/BMC-Teutates_Specification_V1.21.pdf 23 + ftp://ftp.ts.fujitsu.com/pub/Mainboard-OEM-Sales/Services/Software&Tools/Linux_SystemMonitoring&Watchdog&GPIO/Fujitsu_mainboards-1-Sensors_HowTo-en-US.pdf
-6
Documentation/kernel-documentation.rst
··· 366 366 Cross-referencing from reStructuredText 367 367 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 368 368 369 - .. highlight:: none 370 - 371 369 To cross-reference the functions and types defined in the kernel-doc comments 372 370 from reStructuredText documents, please use the `Sphinx C Domain`_ 373 371 references. For example:: ··· 387 389 388 390 Function documentation 389 391 ---------------------- 390 - 391 - .. highlight:: c 392 392 393 393 The general format of a function and function-like macro kernel-doc comment is:: 394 394 ··· 567 571 568 572 Converting DocBook to Sphinx 569 573 ---------------------------- 570 - 571 - .. highlight:: none 572 574 573 575 Over time, we expect all of the documents under ``Documentation/DocBook`` to be 574 576 converted to Sphinx and reStructuredText. For most DocBook XML documents, a good
+4
Documentation/kernel-parameters.txt
··· 3032 3032 PAGE_SIZE is used as alignment. 3033 3033 PCI-PCI bridge can be specified, if resource 3034 3034 windows need to be expanded. 3035 + To specify the alignment for several 3036 + instances of a device, the PCI vendor, 3037 + device, subvendor, and subdevice may be 3038 + specified, e.g., 4096@pci:8086:9c22:103c:198f 3035 3039 ecrc= Enable/disable PCIe ECRC (transaction layer 3036 3040 end-to-end CRC checking). 3037 3041 bios: Use BIOS/firmware settings. This is the
-20
Documentation/networking/dsa/dsa.txt
··· 587 587 TODO 588 588 ==== 589 589 590 - The platform device problem 591 - --------------------------- 592 - DSA is currently implemented as a platform device driver which is far from ideal 593 - as was discussed in this thread: 594 - 595 - http://permalink.gmane.org/gmane.linux.network/329848 596 - 597 - This basically prevents the device driver model to be properly used and applied, 598 - and support non-MDIO, non-MMIO Ethernet connected switches. 599 - 600 - Another problem with the platform device driver approach is that it prevents the 601 - use of a modular switch drivers build due to a circular dependency, illustrated 602 - here: 603 - 604 - http://comments.gmane.org/gmane.linux.network/345803 605 - 606 - Attempts of reworking this has been done here: 607 - 608 - https://lwn.net/Articles/643149/ 609 - 610 590 Making SWITCHDEV and DSA converge towards an unified codebase 611 591 ------------------------------------------------------------- 612 592
+26 -1
Documentation/power/basic-pm-debugging.txt
··· 164 164 Again, if you find the offending module(s), it(they) must be unloaded every time 165 165 before hibernation, and please report the problem with it(them). 166 166 167 - c) Advanced debugging 167 + c) Using the "test_resume" hibernation option 168 + 169 + /sys/power/disk generally tells the kernel what to do after creating a 170 + hibernation image. One of the available options is "test_resume" which 171 + causes the just created image to be used for immediate restoration. Namely, 172 + after doing: 173 + 174 + # echo test_resume > /sys/power/disk 175 + # echo disk > /sys/power/state 176 + 177 + a hibernation image will be created and a resume from it will be triggered 178 + immediately without involving the platform firmware in any way. 179 + 180 + That test can be used to check if failures to resume from hibernation are 181 + related to bad interactions with the platform firmware. That is, if the above 182 + works every time, but resume from actual hibernation does not work or is 183 + unreliable, the platform firmware may be responsible for the failures. 184 + 185 + On architectures and platforms that support using different kernels to restore 186 + hibernation images (that is, the kernel used to read the image from storage and 187 + load it into memory is different from the one included in the image) or support 188 + kernel address space randomization, it also can be used to check if failures 189 + to resume may be related to the differences between the restore and image 190 + kernels. 191 + 192 + d) Advanced debugging 168 193 169 194 In case that hibernation does not work on your system even in the minimal 170 195 configuration and compiling more drivers as modules is not practical or some
+59 -58
Documentation/power/interface.txt
··· 1 - Power Management Interface 1 + Power Management Interface for System Sleep 2 2 3 + Copyright (c) 2016 Intel Corp., Rafael J. Wysocki <rafael.j.wysocki@intel.com> 3 4 4 - The power management subsystem provides a unified sysfs interface to 5 - userspace, regardless of what architecture or platform one is 6 - running. The interface exists in /sys/power/ directory (assuming sysfs 7 - is mounted at /sys). 5 + The power management subsystem provides userspace with a unified sysfs interface 6 + for system sleep regardless of the underlying system architecture or platform. 7 + The interface is located in the /sys/power/ directory (assuming that sysfs is 8 + mounted at /sys). 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 'freeze', 11 - 'standby' (Power-On Suspend), 'mem' (Suspend-to-RAM), and 'disk' 12 - (Suspend-to-Disk). 10 + /sys/power/state is the system sleep state control file. 13 11 14 - Writing to this file one of those strings causes the system to 15 - transition into that state. Please see the file 16 - Documentation/power/states.txt for a description of each of those 17 - states. 12 + Reading from it returns a list of supported sleep states, encoded as: 18 13 14 + 'freeze' (Suspend-to-Idle) 15 + 'standby' (Power-On Suspend) 16 + 'mem' (Suspend-to-RAM) 17 + 'disk' (Suspend-to-Disk) 19 18 20 - /sys/power/disk controls the operating mode of the suspend-to-disk 21 - mechanism. Suspend-to-disk can be handled in several ways. We have a 22 - few options for putting the system to sleep - using the platform driver 23 - (e.g. ACPI or other suspend_ops), powering off the system or rebooting the 24 - system (for testing). 19 + Suspend-to-Idle is always supported. Suspend-to-Disk is always supported 20 + too as long the kernel has been configured to support hibernation at all 21 + (ie. CONFIG_HIBERNATION is set in the kernel configuration file). Support 22 + for Suspend-to-RAM and Power-On Suspend depends on the capabilities of the 23 + platform. 25 24 26 - Additionally, /sys/power/disk can be used to turn on one of the two testing 27 - modes of the suspend-to-disk mechanism: 'testproc' or 'test'. If the 28 - suspend-to-disk mechanism is in the 'testproc' mode, writing 'disk' to 29 - /sys/power/state will cause the kernel to disable nonboot CPUs and freeze 30 - tasks, wait for 5 seconds, unfreeze tasks and enable nonboot CPUs. If it is 31 - in the 'test' mode, writing 'disk' to /sys/power/state will cause the kernel 32 - to disable nonboot CPUs and freeze tasks, shrink memory, suspend devices, wait 33 - for 5 seconds, resume devices, unfreeze tasks and enable nonboot CPUs. Then, 34 - we are able to look in the log messages and work out, for example, which code 35 - is being slow and which device drivers are misbehaving. 25 + If one of the strings listed in /sys/power/state is written to it, the system 26 + will attempt to transition into the corresponding sleep state. Refer to 27 + Documentation/power/states.txt for a description of each of those states. 36 28 37 - Reading from this file will display all supported modes and the currently 38 - selected one in brackets, for example 29 + /sys/power/disk controls the operating mode of hibernation (Suspend-to-Disk). 30 + Specifically, it tells the kernel what to do after creating a hibernation image. 39 31 40 - [shutdown] reboot test testproc 32 + Reading from it returns a list of supported options encoded as: 41 33 42 - Writing to this file will accept one of 34 + 'platform' (put the system into sleep using a platform-provided method) 35 + 'shutdown' (shut the system down) 36 + 'reboot' (reboot the system) 37 + 'suspend' (trigger a Suspend-to-RAM transition) 38 + 'test_resume' (resume-after-hibernation test mode) 43 39 44 - 'platform' (only if the platform supports it) 45 - 'shutdown' 46 - 'reboot' 47 - 'testproc' 48 - 'test' 40 + The currently selected option is printed in square brackets. 49 41 50 - /sys/power/image_size controls the size of the image created by 51 - the suspend-to-disk mechanism. It can be written a string 52 - representing a non-negative integer that will be used as an upper 53 - limit of the image size, in bytes. The suspend-to-disk mechanism will 54 - do its best to ensure the image size will not exceed that number. However, 55 - if this turns out to be impossible, it will try to suspend anyway using the 56 - smallest image possible. In particular, if "0" is written to this file, the 57 - suspend image will be as small as possible. 42 + The 'platform' option is only available if the platform provides a special 43 + mechanism to put the system to sleep after creating a hibernation image (ACPI 44 + does that, for example). The 'suspend' option is available if Suspend-to-RAM 45 + is supported. Refer to Documentation/power/basic_pm_debugging.txt for the 46 + description of the 'test_resume' option. 58 47 59 - Reading from this file will display the current image size limit, which 60 - is set to 2/5 of available RAM by default. 48 + To select an option, write the string representing it to /sys/power/disk. 61 49 62 - /sys/power/pm_trace controls the code which saves the last PM event point in 63 - the RTC across reboots, so that you can debug a machine that just hangs 64 - during suspend (or more commonly, during resume). Namely, the RTC is only 65 - used to save the last PM event point if this file contains '1'. Initially it 66 - contains '0' which may be changed to '1' by writing a string representing a 67 - nonzero integer into it. 50 + /sys/power/image_size controls the size of hibernation images. 68 51 69 - To use this debugging feature you should attempt to suspend the machine, then 70 - reboot it and run 52 + It can be written a string representing a non-negative integer that will be 53 + used as a best-effort upper limit of the image size, in bytes. The hibernation 54 + core will do its best to ensure that the image size will not exceed that number. 55 + However, if that turns out to be impossible to achieve, a hibernation image will 56 + still be created and its size will be as small as possible. In particular, 57 + writing '0' to this file will enforce hibernation images to be as small as 58 + possible. 71 59 72 - dmesg -s 1000000 | grep 'hash matches' 60 + Reading from this file returns the current image size limit, which is set to 61 + around 2/5 of available RAM by default. 73 62 74 - CAUTION: Using it will cause your machine's real-time (CMOS) clock to be 75 - set to a random invalid time after a resume. 63 + /sys/power/pm_trace controls the PM trace mechanism saving the last suspend 64 + or resume event point in the RTC across reboots. 65 + 66 + It helps to debug hard lockups or reboots due to device driver failures that 67 + occur during system suspend or resume (which is more common) more effectively. 68 + 69 + If /sys/power/pm_trace contains '1', the fingerprint of each suspend/resume 70 + event point in turn will be stored in the RTC memory (overwriting the actual 71 + RTC information), so it will survive a system crash if one occurs right after 72 + storing it and it can be used later to identify the driver that caused the crash 73 + to happen (see Documentation/power/s2ram.txt for more information). 74 + 75 + Initially it contains '0' which may be changed to '1' by writing a string 76 + representing a nonzero integer into it.
+2
Documentation/powerpc/transactional_memory.txt
··· 167 167 For signals taken in non-TM or suspended mode, we use the 168 168 normal/non-checkpointed stack pointer. 169 169 170 + Any transaction initiated inside a sighandler and suspended on return 171 + from the sighandler to the kernel will get reclaimed and discarded. 170 172 171 173 Failure cause codes used by kernel 172 174 ==================================
+2 -1
Documentation/sphinx-static/theme_overrides.css
··· 42 42 caption a.headerlink { opacity: 0; } 43 43 caption a.headerlink:hover { opacity: 1; } 44 44 45 - /* inline literal: drop the borderbox and red color */ 45 + /* inline literal: drop the borderbox, padding and red color */ 46 46 47 47 code, .rst-content tt, .rst-content code { 48 48 color: inherit; 49 49 border: none; 50 + padding: unset; 50 51 background: inherit; 51 52 font-size: 85%; 52 53 }
+16 -1
MAINTAINERS
··· 890 890 F: drivers/gpu/drm/arc/ 891 891 F: Documentation/devicetree/bindings/display/snps,arcpgu.txt 892 892 893 + ARM ARCHITECTED TIMER DRIVER 894 + M: Mark Rutland <mark.rutland@arm.com> 895 + M: Marc Zyngier <marc.zyngier@arm.com> 896 + L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) 897 + S: Maintained 898 + F: arch/arm/include/asm/arch_timer.h 899 + F: arch/arm64/include/asm/arch_timer.h 900 + F: drivers/clocksource/arm_arch_timer.c 901 + 893 902 ARM HDLCD DRM DRIVER 894 903 M: Liviu Dudau <liviu.dudau@arm.com> 895 904 S: Supported ··· 4543 4534 S: Maintained 4544 4535 F: drivers/edac/sb_edac.c 4545 4536 4537 + EDAC-SKYLAKE 4538 + M: Tony Luck <tony.luck@intel.com> 4539 + L: linux-edac@vger.kernel.org 4540 + S: Maintained 4541 + F: drivers/edac/skx_edac.c 4542 + 4546 4543 EDAC-XGENE 4547 4544 APPLIED MICRO (APM) X-GENE SOC EDAC 4548 4545 M: Loc Ho <lho@apm.com> ··· 7679 7664 S: Supported 7680 7665 W: https://github.com/SoftRoCE/rxe-dev/wiki/rxe-dev:-Home 7681 7666 Q: http://patchwork.kernel.org/project/linux-rdma/list/ 7682 - F: drivers/infiniband/hw/rxe/ 7667 + F: drivers/infiniband/sw/rxe/ 7683 7668 F: include/uapi/rdma/rdma_user_rxe.h 7684 7669 7685 7670 MEMBARRIER SUPPORT
+1 -1
Makefile
··· 1 1 VERSION = 4 2 2 PATCHLEVEL = 8 3 3 SUBLEVEL = 0 4 - EXTRAVERSION = -rc2 4 + EXTRAVERSION = -rc4 5 5 NAME = Psychotic Stoned Sheep 6 6 7 7 # *DOCUMENTATION*
+2 -2
arch/arc/include/asm/entry.h
··· 142 142 143 143 #ifdef CONFIG_ARC_CURR_IN_REG 144 144 ; Retrieve orig r25 and save it with rest of callee_regs 145 - ld.as r12, [r12, PT_user_r25] 145 + ld r12, [r12, PT_user_r25] 146 146 PUSH r12 147 147 #else 148 148 PUSH r25 ··· 198 198 199 199 ; SP is back to start of pt_regs 200 200 #ifdef CONFIG_ARC_CURR_IN_REG 201 - st.as r12, [sp, PT_user_r25] 201 + st r12, [sp, PT_user_r25] 202 202 #endif 203 203 .endm 204 204
+1 -1
arch/arc/include/asm/irqflags-compact.h
··· 188 188 .endm 189 189 190 190 .macro IRQ_ENABLE scratch 191 + TRACE_ASM_IRQ_ENABLE 191 192 lr \scratch, [status32] 192 193 or \scratch, \scratch, (STATUS_E1_MASK | STATUS_E2_MASK) 193 194 flag \scratch 194 - TRACE_ASM_IRQ_ENABLE 195 195 .endm 196 196 197 197 #endif /* __ASSEMBLY__ */
+1 -1
arch/arc/include/asm/pgtable.h
··· 280 280 281 281 #define pte_page(pte) pfn_to_page(pte_pfn(pte)) 282 282 #define mk_pte(page, prot) pfn_pte(page_to_pfn(page), prot) 283 - #define pfn_pte(pfn, prot) (__pte(((pte_t)(pfn) << PAGE_SHIFT) | pgprot_val(prot))) 283 + #define pfn_pte(pfn, prot) __pte(((pfn) << PAGE_SHIFT) | pgprot_val(prot)) 284 284 285 285 /* Don't use virt_to_pfn for macros below: could cause truncations for PAE40*/ 286 286 #define pte_pfn(pte) (pte_val(pte) >> PAGE_SHIFT)
+9 -2
arch/arc/include/uapi/asm/elf.h
··· 13 13 14 14 /* Machine specific ELF Hdr flags */ 15 15 #define EF_ARC_OSABI_MSK 0x00000f00 16 - #define EF_ARC_OSABI_ORIG 0x00000000 /* MUST be zero for back-compat */ 17 - #define EF_ARC_OSABI_CURRENT 0x00000300 /* v3 (no legacy syscalls) */ 16 + 17 + #define EF_ARC_OSABI_V3 0x00000300 /* v3 (no legacy syscalls) */ 18 + #define EF_ARC_OSABI_V4 0x00000400 /* v4 (64bit data any reg align) */ 19 + 20 + #if __GNUC__ < 6 21 + #define EF_ARC_OSABI_CURRENT EF_ARC_OSABI_V3 22 + #else 23 + #define EF_ARC_OSABI_CURRENT EF_ARC_OSABI_V4 24 + #endif 18 25 19 26 typedef unsigned long elf_greg_t; 20 27 typedef unsigned long elf_fpregset_t;
+2
arch/arc/kernel/arcksyms.c
··· 28 28 extern void __divdf3(void); 29 29 extern void __floatunsidf(void); 30 30 extern void __floatunsisf(void); 31 + extern void __udivdi3(void); 31 32 32 33 EXPORT_SYMBOL(__ashldi3); 33 34 EXPORT_SYMBOL(__ashrdi3); ··· 46 45 EXPORT_SYMBOL(__divdf3); 47 46 EXPORT_SYMBOL(__floatunsidf); 48 47 EXPORT_SYMBOL(__floatunsisf); 48 + EXPORT_SYMBOL(__udivdi3); 49 49 50 50 /* ARC optimised assembler routines */ 51 51 EXPORT_SYMBOL(memset);
+1 -1
arch/arc/kernel/process.c
··· 199 199 } 200 200 201 201 eflags = x->e_flags; 202 - if ((eflags & EF_ARC_OSABI_MSK) < EF_ARC_OSABI_CURRENT) { 202 + if ((eflags & EF_ARC_OSABI_MSK) != EF_ARC_OSABI_CURRENT) { 203 203 pr_err("ABI mismatch - you need newer toolchain\n"); 204 204 force_sigsegv(SIGSEGV, current); 205 205 return 0;
+4 -2
arch/arc/kernel/setup.c
··· 291 291 cpu->dccm.base_addr, TO_KB(cpu->dccm.sz), 292 292 cpu->iccm.base_addr, TO_KB(cpu->iccm.sz)); 293 293 294 - n += scnprintf(buf + n, len - n, 295 - "OS ABI [v3]\t: no-legacy-syscalls\n"); 294 + n += scnprintf(buf + n, len - n, "OS ABI [v%d]\t: %s\n", 295 + EF_ARC_OSABI_CURRENT >> 8, 296 + EF_ARC_OSABI_CURRENT == EF_ARC_OSABI_V3 ? 297 + "no-legacy-syscalls" : "64-bit data any register aligned"); 296 298 297 299 return buf; 298 300 }
+9
arch/arc/mm/cache.c
··· 921 921 922 922 printk(arc_cache_mumbojumbo(0, str, sizeof(str))); 923 923 924 + /* 925 + * Only master CPU needs to execute rest of function: 926 + * - Assume SMP so all cores will have same cache config so 927 + * any geomtry checks will be same for all 928 + * - IOC setup / dma callbacks only need to be setup once 929 + */ 930 + if (cpu) 931 + return; 932 + 924 933 if (IS_ENABLED(CONFIG_ARC_HAS_ICACHE)) { 925 934 struct cpuinfo_arc_cache *ic = &cpuinfo_arc700[cpu].icache; 926 935
+1
arch/arc/mm/highmem.c
··· 61 61 62 62 return kmap_high(page); 63 63 } 64 + EXPORT_SYMBOL(kmap); 64 65 65 66 void *kmap_atomic(struct page *page) 66 67 {
+1
arch/arm/kernel/entry-armv.S
··· 295 295 bl __und_fault 296 296 297 297 __und_svc_finish: 298 + get_thread_info tsk 298 299 ldr r5, [sp, #S_PSR] @ Get SVC cpsr 299 300 svc_exit r5 @ return from exception 300 301 UNWIND(.fnend )
+1 -1
arch/arm/kvm/mmu.c
··· 1309 1309 smp_rmb(); 1310 1310 1311 1311 pfn = gfn_to_pfn_prot(kvm, gfn, write_fault, &writable); 1312 - if (is_error_pfn(pfn)) 1312 + if (is_error_noslot_pfn(pfn)) 1313 1313 return -EFAULT; 1314 1314 1315 1315 if (kvm_is_device_pfn(pfn)) {
+6
arch/arm/mach-imx/gpc.c
··· 271 271 for (i = 0; i < IMR_NUM; i++) 272 272 writel_relaxed(~0, gpc_base + GPC_IMR1 + i * 4); 273 273 274 + /* 275 + * Clear the OF_POPULATED flag set in of_irq_init so that 276 + * later the GPC power domain driver will not be skipped. 277 + */ 278 + of_node_clear_flag(node, OF_POPULATED); 279 + 274 280 return 0; 275 281 } 276 282 IRQCHIP_DECLARE(imx_gpc, "fsl,imx6q-gpc", imx_gpc_init);
+2 -1
arch/arm/mach-pxa/idp.c
··· 83 83 }; 84 84 85 85 static struct smc91x_platdata smc91x_platdata = { 86 - .flags = SMC91X_USE_32BIT | SMC91X_USE_DMA | SMC91X_NOWAIT, 86 + .flags = SMC91X_USE_8BIT | SMC91X_USE_16BIT | SMC91X_USE_32BIT | 87 + SMC91X_USE_DMA | SMC91X_NOWAIT, 87 88 }; 88 89 89 90 static struct platform_device smc91x_device = {
+2 -1
arch/arm/mach-pxa/xcep.c
··· 120 120 }; 121 121 122 122 static struct smc91x_platdata xcep_smc91x_info = { 123 - .flags = SMC91X_USE_32BIT | SMC91X_NOWAIT | SMC91X_USE_DMA, 123 + .flags = SMC91X_USE_8BIT | SMC91X_USE_16BIT | SMC91X_USE_32BIT | 124 + SMC91X_NOWAIT | SMC91X_USE_DMA, 124 125 }; 125 126 126 127 static struct platform_device smc91x_device = {
+2 -1
arch/arm/mach-realview/core.c
··· 93 93 }; 94 94 95 95 static struct smc91x_platdata smc91x_platdata = { 96 - .flags = SMC91X_USE_32BIT | SMC91X_NOWAIT, 96 + .flags = SMC91X_USE_8BIT | SMC91X_USE_16BIT | SMC91X_USE_32BIT | 97 + SMC91X_NOWAIT, 97 98 }; 98 99 99 100 static struct platform_device realview_eth_device = {
+1 -1
arch/arm/mach-sa1100/pleb.c
··· 45 45 }; 46 46 47 47 static struct smc91x_platdata smc91x_platdata = { 48 - .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT, 48 + .flags = SMC91X_USE_16BIT | SMC91X_USE_8BIT | SMC91X_NOWAIT, 49 49 }; 50 50 51 51 static struct platform_device smc91x_device = {
+16 -5
arch/arm/mm/mmu.c
··· 728 728 { 729 729 void *ptr = (void *)__get_free_pages(PGALLOC_GFP, get_order(sz)); 730 730 731 - BUG_ON(!ptr); 731 + if (!ptr || !pgtable_page_ctor(virt_to_page(ptr))) 732 + BUG(); 732 733 return ptr; 733 734 } 734 735 ··· 1156 1155 { 1157 1156 phys_addr_t memblock_limit = 0; 1158 1157 int highmem = 0; 1159 - phys_addr_t vmalloc_limit = __pa(vmalloc_min - 1) + 1; 1158 + u64 vmalloc_limit; 1160 1159 struct memblock_region *reg; 1161 1160 bool should_use_highmem = false; 1161 + 1162 + /* 1163 + * Let's use our own (unoptimized) equivalent of __pa() that is 1164 + * not affected by wrap-arounds when sizeof(phys_addr_t) == 4. 1165 + * The result is used as the upper bound on physical memory address 1166 + * and may itself be outside the valid range for which phys_addr_t 1167 + * and therefore __pa() is defined. 1168 + */ 1169 + vmalloc_limit = (u64)(uintptr_t)vmalloc_min - PAGE_OFFSET + PHYS_OFFSET; 1162 1170 1163 1171 for_each_memblock(memory, reg) { 1164 1172 phys_addr_t block_start = reg->base; ··· 1193 1183 if (reg->size > size_limit) { 1194 1184 phys_addr_t overlap_size = reg->size - size_limit; 1195 1185 1196 - pr_notice("Truncating RAM at %pa-%pa to -%pa", 1197 - &block_start, &block_end, &vmalloc_limit); 1198 - memblock_remove(vmalloc_limit, overlap_size); 1186 + pr_notice("Truncating RAM at %pa-%pa", 1187 + &block_start, &block_end); 1199 1188 block_end = vmalloc_limit; 1189 + pr_cont(" to -%pa", &block_end); 1190 + memblock_remove(vmalloc_limit, overlap_size); 1200 1191 should_use_highmem = true; 1201 1192 } 1202 1193 }
+1 -1
arch/arm/xen/enlighten.c
··· 50 50 static struct vcpu_info __percpu *xen_vcpu_info; 51 51 52 52 /* Linux <-> Xen vCPU id mapping */ 53 - DEFINE_PER_CPU(int, xen_vcpu_id) = -1; 53 + DEFINE_PER_CPU(uint32_t, xen_vcpu_id); 54 54 EXPORT_PER_CPU_SYMBOL(xen_vcpu_id); 55 55 56 56 /* These are unused until we support booting "pre-ballooned" */
+3
arch/arm64/kernel/head.S
··· 757 757 isb 758 758 bl __create_page_tables // recreate kernel mapping 759 759 760 + tlbi vmalle1 // Remove any stale TLB entries 761 + dsb nsh 762 + 760 763 msr sctlr_el1, x19 // re-enable the MMU 761 764 isb 762 765 ic iallu // flush instructions fetched
+9 -1
arch/arm64/kernel/sleep.S
··· 101 101 bl el2_setup // if in EL2 drop to EL1 cleanly 102 102 /* enable the MMU early - so we can access sleep_save_stash by va */ 103 103 adr_l lr, __enable_mmu /* __cpu_setup will return here */ 104 - ldr x27, =_cpu_resume /* __enable_mmu will branch here */ 104 + adr_l x27, _resume_switched /* __enable_mmu will branch here */ 105 105 adrp x25, idmap_pg_dir 106 106 adrp x26, swapper_pg_dir 107 107 b __cpu_setup 108 108 ENDPROC(cpu_resume) 109 + 110 + .pushsection ".idmap.text", "ax" 111 + _resume_switched: 112 + ldr x8, =_cpu_resume 113 + br x8 114 + ENDPROC(_resume_switched) 115 + .ltorg 116 + .popsection 109 117 110 118 ENTRY(_cpu_resume) 111 119 mrs x1, mpidr_el1
+1 -1
arch/arm64/kvm/hyp/switch.c
··· 256 256 257 257 /* 258 258 * We must restore the 32-bit state before the sysregs, thanks 259 - * to Cortex-A57 erratum #852523. 259 + * to erratum #852523 (Cortex-A57) or #853709 (Cortex-A72). 260 260 */ 261 261 __sysreg32_restore_state(vcpu); 262 262 __sysreg_restore_guest_state(guest_ctxt);
+1 -9
arch/arm64/kvm/sys_regs.c
··· 823 823 * Architected system registers. 824 824 * Important: Must be sorted ascending by Op0, Op1, CRn, CRm, Op2 825 825 * 826 - * We could trap ID_DFR0 and tell the guest we don't support performance 827 - * monitoring. Unfortunately the patch to make the kernel check ID_DFR0 was 828 - * NAKed, so it will read the PMCR anyway. 829 - * 830 - * Therefore we tell the guest we have 0 counters. Unfortunately, we 831 - * must always support PMCCNTR (the cycle counter): we just RAZ/WI for 832 - * all PM registers, which doesn't crash the guest kernel at least. 833 - * 834 826 * Debug handling: We do trap most, if not all debug related system 835 827 * registers. The implementation is good enough to ensure that a guest 836 828 * can use these with minimal performance degradation. The drawback is ··· 1352 1360 { Op1( 0), CRn(10), CRm( 3), Op2( 1), access_vm_reg, NULL, c10_AMAIR1 }, 1353 1361 1354 1362 /* ICC_SRE */ 1355 - { Op1( 0), CRn(12), CRm(12), Op2( 5), trap_raz_wi }, 1363 + { Op1( 0), CRn(12), CRm(12), Op2( 5), access_gic_sre }, 1356 1364 1357 1365 { Op1( 0), CRn(13), CRm( 0), Op2( 1), access_vm_reg, NULL, c13_CID }, 1358 1366
+3 -3
arch/arm64/mm/dump.c
··· 242 242 243 243 static void walk_pte(struct pg_state *st, pmd_t *pmd, unsigned long start) 244 244 { 245 - pte_t *pte = pte_offset_kernel(pmd, 0); 245 + pte_t *pte = pte_offset_kernel(pmd, 0UL); 246 246 unsigned long addr; 247 247 unsigned i; 248 248 ··· 254 254 255 255 static void walk_pmd(struct pg_state *st, pud_t *pud, unsigned long start) 256 256 { 257 - pmd_t *pmd = pmd_offset(pud, 0); 257 + pmd_t *pmd = pmd_offset(pud, 0UL); 258 258 unsigned long addr; 259 259 unsigned i; 260 260 ··· 271 271 272 272 static void walk_pud(struct pg_state *st, pgd_t *pgd, unsigned long start) 273 273 { 274 - pud_t *pud = pud_offset(pgd, 0); 274 + pud_t *pud = pud_offset(pgd, 0UL); 275 275 unsigned long addr; 276 276 unsigned i; 277 277
+2
arch/arm64/mm/numa.c
··· 23 23 #include <linux/module.h> 24 24 #include <linux/of.h> 25 25 26 + #include <asm/acpi.h> 27 + 26 28 struct pglist_data *node_data[MAX_NUMNODES] __read_mostly; 27 29 EXPORT_SYMBOL(node_data); 28 30 nodemask_t numa_nodes_parsed __initdata;
+2 -1
arch/blackfin/mach-bf561/boards/cm_bf561.c
··· 146 146 #include <linux/smc91x.h> 147 147 148 148 static struct smc91x_platdata smc91x_info = { 149 - .flags = SMC91X_USE_32BIT | SMC91X_NOWAIT, 149 + .flags = SMC91X_USE_8BIT | SMC91X_USE_16BIT | SMC91X_USE_32BIT | 150 + SMC91X_NOWAIT, 150 151 .leda = RPC_LED_100_10, 151 152 .ledb = RPC_LED_TX_RX, 152 153 };
+2 -1
arch/blackfin/mach-bf561/boards/ezkit.c
··· 134 134 #include <linux/smc91x.h> 135 135 136 136 static struct smc91x_platdata smc91x_info = { 137 - .flags = SMC91X_USE_32BIT | SMC91X_NOWAIT, 137 + .flags = SMC91X_USE_8BIT | SMC91X_USE_16BIT | SMC91X_USE_32BIT | 138 + SMC91X_NOWAIT, 138 139 .leda = RPC_LED_100_10, 139 140 .ledb = RPC_LED_TX_RX, 140 141 };
+2 -2
arch/mips/include/asm/page.h
··· 164 164 */ 165 165 static inline unsigned long ___pa(unsigned long x) 166 166 { 167 - if (config_enabled(CONFIG_64BIT)) { 167 + if (IS_ENABLED(CONFIG_64BIT)) { 168 168 /* 169 169 * For MIPS64 the virtual address may either be in one of 170 170 * the compatibility segements ckseg0 or ckseg1, or it may ··· 173 173 return x < CKSEG0 ? XPHYSADDR(x) : CPHYSADDR(x); 174 174 } 175 175 176 - if (!config_enabled(CONFIG_EVA)) { 176 + if (!IS_ENABLED(CONFIG_EVA)) { 177 177 /* 178 178 * We're using the standard MIPS32 legacy memory map, ie. 179 179 * the address x is going to be in kseg0 or kseg1. We can
+1 -1
arch/mips/kvm/mmu.c
··· 40 40 srcu_idx = srcu_read_lock(&kvm->srcu); 41 41 pfn = gfn_to_pfn(kvm, gfn); 42 42 43 - if (is_error_pfn(pfn)) { 43 + if (is_error_noslot_pfn(pfn)) { 44 44 kvm_err("Couldn't get pfn for gfn %#llx!\n", gfn); 45 45 err = -EFAULT; 46 46 goto out;
+2 -2
arch/parisc/include/uapi/asm/errno.h
··· 97 97 #define ENOTCONN 235 /* Transport endpoint is not connected */ 98 98 #define ESHUTDOWN 236 /* Cannot send after transport endpoint shutdown */ 99 99 #define ETOOMANYREFS 237 /* Too many references: cannot splice */ 100 - #define EREFUSED ECONNREFUSED /* for HP's NFS apparently */ 101 100 #define ETIMEDOUT 238 /* Connection timed out */ 102 101 #define ECONNREFUSED 239 /* Connection refused */ 103 - #define EREMOTERELEASE 240 /* Remote peer released connection */ 102 + #define EREFUSED ECONNREFUSED /* for HP's NFS apparently */ 103 + #define EREMOTERELEASE 240 /* Remote peer released connection */ 104 104 #define EHOSTDOWN 241 /* Host is down */ 105 105 #define EHOSTUNREACH 242 /* No route to host */ 106 106
-8
arch/parisc/kernel/processor.c
··· 51 51 52 52 DEFINE_PER_CPU(struct cpuinfo_parisc, cpu_data); 53 53 54 - extern int update_cr16_clocksource(void); /* from time.c */ 55 - 56 54 /* 57 55 ** PARISC CPU driver - claim "device" and initialize CPU data structures. 58 56 ** ··· 225 227 cpu_up(cpuid); 226 228 } 227 229 #endif 228 - 229 - /* If we've registered more than one cpu, 230 - * we'll use the jiffies clocksource since cr16 231 - * is not synchronized between CPUs. 232 - */ 233 - update_cr16_clocksource(); 234 230 235 231 return 0; 236 232 }
-12
arch/parisc/kernel/time.c
··· 221 221 .flags = CLOCK_SOURCE_IS_CONTINUOUS, 222 222 }; 223 223 224 - int update_cr16_clocksource(void) 225 - { 226 - /* since the cr16 cycle counters are not synchronized across CPUs, 227 - we'll check if we should switch to a safe clocksource: */ 228 - if (clocksource_cr16.rating != 0 && num_online_cpus() > 1) { 229 - clocksource_change_rating(&clocksource_cr16, 0); 230 - return 1; 231 - } 232 - 233 - return 0; 234 - } 235 - 236 224 void __init start_cpu_itimer(void) 237 225 { 238 226 unsigned int cpu = smp_processor_id();
+1
arch/powerpc/include/asm/cputhreads.h
··· 3 3 4 4 #ifndef __ASSEMBLY__ 5 5 #include <linux/cpumask.h> 6 + #include <asm/cpu_has_feature.h> 6 7 7 8 /* 8 9 * Mapping of threads to cores
+1 -1
arch/powerpc/include/asm/hmi.h
··· 21 21 #ifndef __ASM_PPC64_HMI_H__ 22 22 #define __ASM_PPC64_HMI_H__ 23 23 24 - #ifdef CONFIG_PPC_BOOK3S_64 24 + #ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE 25 25 26 26 #define CORE_TB_RESYNC_REQ_BIT 63 27 27 #define MAX_SUBCORE_PER_CORE 4
+7 -5
arch/powerpc/include/asm/paca.h
··· 183 183 */ 184 184 u16 in_mce; 185 185 u8 hmi_event_available; /* HMI event is available */ 186 - /* 187 - * Bitmap for sibling subcore status. See kvm/book3s_hv_ras.c for 188 - * more details 189 - */ 190 - struct sibling_subcore_state *sibling_subcore_state; 191 186 #endif 192 187 193 188 /* Stuff for accurate time accounting */ ··· 197 202 struct kvmppc_book3s_shadow_vcpu shadow_vcpu; 198 203 #endif 199 204 struct kvmppc_host_state kvm_hstate; 205 + #ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE 206 + /* 207 + * Bitmap for sibling subcore status. See kvm/book3s_hv_ras.c for 208 + * more details 209 + */ 210 + struct sibling_subcore_state *sibling_subcore_state; 211 + #endif 200 212 #endif 201 213 }; 202 214
+1
arch/powerpc/include/asm/pci-bridge.h
··· 301 301 /* Allocate & free a PCI host bridge structure */ 302 302 extern struct pci_controller *pcibios_alloc_controller(struct device_node *dev); 303 303 extern void pcibios_free_controller(struct pci_controller *phb); 304 + extern void pcibios_free_controller_deferred(struct pci_host_bridge *bridge); 304 305 305 306 #ifdef CONFIG_PCI 306 307 extern int pcibios_vaddr_is_ioport(void __iomem *address);
+1 -1
arch/powerpc/kernel/Makefile
··· 41 41 obj-$(CONFIG_HAVE_HW_BREAKPOINT) += hw_breakpoint.o 42 42 obj-$(CONFIG_PPC_BOOK3S_64) += cpu_setup_ppc970.o cpu_setup_pa6t.o 43 43 obj-$(CONFIG_PPC_BOOK3S_64) += cpu_setup_power.o 44 - obj-$(CONFIG_PPC_BOOK3S_64) += mce.o mce_power.o hmi.o 44 + obj-$(CONFIG_PPC_BOOK3S_64) += mce.o mce_power.o 45 45 obj-$(CONFIG_PPC_BOOK3E_64) += exceptions-64e.o idle_book3e.o 46 46 obj-$(CONFIG_PPC64) += vdso64/ 47 47 obj-$(CONFIG_ALTIVEC) += vecemu.o
+6 -6
arch/powerpc/kernel/entry_64.S
··· 368 368 tabort_syscall: 369 369 /* Firstly we need to enable TM in the kernel */ 370 370 mfmsr r10 371 - li r13, 1 372 - rldimi r10, r13, MSR_TM_LG, 63-MSR_TM_LG 371 + li r9, 1 372 + rldimi r10, r9, MSR_TM_LG, 63-MSR_TM_LG 373 373 mtmsrd r10, 0 374 374 375 375 /* tabort, this dooms the transaction, nothing else */ 376 - li r13, (TM_CAUSE_SYSCALL|TM_CAUSE_PERSISTENT) 377 - TABORT(R13) 376 + li r9, (TM_CAUSE_SYSCALL|TM_CAUSE_PERSISTENT) 377 + TABORT(R9) 378 378 379 379 /* 380 380 * Return directly to userspace. We have corrupted user register state, ··· 382 382 * resume after the tbegin of the aborted transaction with the 383 383 * checkpointed register state. 384 384 */ 385 - li r13, MSR_RI 386 - andc r10, r10, r13 385 + li r9, MSR_RI 386 + andc r10, r10, r9 387 387 mtmsrd r10, 1 388 388 mtspr SPRN_SRR0, r11 389 389 mtspr SPRN_SRR1, r12
+24 -5
arch/powerpc/kernel/exceptions-64s.S
··· 485 485 EXCEPTION_PROLOG_0(PACA_EXMC) 486 486 machine_check_pSeries_0: 487 487 EXCEPTION_PROLOG_1(PACA_EXMC, KVMTEST, 0x200) 488 - EXCEPTION_PROLOG_PSERIES_1(machine_check_common, EXC_STD) 488 + /* 489 + * The following is essentially EXCEPTION_PROLOG_PSERIES_1 with the 490 + * difference that MSR_RI is not enabled, because PACA_EXMC is being 491 + * used, so nested machine check corrupts it. machine_check_common 492 + * enables MSR_RI. 493 + */ 494 + ld r12,PACAKBASE(r13) 495 + ld r10,PACAKMSR(r13) 496 + xori r10,r10,MSR_RI 497 + mfspr r11,SPRN_SRR0 498 + LOAD_HANDLER(r12, machine_check_common) 499 + mtspr SPRN_SRR0,r12 500 + mfspr r12,SPRN_SRR1 501 + mtspr SPRN_SRR1,r10 502 + rfid 503 + b . /* prevent speculative execution */ 504 + 489 505 KVM_HANDLER_SKIP(PACA_EXMC, EXC_STD, 0x200) 490 506 KVM_HANDLER_SKIP(PACA_EXGEN, EXC_STD, 0x300) 491 507 KVM_HANDLER_SKIP(PACA_EXSLB, EXC_STD, 0x380) ··· 985 969 machine_check_common: 986 970 987 971 mfspr r10,SPRN_DAR 988 - std r10,PACA_EXGEN+EX_DAR(r13) 972 + std r10,PACA_EXMC+EX_DAR(r13) 989 973 mfspr r10,SPRN_DSISR 990 - stw r10,PACA_EXGEN+EX_DSISR(r13) 974 + stw r10,PACA_EXMC+EX_DSISR(r13) 991 975 EXCEPTION_PROLOG_COMMON(0x200, PACA_EXMC) 992 976 FINISH_NAP 993 977 RECONCILE_IRQ_STATE(r10, r11) 994 - ld r3,PACA_EXGEN+EX_DAR(r13) 995 - lwz r4,PACA_EXGEN+EX_DSISR(r13) 978 + ld r3,PACA_EXMC+EX_DAR(r13) 979 + lwz r4,PACA_EXMC+EX_DSISR(r13) 980 + /* Enable MSR_RI when finished with PACA_EXMC */ 981 + li r10,MSR_RI 982 + mtmsrd r10,1 996 983 std r3,_DAR(r1) 997 984 std r4,_DSISR(r1) 998 985 bl save_nvgprs
arch/powerpc/kernel/hmi.c arch/powerpc/kvm/book3s_hv_hmi.c
+1 -1
arch/powerpc/kernel/kprobes.c
··· 29 29 #include <linux/kprobes.h> 30 30 #include <linux/ptrace.h> 31 31 #include <linux/preempt.h> 32 - #include <linux/module.h> 32 + #include <linux/extable.h> 33 33 #include <linux/kdebug.h> 34 34 #include <linux/slab.h> 35 35 #include <asm/code-patching.h>
+36
arch/powerpc/kernel/pci-common.c
··· 154 154 EXPORT_SYMBOL_GPL(pcibios_free_controller); 155 155 156 156 /* 157 + * This function is used to call pcibios_free_controller() 158 + * in a deferred manner: a callback from the PCI subsystem. 159 + * 160 + * _*DO NOT*_ call pcibios_free_controller() explicitly if 161 + * this is used (or it may access an invalid *phb pointer). 162 + * 163 + * The callback occurs when all references to the root bus 164 + * are dropped (e.g., child buses/devices and their users). 165 + * 166 + * It's called as .release_fn() of 'struct pci_host_bridge' 167 + * which is associated with the 'struct pci_controller.bus' 168 + * (root bus) - it expects .release_data to hold a pointer 169 + * to 'struct pci_controller'. 170 + * 171 + * In order to use it, register .release_fn()/release_data 172 + * like this: 173 + * 174 + * pci_set_host_bridge_release(bridge, 175 + * pcibios_free_controller_deferred 176 + * (void *) phb); 177 + * 178 + * e.g. in the pcibios_root_bridge_prepare() callback from 179 + * pci_create_root_bus(). 180 + */ 181 + void pcibios_free_controller_deferred(struct pci_host_bridge *bridge) 182 + { 183 + struct pci_controller *phb = (struct pci_controller *) 184 + bridge->release_data; 185 + 186 + pr_debug("domain %d, dynamic %d\n", phb->global_number, phb->is_dynamic); 187 + 188 + pcibios_free_controller(phb); 189 + } 190 + EXPORT_SYMBOL_GPL(pcibios_free_controller_deferred); 191 + 192 + /* 157 193 * The function is used to return the minimal alignment 158 194 * for memory or I/O windows of the associated P2P bridge. 159 195 * By default, 4KiB alignment for I/O windows and 1MiB for
+6 -3
arch/powerpc/kernel/prom_init.c
··· 695 695 OV4_MIN_ENT_CAP, /* minimum VP entitled capacity */ 696 696 697 697 /* option vector 5: PAPR/OF options */ 698 - VECTOR_LENGTH(18), /* length */ 698 + VECTOR_LENGTH(21), /* length */ 699 699 0, /* don't ignore, don't halt */ 700 700 OV5_FEAT(OV5_LPAR) | OV5_FEAT(OV5_SPLPAR) | OV5_FEAT(OV5_LARGE_PAGES) | 701 701 OV5_FEAT(OV5_DRCONF_MEMORY) | OV5_FEAT(OV5_DONATE_DEDICATE_CPU) | ··· 726 726 0, 727 727 0, 728 728 OV5_FEAT(OV5_PFO_HW_RNG) | OV5_FEAT(OV5_PFO_HW_ENCR) | 729 - OV5_FEAT(OV5_PFO_HW_842), 730 - OV5_FEAT(OV5_SUB_PROCESSORS), 729 + OV5_FEAT(OV5_PFO_HW_842), /* Byte 17 */ 730 + 0, /* Byte 18 */ 731 + 0, /* Byte 19 */ 732 + 0, /* Byte 20 */ 733 + OV5_FEAT(OV5_SUB_PROCESSORS), /* Byte 21 */ 731 734 732 735 /* option vector 6: IBM PAPR hints */ 733 736 VECTOR_LENGTH(3), /* length */
+14
arch/powerpc/kernel/signal_32.c
··· 1226 1226 (regs->gpr[1] + __SIGNAL_FRAMESIZE + 16); 1227 1227 if (!access_ok(VERIFY_READ, rt_sf, sizeof(*rt_sf))) 1228 1228 goto bad; 1229 + 1229 1230 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM 1231 + /* 1232 + * If there is a transactional state then throw it away. 1233 + * The purpose of a sigreturn is to destroy all traces of the 1234 + * signal frame, this includes any transactional state created 1235 + * within in. We only check for suspended as we can never be 1236 + * active in the kernel, we are active, there is nothing better to 1237 + * do than go ahead and Bad Thing later. 1238 + * The cause is not important as there will never be a 1239 + * recheckpoint so it's not user visible. 1240 + */ 1241 + if (MSR_TM_SUSPENDED(mfmsr())) 1242 + tm_reclaim_current(0); 1243 + 1230 1244 if (__get_user(tmp, &rt_sf->uc.uc_link)) 1231 1245 goto bad; 1232 1246 uc_transact = (struct ucontext __user *)(uintptr_t)tmp;
+14
arch/powerpc/kernel/signal_64.c
··· 676 676 if (__copy_from_user(&set, &uc->uc_sigmask, sizeof(set))) 677 677 goto badframe; 678 678 set_current_blocked(&set); 679 + 679 680 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM 681 + /* 682 + * If there is a transactional state then throw it away. 683 + * The purpose of a sigreturn is to destroy all traces of the 684 + * signal frame, this includes any transactional state created 685 + * within in. We only check for suspended as we can never be 686 + * active in the kernel, we are active, there is nothing better to 687 + * do than go ahead and Bad Thing later. 688 + * The cause is not important as there will never be a 689 + * recheckpoint so it's not user visible. 690 + */ 691 + if (MSR_TM_SUSPENDED(mfmsr())) 692 + tm_reclaim_current(0); 693 + 680 694 if (__get_user(msr, &uc->uc_mcontext.gp_regs[PT_MSR])) 681 695 goto badframe; 682 696 if (MSR_TM_ACTIVE(msr)) {
+1 -1
arch/powerpc/kernel/smp.c
··· 830 830 831 831 /* Update sibling maps */ 832 832 base = cpu_first_thread_sibling(cpu); 833 - for (i = 0; i < threads_per_core; i++) { 833 + for (i = 0; i < threads_per_core && base + i < nr_cpu_ids; i++) { 834 834 cpumask_clear_cpu(cpu, cpu_sibling_mask(base + i)); 835 835 cpumask_clear_cpu(base + i, cpu_sibling_mask(cpu)); 836 836 cpumask_clear_cpu(cpu, cpu_core_mask(base + i));
+2 -1
arch/powerpc/kernel/traps.c
··· 25 25 #include <linux/user.h> 26 26 #include <linux/interrupt.h> 27 27 #include <linux/init.h> 28 - #include <linux/module.h> 28 + #include <linux/extable.h> 29 + #include <linux/module.h> /* print_modules */ 29 30 #include <linux/prctl.h> 30 31 #include <linux/delay.h> 31 32 #include <linux/kprobes.h>
+1
arch/powerpc/kvm/Makefile
··· 78 78 79 79 ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE 80 80 kvm-book3s_64-builtin-objs-$(CONFIG_KVM_BOOK3S_64_HANDLER) += \ 81 + book3s_hv_hmi.o \ 81 82 book3s_hv_rmhandlers.o \ 82 83 book3s_hv_rm_mmu.o \ 83 84 book3s_hv_ras.o \
+1 -1
arch/powerpc/mm/fault.c
··· 26 26 #include <linux/mm.h> 27 27 #include <linux/interrupt.h> 28 28 #include <linux/highmem.h> 29 - #include <linux/module.h> 29 + #include <linux/extable.h> 30 30 #include <linux/kprobes.h> 31 31 #include <linux/kdebug.h> 32 32 #include <linux/perf_event.h>
-1
arch/powerpc/platforms/512x/mpc512x_lpbfifo.c
··· 528 528 .remove = mpc512x_lpbfifo_remove, 529 529 .driver = { 530 530 .name = DRV_NAME, 531 - .owner = THIS_MODULE, 532 531 .of_match_table = mpc512x_lpbfifo_match, 533 532 }, 534 533 };
-1
arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c
··· 222 222 static struct i2c_driver mcu_driver = { 223 223 .driver = { 224 224 .name = "mcu-mpc8349emitx", 225 - .owner = THIS_MODULE, 226 225 .of_match_table = mcu_of_match_table, 227 226 }, 228 227 .probe = mcu_probe,
+1 -1
arch/powerpc/platforms/embedded6xx/holly.c
··· 26 26 #include <linux/tty.h> 27 27 #include <linux/serial_core.h> 28 28 #include <linux/of_platform.h> 29 - #include <linux/module.h> 29 + #include <linux/extable.h> 30 30 31 31 #include <asm/time.h> 32 32 #include <asm/machdep.h>
+1 -1
arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.c
··· 23 23 #include <linux/pci.h> 24 24 #include <linux/kdev_t.h> 25 25 #include <linux/console.h> 26 - #include <linux/module.h> 26 + #include <linux/extable.h> 27 27 #include <linux/delay.h> 28 28 #include <linux/irq.h> 29 29 #include <linux/seq_file.h>
+6 -1
arch/powerpc/platforms/powernv/opal-dump.c
··· 370 370 uint32_t dump_id, dump_size, dump_type; 371 371 struct dump_obj *dump; 372 372 char name[22]; 373 + struct kobject *kobj; 373 374 374 375 rc = dump_read_info(&dump_id, &dump_size, &dump_type); 375 376 if (rc != OPAL_SUCCESS) ··· 382 381 * that gracefully and not create two conflicting 383 382 * entries. 384 383 */ 385 - if (kset_find_obj(dump_kset, name)) 384 + kobj = kset_find_obj(dump_kset, name); 385 + if (kobj) { 386 + /* Drop reference added by kset_find_obj() */ 387 + kobject_put(kobj); 386 388 return 0; 389 + } 387 390 388 391 dump = create_dump_obj(dump_id, dump_size, dump_type); 389 392 if (!dump)
+6 -1
arch/powerpc/platforms/powernv/opal-elog.c
··· 247 247 uint64_t elog_type; 248 248 int rc; 249 249 char name[2+16+1]; 250 + struct kobject *kobj; 250 251 251 252 rc = opal_get_elog_size(&id, &size, &type); 252 253 if (rc != OPAL_SUCCESS) { ··· 270 269 * that gracefully and not create two conflicting 271 270 * entries. 272 271 */ 273 - if (kset_find_obj(elog_kset, name)) 272 + kobj = kset_find_obj(elog_kset, name); 273 + if (kobj) { 274 + /* Drop reference added by kset_find_obj() */ 275 + kobject_put(kobj); 274 276 return IRQ_HANDLED; 277 + } 275 278 276 279 create_elog_obj(log_id, elog_size, elog_type); 277 280
+1 -1
arch/powerpc/platforms/powernv/pci-ioda.c
··· 149 149 150 150 static struct pnv_ioda_pe *pnv_ioda_alloc_pe(struct pnv_phb *phb) 151 151 { 152 - unsigned long pe = phb->ioda.total_pe_num - 1; 152 + long pe; 153 153 154 154 for (pe = phb->ioda.total_pe_num - 1; pe >= 0; pe--) { 155 155 if (!test_and_set_bit(pe, phb->ioda.pe_alloc))
+4
arch/powerpc/platforms/pseries/pci.c
··· 119 119 120 120 bus = bridge->bus; 121 121 122 + /* Rely on the pcibios_free_controller_deferred() callback. */ 123 + pci_set_host_bridge_release(bridge, pcibios_free_controller_deferred, 124 + (void *) pci_bus_to_host(bus)); 125 + 122 126 dn = pcibios_get_phb_of_node(bus); 123 127 if (!dn) 124 128 return 0;
+5 -2
arch/powerpc/platforms/pseries/pci_dlpar.c
··· 106 106 release_resource(res); 107 107 } 108 108 109 - /* Free pci_controller data structure */ 110 - pcibios_free_controller(phb); 109 + /* 110 + * The pci_controller data structure is freed by 111 + * the pcibios_free_controller_deferred() callback; 112 + * see pseries_root_bridge_prepare(). 113 + */ 111 114 112 115 return 0; 113 116 }
+4 -2
arch/powerpc/sysdev/cpm1.c
··· 534 534 535 535 static void cpm1_gpio16_save_regs(struct of_mm_gpio_chip *mm_gc) 536 536 { 537 - struct cpm1_gpio16_chip *cpm1_gc = gpiochip_get_data(&mm_gc->gc); 537 + struct cpm1_gpio16_chip *cpm1_gc = 538 + container_of(mm_gc, struct cpm1_gpio16_chip, mm_gc); 538 539 struct cpm_ioport16 __iomem *iop = mm_gc->regs; 539 540 540 541 cpm1_gc->cpdata = in_be16(&iop->dat); ··· 650 649 651 650 static void cpm1_gpio32_save_regs(struct of_mm_gpio_chip *mm_gc) 652 651 { 653 - struct cpm1_gpio32_chip *cpm1_gc = gpiochip_get_data(&mm_gc->gc); 652 + struct cpm1_gpio32_chip *cpm1_gc = 653 + container_of(mm_gc, struct cpm1_gpio32_chip, mm_gc); 654 654 struct cpm_ioport32b __iomem *iop = mm_gc->regs; 655 655 656 656 cpm1_gc->cpdata = in_be32(&iop->dat);
+2 -1
arch/powerpc/sysdev/cpm_common.c
··· 94 94 95 95 static void cpm2_gpio32_save_regs(struct of_mm_gpio_chip *mm_gc) 96 96 { 97 - struct cpm2_gpio32_chip *cpm2_gc = gpiochip_get_data(&mm_gc->gc); 97 + struct cpm2_gpio32_chip *cpm2_gc = 98 + container_of(mm_gc, struct cpm2_gpio32_chip, mm_gc); 98 99 struct cpm2_ioports __iomem *iop = mm_gc->regs; 99 100 100 101 cpm2_gc->cpdata = in_be32(&iop->dat);
+1 -1
arch/powerpc/sysdev/fsl_rio.c
··· 23 23 */ 24 24 25 25 #include <linux/init.h> 26 - #include <linux/module.h> 26 + #include <linux/extable.h> 27 27 #include <linux/types.h> 28 28 #include <linux/dma-mapping.h> 29 29 #include <linux/interrupt.h>
+2 -4
arch/s390/kernel/setup.c
··· 204 204 #endif 205 205 } 206 206 } else if (MACHINE_IS_KVM) { 207 - if (sclp.has_vt220 && 208 - config_enabled(CONFIG_SCLP_VT220_CONSOLE)) 207 + if (sclp.has_vt220 && IS_ENABLED(CONFIG_SCLP_VT220_CONSOLE)) 209 208 SET_CONSOLE_VT220; 210 - else if (sclp.has_linemode && 211 - config_enabled(CONFIG_SCLP_CONSOLE)) 209 + else if (sclp.has_linemode && IS_ENABLED(CONFIG_SCLP_CONSOLE)) 212 210 SET_CONSOLE_SCLP; 213 211 else 214 212 SET_CONSOLE_HVC;
+1 -1
arch/um/include/asm/common.lds.S
··· 81 81 .altinstr_replacement : { *(.altinstr_replacement) } 82 82 /* .exit.text is discard at runtime, not link time, to deal with references 83 83 from .altinstructions and .eh_frame */ 84 - .exit.text : { *(.exit.text) } 84 + .exit.text : { EXIT_TEXT } 85 85 .exit.data : { *(.exit.data) } 86 86 87 87 .preinit_array : {
+2 -2
arch/x86/crypto/sha256-mb/sha256_mb.c
··· 485 485 486 486 req = cast_mcryptd_ctx_to_req(req_ctx); 487 487 if (irqs_disabled()) 488 - rctx->complete(&req->base, ret); 488 + req_ctx->complete(&req->base, ret); 489 489 else { 490 490 local_bh_disable(); 491 - rctx->complete(&req->base, ret); 491 + req_ctx->complete(&req->base, ret); 492 492 local_bh_enable(); 493 493 } 494 494 }
+4 -3
arch/x86/crypto/sha256-mb/sha256_mb_mgr_flush_avx2.S
··· 265 265 vpinsrd $1, _args_digest+1*32(state, idx, 4), %xmm0, %xmm0 266 266 vpinsrd $2, _args_digest+2*32(state, idx, 4), %xmm0, %xmm0 267 267 vpinsrd $3, _args_digest+3*32(state, idx, 4), %xmm0, %xmm0 268 - movl _args_digest+4*32(state, idx, 4), tmp2_w 268 + vmovd _args_digest(state , idx, 4) , %xmm0 269 269 vpinsrd $1, _args_digest+5*32(state, idx, 4), %xmm1, %xmm1 270 270 vpinsrd $2, _args_digest+6*32(state, idx, 4), %xmm1, %xmm1 271 271 vpinsrd $3, _args_digest+7*32(state, idx, 4), %xmm1, %xmm1 272 272 273 - vmovdqu %xmm0, _result_digest(job_rax) 274 - movl tmp2_w, _result_digest+1*16(job_rax) 273 + vmovdqu %xmm0, _result_digest(job_rax) 274 + offset = (_result_digest + 1*16) 275 + vmovdqu %xmm1, offset(job_rax) 275 276 276 277 pop %rbx 277 278
+2 -2
arch/x86/crypto/sha512-mb/sha512_mb.c
··· 497 497 498 498 req = cast_mcryptd_ctx_to_req(req_ctx); 499 499 if (irqs_disabled()) 500 - rctx->complete(&req->base, ret); 500 + req_ctx->complete(&req->base, ret); 501 501 else { 502 502 local_bh_disable(); 503 - rctx->complete(&req->base, ret); 503 + req_ctx->complete(&req->base, ret); 504 504 local_bh_enable(); 505 505 } 506 506 }
+3
arch/x86/kernel/apic/apic.c
··· 1623 1623 unsigned long flags; 1624 1624 int ret, ir_stat; 1625 1625 1626 + if (skip_ioapic_setup) 1627 + return; 1628 + 1626 1629 ir_stat = irq_remapping_prepare(); 1627 1630 if (ir_stat < 0 && !x2apic_supported()) 1628 1631 return;
+8 -1
arch/x86/kernel/cpu/microcode/amd.c
··· 355 355 unsigned int cpu = smp_processor_id(); 356 356 struct equiv_cpu_entry *eq; 357 357 struct microcode_amd *mc; 358 + u8 *cont = container; 358 359 u32 rev, eax; 359 360 u16 eq_id; 360 361 ··· 372 371 if (check_current_patch_level(&rev, false)) 373 372 return; 374 373 374 + /* Add CONFIG_RANDOMIZE_MEMORY offset. */ 375 + cont += PAGE_OFFSET - __PAGE_OFFSET_BASE; 376 + 375 377 eax = cpuid_eax(0x00000001); 376 - eq = (struct equiv_cpu_entry *)(container + CONTAINER_HDR_SZ); 378 + eq = (struct equiv_cpu_entry *)(cont + CONTAINER_HDR_SZ); 377 379 378 380 eq_id = find_equiv_id(eq, eax); 379 381 if (!eq_id) ··· 437 433 (cont - boot_params.hdr.ramdisk_image)); 438 434 else 439 435 container = cont_va; 436 + 437 + /* Add CONFIG_RANDOMIZE_MEMORY offset. */ 438 + container += PAGE_OFFSET - __PAGE_OFFSET_BASE; 440 439 441 440 eax = cpuid_eax(0x00000001); 442 441 eax = ((eax >> 8) & 0xf) + ((eax >> 20) & 0xff);
+16 -9
arch/x86/kernel/smpboot.c
··· 100 100 /* Logical package management. We might want to allocate that dynamically */ 101 101 static int *physical_to_logical_pkg __read_mostly; 102 102 static unsigned long *physical_package_map __read_mostly;; 103 - static unsigned long *logical_package_map __read_mostly; 104 103 static unsigned int max_physical_pkg_id __read_mostly; 105 104 unsigned int __max_logical_packages __read_mostly; 106 105 EXPORT_SYMBOL(__max_logical_packages); 106 + static unsigned int logical_packages __read_mostly; 107 + static bool logical_packages_frozen __read_mostly; 107 108 108 109 /* Maximum number of SMT threads on any online core */ 109 110 int __max_smt_threads __read_mostly; ··· 278 277 if (test_and_set_bit(pkg, physical_package_map)) 279 278 goto found; 280 279 281 - new = find_first_zero_bit(logical_package_map, __max_logical_packages); 282 - if (new >= __max_logical_packages) { 280 + if (logical_packages_frozen) { 283 281 physical_to_logical_pkg[pkg] = -1; 284 - pr_warn("APIC(%x) Package %u exceeds logical package map\n", 282 + pr_warn("APIC(%x) Package %u exceeds logical package max\n", 285 283 apicid, pkg); 286 284 return -ENOSPC; 287 285 } 288 - set_bit(new, logical_package_map); 286 + 287 + new = logical_packages++; 289 288 pr_info("APIC(%x) Converting physical %u to logical package %u\n", 290 289 apicid, pkg, new); 291 290 physical_to_logical_pkg[pkg] = new; ··· 342 341 } 343 342 344 343 __max_logical_packages = DIV_ROUND_UP(total_cpus, ncpus); 344 + logical_packages = 0; 345 345 346 346 /* 347 347 * Possibly larger than what we need as the number of apic ids per ··· 354 352 memset(physical_to_logical_pkg, 0xff, size); 355 353 size = BITS_TO_LONGS(max_physical_pkg_id) * sizeof(unsigned long); 356 354 physical_package_map = kzalloc(size, GFP_KERNEL); 357 - size = BITS_TO_LONGS(__max_logical_packages) * sizeof(unsigned long); 358 - logical_package_map = kzalloc(size, GFP_KERNEL); 359 - 360 - pr_info("Max logical packages: %u\n", __max_logical_packages); 361 355 362 356 for_each_present_cpu(cpu) { 363 357 unsigned int apicid = apic->cpu_present_to_apicid(cpu); ··· 367 369 set_cpu_possible(cpu, false); 368 370 set_cpu_present(cpu, false); 369 371 } 372 + 373 + if (logical_packages > __max_logical_packages) { 374 + pr_warn("Detected more packages (%u), then computed by BIOS data (%u).\n", 375 + logical_packages, __max_logical_packages); 376 + logical_packages_frozen = true; 377 + __max_logical_packages = logical_packages; 378 + } 379 + 380 + pr_info("Max logical packages: %u\n", __max_logical_packages); 370 381 } 371 382 372 383 void __init smp_store_boot_cpu_info(void)
+69 -67
arch/x86/kvm/vmx.c
··· 422 422 struct list_head vmcs02_pool; 423 423 int vmcs02_num; 424 424 u64 vmcs01_tsc_offset; 425 + bool change_vmcs01_virtual_x2apic_mode; 425 426 /* L2 must run next, and mustn't decide to exit to L1. */ 426 427 bool nested_run_pending; 427 428 /* ··· 435 434 struct pi_desc *pi_desc; 436 435 bool pi_pending; 437 436 u16 posted_intr_nv; 437 + 438 + unsigned long *msr_bitmap; 438 439 439 440 struct hrtimer preemption_timer; 440 441 bool preemption_timer_expired; ··· 927 924 static unsigned long *vmx_msr_bitmap_longmode; 928 925 static unsigned long *vmx_msr_bitmap_legacy_x2apic; 929 926 static unsigned long *vmx_msr_bitmap_longmode_x2apic; 930 - static unsigned long *vmx_msr_bitmap_nested; 931 927 static unsigned long *vmx_vmread_bitmap; 932 928 static unsigned long *vmx_vmwrite_bitmap; 933 929 ··· 2200 2198 new.control) != old.control); 2201 2199 } 2202 2200 2201 + static void decache_tsc_multiplier(struct vcpu_vmx *vmx) 2202 + { 2203 + vmx->current_tsc_ratio = vmx->vcpu.arch.tsc_scaling_ratio; 2204 + vmcs_write64(TSC_MULTIPLIER, vmx->current_tsc_ratio); 2205 + } 2206 + 2203 2207 /* 2204 2208 * Switches to specified vcpu, until a matching vcpu_put(), but assumes 2205 2209 * vcpu mutex is already taken. ··· 2264 2256 2265 2257 /* Setup TSC multiplier */ 2266 2258 if (kvm_has_tsc_control && 2267 - vmx->current_tsc_ratio != vcpu->arch.tsc_scaling_ratio) { 2268 - vmx->current_tsc_ratio = vcpu->arch.tsc_scaling_ratio; 2269 - vmcs_write64(TSC_MULTIPLIER, vmx->current_tsc_ratio); 2270 - } 2259 + vmx->current_tsc_ratio != vcpu->arch.tsc_scaling_ratio) 2260 + decache_tsc_multiplier(vmx); 2271 2261 2272 2262 vmx_vcpu_pi_load(vcpu, cpu); 2273 2263 vmx->host_pkru = read_pkru(); ··· 2514 2508 unsigned long *msr_bitmap; 2515 2509 2516 2510 if (is_guest_mode(vcpu)) 2517 - msr_bitmap = vmx_msr_bitmap_nested; 2511 + msr_bitmap = to_vmx(vcpu)->nested.msr_bitmap; 2518 2512 else if (cpu_has_secondary_exec_ctrls() && 2519 2513 (vmcs_read32(SECONDARY_VM_EXEC_CONTROL) & 2520 2514 SECONDARY_EXEC_VIRTUALIZE_X2APIC_MODE)) { ··· 6369 6363 if (!vmx_msr_bitmap_longmode_x2apic) 6370 6364 goto out4; 6371 6365 6372 - if (nested) { 6373 - vmx_msr_bitmap_nested = 6374 - (unsigned long *)__get_free_page(GFP_KERNEL); 6375 - if (!vmx_msr_bitmap_nested) 6376 - goto out5; 6377 - } 6378 - 6379 6366 vmx_vmread_bitmap = (unsigned long *)__get_free_page(GFP_KERNEL); 6380 6367 if (!vmx_vmread_bitmap) 6381 6368 goto out6; ··· 6391 6392 6392 6393 memset(vmx_msr_bitmap_legacy, 0xff, PAGE_SIZE); 6393 6394 memset(vmx_msr_bitmap_longmode, 0xff, PAGE_SIZE); 6394 - if (nested) 6395 - memset(vmx_msr_bitmap_nested, 0xff, PAGE_SIZE); 6396 6395 6397 6396 if (setup_vmcs_config(&vmcs_config) < 0) { 6398 6397 r = -EIO; ··· 6526 6529 out7: 6527 6530 free_page((unsigned long)vmx_vmread_bitmap); 6528 6531 out6: 6529 - if (nested) 6530 - free_page((unsigned long)vmx_msr_bitmap_nested); 6531 - out5: 6532 6532 free_page((unsigned long)vmx_msr_bitmap_longmode_x2apic); 6533 6533 out4: 6534 6534 free_page((unsigned long)vmx_msr_bitmap_longmode); ··· 6551 6557 free_page((unsigned long)vmx_io_bitmap_a); 6552 6558 free_page((unsigned long)vmx_vmwrite_bitmap); 6553 6559 free_page((unsigned long)vmx_vmread_bitmap); 6554 - if (nested) 6555 - free_page((unsigned long)vmx_msr_bitmap_nested); 6556 6560 6557 6561 free_kvm_area(); 6558 6562 } ··· 6987 6995 return 1; 6988 6996 } 6989 6997 6998 + if (cpu_has_vmx_msr_bitmap()) { 6999 + vmx->nested.msr_bitmap = 7000 + (unsigned long *)__get_free_page(GFP_KERNEL); 7001 + if (!vmx->nested.msr_bitmap) 7002 + goto out_msr_bitmap; 7003 + } 7004 + 6990 7005 vmx->nested.cached_vmcs12 = kmalloc(VMCS12_SIZE, GFP_KERNEL); 6991 7006 if (!vmx->nested.cached_vmcs12) 6992 - return -ENOMEM; 7007 + goto out_cached_vmcs12; 6993 7008 6994 7009 if (enable_shadow_vmcs) { 6995 7010 shadow_vmcs = alloc_vmcs(); 6996 - if (!shadow_vmcs) { 6997 - kfree(vmx->nested.cached_vmcs12); 6998 - return -ENOMEM; 6999 - } 7011 + if (!shadow_vmcs) 7012 + goto out_shadow_vmcs; 7000 7013 /* mark vmcs as shadow */ 7001 7014 shadow_vmcs->revision_id |= (1u << 31); 7002 7015 /* init shadow vmcs */ ··· 7021 7024 skip_emulated_instruction(vcpu); 7022 7025 nested_vmx_succeed(vcpu); 7023 7026 return 1; 7027 + 7028 + out_shadow_vmcs: 7029 + kfree(vmx->nested.cached_vmcs12); 7030 + 7031 + out_cached_vmcs12: 7032 + free_page((unsigned long)vmx->nested.msr_bitmap); 7033 + 7034 + out_msr_bitmap: 7035 + return -ENOMEM; 7024 7036 } 7025 7037 7026 7038 /* ··· 7104 7098 vmx->nested.vmxon = false; 7105 7099 free_vpid(vmx->nested.vpid02); 7106 7100 nested_release_vmcs12(vmx); 7101 + if (vmx->nested.msr_bitmap) { 7102 + free_page((unsigned long)vmx->nested.msr_bitmap); 7103 + vmx->nested.msr_bitmap = NULL; 7104 + } 7107 7105 if (enable_shadow_vmcs) 7108 7106 free_vmcs(vmx->nested.current_shadow_vmcs); 7109 7107 kfree(vmx->nested.cached_vmcs12); ··· 8429 8419 { 8430 8420 u32 sec_exec_control; 8431 8421 8422 + /* Postpone execution until vmcs01 is the current VMCS. */ 8423 + if (is_guest_mode(vcpu)) { 8424 + to_vmx(vcpu)->nested.change_vmcs01_virtual_x2apic_mode = true; 8425 + return; 8426 + } 8427 + 8432 8428 /* 8433 8429 * There is not point to enable virtualize x2apic without enable 8434 8430 * apicv ··· 9488 9472 { 9489 9473 int msr; 9490 9474 struct page *page; 9491 - unsigned long *msr_bitmap; 9475 + unsigned long *msr_bitmap_l1; 9476 + unsigned long *msr_bitmap_l0 = to_vmx(vcpu)->nested.msr_bitmap; 9492 9477 9478 + /* This shortcut is ok because we support only x2APIC MSRs so far. */ 9493 9479 if (!nested_cpu_has_virt_x2apic_mode(vmcs12)) 9494 9480 return false; 9495 9481 ··· 9500 9482 WARN_ON(1); 9501 9483 return false; 9502 9484 } 9503 - msr_bitmap = (unsigned long *)kmap(page); 9504 - if (!msr_bitmap) { 9485 + msr_bitmap_l1 = (unsigned long *)kmap(page); 9486 + if (!msr_bitmap_l1) { 9505 9487 nested_release_page_clean(page); 9506 9488 WARN_ON(1); 9507 9489 return false; 9508 9490 } 9509 9491 9492 + memset(msr_bitmap_l0, 0xff, PAGE_SIZE); 9493 + 9510 9494 if (nested_cpu_has_virt_x2apic_mode(vmcs12)) { 9511 9495 if (nested_cpu_has_apic_reg_virt(vmcs12)) 9512 9496 for (msr = 0x800; msr <= 0x8ff; msr++) 9513 9497 nested_vmx_disable_intercept_for_msr( 9514 - msr_bitmap, 9515 - vmx_msr_bitmap_nested, 9498 + msr_bitmap_l1, msr_bitmap_l0, 9516 9499 msr, MSR_TYPE_R); 9517 - /* TPR is allowed */ 9518 - nested_vmx_disable_intercept_for_msr(msr_bitmap, 9519 - vmx_msr_bitmap_nested, 9500 + 9501 + nested_vmx_disable_intercept_for_msr( 9502 + msr_bitmap_l1, msr_bitmap_l0, 9520 9503 APIC_BASE_MSR + (APIC_TASKPRI >> 4), 9521 9504 MSR_TYPE_R | MSR_TYPE_W); 9505 + 9522 9506 if (nested_cpu_has_vid(vmcs12)) { 9523 - /* EOI and self-IPI are allowed */ 9524 9507 nested_vmx_disable_intercept_for_msr( 9525 - msr_bitmap, 9526 - vmx_msr_bitmap_nested, 9508 + msr_bitmap_l1, msr_bitmap_l0, 9527 9509 APIC_BASE_MSR + (APIC_EOI >> 4), 9528 9510 MSR_TYPE_W); 9529 9511 nested_vmx_disable_intercept_for_msr( 9530 - msr_bitmap, 9531 - vmx_msr_bitmap_nested, 9512 + msr_bitmap_l1, msr_bitmap_l0, 9532 9513 APIC_BASE_MSR + (APIC_SELF_IPI >> 4), 9533 9514 MSR_TYPE_W); 9534 9515 } 9535 - } else { 9536 - /* 9537 - * Enable reading intercept of all the x2apic 9538 - * MSRs. We should not rely on vmcs12 to do any 9539 - * optimizations here, it may have been modified 9540 - * by L1. 9541 - */ 9542 - for (msr = 0x800; msr <= 0x8ff; msr++) 9543 - __vmx_enable_intercept_for_msr( 9544 - vmx_msr_bitmap_nested, 9545 - msr, 9546 - MSR_TYPE_R); 9547 - 9548 - __vmx_enable_intercept_for_msr( 9549 - vmx_msr_bitmap_nested, 9550 - APIC_BASE_MSR + (APIC_TASKPRI >> 4), 9551 - MSR_TYPE_W); 9552 - __vmx_enable_intercept_for_msr( 9553 - vmx_msr_bitmap_nested, 9554 - APIC_BASE_MSR + (APIC_EOI >> 4), 9555 - MSR_TYPE_W); 9556 - __vmx_enable_intercept_for_msr( 9557 - vmx_msr_bitmap_nested, 9558 - APIC_BASE_MSR + (APIC_SELF_IPI >> 4), 9559 - MSR_TYPE_W); 9560 9516 } 9561 9517 kunmap(page); 9562 9518 nested_release_page_clean(page); ··· 9949 9957 } 9950 9958 9951 9959 if (cpu_has_vmx_msr_bitmap() && 9952 - exec_control & CPU_BASED_USE_MSR_BITMAPS) { 9953 - nested_vmx_merge_msr_bitmap(vcpu, vmcs12); 9954 - /* MSR_BITMAP will be set by following vmx_set_efer. */ 9955 - } else 9960 + exec_control & CPU_BASED_USE_MSR_BITMAPS && 9961 + nested_vmx_merge_msr_bitmap(vcpu, vmcs12)) 9962 + ; /* MSR_BITMAP will be set by following vmx_set_efer. */ 9963 + else 9956 9964 exec_control &= ~CPU_BASED_USE_MSR_BITMAPS; 9957 9965 9958 9966 /* ··· 10003 10011 vmx->nested.vmcs01_tsc_offset + vmcs12->tsc_offset); 10004 10012 else 10005 10013 vmcs_write64(TSC_OFFSET, vmx->nested.vmcs01_tsc_offset); 10014 + if (kvm_has_tsc_control) 10015 + decache_tsc_multiplier(vmx); 10006 10016 10007 10017 if (enable_vpid) { 10008 10018 /* ··· 10761 10767 else 10762 10768 vmcs_set_bits(PIN_BASED_VM_EXEC_CONTROL, 10763 10769 PIN_BASED_VMX_PREEMPTION_TIMER); 10770 + if (kvm_has_tsc_control) 10771 + decache_tsc_multiplier(vmx); 10772 + 10773 + if (vmx->nested.change_vmcs01_virtual_x2apic_mode) { 10774 + vmx->nested.change_vmcs01_virtual_x2apic_mode = false; 10775 + vmx_set_virtual_x2apic_mode(vcpu, 10776 + vcpu->arch.apic_base & X2APIC_ENABLE); 10777 + } 10764 10778 10765 10779 /* This is needed for same reason as it was needed in prepare_vmcs02 */ 10766 10780 vmx->host_rsp = 0;
+1 -1
arch/x86/mm/kaslr.c
··· 77 77 */ 78 78 static inline bool kaslr_memory_enabled(void) 79 79 { 80 - return kaslr_enabled() && !config_enabled(CONFIG_KASAN); 80 + return kaslr_enabled() && !IS_ENABLED(CONFIG_KASAN); 81 81 } 82 82 83 83 /* Initialize base and padding for each memory region randomized with KASLR */
+8 -2
arch/x86/pci/vmd.c
··· 41 41 * @node: list item for parent traversal. 42 42 * @rcu: RCU callback item for freeing. 43 43 * @irq: back pointer to parent. 44 + * @enabled: true if driver enabled IRQ 44 45 * @virq: the virtual IRQ value provided to the requesting driver. 45 46 * 46 47 * Every MSI/MSI-X IRQ requested for a device in a VMD domain will be mapped to ··· 51 50 struct list_head node; 52 51 struct rcu_head rcu; 53 52 struct vmd_irq_list *irq; 53 + bool enabled; 54 54 unsigned int virq; 55 55 }; 56 56 ··· 124 122 unsigned long flags; 125 123 126 124 raw_spin_lock_irqsave(&list_lock, flags); 125 + WARN_ON(vmdirq->enabled); 127 126 list_add_tail_rcu(&vmdirq->node, &vmdirq->irq->irq_list); 127 + vmdirq->enabled = true; 128 128 raw_spin_unlock_irqrestore(&list_lock, flags); 129 129 130 130 data->chip->irq_unmask(data); ··· 140 136 data->chip->irq_mask(data); 141 137 142 138 raw_spin_lock_irqsave(&list_lock, flags); 143 - list_del_rcu(&vmdirq->node); 144 - INIT_LIST_HEAD_RCU(&vmdirq->node); 139 + if (vmdirq->enabled) { 140 + list_del_rcu(&vmdirq->node); 141 + vmdirq->enabled = false; 142 + } 145 143 raw_spin_unlock_irqrestore(&list_lock, flags); 146 144 } 147 145
+1 -1
arch/x86/power/hibernate_64.c
··· 113 113 return result; 114 114 } 115 115 116 - temp_level4_pgt = (unsigned long)pgd - __PAGE_OFFSET; 116 + temp_level4_pgt = __pa(pgd); 117 117 return 0; 118 118 } 119 119
+1 -1
arch/x86/xen/enlighten.c
··· 118 118 DEFINE_PER_CPU(struct vcpu_info, xen_vcpu_info); 119 119 120 120 /* Linux <-> Xen vCPU id mapping */ 121 - DEFINE_PER_CPU(int, xen_vcpu_id) = -1; 121 + DEFINE_PER_CPU(uint32_t, xen_vcpu_id); 122 122 EXPORT_PER_CPU_SYMBOL(xen_vcpu_id); 123 123 124 124 enum xen_domain_type xen_domain_type = XEN_NATIVE;
+11 -10
block/bio.c
··· 667 667 bio->bi_iter.bi_sector = bio_src->bi_iter.bi_sector; 668 668 bio->bi_iter.bi_size = bio_src->bi_iter.bi_size; 669 669 670 - if (bio_op(bio) == REQ_OP_DISCARD) 671 - goto integrity_clone; 672 - 673 - if (bio_op(bio) == REQ_OP_WRITE_SAME) { 670 + switch (bio_op(bio)) { 671 + case REQ_OP_DISCARD: 672 + case REQ_OP_SECURE_ERASE: 673 + break; 674 + case REQ_OP_WRITE_SAME: 674 675 bio->bi_io_vec[bio->bi_vcnt++] = bio_src->bi_io_vec[0]; 675 - goto integrity_clone; 676 + break; 677 + default: 678 + bio_for_each_segment(bv, bio_src, iter) 679 + bio->bi_io_vec[bio->bi_vcnt++] = bv; 680 + break; 676 681 } 677 682 678 - bio_for_each_segment(bv, bio_src, iter) 679 - bio->bi_io_vec[bio->bi_vcnt++] = bv; 680 - 681 - integrity_clone: 682 683 if (bio_integrity(bio_src)) { 683 684 int ret; 684 685 ··· 1789 1788 * Discards need a mutable bio_vec to accommodate the payload 1790 1789 * required by the DSM TRIM and UNMAP commands. 1791 1790 */ 1792 - if (bio_op(bio) == REQ_OP_DISCARD) 1791 + if (bio_op(bio) == REQ_OP_DISCARD || bio_op(bio) == REQ_OP_SECURE_ERASE) 1793 1792 split = bio_clone_bioset(bio, gfp, bs); 1794 1793 else 1795 1794 split = bio_clone_fast(bio, gfp, bs);
+3 -1
block/blk-core.c
··· 515 515 516 516 void blk_set_queue_dying(struct request_queue *q) 517 517 { 518 - queue_flag_set_unlocked(QUEUE_FLAG_DYING, q); 518 + spin_lock_irq(q->queue_lock); 519 + queue_flag_set(QUEUE_FLAG_DYING, q); 520 + spin_unlock_irq(q->queue_lock); 519 521 520 522 if (q->mq_ops) 521 523 blk_mq_wake_waiters(q);
+41 -14
block/blk-merge.c
··· 94 94 bool do_split = true; 95 95 struct bio *new = NULL; 96 96 const unsigned max_sectors = get_max_io_size(q, bio); 97 + unsigned bvecs = 0; 97 98 98 99 bio_for_each_segment(bv, bio, iter) { 100 + /* 101 + * With arbitrary bio size, the incoming bio may be very 102 + * big. We have to split the bio into small bios so that 103 + * each holds at most BIO_MAX_PAGES bvecs because 104 + * bio_clone() can fail to allocate big bvecs. 105 + * 106 + * It should have been better to apply the limit per 107 + * request queue in which bio_clone() is involved, 108 + * instead of globally. The biggest blocker is the 109 + * bio_clone() in bio bounce. 110 + * 111 + * If bio is splitted by this reason, we should have 112 + * allowed to continue bios merging, but don't do 113 + * that now for making the change simple. 114 + * 115 + * TODO: deal with bio bounce's bio_clone() gracefully 116 + * and convert the global limit into per-queue limit. 117 + */ 118 + if (bvecs++ >= BIO_MAX_PAGES) 119 + goto split; 120 + 99 121 /* 100 122 * If the queue doesn't support SG gaps and adding this 101 123 * offset would create a gap, disallow it. ··· 194 172 struct bio *split, *res; 195 173 unsigned nsegs; 196 174 197 - if (bio_op(*bio) == REQ_OP_DISCARD) 175 + switch (bio_op(*bio)) { 176 + case REQ_OP_DISCARD: 177 + case REQ_OP_SECURE_ERASE: 198 178 split = blk_bio_discard_split(q, *bio, bs, &nsegs); 199 - else if (bio_op(*bio) == REQ_OP_WRITE_SAME) 179 + break; 180 + case REQ_OP_WRITE_SAME: 200 181 split = blk_bio_write_same_split(q, *bio, bs, &nsegs); 201 - else 182 + break; 183 + default: 202 184 split = blk_bio_segment_split(q, *bio, q->bio_split, &nsegs); 185 + break; 186 + } 203 187 204 188 /* physical segments can be figured out during splitting */ 205 189 res = split ? split : *bio; ··· 241 213 * This should probably be returning 0, but blk_add_request_payload() 242 214 * (Christoph!!!!) 243 215 */ 244 - if (bio_op(bio) == REQ_OP_DISCARD) 216 + if (bio_op(bio) == REQ_OP_DISCARD || bio_op(bio) == REQ_OP_SECURE_ERASE) 245 217 return 1; 246 218 247 219 if (bio_op(bio) == REQ_OP_WRITE_SAME) ··· 413 385 nsegs = 0; 414 386 cluster = blk_queue_cluster(q); 415 387 416 - if (bio_op(bio) == REQ_OP_DISCARD) { 388 + switch (bio_op(bio)) { 389 + case REQ_OP_DISCARD: 390 + case REQ_OP_SECURE_ERASE: 417 391 /* 418 392 * This is a hack - drivers should be neither modifying the 419 393 * biovec, nor relying on bi_vcnt - but because of ··· 423 393 * a payload we need to set up here (thank you Christoph) and 424 394 * bi_vcnt is really the only way of telling if we need to. 425 395 */ 426 - 427 - if (bio->bi_vcnt) 428 - goto single_segment; 429 - 430 - return 0; 431 - } 432 - 433 - if (bio_op(bio) == REQ_OP_WRITE_SAME) { 434 - single_segment: 396 + if (!bio->bi_vcnt) 397 + return 0; 398 + /* Fall through */ 399 + case REQ_OP_WRITE_SAME: 435 400 *sg = sglist; 436 401 bvec = bio_iovec(bio); 437 402 sg_set_page(*sg, bvec.bv_page, bvec.bv_len, bvec.bv_offset); 438 403 return 1; 404 + default: 405 + break; 439 406 } 440 407 441 408 for_each_bio(bio)
+19 -41
block/blk-mq.c
··· 793 793 struct list_head *dptr; 794 794 int queued; 795 795 796 - WARN_ON(!cpumask_test_cpu(raw_smp_processor_id(), hctx->cpumask)); 797 - 798 796 if (unlikely(test_bit(BLK_MQ_S_STOPPED, &hctx->state))) 799 797 return; 798 + 799 + WARN_ON(!cpumask_test_cpu(raw_smp_processor_id(), hctx->cpumask) && 800 + cpu_online(hctx->next_cpu)); 800 801 801 802 hctx->run++; 802 803 ··· 1037 1036 EXPORT_SYMBOL(blk_mq_delay_queue); 1038 1037 1039 1038 static inline void __blk_mq_insert_req_list(struct blk_mq_hw_ctx *hctx, 1040 - struct blk_mq_ctx *ctx, 1041 1039 struct request *rq, 1042 1040 bool at_head) 1043 1041 { 1042 + struct blk_mq_ctx *ctx = rq->mq_ctx; 1043 + 1044 1044 trace_block_rq_insert(hctx->queue, rq); 1045 1045 1046 1046 if (at_head) ··· 1055 1053 { 1056 1054 struct blk_mq_ctx *ctx = rq->mq_ctx; 1057 1055 1058 - __blk_mq_insert_req_list(hctx, ctx, rq, at_head); 1056 + __blk_mq_insert_req_list(hctx, rq, at_head); 1059 1057 blk_mq_hctx_mark_pending(hctx, ctx); 1060 1058 } 1061 1059 1062 1060 void blk_mq_insert_request(struct request *rq, bool at_head, bool run_queue, 1063 - bool async) 1061 + bool async) 1064 1062 { 1063 + struct blk_mq_ctx *ctx = rq->mq_ctx; 1065 1064 struct request_queue *q = rq->q; 1066 1065 struct blk_mq_hw_ctx *hctx; 1067 - struct blk_mq_ctx *ctx = rq->mq_ctx, *current_ctx; 1068 - 1069 - current_ctx = blk_mq_get_ctx(q); 1070 - if (!cpu_online(ctx->cpu)) 1071 - rq->mq_ctx = ctx = current_ctx; 1072 1066 1073 1067 hctx = q->mq_ops->map_queue(q, ctx->cpu); 1074 1068 ··· 1074 1076 1075 1077 if (run_queue) 1076 1078 blk_mq_run_hw_queue(hctx, async); 1077 - 1078 - blk_mq_put_ctx(current_ctx); 1079 1079 } 1080 1080 1081 1081 static void blk_mq_insert_requests(struct request_queue *q, ··· 1084 1088 1085 1089 { 1086 1090 struct blk_mq_hw_ctx *hctx; 1087 - struct blk_mq_ctx *current_ctx; 1088 1091 1089 1092 trace_block_unplug(q, depth, !from_schedule); 1090 1093 1091 - current_ctx = blk_mq_get_ctx(q); 1092 - 1093 - if (!cpu_online(ctx->cpu)) 1094 - ctx = current_ctx; 1095 1094 hctx = q->mq_ops->map_queue(q, ctx->cpu); 1096 1095 1097 1096 /* ··· 1098 1107 struct request *rq; 1099 1108 1100 1109 rq = list_first_entry(list, struct request, queuelist); 1110 + BUG_ON(rq->mq_ctx != ctx); 1101 1111 list_del_init(&rq->queuelist); 1102 - rq->mq_ctx = ctx; 1103 - __blk_mq_insert_req_list(hctx, ctx, rq, false); 1112 + __blk_mq_insert_req_list(hctx, rq, false); 1104 1113 } 1105 1114 blk_mq_hctx_mark_pending(hctx, ctx); 1106 1115 spin_unlock(&ctx->lock); 1107 1116 1108 1117 blk_mq_run_hw_queue(hctx, from_schedule); 1109 - blk_mq_put_ctx(current_ctx); 1110 1118 } 1111 1119 1112 1120 static int plug_ctx_cmp(void *priv, struct list_head *a, struct list_head *b) ··· 1620 1630 return 0; 1621 1631 } 1622 1632 1633 + /* 1634 + * 'cpu' is going away. splice any existing rq_list entries from this 1635 + * software queue to the hw queue dispatch list, and ensure that it 1636 + * gets run. 1637 + */ 1623 1638 static int blk_mq_hctx_cpu_offline(struct blk_mq_hw_ctx *hctx, int cpu) 1624 1639 { 1625 - struct request_queue *q = hctx->queue; 1626 1640 struct blk_mq_ctx *ctx; 1627 1641 LIST_HEAD(tmp); 1628 1642 1629 - /* 1630 - * Move ctx entries to new CPU, if this one is going away. 1631 - */ 1632 - ctx = __blk_mq_get_ctx(q, cpu); 1643 + ctx = __blk_mq_get_ctx(hctx->queue, cpu); 1633 1644 1634 1645 spin_lock(&ctx->lock); 1635 1646 if (!list_empty(&ctx->rq_list)) { ··· 1642 1651 if (list_empty(&tmp)) 1643 1652 return NOTIFY_OK; 1644 1653 1645 - ctx = blk_mq_get_ctx(q); 1646 - spin_lock(&ctx->lock); 1647 - 1648 - while (!list_empty(&tmp)) { 1649 - struct request *rq; 1650 - 1651 - rq = list_first_entry(&tmp, struct request, queuelist); 1652 - rq->mq_ctx = ctx; 1653 - list_move_tail(&rq->queuelist, &ctx->rq_list); 1654 - } 1655 - 1656 - hctx = q->mq_ops->map_queue(q, ctx->cpu); 1657 - blk_mq_hctx_mark_pending(hctx, ctx); 1658 - 1659 - spin_unlock(&ctx->lock); 1654 + spin_lock(&hctx->lock); 1655 + list_splice_tail_init(&tmp, &hctx->dispatch); 1656 + spin_unlock(&hctx->lock); 1660 1657 1661 1658 blk_mq_run_hw_queue(hctx, true); 1662 - blk_mq_put_ctx(ctx); 1663 1659 return NOTIFY_OK; 1664 1660 } 1665 1661
+1 -1
block/elevator.c
··· 366 366 list_for_each_prev(entry, &q->queue_head) { 367 367 struct request *pos = list_entry_rq(entry); 368 368 369 - if ((req_op(rq) == REQ_OP_DISCARD) != (req_op(pos) == REQ_OP_DISCARD)) 369 + if (req_op(rq) != req_op(pos)) 370 370 break; 371 371 if (rq_data_dir(rq) != rq_data_dir(pos)) 372 372 break;
+13 -14
drivers/block/floppy.c
··· 3706 3706 if (UFDCS->rawcmd == 1) 3707 3707 UFDCS->rawcmd = 2; 3708 3708 3709 - if (mode & (FMODE_READ|FMODE_WRITE)) { 3710 - UDRS->last_checked = 0; 3711 - clear_bit(FD_OPEN_SHOULD_FAIL_BIT, &UDRS->flags); 3712 - check_disk_change(bdev); 3713 - if (test_bit(FD_DISK_CHANGED_BIT, &UDRS->flags)) 3714 - goto out; 3715 - if (test_bit(FD_OPEN_SHOULD_FAIL_BIT, &UDRS->flags)) 3709 + if (!(mode & FMODE_NDELAY)) { 3710 + if (mode & (FMODE_READ|FMODE_WRITE)) { 3711 + UDRS->last_checked = 0; 3712 + clear_bit(FD_OPEN_SHOULD_FAIL_BIT, &UDRS->flags); 3713 + check_disk_change(bdev); 3714 + if (test_bit(FD_DISK_CHANGED_BIT, &UDRS->flags)) 3715 + goto out; 3716 + if (test_bit(FD_OPEN_SHOULD_FAIL_BIT, &UDRS->flags)) 3717 + goto out; 3718 + } 3719 + res = -EROFS; 3720 + if ((mode & FMODE_WRITE) && 3721 + !test_bit(FD_DISK_WRITABLE_BIT, &UDRS->flags)) 3716 3722 goto out; 3717 3723 } 3718 - 3719 - res = -EROFS; 3720 - 3721 - if ((mode & FMODE_WRITE) && 3722 - !test_bit(FD_DISK_WRITABLE_BIT, &UDRS->flags)) 3723 - goto out; 3724 - 3725 3724 mutex_unlock(&open_lock); 3726 3725 mutex_unlock(&floppy_mutex); 3727 3726 return 0;
+56 -41
drivers/block/xen-blkfront.c
··· 189 189 struct mutex mutex; 190 190 struct xenbus_device *xbdev; 191 191 struct gendisk *gd; 192 + u16 sector_size; 193 + unsigned int physical_sector_size; 192 194 int vdevice; 193 195 blkif_vdev_t handle; 194 196 enum blkif_state connected; ··· 912 910 .map_queue = blk_mq_map_queue, 913 911 }; 914 912 913 + static void blkif_set_queue_limits(struct blkfront_info *info) 914 + { 915 + struct request_queue *rq = info->rq; 916 + struct gendisk *gd = info->gd; 917 + unsigned int segments = info->max_indirect_segments ? : 918 + BLKIF_MAX_SEGMENTS_PER_REQUEST; 919 + 920 + queue_flag_set_unlocked(QUEUE_FLAG_VIRT, rq); 921 + 922 + if (info->feature_discard) { 923 + queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, rq); 924 + blk_queue_max_discard_sectors(rq, get_capacity(gd)); 925 + rq->limits.discard_granularity = info->discard_granularity; 926 + rq->limits.discard_alignment = info->discard_alignment; 927 + if (info->feature_secdiscard) 928 + queue_flag_set_unlocked(QUEUE_FLAG_SECERASE, rq); 929 + } 930 + 931 + /* Hard sector size and max sectors impersonate the equiv. hardware. */ 932 + blk_queue_logical_block_size(rq, info->sector_size); 933 + blk_queue_physical_block_size(rq, info->physical_sector_size); 934 + blk_queue_max_hw_sectors(rq, (segments * XEN_PAGE_SIZE) / 512); 935 + 936 + /* Each segment in a request is up to an aligned page in size. */ 937 + blk_queue_segment_boundary(rq, PAGE_SIZE - 1); 938 + blk_queue_max_segment_size(rq, PAGE_SIZE); 939 + 940 + /* Ensure a merged request will fit in a single I/O ring slot. */ 941 + blk_queue_max_segments(rq, segments / GRANTS_PER_PSEG); 942 + 943 + /* Make sure buffer addresses are sector-aligned. */ 944 + blk_queue_dma_alignment(rq, 511); 945 + 946 + /* Make sure we don't use bounce buffers. */ 947 + blk_queue_bounce_limit(rq, BLK_BOUNCE_ANY); 948 + } 949 + 915 950 static int xlvbd_init_blk_queue(struct gendisk *gd, u16 sector_size, 916 - unsigned int physical_sector_size, 917 - unsigned int segments) 951 + unsigned int physical_sector_size) 918 952 { 919 953 struct request_queue *rq; 920 954 struct blkfront_info *info = gd->private_data; ··· 982 944 } 983 945 984 946 rq->queuedata = info; 985 - queue_flag_set_unlocked(QUEUE_FLAG_VIRT, rq); 986 - 987 - if (info->feature_discard) { 988 - queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, rq); 989 - blk_queue_max_discard_sectors(rq, get_capacity(gd)); 990 - rq->limits.discard_granularity = info->discard_granularity; 991 - rq->limits.discard_alignment = info->discard_alignment; 992 - if (info->feature_secdiscard) 993 - queue_flag_set_unlocked(QUEUE_FLAG_SECERASE, rq); 994 - } 995 - 996 - /* Hard sector size and max sectors impersonate the equiv. hardware. */ 997 - blk_queue_logical_block_size(rq, sector_size); 998 - blk_queue_physical_block_size(rq, physical_sector_size); 999 - blk_queue_max_hw_sectors(rq, (segments * XEN_PAGE_SIZE) / 512); 1000 - 1001 - /* Each segment in a request is up to an aligned page in size. */ 1002 - blk_queue_segment_boundary(rq, PAGE_SIZE - 1); 1003 - blk_queue_max_segment_size(rq, PAGE_SIZE); 1004 - 1005 - /* Ensure a merged request will fit in a single I/O ring slot. */ 1006 - blk_queue_max_segments(rq, segments / GRANTS_PER_PSEG); 1007 - 1008 - /* Make sure buffer addresses are sector-aligned. */ 1009 - blk_queue_dma_alignment(rq, 511); 1010 - 1011 - /* Make sure we don't use bounce buffers. */ 1012 - blk_queue_bounce_limit(rq, BLK_BOUNCE_ANY); 1013 - 1014 - gd->queue = rq; 947 + info->rq = gd->queue = rq; 948 + info->gd = gd; 949 + info->sector_size = sector_size; 950 + info->physical_sector_size = physical_sector_size; 951 + blkif_set_queue_limits(info); 1015 952 1016 953 return 0; 1017 954 } ··· 1149 1136 gd->private_data = info; 1150 1137 set_capacity(gd, capacity); 1151 1138 1152 - if (xlvbd_init_blk_queue(gd, sector_size, physical_sector_size, 1153 - info->max_indirect_segments ? : 1154 - BLKIF_MAX_SEGMENTS_PER_REQUEST)) { 1139 + if (xlvbd_init_blk_queue(gd, sector_size, physical_sector_size)) { 1155 1140 del_gendisk(gd); 1156 1141 goto release; 1157 1142 } 1158 - 1159 - info->rq = gd->queue; 1160 - info->gd = gd; 1161 1143 1162 1144 xlvbd_flush(info); 1163 1145 ··· 1323 1315 rinfo->ring_ref[i] = GRANT_INVALID_REF; 1324 1316 } 1325 1317 } 1326 - free_pages((unsigned long)rinfo->ring.sring, get_order(info->nr_ring_pages * PAGE_SIZE)); 1318 + free_pages((unsigned long)rinfo->ring.sring, get_order(info->nr_ring_pages * XEN_PAGE_SIZE)); 1327 1319 rinfo->ring.sring = NULL; 1328 1320 1329 1321 if (rinfo->irq) ··· 2015 2007 struct split_bio *split_bio; 2016 2008 2017 2009 blkfront_gather_backend_features(info); 2010 + /* Reset limits changed by blk_mq_update_nr_hw_queues(). */ 2011 + blkif_set_queue_limits(info); 2018 2012 segs = info->max_indirect_segments ? : BLKIF_MAX_SEGMENTS_PER_REQUEST; 2019 - blk_queue_max_segments(info->rq, segs); 2013 + blk_queue_max_segments(info->rq, segs / GRANTS_PER_PSEG); 2020 2014 2021 2015 for (r_index = 0; r_index < info->nr_rings; r_index++) { 2022 2016 struct blkfront_ring_info *rinfo = &info->rinfo[r_index]; ··· 2442 2432 if (err) { 2443 2433 xenbus_dev_fatal(info->xbdev, err, "xlvbd_add at %s", 2444 2434 info->xbdev->otherend); 2445 - return; 2435 + goto fail; 2446 2436 } 2447 2437 2448 2438 xenbus_switch_state(info->xbdev, XenbusStateConnected); ··· 2455 2445 device_add_disk(&info->xbdev->dev, info->gd); 2456 2446 2457 2447 info->is_ready = 1; 2448 + return; 2449 + 2450 + fail: 2451 + blkif_free(info, 0); 2452 + return; 2458 2453 } 2459 2454 2460 2455 /**
+10 -6
drivers/clocksource/bcm_kona_timer.c
··· 66 66 67 67 } 68 68 69 - static void 69 + static int 70 70 kona_timer_get_counter(void __iomem *timer_base, uint32_t *msw, uint32_t *lsw) 71 71 { 72 - int loop_limit = 4; 72 + int loop_limit = 3; 73 73 74 74 /* 75 75 * Read 64-bit free running counter ··· 83 83 * if new hi-word is equal to previously read hi-word then stop. 84 84 */ 85 85 86 - while (--loop_limit) { 86 + do { 87 87 *msw = readl(timer_base + KONA_GPTIMER_STCHI_OFFSET); 88 88 *lsw = readl(timer_base + KONA_GPTIMER_STCLO_OFFSET); 89 89 if (*msw == readl(timer_base + KONA_GPTIMER_STCHI_OFFSET)) 90 90 break; 91 - } 91 + } while (--loop_limit); 92 92 if (!loop_limit) { 93 93 pr_err("bcm_kona_timer: getting counter failed.\n"); 94 94 pr_err(" Timer will be impacted\n"); 95 + return -ETIMEDOUT; 95 96 } 96 97 97 - return; 98 + return 0; 98 99 } 99 100 100 101 static int kona_timer_set_next_event(unsigned long clc, ··· 113 112 114 113 uint32_t lsw, msw; 115 114 uint32_t reg; 115 + int ret; 116 116 117 - kona_timer_get_counter(timers.tmr_regs, &msw, &lsw); 117 + ret = kona_timer_get_counter(timers.tmr_regs, &msw, &lsw); 118 + if (ret) 119 + return ret; 118 120 119 121 /* Load the "next" event tick value */ 120 122 writel(lsw + clc, timers.tmr_regs + KONA_GPTIMER_STCM0_OFFSET);
+1 -1
drivers/clocksource/mips-gic-timer.c
··· 164 164 gic_start_count(); 165 165 } 166 166 167 - static void __init gic_clocksource_of_init(struct device_node *node) 167 + static int __init gic_clocksource_of_init(struct device_node *node) 168 168 { 169 169 struct clk *clk; 170 170 int ret;
+2
drivers/clocksource/pxa_timer.c
··· 21 21 #include <linux/of_irq.h> 22 22 #include <linux/sched_clock.h> 23 23 24 + #include <clocksource/pxa.h> 25 + 24 26 #include <asm/div64.h> 25 27 26 28 #define OSMR0 0x00 /* OS Timer 0 Match Register */
+8 -1
drivers/clocksource/sun4i_timer.c
··· 123 123 .set_next_event = sun4i_clkevt_next_event, 124 124 }; 125 125 126 + static void sun4i_timer_clear_interrupt(void) 127 + { 128 + writel(TIMER_IRQ_EN(0), timer_base + TIMER_IRQ_ST_REG); 129 + } 126 130 127 131 static irqreturn_t sun4i_timer_interrupt(int irq, void *dev_id) 128 132 { 129 133 struct clock_event_device *evt = (struct clock_event_device *)dev_id; 130 134 131 - writel(0x1, timer_base + TIMER_IRQ_ST_REG); 135 + sun4i_timer_clear_interrupt(); 132 136 evt->event_handler(evt); 133 137 134 138 return IRQ_HANDLED; ··· 211 207 212 208 /* Make sure timer is stopped before playing with interrupts */ 213 209 sun4i_clkevt_time_stop(0); 210 + 211 + /* clear timer0 interrupt */ 212 + sun4i_timer_clear_interrupt(); 214 213 215 214 sun4i_clockevent.cpumask = cpu_possible_mask; 216 215 sun4i_clockevent.irq = irq;
-1
drivers/clocksource/time-armada-370-xp.c
··· 338 338 struct clk *clk = of_clk_get_by_name(np, "fixed"); 339 339 int ret; 340 340 341 - clk = of_clk_get(np, 0); 342 341 if (IS_ERR(clk)) { 343 342 pr_err("Failed to get clock"); 344 343 return PTR_ERR(clk);
+4 -4
drivers/clocksource/time-pistachio.c
··· 202 202 rate = clk_get_rate(fast_clk); 203 203 204 204 /* Disable irq's for clocksource usage */ 205 - gpt_writel(&pcs_gpt.base, 0, TIMER_IRQ_MASK, 0); 206 - gpt_writel(&pcs_gpt.base, 0, TIMER_IRQ_MASK, 1); 207 - gpt_writel(&pcs_gpt.base, 0, TIMER_IRQ_MASK, 2); 208 - gpt_writel(&pcs_gpt.base, 0, TIMER_IRQ_MASK, 3); 205 + gpt_writel(pcs_gpt.base, 0, TIMER_IRQ_MASK, 0); 206 + gpt_writel(pcs_gpt.base, 0, TIMER_IRQ_MASK, 1); 207 + gpt_writel(pcs_gpt.base, 0, TIMER_IRQ_MASK, 2); 208 + gpt_writel(pcs_gpt.base, 0, TIMER_IRQ_MASK, 3); 209 209 210 210 /* Enable timer block */ 211 211 writel(TIMER_ME_GLOBAL, pcs_gpt.base);
+6
drivers/clocksource/timer-atmel-pit.c
··· 261 261 return PTR_ERR(data->mck); 262 262 } 263 263 264 + ret = clk_prepare_enable(data->mck); 265 + if (ret) { 266 + pr_err("Unable to enable mck\n"); 267 + return ret; 268 + } 269 + 264 270 /* Get the interrupts property */ 265 271 data->irq = irq_of_parse_and_map(node, 0); 266 272 if (!data->irq) {
+3
drivers/dax/pmem.c
··· 116 116 if (rc) 117 117 return rc; 118 118 119 + /* adjust the dax_region resource to the start of data */ 120 + res.start += le64_to_cpu(pfn_sb->dataoff); 121 + 119 122 nd_region = to_nd_region(dev->parent); 120 123 dax_region = alloc_dax_region(dev, nd_region->id, &res, 121 124 le32_to_cpu(pfn_sb->align), addr, PFN_DEV|PFN_MAP);
+8
drivers/edac/Kconfig
··· 251 251 Support for error detection and correction the Intel 252 252 Sandy Bridge, Ivy Bridge and Haswell Integrated Memory Controllers. 253 253 254 + config EDAC_SKX 255 + tristate "Intel Skylake server Integrated MC" 256 + depends on EDAC_MM_EDAC && PCI && X86_64 && X86_MCE_INTEL 257 + depends on PCI_MMCONFIG 258 + help 259 + Support for error detection and correction the Intel 260 + Skylake server Integrated Memory Controllers. 261 + 254 262 config EDAC_MPC85XX 255 263 tristate "Freescale MPC83xx / MPC85xx" 256 264 depends on EDAC_MM_EDAC && FSL_SOC
+1
drivers/edac/Makefile
··· 31 31 obj-$(CONFIG_EDAC_I7300) += i7300_edac.o 32 32 obj-$(CONFIG_EDAC_I7CORE) += i7core_edac.o 33 33 obj-$(CONFIG_EDAC_SBRIDGE) += sb_edac.o 34 + obj-$(CONFIG_EDAC_SKX) += skx_edac.o 34 35 obj-$(CONFIG_EDAC_E7XXX) += e7xxx_edac.o 35 36 obj-$(CONFIG_EDAC_E752X) += e752x_edac.o 36 37 obj-$(CONFIG_EDAC_I82443BXGX) += i82443bxgx_edac.o
+1121
drivers/edac/skx_edac.c
··· 1 + /* 2 + * EDAC driver for Intel(R) Xeon(R) Skylake processors 3 + * Copyright (c) 2016, Intel Corporation. 4 + * 5 + * This program is free software; you can redistribute it and/or modify it 6 + * under the terms and conditions of the GNU General Public License, 7 + * version 2, as published by the Free Software Foundation. 8 + * 9 + * This program is distributed in the hope it will be useful, but WITHOUT 10 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 + * more details. 13 + */ 14 + 15 + #include <linux/module.h> 16 + #include <linux/init.h> 17 + #include <linux/pci.h> 18 + #include <linux/pci_ids.h> 19 + #include <linux/slab.h> 20 + #include <linux/delay.h> 21 + #include <linux/edac.h> 22 + #include <linux/mmzone.h> 23 + #include <linux/smp.h> 24 + #include <linux/bitmap.h> 25 + #include <linux/math64.h> 26 + #include <linux/mod_devicetable.h> 27 + #include <asm/cpu_device_id.h> 28 + #include <asm/processor.h> 29 + #include <asm/mce.h> 30 + 31 + #include "edac_core.h" 32 + 33 + #define SKX_REVISION " Ver: 1.0 " 34 + 35 + /* 36 + * Debug macros 37 + */ 38 + #define skx_printk(level, fmt, arg...) \ 39 + edac_printk(level, "skx", fmt, ##arg) 40 + 41 + #define skx_mc_printk(mci, level, fmt, arg...) \ 42 + edac_mc_chipset_printk(mci, level, "skx", fmt, ##arg) 43 + 44 + /* 45 + * Get a bit field at register value <v>, from bit <lo> to bit <hi> 46 + */ 47 + #define GET_BITFIELD(v, lo, hi) \ 48 + (((v) & GENMASK_ULL((hi), (lo))) >> (lo)) 49 + 50 + static LIST_HEAD(skx_edac_list); 51 + 52 + static u64 skx_tolm, skx_tohm; 53 + 54 + #define NUM_IMC 2 /* memory controllers per socket */ 55 + #define NUM_CHANNELS 3 /* channels per memory controller */ 56 + #define NUM_DIMMS 2 /* Max DIMMS per channel */ 57 + 58 + #define MASK26 0x3FFFFFF /* Mask for 2^26 */ 59 + #define MASK29 0x1FFFFFFF /* Mask for 2^29 */ 60 + 61 + /* 62 + * Each cpu socket contains some pci devices that provide global 63 + * information, and also some that are local to each of the two 64 + * memory controllers on the die. 65 + */ 66 + struct skx_dev { 67 + struct list_head list; 68 + u8 bus[4]; 69 + struct pci_dev *sad_all; 70 + struct pci_dev *util_all; 71 + u32 mcroute; 72 + struct skx_imc { 73 + struct mem_ctl_info *mci; 74 + u8 mc; /* system wide mc# */ 75 + u8 lmc; /* socket relative mc# */ 76 + u8 src_id, node_id; 77 + struct skx_channel { 78 + struct pci_dev *cdev; 79 + struct skx_dimm { 80 + u8 close_pg; 81 + u8 bank_xor_enable; 82 + u8 fine_grain_bank; 83 + u8 rowbits; 84 + u8 colbits; 85 + } dimms[NUM_DIMMS]; 86 + } chan[NUM_CHANNELS]; 87 + } imc[NUM_IMC]; 88 + }; 89 + static int skx_num_sockets; 90 + 91 + struct skx_pvt { 92 + struct skx_imc *imc; 93 + }; 94 + 95 + struct decoded_addr { 96 + struct skx_dev *dev; 97 + u64 addr; 98 + int socket; 99 + int imc; 100 + int channel; 101 + u64 chan_addr; 102 + int sktways; 103 + int chanways; 104 + int dimm; 105 + int rank; 106 + int channel_rank; 107 + u64 rank_address; 108 + int row; 109 + int column; 110 + int bank_address; 111 + int bank_group; 112 + }; 113 + 114 + static struct skx_dev *get_skx_dev(u8 bus, u8 idx) 115 + { 116 + struct skx_dev *d; 117 + 118 + list_for_each_entry(d, &skx_edac_list, list) { 119 + if (d->bus[idx] == bus) 120 + return d; 121 + } 122 + 123 + return NULL; 124 + } 125 + 126 + enum munittype { 127 + CHAN0, CHAN1, CHAN2, SAD_ALL, UTIL_ALL, SAD 128 + }; 129 + 130 + struct munit { 131 + u16 did; 132 + u16 devfn[NUM_IMC]; 133 + u8 busidx; 134 + u8 per_socket; 135 + enum munittype mtype; 136 + }; 137 + 138 + /* 139 + * List of PCI device ids that we need together with some device 140 + * number and function numbers to tell which memory controller the 141 + * device belongs to. 142 + */ 143 + static const struct munit skx_all_munits[] = { 144 + { 0x2054, { }, 1, 1, SAD_ALL }, 145 + { 0x2055, { }, 1, 1, UTIL_ALL }, 146 + { 0x2040, { PCI_DEVFN(10, 0), PCI_DEVFN(12, 0) }, 2, 2, CHAN0 }, 147 + { 0x2044, { PCI_DEVFN(10, 4), PCI_DEVFN(12, 4) }, 2, 2, CHAN1 }, 148 + { 0x2048, { PCI_DEVFN(11, 0), PCI_DEVFN(13, 0) }, 2, 2, CHAN2 }, 149 + { 0x208e, { }, 1, 0, SAD }, 150 + { } 151 + }; 152 + 153 + /* 154 + * We use the per-socket device 0x2016 to count how many sockets are present, 155 + * and to detemine which PCI buses are associated with each socket. Allocate 156 + * and build the full list of all the skx_dev structures that we need here. 157 + */ 158 + static int get_all_bus_mappings(void) 159 + { 160 + struct pci_dev *pdev, *prev; 161 + struct skx_dev *d; 162 + u32 reg; 163 + int ndev = 0; 164 + 165 + prev = NULL; 166 + for (;;) { 167 + pdev = pci_get_device(PCI_VENDOR_ID_INTEL, 0x2016, prev); 168 + if (!pdev) 169 + break; 170 + ndev++; 171 + d = kzalloc(sizeof(*d), GFP_KERNEL); 172 + if (!d) { 173 + pci_dev_put(pdev); 174 + return -ENOMEM; 175 + } 176 + pci_read_config_dword(pdev, 0xCC, &reg); 177 + d->bus[0] = GET_BITFIELD(reg, 0, 7); 178 + d->bus[1] = GET_BITFIELD(reg, 8, 15); 179 + d->bus[2] = GET_BITFIELD(reg, 16, 23); 180 + d->bus[3] = GET_BITFIELD(reg, 24, 31); 181 + edac_dbg(2, "busses: %x, %x, %x, %x\n", 182 + d->bus[0], d->bus[1], d->bus[2], d->bus[3]); 183 + list_add_tail(&d->list, &skx_edac_list); 184 + skx_num_sockets++; 185 + prev = pdev; 186 + } 187 + 188 + return ndev; 189 + } 190 + 191 + static int get_all_munits(const struct munit *m) 192 + { 193 + struct pci_dev *pdev, *prev; 194 + struct skx_dev *d; 195 + u32 reg; 196 + int i = 0, ndev = 0; 197 + 198 + prev = NULL; 199 + for (;;) { 200 + pdev = pci_get_device(PCI_VENDOR_ID_INTEL, m->did, prev); 201 + if (!pdev) 202 + break; 203 + ndev++; 204 + if (m->per_socket == NUM_IMC) { 205 + for (i = 0; i < NUM_IMC; i++) 206 + if (m->devfn[i] == pdev->devfn) 207 + break; 208 + if (i == NUM_IMC) 209 + goto fail; 210 + } 211 + d = get_skx_dev(pdev->bus->number, m->busidx); 212 + if (!d) 213 + goto fail; 214 + 215 + /* Be sure that the device is enabled */ 216 + if (unlikely(pci_enable_device(pdev) < 0)) { 217 + skx_printk(KERN_ERR, 218 + "Couldn't enable %04x:%04x\n", PCI_VENDOR_ID_INTEL, m->did); 219 + goto fail; 220 + } 221 + 222 + switch (m->mtype) { 223 + case CHAN0: case CHAN1: case CHAN2: 224 + pci_dev_get(pdev); 225 + d->imc[i].chan[m->mtype].cdev = pdev; 226 + break; 227 + case SAD_ALL: 228 + pci_dev_get(pdev); 229 + d->sad_all = pdev; 230 + break; 231 + case UTIL_ALL: 232 + pci_dev_get(pdev); 233 + d->util_all = pdev; 234 + break; 235 + case SAD: 236 + /* 237 + * one of these devices per core, including cores 238 + * that don't exist on this SKU. Ignore any that 239 + * read a route table of zero, make sure all the 240 + * non-zero values match. 241 + */ 242 + pci_read_config_dword(pdev, 0xB4, &reg); 243 + if (reg != 0) { 244 + if (d->mcroute == 0) 245 + d->mcroute = reg; 246 + else if (d->mcroute != reg) { 247 + skx_printk(KERN_ERR, 248 + "mcroute mismatch\n"); 249 + goto fail; 250 + } 251 + } 252 + ndev--; 253 + break; 254 + } 255 + 256 + prev = pdev; 257 + } 258 + 259 + return ndev; 260 + fail: 261 + pci_dev_put(pdev); 262 + return -ENODEV; 263 + } 264 + 265 + const struct x86_cpu_id skx_cpuids[] = { 266 + { X86_VENDOR_INTEL, 6, 0x55, 0, 0 }, /* Skylake */ 267 + { } 268 + }; 269 + MODULE_DEVICE_TABLE(x86cpu, skx_cpuids); 270 + 271 + static u8 get_src_id(struct skx_dev *d) 272 + { 273 + u32 reg; 274 + 275 + pci_read_config_dword(d->util_all, 0xF0, &reg); 276 + 277 + return GET_BITFIELD(reg, 12, 14); 278 + } 279 + 280 + static u8 skx_get_node_id(struct skx_dev *d) 281 + { 282 + u32 reg; 283 + 284 + pci_read_config_dword(d->util_all, 0xF4, &reg); 285 + 286 + return GET_BITFIELD(reg, 0, 2); 287 + } 288 + 289 + static int get_dimm_attr(u32 reg, int lobit, int hibit, int add, int minval, 290 + int maxval, char *name) 291 + { 292 + u32 val = GET_BITFIELD(reg, lobit, hibit); 293 + 294 + if (val < minval || val > maxval) { 295 + edac_dbg(2, "bad %s = %d (raw=%x)\n", name, val, reg); 296 + return -EINVAL; 297 + } 298 + return val + add; 299 + } 300 + 301 + #define IS_DIMM_PRESENT(mtr) GET_BITFIELD((mtr), 15, 15) 302 + 303 + #define numrank(reg) get_dimm_attr((reg), 12, 13, 0, 1, 2, "ranks") 304 + #define numrow(reg) get_dimm_attr((reg), 2, 4, 12, 1, 6, "rows") 305 + #define numcol(reg) get_dimm_attr((reg), 0, 1, 10, 0, 2, "cols") 306 + 307 + static int get_width(u32 mtr) 308 + { 309 + switch (GET_BITFIELD(mtr, 8, 9)) { 310 + case 0: 311 + return DEV_X4; 312 + case 1: 313 + return DEV_X8; 314 + case 2: 315 + return DEV_X16; 316 + } 317 + return DEV_UNKNOWN; 318 + } 319 + 320 + static int skx_get_hi_lo(void) 321 + { 322 + struct pci_dev *pdev; 323 + u32 reg; 324 + 325 + pdev = pci_get_device(PCI_VENDOR_ID_INTEL, 0x2034, NULL); 326 + if (!pdev) { 327 + edac_dbg(0, "Can't get tolm/tohm\n"); 328 + return -ENODEV; 329 + } 330 + 331 + pci_read_config_dword(pdev, 0xD0, &reg); 332 + skx_tolm = reg; 333 + pci_read_config_dword(pdev, 0xD4, &reg); 334 + skx_tohm = reg; 335 + pci_read_config_dword(pdev, 0xD8, &reg); 336 + skx_tohm |= (u64)reg << 32; 337 + 338 + pci_dev_put(pdev); 339 + edac_dbg(2, "tolm=%llx tohm=%llx\n", skx_tolm, skx_tohm); 340 + 341 + return 0; 342 + } 343 + 344 + static int get_dimm_info(u32 mtr, u32 amap, struct dimm_info *dimm, 345 + struct skx_imc *imc, int chan, int dimmno) 346 + { 347 + int banks = 16, ranks, rows, cols, npages; 348 + u64 size; 349 + 350 + if (!IS_DIMM_PRESENT(mtr)) 351 + return 0; 352 + ranks = numrank(mtr); 353 + rows = numrow(mtr); 354 + cols = numcol(mtr); 355 + 356 + /* 357 + * Compute size in 8-byte (2^3) words, then shift to MiB (2^20) 358 + */ 359 + size = ((1ull << (rows + cols + ranks)) * banks) >> (20 - 3); 360 + npages = MiB_TO_PAGES(size); 361 + 362 + edac_dbg(0, "mc#%d: channel %d, dimm %d, %lld Mb (%d pages) bank: %d, rank: %d, row: %#x, col: %#x\n", 363 + imc->mc, chan, dimmno, size, npages, 364 + banks, ranks, rows, cols); 365 + 366 + imc->chan[chan].dimms[dimmno].close_pg = GET_BITFIELD(mtr, 0, 0); 367 + imc->chan[chan].dimms[dimmno].bank_xor_enable = GET_BITFIELD(mtr, 9, 9); 368 + imc->chan[chan].dimms[dimmno].fine_grain_bank = GET_BITFIELD(amap, 0, 0); 369 + imc->chan[chan].dimms[dimmno].rowbits = rows; 370 + imc->chan[chan].dimms[dimmno].colbits = cols; 371 + 372 + dimm->nr_pages = npages; 373 + dimm->grain = 32; 374 + dimm->dtype = get_width(mtr); 375 + dimm->mtype = MEM_DDR4; 376 + dimm->edac_mode = EDAC_SECDED; /* likely better than this */ 377 + snprintf(dimm->label, sizeof(dimm->label), "CPU_SrcID#%u_MC#%u_Chan#%u_DIMM#%u", 378 + imc->src_id, imc->lmc, chan, dimmno); 379 + 380 + return 1; 381 + } 382 + 383 + #define SKX_GET_MTMTR(dev, reg) \ 384 + pci_read_config_dword((dev), 0x87c, &reg) 385 + 386 + static bool skx_check_ecc(struct pci_dev *pdev) 387 + { 388 + u32 mtmtr; 389 + 390 + SKX_GET_MTMTR(pdev, mtmtr); 391 + 392 + return !!GET_BITFIELD(mtmtr, 2, 2); 393 + } 394 + 395 + static int skx_get_dimm_config(struct mem_ctl_info *mci) 396 + { 397 + struct skx_pvt *pvt = mci->pvt_info; 398 + struct skx_imc *imc = pvt->imc; 399 + struct dimm_info *dimm; 400 + int i, j; 401 + u32 mtr, amap; 402 + int ndimms; 403 + 404 + for (i = 0; i < NUM_CHANNELS; i++) { 405 + ndimms = 0; 406 + pci_read_config_dword(imc->chan[i].cdev, 0x8C, &amap); 407 + for (j = 0; j < NUM_DIMMS; j++) { 408 + dimm = EDAC_DIMM_PTR(mci->layers, mci->dimms, 409 + mci->n_layers, i, j, 0); 410 + pci_read_config_dword(imc->chan[i].cdev, 411 + 0x80 + 4*j, &mtr); 412 + ndimms += get_dimm_info(mtr, amap, dimm, imc, i, j); 413 + } 414 + if (ndimms && !skx_check_ecc(imc->chan[0].cdev)) { 415 + skx_printk(KERN_ERR, "ECC is disabled on imc %d\n", imc->mc); 416 + return -ENODEV; 417 + } 418 + } 419 + 420 + return 0; 421 + } 422 + 423 + static void skx_unregister_mci(struct skx_imc *imc) 424 + { 425 + struct mem_ctl_info *mci = imc->mci; 426 + 427 + if (!mci) 428 + return; 429 + 430 + edac_dbg(0, "MC%d: mci = %p\n", imc->mc, mci); 431 + 432 + /* Remove MC sysfs nodes */ 433 + edac_mc_del_mc(mci->pdev); 434 + 435 + edac_dbg(1, "%s: free mci struct\n", mci->ctl_name); 436 + kfree(mci->ctl_name); 437 + edac_mc_free(mci); 438 + } 439 + 440 + static int skx_register_mci(struct skx_imc *imc) 441 + { 442 + struct mem_ctl_info *mci; 443 + struct edac_mc_layer layers[2]; 444 + struct pci_dev *pdev = imc->chan[0].cdev; 445 + struct skx_pvt *pvt; 446 + int rc; 447 + 448 + /* allocate a new MC control structure */ 449 + layers[0].type = EDAC_MC_LAYER_CHANNEL; 450 + layers[0].size = NUM_CHANNELS; 451 + layers[0].is_virt_csrow = false; 452 + layers[1].type = EDAC_MC_LAYER_SLOT; 453 + layers[1].size = NUM_DIMMS; 454 + layers[1].is_virt_csrow = true; 455 + mci = edac_mc_alloc(imc->mc, ARRAY_SIZE(layers), layers, 456 + sizeof(struct skx_pvt)); 457 + 458 + if (unlikely(!mci)) 459 + return -ENOMEM; 460 + 461 + edac_dbg(0, "MC#%d: mci = %p\n", imc->mc, mci); 462 + 463 + /* Associate skx_dev and mci for future usage */ 464 + imc->mci = mci; 465 + pvt = mci->pvt_info; 466 + pvt->imc = imc; 467 + 468 + mci->ctl_name = kasprintf(GFP_KERNEL, "Skylake Socket#%d IMC#%d", 469 + imc->node_id, imc->lmc); 470 + mci->mtype_cap = MEM_FLAG_DDR4; 471 + mci->edac_ctl_cap = EDAC_FLAG_NONE; 472 + mci->edac_cap = EDAC_FLAG_NONE; 473 + mci->mod_name = "skx_edac.c"; 474 + mci->dev_name = pci_name(imc->chan[0].cdev); 475 + mci->mod_ver = SKX_REVISION; 476 + mci->ctl_page_to_phys = NULL; 477 + 478 + rc = skx_get_dimm_config(mci); 479 + if (rc < 0) 480 + goto fail; 481 + 482 + /* record ptr to the generic device */ 483 + mci->pdev = &pdev->dev; 484 + 485 + /* add this new MC control structure to EDAC's list of MCs */ 486 + if (unlikely(edac_mc_add_mc(mci))) { 487 + edac_dbg(0, "MC: failed edac_mc_add_mc()\n"); 488 + rc = -EINVAL; 489 + goto fail; 490 + } 491 + 492 + return 0; 493 + 494 + fail: 495 + kfree(mci->ctl_name); 496 + edac_mc_free(mci); 497 + imc->mci = NULL; 498 + return rc; 499 + } 500 + 501 + #define SKX_MAX_SAD 24 502 + 503 + #define SKX_GET_SAD(d, i, reg) \ 504 + pci_read_config_dword((d)->sad_all, 0x60 + 8 * (i), &reg) 505 + #define SKX_GET_ILV(d, i, reg) \ 506 + pci_read_config_dword((d)->sad_all, 0x64 + 8 * (i), &reg) 507 + 508 + #define SKX_SAD_MOD3MODE(sad) GET_BITFIELD((sad), 30, 31) 509 + #define SKX_SAD_MOD3(sad) GET_BITFIELD((sad), 27, 27) 510 + #define SKX_SAD_LIMIT(sad) (((u64)GET_BITFIELD((sad), 7, 26) << 26) | MASK26) 511 + #define SKX_SAD_MOD3ASMOD2(sad) GET_BITFIELD((sad), 5, 6) 512 + #define SKX_SAD_ATTR(sad) GET_BITFIELD((sad), 3, 4) 513 + #define SKX_SAD_INTERLEAVE(sad) GET_BITFIELD((sad), 1, 2) 514 + #define SKX_SAD_ENABLE(sad) GET_BITFIELD((sad), 0, 0) 515 + 516 + #define SKX_ILV_REMOTE(tgt) (((tgt) & 8) == 0) 517 + #define SKX_ILV_TARGET(tgt) ((tgt) & 7) 518 + 519 + static bool skx_sad_decode(struct decoded_addr *res) 520 + { 521 + struct skx_dev *d = list_first_entry(&skx_edac_list, typeof(*d), list); 522 + u64 addr = res->addr; 523 + int i, idx, tgt, lchan, shift; 524 + u32 sad, ilv; 525 + u64 limit, prev_limit; 526 + int remote = 0; 527 + 528 + /* Simple sanity check for I/O space or out of range */ 529 + if (addr >= skx_tohm || (addr >= skx_tolm && addr < BIT_ULL(32))) { 530 + edac_dbg(0, "Address %llx out of range\n", addr); 531 + return false; 532 + } 533 + 534 + restart: 535 + prev_limit = 0; 536 + for (i = 0; i < SKX_MAX_SAD; i++) { 537 + SKX_GET_SAD(d, i, sad); 538 + limit = SKX_SAD_LIMIT(sad); 539 + if (SKX_SAD_ENABLE(sad)) { 540 + if (addr >= prev_limit && addr <= limit) 541 + goto sad_found; 542 + } 543 + prev_limit = limit + 1; 544 + } 545 + edac_dbg(0, "No SAD entry for %llx\n", addr); 546 + return false; 547 + 548 + sad_found: 549 + SKX_GET_ILV(d, i, ilv); 550 + 551 + switch (SKX_SAD_INTERLEAVE(sad)) { 552 + case 0: 553 + idx = GET_BITFIELD(addr, 6, 8); 554 + break; 555 + case 1: 556 + idx = GET_BITFIELD(addr, 8, 10); 557 + break; 558 + case 2: 559 + idx = GET_BITFIELD(addr, 12, 14); 560 + break; 561 + case 3: 562 + idx = GET_BITFIELD(addr, 30, 32); 563 + break; 564 + } 565 + 566 + tgt = GET_BITFIELD(ilv, 4 * idx, 4 * idx + 3); 567 + 568 + /* If point to another node, find it and start over */ 569 + if (SKX_ILV_REMOTE(tgt)) { 570 + if (remote) { 571 + edac_dbg(0, "Double remote!\n"); 572 + return false; 573 + } 574 + remote = 1; 575 + list_for_each_entry(d, &skx_edac_list, list) { 576 + if (d->imc[0].src_id == SKX_ILV_TARGET(tgt)) 577 + goto restart; 578 + } 579 + edac_dbg(0, "Can't find node %d\n", SKX_ILV_TARGET(tgt)); 580 + return false; 581 + } 582 + 583 + if (SKX_SAD_MOD3(sad) == 0) 584 + lchan = SKX_ILV_TARGET(tgt); 585 + else { 586 + switch (SKX_SAD_MOD3MODE(sad)) { 587 + case 0: 588 + shift = 6; 589 + break; 590 + case 1: 591 + shift = 8; 592 + break; 593 + case 2: 594 + shift = 12; 595 + break; 596 + default: 597 + edac_dbg(0, "illegal mod3mode\n"); 598 + return false; 599 + } 600 + switch (SKX_SAD_MOD3ASMOD2(sad)) { 601 + case 0: 602 + lchan = (addr >> shift) % 3; 603 + break; 604 + case 1: 605 + lchan = (addr >> shift) % 2; 606 + break; 607 + case 2: 608 + lchan = (addr >> shift) % 2; 609 + lchan = (lchan << 1) | ~lchan; 610 + break; 611 + case 3: 612 + lchan = ((addr >> shift) % 2) << 1; 613 + break; 614 + } 615 + lchan = (lchan << 1) | (SKX_ILV_TARGET(tgt) & 1); 616 + } 617 + 618 + res->dev = d; 619 + res->socket = d->imc[0].src_id; 620 + res->imc = GET_BITFIELD(d->mcroute, lchan * 3, lchan * 3 + 2); 621 + res->channel = GET_BITFIELD(d->mcroute, lchan * 2 + 18, lchan * 2 + 19); 622 + 623 + edac_dbg(2, "%llx: socket=%d imc=%d channel=%d\n", 624 + res->addr, res->socket, res->imc, res->channel); 625 + return true; 626 + } 627 + 628 + #define SKX_MAX_TAD 8 629 + 630 + #define SKX_GET_TADBASE(d, mc, i, reg) \ 631 + pci_read_config_dword((d)->imc[mc].chan[0].cdev, 0x850 + 4 * (i), &reg) 632 + #define SKX_GET_TADWAYNESS(d, mc, i, reg) \ 633 + pci_read_config_dword((d)->imc[mc].chan[0].cdev, 0x880 + 4 * (i), &reg) 634 + #define SKX_GET_TADCHNILVOFFSET(d, mc, ch, i, reg) \ 635 + pci_read_config_dword((d)->imc[mc].chan[ch].cdev, 0x90 + 4 * (i), &reg) 636 + 637 + #define SKX_TAD_BASE(b) ((u64)GET_BITFIELD((b), 12, 31) << 26) 638 + #define SKX_TAD_SKT_GRAN(b) GET_BITFIELD((b), 4, 5) 639 + #define SKX_TAD_CHN_GRAN(b) GET_BITFIELD((b), 6, 7) 640 + #define SKX_TAD_LIMIT(b) (((u64)GET_BITFIELD((b), 12, 31) << 26) | MASK26) 641 + #define SKX_TAD_OFFSET(b) ((u64)GET_BITFIELD((b), 4, 23) << 26) 642 + #define SKX_TAD_SKTWAYS(b) (1 << GET_BITFIELD((b), 10, 11)) 643 + #define SKX_TAD_CHNWAYS(b) (GET_BITFIELD((b), 8, 9) + 1) 644 + 645 + /* which bit used for both socket and channel interleave */ 646 + static int skx_granularity[] = { 6, 8, 12, 30 }; 647 + 648 + static u64 skx_do_interleave(u64 addr, int shift, int ways, u64 lowbits) 649 + { 650 + addr >>= shift; 651 + addr /= ways; 652 + addr <<= shift; 653 + 654 + return addr | (lowbits & ((1ull << shift) - 1)); 655 + } 656 + 657 + static bool skx_tad_decode(struct decoded_addr *res) 658 + { 659 + int i; 660 + u32 base, wayness, chnilvoffset; 661 + int skt_interleave_bit, chn_interleave_bit; 662 + u64 channel_addr; 663 + 664 + for (i = 0; i < SKX_MAX_TAD; i++) { 665 + SKX_GET_TADBASE(res->dev, res->imc, i, base); 666 + SKX_GET_TADWAYNESS(res->dev, res->imc, i, wayness); 667 + if (SKX_TAD_BASE(base) <= res->addr && res->addr <= SKX_TAD_LIMIT(wayness)) 668 + goto tad_found; 669 + } 670 + edac_dbg(0, "No TAD entry for %llx\n", res->addr); 671 + return false; 672 + 673 + tad_found: 674 + res->sktways = SKX_TAD_SKTWAYS(wayness); 675 + res->chanways = SKX_TAD_CHNWAYS(wayness); 676 + skt_interleave_bit = skx_granularity[SKX_TAD_SKT_GRAN(base)]; 677 + chn_interleave_bit = skx_granularity[SKX_TAD_CHN_GRAN(base)]; 678 + 679 + SKX_GET_TADCHNILVOFFSET(res->dev, res->imc, res->channel, i, chnilvoffset); 680 + channel_addr = res->addr - SKX_TAD_OFFSET(chnilvoffset); 681 + 682 + if (res->chanways == 3 && skt_interleave_bit > chn_interleave_bit) { 683 + /* Must handle channel first, then socket */ 684 + channel_addr = skx_do_interleave(channel_addr, chn_interleave_bit, 685 + res->chanways, channel_addr); 686 + channel_addr = skx_do_interleave(channel_addr, skt_interleave_bit, 687 + res->sktways, channel_addr); 688 + } else { 689 + /* Handle socket then channel. Preserve low bits from original address */ 690 + channel_addr = skx_do_interleave(channel_addr, skt_interleave_bit, 691 + res->sktways, res->addr); 692 + channel_addr = skx_do_interleave(channel_addr, chn_interleave_bit, 693 + res->chanways, res->addr); 694 + } 695 + 696 + res->chan_addr = channel_addr; 697 + 698 + edac_dbg(2, "%llx: chan_addr=%llx sktways=%d chanways=%d\n", 699 + res->addr, res->chan_addr, res->sktways, res->chanways); 700 + return true; 701 + } 702 + 703 + #define SKX_MAX_RIR 4 704 + 705 + #define SKX_GET_RIRWAYNESS(d, mc, ch, i, reg) \ 706 + pci_read_config_dword((d)->imc[mc].chan[ch].cdev, \ 707 + 0x108 + 4 * (i), &reg) 708 + #define SKX_GET_RIRILV(d, mc, ch, idx, i, reg) \ 709 + pci_read_config_dword((d)->imc[mc].chan[ch].cdev, \ 710 + 0x120 + 16 * idx + 4 * (i), &reg) 711 + 712 + #define SKX_RIR_VALID(b) GET_BITFIELD((b), 31, 31) 713 + #define SKX_RIR_LIMIT(b) (((u64)GET_BITFIELD((b), 1, 11) << 29) | MASK29) 714 + #define SKX_RIR_WAYS(b) (1 << GET_BITFIELD((b), 28, 29)) 715 + #define SKX_RIR_CHAN_RANK(b) GET_BITFIELD((b), 16, 19) 716 + #define SKX_RIR_OFFSET(b) ((u64)(GET_BITFIELD((b), 2, 15) << 26)) 717 + 718 + static bool skx_rir_decode(struct decoded_addr *res) 719 + { 720 + int i, idx, chan_rank; 721 + int shift; 722 + u32 rirway, rirlv; 723 + u64 rank_addr, prev_limit = 0, limit; 724 + 725 + if (res->dev->imc[res->imc].chan[res->channel].dimms[0].close_pg) 726 + shift = 6; 727 + else 728 + shift = 13; 729 + 730 + for (i = 0; i < SKX_MAX_RIR; i++) { 731 + SKX_GET_RIRWAYNESS(res->dev, res->imc, res->channel, i, rirway); 732 + limit = SKX_RIR_LIMIT(rirway); 733 + if (SKX_RIR_VALID(rirway)) { 734 + if (prev_limit <= res->chan_addr && 735 + res->chan_addr <= limit) 736 + goto rir_found; 737 + } 738 + prev_limit = limit; 739 + } 740 + edac_dbg(0, "No RIR entry for %llx\n", res->addr); 741 + return false; 742 + 743 + rir_found: 744 + rank_addr = res->chan_addr >> shift; 745 + rank_addr /= SKX_RIR_WAYS(rirway); 746 + rank_addr <<= shift; 747 + rank_addr |= res->chan_addr & GENMASK_ULL(shift - 1, 0); 748 + 749 + res->rank_address = rank_addr; 750 + idx = (res->chan_addr >> shift) % SKX_RIR_WAYS(rirway); 751 + 752 + SKX_GET_RIRILV(res->dev, res->imc, res->channel, idx, i, rirlv); 753 + res->rank_address = rank_addr - SKX_RIR_OFFSET(rirlv); 754 + chan_rank = SKX_RIR_CHAN_RANK(rirlv); 755 + res->channel_rank = chan_rank; 756 + res->dimm = chan_rank / 4; 757 + res->rank = chan_rank % 4; 758 + 759 + edac_dbg(2, "%llx: dimm=%d rank=%d chan_rank=%d rank_addr=%llx\n", 760 + res->addr, res->dimm, res->rank, 761 + res->channel_rank, res->rank_address); 762 + return true; 763 + } 764 + 765 + static u8 skx_close_row[] = { 766 + 15, 16, 17, 18, 20, 21, 22, 28, 10, 11, 12, 13, 29, 30, 31, 32, 33 767 + }; 768 + static u8 skx_close_column[] = { 769 + 3, 4, 5, 14, 19, 23, 24, 25, 26, 27 770 + }; 771 + static u8 skx_open_row[] = { 772 + 14, 15, 16, 20, 28, 21, 22, 23, 24, 25, 26, 27, 29, 30, 31, 32, 33 773 + }; 774 + static u8 skx_open_column[] = { 775 + 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 776 + }; 777 + static u8 skx_open_fine_column[] = { 778 + 3, 4, 5, 7, 8, 9, 10, 11, 12, 13 779 + }; 780 + 781 + static int skx_bits(u64 addr, int nbits, u8 *bits) 782 + { 783 + int i, res = 0; 784 + 785 + for (i = 0; i < nbits; i++) 786 + res |= ((addr >> bits[i]) & 1) << i; 787 + return res; 788 + } 789 + 790 + static int skx_bank_bits(u64 addr, int b0, int b1, int do_xor, int x0, int x1) 791 + { 792 + int ret = GET_BITFIELD(addr, b0, b0) | (GET_BITFIELD(addr, b1, b1) << 1); 793 + 794 + if (do_xor) 795 + ret ^= GET_BITFIELD(addr, x0, x0) | (GET_BITFIELD(addr, x1, x1) << 1); 796 + 797 + return ret; 798 + } 799 + 800 + static bool skx_mad_decode(struct decoded_addr *r) 801 + { 802 + struct skx_dimm *dimm = &r->dev->imc[r->imc].chan[r->channel].dimms[r->dimm]; 803 + int bg0 = dimm->fine_grain_bank ? 6 : 13; 804 + 805 + if (dimm->close_pg) { 806 + r->row = skx_bits(r->rank_address, dimm->rowbits, skx_close_row); 807 + r->column = skx_bits(r->rank_address, dimm->colbits, skx_close_column); 808 + r->column |= 0x400; /* C10 is autoprecharge, always set */ 809 + r->bank_address = skx_bank_bits(r->rank_address, 8, 9, dimm->bank_xor_enable, 22, 28); 810 + r->bank_group = skx_bank_bits(r->rank_address, 6, 7, dimm->bank_xor_enable, 20, 21); 811 + } else { 812 + r->row = skx_bits(r->rank_address, dimm->rowbits, skx_open_row); 813 + if (dimm->fine_grain_bank) 814 + r->column = skx_bits(r->rank_address, dimm->colbits, skx_open_fine_column); 815 + else 816 + r->column = skx_bits(r->rank_address, dimm->colbits, skx_open_column); 817 + r->bank_address = skx_bank_bits(r->rank_address, 18, 19, dimm->bank_xor_enable, 22, 23); 818 + r->bank_group = skx_bank_bits(r->rank_address, bg0, 17, dimm->bank_xor_enable, 20, 21); 819 + } 820 + r->row &= (1u << dimm->rowbits) - 1; 821 + 822 + edac_dbg(2, "%llx: row=%x col=%x bank_addr=%d bank_group=%d\n", 823 + r->addr, r->row, r->column, r->bank_address, 824 + r->bank_group); 825 + return true; 826 + } 827 + 828 + static bool skx_decode(struct decoded_addr *res) 829 + { 830 + 831 + return skx_sad_decode(res) && skx_tad_decode(res) && 832 + skx_rir_decode(res) && skx_mad_decode(res); 833 + } 834 + 835 + #ifdef CONFIG_EDAC_DEBUG 836 + /* 837 + * Debug feature. Make /sys/kernel/debug/skx_edac_test/addr. 838 + * Write an address to this file to exercise the address decode 839 + * logic in this driver. 840 + */ 841 + static struct dentry *skx_test; 842 + static u64 skx_fake_addr; 843 + 844 + static int debugfs_u64_set(void *data, u64 val) 845 + { 846 + struct decoded_addr res; 847 + 848 + res.addr = val; 849 + skx_decode(&res); 850 + 851 + return 0; 852 + } 853 + 854 + DEFINE_SIMPLE_ATTRIBUTE(fops_u64_wo, NULL, debugfs_u64_set, "%llu\n"); 855 + 856 + static struct dentry *mydebugfs_create(const char *name, umode_t mode, 857 + struct dentry *parent, u64 *value) 858 + { 859 + return debugfs_create_file(name, mode, parent, value, &fops_u64_wo); 860 + } 861 + 862 + static void setup_skx_debug(void) 863 + { 864 + skx_test = debugfs_create_dir("skx_edac_test", NULL); 865 + mydebugfs_create("addr", S_IWUSR, skx_test, &skx_fake_addr); 866 + } 867 + 868 + static void teardown_skx_debug(void) 869 + { 870 + debugfs_remove_recursive(skx_test); 871 + } 872 + #else 873 + static void setup_skx_debug(void) 874 + { 875 + } 876 + 877 + static void teardown_skx_debug(void) 878 + { 879 + } 880 + #endif /*CONFIG_EDAC_DEBUG*/ 881 + 882 + static void skx_mce_output_error(struct mem_ctl_info *mci, 883 + const struct mce *m, 884 + struct decoded_addr *res) 885 + { 886 + enum hw_event_mc_err_type tp_event; 887 + char *type, *optype, msg[256]; 888 + bool ripv = GET_BITFIELD(m->mcgstatus, 0, 0); 889 + bool overflow = GET_BITFIELD(m->status, 62, 62); 890 + bool uncorrected_error = GET_BITFIELD(m->status, 61, 61); 891 + bool recoverable; 892 + u32 core_err_cnt = GET_BITFIELD(m->status, 38, 52); 893 + u32 mscod = GET_BITFIELD(m->status, 16, 31); 894 + u32 errcode = GET_BITFIELD(m->status, 0, 15); 895 + u32 optypenum = GET_BITFIELD(m->status, 4, 6); 896 + 897 + recoverable = GET_BITFIELD(m->status, 56, 56); 898 + 899 + if (uncorrected_error) { 900 + if (ripv) { 901 + type = "FATAL"; 902 + tp_event = HW_EVENT_ERR_FATAL; 903 + } else { 904 + type = "NON_FATAL"; 905 + tp_event = HW_EVENT_ERR_UNCORRECTED; 906 + } 907 + } else { 908 + type = "CORRECTED"; 909 + tp_event = HW_EVENT_ERR_CORRECTED; 910 + } 911 + 912 + /* 913 + * According with Table 15-9 of the Intel Architecture spec vol 3A, 914 + * memory errors should fit in this mask: 915 + * 000f 0000 1mmm cccc (binary) 916 + * where: 917 + * f = Correction Report Filtering Bit. If 1, subsequent errors 918 + * won't be shown 919 + * mmm = error type 920 + * cccc = channel 921 + * If the mask doesn't match, report an error to the parsing logic 922 + */ 923 + if (!((errcode & 0xef80) == 0x80)) { 924 + optype = "Can't parse: it is not a mem"; 925 + } else { 926 + switch (optypenum) { 927 + case 0: 928 + optype = "generic undef request error"; 929 + break; 930 + case 1: 931 + optype = "memory read error"; 932 + break; 933 + case 2: 934 + optype = "memory write error"; 935 + break; 936 + case 3: 937 + optype = "addr/cmd error"; 938 + break; 939 + case 4: 940 + optype = "memory scrubbing error"; 941 + break; 942 + default: 943 + optype = "reserved"; 944 + break; 945 + } 946 + } 947 + 948 + snprintf(msg, sizeof(msg), 949 + "%s%s err_code:%04x:%04x socket:%d imc:%d rank:%d bg:%d ba:%d row:%x col:%x", 950 + overflow ? " OVERFLOW" : "", 951 + (uncorrected_error && recoverable) ? " recoverable" : "", 952 + mscod, errcode, 953 + res->socket, res->imc, res->rank, 954 + res->bank_group, res->bank_address, res->row, res->column); 955 + 956 + edac_dbg(0, "%s\n", msg); 957 + 958 + /* Call the helper to output message */ 959 + edac_mc_handle_error(tp_event, mci, core_err_cnt, 960 + m->addr >> PAGE_SHIFT, m->addr & ~PAGE_MASK, 0, 961 + res->channel, res->dimm, -1, 962 + optype, msg); 963 + } 964 + 965 + static int skx_mce_check_error(struct notifier_block *nb, unsigned long val, 966 + void *data) 967 + { 968 + struct mce *mce = (struct mce *)data; 969 + struct decoded_addr res; 970 + struct mem_ctl_info *mci; 971 + char *type; 972 + 973 + if (get_edac_report_status() == EDAC_REPORTING_DISABLED) 974 + return NOTIFY_DONE; 975 + 976 + /* ignore unless this is memory related with an address */ 977 + if ((mce->status & 0xefff) >> 7 != 1 || !(mce->status & MCI_STATUS_ADDRV)) 978 + return NOTIFY_DONE; 979 + 980 + res.addr = mce->addr; 981 + if (!skx_decode(&res)) 982 + return NOTIFY_DONE; 983 + mci = res.dev->imc[res.imc].mci; 984 + 985 + if (mce->mcgstatus & MCG_STATUS_MCIP) 986 + type = "Exception"; 987 + else 988 + type = "Event"; 989 + 990 + skx_mc_printk(mci, KERN_DEBUG, "HANDLING MCE MEMORY ERROR\n"); 991 + 992 + skx_mc_printk(mci, KERN_DEBUG, "CPU %d: Machine Check %s: %Lx " 993 + "Bank %d: %016Lx\n", mce->extcpu, type, 994 + mce->mcgstatus, mce->bank, mce->status); 995 + skx_mc_printk(mci, KERN_DEBUG, "TSC %llx ", mce->tsc); 996 + skx_mc_printk(mci, KERN_DEBUG, "ADDR %llx ", mce->addr); 997 + skx_mc_printk(mci, KERN_DEBUG, "MISC %llx ", mce->misc); 998 + 999 + skx_mc_printk(mci, KERN_DEBUG, "PROCESSOR %u:%x TIME %llu SOCKET " 1000 + "%u APIC %x\n", mce->cpuvendor, mce->cpuid, 1001 + mce->time, mce->socketid, mce->apicid); 1002 + 1003 + skx_mce_output_error(mci, mce, &res); 1004 + 1005 + return NOTIFY_DONE; 1006 + } 1007 + 1008 + static struct notifier_block skx_mce_dec = { 1009 + .notifier_call = skx_mce_check_error, 1010 + }; 1011 + 1012 + static void skx_remove(void) 1013 + { 1014 + int i, j; 1015 + struct skx_dev *d, *tmp; 1016 + 1017 + edac_dbg(0, "\n"); 1018 + 1019 + list_for_each_entry_safe(d, tmp, &skx_edac_list, list) { 1020 + list_del(&d->list); 1021 + for (i = 0; i < NUM_IMC; i++) { 1022 + skx_unregister_mci(&d->imc[i]); 1023 + for (j = 0; j < NUM_CHANNELS; j++) 1024 + pci_dev_put(d->imc[i].chan[j].cdev); 1025 + } 1026 + pci_dev_put(d->util_all); 1027 + pci_dev_put(d->sad_all); 1028 + 1029 + kfree(d); 1030 + } 1031 + } 1032 + 1033 + /* 1034 + * skx_init: 1035 + * make sure we are running on the correct cpu model 1036 + * search for all the devices we need 1037 + * check which DIMMs are present. 1038 + */ 1039 + int __init skx_init(void) 1040 + { 1041 + const struct x86_cpu_id *id; 1042 + const struct munit *m; 1043 + int rc = 0, i; 1044 + u8 mc = 0, src_id, node_id; 1045 + struct skx_dev *d; 1046 + 1047 + edac_dbg(2, "\n"); 1048 + 1049 + id = x86_match_cpu(skx_cpuids); 1050 + if (!id) 1051 + return -ENODEV; 1052 + 1053 + rc = skx_get_hi_lo(); 1054 + if (rc) 1055 + return rc; 1056 + 1057 + rc = get_all_bus_mappings(); 1058 + if (rc < 0) 1059 + goto fail; 1060 + if (rc == 0) { 1061 + edac_dbg(2, "No memory controllers found\n"); 1062 + return -ENODEV; 1063 + } 1064 + 1065 + for (m = skx_all_munits; m->did; m++) { 1066 + rc = get_all_munits(m); 1067 + if (rc < 0) 1068 + goto fail; 1069 + if (rc != m->per_socket * skx_num_sockets) { 1070 + edac_dbg(2, "Expected %d, got %d of %x\n", 1071 + m->per_socket * skx_num_sockets, rc, m->did); 1072 + rc = -ENODEV; 1073 + goto fail; 1074 + } 1075 + } 1076 + 1077 + list_for_each_entry(d, &skx_edac_list, list) { 1078 + src_id = get_src_id(d); 1079 + node_id = skx_get_node_id(d); 1080 + edac_dbg(2, "src_id=%d node_id=%d\n", src_id, node_id); 1081 + for (i = 0; i < NUM_IMC; i++) { 1082 + d->imc[i].mc = mc++; 1083 + d->imc[i].lmc = i; 1084 + d->imc[i].src_id = src_id; 1085 + d->imc[i].node_id = node_id; 1086 + rc = skx_register_mci(&d->imc[i]); 1087 + if (rc < 0) 1088 + goto fail; 1089 + } 1090 + } 1091 + 1092 + /* Ensure that the OPSTATE is set correctly for POLL or NMI */ 1093 + opstate_init(); 1094 + 1095 + setup_skx_debug(); 1096 + 1097 + mce_register_decode_chain(&skx_mce_dec); 1098 + 1099 + return 0; 1100 + fail: 1101 + skx_remove(); 1102 + return rc; 1103 + } 1104 + 1105 + static void __exit skx_exit(void) 1106 + { 1107 + edac_dbg(2, "\n"); 1108 + mce_unregister_decode_chain(&skx_mce_dec); 1109 + skx_remove(); 1110 + teardown_skx_debug(); 1111 + } 1112 + 1113 + module_init(skx_init); 1114 + module_exit(skx_exit); 1115 + 1116 + module_param(edac_op_state, int, 0444); 1117 + MODULE_PARM_DESC(edac_op_state, "EDAC Error Reporting state: 0=Poll,1=NMI"); 1118 + 1119 + MODULE_LICENSE("GPL v2"); 1120 + MODULE_AUTHOR("Tony Luck"); 1121 + MODULE_DESCRIPTION("MC Driver for Intel Skylake server processors");
+6 -5
drivers/gpio/Kconfig
··· 50 50 config OF_GPIO 51 51 def_bool y 52 52 depends on OF 53 + depends on HAS_IOMEM 53 54 54 55 config GPIO_ACPI 55 56 def_bool y ··· 189 188 config GPIO_ETRAXFS 190 189 bool "Axis ETRAX FS General I/O" 191 190 depends on CRIS || COMPILE_TEST 192 - depends on OF 191 + depends on OF_GPIO 193 192 select GPIO_GENERIC 194 193 select GPIOLIB_IRQCHIP 195 194 help ··· 215 214 216 215 config GPIO_GRGPIO 217 216 tristate "Aeroflex Gaisler GRGPIO support" 218 - depends on OF 217 + depends on OF_GPIO 219 218 select GPIO_GENERIC 220 219 select IRQ_DOMAIN 221 220 help ··· 313 312 config GPIO_MVEBU 314 313 def_bool y 315 314 depends on PLAT_ORION 316 - depends on OF 315 + depends on OF_GPIO 317 316 select GENERIC_IRQ_CHIP 318 317 319 318 config GPIO_MXC ··· 406 405 bool "NVIDIA Tegra GPIO support" 407 406 default ARCH_TEGRA 408 407 depends on ARCH_TEGRA || COMPILE_TEST 409 - depends on OF 408 + depends on OF_GPIO 410 409 help 411 410 Say yes here to support GPIO pins on NVIDIA Tegra SoCs. 412 411 ··· 1100 1099 1101 1100 config GPIO_74X164 1102 1101 tristate "74x164 serial-in/parallel-out 8-bits shift register" 1103 - depends on OF 1102 + depends on OF_GPIO 1104 1103 help 1105 1104 Driver for 74x164 compatible serial-in/parallel-out 8-outputs 1106 1105 shift registers. This driver can be used to provide access
+4 -4
drivers/gpio/gpio-max730x.c
··· 192 192 ts->chip.parent = dev; 193 193 ts->chip.owner = THIS_MODULE; 194 194 195 + ret = gpiochip_add_data(&ts->chip, ts); 196 + if (ret) 197 + goto exit_destroy; 198 + 195 199 /* 196 200 * initialize pullups according to platform data and cache the 197 201 * register values for later use. ··· 216 212 goto exit_destroy; 217 213 } 218 214 } 219 - 220 - ret = gpiochip_add_data(&ts->chip, ts); 221 - if (ret) 222 - goto exit_destroy; 223 215 224 216 return ret; 225 217
+4 -2
drivers/gpu/drm/amd/amdgpu/amdgpu.h
··· 426 426 427 427 /* custom LRU management */ 428 428 struct amdgpu_mman_lru log2_size[AMDGPU_TTM_LRU_SIZE]; 429 + /* guard for log2_size array, don't add anything in between */ 430 + struct amdgpu_mman_lru guard; 429 431 }; 430 432 431 433 int amdgpu_copy_buffer(struct amdgpu_ring *ring, ··· 648 646 void amdgpu_gart_table_vram_unpin(struct amdgpu_device *adev); 649 647 int amdgpu_gart_init(struct amdgpu_device *adev); 650 648 void amdgpu_gart_fini(struct amdgpu_device *adev); 651 - void amdgpu_gart_unbind(struct amdgpu_device *adev, unsigned offset, 649 + void amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset, 652 650 int pages); 653 - int amdgpu_gart_bind(struct amdgpu_device *adev, unsigned offset, 651 + int amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t offset, 654 652 int pages, struct page **pagelist, 655 653 dma_addr_t *dma_addr, uint32_t flags); 656 654
+13
drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c
··· 321 321 (le16_to_cpu(path->usConnObjectId) & 322 322 OBJECT_TYPE_MASK) >> OBJECT_TYPE_SHIFT; 323 323 324 + /* Skip TV/CV support */ 325 + if ((le16_to_cpu(path->usDeviceTag) == 326 + ATOM_DEVICE_TV1_SUPPORT) || 327 + (le16_to_cpu(path->usDeviceTag) == 328 + ATOM_DEVICE_CV_SUPPORT)) 329 + continue; 330 + 331 + if (con_obj_id >= ARRAY_SIZE(object_connector_convert)) { 332 + DRM_ERROR("invalid con_obj_id %d for device tag 0x%04x\n", 333 + con_obj_id, le16_to_cpu(path->usDeviceTag)); 334 + continue; 335 + } 336 + 324 337 connector_type = 325 338 object_connector_convert[con_obj_id]; 326 339 connector_object_id = con_obj_id;
-9
drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c
··· 200 200 atpx->is_hybrid = false; 201 201 if (valid_bits & ATPX_MS_HYBRID_GFX_SUPPORTED) { 202 202 printk("ATPX Hybrid Graphics\n"); 203 - #if 1 204 - /* This is a temporary hack until the D3 cold support 205 - * makes it upstream. The ATPX power_control method seems 206 - * to still work on even if the system should be using 207 - * the new standardized hybrid D3 cold ACPI interface. 208 - */ 209 - atpx->functions.power_cntl = true; 210 - #else 211 203 atpx->functions.power_cntl = false; 212 - #endif 213 204 atpx->is_hybrid = true; 214 205 } 215 206
+2 -2
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
··· 221 221 * Unbinds the requested pages from the gart page table and 222 222 * replaces them with the dummy page (all asics). 223 223 */ 224 - void amdgpu_gart_unbind(struct amdgpu_device *adev, unsigned offset, 224 + void amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset, 225 225 int pages) 226 226 { 227 227 unsigned t; ··· 268 268 * (all asics). 269 269 * Returns 0 for success, -EINVAL for failure. 270 270 */ 271 - int amdgpu_gart_bind(struct amdgpu_device *adev, unsigned offset, 271 + int amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t offset, 272 272 int pages, struct page **pagelist, dma_addr_t *dma_addr, 273 273 uint32_t flags) 274 274 {
+10 -2
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
··· 251 251 252 252 adev = amdgpu_get_adev(bo->bdev); 253 253 ring = adev->mman.buffer_funcs_ring; 254 - old_start = old_mem->start << PAGE_SHIFT; 255 - new_start = new_mem->start << PAGE_SHIFT; 254 + old_start = (u64)old_mem->start << PAGE_SHIFT; 255 + new_start = (u64)new_mem->start << PAGE_SHIFT; 256 256 257 257 switch (old_mem->mem_type) { 258 258 case TTM_PL_VRAM: ··· 950 950 struct list_head *res = lru->lru[tbo->mem.mem_type]; 951 951 952 952 lru->lru[tbo->mem.mem_type] = &tbo->lru; 953 + while ((++lru)->lru[tbo->mem.mem_type] == res) 954 + lru->lru[tbo->mem.mem_type] = &tbo->lru; 953 955 954 956 return res; 955 957 } ··· 962 960 struct list_head *res = lru->swap_lru; 963 961 964 962 lru->swap_lru = &tbo->swap; 963 + while ((++lru)->swap_lru == res) 964 + lru->swap_lru = &tbo->swap; 965 965 966 966 return res; 967 967 } ··· 1014 1010 lru->lru[j] = &adev->mman.bdev.man[j].lru; 1015 1011 lru->swap_lru = &adev->mman.bdev.glob->swap_lru; 1016 1012 } 1013 + 1014 + for (j = 0; j < TTM_NUM_MEM_TYPES; ++j) 1015 + adev->mman.guard.lru[j] = NULL; 1016 + adev->mman.guard.swap_lru = NULL; 1017 1017 1018 1018 adev->mman.initialized = true; 1019 1019 r = ttm_bo_init_mm(&adev->mman.bdev, TTM_PL_VRAM,
+2 -1
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
··· 1187 1187 r = 0; 1188 1188 } 1189 1189 1190 - error: 1191 1190 fence_put(fence); 1191 + 1192 + error: 1192 1193 return r; 1193 1194 }
+4 -1
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
··· 1535 1535 r = amd_sched_entity_init(&ring->sched, &vm->entity, 1536 1536 rq, amdgpu_sched_jobs); 1537 1537 if (r) 1538 - return r; 1538 + goto err; 1539 1539 1540 1540 vm->page_directory_fence = NULL; 1541 1541 ··· 1564 1564 1565 1565 error_free_sched_entity: 1566 1566 amd_sched_entity_fini(&ring->sched, &vm->entity); 1567 + 1568 + err: 1569 + drm_free_large(vm->page_tables); 1567 1570 1568 1571 return r; 1569 1572 }
+1 -1
drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c
··· 714 714 DRM_ERROR("amdgpu: IB test timed out\n"); 715 715 r = -ETIMEDOUT; 716 716 goto err1; 717 - } else if (r) { 717 + } else if (r < 0) { 718 718 DRM_ERROR("amdgpu: fence wait failed (%ld).\n", r); 719 719 goto err1; 720 720 }
+1 -1
drivers/gpu/drm/amd/amdkfd/kfd_doorbell.c
··· 184 184 sizeof(u32)) + inx; 185 185 186 186 pr_debug("kfd: get kernel queue doorbell\n" 187 - " doorbell offset == 0x%08d\n" 187 + " doorbell offset == 0x%08X\n" 188 188 " kernel address == 0x%08lX\n", 189 189 *doorbell_off, (uintptr_t)(kfd->doorbell_kernel_ptr + inx)); 190 190
+1 -1
drivers/gpu/drm/amd/scheduler/gpu_scheduler.c
··· 405 405 spin_lock(&sched->job_list_lock); 406 406 s_job = list_first_entry_or_null(&sched->ring_mirror_list, 407 407 struct amd_sched_job, node); 408 - if (s_job) 408 + if (s_job && sched->timeout != MAX_SCHEDULE_TIMEOUT) 409 409 schedule_delayed_work(&s_job->work_tdr, sched->timeout); 410 410 411 411 list_for_each_entry_safe(s_job, tmp, &sched->ring_mirror_list, node) {
+3 -3
drivers/gpu/drm/drm_atomic.c
··· 475 475 val, 476 476 -1, 477 477 &replaced); 478 - state->color_mgmt_changed = replaced; 478 + state->color_mgmt_changed |= replaced; 479 479 return ret; 480 480 } else if (property == config->ctm_property) { 481 481 ret = drm_atomic_replace_property_blob_from_id(crtc, ··· 483 483 val, 484 484 sizeof(struct drm_color_ctm), 485 485 &replaced); 486 - state->color_mgmt_changed = replaced; 486 + state->color_mgmt_changed |= replaced; 487 487 return ret; 488 488 } else if (property == config->gamma_lut_property) { 489 489 ret = drm_atomic_replace_property_blob_from_id(crtc, ··· 491 491 val, 492 492 -1, 493 493 &replaced); 494 - state->color_mgmt_changed = replaced; 494 + state->color_mgmt_changed |= replaced; 495 495 return ret; 496 496 } else if (crtc->funcs->atomic_set_property) 497 497 return crtc->funcs->atomic_set_property(crtc, state, property, val);
+3
drivers/gpu/drm/drm_crtc.c
··· 5404 5404 struct drm_pending_vblank_event *e = NULL; 5405 5405 int ret = -EINVAL; 5406 5406 5407 + if (!drm_core_check_feature(dev, DRIVER_MODESET)) 5408 + return -EINVAL; 5409 + 5407 5410 if (page_flip->flags & ~DRM_MODE_PAGE_FLIP_FLAGS || 5408 5411 page_flip->reserved != 0) 5409 5412 return -EINVAL;
+1 -1
drivers/gpu/drm/drm_fb_helper.c
··· 464 464 465 465 /* Sometimes user space wants everything disabled, so don't steal the 466 466 * display if there's a master. */ 467 - if (lockless_dereference(dev->master)) 467 + if (READ_ONCE(dev->master)) 468 468 return false; 469 469 470 470 drm_for_each_crtc(crtc, dev) {
+5 -5
drivers/gpu/drm/etnaviv/etnaviv_gpu.c
··· 1333 1333 if (ret < 0) 1334 1334 return ret; 1335 1335 1336 - mutex_lock(&gpu->lock); 1337 - 1338 1336 /* 1339 1337 * TODO 1340 1338 * ··· 1346 1348 if (unlikely(event == ~0U)) { 1347 1349 DRM_ERROR("no free event\n"); 1348 1350 ret = -EBUSY; 1349 - goto out_unlock; 1351 + goto out_pm_put; 1350 1352 } 1351 1353 1352 1354 fence = etnaviv_gpu_fence_alloc(gpu); 1353 1355 if (!fence) { 1354 1356 event_free(gpu, event); 1355 1357 ret = -ENOMEM; 1356 - goto out_unlock; 1358 + goto out_pm_put; 1357 1359 } 1360 + 1361 + mutex_lock(&gpu->lock); 1358 1362 1359 1363 gpu->event[event].fence = fence; 1360 1364 submit->fence = fence->seqno; ··· 1395 1395 hangcheck_timer_reset(gpu); 1396 1396 ret = 0; 1397 1397 1398 - out_unlock: 1399 1398 mutex_unlock(&gpu->lock); 1400 1399 1400 + out_pm_put: 1401 1401 etnaviv_gpu_pm_put(gpu); 1402 1402 1403 1403 return ret;
+12 -2
drivers/gpu/drm/i915/i915_drv.h
··· 882 882 883 883 struct i915_ctx_hang_stats hang_stats; 884 884 885 - /* Unique identifier for this context, used by the hw for tracking */ 886 885 unsigned long flags; 887 886 #define CONTEXT_NO_ZEROMAP BIT(0) 888 887 #define CONTEXT_NO_ERROR_CAPTURE BIT(1) 889 - unsigned hw_id; 888 + 889 + /* Unique identifier for this context, used by the hw for tracking */ 890 + unsigned int hw_id; 890 891 u32 user_handle; 891 892 892 893 u32 ggtt_alignment; ··· 1855 1854 enum modeset_restore modeset_restore; 1856 1855 struct mutex modeset_restore_lock; 1857 1856 struct drm_atomic_state *modeset_restore_state; 1857 + struct drm_modeset_acquire_ctx reset_ctx; 1858 1858 1859 1859 struct list_head vm_list; /* Global list of all address spaces */ 1860 1860 struct i915_ggtt ggtt; /* VM representing the global address space */ ··· 1963 1961 bool suspended_to_idle; 1964 1962 struct i915_suspend_saved_registers regfile; 1965 1963 struct vlv_s0ix_state vlv_s0ix_state; 1964 + 1965 + enum { 1966 + I915_SKL_SAGV_UNKNOWN = 0, 1967 + I915_SKL_SAGV_DISABLED, 1968 + I915_SKL_SAGV_ENABLED, 1969 + I915_SKL_SAGV_NOT_CONTROLLED 1970 + } skl_sagv_status; 1966 1971 1967 1972 struct { 1968 1973 /* ··· 3599 3590 /* belongs in i915_gem_gtt.h */ 3600 3591 static inline void i915_gem_chipset_flush(struct drm_i915_private *dev_priv) 3601 3592 { 3593 + wmb(); 3602 3594 if (INTEL_GEN(dev_priv) < 6) 3603 3595 intel_gtt_chipset_flush(); 3604 3596 }
+8 -2
drivers/gpu/drm/i915/i915_gem.c
··· 879 879 ret = i915_gem_shmem_pread(dev, obj, args, file); 880 880 881 881 /* pread for non shmem backed objects */ 882 - if (ret == -EFAULT || ret == -ENODEV) 882 + if (ret == -EFAULT || ret == -ENODEV) { 883 + intel_runtime_pm_get(to_i915(dev)); 883 884 ret = i915_gem_gtt_pread(dev, obj, args->size, 884 885 args->offset, args->data_ptr); 886 + intel_runtime_pm_put(to_i915(dev)); 887 + } 885 888 886 889 out: 887 890 drm_gem_object_unreference(&obj->base); ··· 1309 1306 * textures). Fallback to the shmem path in that case. */ 1310 1307 } 1311 1308 1312 - if (ret == -EFAULT) { 1309 + if (ret == -EFAULT || ret == -ENOSPC) { 1313 1310 if (obj->phys_handle) 1314 1311 ret = i915_gem_phys_pwrite(obj, args, file); 1315 1312 else if (i915_gem_object_has_struct_page(obj)) ··· 3172 3169 } 3173 3170 3174 3171 intel_ring_init_seqno(engine, engine->last_submitted_seqno); 3172 + 3173 + engine->i915->gt.active_engines &= ~intel_engine_flag(engine); 3175 3174 } 3176 3175 3177 3176 void i915_gem_reset(struct drm_device *dev) ··· 3191 3186 3192 3187 for_each_engine(engine, dev_priv) 3193 3188 i915_gem_reset_engine_cleanup(engine); 3189 + mod_delayed_work(dev_priv->wq, &dev_priv->gt.idle_work, 0); 3194 3190 3195 3191 i915_gem_context_reset(dev); 3196 3192
+3 -10
drivers/gpu/drm/i915/i915_gem_execbuffer.c
··· 943 943 { 944 944 const unsigned other_rings = ~intel_engine_flag(req->engine); 945 945 struct i915_vma *vma; 946 - uint32_t flush_domains = 0; 947 - bool flush_chipset = false; 948 946 int ret; 949 947 950 948 list_for_each_entry(vma, vmas, exec_list) { ··· 955 957 } 956 958 957 959 if (obj->base.write_domain & I915_GEM_DOMAIN_CPU) 958 - flush_chipset |= i915_gem_clflush_object(obj, false); 959 - 960 - flush_domains |= obj->base.write_domain; 960 + i915_gem_clflush_object(obj, false); 961 961 } 962 962 963 - if (flush_chipset) 964 - i915_gem_chipset_flush(req->engine->i915); 965 - 966 - if (flush_domains & I915_GEM_DOMAIN_GTT) 967 - wmb(); 963 + /* Unconditionally flush any chipset caches (for streaming writes). */ 964 + i915_gem_chipset_flush(req->engine->i915); 968 965 969 966 /* Unconditionally invalidate gpu caches and ensure that we do flush 970 967 * any residual writes from the previous batch.
+1
drivers/gpu/drm/i915/i915_gem_gtt.c
··· 2873 2873 struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt; 2874 2874 2875 2875 ppgtt->base.cleanup(&ppgtt->base); 2876 + kfree(ppgtt); 2876 2877 } 2877 2878 2878 2879 i915_gem_cleanup_stolen(dev);
+14
drivers/gpu/drm/i915/i915_reg.h
··· 1536 1536 #define BALANCE_LEG_MASK(port) (7<<(8+3*(port))) 1537 1537 /* Balance leg disable bits */ 1538 1538 #define BALANCE_LEG_DISABLE_SHIFT 23 1539 + #define BALANCE_LEG_DISABLE(port) (1 << (23 + (port))) 1539 1540 1540 1541 /* 1541 1542 * Fence registers ··· 7145 7144 7146 7145 #define GEN6_PCODE_MAILBOX _MMIO(0x138124) 7147 7146 #define GEN6_PCODE_READY (1<<31) 7147 + #define GEN6_PCODE_ERROR_MASK 0xFF 7148 + #define GEN6_PCODE_SUCCESS 0x0 7149 + #define GEN6_PCODE_ILLEGAL_CMD 0x1 7150 + #define GEN6_PCODE_MIN_FREQ_TABLE_GT_RATIO_OUT_OF_RANGE 0x2 7151 + #define GEN6_PCODE_TIMEOUT 0x3 7152 + #define GEN6_PCODE_UNIMPLEMENTED_CMD 0xFF 7153 + #define GEN7_PCODE_TIMEOUT 0x2 7154 + #define GEN7_PCODE_ILLEGAL_DATA 0x3 7155 + #define GEN7_PCODE_MIN_FREQ_TABLE_GT_RATIO_OUT_OF_RANGE 0x10 7148 7156 #define GEN6_PCODE_WRITE_RC6VIDS 0x4 7149 7157 #define GEN6_PCODE_READ_RC6VIDS 0x5 7150 7158 #define GEN6_ENCODE_RC6_VID(mv) (((mv) - 245) / 5) ··· 7175 7165 #define HSW_PCODE_DE_WRITE_FREQ_REQ 0x17 7176 7166 #define DISPLAY_IPS_CONTROL 0x19 7177 7167 #define HSW_PCODE_DYNAMIC_DUTY_CYCLE_CONTROL 0x1A 7168 + #define GEN9_PCODE_SAGV_CONTROL 0x21 7169 + #define GEN9_SAGV_DISABLE 0x0 7170 + #define GEN9_SAGV_IS_DISABLED 0x1 7171 + #define GEN9_SAGV_ENABLE 0x3 7178 7172 #define GEN6_PCODE_DATA _MMIO(0x138128) 7179 7173 #define GEN6_PCODE_FREQ_IA_RATIO_SHIFT 8 7180 7174 #define GEN6_PCODE_FREQ_RING_RATIO_SHIFT 16
+6
drivers/gpu/drm/i915/intel_audio.c
··· 600 600 if (!IS_SKYLAKE(dev_priv) && !IS_KABYLAKE(dev_priv)) 601 601 return; 602 602 603 + i915_audio_component_get_power(dev); 604 + 603 605 /* 604 606 * Enable/disable generating the codec wake signal, overriding the 605 607 * internal logic to generate the codec wake to controller. ··· 617 615 I915_WRITE(HSW_AUD_CHICKENBIT, tmp); 618 616 usleep_range(1000, 1500); 619 617 } 618 + 619 + i915_audio_component_put_power(dev); 620 620 } 621 621 622 622 /* Get CDCLK in kHz */ ··· 652 648 !IS_HASWELL(dev_priv)) 653 649 return 0; 654 650 651 + i915_audio_component_get_power(dev); 655 652 mutex_lock(&dev_priv->av_mutex); 656 653 /* 1. get the pipe */ 657 654 intel_encoder = dev_priv->dig_port_map[port]; ··· 703 698 704 699 unlock: 705 700 mutex_unlock(&dev_priv->av_mutex); 701 + i915_audio_component_put_power(dev); 706 702 return err; 707 703 } 708 704
+4 -4
drivers/gpu/drm/i915/intel_csr.c
··· 41 41 * be moved to FW_FAILED. 42 42 */ 43 43 44 - #define I915_CSR_KBL "i915/kbl_dmc_ver1.bin" 44 + #define I915_CSR_KBL "i915/kbl_dmc_ver1_01.bin" 45 45 MODULE_FIRMWARE(I915_CSR_KBL); 46 46 #define KBL_CSR_VERSION_REQUIRED CSR_VERSION(1, 1) 47 47 48 - #define I915_CSR_SKL "i915/skl_dmc_ver1.bin" 48 + #define I915_CSR_SKL "i915/skl_dmc_ver1_26.bin" 49 49 MODULE_FIRMWARE(I915_CSR_SKL); 50 - #define SKL_CSR_VERSION_REQUIRED CSR_VERSION(1, 23) 50 + #define SKL_CSR_VERSION_REQUIRED CSR_VERSION(1, 26) 51 51 52 - #define I915_CSR_BXT "i915/bxt_dmc_ver1.bin" 52 + #define I915_CSR_BXT "i915/bxt_dmc_ver1_07.bin" 53 53 MODULE_FIRMWARE(I915_CSR_BXT); 54 54 #define BXT_CSR_VERSION_REQUIRED CSR_VERSION(1, 7) 55 55
+65 -26
drivers/gpu/drm/i915/intel_ddi.c
··· 145 145 static const struct ddi_buf_trans skl_u_ddi_translations_dp[] = { 146 146 { 0x0000201B, 0x000000A2, 0x0 }, 147 147 { 0x00005012, 0x00000088, 0x0 }, 148 - { 0x80007011, 0x000000CD, 0x0 }, 148 + { 0x80007011, 0x000000CD, 0x1 }, 149 149 { 0x80009010, 0x000000C0, 0x1 }, 150 150 { 0x0000201B, 0x0000009D, 0x0 }, 151 151 { 0x80005012, 0x000000C0, 0x1 }, ··· 158 158 static const struct ddi_buf_trans skl_y_ddi_translations_dp[] = { 159 159 { 0x00000018, 0x000000A2, 0x0 }, 160 160 { 0x00005012, 0x00000088, 0x0 }, 161 - { 0x80007011, 0x000000CD, 0x0 }, 161 + { 0x80007011, 0x000000CD, 0x3 }, 162 162 { 0x80009010, 0x000000C0, 0x3 }, 163 163 { 0x00000018, 0x0000009D, 0x0 }, 164 164 { 0x80005012, 0x000000C0, 0x3 }, ··· 388 388 } 389 389 } 390 390 391 + static int intel_ddi_hdmi_level(struct drm_i915_private *dev_priv, enum port port) 392 + { 393 + int n_hdmi_entries; 394 + int hdmi_level; 395 + int hdmi_default_entry; 396 + 397 + hdmi_level = dev_priv->vbt.ddi_port_info[port].hdmi_level_shift; 398 + 399 + if (IS_BROXTON(dev_priv)) 400 + return hdmi_level; 401 + 402 + if (IS_SKYLAKE(dev_priv) || IS_KABYLAKE(dev_priv)) { 403 + skl_get_buf_trans_hdmi(dev_priv, &n_hdmi_entries); 404 + hdmi_default_entry = 8; 405 + } else if (IS_BROADWELL(dev_priv)) { 406 + n_hdmi_entries = ARRAY_SIZE(bdw_ddi_translations_hdmi); 407 + hdmi_default_entry = 7; 408 + } else if (IS_HASWELL(dev_priv)) { 409 + n_hdmi_entries = ARRAY_SIZE(hsw_ddi_translations_hdmi); 410 + hdmi_default_entry = 6; 411 + } else { 412 + WARN(1, "ddi translation table missing\n"); 413 + n_hdmi_entries = ARRAY_SIZE(bdw_ddi_translations_hdmi); 414 + hdmi_default_entry = 7; 415 + } 416 + 417 + /* Choose a good default if VBT is badly populated */ 418 + if (hdmi_level == HDMI_LEVEL_SHIFT_UNKNOWN || 419 + hdmi_level >= n_hdmi_entries) 420 + hdmi_level = hdmi_default_entry; 421 + 422 + return hdmi_level; 423 + } 424 + 391 425 /* 392 426 * Starting with Haswell, DDI port buffers must be programmed with correct 393 427 * values in advance. The buffer values are different for FDI and DP modes, ··· 433 399 { 434 400 struct drm_i915_private *dev_priv = to_i915(encoder->base.dev); 435 401 u32 iboost_bit = 0; 436 - int i, n_hdmi_entries, n_dp_entries, n_edp_entries, hdmi_default_entry, 402 + int i, n_hdmi_entries, n_dp_entries, n_edp_entries, 437 403 size; 438 404 int hdmi_level; 439 405 enum port port; ··· 444 410 const struct ddi_buf_trans *ddi_translations; 445 411 446 412 port = intel_ddi_get_encoder_port(encoder); 447 - hdmi_level = dev_priv->vbt.ddi_port_info[port].hdmi_level_shift; 413 + hdmi_level = intel_ddi_hdmi_level(dev_priv, port); 448 414 449 415 if (IS_BROXTON(dev_priv)) { 450 416 if (encoder->type != INTEL_OUTPUT_HDMI) ··· 464 430 skl_get_buf_trans_edp(dev_priv, &n_edp_entries); 465 431 ddi_translations_hdmi = 466 432 skl_get_buf_trans_hdmi(dev_priv, &n_hdmi_entries); 467 - hdmi_default_entry = 8; 468 433 /* If we're boosting the current, set bit 31 of trans1 */ 469 434 if (dev_priv->vbt.ddi_port_info[port].hdmi_boost_level || 470 435 dev_priv->vbt.ddi_port_info[port].dp_boost_level) ··· 489 456 490 457 n_dp_entries = ARRAY_SIZE(bdw_ddi_translations_dp); 491 458 n_hdmi_entries = ARRAY_SIZE(bdw_ddi_translations_hdmi); 492 - hdmi_default_entry = 7; 493 459 } else if (IS_HASWELL(dev_priv)) { 494 460 ddi_translations_fdi = hsw_ddi_translations_fdi; 495 461 ddi_translations_dp = hsw_ddi_translations_dp; ··· 496 464 ddi_translations_hdmi = hsw_ddi_translations_hdmi; 497 465 n_dp_entries = n_edp_entries = ARRAY_SIZE(hsw_ddi_translations_dp); 498 466 n_hdmi_entries = ARRAY_SIZE(hsw_ddi_translations_hdmi); 499 - hdmi_default_entry = 6; 500 467 } else { 501 468 WARN(1, "ddi translation table missing\n"); 502 469 ddi_translations_edp = bdw_ddi_translations_dp; ··· 505 474 n_edp_entries = ARRAY_SIZE(bdw_ddi_translations_edp); 506 475 n_dp_entries = ARRAY_SIZE(bdw_ddi_translations_dp); 507 476 n_hdmi_entries = ARRAY_SIZE(bdw_ddi_translations_hdmi); 508 - hdmi_default_entry = 7; 509 477 } 510 478 511 479 switch (encoder->type) { ··· 534 504 535 505 if (encoder->type != INTEL_OUTPUT_HDMI) 536 506 return; 537 - 538 - /* Choose a good default if VBT is badly populated */ 539 - if (hdmi_level == HDMI_LEVEL_SHIFT_UNKNOWN || 540 - hdmi_level >= n_hdmi_entries) 541 - hdmi_level = hdmi_default_entry; 542 507 543 508 /* Entry 9 is for HDMI: */ 544 509 I915_WRITE(DDI_BUF_TRANS_LO(port, i), ··· 1404 1379 TRANS_CLK_SEL_DISABLED); 1405 1380 } 1406 1381 1407 - static void skl_ddi_set_iboost(struct drm_i915_private *dev_priv, 1408 - u32 level, enum port port, int type) 1382 + static void _skl_ddi_set_iboost(struct drm_i915_private *dev_priv, 1383 + enum port port, uint8_t iboost) 1409 1384 { 1385 + u32 tmp; 1386 + 1387 + tmp = I915_READ(DISPIO_CR_TX_BMU_CR0); 1388 + tmp &= ~(BALANCE_LEG_MASK(port) | BALANCE_LEG_DISABLE(port)); 1389 + if (iboost) 1390 + tmp |= iboost << BALANCE_LEG_SHIFT(port); 1391 + else 1392 + tmp |= BALANCE_LEG_DISABLE(port); 1393 + I915_WRITE(DISPIO_CR_TX_BMU_CR0, tmp); 1394 + } 1395 + 1396 + static void skl_ddi_set_iboost(struct intel_encoder *encoder, u32 level) 1397 + { 1398 + struct intel_digital_port *intel_dig_port = enc_to_dig_port(&encoder->base); 1399 + struct drm_i915_private *dev_priv = to_i915(intel_dig_port->base.base.dev); 1400 + enum port port = intel_dig_port->port; 1401 + int type = encoder->type; 1410 1402 const struct ddi_buf_trans *ddi_translations; 1411 1403 uint8_t iboost; 1412 1404 uint8_t dp_iboost, hdmi_iboost; 1413 1405 int n_entries; 1414 - u32 reg; 1415 1406 1416 1407 /* VBT may override standard boost values */ 1417 1408 dp_iboost = dev_priv->vbt.ddi_port_info[port].dp_boost_level; ··· 1469 1428 return; 1470 1429 } 1471 1430 1472 - reg = I915_READ(DISPIO_CR_TX_BMU_CR0); 1473 - reg &= ~BALANCE_LEG_MASK(port); 1474 - reg &= ~(1 << (BALANCE_LEG_DISABLE_SHIFT + port)); 1431 + _skl_ddi_set_iboost(dev_priv, port, iboost); 1475 1432 1476 - if (iboost) 1477 - reg |= iboost << BALANCE_LEG_SHIFT(port); 1478 - else 1479 - reg |= 1 << (BALANCE_LEG_DISABLE_SHIFT + port); 1480 - 1481 - I915_WRITE(DISPIO_CR_TX_BMU_CR0, reg); 1433 + if (port == PORT_A && intel_dig_port->max_lanes == 4) 1434 + _skl_ddi_set_iboost(dev_priv, PORT_E, iboost); 1482 1435 } 1483 1436 1484 1437 static void bxt_ddi_vswing_sequence(struct drm_i915_private *dev_priv, ··· 1603 1568 level = translate_signal_level(signal_levels); 1604 1569 1605 1570 if (IS_SKYLAKE(dev_priv) || IS_KABYLAKE(dev_priv)) 1606 - skl_ddi_set_iboost(dev_priv, level, port, encoder->type); 1571 + skl_ddi_set_iboost(encoder, level); 1607 1572 else if (IS_BROXTON(dev_priv)) 1608 1573 bxt_ddi_vswing_sequence(dev_priv, level, port, encoder->type); 1609 1574 ··· 1672 1637 intel_dp_stop_link_train(intel_dp); 1673 1638 } else if (type == INTEL_OUTPUT_HDMI) { 1674 1639 struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(encoder); 1640 + int level = intel_ddi_hdmi_level(dev_priv, port); 1641 + 1642 + if (IS_SKYLAKE(dev_priv) || IS_KABYLAKE(dev_priv)) 1643 + skl_ddi_set_iboost(intel_encoder, level); 1675 1644 1676 1645 intel_hdmi->set_infoframes(encoder, 1677 1646 crtc->config->has_hdmi_sink,
+125 -64
drivers/gpu/drm/i915/intel_display.c
··· 3093 3093 3094 3094 for_each_crtc(dev, crtc) { 3095 3095 struct intel_plane *plane = to_intel_plane(crtc->primary); 3096 - struct intel_plane_state *plane_state; 3097 - 3098 - drm_modeset_lock_crtc(crtc, &plane->base); 3099 - plane_state = to_intel_plane_state(plane->base.state); 3096 + struct intel_plane_state *plane_state = 3097 + to_intel_plane_state(plane->base.state); 3100 3098 3101 3099 if (plane_state->visible) 3102 3100 plane->update_plane(&plane->base, 3103 3101 to_intel_crtc_state(crtc->state), 3104 3102 plane_state); 3105 - 3106 - drm_modeset_unlock_crtc(crtc); 3107 3103 } 3104 + } 3105 + 3106 + static int 3107 + __intel_display_resume(struct drm_device *dev, 3108 + struct drm_atomic_state *state) 3109 + { 3110 + struct drm_crtc_state *crtc_state; 3111 + struct drm_crtc *crtc; 3112 + int i, ret; 3113 + 3114 + intel_modeset_setup_hw_state(dev); 3115 + i915_redisable_vga(dev); 3116 + 3117 + if (!state) 3118 + return 0; 3119 + 3120 + for_each_crtc_in_state(state, crtc, crtc_state, i) { 3121 + /* 3122 + * Force recalculation even if we restore 3123 + * current state. With fast modeset this may not result 3124 + * in a modeset when the state is compatible. 3125 + */ 3126 + crtc_state->mode_changed = true; 3127 + } 3128 + 3129 + /* ignore any reset values/BIOS leftovers in the WM registers */ 3130 + to_intel_atomic_state(state)->skip_intermediate_wm = true; 3131 + 3132 + ret = drm_atomic_commit(state); 3133 + 3134 + WARN_ON(ret == -EDEADLK); 3135 + return ret; 3108 3136 } 3109 3137 3110 3138 void intel_prepare_reset(struct drm_i915_private *dev_priv) 3111 3139 { 3140 + struct drm_device *dev = &dev_priv->drm; 3141 + struct drm_modeset_acquire_ctx *ctx = &dev_priv->reset_ctx; 3142 + struct drm_atomic_state *state; 3143 + int ret; 3144 + 3112 3145 /* no reset support for gen2 */ 3113 3146 if (IS_GEN2(dev_priv)) 3114 3147 return; 3115 3148 3116 - /* reset doesn't touch the display */ 3149 + /* 3150 + * Need mode_config.mutex so that we don't 3151 + * trample ongoing ->detect() and whatnot. 3152 + */ 3153 + mutex_lock(&dev->mode_config.mutex); 3154 + drm_modeset_acquire_init(ctx, 0); 3155 + while (1) { 3156 + ret = drm_modeset_lock_all_ctx(dev, ctx); 3157 + if (ret != -EDEADLK) 3158 + break; 3159 + 3160 + drm_modeset_backoff(ctx); 3161 + } 3162 + 3163 + /* reset doesn't touch the display, but flips might get nuked anyway, */ 3117 3164 if (INTEL_GEN(dev_priv) >= 5 || IS_G4X(dev_priv)) 3118 3165 return; 3119 3166 3120 - drm_modeset_lock_all(&dev_priv->drm); 3121 3167 /* 3122 3168 * Disabling the crtcs gracefully seems nicer. Also the 3123 3169 * g33 docs say we should at least disable all the planes. 3124 3170 */ 3125 - intel_display_suspend(&dev_priv->drm); 3171 + state = drm_atomic_helper_duplicate_state(dev, ctx); 3172 + if (IS_ERR(state)) { 3173 + ret = PTR_ERR(state); 3174 + state = NULL; 3175 + DRM_ERROR("Duplicating state failed with %i\n", ret); 3176 + goto err; 3177 + } 3178 + 3179 + ret = drm_atomic_helper_disable_all(dev, ctx); 3180 + if (ret) { 3181 + DRM_ERROR("Suspending crtc's failed with %i\n", ret); 3182 + goto err; 3183 + } 3184 + 3185 + dev_priv->modeset_restore_state = state; 3186 + state->acquire_ctx = ctx; 3187 + return; 3188 + 3189 + err: 3190 + drm_atomic_state_free(state); 3126 3191 } 3127 3192 3128 3193 void intel_finish_reset(struct drm_i915_private *dev_priv) 3129 3194 { 3195 + struct drm_device *dev = &dev_priv->drm; 3196 + struct drm_modeset_acquire_ctx *ctx = &dev_priv->reset_ctx; 3197 + struct drm_atomic_state *state = dev_priv->modeset_restore_state; 3198 + int ret; 3199 + 3130 3200 /* 3131 3201 * Flips in the rings will be nuked by the reset, 3132 3202 * so complete all pending flips so that user space ··· 3207 3137 /* no reset support for gen2 */ 3208 3138 if (IS_GEN2(dev_priv)) 3209 3139 return; 3140 + 3141 + dev_priv->modeset_restore_state = NULL; 3210 3142 3211 3143 /* reset doesn't touch the display */ 3212 3144 if (INTEL_GEN(dev_priv) >= 5 || IS_G4X(dev_priv)) { ··· 3221 3149 * FIXME: Atomic will make this obsolete since we won't schedule 3222 3150 * CS-based flips (which might get lost in gpu resets) any more. 3223 3151 */ 3224 - intel_update_primary_planes(&dev_priv->drm); 3225 - return; 3152 + intel_update_primary_planes(dev); 3153 + } else { 3154 + /* 3155 + * The display has been reset as well, 3156 + * so need a full re-initialization. 3157 + */ 3158 + intel_runtime_pm_disable_interrupts(dev_priv); 3159 + intel_runtime_pm_enable_interrupts(dev_priv); 3160 + 3161 + intel_modeset_init_hw(dev); 3162 + 3163 + spin_lock_irq(&dev_priv->irq_lock); 3164 + if (dev_priv->display.hpd_irq_setup) 3165 + dev_priv->display.hpd_irq_setup(dev_priv); 3166 + spin_unlock_irq(&dev_priv->irq_lock); 3167 + 3168 + ret = __intel_display_resume(dev, state); 3169 + if (ret) 3170 + DRM_ERROR("Restoring old state failed with %i\n", ret); 3171 + 3172 + intel_hpd_init(dev_priv); 3226 3173 } 3227 3174 3228 - /* 3229 - * The display has been reset as well, 3230 - * so need a full re-initialization. 3231 - */ 3232 - intel_runtime_pm_disable_interrupts(dev_priv); 3233 - intel_runtime_pm_enable_interrupts(dev_priv); 3234 - 3235 - intel_modeset_init_hw(&dev_priv->drm); 3236 - 3237 - spin_lock_irq(&dev_priv->irq_lock); 3238 - if (dev_priv->display.hpd_irq_setup) 3239 - dev_priv->display.hpd_irq_setup(dev_priv); 3240 - spin_unlock_irq(&dev_priv->irq_lock); 3241 - 3242 - intel_display_resume(&dev_priv->drm); 3243 - 3244 - intel_hpd_init(dev_priv); 3245 - 3246 - drm_modeset_unlock_all(&dev_priv->drm); 3175 + drm_modeset_drop_locks(ctx); 3176 + drm_modeset_acquire_fini(ctx); 3177 + mutex_unlock(&dev->mode_config.mutex); 3247 3178 } 3248 3179 3249 3180 static bool intel_crtc_has_pending_flip(struct drm_crtc *crtc) ··· 13759 13684 intel_state->cdclk_pll_vco != dev_priv->cdclk_pll.vco)) 13760 13685 dev_priv->display.modeset_commit_cdclk(state); 13761 13686 13687 + /* 13688 + * SKL workaround: bspec recommends we disable the SAGV when we 13689 + * have more then one pipe enabled 13690 + */ 13691 + if (IS_SKYLAKE(dev_priv) && !skl_can_enable_sagv(state)) 13692 + skl_disable_sagv(dev_priv); 13693 + 13762 13694 intel_modeset_verify_disabled(dev); 13763 13695 } 13764 13696 ··· 13838 13756 13839 13757 intel_modeset_verify_crtc(crtc, old_crtc_state, crtc->state); 13840 13758 } 13759 + 13760 + if (IS_SKYLAKE(dev_priv) && intel_state->modeset && 13761 + skl_can_enable_sagv(state)) 13762 + skl_enable_sagv(dev_priv); 13841 13763 13842 13764 drm_atomic_helper_commit_hw_done(state); 13843 13765 ··· 16242 16156 struct drm_atomic_state *state = dev_priv->modeset_restore_state; 16243 16157 struct drm_modeset_acquire_ctx ctx; 16244 16158 int ret; 16245 - bool setup = false; 16246 16159 16247 16160 dev_priv->modeset_restore_state = NULL; 16161 + if (state) 16162 + state->acquire_ctx = &ctx; 16248 16163 16249 16164 /* 16250 16165 * This is a cludge because with real atomic modeset mode_config.mutex ··· 16256 16169 mutex_lock(&dev->mode_config.mutex); 16257 16170 drm_modeset_acquire_init(&ctx, 0); 16258 16171 16259 - retry: 16260 - ret = drm_modeset_lock_all_ctx(dev, &ctx); 16172 + while (1) { 16173 + ret = drm_modeset_lock_all_ctx(dev, &ctx); 16174 + if (ret != -EDEADLK) 16175 + break; 16261 16176 16262 - if (ret == 0 && !setup) { 16263 - setup = true; 16264 - 16265 - intel_modeset_setup_hw_state(dev); 16266 - i915_redisable_vga(dev); 16267 - } 16268 - 16269 - if (ret == 0 && state) { 16270 - struct drm_crtc_state *crtc_state; 16271 - struct drm_crtc *crtc; 16272 - int i; 16273 - 16274 - state->acquire_ctx = &ctx; 16275 - 16276 - /* ignore any reset values/BIOS leftovers in the WM registers */ 16277 - to_intel_atomic_state(state)->skip_intermediate_wm = true; 16278 - 16279 - for_each_crtc_in_state(state, crtc, crtc_state, i) { 16280 - /* 16281 - * Force recalculation even if we restore 16282 - * current state. With fast modeset this may not result 16283 - * in a modeset when the state is compatible. 16284 - */ 16285 - crtc_state->mode_changed = true; 16286 - } 16287 - 16288 - ret = drm_atomic_commit(state); 16289 - } 16290 - 16291 - if (ret == -EDEADLK) { 16292 16177 drm_modeset_backoff(&ctx); 16293 - goto retry; 16294 16178 } 16179 + 16180 + if (!ret) 16181 + ret = __intel_display_resume(dev, state); 16295 16182 16296 16183 drm_modeset_drop_locks(&ctx); 16297 16184 drm_modeset_acquire_fini(&ctx);
+3
drivers/gpu/drm/i915/intel_drv.h
··· 1716 1716 void skl_wm_get_hw_state(struct drm_device *dev); 1717 1717 void skl_ddb_get_hw_state(struct drm_i915_private *dev_priv, 1718 1718 struct skl_ddb_allocation *ddb /* out */); 1719 + bool skl_can_enable_sagv(struct drm_atomic_state *state); 1720 + int skl_enable_sagv(struct drm_i915_private *dev_priv); 1721 + int skl_disable_sagv(struct drm_i915_private *dev_priv); 1719 1722 uint32_t ilk_pipe_pixel_rate(const struct intel_crtc_state *pipe_config); 1720 1723 bool ilk_disable_lp_wm(struct drm_device *dev); 1721 1724 int sanitize_rc6_option(struct drm_i915_private *dev_priv, int enable_rc6);
+20
drivers/gpu/drm/i915/intel_fbc.c
··· 1230 1230 if (i915.enable_fbc >= 0) 1231 1231 return !!i915.enable_fbc; 1232 1232 1233 + if (!HAS_FBC(dev_priv)) 1234 + return 0; 1235 + 1233 1236 if (IS_BROADWELL(dev_priv)) 1234 1237 return 1; 1235 1238 1236 1239 return 0; 1240 + } 1241 + 1242 + static bool need_fbc_vtd_wa(struct drm_i915_private *dev_priv) 1243 + { 1244 + #ifdef CONFIG_INTEL_IOMMU 1245 + /* WaFbcTurnOffFbcWhenHyperVisorIsUsed:skl,bxt */ 1246 + if (intel_iommu_gfx_mapped && 1247 + (IS_SKYLAKE(dev_priv) || IS_BROXTON(dev_priv))) { 1248 + DRM_INFO("Disabling framebuffer compression (FBC) to prevent screen flicker with VT-d enabled\n"); 1249 + return true; 1250 + } 1251 + #endif 1252 + 1253 + return false; 1237 1254 } 1238 1255 1239 1256 /** ··· 1269 1252 fbc->enabled = false; 1270 1253 fbc->active = false; 1271 1254 fbc->work.scheduled = false; 1255 + 1256 + if (need_fbc_vtd_wa(dev_priv)) 1257 + mkwrite_device_info(dev_priv)->has_fbc = false; 1272 1258 1273 1259 i915.enable_fbc = intel_sanitize_fbc_option(dev_priv); 1274 1260 DRM_DEBUG_KMS("Sanitized enable_fbc value: %d\n", i915.enable_fbc);
+267 -9
drivers/gpu/drm/i915/intel_pm.c
··· 2852 2852 2853 2853 #define SKL_DDB_SIZE 896 /* in blocks */ 2854 2854 #define BXT_DDB_SIZE 512 2855 + #define SKL_SAGV_BLOCK_TIME 30 /* µs */ 2855 2856 2856 2857 /* 2857 2858 * Return the index of a plane in the SKL DDB and wm result arrays. Primary ··· 2874 2873 MISSING_CASE(plane->base.type); 2875 2874 return plane->plane; 2876 2875 } 2876 + } 2877 + 2878 + /* 2879 + * SAGV dynamically adjusts the system agent voltage and clock frequencies 2880 + * depending on power and performance requirements. The display engine access 2881 + * to system memory is blocked during the adjustment time. Because of the 2882 + * blocking time, having this enabled can cause full system hangs and/or pipe 2883 + * underruns if we don't meet all of the following requirements: 2884 + * 2885 + * - <= 1 pipe enabled 2886 + * - All planes can enable watermarks for latencies >= SAGV engine block time 2887 + * - We're not using an interlaced display configuration 2888 + */ 2889 + int 2890 + skl_enable_sagv(struct drm_i915_private *dev_priv) 2891 + { 2892 + int ret; 2893 + 2894 + if (dev_priv->skl_sagv_status == I915_SKL_SAGV_NOT_CONTROLLED || 2895 + dev_priv->skl_sagv_status == I915_SKL_SAGV_ENABLED) 2896 + return 0; 2897 + 2898 + DRM_DEBUG_KMS("Enabling the SAGV\n"); 2899 + mutex_lock(&dev_priv->rps.hw_lock); 2900 + 2901 + ret = sandybridge_pcode_write(dev_priv, GEN9_PCODE_SAGV_CONTROL, 2902 + GEN9_SAGV_ENABLE); 2903 + 2904 + /* We don't need to wait for the SAGV when enabling */ 2905 + mutex_unlock(&dev_priv->rps.hw_lock); 2906 + 2907 + /* 2908 + * Some skl systems, pre-release machines in particular, 2909 + * don't actually have an SAGV. 2910 + */ 2911 + if (ret == -ENXIO) { 2912 + DRM_DEBUG_DRIVER("No SAGV found on system, ignoring\n"); 2913 + dev_priv->skl_sagv_status = I915_SKL_SAGV_NOT_CONTROLLED; 2914 + return 0; 2915 + } else if (ret < 0) { 2916 + DRM_ERROR("Failed to enable the SAGV\n"); 2917 + return ret; 2918 + } 2919 + 2920 + dev_priv->skl_sagv_status = I915_SKL_SAGV_ENABLED; 2921 + return 0; 2922 + } 2923 + 2924 + static int 2925 + skl_do_sagv_disable(struct drm_i915_private *dev_priv) 2926 + { 2927 + int ret; 2928 + uint32_t temp = GEN9_SAGV_DISABLE; 2929 + 2930 + ret = sandybridge_pcode_read(dev_priv, GEN9_PCODE_SAGV_CONTROL, 2931 + &temp); 2932 + if (ret) 2933 + return ret; 2934 + else 2935 + return temp & GEN9_SAGV_IS_DISABLED; 2936 + } 2937 + 2938 + int 2939 + skl_disable_sagv(struct drm_i915_private *dev_priv) 2940 + { 2941 + int ret, result; 2942 + 2943 + if (dev_priv->skl_sagv_status == I915_SKL_SAGV_NOT_CONTROLLED || 2944 + dev_priv->skl_sagv_status == I915_SKL_SAGV_DISABLED) 2945 + return 0; 2946 + 2947 + DRM_DEBUG_KMS("Disabling the SAGV\n"); 2948 + mutex_lock(&dev_priv->rps.hw_lock); 2949 + 2950 + /* bspec says to keep retrying for at least 1 ms */ 2951 + ret = wait_for(result = skl_do_sagv_disable(dev_priv), 1); 2952 + mutex_unlock(&dev_priv->rps.hw_lock); 2953 + 2954 + if (ret == -ETIMEDOUT) { 2955 + DRM_ERROR("Request to disable SAGV timed out\n"); 2956 + return -ETIMEDOUT; 2957 + } 2958 + 2959 + /* 2960 + * Some skl systems, pre-release machines in particular, 2961 + * don't actually have an SAGV. 2962 + */ 2963 + if (result == -ENXIO) { 2964 + DRM_DEBUG_DRIVER("No SAGV found on system, ignoring\n"); 2965 + dev_priv->skl_sagv_status = I915_SKL_SAGV_NOT_CONTROLLED; 2966 + return 0; 2967 + } else if (result < 0) { 2968 + DRM_ERROR("Failed to disable the SAGV\n"); 2969 + return result; 2970 + } 2971 + 2972 + dev_priv->skl_sagv_status = I915_SKL_SAGV_DISABLED; 2973 + return 0; 2974 + } 2975 + 2976 + bool skl_can_enable_sagv(struct drm_atomic_state *state) 2977 + { 2978 + struct drm_device *dev = state->dev; 2979 + struct drm_i915_private *dev_priv = to_i915(dev); 2980 + struct intel_atomic_state *intel_state = to_intel_atomic_state(state); 2981 + struct drm_crtc *crtc; 2982 + enum pipe pipe; 2983 + int level, plane; 2984 + 2985 + /* 2986 + * SKL workaround: bspec recommends we disable the SAGV when we have 2987 + * more then one pipe enabled 2988 + * 2989 + * If there are no active CRTCs, no additional checks need be performed 2990 + */ 2991 + if (hweight32(intel_state->active_crtcs) == 0) 2992 + return true; 2993 + else if (hweight32(intel_state->active_crtcs) > 1) 2994 + return false; 2995 + 2996 + /* Since we're now guaranteed to only have one active CRTC... */ 2997 + pipe = ffs(intel_state->active_crtcs) - 1; 2998 + crtc = dev_priv->pipe_to_crtc_mapping[pipe]; 2999 + 3000 + if (crtc->state->mode.flags & DRM_MODE_FLAG_INTERLACE) 3001 + return false; 3002 + 3003 + for_each_plane(dev_priv, pipe, plane) { 3004 + /* Skip this plane if it's not enabled */ 3005 + if (intel_state->wm_results.plane[pipe][plane][0] == 0) 3006 + continue; 3007 + 3008 + /* Find the highest enabled wm level for this plane */ 3009 + for (level = ilk_wm_max_level(dev); 3010 + intel_state->wm_results.plane[pipe][plane][level] == 0; --level) 3011 + { } 3012 + 3013 + /* 3014 + * If any of the planes on this pipe don't enable wm levels 3015 + * that incur memory latencies higher then 30µs we can't enable 3016 + * the SAGV 3017 + */ 3018 + if (dev_priv->wm.skl_latency[level] < SKL_SAGV_BLOCK_TIME) 3019 + return false; 3020 + } 3021 + 3022 + return true; 2877 3023 } 2878 3024 2879 3025 static void ··· 3254 3106 total_data_rate += intel_cstate->wm.skl.plane_data_rate[id]; 3255 3107 total_data_rate += intel_cstate->wm.skl.plane_y_data_rate[id]; 3256 3108 } 3257 - 3258 - WARN_ON(cstate->plane_mask && total_data_rate == 0); 3259 3109 3260 3110 return total_data_rate; 3261 3111 } ··· 3490 3344 plane_bytes_per_line *= 4; 3491 3345 plane_blocks_per_line = DIV_ROUND_UP(plane_bytes_per_line, 512); 3492 3346 plane_blocks_per_line /= 4; 3347 + } else if (tiling == DRM_FORMAT_MOD_NONE) { 3348 + plane_blocks_per_line = DIV_ROUND_UP(plane_bytes_per_line, 512) + 1; 3493 3349 } else { 3494 3350 plane_blocks_per_line = DIV_ROUND_UP(plane_bytes_per_line, 512); 3495 3351 } ··· 4058 3910 * pretend that all pipes switched active status so that we'll 4059 3911 * ensure a full DDB recompute. 4060 3912 */ 4061 - if (dev_priv->wm.distrust_bios_wm) 3913 + if (dev_priv->wm.distrust_bios_wm) { 3914 + ret = drm_modeset_lock(&dev->mode_config.connection_mutex, 3915 + state->acquire_ctx); 3916 + if (ret) 3917 + return ret; 3918 + 4062 3919 intel_state->active_pipe_changes = ~0; 3920 + 3921 + /* 3922 + * We usually only initialize intel_state->active_crtcs if we 3923 + * we're doing a modeset; make sure this field is always 3924 + * initialized during the sanitization process that happens 3925 + * on the first commit too. 3926 + */ 3927 + if (!intel_state->modeset) 3928 + intel_state->active_crtcs = dev_priv->active_crtcs; 3929 + } 4063 3930 4064 3931 /* 4065 3932 * If the modeset changes which CRTC's are active, we need to ··· 4104 3941 ret = skl_allocate_pipe_ddb(cstate, ddb); 4105 3942 if (ret) 4106 3943 return ret; 3944 + 3945 + ret = drm_atomic_add_affected_planes(state, &intel_crtc->base); 3946 + if (ret) 3947 + return ret; 4107 3948 } 4108 3949 4109 3950 return 0; 3951 + } 3952 + 3953 + static void 3954 + skl_copy_wm_for_pipe(struct skl_wm_values *dst, 3955 + struct skl_wm_values *src, 3956 + enum pipe pipe) 3957 + { 3958 + dst->wm_linetime[pipe] = src->wm_linetime[pipe]; 3959 + memcpy(dst->plane[pipe], src->plane[pipe], 3960 + sizeof(dst->plane[pipe])); 3961 + memcpy(dst->plane_trans[pipe], src->plane_trans[pipe], 3962 + sizeof(dst->plane_trans[pipe])); 3963 + 3964 + dst->ddb.pipe[pipe] = src->ddb.pipe[pipe]; 3965 + memcpy(dst->ddb.y_plane[pipe], src->ddb.y_plane[pipe], 3966 + sizeof(dst->ddb.y_plane[pipe])); 3967 + memcpy(dst->ddb.plane[pipe], src->ddb.plane[pipe], 3968 + sizeof(dst->ddb.plane[pipe])); 4110 3969 } 4111 3970 4112 3971 static int ··· 4203 4018 struct drm_device *dev = crtc->dev; 4204 4019 struct drm_i915_private *dev_priv = to_i915(dev); 4205 4020 struct skl_wm_values *results = &dev_priv->wm.skl_results; 4021 + struct skl_wm_values *hw_vals = &dev_priv->wm.skl_hw; 4206 4022 struct intel_crtc_state *cstate = to_intel_crtc_state(crtc->state); 4207 4023 struct skl_pipe_wm *pipe_wm = &cstate->wm.skl.optimal; 4024 + int pipe; 4208 4025 4209 4026 if ((results->dirty_pipes & drm_crtc_mask(crtc)) == 0) 4210 4027 return; ··· 4218 4031 skl_write_wm_values(dev_priv, results); 4219 4032 skl_flush_wm_values(dev_priv, results); 4220 4033 4221 - /* store the new configuration */ 4222 - dev_priv->wm.skl_hw = *results; 4034 + /* 4035 + * Store the new configuration (but only for the pipes that have 4036 + * changed; the other values weren't recomputed). 4037 + */ 4038 + for_each_pipe_masked(dev_priv, pipe, results->dirty_pipes) 4039 + skl_copy_wm_for_pipe(hw_vals, results, pipe); 4223 4040 4224 4041 mutex_unlock(&dev_priv->wm.wm_mutex); 4225 4042 } ··· 6765 6574 6766 6575 void intel_cleanup_gt_powersave(struct drm_i915_private *dev_priv) 6767 6576 { 6768 - if (IS_CHERRYVIEW(dev_priv)) 6769 - return; 6770 - else if (IS_VALLEYVIEW(dev_priv)) 6577 + if (IS_VALLEYVIEW(dev_priv)) 6771 6578 valleyview_cleanup_gt_powersave(dev_priv); 6772 6579 6773 6580 if (!i915.enable_rc6) ··· 7847 7658 } 7848 7659 } 7849 7660 7661 + static inline int gen6_check_mailbox_status(struct drm_i915_private *dev_priv) 7662 + { 7663 + uint32_t flags = 7664 + I915_READ_FW(GEN6_PCODE_MAILBOX) & GEN6_PCODE_ERROR_MASK; 7665 + 7666 + switch (flags) { 7667 + case GEN6_PCODE_SUCCESS: 7668 + return 0; 7669 + case GEN6_PCODE_UNIMPLEMENTED_CMD: 7670 + case GEN6_PCODE_ILLEGAL_CMD: 7671 + return -ENXIO; 7672 + case GEN6_PCODE_MIN_FREQ_TABLE_GT_RATIO_OUT_OF_RANGE: 7673 + return -EOVERFLOW; 7674 + case GEN6_PCODE_TIMEOUT: 7675 + return -ETIMEDOUT; 7676 + default: 7677 + MISSING_CASE(flags) 7678 + return 0; 7679 + } 7680 + } 7681 + 7682 + static inline int gen7_check_mailbox_status(struct drm_i915_private *dev_priv) 7683 + { 7684 + uint32_t flags = 7685 + I915_READ_FW(GEN6_PCODE_MAILBOX) & GEN6_PCODE_ERROR_MASK; 7686 + 7687 + switch (flags) { 7688 + case GEN6_PCODE_SUCCESS: 7689 + return 0; 7690 + case GEN6_PCODE_ILLEGAL_CMD: 7691 + return -ENXIO; 7692 + case GEN7_PCODE_TIMEOUT: 7693 + return -ETIMEDOUT; 7694 + case GEN7_PCODE_ILLEGAL_DATA: 7695 + return -EINVAL; 7696 + case GEN7_PCODE_MIN_FREQ_TABLE_GT_RATIO_OUT_OF_RANGE: 7697 + return -EOVERFLOW; 7698 + default: 7699 + MISSING_CASE(flags); 7700 + return 0; 7701 + } 7702 + } 7703 + 7850 7704 int sandybridge_pcode_read(struct drm_i915_private *dev_priv, u32 mbox, u32 *val) 7851 7705 { 7706 + int status; 7707 + 7852 7708 WARN_ON(!mutex_is_locked(&dev_priv->rps.hw_lock)); 7853 7709 7854 7710 /* GEN6_PCODE_* are outside of the forcewake domain, we can ··· 7920 7686 *val = I915_READ_FW(GEN6_PCODE_DATA); 7921 7687 I915_WRITE_FW(GEN6_PCODE_DATA, 0); 7922 7688 7689 + if (INTEL_GEN(dev_priv) > 6) 7690 + status = gen7_check_mailbox_status(dev_priv); 7691 + else 7692 + status = gen6_check_mailbox_status(dev_priv); 7693 + 7694 + if (status) { 7695 + DRM_DEBUG_DRIVER("warning: pcode (read) mailbox access failed: %d\n", 7696 + status); 7697 + return status; 7698 + } 7699 + 7923 7700 return 0; 7924 7701 } 7925 7702 7926 7703 int sandybridge_pcode_write(struct drm_i915_private *dev_priv, 7927 - u32 mbox, u32 val) 7704 + u32 mbox, u32 val) 7928 7705 { 7706 + int status; 7707 + 7929 7708 WARN_ON(!mutex_is_locked(&dev_priv->rps.hw_lock)); 7930 7709 7931 7710 /* GEN6_PCODE_* are outside of the forcewake domain, we can ··· 7962 7715 } 7963 7716 7964 7717 I915_WRITE_FW(GEN6_PCODE_DATA, 0); 7718 + 7719 + if (INTEL_GEN(dev_priv) > 6) 7720 + status = gen7_check_mailbox_status(dev_priv); 7721 + else 7722 + status = gen6_check_mailbox_status(dev_priv); 7723 + 7724 + if (status) { 7725 + DRM_DEBUG_DRIVER("warning: pcode (write) mailbox access failed: %d\n", 7726 + status); 7727 + return status; 7728 + } 7965 7729 7966 7730 return 0; 7967 7731 }
+4 -4
drivers/gpu/drm/i915/intel_ringbuffer.c
··· 1178 1178 I915_WRITE(GEN8_L3SQCREG1, L3_GENERAL_PRIO_CREDITS(62) | 1179 1179 L3_HIGH_PRIO_CREDITS(2)); 1180 1180 1181 - /* WaInsertDummyPushConstPs:bxt */ 1182 - if (IS_BXT_REVID(dev_priv, 0, BXT_REVID_B0)) 1181 + /* WaToEnableHwFixForPushConstHWBug:bxt */ 1182 + if (IS_BXT_REVID(dev_priv, BXT_REVID_C0, REVID_FOREVER)) 1183 1183 WA_SET_BIT_MASKED(COMMON_SLICE_CHICKEN2, 1184 1184 GEN8_SBE_DISABLE_REPLAY_BUF_OPTIMIZATION); 1185 1185 ··· 1222 1222 I915_WRITE(GEN8_L3SQCREG4, I915_READ(GEN8_L3SQCREG4) | 1223 1223 GEN8_LQSC_RO_PERF_DIS); 1224 1224 1225 - /* WaInsertDummyPushConstPs:kbl */ 1226 - if (IS_KBL_REVID(dev_priv, 0, KBL_REVID_B0)) 1225 + /* WaToEnableHwFixForPushConstHWBug:kbl */ 1226 + if (IS_KBL_REVID(dev_priv, KBL_REVID_C0, REVID_FOREVER)) 1227 1227 WA_SET_BIT_MASKED(COMMON_SLICE_CHICKEN2, 1228 1228 GEN8_SBE_DISABLE_REPLAY_BUF_OPTIMIZATION); 1229 1229
+3
drivers/gpu/drm/mediatek/Kconfig
··· 2 2 tristate "DRM Support for Mediatek SoCs" 3 3 depends on DRM 4 4 depends on ARCH_MEDIATEK || (ARM && COMPILE_TEST) 5 + depends on COMMON_CLK 6 + depends on HAVE_ARM_SMCCC 7 + depends on OF 5 8 select DRM_GEM_CMA_HELPER 6 9 select DRM_KMS_HELPER 7 10 select DRM_MIPI_DSI
+4
drivers/gpu/drm/qxl/qxl_fb.c
··· 73 73 } 74 74 } 75 75 76 + #ifdef CONFIG_DRM_FBDEV_EMULATION 76 77 static struct fb_deferred_io qxl_defio = { 77 78 .delay = QXL_DIRTY_DELAY, 78 79 .deferred_io = drm_fb_helper_deferred_io, 79 80 }; 81 + #endif 80 82 81 83 static struct fb_ops qxlfb_ops = { 82 84 .owner = THIS_MODULE, ··· 315 313 goto out_destroy_fbi; 316 314 } 317 315 316 + #ifdef CONFIG_DRM_FBDEV_EMULATION 318 317 info->fbdefio = &qxl_defio; 319 318 fb_deferred_io_init(info); 319 + #endif 320 320 321 321 qdev->fbdev_info = info; 322 322 qdev->fbdev_qfb = &qfbdev->qfb;
+3 -1
drivers/gpu/drm/radeon/atombios_crtc.c
··· 627 627 if (radeon_crtc->ss.refdiv) { 628 628 radeon_crtc->pll_flags |= RADEON_PLL_USE_REF_DIV; 629 629 radeon_crtc->pll_reference_div = radeon_crtc->ss.refdiv; 630 - if (rdev->family >= CHIP_RV770) 630 + if (ASIC_IS_AVIVO(rdev) && 631 + rdev->family != CHIP_RS780 && 632 + rdev->family != CHIP_RS880) 631 633 radeon_crtc->pll_flags |= RADEON_PLL_USE_FRAC_FB_DIV; 632 634 } 633 635 }
-9
drivers/gpu/drm/radeon/radeon_atpx_handler.c
··· 198 198 atpx->is_hybrid = false; 199 199 if (valid_bits & ATPX_MS_HYBRID_GFX_SUPPORTED) { 200 200 printk("ATPX Hybrid Graphics\n"); 201 - #if 1 202 - /* This is a temporary hack until the D3 cold support 203 - * makes it upstream. The ATPX power_control method seems 204 - * to still work on even if the system should be using 205 - * the new standardized hybrid D3 cold ACPI interface. 206 - */ 207 - atpx->functions.power_cntl = true; 208 - #else 209 201 atpx->functions.power_cntl = false; 210 - #endif 211 202 atpx->is_hybrid = true; 212 203 } 213 204
+2 -2
drivers/gpu/drm/radeon/radeon_ttm.c
··· 263 263 264 264 rdev = radeon_get_rdev(bo->bdev); 265 265 ridx = radeon_copy_ring_index(rdev); 266 - old_start = old_mem->start << PAGE_SHIFT; 267 - new_start = new_mem->start << PAGE_SHIFT; 266 + old_start = (u64)old_mem->start << PAGE_SHIFT; 267 + new_start = (u64)new_mem->start << PAGE_SHIFT; 268 268 269 269 switch (old_mem->mem_type) { 270 270 case TTM_PL_VRAM:
+36 -7
drivers/gpu/drm/tegra/dsi.c
··· 840 840 .destroy = tegra_output_encoder_destroy, 841 841 }; 842 842 843 + static void tegra_dsi_unprepare(struct tegra_dsi *dsi) 844 + { 845 + int err; 846 + 847 + if (dsi->slave) 848 + tegra_dsi_unprepare(dsi->slave); 849 + 850 + err = tegra_mipi_disable(dsi->mipi); 851 + if (err < 0) 852 + dev_err(dsi->dev, "failed to disable MIPI calibration: %d\n", 853 + err); 854 + 855 + pm_runtime_put(dsi->dev); 856 + } 857 + 843 858 static void tegra_dsi_encoder_disable(struct drm_encoder *encoder) 844 859 { 845 860 struct tegra_output *output = encoder_to_output(encoder); ··· 891 876 892 877 tegra_dsi_disable(dsi); 893 878 894 - pm_runtime_put(dsi->dev); 879 + tegra_dsi_unprepare(dsi); 880 + } 881 + 882 + static void tegra_dsi_prepare(struct tegra_dsi *dsi) 883 + { 884 + int err; 885 + 886 + pm_runtime_get_sync(dsi->dev); 887 + 888 + err = tegra_mipi_enable(dsi->mipi); 889 + if (err < 0) 890 + dev_err(dsi->dev, "failed to enable MIPI calibration: %d\n", 891 + err); 892 + 893 + err = tegra_dsi_pad_calibrate(dsi); 894 + if (err < 0) 895 + dev_err(dsi->dev, "MIPI calibration failed: %d\n", err); 896 + 897 + if (dsi->slave) 898 + tegra_dsi_prepare(dsi->slave); 895 899 } 896 900 897 901 static void tegra_dsi_encoder_enable(struct drm_encoder *encoder) ··· 921 887 struct tegra_dsi *dsi = to_dsi(output); 922 888 struct tegra_dsi_state *state; 923 889 u32 value; 924 - int err; 925 890 926 - pm_runtime_get_sync(dsi->dev); 927 - 928 - err = tegra_dsi_pad_calibrate(dsi); 929 - if (err < 0) 930 - dev_err(dsi->dev, "MIPI calibration failed: %d\n", err); 891 + tegra_dsi_prepare(dsi); 931 892 932 893 state = tegra_dsi_get_state(dsi); 933 894
+4
drivers/gpu/drm/udl/udl_fb.c
··· 203 203 204 204 ufbdev->fb_count++; 205 205 206 + #ifdef CONFIG_DRM_FBDEV_EMULATION 206 207 if (fb_defio && (info->fbdefio == NULL)) { 207 208 /* enable defio at last moment if not disabled by client */ 208 209 ··· 219 218 info->fbdefio = fbdefio; 220 219 fb_deferred_io_init(info); 221 220 } 221 + #endif 222 222 223 223 pr_notice("open /dev/fb%d user=%d fb_info=%p count=%d\n", 224 224 info->node, user, info, ufbdev->fb_count); ··· 237 235 238 236 ufbdev->fb_count--; 239 237 238 + #ifdef CONFIG_DRM_FBDEV_EMULATION 240 239 if ((ufbdev->fb_count == 0) && (info->fbdefio)) { 241 240 fb_deferred_io_cleanup(info); 242 241 kfree(info->fbdefio); 243 242 info->fbdefio = NULL; 244 243 info->fbops->fb_mmap = udl_fb_mmap; 245 244 } 245 + #endif 246 246 247 247 pr_warn("released /dev/fb%d user=%d count=%d\n", 248 248 info->node, user, ufbdev->fb_count);
+32 -33
drivers/gpu/host1x/mipi.c
··· 242 242 dev->pads = args.args[0]; 243 243 dev->device = device; 244 244 245 - mutex_lock(&dev->mipi->lock); 246 - 247 - if (dev->mipi->usage_count++ == 0) { 248 - err = tegra_mipi_power_up(dev->mipi); 249 - if (err < 0) { 250 - dev_err(dev->mipi->dev, 251 - "failed to power up MIPI bricks: %d\n", 252 - err); 253 - return ERR_PTR(err); 254 - } 255 - } 256 - 257 - mutex_unlock(&dev->mipi->lock); 258 - 259 245 return dev; 260 246 261 247 put: ··· 256 270 257 271 void tegra_mipi_free(struct tegra_mipi_device *device) 258 272 { 259 - int err; 260 - 261 - mutex_lock(&device->mipi->lock); 262 - 263 - if (--device->mipi->usage_count == 0) { 264 - err = tegra_mipi_power_down(device->mipi); 265 - if (err < 0) { 266 - /* 267 - * Not much that can be done here, so an error message 268 - * will have to do. 269 - */ 270 - dev_err(device->mipi->dev, 271 - "failed to power down MIPI bricks: %d\n", 272 - err); 273 - } 274 - } 275 - 276 - mutex_unlock(&device->mipi->lock); 277 - 278 273 platform_device_put(device->pdev); 279 274 kfree(device); 280 275 } 281 276 EXPORT_SYMBOL(tegra_mipi_free); 277 + 278 + int tegra_mipi_enable(struct tegra_mipi_device *dev) 279 + { 280 + int err = 0; 281 + 282 + mutex_lock(&dev->mipi->lock); 283 + 284 + if (dev->mipi->usage_count++ == 0) 285 + err = tegra_mipi_power_up(dev->mipi); 286 + 287 + mutex_unlock(&dev->mipi->lock); 288 + 289 + return err; 290 + 291 + } 292 + EXPORT_SYMBOL(tegra_mipi_enable); 293 + 294 + int tegra_mipi_disable(struct tegra_mipi_device *dev) 295 + { 296 + int err = 0; 297 + 298 + mutex_lock(&dev->mipi->lock); 299 + 300 + if (--dev->mipi->usage_count == 0) 301 + err = tegra_mipi_power_down(dev->mipi); 302 + 303 + mutex_unlock(&dev->mipi->lock); 304 + 305 + return err; 306 + 307 + } 308 + EXPORT_SYMBOL(tegra_mipi_disable); 282 309 283 310 static int tegra_mipi_wait(struct tegra_mipi *mipi) 284 311 {
+2 -1
drivers/hwmon/it87.c
··· 491 491 struct it87_data { 492 492 const struct attribute_group *groups[7]; 493 493 enum chips type; 494 - u16 features; 494 + u32 features; 495 495 u8 peci_mask; 496 496 u8 old_peci_mask; 497 497 ··· 2015 2015 &sensor_dev_attr_in10_input.dev_attr.attr, /* 41 */ 2016 2016 &sensor_dev_attr_in11_input.dev_attr.attr, /* 41 */ 2017 2017 &sensor_dev_attr_in12_input.dev_attr.attr, /* 41 */ 2018 + NULL 2018 2019 }; 2019 2020 2020 2021 static const struct attribute_group it87_group_in = {
+14 -10
drivers/i2c/busses/i2c-at91.c
··· 38 38 #define AT91_I2C_TIMEOUT msecs_to_jiffies(100) /* transfer timeout */ 39 39 #define AT91_I2C_DMA_THRESHOLD 8 /* enable DMA if transfer size is bigger than this threshold */ 40 40 #define AUTOSUSPEND_TIMEOUT 2000 41 + #define AT91_I2C_MAX_ALT_CMD_DATA_SIZE 256 41 42 42 43 /* AT91 TWI register definitions */ 43 44 #define AT91_TWI_CR 0x0000 /* Control Register */ ··· 142 141 unsigned twi_cwgr_reg; 143 142 struct at91_twi_pdata *pdata; 144 143 bool use_dma; 144 + bool use_alt_cmd; 145 145 bool recv_len_abort; 146 146 u32 fifo_size; 147 147 struct at91_twi_dma dma; ··· 271 269 272 270 /* send stop when last byte has been written */ 273 271 if (--dev->buf_len == 0) 274 - if (!dev->pdata->has_alt_cmd) 272 + if (!dev->use_alt_cmd) 275 273 at91_twi_write(dev, AT91_TWI_CR, AT91_TWI_STOP); 276 274 277 275 dev_dbg(dev->dev, "wrote 0x%x, to go %d\n", *dev->buf, dev->buf_len); ··· 294 292 * we just have to enable TXCOMP one. 295 293 */ 296 294 at91_twi_write(dev, AT91_TWI_IER, AT91_TWI_TXCOMP); 297 - if (!dev->pdata->has_alt_cmd) 295 + if (!dev->use_alt_cmd) 298 296 at91_twi_write(dev, AT91_TWI_CR, AT91_TWI_STOP); 299 297 } 300 298 ··· 412 410 } 413 411 414 412 /* send stop if second but last byte has been read */ 415 - if (!dev->pdata->has_alt_cmd && dev->buf_len == 1) 413 + if (!dev->use_alt_cmd && dev->buf_len == 1) 416 414 at91_twi_write(dev, AT91_TWI_CR, AT91_TWI_STOP); 417 415 418 416 dev_dbg(dev->dev, "read 0x%x, to go %d\n", *dev->buf, dev->buf_len); ··· 428 426 dma_unmap_single(dev->dev, sg_dma_address(&dev->dma.sg[0]), 429 427 dev->buf_len, DMA_FROM_DEVICE); 430 428 431 - if (!dev->pdata->has_alt_cmd) { 429 + if (!dev->use_alt_cmd) { 432 430 /* The last two bytes have to be read without using dma */ 433 431 dev->buf += dev->buf_len - 2; 434 432 dev->buf_len = 2; ··· 445 443 struct dma_chan *chan_rx = dma->chan_rx; 446 444 size_t buf_len; 447 445 448 - buf_len = (dev->pdata->has_alt_cmd) ? dev->buf_len : dev->buf_len - 2; 446 + buf_len = (dev->use_alt_cmd) ? dev->buf_len : dev->buf_len - 2; 449 447 dma->direction = DMA_FROM_DEVICE; 450 448 451 449 /* Keep in mind that we won't use dma to read the last two bytes */ ··· 653 651 unsigned start_flags = AT91_TWI_START; 654 652 655 653 /* if only one byte is to be read, immediately stop transfer */ 656 - if (!has_alt_cmd && dev->buf_len <= 1 && 654 + if (!dev->use_alt_cmd && dev->buf_len <= 1 && 657 655 !(dev->msg->flags & I2C_M_RECV_LEN)) 658 656 start_flags |= AT91_TWI_STOP; 659 657 at91_twi_write(dev, AT91_TWI_CR, start_flags); ··· 747 745 int ret; 748 746 unsigned int_addr_flag = 0; 749 747 struct i2c_msg *m_start = msg; 750 - bool is_read, use_alt_cmd = false; 748 + bool is_read; 751 749 752 750 dev_dbg(&adap->dev, "at91_xfer: processing %d messages:\n", num); 753 751 ··· 770 768 at91_twi_write(dev, AT91_TWI_IADR, internal_address); 771 769 } 772 770 771 + dev->use_alt_cmd = false; 773 772 is_read = (m_start->flags & I2C_M_RD); 774 773 if (dev->pdata->has_alt_cmd) { 775 - if (m_start->len > 0) { 774 + if (m_start->len > 0 && 775 + m_start->len < AT91_I2C_MAX_ALT_CMD_DATA_SIZE) { 776 776 at91_twi_write(dev, AT91_TWI_CR, AT91_TWI_ACMEN); 777 777 at91_twi_write(dev, AT91_TWI_ACR, 778 778 AT91_TWI_ACR_DATAL(m_start->len) | 779 779 ((is_read) ? AT91_TWI_ACR_DIR : 0)); 780 - use_alt_cmd = true; 780 + dev->use_alt_cmd = true; 781 781 } else { 782 782 at91_twi_write(dev, AT91_TWI_CR, AT91_TWI_ACMDIS); 783 783 } ··· 788 784 at91_twi_write(dev, AT91_TWI_MMR, 789 785 (m_start->addr << 16) | 790 786 int_addr_flag | 791 - ((!use_alt_cmd && is_read) ? AT91_TWI_MREAD : 0)); 787 + ((!dev->use_alt_cmd && is_read) ? AT91_TWI_MREAD : 0)); 792 788 793 789 dev->buf_len = m_start->len; 794 790 dev->buf = m_start->buf;
+1 -1
drivers/i2c/busses/i2c-bcm-iproc.c
··· 158 158 159 159 if (status & BIT(IS_M_START_BUSY_SHIFT)) { 160 160 iproc_i2c->xfer_is_done = 1; 161 - complete_all(&iproc_i2c->done); 161 + complete(&iproc_i2c->done); 162 162 } 163 163 164 164 writel(status, iproc_i2c->base + IS_OFFSET);
+1 -1
drivers/i2c/busses/i2c-bcm-kona.c
··· 229 229 dev->base + TXFCR_OFFSET); 230 230 231 231 writel(status & ~ISR_RESERVED_MASK, dev->base + ISR_OFFSET); 232 - complete_all(&dev->done); 232 + complete(&dev->done); 233 233 234 234 return IRQ_HANDLED; 235 235 }
+1 -1
drivers/i2c/busses/i2c-brcmstb.c
··· 228 228 return IRQ_NONE; 229 229 230 230 brcmstb_i2c_enable_disable_irq(dev, INT_DISABLE); 231 - complete_all(&dev->done); 231 + complete(&dev->done); 232 232 233 233 dev_dbg(dev->device, "isr handled"); 234 234 return IRQ_HANDLED;
+1 -1
drivers/i2c/busses/i2c-cros-ec-tunnel.c
··· 215 215 msg->outsize = request_len; 216 216 msg->insize = response_len; 217 217 218 - result = cros_ec_cmd_xfer(bus->ec, msg); 218 + result = cros_ec_cmd_xfer_status(bus->ec, msg); 219 219 if (result < 0) { 220 220 dev_err(dev, "Error transferring EC i2c message %d\n", result); 221 221 goto exit;
+3 -3
drivers/i2c/busses/i2c-meson.c
··· 211 211 meson_i2c_add_token(i2c, TOKEN_STOP); 212 212 } else { 213 213 i2c->state = STATE_IDLE; 214 - complete_all(&i2c->done); 214 + complete(&i2c->done); 215 215 } 216 216 } 217 217 ··· 238 238 dev_dbg(i2c->dev, "error bit set\n"); 239 239 i2c->error = -ENXIO; 240 240 i2c->state = STATE_IDLE; 241 - complete_all(&i2c->done); 241 + complete(&i2c->done); 242 242 goto out; 243 243 } 244 244 ··· 269 269 break; 270 270 case STATE_STOP: 271 271 i2c->state = STATE_IDLE; 272 - complete_all(&i2c->done); 272 + complete(&i2c->done); 273 273 break; 274 274 case STATE_IDLE: 275 275 break;
+10 -4
drivers/i2c/busses/i2c-ocores.c
··· 379 379 if (!clock_frequency_present) { 380 380 dev_err(&pdev->dev, 381 381 "Missing required parameter 'opencores,ip-clock-frequency'\n"); 382 + clk_disable_unprepare(i2c->clk); 382 383 return -ENODEV; 383 384 } 384 385 i2c->ip_clock_khz = clock_frequency / 1000; ··· 468 467 default: 469 468 dev_err(&pdev->dev, "Unsupported I/O width (%d)\n", 470 469 i2c->reg_io_width); 471 - return -EINVAL; 470 + ret = -EINVAL; 471 + goto err_clk; 472 472 } 473 473 } 474 474 475 475 ret = ocores_init(&pdev->dev, i2c); 476 476 if (ret) 477 - return ret; 477 + goto err_clk; 478 478 479 479 init_waitqueue_head(&i2c->wait); 480 480 ret = devm_request_irq(&pdev->dev, irq, ocores_isr, 0, 481 481 pdev->name, i2c); 482 482 if (ret) { 483 483 dev_err(&pdev->dev, "Cannot claim IRQ\n"); 484 - return ret; 484 + goto err_clk; 485 485 } 486 486 487 487 /* hook up driver to tree */ ··· 496 494 ret = i2c_add_adapter(&i2c->adap); 497 495 if (ret) { 498 496 dev_err(&pdev->dev, "Failed to add adapter\n"); 499 - return ret; 497 + goto err_clk; 500 498 } 501 499 502 500 /* add in known devices to the bus */ ··· 506 504 } 507 505 508 506 return 0; 507 + 508 + err_clk: 509 + clk_disable_unprepare(i2c->clk); 510 + return ret; 509 511 } 510 512 511 513 static int ocores_i2c_remove(struct platform_device *pdev)
+3 -1
drivers/i2c/muxes/i2c-demux-pinctrl.c
··· 68 68 adap = of_find_i2c_adapter_by_node(priv->chan[new_chan].parent_np); 69 69 if (!adap) { 70 70 ret = -ENODEV; 71 - goto err; 71 + goto err_with_revert; 72 72 } 73 73 74 74 p = devm_pinctrl_get_select(adap->dev.parent, priv->bus_name); ··· 103 103 104 104 err_with_put: 105 105 i2c_put_adapter(adap); 106 + err_with_revert: 107 + of_changeset_revert(&priv->chan[new_chan].chgset); 106 108 err: 107 109 dev_err(priv->dev, "failed to setup demux-adapter %d (%d)\n", new_chan, ret); 108 110 return ret;
+12 -6
drivers/infiniband/core/cma.c
··· 2462 2462 2463 2463 if (addr->dev_addr.bound_dev_if) { 2464 2464 ndev = dev_get_by_index(&init_net, addr->dev_addr.bound_dev_if); 2465 - if (!ndev) 2466 - return -ENODEV; 2465 + if (!ndev) { 2466 + ret = -ENODEV; 2467 + goto err2; 2468 + } 2467 2469 2468 2470 if (ndev->flags & IFF_LOOPBACK) { 2469 2471 dev_put(ndev); 2470 - if (!id_priv->id.device->get_netdev) 2471 - return -EOPNOTSUPP; 2472 + if (!id_priv->id.device->get_netdev) { 2473 + ret = -EOPNOTSUPP; 2474 + goto err2; 2475 + } 2472 2476 2473 2477 ndev = id_priv->id.device->get_netdev(id_priv->id.device, 2474 2478 id_priv->id.port_num); 2475 - if (!ndev) 2476 - return -ENODEV; 2479 + if (!ndev) { 2480 + ret = -ENODEV; 2481 + goto err2; 2482 + } 2477 2483 } 2478 2484 2479 2485 route->path_rec->net = &init_net;
+5 -1
drivers/infiniband/hw/cxgb4/cm.c
··· 1827 1827 (ep->mpa_pkt + sizeof(*mpa)); 1828 1828 ep->ird = ntohs(mpa_v2_params->ird) & 1829 1829 MPA_V2_IRD_ORD_MASK; 1830 + ep->ird = min_t(u32, ep->ird, 1831 + cur_max_read_depth(ep->com.dev)); 1830 1832 ep->ord = ntohs(mpa_v2_params->ord) & 1831 1833 MPA_V2_IRD_ORD_MASK; 1834 + ep->ord = min_t(u32, ep->ord, 1835 + cur_max_read_depth(ep->com.dev)); 1832 1836 PDBG("%s initiator ird %u ord %u\n", __func__, ep->ird, 1833 1837 ep->ord); 1834 1838 if (ntohs(mpa_v2_params->ird) & MPA_V2_PEER2PEER_MODEL) ··· 3140 3136 if (ep->mpa_attr.version == 2 && ep->mpa_attr.enhanced_rdma_conn) { 3141 3137 if (conn_param->ord > ep->ird) { 3142 3138 if (RELAXED_IRD_NEGOTIATION) { 3143 - ep->ord = ep->ird; 3139 + conn_param->ord = ep->ird; 3144 3140 } else { 3145 3141 ep->ird = conn_param->ird; 3146 3142 ep->ord = conn_param->ord;
+5 -5
drivers/infiniband/hw/cxgb4/cq.c
··· 1016 1016 int c4iw_arm_cq(struct ib_cq *ibcq, enum ib_cq_notify_flags flags) 1017 1017 { 1018 1018 struct c4iw_cq *chp; 1019 - int ret; 1019 + int ret = 0; 1020 1020 unsigned long flag; 1021 1021 1022 1022 chp = to_c4iw_cq(ibcq); 1023 1023 spin_lock_irqsave(&chp->lock, flag); 1024 - ret = t4_arm_cq(&chp->cq, 1025 - (flags & IB_CQ_SOLICITED_MASK) == IB_CQ_SOLICITED); 1024 + t4_arm_cq(&chp->cq, 1025 + (flags & IB_CQ_SOLICITED_MASK) == IB_CQ_SOLICITED); 1026 + if (flags & IB_CQ_REPORT_MISSED_EVENTS) 1027 + ret = t4_cq_notempty(&chp->cq); 1026 1028 spin_unlock_irqrestore(&chp->lock, flag); 1027 - if (ret && !(flags & IB_CQ_REPORT_MISSED_EVENTS)) 1028 - ret = 0; 1029 1029 return ret; 1030 1030 }
+5
drivers/infiniband/hw/cxgb4/t4.h
··· 634 634 return (CQE_GENBIT(cqe) == cq->gen); 635 635 } 636 636 637 + static inline int t4_cq_notempty(struct t4_cq *cq) 638 + { 639 + return cq->sw_in_use || t4_valid_cqe(cq, &cq->queue[cq->cidx]); 640 + } 641 + 637 642 static inline int t4_next_hw_cqe(struct t4_cq *cq, struct t4_cqe **cqe) 638 643 { 639 644 int ret;
+14 -9
drivers/infiniband/hw/hfi1/affinity.c
··· 47 47 #include <linux/topology.h> 48 48 #include <linux/cpumask.h> 49 49 #include <linux/module.h> 50 - #include <linux/cpumask.h> 51 50 52 51 #include "hfi.h" 53 52 #include "affinity.h" ··· 681 682 size_t count) 682 683 { 683 684 struct hfi1_affinity_node *entry; 684 - struct cpumask mask; 685 + cpumask_var_t mask; 685 686 int ret, i; 686 687 687 688 spin_lock(&node_affinity.lock); ··· 691 692 if (!entry) 692 693 return -EINVAL; 693 694 694 - ret = cpulist_parse(buf, &mask); 695 - if (ret) 696 - return ret; 695 + ret = zalloc_cpumask_var(&mask, GFP_KERNEL); 696 + if (!ret) 697 + return -ENOMEM; 697 698 698 - if (!cpumask_subset(&mask, cpu_online_mask) || cpumask_empty(&mask)) { 699 + ret = cpulist_parse(buf, mask); 700 + if (ret) 701 + goto out; 702 + 703 + if (!cpumask_subset(mask, cpu_online_mask) || cpumask_empty(mask)) { 699 704 dd_dev_warn(dd, "Invalid CPU mask\n"); 700 - return -EINVAL; 705 + ret = -EINVAL; 706 + goto out; 701 707 } 702 708 703 709 mutex_lock(&sdma_affinity_mutex); 704 710 /* reset the SDMA interrupt affinity details */ 705 711 init_cpu_mask_set(&entry->def_intr); 706 - cpumask_copy(&entry->def_intr.mask, &mask); 712 + cpumask_copy(&entry->def_intr.mask, mask); 707 713 /* 708 714 * Reassign the affinity for each SDMA interrupt. 709 715 */ ··· 724 720 if (ret) 725 721 break; 726 722 } 727 - 728 723 mutex_unlock(&sdma_affinity_mutex); 724 + out: 725 + free_cpumask_var(mask); 729 726 return ret ? ret : strnlen(buf, PAGE_SIZE); 730 727 } 731 728
+9 -5
drivers/infiniband/hw/hfi1/debugfs.c
··· 223 223 DEBUGFS_FILE_OPS(ctx_stats); 224 224 225 225 static void *_qp_stats_seq_start(struct seq_file *s, loff_t *pos) 226 - __acquires(RCU) 226 + __acquires(RCU) 227 227 { 228 228 struct qp_iter *iter; 229 229 loff_t n = *pos; 230 230 231 - rcu_read_lock(); 232 231 iter = qp_iter_init(s->private); 232 + 233 + /* stop calls rcu_read_unlock */ 234 + rcu_read_lock(); 235 + 233 236 if (!iter) 234 237 return NULL; 235 238 236 - while (n--) { 239 + do { 237 240 if (qp_iter_next(iter)) { 238 241 kfree(iter); 239 242 return NULL; 240 243 } 241 - } 244 + } while (n--); 242 245 243 246 return iter; 244 247 } 245 248 246 249 static void *_qp_stats_seq_next(struct seq_file *s, void *iter_ptr, 247 250 loff_t *pos) 251 + __must_hold(RCU) 248 252 { 249 253 struct qp_iter *iter = iter_ptr; 250 254 ··· 263 259 } 264 260 265 261 static void _qp_stats_seq_stop(struct seq_file *s, void *iter_ptr) 266 - __releases(RCU) 262 + __releases(RCU) 267 263 { 268 264 rcu_read_unlock(); 269 265 }
+6 -5
drivers/infiniband/hw/hfi1/driver.c
··· 888 888 } 889 889 890 890 static inline int set_armed_to_active(struct hfi1_ctxtdata *rcd, 891 - struct hfi1_packet packet, 891 + struct hfi1_packet *packet, 892 892 struct hfi1_devdata *dd) 893 893 { 894 894 struct work_struct *lsaw = &rcd->ppd->linkstate_active_work; 895 - struct hfi1_message_header *hdr = hfi1_get_msgheader(packet.rcd->dd, 896 - packet.rhf_addr); 895 + struct hfi1_message_header *hdr = hfi1_get_msgheader(packet->rcd->dd, 896 + packet->rhf_addr); 897 + u8 etype = rhf_rcv_type(packet->rhf); 897 898 898 - if (hdr2sc(hdr, packet.rhf) != 0xf) { 899 + if (etype == RHF_RCV_TYPE_IB && hdr2sc(hdr, packet->rhf) != 0xf) { 899 900 int hwstate = read_logical_state(dd); 900 901 901 902 if (hwstate != LSTATE_ACTIVE) { ··· 980 979 /* Auto activate link on non-SC15 packet receive */ 981 980 if (unlikely(rcd->ppd->host_link_state == 982 981 HLS_UP_ARMED) && 983 - set_armed_to_active(rcd, packet, dd)) 982 + set_armed_to_active(rcd, &packet, dd)) 984 983 goto bail; 985 984 last = process_rcv_packet(&packet, thread); 986 985 }
+3 -1
drivers/infiniband/hw/hfi1/file_ops.c
··· 183 183 if (fd) { 184 184 fd->rec_cpu_num = -1; /* no cpu affinity by default */ 185 185 fd->mm = current->mm; 186 + atomic_inc(&fd->mm->mm_count); 186 187 } 187 188 188 189 fp->private_data = fd; ··· 223 222 ret = assign_ctxt(fp, &uinfo); 224 223 if (ret < 0) 225 224 return ret; 226 - setup_ctxt(fp); 225 + ret = setup_ctxt(fp); 227 226 if (ret) 228 227 return ret; 229 228 ret = user_init(fp); ··· 780 779 mutex_unlock(&hfi1_mutex); 781 780 hfi1_free_ctxtdata(dd, uctxt); 782 781 done: 782 + mmdrop(fdata->mm); 783 783 kobject_put(&dd->kobj); 784 784 kfree(fdata); 785 785 return 0;
+18 -2
drivers/infiniband/hw/hfi1/hfi.h
··· 1272 1272 ((!!(rhf_dc_info(rhf))) << 4); 1273 1273 } 1274 1274 1275 + #define HFI1_JKEY_WIDTH 16 1276 + #define HFI1_JKEY_MASK (BIT(16) - 1) 1277 + #define HFI1_ADMIN_JKEY_RANGE 32 1278 + 1279 + /* 1280 + * J_KEYs are split and allocated in the following groups: 1281 + * 0 - 31 - users with administrator privileges 1282 + * 32 - 63 - kernel protocols using KDETH packets 1283 + * 64 - 65535 - all other users using KDETH packets 1284 + */ 1275 1285 static inline u16 generate_jkey(kuid_t uid) 1276 1286 { 1277 - return from_kuid(current_user_ns(), uid) & 0xffff; 1287 + u16 jkey = from_kuid(current_user_ns(), uid) & HFI1_JKEY_MASK; 1288 + 1289 + if (capable(CAP_SYS_ADMIN)) 1290 + jkey &= HFI1_ADMIN_JKEY_RANGE - 1; 1291 + else if (jkey < 64) 1292 + jkey |= BIT(HFI1_JKEY_WIDTH - 1); 1293 + 1294 + return jkey; 1278 1295 } 1279 1296 1280 1297 /* ··· 1673 1656 struct hfi1_devdata *hfi1_init_dd(struct pci_dev *, 1674 1657 const struct pci_device_id *); 1675 1658 void hfi1_free_devdata(struct hfi1_devdata *); 1676 - void cc_state_reclaim(struct rcu_head *rcu); 1677 1659 struct hfi1_devdata *hfi1_alloc_devdata(struct pci_dev *pdev, size_t extra); 1678 1660 1679 1661 /* LED beaconing functions */
+1 -1
drivers/infiniband/hw/hfi1/init.c
··· 1333 1333 spin_unlock(&ppd->cc_state_lock); 1334 1334 1335 1335 if (cc_state) 1336 - call_rcu(&cc_state->rcu, cc_state_reclaim); 1336 + kfree_rcu(cc_state, rcu); 1337 1337 } 1338 1338 1339 1339 free_credit_return(dd);
+6 -8
drivers/infiniband/hw/hfi1/mad.c
··· 1819 1819 u32 len = OPA_AM_CI_LEN(am) + 1; 1820 1820 int ret; 1821 1821 1822 + if (dd->pport->port_type != PORT_TYPE_QSFP) { 1823 + smp->status |= IB_SMP_INVALID_FIELD; 1824 + return reply((struct ib_mad_hdr *)smp); 1825 + } 1826 + 1822 1827 #define __CI_PAGE_SIZE BIT(7) /* 128 bytes */ 1823 1828 #define __CI_PAGE_MASK ~(__CI_PAGE_SIZE - 1) 1824 1829 #define __CI_PAGE_NUM(a) ((a) & __CI_PAGE_MASK) ··· 3403 3398 3404 3399 spin_unlock(&ppd->cc_state_lock); 3405 3400 3406 - call_rcu(&old_cc_state->rcu, cc_state_reclaim); 3401 + kfree_rcu(old_cc_state, rcu); 3407 3402 } 3408 3403 3409 3404 static int __subn_set_opa_cong_setting(struct opa_smp *smp, u32 am, u8 *data, ··· 3556 3551 *resp_len += sizeof(u16) * (IB_CCT_ENTRIES * n_blocks + 1); 3557 3552 3558 3553 return reply((struct ib_mad_hdr *)smp); 3559 - } 3560 - 3561 - void cc_state_reclaim(struct rcu_head *rcu) 3562 - { 3563 - struct cc_state *cc_state = container_of(rcu, struct cc_state, rcu); 3564 - 3565 - kfree(cc_state); 3566 3554 } 3567 3555 3568 3556 static int __subn_set_opa_cc_table(struct opa_smp *smp, u32 am, u8 *data,
-4
drivers/infiniband/hw/hfi1/qp.c
··· 656 656 657 657 iter->dev = dev; 658 658 iter->specials = dev->rdi.ibdev.phys_port_cnt * 2; 659 - if (qp_iter_next(iter)) { 660 - kfree(iter); 661 - return NULL; 662 - } 663 659 664 660 return iter; 665 661 }
+30 -2
drivers/infiniband/hw/hfi1/qsfp.c
··· 706 706 u8 *data) 707 707 { 708 708 struct hfi1_pportdata *ppd; 709 - u32 excess_len = 0; 710 - int ret = 0; 709 + u32 excess_len = len; 710 + int ret = 0, offset = 0; 711 711 712 712 if (port_num > dd->num_pports || port_num < 1) { 713 713 dd_dev_info(dd, "%s: Invalid port number %d\n", ··· 740 740 } 741 741 742 742 memcpy(data, &ppd->qsfp_info.cache[addr], len); 743 + 744 + if (addr <= QSFP_MONITOR_VAL_END && 745 + (addr + len) >= QSFP_MONITOR_VAL_START) { 746 + /* Overlap with the dynamic channel monitor range */ 747 + if (addr < QSFP_MONITOR_VAL_START) { 748 + if (addr + len <= QSFP_MONITOR_VAL_END) 749 + len = addr + len - QSFP_MONITOR_VAL_START; 750 + else 751 + len = QSFP_MONITOR_RANGE; 752 + offset = QSFP_MONITOR_VAL_START - addr; 753 + addr = QSFP_MONITOR_VAL_START; 754 + } else if (addr == QSFP_MONITOR_VAL_START) { 755 + offset = 0; 756 + if (addr + len > QSFP_MONITOR_VAL_END) 757 + len = QSFP_MONITOR_RANGE; 758 + } else { 759 + offset = 0; 760 + if (addr + len > QSFP_MONITOR_VAL_END) 761 + len = QSFP_MONITOR_VAL_END - addr + 1; 762 + } 763 + /* Refresh the values of the dynamic monitors from the cable */ 764 + ret = one_qsfp_read(ppd, dd->hfi1_id, addr, data + offset, len); 765 + if (ret != len) { 766 + ret = -EAGAIN; 767 + goto set_zeroes; 768 + } 769 + } 770 + 743 771 return 0; 744 772 745 773 set_zeroes:
+3
drivers/infiniband/hw/hfi1/qsfp.h
··· 74 74 /* Defined fields that Intel requires of qualified cables */ 75 75 /* Byte 0 is Identifier, not checked */ 76 76 /* Byte 1 is reserved "status MSB" */ 77 + #define QSFP_MONITOR_VAL_START 22 78 + #define QSFP_MONITOR_VAL_END 81 79 + #define QSFP_MONITOR_RANGE (QSFP_MONITOR_VAL_END - QSFP_MONITOR_VAL_START + 1) 77 80 #define QSFP_TX_CTRL_BYTE_OFFS 86 78 81 #define QSFP_PWR_CTRL_BYTE_OFFS 93 79 82 #define QSFP_CDR_CTRL_BYTE_OFFS 98
+2 -2
drivers/infiniband/hw/i40iw/i40iw.h
··· 232 232 struct i40e_client *client; 233 233 struct i40iw_hw hw; 234 234 struct i40iw_cm_core cm_core; 235 - unsigned long *mem_resources; 235 + u8 *mem_resources; 236 236 unsigned long *allocated_qps; 237 237 unsigned long *allocated_cqs; 238 238 unsigned long *allocated_mrs; ··· 435 435 *next = resource_num + 1; 436 436 if (*next == max_resources) 437 437 *next = 0; 438 - spin_unlock_irqrestore(&iwdev->resource_lock, flags); 439 438 *req_resource_num = resource_num; 439 + spin_unlock_irqrestore(&iwdev->resource_lock, flags); 440 440 441 441 return 0; 442 442 }
+3 -23
drivers/infiniband/hw/i40iw/i40iw_cm.c
··· 535 535 buf += hdr_len; 536 536 } 537 537 538 - if (pd_len) 539 - memcpy(buf, pdata->addr, pd_len); 538 + if (pdata && pdata->addr) 539 + memcpy(buf, pdata->addr, pdata->size); 540 540 541 541 atomic_set(&sqbuf->refcount, 1); 542 542 ··· 3347 3347 } 3348 3348 3349 3349 /** 3350 - * i40iw_loopback_nop - Send a nop 3351 - * @qp: associated hw qp 3352 - */ 3353 - static void i40iw_loopback_nop(struct i40iw_sc_qp *qp) 3354 - { 3355 - u64 *wqe; 3356 - u64 header; 3357 - 3358 - wqe = qp->qp_uk.sq_base->elem; 3359 - set_64bit_val(wqe, 0, 0); 3360 - set_64bit_val(wqe, 8, 0); 3361 - set_64bit_val(wqe, 16, 0); 3362 - 3363 - header = LS_64(I40IWQP_OP_NOP, I40IWQPSQ_OPCODE) | 3364 - LS_64(0, I40IWQPSQ_SIGCOMPL) | 3365 - LS_64(qp->qp_uk.swqe_polarity, I40IWQPSQ_VALID); 3366 - set_64bit_val(wqe, 24, header); 3367 - } 3368 - 3369 - /** 3370 3350 * i40iw_qp_disconnect - free qp and close cm 3371 3351 * @iwqp: associate qp for the connection 3372 3352 */ ··· 3618 3638 } else { 3619 3639 if (iwqp->page) 3620 3640 iwqp->sc_qp.qp_uk.sq_base = kmap(iwqp->page); 3621 - i40iw_loopback_nop(&iwqp->sc_qp); 3641 + dev->iw_priv_qp_ops->qp_send_lsmm(&iwqp->sc_qp, NULL, 0, 0); 3622 3642 } 3623 3643 3624 3644 if (iwqp->page)
+4
drivers/infiniband/hw/i40iw/i40iw_main.c
··· 1558 1558 enum i40iw_status_code status; 1559 1559 struct i40iw_handler *hdl; 1560 1560 1561 + hdl = i40iw_find_netdev(ldev->netdev); 1562 + if (hdl) 1563 + return 0; 1564 + 1561 1565 hdl = kzalloc(sizeof(*hdl), GFP_KERNEL); 1562 1566 if (!hdl) 1563 1567 return -ENOMEM;
+4 -1
drivers/infiniband/hw/i40iw/i40iw_utils.c
··· 673 673 { 674 674 if (!mem) 675 675 return I40IW_ERR_PARAM; 676 + /* 677 + * mem->va points to the parent of mem, so both mem and mem->va 678 + * can not be touched once mem->va is freed 679 + */ 676 680 kfree(mem->va); 677 - mem->va = NULL; 678 681 return 0; 679 682 } 680 683
+1 -3
drivers/infiniband/hw/i40iw/i40iw_verbs.c
··· 794 794 return &iwqp->ibqp; 795 795 error: 796 796 i40iw_free_qp_resources(iwdev, iwqp, qp_num); 797 - kfree(mem); 798 797 return ERR_PTR(err_code); 799 798 } 800 799 ··· 1925 1926 } 1926 1927 if (iwpbl->pbl_allocated) 1927 1928 i40iw_free_pble(iwdev->pble_rsrc, palloc); 1928 - kfree(iwpbl->iwmr); 1929 - iwpbl->iwmr = NULL; 1929 + kfree(iwmr); 1930 1930 return 0; 1931 1931 } 1932 1932
+10 -10
drivers/infiniband/hw/mlx4/cq.c
··· 576 576 checksum == cpu_to_be16(0xffff); 577 577 } 578 578 579 - static int use_tunnel_data(struct mlx4_ib_qp *qp, struct mlx4_ib_cq *cq, struct ib_wc *wc, 580 - unsigned tail, struct mlx4_cqe *cqe, int is_eth) 579 + static void use_tunnel_data(struct mlx4_ib_qp *qp, struct mlx4_ib_cq *cq, struct ib_wc *wc, 580 + unsigned tail, struct mlx4_cqe *cqe, int is_eth) 581 581 { 582 582 struct mlx4_ib_proxy_sqp_hdr *hdr; 583 583 ··· 600 600 wc->slid = be16_to_cpu(hdr->tun.slid_mac_47_32); 601 601 wc->sl = (u8) (be16_to_cpu(hdr->tun.sl_vid) >> 12); 602 602 } 603 - 604 - return 0; 605 603 } 606 604 607 605 static void mlx4_ib_qp_sw_comp(struct mlx4_ib_qp *qp, int num_entries, ··· 690 692 if (unlikely((cqe->owner_sr_opcode & MLX4_CQE_OPCODE_MASK) == MLX4_OPCODE_NOP && 691 693 is_send)) { 692 694 pr_warn("Completion for NOP opcode detected!\n"); 693 - return -EINVAL; 695 + return -EAGAIN; 694 696 } 695 697 696 698 /* Resize CQ in progress */ ··· 721 723 if (unlikely(!mqp)) { 722 724 pr_warn("CQ %06x with entry for unknown QPN %06x\n", 723 725 cq->mcq.cqn, be32_to_cpu(cqe->vlan_my_qpn) & MLX4_CQE_QPN_MASK); 724 - return -EINVAL; 726 + return -EAGAIN; 725 727 } 726 728 727 729 *cur_qp = to_mibqp(mqp); ··· 739 741 if (unlikely(!msrq)) { 740 742 pr_warn("CQ %06x with entry for unknown SRQN %06x\n", 741 743 cq->mcq.cqn, srq_num); 742 - return -EINVAL; 744 + return -EAGAIN; 743 745 } 744 746 } 745 747 ··· 850 852 if (mlx4_is_mfunc(to_mdev(cq->ibcq.device)->dev)) { 851 853 if ((*cur_qp)->mlx4_ib_qp_type & 852 854 (MLX4_IB_QPT_PROXY_SMI_OWNER | 853 - MLX4_IB_QPT_PROXY_SMI | MLX4_IB_QPT_PROXY_GSI)) 854 - return use_tunnel_data(*cur_qp, cq, wc, tail, 855 - cqe, is_eth); 855 + MLX4_IB_QPT_PROXY_SMI | MLX4_IB_QPT_PROXY_GSI)) { 856 + use_tunnel_data(*cur_qp, cq, wc, tail, cqe, 857 + is_eth); 858 + return 0; 859 + } 856 860 } 857 861 858 862 wc->slid = be16_to_cpu(cqe->rlid);
-1
drivers/infiniband/hw/mlx5/main.c
··· 37 37 #include <linux/pci.h> 38 38 #include <linux/dma-mapping.h> 39 39 #include <linux/slab.h> 40 - #include <linux/io-mapping.h> 41 40 #if defined(CONFIG_X86) 42 41 #include <asm/pat.h> 43 42 #endif
+7 -7
drivers/infiniband/hw/ocrdma/ocrdma_hw.c
··· 1156 1156 attr->max_srq = 1157 1157 (rsp->max_srq_rpir_qps & OCRDMA_MBX_QUERY_CFG_MAX_SRQ_MASK) >> 1158 1158 OCRDMA_MBX_QUERY_CFG_MAX_SRQ_OFFSET; 1159 - attr->max_send_sge = ((rsp->max_write_send_sge & 1159 + attr->max_send_sge = ((rsp->max_recv_send_sge & 1160 1160 OCRDMA_MBX_QUERY_CFG_MAX_SEND_SGE_MASK) >> 1161 1161 OCRDMA_MBX_QUERY_CFG_MAX_SEND_SGE_SHIFT); 1162 - attr->max_recv_sge = (rsp->max_write_send_sge & 1163 - OCRDMA_MBX_QUERY_CFG_MAX_SEND_SGE_MASK) >> 1164 - OCRDMA_MBX_QUERY_CFG_MAX_SEND_SGE_SHIFT; 1162 + attr->max_recv_sge = (rsp->max_recv_send_sge & 1163 + OCRDMA_MBX_QUERY_CFG_MAX_RECV_SGE_MASK) >> 1164 + OCRDMA_MBX_QUERY_CFG_MAX_RECV_SGE_SHIFT; 1165 1165 attr->max_srq_sge = (rsp->max_srq_rqe_sge & 1166 1166 OCRDMA_MBX_QUERY_CFG_MAX_SRQ_SGE_MASK) >> 1167 1167 OCRDMA_MBX_QUERY_CFG_MAX_SRQ_SGE_OFFSET; 1168 - attr->max_rdma_sge = (rsp->max_write_send_sge & 1169 - OCRDMA_MBX_QUERY_CFG_MAX_WRITE_SGE_MASK) >> 1170 - OCRDMA_MBX_QUERY_CFG_MAX_WRITE_SGE_SHIFT; 1168 + attr->max_rdma_sge = (rsp->max_wr_rd_sge & 1169 + OCRDMA_MBX_QUERY_CFG_MAX_RD_SGE_MASK) >> 1170 + OCRDMA_MBX_QUERY_CFG_MAX_RD_SGE_SHIFT; 1171 1171 attr->max_ord_per_qp = (rsp->max_ird_ord_per_qp & 1172 1172 OCRDMA_MBX_QUERY_CFG_MAX_ORD_PER_QP_MASK) >> 1173 1173 OCRDMA_MBX_QUERY_CFG_MAX_ORD_PER_QP_SHIFT;
+8 -4
drivers/infiniband/hw/ocrdma/ocrdma_sli.h
··· 554 554 OCRDMA_MBX_QUERY_CFG_L3_TYPE_MASK = 0x18, 555 555 OCRDMA_MBX_QUERY_CFG_MAX_SEND_SGE_SHIFT = 0, 556 556 OCRDMA_MBX_QUERY_CFG_MAX_SEND_SGE_MASK = 0xFFFF, 557 - OCRDMA_MBX_QUERY_CFG_MAX_WRITE_SGE_SHIFT = 16, 558 - OCRDMA_MBX_QUERY_CFG_MAX_WRITE_SGE_MASK = 0xFFFF << 559 - OCRDMA_MBX_QUERY_CFG_MAX_WRITE_SGE_SHIFT, 557 + OCRDMA_MBX_QUERY_CFG_MAX_RECV_SGE_SHIFT = 16, 558 + OCRDMA_MBX_QUERY_CFG_MAX_RECV_SGE_MASK = 0xFFFF << 559 + OCRDMA_MBX_QUERY_CFG_MAX_RECV_SGE_SHIFT, 560 560 561 561 OCRDMA_MBX_QUERY_CFG_MAX_ORD_PER_QP_SHIFT = 0, 562 562 OCRDMA_MBX_QUERY_CFG_MAX_ORD_PER_QP_MASK = 0xFFFF, ··· 612 612 OCRDMA_MBX_QUERY_CFG_MAX_SRQ_SGE_OFFSET = 0, 613 613 OCRDMA_MBX_QUERY_CFG_MAX_SRQ_SGE_MASK = 0xFFFF << 614 614 OCRDMA_MBX_QUERY_CFG_MAX_SRQ_SGE_OFFSET, 615 + OCRDMA_MBX_QUERY_CFG_MAX_RD_SGE_SHIFT = 0, 616 + OCRDMA_MBX_QUERY_CFG_MAX_RD_SGE_MASK = 0xFFFF, 615 617 }; 616 618 617 619 struct ocrdma_mbx_query_config { ··· 621 619 struct ocrdma_mbx_rsp rsp; 622 620 u32 qp_srq_cq_ird_ord; 623 621 u32 max_pd_ca_ack_delay; 624 - u32 max_write_send_sge; 622 + u32 max_recv_send_sge; 625 623 u32 max_ird_ord_per_qp; 626 624 u32 max_shared_ird_ord; 627 625 u32 max_mr; ··· 641 639 u32 max_wqes_rqes_per_q; 642 640 u32 max_cq_cqes_per_cq; 643 641 u32 max_srq_rqe_sge; 642 + u32 max_wr_rd_sge; 643 + u32 ird_pgsz_num_pages; 644 644 }; 645 645 646 646 struct ocrdma_fw_ver_rsp {
+2 -2
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
··· 125 125 IB_DEVICE_SYS_IMAGE_GUID | 126 126 IB_DEVICE_LOCAL_DMA_LKEY | 127 127 IB_DEVICE_MEM_MGT_EXTENSIONS; 128 - attr->max_sge = dev->attr.max_send_sge; 129 - attr->max_sge_rd = attr->max_sge; 128 + attr->max_sge = min(dev->attr.max_send_sge, dev->attr.max_recv_sge); 129 + attr->max_sge_rd = dev->attr.max_rdma_sge; 130 130 attr->max_cq = dev->attr.max_cq; 131 131 attr->max_cqe = dev->attr.max_cqe; 132 132 attr->max_mr = dev->attr.max_mr;
+9 -3
drivers/infiniband/hw/qib/qib_debugfs.c
··· 189 189 DEBUGFS_FILE(ctx_stats) 190 190 191 191 static void *_qp_stats_seq_start(struct seq_file *s, loff_t *pos) 192 + __acquires(RCU) 192 193 { 193 194 struct qib_qp_iter *iter; 194 195 loff_t n = *pos; 195 196 196 - rcu_read_lock(); 197 197 iter = qib_qp_iter_init(s->private); 198 + 199 + /* stop calls rcu_read_unlock */ 200 + rcu_read_lock(); 201 + 198 202 if (!iter) 199 203 return NULL; 200 204 201 - while (n--) { 205 + do { 202 206 if (qib_qp_iter_next(iter)) { 203 207 kfree(iter); 204 208 return NULL; 205 209 } 206 - } 210 + } while (n--); 207 211 208 212 return iter; 209 213 } 210 214 211 215 static void *_qp_stats_seq_next(struct seq_file *s, void *iter_ptr, 212 216 loff_t *pos) 217 + __must_hold(RCU) 213 218 { 214 219 struct qib_qp_iter *iter = iter_ptr; 215 220 ··· 229 224 } 230 225 231 226 static void _qp_stats_seq_stop(struct seq_file *s, void *iter_ptr) 227 + __releases(RCU) 232 228 { 233 229 rcu_read_unlock(); 234 230 }
+5 -21
drivers/infiniband/hw/qib/qib_fs.c
··· 328 328 329 329 pos = *ppos; 330 330 331 - if (pos != 0) { 332 - ret = -EINVAL; 333 - goto bail; 334 - } 331 + if (pos != 0 || count != sizeof(struct qib_flash)) 332 + return -EINVAL; 335 333 336 - if (count != sizeof(struct qib_flash)) { 337 - ret = -EINVAL; 338 - goto bail; 339 - } 340 - 341 - tmp = kmalloc(count, GFP_KERNEL); 342 - if (!tmp) { 343 - ret = -ENOMEM; 344 - goto bail; 345 - } 346 - 347 - if (copy_from_user(tmp, buf, count)) { 348 - ret = -EFAULT; 349 - goto bail_tmp; 350 - } 334 + tmp = memdup_user(buf, count); 335 + if (IS_ERR(tmp)) 336 + return PTR_ERR(tmp); 351 337 352 338 dd = private2dd(file); 353 339 if (qib_eeprom_write(dd, pos, tmp, count)) { ··· 347 361 348 362 bail_tmp: 349 363 kfree(tmp); 350 - 351 - bail: 352 364 return ret; 353 365 } 354 366
-4
drivers/infiniband/hw/qib/qib_qp.c
··· 573 573 return NULL; 574 574 575 575 iter->dev = dev; 576 - if (qib_qp_iter_next(iter)) { 577 - kfree(iter); 578 - return NULL; 579 - } 580 576 581 577 return iter; 582 578 }
+2 -1
drivers/infiniband/hw/usnic/usnic_ib_main.c
··· 664 664 return err; 665 665 } 666 666 667 - if (pci_register_driver(&usnic_ib_pci_driver)) { 667 + err = pci_register_driver(&usnic_ib_pci_driver); 668 + if (err) { 668 669 usnic_err("Unable to register with PCI\n"); 669 670 goto out_umem_fini; 670 671 }
+2 -1
drivers/infiniband/sw/rdmavt/qp.c
··· 873 873 free_qpn(&rdi->qp_dev->qpn_table, qp->ibqp.qp_num); 874 874 875 875 bail_rq_wq: 876 - vfree(qp->r_rq.wq); 876 + if (!qp->ip) 877 + vfree(qp->r_rq.wq); 877 878 878 879 bail_driver_priv: 879 880 rdi->driver_f.qp_priv_free(rdi, qp);
+1 -1
drivers/infiniband/ulp/isert/ib_isert.c
··· 448 448 449 449 isert_conn->login_rsp_buf = kzalloc(ISER_RX_PAYLOAD_SIZE, GFP_KERNEL); 450 450 if (!isert_conn->login_rsp_buf) { 451 - isert_err("Unable to allocate isert_conn->login_rspbuf\n"); 451 + ret = -ENOMEM; 452 452 goto out_unmap_login_req_buf; 453 453 } 454 454
+5 -4
drivers/infiniband/ulp/srpt/ib_srpt.c
··· 522 522 if (ret) 523 523 goto err_query_port; 524 524 525 + snprintf(sport->port_guid, sizeof(sport->port_guid), 526 + "0x%016llx%016llx", 527 + be64_to_cpu(sport->gid.global.subnet_prefix), 528 + be64_to_cpu(sport->gid.global.interface_id)); 529 + 525 530 if (!sport->mad_agent) { 526 531 memset(&reg_req, 0, sizeof(reg_req)); 527 532 reg_req.mgmt_class = IB_MGMT_CLASS_DEVICE_MGMT; ··· 2553 2548 sdev->device->name, i); 2554 2549 goto err_ring; 2555 2550 } 2556 - snprintf(sport->port_guid, sizeof(sport->port_guid), 2557 - "0x%016llx%016llx", 2558 - be64_to_cpu(sport->gid.global.subnet_prefix), 2559 - be64_to_cpu(sport->gid.global.interface_id)); 2560 2551 } 2561 2552 2562 2553 spin_lock(&srpt_dev_lock);
+1 -1
drivers/input/keyboard/tegra-kbc.c
··· 376 376 /* Reset the KBC controller to clear all previous status.*/ 377 377 reset_control_assert(kbc->rst); 378 378 udelay(100); 379 - reset_control_assert(kbc->rst); 379 + reset_control_deassert(kbc->rst); 380 380 udelay(100); 381 381 382 382 tegra_kbc_config_pins(kbc);
+2 -1
drivers/input/rmi4/rmi_driver.c
··· 553 553 goto free_struct_buff; 554 554 555 555 reg = find_first_bit(rdesc->presense_map, RMI_REG_DESC_PRESENSE_BITS); 556 - map_offset = 0; 557 556 for (i = 0; i < rdesc->num_registers; i++) { 558 557 struct rmi_register_desc_item *item = &rdesc->registers[i]; 559 558 int reg_size = struct_buf[offset]; ··· 574 575 575 576 item->reg = reg; 576 577 item->reg_size = reg_size; 578 + 579 + map_offset = 0; 577 580 578 581 do { 579 582 for (b = 0; b < 7; b++) {
+1
drivers/input/serio/i8042.c
··· 1305 1305 serio->write = i8042_aux_write; 1306 1306 serio->start = i8042_start; 1307 1307 serio->stop = i8042_stop; 1308 + serio->ps2_cmd_mutex = &i8042_mutex; 1308 1309 serio->port_data = port; 1309 1310 serio->dev.parent = &i8042_platform_device->dev; 1310 1311 if (idx < 0) {
-1
drivers/input/touchscreen/ads7846.c
··· 1473 1473 1474 1474 ads784x_hwmon_unregister(spi, ts); 1475 1475 1476 - regulator_disable(ts->reg); 1477 1476 regulator_put(ts->reg); 1478 1477 1479 1478 if (!ts->get_pendown_state) {
+1 -1
drivers/input/touchscreen/silead.c
··· 464 464 return -ENODEV; 465 465 466 466 /* Power GPIO pin */ 467 - data->gpio_power = gpiod_get_optional(dev, "power", GPIOD_OUT_LOW); 467 + data->gpio_power = devm_gpiod_get_optional(dev, "power", GPIOD_OUT_LOW); 468 468 if (IS_ERR(data->gpio_power)) { 469 469 if (PTR_ERR(data->gpio_power) != -EPROBE_DEFER) 470 470 dev_err(dev, "Shutdown GPIO request failed\n");
+5 -2
drivers/iommu/arm-smmu-v3.c
··· 879 879 * We may have concurrent producers, so we need to be careful 880 880 * not to touch any of the shadow cmdq state. 881 881 */ 882 - queue_read(cmd, Q_ENT(q, idx), q->ent_dwords); 882 + queue_read(cmd, Q_ENT(q, cons), q->ent_dwords); 883 883 dev_err(smmu->dev, "skipping command in error state:\n"); 884 884 for (i = 0; i < ARRAY_SIZE(cmd); ++i) 885 885 dev_err(smmu->dev, "\t0x%016llx\n", (unsigned long long)cmd[i]); ··· 890 890 return; 891 891 } 892 892 893 - queue_write(cmd, Q_ENT(q, idx), q->ent_dwords); 893 + queue_write(Q_ENT(q, cons), cmd, q->ent_dwords); 894 894 } 895 895 896 896 static void arm_smmu_cmdq_issue_cmd(struct arm_smmu_device *smmu, ··· 1034 1034 case STRTAB_STE_0_CFG_S2_TRANS: 1035 1035 ste_live = true; 1036 1036 break; 1037 + case STRTAB_STE_0_CFG_ABORT: 1038 + if (disable_bypass) 1039 + break; 1037 1040 default: 1038 1041 BUG(); /* STE corruption */ 1039 1042 }
+7 -27
drivers/iommu/arm-smmu.c
··· 686 686 687 687 static irqreturn_t arm_smmu_context_fault(int irq, void *dev) 688 688 { 689 - int flags, ret; 690 - u32 fsr, fsynr, resume; 689 + u32 fsr, fsynr; 691 690 unsigned long iova; 692 691 struct iommu_domain *domain = dev; 693 692 struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain); ··· 700 701 if (!(fsr & FSR_FAULT)) 701 702 return IRQ_NONE; 702 703 703 - if (fsr & FSR_IGN) 704 - dev_err_ratelimited(smmu->dev, 705 - "Unexpected context fault (fsr 0x%x)\n", 706 - fsr); 707 - 708 704 fsynr = readl_relaxed(cb_base + ARM_SMMU_CB_FSYNR0); 709 - flags = fsynr & FSYNR0_WNR ? IOMMU_FAULT_WRITE : IOMMU_FAULT_READ; 710 - 711 705 iova = readq_relaxed(cb_base + ARM_SMMU_CB_FAR); 712 - if (!report_iommu_fault(domain, smmu->dev, iova, flags)) { 713 - ret = IRQ_HANDLED; 714 - resume = RESUME_RETRY; 715 - } else { 716 - dev_err_ratelimited(smmu->dev, 717 - "Unhandled context fault: iova=0x%08lx, fsynr=0x%x, cb=%d\n", 718 - iova, fsynr, cfg->cbndx); 719 - ret = IRQ_NONE; 720 - resume = RESUME_TERMINATE; 721 - } 722 706 723 - /* Clear the faulting FSR */ 707 + dev_err_ratelimited(smmu->dev, 708 + "Unhandled context fault: fsr=0x%x, iova=0x%08lx, fsynr=0x%x, cb=%d\n", 709 + fsr, iova, fsynr, cfg->cbndx); 710 + 724 711 writel(fsr, cb_base + ARM_SMMU_CB_FSR); 725 - 726 - /* Retry or terminate any stalled transactions */ 727 - if (fsr & FSR_SS) 728 - writel_relaxed(resume, cb_base + ARM_SMMU_CB_RESUME); 729 - 730 - return ret; 712 + return IRQ_HANDLED; 731 713 } 732 714 733 715 static irqreturn_t arm_smmu_global_fault(int irq, void *dev) ··· 817 837 } 818 838 819 839 /* SCTLR */ 820 - reg = SCTLR_CFCFG | SCTLR_CFIE | SCTLR_CFRE | SCTLR_M | SCTLR_EAE_SBOP; 840 + reg = SCTLR_CFIE | SCTLR_CFRE | SCTLR_M | SCTLR_EAE_SBOP; 821 841 if (stage1) 822 842 reg |= SCTLR_S1_ASIDPNE; 823 843 #ifdef __BIG_ENDIAN
+3 -1
drivers/iommu/io-pgtable-arm-v7s.c
··· 286 286 int prot = IOMMU_READ; 287 287 arm_v7s_iopte attr = pte >> ARM_V7S_ATTR_SHIFT(lvl); 288 288 289 - if (attr & ARM_V7S_PTE_AP_RDONLY) 289 + if (!(attr & ARM_V7S_PTE_AP_RDONLY)) 290 290 prot |= IOMMU_WRITE; 291 291 if ((attr & (ARM_V7S_TEX_MASK << ARM_V7S_TEX_SHIFT)) == 0) 292 292 prot |= IOMMU_MMIO; 293 293 else if (pte & ARM_V7S_ATTR_C) 294 294 prot |= IOMMU_CACHE; 295 + if (pte & ARM_V7S_ATTR_XN(lvl)) 296 + prot |= IOMMU_NOEXEC; 295 297 296 298 return prot; 297 299 }
+6 -1
drivers/irqchip/irq-gic-v3-its.c
··· 1545 1545 u32 val; 1546 1546 1547 1547 val = readl_relaxed(base + GITS_CTLR); 1548 - if (val & GITS_CTLR_QUIESCENT) 1548 + /* 1549 + * GIC architecture specification requires the ITS to be both 1550 + * disabled and quiescent for writes to GITS_BASER<n> or 1551 + * GITS_CBASER to not have UNPREDICTABLE results. 1552 + */ 1553 + if ((val & GITS_CTLR_QUIESCENT) && !(val & GITS_CTLR_ENABLE)) 1549 1554 return 0; 1550 1555 1551 1556 /* Disable the generation of all interrupts to this ITS */
+9 -2
drivers/irqchip/irq-gic-v3.c
··· 667 667 #endif 668 668 669 669 #ifdef CONFIG_CPU_PM 670 + /* Check whether it's single security state view */ 671 + static bool gic_dist_security_disabled(void) 672 + { 673 + return readl_relaxed(gic_data.dist_base + GICD_CTLR) & GICD_CTLR_DS; 674 + } 675 + 670 676 static int gic_cpu_pm_notifier(struct notifier_block *self, 671 677 unsigned long cmd, void *v) 672 678 { 673 679 if (cmd == CPU_PM_EXIT) { 674 - gic_enable_redist(true); 680 + if (gic_dist_security_disabled()) 681 + gic_enable_redist(true); 675 682 gic_cpu_sys_reg_init(); 676 - } else if (cmd == CPU_PM_ENTER) { 683 + } else if (cmd == CPU_PM_ENTER && gic_dist_security_disabled()) { 677 684 gic_write_grpen1(0); 678 685 gic_enable_redist(false); 679 686 }
+7
drivers/irqchip/irq-gic.c
··· 769 769 int cpu; 770 770 unsigned long flags, map = 0; 771 771 772 + if (unlikely(nr_cpu_ids == 1)) { 773 + /* Only one CPU? let's do a self-IPI... */ 774 + writel_relaxed(2 << 24 | irq, 775 + gic_data_dist_base(&gic_data[0]) + GIC_DIST_SOFTINT); 776 + return; 777 + } 778 + 772 779 raw_spin_lock_irqsave(&irq_controller_lock, flags); 773 780 774 781 /* Convert our logical CPU mask into a physical one. */
+14 -4
drivers/irqchip/irq-mips-gic.c
··· 713 713 unsigned long flags; 714 714 int i; 715 715 716 - irq_set_chip_and_handler(virq, &gic_level_irq_controller, 717 - handle_level_irq); 718 - 719 716 spin_lock_irqsave(&gic_lock, flags); 720 717 gic_map_to_pin(intr, gic_cpu_pin); 721 718 gic_map_to_vpe(intr, mips_cm_vp_id(vpe)); ··· 729 732 { 730 733 if (GIC_HWIRQ_TO_LOCAL(hw) < GIC_NUM_LOCAL_INTRS) 731 734 return gic_local_irq_domain_map(d, virq, hw); 735 + 736 + irq_set_chip_and_handler(virq, &gic_level_irq_controller, 737 + handle_level_irq); 738 + 732 739 return gic_shared_irq_domain_map(d, virq, hw, 0); 733 740 } 734 741 ··· 772 771 hwirq = GIC_SHARED_TO_HWIRQ(base_hwirq + i); 773 772 774 773 ret = irq_domain_set_hwirq_and_chip(d, virq + i, hwirq, 775 - &gic_edge_irq_controller, 774 + &gic_level_irq_controller, 776 775 NULL); 777 776 if (ret) 778 777 goto error; 778 + 779 + irq_set_handler(virq + i, handle_level_irq); 779 780 780 781 ret = gic_shared_irq_domain_map(d, virq + i, hwirq, cpu); 781 782 if (ret) ··· 893 890 return; 894 891 } 895 892 893 + static void gic_dev_domain_activate(struct irq_domain *domain, 894 + struct irq_data *d) 895 + { 896 + gic_shared_irq_domain_map(domain, d->irq, d->hwirq, 0); 897 + } 898 + 896 899 static struct irq_domain_ops gic_dev_domain_ops = { 897 900 .xlate = gic_dev_domain_xlate, 898 901 .alloc = gic_dev_domain_alloc, 899 902 .free = gic_dev_domain_free, 903 + .activate = gic_dev_domain_activate, 900 904 }; 901 905 902 906 static int gic_ipi_domain_xlate(struct irq_domain *d, struct device_node *ctrlr,
-1
drivers/macintosh/ams/ams-i2c.c
··· 73 73 static struct i2c_driver ams_i2c_driver = { 74 74 .driver = { 75 75 .name = "ams", 76 - .owner = THIS_MODULE, 77 76 }, 78 77 .probe = ams_i2c_probe, 79 78 .remove = ams_i2c_remove,
-1
drivers/macintosh/windfarm_pm112.c
··· 668 668 .remove = wf_pm112_remove, 669 669 .driver = { 670 670 .name = "windfarm", 671 - .owner = THIS_MODULE, 672 671 }, 673 672 }; 674 673
-1
drivers/macintosh/windfarm_pm72.c
··· 789 789 .remove = wf_pm72_remove, 790 790 .driver = { 791 791 .name = "windfarm", 792 - .owner = THIS_MODULE, 793 792 }, 794 793 }; 795 794
-1
drivers/macintosh/windfarm_rm31.c
··· 682 682 .remove = wf_rm31_remove, 683 683 .driver = { 684 684 .name = "windfarm", 685 - .owner = THIS_MODULE, 686 685 }, 687 686 }; 688 687
+10 -4
drivers/md/bcache/super.c
··· 760 760 if (!d->nr_stripes || 761 761 d->nr_stripes > INT_MAX || 762 762 d->nr_stripes > SIZE_MAX / sizeof(atomic_t)) { 763 - pr_err("nr_stripes too large"); 763 + pr_err("nr_stripes too large or invalid: %u (start sector beyond end of disk?)", 764 + (unsigned)d->nr_stripes); 764 765 return -ENOMEM; 765 766 } 766 767 ··· 1821 1820 free = roundup_pow_of_two(ca->sb.nbuckets) >> 10; 1822 1821 1823 1822 if (!init_fifo(&ca->free[RESERVE_BTREE], 8, GFP_KERNEL) || 1824 - !init_fifo(&ca->free[RESERVE_PRIO], prio_buckets(ca), GFP_KERNEL) || 1823 + !init_fifo_exact(&ca->free[RESERVE_PRIO], prio_buckets(ca), GFP_KERNEL) || 1825 1824 !init_fifo(&ca->free[RESERVE_MOVINGGC], free, GFP_KERNEL) || 1826 1825 !init_fifo(&ca->free[RESERVE_NONE], free, GFP_KERNEL) || 1827 1826 !init_fifo(&ca->free_inc, free << 2, GFP_KERNEL) || ··· 1845 1844 struct block_device *bdev, struct cache *ca) 1846 1845 { 1847 1846 char name[BDEVNAME_SIZE]; 1848 - const char *err = NULL; 1847 + const char *err = NULL; /* must be set for any error case */ 1849 1848 int ret = 0; 1850 1849 1851 1850 memcpy(&ca->sb, sb, sizeof(struct cache_sb)); ··· 1862 1861 ca->discard = CACHE_DISCARD(&ca->sb); 1863 1862 1864 1863 ret = cache_alloc(ca); 1865 - if (ret != 0) 1864 + if (ret != 0) { 1865 + if (ret == -ENOMEM) 1866 + err = "cache_alloc(): -ENOMEM"; 1867 + else 1868 + err = "cache_alloc(): unknown error"; 1866 1869 goto err; 1870 + } 1867 1871 1868 1872 if (kobject_add(&ca->kobj, &part_to_dev(bdev->bd_part)->kobj, "bcache")) { 1869 1873 err = "error calling kobject_add";
+1 -1
drivers/md/dm-crypt.c
··· 181 181 u8 key[0]; 182 182 }; 183 183 184 - #define MIN_IOS 16 184 + #define MIN_IOS 64 185 185 186 186 static void clone_init(struct dm_crypt_io *, struct bio *); 187 187 static void kcryptd_queue_crypt(struct dm_crypt_io *io);
+16 -11
drivers/md/dm-flakey.c
··· 289 289 pb->bio_submitted = true; 290 290 291 291 /* 292 - * Map reads as normal only if corrupt_bio_byte set. 292 + * Error reads if neither corrupt_bio_byte or drop_writes are set. 293 + * Otherwise, flakey_end_io() will decide if the reads should be modified. 293 294 */ 294 295 if (bio_data_dir(bio) == READ) { 295 - /* If flags were specified, only corrupt those that match. */ 296 - if (fc->corrupt_bio_byte && (fc->corrupt_bio_rw == READ) && 297 - all_corrupt_bio_flags_match(bio, fc)) 298 - goto map_bio; 299 - else 296 + if (!fc->corrupt_bio_byte && !test_bit(DROP_WRITES, &fc->flags)) 300 297 return -EIO; 298 + goto map_bio; 301 299 } 302 300 303 301 /* ··· 332 334 struct flakey_c *fc = ti->private; 333 335 struct per_bio_data *pb = dm_per_bio_data(bio, sizeof(struct per_bio_data)); 334 336 335 - /* 336 - * Corrupt successful READs while in down state. 337 - */ 338 337 if (!error && pb->bio_submitted && (bio_data_dir(bio) == READ)) { 339 - if (fc->corrupt_bio_byte) 338 + if (fc->corrupt_bio_byte && (fc->corrupt_bio_rw == READ) && 339 + all_corrupt_bio_flags_match(bio, fc)) { 340 + /* 341 + * Corrupt successful matching READs while in down state. 342 + */ 340 343 corrupt_bio_data(bio, fc); 341 - else 344 + 345 + } else if (!test_bit(DROP_WRITES, &fc->flags)) { 346 + /* 347 + * Error read during the down_interval if drop_writes 348 + * wasn't configured. 349 + */ 342 350 return -EIO; 351 + } 343 352 } 344 353 345 354 return error;
+6 -5
drivers/md/dm-log.c
··· 291 291 core->nr_regions = le64_to_cpu(disk->nr_regions); 292 292 } 293 293 294 - static int rw_header(struct log_c *lc, int rw) 294 + static int rw_header(struct log_c *lc, int op) 295 295 { 296 - lc->io_req.bi_op = rw; 296 + lc->io_req.bi_op = op; 297 + lc->io_req.bi_op_flags = 0; 297 298 298 299 return dm_io(&lc->io_req, 1, &lc->header_location, NULL); 299 300 } ··· 317 316 { 318 317 int r; 319 318 320 - r = rw_header(log, READ); 319 + r = rw_header(log, REQ_OP_READ); 321 320 if (r) 322 321 return r; 323 322 ··· 631 630 header_to_disk(&lc->header, lc->disk_header); 632 631 633 632 /* write the new header */ 634 - r = rw_header(lc, WRITE); 633 + r = rw_header(lc, REQ_OP_WRITE); 635 634 if (!r) { 636 635 r = flush_header(lc); 637 636 if (r) ··· 699 698 log_clear_bit(lc, lc->clean_bits, i); 700 699 } 701 700 702 - r = rw_header(lc, WRITE); 701 + r = rw_header(lc, REQ_OP_WRITE); 703 702 if (r) 704 703 fail_log_device(lc); 705 704 else {
+48 -36
drivers/md/dm-raid.c
··· 191 191 #define RT_FLAG_RS_BITMAP_LOADED 2 192 192 #define RT_FLAG_UPDATE_SBS 3 193 193 #define RT_FLAG_RESHAPE_RS 4 194 - #define RT_FLAG_KEEP_RS_FROZEN 5 195 194 196 195 /* Array elements of 64 bit needed for rebuild/failed disk bits */ 197 196 #define DISKS_ARRAY_ELEMS ((MAX_RAID_DEVICES + (sizeof(uint64_t) * 8 - 1)) / sizeof(uint64_t) / 8) ··· 860 861 { 861 862 unsigned long min_region_size = rs->ti->len / (1 << 21); 862 863 864 + if (rs_is_raid0(rs)) 865 + return 0; 866 + 863 867 if (!region_size) { 864 868 /* 865 869 * Choose a reasonable default. All figures in sectors. ··· 932 930 rebuild_cnt++; 933 931 934 932 switch (rs->raid_type->level) { 933 + case 0: 934 + break; 935 935 case 1: 936 936 if (rebuild_cnt >= rs->md.raid_disks) 937 937 goto too_many; ··· 2339 2335 case 0: 2340 2336 break; 2341 2337 default: 2338 + /* 2339 + * We have to keep any raid0 data/metadata device pairs or 2340 + * the MD raid0 personality will fail to start the array. 2341 + */ 2342 + if (rs_is_raid0(rs)) 2343 + continue; 2344 + 2342 2345 dev = container_of(rdev, struct raid_dev, rdev); 2343 2346 if (dev->meta_dev) 2344 2347 dm_put_device(ti, dev->meta_dev); ··· 2590 2579 } else { 2591 2580 /* Process raid1 without delta_disks */ 2592 2581 mddev->raid_disks = rs->raid_disks; 2593 - set_bit(RT_FLAG_KEEP_RS_FROZEN, &rs->runtime_flags); 2594 2582 reshape = false; 2595 2583 } 2596 2584 } else { ··· 2600 2590 if (reshape) { 2601 2591 set_bit(RT_FLAG_RESHAPE_RS, &rs->runtime_flags); 2602 2592 set_bit(RT_FLAG_UPDATE_SBS, &rs->runtime_flags); 2603 - set_bit(RT_FLAG_KEEP_RS_FROZEN, &rs->runtime_flags); 2604 2593 } else if (mddev->raid_disks < rs->raid_disks) 2605 2594 /* Create new superblocks and bitmaps, if any new disks */ 2606 2595 set_bit(RT_FLAG_UPDATE_SBS, &rs->runtime_flags); ··· 2911 2902 goto bad; 2912 2903 2913 2904 set_bit(RT_FLAG_UPDATE_SBS, &rs->runtime_flags); 2914 - set_bit(RT_FLAG_KEEP_RS_FROZEN, &rs->runtime_flags); 2915 2905 /* Takeover ain't recovery, so disable recovery */ 2916 2906 rs_setup_recovery(rs, MaxSector); 2917 2907 rs_set_new(rs); ··· 3394 3386 { 3395 3387 struct raid_set *rs = ti->private; 3396 3388 3397 - if (test_and_clear_bit(RT_FLAG_RS_RESUMED, &rs->runtime_flags)) { 3398 - if (!rs->md.suspended) 3399 - mddev_suspend(&rs->md); 3400 - rs->md.ro = 1; 3401 - } 3389 + if (!rs->md.suspended) 3390 + mddev_suspend(&rs->md); 3391 + 3392 + rs->md.ro = 1; 3402 3393 } 3403 3394 3404 3395 static void attempt_restore_of_faulty_devices(struct raid_set *rs) 3405 3396 { 3406 3397 int i; 3407 - uint64_t failed_devices, cleared_failed_devices = 0; 3398 + uint64_t cleared_failed_devices[DISKS_ARRAY_ELEMS]; 3408 3399 unsigned long flags; 3400 + bool cleared = false; 3409 3401 struct dm_raid_superblock *sb; 3402 + struct mddev *mddev = &rs->md; 3410 3403 struct md_rdev *r; 3404 + 3405 + /* RAID personalities have to provide hot add/remove methods or we need to bail out. */ 3406 + if (!mddev->pers || !mddev->pers->hot_add_disk || !mddev->pers->hot_remove_disk) 3407 + return; 3408 + 3409 + memset(cleared_failed_devices, 0, sizeof(cleared_failed_devices)); 3411 3410 3412 3411 for (i = 0; i < rs->md.raid_disks; i++) { 3413 3412 r = &rs->dev[i].rdev; ··· 3435 3420 * ourselves. 3436 3421 */ 3437 3422 if ((r->raid_disk >= 0) && 3438 - (r->mddev->pers->hot_remove_disk(r->mddev, r) != 0)) 3423 + (mddev->pers->hot_remove_disk(mddev, r) != 0)) 3439 3424 /* Failed to revive this device, try next */ 3440 3425 continue; 3441 3426 ··· 3445 3430 clear_bit(Faulty, &r->flags); 3446 3431 clear_bit(WriteErrorSeen, &r->flags); 3447 3432 clear_bit(In_sync, &r->flags); 3448 - if (r->mddev->pers->hot_add_disk(r->mddev, r)) { 3433 + if (mddev->pers->hot_add_disk(mddev, r)) { 3449 3434 r->raid_disk = -1; 3450 3435 r->saved_raid_disk = -1; 3451 3436 r->flags = flags; 3452 3437 } else { 3453 3438 r->recovery_offset = 0; 3454 - cleared_failed_devices |= 1 << i; 3439 + set_bit(i, (void *) cleared_failed_devices); 3440 + cleared = true; 3455 3441 } 3456 3442 } 3457 3443 } 3458 - if (cleared_failed_devices) { 3444 + 3445 + /* If any failed devices could be cleared, update all sbs failed_devices bits */ 3446 + if (cleared) { 3447 + uint64_t failed_devices[DISKS_ARRAY_ELEMS]; 3448 + 3459 3449 rdev_for_each(r, &rs->md) { 3460 3450 sb = page_address(r->sb_page); 3461 - failed_devices = le64_to_cpu(sb->failed_devices); 3462 - failed_devices &= ~cleared_failed_devices; 3463 - sb->failed_devices = cpu_to_le64(failed_devices); 3451 + sb_retrieve_failed_devices(sb, failed_devices); 3452 + 3453 + for (i = 0; i < DISKS_ARRAY_ELEMS; i++) 3454 + failed_devices[i] &= ~cleared_failed_devices[i]; 3455 + 3456 + sb_update_failed_devices(sb, failed_devices); 3464 3457 } 3465 3458 } 3466 3459 } ··· 3633 3610 * devices are reachable again. 3634 3611 */ 3635 3612 attempt_restore_of_faulty_devices(rs); 3636 - } else { 3637 - mddev->ro = 0; 3638 - mddev->in_sync = 0; 3639 - 3640 - /* 3641 - * When passing in flags to the ctr, we expect userspace 3642 - * to reset them because they made it to the superblocks 3643 - * and reload the mapping anyway. 3644 - * 3645 - * -> only unfreeze recovery in case of a table reload or 3646 - * we'll have a bogus recovery/reshape position 3647 - * retrieved from the superblock by the ctr because 3648 - * the ongoing recovery/reshape will change it after read. 3649 - */ 3650 - if (!test_bit(RT_FLAG_KEEP_RS_FROZEN, &rs->runtime_flags)) 3651 - clear_bit(MD_RECOVERY_FROZEN, &mddev->recovery); 3652 - 3653 - if (mddev->suspended) 3654 - mddev_resume(mddev); 3655 3613 } 3614 + 3615 + mddev->ro = 0; 3616 + mddev->in_sync = 0; 3617 + 3618 + clear_bit(MD_RECOVERY_FROZEN, &mddev->recovery); 3619 + 3620 + if (mddev->suspended) 3621 + mddev_resume(mddev); 3656 3622 } 3657 3623 3658 3624 static struct target_type raid_target = {
+5 -2
drivers/md/dm-round-robin.c
··· 210 210 struct path_info *pi = NULL; 211 211 struct dm_path *current_path = NULL; 212 212 213 + local_irq_save(flags); 213 214 current_path = *this_cpu_ptr(s->current_path); 214 215 if (current_path) { 215 216 percpu_counter_dec(&s->repeat_count); 216 - if (percpu_counter_read_positive(&s->repeat_count) > 0) 217 + if (percpu_counter_read_positive(&s->repeat_count) > 0) { 218 + local_irq_restore(flags); 217 219 return current_path; 220 + } 218 221 } 219 222 220 - spin_lock_irqsave(&s->lock, flags); 223 + spin_lock(&s->lock); 221 224 if (!list_empty(&s->valid_paths)) { 222 225 pi = list_entry(s->valid_paths.next, struct path_info, list); 223 226 list_move_tail(&pi->list, &s->valid_paths);
+9 -1
drivers/misc/cxl/vphb.c
··· 230 230 if (phb->bus == NULL) 231 231 return -ENXIO; 232 232 233 + /* Set release hook on root bus */ 234 + pci_set_host_bridge_release(to_pci_host_bridge(phb->bus->bridge), 235 + pcibios_free_controller_deferred, 236 + (void *) phb); 237 + 233 238 /* Claim resources. This might need some rework as well depending 234 239 * whether we are doing probe-only or not, like assigning unassigned 235 240 * resources etc... ··· 261 256 afu->phb = NULL; 262 257 263 258 pci_remove_root_bus(phb->bus); 264 - pcibios_free_controller(phb); 259 + /* 260 + * We don't free phb here - that's handled by 261 + * pcibios_free_controller_deferred() 262 + */ 265 263 } 266 264 267 265 static bool _cxl_pci_is_vphb_device(struct pci_controller *phb)
+3 -2
drivers/mmc/card/block.c
··· 1726 1726 break; 1727 1727 1728 1728 if (req_op(next) == REQ_OP_DISCARD || 1729 + req_op(next) == REQ_OP_SECURE_ERASE || 1729 1730 req_op(next) == REQ_OP_FLUSH) 1730 1731 break; 1731 1732 ··· 2151 2150 struct mmc_card *card = md->queue.card; 2152 2151 struct mmc_host *host = card->host; 2153 2152 unsigned long flags; 2153 + bool req_is_special = mmc_req_is_special(req); 2154 2154 2155 2155 if (req && !mq->mqrq_prev->req) 2156 2156 /* claim host only for the first request */ ··· 2192 2190 } 2193 2191 2194 2192 out: 2195 - if ((!req && !(mq->flags & MMC_QUEUE_NEW_REQUEST)) || 2196 - mmc_req_is_special(req)) 2193 + if ((!req && !(mq->flags & MMC_QUEUE_NEW_REQUEST)) || req_is_special) 2197 2194 /* 2198 2195 * Release host when there are no more requests 2199 2196 * and after special request(discard, flush) is done.
+5 -2
drivers/mmc/card/queue.c
··· 33 33 /* 34 34 * We only like normal block requests and discards. 35 35 */ 36 - if (req->cmd_type != REQ_TYPE_FS && req_op(req) != REQ_OP_DISCARD) { 36 + if (req->cmd_type != REQ_TYPE_FS && req_op(req) != REQ_OP_DISCARD && 37 + req_op(req) != REQ_OP_SECURE_ERASE) { 37 38 blk_dump_rq_flags(req, "MMC bad request"); 38 39 return BLKPREP_KILL; 39 40 } ··· 65 64 spin_unlock_irq(q->queue_lock); 66 65 67 66 if (req || mq->mqrq_prev->req) { 67 + bool req_is_special = mmc_req_is_special(req); 68 + 68 69 set_current_state(TASK_RUNNING); 69 70 mq->issue_fn(mq, req); 70 71 cond_resched(); ··· 82 79 * has been finished. Do not assign it to previous 83 80 * request. 84 81 */ 85 - if (mmc_req_is_special(req)) 82 + if (req_is_special) 86 83 mq->mqrq_cur->req = NULL; 87 84 88 85 mq->mqrq_prev->brq.mrq.data = NULL;
+3 -1
drivers/mmc/card/queue.h
··· 4 4 static inline bool mmc_req_is_special(struct request *req) 5 5 { 6 6 return req && 7 - (req_op(req) == REQ_OP_FLUSH || req_op(req) == REQ_OP_DISCARD); 7 + (req_op(req) == REQ_OP_FLUSH || 8 + req_op(req) == REQ_OP_DISCARD || 9 + req_op(req) == REQ_OP_SECURE_ERASE); 8 10 } 9 11 10 12 struct request;
+1 -1
drivers/net/dsa/bcm_sf2.h
··· 145 145 static inline void intrl2_##which##_mask_clear(struct bcm_sf2_priv *priv, \ 146 146 u32 mask) \ 147 147 { \ 148 - intrl2_##which##_writel(priv, mask, INTRL2_CPU_MASK_CLEAR); \ 149 148 priv->irq##which##_mask &= ~(mask); \ 149 + intrl2_##which##_writel(priv, mask, INTRL2_CPU_MASK_CLEAR); \ 150 150 } \ 151 151 static inline void intrl2_##which##_mask_set(struct bcm_sf2_priv *priv, \ 152 152 u32 mask) \
+6 -2
drivers/net/dsa/mv88e6xxx/chip.c
··· 2646 2646 return ret; 2647 2647 } 2648 2648 2649 + /* Rate Control: disable ingress rate limiting. */ 2649 2650 if (mv88e6xxx_6352_family(chip) || mv88e6xxx_6351_family(chip) || 2650 2651 mv88e6xxx_6165_family(chip) || mv88e6xxx_6097_family(chip) || 2651 - mv88e6xxx_6185_family(chip) || mv88e6xxx_6095_family(chip) || 2652 2652 mv88e6xxx_6320_family(chip)) { 2653 - /* Rate Control: disable ingress rate limiting. */ 2654 2653 ret = _mv88e6xxx_reg_write(chip, REG_PORT(port), 2655 2654 PORT_RATE_CONTROL, 0x0001); 2655 + if (ret) 2656 + return ret; 2657 + } else if (mv88e6xxx_6185_family(chip) || mv88e6xxx_6095_family(chip)) { 2658 + ret = _mv88e6xxx_reg_write(chip, REG_PORT(port), 2659 + PORT_RATE_CONTROL, 0x0000); 2656 2660 if (ret) 2657 2661 return ret; 2658 2662 }
+2
drivers/net/ethernet/atheros/alx/main.c
··· 1612 1612 .driver_data = ALX_DEV_QUIRK_MSI_INTX_DISABLE_BUG }, 1613 1613 { PCI_VDEVICE(ATTANSIC, ALX_DEV_ID_E2400), 1614 1614 .driver_data = ALX_DEV_QUIRK_MSI_INTX_DISABLE_BUG }, 1615 + { PCI_VDEVICE(ATTANSIC, ALX_DEV_ID_E2500), 1616 + .driver_data = ALX_DEV_QUIRK_MSI_INTX_DISABLE_BUG }, 1615 1617 { PCI_VDEVICE(ATTANSIC, ALX_DEV_ID_AR8162), 1616 1618 .driver_data = ALX_DEV_QUIRK_MSI_INTX_DISABLE_BUG }, 1617 1619 { PCI_VDEVICE(ATTANSIC, ALX_DEV_ID_AR8171) },
+1
drivers/net/ethernet/atheros/alx/reg.h
··· 38 38 #define ALX_DEV_ID_AR8161 0x1091 39 39 #define ALX_DEV_ID_E2200 0xe091 40 40 #define ALX_DEV_ID_E2400 0xe0a1 41 + #define ALX_DEV_ID_E2500 0xe0b1 41 42 #define ALX_DEV_ID_AR8162 0x1090 42 43 #define ALX_DEV_ID_AR8171 0x10A1 43 44 #define ALX_DEV_ID_AR8172 0x10A0
+1 -1
drivers/net/ethernet/broadcom/bgmac-bcma.c
··· 161 161 if (!bgmac_is_bcm4707_family(core) && 162 162 !(ci->id == BCMA_CHIP_ID_BCM53573 && core->core_unit == 1)) { 163 163 mii_bus = bcma_mdio_mii_register(core, bgmac->phyaddr); 164 - if (!IS_ERR(mii_bus)) { 164 + if (IS_ERR(mii_bus)) { 165 165 err = PTR_ERR(mii_bus); 166 166 goto err; 167 167 }
-1
drivers/net/ethernet/cavium/thunder/nic_reg.h
··· 185 185 #define NIC_QSET_SQ_0_7_DOOR (0x010838) 186 186 #define NIC_QSET_SQ_0_7_STATUS (0x010840) 187 187 #define NIC_QSET_SQ_0_7_DEBUG (0x010848) 188 - #define NIC_QSET_SQ_0_7_CNM_CHG (0x010860) 189 188 #define NIC_QSET_SQ_0_7_STAT_0_1 (0x010900) 190 189 191 190 #define NIC_QSET_RBDR_0_1_CFG (0x010C00)
+4 -1
drivers/net/ethernet/cavium/thunder/nicvf_ethtool.c
··· 382 382 p[i++] = nicvf_queue_reg_read(nic, NIC_QSET_SQ_0_7_DOOR, q); 383 383 p[i++] = nicvf_queue_reg_read(nic, NIC_QSET_SQ_0_7_STATUS, q); 384 384 p[i++] = nicvf_queue_reg_read(nic, NIC_QSET_SQ_0_7_DEBUG, q); 385 - p[i++] = nicvf_queue_reg_read(nic, NIC_QSET_SQ_0_7_CNM_CHG, q); 385 + /* Padding, was NIC_QSET_SQ_0_7_CNM_CHG, which 386 + * produces bus errors when read 387 + */ 388 + p[i++] = 0; 386 389 p[i++] = nicvf_queue_reg_read(nic, NIC_QSET_SQ_0_7_STAT_0_1, q); 387 390 reg_offset = NIC_QSET_SQ_0_7_STAT_0_1 | (1 << 3); 388 391 p[i++] = nicvf_queue_reg_read(nic, reg_offset, q);
+14 -6
drivers/net/ethernet/freescale/gianfar.c
··· 2922 2922 { 2923 2923 unsigned int size = lstatus & BD_LENGTH_MASK; 2924 2924 struct page *page = rxb->page; 2925 + bool last = !!(lstatus & BD_LFLAG(RXBD_LAST)); 2925 2926 2926 2927 /* Remove the FCS from the packet length */ 2927 - if (likely(lstatus & BD_LFLAG(RXBD_LAST))) 2928 + if (last) 2928 2929 size -= ETH_FCS_LEN; 2929 2930 2930 - if (likely(first)) 2931 + if (likely(first)) { 2931 2932 skb_put(skb, size); 2932 - else 2933 - skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, page, 2934 - rxb->page_offset + RXBUF_ALIGNMENT, 2935 - size, GFAR_RXB_TRUESIZE); 2933 + } else { 2934 + /* the last fragments' length contains the full frame length */ 2935 + if (last) 2936 + size -= skb->len; 2937 + 2938 + /* in case the last fragment consisted only of the FCS */ 2939 + if (size > 0) 2940 + skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, page, 2941 + rxb->page_offset + RXBUF_ALIGNMENT, 2942 + size, GFAR_RXB_TRUESIZE); 2943 + } 2936 2944 2937 2945 /* try reuse page */ 2938 2946 if (unlikely(page_count(page) != 1))
+2 -1
drivers/net/ethernet/freescale/gianfar.h
··· 100 100 #define DEFAULT_RX_LFC_THR 16 101 101 #define DEFAULT_LFC_PTVVAL 4 102 102 103 - #define GFAR_RXB_SIZE 1536 103 + /* prevent fragmenation by HW in DSA environments */ 104 + #define GFAR_RXB_SIZE roundup(1536 + 8, 64) 104 105 #define GFAR_SKBFRAG_SIZE (RXBUF_ALIGNMENT + GFAR_RXB_SIZE \ 105 106 + SKB_DATA_ALIGN(sizeof(struct skb_shared_info))) 106 107 #define GFAR_RXB_TRUESIZE 2048
+2 -1
drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.c
··· 328 328 static void hns_ppe_uninit_hw(struct hns_ppe_cb *ppe_cb) 329 329 { 330 330 u32 port; 331 - struct dsaf_device *dsaf_dev = ppe_cb->ppe_common_cb->dsaf_dev; 332 331 333 332 if (ppe_cb->ppe_common_cb) { 333 + struct dsaf_device *dsaf_dev = ppe_cb->ppe_common_cb->dsaf_dev; 334 + 334 335 port = ppe_cb->index; 335 336 dsaf_dev->misc_op->ppe_srst(dsaf_dev, port, 0); 336 337 }
+30 -11
drivers/net/ethernet/intel/i40e/i40e_client.c
··· 209 209 void i40e_notify_client_of_netdev_open(struct i40e_vsi *vsi) 210 210 { 211 211 struct i40e_client_instance *cdev; 212 + int ret = 0; 212 213 213 214 if (!vsi) 214 215 return; ··· 222 221 "Cannot locate client instance open routine\n"); 223 222 continue; 224 223 } 225 - cdev->client->ops->open(&cdev->lan_info, cdev->client); 224 + if (!(test_bit(__I40E_CLIENT_INSTANCE_OPENED, 225 + &cdev->state))) { 226 + ret = cdev->client->ops->open(&cdev->lan_info, 227 + cdev->client); 228 + if (!ret) 229 + set_bit(__I40E_CLIENT_INSTANCE_OPENED, 230 + &cdev->state); 231 + } 226 232 } 227 233 } 228 234 mutex_unlock(&i40e_client_instance_mutex); ··· 440 432 * i40e_client_add_instance - add a client instance struct to the instance list 441 433 * @pf: pointer to the board struct 442 434 * @client: pointer to a client struct in the client list. 435 + * @existing: if there was already an existing instance 443 436 * 444 - * Returns cdev ptr on success, NULL on failure 437 + * Returns cdev ptr on success or if already exists, NULL on failure 445 438 **/ 446 439 static 447 440 struct i40e_client_instance *i40e_client_add_instance(struct i40e_pf *pf, 448 - struct i40e_client *client) 441 + struct i40e_client *client, 442 + bool *existing) 449 443 { 450 444 struct i40e_client_instance *cdev; 451 445 struct netdev_hw_addr *mac = NULL; ··· 456 446 mutex_lock(&i40e_client_instance_mutex); 457 447 list_for_each_entry(cdev, &i40e_client_instances, list) { 458 448 if ((cdev->lan_info.pf == pf) && (cdev->client == client)) { 459 - cdev = NULL; 449 + *existing = true; 460 450 goto out; 461 451 } 462 452 } ··· 540 530 { 541 531 struct i40e_client_instance *cdev; 542 532 struct i40e_client *client; 533 + bool existing = false; 543 534 int ret = 0; 544 535 545 536 if (!(pf->flags & I40E_FLAG_SERVICE_CLIENT_REQUESTED)) ··· 564 553 /* check if L2 VSI is up, if not we are not ready */ 565 554 if (test_bit(__I40E_DOWN, &pf->vsi[pf->lan_vsi]->state)) 566 555 continue; 556 + } else { 557 + dev_warn(&pf->pdev->dev, "This client %s is being instanciated at probe\n", 558 + client->name); 567 559 } 568 560 569 561 /* Add the client instance to the instance list */ 570 - cdev = i40e_client_add_instance(pf, client); 562 + cdev = i40e_client_add_instance(pf, client, &existing); 571 563 if (!cdev) 572 564 continue; 573 565 574 - /* Also up the ref_cnt of no. of instances of this client */ 575 - atomic_inc(&client->ref_cnt); 576 - dev_info(&pf->pdev->dev, "Added instance of Client %s to PF%d bus=0x%02x func=0x%02x\n", 577 - client->name, pf->hw.pf_id, 578 - pf->hw.bus.device, pf->hw.bus.func); 566 + if (!existing) { 567 + /* Also up the ref_cnt for no. of instances of this 568 + * client. 569 + */ 570 + atomic_inc(&client->ref_cnt); 571 + dev_info(&pf->pdev->dev, "Added instance of Client %s to PF%d bus=0x%02x func=0x%02x\n", 572 + client->name, pf->hw.pf_id, 573 + pf->hw.bus.device, pf->hw.bus.func); 574 + } 579 575 580 576 mutex_lock(&i40e_client_instance_mutex); 581 577 /* Send an Open request to the client */ ··· 634 616 pf->hw.pf_id, pf->hw.bus.device, pf->hw.bus.func); 635 617 636 618 /* Since in some cases register may have happened before a device gets 637 - * added, we can schedule a subtask to go initiate the clients. 619 + * added, we can schedule a subtask to go initiate the clients if 620 + * they can be launched at probe time. 638 621 */ 639 622 pf->flags |= I40E_FLAG_SERVICE_CLIENT_REQUESTED; 640 623 i40e_service_event_schedule(pf);
-1
drivers/net/ethernet/intel/i40e/i40e_main.c
··· 5430 5430 wr32(&pf->hw, I40E_GLLAN_TSOMSK_L, be32_to_cpu(TCP_FLAG_CWR) >> 16); 5431 5431 5432 5432 udp_tunnel_get_rx_info(netdev); 5433 - i40e_notify_client_of_netdev_open(vsi); 5434 5433 5435 5434 return 0; 5436 5435 }
+3 -1
drivers/net/ethernet/intel/ixgbe/ixgbe_common.c
··· 2959 2959 } 2960 2960 2961 2961 /* was that the last pool using this rar? */ 2962 - if (mpsar_lo == 0 && mpsar_hi == 0 && rar != 0) 2962 + if (mpsar_lo == 0 && mpsar_hi == 0 && 2963 + rar != 0 && rar != hw->mac.san_mac_rar_index) 2963 2964 hw->mac.ops.clear_rar(hw, rar); 2965 + 2964 2966 return 0; 2965 2967 } 2966 2968
+53 -30
drivers/net/ethernet/mellanox/mlx5/core/cmd.c
··· 143 143 return cmd->cmd_buf + (idx << cmd->log_stride); 144 144 } 145 145 146 - static u8 xor8_buf(void *buf, int len) 146 + static u8 xor8_buf(void *buf, size_t offset, int len) 147 147 { 148 148 u8 *ptr = buf; 149 149 u8 sum = 0; 150 150 int i; 151 + int end = len + offset; 151 152 152 - for (i = 0; i < len; i++) 153 + for (i = offset; i < end; i++) 153 154 sum ^= ptr[i]; 154 155 155 156 return sum; ··· 158 157 159 158 static int verify_block_sig(struct mlx5_cmd_prot_block *block) 160 159 { 161 - if (xor8_buf(block->rsvd0, sizeof(*block) - sizeof(block->data) - 1) != 0xff) 160 + size_t rsvd0_off = offsetof(struct mlx5_cmd_prot_block, rsvd0); 161 + int xor_len = sizeof(*block) - sizeof(block->data) - 1; 162 + 163 + if (xor8_buf(block, rsvd0_off, xor_len) != 0xff) 162 164 return -EINVAL; 163 165 164 - if (xor8_buf(block, sizeof(*block)) != 0xff) 166 + if (xor8_buf(block, 0, sizeof(*block)) != 0xff) 165 167 return -EINVAL; 166 168 167 169 return 0; 168 170 } 169 171 170 - static void calc_block_sig(struct mlx5_cmd_prot_block *block, u8 token, 171 - int csum) 172 + static void calc_block_sig(struct mlx5_cmd_prot_block *block) 172 173 { 173 - block->token = token; 174 - if (csum) { 175 - block->ctrl_sig = ~xor8_buf(block->rsvd0, sizeof(*block) - 176 - sizeof(block->data) - 2); 177 - block->sig = ~xor8_buf(block, sizeof(*block) - 1); 178 - } 174 + int ctrl_xor_len = sizeof(*block) - sizeof(block->data) - 2; 175 + size_t rsvd0_off = offsetof(struct mlx5_cmd_prot_block, rsvd0); 176 + 177 + block->ctrl_sig = ~xor8_buf(block, rsvd0_off, ctrl_xor_len); 178 + block->sig = ~xor8_buf(block, 0, sizeof(*block) - 1); 179 179 } 180 180 181 - static void calc_chain_sig(struct mlx5_cmd_msg *msg, u8 token, int csum) 181 + static void calc_chain_sig(struct mlx5_cmd_msg *msg) 182 182 { 183 183 struct mlx5_cmd_mailbox *next = msg->next; 184 + int size = msg->len; 185 + int blen = size - min_t(int, sizeof(msg->first.data), size); 186 + int n = (blen + MLX5_CMD_DATA_BLOCK_SIZE - 1) 187 + / MLX5_CMD_DATA_BLOCK_SIZE; 188 + int i = 0; 184 189 185 - while (next) { 186 - calc_block_sig(next->buf, token, csum); 190 + for (i = 0; i < n && next; i++) { 191 + calc_block_sig(next->buf); 187 192 next = next->next; 188 193 } 189 194 } 190 195 191 196 static void set_signature(struct mlx5_cmd_work_ent *ent, int csum) 192 197 { 193 - ent->lay->sig = ~xor8_buf(ent->lay, sizeof(*ent->lay)); 194 - calc_chain_sig(ent->in, ent->token, csum); 195 - calc_chain_sig(ent->out, ent->token, csum); 198 + ent->lay->sig = ~xor8_buf(ent->lay, 0, sizeof(*ent->lay)); 199 + if (csum) { 200 + calc_chain_sig(ent->in); 201 + calc_chain_sig(ent->out); 202 + } 196 203 } 197 204 198 205 static void poll_timeout(struct mlx5_cmd_work_ent *ent) ··· 231 222 struct mlx5_cmd_mailbox *next = ent->out->next; 232 223 int err; 233 224 u8 sig; 225 + int size = ent->out->len; 226 + int blen = size - min_t(int, sizeof(ent->out->first.data), size); 227 + int n = (blen + MLX5_CMD_DATA_BLOCK_SIZE - 1) 228 + / MLX5_CMD_DATA_BLOCK_SIZE; 229 + int i = 0; 234 230 235 - sig = xor8_buf(ent->lay, sizeof(*ent->lay)); 231 + sig = xor8_buf(ent->lay, 0, sizeof(*ent->lay)); 236 232 if (sig != 0xff) 237 233 return -EINVAL; 238 234 239 - while (next) { 235 + for (i = 0; i < n && next; i++) { 240 236 err = verify_block_sig(next->buf); 241 237 if (err) 242 238 return err; ··· 797 783 spin_unlock_irqrestore(&cmd->alloc_lock, flags); 798 784 } 799 785 800 - ent->token = alloc_token(cmd); 801 786 cmd->ent_arr[ent->idx] = ent; 802 787 lay = get_inst(cmd, ent->idx); 803 788 ent->lay = lay; ··· 896 883 static int mlx5_cmd_invoke(struct mlx5_core_dev *dev, struct mlx5_cmd_msg *in, 897 884 struct mlx5_cmd_msg *out, void *uout, int uout_size, 898 885 mlx5_cmd_cbk_t callback, 899 - void *context, int page_queue, u8 *status) 886 + void *context, int page_queue, u8 *status, 887 + u8 token) 900 888 { 901 889 struct mlx5_cmd *cmd = &dev->cmd; 902 890 struct mlx5_cmd_work_ent *ent; ··· 913 899 page_queue); 914 900 if (IS_ERR(ent)) 915 901 return PTR_ERR(ent); 902 + 903 + ent->token = token; 916 904 917 905 if (!callback) 918 906 init_completion(&ent->done); ··· 987 971 .write = dbg_write, 988 972 }; 989 973 990 - static int mlx5_copy_to_msg(struct mlx5_cmd_msg *to, void *from, int size) 974 + static int mlx5_copy_to_msg(struct mlx5_cmd_msg *to, void *from, int size, 975 + u8 token) 991 976 { 992 977 struct mlx5_cmd_prot_block *block; 993 978 struct mlx5_cmd_mailbox *next; ··· 1014 997 memcpy(block->data, from, copy); 1015 998 from += copy; 1016 999 size -= copy; 1000 + block->token = token; 1017 1001 next = next->next; 1018 1002 } 1019 1003 ··· 1084 1066 } 1085 1067 1086 1068 static struct mlx5_cmd_msg *mlx5_alloc_cmd_msg(struct mlx5_core_dev *dev, 1087 - gfp_t flags, int size) 1069 + gfp_t flags, int size, 1070 + u8 token) 1088 1071 { 1089 1072 struct mlx5_cmd_mailbox *tmp, *head = NULL; 1090 1073 struct mlx5_cmd_prot_block *block; ··· 1114 1095 tmp->next = head; 1115 1096 block->next = cpu_to_be64(tmp->next ? tmp->next->dma : 0); 1116 1097 block->block_num = cpu_to_be32(n - i - 1); 1098 + block->token = token; 1117 1099 head = tmp; 1118 1100 } 1119 1101 msg->next = head; ··· 1483 1463 } 1484 1464 1485 1465 if (IS_ERR(msg)) 1486 - msg = mlx5_alloc_cmd_msg(dev, gfp, in_size); 1466 + msg = mlx5_alloc_cmd_msg(dev, gfp, in_size, 0); 1487 1467 1488 1468 return msg; 1489 1469 } ··· 1503 1483 int err; 1504 1484 u8 status = 0; 1505 1485 u32 drv_synd; 1486 + u8 token; 1506 1487 1507 1488 if (pci_channel_offline(dev->pdev) || 1508 1489 dev->state == MLX5_DEVICE_STATE_INTERNAL_ERROR) { ··· 1524 1503 return err; 1525 1504 } 1526 1505 1527 - err = mlx5_copy_to_msg(inb, in, in_size); 1506 + token = alloc_token(&dev->cmd); 1507 + 1508 + err = mlx5_copy_to_msg(inb, in, in_size, token); 1528 1509 if (err) { 1529 1510 mlx5_core_warn(dev, "err %d\n", err); 1530 1511 goto out_in; 1531 1512 } 1532 1513 1533 - outb = mlx5_alloc_cmd_msg(dev, gfp, out_size); 1514 + outb = mlx5_alloc_cmd_msg(dev, gfp, out_size, token); 1534 1515 if (IS_ERR(outb)) { 1535 1516 err = PTR_ERR(outb); 1536 1517 goto out_in; 1537 1518 } 1538 1519 1539 1520 err = mlx5_cmd_invoke(dev, inb, outb, out, out_size, callback, context, 1540 - pages_queue, &status); 1521 + pages_queue, &status, token); 1541 1522 if (err) 1542 1523 goto out_out; 1543 1524 ··· 1610 1587 INIT_LIST_HEAD(&cmd->cache.med.head); 1611 1588 1612 1589 for (i = 0; i < NUM_LONG_LISTS; i++) { 1613 - msg = mlx5_alloc_cmd_msg(dev, GFP_KERNEL, LONG_LIST_SIZE); 1590 + msg = mlx5_alloc_cmd_msg(dev, GFP_KERNEL, LONG_LIST_SIZE, 0); 1614 1591 if (IS_ERR(msg)) { 1615 1592 err = PTR_ERR(msg); 1616 1593 goto ex_err; ··· 1620 1597 } 1621 1598 1622 1599 for (i = 0; i < NUM_MED_LISTS; i++) { 1623 - msg = mlx5_alloc_cmd_msg(dev, GFP_KERNEL, MED_LIST_SIZE); 1600 + msg = mlx5_alloc_cmd_msg(dev, GFP_KERNEL, MED_LIST_SIZE, 0); 1624 1601 if (IS_ERR(msg)) { 1625 1602 err = PTR_ERR(msg); 1626 1603 goto ex_err;
+9 -12
drivers/net/ethernet/mellanox/mlx5/core/en.h
··· 73 73 #define MLX5_MPWRQ_PAGES_PER_WQE BIT(MLX5_MPWRQ_WQE_PAGE_ORDER) 74 74 #define MLX5_MPWRQ_STRIDES_PER_PAGE (MLX5_MPWRQ_NUM_STRIDES >> \ 75 75 MLX5_MPWRQ_WQE_PAGE_ORDER) 76 - #define MLX5_CHANNEL_MAX_NUM_MTTS (ALIGN(MLX5_MPWRQ_PAGES_PER_WQE, 8) * \ 77 - BIT(MLX5E_PARAMS_MAXIMUM_LOG_RQ_SIZE_MPW)) 76 + 77 + #define MLX5_MTT_OCTW(npages) (ALIGN(npages, 8) / 2) 78 + #define MLX5E_REQUIRED_MTTS(rqs, wqes)\ 79 + (rqs * wqes * ALIGN(MLX5_MPWRQ_PAGES_PER_WQE, 8)) 80 + #define MLX5E_VALID_NUM_MTTS(num_mtts) (MLX5_MTT_OCTW(num_mtts) <= U16_MAX) 81 + 78 82 #define MLX5_UMR_ALIGN (2048) 79 83 #define MLX5_MPWRQ_SMALL_PACKET_THRESHOLD (128) 80 84 ··· 223 219 }; 224 220 225 221 enum { 226 - MLX5E_RQ_STATE_POST_WQES_ENABLE, 222 + MLX5E_RQ_STATE_FLUSH, 227 223 MLX5E_RQ_STATE_UMR_WQE_IN_PROGRESS, 228 - MLX5E_RQ_STATE_FLUSH_TIMEOUT, 229 224 MLX5E_RQ_STATE_AM, 230 225 }; 231 226 ··· 307 304 308 305 unsigned long state; 309 306 int ix; 307 + u32 mpwqe_mtt_offset; 310 308 311 309 struct mlx5e_rx_am am; /* Adaptive Moderation */ 312 310 ··· 369 365 }; 370 366 371 367 enum { 372 - MLX5E_SQ_STATE_WAKE_TXQ_ENABLE, 368 + MLX5E_SQ_STATE_FLUSH, 373 369 MLX5E_SQ_STATE_BF_ENABLE, 374 - MLX5E_SQ_STATE_TX_TIMEOUT, 375 370 }; 376 371 377 372 struct mlx5e_ico_wqe_info { ··· 667 664 bool mlx5e_poll_tx_cq(struct mlx5e_cq *cq, int napi_budget); 668 665 int mlx5e_poll_rx_cq(struct mlx5e_cq *cq, int budget); 669 666 void mlx5e_free_tx_descs(struct mlx5e_sq *sq); 670 - void mlx5e_free_rx_descs(struct mlx5e_rq *rq); 671 667 672 668 void mlx5e_handle_rx_cqe(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe); 673 669 void mlx5e_handle_rx_cqe_mpwrq(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe); ··· 780 778 { 781 779 return min_t(int, mdev->priv.eq_table.num_comp_vectors, 782 780 MLX5E_MAX_NUM_CHANNELS); 783 - } 784 - 785 - static inline int mlx5e_get_mtt_octw(int npages) 786 - { 787 - return ALIGN(npages, 8) / 2; 788 781 } 789 782 790 783 extern const struct ethtool_ops mlx5e_ethtool_ops;
+4 -3
drivers/net/ethernet/mellanox/mlx5/core/en_common.c
··· 142 142 struct mlx5e_tir *tir; 143 143 void *in; 144 144 int inlen; 145 - int err; 145 + int err = 0; 146 146 147 147 inlen = MLX5_ST_SZ_BYTES(modify_tir_in); 148 148 in = mlx5_vzalloc(inlen); ··· 154 154 list_for_each_entry(tir, &mdev->mlx5e_res.td.tirs_list, list) { 155 155 err = mlx5_core_modify_tir(mdev, tir->tirn, in, inlen); 156 156 if (err) 157 - return err; 157 + goto out; 158 158 } 159 159 160 + out: 160 161 kvfree(in); 161 162 162 - return 0; 163 + return err; 163 164 }
+16 -5
drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c
··· 127 127 return mlx5_set_port_tc_bw_alloc(mdev, tc_tx_bw); 128 128 } 129 129 130 - static int mlx5e_dbcnl_validate_ets(struct ieee_ets *ets) 130 + static int mlx5e_dbcnl_validate_ets(struct net_device *netdev, 131 + struct ieee_ets *ets) 131 132 { 132 133 int bw_sum = 0; 133 134 int i; 134 135 135 136 /* Validate Priority */ 136 137 for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) { 137 - if (ets->prio_tc[i] >= MLX5E_MAX_PRIORITY) 138 + if (ets->prio_tc[i] >= MLX5E_MAX_PRIORITY) { 139 + netdev_err(netdev, 140 + "Failed to validate ETS: priority value greater than max(%d)\n", 141 + MLX5E_MAX_PRIORITY); 138 142 return -EINVAL; 143 + } 139 144 } 140 145 141 146 /* Validate Bandwidth Sum */ 142 147 for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) { 143 148 if (ets->tc_tsa[i] == IEEE_8021QAZ_TSA_ETS) { 144 - if (!ets->tc_tx_bw[i]) 149 + if (!ets->tc_tx_bw[i]) { 150 + netdev_err(netdev, 151 + "Failed to validate ETS: BW 0 is illegal\n"); 145 152 return -EINVAL; 153 + } 146 154 147 155 bw_sum += ets->tc_tx_bw[i]; 148 156 } 149 157 } 150 158 151 - if (bw_sum != 0 && bw_sum != 100) 159 + if (bw_sum != 0 && bw_sum != 100) { 160 + netdev_err(netdev, 161 + "Failed to validate ETS: BW sum is illegal\n"); 152 162 return -EINVAL; 163 + } 153 164 return 0; 154 165 } 155 166 ··· 170 159 struct mlx5e_priv *priv = netdev_priv(netdev); 171 160 int err; 172 161 173 - err = mlx5e_dbcnl_validate_ets(ets); 162 + err = mlx5e_dbcnl_validate_ets(netdev, ets); 174 163 if (err) 175 164 return err; 176 165
+85 -8
drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
··· 352 352 sq_stats_desc, j); 353 353 } 354 354 355 + static u32 mlx5e_rx_wqes_to_packets(struct mlx5e_priv *priv, int rq_wq_type, 356 + int num_wqe) 357 + { 358 + int packets_per_wqe; 359 + int stride_size; 360 + int num_strides; 361 + int wqe_size; 362 + 363 + if (rq_wq_type != MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ) 364 + return num_wqe; 365 + 366 + stride_size = 1 << priv->params.mpwqe_log_stride_sz; 367 + num_strides = 1 << priv->params.mpwqe_log_num_strides; 368 + wqe_size = stride_size * num_strides; 369 + 370 + packets_per_wqe = wqe_size / 371 + ALIGN(ETH_DATA_LEN, stride_size); 372 + return (1 << (order_base_2(num_wqe * packets_per_wqe) - 1)); 373 + } 374 + 375 + static u32 mlx5e_packets_to_rx_wqes(struct mlx5e_priv *priv, int rq_wq_type, 376 + int num_packets) 377 + { 378 + int packets_per_wqe; 379 + int stride_size; 380 + int num_strides; 381 + int wqe_size; 382 + int num_wqes; 383 + 384 + if (rq_wq_type != MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ) 385 + return num_packets; 386 + 387 + stride_size = 1 << priv->params.mpwqe_log_stride_sz; 388 + num_strides = 1 << priv->params.mpwqe_log_num_strides; 389 + wqe_size = stride_size * num_strides; 390 + 391 + num_packets = (1 << order_base_2(num_packets)); 392 + 393 + packets_per_wqe = wqe_size / 394 + ALIGN(ETH_DATA_LEN, stride_size); 395 + num_wqes = DIV_ROUND_UP(num_packets, packets_per_wqe); 396 + return 1 << (order_base_2(num_wqes)); 397 + } 398 + 355 399 static void mlx5e_get_ringparam(struct net_device *dev, 356 400 struct ethtool_ringparam *param) 357 401 { 358 402 struct mlx5e_priv *priv = netdev_priv(dev); 359 403 int rq_wq_type = priv->params.rq_wq_type; 360 404 361 - param->rx_max_pending = 1 << mlx5_max_log_rq_size(rq_wq_type); 405 + param->rx_max_pending = mlx5e_rx_wqes_to_packets(priv, rq_wq_type, 406 + 1 << mlx5_max_log_rq_size(rq_wq_type)); 362 407 param->tx_max_pending = 1 << MLX5E_PARAMS_MAXIMUM_LOG_SQ_SIZE; 363 - param->rx_pending = 1 << priv->params.log_rq_size; 408 + param->rx_pending = mlx5e_rx_wqes_to_packets(priv, rq_wq_type, 409 + 1 << priv->params.log_rq_size); 364 410 param->tx_pending = 1 << priv->params.log_sq_size; 365 411 } 366 412 ··· 416 370 struct mlx5e_priv *priv = netdev_priv(dev); 417 371 bool was_opened; 418 372 int rq_wq_type = priv->params.rq_wq_type; 373 + u32 rx_pending_wqes; 374 + u32 min_rq_size; 375 + u32 max_rq_size; 419 376 u16 min_rx_wqes; 420 377 u8 log_rq_size; 421 378 u8 log_sq_size; 379 + u32 num_mtts; 422 380 int err = 0; 423 381 424 382 if (param->rx_jumbo_pending) { ··· 435 385 __func__); 436 386 return -EINVAL; 437 387 } 438 - if (param->rx_pending < (1 << mlx5_min_log_rq_size(rq_wq_type))) { 388 + 389 + min_rq_size = mlx5e_rx_wqes_to_packets(priv, rq_wq_type, 390 + 1 << mlx5_min_log_rq_size(rq_wq_type)); 391 + max_rq_size = mlx5e_rx_wqes_to_packets(priv, rq_wq_type, 392 + 1 << mlx5_max_log_rq_size(rq_wq_type)); 393 + rx_pending_wqes = mlx5e_packets_to_rx_wqes(priv, rq_wq_type, 394 + param->rx_pending); 395 + 396 + if (param->rx_pending < min_rq_size) { 439 397 netdev_info(dev, "%s: rx_pending (%d) < min (%d)\n", 440 398 __func__, param->rx_pending, 441 - 1 << mlx5_min_log_rq_size(rq_wq_type)); 399 + min_rq_size); 442 400 return -EINVAL; 443 401 } 444 - if (param->rx_pending > (1 << mlx5_max_log_rq_size(rq_wq_type))) { 402 + if (param->rx_pending > max_rq_size) { 445 403 netdev_info(dev, "%s: rx_pending (%d) > max (%d)\n", 446 404 __func__, param->rx_pending, 447 - 1 << mlx5_max_log_rq_size(rq_wq_type)); 405 + max_rq_size); 448 406 return -EINVAL; 449 407 } 408 + 409 + num_mtts = MLX5E_REQUIRED_MTTS(priv->params.num_channels, 410 + rx_pending_wqes); 411 + if (priv->params.rq_wq_type == MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ && 412 + !MLX5E_VALID_NUM_MTTS(num_mtts)) { 413 + netdev_info(dev, "%s: rx_pending (%d) request can't be satisfied, try to reduce.\n", 414 + __func__, param->rx_pending); 415 + return -EINVAL; 416 + } 417 + 450 418 if (param->tx_pending < (1 << MLX5E_PARAMS_MINIMUM_LOG_SQ_SIZE)) { 451 419 netdev_info(dev, "%s: tx_pending (%d) < min (%d)\n", 452 420 __func__, param->tx_pending, ··· 478 410 return -EINVAL; 479 411 } 480 412 481 - log_rq_size = order_base_2(param->rx_pending); 413 + log_rq_size = order_base_2(rx_pending_wqes); 482 414 log_sq_size = order_base_2(param->tx_pending); 483 - min_rx_wqes = mlx5_min_rx_wqes(rq_wq_type, param->rx_pending); 415 + min_rx_wqes = mlx5_min_rx_wqes(rq_wq_type, rx_pending_wqes); 484 416 485 417 if (log_rq_size == priv->params.log_rq_size && 486 418 log_sq_size == priv->params.log_sq_size && ··· 522 454 unsigned int count = ch->combined_count; 523 455 bool arfs_enabled; 524 456 bool was_opened; 457 + u32 num_mtts; 525 458 int err = 0; 526 459 527 460 if (!count) { ··· 538 469 if (count > ncv) { 539 470 netdev_info(dev, "%s: count (%d) > max (%d)\n", 540 471 __func__, count, ncv); 472 + return -EINVAL; 473 + } 474 + 475 + num_mtts = MLX5E_REQUIRED_MTTS(count, BIT(priv->params.log_rq_size)); 476 + if (priv->params.rq_wq_type == MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ && 477 + !MLX5E_VALID_NUM_MTTS(num_mtts)) { 478 + netdev_info(dev, "%s: rx count (%d) request can't be satisfied, try to reduce.\n", 479 + __func__, count); 541 480 return -EINVAL; 542 481 } 543 482
+58 -65
drivers/net/ethernet/mellanox/mlx5/core/en_main.c
··· 39 39 #include "eswitch.h" 40 40 #include "vxlan.h" 41 41 42 - enum { 43 - MLX5_EN_QP_FLUSH_TIMEOUT_MS = 5000, 44 - MLX5_EN_QP_FLUSH_MSLEEP_QUANT = 20, 45 - MLX5_EN_QP_FLUSH_MAX_ITER = MLX5_EN_QP_FLUSH_TIMEOUT_MS / 46 - MLX5_EN_QP_FLUSH_MSLEEP_QUANT, 47 - }; 48 - 49 42 struct mlx5e_rq_param { 50 43 u32 rqc[MLX5_ST_SZ_DW(rqc)]; 51 44 struct mlx5_wq_param wq; ··· 155 162 s->tx_queue_stopped += sq_stats->stopped; 156 163 s->tx_queue_wake += sq_stats->wake; 157 164 s->tx_queue_dropped += sq_stats->dropped; 165 + s->tx_xmit_more += sq_stats->xmit_more; 158 166 s->tx_csum_partial_inner += sq_stats->csum_partial_inner; 159 167 tx_offload_none += sq_stats->csum_none; 160 168 } ··· 331 337 rq->alloc_wqe = mlx5e_alloc_rx_mpwqe; 332 338 rq->dealloc_wqe = mlx5e_dealloc_rx_mpwqe; 333 339 340 + rq->mpwqe_mtt_offset = c->ix * 341 + MLX5E_REQUIRED_MTTS(1, BIT(priv->params.log_rq_size)); 342 + 334 343 rq->mpwqe_stride_sz = BIT(priv->params.mpwqe_log_stride_sz); 335 344 rq->mpwqe_num_strides = BIT(priv->params.mpwqe_log_num_strides); 336 345 rq->wqe_sz = rq->mpwqe_stride_sz * rq->mpwqe_num_strides; ··· 422 425 423 426 MLX5_SET(rqc, rqc, cqn, rq->cq.mcq.cqn); 424 427 MLX5_SET(rqc, rqc, state, MLX5_RQC_STATE_RST); 425 - MLX5_SET(rqc, rqc, flush_in_error_en, 1); 426 428 MLX5_SET(rqc, rqc, vsd, priv->params.vlan_strip_disable); 427 429 MLX5_SET(wq, wq, log_wq_pg_sz, rq->wq_ctrl.buf.page_shift - 428 430 MLX5_ADAPTER_PAGE_SHIFT); ··· 519 523 return -ETIMEDOUT; 520 524 } 521 525 526 + static void mlx5e_free_rx_descs(struct mlx5e_rq *rq) 527 + { 528 + struct mlx5_wq_ll *wq = &rq->wq; 529 + struct mlx5e_rx_wqe *wqe; 530 + __be16 wqe_ix_be; 531 + u16 wqe_ix; 532 + 533 + /* UMR WQE (if in progress) is always at wq->head */ 534 + if (test_bit(MLX5E_RQ_STATE_UMR_WQE_IN_PROGRESS, &rq->state)) 535 + mlx5e_free_rx_fragmented_mpwqe(rq, &rq->wqe_info[wq->head]); 536 + 537 + while (!mlx5_wq_ll_is_empty(wq)) { 538 + wqe_ix_be = *wq->tail_next; 539 + wqe_ix = be16_to_cpu(wqe_ix_be); 540 + wqe = mlx5_wq_ll_get_wqe(&rq->wq, wqe_ix); 541 + rq->dealloc_wqe(rq, wqe_ix); 542 + mlx5_wq_ll_pop(&rq->wq, wqe_ix_be, 543 + &wqe->next.next_wqe_index); 544 + } 545 + } 546 + 522 547 static int mlx5e_open_rq(struct mlx5e_channel *c, 523 548 struct mlx5e_rq_param *param, 524 549 struct mlx5e_rq *rq) ··· 563 546 if (param->am_enabled) 564 547 set_bit(MLX5E_RQ_STATE_AM, &c->rq.state); 565 548 566 - set_bit(MLX5E_RQ_STATE_POST_WQES_ENABLE, &rq->state); 567 - 568 549 sq->ico_wqe_info[pi].opcode = MLX5_OPCODE_NOP; 569 550 sq->ico_wqe_info[pi].num_wqebbs = 1; 570 551 mlx5e_send_nop(sq, true); /* trigger mlx5e_post_rx_wqes() */ ··· 579 564 580 565 static void mlx5e_close_rq(struct mlx5e_rq *rq) 581 566 { 582 - int tout = 0; 583 - int err; 584 - 585 - clear_bit(MLX5E_RQ_STATE_POST_WQES_ENABLE, &rq->state); 567 + set_bit(MLX5E_RQ_STATE_FLUSH, &rq->state); 586 568 napi_synchronize(&rq->channel->napi); /* prevent mlx5e_post_rx_wqes */ 587 - 588 - err = mlx5e_modify_rq_state(rq, MLX5_RQC_STATE_RDY, MLX5_RQC_STATE_ERR); 589 - while (!mlx5_wq_ll_is_empty(&rq->wq) && !err && 590 - tout++ < MLX5_EN_QP_FLUSH_MAX_ITER) 591 - msleep(MLX5_EN_QP_FLUSH_MSLEEP_QUANT); 592 - 593 - if (err || tout == MLX5_EN_QP_FLUSH_MAX_ITER) 594 - set_bit(MLX5E_RQ_STATE_FLUSH_TIMEOUT, &rq->state); 595 - 596 - /* avoid destroying rq before mlx5e_poll_rx_cq() is done with it */ 597 - napi_synchronize(&rq->channel->napi); 598 - 599 569 cancel_work_sync(&rq->am.work); 600 570 601 571 mlx5e_disable_rq(rq); ··· 819 819 goto err_disable_sq; 820 820 821 821 if (sq->txq) { 822 - set_bit(MLX5E_SQ_STATE_WAKE_TXQ_ENABLE, &sq->state); 823 822 netdev_tx_reset_queue(sq->txq); 824 823 netif_tx_start_queue(sq->txq); 825 824 } ··· 842 843 843 844 static void mlx5e_close_sq(struct mlx5e_sq *sq) 844 845 { 845 - int tout = 0; 846 - int err; 847 - 848 - if (sq->txq) { 849 - clear_bit(MLX5E_SQ_STATE_WAKE_TXQ_ENABLE, &sq->state); 850 - /* prevent netif_tx_wake_queue */ 851 - napi_synchronize(&sq->channel->napi); 852 - netif_tx_disable_queue(sq->txq); 853 - 854 - /* ensure hw is notified of all pending wqes */ 855 - if (mlx5e_sq_has_room_for(sq, 1)) 856 - mlx5e_send_nop(sq, true); 857 - 858 - err = mlx5e_modify_sq(sq, MLX5_SQC_STATE_RDY, 859 - MLX5_SQC_STATE_ERR, false, 0); 860 - if (err) 861 - set_bit(MLX5E_SQ_STATE_TX_TIMEOUT, &sq->state); 862 - } 863 - 864 - /* wait till sq is empty, unless a TX timeout occurred on this SQ */ 865 - while (sq->cc != sq->pc && 866 - !test_bit(MLX5E_SQ_STATE_TX_TIMEOUT, &sq->state)) { 867 - msleep(MLX5_EN_QP_FLUSH_MSLEEP_QUANT); 868 - if (tout++ > MLX5_EN_QP_FLUSH_MAX_ITER) 869 - set_bit(MLX5E_SQ_STATE_TX_TIMEOUT, &sq->state); 870 - } 871 - 872 - /* avoid destroying sq before mlx5e_poll_tx_cq() is done with it */ 846 + set_bit(MLX5E_SQ_STATE_FLUSH, &sq->state); 847 + /* prevent netif_tx_wake_queue */ 873 848 napi_synchronize(&sq->channel->napi); 874 849 875 - mlx5e_free_tx_descs(sq); 850 + if (sq->txq) { 851 + netif_tx_disable_queue(sq->txq); 852 + 853 + /* last doorbell out, godspeed .. */ 854 + if (mlx5e_sq_has_room_for(sq, 1)) 855 + mlx5e_send_nop(sq, true); 856 + } 857 + 876 858 mlx5e_disable_sq(sq); 859 + mlx5e_free_tx_descs(sq); 877 860 mlx5e_destroy_sq(sq); 878 861 } 879 862 ··· 1805 1824 netif_set_real_num_tx_queues(netdev, num_txqs); 1806 1825 netif_set_real_num_rx_queues(netdev, priv->params.num_channels); 1807 1826 1808 - err = mlx5e_set_dev_port_mtu(netdev); 1809 - if (err) 1810 - goto err_clear_state_opened_flag; 1811 - 1812 1827 err = mlx5e_open_channels(priv); 1813 1828 if (err) { 1814 1829 netdev_err(netdev, "%s: mlx5e_open_channels failed, %d\n", ··· 2549 2572 u16 max_mtu; 2550 2573 u16 min_mtu; 2551 2574 int err = 0; 2575 + bool reset; 2552 2576 2553 2577 mlx5_query_port_max_mtu(mdev, &max_mtu, 1); 2554 2578 ··· 2565 2587 2566 2588 mutex_lock(&priv->state_lock); 2567 2589 2590 + reset = !priv->params.lro_en && 2591 + (priv->params.rq_wq_type != 2592 + MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ); 2593 + 2568 2594 was_opened = test_bit(MLX5E_STATE_OPENED, &priv->state); 2569 - if (was_opened) 2595 + if (was_opened && reset) 2570 2596 mlx5e_close_locked(netdev); 2571 2597 2572 2598 netdev->mtu = new_mtu; 2599 + mlx5e_set_dev_port_mtu(netdev); 2573 2600 2574 - if (was_opened) 2601 + if (was_opened && reset) 2575 2602 err = mlx5e_open_locked(netdev); 2576 2603 2577 2604 mutex_unlock(&priv->state_lock); ··· 2776 2793 if (!netif_xmit_stopped(netdev_get_tx_queue(dev, i))) 2777 2794 continue; 2778 2795 sched_work = true; 2779 - set_bit(MLX5E_SQ_STATE_TX_TIMEOUT, &sq->state); 2796 + set_bit(MLX5E_SQ_STATE_FLUSH, &sq->state); 2780 2797 netdev_err(dev, "TX timeout on queue: %d, SQ: 0x%x, CQ: 0x%x, SQ Cons: 0x%x SQ Prod: 0x%x\n", 2781 2798 i, sq->sqn, sq->cq.mcq.cqn, sq->cc, sq->pc); 2782 2799 } ··· 3210 3227 static int mlx5e_create_umr_mkey(struct mlx5e_priv *priv) 3211 3228 { 3212 3229 struct mlx5_core_dev *mdev = priv->mdev; 3213 - u64 npages = priv->profile->max_nch(mdev) * MLX5_CHANNEL_MAX_NUM_MTTS; 3230 + u64 npages = MLX5E_REQUIRED_MTTS(priv->profile->max_nch(mdev), 3231 + BIT(MLX5E_PARAMS_MAXIMUM_LOG_RQ_SIZE_MPW)); 3214 3232 int inlen = MLX5_ST_SZ_BYTES(create_mkey_in); 3215 3233 void *mkc; 3216 3234 u32 *in; ··· 3223 3239 3224 3240 mkc = MLX5_ADDR_OF(create_mkey_in, in, memory_key_mkey_entry); 3225 3241 3242 + npages = min_t(u32, ALIGN(U16_MAX, 4) * 2, npages); 3243 + 3226 3244 MLX5_SET(mkc, mkc, free, 1); 3227 3245 MLX5_SET(mkc, mkc, umr_en, 1); 3228 3246 MLX5_SET(mkc, mkc, lw, 1); ··· 3235 3249 MLX5_SET(mkc, mkc, pd, mdev->mlx5e_res.pdn); 3236 3250 MLX5_SET64(mkc, mkc, len, npages << PAGE_SHIFT); 3237 3251 MLX5_SET(mkc, mkc, translations_octword_size, 3238 - mlx5e_get_mtt_octw(npages)); 3252 + MLX5_MTT_OCTW(npages)); 3239 3253 MLX5_SET(mkc, mkc, log_page_size, PAGE_SHIFT); 3240 3254 3241 3255 err = mlx5_core_create_mkey(mdev, &priv->umr_mkey, in, inlen); ··· 3371 3385 queue_work(priv->wq, &priv->set_rx_mode_work); 3372 3386 3373 3387 if (MLX5_CAP_GEN(mdev, vport_group_manager)) { 3388 + mlx5_query_nic_vport_mac_address(mdev, 0, rep.hw_id); 3374 3389 rep.load = mlx5e_nic_rep_load; 3375 3390 rep.unload = mlx5e_nic_rep_unload; 3376 3391 rep.vport = 0; ··· 3451 3464 3452 3465 mlx5e_init_l2_addr(priv); 3453 3466 3467 + mlx5e_set_dev_port_mtu(netdev); 3468 + 3454 3469 err = register_netdev(netdev); 3455 3470 if (err) { 3456 3471 mlx5_core_err(mdev, "register_netdev failed, %d\n", err); ··· 3491 3502 struct mlx5_eswitch *esw = mdev->priv.eswitch; 3492 3503 int total_vfs = MLX5_TOTAL_VPORTS(mdev); 3493 3504 int vport; 3505 + u8 mac[ETH_ALEN]; 3494 3506 3495 3507 if (!MLX5_CAP_GEN(mdev, vport_group_manager)) 3496 3508 return; 3509 + 3510 + mlx5_query_nic_vport_mac_address(mdev, 0, mac); 3497 3511 3498 3512 for (vport = 1; vport < total_vfs; vport++) { 3499 3513 struct mlx5_eswitch_rep rep; ··· 3504 3512 rep.load = mlx5e_vport_rep_load; 3505 3513 rep.unload = mlx5e_vport_rep_unload; 3506 3514 rep.vport = vport; 3515 + ether_addr_copy(rep.hw_id, mac); 3507 3516 mlx5_eswitch_register_vport_rep(esw, &rep); 3508 3517 } 3509 3518 }
+2 -3
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
··· 135 135 int mlx5e_attr_get(struct net_device *dev, struct switchdev_attr *attr) 136 136 { 137 137 struct mlx5e_priv *priv = netdev_priv(dev); 138 + struct mlx5_eswitch_rep *rep = priv->ppriv; 138 139 struct mlx5_eswitch *esw = priv->mdev->priv.eswitch; 139 - u8 mac[ETH_ALEN]; 140 140 141 141 if (esw->mode == SRIOV_NONE) 142 142 return -EOPNOTSUPP; 143 143 144 144 switch (attr->id) { 145 145 case SWITCHDEV_ATTR_ID_PORT_PARENT_ID: 146 - mlx5_query_nic_vport_mac_address(priv->mdev, 0, mac); 147 146 attr->u.ppid.id_len = ETH_ALEN; 148 - memcpy(&attr->u.ppid.id, &mac, ETH_ALEN); 147 + ether_addr_copy(attr->u.ppid.id, rep->hw_id); 149 148 break; 150 149 default: 151 150 return -EOPNOTSUPP;
+15 -26
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
··· 324 324 } 325 325 } 326 326 327 - static u16 mlx5e_get_wqe_mtt_offset(u16 rq_ix, u16 wqe_ix) 327 + static u32 mlx5e_get_wqe_mtt_offset(struct mlx5e_rq *rq, u16 wqe_ix) 328 328 { 329 - return rq_ix * MLX5_CHANNEL_MAX_NUM_MTTS + 329 + return rq->mpwqe_mtt_offset + 330 330 wqe_ix * ALIGN(MLX5_MPWRQ_PAGES_PER_WQE, 8); 331 331 } 332 332 ··· 340 340 struct mlx5_wqe_data_seg *dseg = &wqe->data; 341 341 struct mlx5e_mpw_info *wi = &rq->wqe_info[ix]; 342 342 u8 ds_cnt = DIV_ROUND_UP(sizeof(*wqe), MLX5_SEND_WQE_DS); 343 - u16 umr_wqe_mtt_offset = mlx5e_get_wqe_mtt_offset(rq->ix, ix); 343 + u32 umr_wqe_mtt_offset = mlx5e_get_wqe_mtt_offset(rq, ix); 344 344 345 345 memset(wqe, 0, sizeof(*wqe)); 346 346 cseg->opmod_idx_opcode = ··· 353 353 354 354 ucseg->flags = MLX5_UMR_TRANSLATION_OFFSET_EN; 355 355 ucseg->klm_octowords = 356 - cpu_to_be16(mlx5e_get_mtt_octw(MLX5_MPWRQ_PAGES_PER_WQE)); 356 + cpu_to_be16(MLX5_MTT_OCTW(MLX5_MPWRQ_PAGES_PER_WQE)); 357 357 ucseg->bsf_octowords = 358 - cpu_to_be16(mlx5e_get_mtt_octw(umr_wqe_mtt_offset)); 358 + cpu_to_be16(MLX5_MTT_OCTW(umr_wqe_mtt_offset)); 359 359 ucseg->mkey_mask = cpu_to_be64(MLX5_MKEY_MASK_FREE); 360 360 361 361 dseg->lkey = sq->mkey_be; ··· 423 423 { 424 424 struct mlx5e_mpw_info *wi = &rq->wqe_info[ix]; 425 425 int mtt_sz = mlx5e_get_wqe_mtt_sz(); 426 - u32 dma_offset = mlx5e_get_wqe_mtt_offset(rq->ix, ix) << PAGE_SHIFT; 426 + u64 dma_offset = (u64)mlx5e_get_wqe_mtt_offset(rq, ix) << PAGE_SHIFT; 427 427 int i; 428 428 429 429 wi->umr.dma_info = kmalloc(sizeof(*wi->umr.dma_info) * ··· 506 506 struct mlx5e_rx_wqe *wqe = mlx5_wq_ll_get_wqe(wq, wq->head); 507 507 508 508 clear_bit(MLX5E_RQ_STATE_UMR_WQE_IN_PROGRESS, &rq->state); 509 + 510 + if (unlikely(test_bit(MLX5E_RQ_STATE_FLUSH, &rq->state))) { 511 + mlx5e_free_rx_fragmented_mpwqe(rq, &rq->wqe_info[wq->head]); 512 + return; 513 + } 514 + 509 515 mlx5_wq_ll_push(wq, be16_to_cpu(wqe->next.next_wqe_index)); 510 516 rq->stats.mpwqe_frag++; 511 517 ··· 601 595 wi->free_wqe(rq, wi); 602 596 } 603 597 604 - void mlx5e_free_rx_descs(struct mlx5e_rq *rq) 605 - { 606 - struct mlx5_wq_ll *wq = &rq->wq; 607 - struct mlx5e_rx_wqe *wqe; 608 - __be16 wqe_ix_be; 609 - u16 wqe_ix; 610 - 611 - while (!mlx5_wq_ll_is_empty(wq)) { 612 - wqe_ix_be = *wq->tail_next; 613 - wqe_ix = be16_to_cpu(wqe_ix_be); 614 - wqe = mlx5_wq_ll_get_wqe(&rq->wq, wqe_ix); 615 - rq->dealloc_wqe(rq, wqe_ix); 616 - mlx5_wq_ll_pop(&rq->wq, wqe_ix_be, 617 - &wqe->next.next_wqe_index); 618 - } 619 - } 620 - 621 598 #define RQ_CANNOT_POST(rq) \ 622 - (!test_bit(MLX5E_RQ_STATE_POST_WQES_ENABLE, &rq->state) || \ 623 - test_bit(MLX5E_RQ_STATE_UMR_WQE_IN_PROGRESS, &rq->state)) 599 + (test_bit(MLX5E_RQ_STATE_FLUSH, &rq->state) || \ 600 + test_bit(MLX5E_RQ_STATE_UMR_WQE_IN_PROGRESS, &rq->state)) 624 601 625 602 bool mlx5e_post_rx_wqes(struct mlx5e_rq *rq) 626 603 { ··· 905 916 struct mlx5e_rq *rq = container_of(cq, struct mlx5e_rq, cq); 906 917 int work_done = 0; 907 918 908 - if (unlikely(test_bit(MLX5E_RQ_STATE_FLUSH_TIMEOUT, &rq->state))) 919 + if (unlikely(test_bit(MLX5E_RQ_STATE_FLUSH, &rq->state))) 909 920 return 0; 910 921 911 922 if (cq->decmprs_left)
+4
drivers/net/ethernet/mellanox/mlx5/core/en_stats.h
··· 70 70 u64 tx_queue_stopped; 71 71 u64 tx_queue_wake; 72 72 u64 tx_queue_dropped; 73 + u64 tx_xmit_more; 73 74 u64 rx_wqe_err; 74 75 u64 rx_mpwqe_filler; 75 76 u64 rx_mpwqe_frag; ··· 102 101 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_queue_stopped) }, 103 102 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_queue_wake) }, 104 103 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_queue_dropped) }, 104 + { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_xmit_more) }, 105 105 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_wqe_err) }, 106 106 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_mpwqe_filler) }, 107 107 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_mpwqe_frag) }, ··· 300 298 /* commonly accessed in data path */ 301 299 u64 packets; 302 300 u64 bytes; 301 + u64 xmit_more; 303 302 u64 tso_packets; 304 303 u64 tso_bytes; 305 304 u64 tso_inner_packets; ··· 327 324 { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, stopped) }, 328 325 { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, wake) }, 329 326 { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, dropped) }, 327 + { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, xmit_more) }, 330 328 }; 331 329 332 330 #define NUM_SW_COUNTERS ARRAY_SIZE(sw_stats_desc)
+1 -1
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
··· 170 170 if (dissector_uses_key(f->dissector, FLOW_DISSECTOR_KEY_CONTROL)) { 171 171 struct flow_dissector_key_control *key = 172 172 skb_flow_dissector_target(f->dissector, 173 - FLOW_DISSECTOR_KEY_BASIC, 173 + FLOW_DISSECTOR_KEY_CONTROL, 174 174 f->key); 175 175 addr_type = key->addr_type; 176 176 }
+34 -34
drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
··· 375 375 376 376 sq->stats.packets++; 377 377 sq->stats.bytes += num_bytes; 378 + sq->stats.xmit_more += skb->xmit_more; 378 379 return NETDEV_TX_OK; 379 380 380 381 dma_unmap_wqe_err: ··· 395 394 return mlx5e_sq_xmit(sq, skb); 396 395 } 397 396 398 - void mlx5e_free_tx_descs(struct mlx5e_sq *sq) 399 - { 400 - struct mlx5e_tx_wqe_info *wi; 401 - struct sk_buff *skb; 402 - u16 ci; 403 - int i; 404 - 405 - while (sq->cc != sq->pc) { 406 - ci = sq->cc & sq->wq.sz_m1; 407 - skb = sq->skb[ci]; 408 - wi = &sq->wqe_info[ci]; 409 - 410 - if (!skb) { /* nop */ 411 - sq->cc++; 412 - continue; 413 - } 414 - 415 - for (i = 0; i < wi->num_dma; i++) { 416 - struct mlx5e_sq_dma *dma = 417 - mlx5e_dma_get(sq, sq->dma_fifo_cc++); 418 - 419 - mlx5e_tx_dma_unmap(sq->pdev, dma); 420 - } 421 - 422 - dev_kfree_skb_any(skb); 423 - sq->cc += wi->num_wqebbs; 424 - } 425 - } 426 - 427 397 bool mlx5e_poll_tx_cq(struct mlx5e_cq *cq, int napi_budget) 428 398 { 429 399 struct mlx5e_sq *sq; ··· 406 434 407 435 sq = container_of(cq, struct mlx5e_sq, cq); 408 436 409 - if (unlikely(test_bit(MLX5E_SQ_STATE_TX_TIMEOUT, &sq->state))) 437 + if (unlikely(test_bit(MLX5E_SQ_STATE_FLUSH, &sq->state))) 410 438 return false; 411 439 412 440 npkts = 0; ··· 484 512 netdev_tx_completed_queue(sq->txq, npkts, nbytes); 485 513 486 514 if (netif_tx_queue_stopped(sq->txq) && 487 - mlx5e_sq_has_room_for(sq, MLX5E_SQ_STOP_ROOM) && 488 - likely(test_bit(MLX5E_SQ_STATE_WAKE_TXQ_ENABLE, &sq->state))) { 489 - netif_tx_wake_queue(sq->txq); 490 - sq->stats.wake++; 515 + mlx5e_sq_has_room_for(sq, MLX5E_SQ_STOP_ROOM)) { 516 + netif_tx_wake_queue(sq->txq); 517 + sq->stats.wake++; 491 518 } 492 519 493 520 return (i == MLX5E_TX_CQ_POLL_BUDGET); 521 + } 522 + 523 + void mlx5e_free_tx_descs(struct mlx5e_sq *sq) 524 + { 525 + struct mlx5e_tx_wqe_info *wi; 526 + struct sk_buff *skb; 527 + u16 ci; 528 + int i; 529 + 530 + while (sq->cc != sq->pc) { 531 + ci = sq->cc & sq->wq.sz_m1; 532 + skb = sq->skb[ci]; 533 + wi = &sq->wqe_info[ci]; 534 + 535 + if (!skb) { /* nop */ 536 + sq->cc++; 537 + continue; 538 + } 539 + 540 + for (i = 0; i < wi->num_dma; i++) { 541 + struct mlx5e_sq_dma *dma = 542 + mlx5e_dma_get(sq, sq->dma_fifo_cc++); 543 + 544 + mlx5e_tx_dma_unmap(sq->pdev, dma); 545 + } 546 + 547 + dev_kfree_skb_any(skb); 548 + sq->cc += wi->num_wqebbs; 549 + } 494 550 }
+4 -2
drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c
··· 51 51 52 52 static void mlx5e_poll_ico_cq(struct mlx5e_cq *cq) 53 53 { 54 + struct mlx5e_sq *sq = container_of(cq, struct mlx5e_sq, cq); 54 55 struct mlx5_wq_cyc *wq; 55 56 struct mlx5_cqe64 *cqe; 56 - struct mlx5e_sq *sq; 57 57 u16 sqcc; 58 + 59 + if (unlikely(test_bit(MLX5E_SQ_STATE_FLUSH, &sq->state))) 60 + return; 58 61 59 62 cqe = mlx5e_get_cqe(cq); 60 63 if (likely(!cqe)) 61 64 return; 62 65 63 - sq = container_of(cq, struct mlx5e_sq, cq); 64 66 wq = &sq->wq; 65 67 66 68 /* sq->cc must be updated only after mlx5_cqwq_update_db_record(),
+9 -7
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
··· 1421 1421 1422 1422 esw_debug(esw->dev, "Enabling VPORT(%d)\n", vport_num); 1423 1423 1424 - if (vport_num) { /* Only VFs need ACLs for VST and spoofchk filtering */ 1424 + /* Only VFs need ACLs for VST and spoofchk filtering */ 1425 + if (vport_num && esw->mode == SRIOV_LEGACY) { 1425 1426 esw_vport_ingress_config(esw, vport); 1426 1427 esw_vport_egress_config(esw, vport); 1427 1428 } ··· 1473 1472 */ 1474 1473 esw_vport_change_handle_locked(vport); 1475 1474 vport->enabled_events = 0; 1476 - if (vport_num) { 1475 + if (vport_num && esw->mode == SRIOV_LEGACY) { 1477 1476 esw_vport_disable_egress_acl(esw, vport); 1478 1477 esw_vport_disable_ingress_acl(esw, vport); 1479 1478 } ··· 1738 1737 vport, err); 1739 1738 1740 1739 mutex_lock(&esw->state_lock); 1741 - if (evport->enabled) 1740 + if (evport->enabled && esw->mode == SRIOV_LEGACY) 1742 1741 err = esw_vport_ingress_config(esw, evport); 1743 1742 mutex_unlock(&esw->state_lock); 1744 1743 return err; ··· 1810 1809 mutex_lock(&esw->state_lock); 1811 1810 evport->vlan = vlan; 1812 1811 evport->qos = qos; 1813 - if (evport->enabled) { 1812 + if (evport->enabled && esw->mode == SRIOV_LEGACY) { 1814 1813 err = esw_vport_ingress_config(esw, evport); 1815 1814 if (err) 1816 1815 goto out; ··· 1839 1838 mutex_lock(&esw->state_lock); 1840 1839 pschk = evport->spoofchk; 1841 1840 evport->spoofchk = spoofchk; 1842 - if (evport->enabled) 1841 + if (evport->enabled && esw->mode == SRIOV_LEGACY) { 1843 1842 err = esw_vport_ingress_config(esw, evport); 1844 - if (err) 1845 - evport->spoofchk = pschk; 1843 + if (err) 1844 + evport->spoofchk = pschk; 1845 + } 1846 1846 mutex_unlock(&esw->state_lock); 1847 1847 1848 1848 return err;
+1
drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
··· 174 174 void *priv_data; 175 175 struct list_head vport_sqs_list; 176 176 bool valid; 177 + u8 hw_id[ETH_ALEN]; 177 178 }; 178 179 179 180 struct mlx5_esw_offload {
+20 -6
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
··· 113 113 dest.type = MLX5_FLOW_DESTINATION_TYPE_VPORT; 114 114 dest.vport_num = vport; 115 115 116 - flow_rule = mlx5_add_flow_rule(esw->fdb_table.fdb, spec, 116 + flow_rule = mlx5_add_flow_rule(esw->fdb_table.offloads.fdb, spec, 117 117 MLX5_FLOW_CONTEXT_ACTION_FWD_DEST, 118 118 0, &dest); 119 119 if (IS_ERR(flow_rule)) ··· 535 535 esw_destroy_offloads_fdb_table(esw); 536 536 } 537 537 538 - static int mlx5_esw_mode_from_devlink(u16 mode, u16 *mlx5_mode) 538 + static int esw_mode_from_devlink(u16 mode, u16 *mlx5_mode) 539 539 { 540 540 switch (mode) { 541 541 case DEVLINK_ESWITCH_MODE_LEGACY: ··· 543 543 break; 544 544 case DEVLINK_ESWITCH_MODE_SWITCHDEV: 545 545 *mlx5_mode = SRIOV_OFFLOADS; 546 + break; 547 + default: 548 + return -EINVAL; 549 + } 550 + 551 + return 0; 552 + } 553 + 554 + static int esw_mode_to_devlink(u16 mlx5_mode, u16 *mode) 555 + { 556 + switch (mlx5_mode) { 557 + case SRIOV_LEGACY: 558 + *mode = DEVLINK_ESWITCH_MODE_LEGACY; 559 + break; 560 + case SRIOV_OFFLOADS: 561 + *mode = DEVLINK_ESWITCH_MODE_SWITCHDEV; 546 562 break; 547 563 default: 548 564 return -EINVAL; ··· 582 566 if (cur_mlx5_mode == SRIOV_NONE) 583 567 return -EOPNOTSUPP; 584 568 585 - if (mlx5_esw_mode_from_devlink(mode, &mlx5_mode)) 569 + if (esw_mode_from_devlink(mode, &mlx5_mode)) 586 570 return -EINVAL; 587 571 588 572 if (cur_mlx5_mode == mlx5_mode) ··· 608 592 if (dev->priv.eswitch->mode == SRIOV_NONE) 609 593 return -EOPNOTSUPP; 610 594 611 - *mode = dev->priv.eswitch->mode; 612 - 613 - return 0; 595 + return esw_mode_to_devlink(dev->priv.eswitch->mode, mode); 614 596 } 615 597 616 598 void mlx5_eswitch_register_vport_rep(struct mlx5_eswitch *esw,
+1 -1
drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
··· 80 80 LEFTOVERS_NUM_PRIOS) 81 81 82 82 #define ETHTOOL_PRIO_NUM_LEVELS 1 83 - #define ETHTOOL_NUM_PRIOS 10 83 + #define ETHTOOL_NUM_PRIOS 11 84 84 #define ETHTOOL_MIN_LEVEL (KERNEL_MIN_LEVEL + ETHTOOL_NUM_PRIOS) 85 85 /* Vlan, mac, ttc, aRFS */ 86 86 #define KERNEL_NIC_PRIO_NUM_LEVELS 4
+10 -1
drivers/net/ethernet/mellanox/mlx5/core/fs_counters.c
··· 126 126 for (node = &first->node; node; node = rb_next(node)) { 127 127 struct mlx5_fc *counter = rb_entry(node, struct mlx5_fc, node); 128 128 struct mlx5_fc_cache *c = &counter->cache; 129 + u64 packets; 130 + u64 bytes; 129 131 130 132 if (counter->id > last_id) 131 133 break; 132 134 133 135 mlx5_cmd_fc_bulk_get(dev, b, 134 - counter->id, &c->packets, &c->bytes); 136 + counter->id, &packets, &bytes); 137 + 138 + if (c->packets == packets) 139 + continue; 140 + 141 + c->packets = packets; 142 + c->bytes = bytes; 143 + c->lastuse = jiffies; 135 144 } 136 145 137 146 out:
+31 -32
drivers/net/ethernet/mellanox/mlx5/core/main.c
··· 1417 1417 dev_info(&pdev->dev, "%s was called\n", __func__); 1418 1418 mlx5_enter_error_state(dev); 1419 1419 mlx5_unload_one(dev, priv); 1420 + pci_save_state(pdev); 1420 1421 mlx5_pci_disable_device(dev); 1421 1422 return state == pci_channel_io_perm_failure ? 1422 1423 PCI_ERS_RESULT_DISCONNECT : PCI_ERS_RESULT_NEED_RESET; 1423 - } 1424 - 1425 - static pci_ers_result_t mlx5_pci_slot_reset(struct pci_dev *pdev) 1426 - { 1427 - struct mlx5_core_dev *dev = pci_get_drvdata(pdev); 1428 - int err = 0; 1429 - 1430 - dev_info(&pdev->dev, "%s was called\n", __func__); 1431 - 1432 - err = mlx5_pci_enable_device(dev); 1433 - if (err) { 1434 - dev_err(&pdev->dev, "%s: mlx5_pci_enable_device failed with error code: %d\n" 1435 - , __func__, err); 1436 - return PCI_ERS_RESULT_DISCONNECT; 1437 - } 1438 - pci_set_master(pdev); 1439 - pci_set_power_state(pdev, PCI_D0); 1440 - pci_restore_state(pdev); 1441 - 1442 - return err ? PCI_ERS_RESULT_DISCONNECT : PCI_ERS_RESULT_RECOVERED; 1443 - } 1444 - 1445 - void mlx5_disable_device(struct mlx5_core_dev *dev) 1446 - { 1447 - mlx5_pci_err_detected(dev->pdev, 0); 1448 1424 } 1449 1425 1450 1426 /* wait for the device to show vital signs by waiting ··· 1450 1474 return -ETIMEDOUT; 1451 1475 } 1452 1476 1477 + static pci_ers_result_t mlx5_pci_slot_reset(struct pci_dev *pdev) 1478 + { 1479 + struct mlx5_core_dev *dev = pci_get_drvdata(pdev); 1480 + int err; 1481 + 1482 + dev_info(&pdev->dev, "%s was called\n", __func__); 1483 + 1484 + err = mlx5_pci_enable_device(dev); 1485 + if (err) { 1486 + dev_err(&pdev->dev, "%s: mlx5_pci_enable_device failed with error code: %d\n" 1487 + , __func__, err); 1488 + return PCI_ERS_RESULT_DISCONNECT; 1489 + } 1490 + 1491 + pci_set_master(pdev); 1492 + pci_restore_state(pdev); 1493 + 1494 + if (wait_vital(pdev)) { 1495 + dev_err(&pdev->dev, "%s: wait_vital timed out\n", __func__); 1496 + return PCI_ERS_RESULT_DISCONNECT; 1497 + } 1498 + 1499 + return PCI_ERS_RESULT_RECOVERED; 1500 + } 1501 + 1502 + void mlx5_disable_device(struct mlx5_core_dev *dev) 1503 + { 1504 + mlx5_pci_err_detected(dev->pdev, 0); 1505 + } 1506 + 1453 1507 static void mlx5_pci_resume(struct pci_dev *pdev) 1454 1508 { 1455 1509 struct mlx5_core_dev *dev = pci_get_drvdata(pdev); ··· 1487 1481 int err; 1488 1482 1489 1483 dev_info(&pdev->dev, "%s was called\n", __func__); 1490 - 1491 - pci_save_state(pdev); 1492 - err = wait_vital(pdev); 1493 - if (err) { 1494 - dev_err(&pdev->dev, "%s: wait_vital timed out\n", __func__); 1495 - return; 1496 - } 1497 1484 1498 1485 err = mlx5_load_one(dev, priv); 1499 1486 if (err)
+1
drivers/net/ethernet/mellanox/mlxsw/port.h
··· 56 56 #define MLXSW_PORT_PHY_BITS_MASK (MLXSW_PORT_MAX_PHY_PORTS - 1) 57 57 58 58 #define MLXSW_PORT_CPU_PORT 0x0 59 + #define MLXSW_PORT_ROUTER_PORT (MLXSW_PORT_MAX_PHY_PORTS + 2) 59 60 60 61 #define MLXSW_PORT_DONT_CARE (MLXSW_PORT_MAX_PORTS) 61 62
+42 -1
drivers/net/ethernet/mellanox/mlxsw/spectrum.c
··· 3248 3248 return mlxsw_sp_fid_find(mlxsw_sp, fid); 3249 3249 } 3250 3250 3251 + static enum mlxsw_flood_table_type mlxsw_sp_flood_table_type_get(u16 fid) 3252 + { 3253 + return mlxsw_sp_fid_is_vfid(fid) ? MLXSW_REG_SFGC_TABLE_TYPE_FID : 3254 + MLXSW_REG_SFGC_TABLE_TYPE_FID_OFFEST; 3255 + } 3256 + 3257 + static u16 mlxsw_sp_flood_table_index_get(u16 fid) 3258 + { 3259 + return mlxsw_sp_fid_is_vfid(fid) ? mlxsw_sp_fid_to_vfid(fid) : fid; 3260 + } 3261 + 3262 + static int mlxsw_sp_router_port_flood_set(struct mlxsw_sp *mlxsw_sp, u16 fid, 3263 + bool set) 3264 + { 3265 + enum mlxsw_flood_table_type table_type; 3266 + char *sftr_pl; 3267 + u16 index; 3268 + int err; 3269 + 3270 + sftr_pl = kmalloc(MLXSW_REG_SFTR_LEN, GFP_KERNEL); 3271 + if (!sftr_pl) 3272 + return -ENOMEM; 3273 + 3274 + table_type = mlxsw_sp_flood_table_type_get(fid); 3275 + index = mlxsw_sp_flood_table_index_get(fid); 3276 + mlxsw_reg_sftr_pack(sftr_pl, MLXSW_SP_FLOOD_TABLE_BM, index, table_type, 3277 + 1, MLXSW_PORT_ROUTER_PORT, set); 3278 + err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(sftr), sftr_pl); 3279 + 3280 + kfree(sftr_pl); 3281 + return err; 3282 + } 3283 + 3251 3284 static enum mlxsw_reg_ritr_if_type mlxsw_sp_rif_type_get(u16 fid) 3252 3285 { 3253 3286 if (mlxsw_sp_fid_is_vfid(fid)) ··· 3317 3284 if (rif == MLXSW_SP_RIF_MAX) 3318 3285 return -ERANGE; 3319 3286 3320 - err = mlxsw_sp_rif_bridge_op(mlxsw_sp, l3_dev, f->fid, rif, true); 3287 + err = mlxsw_sp_router_port_flood_set(mlxsw_sp, f->fid, true); 3321 3288 if (err) 3322 3289 return err; 3290 + 3291 + err = mlxsw_sp_rif_bridge_op(mlxsw_sp, l3_dev, f->fid, rif, true); 3292 + if (err) 3293 + goto err_rif_bridge_op; 3323 3294 3324 3295 err = mlxsw_sp_rif_fdb_op(mlxsw_sp, l3_dev->dev_addr, f->fid, true); 3325 3296 if (err) ··· 3346 3309 mlxsw_sp_rif_fdb_op(mlxsw_sp, l3_dev->dev_addr, f->fid, false); 3347 3310 err_rif_fdb_op: 3348 3311 mlxsw_sp_rif_bridge_op(mlxsw_sp, l3_dev, f->fid, rif, false); 3312 + err_rif_bridge_op: 3313 + mlxsw_sp_router_port_flood_set(mlxsw_sp, f->fid, false); 3349 3314 return err; 3350 3315 } 3351 3316 ··· 3366 3327 mlxsw_sp_rif_fdb_op(mlxsw_sp, l3_dev->dev_addr, f->fid, false); 3367 3328 3368 3329 mlxsw_sp_rif_bridge_op(mlxsw_sp, l3_dev, f->fid, rif, false); 3330 + 3331 + mlxsw_sp_router_port_flood_set(mlxsw_sp, f->fid, false); 3369 3332 3370 3333 netdev_dbg(l3_dev, "RIF=%d destroyed\n", rif); 3371 3334 }
+4 -8
drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c
··· 717 717 u8 local_port = mlxsw_sp_port->local_port; 718 718 u8 pg_buff = tc_index; 719 719 enum mlxsw_reg_sbxx_dir dir = pool_type; 720 - u8 pool = pool_index; 720 + u8 pool = pool_get(pool_index); 721 721 u32 max_buff; 722 722 int err; 723 + 724 + if (dir != dir_get(pool_index)) 725 + return -EINVAL; 723 726 724 727 err = mlxsw_sp_sb_threshold_in(mlxsw_sp, pool, dir, 725 728 threshold, &max_buff); 726 729 if (err) 727 730 return err; 728 731 729 - if (pool_type == DEVLINK_SB_POOL_TYPE_EGRESS) { 730 - if (pool < MLXSW_SP_SB_POOL_COUNT) 731 - return -EINVAL; 732 - pool -= MLXSW_SP_SB_POOL_COUNT; 733 - } else if (pool >= MLXSW_SP_SB_POOL_COUNT) { 734 - return -EINVAL; 735 - } 736 732 return mlxsw_sp_sb_cm_write(mlxsw_sp, local_port, pg_buff, dir, 737 733 0, max_buff, pool); 738 734 }
+1 -1
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
··· 657 657 return 0; 658 658 } 659 659 660 - r = mlxsw_sp_rif_find_by_dev(mlxsw_sp, dev); 660 + r = mlxsw_sp_rif_find_by_dev(mlxsw_sp, n->dev); 661 661 if (WARN_ON(!r)) 662 662 return -EINVAL; 663 663
+9 -11
drivers/net/ethernet/nxp/lpc_eth.c
··· 475 475 mac[5] = tmp >> 8; 476 476 } 477 477 478 - static void __lpc_eth_clock_enable(struct netdata_local *pldat, bool enable) 479 - { 480 - if (enable) 481 - clk_prepare_enable(pldat->clk); 482 - else 483 - clk_disable_unprepare(pldat->clk); 484 - } 485 - 486 478 static void __lpc_params_setup(struct netdata_local *pldat) 487 479 { 488 480 u32 tmp; ··· 1048 1056 writel(0, LPC_ENET_MAC2(pldat->net_base)); 1049 1057 spin_unlock_irqrestore(&pldat->lock, flags); 1050 1058 1051 - __lpc_eth_clock_enable(pldat, false); 1059 + clk_disable_unprepare(pldat->clk); 1052 1060 1053 1061 return 0; 1054 1062 } ··· 1189 1197 static int lpc_eth_open(struct net_device *ndev) 1190 1198 { 1191 1199 struct netdata_local *pldat = netdev_priv(ndev); 1200 + int ret; 1192 1201 1193 1202 if (netif_msg_ifup(pldat)) 1194 1203 dev_dbg(&pldat->pdev->dev, "enabling %s\n", ndev->name); 1195 1204 1196 - __lpc_eth_clock_enable(pldat, true); 1205 + ret = clk_prepare_enable(pldat->clk); 1206 + if (ret) 1207 + return ret; 1197 1208 1198 1209 /* Suspended PHY makes LPC ethernet core block, so resume now */ 1199 1210 phy_resume(ndev->phydev); ··· 1315 1320 } 1316 1321 1317 1322 /* Enable network clock */ 1318 - __lpc_eth_clock_enable(pldat, true); 1323 + ret = clk_prepare_enable(pldat->clk); 1324 + if (ret) 1325 + goto err_out_clk_put; 1319 1326 1320 1327 /* Map IO space */ 1321 1328 pldat->net_base = ioremap(res->start, resource_size(res)); ··· 1451 1454 iounmap(pldat->net_base); 1452 1455 err_out_disable_clocks: 1453 1456 clk_disable_unprepare(pldat->clk); 1457 + err_out_clk_put: 1454 1458 clk_put(pldat->clk); 1455 1459 err_out_free_dev: 1456 1460 free_netdev(ndev);
+10 -1
drivers/net/ethernet/qlogic/qed/qed.h
··· 563 563 static inline u8 qed_concrete_to_sw_fid(struct qed_dev *cdev, 564 564 u32 concrete_fid) 565 565 { 566 + u8 vfid = GET_FIELD(concrete_fid, PXP_CONCRETE_FID_VFID); 566 567 u8 pfid = GET_FIELD(concrete_fid, PXP_CONCRETE_FID_PFID); 568 + u8 vf_valid = GET_FIELD(concrete_fid, 569 + PXP_CONCRETE_FID_VFVALID); 570 + u8 sw_fid; 567 571 568 - return pfid; 572 + if (vf_valid) 573 + sw_fid = vfid + MAX_NUM_PFS; 574 + else 575 + sw_fid = pfid; 576 + 577 + return sw_fid; 569 578 } 570 579 571 580 #define PURE_LB_TC 8
+4 -1
drivers/net/ethernet/qlogic/qede/qede_main.c
··· 722 722 txq->tx_db.data.bd_prod = 723 723 cpu_to_le16(qed_chain_get_prod_idx(&txq->tx_pbl)); 724 724 725 - if (!skb->xmit_more || netif_tx_queue_stopped(netdev_txq)) 725 + if (!skb->xmit_more || netif_xmit_stopped(netdev_txq)) 726 726 qede_update_tx_producer(txq); 727 727 728 728 if (unlikely(qed_chain_get_elem_left(&txq->tx_pbl) 729 729 < (MAX_SKB_FRAGS + 1))) { 730 + if (skb->xmit_more) 731 + qede_update_tx_producer(txq); 732 + 730 733 netif_tx_stop_queue(netdev_txq); 731 734 txq->stopped_cnt++; 732 735 DP_VERBOSE(edev, NETIF_MSG_TX_QUEUED,
+1 -1
drivers/net/ethernet/realtek/8139cp.c
··· 467 467 unsigned int rx_tail = cp->rx_tail; 468 468 int rx; 469 469 470 - rx_status_loop: 471 470 rx = 0; 471 + rx_status_loop: 472 472 cpw16(IntrStatus, cp_rx_intr_mask); 473 473 474 474 while (rx < budget) {
+2 -1
drivers/net/ethernet/sfc/ef10.c
··· 1616 1616 } 1617 1617 1618 1618 #if BITS_PER_LONG == 64 1619 + BUILD_BUG_ON(BITS_TO_LONGS(EF10_STAT_COUNT) != 2); 1619 1620 mask[0] = raw_mask[0]; 1620 1621 mask[1] = raw_mask[1]; 1621 1622 #else 1623 + BUILD_BUG_ON(BITS_TO_LONGS(EF10_STAT_COUNT) != 3); 1622 1624 mask[0] = raw_mask[0] & 0xffffffff; 1623 1625 mask[1] = raw_mask[0] >> 32; 1624 1626 mask[2] = raw_mask[1] & 0xffffffff; 1625 - mask[3] = raw_mask[1] >> 32; 1626 1627 #endif 1627 1628 } 1628 1629
+7
drivers/net/ethernet/smsc/smc91x.c
··· 2275 2275 if (pd) { 2276 2276 memcpy(&lp->cfg, pd, sizeof(lp->cfg)); 2277 2277 lp->io_shift = SMC91X_IO_SHIFT(lp->cfg.flags); 2278 + 2279 + if (!SMC_8BIT(lp) && !SMC_16BIT(lp)) { 2280 + dev_err(&pdev->dev, 2281 + "at least one of 8-bit or 16-bit access support is required.\n"); 2282 + ret = -ENXIO; 2283 + goto out_free_netdev; 2284 + } 2278 2285 } 2279 2286 2280 2287 #if IS_BUILTIN(CONFIG_OF)
+45 -20
drivers/net/ethernet/smsc/smc91x.h
··· 37 37 #include <linux/smc91x.h> 38 38 39 39 /* 40 + * Any 16-bit access is performed with two 8-bit accesses if the hardware 41 + * can't do it directly. Most registers are 16-bit so those are mandatory. 42 + */ 43 + #define SMC_outw_b(x, a, r) \ 44 + do { \ 45 + unsigned int __val16 = (x); \ 46 + unsigned int __reg = (r); \ 47 + SMC_outb(__val16, a, __reg); \ 48 + SMC_outb(__val16 >> 8, a, __reg + (1 << SMC_IO_SHIFT)); \ 49 + } while (0) 50 + 51 + #define SMC_inw_b(a, r) \ 52 + ({ \ 53 + unsigned int __val16; \ 54 + unsigned int __reg = r; \ 55 + __val16 = SMC_inb(a, __reg); \ 56 + __val16 |= SMC_inb(a, __reg + (1 << SMC_IO_SHIFT)) << 8; \ 57 + __val16; \ 58 + }) 59 + 60 + /* 40 61 * Define your architecture specific bus configuration parameters here. 41 62 */ 42 63 ··· 76 55 #define SMC_IO_SHIFT (lp->io_shift) 77 56 78 57 #define SMC_inb(a, r) readb((a) + (r)) 79 - #define SMC_inw(a, r) readw((a) + (r)) 58 + #define SMC_inw(a, r) \ 59 + ({ \ 60 + unsigned int __smc_r = r; \ 61 + SMC_16BIT(lp) ? readw((a) + __smc_r) : \ 62 + SMC_8BIT(lp) ? SMC_inw_b(a, __smc_r) : \ 63 + ({ BUG(); 0; }); \ 64 + }) 65 + 80 66 #define SMC_inl(a, r) readl((a) + (r)) 81 67 #define SMC_outb(v, a, r) writeb(v, (a) + (r)) 68 + #define SMC_outw(v, a, r) \ 69 + do { \ 70 + unsigned int __v = v, __smc_r = r; \ 71 + if (SMC_16BIT(lp)) \ 72 + __SMC_outw(__v, a, __smc_r); \ 73 + else if (SMC_8BIT(lp)) \ 74 + SMC_outw_b(__v, a, __smc_r); \ 75 + else \ 76 + BUG(); \ 77 + } while (0) 78 + 82 79 #define SMC_outl(v, a, r) writel(v, (a) + (r)) 80 + #define SMC_insb(a, r, p, l) readsb((a) + (r), p, l) 81 + #define SMC_outsb(a, r, p, l) writesb((a) + (r), p, l) 83 82 #define SMC_insw(a, r, p, l) readsw((a) + (r), p, l) 84 83 #define SMC_outsw(a, r, p, l) writesw((a) + (r), p, l) 85 84 #define SMC_insl(a, r, p, l) readsl((a) + (r), p, l) ··· 107 66 #define SMC_IRQ_FLAGS (-1) /* from resource */ 108 67 109 68 /* We actually can't write halfwords properly if not word aligned */ 110 - static inline void SMC_outw(u16 val, void __iomem *ioaddr, int reg) 69 + static inline void __SMC_outw(u16 val, void __iomem *ioaddr, int reg) 111 70 { 112 71 if ((machine_is_mainstone() || machine_is_stargate2() || 113 72 machine_is_pxa_idp()) && reg & 2) { ··· 457 416 458 417 #if ! SMC_CAN_USE_16BIT 459 418 460 - /* 461 - * Any 16-bit access is performed with two 8-bit accesses if the hardware 462 - * can't do it directly. Most registers are 16-bit so those are mandatory. 463 - */ 464 - #define SMC_outw(x, ioaddr, reg) \ 465 - do { \ 466 - unsigned int __val16 = (x); \ 467 - SMC_outb( __val16, ioaddr, reg ); \ 468 - SMC_outb( __val16 >> 8, ioaddr, reg + (1 << SMC_IO_SHIFT));\ 469 - } while (0) 470 - #define SMC_inw(ioaddr, reg) \ 471 - ({ \ 472 - unsigned int __val16; \ 473 - __val16 = SMC_inb( ioaddr, reg ); \ 474 - __val16 |= SMC_inb( ioaddr, reg + (1 << SMC_IO_SHIFT)) << 8; \ 475 - __val16; \ 476 - }) 477 - 419 + #define SMC_outw(x, ioaddr, reg) SMC_outw_b(x, ioaddr, reg) 420 + #define SMC_inw(ioaddr, reg) SMC_inw_b(ioaddr, reg) 478 421 #define SMC_insw(a, r, p, l) BUG() 479 422 #define SMC_outsw(a, r, p, l) BUG() 480 423
+10 -7
drivers/net/ethernet/synopsys/dwc_eth_qos.c
··· 1622 1622 DWCEQOS_MMC_CTRL_RSTONRD); 1623 1623 dwceqos_enable_mmc_interrupt(lp); 1624 1624 1625 - /* Enable Interrupts */ 1626 - dwceqos_write(lp, REG_DWCEQOS_DMA_CH0_IE, 1627 - DWCEQOS_DMA_CH0_IE_NIE | 1628 - DWCEQOS_DMA_CH0_IE_RIE | DWCEQOS_DMA_CH0_IE_TIE | 1629 - DWCEQOS_DMA_CH0_IE_AIE | 1630 - DWCEQOS_DMA_CH0_IE_FBEE); 1631 - 1625 + dwceqos_write(lp, REG_DWCEQOS_DMA_CH0_IE, 0); 1632 1626 dwceqos_write(lp, REG_DWCEQOS_MAC_IE, 0); 1633 1627 1634 1628 dwceqos_write(lp, REG_DWCEQOS_MAC_CFG, DWCEQOS_MAC_CFG_IPC | ··· 1898 1904 1899 1905 netif_start_queue(ndev); 1900 1906 tasklet_enable(&lp->tx_bdreclaim_tasklet); 1907 + 1908 + /* Enable Interrupts -- do this only after we enable NAPI and the 1909 + * tasklet. 1910 + */ 1911 + dwceqos_write(lp, REG_DWCEQOS_DMA_CH0_IE, 1912 + DWCEQOS_DMA_CH0_IE_NIE | 1913 + DWCEQOS_DMA_CH0_IE_RIE | DWCEQOS_DMA_CH0_IE_TIE | 1914 + DWCEQOS_DMA_CH0_IE_AIE | 1915 + DWCEQOS_DMA_CH0_IE_FBEE); 1901 1916 1902 1917 return 0; 1903 1918 }
+1 -1
drivers/net/ethernet/tehuti/tehuti.c
··· 1987 1987 if ((readl(nic->regs + FPGA_VER) & 0xFFF) >= 378) { 1988 1988 err = pci_enable_msi(pdev); 1989 1989 if (err) 1990 - pr_err("Can't eneble msi. error is %d\n", err); 1990 + pr_err("Can't enable msi. error is %d\n", err); 1991 1991 else 1992 1992 nic->irq_type = IRQ_MSI; 1993 1993 } else
+5 -3
drivers/net/ethernet/xilinx/xilinx_emaclite.c
··· 1131 1131 lp->rx_ping_pong = get_bool(ofdev, "xlnx,rx-ping-pong"); 1132 1132 mac_address = of_get_mac_address(ofdev->dev.of_node); 1133 1133 1134 - if (mac_address) 1134 + if (mac_address) { 1135 1135 /* Set the MAC address. */ 1136 1136 memcpy(ndev->dev_addr, mac_address, ETH_ALEN); 1137 - else 1138 - dev_warn(dev, "No MAC address found\n"); 1137 + } else { 1138 + dev_warn(dev, "No MAC address found, using random\n"); 1139 + eth_hw_addr_random(ndev); 1140 + } 1139 1141 1140 1142 /* Clear the Tx CSR's in case this is a restart */ 1141 1143 __raw_writel(0, lp->base_addr + XEL_TSR_OFFSET);
+1 -1
drivers/net/phy/micrel.c
··· 964 964 .get_strings = kszphy_get_strings, 965 965 .get_stats = kszphy_get_stats, 966 966 .suspend = genphy_suspend, 967 - .resume = genphy_resume, 967 + .resume = kszphy_resume, 968 968 }, { 969 969 .phy_id = PHY_ID_KSZ8873MLL, 970 970 .phy_id_mask = MICREL_PHY_ID_MASK,
+4 -2
drivers/net/phy/phy.c
··· 722 722 int phy_start_interrupts(struct phy_device *phydev) 723 723 { 724 724 atomic_set(&phydev->irq_disable, 0); 725 - if (request_irq(phydev->irq, phy_interrupt, 0, "phy_interrupt", 726 - phydev) < 0) { 725 + if (request_irq(phydev->irq, phy_interrupt, 726 + IRQF_SHARED, 727 + "phy_interrupt", 728 + phydev) < 0) { 727 729 pr_warn("%s: Can't get IRQ %d (PHY)\n", 728 730 phydev->mdio.bus->name, phydev->irq); 729 731 phydev->irq = PHY_POLL;
+15
drivers/net/team/team_mode_loadbalance.c
··· 14 14 #include <linux/init.h> 15 15 #include <linux/errno.h> 16 16 #include <linux/netdevice.h> 17 + #include <linux/etherdevice.h> 17 18 #include <linux/filter.h> 18 19 #include <linux/if_team.h> 20 + 21 + static rx_handler_result_t lb_receive(struct team *team, struct team_port *port, 22 + struct sk_buff *skb) 23 + { 24 + if (unlikely(skb->protocol == htons(ETH_P_SLOW))) { 25 + /* LACPDU packets should go to exact delivery */ 26 + const unsigned char *dest = eth_hdr(skb)->h_dest; 27 + 28 + if (is_link_local_ether_addr(dest) && dest[5] == 0x02) 29 + return RX_HANDLER_EXACT; 30 + } 31 + return RX_HANDLER_ANOTHER; 32 + } 19 33 20 34 struct lb_priv; 21 35 ··· 666 652 .port_enter = lb_port_enter, 667 653 .port_leave = lb_port_leave, 668 654 .port_disabled = lb_port_disabled, 655 + .receive = lb_receive, 669 656 .transmit = lb_transmit, 670 657 }; 671 658
+1 -5
drivers/net/tun.c
··· 888 888 if (unlikely(skb_orphan_frags(skb, GFP_ATOMIC))) 889 889 goto drop; 890 890 891 - if (skb->sk && sk_fullsock(skb->sk)) { 892 - sock_tx_timestamp(skb->sk, skb->sk->sk_tsflags, 893 - &skb_shinfo(skb)->tx_flags); 894 - sw_tx_timestamp(skb); 895 - } 891 + skb_tx_timestamp(skb); 896 892 897 893 /* Orphan the skb - required as we might hang on to it 898 894 * for indefinite time.
+7 -3
drivers/net/usb/kaweth.c
··· 1009 1009 struct net_device *netdev; 1010 1010 const eth_addr_t bcast_addr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; 1011 1011 int result = 0; 1012 + int rv = -EIO; 1012 1013 1013 1014 dev_dbg(dev, 1014 1015 "Kawasaki Device Probe (Device number:%d): 0x%4.4x:0x%4.4x:0x%4.4x\n", ··· 1030 1029 kaweth = netdev_priv(netdev); 1031 1030 kaweth->dev = udev; 1032 1031 kaweth->net = netdev; 1032 + kaweth->intf = intf; 1033 1033 1034 1034 spin_lock_init(&kaweth->device_lock); 1035 1035 init_waitqueue_head(&kaweth->term_wait); ··· 1050 1048 /* Download the firmware */ 1051 1049 dev_info(dev, "Downloading firmware...\n"); 1052 1050 kaweth->firmware_buf = (__u8 *)__get_free_page(GFP_KERNEL); 1051 + if (!kaweth->firmware_buf) { 1052 + rv = -ENOMEM; 1053 + goto err_free_netdev; 1054 + } 1053 1055 if ((result = kaweth_download_firmware(kaweth, 1054 1056 "kaweth/new_code.bin", 1055 1057 100, ··· 1145 1139 1146 1140 dev_dbg(dev, "Initializing net device.\n"); 1147 1141 1148 - kaweth->intf = intf; 1149 - 1150 1142 kaweth->tx_urb = usb_alloc_urb(0, GFP_KERNEL); 1151 1143 if (!kaweth->tx_urb) 1152 1144 goto err_free_netdev; ··· 1208 1204 err_free_netdev: 1209 1205 free_netdev(netdev); 1210 1206 1211 - return -EIO; 1207 + return rv; 1212 1208 } 1213 1209 1214 1210 /****************************************************************
+3 -1
drivers/net/vmxnet3/vmxnet3_drv.c
··· 914 914 { 915 915 struct Vmxnet3_TxDataDesc *tdd; 916 916 917 - tdd = tq->data_ring.base + tq->tx_ring.next2fill; 917 + tdd = (struct Vmxnet3_TxDataDesc *)((u8 *)tq->data_ring.base + 918 + tq->tx_ring.next2fill * 919 + tq->txdata_desc_size); 918 920 919 921 memcpy(tdd->data, skb->data, ctx->copy_size); 920 922 netdev_dbg(adapter->netdev,
+2 -2
drivers/net/vmxnet3/vmxnet3_int.h
··· 69 69 /* 70 70 * Version numbers 71 71 */ 72 - #define VMXNET3_DRIVER_VERSION_STRING "1.4.9.0-k" 72 + #define VMXNET3_DRIVER_VERSION_STRING "1.4.a.0-k" 73 73 74 74 /* a 32-bit int, each byte encode a verion number in VMXNET3_DRIVER_VERSION */ 75 - #define VMXNET3_DRIVER_VERSION_NUM 0x01040900 75 + #define VMXNET3_DRIVER_VERSION_NUM 0x01040a00 76 76 77 77 #if defined(CONFIG_PCI_MSI) 78 78 /* RSS only makes sense if MSI-X is supported. */
+7 -4
drivers/nvme/host/core.c
··· 81 81 bool nvme_change_ctrl_state(struct nvme_ctrl *ctrl, 82 82 enum nvme_ctrl_state new_state) 83 83 { 84 - enum nvme_ctrl_state old_state = ctrl->state; 84 + enum nvme_ctrl_state old_state; 85 85 bool changed = false; 86 86 87 87 spin_lock_irq(&ctrl->lock); 88 + 89 + old_state = ctrl->state; 88 90 switch (new_state) { 89 91 case NVME_CTRL_LIVE: 90 92 switch (old_state) { ··· 142 140 default: 143 141 break; 144 142 } 145 - spin_unlock_irq(&ctrl->lock); 146 143 147 144 if (changed) 148 145 ctrl->state = new_state; 146 + 147 + spin_unlock_irq(&ctrl->lock); 149 148 150 149 return changed; 151 150 } ··· 611 608 612 609 ret = __nvme_submit_sync_cmd(dev->admin_q, &c, &cqe, NULL, 0, 0, 613 610 NVME_QID_ANY, 0, 0); 614 - if (ret >= 0) 611 + if (ret >= 0 && result) 615 612 *result = le32_to_cpu(cqe.result); 616 613 return ret; 617 614 } ··· 631 628 632 629 ret = __nvme_submit_sync_cmd(dev->admin_q, &c, &cqe, NULL, 0, 0, 633 630 NVME_QID_ANY, 0, 0); 634 - if (ret >= 0) 631 + if (ret >= 0 && result) 635 632 *result = le32_to_cpu(cqe.result); 636 633 return ret; 637 634 }
+3 -11
drivers/of/base.c
··· 1631 1631 */ 1632 1632 1633 1633 err: 1634 - if (it.node) 1635 - of_node_put(it.node); 1634 + of_node_put(it.node); 1636 1635 return rc; 1637 1636 } 1638 1637 ··· 2342 2343 const struct device_node *parent, int port_reg, int reg) 2343 2344 { 2344 2345 struct of_endpoint endpoint; 2345 - struct device_node *node, *prev_node = NULL; 2346 + struct device_node *node = NULL; 2346 2347 2347 - while (1) { 2348 - node = of_graph_get_next_endpoint(parent, prev_node); 2349 - of_node_put(prev_node); 2350 - if (!node) 2351 - break; 2352 - 2348 + for_each_endpoint_of_node(parent, node) { 2353 2349 of_graph_parse_endpoint(node, &endpoint); 2354 2350 if (((port_reg == -1) || (endpoint.port == port_reg)) && 2355 2351 ((reg == -1) || (endpoint.id == reg))) 2356 2352 return node; 2357 - 2358 - prev_node = node; 2359 2353 } 2360 2354 2361 2355 return NULL;
+1 -1
drivers/of/fdt.c
··· 517 517 pr_warning("End of tree marker overwritten: %08x\n", 518 518 be32_to_cpup(mem + size)); 519 519 520 - if (detached) { 520 + if (detached && mynodes) { 521 521 of_node_set_flag(*mynodes, OF_DETACHED); 522 522 pr_debug("unflattened tree is detached\n"); 523 523 }
+3 -2
drivers/of/irq.c
··· 544 544 545 545 list_del(&desc->list); 546 546 547 + of_node_set_flag(desc->dev, OF_POPULATED); 548 + 547 549 pr_debug("of_irq_init: init %s (%p), parent %p\n", 548 550 desc->dev->full_name, 549 551 desc->dev, desc->interrupt_parent); 550 552 ret = desc->irq_init_cb(desc->dev, 551 553 desc->interrupt_parent); 552 554 if (ret) { 555 + of_node_clear_flag(desc->dev, OF_POPULATED); 553 556 kfree(desc); 554 557 continue; 555 558 } ··· 562 559 * its children can get processed in a subsequent pass. 563 560 */ 564 561 list_add_tail(&desc->list, &intc_parent_list); 565 - 566 - of_node_set_flag(desc->dev, OF_POPULATED); 567 562 } 568 563 569 564 /* Get the next pending parent that might have children */
+2
drivers/of/platform.c
··· 497 497 } 498 498 EXPORT_SYMBOL_GPL(of_platform_default_populate); 499 499 500 + #ifndef CONFIG_PPC 500 501 static int __init of_platform_default_populate_init(void) 501 502 { 502 503 struct device_node *node; ··· 522 521 return 0; 523 522 } 524 523 arch_initcall_sync(of_platform_default_populate_init); 524 + #endif 525 525 526 526 static int of_platform_device_destroy(struct device *dev, void *data) 527 527 {
+1
drivers/pci/host-bridge.c
··· 44 44 bridge->release_fn = release_fn; 45 45 bridge->release_data = release_data; 46 46 } 47 + EXPORT_SYMBOL_GPL(pci_set_host_bridge_release); 47 48 48 49 void pcibios_resource_to_bus(struct pci_bus *bus, struct pci_bus_region *region, 49 50 struct resource *res)
+10 -8
drivers/pci/msi.c
··· 1069 1069 nvec = maxvec; 1070 1070 1071 1071 for (;;) { 1072 - if (!(flags & PCI_IRQ_NOAFFINITY)) { 1072 + if (flags & PCI_IRQ_AFFINITY) { 1073 1073 dev->irq_affinity = irq_create_affinity_mask(&nvec); 1074 1074 if (nvec < minvec) 1075 1075 return -ENOSPC; ··· 1105 1105 **/ 1106 1106 int pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec) 1107 1107 { 1108 - return __pci_enable_msi_range(dev, minvec, maxvec, PCI_IRQ_NOAFFINITY); 1108 + return __pci_enable_msi_range(dev, minvec, maxvec, 0); 1109 1109 } 1110 1110 EXPORT_SYMBOL(pci_enable_msi_range); 1111 1111 ··· 1120 1120 return -ERANGE; 1121 1121 1122 1122 for (;;) { 1123 - if (!(flags & PCI_IRQ_NOAFFINITY)) { 1123 + if (flags & PCI_IRQ_AFFINITY) { 1124 1124 dev->irq_affinity = irq_create_affinity_mask(&nvec); 1125 1125 if (nvec < minvec) 1126 1126 return -ENOSPC; ··· 1160 1160 int pci_enable_msix_range(struct pci_dev *dev, struct msix_entry *entries, 1161 1161 int minvec, int maxvec) 1162 1162 { 1163 - return __pci_enable_msix_range(dev, entries, minvec, maxvec, 1164 - PCI_IRQ_NOAFFINITY); 1163 + return __pci_enable_msix_range(dev, entries, minvec, maxvec, 0); 1165 1164 } 1166 1165 EXPORT_SYMBOL(pci_enable_msix_range); 1167 1166 ··· 1186 1187 { 1187 1188 int vecs = -ENOSPC; 1188 1189 1189 - if (!(flags & PCI_IRQ_NOMSIX)) { 1190 + if (flags & PCI_IRQ_MSIX) { 1190 1191 vecs = __pci_enable_msix_range(dev, NULL, min_vecs, max_vecs, 1191 1192 flags); 1192 1193 if (vecs > 0) 1193 1194 return vecs; 1194 1195 } 1195 1196 1196 - if (!(flags & PCI_IRQ_NOMSI)) { 1197 + if (flags & PCI_IRQ_MSI) { 1197 1198 vecs = __pci_enable_msi_range(dev, min_vecs, max_vecs, flags); 1198 1199 if (vecs > 0) 1199 1200 return vecs; 1200 1201 } 1201 1202 1202 1203 /* use legacy irq if allowed */ 1203 - if (!(flags & PCI_IRQ_NOLEGACY) && min_vecs == 1) 1204 + if ((flags & PCI_IRQ_LEGACY) && min_vecs == 1) { 1205 + pci_intx(dev, 1); 1204 1206 return 1; 1207 + } 1208 + 1205 1209 return vecs; 1206 1210 } 1207 1211 EXPORT_SYMBOL(pci_alloc_irq_vectors);
+3 -5
drivers/platform/olpc/olpc-ec.c
··· 1 1 /* 2 2 * Generic driver for the OLPC Embedded Controller. 3 3 * 4 + * Author: Andres Salomon <dilinger@queued.net> 5 + * 4 6 * Copyright (C) 2011-2012 One Laptop per Child Foundation. 5 7 * 6 8 * Licensed under the GPL v2 or later. ··· 14 12 #include <linux/platform_device.h> 15 13 #include <linux/slab.h> 16 14 #include <linux/workqueue.h> 17 - #include <linux/module.h> 15 + #include <linux/init.h> 18 16 #include <linux/list.h> 19 17 #include <linux/olpc-ec.h> 20 18 #include <asm/olpc.h> ··· 328 326 { 329 327 return platform_driver_register(&olpc_ec_plat_driver); 330 328 } 331 - 332 329 arch_initcall(olpc_ec_init_module); 333 - 334 - MODULE_AUTHOR("Andres Salomon <dilinger@queued.net>"); 335 - MODULE_LICENSE("GPL");
+2 -6
drivers/platform/x86/intel_pmic_gpio.c
··· 1 1 /* Moorestown PMIC GPIO (access through IPC) driver 2 2 * Copyright (c) 2008 - 2009, Intel Corporation. 3 3 * 4 + * Author: Alek Du <alek.du@intel.com> 5 + * 4 6 * This program is free software; you can redistribute it and/or modify 5 7 * it under the terms of the GNU General Public License version 2 as 6 8 * published by the Free Software Foundation. ··· 23 21 24 22 #define pr_fmt(fmt) "%s: " fmt, __func__ 25 23 26 - #include <linux/module.h> 27 24 #include <linux/kernel.h> 28 25 #include <linux/interrupt.h> 29 26 #include <linux/delay.h> ··· 323 322 { 324 323 return platform_driver_register(&platform_pmic_gpio_driver); 325 324 } 326 - 327 325 subsys_initcall(platform_pmic_gpio_init); 328 - 329 - MODULE_AUTHOR("Alek Du <alek.du@intel.com>"); 330 - MODULE_DESCRIPTION("Intel Moorestown PMIC GPIO driver"); 331 - MODULE_LICENSE("GPL v2");
+11 -2
drivers/scsi/aacraid/commctrl.c
··· 63 63 struct fib *fibptr; 64 64 struct hw_fib * hw_fib = (struct hw_fib *)0; 65 65 dma_addr_t hw_fib_pa = (dma_addr_t)0LL; 66 - unsigned size; 66 + unsigned int size, osize; 67 67 int retval; 68 68 69 69 if (dev->in_reset) { ··· 87 87 * will not overrun the buffer when we copy the memory. Return 88 88 * an error if we would. 89 89 */ 90 - size = le16_to_cpu(kfib->header.Size) + sizeof(struct aac_fibhdr); 90 + osize = size = le16_to_cpu(kfib->header.Size) + 91 + sizeof(struct aac_fibhdr); 91 92 if (size < le16_to_cpu(kfib->header.SenderSize)) 92 93 size = le16_to_cpu(kfib->header.SenderSize); 93 94 if (size > dev->max_fib_size) { ··· 116 115 117 116 if (copy_from_user(kfib, arg, size)) { 118 117 retval = -EFAULT; 118 + goto cleanup; 119 + } 120 + 121 + /* Sanity check the second copy */ 122 + if ((osize != le16_to_cpu(kfib->header.Size) + 123 + sizeof(struct aac_fibhdr)) 124 + || (size < le16_to_cpu(kfib->header.SenderSize))) { 125 + retval = -EINVAL; 119 126 goto cleanup; 120 127 } 121 128
+1 -1
drivers/scsi/fcoe/fcoe_ctlr.c
··· 2923 2923 mutex_unlock(&fip->ctlr_mutex); 2924 2924 2925 2925 drop: 2926 - kfree(skb); 2926 + kfree_skb(skb); 2927 2927 return rc; 2928 2928 } 2929 2929
+3 -3
drivers/scsi/megaraid/megaraid_sas_base.c
··· 5037 5037 /* Find first memory bar */ 5038 5038 bar_list = pci_select_bars(instance->pdev, IORESOURCE_MEM); 5039 5039 instance->bar = find_first_bit(&bar_list, sizeof(unsigned long)); 5040 - if (pci_request_selected_regions(instance->pdev, instance->bar, 5040 + if (pci_request_selected_regions(instance->pdev, 1<<instance->bar, 5041 5041 "megasas: LSI")) { 5042 5042 dev_printk(KERN_DEBUG, &instance->pdev->dev, "IO memory region busy!\n"); 5043 5043 return -EBUSY; ··· 5339 5339 iounmap(instance->reg_set); 5340 5340 5341 5341 fail_ioremap: 5342 - pci_release_selected_regions(instance->pdev, instance->bar); 5342 + pci_release_selected_regions(instance->pdev, 1<<instance->bar); 5343 5343 5344 5344 return -EINVAL; 5345 5345 } ··· 5360 5360 5361 5361 iounmap(instance->reg_set); 5362 5362 5363 - pci_release_selected_regions(instance->pdev, instance->bar); 5363 + pci_release_selected_regions(instance->pdev, 1<<instance->bar); 5364 5364 } 5365 5365 5366 5366 /**
+1 -1
drivers/scsi/megaraid/megaraid_sas_fusion.c
··· 2603 2603 2604 2604 iounmap(instance->reg_set); 2605 2605 2606 - pci_release_selected_regions(instance->pdev, instance->bar); 2606 + pci_release_selected_regions(instance->pdev, 1<<instance->bar); 2607 2607 } 2608 2608 2609 2609 /**
+11 -11
drivers/scsi/mpt3sas/mpt3sas_base.c
··· 2188 2188 } else 2189 2189 ioc->msix96_vector = 0; 2190 2190 2191 + if (ioc->is_warpdrive) { 2192 + ioc->reply_post_host_index[0] = (resource_size_t __iomem *) 2193 + &ioc->chip->ReplyPostHostIndex; 2194 + 2195 + for (i = 1; i < ioc->cpu_msix_table_sz; i++) 2196 + ioc->reply_post_host_index[i] = 2197 + (resource_size_t __iomem *) 2198 + ((u8 __iomem *)&ioc->chip->Doorbell + (0x4000 + ((i - 1) 2199 + * 4))); 2200 + } 2201 + 2191 2202 list_for_each_entry(reply_q, &ioc->reply_queue_list, list) 2192 2203 pr_info(MPT3SAS_FMT "%s: IRQ %d\n", 2193 2204 reply_q->name, ((ioc->msix_enable) ? "PCI-MSI-X enabled" : ··· 5290 5279 r = mpt3sas_base_map_resources(ioc); 5291 5280 if (r) 5292 5281 goto out_free_resources; 5293 - 5294 - if (ioc->is_warpdrive) { 5295 - ioc->reply_post_host_index[0] = (resource_size_t __iomem *) 5296 - &ioc->chip->ReplyPostHostIndex; 5297 - 5298 - for (i = 1; i < ioc->cpu_msix_table_sz; i++) 5299 - ioc->reply_post_host_index[i] = 5300 - (resource_size_t __iomem *) 5301 - ((u8 __iomem *)&ioc->chip->Doorbell + (0x4000 + ((i - 1) 5302 - * 4))); 5303 - } 5304 5282 5305 5283 pci_set_drvdata(ioc->pdev, ioc->shost); 5306 5284 r = _base_get_ioc_facts(ioc, CAN_SLEEP);
+2 -1
drivers/scsi/ses.c
··· 778 778 if (!edev) 779 779 return; 780 780 781 + enclosure_unregister(edev); 782 + 781 783 ses_dev = edev->scratch; 782 784 edev->scratch = NULL; 783 785 ··· 791 789 kfree(edev->component[0].scratch); 792 790 793 791 put_device(&edev->edev); 794 - enclosure_unregister(edev); 795 792 } 796 793 797 794 static void ses_intf_remove(struct device *cdev,
+16 -5
drivers/thermal/cpu_cooling.c
··· 740 740 } 741 741 742 742 /* Bind cpufreq callbacks to thermal cooling device ops */ 743 + 743 744 static struct thermal_cooling_device_ops cpufreq_cooling_ops = { 744 745 .get_max_state = cpufreq_get_max_state, 745 746 .get_cur_state = cpufreq_get_cur_state, 746 747 .set_cur_state = cpufreq_set_cur_state, 748 + }; 749 + 750 + static struct thermal_cooling_device_ops cpufreq_power_cooling_ops = { 751 + .get_max_state = cpufreq_get_max_state, 752 + .get_cur_state = cpufreq_get_cur_state, 753 + .set_cur_state = cpufreq_set_cur_state, 754 + .get_requested_power = cpufreq_get_requested_power, 755 + .state2power = cpufreq_state2power, 756 + .power2state = cpufreq_power2state, 747 757 }; 748 758 749 759 /* Notifier for cpufreq policy change */ ··· 805 795 struct cpumask temp_mask; 806 796 unsigned int freq, i, num_cpus; 807 797 int ret; 798 + struct thermal_cooling_device_ops *cooling_ops; 808 799 809 800 cpumask_and(&temp_mask, clip_cpus, cpu_online_mask); 810 801 policy = cpufreq_cpu_get(cpumask_first(&temp_mask)); ··· 861 850 cpumask_copy(&cpufreq_dev->allowed_cpus, clip_cpus); 862 851 863 852 if (capacitance) { 864 - cpufreq_cooling_ops.get_requested_power = 865 - cpufreq_get_requested_power; 866 - cpufreq_cooling_ops.state2power = cpufreq_state2power; 867 - cpufreq_cooling_ops.power2state = cpufreq_power2state; 868 853 cpufreq_dev->plat_get_static_power = plat_static_func; 869 854 870 855 ret = build_dyn_power_table(cpufreq_dev, capacitance); ··· 868 861 cool_dev = ERR_PTR(ret); 869 862 goto free_table; 870 863 } 864 + 865 + cooling_ops = &cpufreq_power_cooling_ops; 866 + } else { 867 + cooling_ops = &cpufreq_cooling_ops; 871 868 } 872 869 873 870 ret = get_idr(&cpufreq_idr, &cpufreq_dev->id); ··· 896 885 cpufreq_dev->id); 897 886 898 887 cool_dev = thermal_of_cooling_device_register(np, dev_name, cpufreq_dev, 899 - &cpufreq_cooling_ops); 888 + cooling_ops); 900 889 if (IS_ERR(cool_dev)) 901 890 goto remove_idr; 902 891
+1 -3
drivers/thermal/imx_thermal.c
··· 471 471 472 472 static int imx_thermal_probe(struct platform_device *pdev) 473 473 { 474 - const struct of_device_id *of_id = 475 - of_match_device(of_imx_thermal_match, &pdev->dev); 476 474 struct imx_thermal_data *data; 477 475 struct regmap *map; 478 476 int measure_freq; ··· 488 490 } 489 491 data->tempmon = map; 490 492 491 - data->socdata = of_id->data; 493 + data->socdata = of_device_get_match_data(&pdev->dev); 492 494 493 495 /* make sure the IRQ flag is clear before enabling irq on i.MX6SX */ 494 496 if (data->socdata->version == TEMPMON_IMX6SX) {
-1
drivers/thermal/int340x_thermal/int3406_thermal.c
··· 225 225 .remove = int3406_thermal_remove, 226 226 .driver = { 227 227 .name = "int3406 thermal", 228 - .owner = THIS_MODULE, 229 228 .acpi_match_table = int3406_thermal_match, 230 229 }, 231 230 };
+2 -3
drivers/usb/class/cdc-acm.c
··· 1354 1354 spin_lock_init(&acm->write_lock); 1355 1355 spin_lock_init(&acm->read_lock); 1356 1356 mutex_init(&acm->mutex); 1357 - acm->rx_endpoint = usb_rcvbulkpipe(usb_dev, epread->bEndpointAddress); 1358 1357 acm->is_int_ep = usb_endpoint_xfer_int(epread); 1359 1358 if (acm->is_int_ep) 1360 1359 acm->bInterval = epread->bInterval; ··· 1393 1394 urb->transfer_dma = rb->dma; 1394 1395 if (acm->is_int_ep) { 1395 1396 usb_fill_int_urb(urb, acm->dev, 1396 - acm->rx_endpoint, 1397 + usb_rcvintpipe(usb_dev, epread->bEndpointAddress), 1397 1398 rb->base, 1398 1399 acm->readsize, 1399 1400 acm_read_bulk_callback, rb, 1400 1401 acm->bInterval); 1401 1402 } else { 1402 1403 usb_fill_bulk_urb(urb, acm->dev, 1403 - acm->rx_endpoint, 1404 + usb_rcvbulkpipe(usb_dev, epread->bEndpointAddress), 1404 1405 rb->base, 1405 1406 acm->readsize, 1406 1407 acm_read_bulk_callback, rb);
-1
drivers/usb/class/cdc-acm.h
··· 96 96 struct acm_rb read_buffers[ACM_NR]; 97 97 struct acm_wb *putbuffer; /* for acm_tty_put_char() */ 98 98 int rx_buflimit; 99 - int rx_endpoint; 100 99 spinlock_t read_lock; 101 100 int write_used; /* number of non-empty write buffers */ 102 101 int transmitting;
+63 -3
drivers/usb/core/config.c
··· 171 171 ep, buffer, size); 172 172 } 173 173 174 + static const unsigned short low_speed_maxpacket_maxes[4] = { 175 + [USB_ENDPOINT_XFER_CONTROL] = 8, 176 + [USB_ENDPOINT_XFER_ISOC] = 0, 177 + [USB_ENDPOINT_XFER_BULK] = 0, 178 + [USB_ENDPOINT_XFER_INT] = 8, 179 + }; 180 + static const unsigned short full_speed_maxpacket_maxes[4] = { 181 + [USB_ENDPOINT_XFER_CONTROL] = 64, 182 + [USB_ENDPOINT_XFER_ISOC] = 1023, 183 + [USB_ENDPOINT_XFER_BULK] = 64, 184 + [USB_ENDPOINT_XFER_INT] = 64, 185 + }; 186 + static const unsigned short high_speed_maxpacket_maxes[4] = { 187 + [USB_ENDPOINT_XFER_CONTROL] = 64, 188 + [USB_ENDPOINT_XFER_ISOC] = 1024, 189 + [USB_ENDPOINT_XFER_BULK] = 512, 190 + [USB_ENDPOINT_XFER_INT] = 1023, 191 + }; 192 + static const unsigned short super_speed_maxpacket_maxes[4] = { 193 + [USB_ENDPOINT_XFER_CONTROL] = 512, 194 + [USB_ENDPOINT_XFER_ISOC] = 1024, 195 + [USB_ENDPOINT_XFER_BULK] = 1024, 196 + [USB_ENDPOINT_XFER_INT] = 1024, 197 + }; 198 + 174 199 static int usb_parse_endpoint(struct device *ddev, int cfgno, int inum, 175 200 int asnum, struct usb_host_interface *ifp, int num_ep, 176 201 unsigned char *buffer, int size) ··· 204 179 struct usb_endpoint_descriptor *d; 205 180 struct usb_host_endpoint *endpoint; 206 181 int n, i, j, retval; 182 + unsigned int maxp; 183 + const unsigned short *maxpacket_maxes; 207 184 208 185 d = (struct usb_endpoint_descriptor *) buffer; 209 186 buffer += d->bLength; ··· 313 286 endpoint->desc.wMaxPacketSize = cpu_to_le16(8); 314 287 } 315 288 289 + /* Validate the wMaxPacketSize field */ 290 + maxp = usb_endpoint_maxp(&endpoint->desc); 291 + 292 + /* Find the highest legal maxpacket size for this endpoint */ 293 + i = 0; /* additional transactions per microframe */ 294 + switch (to_usb_device(ddev)->speed) { 295 + case USB_SPEED_LOW: 296 + maxpacket_maxes = low_speed_maxpacket_maxes; 297 + break; 298 + case USB_SPEED_FULL: 299 + maxpacket_maxes = full_speed_maxpacket_maxes; 300 + break; 301 + case USB_SPEED_HIGH: 302 + /* Bits 12..11 are allowed only for HS periodic endpoints */ 303 + if (usb_endpoint_xfer_int(d) || usb_endpoint_xfer_isoc(d)) { 304 + i = maxp & (BIT(12) | BIT(11)); 305 + maxp &= ~i; 306 + } 307 + /* fallthrough */ 308 + default: 309 + maxpacket_maxes = high_speed_maxpacket_maxes; 310 + break; 311 + case USB_SPEED_SUPER: 312 + case USB_SPEED_SUPER_PLUS: 313 + maxpacket_maxes = super_speed_maxpacket_maxes; 314 + break; 315 + } 316 + j = maxpacket_maxes[usb_endpoint_type(&endpoint->desc)]; 317 + 318 + if (maxp > j) { 319 + dev_warn(ddev, "config %d interface %d altsetting %d endpoint 0x%X has invalid maxpacket %d, setting to %d\n", 320 + cfgno, inum, asnum, d->bEndpointAddress, maxp, j); 321 + maxp = j; 322 + endpoint->desc.wMaxPacketSize = cpu_to_le16(i | maxp); 323 + } 324 + 316 325 /* 317 326 * Some buggy high speed devices have bulk endpoints using 318 327 * maxpacket sizes other than 512. High speed HCDs may not ··· 356 293 */ 357 294 if (to_usb_device(ddev)->speed == USB_SPEED_HIGH 358 295 && usb_endpoint_xfer_bulk(d)) { 359 - unsigned maxp; 360 - 361 - maxp = usb_endpoint_maxp(&endpoint->desc) & 0x07ff; 362 296 if (maxp != 512) 363 297 dev_warn(ddev, "config %d interface %d altsetting %d " 364 298 "bulk endpoint 0x%X has invalid maxpacket %d\n",
+5 -2
drivers/usb/core/devio.c
··· 241 241 goto error_decrease_mem; 242 242 } 243 243 244 - mem = usb_alloc_coherent(ps->dev, size, GFP_USER, &dma_handle); 244 + mem = usb_alloc_coherent(ps->dev, size, GFP_USER | __GFP_NOWARN, 245 + &dma_handle); 245 246 if (!mem) { 246 247 ret = -ENOMEM; 247 248 goto error_free_usbm; ··· 2583 2582 if (file->f_mode & FMODE_WRITE && !list_empty(&ps->async_completed)) 2584 2583 mask |= POLLOUT | POLLWRNORM; 2585 2584 if (!connected(ps)) 2586 - mask |= POLLERR | POLLHUP; 2585 + mask |= POLLHUP; 2586 + if (list_empty(&ps->list)) 2587 + mask |= POLLERR; 2587 2588 return mask; 2588 2589 } 2589 2590
+9 -14
drivers/usb/core/hub.c
··· 1052 1052 1053 1053 /* Continue a partial initialization */ 1054 1054 if (type == HUB_INIT2 || type == HUB_INIT3) { 1055 - device_lock(hub->intfdev); 1055 + device_lock(&hdev->dev); 1056 1056 1057 1057 /* Was the hub disconnected while we were waiting? */ 1058 - if (hub->disconnected) { 1059 - device_unlock(hub->intfdev); 1060 - kref_put(&hub->kref, hub_release); 1061 - return; 1062 - } 1058 + if (hub->disconnected) 1059 + goto disconnected; 1063 1060 if (type == HUB_INIT2) 1064 1061 goto init2; 1065 1062 goto init3; ··· 1259 1262 queue_delayed_work(system_power_efficient_wq, 1260 1263 &hub->init_work, 1261 1264 msecs_to_jiffies(delay)); 1262 - device_unlock(hub->intfdev); 1265 + device_unlock(&hdev->dev); 1263 1266 return; /* Continues at init3: below */ 1264 1267 } else { 1265 1268 msleep(delay); ··· 1278 1281 /* Scan all ports that need attention */ 1279 1282 kick_hub_wq(hub); 1280 1283 1281 - /* Allow autosuspend if it was suppressed */ 1282 - if (type <= HUB_INIT3) 1284 + if (type == HUB_INIT2 || type == HUB_INIT3) { 1285 + /* Allow autosuspend if it was suppressed */ 1286 + disconnected: 1283 1287 usb_autopm_put_interface_async(to_usb_interface(hub->intfdev)); 1284 - 1285 - if (type == HUB_INIT2 || type == HUB_INIT3) 1286 - device_unlock(hub->intfdev); 1288 + device_unlock(&hdev->dev); 1289 + } 1287 1290 1288 1291 kref_put(&hub->kref, hub_release); 1289 1292 } ··· 1311 1314 { 1312 1315 struct usb_device *hdev = hub->hdev; 1313 1316 int i; 1314 - 1315 - cancel_delayed_work_sync(&hub->init_work); 1316 1317 1317 1318 /* hub_wq and related activity won't re-trigger */ 1318 1319 hub->quiescing = 1;
+1
drivers/usb/dwc3/dwc3-of-simple.c
··· 61 61 if (!simple->clks) 62 62 return -ENOMEM; 63 63 64 + platform_set_drvdata(pdev, simple); 64 65 simple->dev = dev; 65 66 66 67 for (i = 0; i < simple->num_clocks; i++) {
+2
drivers/usb/dwc3/dwc3-pci.c
··· 37 37 #define PCI_DEVICE_ID_INTEL_BXT 0x0aaa 38 38 #define PCI_DEVICE_ID_INTEL_BXT_M 0x1aaa 39 39 #define PCI_DEVICE_ID_INTEL_APL 0x5aaa 40 + #define PCI_DEVICE_ID_INTEL_KBP 0xa2b0 40 41 41 42 static const struct acpi_gpio_params reset_gpios = { 0, 0, false }; 42 43 static const struct acpi_gpio_params cs_gpios = { 1, 0, false }; ··· 228 227 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_BXT), }, 229 228 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_BXT_M), }, 230 229 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_APL), }, 230 + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_KBP), }, 231 231 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_NL_USB), }, 232 232 { } /* Terminating Entry */ 233 233 };
+33 -22
drivers/usb/dwc3/gadget.c
··· 829 829 if (!req->request.no_interrupt && !chain) 830 830 trb->ctrl |= DWC3_TRB_CTRL_IOC | DWC3_TRB_CTRL_ISP_IMI; 831 831 832 - if (last) 832 + if (last && !usb_endpoint_xfer_isoc(dep->endpoint.desc)) 833 833 trb->ctrl |= DWC3_TRB_CTRL_LST; 834 834 835 835 if (chain) ··· 1955 1955 1956 1956 static int __dwc3_cleanup_done_trbs(struct dwc3 *dwc, struct dwc3_ep *dep, 1957 1957 struct dwc3_request *req, struct dwc3_trb *trb, 1958 - const struct dwc3_event_depevt *event, int status) 1958 + const struct dwc3_event_depevt *event, int status, 1959 + int chain) 1959 1960 { 1960 1961 unsigned int count; 1961 1962 unsigned int s_pkt = 0; ··· 1965 1964 dep->queued_requests--; 1966 1965 trace_dwc3_complete_trb(dep, trb); 1967 1966 1967 + /* 1968 + * If we're in the middle of series of chained TRBs and we 1969 + * receive a short transfer along the way, DWC3 will skip 1970 + * through all TRBs including the last TRB in the chain (the 1971 + * where CHN bit is zero. DWC3 will also avoid clearing HWO 1972 + * bit and SW has to do it manually. 1973 + * 1974 + * We're going to do that here to avoid problems of HW trying 1975 + * to use bogus TRBs for transfers. 1976 + */ 1977 + if (chain && (trb->ctrl & DWC3_TRB_CTRL_HWO)) 1978 + trb->ctrl &= ~DWC3_TRB_CTRL_HWO; 1979 + 1968 1980 if ((trb->ctrl & DWC3_TRB_CTRL_HWO) && status != -ESHUTDOWN) 1969 - /* 1970 - * We continue despite the error. There is not much we 1971 - * can do. If we don't clean it up we loop forever. If 1972 - * we skip the TRB then it gets overwritten after a 1973 - * while since we use them in a ring buffer. A BUG() 1974 - * would help. Lets hope that if this occurs, someone 1975 - * fixes the root cause instead of looking away :) 1976 - */ 1977 - dev_err(dwc->dev, "%s's TRB (%p) still owned by HW\n", 1978 - dep->name, trb); 1981 + return 1; 1982 + 1979 1983 count = trb->size & DWC3_TRB_SIZE_MASK; 1980 1984 1981 1985 if (dep->direction) { ··· 2019 2013 s_pkt = 1; 2020 2014 } 2021 2015 2022 - /* 2023 - * We assume here we will always receive the entire data block 2024 - * which we should receive. Meaning, if we program RX to 2025 - * receive 4K but we receive only 2K, we assume that's all we 2026 - * should receive and we simply bounce the request back to the 2027 - * gadget driver for further processing. 2028 - */ 2029 - req->request.actual += req->request.length - count; 2030 - if (s_pkt) 2016 + if (s_pkt && !chain) 2031 2017 return 1; 2032 2018 if ((event->status & DEPEVT_STATUS_LST) && 2033 2019 (trb->ctrl & (DWC3_TRB_CTRL_LST | ··· 2038 2040 struct dwc3_trb *trb; 2039 2041 unsigned int slot; 2040 2042 unsigned int i; 2043 + int count = 0; 2041 2044 int ret; 2042 2045 2043 2046 do { 2047 + int chain; 2048 + 2044 2049 req = next_request(&dep->started_list); 2045 2050 if (WARN_ON_ONCE(!req)) 2046 2051 return 1; 2047 2052 2053 + chain = req->request.num_mapped_sgs > 0; 2048 2054 i = 0; 2049 2055 do { 2050 2056 slot = req->first_trb_index + i; ··· 2056 2054 slot++; 2057 2055 slot %= DWC3_TRB_NUM; 2058 2056 trb = &dep->trb_pool[slot]; 2057 + count += trb->size & DWC3_TRB_SIZE_MASK; 2059 2058 2060 2059 ret = __dwc3_cleanup_done_trbs(dwc, dep, req, trb, 2061 - event, status); 2060 + event, status, chain); 2062 2061 if (ret) 2063 2062 break; 2064 2063 } while (++i < req->request.num_mapped_sgs); 2065 2064 2065 + /* 2066 + * We assume here we will always receive the entire data block 2067 + * which we should receive. Meaning, if we program RX to 2068 + * receive 4K but we receive only 2K, we assume that's all we 2069 + * should receive and we simply bounce the request back to the 2070 + * gadget driver for further processing. 2071 + */ 2072 + req->request.actual += req->request.length - count; 2066 2073 dwc3_gadget_giveback(dep, req, status); 2067 2074 2068 2075 if (ret)
+4 -2
drivers/usb/gadget/composite.c
··· 1913 1913 break; 1914 1914 1915 1915 case USB_RECIP_ENDPOINT: 1916 + if (!cdev->config) 1917 + break; 1916 1918 endp = ((w_index & 0x80) >> 3) | (w_index & 0x0f); 1917 1919 list_for_each_entry(f, &cdev->config->functions, list) { 1918 1920 if (test_bit(endp, f->endpoints)) ··· 2126 2124 2127 2125 cdev->os_desc_req = usb_ep_alloc_request(ep0, GFP_KERNEL); 2128 2126 if (!cdev->os_desc_req) { 2129 - ret = PTR_ERR(cdev->os_desc_req); 2127 + ret = -ENOMEM; 2130 2128 goto end; 2131 2129 } 2132 2130 2133 2131 /* OS feature descriptor length <= 4kB */ 2134 2132 cdev->os_desc_req->buf = kmalloc(4096, GFP_KERNEL); 2135 2133 if (!cdev->os_desc_req->buf) { 2136 - ret = PTR_ERR(cdev->os_desc_req->buf); 2134 + ret = -ENOMEM; 2137 2135 kfree(cdev->os_desc_req); 2138 2136 goto end; 2139 2137 }
+2
drivers/usb/gadget/configfs.c
··· 1490 1490 { 1491 1491 struct gadget_info *gi = to_gadget_info(item); 1492 1492 1493 + mutex_lock(&gi->lock); 1493 1494 unregister_gadget(gi); 1495 + mutex_unlock(&gi->lock); 1494 1496 } 1495 1497 EXPORT_SYMBOL_GPL(unregister_gadget_item); 1496 1498
+6
drivers/usb/gadget/function/rndis.c
··· 680 680 { 681 681 rndis_reset_cmplt_type *resp; 682 682 rndis_resp_t *r; 683 + u8 *xbuf; 684 + u32 length; 685 + 686 + /* drain the response queue */ 687 + while ((xbuf = rndis_get_next_response(params, &length))) 688 + rndis_free_response(params, xbuf); 683 689 684 690 r = rndis_add_response(params, sizeof(rndis_reset_cmplt_type)); 685 691 if (!r)
+2 -1
drivers/usb/gadget/function/u_ether.c
··· 556 556 /* Multi frame CDC protocols may store the frame for 557 557 * later which is not a dropped frame. 558 558 */ 559 - if (dev->port_usb->supports_multi_frame) 559 + if (dev->port_usb && 560 + dev->port_usb->supports_multi_frame) 560 561 goto multiframe; 561 562 goto drop; 562 563 }
+1 -1
drivers/usb/gadget/function/uvc_configfs.c
··· 2023 2023 if (!data) { 2024 2024 kfree(*class_array); 2025 2025 *class_array = NULL; 2026 - ret = PTR_ERR(data); 2026 + ret = -ENOMEM; 2027 2027 goto unlock; 2028 2028 } 2029 2029 cl_arr = *class_array;
+2 -2
drivers/usb/gadget/legacy/inode.c
··· 542 542 */ 543 543 spin_lock_irq(&epdata->dev->lock); 544 544 value = -ENODEV; 545 - if (unlikely(epdata->ep)) 545 + if (unlikely(epdata->ep == NULL)) 546 546 goto fail; 547 547 548 548 req = usb_ep_alloc_request(epdata->ep, GFP_ATOMIC); ··· 606 606 } 607 607 if (is_sync_kiocb(iocb)) { 608 608 value = ep_io(epdata, buf, len); 609 - if (value >= 0 && copy_to_iter(buf, value, to)) 609 + if (value >= 0 && (copy_to_iter(buf, value, to) != value)) 610 610 value = -EFAULT; 611 611 } else { 612 612 struct kiocb_priv *priv = kzalloc(sizeof *priv, GFP_KERNEL);
+4 -1
drivers/usb/gadget/udc/core.c
··· 1145 1145 if (ret != -EPROBE_DEFER) 1146 1146 list_del(&driver->pending); 1147 1147 if (ret) 1148 - goto err4; 1148 + goto err5; 1149 1149 break; 1150 1150 } 1151 1151 } ··· 1153 1153 mutex_unlock(&udc_lock); 1154 1154 1155 1155 return 0; 1156 + 1157 + err5: 1158 + device_del(&udc->dev); 1156 1159 1157 1160 err4: 1158 1161 list_del(&udc->list);
+1 -1
drivers/usb/gadget/udc/fsl_qe_udc.c
··· 2053 2053 struct qe_ep *ep; 2054 2054 2055 2055 if (wValue != 0 || wLength != 0 2056 - || pipe > USB_MAX_ENDPOINTS) 2056 + || pipe >= USB_MAX_ENDPOINTS) 2057 2057 break; 2058 2058 ep = &udc->eps[pipe]; 2059 2059
+2 -2
drivers/usb/host/ehci-hcd.c
··· 332 332 int port = HCS_N_PORTS(ehci->hcs_params); 333 333 334 334 while (port--) { 335 - ehci_writel(ehci, PORT_RWC_BITS, 336 - &ehci->regs->port_status[port]); 337 335 spin_unlock_irq(&ehci->lock); 338 336 ehci_port_power(ehci, port, false); 339 337 spin_lock_irq(&ehci->lock); 338 + ehci_writel(ehci, PORT_RWC_BITS, 339 + &ehci->regs->port_status[port]); 340 340 } 341 341 } 342 342
+1 -1
drivers/usb/host/max3421-hcd.c
··· 1675 1675 if (pin_number > 7) 1676 1676 return; 1677 1677 1678 - mask = 1u << pin_number; 1678 + mask = 1u << (pin_number % 4); 1679 1679 idx = pin_number / 4; 1680 1680 1681 1681 if (value)
+3
drivers/usb/host/xhci-hub.c
··· 386 386 387 387 ret = 0; 388 388 virt_dev = xhci->devs[slot_id]; 389 + if (!virt_dev) 390 + return -ENODEV; 391 + 389 392 cmd = xhci_alloc_command(xhci, false, true, GFP_NOIO); 390 393 if (!cmd) { 391 394 xhci_dbg(xhci, "Couldn't allocate command structure.\n");
+2 -1
drivers/usb/host/xhci-pci.c
··· 314 314 usb_remove_hcd(xhci->shared_hcd); 315 315 usb_put_hcd(xhci->shared_hcd); 316 316 } 317 - usb_hcd_pci_remove(dev); 318 317 319 318 /* Workaround for spurious wakeups at shutdown with HSW */ 320 319 if (xhci->quirks & XHCI_SPURIOUS_WAKEUP) 321 320 pci_set_power_state(dev, PCI_D3hot); 321 + 322 + usb_hcd_pci_remove(dev); 322 323 } 323 324 324 325 #ifdef CONFIG_PM
+9 -7
drivers/usb/host/xhci-ring.c
··· 1334 1334 1335 1335 cmd = list_entry(xhci->cmd_list.next, struct xhci_command, cmd_list); 1336 1336 1337 - if (cmd->command_trb != xhci->cmd_ring->dequeue) { 1338 - xhci_err(xhci, 1339 - "Command completion event does not match command\n"); 1340 - return; 1341 - } 1342 - 1343 1337 del_timer(&xhci->cmd_timer); 1344 1338 1345 1339 trace_xhci_cmd_completion(cmd_trb, (struct xhci_generic_trb *) event); ··· 1345 1351 xhci_handle_stopped_cmd_ring(xhci, cmd); 1346 1352 return; 1347 1353 } 1354 + 1355 + if (cmd->command_trb != xhci->cmd_ring->dequeue) { 1356 + xhci_err(xhci, 1357 + "Command completion event does not match command\n"); 1358 + return; 1359 + } 1360 + 1348 1361 /* 1349 1362 * Host aborted the command ring, check if the current command was 1350 1363 * supposed to be aborted, otherwise continue normally. ··· 3244 3243 send_addr = addr; 3245 3244 3246 3245 /* Queue the TRBs, even if they are zero-length */ 3247 - for (enqd_len = 0; enqd_len < full_len; enqd_len += trb_buff_len) { 3246 + for (enqd_len = 0; first_trb || enqd_len < full_len; 3247 + enqd_len += trb_buff_len) { 3248 3248 field = TRB_TYPE(TRB_NORMAL); 3249 3249 3250 3250 /* TRB buffer should not cross 64KB boundaries */
+5 -5
drivers/usb/misc/ftdi-elan.c
··· 665 665 { 666 666 char data[30 *3 + 4]; 667 667 char *d = data; 668 - int m = (sizeof(data) - 1) / 3; 668 + int m = (sizeof(data) - 1) / 3 - 1; 669 669 int bytes_read = 0; 670 670 int retry_on_empty = 10; 671 671 int retry_on_timeout = 5; ··· 1684 1684 int i = 0; 1685 1685 char data[30 *3 + 4]; 1686 1686 char *d = data; 1687 - int m = (sizeof(data) - 1) / 3; 1687 + int m = (sizeof(data) - 1) / 3 - 1; 1688 1688 int l = 0; 1689 1689 struct u132_target *target = &ftdi->target[ed]; 1690 1690 struct u132_command *command = &ftdi->command[ ··· 1876 1876 if (packet_bytes > 2) { 1877 1877 char diag[30 *3 + 4]; 1878 1878 char *d = diag; 1879 - int m = (sizeof(diag) - 1) / 3; 1879 + int m = (sizeof(diag) - 1) / 3 - 1; 1880 1880 char *b = ftdi->bulk_in_buffer; 1881 1881 int bytes_read = 0; 1882 1882 diag[0] = 0; ··· 2053 2053 if (packet_bytes > 2) { 2054 2054 char diag[30 *3 + 4]; 2055 2055 char *d = diag; 2056 - int m = (sizeof(diag) - 1) / 3; 2056 + int m = (sizeof(diag) - 1) / 3 - 1; 2057 2057 char *b = ftdi->bulk_in_buffer; 2058 2058 int bytes_read = 0; 2059 2059 unsigned char c = 0; ··· 2155 2155 if (packet_bytes > 2) { 2156 2156 char diag[30 *3 + 4]; 2157 2157 char *d = diag; 2158 - int m = (sizeof(diag) - 1) / 3; 2158 + int m = (sizeof(diag) - 1) / 3 - 1; 2159 2159 char *b = ftdi->bulk_in_buffer; 2160 2160 int bytes_read = 0; 2161 2161 diag[0] = 0;
+5 -4
drivers/usb/misc/usbtest.c
··· 585 585 { 586 586 struct usb_sg_request *req = (struct usb_sg_request *) _req; 587 587 588 - req->status = -ETIMEDOUT; 589 588 usb_sg_cancel(req); 590 589 } 591 590 ··· 615 616 mod_timer(&sg_timer, jiffies + 616 617 msecs_to_jiffies(SIMPLE_IO_TIMEOUT)); 617 618 usb_sg_wait(req); 618 - del_timer_sync(&sg_timer); 619 - retval = req->status; 619 + if (!del_timer_sync(&sg_timer)) 620 + retval = -ETIMEDOUT; 621 + else 622 + retval = req->status; 620 623 621 624 /* FIXME check resulting data pattern */ 622 625 ··· 2603 2602 ktime_get_ts64(&start); 2604 2603 2605 2604 retval = usbtest_do_ioctl(intf, param_32); 2606 - if (retval) 2605 + if (retval < 0) 2607 2606 goto free_mutex; 2608 2607 2609 2608 ktime_get_ts64(&end);
+2
drivers/usb/phy/phy-omap-otg.c
··· 140 140 (rev >> 4) & 0xf, rev & 0xf, config->extcon, otg_dev->id, 141 141 otg_dev->vbus); 142 142 143 + platform_set_drvdata(pdev, otg_dev); 144 + 143 145 return 0; 144 146 } 145 147
+2 -1
drivers/usb/renesas_usbhs/common.c
··· 514 514 if (gpio > 0) 515 515 dparam->enable_gpio = gpio; 516 516 517 - if (dparam->type == USBHS_TYPE_RCAR_GEN2) 517 + if (dparam->type == USBHS_TYPE_RCAR_GEN2 || 518 + dparam->type == USBHS_TYPE_RCAR_GEN3) 518 519 dparam->has_usb_dmac = 1; 519 520 520 521 return info;
+2 -2
drivers/usb/renesas_usbhs/fifo.c
··· 871 871 872 872 /* use PIO if packet is less than pio_dma_border or pipe is DCP */ 873 873 if ((len < usbhs_get_dparam(priv, pio_dma_border)) || 874 - usbhs_pipe_is_dcp(pipe)) 874 + usbhs_pipe_type_is(pipe, USB_ENDPOINT_XFER_ISOC)) 875 875 goto usbhsf_pio_prepare_push; 876 876 877 877 /* check data length if this driver don't use USB-DMAC */ ··· 976 976 977 977 /* use PIO if packet is less than pio_dma_border or pipe is DCP */ 978 978 if ((pkt->length < usbhs_get_dparam(priv, pio_dma_border)) || 979 - usbhs_pipe_is_dcp(pipe)) 979 + usbhs_pipe_type_is(pipe, USB_ENDPOINT_XFER_ISOC)) 980 980 goto usbhsf_pio_prepare_pop; 981 981 982 982 fifo = usbhsf_get_dma_fifo(priv, pkt);
+5 -2
drivers/usb/renesas_usbhs/mod_gadget.c
··· 617 617 * use dmaengine if possible. 618 618 * It will use pio handler if impossible. 619 619 */ 620 - if (usb_endpoint_dir_in(desc)) 620 + if (usb_endpoint_dir_in(desc)) { 621 621 pipe->handler = &usbhs_fifo_dma_push_handler; 622 - else 622 + } else { 623 623 pipe->handler = &usbhs_fifo_dma_pop_handler; 624 + usbhs_xxxsts_clear(priv, BRDYSTS, 625 + usbhs_pipe_number(pipe)); 626 + } 624 627 625 628 ret = 0; 626 629 }
+3
drivers/usb/serial/ftdi_sio.c
··· 648 648 { USB_DEVICE(FTDI_VID, FTDI_ELV_TFD128_PID) }, 649 649 { USB_DEVICE(FTDI_VID, FTDI_ELV_FM3RX_PID) }, 650 650 { USB_DEVICE(FTDI_VID, FTDI_ELV_WS777_PID) }, 651 + { USB_DEVICE(FTDI_VID, FTDI_PALMSENS_PID) }, 652 + { USB_DEVICE(FTDI_VID, FTDI_IVIUM_XSTAT_PID) }, 651 653 { USB_DEVICE(FTDI_VID, LINX_SDMUSBQSS_PID) }, 652 654 { USB_DEVICE(FTDI_VID, LINX_MASTERDEVEL2_PID) }, 653 655 { USB_DEVICE(FTDI_VID, LINX_FUTURE_0_PID) }, ··· 1010 1008 { USB_DEVICE(ICPDAS_VID, ICPDAS_I7560U_PID) }, 1011 1009 { USB_DEVICE(ICPDAS_VID, ICPDAS_I7561U_PID) }, 1012 1010 { USB_DEVICE(ICPDAS_VID, ICPDAS_I7563U_PID) }, 1011 + { USB_DEVICE(WICED_VID, WICED_USB20706V2_PID) }, 1013 1012 { } /* Terminating entry */ 1014 1013 }; 1015 1014
+12
drivers/usb/serial/ftdi_sio_ids.h
··· 406 406 #define FTDI_4N_GALAXY_DE_3_PID 0xF3C2 407 407 408 408 /* 409 + * Ivium Technologies product IDs 410 + */ 411 + #define FTDI_PALMSENS_PID 0xf440 412 + #define FTDI_IVIUM_XSTAT_PID 0xf441 413 + 414 + /* 409 415 * Linx Technologies product ids 410 416 */ 411 417 #define LINX_SDMUSBQSS_PID 0xF448 /* Linx SDM-USB-QS-S */ ··· 677 671 #define INTREPID_VID 0x093C 678 672 #define INTREPID_VALUECAN_PID 0x0601 679 673 #define INTREPID_NEOVI_PID 0x0701 674 + 675 + /* 676 + * WICED USB UART 677 + */ 678 + #define WICED_VID 0x0A5C 679 + #define WICED_USB20706V2_PID 0x6422 680 680 681 681 /* 682 682 * Definitions for ID TECH (www.idt-net.com) devices
+22
drivers/usb/serial/option.c
··· 274 274 #define TELIT_PRODUCT_LE920 0x1200 275 275 #define TELIT_PRODUCT_LE910 0x1201 276 276 #define TELIT_PRODUCT_LE910_USBCFG4 0x1206 277 + #define TELIT_PRODUCT_LE920A4_1207 0x1207 278 + #define TELIT_PRODUCT_LE920A4_1208 0x1208 279 + #define TELIT_PRODUCT_LE920A4_1211 0x1211 280 + #define TELIT_PRODUCT_LE920A4_1212 0x1212 281 + #define TELIT_PRODUCT_LE920A4_1213 0x1213 282 + #define TELIT_PRODUCT_LE920A4_1214 0x1214 277 283 278 284 /* ZTE PRODUCTS */ 279 285 #define ZTE_VENDOR_ID 0x19d2 ··· 632 626 static const struct option_blacklist_info telit_le920_blacklist = { 633 627 .sendsetup = BIT(0), 634 628 .reserved = BIT(1) | BIT(5), 629 + }; 630 + 631 + static const struct option_blacklist_info telit_le920a4_blacklist_1 = { 632 + .sendsetup = BIT(0), 633 + .reserved = BIT(1), 635 634 }; 636 635 637 636 static const struct option_blacklist_info telit_le922_blacklist_usbcfg0 = { ··· 1214 1203 .driver_info = (kernel_ulong_t)&telit_le922_blacklist_usbcfg3 }, 1215 1204 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE920), 1216 1205 .driver_info = (kernel_ulong_t)&telit_le920_blacklist }, 1206 + { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE920A4_1207) }, 1207 + { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE920A4_1208), 1208 + .driver_info = (kernel_ulong_t)&telit_le920a4_blacklist_1 }, 1209 + { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE920A4_1211), 1210 + .driver_info = (kernel_ulong_t)&telit_le922_blacklist_usbcfg3 }, 1211 + { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE920A4_1212), 1212 + .driver_info = (kernel_ulong_t)&telit_le920a4_blacklist_1 }, 1213 + { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, TELIT_PRODUCT_LE920A4_1213, 0xff) }, 1214 + { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE920A4_1214), 1215 + .driver_info = (kernel_ulong_t)&telit_le922_blacklist_usbcfg3 }, 1217 1216 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_MF622, 0xff, 0xff, 0xff) }, /* ZTE WCDMA products */ 1218 1217 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0002, 0xff, 0xff, 0xff), 1219 1218 .driver_info = (kernel_ulong_t)&net_intf1_blacklist }, ··· 1987 1966 .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, 1988 1967 { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x3e01, 0xff, 0xff, 0xff) }, /* D-Link DWM-152/C1 */ 1989 1968 { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x3e02, 0xff, 0xff, 0xff) }, /* D-Link DWM-156/C1 */ 1969 + { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x7e11, 0xff, 0xff, 0xff) }, /* D-Link DWM-156/A3 */ 1990 1970 { USB_DEVICE_INTERFACE_CLASS(0x2020, 0x4000, 0xff) }, /* OLICARD300 - MT6225 */ 1991 1971 { USB_DEVICE(INOVIA_VENDOR_ID, INOVIA_SEW858) }, 1992 1972 { USB_DEVICE(VIATELECOM_VENDOR_ID, VIATELECOM_PRODUCT_CDS7) },
+3 -1
drivers/usb/serial/usb-serial.c
··· 1433 1433 1434 1434 rc = usb_register(udriver); 1435 1435 if (rc) 1436 - return rc; 1436 + goto failed_usb_register; 1437 1437 1438 1438 for (sd = serial_drivers; *sd; ++sd) { 1439 1439 (*sd)->usb_driver = udriver; ··· 1451 1451 while (sd-- > serial_drivers) 1452 1452 usb_serial_deregister(*sd); 1453 1453 usb_deregister(udriver); 1454 + failed_usb_register: 1455 + kfree(udriver); 1454 1456 return rc; 1455 1457 } 1456 1458 EXPORT_SYMBOL_GPL(usb_serial_register_drivers);
+3 -3
drivers/vhost/scsi.c
··· 88 88 struct scatterlist *tvc_prot_sgl; 89 89 struct page **tvc_upages; 90 90 /* Pointer to response header iovec */ 91 - struct iovec *tvc_resp_iov; 91 + struct iovec tvc_resp_iov; 92 92 /* Pointer to vhost_scsi for our device */ 93 93 struct vhost_scsi *tvc_vhost; 94 94 /* Pointer to vhost_virtqueue for the cmd */ ··· 547 547 memcpy(v_rsp.sense, cmd->tvc_sense_buf, 548 548 se_cmd->scsi_sense_length); 549 549 550 - iov_iter_init(&iov_iter, READ, cmd->tvc_resp_iov, 550 + iov_iter_init(&iov_iter, READ, &cmd->tvc_resp_iov, 551 551 cmd->tvc_in_iovs, sizeof(v_rsp)); 552 552 ret = copy_to_iter(&v_rsp, sizeof(v_rsp), &iov_iter); 553 553 if (likely(ret == sizeof(v_rsp))) { ··· 1044 1044 } 1045 1045 cmd->tvc_vhost = vs; 1046 1046 cmd->tvc_vq = vq; 1047 - cmd->tvc_resp_iov = &vq->iov[out]; 1047 + cmd->tvc_resp_iov = vq->iov[out]; 1048 1048 cmd->tvc_in_iovs = in; 1049 1049 1050 1050 pr_debug("vhost_scsi got command opcode: %#02x, lun: %d\n",
+1 -1
drivers/xen/xenbus/xenbus_dev_frontend.c
··· 316 316 rc = -ENOMEM; 317 317 goto out; 318 318 } 319 - } else { 319 + } else if (msg_type == XS_TRANSACTION_END) { 320 320 list_for_each_entry(trans, &u->transactions, list) 321 321 if (trans->handle.id == u->u.msg.tx_id) 322 322 break;
+3 -2
fs/block_dev.c
··· 249 249 * thaw_bdev drops it. 250 250 */ 251 251 sb = get_super(bdev); 252 - drop_super(sb); 252 + if (sb) 253 + drop_super(sb); 253 254 mutex_unlock(&bdev->bd_fsfreeze_mutex); 254 255 return sb; 255 256 } ··· 647 646 { 648 647 struct dentry *dent; 649 648 dent = mount_pseudo(fs_type, "bdev:", &bdev_sops, NULL, BDEVFS_MAGIC); 650 - if (dent) 649 + if (!IS_ERR(dent)) 651 650 dent->d_sb->s_iflags |= SB_I_CGROUPWB; 652 651 return dent; 653 652 }
+1
fs/btrfs/backref.c
··· 589 589 590 590 list_del(&ref2->list); 591 591 kmem_cache_free(btrfs_prelim_ref_cache, ref2); 592 + cond_resched(); 592 593 } 593 594 594 595 }
+4 -1
fs/btrfs/ctree.h
··· 1028 1028 struct btrfs_workqueue *qgroup_rescan_workers; 1029 1029 struct completion qgroup_rescan_completion; 1030 1030 struct btrfs_work qgroup_rescan_work; 1031 + bool qgroup_rescan_running; /* protected by qgroup_rescan_lock */ 1031 1032 1032 1033 /* filesystem state */ 1033 1034 unsigned long fs_state; ··· 1080 1079 struct list_head pinned_chunks; 1081 1080 1082 1081 int creating_free_space_tree; 1082 + /* Used to record internally whether fs has been frozen */ 1083 + int fs_frozen; 1083 1084 }; 1084 1085 1085 1086 struct btrfs_subvolume_writers { ··· 2581 2578 struct btrfs_root *root, 2582 2579 u64 root_objectid, u64 owner, u64 offset, 2583 2580 struct btrfs_key *ins); 2584 - int btrfs_reserve_extent(struct btrfs_root *root, u64 num_bytes, 2581 + int btrfs_reserve_extent(struct btrfs_root *root, u64 ram_bytes, u64 num_bytes, 2585 2582 u64 min_alloc_size, u64 empty_size, u64 hint_byte, 2586 2583 struct btrfs_key *ins, int is_data, int delalloc); 2587 2584 int btrfs_inc_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root,
+2 -5
fs/btrfs/delayed-ref.c
··· 541 541 struct btrfs_delayed_ref_head *existing; 542 542 struct btrfs_delayed_ref_head *head_ref = NULL; 543 543 struct btrfs_delayed_ref_root *delayed_refs; 544 - struct btrfs_qgroup_extent_record *qexisting; 545 544 int count_mod = 1; 546 545 int must_insert_reserved = 0; 547 546 ··· 605 606 qrecord->num_bytes = num_bytes; 606 607 qrecord->old_roots = NULL; 607 608 608 - qexisting = btrfs_qgroup_insert_dirty_extent(fs_info, 609 - delayed_refs, 610 - qrecord); 611 - if (qexisting) 609 + if(btrfs_qgroup_insert_dirty_extent_nolock(fs_info, 610 + delayed_refs, qrecord)) 612 611 kfree(qrecord); 613 612 } 614 613
+51 -5
fs/btrfs/disk-io.c
··· 559 559 u32 nritems = btrfs_header_nritems(leaf); 560 560 int slot; 561 561 562 - if (nritems == 0) 562 + if (nritems == 0) { 563 + struct btrfs_root *check_root; 564 + 565 + key.objectid = btrfs_header_owner(leaf); 566 + key.type = BTRFS_ROOT_ITEM_KEY; 567 + key.offset = (u64)-1; 568 + 569 + check_root = btrfs_get_fs_root(root->fs_info, &key, false); 570 + /* 571 + * The only reason we also check NULL here is that during 572 + * open_ctree() some roots has not yet been set up. 573 + */ 574 + if (!IS_ERR_OR_NULL(check_root)) { 575 + /* if leaf is the root, then it's fine */ 576 + if (leaf->start != 577 + btrfs_root_bytenr(&check_root->root_item)) { 578 + CORRUPT("non-root leaf's nritems is 0", 579 + leaf, root, 0); 580 + return -EIO; 581 + } 582 + } 563 583 return 0; 584 + } 564 585 565 586 /* Check the 0 item */ 566 587 if (btrfs_item_offset_nr(leaf, 0) + btrfs_item_size_nr(leaf, 0) != ··· 630 609 } 631 610 } 632 611 612 + return 0; 613 + } 614 + 615 + static int check_node(struct btrfs_root *root, struct extent_buffer *node) 616 + { 617 + unsigned long nr = btrfs_header_nritems(node); 618 + 619 + if (nr == 0 || nr > BTRFS_NODEPTRS_PER_BLOCK(root)) { 620 + btrfs_crit(root->fs_info, 621 + "corrupt node: block %llu root %llu nritems %lu", 622 + node->start, root->objectid, nr); 623 + return -EIO; 624 + } 633 625 return 0; 634 626 } 635 627 ··· 715 681 set_bit(EXTENT_BUFFER_CORRUPT, &eb->bflags); 716 682 ret = -EIO; 717 683 } 684 + 685 + if (found_level > 0 && check_node(root, eb)) 686 + ret = -EIO; 718 687 719 688 if (!ret) 720 689 set_extent_buffer_uptodate(eb); ··· 1655 1618 return ret; 1656 1619 } 1657 1620 1658 - static struct btrfs_root *btrfs_lookup_fs_root(struct btrfs_fs_info *fs_info, 1659 - u64 root_id) 1621 + struct btrfs_root *btrfs_lookup_fs_root(struct btrfs_fs_info *fs_info, 1622 + u64 root_id) 1660 1623 { 1661 1624 struct btrfs_root *root; 1662 1625 ··· 2335 2298 fs_info->quota_enabled = 0; 2336 2299 fs_info->pending_quota_state = 0; 2337 2300 fs_info->qgroup_ulist = NULL; 2301 + fs_info->qgroup_rescan_running = false; 2338 2302 mutex_init(&fs_info->qgroup_rescan_lock); 2339 2303 } 2340 2304 ··· 2662 2624 atomic_set(&fs_info->qgroup_op_seq, 0); 2663 2625 atomic_set(&fs_info->reada_works_cnt, 0); 2664 2626 atomic64_set(&fs_info->tree_mod_seq, 0); 2627 + fs_info->fs_frozen = 0; 2665 2628 fs_info->sb = sb; 2666 2629 fs_info->max_inline = BTRFS_DEFAULT_MAX_INLINE; 2667 2630 fs_info->metadata_ratio = 0; ··· 3778 3739 if (btrfs_root_refs(&root->root_item) == 0) 3779 3740 synchronize_srcu(&fs_info->subvol_srcu); 3780 3741 3781 - if (test_bit(BTRFS_FS_STATE_ERROR, &fs_info->fs_state)) 3742 + if (test_bit(BTRFS_FS_STATE_ERROR, &fs_info->fs_state)) { 3782 3743 btrfs_free_log(NULL, root); 3744 + if (root->reloc_root) { 3745 + free_extent_buffer(root->reloc_root->node); 3746 + free_extent_buffer(root->reloc_root->commit_root); 3747 + btrfs_put_fs_root(root->reloc_root); 3748 + root->reloc_root = NULL; 3749 + } 3750 + } 3783 3751 3784 3752 if (root->free_ino_pinned) 3785 3753 __btrfs_remove_free_space_cache(root->free_ino_pinned); ··· 3897 3851 smp_mb(); 3898 3852 3899 3853 /* wait for the qgroup rescan worker to stop */ 3900 - btrfs_qgroup_wait_for_completion(fs_info); 3854 + btrfs_qgroup_wait_for_completion(fs_info, false); 3901 3855 3902 3856 /* wait for the uuid_scan task to finish */ 3903 3857 down(&fs_info->uuid_tree_rescan_sem);
+2
fs/btrfs/disk-io.h
··· 68 68 struct btrfs_root *btrfs_read_fs_root(struct btrfs_root *tree_root, 69 69 struct btrfs_key *location); 70 70 int btrfs_init_fs_root(struct btrfs_root *root); 71 + struct btrfs_root *btrfs_lookup_fs_root(struct btrfs_fs_info *fs_info, 72 + u64 root_id); 71 73 int btrfs_insert_fs_root(struct btrfs_fs_info *fs_info, 72 74 struct btrfs_root *root); 73 75 void btrfs_free_fs_roots(struct btrfs_fs_info *fs_info);
+86 -99
fs/btrfs/extent-tree.c
··· 60 60 CHUNK_ALLOC_FORCE = 2, 61 61 }; 62 62 63 - /* 64 - * Control how reservations are dealt with. 65 - * 66 - * RESERVE_FREE - freeing a reservation. 67 - * RESERVE_ALLOC - allocating space and we need to update bytes_may_use for 68 - * ENOSPC accounting 69 - * RESERVE_ALLOC_NO_ACCOUNT - allocating space and we should not update 70 - * bytes_may_use as the ENOSPC accounting is done elsewhere 71 - */ 72 - enum { 73 - RESERVE_FREE = 0, 74 - RESERVE_ALLOC = 1, 75 - RESERVE_ALLOC_NO_ACCOUNT = 2, 76 - }; 77 - 78 63 static int update_block_group(struct btrfs_trans_handle *trans, 79 64 struct btrfs_root *root, u64 bytenr, 80 65 u64 num_bytes, int alloc); ··· 89 104 struct btrfs_key *key); 90 105 static void dump_space_info(struct btrfs_space_info *info, u64 bytes, 91 106 int dump_block_groups); 92 - static int btrfs_update_reserved_bytes(struct btrfs_block_group_cache *cache, 93 - u64 num_bytes, int reserve, 94 - int delalloc); 107 + static int btrfs_add_reserved_bytes(struct btrfs_block_group_cache *cache, 108 + u64 ram_bytes, u64 num_bytes, int delalloc); 109 + static int btrfs_free_reserved_bytes(struct btrfs_block_group_cache *cache, 110 + u64 num_bytes, int delalloc); 95 111 static int block_rsv_use_bytes(struct btrfs_block_rsv *block_rsv, 96 112 u64 num_bytes); 97 113 int btrfs_pin_extent(struct btrfs_root *root, ··· 3487 3501 dcs = BTRFS_DC_SETUP; 3488 3502 else if (ret == -ENOSPC) 3489 3503 set_bit(BTRFS_TRANS_CACHE_ENOSPC, &trans->transaction->flags); 3490 - btrfs_free_reserved_data_space(inode, 0, num_pages); 3491 3504 3492 3505 out_put: 3493 3506 iput(inode); ··· 4457 4472 } 4458 4473 } 4459 4474 4475 + /* 4476 + * If force is CHUNK_ALLOC_FORCE: 4477 + * - return 1 if it successfully allocates a chunk, 4478 + * - return errors including -ENOSPC otherwise. 4479 + * If force is NOT CHUNK_ALLOC_FORCE: 4480 + * - return 0 if it doesn't need to allocate a new chunk, 4481 + * - return 1 if it successfully allocates a chunk, 4482 + * - return errors including -ENOSPC otherwise. 4483 + */ 4460 4484 static int do_chunk_alloc(struct btrfs_trans_handle *trans, 4461 4485 struct btrfs_root *extent_root, u64 flags, int force) 4462 4486 { ··· 4876 4882 btrfs_get_alloc_profile(root, 0), 4877 4883 CHUNK_ALLOC_NO_FORCE); 4878 4884 btrfs_end_transaction(trans, root); 4879 - if (ret == -ENOSPC) 4885 + if (ret > 0 || ret == -ENOSPC) 4880 4886 ret = 0; 4881 4887 break; 4882 4888 case COMMIT_TRANS: ··· 6491 6497 } 6492 6498 6493 6499 /** 6494 - * btrfs_update_reserved_bytes - update the block_group and space info counters 6500 + * btrfs_add_reserved_bytes - update the block_group and space info counters 6495 6501 * @cache: The cache we are manipulating 6502 + * @ram_bytes: The number of bytes of file content, and will be same to 6503 + * @num_bytes except for the compress path. 6496 6504 * @num_bytes: The number of bytes in question 6497 - * @reserve: One of the reservation enums 6498 6505 * @delalloc: The blocks are allocated for the delalloc write 6499 6506 * 6500 - * This is called by the allocator when it reserves space, or by somebody who is 6501 - * freeing space that was never actually used on disk. For example if you 6502 - * reserve some space for a new leaf in transaction A and before transaction A 6503 - * commits you free that leaf, you call this with reserve set to 0 in order to 6504 - * clear the reservation. 6505 - * 6506 - * Metadata reservations should be called with RESERVE_ALLOC so we do the proper 6507 + * This is called by the allocator when it reserves space. Metadata 6508 + * reservations should be called with RESERVE_ALLOC so we do the proper 6507 6509 * ENOSPC accounting. For data we handle the reservation through clearing the 6508 6510 * delalloc bits in the io_tree. We have to do this since we could end up 6509 6511 * allocating less disk space for the amount of data we have reserved in the ··· 6509 6519 * make the reservation and return -EAGAIN, otherwise this function always 6510 6520 * succeeds. 6511 6521 */ 6512 - static int btrfs_update_reserved_bytes(struct btrfs_block_group_cache *cache, 6513 - u64 num_bytes, int reserve, int delalloc) 6522 + static int btrfs_add_reserved_bytes(struct btrfs_block_group_cache *cache, 6523 + u64 ram_bytes, u64 num_bytes, int delalloc) 6514 6524 { 6515 6525 struct btrfs_space_info *space_info = cache->space_info; 6516 6526 int ret = 0; 6517 6527 6518 6528 spin_lock(&space_info->lock); 6519 6529 spin_lock(&cache->lock); 6520 - if (reserve != RESERVE_FREE) { 6521 - if (cache->ro) { 6522 - ret = -EAGAIN; 6523 - } else { 6524 - cache->reserved += num_bytes; 6525 - space_info->bytes_reserved += num_bytes; 6526 - if (reserve == RESERVE_ALLOC) { 6527 - trace_btrfs_space_reservation(cache->fs_info, 6528 - "space_info", space_info->flags, 6529 - num_bytes, 0); 6530 - space_info->bytes_may_use -= num_bytes; 6531 - } 6532 - 6533 - if (delalloc) 6534 - cache->delalloc_bytes += num_bytes; 6535 - } 6530 + if (cache->ro) { 6531 + ret = -EAGAIN; 6536 6532 } else { 6537 - if (cache->ro) 6538 - space_info->bytes_readonly += num_bytes; 6539 - cache->reserved -= num_bytes; 6540 - space_info->bytes_reserved -= num_bytes; 6533 + cache->reserved += num_bytes; 6534 + space_info->bytes_reserved += num_bytes; 6541 6535 6536 + trace_btrfs_space_reservation(cache->fs_info, 6537 + "space_info", space_info->flags, 6538 + ram_bytes, 0); 6539 + space_info->bytes_may_use -= ram_bytes; 6542 6540 if (delalloc) 6543 - cache->delalloc_bytes -= num_bytes; 6541 + cache->delalloc_bytes += num_bytes; 6544 6542 } 6545 6543 spin_unlock(&cache->lock); 6546 6544 spin_unlock(&space_info->lock); 6547 6545 return ret; 6548 6546 } 6549 6547 6548 + /** 6549 + * btrfs_free_reserved_bytes - update the block_group and space info counters 6550 + * @cache: The cache we are manipulating 6551 + * @num_bytes: The number of bytes in question 6552 + * @delalloc: The blocks are allocated for the delalloc write 6553 + * 6554 + * This is called by somebody who is freeing space that was never actually used 6555 + * on disk. For example if you reserve some space for a new leaf in transaction 6556 + * A and before transaction A commits you free that leaf, you call this with 6557 + * reserve set to 0 in order to clear the reservation. 6558 + */ 6559 + 6560 + static int btrfs_free_reserved_bytes(struct btrfs_block_group_cache *cache, 6561 + u64 num_bytes, int delalloc) 6562 + { 6563 + struct btrfs_space_info *space_info = cache->space_info; 6564 + int ret = 0; 6565 + 6566 + spin_lock(&space_info->lock); 6567 + spin_lock(&cache->lock); 6568 + if (cache->ro) 6569 + space_info->bytes_readonly += num_bytes; 6570 + cache->reserved -= num_bytes; 6571 + space_info->bytes_reserved -= num_bytes; 6572 + 6573 + if (delalloc) 6574 + cache->delalloc_bytes -= num_bytes; 6575 + spin_unlock(&cache->lock); 6576 + spin_unlock(&space_info->lock); 6577 + return ret; 6578 + } 6550 6579 void btrfs_prepare_extent_commit(struct btrfs_trans_handle *trans, 6551 6580 struct btrfs_root *root) 6552 6581 { ··· 7200 7191 WARN_ON(test_bit(EXTENT_BUFFER_DIRTY, &buf->bflags)); 7201 7192 7202 7193 btrfs_add_free_space(cache, buf->start, buf->len); 7203 - btrfs_update_reserved_bytes(cache, buf->len, RESERVE_FREE, 0); 7194 + btrfs_free_reserved_bytes(cache, buf->len, 0); 7204 7195 btrfs_put_block_group(cache); 7205 7196 trace_btrfs_reserved_extent_free(root, buf->start, buf->len); 7206 7197 pin = 0; ··· 7425 7416 * the free space extent currently. 7426 7417 */ 7427 7418 static noinline int find_free_extent(struct btrfs_root *orig_root, 7428 - u64 num_bytes, u64 empty_size, 7429 - u64 hint_byte, struct btrfs_key *ins, 7430 - u64 flags, int delalloc) 7419 + u64 ram_bytes, u64 num_bytes, u64 empty_size, 7420 + u64 hint_byte, struct btrfs_key *ins, 7421 + u64 flags, int delalloc) 7431 7422 { 7432 7423 int ret = 0; 7433 7424 struct btrfs_root *root = orig_root->fs_info->extent_root; ··· 7439 7430 struct btrfs_space_info *space_info; 7440 7431 int loop = 0; 7441 7432 int index = __get_raid_index(flags); 7442 - int alloc_type = (flags & BTRFS_BLOCK_GROUP_DATA) ? 7443 - RESERVE_ALLOC_NO_ACCOUNT : RESERVE_ALLOC; 7444 7433 bool failed_cluster_refill = false; 7445 7434 bool failed_alloc = false; 7446 7435 bool use_cluster = true; ··· 7770 7763 search_start - offset); 7771 7764 BUG_ON(offset > search_start); 7772 7765 7773 - ret = btrfs_update_reserved_bytes(block_group, num_bytes, 7774 - alloc_type, delalloc); 7766 + ret = btrfs_add_reserved_bytes(block_group, ram_bytes, 7767 + num_bytes, delalloc); 7775 7768 if (ret == -EAGAIN) { 7776 7769 btrfs_add_free_space(block_group, offset, num_bytes); 7777 7770 goto loop; ··· 7943 7936 up_read(&info->groups_sem); 7944 7937 } 7945 7938 7946 - int btrfs_reserve_extent(struct btrfs_root *root, 7939 + int btrfs_reserve_extent(struct btrfs_root *root, u64 ram_bytes, 7947 7940 u64 num_bytes, u64 min_alloc_size, 7948 7941 u64 empty_size, u64 hint_byte, 7949 7942 struct btrfs_key *ins, int is_data, int delalloc) ··· 7955 7948 flags = btrfs_get_alloc_profile(root, is_data); 7956 7949 again: 7957 7950 WARN_ON(num_bytes < root->sectorsize); 7958 - ret = find_free_extent(root, num_bytes, empty_size, hint_byte, ins, 7959 - flags, delalloc); 7951 + ret = find_free_extent(root, ram_bytes, num_bytes, empty_size, 7952 + hint_byte, ins, flags, delalloc); 7960 7953 if (!ret && !is_data) { 7961 7954 btrfs_dec_block_group_reservations(root->fs_info, 7962 7955 ins->objectid); ··· 7965 7958 num_bytes = min(num_bytes >> 1, ins->offset); 7966 7959 num_bytes = round_down(num_bytes, root->sectorsize); 7967 7960 num_bytes = max(num_bytes, min_alloc_size); 7961 + ram_bytes = num_bytes; 7968 7962 if (num_bytes == min_alloc_size) 7969 7963 final_tried = true; 7970 7964 goto again; ··· 8003 7995 if (btrfs_test_opt(root->fs_info, DISCARD)) 8004 7996 ret = btrfs_discard_extent(root, start, len, NULL); 8005 7997 btrfs_add_free_space(cache, start, len); 8006 - btrfs_update_reserved_bytes(cache, len, RESERVE_FREE, delalloc); 7998 + btrfs_free_reserved_bytes(cache, len, delalloc); 8007 7999 trace_btrfs_reserved_extent_free(root, start, len); 8008 8000 } 8009 8001 ··· 8231 8223 if (!block_group) 8232 8224 return -EINVAL; 8233 8225 8234 - ret = btrfs_update_reserved_bytes(block_group, ins->offset, 8235 - RESERVE_ALLOC_NO_ACCOUNT, 0); 8226 + ret = btrfs_add_reserved_bytes(block_group, ins->offset, 8227 + ins->offset, 0); 8236 8228 BUG_ON(ret); /* logic error */ 8237 8229 ret = alloc_reserved_file_extent(trans, root, 0, root_objectid, 8238 8230 0, owner, offset, ins, 1); ··· 8376 8368 if (IS_ERR(block_rsv)) 8377 8369 return ERR_CAST(block_rsv); 8378 8370 8379 - ret = btrfs_reserve_extent(root, blocksize, blocksize, 8371 + ret = btrfs_reserve_extent(root, blocksize, blocksize, blocksize, 8380 8372 empty_size, hint, &ins, 0, 0); 8381 8373 if (ret) 8382 8374 goto out_unuse; ··· 8529 8521 wc->reada_slot = slot; 8530 8522 } 8531 8523 8532 - /* 8533 - * These may not be seen by the usual inc/dec ref code so we have to 8534 - * add them here. 8535 - */ 8536 - static int record_one_subtree_extent(struct btrfs_trans_handle *trans, 8537 - struct btrfs_root *root, u64 bytenr, 8538 - u64 num_bytes) 8539 - { 8540 - struct btrfs_qgroup_extent_record *qrecord; 8541 - struct btrfs_delayed_ref_root *delayed_refs; 8542 - 8543 - qrecord = kmalloc(sizeof(*qrecord), GFP_NOFS); 8544 - if (!qrecord) 8545 - return -ENOMEM; 8546 - 8547 - qrecord->bytenr = bytenr; 8548 - qrecord->num_bytes = num_bytes; 8549 - qrecord->old_roots = NULL; 8550 - 8551 - delayed_refs = &trans->transaction->delayed_refs; 8552 - spin_lock(&delayed_refs->lock); 8553 - if (btrfs_qgroup_insert_dirty_extent(trans->fs_info, 8554 - delayed_refs, qrecord)) 8555 - kfree(qrecord); 8556 - spin_unlock(&delayed_refs->lock); 8557 - 8558 - return 0; 8559 - } 8560 - 8561 8524 static int account_leaf_items(struct btrfs_trans_handle *trans, 8562 8525 struct btrfs_root *root, 8563 8526 struct extent_buffer *eb) ··· 8562 8583 8563 8584 num_bytes = btrfs_file_extent_disk_num_bytes(eb, fi); 8564 8585 8565 - ret = record_one_subtree_extent(trans, root, bytenr, num_bytes); 8586 + ret = btrfs_qgroup_insert_dirty_extent(trans, root->fs_info, 8587 + bytenr, num_bytes, GFP_NOFS); 8566 8588 if (ret) 8567 8589 return ret; 8568 8590 } ··· 8712 8732 btrfs_set_lock_blocking_rw(eb, BTRFS_READ_LOCK); 8713 8733 path->locks[level] = BTRFS_READ_LOCK_BLOCKING; 8714 8734 8715 - ret = record_one_subtree_extent(trans, root, child_bytenr, 8716 - root->nodesize); 8735 + ret = btrfs_qgroup_insert_dirty_extent(trans, 8736 + root->fs_info, child_bytenr, 8737 + root->nodesize, GFP_NOFS); 8717 8738 if (ret) 8718 8739 goto out; 8719 8740 } ··· 9887 9906 } else { 9888 9907 ret = 0; 9889 9908 } 9909 + free_extent_map(em); 9890 9910 goto out; 9891 9911 } 9892 9912 path->slots[0]++; ··· 9924 9942 block_group->iref = 0; 9925 9943 block_group->inode = NULL; 9926 9944 spin_unlock(&block_group->lock); 9945 + ASSERT(block_group->io_ctl.inode == NULL); 9927 9946 iput(inode); 9928 9947 last = block_group->key.objectid + block_group->key.offset; 9929 9948 btrfs_put_block_group(block_group); ··· 9982 9999 free_excluded_extents(info->extent_root, block_group); 9983 10000 9984 10001 btrfs_remove_free_space_cache(block_group); 10002 + ASSERT(list_empty(&block_group->dirty_list)); 10003 + ASSERT(list_empty(&block_group->io_list)); 10004 + ASSERT(list_empty(&block_group->bg_list)); 10005 + ASSERT(atomic_read(&block_group->count) == 1); 9985 10006 btrfs_put_block_group(block_group); 9986 10007 9987 10008 spin_lock(&info->block_group_cache_lock);
+1
fs/btrfs/extent_io.h
··· 20 20 #define EXTENT_DAMAGED (1U << 14) 21 21 #define EXTENT_NORESERVE (1U << 15) 22 22 #define EXTENT_QGROUP_RESERVED (1U << 16) 23 + #define EXTENT_CLEAR_DATA_RESV (1U << 17) 23 24 #define EXTENT_IOBITS (EXTENT_LOCKED | EXTENT_WRITEBACK) 24 25 #define EXTENT_CTLBITS (EXTENT_DO_ACCOUNTING | EXTENT_FIRST_DELALLOC) 25 26
+16 -12
fs/btrfs/file.c
··· 2070 2070 } 2071 2071 trans->sync = true; 2072 2072 2073 - btrfs_init_log_ctx(&ctx); 2073 + btrfs_init_log_ctx(&ctx, inode); 2074 2074 2075 2075 ret = btrfs_log_dentry_safe(trans, root, dentry, start, end, &ctx); 2076 2076 if (ret < 0) { ··· 2675 2675 2676 2676 alloc_start = round_down(offset, blocksize); 2677 2677 alloc_end = round_up(offset + len, blocksize); 2678 + cur_offset = alloc_start; 2678 2679 2679 2680 /* Make sure we aren't being give some crap mode */ 2680 2681 if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE)) ··· 2768 2767 2769 2768 /* First, check if we exceed the qgroup limit */ 2770 2769 INIT_LIST_HEAD(&reserve_list); 2771 - cur_offset = alloc_start; 2772 2770 while (1) { 2773 2771 em = btrfs_get_extent(inode, NULL, 0, cur_offset, 2774 2772 alloc_end - cur_offset, 0); ··· 2794 2794 last_byte - cur_offset); 2795 2795 if (ret < 0) 2796 2796 break; 2797 + } else { 2798 + /* 2799 + * Do not need to reserve unwritten extent for this 2800 + * range, free reserved data space first, otherwise 2801 + * it'll result in false ENOSPC error. 2802 + */ 2803 + btrfs_free_reserved_data_space(inode, cur_offset, 2804 + last_byte - cur_offset); 2797 2805 } 2798 2806 free_extent_map(em); 2799 2807 cur_offset = last_byte; ··· 2819 2811 range->start, 2820 2812 range->len, 1 << inode->i_blkbits, 2821 2813 offset + len, &alloc_hint); 2814 + else 2815 + btrfs_free_reserved_data_space(inode, range->start, 2816 + range->len); 2822 2817 list_del(&range->list); 2823 2818 kfree(range); 2824 2819 } ··· 2856 2845 unlock_extent_cached(&BTRFS_I(inode)->io_tree, alloc_start, locked_end, 2857 2846 &cached_state, GFP_KERNEL); 2858 2847 out: 2859 - /* 2860 - * As we waited the extent range, the data_rsv_map must be empty 2861 - * in the range, as written data range will be released from it. 2862 - * And for prealloacted extent, it will also be released when 2863 - * its metadata is written. 2864 - * So this is completely used as cleanup. 2865 - */ 2866 - btrfs_qgroup_free_data(inode, alloc_start, alloc_end - alloc_start); 2867 2848 inode_unlock(inode); 2868 2849 /* Let go of our reservation. */ 2869 - btrfs_free_reserved_data_space(inode, alloc_start, 2870 - alloc_end - alloc_start); 2850 + if (ret != 0) 2851 + btrfs_free_reserved_data_space(inode, alloc_start, 2852 + alloc_end - cur_offset); 2871 2853 return ret; 2872 2854 } 2873 2855
+1 -2
fs/btrfs/inode-map.c
··· 495 495 ret = btrfs_prealloc_file_range_trans(inode, trans, 0, 0, prealloc, 496 496 prealloc, prealloc, &alloc_hint); 497 497 if (ret) { 498 - btrfs_delalloc_release_space(inode, 0, prealloc); 498 + btrfs_delalloc_release_metadata(inode, prealloc); 499 499 goto out_put; 500 500 } 501 - btrfs_free_reserved_data_space(inode, 0, prealloc); 502 501 503 502 ret = btrfs_write_out_ino_cache(root, trans, path, inode); 504 503 out_put:
+27 -10
fs/btrfs/inode.c
··· 566 566 PAGE_SET_WRITEBACK | 567 567 page_error_op | 568 568 PAGE_END_WRITEBACK); 569 + btrfs_free_reserved_data_space_noquota(inode, start, 570 + end - start + 1); 569 571 goto free_pages_out; 570 572 } 571 573 } ··· 744 742 lock_extent(io_tree, async_extent->start, 745 743 async_extent->start + async_extent->ram_size - 1); 746 744 747 - ret = btrfs_reserve_extent(root, 745 + ret = btrfs_reserve_extent(root, async_extent->ram_size, 748 746 async_extent->compressed_size, 749 747 async_extent->compressed_size, 750 748 0, alloc_hint, &ins, 1, 1); ··· 971 969 EXTENT_DEFRAG, PAGE_UNLOCK | 972 970 PAGE_CLEAR_DIRTY | PAGE_SET_WRITEBACK | 973 971 PAGE_END_WRITEBACK); 974 - 972 + btrfs_free_reserved_data_space_noquota(inode, start, 973 + end - start + 1); 975 974 *nr_written = *nr_written + 976 975 (end - start + PAGE_SIZE) / PAGE_SIZE; 977 976 *page_started = 1; ··· 992 989 unsigned long op; 993 990 994 991 cur_alloc_size = disk_num_bytes; 995 - ret = btrfs_reserve_extent(root, cur_alloc_size, 992 + ret = btrfs_reserve_extent(root, cur_alloc_size, cur_alloc_size, 996 993 root->sectorsize, 0, alloc_hint, 997 994 &ins, 1, 1); 998 995 if (ret < 0) ··· 1492 1489 extent_clear_unlock_delalloc(inode, cur_offset, 1493 1490 cur_offset + num_bytes - 1, 1494 1491 locked_page, EXTENT_LOCKED | 1495 - EXTENT_DELALLOC, PAGE_UNLOCK | 1496 - PAGE_SET_PRIVATE2); 1492 + EXTENT_DELALLOC | 1493 + EXTENT_CLEAR_DATA_RESV, 1494 + PAGE_UNLOCK | PAGE_SET_PRIVATE2); 1495 + 1497 1496 if (!nolock && nocow) 1498 1497 btrfs_end_write_no_snapshoting(root); 1499 1498 cur_offset = extent_end; ··· 1812 1807 return; 1813 1808 1814 1809 if (root->root_key.objectid != BTRFS_DATA_RELOC_TREE_OBJECTID 1815 - && do_list && !(state->state & EXTENT_NORESERVE)) 1810 + && do_list && !(state->state & EXTENT_NORESERVE) 1811 + && (*bits & (EXTENT_DO_ACCOUNTING | 1812 + EXTENT_CLEAR_DATA_RESV))) 1816 1813 btrfs_free_reserved_data_space_noquota(inode, 1817 1814 state->start, len); 1818 1815 ··· 7258 7251 int ret; 7259 7252 7260 7253 alloc_hint = get_extent_allocation_hint(inode, start, len); 7261 - ret = btrfs_reserve_extent(root, len, root->sectorsize, 0, 7254 + ret = btrfs_reserve_extent(root, len, len, root->sectorsize, 0, 7262 7255 alloc_hint, &ins, 1, 1); 7263 7256 if (ret) 7264 7257 return ERR_PTR(ret); ··· 7758 7751 ret = PTR_ERR(em2); 7759 7752 goto unlock_err; 7760 7753 } 7754 + /* 7755 + * For inode marked NODATACOW or extent marked PREALLOC, 7756 + * use the existing or preallocated extent, so does not 7757 + * need to adjust btrfs_space_info's bytes_may_use. 7758 + */ 7759 + btrfs_free_reserved_data_space_noquota(inode, 7760 + start, len); 7761 7761 goto unlock; 7762 7762 } 7763 7763 } ··· 7799 7785 i_size_write(inode, start + len); 7800 7786 7801 7787 adjust_dio_outstanding_extents(inode, dio_data, len); 7802 - btrfs_free_reserved_data_space(inode, start, len); 7803 7788 WARN_ON(dio_data->reserve < len); 7804 7789 dio_data->reserve -= len; 7805 7790 dio_data->unsubmitted_oe_range_end = start + len; ··· 10319 10306 u64 last_alloc = (u64)-1; 10320 10307 int ret = 0; 10321 10308 bool own_trans = true; 10309 + u64 end = start + num_bytes - 1; 10322 10310 10323 10311 if (trans) 10324 10312 own_trans = false; ··· 10341 10327 * sized chunks. 10342 10328 */ 10343 10329 cur_bytes = min(cur_bytes, last_alloc); 10344 - ret = btrfs_reserve_extent(root, cur_bytes, min_size, 0, 10345 - *alloc_hint, &ins, 1, 0); 10330 + ret = btrfs_reserve_extent(root, cur_bytes, cur_bytes, 10331 + min_size, 0, *alloc_hint, &ins, 1, 0); 10346 10332 if (ret) { 10347 10333 if (own_trans) 10348 10334 btrfs_end_transaction(trans, root); ··· 10428 10414 if (own_trans) 10429 10415 btrfs_end_transaction(trans, root); 10430 10416 } 10417 + if (cur_offset < end) 10418 + btrfs_free_reserved_data_space(inode, cur_offset, 10419 + end - cur_offset + 1); 10431 10420 return ret; 10432 10421 } 10433 10422
+1 -1
fs/btrfs/ioctl.c
··· 5084 5084 if (!capable(CAP_SYS_ADMIN)) 5085 5085 return -EPERM; 5086 5086 5087 - return btrfs_qgroup_wait_for_completion(root->fs_info); 5087 + return btrfs_qgroup_wait_for_completion(root->fs_info, true); 5088 5088 } 5089 5089 5090 5090 static long _btrfs_ioctl_set_received_subvol(struct file *file,
+52 -10
fs/btrfs/qgroup.c
··· 995 995 goto out; 996 996 fs_info->quota_enabled = 0; 997 997 fs_info->pending_quota_state = 0; 998 - btrfs_qgroup_wait_for_completion(fs_info); 998 + btrfs_qgroup_wait_for_completion(fs_info, false); 999 999 spin_lock(&fs_info->qgroup_lock); 1000 1000 quota_root = fs_info->quota_root; 1001 1001 fs_info->quota_root = NULL; ··· 1453 1453 return ret; 1454 1454 } 1455 1455 1456 - struct btrfs_qgroup_extent_record * 1457 - btrfs_qgroup_insert_dirty_extent(struct btrfs_fs_info *fs_info, 1458 - struct btrfs_delayed_ref_root *delayed_refs, 1459 - struct btrfs_qgroup_extent_record *record) 1456 + int btrfs_qgroup_insert_dirty_extent_nolock(struct btrfs_fs_info *fs_info, 1457 + struct btrfs_delayed_ref_root *delayed_refs, 1458 + struct btrfs_qgroup_extent_record *record) 1460 1459 { 1461 1460 struct rb_node **p = &delayed_refs->dirty_extent_root.rb_node; 1462 1461 struct rb_node *parent_node = NULL; ··· 1474 1475 else if (bytenr > entry->bytenr) 1475 1476 p = &(*p)->rb_right; 1476 1477 else 1477 - return entry; 1478 + return 1; 1478 1479 } 1479 1480 1480 1481 rb_link_node(&record->node, parent_node, p); 1481 1482 rb_insert_color(&record->node, &delayed_refs->dirty_extent_root); 1482 - return NULL; 1483 + return 0; 1484 + } 1485 + 1486 + int btrfs_qgroup_insert_dirty_extent(struct btrfs_trans_handle *trans, 1487 + struct btrfs_fs_info *fs_info, u64 bytenr, u64 num_bytes, 1488 + gfp_t gfp_flag) 1489 + { 1490 + struct btrfs_qgroup_extent_record *record; 1491 + struct btrfs_delayed_ref_root *delayed_refs; 1492 + int ret; 1493 + 1494 + if (!fs_info->quota_enabled || bytenr == 0 || num_bytes == 0) 1495 + return 0; 1496 + if (WARN_ON(trans == NULL)) 1497 + return -EINVAL; 1498 + record = kmalloc(sizeof(*record), gfp_flag); 1499 + if (!record) 1500 + return -ENOMEM; 1501 + 1502 + delayed_refs = &trans->transaction->delayed_refs; 1503 + record->bytenr = bytenr; 1504 + record->num_bytes = num_bytes; 1505 + record->old_roots = NULL; 1506 + 1507 + spin_lock(&delayed_refs->lock); 1508 + ret = btrfs_qgroup_insert_dirty_extent_nolock(fs_info, delayed_refs, 1509 + record); 1510 + spin_unlock(&delayed_refs->lock); 1511 + if (ret > 0) 1512 + kfree(record); 1513 + return 0; 1483 1514 } 1484 1515 1485 1516 #define UPDATE_NEW 0 ··· 2332 2303 int err = -ENOMEM; 2333 2304 int ret = 0; 2334 2305 2306 + mutex_lock(&fs_info->qgroup_rescan_lock); 2307 + fs_info->qgroup_rescan_running = true; 2308 + mutex_unlock(&fs_info->qgroup_rescan_lock); 2309 + 2335 2310 path = btrfs_alloc_path(); 2336 2311 if (!path) 2337 2312 goto out; ··· 2402 2369 } 2403 2370 2404 2371 done: 2372 + mutex_lock(&fs_info->qgroup_rescan_lock); 2373 + fs_info->qgroup_rescan_running = false; 2374 + mutex_unlock(&fs_info->qgroup_rescan_lock); 2405 2375 complete_all(&fs_info->qgroup_rescan_completion); 2406 2376 } 2407 2377 ··· 2523 2487 return 0; 2524 2488 } 2525 2489 2526 - int btrfs_qgroup_wait_for_completion(struct btrfs_fs_info *fs_info) 2490 + int btrfs_qgroup_wait_for_completion(struct btrfs_fs_info *fs_info, 2491 + bool interruptible) 2527 2492 { 2528 2493 int running; 2529 2494 int ret = 0; 2530 2495 2531 2496 mutex_lock(&fs_info->qgroup_rescan_lock); 2532 2497 spin_lock(&fs_info->qgroup_lock); 2533 - running = fs_info->qgroup_flags & BTRFS_QGROUP_STATUS_FLAG_RESCAN; 2498 + running = fs_info->qgroup_rescan_running; 2534 2499 spin_unlock(&fs_info->qgroup_lock); 2535 2500 mutex_unlock(&fs_info->qgroup_rescan_lock); 2536 2501 2537 - if (running) 2502 + if (!running) 2503 + return 0; 2504 + 2505 + if (interruptible) 2538 2506 ret = wait_for_completion_interruptible( 2539 2507 &fs_info->qgroup_rescan_completion); 2508 + else 2509 + wait_for_completion(&fs_info->qgroup_rescan_completion); 2540 2510 2541 2511 return ret; 2542 2512 }
+31 -5
fs/btrfs/qgroup.h
··· 46 46 struct btrfs_fs_info *fs_info); 47 47 int btrfs_qgroup_rescan(struct btrfs_fs_info *fs_info); 48 48 void btrfs_qgroup_rescan_resume(struct btrfs_fs_info *fs_info); 49 - int btrfs_qgroup_wait_for_completion(struct btrfs_fs_info *fs_info); 49 + int btrfs_qgroup_wait_for_completion(struct btrfs_fs_info *fs_info, 50 + bool interruptible); 50 51 int btrfs_add_qgroup_relation(struct btrfs_trans_handle *trans, 51 52 struct btrfs_fs_info *fs_info, u64 src, u64 dst); 52 53 int btrfs_del_qgroup_relation(struct btrfs_trans_handle *trans, ··· 64 63 struct btrfs_delayed_extent_op; 65 64 int btrfs_qgroup_prepare_account_extents(struct btrfs_trans_handle *trans, 66 65 struct btrfs_fs_info *fs_info); 67 - struct btrfs_qgroup_extent_record * 68 - btrfs_qgroup_insert_dirty_extent(struct btrfs_fs_info *fs_info, 69 - struct btrfs_delayed_ref_root *delayed_refs, 70 - struct btrfs_qgroup_extent_record *record); 66 + /* 67 + * Insert one dirty extent record into @delayed_refs, informing qgroup to 68 + * account that extent at commit trans time. 69 + * 70 + * No lock version, caller must acquire delayed ref lock and allocate memory. 71 + * 72 + * Return 0 for success insert 73 + * Return >0 for existing record, caller can free @record safely. 74 + * Error is not possible 75 + */ 76 + int btrfs_qgroup_insert_dirty_extent_nolock( 77 + struct btrfs_fs_info *fs_info, 78 + struct btrfs_delayed_ref_root *delayed_refs, 79 + struct btrfs_qgroup_extent_record *record); 80 + 81 + /* 82 + * Insert one dirty extent record into @delayed_refs, informing qgroup to 83 + * account that extent at commit trans time. 84 + * 85 + * Better encapsulated version. 86 + * 87 + * Return 0 if the operation is done. 88 + * Return <0 for error, like memory allocation failure or invalid parameter 89 + * (NULL trans) 90 + */ 91 + int btrfs_qgroup_insert_dirty_extent(struct btrfs_trans_handle *trans, 92 + struct btrfs_fs_info *fs_info, u64 bytenr, u64 num_bytes, 93 + gfp_t gfp_flag); 94 + 71 95 int 72 96 btrfs_qgroup_account_extent(struct btrfs_trans_handle *trans, 73 97 struct btrfs_fs_info *fs_info,
+116 -10
fs/btrfs/relocation.c
··· 31 31 #include "async-thread.h" 32 32 #include "free-space-cache.h" 33 33 #include "inode-map.h" 34 + #include "qgroup.h" 34 35 35 36 /* 36 37 * backref_node, mapping_node and tree_block start with this ··· 3038 3037 u64 num_bytes; 3039 3038 int nr = 0; 3040 3039 int ret = 0; 3040 + u64 prealloc_start = cluster->start - offset; 3041 + u64 prealloc_end = cluster->end - offset; 3042 + u64 cur_offset; 3041 3043 3042 3044 BUG_ON(cluster->start != cluster->boundary[0]); 3043 3045 inode_lock(inode); 3044 3046 3045 - ret = btrfs_check_data_free_space(inode, cluster->start, 3046 - cluster->end + 1 - cluster->start); 3047 + ret = btrfs_check_data_free_space(inode, prealloc_start, 3048 + prealloc_end + 1 - prealloc_start); 3047 3049 if (ret) 3048 3050 goto out; 3049 3051 3052 + cur_offset = prealloc_start; 3050 3053 while (nr < cluster->nr) { 3051 3054 start = cluster->boundary[nr] - offset; 3052 3055 if (nr + 1 < cluster->nr) ··· 3060 3055 3061 3056 lock_extent(&BTRFS_I(inode)->io_tree, start, end); 3062 3057 num_bytes = end + 1 - start; 3058 + if (cur_offset < start) 3059 + btrfs_free_reserved_data_space(inode, cur_offset, 3060 + start - cur_offset); 3063 3061 ret = btrfs_prealloc_file_range(inode, 0, start, 3064 3062 num_bytes, num_bytes, 3065 3063 end + 1, &alloc_hint); 3064 + cur_offset = end + 1; 3066 3065 unlock_extent(&BTRFS_I(inode)->io_tree, start, end); 3067 3066 if (ret) 3068 3067 break; 3069 3068 nr++; 3070 3069 } 3071 - btrfs_free_reserved_data_space(inode, cluster->start, 3072 - cluster->end + 1 - cluster->start); 3070 + if (cur_offset < prealloc_end) 3071 + btrfs_free_reserved_data_space(inode, cur_offset, 3072 + prealloc_end + 1 - cur_offset); 3073 3073 out: 3074 3074 inode_unlock(inode); 3075 3075 return ret; ··· 3926 3916 return 0; 3927 3917 } 3928 3918 3919 + /* 3920 + * Qgroup fixer for data chunk relocation. 3921 + * The data relocation is done in the following steps 3922 + * 1) Copy data extents into data reloc tree 3923 + * 2) Create tree reloc tree(special snapshot) for related subvolumes 3924 + * 3) Modify file extents in tree reloc tree 3925 + * 4) Merge tree reloc tree with original fs tree, by swapping tree blocks 3926 + * 3927 + * The problem is, data and tree reloc tree are not accounted to qgroup, 3928 + * and 4) will only info qgroup to track tree blocks change, not file extents 3929 + * in the tree blocks. 3930 + * 3931 + * The good news is, related data extents are all in data reloc tree, so we 3932 + * only need to info qgroup to track all file extents in data reloc tree 3933 + * before commit trans. 3934 + */ 3935 + static int qgroup_fix_relocated_data_extents(struct btrfs_trans_handle *trans, 3936 + struct reloc_control *rc) 3937 + { 3938 + struct btrfs_fs_info *fs_info = rc->extent_root->fs_info; 3939 + struct inode *inode = rc->data_inode; 3940 + struct btrfs_root *data_reloc_root = BTRFS_I(inode)->root; 3941 + struct btrfs_path *path; 3942 + struct btrfs_key key; 3943 + int ret = 0; 3944 + 3945 + if (!fs_info->quota_enabled) 3946 + return 0; 3947 + 3948 + /* 3949 + * Only for stage where we update data pointers the qgroup fix is 3950 + * valid. 3951 + * For MOVING_DATA stage, we will miss the timing of swapping tree 3952 + * blocks, and won't fix it. 3953 + */ 3954 + if (!(rc->stage == UPDATE_DATA_PTRS && rc->extents_found)) 3955 + return 0; 3956 + 3957 + path = btrfs_alloc_path(); 3958 + if (!path) 3959 + return -ENOMEM; 3960 + key.objectid = btrfs_ino(inode); 3961 + key.type = BTRFS_EXTENT_DATA_KEY; 3962 + key.offset = 0; 3963 + 3964 + ret = btrfs_search_slot(NULL, data_reloc_root, &key, path, 0, 0); 3965 + if (ret < 0) 3966 + goto out; 3967 + 3968 + lock_extent(&BTRFS_I(inode)->io_tree, 0, (u64)-1); 3969 + while (1) { 3970 + struct btrfs_file_extent_item *fi; 3971 + 3972 + btrfs_item_key_to_cpu(path->nodes[0], &key, path->slots[0]); 3973 + if (key.objectid > btrfs_ino(inode)) 3974 + break; 3975 + if (key.type != BTRFS_EXTENT_DATA_KEY) 3976 + goto next; 3977 + fi = btrfs_item_ptr(path->nodes[0], path->slots[0], 3978 + struct btrfs_file_extent_item); 3979 + if (btrfs_file_extent_type(path->nodes[0], fi) != 3980 + BTRFS_FILE_EXTENT_REG) 3981 + goto next; 3982 + ret = btrfs_qgroup_insert_dirty_extent(trans, fs_info, 3983 + btrfs_file_extent_disk_bytenr(path->nodes[0], fi), 3984 + btrfs_file_extent_disk_num_bytes(path->nodes[0], fi), 3985 + GFP_NOFS); 3986 + if (ret < 0) 3987 + break; 3988 + next: 3989 + ret = btrfs_next_item(data_reloc_root, path); 3990 + if (ret < 0) 3991 + break; 3992 + if (ret > 0) { 3993 + ret = 0; 3994 + break; 3995 + } 3996 + } 3997 + unlock_extent(&BTRFS_I(inode)->io_tree, 0 , (u64)-1); 3998 + out: 3999 + btrfs_free_path(path); 4000 + return ret; 4001 + } 4002 + 3929 4003 static noinline_for_stack int relocate_block_group(struct reloc_control *rc) 3930 4004 { 3931 4005 struct rb_root blocks = RB_ROOT; ··· 4196 4102 4197 4103 /* get rid of pinned extents */ 4198 4104 trans = btrfs_join_transaction(rc->extent_root); 4199 - if (IS_ERR(trans)) 4105 + if (IS_ERR(trans)) { 4200 4106 err = PTR_ERR(trans); 4201 - else 4202 - btrfs_commit_transaction(trans, rc->extent_root); 4107 + goto out_free; 4108 + } 4109 + err = qgroup_fix_relocated_data_extents(trans, rc); 4110 + if (err < 0) { 4111 + btrfs_abort_transaction(trans, err); 4112 + goto out_free; 4113 + } 4114 + btrfs_commit_transaction(trans, rc->extent_root); 4203 4115 out_free: 4204 4116 btrfs_free_block_rsv(rc->extent_root, rc->block_rsv); 4205 4117 btrfs_free_path(path); ··· 4568 4468 unset_reloc_control(rc); 4569 4469 4570 4470 trans = btrfs_join_transaction(rc->extent_root); 4571 - if (IS_ERR(trans)) 4471 + if (IS_ERR(trans)) { 4572 4472 err = PTR_ERR(trans); 4573 - else 4574 - err = btrfs_commit_transaction(trans, rc->extent_root); 4473 + goto out_free; 4474 + } 4475 + err = qgroup_fix_relocated_data_extents(trans, rc); 4476 + if (err < 0) { 4477 + btrfs_abort_transaction(trans, err); 4478 + goto out_free; 4479 + } 4480 + err = btrfs_commit_transaction(trans, rc->extent_root); 4575 4481 out_free: 4576 4482 kfree(rc); 4577 4483 out:
+18 -9
fs/btrfs/root-tree.c
··· 272 272 root_key.objectid = key.offset; 273 273 key.offset++; 274 274 275 + /* 276 + * The root might have been inserted already, as before we look 277 + * for orphan roots, log replay might have happened, which 278 + * triggers a transaction commit and qgroup accounting, which 279 + * in turn reads and inserts fs roots while doing backref 280 + * walking. 281 + */ 282 + root = btrfs_lookup_fs_root(tree_root->fs_info, 283 + root_key.objectid); 284 + if (root) { 285 + WARN_ON(!test_bit(BTRFS_ROOT_ORPHAN_ITEM_INSERTED, 286 + &root->state)); 287 + if (btrfs_root_refs(&root->root_item) == 0) 288 + btrfs_add_dead_root(root); 289 + continue; 290 + } 291 + 275 292 root = btrfs_read_fs_root(tree_root, &root_key); 276 293 err = PTR_ERR_OR_ZERO(root); 277 294 if (err && err != -ENOENT) { ··· 327 310 set_bit(BTRFS_ROOT_ORPHAN_ITEM_INSERTED, &root->state); 328 311 329 312 err = btrfs_insert_fs_root(root->fs_info, root); 330 - /* 331 - * The root might have been inserted already, as before we look 332 - * for orphan roots, log replay might have happened, which 333 - * triggers a transaction commit and qgroup accounting, which 334 - * in turn reads and inserts fs roots while doing backref 335 - * walking. 336 - */ 337 - if (err == -EEXIST) 338 - err = 0; 339 313 if (err) { 314 + BUG_ON(err == -EEXIST); 340 315 btrfs_free_fs_root(root); 341 316 break; 342 317 }
+16
fs/btrfs/super.c
··· 2241 2241 struct btrfs_trans_handle *trans; 2242 2242 struct btrfs_root *root = btrfs_sb(sb)->tree_root; 2243 2243 2244 + root->fs_info->fs_frozen = 1; 2245 + /* 2246 + * We don't need a barrier here, we'll wait for any transaction that 2247 + * could be in progress on other threads (and do delayed iputs that 2248 + * we want to avoid on a frozen filesystem), or do the commit 2249 + * ourselves. 2250 + */ 2244 2251 trans = btrfs_attach_transaction_barrier(root); 2245 2252 if (IS_ERR(trans)) { 2246 2253 /* no transaction, don't bother */ ··· 2256 2249 return PTR_ERR(trans); 2257 2250 } 2258 2251 return btrfs_commit_transaction(trans, root); 2252 + } 2253 + 2254 + static int btrfs_unfreeze(struct super_block *sb) 2255 + { 2256 + struct btrfs_root *root = btrfs_sb(sb)->tree_root; 2257 + 2258 + root->fs_info->fs_frozen = 0; 2259 + return 0; 2259 2260 } 2260 2261 2261 2262 static int btrfs_show_devname(struct seq_file *m, struct dentry *root) ··· 2314 2299 .statfs = btrfs_statfs, 2315 2300 .remount_fs = btrfs_remount, 2316 2301 .freeze_fs = btrfs_freeze, 2302 + .unfreeze_fs = btrfs_unfreeze, 2317 2303 }; 2318 2304 2319 2305 static const struct file_operations btrfs_ctl_fops = {
+6 -1
fs/btrfs/transaction.c
··· 2278 2278 2279 2279 kmem_cache_free(btrfs_trans_handle_cachep, trans); 2280 2280 2281 + /* 2282 + * If fs has been frozen, we can not handle delayed iputs, otherwise 2283 + * it'll result in deadlock about SB_FREEZE_FS. 2284 + */ 2281 2285 if (current != root->fs_info->transaction_kthread && 2282 - current != root->fs_info->cleaner_kthread) 2286 + current != root->fs_info->cleaner_kthread && 2287 + !root->fs_info->fs_frozen) 2283 2288 btrfs_run_delayed_iputs(root); 2284 2289 2285 2290 return ret;
+19 -2
fs/btrfs/tree-log.c
··· 27 27 #include "backref.h" 28 28 #include "hash.h" 29 29 #include "compression.h" 30 + #include "qgroup.h" 30 31 31 32 /* magic values for the inode_only field in btrfs_log_inode: 32 33 * ··· 680 679 ins.offset = btrfs_file_extent_disk_num_bytes(eb, item); 681 680 ins.type = BTRFS_EXTENT_ITEM_KEY; 682 681 offset = key->offset - btrfs_file_extent_offset(eb, item); 682 + 683 + /* 684 + * Manually record dirty extent, as here we did a shallow 685 + * file extent item copy and skip normal backref update, 686 + * but modifying extent tree all by ourselves. 687 + * So need to manually record dirty extent for qgroup, 688 + * as the owner of the file extent changed from log tree 689 + * (doesn't affect qgroup) to fs/file tree(affects qgroup) 690 + */ 691 + ret = btrfs_qgroup_insert_dirty_extent(trans, root->fs_info, 692 + btrfs_file_extent_disk_bytenr(eb, item), 693 + btrfs_file_extent_disk_num_bytes(eb, item), 694 + GFP_NOFS); 695 + if (ret < 0) 696 + goto out; 683 697 684 698 if (ins.objectid > 0) { 685 699 u64 csum_start; ··· 2823 2807 */ 2824 2808 mutex_unlock(&root->log_mutex); 2825 2809 2826 - btrfs_init_log_ctx(&root_log_ctx); 2810 + btrfs_init_log_ctx(&root_log_ctx, NULL); 2827 2811 2828 2812 mutex_lock(&log_root_tree->log_mutex); 2829 2813 atomic_inc(&log_root_tree->log_batch); ··· 4757 4741 if (ret < 0) { 4758 4742 err = ret; 4759 4743 goto out_unlock; 4760 - } else if (ret > 0) { 4744 + } else if (ret > 0 && ctx && 4745 + other_ino != btrfs_ino(ctx->inode)) { 4761 4746 struct btrfs_key inode_key; 4762 4747 struct inode *other_inode; 4763 4748
+4 -1
fs/btrfs/tree-log.h
··· 30 30 int log_transid; 31 31 int io_err; 32 32 bool log_new_dentries; 33 + struct inode *inode; 33 34 struct list_head list; 34 35 }; 35 36 36 - static inline void btrfs_init_log_ctx(struct btrfs_log_ctx *ctx) 37 + static inline void btrfs_init_log_ctx(struct btrfs_log_ctx *ctx, 38 + struct inode *inode) 37 39 { 38 40 ctx->log_ret = 0; 39 41 ctx->log_transid = 0; 40 42 ctx->io_err = 0; 41 43 ctx->log_new_dentries = false; 44 + ctx->inode = inode; 42 45 INIT_LIST_HEAD(&ctx->list); 43 46 } 44 47
+19 -8
fs/btrfs/volumes.c
··· 834 834 struct btrfs_device *device; 835 835 836 836 device = container_of(work, struct btrfs_device, rcu_work); 837 - 838 - if (device->bdev) 839 - blkdev_put(device->bdev, device->mode); 840 - 841 837 rcu_string_free(device->name); 842 838 kfree(device); 843 839 } ··· 846 850 847 851 INIT_WORK(&device->rcu_work, __free_device); 848 852 schedule_work(&device->rcu_work); 853 + } 854 + 855 + static void btrfs_close_bdev(struct btrfs_device *device) 856 + { 857 + if (device->bdev && device->writeable) { 858 + sync_blockdev(device->bdev); 859 + invalidate_bdev(device->bdev); 860 + } 861 + 862 + if (device->bdev) 863 + blkdev_put(device->bdev, device->mode); 849 864 } 850 865 851 866 static void btrfs_close_one_device(struct btrfs_device *device) ··· 877 870 if (device->missing) 878 871 fs_devices->missing_devices--; 879 872 880 - if (device->bdev && device->writeable) { 881 - sync_blockdev(device->bdev); 882 - invalidate_bdev(device->bdev); 883 - } 873 + btrfs_close_bdev(device); 884 874 885 875 new_device = btrfs_alloc_device(NULL, &device->devid, 886 876 device->uuid); ··· 1936 1932 btrfs_sysfs_rm_device_link(root->fs_info->fs_devices, device); 1937 1933 } 1938 1934 1935 + btrfs_close_bdev(device); 1936 + 1939 1937 call_rcu(&device->rcu, free_device); 1940 1938 1941 1939 num_devices = btrfs_super_num_devices(root->fs_info->super_copy) - 1; ··· 2031 2025 /* zero out the old super if it is writable */ 2032 2026 btrfs_scratch_superblocks(srcdev->bdev, srcdev->name->str); 2033 2027 } 2028 + 2029 + btrfs_close_bdev(srcdev); 2030 + 2034 2031 call_rcu(&srcdev->rcu, free_device); 2035 2032 2036 2033 /* ··· 2089 2080 * the device_list_mutex lock. 2090 2081 */ 2091 2082 btrfs_scratch_superblocks(tgtdev->bdev, tgtdev->name->str); 2083 + 2084 + btrfs_close_bdev(tgtdev); 2092 2085 call_rcu(&tgtdev->rcu, free_device); 2093 2086 } 2094 2087
+48 -14
fs/dlm/debug_fs.c
··· 607 607 static const struct file_operations format3_fops; 608 608 static const struct file_operations format4_fops; 609 609 610 - static int table_open(struct inode *inode, struct file *file) 610 + static int table_open1(struct inode *inode, struct file *file) 611 611 { 612 612 struct seq_file *seq; 613 - int ret = -1; 613 + int ret; 614 614 615 - if (file->f_op == &format1_fops) 616 - ret = seq_open(file, &format1_seq_ops); 617 - else if (file->f_op == &format2_fops) 618 - ret = seq_open(file, &format2_seq_ops); 619 - else if (file->f_op == &format3_fops) 620 - ret = seq_open(file, &format3_seq_ops); 621 - else if (file->f_op == &format4_fops) 622 - ret = seq_open(file, &format4_seq_ops); 615 + ret = seq_open(file, &format1_seq_ops); 616 + if (ret) 617 + return ret; 623 618 619 + seq = file->private_data; 620 + seq->private = inode->i_private; /* the dlm_ls */ 621 + return 0; 622 + } 623 + 624 + static int table_open2(struct inode *inode, struct file *file) 625 + { 626 + struct seq_file *seq; 627 + int ret; 628 + 629 + ret = seq_open(file, &format2_seq_ops); 630 + if (ret) 631 + return ret; 632 + 633 + seq = file->private_data; 634 + seq->private = inode->i_private; /* the dlm_ls */ 635 + return 0; 636 + } 637 + 638 + static int table_open3(struct inode *inode, struct file *file) 639 + { 640 + struct seq_file *seq; 641 + int ret; 642 + 643 + ret = seq_open(file, &format3_seq_ops); 644 + if (ret) 645 + return ret; 646 + 647 + seq = file->private_data; 648 + seq->private = inode->i_private; /* the dlm_ls */ 649 + return 0; 650 + } 651 + 652 + static int table_open4(struct inode *inode, struct file *file) 653 + { 654 + struct seq_file *seq; 655 + int ret; 656 + 657 + ret = seq_open(file, &format4_seq_ops); 624 658 if (ret) 625 659 return ret; 626 660 ··· 665 631 666 632 static const struct file_operations format1_fops = { 667 633 .owner = THIS_MODULE, 668 - .open = table_open, 634 + .open = table_open1, 669 635 .read = seq_read, 670 636 .llseek = seq_lseek, 671 637 .release = seq_release ··· 673 639 674 640 static const struct file_operations format2_fops = { 675 641 .owner = THIS_MODULE, 676 - .open = table_open, 642 + .open = table_open2, 677 643 .read = seq_read, 678 644 .llseek = seq_lseek, 679 645 .release = seq_release ··· 681 647 682 648 static const struct file_operations format3_fops = { 683 649 .owner = THIS_MODULE, 684 - .open = table_open, 650 + .open = table_open3, 685 651 .read = seq_read, 686 652 .llseek = seq_lseek, 687 653 .release = seq_release ··· 689 655 690 656 static const struct file_operations format4_fops = { 691 657 .owner = THIS_MODULE, 692 - .open = table_open, 658 + .open = table_open4, 693 659 .read = seq_read, 694 660 .llseek = seq_lseek, 695 661 .release = seq_release
-2
fs/ext4/inode.c
··· 5466 5466 sbi->s_want_extra_isize, 5467 5467 iloc, handle); 5468 5468 if (ret) { 5469 - ext4_set_inode_state(inode, 5470 - EXT4_STATE_NO_EXPAND); 5471 5469 if (mnt_count != 5472 5470 le16_to_cpu(sbi->s_es->s_mnt_count)) { 5473 5471 ext4_warning(inode->i_sb,
+17 -1
fs/ext4/super.c
··· 2211 2211 2212 2212 /* Called at mount-time, super-block is locked */ 2213 2213 static int ext4_check_descriptors(struct super_block *sb, 2214 + ext4_fsblk_t sb_block, 2214 2215 ext4_group_t *first_not_zeroed) 2215 2216 { 2216 2217 struct ext4_sb_info *sbi = EXT4_SB(sb); ··· 2242 2241 grp = i; 2243 2242 2244 2243 block_bitmap = ext4_block_bitmap(sb, gdp); 2244 + if (block_bitmap == sb_block) { 2245 + ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " 2246 + "Block bitmap for group %u overlaps " 2247 + "superblock", i); 2248 + } 2245 2249 if (block_bitmap < first_block || block_bitmap > last_block) { 2246 2250 ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " 2247 2251 "Block bitmap for group %u not in group " ··· 2254 2248 return 0; 2255 2249 } 2256 2250 inode_bitmap = ext4_inode_bitmap(sb, gdp); 2251 + if (inode_bitmap == sb_block) { 2252 + ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " 2253 + "Inode bitmap for group %u overlaps " 2254 + "superblock", i); 2255 + } 2257 2256 if (inode_bitmap < first_block || inode_bitmap > last_block) { 2258 2257 ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " 2259 2258 "Inode bitmap for group %u not in group " ··· 2266 2255 return 0; 2267 2256 } 2268 2257 inode_table = ext4_inode_table(sb, gdp); 2258 + if (inode_table == sb_block) { 2259 + ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " 2260 + "Inode table for group %u overlaps " 2261 + "superblock", i); 2262 + } 2269 2263 if (inode_table < first_block || 2270 2264 inode_table + sbi->s_itb_per_group - 1 > last_block) { 2271 2265 ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " ··· 3773 3757 goto failed_mount2; 3774 3758 } 3775 3759 } 3776 - if (!ext4_check_descriptors(sb, &first_not_zeroed)) { 3760 + if (!ext4_check_descriptors(sb, logical_sb_block, &first_not_zeroed)) { 3777 3761 ext4_msg(sb, KERN_ERR, "group descriptors corrupted!"); 3778 3762 ret = -EFSCORRUPTED; 3779 3763 goto failed_mount2;
+31 -22
fs/ext4/xattr.c
··· 1353 1353 size_t min_offs, free; 1354 1354 int total_ino; 1355 1355 void *base, *start, *end; 1356 - int extra_isize = 0, error = 0, tried_min_extra_isize = 0; 1356 + int error = 0, tried_min_extra_isize = 0; 1357 1357 int s_min_extra_isize = le16_to_cpu(EXT4_SB(inode->i_sb)->s_es->s_min_extra_isize); 1358 + int isize_diff; /* How much do we need to grow i_extra_isize */ 1358 1359 1359 1360 down_write(&EXT4_I(inode)->xattr_sem); 1361 + /* 1362 + * Set EXT4_STATE_NO_EXPAND to avoid recursion when marking inode dirty 1363 + */ 1364 + ext4_set_inode_state(inode, EXT4_STATE_NO_EXPAND); 1360 1365 retry: 1361 - if (EXT4_I(inode)->i_extra_isize >= new_extra_isize) { 1362 - up_write(&EXT4_I(inode)->xattr_sem); 1363 - return 0; 1364 - } 1366 + isize_diff = new_extra_isize - EXT4_I(inode)->i_extra_isize; 1367 + if (EXT4_I(inode)->i_extra_isize >= new_extra_isize) 1368 + goto out; 1365 1369 1366 1370 header = IHDR(inode, raw_inode); 1367 1371 entry = IFIRST(header); ··· 1386 1382 goto cleanup; 1387 1383 1388 1384 free = ext4_xattr_free_space(last, &min_offs, base, &total_ino); 1389 - if (free >= new_extra_isize) { 1385 + if (free >= isize_diff) { 1390 1386 entry = IFIRST(header); 1391 1387 ext4_xattr_shift_entries(entry, EXT4_I(inode)->i_extra_isize 1392 1388 - new_extra_isize, (void *)raw_inode + ··· 1394 1390 (void *)header, total_ino, 1395 1391 inode->i_sb->s_blocksize); 1396 1392 EXT4_I(inode)->i_extra_isize = new_extra_isize; 1397 - error = 0; 1398 - goto cleanup; 1393 + goto out; 1399 1394 } 1400 1395 1401 1396 /* ··· 1417 1414 end = bh->b_data + bh->b_size; 1418 1415 min_offs = end - base; 1419 1416 free = ext4_xattr_free_space(first, &min_offs, base, NULL); 1420 - if (free < new_extra_isize) { 1417 + if (free < isize_diff) { 1421 1418 if (!tried_min_extra_isize && s_min_extra_isize) { 1422 1419 tried_min_extra_isize++; 1423 1420 new_extra_isize = s_min_extra_isize; ··· 1431 1428 free = inode->i_sb->s_blocksize; 1432 1429 } 1433 1430 1434 - while (new_extra_isize > 0) { 1431 + while (isize_diff > 0) { 1435 1432 size_t offs, size, entry_size; 1436 1433 struct ext4_xattr_entry *small_entry = NULL; 1437 1434 struct ext4_xattr_info i = { ··· 1462 1459 EXT4_XATTR_SIZE(le32_to_cpu(last->e_value_size)) + 1463 1460 EXT4_XATTR_LEN(last->e_name_len); 1464 1461 if (total_size <= free && total_size < min_total_size) { 1465 - if (total_size < new_extra_isize) { 1462 + if (total_size < isize_diff) { 1466 1463 small_entry = last; 1467 1464 } else { 1468 1465 entry = last; ··· 1517 1514 error = ext4_xattr_ibody_set(handle, inode, &i, is); 1518 1515 if (error) 1519 1516 goto cleanup; 1517 + total_ino -= entry_size; 1520 1518 1521 1519 entry = IFIRST(header); 1522 - if (entry_size + EXT4_XATTR_SIZE(size) >= new_extra_isize) 1523 - shift_bytes = new_extra_isize; 1520 + if (entry_size + EXT4_XATTR_SIZE(size) >= isize_diff) 1521 + shift_bytes = isize_diff; 1524 1522 else 1525 - shift_bytes = entry_size + size; 1523 + shift_bytes = entry_size + EXT4_XATTR_SIZE(size); 1526 1524 /* Adjust the offsets and shift the remaining entries ahead */ 1527 - ext4_xattr_shift_entries(entry, EXT4_I(inode)->i_extra_isize - 1528 - shift_bytes, (void *)raw_inode + 1529 - EXT4_GOOD_OLD_INODE_SIZE + extra_isize + shift_bytes, 1530 - (void *)header, total_ino - entry_size, 1531 - inode->i_sb->s_blocksize); 1525 + ext4_xattr_shift_entries(entry, -shift_bytes, 1526 + (void *)raw_inode + EXT4_GOOD_OLD_INODE_SIZE + 1527 + EXT4_I(inode)->i_extra_isize + shift_bytes, 1528 + (void *)header, total_ino, inode->i_sb->s_blocksize); 1532 1529 1533 - extra_isize += shift_bytes; 1534 - new_extra_isize -= shift_bytes; 1535 - EXT4_I(inode)->i_extra_isize = extra_isize; 1530 + isize_diff -= shift_bytes; 1531 + EXT4_I(inode)->i_extra_isize += shift_bytes; 1532 + header = IHDR(inode, raw_inode); 1536 1533 1537 1534 i.name = b_entry_name; 1538 1535 i.value = buffer; ··· 1554 1551 kfree(bs); 1555 1552 } 1556 1553 brelse(bh); 1554 + out: 1555 + ext4_clear_inode_state(inode, EXT4_STATE_NO_EXPAND); 1557 1556 up_write(&EXT4_I(inode)->xattr_sem); 1558 1557 return 0; 1559 1558 ··· 1567 1562 kfree(is); 1568 1563 kfree(bs); 1569 1564 brelse(bh); 1565 + /* 1566 + * We deliberately leave EXT4_STATE_NO_EXPAND set here since inode 1567 + * size expansion failed. 1568 + */ 1570 1569 up_write(&EXT4_I(inode)->xattr_sem); 1571 1570 return error; 1572 1571 }
+1
fs/ext4/xattr.h
··· 24 24 #define EXT4_XATTR_INDEX_SYSTEM 7 25 25 #define EXT4_XATTR_INDEX_RICHACL 8 26 26 #define EXT4_XATTR_INDEX_ENCRYPTION 9 27 + #define EXT4_XATTR_INDEX_HURD 10 /* Reserved for Hurd */ 27 28 28 29 struct ext4_xattr_header { 29 30 __le32 h_magic; /* magic number for identification */
+1 -1
fs/f2fs/data.c
··· 1699 1699 trace_f2fs_write_end(inode, pos, len, copied); 1700 1700 1701 1701 set_page_dirty(page); 1702 - f2fs_put_page(page, 1); 1703 1702 1704 1703 if (pos + copied > i_size_read(inode)) 1705 1704 f2fs_i_size_write(inode, pos + copied); 1706 1705 1706 + f2fs_put_page(page, 1); 1707 1707 f2fs_update_time(F2FS_I_SB(inode), REQ_TIME); 1708 1708 return copied; 1709 1709 }
+6 -6
fs/f2fs/f2fs.h
··· 538 538 /* NAT cache management */ 539 539 struct radix_tree_root nat_root;/* root of the nat entry cache */ 540 540 struct radix_tree_root nat_set_root;/* root of the nat set cache */ 541 - struct percpu_rw_semaphore nat_tree_lock; /* protect nat_tree_lock */ 541 + struct rw_semaphore nat_tree_lock; /* protect nat_tree_lock */ 542 542 struct list_head nat_entries; /* cached nat entry list (clean) */ 543 543 unsigned int nat_cnt; /* the # of cached nat entries */ 544 544 unsigned int dirty_nat_cnt; /* total num of nat entries in set */ ··· 787 787 struct f2fs_checkpoint *ckpt; /* raw checkpoint pointer */ 788 788 struct inode *meta_inode; /* cache meta blocks */ 789 789 struct mutex cp_mutex; /* checkpoint procedure lock */ 790 - struct percpu_rw_semaphore cp_rwsem; /* blocking FS operations */ 790 + struct rw_semaphore cp_rwsem; /* blocking FS operations */ 791 791 struct rw_semaphore node_write; /* locking node writes */ 792 792 wait_queue_head_t cp_wait; 793 793 unsigned long last_time[MAX_TIME]; /* to store time in jiffies */ ··· 1074 1074 1075 1075 static inline void f2fs_lock_op(struct f2fs_sb_info *sbi) 1076 1076 { 1077 - percpu_down_read(&sbi->cp_rwsem); 1077 + down_read(&sbi->cp_rwsem); 1078 1078 } 1079 1079 1080 1080 static inline void f2fs_unlock_op(struct f2fs_sb_info *sbi) 1081 1081 { 1082 - percpu_up_read(&sbi->cp_rwsem); 1082 + up_read(&sbi->cp_rwsem); 1083 1083 } 1084 1084 1085 1085 static inline void f2fs_lock_all(struct f2fs_sb_info *sbi) 1086 1086 { 1087 - percpu_down_write(&sbi->cp_rwsem); 1087 + down_write(&sbi->cp_rwsem); 1088 1088 } 1089 1089 1090 1090 static inline void f2fs_unlock_all(struct f2fs_sb_info *sbi) 1091 1091 { 1092 - percpu_up_write(&sbi->cp_rwsem); 1092 + up_write(&sbi->cp_rwsem); 1093 1093 } 1094 1094 1095 1095 static inline int __get_cp_reason(struct f2fs_sb_info *sbi)
+9 -4
fs/f2fs/file.c
··· 2086 2086 if (unlikely(f2fs_readonly(src->i_sb))) 2087 2087 return -EROFS; 2088 2088 2089 - if (S_ISDIR(src->i_mode) || S_ISDIR(dst->i_mode)) 2090 - return -EISDIR; 2089 + if (!S_ISREG(src->i_mode) || !S_ISREG(dst->i_mode)) 2090 + return -EINVAL; 2091 2091 2092 2092 if (f2fs_encrypted_inode(src) || f2fs_encrypted_inode(dst)) 2093 2093 return -EOPNOTSUPP; 2094 2094 2095 2095 inode_lock(src); 2096 - if (src != dst) 2097 - inode_lock(dst); 2096 + if (src != dst) { 2097 + if (!inode_trylock(dst)) { 2098 + ret = -EBUSY; 2099 + goto out; 2100 + } 2101 + } 2098 2102 2099 2103 ret = -EINVAL; 2100 2104 if (pos_in + len > src->i_size || pos_in + len < pos_in) ··· 2156 2152 out_unlock: 2157 2153 if (src != dst) 2158 2154 inode_unlock(dst); 2155 + out: 2159 2156 inode_unlock(src); 2160 2157 return ret; 2161 2158 }
+23 -24
fs/f2fs/node.c
··· 206 206 struct nat_entry *e; 207 207 bool need = false; 208 208 209 - percpu_down_read(&nm_i->nat_tree_lock); 209 + down_read(&nm_i->nat_tree_lock); 210 210 e = __lookup_nat_cache(nm_i, nid); 211 211 if (e) { 212 212 if (!get_nat_flag(e, IS_CHECKPOINTED) && 213 213 !get_nat_flag(e, HAS_FSYNCED_INODE)) 214 214 need = true; 215 215 } 216 - percpu_up_read(&nm_i->nat_tree_lock); 216 + up_read(&nm_i->nat_tree_lock); 217 217 return need; 218 218 } 219 219 ··· 223 223 struct nat_entry *e; 224 224 bool is_cp = true; 225 225 226 - percpu_down_read(&nm_i->nat_tree_lock); 226 + down_read(&nm_i->nat_tree_lock); 227 227 e = __lookup_nat_cache(nm_i, nid); 228 228 if (e && !get_nat_flag(e, IS_CHECKPOINTED)) 229 229 is_cp = false; 230 - percpu_up_read(&nm_i->nat_tree_lock); 230 + up_read(&nm_i->nat_tree_lock); 231 231 return is_cp; 232 232 } 233 233 ··· 237 237 struct nat_entry *e; 238 238 bool need_update = true; 239 239 240 - percpu_down_read(&nm_i->nat_tree_lock); 240 + down_read(&nm_i->nat_tree_lock); 241 241 e = __lookup_nat_cache(nm_i, ino); 242 242 if (e && get_nat_flag(e, HAS_LAST_FSYNC) && 243 243 (get_nat_flag(e, IS_CHECKPOINTED) || 244 244 get_nat_flag(e, HAS_FSYNCED_INODE))) 245 245 need_update = false; 246 - percpu_up_read(&nm_i->nat_tree_lock); 246 + up_read(&nm_i->nat_tree_lock); 247 247 return need_update; 248 248 } 249 249 ··· 284 284 struct f2fs_nm_info *nm_i = NM_I(sbi); 285 285 struct nat_entry *e; 286 286 287 - percpu_down_write(&nm_i->nat_tree_lock); 287 + down_write(&nm_i->nat_tree_lock); 288 288 e = __lookup_nat_cache(nm_i, ni->nid); 289 289 if (!e) { 290 290 e = grab_nat_entry(nm_i, ni->nid); ··· 334 334 set_nat_flag(e, HAS_FSYNCED_INODE, true); 335 335 set_nat_flag(e, HAS_LAST_FSYNC, fsync_done); 336 336 } 337 - percpu_up_write(&nm_i->nat_tree_lock); 337 + up_write(&nm_i->nat_tree_lock); 338 338 } 339 339 340 340 int try_to_free_nats(struct f2fs_sb_info *sbi, int nr_shrink) ··· 342 342 struct f2fs_nm_info *nm_i = NM_I(sbi); 343 343 int nr = nr_shrink; 344 344 345 - percpu_down_write(&nm_i->nat_tree_lock); 345 + if (!down_write_trylock(&nm_i->nat_tree_lock)) 346 + return 0; 346 347 347 348 while (nr_shrink && !list_empty(&nm_i->nat_entries)) { 348 349 struct nat_entry *ne; ··· 352 351 __del_from_nat_cache(nm_i, ne); 353 352 nr_shrink--; 354 353 } 355 - percpu_up_write(&nm_i->nat_tree_lock); 354 + up_write(&nm_i->nat_tree_lock); 356 355 return nr - nr_shrink; 357 356 } 358 357 ··· 374 373 ni->nid = nid; 375 374 376 375 /* Check nat cache */ 377 - percpu_down_read(&nm_i->nat_tree_lock); 376 + down_read(&nm_i->nat_tree_lock); 378 377 e = __lookup_nat_cache(nm_i, nid); 379 378 if (e) { 380 379 ni->ino = nat_get_ino(e); 381 380 ni->blk_addr = nat_get_blkaddr(e); 382 381 ni->version = nat_get_version(e); 383 - percpu_up_read(&nm_i->nat_tree_lock); 382 + up_read(&nm_i->nat_tree_lock); 384 383 return; 385 384 } 386 385 ··· 404 403 node_info_from_raw_nat(ni, &ne); 405 404 f2fs_put_page(page, 1); 406 405 cache: 407 - percpu_up_read(&nm_i->nat_tree_lock); 406 + up_read(&nm_i->nat_tree_lock); 408 407 /* cache nat entry */ 409 - percpu_down_write(&nm_i->nat_tree_lock); 408 + down_write(&nm_i->nat_tree_lock); 410 409 cache_nat_entry(sbi, nid, &ne); 411 - percpu_up_write(&nm_i->nat_tree_lock); 410 + up_write(&nm_i->nat_tree_lock); 412 411 } 413 412 414 413 /* ··· 1789 1788 ra_meta_pages(sbi, NAT_BLOCK_OFFSET(nid), FREE_NID_PAGES, 1790 1789 META_NAT, true); 1791 1790 1792 - percpu_down_read(&nm_i->nat_tree_lock); 1791 + down_read(&nm_i->nat_tree_lock); 1793 1792 1794 1793 while (1) { 1795 1794 struct page *page = get_current_nat_page(sbi, nid); ··· 1821 1820 remove_free_nid(nm_i, nid); 1822 1821 } 1823 1822 up_read(&curseg->journal_rwsem); 1824 - percpu_up_read(&nm_i->nat_tree_lock); 1823 + up_read(&nm_i->nat_tree_lock); 1825 1824 1826 1825 ra_meta_pages(sbi, NAT_BLOCK_OFFSET(nm_i->next_scan_nid), 1827 1826 nm_i->ra_nid_pages, META_NAT, false); ··· 2210 2209 if (!nm_i->dirty_nat_cnt) 2211 2210 return; 2212 2211 2213 - percpu_down_write(&nm_i->nat_tree_lock); 2212 + down_write(&nm_i->nat_tree_lock); 2214 2213 2215 2214 /* 2216 2215 * if there are no enough space in journal to store dirty nat ··· 2233 2232 list_for_each_entry_safe(set, tmp, &sets, set_list) 2234 2233 __flush_nat_entry_set(sbi, set); 2235 2234 2236 - percpu_up_write(&nm_i->nat_tree_lock); 2235 + up_write(&nm_i->nat_tree_lock); 2237 2236 2238 2237 f2fs_bug_on(sbi, nm_i->dirty_nat_cnt); 2239 2238 } ··· 2269 2268 2270 2269 mutex_init(&nm_i->build_lock); 2271 2270 spin_lock_init(&nm_i->free_nid_list_lock); 2272 - if (percpu_init_rwsem(&nm_i->nat_tree_lock)) 2273 - return -ENOMEM; 2271 + init_rwsem(&nm_i->nat_tree_lock); 2274 2272 2275 2273 nm_i->next_scan_nid = le32_to_cpu(sbi->ckpt->next_free_nid); 2276 2274 nm_i->bitmap_size = __bitmap_size(sbi, NAT_BITMAP); ··· 2326 2326 spin_unlock(&nm_i->free_nid_list_lock); 2327 2327 2328 2328 /* destroy nat cache */ 2329 - percpu_down_write(&nm_i->nat_tree_lock); 2329 + down_write(&nm_i->nat_tree_lock); 2330 2330 while ((found = __gang_lookup_nat_cache(nm_i, 2331 2331 nid, NATVEC_SIZE, natvec))) { 2332 2332 unsigned idx; ··· 2351 2351 kmem_cache_free(nat_entry_set_slab, setvec[idx]); 2352 2352 } 2353 2353 } 2354 - percpu_up_write(&nm_i->nat_tree_lock); 2354 + up_write(&nm_i->nat_tree_lock); 2355 2355 2356 - percpu_free_rwsem(&nm_i->nat_tree_lock); 2357 2356 kfree(nm_i->nat_bitmap); 2358 2357 sbi->nm_info = NULL; 2359 2358 kfree(nm_i);
+1 -5
fs/f2fs/super.c
··· 706 706 percpu_counter_destroy(&sbi->nr_pages[i]); 707 707 percpu_counter_destroy(&sbi->alloc_valid_block_count); 708 708 percpu_counter_destroy(&sbi->total_valid_inode_count); 709 - 710 - percpu_free_rwsem(&sbi->cp_rwsem); 711 709 } 712 710 713 711 static void f2fs_put_super(struct super_block *sb) ··· 1481 1483 { 1482 1484 int i, err; 1483 1485 1484 - if (percpu_init_rwsem(&sbi->cp_rwsem)) 1485 - return -ENOMEM; 1486 - 1487 1486 for (i = 0; i < NR_COUNT_TYPE; i++) { 1488 1487 err = percpu_counter_init(&sbi->nr_pages[i], 0, GFP_KERNEL); 1489 1488 if (err) ··· 1681 1686 sbi->write_io[i].bio = NULL; 1682 1687 } 1683 1688 1689 + init_rwsem(&sbi->cp_rwsem); 1684 1690 init_waitqueue_head(&sbi->cp_wait); 1685 1691 init_sb_info(sbi); 1686 1692
+13 -8
fs/iomap.c
··· 84 84 * Now the data has been copied, commit the range we've copied. This 85 85 * should not fail unless the filesystem has had a fatal error. 86 86 */ 87 - ret = ops->iomap_end(inode, pos, length, written > 0 ? written : 0, 88 - flags, &iomap); 87 + if (ops->iomap_end) { 88 + ret = ops->iomap_end(inode, pos, length, 89 + written > 0 ? written : 0, 90 + flags, &iomap); 91 + } 89 92 90 93 return written ? written : ret; 91 94 } ··· 197 194 if (mapping_writably_mapped(inode->i_mapping)) 198 195 flush_dcache_page(page); 199 196 200 - pagefault_disable(); 201 197 copied = iov_iter_copy_from_user_atomic(page, i, offset, bytes); 202 - pagefault_enable(); 203 198 204 199 flush_dcache_page(page); 205 - mark_page_accessed(page); 206 200 207 201 status = iomap_write_end(inode, pos, bytes, copied, page); 208 202 if (unlikely(status < 0)) ··· 470 470 if (ret) 471 471 return ret; 472 472 473 - ret = filemap_write_and_wait(inode->i_mapping); 474 - if (ret) 475 - return ret; 473 + if (fi->fi_flags & FIEMAP_FLAG_SYNC) { 474 + ret = filemap_write_and_wait(inode->i_mapping); 475 + if (ret) 476 + return ret; 477 + } 476 478 477 479 while (len > 0) { 478 480 ret = iomap_apply(inode, start, len, 0, ops, &ctx, 479 481 iomap_fiemap_actor); 482 + /* inode with no (attribute) mapping will give ENOENT */ 483 + if (ret == -ENOENT) 484 + break; 480 485 if (ret < 0) 481 486 return ret; 482 487 if (ret == 0)
+3 -1
fs/seq_file.c
··· 223 223 size -= n; 224 224 buf += n; 225 225 copied += n; 226 - if (!m->count) 226 + if (!m->count) { 227 + m->from = 0; 227 228 m->index++; 229 + } 228 230 if (!size) 229 231 goto Done; 230 232 }
+1 -1
fs/ubifs/tnc_commit.c
··· 370 370 371 371 p = c->gap_lebs; 372 372 do { 373 - ubifs_assert(p < c->gap_lebs + sizeof(int) * c->lst.idx_lebs); 373 + ubifs_assert(p < c->gap_lebs + c->lst.idx_lebs); 374 374 written = layout_leb_in_gaps(c, p); 375 375 if (written < 0) { 376 376 err = written;
+4 -1
fs/ubifs/xattr.c
··· 575 575 dbg_gen("xattr '%s', ino %lu ('%pd'), buf size %zd", name, 576 576 inode->i_ino, dentry, size); 577 577 578 - return __ubifs_getxattr(inode, name, buffer, size); 578 + name = xattr_full_name(handler, name); 579 + return __ubifs_getxattr(inode, name, buffer, size); 579 580 } 580 581 581 582 static int ubifs_xattr_set(const struct xattr_handler *handler, ··· 586 585 { 587 586 dbg_gen("xattr '%s', host ino %lu ('%pd'), size %zd", 588 587 name, inode->i_ino, dentry, size); 588 + 589 + name = xattr_full_name(handler, name); 589 590 590 591 if (value) 591 592 return __ubifs_setxattr(inode, name, value, size, flags);
+14
fs/xfs/libxfs/xfs_alloc.c
··· 1582 1582 xfs_extlen_t *flenp, /* result length */ 1583 1583 int *stat) /* status: 0-freelist, 1-normal/none */ 1584 1584 { 1585 + struct xfs_owner_info oinfo; 1585 1586 int error; 1586 1587 xfs_agblock_t fbno; 1587 1588 xfs_extlen_t flen; ··· 1625 1624 error0); 1626 1625 args->wasfromfl = 1; 1627 1626 trace_xfs_alloc_small_freelist(args); 1627 + 1628 + /* 1629 + * If we're feeding an AGFL block to something that 1630 + * doesn't live in the free space, we need to clear 1631 + * out the OWN_AG rmap. 1632 + */ 1633 + xfs_rmap_ag_owner(&oinfo, XFS_RMAP_OWN_AG); 1634 + error = xfs_rmap_free(args->tp, args->agbp, args->agno, 1635 + fbno, 1, &oinfo); 1636 + if (error) 1637 + goto error0; 1638 + 1628 1639 *stat = 0; 1629 1640 return 0; 1630 1641 } ··· 2277 2264 offsetof(xfs_agf_t, agf_longest), 2278 2265 offsetof(xfs_agf_t, agf_btreeblks), 2279 2266 offsetof(xfs_agf_t, agf_uuid), 2267 + offsetof(xfs_agf_t, agf_rmap_blocks), 2280 2268 sizeof(xfs_agf_t) 2281 2269 }; 2282 2270
+8 -3
fs/xfs/libxfs/xfs_format.h
··· 640 640 __be32 agf_btreeblks; /* # of blocks held in AGF btrees */ 641 641 uuid_t agf_uuid; /* uuid of filesystem */ 642 642 643 + __be32 agf_rmap_blocks; /* rmapbt blocks used */ 644 + __be32 agf_padding; /* padding */ 645 + 643 646 /* 644 647 * reserve some contiguous space for future logged fields before we add 645 648 * the unlogged fields. This makes the range logging via flags and 646 649 * structure offsets much simpler. 647 650 */ 648 - __be64 agf_spare64[16]; 651 + __be64 agf_spare64[15]; 649 652 650 653 /* unlogged fields, written during buffer writeback. */ 651 654 __be64 agf_lsn; /* last write sequence */ ··· 673 670 #define XFS_AGF_LONGEST 0x00000400 674 671 #define XFS_AGF_BTREEBLKS 0x00000800 675 672 #define XFS_AGF_UUID 0x00001000 676 - #define XFS_AGF_NUM_BITS 13 673 + #define XFS_AGF_RMAP_BLOCKS 0x00002000 674 + #define XFS_AGF_NUM_BITS 14 677 675 #define XFS_AGF_ALL_BITS ((1 << XFS_AGF_NUM_BITS) - 1) 678 676 679 677 #define XFS_AGF_FLAGS \ ··· 690 686 { XFS_AGF_FREEBLKS, "FREEBLKS" }, \ 691 687 { XFS_AGF_LONGEST, "LONGEST" }, \ 692 688 { XFS_AGF_BTREEBLKS, "BTREEBLKS" }, \ 693 - { XFS_AGF_UUID, "UUID" } 689 + { XFS_AGF_UUID, "UUID" }, \ 690 + { XFS_AGF_RMAP_BLOCKS, "RMAP_BLOCKS" } 694 691 695 692 /* disk block (xfs_daddr_t) in the AG */ 696 693 #define XFS_AGF_DADDR(mp) ((xfs_daddr_t)(1 << (mp)->m_sectbb_log))
+6
fs/xfs/libxfs/xfs_rmap_btree.c
··· 98 98 union xfs_btree_ptr *new, 99 99 int *stat) 100 100 { 101 + struct xfs_buf *agbp = cur->bc_private.a.agbp; 102 + struct xfs_agf *agf = XFS_BUF_TO_AGF(agbp); 101 103 int error; 102 104 xfs_agblock_t bno; 103 105 ··· 126 124 127 125 xfs_trans_agbtree_delta(cur->bc_tp, 1); 128 126 new->s = cpu_to_be32(bno); 127 + be32_add_cpu(&agf->agf_rmap_blocks, 1); 128 + xfs_alloc_log_agf(cur->bc_tp, agbp, XFS_AGF_RMAP_BLOCKS); 129 129 130 130 XFS_BTREE_TRACE_CURSOR(cur, XBT_EXIT); 131 131 *stat = 1; ··· 147 143 bno = xfs_daddr_to_agbno(cur->bc_mp, XFS_BUF_ADDR(bp)); 148 144 trace_xfs_rmapbt_free_block(cur->bc_mp, cur->bc_private.a.agno, 149 145 bno, 1); 146 + be32_add_cpu(&agf->agf_rmap_blocks, -1); 147 + xfs_alloc_log_agf(cur->bc_tp, agbp, XFS_AGF_RMAP_BLOCKS); 150 148 error = xfs_alloc_put_freelist(cur->bc_tp, agbp, NULL, bno, 1); 151 149 if (error) 152 150 return error;
-1
fs/xfs/xfs_buf.c
··· 115 115 if (!(bp->b_flags & _XBF_IN_FLIGHT)) 116 116 return; 117 117 118 - ASSERT(bp->b_flags & XBF_ASYNC); 119 118 bp->b_flags &= ~_XBF_IN_FLIGHT; 120 119 percpu_counter_dec(&bp->b_target->bt_io_count); 121 120 }
+12 -1
fs/xfs/xfs_file.c
··· 741 741 * page is inserted into the pagecache when we have to serve a write 742 742 * fault on a hole. It should never be dirtied and can simply be 743 743 * dropped from the pagecache once we get real data for the page. 744 + * 745 + * XXX: This is racy against mmap, and there's nothing we can do about 746 + * it. dax_do_io() should really do this invalidation internally as 747 + * it will know if we've allocated over a holei for this specific IO and 748 + * if so it needs to update the mapping tree and invalidate existing 749 + * PTEs over the newly allocated range. Remove this invalidation when 750 + * dax_do_io() is fixed up. 744 751 */ 745 752 if (mapping->nrpages) { 746 - ret = invalidate_inode_pages2(mapping); 753 + loff_t end = iocb->ki_pos + iov_iter_count(from) - 1; 754 + 755 + ret = invalidate_inode_pages2_range(mapping, 756 + iocb->ki_pos >> PAGE_SHIFT, 757 + end >> PAGE_SHIFT); 747 758 WARN_ON_ONCE(ret); 748 759 } 749 760
+1
fs/xfs/xfs_fsops.c
··· 248 248 agf->agf_roots[XFS_BTNUM_RMAPi] = 249 249 cpu_to_be32(XFS_RMAP_BLOCK(mp)); 250 250 agf->agf_levels[XFS_BTNUM_RMAPi] = cpu_to_be32(1); 251 + agf->agf_rmap_blocks = cpu_to_be32(1); 251 252 } 252 253 253 254 agf->agf_flfirst = cpu_to_be32(1);
+56 -13
fs/xfs/xfs_iomap.c
··· 715 715 * is in the delayed allocation extent on which we sit 716 716 * but before our buffer starts. 717 717 */ 718 - 719 718 nimaps = 0; 720 719 while (nimaps == 0) { 721 720 nres = XFS_EXTENTADD_SPACE_RES(mp, XFS_DATA_FORK); 722 - 723 - error = xfs_trans_alloc(mp, &M_RES(mp)->tr_write, nres, 721 + /* 722 + * We have already reserved space for the extent and any 723 + * indirect blocks when creating the delalloc extent, 724 + * there is no need to reserve space in this transaction 725 + * again. 726 + */ 727 + error = xfs_trans_alloc(mp, &M_RES(mp)->tr_write, 0, 724 728 0, XFS_TRANS_RESERVE, &tp); 725 729 if (error) 726 730 return error; ··· 1041 1037 return error; 1042 1038 1043 1039 trace_xfs_iomap_alloc(ip, offset, length, 0, &imap); 1044 - xfs_bmbt_to_iomap(ip, iomap, &imap); 1045 - } else if (nimaps) { 1040 + } else { 1041 + ASSERT(nimaps); 1042 + 1046 1043 xfs_iunlock(ip, XFS_ILOCK_EXCL); 1047 1044 trace_xfs_iomap_found(ip, offset, length, 0, &imap); 1048 - xfs_bmbt_to_iomap(ip, iomap, &imap); 1049 - } else { 1050 - xfs_iunlock(ip, XFS_ILOCK_EXCL); 1051 - trace_xfs_iomap_not_found(ip, offset, length, 0, &imap); 1052 - iomap->blkno = IOMAP_NULL_BLOCK; 1053 - iomap->type = IOMAP_HOLE; 1054 - iomap->offset = offset; 1055 - iomap->length = length; 1056 1045 } 1057 1046 1047 + xfs_bmbt_to_iomap(ip, iomap, &imap); 1058 1048 return 0; 1059 1049 } 1060 1050 ··· 1109 1111 struct iomap_ops xfs_iomap_ops = { 1110 1112 .iomap_begin = xfs_file_iomap_begin, 1111 1113 .iomap_end = xfs_file_iomap_end, 1114 + }; 1115 + 1116 + static int 1117 + xfs_xattr_iomap_begin( 1118 + struct inode *inode, 1119 + loff_t offset, 1120 + loff_t length, 1121 + unsigned flags, 1122 + struct iomap *iomap) 1123 + { 1124 + struct xfs_inode *ip = XFS_I(inode); 1125 + struct xfs_mount *mp = ip->i_mount; 1126 + xfs_fileoff_t offset_fsb = XFS_B_TO_FSBT(mp, offset); 1127 + xfs_fileoff_t end_fsb = XFS_B_TO_FSB(mp, offset + length); 1128 + struct xfs_bmbt_irec imap; 1129 + int nimaps = 1, error = 0; 1130 + unsigned lockmode; 1131 + 1132 + if (XFS_FORCED_SHUTDOWN(mp)) 1133 + return -EIO; 1134 + 1135 + lockmode = xfs_ilock_data_map_shared(ip); 1136 + 1137 + /* if there are no attribute fork or extents, return ENOENT */ 1138 + if (XFS_IFORK_Q(ip) || !ip->i_d.di_anextents) { 1139 + error = -ENOENT; 1140 + goto out_unlock; 1141 + } 1142 + 1143 + ASSERT(ip->i_d.di_aformat != XFS_DINODE_FMT_LOCAL); 1144 + error = xfs_bmapi_read(ip, offset_fsb, end_fsb - offset_fsb, &imap, 1145 + &nimaps, XFS_BMAPI_ENTIRE | XFS_BMAPI_ATTRFORK); 1146 + out_unlock: 1147 + xfs_iunlock(ip, lockmode); 1148 + 1149 + if (!error) { 1150 + ASSERT(nimaps); 1151 + xfs_bmbt_to_iomap(ip, iomap, &imap); 1152 + } 1153 + 1154 + return error; 1155 + } 1156 + 1157 + struct iomap_ops xfs_xattr_iomap_ops = { 1158 + .iomap_begin = xfs_xattr_iomap_begin, 1112 1159 };
+1
fs/xfs/xfs_iomap.h
··· 35 35 struct xfs_bmbt_irec *); 36 36 37 37 extern struct iomap_ops xfs_iomap_ops; 38 + extern struct iomap_ops xfs_xattr_iomap_ops; 38 39 39 40 #endif /* __XFS_IOMAP_H__*/
+8 -1
fs/xfs/xfs_iops.c
··· 1009 1009 int error; 1010 1010 1011 1011 xfs_ilock(XFS_I(inode), XFS_IOLOCK_SHARED); 1012 - error = iomap_fiemap(inode, fieinfo, start, length, &xfs_iomap_ops); 1012 + if (fieinfo->fi_flags & FIEMAP_FLAG_XATTR) { 1013 + fieinfo->fi_flags &= ~FIEMAP_FLAG_XATTR; 1014 + error = iomap_fiemap(inode, fieinfo, start, length, 1015 + &xfs_xattr_iomap_ops); 1016 + } else { 1017 + error = iomap_fiemap(inode, fieinfo, start, length, 1018 + &xfs_iomap_ops); 1019 + } 1013 1020 xfs_iunlock(XFS_I(inode), XFS_IOLOCK_SHARED); 1014 1021 1015 1022 return error;
-1
fs/xfs/xfs_trace.h
··· 1298 1298 DEFINE_IOMAP_EVENT(xfs_get_blocks_map_direct); 1299 1299 DEFINE_IOMAP_EVENT(xfs_iomap_alloc); 1300 1300 DEFINE_IOMAP_EVENT(xfs_iomap_found); 1301 - DEFINE_IOMAP_EVENT(xfs_iomap_not_found); 1302 1301 1303 1302 DECLARE_EVENT_CLASS(xfs_simple_io_class, 1304 1303 TP_PROTO(struct xfs_inode *ip, xfs_off_t offset, ssize_t count),
+8 -2
include/linux/bio.h
··· 71 71 { 72 72 if (bio && 73 73 bio->bi_iter.bi_size && 74 - bio_op(bio) != REQ_OP_DISCARD) 74 + bio_op(bio) != REQ_OP_DISCARD && 75 + bio_op(bio) != REQ_OP_SECURE_ERASE) 75 76 return true; 76 77 77 78 return false; ··· 80 79 81 80 static inline bool bio_no_advance_iter(struct bio *bio) 82 81 { 83 - return bio_op(bio) == REQ_OP_DISCARD || bio_op(bio) == REQ_OP_WRITE_SAME; 82 + return bio_op(bio) == REQ_OP_DISCARD || 83 + bio_op(bio) == REQ_OP_SECURE_ERASE || 84 + bio_op(bio) == REQ_OP_WRITE_SAME; 84 85 } 85 86 86 87 static inline bool bio_is_rw(struct bio *bio) ··· 200 197 */ 201 198 202 199 if (bio_op(bio) == REQ_OP_DISCARD) 200 + return 1; 201 + 202 + if (bio_op(bio) == REQ_OP_SECURE_ERASE) 203 203 return 1; 204 204 205 205 if (bio_op(bio) == REQ_OP_WRITE_SAME)
+4 -2
include/linux/blkdev.h
··· 882 882 static inline unsigned int blk_queue_get_max_sectors(struct request_queue *q, 883 883 int op) 884 884 { 885 - if (unlikely(op == REQ_OP_DISCARD)) 885 + if (unlikely(op == REQ_OP_DISCARD || op == REQ_OP_SECURE_ERASE)) 886 886 return min(q->limits.max_discard_sectors, UINT_MAX >> 9); 887 887 888 888 if (unlikely(op == REQ_OP_WRITE_SAME)) ··· 913 913 if (unlikely(rq->cmd_type != REQ_TYPE_FS)) 914 914 return q->limits.max_hw_sectors; 915 915 916 - if (!q->limits.chunk_sectors || (req_op(rq) == REQ_OP_DISCARD)) 916 + if (!q->limits.chunk_sectors || 917 + req_op(rq) == REQ_OP_DISCARD || 918 + req_op(rq) == REQ_OP_SECURE_ERASE) 917 919 return blk_queue_get_max_sectors(q, req_op(rq)); 918 920 919 921 return min(blk_max_size_offset(q, offset),
+6 -2
include/linux/compiler-gcc.h
··· 242 242 */ 243 243 #define asm_volatile_goto(x...) do { asm goto(x); asm (""); } while (0) 244 244 245 - #ifdef CONFIG_ARCH_USE_BUILTIN_BSWAP 245 + /* 246 + * sparse (__CHECKER__) pretends to be gcc, but can't do constant 247 + * folding in __builtin_bswap*() (yet), so don't set these for it. 248 + */ 249 + #if defined(CONFIG_ARCH_USE_BUILTIN_BSWAP) && !defined(__CHECKER__) 246 250 #if GCC_VERSION >= 40400 247 251 #define __HAVE_BUILTIN_BSWAP32__ 248 252 #define __HAVE_BUILTIN_BSWAP64__ ··· 254 250 #if GCC_VERSION >= 40800 255 251 #define __HAVE_BUILTIN_BSWAP16__ 256 252 #endif 257 - #endif /* CONFIG_ARCH_USE_BUILTIN_BSWAP */ 253 + #endif /* CONFIG_ARCH_USE_BUILTIN_BSWAP && !__CHECKER__ */ 258 254 259 255 #if GCC_VERSION >= 50000 260 256 #define KASAN_ABI_VERSION 4
+3 -3
include/linux/compiler.h
··· 527 527 * object's lifetime is managed by something other than RCU. That 528 528 * "something other" might be reference counting or simple immortality. 529 529 * 530 - * The seemingly unused void * variable is to validate @p is indeed a pointer 531 - * type. All pointer types silently cast to void *. 530 + * The seemingly unused size_t variable is to validate @p is indeed a pointer 531 + * type by making sure it can be dereferenced. 532 532 */ 533 533 #define lockless_dereference(p) \ 534 534 ({ \ 535 535 typeof(p) _________p1 = READ_ONCE(p); \ 536 - __maybe_unused const void * const _________p2 = _________p1; \ 536 + size_t __maybe_unused __size_of_ptr = sizeof(*(p)); \ 537 537 smp_read_barrier_depends(); /* Dependency order vs. p above. */ \ 538 538 (_________p1); \ 539 539 })
+2
include/linux/host1x.h
··· 304 304 305 305 struct tegra_mipi_device *tegra_mipi_request(struct device *device); 306 306 void tegra_mipi_free(struct tegra_mipi_device *device); 307 + int tegra_mipi_enable(struct tegra_mipi_device *device); 308 + int tegra_mipi_disable(struct tegra_mipi_device *device); 307 309 int tegra_mipi_calibrate(struct tegra_mipi_device *device); 308 310 309 311 #endif
+1
include/linux/irqchip/arm-gic-v3.h
··· 337 337 */ 338 338 #define E_ITS_MOVI_UNMAPPED_INTERRUPT 0x010107 339 339 #define E_ITS_MOVI_UNMAPPED_COLLECTION 0x010109 340 + #define E_ITS_INT_UNMAPPED_INTERRUPT 0x010307 340 341 #define E_ITS_CLEAR_UNMAPPED_INTERRUPT 0x010507 341 342 #define E_ITS_MAPD_DEVICE_OOR 0x010801 342 343 #define E_ITS_MAPC_PROCNUM_OOR 0x010902
+6 -4
include/linux/pci.h
··· 1251 1251 int pci_set_vga_state(struct pci_dev *pdev, bool decode, 1252 1252 unsigned int command_bits, u32 flags); 1253 1253 1254 - #define PCI_IRQ_NOLEGACY (1 << 0) /* don't use legacy interrupts */ 1255 - #define PCI_IRQ_NOMSI (1 << 1) /* don't use MSI interrupts */ 1256 - #define PCI_IRQ_NOMSIX (1 << 2) /* don't use MSI-X interrupts */ 1257 - #define PCI_IRQ_NOAFFINITY (1 << 3) /* don't auto-assign affinity */ 1254 + #define PCI_IRQ_LEGACY (1 << 0) /* allow legacy interrupts */ 1255 + #define PCI_IRQ_MSI (1 << 1) /* allow MSI interrupts */ 1256 + #define PCI_IRQ_MSIX (1 << 2) /* allow MSI-X interrupts */ 1257 + #define PCI_IRQ_AFFINITY (1 << 3) /* auto-assign affinity */ 1258 + #define PCI_IRQ_ALL_TYPES \ 1259 + (PCI_IRQ_LEGACY | PCI_IRQ_MSI | PCI_IRQ_MSIX) 1258 1260 1259 1261 /* kmem_cache style wrapper around pci_alloc_consistent() */ 1260 1262
+10
include/linux/smc91x.h
··· 1 1 #ifndef __SMC91X_H__ 2 2 #define __SMC91X_H__ 3 3 4 + /* 5 + * These bits define which access sizes a platform can support, rather 6 + * than the maximal access size. So, if your platform can do 16-bit 7 + * and 32-bit accesses to the SMC91x device, but not 8-bit, set both 8 + * SMC91X_USE_16BIT and SMC91X_USE_32BIT. 9 + * 10 + * The SMC91x driver requires at least one of SMC91X_USE_8BIT or 11 + * SMC91X_USE_16BIT to be supported - just setting SMC91X_USE_32BIT is 12 + * an invalid configuration. 13 + */ 4 14 #define SMC91X_USE_8BIT (1 << 0) 5 15 #define SMC91X_USE_16BIT (1 << 1) 6 16 #define SMC91X_USE_32BIT (1 << 2)
+2
include/linux/sysctl.h
··· 43 43 void __user *, size_t *, loff_t *); 44 44 extern int proc_dointvec(struct ctl_table *, int, 45 45 void __user *, size_t *, loff_t *); 46 + extern int proc_douintvec(struct ctl_table *, int, 47 + void __user *, size_t *, loff_t *); 46 48 extern int proc_dointvec_minmax(struct ctl_table *, int, 47 49 void __user *, size_t *, loff_t *); 48 50 extern int proc_dointvec_jiffies(struct ctl_table *, int,
+2
include/net/tcp.h
··· 1521 1521 { 1522 1522 if (sk->sk_send_head == skb_unlinked) 1523 1523 sk->sk_send_head = NULL; 1524 + if (tcp_sk(sk)->highest_sack == skb_unlinked) 1525 + tcp_sk(sk)->highest_sack = NULL; 1524 1526 } 1525 1527 1526 1528 static inline void tcp_init_send_head(struct sock *sk)
+3 -8
include/rdma/ib_verbs.h
··· 2115 2115 size_t len) 2116 2116 { 2117 2117 const void __user *p = udata->inbuf + offset; 2118 - bool ret = false; 2118 + bool ret; 2119 2119 u8 *buf; 2120 2120 2121 2121 if (len > USHRT_MAX) 2122 2122 return false; 2123 2123 2124 - buf = kmalloc(len, GFP_KERNEL); 2125 - if (!buf) 2124 + buf = memdup_user(p, len); 2125 + if (IS_ERR(buf)) 2126 2126 return false; 2127 2127 2128 - if (copy_from_user(buf, p, len)) 2129 - goto free; 2130 - 2131 2128 ret = !memchr_inv(buf, 0, len); 2132 - 2133 - free: 2134 2129 kfree(buf); 2135 2130 return ret; 2136 2131 }
+1
include/uapi/linux/atm_zatm.h
··· 14 14 15 15 #include <linux/atmapi.h> 16 16 #include <linux/atmioc.h> 17 + #include <linux/time.h> 17 18 18 19 #define ZATM_GETPOOL _IOW('a',ATMIOC_SARPRV+1,struct atmif_sioc) 19 20 /* get pool statistics */
+2 -1
include/uapi/linux/if_pppol2tp.h
··· 16 16 #define _UAPI__LINUX_IF_PPPOL2TP_H 17 17 18 18 #include <linux/types.h> 19 - 19 + #include <linux/in.h> 20 + #include <linux/in6.h> 20 21 21 22 /* Structure used to connect() the socket to a particular tunnel UDP 22 23 * socket over IPv4.
+3
include/uapi/linux/if_pppox.h
··· 21 21 #include <asm/byteorder.h> 22 22 23 23 #include <linux/socket.h> 24 + #include <linux/if.h> 24 25 #include <linux/if_ether.h> 25 26 #include <linux/if_pppol2tp.h> 27 + #include <linux/in.h> 28 + #include <linux/in6.h> 26 29 27 30 /* For user-space programs to pick up these definitions 28 31 * which they wouldn't get otherwise without defining __KERNEL__
+3
include/uapi/linux/if_tunnel.h
··· 2 2 #define _UAPI_IF_TUNNEL_H_ 3 3 4 4 #include <linux/types.h> 5 + #include <linux/if.h> 6 + #include <linux/ip.h> 7 + #include <linux/in6.h> 5 8 #include <asm/byteorder.h> 6 9 7 10
+12 -1
include/uapi/linux/ipx.h
··· 1 1 #ifndef _IPX_H_ 2 2 #define _IPX_H_ 3 + #include <linux/libc-compat.h> /* for compatibility with glibc netipx/ipx.h */ 3 4 #include <linux/types.h> 4 5 #include <linux/sockios.h> 5 6 #include <linux/socket.h> 6 7 #define IPX_NODE_LEN 6 7 8 #define IPX_MTU 576 8 9 10 + #if __UAPI_DEF_SOCKADDR_IPX 9 11 struct sockaddr_ipx { 10 12 __kernel_sa_family_t sipx_family; 11 13 __be16 sipx_port; ··· 16 14 __u8 sipx_type; 17 15 unsigned char sipx_zero; /* 16 byte fill */ 18 16 }; 17 + #endif /* __UAPI_DEF_SOCKADDR_IPX */ 19 18 20 19 /* 21 20 * So we can fit the extra info for SIOCSIFADDR into the address nicely ··· 26 23 #define IPX_DLTITF 0 27 24 #define IPX_CRTITF 1 28 25 26 + #if __UAPI_DEF_IPX_ROUTE_DEFINITION 29 27 struct ipx_route_definition { 30 28 __be32 ipx_network; 31 29 __be32 ipx_router_network; 32 30 unsigned char ipx_router_node[IPX_NODE_LEN]; 33 31 }; 32 + #endif /* __UAPI_DEF_IPX_ROUTE_DEFINITION */ 34 33 34 + #if __UAPI_DEF_IPX_INTERFACE_DEFINITION 35 35 struct ipx_interface_definition { 36 36 __be32 ipx_network; 37 37 unsigned char ipx_device[16]; ··· 51 45 #define IPX_INTERNAL 2 52 46 unsigned char ipx_node[IPX_NODE_LEN]; 53 47 }; 54 - 48 + #endif /* __UAPI_DEF_IPX_INTERFACE_DEFINITION */ 49 + 50 + #if __UAPI_DEF_IPX_CONFIG_DATA 55 51 struct ipx_config_data { 56 52 unsigned char ipxcfg_auto_select_primary; 57 53 unsigned char ipxcfg_auto_create_interfaces; 58 54 }; 55 + #endif /* __UAPI_DEF_IPX_CONFIG_DATA */ 59 56 60 57 /* 61 58 * OLD Route Definition for backward compatibility. 62 59 */ 63 60 61 + #if __UAPI_DEF_IPX_ROUTE_DEF 64 62 struct ipx_route_def { 65 63 __be32 ipx_network; 66 64 __be32 ipx_router_network; ··· 77 67 #define IPX_RT_BLUEBOOK 2 78 68 #define IPX_RT_ROUTED 1 79 69 }; 70 + #endif /* __UAPI_DEF_IPX_ROUTE_DEF */ 80 71 81 72 #define SIOCAIPXITFCRT (SIOCPROTOPRIVATE) 82 73 #define SIOCAIPXPRISLT (SIOCPROTOPRIVATE + 1)
+26
include/uapi/linux/libc-compat.h
··· 139 139 140 140 #endif /* _NETINET_IN_H */ 141 141 142 + /* Coordinate with glibc netipx/ipx.h header. */ 143 + #if defined(__NETIPX_IPX_H) 144 + 145 + #define __UAPI_DEF_SOCKADDR_IPX 0 146 + #define __UAPI_DEF_IPX_ROUTE_DEFINITION 0 147 + #define __UAPI_DEF_IPX_INTERFACE_DEFINITION 0 148 + #define __UAPI_DEF_IPX_CONFIG_DATA 0 149 + #define __UAPI_DEF_IPX_ROUTE_DEF 0 150 + 151 + #else /* defined(__NETIPX_IPX_H) */ 152 + 153 + #define __UAPI_DEF_SOCKADDR_IPX 1 154 + #define __UAPI_DEF_IPX_ROUTE_DEFINITION 1 155 + #define __UAPI_DEF_IPX_INTERFACE_DEFINITION 1 156 + #define __UAPI_DEF_IPX_CONFIG_DATA 1 157 + #define __UAPI_DEF_IPX_ROUTE_DEF 1 158 + 159 + #endif /* defined(__NETIPX_IPX_H) */ 160 + 142 161 /* Definitions for xattr.h */ 143 162 #if defined(_SYS_XATTR_H) 144 163 #define __UAPI_DEF_XATTR 0 ··· 197 178 #define __UAPI_DEF_IPV6_OPTIONS 1 198 179 #define __UAPI_DEF_IN6_PKTINFO 1 199 180 #define __UAPI_DEF_IP6_MTUINFO 1 181 + 182 + /* Definitions for ipx.h */ 183 + #define __UAPI_DEF_SOCKADDR_IPX 1 184 + #define __UAPI_DEF_IPX_ROUTE_DEFINITION 1 185 + #define __UAPI_DEF_IPX_INTERFACE_DEFINITION 1 186 + #define __UAPI_DEF_IPX_CONFIG_DATA 1 187 + #define __UAPI_DEF_IPX_ROUTE_DEF 1 200 188 201 189 /* Definitions for xattr.h */ 202 190 #define __UAPI_DEF_XATTR 1
+3 -3
include/uapi/linux/openvswitch.h
··· 583 583 #define OVS_USERSPACE_ATTR_MAX (__OVS_USERSPACE_ATTR_MAX - 1) 584 584 585 585 struct ovs_action_trunc { 586 - uint32_t max_len; /* Max packet size in bytes. */ 586 + __u32 max_len; /* Max packet size in bytes. */ 587 587 }; 588 588 589 589 /** ··· 632 632 * @hash_basis: basis used for computing hash. 633 633 */ 634 634 struct ovs_action_hash { 635 - uint32_t hash_alg; /* One of ovs_hash_alg. */ 636 - uint32_t hash_basis; 635 + __u32 hash_alg; /* One of ovs_hash_alg. */ 636 + __u32 hash_basis; 637 637 }; 638 638 639 639 /**
+2 -2
include/xen/xen-ops.h
··· 9 9 10 10 DECLARE_PER_CPU(struct vcpu_info *, xen_vcpu); 11 11 12 - DECLARE_PER_CPU(int, xen_vcpu_id); 13 - static inline int xen_vcpu_nr(int cpu) 12 + DECLARE_PER_CPU(uint32_t, xen_vcpu_id); 13 + static inline uint32_t xen_vcpu_nr(int cpu) 14 14 { 15 15 return per_cpu(xen_vcpu_id, cpu); 16 16 }
+69 -28
kernel/events/core.c
··· 242 242 return ret; 243 243 } 244 244 245 - static void event_function_local(struct perf_event *event, event_f func, void *data) 246 - { 247 - struct event_function_struct efs = { 248 - .event = event, 249 - .func = func, 250 - .data = data, 251 - }; 252 - 253 - int ret = event_function(&efs); 254 - WARN_ON_ONCE(ret); 255 - } 256 - 257 245 static void event_function_call(struct perf_event *event, event_f func, void *data) 258 246 { 259 247 struct perf_event_context *ctx = event->ctx; ··· 289 301 } 290 302 func(event, NULL, ctx, data); 291 303 raw_spin_unlock_irq(&ctx->lock); 304 + } 305 + 306 + /* 307 + * Similar to event_function_call() + event_function(), but hard assumes IRQs 308 + * are already disabled and we're on the right CPU. 309 + */ 310 + static void event_function_local(struct perf_event *event, event_f func, void *data) 311 + { 312 + struct perf_event_context *ctx = event->ctx; 313 + struct perf_cpu_context *cpuctx = __get_cpu_context(ctx); 314 + struct task_struct *task = READ_ONCE(ctx->task); 315 + struct perf_event_context *task_ctx = NULL; 316 + 317 + WARN_ON_ONCE(!irqs_disabled()); 318 + 319 + if (task) { 320 + if (task == TASK_TOMBSTONE) 321 + return; 322 + 323 + task_ctx = ctx; 324 + } 325 + 326 + perf_ctx_lock(cpuctx, task_ctx); 327 + 328 + task = ctx->task; 329 + if (task == TASK_TOMBSTONE) 330 + goto unlock; 331 + 332 + if (task) { 333 + /* 334 + * We must be either inactive or active and the right task, 335 + * otherwise we're screwed, since we cannot IPI to somewhere 336 + * else. 337 + */ 338 + if (ctx->is_active) { 339 + if (WARN_ON_ONCE(task != current)) 340 + goto unlock; 341 + 342 + if (WARN_ON_ONCE(cpuctx->task_ctx != ctx)) 343 + goto unlock; 344 + } 345 + } else { 346 + WARN_ON_ONCE(&cpuctx->ctx != ctx); 347 + } 348 + 349 + func(event, cpuctx, ctx, data); 350 + unlock: 351 + perf_ctx_unlock(cpuctx, task_ctx); 292 352 } 293 353 294 354 #define PERF_FLAG_ALL (PERF_FLAG_FD_NO_GROUP |\ ··· 3549 3513 .group = group, 3550 3514 .ret = 0, 3551 3515 }; 3552 - smp_call_function_single(event->oncpu, 3553 - __perf_event_read, &data, 1); 3554 - ret = data.ret; 3516 + ret = smp_call_function_single(event->oncpu, __perf_event_read, &data, 1); 3517 + /* The event must have been read from an online CPU: */ 3518 + WARN_ON_ONCE(ret); 3519 + ret = ret ? : data.ret; 3555 3520 } else if (event->state == PERF_EVENT_STATE_INACTIVE) { 3556 3521 struct perf_event_context *ctx = event->ctx; 3557 3522 unsigned long flags; ··· 6166 6129 { 6167 6130 struct perf_event *event = info; 6168 6131 struct pmu *pmu = event->pmu; 6169 - struct perf_cpu_context *cpuctx = get_cpu_ptr(pmu->pmu_cpu_context); 6132 + struct perf_cpu_context *cpuctx = this_cpu_ptr(pmu->pmu_cpu_context); 6170 6133 struct remote_output ro = { 6171 6134 .rb = event->rb, 6172 6135 }; ··· 6621 6584 } 6622 6585 6623 6586 /* 6624 - * Whether this @filter depends on a dynamic object which is not loaded 6625 - * yet or its load addresses are not known. 6626 - */ 6627 - static bool perf_addr_filter_needs_mmap(struct perf_addr_filter *filter) 6628 - { 6629 - return filter->filter && filter->inode; 6630 - } 6631 - 6632 - /* 6633 6587 * Check whether inode and address range match filter criteria. 6634 6588 */ 6635 6589 static bool perf_addr_filter_match(struct perf_addr_filter *filter, ··· 6680 6652 { 6681 6653 struct perf_event_context *ctx; 6682 6654 int ctxn; 6655 + 6656 + /* 6657 + * Data tracing isn't supported yet and as such there is no need 6658 + * to keep track of anything that isn't related to executable code: 6659 + */ 6660 + if (!(vma->vm_flags & VM_EXEC)) 6661 + return; 6683 6662 6684 6663 rcu_read_lock(); 6685 6664 for_each_task_context_nr(ctxn) { ··· 7840 7805 list_for_each_entry(filter, &ifh->list, entry) { 7841 7806 event->addr_filters_offs[count] = 0; 7842 7807 7843 - if (perf_addr_filter_needs_mmap(filter)) 7808 + /* 7809 + * Adjust base offset if the filter is associated to a binary 7810 + * that needs to be mapped: 7811 + */ 7812 + if (filter->inode) 7844 7813 event->addr_filters_offs[count] = 7845 7814 perf_addr_filter_apply(filter, mm); 7846 7815 ··· 7975 7936 goto fail; 7976 7937 } 7977 7938 7978 - if (token == IF_SRC_FILE) { 7979 - filename = match_strdup(&args[2]); 7939 + if (token == IF_SRC_FILE || token == IF_SRC_FILEADDR) { 7940 + int fpos = filter->range ? 2 : 1; 7941 + 7942 + filename = match_strdup(&args[fpos]); 7980 7943 if (!filename) { 7981 7944 ret = -ENOMEM; 7982 7945 goto fail;
+3 -2
kernel/events/uprobes.c
··· 172 172 mmu_notifier_invalidate_range_start(mm, mmun_start, mmun_end); 173 173 err = -EAGAIN; 174 174 ptep = page_check_address(page, mm, addr, &ptl, 0); 175 - if (!ptep) 175 + if (!ptep) { 176 + mem_cgroup_cancel_charge(kpage, memcg, false); 176 177 goto unlock; 178 + } 177 179 178 180 get_page(kpage); 179 181 page_add_new_anon_rmap(kpage, vma, addr, false); ··· 202 200 203 201 err = 0; 204 202 unlock: 205 - mem_cgroup_cancel_charge(kpage, memcg, false); 206 203 mmu_notifier_invalidate_range_end(mm, mmun_start, mmun_end); 207 204 unlock_page(page); 208 205 return err;
+2
kernel/irq/affinity.c
··· 39 39 return NULL; 40 40 } 41 41 42 + get_online_cpus(); 42 43 if (max_vecs >= num_online_cpus()) { 43 44 cpumask_copy(affinity_mask, cpu_online_mask); 44 45 *nr_vecs = num_online_cpus(); ··· 57 56 } 58 57 *nr_vecs = vecs; 59 58 } 59 + put_online_cpus(); 60 60 61 61 return affinity_mask; 62 62 }
+11
kernel/irq/chip.c
··· 820 820 desc->name = name; 821 821 822 822 if (handle != handle_bad_irq && is_chained) { 823 + /* 824 + * We're about to start this interrupt immediately, 825 + * hence the need to set the trigger configuration. 826 + * But the .set_type callback may have overridden the 827 + * flow handler, ignoring that we're dealing with a 828 + * chained interrupt. Reset it immediately because we 829 + * do know better. 830 + */ 831 + __irq_set_trigger(desc, irqd_get_trigger_type(&desc->irq_data)); 832 + desc->handle_irq = handle; 833 + 823 834 irq_settings_set_noprobe(desc); 824 835 irq_settings_set_norequest(desc); 825 836 irq_settings_set_nothread(desc);
+6 -2
kernel/irq/manage.c
··· 1681 1681 action->dev_id = dev_id; 1682 1682 1683 1683 retval = irq_chip_pm_get(&desc->irq_data); 1684 - if (retval < 0) 1684 + if (retval < 0) { 1685 + kfree(action); 1685 1686 return retval; 1687 + } 1686 1688 1687 1689 chip_bus_lock(desc); 1688 1690 retval = __setup_irq(irq, desc, action); ··· 1987 1985 action->percpu_dev_id = dev_id; 1988 1986 1989 1987 retval = irq_chip_pm_get(&desc->irq_data); 1990 - if (retval < 0) 1988 + if (retval < 0) { 1989 + kfree(action); 1991 1990 return retval; 1991 + } 1992 1992 1993 1993 chip_bus_lock(desc); 1994 1994 retval = __setup_irq(irq, desc, action);
+5 -5
kernel/power/snapshot.c
··· 835 835 */ 836 836 static bool rtree_next_node(struct memory_bitmap *bm) 837 837 { 838 - bm->cur.node = list_entry(bm->cur.node->list.next, 839 - struct rtree_node, list); 840 - if (&bm->cur.node->list != &bm->cur.zone->leaves) { 838 + if (!list_is_last(&bm->cur.node->list, &bm->cur.zone->leaves)) { 839 + bm->cur.node = list_entry(bm->cur.node->list.next, 840 + struct rtree_node, list); 841 841 bm->cur.node_pfn += BM_BITS_PER_BLOCK; 842 842 bm->cur.node_bit = 0; 843 843 touch_softlockup_watchdog(); ··· 845 845 } 846 846 847 847 /* No more nodes, goto next zone */ 848 - bm->cur.zone = list_entry(bm->cur.zone->list.next, 848 + if (!list_is_last(&bm->cur.zone->list, &bm->zones)) { 849 + bm->cur.zone = list_entry(bm->cur.zone->list.next, 849 850 struct mem_zone_bm_rtree, list); 850 - if (&bm->cur.zone->list != &bm->zones) { 851 851 bm->cur.node = list_entry(bm->cur.zone->leaves.next, 852 852 struct rtree_node, list); 853 853 bm->cur.node_pfn = 0;
+2 -2
kernel/printk/braille.c
··· 9 9 10 10 char *_braille_console_setup(char **str, char **brl_options) 11 11 { 12 - if (!memcmp(*str, "brl,", 4)) { 12 + if (!strncmp(*str, "brl,", 4)) { 13 13 *brl_options = ""; 14 14 *str += 4; 15 - } else if (!memcmp(str, "brl=", 4)) { 15 + } else if (!strncmp(*str, "brl=", 4)) { 16 16 *brl_options = *str + 4; 17 17 *str = strchr(*brl_options, ','); 18 18 if (!*str)
+25 -8
kernel/sched/cputime.c
··· 263 263 cpustat[CPUTIME_IDLE] += (__force u64) cputime; 264 264 } 265 265 266 + /* 267 + * When a guest is interrupted for a longer amount of time, missed clock 268 + * ticks are not redelivered later. Due to that, this function may on 269 + * occasion account more time than the calling functions think elapsed. 270 + */ 266 271 static __always_inline cputime_t steal_account_process_time(cputime_t maxtime) 267 272 { 268 273 #ifdef CONFIG_PARAVIRT ··· 376 371 * idle, or potentially user or system time. Due to rounding, 377 372 * other time can exceed ticks occasionally. 378 373 */ 379 - other = account_other_time(cputime); 374 + other = account_other_time(ULONG_MAX); 380 375 if (other >= cputime) 381 376 return; 382 377 cputime -= other; ··· 491 486 } 492 487 493 488 cputime = cputime_one_jiffy; 494 - steal = steal_account_process_time(cputime); 489 + steal = steal_account_process_time(ULONG_MAX); 495 490 496 491 if (steal >= cputime) 497 492 return; ··· 521 516 } 522 517 523 518 cputime = jiffies_to_cputime(ticks); 524 - steal = steal_account_process_time(cputime); 519 + steal = steal_account_process_time(ULONG_MAX); 525 520 526 521 if (steal >= cputime) 527 522 return; ··· 619 614 stime = curr->stime; 620 615 utime = curr->utime; 621 616 622 - if (utime == 0) { 623 - stime = rtime; 617 + /* 618 + * If either stime or both stime and utime are 0, assume all runtime is 619 + * userspace. Once a task gets some ticks, the monotonicy code at 620 + * 'update' will ensure things converge to the observed ratio. 621 + */ 622 + if (stime == 0) { 623 + utime = rtime; 624 624 goto update; 625 625 } 626 626 627 - if (stime == 0) { 628 - utime = rtime; 627 + if (utime == 0) { 628 + stime = rtime; 629 629 goto update; 630 630 } 631 631 632 632 stime = scale_stime((__force u64)stime, (__force u64)rtime, 633 633 (__force u64)(stime + utime)); 634 634 635 + update: 635 636 /* 636 637 * Make sure stime doesn't go backwards; this preserves monotonicity 637 638 * for utime because rtime is monotonic. ··· 660 649 stime = rtime - utime; 661 650 } 662 651 663 - update: 664 652 prev->stime = stime; 665 653 prev->utime = utime; 666 654 out: ··· 704 694 unsigned long now = READ_ONCE(jiffies); 705 695 cputime_t delta, other; 706 696 697 + /* 698 + * Unlike tick based timing, vtime based timing never has lost 699 + * ticks, and no need for steal time accounting to make up for 700 + * lost ticks. Vtime accounts a rounded version of actual 701 + * elapsed time. Limit account_other_time to prevent rounding 702 + * errors from causing elapsed vtime to go negative. 703 + */ 707 704 delta = jiffies_to_cputime(now - tsk->vtime_snap); 708 705 other = account_other_time(delta); 709 706 WARN_ON_ONCE(tsk->vtime_snap_whence == VTIME_INACTIVE);
+43 -2
kernel/sysctl.c
··· 2140 2140 return 0; 2141 2141 } 2142 2142 2143 + static int do_proc_douintvec_conv(bool *negp, unsigned long *lvalp, 2144 + int *valp, 2145 + int write, void *data) 2146 + { 2147 + if (write) { 2148 + if (*negp) 2149 + return -EINVAL; 2150 + *valp = *lvalp; 2151 + } else { 2152 + unsigned int val = *valp; 2153 + *lvalp = (unsigned long)val; 2154 + } 2155 + return 0; 2156 + } 2157 + 2143 2158 static const char proc_wspace_sep[] = { ' ', '\t', '\n' }; 2144 2159 2145 2160 static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table, ··· 2274 2259 int proc_dointvec(struct ctl_table *table, int write, 2275 2260 void __user *buffer, size_t *lenp, loff_t *ppos) 2276 2261 { 2277 - return do_proc_dointvec(table,write,buffer,lenp,ppos, 2278 - NULL,NULL); 2262 + return do_proc_dointvec(table, write, buffer, lenp, ppos, NULL, NULL); 2263 + } 2264 + 2265 + /** 2266 + * proc_douintvec - read a vector of unsigned integers 2267 + * @table: the sysctl table 2268 + * @write: %TRUE if this is a write to the sysctl file 2269 + * @buffer: the user buffer 2270 + * @lenp: the size of the user buffer 2271 + * @ppos: file position 2272 + * 2273 + * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer 2274 + * values from/to the user buffer, treated as an ASCII string. 2275 + * 2276 + * Returns 0 on success. 2277 + */ 2278 + int proc_douintvec(struct ctl_table *table, int write, 2279 + void __user *buffer, size_t *lenp, loff_t *ppos) 2280 + { 2281 + return do_proc_dointvec(table, write, buffer, lenp, ppos, 2282 + do_proc_douintvec_conv, NULL); 2279 2283 } 2280 2284 2281 2285 /* ··· 2892 2858 return -ENOSYS; 2893 2859 } 2894 2860 2861 + int proc_douintvec(struct ctl_table *table, int write, 2862 + void __user *buffer, size_t *lenp, loff_t *ppos) 2863 + { 2864 + return -ENOSYS; 2865 + } 2866 + 2895 2867 int proc_dointvec_minmax(struct ctl_table *table, int write, 2896 2868 void __user *buffer, size_t *lenp, loff_t *ppos) 2897 2869 { ··· 2943 2903 * exception granted :-) 2944 2904 */ 2945 2905 EXPORT_SYMBOL(proc_dointvec); 2906 + EXPORT_SYMBOL(proc_douintvec); 2946 2907 EXPORT_SYMBOL(proc_dointvec_jiffies); 2947 2908 EXPORT_SYMBOL(proc_dointvec_minmax); 2948 2909 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
+4 -1
kernel/time/timekeeping.c
··· 401 401 do { 402 402 seq = raw_read_seqcount_latch(&tkf->seq); 403 403 tkr = tkf->base + (seq & 0x01); 404 - now = ktime_to_ns(tkr->base) + timekeeping_get_ns(tkr); 404 + now = ktime_to_ns(tkr->base); 405 + 406 + now += clocksource_delta(tkr->read(tkr->clock), 407 + tkr->cycle_last, tkr->mask); 405 408 } while (read_seqcount_retry(&tkf->seq, seq)); 406 409 407 410 return now;
+7 -2
kernel/time/timekeeping_debug.c
··· 23 23 24 24 #include "timekeeping_internal.h" 25 25 26 - static unsigned int sleep_time_bin[32] = {0}; 26 + #define NUM_BINS 32 27 + 28 + static unsigned int sleep_time_bin[NUM_BINS] = {0}; 27 29 28 30 static int tk_debug_show_sleep_time(struct seq_file *s, void *data) 29 31 { ··· 71 69 72 70 void tk_debug_account_sleep_time(struct timespec64 *t) 73 71 { 74 - sleep_time_bin[fls(t->tv_sec)]++; 72 + /* Cap bin index so we don't overflow the array */ 73 + int bin = min(fls(t->tv_sec), NUM_BINS-1); 74 + 75 + sleep_time_bin[bin]++; 75 76 } 76 77
+1 -1
kernel/trace/blktrace.c
··· 223 223 what |= MASK_TC_BIT(op_flags, META); 224 224 what |= MASK_TC_BIT(op_flags, PREFLUSH); 225 225 what |= MASK_TC_BIT(op_flags, FUA); 226 - if (op == REQ_OP_DISCARD) 226 + if (op == REQ_OP_DISCARD || op == REQ_OP_SECURE_ERASE) 227 227 what |= BLK_TC_ACT(BLK_TC_DISCARD); 228 228 if (op == REQ_OP_FLUSH) 229 229 what |= BLK_TC_ACT(BLK_TC_FLUSH);
+4 -3
lib/rhashtable.c
··· 77 77 size = min_t(unsigned int, size, tbl->size >> 1); 78 78 79 79 if (sizeof(spinlock_t) != 0) { 80 + tbl->locks = NULL; 80 81 #ifdef CONFIG_NUMA 81 82 if (size * sizeof(spinlock_t) > PAGE_SIZE && 82 83 gfp == GFP_KERNEL) 83 84 tbl->locks = vmalloc(size * sizeof(spinlock_t)); 84 - else 85 85 #endif 86 86 if (gfp != GFP_KERNEL) 87 87 gfp |= __GFP_NOWARN | __GFP_NORETRY; 88 88 89 - tbl->locks = kmalloc_array(size, sizeof(spinlock_t), 90 - gfp); 89 + if (!tbl->locks) 90 + tbl->locks = kmalloc_array(size, sizeof(spinlock_t), 91 + gfp); 91 92 if (!tbl->locks) 92 93 return -ENOMEM; 93 94 for (i = 0; i < size; i++)
+8 -1
mm/Kconfig
··· 262 262 select MIGRATION 263 263 depends on MMU 264 264 help 265 - Allows the compaction of memory for the allocation of huge pages. 265 + Compaction is the only memory management component to form 266 + high order (larger physically contiguous) memory blocks 267 + reliably. The page allocator relies on compaction heavily and 268 + the lack of the feature can lead to unexpected OOM killer 269 + invocations for high order memory requests. You shouldn't 270 + disable this option unless there really is a strong reason for 271 + it and then we would be really interested to hear about that at 272 + linux-mm@kvack.org. 266 273 267 274 # 268 275 # support for page migration
+6 -1
mm/huge_memory.c
··· 1512 1512 struct page *page; 1513 1513 pgtable_t pgtable; 1514 1514 pmd_t _pmd; 1515 - bool young, write, dirty; 1515 + bool young, write, dirty, soft_dirty; 1516 1516 unsigned long addr; 1517 1517 int i; 1518 1518 ··· 1546 1546 write = pmd_write(*pmd); 1547 1547 young = pmd_young(*pmd); 1548 1548 dirty = pmd_dirty(*pmd); 1549 + soft_dirty = pmd_soft_dirty(*pmd); 1549 1550 1550 1551 pmdp_huge_split_prepare(vma, haddr, pmd); 1551 1552 pgtable = pgtable_trans_huge_withdraw(mm, pmd); ··· 1563 1562 swp_entry_t swp_entry; 1564 1563 swp_entry = make_migration_entry(page + i, write); 1565 1564 entry = swp_entry_to_pte(swp_entry); 1565 + if (soft_dirty) 1566 + entry = pte_swp_mksoft_dirty(entry); 1566 1567 } else { 1567 1568 entry = mk_pte(page + i, vma->vm_page_prot); 1568 1569 entry = maybe_mkwrite(entry, vma); ··· 1572 1569 entry = pte_wrprotect(entry); 1573 1570 if (!young) 1574 1571 entry = pte_mkold(entry); 1572 + if (soft_dirty) 1573 + entry = pte_mksoft_dirty(entry); 1575 1574 } 1576 1575 if (dirty) 1577 1576 SetPageDirty(page + i);
+18 -18
mm/memcontrol.c
··· 4082 4082 atomic_add(n, &memcg->id.ref); 4083 4083 } 4084 4084 4085 - static struct mem_cgroup *mem_cgroup_id_get_online(struct mem_cgroup *memcg) 4086 - { 4087 - while (!atomic_inc_not_zero(&memcg->id.ref)) { 4088 - /* 4089 - * The root cgroup cannot be destroyed, so it's refcount must 4090 - * always be >= 1. 4091 - */ 4092 - if (WARN_ON_ONCE(memcg == root_mem_cgroup)) { 4093 - VM_BUG_ON(1); 4094 - break; 4095 - } 4096 - memcg = parent_mem_cgroup(memcg); 4097 - if (!memcg) 4098 - memcg = root_mem_cgroup; 4099 - } 4100 - return memcg; 4101 - } 4102 - 4103 4085 static void mem_cgroup_id_put_many(struct mem_cgroup *memcg, unsigned int n) 4104 4086 { 4105 4087 if (atomic_sub_and_test(n, &memcg->id.ref)) { ··· 5803 5821 subsys_initcall(mem_cgroup_init); 5804 5822 5805 5823 #ifdef CONFIG_MEMCG_SWAP 5824 + static struct mem_cgroup *mem_cgroup_id_get_online(struct mem_cgroup *memcg) 5825 + { 5826 + while (!atomic_inc_not_zero(&memcg->id.ref)) { 5827 + /* 5828 + * The root cgroup cannot be destroyed, so it's refcount must 5829 + * always be >= 1. 5830 + */ 5831 + if (WARN_ON_ONCE(memcg == root_mem_cgroup)) { 5832 + VM_BUG_ON(1); 5833 + break; 5834 + } 5835 + memcg = parent_mem_cgroup(memcg); 5836 + if (!memcg) 5837 + memcg = root_mem_cgroup; 5838 + } 5839 + return memcg; 5840 + } 5841 + 5806 5842 /** 5807 5843 * mem_cgroup_swapout - transfer a memsw charge to swap 5808 5844 * @page: page whose memsw charge to transfer
+9
mm/readahead.c
··· 8 8 */ 9 9 10 10 #include <linux/kernel.h> 11 + #include <linux/dax.h> 11 12 #include <linux/gfp.h> 12 13 #include <linux/export.h> 13 14 #include <linux/blkdev.h> ··· 544 543 { 545 544 if (!mapping || !mapping->a_ops) 546 545 return -EINVAL; 546 + 547 + /* 548 + * Readahead doesn't make sense for DAX inodes, but we don't want it 549 + * to report a failure either. Instead, we just return success and 550 + * don't do any work. 551 + */ 552 + if (dax_mapping(mapping)) 553 + return 0; 547 554 548 555 return force_page_cache_readahead(mapping, filp, index, nr); 549 556 }
+2 -2
mm/usercopy.c
··· 83 83 unsigned long check_high = check_low + n; 84 84 85 85 /* Does not overlap if entirely above or entirely below. */ 86 - if (check_low >= high || check_high < low) 86 + if (check_low >= high || check_high <= low) 87 87 return false; 88 88 89 89 return true; ··· 124 124 static inline const char *check_bogus_address(const void *ptr, unsigned long n) 125 125 { 126 126 /* Reject if object wraps past end of memory. */ 127 - if (ptr + n < ptr) 127 + if ((unsigned long)ptr + n < (unsigned long)ptr) 128 128 return "<wrapped address>"; 129 129 130 130 /* Reject if NULL or ZERO-allocation. */
+1 -1
net/bluetooth/af_bluetooth.c
··· 250 250 251 251 skb_free_datagram(sk, skb); 252 252 253 - if (msg->msg_flags & MSG_TRUNC) 253 + if (flags & MSG_TRUNC) 254 254 copied = skblen; 255 255 256 256 return err ? : copied;
+2
net/bluetooth/hci_request.c
··· 262 262 break; 263 263 } 264 264 265 + kfree_skb(hdev->req_skb); 266 + hdev->req_skb = NULL; 265 267 hdev->req_status = hdev->req_result = 0; 266 268 267 269 BT_DBG("%s end: err %d", hdev->name, err);
+1 -1
net/bluetooth/hci_sock.c
··· 1091 1091 1092 1092 skb_free_datagram(sk, skb); 1093 1093 1094 - if (msg->msg_flags & MSG_TRUNC) 1094 + if (flags & MSG_TRUNC) 1095 1095 copied = skblen; 1096 1096 1097 1097 return err ? : copied;
+8
net/bluetooth/l2cap_core.c
··· 32 32 33 33 #include <linux/debugfs.h> 34 34 #include <linux/crc16.h> 35 + #include <linux/filter.h> 35 36 36 37 #include <net/bluetooth/bluetooth.h> 37 38 #include <net/bluetooth/hci_core.h> ··· 5836 5835 if (chan->sdu) 5837 5836 break; 5838 5837 5838 + if (!pskb_may_pull(skb, L2CAP_SDULEN_SIZE)) 5839 + break; 5840 + 5839 5841 chan->sdu_len = get_unaligned_le16(skb->data); 5840 5842 skb_pull(skb, L2CAP_SDULEN_SIZE); 5841 5843 ··· 6613 6609 l2cap_send_disconn_req(chan, ECONNRESET); 6614 6610 goto drop; 6615 6611 } 6612 + 6613 + if ((chan->mode == L2CAP_MODE_ERTM || 6614 + chan->mode == L2CAP_MODE_STREAMING) && sk_filter(chan->data, skb)) 6615 + goto drop; 6616 6616 6617 6617 if (!control->sframe) { 6618 6618 int err;
+12 -2
net/bluetooth/l2cap_sock.c
··· 1019 1019 goto done; 1020 1020 1021 1021 if (pi->rx_busy_skb) { 1022 - if (!sock_queue_rcv_skb(sk, pi->rx_busy_skb)) 1022 + if (!__sock_queue_rcv_skb(sk, pi->rx_busy_skb)) 1023 1023 pi->rx_busy_skb = NULL; 1024 1024 else 1025 1025 goto done; ··· 1270 1270 goto done; 1271 1271 } 1272 1272 1273 - err = sock_queue_rcv_skb(sk, skb); 1273 + if (chan->mode != L2CAP_MODE_ERTM && 1274 + chan->mode != L2CAP_MODE_STREAMING) { 1275 + /* Even if no filter is attached, we could potentially 1276 + * get errors from security modules, etc. 1277 + */ 1278 + err = sk_filter(sk, skb); 1279 + if (err) 1280 + goto done; 1281 + } 1282 + 1283 + err = __sock_queue_rcv_skb(sk, skb); 1274 1284 1275 1285 /* For ERTM, handle one skb that doesn't fit into the recv 1276 1286 * buffer. This is important to do because the data frames
+2 -2
net/ipv4/fib_trie.c
··· 249 249 * index into the parent's child array. That is, they will be used to find 250 250 * 'n' among tp's children. 251 251 * 252 - * The bits from (n->pos + n->bits) to (tn->pos - 1) - "S" - are skipped bits 252 + * The bits from (n->pos + n->bits) to (tp->pos - 1) - "S" - are skipped bits 253 253 * for the node n. 254 254 * 255 255 * All the bits we have seen so far are significant to the node n. The rest ··· 258 258 * The bits from (n->pos) to (n->pos + n->bits - 1) - "C" - are the index into 259 259 * n's child array, and will of course be different for each child. 260 260 * 261 - * The rest of the bits, from 0 to (n->pos + n->bits), are completely unknown 261 + * The rest of the bits, from 0 to (n->pos -1) - "u" - are completely unknown 262 262 * at this point. 263 263 */ 264 264
+5 -3
net/ipv4/ip_tunnel_core.c
··· 73 73 skb_dst_set(skb, &rt->dst); 74 74 memset(IPCB(skb), 0, sizeof(*IPCB(skb))); 75 75 76 - if (skb_iif && proto == IPPROTO_UDP) { 77 - /* Arrived from an ingress interface and got udp encapuslated. 78 - * The encapsulated network segment length may exceed dst mtu. 76 + if (skb_iif && !(df & htons(IP_DF))) { 77 + /* Arrived from an ingress interface, got encapsulated, with 78 + * fragmentation of encapulating frames allowed. 79 + * If skb is gso, the resulting encapsulated network segments 80 + * may exceed dst mtu. 79 81 * Allow IP Fragmentation of segments. 80 82 */ 81 83 IPCB(skb)->flags |= IPSKB_FRAG_SEGS;
-2
net/ipv4/tcp.c
··· 3182 3182 local_bh_enable(); 3183 3183 return 0; 3184 3184 } 3185 - sock_gen_put(sk); 3186 3185 return -EOPNOTSUPP; 3187 3186 } 3188 3187 ··· 3210 3211 bh_unlock_sock(sk); 3211 3212 local_bh_enable(); 3212 3213 release_sock(sk); 3213 - sock_put(sk); 3214 3214 return 0; 3215 3215 } 3216 3216 EXPORT_SYMBOL_GPL(tcp_abort);
+6 -1
net/ipv4/tcp_diag.c
··· 54 54 { 55 55 struct net *net = sock_net(in_skb->sk); 56 56 struct sock *sk = inet_diag_find_one_icsk(net, &tcp_hashinfo, req); 57 + int err; 57 58 58 59 if (IS_ERR(sk)) 59 60 return PTR_ERR(sk); 60 61 61 - return sock_diag_destroy(sk, ECONNABORTED); 62 + err = sock_diag_destroy(sk, ECONNABORTED); 63 + 64 + sock_gen_put(sk); 65 + 66 + return err; 62 67 } 63 68 #endif 64 69
+7 -1
net/ipv4/tcp_ipv4.c
··· 814 814 u32 seq = (sk->sk_state == TCP_LISTEN) ? tcp_rsk(req)->snt_isn + 1 : 815 815 tcp_sk(sk)->snd_nxt; 816 816 817 + /* RFC 7323 2.3 818 + * The window field (SEG.WND) of every outgoing segment, with the 819 + * exception of <SYN> segments, MUST be right-shifted by 820 + * Rcv.Wind.Shift bits: 821 + */ 817 822 tcp_v4_send_ack(sock_net(sk), skb, seq, 818 - tcp_rsk(req)->rcv_nxt, req->rsk_rcv_wnd, 823 + tcp_rsk(req)->rcv_nxt, 824 + req->rsk_rcv_wnd >> inet_rsk(req)->rcv_wscale, 819 825 tcp_time_stamp, 820 826 req->ts_recent, 821 827 0,
+6 -7
net/ipv4/udp.c
··· 1183 1183 * @sk: socket 1184 1184 * 1185 1185 * Drops all bad checksum frames, until a valid one is found. 1186 - * Returns the length of found skb, or 0 if none is found. 1186 + * Returns the length of found skb, or -1 if none is found. 1187 1187 */ 1188 - static unsigned int first_packet_length(struct sock *sk) 1188 + static int first_packet_length(struct sock *sk) 1189 1189 { 1190 1190 struct sk_buff_head list_kill, *rcvq = &sk->sk_receive_queue; 1191 1191 struct sk_buff *skb; 1192 - unsigned int res; 1192 + int res; 1193 1193 1194 1194 __skb_queue_head_init(&list_kill); 1195 1195 ··· 1204 1204 __skb_unlink(skb, rcvq); 1205 1205 __skb_queue_tail(&list_kill, skb); 1206 1206 } 1207 - res = skb ? skb->len : 0; 1207 + res = skb ? skb->len : -1; 1208 1208 spin_unlock_bh(&rcvq->lock); 1209 1209 1210 1210 if (!skb_queue_empty(&list_kill)) { ··· 1233 1233 1234 1234 case SIOCINQ: 1235 1235 { 1236 - unsigned int amount = first_packet_length(sk); 1236 + int amount = max_t(int, 0, first_packet_length(sk)); 1237 1237 1238 1238 return put_user(amount, (int __user *)arg); 1239 1239 } ··· 2185 2185 2186 2186 /* Check for false positives due to checksum errors */ 2187 2187 if ((mask & POLLRDNORM) && !(file->f_flags & O_NONBLOCK) && 2188 - !(sk->sk_shutdown & RCV_SHUTDOWN) && !first_packet_length(sk)) 2188 + !(sk->sk_shutdown & RCV_SHUTDOWN) && first_packet_length(sk) == -1) 2189 2189 mask &= ~(POLLIN | POLLRDNORM); 2190 2190 2191 2191 return mask; ··· 2231 2231 .sysctl_wmem = &sysctl_udp_wmem_min, 2232 2232 .sysctl_rmem = &sysctl_udp_rmem_min, 2233 2233 .obj_size = sizeof(struct udp_sock), 2234 - .slab_flags = SLAB_DESTROY_BY_RCU, 2235 2234 .h.udp_table = &udp_table, 2236 2235 #ifdef CONFIG_COMPAT 2237 2236 .compat_setsockopt = compat_udp_setsockopt,
-1
net/ipv4/udplite.c
··· 55 55 .unhash = udp_lib_unhash, 56 56 .get_port = udp_v4_get_port, 57 57 .obj_size = sizeof(struct udp_sock), 58 - .slab_flags = SLAB_DESTROY_BY_RCU, 59 58 .h.udp_table = &udplite_table, 60 59 #ifdef CONFIG_COMPAT 61 60 .compat_setsockopt = compat_udp_setsockopt,
+21 -13
net/ipv6/addrconf.c
··· 1872 1872 1873 1873 void addrconf_dad_failure(struct inet6_ifaddr *ifp) 1874 1874 { 1875 - struct in6_addr addr; 1876 1875 struct inet6_dev *idev = ifp->idev; 1877 1876 struct net *net = dev_net(ifp->idev->dev); 1878 1877 ··· 1933 1934 in6_ifa_put(ifp2); 1934 1935 lock_errdad: 1935 1936 spin_lock_bh(&ifp->lock); 1936 - } else if (idev->cnf.accept_dad > 1 && !idev->cnf.disable_ipv6) { 1937 - addr.s6_addr32[0] = htonl(0xfe800000); 1938 - addr.s6_addr32[1] = 0; 1939 - 1940 - if (!ipv6_generate_eui64(addr.s6_addr + 8, idev->dev) && 1941 - ipv6_addr_equal(&ifp->addr, &addr)) { 1942 - /* DAD failed for link-local based on MAC address */ 1943 - idev->cnf.disable_ipv6 = 1; 1944 - 1945 - pr_info("%s: IPv6 being disabled!\n", 1946 - ifp->idev->dev->name); 1947 - } 1948 1937 } 1949 1938 1950 1939 errdad: ··· 3808 3821 dad_work); 3809 3822 struct inet6_dev *idev = ifp->idev; 3810 3823 struct in6_addr mcaddr; 3824 + bool disable_ipv6 = false; 3811 3825 3812 3826 enum { 3813 3827 DAD_PROCESS, ··· 3825 3837 } else if (ifp->state == INET6_IFADDR_STATE_ERRDAD) { 3826 3838 action = DAD_ABORT; 3827 3839 ifp->state = INET6_IFADDR_STATE_POSTDAD; 3840 + 3841 + if (idev->cnf.accept_dad > 1 && !idev->cnf.disable_ipv6 && 3842 + !(ifp->flags & IFA_F_STABLE_PRIVACY)) { 3843 + struct in6_addr addr; 3844 + 3845 + addr.s6_addr32[0] = htonl(0xfe800000); 3846 + addr.s6_addr32[1] = 0; 3847 + 3848 + if (!ipv6_generate_eui64(addr.s6_addr + 8, idev->dev) && 3849 + ipv6_addr_equal(&ifp->addr, &addr)) { 3850 + /* DAD failed for link-local based on MAC */ 3851 + idev->cnf.disable_ipv6 = 1; 3852 + 3853 + pr_info("%s: IPv6 being disabled!\n", 3854 + ifp->idev->dev->name); 3855 + disable_ipv6 = true; 3856 + } 3857 + } 3828 3858 } 3829 3859 spin_unlock_bh(&ifp->lock); 3830 3860 ··· 3851 3845 goto out; 3852 3846 } else if (action == DAD_ABORT) { 3853 3847 addrconf_dad_stop(ifp, 1); 3848 + if (disable_ipv6) 3849 + addrconf_ifdown(idev->dev, 0); 3854 3850 goto out; 3855 3851 } 3856 3852
+7 -1
net/ipv6/tcp_ipv6.c
··· 945 945 /* sk->sk_state == TCP_LISTEN -> for regular TCP_SYN_RECV 946 946 * sk->sk_state == TCP_SYN_RECV -> for Fast Open. 947 947 */ 948 + /* RFC 7323 2.3 949 + * The window field (SEG.WND) of every outgoing segment, with the 950 + * exception of <SYN> segments, MUST be right-shifted by 951 + * Rcv.Wind.Shift bits: 952 + */ 948 953 tcp_v6_send_ack(sk, skb, (sk->sk_state == TCP_LISTEN) ? 949 954 tcp_rsk(req)->snt_isn + 1 : tcp_sk(sk)->snd_nxt, 950 - tcp_rsk(req)->rcv_nxt, req->rsk_rcv_wnd, 955 + tcp_rsk(req)->rcv_nxt, 956 + req->rsk_rcv_wnd >> inet_rsk(req)->rcv_wscale, 951 957 tcp_time_stamp, req->ts_recent, sk->sk_bound_dev_if, 952 958 tcp_v6_md5_do_lookup(sk, &ipv6_hdr(skb)->daddr), 953 959 0, 0);
-1
net/ipv6/udp.c
··· 1449 1449 .sysctl_wmem = &sysctl_udp_wmem_min, 1450 1450 .sysctl_rmem = &sysctl_udp_rmem_min, 1451 1451 .obj_size = sizeof(struct udp6_sock), 1452 - .slab_flags = SLAB_DESTROY_BY_RCU, 1453 1452 .h.udp_table = &udp_table, 1454 1453 #ifdef CONFIG_COMPAT 1455 1454 .compat_setsockopt = compat_udpv6_setsockopt,
-1
net/ipv6/udplite.c
··· 50 50 .unhash = udp_lib_unhash, 51 51 .get_port = udp_v6_get_port, 52 52 .obj_size = sizeof(struct udp6_sock), 53 - .slab_flags = SLAB_DESTROY_BY_RCU, 54 53 .h.udp_table = &udplite_table, 55 54 #ifdef CONFIG_COMPAT 56 55 .compat_setsockopt = compat_udpv6_setsockopt,
+1 -1
net/l2tp/l2tp_ppp.c
··· 854 854 error = -ENOTCONN; 855 855 if (sk == NULL) 856 856 goto end; 857 - if (sk->sk_state != PPPOX_CONNECTED) 857 + if (!(sk->sk_state & PPPOX_CONNECTED)) 858 858 goto end; 859 859 860 860 error = -EBADF;
+4
net/netfilter/nf_conntrack_standalone.c
··· 205 205 struct nf_conn *ct = nf_ct_tuplehash_to_ctrack(hash); 206 206 const struct nf_conntrack_l3proto *l3proto; 207 207 const struct nf_conntrack_l4proto *l4proto; 208 + struct net *net = seq_file_net(s); 208 209 int ret = 0; 209 210 210 211 NF_CT_ASSERT(ct); ··· 214 213 215 214 /* we only want to print DIR_ORIGINAL */ 216 215 if (NF_CT_DIRECTION(hash)) 216 + goto release; 217 + 218 + if (!net_eq(nf_ct_net(ct), net)) 217 219 goto release; 218 220 219 221 l3proto = __nf_ct_l3proto_find(nf_ct_l3num(ct));
+4
net/netfilter/xt_TPROXY.c
··· 127 127 daddr, dport, 128 128 in->ifindex); 129 129 130 + if (sk && !atomic_inc_not_zero(&sk->sk_refcnt)) 131 + sk = NULL; 130 132 /* NOTE: we return listeners even if bound to 131 133 * 0.0.0.0, those are filtered out in 132 134 * xt_socket, since xt_TPROXY needs 0 bound ··· 197 195 daddr, ntohs(dport), 198 196 in->ifindex); 199 197 198 + if (sk && !atomic_inc_not_zero(&sk->sk_refcnt)) 199 + sk = NULL; 200 200 /* NOTE: we return listeners even if bound to 201 201 * 0.0.0.0, those are filtered out in 202 202 * xt_socket, since xt_TPROXY needs 0 bound
+1 -1
net/netfilter/xt_nfacct.c
··· 26 26 27 27 nfnl_acct_update(skb, info->nfacct); 28 28 29 - overquota = nfnl_acct_overquota(skb, info->nfacct); 29 + overquota = nfnl_acct_overquota(par->net, skb, info->nfacct); 30 30 31 31 return overquota == NFACCT_UNDERQUOTA ? false : true; 32 32 }
+10 -8
net/sched/act_ife.c
··· 53 53 u32 *tlv = (u32 *)(skbdata); 54 54 u16 totlen = nla_total_size(dlen); /*alignment + hdr */ 55 55 char *dptr = (char *)tlv + NLA_HDRLEN; 56 - u32 htlv = attrtype << 16 | totlen; 56 + u32 htlv = attrtype << 16 | dlen; 57 57 58 58 *tlv = htonl(htlv); 59 59 memset(dptr, 0, totlen - NLA_HDRLEN); ··· 135 135 136 136 int ife_validate_meta_u32(void *val, int len) 137 137 { 138 - if (len == 4) 138 + if (len == sizeof(u32)) 139 139 return 0; 140 140 141 141 return -EINVAL; ··· 144 144 145 145 int ife_validate_meta_u16(void *val, int len) 146 146 { 147 - /* length will include padding */ 148 - if (len == NLA_ALIGN(2)) 147 + /* length will not include padding */ 148 + if (len == sizeof(u16)) 149 149 return 0; 150 150 151 151 return -EINVAL; ··· 652 652 u8 *tlvdata = (u8 *)tlv; 653 653 u16 mtype = tlv->type; 654 654 u16 mlen = tlv->len; 655 + u16 alen; 655 656 656 657 mtype = ntohs(mtype); 657 658 mlen = ntohs(mlen); 659 + alen = NLA_ALIGN(mlen); 658 660 659 - if (find_decode_metaid(skb, ife, mtype, (mlen - 4), 660 - (void *)(tlvdata + 4))) { 661 + if (find_decode_metaid(skb, ife, mtype, (mlen - NLA_HDRLEN), 662 + (void *)(tlvdata + NLA_HDRLEN))) { 661 663 /* abuse overlimits to count when we receive metadata 662 664 * but dont have an ops for it 663 665 */ ··· 668 666 ife->tcf_qstats.overlimits++; 669 667 } 670 668 671 - tlvdata += mlen; 672 - ifehdrln -= mlen; 669 + tlvdata += alen; 670 + ifehdrln -= alen; 673 671 tlv = (struct meta_tlvhdr *)tlvdata; 674 672 } 675 673
+5 -4
net/sched/sch_generic.c
··· 641 641 struct Qdisc *sch; 642 642 643 643 if (!try_module_get(ops->owner)) 644 - goto errout; 644 + return NULL; 645 645 646 646 sch = qdisc_alloc(dev_queue, ops); 647 - if (IS_ERR(sch)) 648 - goto errout; 647 + if (IS_ERR(sch)) { 648 + module_put(ops->owner); 649 + return NULL; 650 + } 649 651 sch->parent = parentid; 650 652 651 653 if (!ops->init || ops->init(sch, NULL) == 0) 652 654 return sch; 653 655 654 656 qdisc_destroy(sch); 655 - errout: 656 657 return NULL; 657 658 } 658 659 EXPORT_SYMBOL(qdisc_create_dflt);
+7 -4
net/sctp/input.c
··· 119 119 skb_transport_offset(skb)) 120 120 goto discard_it; 121 121 122 - if (!pskb_may_pull(skb, sizeof(struct sctphdr))) 122 + /* If the packet is fragmented and we need to do crc checking, 123 + * it's better to just linearize it otherwise crc computing 124 + * takes longer. 125 + */ 126 + if ((!(skb_shinfo(skb)->gso_type & SKB_GSO_SCTP) && 127 + skb_linearize(skb)) || 128 + !pskb_may_pull(skb, sizeof(struct sctphdr))) 123 129 goto discard_it; 124 130 125 131 /* Pull up the IP header. */ ··· 1181 1175 * those cannot be on GSO-style anyway. 1182 1176 */ 1183 1177 if ((skb_shinfo(skb)->gso_type & SKB_GSO_SCTP) == SKB_GSO_SCTP) 1184 - return NULL; 1185 - 1186 - if (skb_linearize(skb)) 1187 1178 return NULL; 1188 1179 1189 1180 ch = (sctp_chunkhdr_t *) skb->data;
-13
net/sctp/inqueue.c
··· 170 170 171 171 chunk = list_entry(entry, struct sctp_chunk, list); 172 172 173 - /* Linearize if it's not GSO */ 174 - if ((skb_shinfo(chunk->skb)->gso_type & SKB_GSO_SCTP) != SKB_GSO_SCTP && 175 - skb_is_nonlinear(chunk->skb)) { 176 - if (skb_linearize(chunk->skb)) { 177 - __SCTP_INC_STATS(dev_net(chunk->skb->dev), SCTP_MIB_IN_PKT_DISCARDS); 178 - sctp_chunk_free(chunk); 179 - goto next_chunk; 180 - } 181 - 182 - /* Update sctp_hdr as it probably changed */ 183 - chunk->sctp_hdr = sctp_hdr(chunk->skb); 184 - } 185 - 186 173 if ((skb_shinfo(chunk->skb)->gso_type & SKB_GSO_SCTP) == SKB_GSO_SCTP) { 187 174 /* GSO-marked skbs but without frags, handle 188 175 * them normally
+4 -2
net/sctp/sctp_diag.c
··· 424 424 paddr.v4.sin_family = AF_INET; 425 425 } else { 426 426 laddr.v6.sin6_port = req->id.idiag_sport; 427 - memcpy(&laddr.v6.sin6_addr, req->id.idiag_src, 64); 427 + memcpy(&laddr.v6.sin6_addr, req->id.idiag_src, 428 + sizeof(laddr.v6.sin6_addr)); 428 429 laddr.v6.sin6_family = AF_INET6; 429 430 430 431 paddr.v6.sin6_port = req->id.idiag_dport; 431 - memcpy(&paddr.v6.sin6_addr, req->id.idiag_dst, 64); 432 + memcpy(&paddr.v6.sin6_addr, req->id.idiag_dst, 433 + sizeof(paddr.v6.sin6_addr)); 432 434 paddr.v6.sin6_family = AF_INET6; 433 435 } 434 436
+2
net/tipc/udp_media.c
··· 732 732 733 733 return 0; 734 734 err: 735 + if (ub->ubsock) 736 + udp_tunnel_sock_release(ub->ubsock); 735 737 kfree(ub); 736 738 return err; 737 739 }
+3 -1
scripts/get_maintainer.pl
··· 2136 2136 2137 2137 my $cmd = $VCS_cmds{"file_exists_cmd"}; 2138 2138 $cmd =~ s/(\$\w+)/$1/eeg; # interpolate $cmd 2139 - 2139 + $cmd .= " 2>&1"; 2140 2140 $exists = &{$VCS_cmds{"execute_cmd"}}($cmd); 2141 + 2142 + return 0 if ($? != 0); 2141 2143 2142 2144 return $exists; 2143 2145 }
+1
security/Kconfig
··· 136 136 config HARDENED_USERCOPY 137 137 bool "Harden memory copies between kernel and userspace" 138 138 depends on HAVE_ARCH_HARDENED_USERCOPY 139 + depends on HAVE_HARDENED_USERCOPY_ALLOCATOR 139 140 select BUG 140 141 help 141 142 This option checks for obviously wrong memory regions when
+4 -3
sound/pci/hda/patch_realtek.c
··· 4828 4828 ALC293_FIXUP_DELL1_MIC_NO_PRESENCE, 4829 4829 ALC292_FIXUP_TPT440_DOCK, 4830 4830 ALC292_FIXUP_TPT440, 4831 - ALC283_FIXUP_BXBT2807_MIC, 4831 + ALC283_FIXUP_HEADSET_MIC, 4832 4832 ALC255_FIXUP_DELL_WMI_MIC_MUTE_LED, 4833 4833 ALC282_FIXUP_ASPIRE_V5_PINS, 4834 4834 ALC280_FIXUP_HP_GPIO4, ··· 5321 5321 .chained = true, 5322 5322 .chain_id = ALC292_FIXUP_TPT440_DOCK, 5323 5323 }, 5324 - [ALC283_FIXUP_BXBT2807_MIC] = { 5324 + [ALC283_FIXUP_HEADSET_MIC] = { 5325 5325 .type = HDA_FIXUP_PINS, 5326 5326 .v.pins = (const struct hda_pintbl[]) { 5327 5327 { 0x19, 0x04a110f0 }, ··· 5651 5651 SND_PCI_QUIRK(0x10cf, 0x1757, "Lifebook E752", ALC269_FIXUP_LIFEBOOK_HP_PIN), 5652 5652 SND_PCI_QUIRK(0x10cf, 0x1845, "Lifebook U904", ALC269_FIXUP_LIFEBOOK_EXTMIC), 5653 5653 SND_PCI_QUIRK(0x144d, 0xc109, "Samsung Ativ book 9 (NP900X3G)", ALC269_FIXUP_INV_DMIC), 5654 - SND_PCI_QUIRK(0x1458, 0xfa53, "Gigabyte BXBT-2807", ALC283_FIXUP_BXBT2807_MIC), 5654 + SND_PCI_QUIRK(0x1458, 0xfa53, "Gigabyte BXBT-2807", ALC283_FIXUP_HEADSET_MIC), 5655 + SND_PCI_QUIRK(0x1462, 0xb120, "MSI Cubi MS-B120", ALC283_FIXUP_HEADSET_MIC), 5655 5656 SND_PCI_QUIRK(0x17aa, 0x20f2, "Thinkpad SL410/510", ALC269_FIXUP_SKU_IGNORE), 5656 5657 SND_PCI_QUIRK(0x17aa, 0x215e, "Thinkpad L512", ALC269_FIXUP_SKU_IGNORE), 5657 5658 SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_SKU_IGNORE),
+3 -2
sound/soc/atmel/atmel_ssc_dai.c
··· 299 299 clk_enable(ssc_p->ssc->clk); 300 300 ssc_p->mck_rate = clk_get_rate(ssc_p->ssc->clk); 301 301 302 - /* Reset the SSC to keep it at a clean status */ 303 - ssc_writel(ssc_p->ssc->regs, CR, SSC_BIT(CR_SWRST)); 302 + /* Reset the SSC unless initialized to keep it in a clean state */ 303 + if (!ssc_p->initialized) 304 + ssc_writel(ssc_p->ssc->regs, CR, SSC_BIT(CR_SWRST)); 304 305 305 306 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { 306 307 dir = 0;
+2 -2
sound/soc/codecs/da7213.c
··· 1247 1247 return -EINVAL; 1248 1248 } 1249 1249 1250 - /* By default only 32 BCLK per WCLK is supported */ 1251 - dai_clk_mode |= DA7213_DAI_BCLKS_PER_WCLK_32; 1250 + /* By default only 64 BCLK per WCLK is supported */ 1251 + dai_clk_mode |= DA7213_DAI_BCLKS_PER_WCLK_64; 1252 1252 1253 1253 snd_soc_write(codec, DA7213_DAI_CLK_MODE, dai_clk_mode); 1254 1254 snd_soc_update_bits(codec, DA7213_DAI_CTRL, DA7213_DAI_FORMAT_MASK,
+1
sound/soc/codecs/max98371.c
··· 412 412 413 413 static const struct i2c_device_id max98371_i2c_id[] = { 414 414 { "max98371", 0 }, 415 + { } 415 416 }; 416 417 417 418 MODULE_DEVICE_TABLE(i2c, max98371_i2c_id);
+32 -46
sound/soc/codecs/nau8825.c
··· 212 212 0xfa2f, 0xfaea, 0xfba5, 0xfc60, 0xfd1a, 0xfdd4, 0xfe8e, 0xff47 213 213 }; 214 214 215 - static struct snd_soc_dai *nau8825_get_codec_dai(struct nau8825 *nau8825) 216 - { 217 - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(nau8825->dapm); 218 - struct snd_soc_component *component = &codec->component; 219 - struct snd_soc_dai *codec_dai, *_dai; 220 - 221 - list_for_each_entry_safe(codec_dai, _dai, &component->dai_list, list) { 222 - if (!strncmp(codec_dai->name, NUVOTON_CODEC_DAI, 223 - strlen(NUVOTON_CODEC_DAI))) 224 - return codec_dai; 225 - } 226 - return NULL; 227 - } 228 - 229 - static bool nau8825_dai_is_active(struct nau8825 *nau8825) 230 - { 231 - struct snd_soc_dai *codec_dai = nau8825_get_codec_dai(nau8825); 232 - 233 - if (codec_dai) { 234 - if (codec_dai->playback_active || codec_dai->capture_active) 235 - return true; 236 - } 237 - return false; 238 - } 239 - 240 215 /** 241 216 * nau8825_sema_acquire - acquire the semaphore of nau88l25 242 217 * @nau8825: component to register the codec private data with ··· 225 250 * Acquires the semaphore without jiffies. If no more tasks are allowed 226 251 * to acquire the semaphore, calling this function will put the task to 227 252 * sleep until the semaphore is released. 228 - * It returns if the semaphore was acquired. 253 + * If the semaphore is not released within the specified number of jiffies, 254 + * this function returns -ETIME. 255 + * If the sleep is interrupted by a signal, this function will return -EINTR. 256 + * It returns 0 if the semaphore was acquired successfully. 229 257 */ 230 - static void nau8825_sema_acquire(struct nau8825 *nau8825, long timeout) 258 + static int nau8825_sema_acquire(struct nau8825 *nau8825, long timeout) 231 259 { 232 260 int ret; 233 261 234 - if (timeout) 262 + if (timeout) { 235 263 ret = down_timeout(&nau8825->xtalk_sem, timeout); 236 - else 264 + if (ret < 0) 265 + dev_warn(nau8825->dev, "Acquire semaphone timeout\n"); 266 + } else { 237 267 ret = down_interruptible(&nau8825->xtalk_sem); 268 + if (ret < 0) 269 + dev_warn(nau8825->dev, "Acquire semaphone fail\n"); 270 + } 238 271 239 - if (ret < 0) 240 - dev_warn(nau8825->dev, "Acquire semaphone fail\n"); 272 + return ret; 241 273 } 242 274 243 275 /** ··· 1187 1205 struct nau8825 *nau8825 = snd_soc_codec_get_drvdata(codec); 1188 1206 unsigned int val_len = 0; 1189 1207 1208 + nau8825_sema_acquire(nau8825, 2 * HZ); 1209 + 1190 1210 switch (params_width(params)) { 1191 1211 case 16: 1192 1212 val_len |= NAU8825_I2S_DL_16; ··· 1209 1225 regmap_update_bits(nau8825->regmap, NAU8825_REG_I2S_PCM_CTRL1, 1210 1226 NAU8825_I2S_DL_MASK, val_len); 1211 1227 1228 + /* Release the semaphone. */ 1229 + nau8825_sema_release(nau8825); 1230 + 1212 1231 return 0; 1213 1232 } 1214 1233 ··· 1220 1233 struct snd_soc_codec *codec = codec_dai->codec; 1221 1234 struct nau8825 *nau8825 = snd_soc_codec_get_drvdata(codec); 1222 1235 unsigned int ctrl1_val = 0, ctrl2_val = 0; 1236 + 1237 + nau8825_sema_acquire(nau8825, 2 * HZ); 1223 1238 1224 1239 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { 1225 1240 case SND_SOC_DAIFMT_CBM_CFM: ··· 1270 1281 ctrl1_val); 1271 1282 regmap_update_bits(nau8825->regmap, NAU8825_REG_I2S_PCM_CTRL2, 1272 1283 NAU8825_I2S_MS_MASK, ctrl2_val); 1284 + 1285 + /* Release the semaphone. */ 1286 + nau8825_sema_release(nau8825); 1273 1287 1274 1288 return 0; 1275 1289 } ··· 1603 1611 * cess and restore changes if process 1604 1612 * is ongoing when ejection. 1605 1613 */ 1614 + int ret; 1606 1615 nau8825->xtalk_protect = true; 1607 - nau8825_sema_acquire(nau8825, 0); 1616 + ret = nau8825_sema_acquire(nau8825, 0); 1617 + if (ret < 0) 1618 + nau8825->xtalk_protect = false; 1608 1619 } 1609 1620 /* Startup cross talk detection process */ 1610 1621 nau8825->xtalk_state = NAU8825_XTALK_PREPARE; ··· 2233 2238 static int __maybe_unused nau8825_resume(struct snd_soc_codec *codec) 2234 2239 { 2235 2240 struct nau8825 *nau8825 = snd_soc_codec_get_drvdata(codec); 2241 + int ret; 2236 2242 2237 2243 regcache_cache_only(nau8825->regmap, false); 2238 2244 regcache_sync(nau8825->regmap); 2239 - if (nau8825_is_jack_inserted(nau8825->regmap)) { 2240 - /* If the jack is inserted, we need to check whether the play- 2241 - * back is active before suspend. If active, the driver has to 2242 - * raise the protection for cross talk function to avoid the 2243 - * playback recovers before cross talk process finish. Other- 2244 - * wise, the playback will be interfered by cross talk func- 2245 - * tion. It is better to apply hardware related parameters 2246 - * before starting playback or record. 2247 - */ 2248 - if (nau8825_dai_is_active(nau8825)) { 2249 - nau8825->xtalk_protect = true; 2250 - nau8825_sema_acquire(nau8825, 0); 2251 - } 2252 - } 2245 + nau8825->xtalk_protect = true; 2246 + ret = nau8825_sema_acquire(nau8825, 0); 2247 + if (ret < 0) 2248 + nau8825->xtalk_protect = false; 2253 2249 enable_irq(nau8825->irq); 2254 2250 2255 2251 return 0;
+1 -1
sound/soc/codecs/wm2000.c
··· 581 581 if (anc_transitions[i].dest == ANC_OFF) 582 582 clk_disable_unprepare(wm2000->mclk); 583 583 584 - return ret; 584 + return 0; 585 585 } 586 586 587 587 static int wm2000_anc_set_mode(struct wm2000_priv *wm2000)
+3 -3
sound/soc/generic/Makefile
··· 1 - obj-$(CONFIG_SND_SIMPLE_CARD_UTILS) := simple-card-utils.o 2 - 1 + snd-soc-simple-card-utils-objs := simple-card-utils.o 3 2 snd-soc-simple-card-objs := simple-card.o 4 3 5 - obj-$(CONFIG_SND_SIMPLE_CARD) += snd-soc-simple-card.o 4 + obj-$(CONFIG_SND_SIMPLE_CARD_UTILS) += snd-soc-simple-card-utils.o 5 + obj-$(CONFIG_SND_SIMPLE_CARD) += snd-soc-simple-card.o
+6
sound/soc/generic/simple-card-utils.c
··· 7 7 * it under the terms of the GNU General Public License version 2 as 8 8 * published by the Free Software Foundation. 9 9 */ 10 + #include <linux/module.h> 10 11 #include <linux/of.h> 11 12 #include <sound/simple_card_utils.h> 12 13 ··· 96 95 return 0; 97 96 } 98 97 EXPORT_SYMBOL_GPL(asoc_simple_card_parse_card_name); 98 + 99 + /* Module information */ 100 + MODULE_AUTHOR("Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>"); 101 + MODULE_DESCRIPTION("ALSA SoC Simple Card Utils"); 102 + MODULE_LICENSE("GPL v2");
+5
sound/soc/intel/skylake/skl-sst-utils.c
··· 123 123 124 124 uuid_mod = (uuid_le *)uuid; 125 125 126 + if (list_empty(&ctx->uuid_list)) { 127 + dev_err(ctx->dev, "Module list is empty\n"); 128 + return -EINVAL; 129 + } 130 + 126 131 list_for_each_entry(module, &ctx->uuid_list, list) { 127 132 if (uuid_le_cmp(*uuid_mod, module->uuid) == 0) { 128 133 dfw_config->module_id = module->id;
+3 -1
sound/soc/intel/skylake/skl.c
··· 672 672 673 673 skl->nhlt = skl_nhlt_init(bus->dev); 674 674 675 - if (skl->nhlt == NULL) 675 + if (skl->nhlt == NULL) { 676 + err = -ENODEV; 676 677 goto out_free; 678 + } 677 679 678 680 skl_nhlt_update_topology_bin(skl); 679 681
+32 -29
sound/soc/omap/omap-abe-twl6040.c
··· 38 38 struct abe_twl6040 { 39 39 int jack_detection; /* board can detect jack events */ 40 40 int mclk_freq; /* MCLK frequency speed for twl6040 */ 41 - 42 - struct platform_device *dmic_codec_dev; 43 41 }; 42 + 43 + struct platform_device *dmic_codec_dev; 44 44 45 45 static int omap_abe_hw_params(struct snd_pcm_substream *substream, 46 46 struct snd_pcm_hw_params *params) ··· 258 258 if (priv == NULL) 259 259 return -ENOMEM; 260 260 261 - priv->dmic_codec_dev = ERR_PTR(-EINVAL); 262 - 263 261 if (snd_soc_of_parse_card_name(card, "ti,model")) { 264 262 dev_err(&pdev->dev, "Card name is not provided\n"); 265 263 return -ENODEV; ··· 282 284 num_links = 2; 283 285 abe_twl6040_dai_links[1].cpu_of_node = dai_node; 284 286 abe_twl6040_dai_links[1].platform_of_node = dai_node; 285 - 286 - priv->dmic_codec_dev = platform_device_register_simple( 287 - "dmic-codec", -1, NULL, 0); 288 - if (IS_ERR(priv->dmic_codec_dev)) { 289 - dev_err(&pdev->dev, "Can't instantiate dmic-codec\n"); 290 - return PTR_ERR(priv->dmic_codec_dev); 291 - } 292 287 } else { 293 288 num_links = 1; 294 289 } ··· 290 299 of_property_read_u32(node, "ti,mclk-freq", &priv->mclk_freq); 291 300 if (!priv->mclk_freq) { 292 301 dev_err(&pdev->dev, "MCLK frequency not provided\n"); 293 - ret = -EINVAL; 294 - goto err_unregister; 302 + return -EINVAL; 295 303 } 296 304 297 305 card->fully_routed = 1; 298 306 299 307 if (!priv->mclk_freq) { 300 308 dev_err(&pdev->dev, "MCLK frequency missing\n"); 301 - ret = -ENODEV; 302 - goto err_unregister; 309 + return -ENODEV; 303 310 } 304 311 305 312 card->dai_link = abe_twl6040_dai_links; ··· 306 317 snd_soc_card_set_drvdata(card, priv); 307 318 308 319 ret = snd_soc_register_card(card); 309 - if (ret) { 320 + if (ret) 310 321 dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", 311 322 ret); 312 - goto err_unregister; 313 - } 314 - 315 - return 0; 316 - 317 - err_unregister: 318 - if (!IS_ERR(priv->dmic_codec_dev)) 319 - platform_device_unregister(priv->dmic_codec_dev); 320 323 321 324 return ret; 322 325 } ··· 316 335 static int omap_abe_remove(struct platform_device *pdev) 317 336 { 318 337 struct snd_soc_card *card = platform_get_drvdata(pdev); 319 - struct abe_twl6040 *priv = snd_soc_card_get_drvdata(card); 320 338 321 339 snd_soc_unregister_card(card); 322 - 323 - if (!IS_ERR(priv->dmic_codec_dev)) 324 - platform_device_unregister(priv->dmic_codec_dev); 325 340 326 341 return 0; 327 342 } ··· 338 361 .remove = omap_abe_remove, 339 362 }; 340 363 341 - module_platform_driver(omap_abe_driver); 364 + static int __init omap_abe_init(void) 365 + { 366 + int ret; 367 + 368 + dmic_codec_dev = platform_device_register_simple("dmic-codec", -1, NULL, 369 + 0); 370 + if (IS_ERR(dmic_codec_dev)) { 371 + pr_err("%s: dmic-codec device registration failed\n", __func__); 372 + return PTR_ERR(dmic_codec_dev); 373 + } 374 + 375 + ret = platform_driver_register(&omap_abe_driver); 376 + if (ret) { 377 + pr_err("%s: platform driver registration failed\n", __func__); 378 + platform_device_unregister(dmic_codec_dev); 379 + } 380 + 381 + return ret; 382 + } 383 + module_init(omap_abe_init); 384 + 385 + static void __exit omap_abe_exit(void) 386 + { 387 + platform_driver_unregister(&omap_abe_driver); 388 + platform_device_unregister(dmic_codec_dev); 389 + } 390 + module_exit(omap_abe_exit); 342 391 343 392 MODULE_AUTHOR("Misael Lopez Cruz <misael.lopez@ti.com>"); 344 393 MODULE_DESCRIPTION("ALSA SoC for OMAP boards with ABE and twl6040 codec");
+3 -19
sound/soc/omap/omap-mcpdm.c
··· 31 31 #include <linux/err.h> 32 32 #include <linux/io.h> 33 33 #include <linux/irq.h> 34 - #include <linux/clk.h> 35 34 #include <linux/slab.h> 36 35 #include <linux/pm_runtime.h> 37 36 #include <linux/of_device.h> ··· 54 55 unsigned long phys_base; 55 56 void __iomem *io_base; 56 57 int irq; 57 - struct clk *pdmclk; 58 58 59 59 struct mutex mutex; 60 60 ··· 388 390 struct omap_mcpdm *mcpdm = snd_soc_dai_get_drvdata(dai); 389 391 int ret; 390 392 391 - clk_prepare_enable(mcpdm->pdmclk); 392 393 pm_runtime_enable(mcpdm->dev); 393 394 394 395 /* Disable lines while request is ongoing */ 395 396 pm_runtime_get_sync(mcpdm->dev); 396 397 omap_mcpdm_write(mcpdm, MCPDM_REG_CTRL, 0x00); 397 398 398 - ret = devm_request_irq(mcpdm->dev, mcpdm->irq, omap_mcpdm_irq_handler, 399 - 0, "McPDM", (void *)mcpdm); 399 + ret = request_irq(mcpdm->irq, omap_mcpdm_irq_handler, 0, "McPDM", 400 + (void *)mcpdm); 400 401 401 402 pm_runtime_put_sync(mcpdm->dev); 402 403 ··· 420 423 { 421 424 struct omap_mcpdm *mcpdm = snd_soc_dai_get_drvdata(dai); 422 425 426 + free_irq(mcpdm->irq, (void *)mcpdm); 423 427 pm_runtime_disable(mcpdm->dev); 424 428 425 - clk_disable_unprepare(mcpdm->pdmclk); 426 429 return 0; 427 430 } 428 431 ··· 442 445 mcpdm->pm_active_count++; 443 446 } 444 447 445 - clk_disable_unprepare(mcpdm->pdmclk); 446 - 447 448 return 0; 448 449 } 449 450 450 451 static int omap_mcpdm_resume(struct snd_soc_dai *dai) 451 452 { 452 453 struct omap_mcpdm *mcpdm = snd_soc_dai_get_drvdata(dai); 453 - 454 - clk_prepare_enable(mcpdm->pdmclk); 455 454 456 455 if (mcpdm->pm_active_count) { 457 456 while (mcpdm->pm_active_count--) ··· 541 548 return mcpdm->irq; 542 549 543 550 mcpdm->dev = &pdev->dev; 544 - 545 - mcpdm->pdmclk = devm_clk_get(&pdev->dev, "pdmclk"); 546 - if (IS_ERR(mcpdm->pdmclk)) { 547 - if (PTR_ERR(mcpdm->pdmclk) == -EPROBE_DEFER) 548 - return -EPROBE_DEFER; 549 - dev_warn(&pdev->dev, "Error getting pdmclk (%ld)!\n", 550 - PTR_ERR(mcpdm->pdmclk)); 551 - mcpdm->pdmclk = NULL; 552 - } 553 551 554 552 ret = devm_snd_soc_register_component(&pdev->dev, 555 553 &omap_mcpdm_component,
+4 -3
sound/soc/samsung/s3c24xx_uda134x.c
··· 58 58 59 59 static int s3c24xx_uda134x_startup(struct snd_pcm_substream *substream) 60 60 { 61 - int ret = 0; 61 + struct snd_soc_pcm_runtime *rtd = substream->private_data; 62 + struct snd_soc_dai *cpu_dai = rtd->cpu_dai; 62 63 #ifdef ENFORCE_RATES 63 64 struct snd_pcm_runtime *runtime = substream->runtime; 64 65 #endif 66 + int ret = 0; 65 67 66 68 mutex_lock(&clk_lock); 67 69 pr_debug("%s %d\n", __func__, clk_users); ··· 73 71 printk(KERN_ERR "%s cannot get xtal\n", __func__); 74 72 ret = PTR_ERR(xtal); 75 73 } else { 76 - pclk = clk_get(&s3c24xx_uda134x_snd_device->dev, 77 - "pclk"); 74 + pclk = clk_get(cpu_dai->dev, "iis"); 78 75 if (IS_ERR(pclk)) { 79 76 printk(KERN_ERR "%s cannot get pclk\n", 80 77 __func__);
+5 -1
sound/soc/sh/rcar/src.c
··· 226 226 ifscr = 0; 227 227 fsrate = 0; 228 228 if (fin != fout) { 229 + u64 n; 230 + 229 231 ifscr = 1; 230 - fsrate = 0x0400000 / fout * fin; 232 + n = (u64)0x0400000 * fin; 233 + do_div(n, fout); 234 + fsrate = n; 231 235 } 232 236 233 237 /*
+3 -1
sound/soc/soc-compress.c
··· 121 121 122 122 dpcm_be_disconnect(fe, stream); 123 123 fe->dpcm[stream].runtime = NULL; 124 - goto fe_err; 124 + goto path_err; 125 125 } 126 126 127 127 dpcm_clear_pending_state(fe, stream); ··· 136 136 137 137 return 0; 138 138 139 + path_err: 140 + dpcm_path_put(&list); 139 141 fe_err: 140 142 if (fe->dai_link->compr_ops && fe->dai_link->compr_ops->shutdown) 141 143 fe->dai_link->compr_ops->shutdown(cstream);
+2 -3
sound/soc/soc-core.c
··· 1056 1056 if (!rtd->platform) { 1057 1057 dev_err(card->dev, "ASoC: platform %s not registered\n", 1058 1058 dai_link->platform_name); 1059 - return -EPROBE_DEFER; 1059 + goto _err_defer; 1060 1060 } 1061 1061 1062 1062 soc_add_pcm_runtime(card, rtd); ··· 2083 2083 /* remove auxiliary devices */ 2084 2084 soc_remove_aux_devices(card); 2085 2085 2086 + snd_soc_dapm_free(&card->dapm); 2086 2087 soc_cleanup_card_debugfs(card); 2087 2088 2088 2089 /* remove the card */ 2089 2090 if (card->remove) 2090 2091 card->remove(card); 2091 - 2092 - snd_soc_dapm_free(&card->dapm); 2093 2092 2094 2093 snd_card_free(card->snd_card); 2095 2094 return 0;
+10
sound/soc/soc-dapm.c
··· 3493 3493 const struct snd_soc_pcm_stream *config = w->params + w->params_select; 3494 3494 struct snd_pcm_substream substream; 3495 3495 struct snd_pcm_hw_params *params = NULL; 3496 + struct snd_pcm_runtime *runtime = NULL; 3496 3497 u64 fmt; 3497 3498 int ret; 3498 3499 ··· 3541 3540 = config->channels_max; 3542 3541 3543 3542 memset(&substream, 0, sizeof(substream)); 3543 + 3544 + /* Allocate a dummy snd_pcm_runtime for startup() and other ops() */ 3545 + runtime = kzalloc(sizeof(*runtime), GFP_KERNEL); 3546 + if (!runtime) { 3547 + ret = -ENOMEM; 3548 + goto out; 3549 + } 3550 + substream.runtime = runtime; 3544 3551 3545 3552 switch (event) { 3546 3553 case SND_SOC_DAPM_PRE_PMU: ··· 3615 3606 } 3616 3607 3617 3608 out: 3609 + kfree(runtime); 3618 3610 kfree(params); 3619 3611 return ret; 3620 3612 }
+2 -1
sound/usb/line6/pcm.c
··· 55 55 err = line6_pcm_acquire(line6pcm, LINE6_STREAM_IMPULSE); 56 56 if (err < 0) { 57 57 line6pcm->impulse_volume = 0; 58 - line6_pcm_release(line6pcm, LINE6_STREAM_IMPULSE); 59 58 return err; 60 59 } 61 60 } else { ··· 210 211 spin_lock_irqsave(&pstr->lock, flags); 211 212 clear_bit(type, &pstr->running); 212 213 if (!pstr->running) { 214 + spin_unlock_irqrestore(&pstr->lock, flags); 213 215 line6_unlink_audio_urbs(line6pcm, pstr); 216 + spin_lock_irqsave(&pstr->lock, flags); 214 217 if (direction == SNDRV_PCM_STREAM_CAPTURE) { 215 218 line6pcm->prev_fbuf = NULL; 216 219 line6pcm->prev_fsize = 0;
+6 -6
sound/usb/line6/pod.c
··· 244 244 static ssize_t serial_number_show(struct device *dev, 245 245 struct device_attribute *attr, char *buf) 246 246 { 247 - struct usb_interface *interface = to_usb_interface(dev); 248 - struct usb_line6_pod *pod = usb_get_intfdata(interface); 247 + struct snd_card *card = dev_to_snd_card(dev); 248 + struct usb_line6_pod *pod = card->private_data; 249 249 250 250 return sprintf(buf, "%u\n", pod->serial_number); 251 251 } ··· 256 256 static ssize_t firmware_version_show(struct device *dev, 257 257 struct device_attribute *attr, char *buf) 258 258 { 259 - struct usb_interface *interface = to_usb_interface(dev); 260 - struct usb_line6_pod *pod = usb_get_intfdata(interface); 259 + struct snd_card *card = dev_to_snd_card(dev); 260 + struct usb_line6_pod *pod = card->private_data; 261 261 262 262 return sprintf(buf, "%d.%02d\n", pod->firmware_version / 100, 263 263 pod->firmware_version % 100); ··· 269 269 static ssize_t device_id_show(struct device *dev, 270 270 struct device_attribute *attr, char *buf) 271 271 { 272 - struct usb_interface *interface = to_usb_interface(dev); 273 - struct usb_line6_pod *pod = usb_get_intfdata(interface); 272 + struct snd_card *card = dev_to_snd_card(dev); 273 + struct usb_line6_pod *pod = card->private_data; 274 274 275 275 return sprintf(buf, "%d\n", pod->device_id); 276 276 }
+2
tools/arch/arm64/include/uapi/asm/kvm.h
··· 87 87 /* Supported VGICv3 address types */ 88 88 #define KVM_VGIC_V3_ADDR_TYPE_DIST 2 89 89 #define KVM_VGIC_V3_ADDR_TYPE_REDIST 3 90 + #define KVM_VGIC_ITS_ADDR_TYPE 4 90 91 91 92 #define KVM_VGIC_V3_DIST_SIZE SZ_64K 92 93 #define KVM_VGIC_V3_REDIST_SIZE (2 * SZ_64K) 94 + #define KVM_VGIC_V3_ITS_SIZE (2 * SZ_64K) 93 95 94 96 #define KVM_ARM_VCPU_POWER_OFF 0 /* CPU is started in OFF state */ 95 97 #define KVM_ARM_VCPU_EL1_32BIT 1 /* CPU running a 32bit VM */
+41
tools/arch/s390/include/uapi/asm/kvm.h
··· 93 93 __u64 fac_list[256]; 94 94 }; 95 95 96 + #define KVM_S390_VM_CPU_PROCESSOR_FEAT 2 97 + #define KVM_S390_VM_CPU_MACHINE_FEAT 3 98 + 99 + #define KVM_S390_VM_CPU_FEAT_NR_BITS 1024 100 + #define KVM_S390_VM_CPU_FEAT_ESOP 0 101 + #define KVM_S390_VM_CPU_FEAT_SIEF2 1 102 + #define KVM_S390_VM_CPU_FEAT_64BSCAO 2 103 + #define KVM_S390_VM_CPU_FEAT_SIIF 3 104 + #define KVM_S390_VM_CPU_FEAT_GPERE 4 105 + #define KVM_S390_VM_CPU_FEAT_GSLS 5 106 + #define KVM_S390_VM_CPU_FEAT_IB 6 107 + #define KVM_S390_VM_CPU_FEAT_CEI 7 108 + #define KVM_S390_VM_CPU_FEAT_IBS 8 109 + #define KVM_S390_VM_CPU_FEAT_SKEY 9 110 + #define KVM_S390_VM_CPU_FEAT_CMMA 10 111 + #define KVM_S390_VM_CPU_FEAT_PFMFI 11 112 + #define KVM_S390_VM_CPU_FEAT_SIGPIF 12 113 + struct kvm_s390_vm_cpu_feat { 114 + __u64 feat[16]; 115 + }; 116 + 117 + #define KVM_S390_VM_CPU_PROCESSOR_SUBFUNC 4 118 + #define KVM_S390_VM_CPU_MACHINE_SUBFUNC 5 119 + /* for "test bit" instructions MSB 0 bit ordering, for "query" raw blocks */ 120 + struct kvm_s390_vm_cpu_subfunc { 121 + __u8 plo[32]; /* always */ 122 + __u8 ptff[16]; /* with TOD-clock steering */ 123 + __u8 kmac[16]; /* with MSA */ 124 + __u8 kmc[16]; /* with MSA */ 125 + __u8 km[16]; /* with MSA */ 126 + __u8 kimd[16]; /* with MSA */ 127 + __u8 klmd[16]; /* with MSA */ 128 + __u8 pckmo[16]; /* with MSA3 */ 129 + __u8 kmctr[16]; /* with MSA4 */ 130 + __u8 kmf[16]; /* with MSA4 */ 131 + __u8 kmo[16]; /* with MSA4 */ 132 + __u8 pcc[16]; /* with MSA4 */ 133 + __u8 ppno[16]; /* with MSA5 */ 134 + __u8 reserved[1824]; 135 + }; 136 + 96 137 /* kvm attributes for crypto */ 97 138 #define KVM_S390_VM_CRYPTO_ENABLE_AES_KW 0 98 139 #define KVM_S390_VM_CRYPTO_ENABLE_DEA_KW 1
+1
tools/arch/s390/include/uapi/asm/sie.h
··· 140 140 exit_code_ipa0(0xB2, 0x4c, "TAR"), \ 141 141 exit_code_ipa0(0xB2, 0x50, "CSP"), \ 142 142 exit_code_ipa0(0xB2, 0x54, "MVPG"), \ 143 + exit_code_ipa0(0xB2, 0x56, "STHYI"), \ 143 144 exit_code_ipa0(0xB2, 0x58, "BSG"), \ 144 145 exit_code_ipa0(0xB2, 0x5a, "BSA"), \ 145 146 exit_code_ipa0(0xB2, 0x5f, "CHSC"), \
+1 -1
tools/gpio/gpio-event-mon.c
··· 1 1 /* 2 - * gpio-hammer - example swiss army knife to shake GPIO lines on a system 2 + * gpio-event-mon - monitor GPIO line events from userspace 3 3 * 4 4 * Copyright (C) 2016 Linus Walleij 5 5 *
+5 -1
tools/include/linux/string.h
··· 8 8 9 9 int strtobool(const char *s, bool *res); 10 10 11 - #ifdef __GLIBC__ 11 + /* 12 + * glibc based builds needs the extern while uClibc doesn't. 13 + * However uClibc headers also define __GLIBC__ hence the hack below 14 + */ 15 + #if defined(__GLIBC__) && !defined(__UCLIBC__) 12 16 extern size_t strlcpy(char *dest, const char *src, size_t size); 13 17 #endif 14 18
+2
tools/perf/arch/powerpc/util/sym-handling.c
··· 97 97 } 98 98 } 99 99 100 + #ifdef HAVE_LIBELF_SUPPORT 100 101 void arch__post_process_probe_trace_events(struct perf_probe_event *pev, 101 102 int ntevs) 102 103 { ··· 119 118 } 120 119 } 121 120 } 121 + #endif /* HAVE_LIBELF_SUPPORT */ 122 122 123 123 #endif
+5 -1
tools/perf/arch/x86/util/intel-pt.c
··· 501 501 struct intel_pt_recording *ptr = 502 502 container_of(itr, struct intel_pt_recording, itr); 503 503 struct perf_pmu *intel_pt_pmu = ptr->intel_pt_pmu; 504 - bool have_timing_info; 504 + bool have_timing_info, need_immediate = false; 505 505 struct perf_evsel *evsel, *intel_pt_evsel = NULL; 506 506 const struct cpu_map *cpus = evlist->cpus; 507 507 bool privileged = geteuid() == 0 || perf_event_paranoid() < 0; ··· 655 655 ptr->have_sched_switch = 3; 656 656 } else { 657 657 opts->record_switch_events = true; 658 + need_immediate = true; 658 659 if (cpu_wide) 659 660 ptr->have_sched_switch = 3; 660 661 else ··· 700 699 701 700 tracking_evsel->attr.freq = 0; 702 701 tracking_evsel->attr.sample_period = 1; 702 + 703 + if (need_immediate) 704 + tracking_evsel->immediate = true; 703 705 704 706 /* In per-cpu case, always need the time of mmap events etc */ 705 707 if (!cpu_map__empty(cpus)) {
+3
tools/perf/builtin-mem.c
··· 88 88 if (mem->operation & MEM_OPERATION_LOAD) 89 89 perf_mem_events[PERF_MEM_EVENTS__LOAD].record = true; 90 90 91 + if (mem->operation & MEM_OPERATION_STORE) 92 + perf_mem_events[PERF_MEM_EVENTS__STORE].record = true; 93 + 91 94 if (perf_mem_events[PERF_MEM_EVENTS__LOAD].record) 92 95 rec_argv[i++] = "-W"; 93 96
+10 -3
tools/perf/builtin-script.c
··· 371 371 372 372 if (!no_callchain) { 373 373 bool use_callchain = false; 374 + bool not_pipe = false; 374 375 375 376 evlist__for_each_entry(session->evlist, evsel) { 377 + not_pipe = true; 376 378 if (evsel->attr.sample_type & PERF_SAMPLE_CALLCHAIN) { 377 379 use_callchain = true; 378 380 break; 379 381 } 380 382 } 381 - if (!use_callchain) 383 + if (not_pipe && !use_callchain) 382 384 symbol_conf.use_callchain = false; 383 385 } 384 386 ··· 1692 1690 snprintf(scripts_path, MAXPATHLEN, "%s/scripts", get_argv_exec_path()); 1693 1691 1694 1692 scripts_dir = opendir(scripts_path); 1695 - if (!scripts_dir) 1696 - return -1; 1693 + if (!scripts_dir) { 1694 + fprintf(stdout, 1695 + "open(%s) failed.\n" 1696 + "Check \"PERF_EXEC_PATH\" env to set scripts dir.\n", 1697 + scripts_path); 1698 + exit(-1); 1699 + } 1697 1700 1698 1701 for_each_lang(scripts_path, scripts_dir, lang_dirent) { 1699 1702 snprintf(lang_path, MAXPATHLEN, "%s/%s/bin", scripts_path,
+3 -3
tools/perf/util/evsel.c
··· 507 507 u8 op, result, type = (config >> 0) & 0xff; 508 508 const char *err = "unknown-ext-hardware-cache-type"; 509 509 510 - if (type > PERF_COUNT_HW_CACHE_MAX) 510 + if (type >= PERF_COUNT_HW_CACHE_MAX) 511 511 goto out_err; 512 512 513 513 op = (config >> 8) & 0xff; 514 514 err = "unknown-ext-hardware-cache-op"; 515 - if (op > PERF_COUNT_HW_CACHE_OP_MAX) 515 + if (op >= PERF_COUNT_HW_CACHE_OP_MAX) 516 516 goto out_err; 517 517 518 518 result = (config >> 16) & 0xff; 519 519 err = "unknown-ext-hardware-cache-result"; 520 - if (result > PERF_COUNT_HW_CACHE_RESULT_MAX) 520 + if (result >= PERF_COUNT_HW_CACHE_RESULT_MAX) 521 521 goto out_err; 522 522 523 523 err = "invalid-cache";
+23 -21
tools/perf/util/intel-pt-decoder/intel-pt-decoder.c
··· 123 123 bool have_calc_cyc_to_tsc; 124 124 int exec_mode; 125 125 unsigned int insn_bytes; 126 - uint64_t sign_bit; 127 - uint64_t sign_bits; 128 126 uint64_t period; 129 127 enum intel_pt_period_type period_type; 130 128 uint64_t tot_insn_cnt; ··· 188 190 decoder->walk_insn = params->walk_insn; 189 191 decoder->data = params->data; 190 192 decoder->return_compression = params->return_compression; 191 - 192 - decoder->sign_bit = (uint64_t)1 << 47; 193 - decoder->sign_bits = ~(((uint64_t)1 << 48) - 1); 194 193 195 194 decoder->period = params->period; 196 195 decoder->period_type = params->period_type; ··· 357 362 return 0; 358 363 } 359 364 360 - static uint64_t intel_pt_calc_ip(struct intel_pt_decoder *decoder, 361 - const struct intel_pt_pkt *packet, 365 + static uint64_t intel_pt_calc_ip(const struct intel_pt_pkt *packet, 362 366 uint64_t last_ip) 363 367 { 364 368 uint64_t ip; 365 369 366 370 switch (packet->count) { 367 - case 2: 371 + case 1: 368 372 ip = (last_ip & (uint64_t)0xffffffffffff0000ULL) | 369 373 packet->payload; 370 374 break; 371 - case 4: 375 + case 2: 372 376 ip = (last_ip & (uint64_t)0xffffffff00000000ULL) | 377 + packet->payload; 378 + break; 379 + case 3: 380 + ip = packet->payload; 381 + /* Sign-extend 6-byte ip */ 382 + if (ip & (uint64_t)0x800000000000ULL) 383 + ip |= (uint64_t)0xffff000000000000ULL; 384 + break; 385 + case 4: 386 + ip = (last_ip & (uint64_t)0xffff000000000000ULL) | 373 387 packet->payload; 374 388 break; 375 389 case 6: ··· 388 384 return 0; 389 385 } 390 386 391 - if (ip & decoder->sign_bit) 392 - return ip | decoder->sign_bits; 393 - 394 387 return ip; 395 388 } 396 389 397 390 static inline void intel_pt_set_last_ip(struct intel_pt_decoder *decoder) 398 391 { 399 - decoder->last_ip = intel_pt_calc_ip(decoder, &decoder->packet, 400 - decoder->last_ip); 392 + decoder->last_ip = intel_pt_calc_ip(&decoder->packet, decoder->last_ip); 401 393 } 402 394 403 395 static inline void intel_pt_set_ip(struct intel_pt_decoder *decoder) ··· 1657 1657 } 1658 1658 } 1659 1659 1660 + static inline bool intel_pt_have_ip(struct intel_pt_decoder *decoder) 1661 + { 1662 + return decoder->last_ip || decoder->packet.count == 0 || 1663 + decoder->packet.count == 3 || decoder->packet.count == 6; 1664 + } 1665 + 1660 1666 /* Walk PSB+ packets to get in sync. */ 1661 1667 static int intel_pt_walk_psb(struct intel_pt_decoder *decoder) 1662 1668 { ··· 1683 1677 1684 1678 case INTEL_PT_FUP: 1685 1679 decoder->pge = true; 1686 - if (decoder->last_ip || decoder->packet.count == 6 || 1687 - decoder->packet.count == 0) { 1680 + if (intel_pt_have_ip(decoder)) { 1688 1681 uint64_t current_ip = decoder->ip; 1689 1682 1690 1683 intel_pt_set_ip(decoder); ··· 1772 1767 case INTEL_PT_TIP_PGE: 1773 1768 case INTEL_PT_TIP: 1774 1769 decoder->pge = decoder->packet.type != INTEL_PT_TIP_PGD; 1775 - if (decoder->last_ip || decoder->packet.count == 6 || 1776 - decoder->packet.count == 0) 1770 + if (intel_pt_have_ip(decoder)) 1777 1771 intel_pt_set_ip(decoder); 1778 1772 if (decoder->ip) 1779 1773 return 0; ··· 1780 1776 1781 1777 case INTEL_PT_FUP: 1782 1778 if (decoder->overflow) { 1783 - if (decoder->last_ip || 1784 - decoder->packet.count == 6 || 1785 - decoder->packet.count == 0) 1779 + if (intel_pt_have_ip(decoder)) 1786 1780 intel_pt_set_ip(decoder); 1787 1781 if (decoder->ip) 1788 1782 return 0;
+17 -7
tools/perf/util/intel-pt-decoder/intel-pt-pkt-decoder.c
··· 292 292 const unsigned char *buf, size_t len, 293 293 struct intel_pt_pkt *packet) 294 294 { 295 - switch (byte >> 5) { 295 + int ip_len; 296 + 297 + packet->count = byte >> 5; 298 + 299 + switch (packet->count) { 296 300 case 0: 297 - packet->count = 0; 301 + ip_len = 0; 298 302 break; 299 303 case 1: 300 304 if (len < 3) 301 305 return INTEL_PT_NEED_MORE_BYTES; 302 - packet->count = 2; 306 + ip_len = 2; 303 307 packet->payload = le16_to_cpu(*(uint16_t *)(buf + 1)); 304 308 break; 305 309 case 2: 306 310 if (len < 5) 307 311 return INTEL_PT_NEED_MORE_BYTES; 308 - packet->count = 4; 312 + ip_len = 4; 309 313 packet->payload = le32_to_cpu(*(uint32_t *)(buf + 1)); 310 314 break; 311 315 case 3: 312 - case 6: 316 + case 4: 313 317 if (len < 7) 314 318 return INTEL_PT_NEED_MORE_BYTES; 315 - packet->count = 6; 319 + ip_len = 6; 316 320 memcpy_le64(&packet->payload, buf + 1, 6); 321 + break; 322 + case 6: 323 + if (len < 9) 324 + return INTEL_PT_NEED_MORE_BYTES; 325 + ip_len = 8; 326 + packet->payload = le64_to_cpu(*(uint64_t *)(buf + 1)); 317 327 break; 318 328 default: 319 329 return INTEL_PT_BAD_PACKET; ··· 331 321 332 322 packet->type = type; 333 323 334 - return packet->count + 1; 324 + return ip_len + 1; 335 325 } 336 326 337 327 static int intel_pt_get_mode(const unsigned char *buf, size_t len,
+1
tools/perf/util/jitdump.c
··· 1 + #include <sys/sysmacros.h> 1 2 #include <sys/types.h> 2 3 #include <stdio.h> 3 4 #include <stdlib.h>
+29 -7
tools/perf/util/probe-file.c
··· 133 133 /* Get raw string list of current kprobe_events or uprobe_events */ 134 134 struct strlist *probe_file__get_rawlist(int fd) 135 135 { 136 - int ret, idx; 136 + int ret, idx, fddup; 137 137 FILE *fp; 138 138 char buf[MAX_CMDLEN]; 139 139 char *p; ··· 143 143 return NULL; 144 144 145 145 sl = strlist__new(NULL, NULL); 146 + if (sl == NULL) 147 + return NULL; 146 148 147 - fp = fdopen(dup(fd), "r"); 149 + fddup = dup(fd); 150 + if (fddup < 0) 151 + goto out_free_sl; 152 + 153 + fp = fdopen(fddup, "r"); 154 + if (!fp) 155 + goto out_close_fddup; 156 + 148 157 while (!feof(fp)) { 149 158 p = fgets(buf, MAX_CMDLEN, fp); 150 159 if (!p) ··· 165 156 ret = strlist__add(sl, buf); 166 157 if (ret < 0) { 167 158 pr_debug("strlist__add failed (%d)\n", ret); 168 - strlist__delete(sl); 169 - return NULL; 159 + goto out_close_fp; 170 160 } 171 161 } 172 162 fclose(fp); 173 163 174 164 return sl; 165 + 166 + out_close_fp: 167 + fclose(fp); 168 + goto out_free_sl; 169 + out_close_fddup: 170 + close(fddup); 171 + out_free_sl: 172 + strlist__delete(sl); 173 + return NULL; 175 174 } 176 175 177 176 static struct strlist *__probe_file__get_namelist(int fd, bool include_group) ··· 464 447 { 465 448 struct probe_cache_entry *entry = NULL; 466 449 char buf[MAX_CMDLEN], *p; 467 - int ret = 0; 450 + int ret = 0, fddup; 468 451 FILE *fp; 469 452 470 - fp = fdopen(dup(pcache->fd), "r"); 471 - if (!fp) 453 + fddup = dup(pcache->fd); 454 + if (fddup < 0) 455 + return -errno; 456 + fp = fdopen(fddup, "r"); 457 + if (!fp) { 458 + close(fddup); 472 459 return -EINVAL; 460 + } 473 461 474 462 while (!feof(fp)) { 475 463 if (!fgets(buf, MAX_CMDLEN, fp))
+2 -1
tools/perf/util/symbol-elf.c
··· 837 837 sec = syms_ss->symtab; 838 838 shdr = syms_ss->symshdr; 839 839 840 - if (elf_section_by_name(elf, &ehdr, &tshdr, ".text", NULL)) 840 + if (elf_section_by_name(runtime_ss->elf, &runtime_ss->ehdr, &tshdr, 841 + ".text", NULL)) 841 842 dso->text_offset = tshdr.sh_addr - tshdr.sh_offset; 842 843 843 844 if (runtime_ss->opdsec)
+1 -1
tools/perf/util/unwind-libdw.c
··· 66 66 if (__report_module(&al, ip, ui)) 67 67 return -1; 68 68 69 - e->ip = ip; 69 + e->ip = al.addr; 70 70 e->map = al.map; 71 71 e->sym = al.sym; 72 72
+1 -1
tools/perf/util/unwind-libunwind-local.c
··· 542 542 thread__find_addr_location(thread, PERF_RECORD_MISC_USER, 543 543 MAP__FUNCTION, ip, &al); 544 544 545 - e.ip = ip; 545 + e.ip = al.addr; 546 546 e.map = al.map; 547 547 e.sym = al.sym; 548 548
+10 -1
virt/kvm/arm/arch_timer.c
··· 33 33 static struct timecounter *timecounter; 34 34 static struct workqueue_struct *wqueue; 35 35 static unsigned int host_vtimer_irq; 36 + static u32 host_vtimer_irq_flags; 36 37 37 38 void kvm_timer_vcpu_put(struct kvm_vcpu *vcpu) 38 39 { ··· 366 365 367 366 static void kvm_timer_init_interrupt(void *info) 368 367 { 369 - enable_percpu_irq(host_vtimer_irq, 0); 368 + enable_percpu_irq(host_vtimer_irq, host_vtimer_irq_flags); 370 369 } 371 370 372 371 int kvm_arm_timer_set_reg(struct kvm_vcpu *vcpu, u64 regid, u64 value) ··· 432 431 return -ENODEV; 433 432 } 434 433 host_vtimer_irq = info->virtual_irq; 434 + 435 + host_vtimer_irq_flags = irq_get_trigger_type(host_vtimer_irq); 436 + if (host_vtimer_irq_flags != IRQF_TRIGGER_HIGH && 437 + host_vtimer_irq_flags != IRQF_TRIGGER_LOW) { 438 + kvm_err("Invalid trigger for IRQ%d, assuming level low\n", 439 + host_vtimer_irq); 440 + host_vtimer_irq_flags = IRQF_TRIGGER_LOW; 441 + } 435 442 436 443 err = request_percpu_irq(host_vtimer_irq, kvm_arch_timer_handler, 437 444 "kvm guest timer", kvm_get_running_vcpus());
+113 -43
virt/kvm/arm/vgic/vgic-its.c
··· 51 51 52 52 irq = kzalloc(sizeof(struct vgic_irq), GFP_KERNEL); 53 53 if (!irq) 54 - return NULL; 54 + return ERR_PTR(-ENOMEM); 55 55 56 56 INIT_LIST_HEAD(&irq->lpi_list); 57 57 INIT_LIST_HEAD(&irq->ap_list); ··· 441 441 * Find the target VCPU and the LPI number for a given devid/eventid pair 442 442 * and make this IRQ pending, possibly injecting it. 443 443 * Must be called with the its_lock mutex held. 444 + * Returns 0 on success, a positive error value for any ITS mapping 445 + * related errors and negative error values for generic errors. 444 446 */ 445 - static void vgic_its_trigger_msi(struct kvm *kvm, struct vgic_its *its, 446 - u32 devid, u32 eventid) 447 + static int vgic_its_trigger_msi(struct kvm *kvm, struct vgic_its *its, 448 + u32 devid, u32 eventid) 447 449 { 450 + struct kvm_vcpu *vcpu; 448 451 struct its_itte *itte; 449 452 450 453 if (!its->enabled) 451 - return; 454 + return -EBUSY; 452 455 453 456 itte = find_itte(its, devid, eventid); 454 - /* Triggering an unmapped IRQ gets silently dropped. */ 455 - if (itte && its_is_collection_mapped(itte->collection)) { 456 - struct kvm_vcpu *vcpu; 457 + if (!itte || !its_is_collection_mapped(itte->collection)) 458 + return E_ITS_INT_UNMAPPED_INTERRUPT; 457 459 458 - vcpu = kvm_get_vcpu(kvm, itte->collection->target_addr); 459 - if (vcpu && vcpu->arch.vgic_cpu.lpis_enabled) { 460 - spin_lock(&itte->irq->irq_lock); 461 - itte->irq->pending = true; 462 - vgic_queue_irq_unlock(kvm, itte->irq); 463 - } 464 - } 460 + vcpu = kvm_get_vcpu(kvm, itte->collection->target_addr); 461 + if (!vcpu) 462 + return E_ITS_INT_UNMAPPED_INTERRUPT; 463 + 464 + if (!vcpu->arch.vgic_cpu.lpis_enabled) 465 + return -EBUSY; 466 + 467 + spin_lock(&itte->irq->irq_lock); 468 + itte->irq->pending = true; 469 + vgic_queue_irq_unlock(kvm, itte->irq); 470 + 471 + return 0; 472 + } 473 + 474 + static struct vgic_io_device *vgic_get_its_iodev(struct kvm_io_device *dev) 475 + { 476 + struct vgic_io_device *iodev; 477 + 478 + if (dev->ops != &kvm_io_gic_ops) 479 + return NULL; 480 + 481 + iodev = container_of(dev, struct vgic_io_device, dev); 482 + 483 + if (iodev->iodev_type != IODEV_ITS) 484 + return NULL; 485 + 486 + return iodev; 465 487 } 466 488 467 489 /* 468 490 * Queries the KVM IO bus framework to get the ITS pointer from the given 469 491 * doorbell address. 470 492 * We then call vgic_its_trigger_msi() with the decoded data. 493 + * According to the KVM_SIGNAL_MSI API description returns 1 on success. 471 494 */ 472 495 int vgic_its_inject_msi(struct kvm *kvm, struct kvm_msi *msi) 473 496 { 474 497 u64 address; 475 498 struct kvm_io_device *kvm_io_dev; 476 499 struct vgic_io_device *iodev; 500 + int ret; 477 501 478 502 if (!vgic_has_its(kvm)) 479 503 return -ENODEV; ··· 509 485 510 486 kvm_io_dev = kvm_io_bus_get_dev(kvm, KVM_MMIO_BUS, address); 511 487 if (!kvm_io_dev) 512 - return -ENODEV; 488 + return -EINVAL; 513 489 514 - iodev = container_of(kvm_io_dev, struct vgic_io_device, dev); 490 + iodev = vgic_get_its_iodev(kvm_io_dev); 491 + if (!iodev) 492 + return -EINVAL; 515 493 516 494 mutex_lock(&iodev->its->its_lock); 517 - vgic_its_trigger_msi(kvm, iodev->its, msi->devid, msi->data); 495 + ret = vgic_its_trigger_msi(kvm, iodev->its, msi->devid, msi->data); 518 496 mutex_unlock(&iodev->its->its_lock); 519 497 520 - return 0; 498 + if (ret < 0) 499 + return ret; 500 + 501 + /* 502 + * KVM_SIGNAL_MSI demands a return value > 0 for success and 0 503 + * if the guest has blocked the MSI. So we map any LPI mapping 504 + * related error to that. 505 + */ 506 + if (ret) 507 + return 0; 508 + else 509 + return 1; 521 510 } 522 511 523 512 /* Requires the its_lock to be held. */ ··· 539 502 list_del(&itte->itte_list); 540 503 541 504 /* This put matches the get in vgic_add_lpi. */ 542 - vgic_put_irq(kvm, itte->irq); 505 + if (itte->irq) 506 + vgic_put_irq(kvm, itte->irq); 543 507 544 508 kfree(itte); 545 509 } ··· 735 697 struct its_device *device; 736 698 struct its_collection *collection, *new_coll = NULL; 737 699 int lpi_nr; 700 + struct vgic_irq *irq; 738 701 739 702 device = find_its_device(its, device_id); 740 703 if (!device) ··· 749 710 lpi_nr >= max_lpis_propbaser(kvm->arch.vgic.propbaser)) 750 711 return E_ITS_MAPTI_PHYSICALID_OOR; 751 712 713 + /* If there is an existing mapping, behavior is UNPREDICTABLE. */ 714 + if (find_itte(its, device_id, event_id)) 715 + return 0; 716 + 752 717 collection = find_collection(its, coll_id); 753 718 if (!collection) { 754 719 int ret = vgic_its_alloc_collection(its, &collection, coll_id); ··· 761 718 new_coll = collection; 762 719 } 763 720 764 - itte = find_itte(its, device_id, event_id); 721 + itte = kzalloc(sizeof(struct its_itte), GFP_KERNEL); 765 722 if (!itte) { 766 - itte = kzalloc(sizeof(struct its_itte), GFP_KERNEL); 767 - if (!itte) { 768 - if (new_coll) 769 - vgic_its_free_collection(its, coll_id); 770 - return -ENOMEM; 771 - } 772 - 773 - itte->event_id = event_id; 774 - list_add_tail(&itte->itte_list, &device->itt_head); 723 + if (new_coll) 724 + vgic_its_free_collection(its, coll_id); 725 + return -ENOMEM; 775 726 } 727 + 728 + itte->event_id = event_id; 729 + list_add_tail(&itte->itte_list, &device->itt_head); 776 730 777 731 itte->collection = collection; 778 732 itte->lpi = lpi_nr; 779 - itte->irq = vgic_add_lpi(kvm, lpi_nr); 733 + 734 + irq = vgic_add_lpi(kvm, lpi_nr); 735 + if (IS_ERR(irq)) { 736 + if (new_coll) 737 + vgic_its_free_collection(its, coll_id); 738 + its_free_itte(kvm, itte); 739 + return PTR_ERR(irq); 740 + } 741 + itte->irq = irq; 742 + 780 743 update_affinity_itte(kvm, itte); 781 744 782 745 /* ··· 1030 981 u32 msi_data = its_cmd_get_id(its_cmd); 1031 982 u64 msi_devid = its_cmd_get_deviceid(its_cmd); 1032 983 1033 - vgic_its_trigger_msi(kvm, its, msi_devid, msi_data); 1034 - 1035 - return 0; 984 + return vgic_its_trigger_msi(kvm, its, msi_devid, msi_data); 1036 985 } 1037 986 1038 987 /* ··· 1335 1288 its_sync_lpi_pending_table(vcpu); 1336 1289 } 1337 1290 1338 - static int vgic_its_init_its(struct kvm *kvm, struct vgic_its *its) 1291 + static int vgic_register_its_iodev(struct kvm *kvm, struct vgic_its *its) 1339 1292 { 1340 1293 struct vgic_io_device *iodev = &its->iodev; 1341 1294 int ret; 1342 1295 1343 - if (its->initialized) 1344 - return 0; 1296 + if (!its->initialized) 1297 + return -EBUSY; 1345 1298 1346 1299 if (IS_VGIC_ADDR_UNDEF(its->vgic_its_base)) 1347 1300 return -ENXIO; ··· 1357 1310 ret = kvm_io_bus_register_dev(kvm, KVM_MMIO_BUS, iodev->base_addr, 1358 1311 KVM_VGIC_V3_ITS_SIZE, &iodev->dev); 1359 1312 mutex_unlock(&kvm->slots_lock); 1360 - 1361 - if (!ret) 1362 - its->initialized = true; 1363 1313 1364 1314 return ret; 1365 1315 } ··· 1479 1435 if (type != KVM_VGIC_ITS_ADDR_TYPE) 1480 1436 return -ENODEV; 1481 1437 1482 - if (its->initialized) 1483 - return -EBUSY; 1484 - 1485 1438 if (copy_from_user(&addr, uaddr, sizeof(addr))) 1486 1439 return -EFAULT; 1487 1440 ··· 1494 1453 case KVM_DEV_ARM_VGIC_GRP_CTRL: 1495 1454 switch (attr->attr) { 1496 1455 case KVM_DEV_ARM_VGIC_CTRL_INIT: 1497 - return vgic_its_init_its(dev->kvm, its); 1456 + its->initialized = true; 1457 + 1458 + return 0; 1498 1459 } 1499 1460 break; 1500 1461 } ··· 1540 1497 { 1541 1498 return kvm_register_device_ops(&kvm_arm_vgic_its_ops, 1542 1499 KVM_DEV_TYPE_ARM_VGIC_ITS); 1500 + } 1501 + 1502 + /* 1503 + * Registers all ITSes with the kvm_io_bus framework. 1504 + * To follow the existing VGIC initialization sequence, this has to be 1505 + * done as late as possible, just before the first VCPU runs. 1506 + */ 1507 + int vgic_register_its_iodevs(struct kvm *kvm) 1508 + { 1509 + struct kvm_device *dev; 1510 + int ret = 0; 1511 + 1512 + list_for_each_entry(dev, &kvm->devices, vm_node) { 1513 + if (dev->ops != &kvm_arm_vgic_its_ops) 1514 + continue; 1515 + 1516 + ret = vgic_register_its_iodev(kvm, dev->private); 1517 + if (ret) 1518 + return ret; 1519 + /* 1520 + * We don't need to care about tearing down previously 1521 + * registered ITSes, as the kvm_io_bus framework removes 1522 + * them for us if the VM gets destroyed. 1523 + */ 1524 + } 1525 + 1526 + return ret; 1543 1527 }
+16 -10
virt/kvm/arm/vgic/vgic-mmio-v3.c
··· 306 306 { 307 307 struct vgic_dist *dist = &vcpu->kvm->arch.vgic; 308 308 struct vgic_cpu *vgic_cpu = &vcpu->arch.vgic_cpu; 309 - u64 propbaser = dist->propbaser; 309 + u64 old_propbaser, propbaser; 310 310 311 311 /* Storing a value with LPIs already enabled is undefined */ 312 312 if (vgic_cpu->lpis_enabled) 313 313 return; 314 314 315 - propbaser = update_64bit_reg(propbaser, addr & 4, len, val); 316 - propbaser = vgic_sanitise_propbaser(propbaser); 317 - 318 - dist->propbaser = propbaser; 315 + do { 316 + old_propbaser = dist->propbaser; 317 + propbaser = old_propbaser; 318 + propbaser = update_64bit_reg(propbaser, addr & 4, len, val); 319 + propbaser = vgic_sanitise_propbaser(propbaser); 320 + } while (cmpxchg64(&dist->propbaser, old_propbaser, 321 + propbaser) != old_propbaser); 319 322 } 320 323 321 324 static unsigned long vgic_mmio_read_pendbase(struct kvm_vcpu *vcpu, ··· 334 331 unsigned long val) 335 332 { 336 333 struct vgic_cpu *vgic_cpu = &vcpu->arch.vgic_cpu; 337 - u64 pendbaser = vgic_cpu->pendbaser; 334 + u64 old_pendbaser, pendbaser; 338 335 339 336 /* Storing a value with LPIs already enabled is undefined */ 340 337 if (vgic_cpu->lpis_enabled) 341 338 return; 342 339 343 - pendbaser = update_64bit_reg(pendbaser, addr & 4, len, val); 344 - pendbaser = vgic_sanitise_pendbaser(pendbaser); 345 - 346 - vgic_cpu->pendbaser = pendbaser; 340 + do { 341 + old_pendbaser = vgic_cpu->pendbaser; 342 + pendbaser = old_pendbaser; 343 + pendbaser = update_64bit_reg(pendbaser, addr & 4, len, val); 344 + pendbaser = vgic_sanitise_pendbaser(pendbaser); 345 + } while (cmpxchg64(&vgic_cpu->pendbaser, old_pendbaser, 346 + pendbaser) != old_pendbaser); 347 347 } 348 348 349 349 /*
+8
virt/kvm/arm/vgic/vgic-v3.c
··· 289 289 goto out; 290 290 } 291 291 292 + if (vgic_has_its(kvm)) { 293 + ret = vgic_register_its_iodevs(kvm); 294 + if (ret) { 295 + kvm_err("Unable to register VGIC ITS MMIO regions\n"); 296 + goto out; 297 + } 298 + } 299 + 292 300 dist->ready = true; 293 301 294 302 out:
+6 -6
virt/kvm/arm/vgic/vgic.c
··· 117 117 118 118 void vgic_put_irq(struct kvm *kvm, struct vgic_irq *irq) 119 119 { 120 - struct vgic_dist *dist; 120 + struct vgic_dist *dist = &kvm->arch.vgic; 121 121 122 122 if (irq->intid < VGIC_MIN_LPI) 123 123 return; 124 124 125 - if (!kref_put(&irq->refcount, vgic_irq_release)) 126 - return; 127 - 128 - dist = &kvm->arch.vgic; 129 - 130 125 spin_lock(&dist->lpi_list_lock); 126 + if (!kref_put(&irq->refcount, vgic_irq_release)) { 127 + spin_unlock(&dist->lpi_list_lock); 128 + return; 129 + }; 130 + 131 131 list_del(&irq->lpi_list); 132 132 dist->lpi_list_count--; 133 133 spin_unlock(&dist->lpi_list_lock);
+6
virt/kvm/arm/vgic/vgic.h
··· 84 84 int vgic_v3_probe(const struct gic_kvm_info *info); 85 85 int vgic_v3_map_resources(struct kvm *kvm); 86 86 int vgic_register_redist_iodevs(struct kvm *kvm, gpa_t dist_base_address); 87 + int vgic_register_its_iodevs(struct kvm *kvm); 87 88 bool vgic_has_its(struct kvm *kvm); 88 89 int kvm_vgic_register_its_device(void); 89 90 void vgic_enable_lpis(struct kvm_vcpu *vcpu); ··· 137 136 138 137 static inline int vgic_register_redist_iodevs(struct kvm *kvm, 139 138 gpa_t dist_base_address) 139 + { 140 + return -ENODEV; 141 + } 142 + 143 + static inline int vgic_register_its_iodevs(struct kvm *kvm) 140 144 { 141 145 return -ENODEV; 142 146 }